var Sg=Object.defineProperty,Cg=Object.defineProperties;var Ag=Object.getOwnPropertyDescriptors;var pu=Object.getOwnPropertySymbols;var Tg=Object.prototype.hasOwnProperty,Mg=Object.prototype.propertyIsEnumerable;var mu=(i,e,t)=>e in i?Sg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Pe=(i,e)=>{for(var t in e||(e={}))Tg.call(e,t)&&mu(i,t,e[t]);if(pu)for(var t of pu(e))Mg.call(e,t)&&mu(i,t,e[t]);return i},qt=(i,e)=>Cg(i,Ag(e));var nt=(i,e,t)=>new Promise((n,s)=>{var r=a=>{try{l(t.next(a))}catch(c){s(c)}},o=a=>{try{l(t.throw(a))}catch(c){s(c)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(r,o);l((t=t.apply(i,e)).next())});import{d as Gt,f as ze,c as dt,h as Xs,w as mt,u as Y,a9 as vt,_ as it,a6 as Bt,a7 as ft,$ as dn,F as _s,a8 as Yn,G as Hn,a2 as Xn,aa as cn,ab as Vi,ac as xn,ae as Hi,af as fs,k as rt,a1 as $i,o as Ir,H as Dg,a0 as ss,a3 as No,ad as Za,s as Ol,e as Og,j as kf,l as Eg,J as ia,L as Fg,Q as Pg,y as Lr,m as xf,A as Sf,I as Bg,i as Rg,an as Ng,g as Ig,r as gu,ak as Lg,b as $g}from"./vue-B5pbXMv7.js";import{u as Yi,C as _g}from"./index-x2bUusKH.js";import{p as Ee,aJ as ws,b as Nn,_ as Tn,aF as as,f as ul,aM as bu,I as yu,z as ec,i as Cf,ak as Af,Z as zg,c as Vg,O as Hg,aB as wu,s as Wg,t as jg,ao as qg,x as Bi,aN as wi,an as Ug,aO as vu,aL as Co,d as Tf,aK as Kg,aP as Gg}from"./entry/index-BOVpYCVt-1731915664217.js";import{ak as Fs,o as $r,e as Et,al as Sn,l as fr,am as hl,an as zs,ao as Yg,ap as Mf,aq as Df,ar as Of,as as _r,at as tc,au as Xg,n as Gn,av as Jg,t as Js,N as Qg,aw as Zg,ax as e0,_ as Ef,ay as t0,a2 as fl,az as n0,aA as i0,a9 as s0,ad as Ff,aB as r0,aC as o0,F as Pf,H as Io,O as Cs,aa as Lo,f as _i,aD as l0,aE as a0,s as cs,aF as ku,d as dr,aG as xu,Z as c0,R as u0}from"./antd-DXvsKA0x.js";import{b as h0}from"./tree-Nv0Zt4Ov.js";import{u as f0,c as d0}from"./copyTextToClipboard-7uPthhEV.js";import{I as p0,B as m0}from"./index-BEZBHtc2.js";import{S as g0}from"./index-DKfaJplO.js";import{S as b0,B as Bf,a as y0,b as w0}from"./index-EdNvCi60.js";import{C as v0}from"./index-DTfAZuwl.js";import{t as El}from"./plugin-CRRssOeV.js";import{b as Su}from"./uuid-BUBnBT7J.js";import{o as k0}from"./onMountedOrActivated-C3HH8-CK.js";import{u as x0}from"./index-DaqRmjER.js";function S0(i){return"slot"in i}function C0(i){return!S0(i)}const A0=Gt({name:"ApiRadioGroup",components:{RadioGroup:Fs.Group,RadioButton:Fs.Button,Radio:Fs},props:{api:{type:Function,default:null},params:{type:[Object,String],default:()=>({})},value:{type:[String,Number,Boolean]},isBtn:{type:[Boolean],default:!1},numberToString:Ee.bool,resultField:Ee.string.def(""),labelField:Ee.string.def("label"),valueField:Ee.string.def("value"),immediate:Ee.bool.def(!0)},emits:["options-change","change"],setup(i,{emit:e}){const t=ze([]),n=ze(!1),s=ze(!0),r=ze([]),o=ws(),{t:l}=Nn(),[a]=Yi(i,"value","change",r),c=dt(()=>{const{labelField:d,valueField:p,numberToString:y}=i;return Y(t).reduce((b,m)=>{if(m){const x=m[p];b.push(Pe({label:m[d],value:y?`${x}`:x},$r(m,[d,p])))}return b},[])});Xs(()=>{i.immediate&&u()}),mt(()=>i.params,()=>{!Y(s)&&u()},{deep:!0});function u(){return nt(this,null,function*(){const d=i.api;if(!(!d||!Et(d))){t.value=[];try{n.value=!0;const p=yield d(i.params);if(Array.isArray(p)){t.value=p,h();return}i.resultField&&(t.value=Sn(p,i.resultField)||[]),h()}catch(p){}finally{n.value=!1}}})}function h(){e("options-change",Y(c))}function f(...d){r.value=d}return{state:a,getOptions:c,attrs:o,loading:n,t:l,handleClick:f,props:i}}});function T0(i,e,t,n,s,r){const o=vt("RadioButton"),l=vt("Radio"),a=vt("RadioGroup");return it(),Bt(a,cn(i.attrs,{value:i.state,"onUpdate:value":e[0]||(e[0]=c=>i.state=c),"button-style":"solid"}),{default:ft(()=>[(it(!0),dn(_s,null,Yn(i.getOptions,c=>(it(),dn(_s,{key:`${c.value}`},[i.props.isBtn?(it(),Bt(o,{key:0,value:c.value,disabled:c.disabled,onClick:u=>i.handleClick(c)},{default:ft(()=>[Hn(Xn(c.label),1)]),_:2},1032,["value","disabled","onClick"])):(it(),Bt(l,{key:1,value:c.value,disabled:c.disabled,onClick:u=>i.handleClick(c)},{default:ft(()=>[Hn(Xn(c.label),1)]),_:2},1032,["value","disabled","onClick"]))],64))),128))]),_:1},16,["value"])}const M0=Tn(A0,[["render",T0]]),D0=Gt({name:"RadioButtonGroup",components:{RadioGroup:Fs.Group,RadioButton:Fs.Button},props:{value:{type:[String,Number,Boolean]},options:{type:Array,default:()=>[]}},emits:["change"],setup(i){const e=ws(),t=ze([]),[n]=Yi(i,"value","change",t),s=dt(()=>{const{options:o}=i;return!o||(o==null?void 0:o.length)===0?[]:o.some(a=>fr(a))?o.map(a=>({label:a,value:a})):o});function r(...o){t.value=o}return{state:n,getOptions:s,attrs:e,handleClick:r}}});function O0(i,e,t,n,s,r){const o=vt("RadioButton"),l=vt("RadioGroup");return it(),Bt(l,cn(i.attrs,{value:i.state,"onUpdate:value":e[0]||(e[0]=a=>i.state=a),"button-style":"solid"}),{default:ft(()=>[(it(!0),dn(_s,null,Yn(i.getOptions,a=>(it(),Bt(o,{key:`${a.value}`,value:a.value,disabled:a.disabled,onClick:c=>i.handleClick(a)},{default:ft(()=>[Hn(Xn(a.label),1)]),_:2},1032,["value","disabled","onClick"]))),128))]),_:1},16,["value"])}const E0=Tn(D0,[["render",O0]]),F0=Gt({name:"ApiSelect",components:{Select:hl,LoadingOutlined:zs},inheritAttrs:!1,props:{value:{type:[Array,Object,String,Number]},numberToString:Ee.bool,api:{type:Function,default:null},params:Ee.any.def({}),resultField:Ee.string.def(""),labelField:Ee.string.def("label"),valueField:Ee.string.def("value"),immediate:Ee.bool.def(!0),alwaysLoad:Ee.bool.def(!1),options:{type:Array,default:[]},isSearch:Ee.bool.def(!1),searchField:Ee.string},emits:["options-change","change","update:value"],setup(i,{emit:e}){const t=ze([]),n=ze(!1),s=ze(!1),r=ze([]),o=ws(),{t:l}=Nn(),a=i.isSearch,c=ze();a&&(c.value=d);const[u]=Yi(i,"value","change",r),h=dt(()=>{const{labelField:m,valueField:x,numberToString:v}=i;let P=Y(t).reduce((O,D)=>{if(D){const F=Sn(D,x);O.push(qt(Pe({},$r(D,[m,x])),{label:Sn(D,m),value:v?`${F}`:F}))}return O},[]);return P.length>0?P:i.options});mt(()=>u.value,m=>{e("update:value",m)}),mt(()=>i.params,()=>{a==!1&&!Y(s)&&f()},{deep:!0,immediate:i.immediate});function f(){return nt(this,null,function*(){const m=i.api;if(!(!m||!Et(m)||n.value)){t.value=[];try{n.value=!0;const x=yield m(i.params);if(s.value=!0,Array.isArray(x)){t.value=x,y();return}i.resultField&&(t.value=Sn(x,i.resultField)||[]),y()}catch(x){}finally{n.value=!1,s.value=!1}}})}function d(m){return nt(this,null,function*(){const x=i.api;if(!(!x||!Et(x)||n.value)){t.value=[];try{n.value=!0;let v={};i.searchField!=null&&(v[i.searchField]=m),v.page=1,v.pageSize=10;const P=yield x(v);if(Array.isArray(P)){t.value=P,y();return}i.resultField&&(t.value=Sn(P,i.resultField)||[]),y()}catch(v){}finally{n.value=!1}}})}function p(m){return nt(this,null,function*(){m&&!a&&(i.alwaysLoad?yield f():!i.immediate&&!Y(s)&&(yield f()))})}function y(){e("options-change",Y(h))}function b(m,...x){r.value=x,e("change",x)}return{state:u,attrs:o,getOptions:h,loading:n,t:l,handleFetch:p,handleChange:b,useSearch:a,searchFun:c}}});function P0(i,e,t,n,s,r){const o=vt("LoadingOutlined"),l=vt("Select");return it(),Bt(l,cn({onDropdownVisibleChange:i.handleFetch},i.$attrs,{onChange:i.handleChange,options:i.getOptions,value:i.state,"onUpdate:value":e[0]||(e[0]=a=>i.state=a),"show-search":i.useSearch,onSearch:i.searchFun,"show-arrow":!1,"filter-option":!1}),Vi({_:2},[Yn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[xn(i.$slots,a,Hi(fs(c||{})))])})),i.loading?{name:"suffixIcon",fn:ft(()=>[rt(o,{spin:""})]),key:"0"}:void 0,i.loading?{name:"notFoundContent",fn:ft(()=>[$i("span",null,[rt(o,{spin:"",class:"mr-1"}),Hn(" "+Xn(i.t("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1040,["onDropdownVisibleChange","onChange","options","value","show-search","onSearch"])}const B0=Tn(F0,[["render",P0]]),R0=Gt({name:"ApiTree",components:{ATree:Yg},props:{api:{type:Function},params:{type:Object},immediate:{type:Boolean,default:!0},resultField:Ee.string.def(""),afterFetch:{type:Function}},emits:["options-change","change"],setup(i,{attrs:e,emit:t}){const n=ze([]),s=ze(!1),r=ze(!1),o=dt(()=>Pe(Pe({},i.api?{treeData:Y(n)}:{}),e));function l(...c){t("change",...c)}mt(()=>i.params,()=>{!Y(s)&&a()},{deep:!0}),mt(()=>i.immediate,c=>{c&&!s.value&&a()}),Ir(()=>{i.immediate&&a()});function a(){return nt(this,null,function*(){const{api:c,afterFetch:u}=i;if(!c||!Et(c))return;r.value=!0,n.value=[];let h;try{h=yield c(i.params)}catch(f){}u&&Et(u)&&(h=u(h)),r.value=!1,h&&(as(h)||(h=Sn(h,i.resultField)),n.value=h||[],s.value=!0,t("options-change",n.value))})}return{getAttrs:o,loading:r,handleChange:l}}});function N0(i,e,t,n,s,r){const o=vt("ATree");return it(),Bt(o,cn(i.getAttrs,{onChange:i.handleChange}),Vi({_:2},[Yn(Object.keys(i.$slots),l=>({name:l,fn:ft(a=>[xn(i.$slots,l,Hi(fs(a||{})))])}))]),1040,["onChange"])}const I0=Tn(R0,[["render",N0]]),L0=Gt({name:"ApiTreeSelect",components:{ATreeSelect:Mf,LoadingOutlined:zs},props:{api:{type:Function},params:{type:Object},immediate:{type:Boolean,default:!0},resultField:Ee.string.def(""),labelField:Ee.string.def(""),valueField:Ee.string.def(""),idKeyField:Ee.string.def("id"),parentKeyField:Ee.string.def("parentId"),childrenKeyField:Ee.string.def("children"),defaultValue:{type:Object}},emits:["options-change","change"],setup(i,{attrs:e,emit:t}){const n=ze([]),s=ze(!1),r=ze(!1),o=dt(()=>Pe(Pe({},i.api?{treeData:Y(n)}:{}),e));function l(...c){t("change",...c)}mt(()=>i.params,()=>{!Y(s)&&a()},{deep:!0}),mt(()=>i.immediate,c=>{c&&!s.value&&a()}),Ir(()=>{i.immediate&&a()});function a(){return nt(this,null,function*(){const{api:c}=i;if(!c||!Et(c))return;r.value=!0,n.value=[];let u;try{u=yield c(i.params)}catch(h){}r.value=!1,u&&(as(u)||(u=Sn(u,i.resultField)),n.value=h0(u,{idKeyField:i.idKeyField,parentKeyField:i.parentKeyField,childrenKeyField:i.childrenKeyField,valueField:i.valueField,labelField:i.labelField,defaultValue:i.defaultValue}),s.value=!0,t("options-change",n.value))})}return{getAttrs:o,loading:r,handleChange:l,fetch:a}}});function $0(i,e,t,n,s,r){const o=vt("LoadingOutlined"),l=vt("a-tree-select");return it(),Bt(l,cn(i.getAttrs,{onChange:i.handleChange,onDropdownVisibleChange:i.fetch}),Vi({_:2},[Yn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[xn(i.$slots,a,Hi(fs(c||{})))])})),i.loading?{name:"suffixIcon",fn:ft(()=>[rt(o,{spin:""})]),key:"0"}:void 0]),1040,["onChange","onDropdownVisibleChange"])}const _0=Tn(L0,[["render",$0]]),z0=Gt({name:"ApiCascader",__name:"ApiCascader",props:{value:{type:Array},api:{type:Function,default:null},numberToString:Ee.bool,resultField:Ee.string.def(""),labelField:Ee.string.def("label"),valueField:Ee.string.def("value"),childrenField:Ee.string.def("children"),apiParamKey:Ee.string.def("parentCode"),immediate:Ee.bool.def(!0),initFetchParams:{type:Object,default:()=>({})},isLeaf:{type:Function,default:null},displayRenderArray:{type:Array}},emits:["change","defaultChange"],setup(i,{emit:e}){const t=i,n=e,s=ze([]),r=ze([]),o=ze(!1),l=ze([]),a=ze(!0),{t:c}=Nn(),[u]=Yi(t,"value","change",l);mt(s,b=>{const m=h(b);r.value=m},{deep:!0});function h(b){const{labelField:m,valueField:x,numberToString:v,childrenField:P,isLeaf:O}=t;return b.reduce((D,F)=>{if(F){const T=F[x],M=qt(Pe({},$r(F,[m,x])),{label:F[m],value:v?`${T}`:T,isLeaf:O&&typeof O=="function"?O(F):!1}),W=Reflect.get(F,P);W&&Reflect.set(M,P,h(W)),D.push(M)}return D},[])}function f(){return nt(this,null,function*(){const b=t.api;if(!(!b||!Et(b))){s.value=[],o.value=!0;try{const m=yield b(t.initFetchParams);if(Array.isArray(m)){s.value=m;return}t.resultField&&(s.value=Sn(m,t.resultField)||[])}catch(m){}finally{o.value=!1}}})}const d=b=>nt(this,null,function*(){const m=b[b.length-1];m.loading=!0;const x=t.api;if(!(!x||!Et(x)))try{const v=yield x({[t.apiParamKey]:Reflect.get(m,"value")});if(Array.isArray(v)){const P=h(v);m.children=P;return}if(t.resultField){const P=h(Sn(v,t.resultField)||[]);m.children=P}}catch(v){}finally{m.loading=!1}});Xs(()=>{t.immediate&&f()}),mt(()=>t.initFetchParams,()=>{!Y(a)&&f()},{deep:!0});function p(b,m){l.value=m,n("defaultChange",b,m)}const y=({labels:b,selectedOptions:m})=>Y(l).length===(m==null?void 0:m.length)?b.join(" / "):t.displayRenderArray?t.displayRenderArray.join(" / "):"";return(b,m)=>(it(),Bt(Y(Df),{value:Y(u),"onUpdate:value":m[0]||(m[0]=x=>Dg(u)?u.value=x:null),options:r.value,"load-data":d,"change-on-select":"",onChange:p,displayRender:y},Vi({_:2},[o.value?{name:"suffixIcon",fn:ft(()=>[rt(Y(zs),{spin:""})]),key:"0"}:void 0,o.value?{name:"notFoundContent",fn:ft(()=>[$i("span",null,[rt(Y(zs),{spin:"",class:"mr-1"}),Hn(" "+Xn(Y(c)("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1032,["value","options"]))}}),V0=Gt({name:"ApiTransfer",components:{Transfer:Of},props:{value:{type:Array},api:{type:Function,default:null},params:{type:Object},dataSource:{type:Array},immediate:Ee.bool.def(!0),alwaysLoad:Ee.bool.def(!1),afterFetch:{type:Function},resultField:Ee.string.def(""),labelField:Ee.string.def("title"),valueField:Ee.string.def("key"),showSearch:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},filterOption:{type:Function},selectedKeys:{type:Array},showSelectAll:{type:Boolean,default:!1},targetKeys:{type:Array}},emits:["options-change","change"],setup(i,{attrs:e,emit:t}){const n=ze([]),s=ze([]),{t:r}=Nn(),o=dt(()=>Pe(Pe({},i.api?{}:{dataSource:Y(n)}),e)),l=dt(()=>{const{labelField:f,valueField:d}=i;return Y(n).reduce((p,y)=>(y&&p.push(qt(Pe({},$r(y,[f,d])),{title:y[f],key:y[d]})),p),[])}),a=dt(()=>Array.isArray(i.value)?i.value:Array.isArray(i.targetKeys)?i.targetKeys:[]);function c(f,d,p){s.value=f,t("change",f)}Xs(()=>{i.immediate&&!i.alwaysLoad&&u()}),mt(()=>i.params,()=>{u()},{deep:!0});function u(){return nt(this,null,function*(){const f=i.api;if(!f||!Et(f)){Array.isArray(i.dataSource)&&(n.value=i.dataSource);return}n.value=[];try{const d=yield f(i.params);if(Array.isArray(d)){n.value=d,h();return}i.resultField&&(n.value=Sn(d,i.resultField)||[]),h()}catch(d){}})}function h(){t("options-change",Y(l))}return{getTargetKeys:a,getdataSource:l,t:r,getAttrs:o,handleChange:c}}});function H0(i,e,t,n,s,r){const o=vt("Transfer");return it(),Bt(o,{"data-source":i.getdataSource,"filter-option":i.filterOption,render:l=>l.title,showSelectAll:i.showSelectAll,selectedKeys:i.selectedKeys,targetKeys:i.getTargetKeys,showSearch:i.showSearch,disabled:i.disabled,onChange:i.handleChange},null,8,["data-source","filter-option","render","showSelectAll","selectedKeys","targetKeys","showSearch","disabled","onChange"])}const W0=Tn(V0,[["render",H0]]),j0=Gt({name:"SimpleTimePicker",components:{DatePicker:_r,TimePicker:tc,FormItemRest:Xg},inheritAttrs:!1,props:{timeMode:Ee.string.def("datetime"),valueFormat:Ee.string.def("unixmilli"),value:[Number]},emits:["options-change","change","update:value"],setup(i,{emit:e}){const t=ze([]),n=ws(),{t:s}=Nn(),r=ze(),o=ze(),l=ze();i.timeMode==="datetime"?l.value=!0:l.value=!1;const[a]=Yi(i,"value","change",t);mt(()=>a.value,u=>{u!==null&&u!=null&&(i.valueFormat==="unixmilli"?(r.value=Gn(u),o.value=Gn(u)):u!==void 0&&(r.value=Gn.unix(u),o.value=Gn.unix(u))),e("update:value",u),e("change",u)});function c(u){var h;if(u!==null){let f=Gn();r.value!=null&&(f=(h=r.value)==null?void 0:h.clone()),i.timeMode==="datetime"?o.value!=null&&(f=f.hour(o.value.hour()).minute(o.value.minute()).second(o.value.second()).millisecond(0)):f=f.hour(0).minute(0).second(0).millisecond(0),i.valueFormat==="unixmilli"?a.value=f.valueOf():a.value=f.unix()}else a.value=void 0}return{state:a,attrs:n,showTimePicker:l,t:s,handleChange:c,dateVal:r,timeVal:o}}});function q0(i,e,t,n,s,r){const o=vt("DatePicker"),l=vt("TimePicker"),a=vt("FormItemRest");return it(),dn(_s,null,[rt(o,{"allow-clear":"",value:i.dateVal,"onUpdate:value":e[0]||(e[0]=c=>i.dateVal=c),onChange:i.handleChange},null,8,["value","onChange"]),rt(a,null,{default:ft(()=>[i.showTimePicker?(it(),Bt(l,{key:0,class:"ml-4",value:i.timeVal,"onUpdate:value":e[1]||(e[1]=c=>i.timeVal=c),onChange:i.handleChange,"allow-clear":""},null,8,["value","onChange"])):ss("",!0)]),_:1})],64)}const U0=Tn(j0,[["render",q0]]),K0=Gt({name:"SimpleRangePicker",components:{RangePicker:Jg},inheritAttrs:!1,props:{timeMode:Ee.string.def("datetime"),valueFormat:Ee.string.def("unixmilli"),value:{type:Array,default:void 0}},emits:["options-change","change","update:value"],setup(i,{emit:e}){const t=ze([]),n=ws(),{t:s}=Nn(),r=ze(),o=ze();i.timeMode==="datetime"?o.value=!0:o.value=!1;const[l]=Yi(i,"value","change",t);mt(()=>l.value,c=>{c!==null&&c!=null&&(i.valueFormat==="unixmilli"?r.value=[Gn(c[0]),Gn(c[1])]:c!==void 0&&(r.value=[Gn.unix(c[0]),Gn.unix(c[1])])),e("update:value",c),e("change",c)});function a(c){var u,h;if(c!==null){let f=[Gn(),Gn()];r.value!=null&&(f[0]=(u=r.value[0])==null?void 0:u.clone(),f[1]=(h=r.value[1])==null?void 0:h.clone()),i.timeMode!=="datetime"&&(f[0]=f[0].hour(0).minute(0).second(0).millisecond(0),f[1]=f[1].hour(0).minute(0).second(0).millisecond(0)),i.valueFormat==="unixmilli"?l.value=[f[0].valueOf(),f[1].valueOf()]:l.value=[f[0].unix(),f[1].unix()]}else l.value=[0,0]}return{state:l,attrs:n,showTimePicker:o,t:s,handleChange:a,dateVal:r}}});function G0(i,e,t,n,s,r){const o=vt("RangePicker");return it(),Bt(o,{"allow-clear":"",value:i.dateVal,"onUpdate:value":e[0]||(e[0]=l=>i.dateVal=l),onChange:i.handleChange,"show-time":i.showTimePicker},null,8,["value","onChange","show-time"])}const Y0=Tn(K0,[["render",G0]]),X0=Gt({name:"ApiMultipleSelect",components:{Select:hl,LoadingOutlined:zs},inheritAttrs:!1,props:{value:[Array,Object,String,Number],numberToString:Ee.bool,api:{type:Function,default:null},params:{type:Object,default:()=>({})},resultField:Ee.string.def(""),labelField:Ee.string.def("label"),valueField:Ee.string.def("value"),immediate:Ee.bool.def(!0),alwaysLoad:Ee.bool.def(!1)},emits:["options-change","change","update:value"],setup(i,{emit:e}){const t=ze([]),n=ze(!1),s=ze(!0),r=ze([]),o=ws(),{t:l}=Nn(),[a]=Yi(i,"value","change",r),c=dt(()=>{const{labelField:p,valueField:y,numberToString:b}=i;return Y(t).reduce((m,x)=>{if(x){const v=x[y];m.push(qt(Pe({},$r(x,[p,y])),{label:x[p],value:b?`${v}`:v}))}return m},[])});Xs(()=>{i.immediate&&!i.alwaysLoad&&u()}),mt(()=>a.value,p=>{e("update:value",p)}),mt(()=>i.params,()=>{!Y(s)&&u()},{deep:!0});function u(){return nt(this,null,function*(){const p=i.api;if(!(!p||!Et(p))){t.value=[];try{n.value=!0;const y=yield p(i.params);if(Array.isArray(y)){t.value=y,f();return}i.resultField&&(t.value=Sn(y,i.resultField)||[]),f()}catch(y){}finally{n.value=!1}}})}function h(p){return nt(this,null,function*(){p&&(i.alwaysLoad?yield u():!i.immediate&&Y(s)&&(yield u(),s.value=!1))})}function f(){e("options-change",Y(c))}function d(p,...y){r.value=y,e("change",y)}return{state:a,attrs:o,getOptions:c,loading:n,t:l,handleFetch:h,handleChange:d}}});function J0(i,e,t,n,s,r){const o=vt("LoadingOutlined"),l=vt("Select");return it(),Bt(l,cn({onDropdownVisibleChange:i.handleFetch},i.$attrs,{onChange:i.handleChange,options:i.getOptions,mode:"multiple",value:i.state,"onUpdate:value":e[0]||(e[0]=a=>i.state=a)}),Vi({_:2},[Yn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[xn(i.$slots,a,Hi(fs(c||{})))])})),i.loading?{name:"suffixIcon",fn:ft(()=>[rt(o,{spin:""})]),key:"0"}:void 0,i.loading?{name:"notFoundContent",fn:ft(()=>[$i("span",null,[rt(o,{spin:"",class:"mr-1"}),Hn(" "+Xn(i.t("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1040,["onDropdownVisibleChange","onChange","options","value"])}const Q0=Tn(X0,[["render",J0]]),Z0=Gt({name:"DictionarySelect",components:{Select:hl,LoadingOutlined:zs},inheritAttrs:!1,props:{dictionaryName:Ee.string.def(""),value:[String,Number],cache:Ee.bool.def(!0)},emits:["options-change","change","update:value"],setup(i,{emit:e}){const t=ze(!1),n=ze([]),s=ws(),{t:r}=Nn(),o=ze(),[l]=Yi(i,"value","change",n);Ir(()=>{a()}),mt(()=>l.value,u=>{e("update:value",u)});function a(){return nt(this,null,function*(){t.value=!0;const h=yield f0().getDictionary(i.dictionaryName,i.cache);h!=null&&(o.value=h.data),t.value=!1})}function c(u,...h){n.value=h,e("change",h)}return{state:l,attrs:s,loading:t,t:r,options:o,handleFetch:a,handleChange:c}}});function eb(i,e,t,n,s,r){const o=vt("LoadingOutlined"),l=vt("Select");return it(),Bt(l,cn(i.$attrs,{onChange:i.handleChange,options:i.options,value:i.state,"onUpdate:value":e[0]||(e[0]=a=>i.state=a)}),Vi({_:2},[Yn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[xn(i.$slots,a,Hi(fs(c||{})))])})),i.loading?{name:"suffixIcon",fn:ft(()=>[rt(o,{spin:""})]),key:"0"}:void 0,i.loading?{name:"notFoundContent",fn:ft(()=>[$i("span",null,[rt(o,{spin:"",class:"mr-1"}),Hn(" "+Xn(i.t("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1040,["onChange","options","value"])}const tb=Tn(Z0,[["render",eb]]),Cu={prefix:"ant-design",icons:["account-book-filled","account-book-outlined","account-book-twotone","aim-outlined","alert-filled","alert-outlined","alert-twotone","alibaba-outlined","align-center-outlined","align-left-outlined","align-right-outlined","alipay-circle-filled","alipay-circle-outlined","alipay-outlined","alipay-square-filled","aliwangwang-filled","aliwangwang-outlined","aliyun-outlined","amazon-circle-filled","amazon-outlined","amazon-square-filled","android-filled","android-outlined","ant-cloud-outlined","ant-design-outlined","apartment-outlined","api-filled","api-outlined","api-twotone","apple-filled","apple-outlined","appstore-add-outlined","appstore-filled","appstore-outlined","appstore-twotone","area-chart-outlined","arrow-down-outlined","arrow-left-outlined","arrow-right-outlined","arrow-up-outlined","arrows-alt-outlined","audio-filled","audio-muted-outlined","audio-outlined","audio-twotone","audit-outlined","backward-filled","backward-outlined","bank-filled","bank-outlined","bank-twotone","bar-chart-outlined","barcode-outlined","bars-outlined","behance-circle-filled","behance-outlined","behance-square-filled","behance-square-outlined","bell-filled","bell-outlined","bell-twotone","bg-colors-outlined","block-outlined","bold-outlined","book-filled","book-outlined","book-twotone","border-bottom-outlined","border-horizontal-outlined","border-inner-outlined","border-left-outlined","border-outer-outlined","border-outlined","border-right-outlined","border-top-outlined","border-verticle-outlined","borderless-table-outlined","box-plot-filled","box-plot-outlined","box-plot-twotone","branches-outlined","bug-filled","bug-outlined","bug-twotone","build-filled","build-outlined","build-twotone","bulb-filled","bulb-outlined","bulb-twotone","calculator-filled","calculator-outlined","calculator-twotone","calendar-filled","calendar-outlined","calendar-twotone","camera-filled","camera-outlined","camera-twotone","car-filled","car-outlined","car-twotone","caret-down-filled","caret-down-outlined","caret-left-filled","caret-left-outlined","caret-right-filled","caret-right-outlined","caret-up-filled","caret-up-outlined","carry-out-filled","carry-out-outlined","carry-out-twotone","check-circle-filled","check-circle-outlined","check-circle-twotone","check-outlined","check-square-filled","check-square-outlined","check-square-twotone","chrome-filled","chrome-outlined","ci-circle-filled","ci-circle-outlined","ci-circle-twotone","ci-outlined","ci-twotone","clear-outlined","clock-circle-filled","clock-circle-outlined","clock-circle-twotone","close-circle-filled","close-circle-outlined","close-circle-twotone","close-outlined","close-square-filled","close-square-outlined","close-square-twotone","cloud-download-outlined","cloud-filled","cloud-outlined","cloud-server-outlined","cloud-sync-outlined","cloud-twotone","cloud-upload-outlined","cluster-outlined","code-filled","code-outlined","code-sandbox-circle-filled","code-sandbox-outlined","code-sandbox-square-filled","code-twotone","codepen-circle-filled","codepen-circle-outlined","codepen-outlined","codepen-square-filled","coffee-outlined","column-height-outlined","column-width-outlined","comment-outlined","compass-filled","compass-outlined","compass-twotone","compress-outlined","console-sql-outlined","contacts-filled","contacts-outlined","contacts-twotone","container-filled","container-outlined","container-twotone","control-filled","control-outlined","control-twotone","copy-filled","copy-outlined","copy-twotone","copyright-circle-filled","copyright-circle-outlined","copyright-circle-twotone","copyright-outlined","copyright-twotone","credit-card-filled","credit-card-outlined","credit-card-twotone","crown-filled","crown-outlined","crown-twotone","customer-service-filled","customer-service-outlined","customer-service-twotone","dash-outlined","dashboard-filled","dashboard-outlined","dashboard-twotone","database-filled","database-outlined","database-twotone","delete-column-outlined","delete-filled","delete-outlined","delete-row-outlined","delete-twotone","delivered-procedure-outlined","deployment-unit-outlined","desktop-outlined","diff-filled","diff-outlined","diff-twotone","dingding-outlined","dingtalk-circle-filled","dingtalk-outlined","dingtalk-square-filled","disconnect-outlined","dislike-filled","dislike-outlined","dislike-twotone","dollar-circle-filled","dollar-circle-outlined","dollar-circle-twotone","dollar-outlined","dollar-twotone","dot-chart-outlined","double-left-outlined","double-right-outlined","down-circle-filled","down-circle-outlined","down-circle-twotone","down-outlined","down-square-filled","down-square-outlined","down-square-twotone","download-outlined","drag-outlined","dribbble-circle-filled","dribbble-outlined","dribbble-square-filled","dribbble-square-outlined","dropbox-circle-filled","dropbox-outlined","dropbox-square-filled","edit-filled","edit-outlined","edit-twotone","ellipsis-outlined","enter-outlined","environment-filled","environment-outlined","environment-twotone","euro-circle-filled","euro-circle-outlined","euro-circle-twotone","euro-outlined","euro-twotone","exception-outlined","exclamation-circle-filled","exclamation-circle-outlined","exclamation-circle-twotone","exclamation-outlined","expand-alt-outlined","expand-outlined","experiment-filled","experiment-outlined","experiment-twotone","export-outlined","eye-filled","eye-invisible-filled","eye-invisible-outlined","eye-invisible-twotone","eye-outlined","eye-twotone","facebook-filled","facebook-outlined","fall-outlined","fast-backward-filled","fast-backward-outlined","fast-forward-filled","fast-forward-outlined","field-binary-outlined","field-number-outlined","field-string-outlined","field-time-outlined","file-add-filled","file-add-outlined","file-add-twotone","file-done-outlined","file-excel-filled","file-excel-outlined","file-excel-twotone","file-exclamation-filled","file-exclamation-outlined","file-exclamation-twotone","file-filled","file-gif-outlined","file-image-filled","file-image-outlined","file-image-twotone","file-jpg-outlined","file-markdown-filled","file-markdown-outlined","file-markdown-twotone","file-outlined","file-pdf-filled","file-pdf-outlined","file-pdf-twotone","file-ppt-filled","file-ppt-outlined","file-ppt-twotone","file-protect-outlined","file-search-outlined","file-sync-outlined","file-text-filled","file-text-outlined","file-text-twotone","file-twotone","file-unknown-filled","file-unknown-outlined","file-unknown-twotone","file-word-filled","file-word-outlined","file-word-twotone","file-zip-filled","file-zip-outlined","file-zip-twotone","filter-filled","filter-outlined","filter-twotone","fire-filled","fire-outlined","fire-twotone","flag-filled","flag-outlined","flag-twotone","folder-add-filled","folder-add-outlined","folder-add-twotone","folder-filled","folder-open-filled","folder-open-outlined","folder-open-twotone","folder-outlined","folder-twotone","folder-view-outlined","font-colors-outlined","font-size-outlined","fork-outlined","form-outlined","format-painter-filled","format-painter-outlined","forward-filled","forward-outlined","frown-filled","frown-outlined","frown-twotone","fullscreen-exit-outlined","fullscreen-outlined","function-outlined","fund-filled","fund-outlined","fund-projection-screen-outlined","fund-twotone","fund-view-outlined","funnel-plot-filled","funnel-plot-outlined","funnel-plot-twotone","gateway-outlined","gif-outlined","gift-filled","gift-outlined","gift-twotone","github-filled","github-outlined","gitlab-filled","gitlab-outlined","global-outlined","gold-filled","gold-outlined","gold-twotone","golden-filled","google-circle-filled","google-outlined","google-plus-circle-filled","google-plus-outlined","google-plus-square-filled","google-square-filled","group-outlined","hdd-filled","hdd-outlined","hdd-twotone","heart-filled","heart-outlined","heart-twotone","heat-map-outlined","highlight-filled","highlight-outlined","highlight-twotone","history-outlined","home-filled","home-outlined","home-twotone","hourglass-filled","hourglass-outlined","hourglass-twotone","html5-filled","html5-outlined","html5-twotone","idcard-filled","idcard-outlined","idcard-twotone","ie-circle-filled","ie-outlined","ie-square-filled","import-outlined","inbox-outlined","info-circle-filled","info-circle-outlined","info-circle-twotone","info-outlined","insert-row-above-outlined","insert-row-below-outlined","insert-row-left-outlined","insert-row-right-outlined","instagram-filled","instagram-outlined","insurance-filled","insurance-outlined","insurance-twotone","interaction-filled","interaction-outlined","interaction-twotone","issues-close-outlined","italic-outlined","key-outlined","laptop-outlined","layout-filled","layout-outlined","layout-twotone","left-circle-filled","left-circle-outlined","left-circle-twotone","left-outlined","left-square-filled","left-square-outlined","left-square-twotone","like-filled","like-outlined","like-twotone","line-chart-outlined","line-height-outlined","line-outlined","link-outlined","linkedin-filled","linkedin-outlined","loading-3-quarters-outlined","loading-outlined","lock-filled","lock-outlined","lock-twotone","login-outlined","logout-outlined","mac-command-filled","mac-command-outlined","mail-filled","mail-outlined","mail-twotone","man-outlined","medicine-box-filled","medicine-box-outlined","medicine-box-twotone","medium-circle-filled","medium-outlined","medium-square-filled","medium-workmark-outlined","meh-filled","meh-outlined","meh-twotone","menu-fold-outlined","menu-outlined","menu-unfold-outlined","merge-cells-outlined","message-filled","message-outlined","message-twotone","minus-circle-filled","minus-circle-outlined","minus-circle-twotone","minus-outlined","minus-square-filled","minus-square-outlined","minus-square-twotone","mobile-filled","mobile-outlined","mobile-twotone","money-collect-filled","money-collect-outlined","money-collect-twotone","monitor-outlined","more-outlined","node-collapse-outlined","node-expand-outlined","node-index-outlined","notification-filled","notification-outlined","notification-twotone","number-outlined","one-to-one-outlined","ordered-list-outlined","paper-clip-outlined","partition-outlined","pause-circle-filled","pause-circle-outlined","pause-circle-twotone","pause-outlined","pay-circle-filled","pay-circle-outlined","percentage-outlined","phone-filled","phone-outlined","phone-twotone","pic-center-outlined","pic-left-outlined","pic-right-outlined","picture-filled","picture-outlined","picture-twotone","pie-chart-filled","pie-chart-outlined","pie-chart-twotone","play-circle-filled","play-circle-outlined","play-circle-twotone","play-square-filled","play-square-outlined","play-square-twotone","plus-circle-filled","plus-circle-outlined","plus-circle-twotone","plus-outlined","plus-square-filled","plus-square-outlined","plus-square-twotone","pound-circle-filled","pound-circle-outlined","pound-circle-twotone","pound-outlined","poweroff-outlined","printer-filled","printer-outlined","printer-twotone","profile-filled","profile-outlined","profile-twotone","project-filled","project-outlined","project-twotone","property-safety-filled","property-safety-outlined","property-safety-twotone","pull-request-outlined","pushpin-filled","pushpin-outlined","pushpin-twotone","qq-circle-filled","qq-outlined","qq-square-filled","qrcode-outlined","question-circle-filled","question-circle-outlined","question-circle-twotone","question-outlined","radar-chart-outlined","radius-bottomleft-outlined","radius-bottomright-outlined","radius-setting-outlined","radius-upleft-outlined","radius-upright-outlined","read-filled","read-outlined","reconciliation-filled","reconciliation-outlined","reconciliation-twotone","red-envelope-filled","red-envelope-outlined","red-envelope-twotone","reddit-circle-filled","reddit-outlined","reddit-square-filled","redo-outlined","reload-outlined","rest-filled","rest-outlined","rest-twotone","retweet-outlined","right-circle-filled","right-circle-outlined","right-circle-twotone","right-outlined","right-square-filled","right-square-outlined","right-square-twotone","rise-outlined","robot-filled","robot-outlined","rocket-filled","rocket-outlined","rocket-twotone","rollback-outlined","rotate-left-outlined","rotate-right-outlined","safety-certificate-filled","safety-certificate-outlined","safety-certificate-twotone","safety-outlined","save-filled","save-outlined","save-twotone","scan-outlined","schedule-filled","schedule-outlined","schedule-twotone","scissor-outlined","search-outlined","security-scan-filled","security-scan-outlined","security-scan-twotone","select-outlined","send-outlined","setting-filled","setting-outlined","setting-twotone","shake-outlined","share-alt-outlined","shop-filled","shop-outlined","shop-twotone","shopping-cart-outlined","shopping-filled","shopping-outlined","shopping-twotone","shrink-outlined","signal-filled","sisternode-outlined","sketch-circle-filled","sketch-outlined","sketch-square-filled","skin-filled","skin-outlined","skin-twotone","skype-filled","skype-outlined","slack-circle-filled","slack-outlined","slack-square-filled","slack-square-outlined","sliders-filled","sliders-outlined","sliders-twotone","small-dash-outlined","smile-filled","smile-outlined","smile-twotone","snippets-filled","snippets-outlined","snippets-twotone","solution-outlined","sort-ascending-outlined","sort-descending-outlined","sound-filled","sound-outlined","sound-twotone","split-cells-outlined","star-filled","star-outlined","star-twotone","step-backward-filled","step-backward-outlined","step-forward-filled","step-forward-outlined","stock-outlined","stop-filled","stop-outlined","stop-twotone","strikethrough-outlined","subnode-outlined","swap-left-outlined","swap-outlined","swap-right-outlined","switcher-filled","switcher-outlined","switcher-twotone","sync-outlined","table-outlined","tablet-filled","tablet-outlined","tablet-twotone","tag-filled","tag-outlined","tag-twotone","tags-filled","tags-outlined","tags-twotone","taobao-circle-filled","taobao-circle-outlined","taobao-outlined","taobao-square-filled","team-outlined","thunderbolt-filled","thunderbolt-outlined","thunderbolt-twotone","to-top-outlined","tool-filled","tool-outlined","tool-twotone","trademark-circle-filled","trademark-circle-outlined","trademark-circle-twotone","trademark-outlined","transaction-outlined","translation-outlined","trophy-filled","trophy-outlined","trophy-twotone","twitter-circle-filled","twitter-outlined","twitter-square-filled","underline-outlined","undo-outlined","ungroup-outlined","unlock-filled","unlock-outlined","unlock-twotone","unordered-list-outlined","up-circle-filled","up-circle-outlined","up-circle-twotone","up-outlined","up-square-filled","up-square-outlined","up-square-twotone","upload-outlined","usb-filled","usb-outlined","usb-twotone","user-add-outlined","user-delete-outlined","user-outlined","user-switch-outlined","usergroup-add-outlined","usergroup-delete-outlined","verified-outlined","vertical-align-bottom-outlined","vertical-align-middle-outlined","vertical-align-top-outlined","vertical-left-outlined","vertical-right-outlined","video-camera-add-outlined","video-camera-filled","video-camera-outlined","video-camera-twotone","wallet-filled","wallet-outlined","wallet-twotone","warning-filled","warning-outlined","warning-twotone","wechat-filled","wechat-outlined","weibo-circle-filled","weibo-circle-outlined","weibo-outlined","weibo-square-filled","weibo-square-outlined","whats-app-outlined","wifi-outlined","windows-filled","windows-outlined","woman-outlined","yahoo-filled","yahoo-outlined","youtube-filled","youtube-outlined","yuque-filled","yuque-outlined","zhihu-circle-filled","zhihu-outlined","zhihu-square-filled","zoom-in-outlined","zoom-out-outlined"]};function nb(i,e,t){const n=(e-1)*Number(t);return n+Number(t)>=i.length?i.slice(n,i.length):i.slice(n,n+Number(t))}function ib(i,e){const t=ze(1),n=ze(e),s=dt(()=>nb(Y(i),Y(t),Y(n))),r=dt(()=>Y(i).length);function o(a){t.value=a}function l(a){n.value=a}return{setCurrentPage:o,getTotal:r,setPageSize:l,getPaginationList:s}}const sb=["icon-download-count","icon-dynamic-avatar-1","icon-dynamic-avatar-2","icon-dynamic-avatar-3","icon-dynamic-avatar-4","icon-dynamic-avatar-5","icon-dynamic-avatar-6","icon-moon","icon-sun","icon-test","icon-total-sales","icon-transaction","icon-visit-count"],rb={class:"flex justify-between"},ob={key:0},lb={class:"flex flex-wrap px-2"},ab=["onClick","title"],cb={key:0,class:"flex py-2 items-center justify-center"},ub={key:1,class:"p-5"},hb={key:0,class:"cursor-pointer px-2 py-1 flex items-center"},fb=Gt({inheritAttrs:!1,__name:"IconPicker",props:{value:{default:""},width:{default:"100%"},pageSize:{default:140},copy:{type:Boolean,default:!1},mode:{default:"iconify"}},emits:["change","update:value"],setup(i,{emit:e}){const t=Js,n=Qg,s=Zg,r=e0;function o(){const W=Cu.prefix;return Cu.icons.map(V=>`${W}:${V}`)}function l(){return sb.map(W=>W.replace("icon-",""))}const a=i,c=e,u=a.mode==="svg",h=u?l():o(),f=ze(""),d=ze(!1),p=ze(h),y=ze(),b=()=>{y.value&&y.value.click()},{t:m}=Nn(),{prefixCls:x}=ul("icon-picker"),v=ec(M,100),{getPaginationList:P,getTotal:O,setCurrentPage:D}=ib(p,a.pageSize);Xs(()=>{f.value=a.value}),mt(()=>f.value,W=>{c("update:value",W),c("change",W)});function F(W){D(W)}function T(W){f.value=W,a.copy&&d0(W,m("component.icon.copy"))}function M(W){const V=W.target.value;if(!V){D(1),p.value=h;return}f.value=V,p.value=h.filter(Q=>Q.includes(V))}return(W,V)=>(it(),Bt(Y(t),{readonly:"",style:Za({width:W.width}),placeholder:Y(m)("component.icon.placeholder"),class:No(Y(x)),value:f.value,"onUpdate:value":V[1]||(V[1]=Q=>f.value=Q),onClick:b},{addonAfter:ft(()=>[rt(Y(n),{placement:"bottomLeft",trigger:"click",modelValue:d.value,"onUpdate:modelValue":V[0]||(V[0]=Q=>d.value=Q),overlayClassName:`${Y(x)}-popover`},{title:ft(()=>[$i("div",rb,[rt(Y(t),{placeholder:Y(m)("component.icon.search"),onChange:Y(v),allowClear:""},null,8,["placeholder","onChange"])])]),content:ft(()=>[Y(P).length?(it(),dn("div",ob,[rt(Y(b0),{class:"border border-solid border-t-0"},{default:ft(()=>[$i("ul",lb,[(it(!0),dn(_s,null,Yn(Y(P),Q=>(it(),dn("li",{key:Q,class:No([f.value===Q?"border border-primary":"","p-2 w-1/8 cursor-pointer mr-1 mt-1 flex justify-center items-center border border-solid hover:border-primary"]),onClick:ce=>T(Q),title:Q},[u?(it(),Bt(bu,{key:0,name:Q},null,8,["name"])):(it(),Bt(yu,{key:1,icon:Q},null,8,["icon"]))],10,ab))),128))])]),_:1}),Y(O)>=W.pageSize?(it(),dn("div",cb,[rt(Y(s),{showLessItems:"",size:"small",pageSize:W.pageSize,total:Y(O),onChange:F},null,8,["pageSize","total"])])):ss("",!0)])):(it(),dn("div",ub,[rt(Y(r))]))]),default:ft(()=>[$i("div",{ref_key:"trigger",ref:y},[u&&f.value?(it(),dn("span",hb,[rt(bu,{name:f.value},null,8,["name"])])):(it(),Bt(yu,{key:1,icon:f.value||"ion:apps-outline",class:"cursor-pointer px-2 py-1"},null,8,["icon"]))],512)]),_:1},8,["modelValue","overlayClassName"])]),_:1},8,["style","placeholder","class","value"]))}});class yt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Vs(this,e,t);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(t,this.length,s,1),ci.from(s,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Vs(this,e,t);let n=[];return this.decompose(e,t,n,0),ci.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new pr(this),r=new pr(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=n)return!0}}iter(e=1){return new pr(this,e)}iterRange(e,t=this.length){return new Rf(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Nf(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?yt.empty:e.length<=32?new zt(e):ci.from(zt.split(e,[]))}}class zt extends yt{constructor(e,t=db(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?n:l)>=e)return new pb(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new zt(Au(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=Ao(r.text,o.text.slice(),0,r.length);if(l.length<=32)n.push(new zt(l,o.length+r.length));else{let a=l.length>>1;n.push(new zt(l.slice(0,a)),new zt(l.slice(a)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof zt))return super.replace(e,t,n);[e,t]=Vs(this,e,t);let s=Ao(this.text,Ao(n.text,Au(this.text,0,e)),t),r=this.length+n.length-(t-e);return s.length<=32?new zt(s,r):ci.from(zt.split(s,[]),r)}sliceString(e,t=this.length,n=` `){[e,t]=Vs(this,e,t);let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=n),er&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],s=-1;for(let r of e)n.push(r),s+=r.length+1,n.length==32&&(t.push(new zt(n,s)),n=[],s=-1);return s>-1&&t.push(new zt(n,s)),t}}class ci extends yt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,s);s=l+1,n=a+1}}decompose(e,t,n,s){for(let r=0,o=0;o<=t&&r=o){let c=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!c?n.push(l):l.decompose(e-o,t-o,n,c)}o=a+1}}replace(e,t,n){if([e,t]=Vs(this,e,t),n.lines=r&&t<=l){let a=o.replace(e-r,t-r,n),c=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>c>>6){let u=this.children.slice();return u[s]=a,new ci(u,this.length-(t-e)+n.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` `){[e,t]=Vs(this,e,t);let s="";for(let r=0,o=0;re&&r&&(s+=n),eo&&(s+=l.sliceString(e-o,t-o,n)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof ci))return 0;let n=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return n;let a=this.children[s],c=e.children[r];if(a!=c)return n+a.scanIdentical(c,t);n+=a.length+1}}static from(e,t=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new zt(d,t)}let s=Math.max(32,n>>5),r=s<<1,o=s>>1,l=[],a=0,c=-1,u=[];function h(d){let p;if(d.lines>r&&d instanceof ci)for(let y of d.children)h(y);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof zt&&a&&(p=u[u.length-1])instanceof zt&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,u[u.length-1]=new zt(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&f(),a+=d.lines,c+=d.length+1,u.push(d))}function f(){a!=0&&(l.push(u.length==1?u[0]:ci.from(u,c)),c=-1,a=u.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new ci(l,t)}}yt.empty=new zt([""],0);function db(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Ao(i,e,t=0,n=1e9){for(let s=0,r=0,o=!0;r=t&&(a>n&&(l=l.slice(0,n-s)),s0?1:(e instanceof zt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],r=this.offsets[n],o=r>>1,l=s instanceof zt?s.text.length:s.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(s instanceof zt){let a=s.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof zt?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Rf{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new pr(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=n?s:t<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Nf{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol!="undefined"&&(yt.prototype[Symbol.iterator]=function(){return this.iter()},pr.prototype[Symbol.iterator]=Rf.prototype[Symbol.iterator]=Nf.prototype[Symbol.iterator]=function(){return this});class pb{constructor(e,t,n,s){this.from=e,this.to=t,this.number=n,this.text=s}get length(){return this.to-this.from}}function Vs(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}let Ps="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;ii)return Ps[e-1]<=i;return!1}function Tu(i){return i>=127462&&i<=127487}const Mu=8205;function nn(i,e,t=!0,n=!0){return(t?If:gb)(i,e,n)}function If(i,e,t){if(e==i.length)return e;e&&Lf(i.charCodeAt(e))&&$f(i.charCodeAt(e-1))&&e--;let n=en(i,e);for(e+=$n(n);e=0&&Tu(en(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function gb(i,e,t){for(;e>0;){let n=If(i,e-2,t);if(n=56320&&i<57344}function $f(i){return i>=55296&&i<56320}function en(i,e){let t=i.charCodeAt(e);if(!$f(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Lf(n)?(t-55296<<10)+(n-56320)+65536:t}function nc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function $n(i){return i<65536?1:2}const sa=/\r\n?|\n/;var mn=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(mn||(mn={}));class di{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=l}else{if(n!=mn.Simple&&c>=e&&(n==mn.TrackDel&&se||n==mn.TrackBefore&&se))return null;if(c>e||c==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=c}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let n=0,s=0;n=0&&s<=t&&l>=e)return st?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new di(e)}static create(e){return new di(e)}}class Ut extends di{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ra(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return oa(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let s=0,r=0;s=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;n.length0&&Ri(n,t,r.text),r.forward(u),l+=u}let c=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,n){let s=[],r=[],o=0,l=null;function a(u=!1){if(!u&&!s.length)return;of||h<0||f>t)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?yt.of(d.split(n||sa)):d:yt.empty,y=p.length;if(h==f&&y==0)return;ho&&ln(s,h-o,-1),ln(s,f-h,y),Ri(r,s,p),o=f}}return c(e),a(!l),l}static empty(e){return new Ut(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let s=0;sl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;n.length=0&&t<=0&&t==i[s+1]?i[s]+=e:e==0&&i[s]==0?i[s+1]+=t:n?(i[s]+=e,i[s+1]+=t):i.push(e,t)}function Ri(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(s,c,r,u,h),s=c,r=u}}}function oa(i,e,t,n=!1){let s=[],r=n?[]:null,o=new vr(i),l=new vr(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);ln(s,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let c=0,u=o.len;for(;u;)if(l.ins==-1){let h=Math.min(u,l.len);c+=h,u-=h,l.forward(h)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||n.length>c),r.forward2(a),o.forward(a)}}}}class vr{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?yt.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?yt.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class rs{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new rs(n,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return ae.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ae.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ae.range(e.anchor,e.head)}static create(e,t,n){return new rs(e,t,n)}}class ae{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ae.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ae(e.ranges.map(t=>rs.fromJSON(t)),e.main)}static single(e,t=e){return new ae([ae.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,s=0;se?8:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(n);for(let s=1;sr.head?ae.range(a,l):ae.range(l,a))}}return new ae(e,t)}}function zf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let ic=0;class Be{constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=ic++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new Be(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:sc),!!e.static,e.enables)}of(e){return new To([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new To(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new To(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function sc(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class To{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=ic++}dynamicSlot(e){var t;let n=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,c=!1,u=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?c=!0:((t=e[h.id])!==null&&t!==void 0?t:1)&1||u.push(e[h.id]);return{create(h){return h.values[o]=n(h),1},update(h,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||la(h,u)){let d=n(h);if(l?!Du(d,h.values[o],s):!s(d,h.values[o]))return h.values[o]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[r];if(p!=null){let y=_o(f,p);if(this.dependencies.every(b=>b instanceof Be?f.facet(b)===h.facet(b):b instanceof rn?f.field(b,!1)==h.field(b,!1):!0)||(l?Du(d=n(h),y,s):s(d=n(h),y)))return h.values[o]=y,0}else d=n(h);return h.values[o]=d,1}}}}function Du(i,e,t){if(i.length!=e.length)return!1;for(let n=0;ni[a.id]),s=t.map(a=>a.type),r=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let c=[];for(let u=0;un===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ou).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,s)=>{let r=n.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(n.values[t]=o,1)},reconfigure:(n,s)=>s.config.address[this.id]!=null?(n.values[t]=s.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,Ou.of({field:this,create:e})]}get extension(){return this}}const ts={lowest:4,low:3,default:2,high:1,highest:0};function tr(i){return e=>new Vf(e,i)}const vs={highest:tr(ts.highest),high:tr(ts.high),default:tr(ts.default),low:tr(ts.low),lowest:tr(ts.lowest)};class Vf{constructor(e,t){this.inner=e,this.prec=t}}class zr{of(e){return new aa(this,e)}reconfigure(e){return zr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class aa{constructor(e,t){this.compartment=e,this.inner=t}}class $o{constructor(e,t,n,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let s=[],r=Object.create(null),o=new Map;for(let f of yb(e,t,o))f instanceof rn?s.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of s)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let u=n==null?void 0:n.config.facets;for(let f in r){let d=r[f],p=d[0].facet,y=u&&u[f]||[];if(d.every(b=>b.type==0))if(l[p.id]=a.length<<1|1,sc(y,d))a.push(n.facet(p));else{let b=p.combine(d.map(m=>m.value));a.push(n&&p.compare(b,n.facet(p))?n.facet(p):b)}else{for(let b of d)b.type==0?(l[b.id]=a.length<<1|1,a.push(b.value)):(l[b.id]=c.length<<1,c.push(m=>b.dynamicSlot(m)));l[p.id]=c.length<<1,c.push(b=>bb(b,p,d))}}let h=c.map(f=>f(l));return new $o(e,o,h,l,a,r)}}function yb(i,e,t){let n=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let c=n[a].indexOf(o);c>-1&&n[a].splice(c,1),o instanceof aa&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let c of o)r(c,l);else if(o instanceof aa){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,l)}else if(o instanceof Vf)r(o.inner,o.prec);else if(o instanceof rn)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof To)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,ts.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(c,l)}}return r(i,ts.default),n.reduce((o,l)=>o.concat(l))}function mr(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let s=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|s}function _o(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const Hf=Be.define(),ca=Be.define({combine:i=>i.some(e=>e),static:!0}),Wf=Be.define({combine:i=>i.length?i[0]:void 0,static:!0}),jf=Be.define(),qf=Be.define(),Uf=Be.define(),Kf=Be.define({combine:i=>i.length?i[0]:!1});class Si{constructor(e,t){this.type=e,this.value=t}static define(){return new wb}}class wb{of(e){return new Si(this,e)}}class vb{constructor(e){this.map=e}of(e){return new et(this,e)}}class et{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new et(this.type,t)}is(e){return this.type==e}static define(e={}){return new vb(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let s of e){let r=s.map(t);r&&n.push(r)}return n}}et.reconfigure=et.define();et.appendConfig=et.define();class Kt{constructor(e,t,n,s,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&zf(n,t.newLength),r.some(l=>l.type==Kt.time)||(this.annotations=r.concat(Kt.time.of(Date.now())))}static create(e,t,n,s,r,o){return new Kt(e,t,n,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Kt.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Kt.time=Si.define();Kt.userEvent=Si.define();Kt.addToHistory=Si.define();Kt.remote=Si.define();function kb(i,e){let t=[];for(let n=0,s=0;;){let r,o;if(n=i[n]))r=i[n++],o=i[n++];else if(s=0;s--){let r=n[s](i);r instanceof Kt?i=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Kt?i=r[0]:i=Yf(e,Bs(r),!1)}return i}function Sb(i){let e=i.startState,t=e.facet(Uf),n=i;for(let s=t.length-1;s>=0;s--){let r=t[s](i);r&&Object.keys(r).length&&(n=Gf(n,ua(e,r,i.changes.newLength),!0))}return n==i?i:Kt.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const Cb=[];function Bs(i){return i==null?Cb:Array.isArray(i)?i:[i]}var It=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(It||(It={}));const Ab=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ha;try{ha=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(i){}function Tb(i){if(ha)return ha.test(i);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Ab.test(t)))return!0}return!1}function Mb(i){return e=>{if(!/\S/.test(e))return It.Space;if(Tb(e))return It.Word;for(let t=0;t-1)return It.Word;return It.Other}}class ht{constructor(e,t,n,s,r,o){this.config=e,this.doc=t,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ls.set(c,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(et.reconfigure)?(t=null,n=l.value):l.is(et.appendConfig)&&(t=null,n=Bs(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=$o.resolve(n,s,this),r=new ht(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(ca)?e.newSelection:e.newSelection.asSingle();new ht(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:ae.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),s=this.changes(n.changes),r=[n.range],o=Bs(n.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return ht.create({doc:e.doc,selection:ae.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=$o.resolve(e.extensions||[],new Map),n=e.doc instanceof yt?e.doc:yt.of((e.doc||"").split(t.staticFacet(ht.lineSeparator)||sa)),s=e.selection?e.selection instanceof ae?e.selection:ae.single(e.selection.anchor,e.selection.head):ae.single(0);return zf(s,n.length),t.staticFacet(ca)||(s=s.asSingle()),new ht(t,n,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(ht.tabSize)}get lineBreak(){return this.facet(ht.lineSeparator)||` `}get readOnly(){return this.facet(Kf)}phrase(e,...t){for(let n of this.facet(ht.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?n:t[r-1]})),e}languageDataAt(e,t,n=-1){let s=[];for(let r of this.facet(Hf))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return Mb(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=nn(t,o,!1);if(r(t.slice(a,o))!=It.Word)break;o=a}for(;li.length?i[0]:4});ht.lineSeparator=Wf;ht.readOnly=Kf;ht.phrases=Be.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(s=>i[s]==e[s])}});ht.languageData=Hf;ht.changeFilter=jf;ht.transactionFilter=qf;ht.transactionExtender=Uf;zr.reconfigure=et.define();function mi(i,e,t={}){let n={};for(let s of i)for(let r of Object.keys(s)){let o=s[r],l=n[r];if(l===void 0)n[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))n[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)n[s]===void 0&&(n[s]=e[s]);return n}class ds{eq(e){return this==e}range(e,t=e){return fa.create(e,t,this)}}ds.prototype.startSide=ds.prototype.endSide=0;ds.prototype.point=!1;ds.prototype.mapMode=mn.TrackDel;let fa=class Xf{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Xf(e,t,n)}};function da(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class rc{constructor(e,t,n,s){this.from=e,this.to=t,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,s=0){let r=n?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,c=r[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(e,t,n,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);rd||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(l=Math.max(l,d-f)),n.push(c),s.push(f-o),r.push(d-o))}return{mapped:n.length?new rc(s,r,n,l):null,pos:o}}}class gt{constructor(e,t,n,s){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=s}static create(e,t,n,s){return new gt(e,t,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(da)),this.isEmpty)return t.length?gt.of(t):this;let l=new Jf(this,null,-1).goto(0),a=0,c=[],u=new Wi;for(;l.value||a=0){let h=t[a++];u.addInner(h.from,h.to,h.value)||c.push(h)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return kr.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return kr.from(e).goto(t)}static compare(e,t,n,s,r=-1){let o=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=r),l=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=r),a=Eu(o,l,n),c=new nr(o,a,r),u=new nr(l,a,r);n.iterGaps((h,f,d)=>Fu(c,h,u,f,d,s)),n.empty&&n.length==0&&Fu(c,0,u,0,0,s)}static eq(e,t,n=0,s){s==null&&(s=999999999);let r=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),o=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Eu(r,o),a=new nr(r,l,0).goto(n),c=new nr(o,l,0).goto(n);for(;;){if(a.to!=c.to||!pa(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>s)return!0;a.next(),c.next()}}static spans(e,t,n,s,r=-1){let o=new nr(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let u=o.activeForPoint(o.to),h=o.pointFroml&&(s.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,t=!1){let n=new Wi;for(let s of e instanceof fa?[e]:t?Db(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return gt.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=gt.empty;s=s.nextLayer)t=new gt(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}gt.empty=new gt([],[],null,-1);function Db(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort(da);e=n}return i}gt.empty.nextLayer=gt.empty;class Wi{finishChunk(e){this.chunks.push(new rc(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Wi)).add(e,t,n)}addInner(e,t,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(gt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=gt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Eu(i,e,t){let n=new Map;for(let r of i)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&s.push(new Jf(o,t,n,r));return s.length==1?s[0]:new kr(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Fl(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Fl(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Fl(this.heap,0)}}}function Fl(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let s=i[n];if(n+1=0&&(s=i[n+1],n++),t.compare(s)<0)break;i[n]=t,i[e]=s,e=n}}class nr{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=kr.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Qr(this.active,e),Qr(this.activeTo,e),Qr(this.activeRank,e),this.minActive=Pu(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:s,rank:r}=this.cursor;for(;t0;)t++;Zr(this.active,t,n),Zr(this.activeTo,t,s),Zr(this.activeRank,t,r),e&&Zr(e,t,this.cursor.from),this.minActive=Pu(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&Qr(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[s]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function Fu(i,e,t,n,s,r){i.goto(e),t.goto(n);let o=n+s,l=n,a=n-e;for(;;){let c=i.to+a-t.to||i.endSide-t.endSide,u=c<0?i.to+a:t.to,h=Math.min(u,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&pa(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,h,i.point,t.point):h>l&&!pa(i.active,t.active)&&r.compareRange(l,h,i.active,t.active),u>o)break;l=u,c<=0&&i.next(),c>=0&&t.next()}}function pa(i,e){if(i.length!=e.length)return!1;for(let t=0;t=e;n--)i[n+1]=i[n];i[e]=t}function Pu(i,e){let t=-1,n=1e9;for(let s=0;s=e)return s;if(s==i.length)break;r+=i.charCodeAt(s)==9?t-r%t:1,s=nn(i,s)}return n===!0?-1:i.length}const ga="ͼ",Bu=typeof Symbol=="undefined"?"__"+ga:Symbol.for(ga),ba=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ru=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{};class ji{constructor(e,t){this.rules=[];let{finish:n}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,c){let u=[],h=/^@(\w+)\b/.exec(o[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(y=>o.map(b=>y.replace(/&/,b))).reduce((y,b)=>y.concat(b)),p,a);else if(p&&typeof p=="object"){if(!h)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,u,f)}else p!=null&&u.push(d.replace(/_.*/,"").replace(/[A-Z]/g,y=>"-"+y.toLowerCase())+": "+p+";")}(u.length||f)&&a.push((n&&!h&&!c?o.map(n):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Ru[Bu]||1;return Ru[Bu]=e+1,ga+e.toString(36)}static mount(e,t,n){let s=e[ba],r=n&&n.nonce;s?r&&s.setNonce(r):s=new Ob(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let Nu=new Map;class Ob{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=Nu.get(n);if(r)return e[ba]=r;this.sheet=new s.CSSStyleSheet,Nu.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[ba]=this}mount(e,t){let n=this.sheet,s=0,r=0;for(let o=0;o-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),n)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Eb=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Fb=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var tn=0;tn<10;tn++)qi[48+tn]=qi[96+tn]=String(tn);for(var tn=1;tn<=24;tn++)qi[tn+111]="F"+tn;for(var tn=65;tn<=90;tn++)qi[tn]=String.fromCharCode(tn+32),xr[tn]=String.fromCharCode(tn);for(var Pl in qi)xr.hasOwnProperty(Pl)||(xr[Pl]=qi[Pl]);function Pb(i){var e=Eb&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Fb&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?xr:qi)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Sr(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function ya(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Mo(i,e){if(!e.anchorNode)return!1;try{return ya(i,e.anchorNode)}catch(t){return!1}}function Hs(i){return i.nodeType==3?ms(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function gr(i,e,t,n){return t?Iu(i,e,t,n,-1)||Iu(i,e,t,n,1):!1}function ps(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function zo(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function Iu(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:pi(i))){if(i.nodeName=="DIV")return!1;let r=i.parentNode;if(!r||r.nodeType!=1)return!1;e=ps(i)+(s<0?0:1),i=r}else if(i.nodeType==1){if(i=i.childNodes[e+(s<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=s<0?pi(i):0}else return!1}}function pi(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function Vr(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Bb(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function Qf(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function Rb(i,e,t,n,s,r,o,l){let a=i.ownerDocument,c=a.defaultView||window;for(let u=i,h=!1;u&&!h;)if(u.nodeType==1){let f,d=u==a.body,p=1,y=1;if(d)f=Bb(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let x=u.getBoundingClientRect();({scaleX:p,scaleY:y}=Qf(u,x)),f={left:x.left,right:x.left+u.clientWidth*p,top:x.top,bottom:x.top+u.clientHeight*y}}let b=0,m=0;if(s=="nearest")e.top0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+o)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+o,t<0&&e.top-m0&&e.right>f.right+b&&(b=e.right-f.right+b+r)):e.right>f.right&&(b=e.right-f.right+r,t<0&&e.lefts.clientHeight&&(n=s),!t&&s.scrollWidth>s.clientWidth&&(t=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:t,y:n}}class Ib{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?pi(t):0),n,Math.min(e.focusOffset,n?pi(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let Ss=null;function Zf(i){if(i.setActive)return i.setActive();if(Ss)return i.focus(Ss);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Ss==null?{get preventScroll(){return Ss={preventScroll:!0},!0}}:void 0),!Ss){Ss=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}function nd(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=pi(t)}else if(t.parentNode&&!zo(t))n=ps(t),t=t.parentNode;else return null}}function id(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&nt)return h.domBoundsAround(e,t,c);if(f>=e&&s==-1&&(s=a,r=c),c>t&&h.dom.parentNode==this.dom){o=a,l=u;break}u=f,c=f+h.breakAfter}return{from:r,to:l<0?n+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=oc){this.markDirty();for(let s=e;sthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function rd(i,e,t,n,s,r,o,l,a){let{children:c}=i,u=c.length?c[e]:null,h=r.length?r[r.length-1]:null,f=h?h.breakAfter:o;if(!(e==n&&u&&!o&&!f&&r.length<2&&u.merge(t,s,r.length?h:null,t==0,l,a))){if(n0&&(!o&&r.length&&u.merge(t,u.length,r[0],!1,l,0)?u.breakAfter=r.shift().breakAfter:(t2);var Ne={mac:Vu||/Mac/.test(vn.platform),windows:/Win/.test(vn.platform),linux:/Linux|X11/.test(vn.platform),ie:dl,ie_version:ld?wa.documentMode||6:ka?+ka[1]:va?+va[1]:0,gecko:_u,gecko_version:_u?+(/Firefox\/(\d+)/.exec(vn.userAgent)||[0,0])[1]:0,chrome:!!Bl,chrome_version:Bl?+Bl[1]:0,ios:Vu,android:/Android\b/.test(vn.userAgent),webkit:zu,safari:ad,webkit_version:zu?+(/\bAppleWebKit\/(\d+)/.exec(vn.userAgent)||[0,0])[1]:0,tabSize:wa.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const _b=256;class Jn extends At{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof Jn)||this.length-(t-e)+n.length>_b||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Jn(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new an(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return zb(this.dom,e,t)}}class ki extends At{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let s of t)s.setParent(this)}setAttrs(e){if(ed(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,s,r,o){return n&&(!(n instanceof ki&&n.mark.eq(this.mark))||e&&r<=0||te&&t.push(n=e&&(s=r),n=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new ki(this.mark,t,o)}domAtPos(e){return cd(this,e)}coordsAt(e,t){return hd(this,e,t)}}function zb(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;e==0&&t<0||e==n&&t>=0?Ne.chrome||Ne.gecko||(e?(s--,o=1):r=0)?0:l.length-1];return Ne.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),o?Vr(a,o<0):a||null}class Ni extends At{static create(e,t,n){return new Ni(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=Ni.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,s,r,o){return n&&(!(n instanceof Ni)||!this.widget.compare(n.widget)||e>0&&r<=0||t0)?an.before(this.dom):an.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?s.length-1:0;r=s[l],!(e>0?l==0:l==s.length-1||r.top0?an.before(this.dom):an.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return yt.empty}get isHidden(){return!0}}Jn.prototype.children=Ni.prototype.children=Ws.prototype.children=oc;function cd(i,e){let t=i.dom,{children:n}=i,s=0;for(let r=0;sr&&e0;r--){let o=n[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r0&&e instanceof ki&&s.length&&(n=s[s.length-1])instanceof ki&&n.mark.eq(e.mark)?ud(n,e.children[0],t-1):(s.push(e),e.setParent(i)),i.length+=e.length}function hd(i,e,t){let n=null,s=-1,r=null,o=-1;function l(c,u){for(let h=0,f=0;h=u&&(d.children.length?l(d,u-f):(!r||r.isHidden&&t>0)&&(p>u||f==p&&d.getSide()>0)?(r=d,o=u-f):(f-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let r of n)if(r!=t&&(s.indexOf(r)==-1||i[r]!==e[r]))return!1;return!0}function Sa(i,e,t){let n=!1;if(e)for(let s in e)t&&s in t||(n=!0,s=="style"?i.style.cssText="":i.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(n=!0,s=="style"?i.style.cssText=t[s]:i.setAttribute(s,t[s]));return n}function Hb(i){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Ui(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,s;if(e.isBlockGap)n=-5e8,s=4e8;else{let{start:r,end:o}=fd(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ui(e,n,s,t,e.widget||null,!0)}static line(e){return new Wr(e)}static set(e,t=!1){return gt.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}_e.none=gt.empty;class Hr extends _e{constructor(e){let{start:t,end:n}=fd(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof Hr&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&Vo(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Hr.prototype.point=!1;class Wr extends _e{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Wr&&this.spec.class==e.spec.class&&Vo(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Wr.prototype.mapMode=mn.TrackBefore;Wr.prototype.point=!0;class Ui extends _e{constructor(e,t,n,s,r,o){super(t,n,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?mn.TrackBefore:mn.TrackAfter:mn.TrackDel}get type(){return this.startSide!=this.endSide?gn.WidgetRange:this.startSide<=0?gn.WidgetBefore:gn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ui&&Wb(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ui.prototype.point=!0;function fd(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t!=null?t:e,end:n!=null?n:e}}function Wb(i,e){return i==e||!!(i&&e&&i.compare(e))}function Ca(i,e,t,n=0){let s=t.length-1;s>=0&&t[s]+n>=i?t[s]=Math.max(t[s],e):t.push(i,e)}class Ht extends At{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,s,r,o){if(n){if(!(n instanceof Ht))return!1;this.dom||n.transferDOM(this)}return s&&this.setDeco(n?n.attrs:null),od(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new Ht;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:s}=this.childPos(e);s&&(t.append(this.children[n].split(s),0),this.children[n].merge(s,this.children[n].length,null,!1,0,0),n++);for(let r=n;r0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Vo(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){ud(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=xa(t,this.attrs||{})),n&&(this.attrs=xa({class:n},this.attrs||{}))}domAtPos(e){return cd(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(ed(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Sa(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&At.get(s)instanceof ki;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((n=At.get(s))===null||n===void 0?void 0:n.isEditable)==!1&&(!Ne.ios||!this.children.some(r=>r instanceof Jn))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof Jn)||/[^ -~]/.test(n.text))return null;let s=Hs(n.dom);if(s.length!=1)return null;e+=s[0].width,t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=hd(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:s}=this.parent.view.viewState,r=n.bottom-n.top;if(Math.abs(r-s.lineHeight)<2&&s.textHeight=t){if(r instanceof Ht)return r;if(o>t)break}s=o+r.breakAfter}return null}}class vi extends At{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,s,r,o){return n&&(!(n instanceof vi)||!this.widget.compare(n.widget)||e>0&&r<=0||t0}}class Aa extends Ci{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class br{constructor(e,t,n,s){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof vi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ht),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(eo(new Ws(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof vi)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=r,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(eo(new Jn(this.text.slice(this.textOff,this.textOff+s)),t),n),this.atCursorPos=!0,this.textOff+=s,e-=s,n=0}}span(e,t,n,s){this.buildText(t-e,n,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,n,s,r,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Ui){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(n instanceof Ui)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new vi(n.widget||js.block,l,n));else{let a=Ni.create(n.widget||js.inline,l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e0),u=!a.isEditable&&(es.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),c&&(h.append(eo(new Ws(1),s),r),r=s.length+Math.max(0,r-s.length)),h.append(eo(a,s),r),this.atCursorPos=u,this.pendingBuffer=u?es.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,s,r){let o=new br(e,t,n,r);return o.openEnd=gt.spans(s,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function eo(i,e){for(let t of e)i=new ki(t,[i],i.length);return i}class js extends Ci{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}js.inline=new js("span");js.block=new js("div");var Rt=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(Rt||(Rt={}));const gs=Rt.LTR,lc=Rt.RTL;function dd(i){let e=[];for(let t=0;t=t){if(l.level==n)return o;(r<0||(s!=0?s<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function md(i,e){if(i.length!=e.length)return!1;for(let t=0;t=0;y-=3)if(ri[y+1]==-d){let b=ri[y+2],m=b&2?s:b&4?b&1?r:s:0;m&&(Ct[h]=Ct[ri[y]]=m),l=y;break}}else{if(ri.length==189)break;ri[l++]=h,ri[l++]=f,ri[l++]=a}else if((p=Ct[h])==2||p==1){let y=p==s;a=y?0:1;for(let b=l-3;b>=0;b-=3){let m=ri[b+2];if(m&2)break;if(y)ri[b+2]|=2;else{if(m&4)break;ri[b+2]|=4}}}}}function Yb(i,e,t,n){for(let s=0,r=n;s<=t.length;s++){let o=s?t[s-1].to:i,l=sa;)p==b&&(p=t[--y].from,b=y?t[y-1].to:i),Ct[--p]=d;a=u}else r=c,a++}}}function Ma(i,e,t,n,s,r,o){let l=n%2?2:1;if(n%2==s%2)for(let a=e,c=0;aa&&o.push(new Ii(a,y.from,d));let b=y.direction==gs!=!(d%2);Da(i,b?n+1:n,s,y.inner,y.from,y.to,o),a=y.to}p=y.to}else{if(p==t||(u?Ct[p]!=l:Ct[p]==l))break;p++}f?Ma(i,a,p,n+1,s,f,o):ae;){let u=!0,h=!1;if(!c||a>r[c-1].to){let y=Ct[a-1];y!=l&&(u=!1,h=y==16)}let f=!u&&l==1?[]:null,d=u?n:n+1,p=a;e:for(;;)if(c&&p==r[c-1].to){if(h)break e;let y=r[--c];if(!u)for(let b=y.from,m=c;;){if(b==e)break e;if(m&&r[m-1].to==b)b=r[--m].from;else{if(Ct[b-1]==l)break e;break}}if(f)f.push(y);else{y.toCt.length;)Ct[Ct.length]=256;let n=[],s=e==gs?0:1;return Da(i,s,s,t,0,i.length,n),n}function gd(i){return[new Ii(0,i,0)]}let bd="";function Jb(i,e,t,n,s){var r;let o=n.head-i.from,l=Ii.find(e,o,(r=n.bidiLevel)!==null&&r!==void 0?r:-1,n.assoc),a=e[l],c=a.side(s,t);if(o==c){let f=l+=s?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!s,t),c=a.side(s,t)}let u=nn(i.text,o,a.forward(s,t));(ua.to)&&(u=c),bd=i.text.slice(Math.min(o,u),Math.max(o,u));let h=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return h&&u==c&&h.level+(s?0:1)i.some(e=>e)}),Ad=Be.define({combine:i=>i.some(e=>e)}),Td=Be.define();class Ns{constructor(e,t="nearest",n="nearest",s=5,r=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Ns(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ns(ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const to=et.define({map:(i,e)=>i.map(e)}),Md=et.define();function Cn(i,e,t){let n=i.facet(kd);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)}const Fi=Be.define({combine:i=>i.length?i[0]:!0});let Zb=0;const lr=Be.define();class Vt{constructor(e,t,n,s,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=s,this.extension=r(this)}static define(e,t){const{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=t||{};return new Vt(Zb++,e,n,s,l=>{let a=[lr.of(l)];return o&&a.push(Cr.of(c=>{let u=c.plugin(l);return u?o(u):_e.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return Vt.define(n=>new e(n),t)}}class Rl{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Cn(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(s){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Cn(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Cn(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Dd=Be.define(),uc=Be.define(),Cr=Be.define(),Od=Be.define(),hc=Be.define(),Ed=Be.define();function Wu(i,e){let t=i.state.facet(Ed);if(!t.length)return t;let n=t.map(r=>r instanceof Function?r(i):r),s=[];return gt.spans(n,e.from,e.to,{point(){},span(r,o,l,a){let c=r-e.from,u=o-e.from,h=s;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=Qb(e.text,c,u)),a>0&&h.length&&(p=h[h.length-1]).to==c&&p.direction==d)p.to=u,h=p.inner;else{let y={from:c,to:u,direction:d,inner:[]};h.push(y),h=y.inner}}}}),s}const Fd=Be.define();function Pd(i){let e=0,t=0,n=0,s=0;for(let r of i.state.facet(Fd)){let o=r(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:n,bottom:s}}const ar=Be.define();class Wn{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new Wn(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>n.toA)){if(s.toAu)break;r+=2}if(!a)return n;new Wn(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}}class Ho{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ut.empty(this.startState.doc.length);for(let r of n)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new Wn(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new Ho(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class ju extends At{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=_e.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ht],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Wn(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:c,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!oy(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?ty(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:c,to:u}=this.hasComposition;n=new Wn(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Ne.ie||Ne.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=sy(o,l,e.changes);return n=Wn.extendWithRanges(n,a),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=Ne.chrome||Ne.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||s.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to=0?s[o]:null;if(!l)break;let{fromA:a,toA:c,fromB:u,toB:h}=l,f,d,p,y;if(n&&n.range.fromBu){let P=br.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),O=br.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);d=P.breakAtStart,p=P.openStart,y=O.openEnd;let D=this.compositionView(n);O.breakAtStart?D.breakAfter=1:O.content.length&&D.merge(D.length,D.length,O.content[0],!1,O.openStart,0)&&(D.breakAfter=O.content[0].breakAfter,O.content.shift()),P.content.length&&D.merge(0,0,P.content[P.content.length-1],!0,0,P.openEnd)&&P.content.pop(),f=P.content.concat(D).concat(O.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:y}=br.build(this.view.state.doc,u,h,this.decorations,this.dynamicDecorationMap));let{i:b,off:m}=r.findPos(c,1),{i:x,off:v}=r.findPos(a,-1);rd(this,x,v,b,m,f,d,p,y)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(Md)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new Jn(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new ki(s,[t],t.length);let n=new Ht;return n.append(t,0),n}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=At.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},n=this.childPos(e.range.fromB,1),s=this.children[n.i];t(e.line,s);for(let r=e.marks.length-1;r>=-1;r--)n=s.childPos(n.off,1),s=s.children[n.i],t(r>=0?e.marks[r].node:e.text,s)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,s=n==this.dom,r=!s&&Mo(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),c=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(Ne.gecko&&l.empty&&!this.hasComposition&&ey(a)){let h=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(h,a.node.childNodes[a.offset]||null)),a=c=new an(h,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!gr(a.node,a.offset,u.anchorNode,u.anchorOffset)||!gr(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{Ne.android&&Ne.chrome&&this.dom.contains(u.focusNode)&&ry(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Sr(this.view.root);if(h)if(l.empty){if(Ne.gecko){let f=ny(a.node,a.offset);if(f&&f!=3){let d=(f==1?nd:id)(a.node,a.offset);d&&(a=new an(d.node,d.offset))}}h.collapse(a.node,a.offset),l.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(a.node,a.offset);try{h.extend(c.node,c.offset)}catch(f){}}else{let f=document.createRange();l.anchor>l.head&&([a,c]=[c,a]),f.setEnd(c.node,c.offset),f.setStart(a.node,a.offset),h.removeAllRanges(),h.addRange(f)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,c)),this.impreciseAnchor=a.precise?null:new an(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new an(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&gr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Sr(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Ht.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(s,r)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let s=e.offset;!n&&s=0;s--){let r=At.get(t.childNodes[s]);r instanceof Ht&&(n=r.domAtPos(r.length))}return n?new an(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=At.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t=0;o--){let l=this.children[o],a=r-l.breakAfter,c=a-l.length;if(ae||l.covers(1))&&(!n||l instanceof Ht&&!(n instanceof Ht&&t>=0)))n=l,s=c;else if(n&&c==e&&a==e&&l instanceof vi&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(n=null)}r=c}return n?n.coordsAt(e-s,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),s=this.children[t];if(!(s instanceof Ht))return null;for(;s.children.length;){let{i:l,off:a}=s.childPos(n,1);for(;;l++){if(l==s.children.length)return null;if((s=s.children[l]).length)break}n=a}if(!(s instanceof Jn))return null;let r=nn(s.text,n);if(r==n)return null;let o=ms(s.dom,n,r).getClientRects();for(let l=0;lMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Rt.LTR;for(let c=0,u=0;us)break;if(c>=n){let d=h.dom.getBoundingClientRect();if(t.push(d.height),o){let p=h.dom.lastChild,y=p?Hs(p):[];if(y.length){let b=y[y.length-1],m=a?b.right-d.left:d.right-b.left;m>l&&(l=m,this.minWidth=r,this.minWidthFrom=c,this.minWidthTo=f)}}}c=f+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?Rt.RTL:Rt.LTR}measureTextSize(){for(let r of this.children)if(r instanceof Ht){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=Hs(e.firstChild)[0];t=e.getBoundingClientRect().height,n=r?r.width/27:7,s=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:s}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new sd(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>n){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(_e.replace({widget:new Aa(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return _e.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Cr).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(Od).map((r,o)=>{let l=typeof r=="function";return l&&(n=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=n,t.push(gt.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),s;if(!n)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,s.left),top:Math.min(n.top,s.top),right:Math.max(n.right,s.right),bottom:Math.max(n.bottom,s.bottom)});let r=Pd(this.view),o={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Rb(this.view.scrollDOM,o,t.head{ne.from&&(t=!0)}),t}function ly(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return ae.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=nn(s.text,r,!1):l=nn(s.text,r);let a=n(s.text.slice(o,l));for(;o>0;){let c=nn(s.text,o,!1);if(n(s.text.slice(c,o))!=a)break;o=c}for(;li?e.left-i:Math.max(0,i-e.right)}function cy(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function Nl(i,e){return i.tope.top+1}function qu(i,e){return ei.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Ea(i,e,t){let n,s,r,o,l=!1,a,c,u,h;for(let p=i.firstChild;p;p=p.nextSibling){let y=Hs(p);for(let b=0;bv||o==v&&r>x){n=p,s=m,r=x,o=v;let P=v?t0?b0)}x==0?t>m.bottom&&(!u||u.bottomm.top)&&(c=p,h=m):u&&Nl(u,m)?u=Uu(u,m.bottom):h&&Nl(h,m)&&(h=qu(h,m.top))}}if(u&&u.bottom>=t?(n=a,s=u):h&&h.top<=t&&(n=c,s=h),!n)return{node:i,offset:0};let f=Math.max(s.left,Math.min(s.right,e));if(n.nodeType==3)return Ku(n,f,t);if(l&&n.contentEditable!="false")return Ea(n,f,t);let d=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(s.left+s.right)/2?1:0);return{node:i,offset:d}}function Ku(i,e,t){let n=i.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;lt?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&h=(u.left+u.right)/2,d=f;if((Ne.chrome||Ne.gecko)&&ms(i,l).getBoundingClientRect().left==u.right&&(d=!f),h<=0)return{node:i,offset:l+(d?1:0)};s=l+(d?1:0),r=h}}}return{node:i,offset:s>-1?s:o>0?i.nodeValue.length:0}}function Rd(i,e,t,n=-1){var s,r;let o=i.contentDOM.getBoundingClientRect(),l=o.top+i.viewState.paddingTop,a,{docHeight:c}=i.viewState,{x:u,y:h}=e,f=h-l;if(f<0)return 0;if(f>c)return i.state.doc.length;for(let P=i.viewState.heightOracle.textHeight/2,O=!1;a=i.elementAtHeight(f),a.type!=gn.Text;)for(;f=n>0?a.bottom+P:a.top-P,!(f>=0&&f<=c);){if(O)return t?null:0;O=!0,n=-n}h=l+f;let d=a.from;if(di.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Gu(i,o,a,u,h);let p=i.dom.ownerDocument,y=i.root.elementFromPoint?i.root:p,b=y.elementFromPoint(u,h);b&&!i.contentDOM.contains(b)&&(b=null),b||(u=Math.max(o.left+1,Math.min(o.right-1,u)),b=y.elementFromPoint(u,h),b&&!i.contentDOM.contains(b)&&(b=null));let m,x=-1;if(b&&((s=i.docView.nearest(b))===null||s===void 0?void 0:s.isEditable)!=!1){if(p.caretPositionFromPoint){let P=p.caretPositionFromPoint(u,h);P&&({offsetNode:m,offset:x}=P)}else if(p.caretRangeFromPoint){let P=p.caretRangeFromPoint(u,h);P&&({startContainer:m,startOffset:x}=P,(!i.contentDOM.contains(m)||Ne.safari&&uy(m,x,u)||Ne.chrome&&hy(m,x,u))&&(m=void 0))}m&&(x=Math.min(pi(m),x))}if(!m||!i.docView.dom.contains(m)){let P=Ht.find(i.docView,d);if(!P)return f>a.top+a.height/2?a.to:a.from;({node:m,offset:x}=Ea(P.dom,u,h))}let v=i.docView.nearest(m);if(!v)return null;if(v.isWidget&&((r=v.dom)===null||r===void 0?void 0:r.nodeType)==1){let P=v.dom.getBoundingClientRect();return e.yi.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(i.defaultLineHeight-l)*.5)/l);r+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+ma(o,r,i.state.tabSize)}function uy(i,e,t){let n;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(let s=i.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return ms(i,n-1,n).getBoundingClientRect().left>t}function hy(i,e,t){if(e!=0)return!1;for(let s=i;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let n=i.nodeType==1?i.getBoundingClientRect():ms(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Fa(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==gn.Text))return n}return t}function fy(i,e,t,n){let s=Fa(i,e.head),r=!n||s.type!=gn.Text||!(i.lineWrapping||s.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(s.from),a=i.posAtCoords({x:t==(l==Rt.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return ae.cursor(a,t?-1:1)}return ae.cursor(t?s.to:s.from,t?-1:1)}function Yu(i,e,t,n){let s=i.state.doc.lineAt(e.head),r=i.bidiSpans(s),o=i.textDirectionAt(s.from);for(let l=e,a=null;;){let c=Jb(s,r,o,l,t),u=bd;if(!c){if(s.number==(t?i.state.doc.lines:1))return l;u=` `,s=i.state.doc.line(s.number+(t?1:-1)),r=i.bidiSpans(s),c=i.visualLineSide(s,!t)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function dy(i,e,t){let n=i.state.charCategorizer(e),s=n(t);return r=>{let o=n(r);return s==It.Space&&(s=o),s==o}}function py(i,e,t,n){let s=e.head,r=t?1:-1;if(s==(t?i.state.doc.length:0))return ae.cursor(s,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),c=i.coordsAtPos(s,e.assoc||-1),u=i.documentTop;if(c)o==null&&(o=c.left-a.left),l=r<0?c.top:c.bottom;else{let d=i.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(s-d.from))),l=(r<0?d.top:d.bottom)+u}let h=a.left+o,f=n!=null?n:i.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(f+d)*r,y=Rd(i,{x:h,y:p},!1,r);if(pa.bottom||(r<0?ys)){let b=i.docView.coordsForChar(y),m=!b||p{if(e>r&&es(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:ae.cursor(n,nr)&&this.lineBreak(),s=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=r+o}}readNode(e){if(e.cmIgnore)return;let t=At.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let s=n.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(gy(e,n.node,n.offset)?t:0))}}function gy(i,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let l=r||o?[]:vy(e),a=new my(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=ky(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!ya(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!ya(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((Ne.ios||Ne.chrome)&&e.state.selection.main.empty&&a!=c&&(u.from>0||u.toDate.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,c=null;(r===8||Ne.android&&e.text.length=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:i.state.doc.slice(s.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,s.to))}:(Ne.mac||Ne.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=ae.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:yt.of([" "])}):Ne.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` `&&i.lineWrapping&&(n&&(n=ae.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:yt.of([" "])}),t)return fc(i,t,n,r);if(n&&!n.main.eq(s)){let o=!1,l="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),l=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function fc(i,e,t,n=-1){if(Ne.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(Ne.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&i.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Rs(i.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||n==8&&e.insert.lengths.head)&&Rs(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Rs(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=yy(i,e,t));return i.state.facet(xd).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function yy(i,e,t){let n,s=i.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let l=r.frome.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(i.state.toText(l+e.insert.sliceString(0,void 0,i.state.lineBreak)+a))}else{let l=s.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(s.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let c=i.state.sliceDoc(e.from,e.to),u,h=t&&Bd(i,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);u={from:h.from,to:h.to-p}}else u=i.state.doc.lineAt(r.head);let f=r.to-e.to,d=r.to-r.from;n=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:l,range:a||p.map(l)};let y=p.to-f,b=y-c.length;if(p.to-p.from!=d||i.state.sliceDoc(b,y)!=c||p.to>=u.from&&p.from<=u.to)return{range:p};let m=s.changes({from:b,to:y,insert:e.insert}),x=p.to-r.to;return{changes:m,range:a?ae.range(Math.max(0,a.anchor+x),Math.max(0,a.head+x)):p.map(m)}})}else n={changes:l,selection:a&&s.selection.replaceRange(a)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:o,scrollIntoView:!0})}function wy(i,e,t,n){let s=Math.min(i.length,e.length),r=0;for(;r0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function vy(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}=i.observer.selectionRange;return t&&(e.push(new Xu(t,n)),(s!=t||r!=n)&&e.push(new Xu(s,r))),e}function ky(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?ae.single(t+e,n+e):null}class xy{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Ne.safari&&e.contentDOM.addEventListener("input",()=>null),Ne.gecko&&$y(e.contentDOM.ownerDocument)}handleEvent(e){!Ey(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let s of n.observers)s(this.view,t);for(let s of n.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Sy(e),n=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=n[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in n)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ld.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ne.android&&Ne.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return Ne.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Id.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Cy.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:Ne.safari&&!Ne.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Ju(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){Cn(t.state,s)}}}function Sy(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let s=n.spec;if(s&&s.domEventHandlers)for(let r in s.domEventHandlers){let o=s.domEventHandlers[r];o&&t(r).handlers.push(Ju(n.value,o))}if(s&&s.domEventObservers)for(let r in s.domEventObservers){let o=s.domEventObservers[r];o&&t(r).observers.push(Ju(n.value,o))}}for(let n in Qn)t(n).handlers.push(Qn[n]);for(let n in qn)t(n).observers.push(qn[n]);return e}const Id=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Cy="dthko",Ld=[16,17,18,20,91,92,224,225],no=6;function io(i){return Math.max(0,i)*.7+8}function Ay(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class Ty{constructor(e,t,n,s){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Nb(e.contentDOM),this.atoms=e.state.facet(hc).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ht.allowMultipleSelections)&&My(e,t),this.dragging=Oy(e,t)&&zd(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Ay(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Pd(this.view);e.clientX-a.left<=s+no?t=-io(s-e.clientX):e.clientX+a.right>=o-no&&(t=io(e.clientX-o)),e.clientY-a.top<=r+no?n=-io(r-e.clientY):e.clientY+a.bottom>=l-no&&(n=io(e.clientY-l)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;nt.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function My(i,e){let t=i.state.facet(yd);return t.length?t[0](e):Ne.mac?e.metaKey:e.ctrlKey}function Dy(i,e){let t=i.state.facet(wd);return t.length?t[0](e):Ne.mac?!e.altKey:!e.ctrlKey}function Oy(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Sr(i.root);if(!n||n.rangeCount==0)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Ey(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=At.get(t))&&n.ignoreEvent(e))return!1;return!0}const Qn=Object.create(null),qn=Object.create(null),$d=Ne.ie&&Ne.ie_version<15||Ne.ios&&Ne.webkit_version<604;function Fy(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),_d(i,t.value)},50)}function pl(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function _d(i,e){e=pl(i.state,ac,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Pa!=null&&t.selection.ranges.every(a=>a.empty)&&Pa==r.toString()){let a=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==a)return{range:c};a=u.from;let h=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:h},range:ae.cursor(c.from+h.length)}})}else o?n=t.changeByRange(a=>{let c=r.line(s++);return{changes:{from:a.from,to:a.to,insert:c.text},range:ae.cursor(a.from+c.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}qn.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Qn.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);qn.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};qn.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Qn.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(vd))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=Ry(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new Ty(i,e,t,n)),n&&i.observer.ignore(()=>{Zf(i.contentDOM);let r=i.root.activeElement;r&&!r.contains(i.contentDOM)&&r.blur()});let s=i.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}return!1};function Qu(i,e,t,n){if(n==1)return ae.cursor(e,t);if(n==2)return ly(i.state,e,t);{let s=Ht.find(i.docView,e),r=i.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return le>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function Py(i,e,t,n){let s=Ht.find(i.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Zu(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&Zu(t,n,l)?1:o&&o.bottom>=n?-1:1}function eh(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Py(i,t,e.clientX,e.clientY)}}const By=Ne.ie&&Ne.ie_version<=11;let th=null,nh=0,ih=0;function zd(i){if(!By)return i.detail;let e=th,t=ih;return th=i,ih=Date.now(),nh=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(nh+1)%3:1}function Ry(i,e){let t=eh(i,e),n=zd(e),s=i.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=eh(i,r),c,u=Qu(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let h=Qu(i,t.pos,t.bias,n),f=Math.min(h.from,u.from),d=Math.max(h.to,u.to);u=f1&&(c=Ny(s,a.pos))?c:l?s.addRange(u):ae.create([u])}}}function Ny(i,e){for(let t=0;t=e)return ae.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}Qn.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let s=i.docView.nearest(e.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=ae.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",pl(i.state,cc,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Qn.dragend=i=>(i.inputState.draggedContent=null,!1);function sh(i,e,t,n){if(t=pl(i.state,ac,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&Dy(i,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}Qn.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),s=0,r=()=>{++s==t.length&&sh(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return sh(i,e,n,!0),!0}return!1};Qn.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=$d?null:e.clipboardData;return t?(_d(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Fy(i),!1)};function Iy(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function Ly(i){let e=[],t=[],n=!1;for(let s of i.selection.ranges)s.empty||(e.push(i.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of i.selection.ranges){let o=i.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),s=o.number}n=!0}return{text:pl(i,cc,e.join(i.lineBreak)),ranges:t,linewise:n}}let Pa=null;Qn.copy=Qn.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=Ly(i.state);if(!t&&!s)return!1;Pa=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=$d?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Iy(i,t),!1)};const Vd=Si.define();function Hd(i,e){let t=[];for(let n of i.facet(Sd)){let s=n(i,e);s&&t.push(s)}return t?i.update({effects:t,annotations:Vd.of(!0)}):null}function Wd(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Hd(i.state,e);t?i.dispatch(t):i.update([])}},10)}qn.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Wd(i)};qn.blur=i=>{i.observer.clearSelectionRange(),Wd(i)};qn.compositionstart=qn.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};qn.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,Ne.chrome&&Ne.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};qn.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Qn.beforeinput=(i,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&i.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),c=i.posAtDOM(l.endContainer,l.endOffset);return fc(i,{from:a,to:c,insert:i.state.toText(r)},null),!0}}let s;if(Ne.chrome&&Ne.android&&(s=Id.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return Ne.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),Ne.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>qn.compositionend(i,e),20),!1};const rh=new Set;function $y(i){rh.has(i)||(rh.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const oh=["pre-wrap","normal","pre-line","break-spaces"];let qs=!1;function lh(){qs=!1}class _y{constructor(e){this.lineWrapping=e,this.doc=yt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return oh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Oo&&(qs=!0),this.height=e)}replace(e,t,n){return bn.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,s){let r=this,o=n.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:u,toB:h}=s[l],f=r.lineAt(a,Pt.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=c?f:r.lineAt(c,Pt.ByPosNoHeight,n,0,0);for(h+=d.to-c,c=d.to;l>0&&f.from<=s[l-1].toA;)a=s[l-1].fromA,u=s[l-1].fromB,l--,ar*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,s-=l.size}else if(r>s*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,r-=l.size}else break;else if(s=r&&o(this.blockAt(0,n,s,r))}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Bn extends jd{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,s){return new ui(s,this.length,n,this.height,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof Bn||s instanceof Zt&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Zt?s=new Bn(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):bn.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setHeight(s.heights[s.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Zt extends bn{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:n,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,n,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let c=s+(e0){let r=n[n.length-1];r instanceof Zt?n[n.length-1]=new Zt(r.length+s):n.push(null,new Zt(s-1))}if(e>0){let r=n[0];r instanceof Zt?n[0]=new Zt(e+r.length):n.unshift(new Zt(e-1),null)}return bn.of(n)}decomposeLeft(e,t){t.push(new Zt(e-1),null)}decomposeRight(e,t){t.push(null,new Zt(this.length-e-1))}updateHeight(e,t=0,n=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new Zt(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let u=e.doc.lineAt(l).length;o.length&&o.push(null);let h=s.heights[s.index++];a==-1?a=h:Math.abs(h-a)>=Oo&&(a=-2);let f=new Bn(u,h);f.outdated=!1,o.push(f),l+=u+1}l<=r&&o.push(null,new Zt(r-l).updateHeight(e,l));let c=bn.of(o);return(a<0||Math.abs(c.height-this.height)>=Oo||Math.abs(a-this.heightMetrics(e,t).perLine)>=Oo)&&(qs=!0),Wo(this,c)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Vy extends bn{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,s){let r=n+this.left.height;return el))return c;let u=t==Pt.ByPosNoHeight?Pt.ByPosNoHeight:Pt.ByPos;return a?c.join(this.right.lineAt(l,u,n,o,l)):this.left.lineAt(l,u,n,s,r).join(c)}forEachLine(e,t,n,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,n,l,a,o);else{let c=this.lineAt(a,Pt.ByPos,n,s,r);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,l,a,o)}}replace(e,t,n){let s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of n)r.push(l);if(e>0&&ah(r,o-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?bn.of(this.break?[e,null,t]:[e,t]):(this.left=Wo(this.left,e),this.right=Wo(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,n,s):r.updateHeight(e,t,n),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,n,s):o.updateHeight(e,l,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ah(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Zt&&(n=i[e+1])instanceof Zt&&i.splice(e-1,3,new Zt(t.length+1+n.length))}const Hy=5;class dc{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Bn?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Bn(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=Hy)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Bn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Zt(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Bn)return e;let t=new Bn(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Bn)&&!this.isCovered?this.nodes.push(new Bn(0,-1)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&h.overflow!="visible"){let f=u.getBoundingClientRect();r=Math.max(r,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(c==i.parentNode?s.innerHeight:a,f.bottom)}c=h.position=="absolute"||h.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Uy(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ll{constructor(e,t,n,s){this.from=e,this.to=t,this.size=n,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new _y(t),this.stateDeco=e.facet(Cr).filter(n=>typeof n!="function"),this.heightMap=bn.empty().applyChanges(this.stateDeco,yt.empty,this.heightOracle.setDoc(e.doc),[new Wn(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=_e.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let s=n?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new so(r,o))}}return this.viewports=e.sort((n,s)=>n.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?uh:new pc(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ur(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Cr).filter(u=>typeof u!="function");let s=e.changedRanges,r=Wn.extendWithRanges(s,Wy(n,this.stateDeco,e?e.changes:Ut.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);lh(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||qs)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ad)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Rt.RTL:Rt.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,u=0;if(l.width&&l.height){let{scaleX:P,scaleY:O}=Qf(t,l);(P>.005&&Math.abs(this.scaleX-P)>.005||O>.005&&Math.abs(this.scaleY-O)>.005)&&(this.scaleX=P,this.scaleY=O,c|=8,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=td(e.scrollDOM);let p=(this.printing?Uy:qy)(t,this.paddingTop),y=p.top-this.pixelViewport.top,b=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),a){let P=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(P)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:O,charWidth:D,textHeight:F}=e.docView.measureTextSize();o=O>0&&s.refresh(r,O,D,F,x/D,P),o&&(e.docView.minWidth=0,c|=8)}y>0&&b>0?u=Math.max(y,b):y<0&&b<0&&(u=Math.min(y,b)),lh();for(let O of this.viewports){let D=O.from==this.viewport.from?P:e.docView.measureVisibleLineHeights(O);this.heightMap=(o?bn.empty().applyChanges(this.stateDeco,yt.empty,this.heightOracle,[new Wn(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new zy(O.from,D))}qs&&(c|=2)}let v=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return v&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new so(s.lineAt(o-n*1e3,Pt.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,Pt.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(ca.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=s.lineAt(c,Pt.ByPos,r,0,0),f;t.y=="center"?f=(h.top+h.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c=l+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=Rt.LTR&&!n)return[];let l=[],a=(u,h,f,d)=>{if(h-uu&&mm.from>=f.from&&m.to<=f.to&&Math.abs(m.from-u)m.fromx));if(!b){if(hv.from<=h&&v.to>=h)){let v=t.moveToLineBoundary(ae.cursor(h),!1,!0).head;v>u&&(h=v)}let m=this.gapSize(f,u,h,d),x=n||m<2e6?m:2e6;b=new Ll(u,h,m,x)}l.push(b)},c=u=>{if(u.length2e6)for(let D of e)D.from>=u.from&&D.fromu.from&&a(u.from,d,u,h),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];gt.spans(e,this.viewport.from,this.viewport.to,{span(s,r){t.push({from:s,to:r})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=t[r].from||s.to!=t[r].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ur(this.heightMap.lineAt(e,Pt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ur(this.heightMap.lineAt(this.scaler.fromDOM(e),Pt.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ur(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class so{constructor(e,t){this.from=e,this.to=t}}function Gy(i,e,t){let n=[],s=i,r=0;return gt.spans(t,i,e,{span(){},point(o,l){o>s&&(n.push({from:s,to:o}),r+=o-s),s=l}},20),s=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(n<=l)return r+n;n-=l}}function oo(i,e){let t=0;for(let{from:n,to:s}of i.ranges){if(e<=s){t+=e-n;break}t+=s-n}return t/i.total}function Yy(i,e){for(let t of i)if(e(t))return t}const uh={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class pc{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let c=t.lineAt(l,Pt.ByPos,e,0,0).top,u=t.lineAt(a,Pt.ByPos,e,0,0).bottom;return s+=u-c,{from:l,to:a,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,n=0,s=0;;t++){let r=tt.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function ur(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new ui(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>ur(s,e)):i._content)}const lo=Be.define({combine:i=>i.join(" ")}),Ba=Be.define({combine:i=>i.indexOf(!0)>-1}),Ra=ji.newName(),qd=ji.newName(),Ud=ji.newName(),Kd={"&light":"."+qd,"&dark":"."+Ud};function Na(i,e,t){return new ji(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,s=>{if(s=="&")return i;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):i+" "+n}})}const Xy=Na("."+Ra,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Kd),Jy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},$l=Ne.ie&&Ne.ie_version<=11;class Qy{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Ib,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(Ne.ie&&Ne.ie_version<=11||Ne.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(Ne.chrome&&Ne.chrome_version<126)&&(this.editContext=new ew(e),e.state.facet(Fi)&&(e.contentDOM.editContext=this.editContext.editContext)),$l&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,s=this.selectionRange;if(n.state.facet(Fi)?n.root.activeElement!=this.dom:!Mo(this.dom,s))return;let r=s.anchorNode&&n.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Ne.ie&&Ne.ie_version<=11||Ne.android&&Ne.chrome)&&!n.state.selection.main.empty&&s.focusNode&&gr(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Sr(e.root);if(!t)return!1;let n=Ne.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Zy(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=Mo(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Rs(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:s}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),s=this.selectionChanged&&Mo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new by(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,s=Nd(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=hh(t,e.previousSibling||e.target.previousSibling,-1),s=hh(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Fi)!=e.state.facet(Fi)&&(e.view.contentDOM.editContext=e.state.facet(Fi)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function hh(i,e,t){for(;e;){let n=At.get(e);if(n&&n.parent==i)return n;let s=e.parentNode;e=s!=i.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function fh(i,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return gr(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function Zy(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return fh(i,s)}let t=null;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?fh(i,t):null}class ew{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let{anchor:s}=e.state.selection.main,r={from:this.toEditorPos(n.updateRangeStart),to:this.toEditorPos(n.updateRangeEnd),insert:yt.of(n.text.split(` `))};r.from==this.from&&sthis.to&&(r.to=s),!(r.from==r.to&&!r.insert.length)&&(this.pendingContextChange=r,e.state.readOnly||fc(e,r,ae.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o{let s=[];for(let r of n.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(o!="None"&&l!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;s.push(_e.mark({attributes:{style:a}}).range(this.toEditorPos(r.rangeStart),this.toEditorPos(r.rangeEnd)))}}e.dispatch({effects:Md.of(_e.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=Sr(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,c)=>{if(n)return;let u=c.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(c)){s=this.pendingContextChange=null,t+=u,this.to+=u;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(rthis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=u}t+=u}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Fe{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(r=>n(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Lb(e.parent)||document,this.viewState=new ch(e.state||ht.create(e)),e.scrollTo&&e.scrollTo.is(to)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(lr).map(s=>new Rl(s));for(let s of this.plugins)s.update(this);this.observer=new Qy(this),this.inputState=new xy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ju(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Kt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,r=this.state;for(let f of e){if(f.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=f.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Vd))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Hd(r,o),a||(l=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(u=null)):this.observer.clear(),r.facet(ht.phrases)!=this.state.facet(ht.phrases))return this.setState(r);s=Ho.create(this,r,e),s.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;h=new Ns(d.empty?d:ae.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(to)&&(h=d.value.clip(this.state))}this.viewState.update(s,h),this.bidiCache=jo.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(ar)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(lo)!=s.state.facet(lo)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(Oa))try{f(s)}catch(d){Cn(this.state,d,"update listener")}(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!Nd(this,u)&&c.force&&Rs(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new ch(e),this.plugins=e.facet(lr).map(n=>new Rl(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new ju(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(lr),n=e.state.facet(lr);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new Rl(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,s=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(td(n))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null||l>5)break;let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Cn(this.state,p),dh}}),h=Ho.create(this,this.state,[]),f=!1;h.flags|=a,t?t.flags|=a:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let d=0;d1||p<-1){s=s+p,n.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Oa))l(t)}get themeClasses(){return Ra+" "+(this.state.facet(Ba)?Ud:qd)+" "+this.state.facet(lo)}updateAttrs(){let e=ph(this,Dd,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Fi)?"true":"false",class:"cm-content",style:`${Ne.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),ph(this,uc,t);let n=this.observer.ignore(()=>{let s=Sa(this.contentDOM,this.contentAttrs,t),r=Sa(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(Fe.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(ar);let e=this.state.facet(Fe.cspNonce);ji.mount(this.root,this.styleModules.concat(Xy).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tn.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Il(this,e,Yu(this,e,t,n))}moveByGroup(e,t){return Il(this,e,Yu(this,e,t,n=>dy(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return ae.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return fy(this,e,t,n)}moveVertically(e,t,n){return Il(this,e,py(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Rd(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[Ii.find(r,e-s.from,-1,t)];return Vr(n,o.dir==Rt.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Cd)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>tw)return gd(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||md(r.isolates,n=Wu(this,e))))return r.order;n||(n=Wu(this,e));let s=Xb(e.text,t,n);return this.bidiCache.push(new jo(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ne.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Zf(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return to.of(new Ns(typeof e=="number"?ae.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return to.of(new Ns(ae.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Vt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Vt.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=ji.newName(),s=[lo.of(n),ar.of(Na(`.${n}`,e))];return t&&t.dark&&s.push(Ba.of(!0)),s}static baseTheme(e){return vs.lowest(ar.of(Na("."+Ra,e,Kd)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&At.get(n)||At.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}Fe.styleModule=ar;Fe.inputHandler=xd;Fe.clipboardInputFilter=ac;Fe.clipboardOutputFilter=cc;Fe.scrollHandler=Td;Fe.focusChangeEffect=Sd;Fe.perLineTextDirection=Cd;Fe.exceptionSink=kd;Fe.updateListener=Oa;Fe.editable=Fi;Fe.mouseSelectionStyle=vd;Fe.dragMovesSelection=wd;Fe.clickAddsSelectionRange=yd;Fe.decorations=Cr;Fe.outerDecorations=Od;Fe.atomicRanges=hc;Fe.bidiIsolatedRanges=Ed;Fe.scrollMargins=Fd;Fe.darkTheme=Ba;Fe.cspNonce=Be.define({combine:i=>i.length?i[0]:""});Fe.contentAttributes=uc;Fe.editorAttributes=Dd;Fe.lineWrapping=Fe.contentAttributes.of({class:"cm-lineWrapping"});Fe.announce=et.define();const tw=4096,dh={};class jo{constructor(e,t,n,s,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:Rt.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=n[s],o=typeof r=="function"?r(i):r;o&&xa(o,t)}return t}const nw=Ne.mac?"mac":Ne.windows?"win":Ne.linux?"linux":"key";function iw(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,r,o,l;for(let a=0;an.concat(s),[]))),t}function rw(i,e,t){return Yd(Gd(i.state),e,i,t)}let Pi=null;const ow=4e3;function lw(i,e=nw){let t=Object.create(null),n=Object.create(null),s=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,c,u)=>{var h,f;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(m=>iw(m,e));for(let m=1;m{let P=Pi={view:v,prefix:x,scope:o};return setTimeout(()=>{Pi==P&&(Pi=null)},ow),!0}]})}let y=p.join(" ");s(y,!1);let b=d[y]||(d[y]={preventDefault:!1,stopPropagation:!1,run:((f=(h=d._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});a&&b.run.push(a),c&&(b.preventDefault=!0),u&&(b.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let f in u)u[f].run.push(d=>h(d,Ia))}let a=o[e]||o.key;if(a)for(let c of l)r(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Ia=null;function Yd(i,e,t,n){Ia=e;let s=Pb(e),r=en(s,0),o=$n(r)==s.length&&s!=" ",l="",a=!1,c=!1,u=!1;Pi&&Pi.view==t&&Pi.scope==n&&(l=Pi.prefix+" ",Ld.indexOf(e.keyCode)<0&&(c=!0,Pi=null));let h=new Set,f=b=>{if(b){for(let m of b.run)if(!h.has(m)&&(h.add(m),m(t)))return b.stopPropagation&&(u=!0),!0;b.preventDefault&&(b.stopPropagation&&(u=!0),c=!0)}return!1},d=i[n],p,y;return d&&(f(d[l+ao(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ne.windows&&e.ctrlKey&&e.altKey)&&(p=qi[e.keyCode])&&p!=s?(f(d[l+ao(p,e,!0)])||e.shiftKey&&(y=xr[e.keyCode])!=s&&y!=p&&f(d[l+ao(y,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+ao(s,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),Ia=null,a}class jr{constructor(e,t,n,s,r){this.className=e,this.left=t,this.top=n,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let r=Xd(e);return[new jr(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return aw(e,t,n)}}function Xd(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Rt.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function gh(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let r=i.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=i.posAtCoords({x:r.left+1,y:o}),a=i.posAtCoords({x:r.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function aw(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),r=i.textDirection==Rt.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Xd(i),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=l.right-(u?parseInt(u.paddingRight):0),d=Fa(i,n),p=Fa(i,s),y=d.type==gn.Text?d:null,b=p.type==gn.Text?p:null;if(y&&(i.lineWrapping||d.widgetLineBreaks)&&(y=gh(i,n,1,y)),b&&(i.lineWrapping||p.widgetLineBreaks)&&(b=gh(i,s,-1,b)),y&&b&&y.from==b.from&&y.to==b.to)return x(v(t.from,t.to,y));{let O=y?v(t.from,null,y):P(d,!1),D=b?v(null,t.to,b):P(p,!0),F=[];return(y||d).to<(b||p).from-(y&&b?1:0)||d.widgetLineBreaks>1&&O.bottom+i.defaultLineHeight/2Q&&L.from=R)break;ue>se&&V(Math.max(ne,se),O==null&&ne<=Q,Math.min(ue,R),D==null&&ue>=ce,$.dir)}if(se=ee.to+1,se>=R)break}return W.length==0&&V(Q,O==null,ce,D==null,i.textDirection),{top:T,bottom:M,horizontal:W}}function P(O,D){let F=l.top+(D?O.top:O.bottom);return{top:F,bottom:F,horizontal:[]}}}function cw(i,e){return i.constructor==e.constructor&&i.eq(e)}class uw{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Eo)!=e.state.facet(Eo)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Eo);for(;t!cw(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Eo=Be.define();function Jd(i){return[Vt.define(e=>new uw(e,i)),Eo.of(i)]}const Qd=!Ne.ios,Ar=Be.define({combine(i){return mi(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function hw(i={}){return[Ar.of(i),fw,dw,pw,Ad.of(!0)]}function Zd(i){return i.startState.facet(Ar)!=i.state.facet(Ar)}const fw=Jd({above:!0,markers(i){let{state:e}=i,t=e.facet(Ar),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty?!r||Qd:t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:ae.cursor(s.head,s.head>s.anchor?-1:1);for(let a of jr.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Zd(i);return t&&bh(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){bh(e.state,i)},class:"cm-cursorLayer"});function bh(i,e){e.style.animationDuration=i.facet(Ar).cursorBlinkRate+"ms"}const dw=Jd({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:jr.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Zd(i)},class:"cm-selectionLayer"}),La={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Qd&&(La[".cm-line"].caretColor=La[".cm-content"].caretColor="transparent !important");const pw=vs.highest(Fe.theme(La)),ep=et.define({map(i,e){return i==null?null:e.mapPos(i)}}),hr=rn.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(ep)?n.value:t,i)}}),mw=Vt.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(hr);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(hr)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(hr),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(hr)!=i&&this.view.dispatch({effects:ep.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function gw(){return[hr,mw]}function yh(i,e,t,n,s){e.lastIndex=0;for(let r=i.iterRange(t,n),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function bw(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:r}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),r=Math.min(i.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}class yw{constructor(e){const{regexp:t,decoration:n,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,c,u)=>s(u,c,c+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,c,u)=>{let h=n(l,a,c);h&&u(c,c+l[0].length,h)};else if(n)this.addMatch=(l,a,c,u)=>u(c,c+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Wi,n=t.add.bind(t);for(let{from:s,to:r}of bw(e,this.maxLength))yh(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>e.view.viewport.from&&l1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let r of e.visibleRanges){let o=Math.max(r.from,n),l=Math.min(r.to,s);if(l>o){let a=e.state.doc.lineAt(o),c=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){u=o;break}for(;lf.push(m.range(y,b));if(a==c)for(this.regexp.lastIndex=u-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(b,e,y,p));t=t.update({filterFrom:u,filterTo:h,filter:(y,b)=>yh,add:f})}}return t}}const $a=/x/.unicode!=null?"gu":"g",ww=new RegExp(`[\0-\b --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,$a),vw={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _l=null;function kw(){var i;if(_l==null&&typeof document!="undefined"&&document.body){let e=document.body.style;_l=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return _l||!1}const Fo=Be.define({combine(i){let e=mi(i,{render:null,specialChars:ww,addSpecialChars:null});return(e.replaceTabs=!kw())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,$a)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,$a)),e}});function xw(i={}){return[Fo.of(i),Sw()]}let wh=null;function Sw(){return wh||(wh=Vt.fromClass(class{constructor(i){this.view=i,this.decorations=_e.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(Fo)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new yw({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=en(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=Qs(o.text,l,n-o.from);return _e.replace({widget:new Mw((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=_e.replace({widget:new Tw(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(Fo);i.startState.facet(Fo)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const Cw="•";function Aw(i){return i>=32?Cw:i==10?"␤":String.fromCharCode(9216+i)}class Tw extends Ci{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Aw(this.code),n=e.state.phrase("Control character")+" "+(vw[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Mw extends Ci{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function Dw(){return Ew}const Ow=_e.line({class:"cm-activeLine"}),Ew=Vt.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(Ow.range(s.from)),e=s.from)}return _e.set(t)}},{decorations:i=>i.decorations});class Fw extends Ci{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),typeof this.content=="string"?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Hs(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=Vr(t[0],n.direction!="rtl"),r=parseInt(n.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function Pw(i){return Vt.fromClass(class{constructor(e){this.view=e,this.placeholder=i?_e.set([_e.widget({widget:new Fw(i),side:1}).range(0)]):_e.none}get decorations(){return this.view.state.doc.length?_e.none:this.placeholder}},{decorations:e=>e.decorations})}const _a=2e3;function Bw(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>_a||t.off>_a||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=s;a++){let c=i.doc.line(a);c.length<=l&&r.push(ae.range(c.from+o,c.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=s;a++){let c=i.doc.line(a),u=ma(c.text,o,i.tabSize,!0);if(u<0)r.push(ae.cursor(c.to));else{let h=ma(c.text,l,i.tabSize);r.push(ae.range(c.from+u,c.from+h))}}}return r}function Rw(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function vh(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,r=s>_a?-1:s==n.length?Rw(i,e.clientX):Qs(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function Nw(i,e){let t=vh(i,e),n=i.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(s.changes)}},get(s,r,o){let l=vh(i,s);if(!l)return n;let a=Bw(i.state,t,l);return a.length?o?ae.create(a.concat(n.ranges)):ae.create(a):n}}:null}function Iw(i){let e=t=>t.altKey&&t.button==0;return Fe.mouseSelectionStyle.of((t,n)=>e(n)?Nw(t,n):null)}const Lw={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},$w={style:"cursor: crosshair"};function _w(i={}){let[e,t]=Lw[i.key||"Alt"],n=Vt.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[n,Fe.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?$w:null})]}const ir="-10000px";class tp{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=n(o,r))}update(e,t){var n;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;at[c]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function zw(i){let{win:e}=i;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const zl=Be.define({combine:i=>{var e,t,n;return{position:Ne.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||zw}}}),kh=new WeakMap,mc=Vt.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(zl);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new tp(i,gc,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(zl);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=ir,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=this.view.dom.getBoundingClientRect(),e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Ne.gecko)n=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==ir&&s.style.left=="0px"){let r=s.getBoundingClientRect();n=Math.abs(r.top+1e4)>1||Math.abs(r.left)>1}}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:i,parent:this.parent?this.container.getBoundingClientRect():i,pos:this.manager.tooltips.map((s,r)=>{let o=this.manager.tooltipViews[r];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(zl).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:n,scaleX:s,scaleY:r}=i,o=[];for(let l=0;l=Math.min(t.bottom,n.bottom)||h.rightMath.min(t.right,n.right)+.1){u.style.top=ir;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,y=f.right-f.left,b=(e=kh.get(c))!==null&&e!==void 0?e:f.bottom-f.top,m=c.offset||Hw,x=this.view.textDirection==Rt.LTR,v=f.width>n.right-n.left?x?n.left:n.right-f.width:x?Math.max(n.left,Math.min(h.left-(d?14:0)+m.x,n.right-y)):Math.min(Math.max(n.left,h.left-y+(d?14:0)-m.x),n.right-y),P=this.above[l];!a.strictSide&&(P?h.top-(f.bottom-f.top)-m.yn.bottom)&&P==n.bottom-h.bottom>h.top-n.top&&(P=this.above[l]=!P);let O=(P?h.top-n.top:n.bottom-h.bottom)-p;if(Ov&&T.topD&&(D=P?T.top-b-2-p:T.bottom+p+2);if(this.position=="absolute"?(u.style.top=(D-i.parent.top)/r+"px",u.style.left=(v-i.parent.left)/s+"px"):(u.style.top=D/r+"px",u.style.left=v/s+"px"),d){let T=h.left+(x?m.x:-m.x)-(v+14-7);d.style.left=T/s+"px"}c.overlap!==!0&&o.push({left:v,top:D,right:F,bottom:D+b}),u.classList.toggle("cm-tooltip-above",P),u.classList.toggle("cm-tooltip-below",!P),c.positioned&&c.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=ir}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Vw=Fe.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Hw={x:0,y:0},gc=Be.define({enables:[mc,Vw]}),qo=Be.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class gl{static create(e){return new gl(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new tp(e,qo,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Ww=gc.compute([qo],i=>{let e=i.facet(qo);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:gl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class jw{constructor(e,t,n,s,r){this.view=e,this.source=t,this.field=n,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;el.bottom||t.xl.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(u=>u.from<=s&&u.to>=s),c=a&&a.dir==Rt.RTL?-1:1;r=t.x{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>Cn(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(mc),t=e?e.manager.tooltips.findIndex(n=>n.create==gl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&r&&!qw(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Uw(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const co=4;function qw(i,e){let{left:t,right:n,top:s,bottom:r}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-co&&e.clientX<=n+co&&e.clientY>=s-co&&e.clientY<=r+co}function Uw(i,e,t,n,s,r){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.rights||Math.min(o.bottom,l)=e&&a<=t}function Kw(i,e={}){let t=et.define(),n=rn.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,mn.TrackDel);if(a!=null){let c=Object.assign(Object.create(null),l);c.pos=a,c.end!=null&&(c.end=r.changes.mapPos(c.end)),o.push(c)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(Gw)&&(s=[]);return s},provide:s=>qo.from(s)});return{active:n,extension:[n,Vt.define(s=>new jw(s,i,n,t,e.hoverTime||300)),Ww]}}function np(i,e){let t=i.plugin(mc);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const Gw=et.define(),xh=Be.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Tr(i,e){let t=i.plugin(ip),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const ip=Vt.fromClass(class{constructor(i){this.input=i.state.facet(Mr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(xh);this.top=new uo(i,!0,e.topContainer),this.bottom=new uo(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(xh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new uo(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new uo(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Mr);if(t!=this.input){let n=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of n){let c=this.specs.indexOf(a),u;c<0?(u=a(i.view),l.push(u)):(u=this.panels[c],u.update&&u.update(i)),s.push(u),(u.top?r:o).push(u)}this.specs=n,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>Fe.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class uo{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Sh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Sh(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Sh(i){let e=i.nextSibling;return i.remove(),e}const Mr=Be.define({enables:ip});class xi extends ds{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}xi.prototype.elementClass="";xi.prototype.toDOM=void 0;xi.prototype.mapMode=mn.TrackBefore;xi.prototype.startSide=xi.prototype.endSide=-1;xi.prototype.point=!0;const Po=Be.define(),Yw=Be.define(),Xw={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>gt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},yr=Be.define();function Jw(i){return[sp(),yr.of(Object.assign(Object.assign({},Xw),i))]}const Ch=Be.define({combine:i=>i.some(e=>e)});function sp(i){return[Qw]}const Qw=Vt.fromClass(class{constructor(i){this.view=i,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(yr).map(e=>new Th(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(Ch),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}i.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Ch)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&this.dom.remove();let t=gt.iter(this.view.state.facet(Po),this.view.viewport.from),n=[],s=this.gutters.map(r=>new Zw(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==gn.Text&&o){za(t,n,l.from);for(let a of s)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==gn.Text){za(t,n,r.from);for(let o of s)o.line(this.view,r,n)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();i&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(i){let e=i.startState.facet(yr),t=i.state.facet(yr),n=i.docChanged||i.heightChanged||i.viewportChanged||!gt.eq(i.startState.facet(Po),i.state.facet(Po),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Th(this.view,r)):(this.gutters[o].update(i),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove()}},{provide:i=>Fe.scrollMargins.of(e=>{let t=e.plugin(i);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==Rt.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Ah(i){return Array.isArray(i)?i:[i]}function za(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class Zw{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=gt.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new rp(e,o,r,n);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];za(this.cursor,s,t.from),n.length&&(s=s.concat(n));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let r of e.state.facet(Yw)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Th{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,l,s)&&s.preventDefault()});this.markers=Ah(t.markers(e)),t.initialSpacer&&(this.spacer=new rp(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Ah(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!gt.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class rp{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),ev(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=rr(l,a,c)||o(l,a,c):o}return n}})}});class Vl extends xi{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Hl(i,e){return i.state.facet(Os).formatNumber(e,i.state)}const iv=yr.compute([Os],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(tv)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new Vl(Hl(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(nv)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Os)!=e.state.facet(Os),initialSpacer(e){return new Vl(Hl(e,Mh(e.state.doc.lines)))},updateSpacer(e,t){let n=Hl(t.view,Mh(t.view.state.doc.lines));return n==e.number?e:new Vl(n)},domEventHandlers:i.facet(Os).domEventHandlers}));function sv(i={}){return[Os.of(i),sp(),iv]}function Mh(i){let e=9;for(;e{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push(rv.range(s)))}return gt.of(e)});function lv(){return ov}const op=1024;let av=0;class Wl{constructor(e,t){this.from=e,this.to=t}}class ot{constructor(e={}){this.id=av++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=yn.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}ot.closedBy=new ot({deserialize:i=>i.split(" ")});ot.openedBy=new ot({deserialize:i=>i.split(" ")});ot.group=new ot({deserialize:i=>i.split(" ")});ot.isolate=new ot({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});ot.contextHash=new ot({perNode:!0});ot.lookAhead=new ot({perNode:!0});ot.mounted=new ot({perNode:!0});class Uo{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[ot.mounted.id]}}const cv=Object.create(null);class yn{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):cv,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new yn(e.name||"",t,e.id,n);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(ot.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return n=>{for(let s=n.prop(ot.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?n.name:s[r]];if(o)return o}}}}yn.none=new yn("",Object.create(null),0,8);class bl{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|Xt.IncludeAnonymous);;){let c=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:wc(yn.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Tt(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Tt(yn.none,t,n,s)))}static build(e){return dv(e)}}Tt.empty=new Tt(yn.none,[],[],0);class bc{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new bc(this.buffer,this.index)}}class Ki{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return yn.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,n){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Dr(i,e,t,n){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?l.length:-1;e!=c;e+=t){let u=l[e],h=a[e]+o.from;if(lp(s,n,h,h+u.length)){if(u instanceof Ki){if(r&Xt.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-h,s);if(f>-1)return new Li(new uv(o,u,e,h),null,f)}else if(r&Xt.IncludeAnonymous||!u.type.isAnonymous||yc(u)){let f;if(!(r&Xt.IgnoreMounts)&&(f=Uo.get(u))&&!f.overlay)return new jn(f.tree,h,e,o);let d=new jn(u,h,e,o);return r&Xt.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?u.children.length-1:0,t,n,s)}}}if(r&Xt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let s;if(!(n&Xt.IgnoreOverlays)&&(s=Uo.get(this._tree))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o=r:l>r))return new jn(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Oh(i,e,t,n){let s=i.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(n!=null&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return n==null?r:[]}}function Va(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class uv{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class Li extends ap{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new Li(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&Xt.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Li(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Li(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Li(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,r=n.buffer[this.index+3];if(r>s){let o=n.buffer[this.index+1];e.push(n.slice(s,r,o)),t.push(0)}return new Tt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function cp(i){if(!i.length)return null;let e=0,t=i[0];for(let r=1;rt.from||o.to=e){let l=new jn(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(Dr(l,e,t,!1))}}return s?cp(s):n}class Ha{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof jn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof jn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Xt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Xt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Xt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:n._tree.children.length;r!=o;r+=e){let l=n._tree.children[r];if(this.mode&Xt.IncludeAnonymous||l instanceof Ki||!l.type.isAnonymous||yc(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,n=r+1;break e}s=this.stack[--r]}for(let s=n;s=0;r--){if(r<0)return Va(this._tree,e,s);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function yc(i){return i.children.some(e=>e instanceof Ki||!e.type.isAnonymous||yc(e))}function dv(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=op,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new bc(t,t.length):t,a=n.types,c=0,u=0;function h(O,D,F,T,M,W){let{id:V,start:Q,end:ce,size:L}=l,se=u,R=c;for(;L<0;)if(l.next(),L==-1){let z=r[V];F.push(z),T.push(Q-O);return}else if(L==-3){c=V;return}else if(L==-4){u=V;return}else throw new RangeError(`Unrecognized record size: ${L}`);let ee=a[V],$,ne,ue=Q-O;if(ce-Q<=s&&(ne=b(l.pos-D,M))){let z=new Uint16Array(ne.size-ne.skip),G=l.pos-ne.size,be=z.length;for(;l.pos>G;)be=m(ne.start,z,be);$=new Ki(z,ce-ne.start,n),ue=ne.start-O}else{let z=l.pos-L;l.next();let G=[],be=[],we=V>=o?V:-1,Ie=0,ve=ce;for(;l.pos>z;)we>=0&&l.id==we&&l.size>=0?(l.end<=ve-s&&(p(G,be,Q,Ie,l.end,ve,we,se,R),Ie=G.length,ve=l.end),l.next()):W>2500?f(Q,z,G,be):h(Q,z,G,be,we,W+1);if(we>=0&&Ie>0&&Ie-1&&Ie>0){let je=d(ee,R);$=wc(ee,G,be,0,G.length,0,ce-Q,je,je)}else $=y(ee,G,be,ce-Q,se-ce,R)}F.push($),T.push(ue)}function f(O,D,F,T){let M=[],W=0,V=-1;for(;l.pos>D;){let{id:Q,start:ce,end:L,size:se}=l;if(se>4)l.next();else{if(V>-1&&ce=0;L-=3)Q[se++]=M[L],Q[se++]=M[L+1]-ce,Q[se++]=M[L+2]-ce,Q[se++]=se;F.push(new Ki(Q,M[2]-ce,n)),T.push(ce-O)}}function d(O,D){return(F,T,M)=>{let W=0,V=F.length-1,Q,ce;if(V>=0&&(Q=F[V])instanceof Tt){if(!V&&Q.type==O&&Q.length==M)return Q;(ce=Q.prop(ot.lookAhead))&&(W=T[V]+Q.length+ce)}return y(O,F,T,M,W,D)}}function p(O,D,F,T,M,W,V,Q,ce){let L=[],se=[];for(;O.length>T;)L.push(O.pop()),se.push(D.pop()+F-M);O.push(y(n.types[V],L,se,W-M,Q-W,ce)),D.push(M-F)}function y(O,D,F,T,M,W,V){if(W){let Q=[ot.contextHash,W];V=V?[Q].concat(V):[Q]}if(M>25){let Q=[ot.lookAhead,M];V=V?[Q].concat(V):[Q]}return new Tt(O,D,F,T,V)}function b(O,D){let F=l.fork(),T=0,M=0,W=0,V=F.end-s,Q={size:0,start:0,skip:0};e:for(let ce=F.pos-O;F.pos>ce;){let L=F.size;if(F.id==D&&L>=0){Q.size=T,Q.start=M,Q.skip=W,W+=4,T+=4,F.next();continue}let se=F.pos-L;if(L<0||se=o?4:0,ee=F.start;for(F.next();F.pos>se;){if(F.size<0)if(F.size==-3)R+=4;else break e;else F.id>=o&&(R+=4);F.next()}M=ee,T+=L,W+=R}return(D<0||T==O)&&(Q.size=T,Q.start=M,Q.skip=W),Q.size>4?Q:void 0}function m(O,D,F){let{id:T,start:M,end:W,size:V}=l;if(l.next(),V>=0&&T4){let ce=l.pos-(V-4);for(;l.pos>ce;)F=m(O,D,F)}D[--F]=Q,D[--F]=W-O,D[--F]=M-O,D[--F]=T}else V==-3?c=T:V==-4&&(u=T);return F}let x=[],v=[];for(;l.pos>0;)h(i.start||0,i.bufferStart||0,x,v,-1,0);let P=(e=i.length)!==null&&e!==void 0?e:x.length?v[0]+x[0].length:0;return new Tt(a[i.topID],x.reverse(),v.reverse(),P)}const Eh=new WeakMap;function Bo(i,e){if(!i.isAnonymous||e instanceof Ki||e.type!=i)return 1;let t=Eh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Tt)){t=1;break}t+=Bo(i,n)}Eh.set(e,t)}return t}function wc(i,e,t,n,s,r,o,l,a){let c=0;for(let p=n;p=u)break;D+=F}if(v==P+1){if(D>u){let F=p[P];d(F.children,F.positions,0,F.children.length,y[P]+x);continue}h.push(p[P])}else{let F=y[v-1]+p[v-1].length-O;h.push(wc(i,p,y,P,v,O,F,null,a))}f.push(O+x-r)}}return d(e,t,n,s,0),(l||a)(h,f,o)}class us{constructor(e,t,n,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let s=[new us(0,e.length,e,0,!1,n)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let u=l=n)for(;o&&o.from=f.from||h<=f.to||c){let d=Math.max(f.from,a)-c,p=Math.min(f.to,h)-c;f=d>=p?null:new us(d,p,f.tree,f.offset+c,l>0,!!u)}if(f&&s.push(f),o.to>h)break;o=rnew Wl(s.from,s.to)):[new Wl(0,0)]:[new Wl(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let r=s.advance();if(r)return r}}}class pv{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new ot({perNode:!0});let mv=0;class Ln{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=mv++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof Ln&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new Ln(n,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new Ko(e);return n=>n.modified.indexOf(t)>-1?n:Ko.get(n.base||n,n.modified.concat(t).sort((s,r)=>s.id-r.id))}}let gv=0;class Ko{constructor(e){this.name=e,this.instances=[],this.id=gv++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&bv(t,l.modified));if(n)return n;let s=[],r=new Ln(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=yv(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(Ko.get(l,a));return r}}function bv(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function yv(i){let e=[[]];for(let t=0;tn.length-t.length)}function up(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let h=0;;){if(l=="..."&&h>0&&h+3==s.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+s);if(r.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==s.length)break;let d=s[h++];if(h==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(h)}let a=r.length-1,c=r[a];if(!c)throw new RangeError("Invalid path: "+s);let u=new Go(n,o,a>0?r.slice(0,a):null);e[c]=u.sort(e[c])}}return hp.add(e)}const hp=new ot;class Go{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let l of r)for(let a of l.set){let c=t[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function wv(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function vv(i,e,t,n=0,s=i.length){let r=new kv(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}class kv{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,s,r){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=s,u=xv(e)||Go.empty,h=wv(r,u.tags);if(h&&(c&&(c+=" "),c+=h,u.mode==1&&(s+=(s?" ":"")+h)),this.startSpan(Math.max(t,l),c),u.opaque)return;let f=e.tree&&e.tree.prop(ot.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(b=>!b.scope||b.scope(f.tree.type)),y=e.firstChild();for(let b=0,m=l;;b++){let x=b=v||!e.nextSibling())););if(!x||v>n)break;m=x.to+l,m>t&&(this.highlightRange(d.cursor(),Math.max(t,x.from+l),Math.min(n,m),"",p),this.startSpan(Math.min(n,m),c))}y&&e.parent()}else if(e.firstChild()){f&&(s="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,s,r),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}}function xv(i){let e=i.type.prop(hp);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const Te=Ln.define,fo=Te(),Oi=Te(),Fh=Te(Oi),Ph=Te(Oi),Ei=Te(),po=Te(Ei),jl=Te(Ei),ai=Te(),Zi=Te(ai),oi=Te(),li=Te(),Wa=Te(),sr=Te(Wa),mo=Te(),X={comment:fo,lineComment:Te(fo),blockComment:Te(fo),docComment:Te(fo),name:Oi,variableName:Te(Oi),typeName:Fh,tagName:Te(Fh),propertyName:Ph,attributeName:Te(Ph),className:Te(Oi),labelName:Te(Oi),namespace:Te(Oi),macroName:Te(Oi),literal:Ei,string:po,docString:Te(po),character:Te(po),attributeValue:Te(po),number:jl,integer:Te(jl),float:Te(jl),bool:Te(Ei),regexp:Te(Ei),escape:Te(Ei),color:Te(Ei),url:Te(Ei),keyword:oi,self:Te(oi),null:Te(oi),atom:Te(oi),unit:Te(oi),modifier:Te(oi),operatorKeyword:Te(oi),controlKeyword:Te(oi),definitionKeyword:Te(oi),moduleKeyword:Te(oi),operator:li,derefOperator:Te(li),arithmeticOperator:Te(li),logicOperator:Te(li),bitwiseOperator:Te(li),compareOperator:Te(li),updateOperator:Te(li),definitionOperator:Te(li),typeOperator:Te(li),controlOperator:Te(li),punctuation:Wa,separator:Te(Wa),bracket:sr,angleBracket:Te(sr),squareBracket:Te(sr),paren:Te(sr),brace:Te(sr),content:ai,heading:Zi,heading1:Te(Zi),heading2:Te(Zi),heading3:Te(Zi),heading4:Te(Zi),heading5:Te(Zi),heading6:Te(Zi),contentSeparator:Te(ai),list:Te(ai),quote:Te(ai),emphasis:Te(ai),strong:Te(ai),link:Te(ai),monospace:Te(ai),strikethrough:Te(ai),inserted:Te(),deleted:Te(),changed:Te(),invalid:Te(),meta:mo,documentMeta:Te(mo),annotation:Te(mo),processingInstruction:Te(mo),definition:Ln.defineModifier("definition"),constant:Ln.defineModifier("constant"),function:Ln.defineModifier("function"),standard:Ln.defineModifier("standard"),local:Ln.defineModifier("local"),special:Ln.defineModifier("special")};for(let i in X){let e=X[i];e instanceof Ln&&(e.name=i)}fp([{tag:X.link,class:"tok-link"},{tag:X.heading,class:"tok-heading"},{tag:X.emphasis,class:"tok-emphasis"},{tag:X.strong,class:"tok-strong"},{tag:X.keyword,class:"tok-keyword"},{tag:X.atom,class:"tok-atom"},{tag:X.bool,class:"tok-bool"},{tag:X.url,class:"tok-url"},{tag:X.labelName,class:"tok-labelName"},{tag:X.inserted,class:"tok-inserted"},{tag:X.deleted,class:"tok-deleted"},{tag:X.literal,class:"tok-literal"},{tag:X.string,class:"tok-string"},{tag:X.number,class:"tok-number"},{tag:[X.regexp,X.escape,X.special(X.string)],class:"tok-string2"},{tag:X.variableName,class:"tok-variableName"},{tag:X.local(X.variableName),class:"tok-variableName tok-local"},{tag:X.definition(X.variableName),class:"tok-variableName tok-definition"},{tag:X.special(X.variableName),class:"tok-variableName2"},{tag:X.definition(X.propertyName),class:"tok-propertyName tok-definition"},{tag:X.typeName,class:"tok-typeName"},{tag:X.namespace,class:"tok-namespace"},{tag:X.className,class:"tok-className"},{tag:X.macroName,class:"tok-macroName"},{tag:X.propertyName,class:"tok-propertyName"},{tag:X.operator,class:"tok-operator"},{tag:X.comment,class:"tok-comment"},{tag:X.meta,class:"tok-meta"},{tag:X.invalid,class:"tok-invalid"},{tag:X.punctuation,class:"tok-punctuation"}]);var ql;const os=new ot;function dp(i){return Be.define({combine:i?e=>e.concat(i):void 0})}const Sv=new ot;class _n{constructor(e,t,n=[],s=""){this.data=e,this.name=s,ht.prototype.hasOwnProperty("tree")||Object.defineProperty(ht.prototype,"tree",{get(){return sn(this)}}),this.parser=t,this.extension=[Gi.of(this),ht.languageData.of((r,o,l)=>{let a=Bh(r,o,l),c=a.type.prop(os);if(!c)return[];let u=r.facet(c),h=a.type.prop(Sv);if(h){let f=a.resolve(o-a.from,l);for(let d of h)if(d.test(f,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Bh(e,t,n).type.prop(os)==this.data}findRegions(e){let t=e.facet(Gi);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(os)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(ot.mounted);if(l){if(l.tree.prop(os)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;an.isTop?t:void 0)]}),e.name)}configure(e,t){return new Yo(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function sn(i){let e=i.field(_n.state,!1);return e?e.tree:Tt.empty}class Cv{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let rr=null;class Us{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Us(e,t,[],Tt.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Cv(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Tt.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(us.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=rr;rr=this;try{return e()}finally{rr=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Rh(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,u,h,f)=>a.push({fromA:c,toA:u,fromB:h,toB:f})),n=us.applyChanges(n,a),s=Tt.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),h=e.mapPos(c.to,-1);ue.from&&(this.fragments=Rh(this.fragments,s,r),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends vc{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=rr;if(a){for(let c of s)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Tt(yn.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return rr}}function Rh(i,e,t){return us.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Ks{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Ks(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Us.create(e.facet(Gi).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Ks(n)}}_n.state=rn.define({create:Ks.init,update(i,e){for(let t of e.effects)if(t.is(_n.setState))return t.value;return e.startState.facet(Gi)!=e.state.facet(Gi)?Ks.init(e.state):i.apply(e)}});let pp=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(pp=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Ul=typeof navigator!="undefined"&&(!((ql=navigator.scheduling)===null||ql===void 0)&&ql.isInputPending)?()=>navigator.scheduling.isInputPending():null,Av=Vt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(_n.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(_n.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=pp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,a=r.context.work(()=>Ul&&Ul()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:_n.setState.of(new Ks(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Cn(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Gi=Be.define({combine(i){return i.length?i[0]:null},enables:i=>[_n.state,Av,Fe.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class Tv{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const mp=Be.define(),yl=Be.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function bs(i){let e=i.facet(yl);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Or(i,e){let t="",n=i.tabSize,s=i.facet(yl)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r=e?Mv(i,t,e):null}class wl{constructor(e,t={}){this.state=e,this.options=t,this.unit=bs(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=n.from&&s<=n.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return Qs(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gp=new ot;function Mv(i,e,t){let n=e.resolveStack(t),s=n.node.enterUnfinishedNodesBefore(t);if(s!=n.node){let r=[];for(let o=s;o!=n.node;o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)n={node:r[o],next:n}}return bp(n,i,t)}function bp(i,e,t){for(let n=i;n;n=n.next){let s=Ov(n.node);if(s)return s(xc.create(e,t,n))}return 0}function Dv(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Ov(i){let e=i.type.prop(gp);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(ot.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>Bv(o,!0,1,void 0,r&&!Dv(o)?s.from:void 0)}return i.parent==null?Ev:null}function Ev(){return 0}class xc extends wl{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new xc(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Fv(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return bp(this.context.next,this.base,this.pos)}}function Fv(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Pv(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,r=i.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function Bv(i,e,t,n,s){let r=i.textAfter,o=r.match(/^\s*/)[0].length,l=s==i.pos+o,a=Pv(i);return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}function Nh({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const Rv=200;function Nv(){return ht.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,s=t.lineAt(n);if(n>s.from+Rv)return i;let r=t.sliceString(s.from,n);if(!e.some(c=>c.test(r)))return i;let{state:o}=i,l=-1,a=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==l)continue;l=u.from;let h=kc(o,u.from);if(h==null)continue;let f=/^\s*/.exec(u.text)[0],d=Or(o,h);f!=d&&a.push({from:u.from,to:u.from+f.length,insert:d})}return a.length?[i,{changes:a,sequential:!0}]:i})}const Iv=Be.define(),yp=new ot;function Lv(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(r&&l.from=e&&c.to>t&&(r=c)}}return r}function _v(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Xo(i,e,t){for(let n of i.facet(Iv)){let s=n(i,e,t);if(s)return s}return $v(i,e,t)}function wp(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const vl=et.define({map:wp}),qr=et.define({map:wp});function vp(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const ys=rn.define({create(){return _e.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)if(t.is(vl)&&!zv(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(Sp),s=n?_e.replace({widget:new Kv(n(e.state,t.value))}):Ih;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(qr)&&(i=i.update({filter:(n,s)=>t.value.from!=n||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;i.between(n,n,(s,r)=>{sn&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(s,r)=>r<=n||s>=n}))}return i},provide:i=>Fe.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,s)=>{t.push(n,s)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!s||s.from>r)&&(s={from:r,to:o})}),s}function zv(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function kp(i,e){return i.field(ys,!1)?e:e.concat(et.appendConfig.of(Cp()))}const Vv=i=>{for(let e of vp(i)){let t=Xo(i.state,e.from,e.to);if(t)return i.dispatch({effects:kp(i.state,[vl.of(t),xp(i,t)])}),!0}return!1},Hv=i=>{if(!i.state.field(ys,!1))return!1;let e=[];for(let t of vp(i)){let n=Jo(i.state,t.from,t.to);n&&e.push(qr.of(n),xp(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function xp(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return Fe.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const Wv=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(ys,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(qr.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},qv=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Vv},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Hv},{key:"Ctrl-Alt-[",run:Wv},{key:"Ctrl-Alt-]",run:jv}],Uv={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Sp=Be.define({combine(i){return mi(i,Uv)}});function Cp(i){return[ys,Xv]}function Ap(i,e){let{state:t}=i,n=t.facet(Sp),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Jo(i.state,l.from,l.to);a&&i.dispatch({effects:qr.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const Ih=_e.replace({widget:new class extends Ci{toDOM(i){return Ap(i,null)}}});class Kv extends Ci{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Ap(e,this.value)}}const Gv={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Kl extends xi{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Yv(i={}){let e=Object.assign(Object.assign({},Gv),i),t=new Kl(e,!0),n=new Kl(e,!1),s=Vt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Gi)!=o.state.facet(Gi)||o.startState.field(ys,!1)!=o.state.field(ys,!1)||sn(o.startState)!=sn(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Wi;for(let a of o.viewportLineBlocks){let c=Jo(o.state,a.from,a.to)?n:Xo(o.state,a.from,a.to)?t:null;c&&l.add(a.from,a.from,c)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Jw({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||gt.empty},initialSpacer(){return new Kl(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let c=Jo(o.state,l.from,l.to);if(c)return o.dispatch({effects:qr.of(c)}),!0;let u=Xo(o.state,l.from,l.to);return u?(o.dispatch({effects:vl.of(u)}),!0):!1}})}),Cp()]}const Xv=Fe.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Ur{constructor(e,t){this.specs=e;let n;function s(l){let a=ji.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof _n?l=>l.prop(os)==o.data:o?l=>l==o:void 0,this.style=fp(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new ji(n):null,this.themeType=t.themeType}static define(e,t){return new Ur(e,t||{})}}const ja=Be.define(),Tp=Be.define({combine(i){return i.length?[i[0]]:null}});function Gl(i){let e=i.facet(ja);return e.length?e:i.facet(Tp)}function Mp(i,e){let t=[Qv],n;return i instanceof Ur&&(i.module&&t.push(Fe.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(Tp.of(i)):n?t.push(ja.computeN([Fe.darkTheme],s=>s.facet(Fe.darkTheme)==(n=="dark")?[i]:[])):t.push(ja.of(i)),t}class Jv{constructor(e){this.markCache=Object.create(null),this.tree=sn(e.state),this.decorations=this.buildDeco(e,Gl(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=sn(e.state),n=Gl(e.state),s=n!=Gl(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return _e.none;let n=new Wi;for(let{from:s,to:r}of e.visibleRanges)vv(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=_e.mark({class:a})))},s,r);return n.finish()}}const Qv=vs.high(Vt.fromClass(Jv,{decorations:i=>i.decorations})),Zv=Ur.define([{tag:X.meta,color:"#404740"},{tag:X.link,textDecoration:"underline"},{tag:X.heading,textDecoration:"underline",fontWeight:"bold"},{tag:X.emphasis,fontStyle:"italic"},{tag:X.strong,fontWeight:"bold"},{tag:X.strikethrough,textDecoration:"line-through"},{tag:X.keyword,color:"#708"},{tag:[X.atom,X.bool,X.url,X.contentSeparator,X.labelName],color:"#219"},{tag:[X.literal,X.inserted],color:"#164"},{tag:[X.string,X.deleted],color:"#a11"},{tag:[X.regexp,X.escape,X.special(X.string)],color:"#e40"},{tag:X.definition(X.variableName),color:"#00f"},{tag:X.local(X.variableName),color:"#30a"},{tag:[X.typeName,X.namespace],color:"#085"},{tag:X.className,color:"#167"},{tag:[X.special(X.variableName),X.macroName],color:"#256"},{tag:X.definition(X.propertyName),color:"#00c"},{tag:X.comment,color:"#940"},{tag:X.invalid,color:"#f00"}]),e1=Fe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Dp=1e4,Op="()[]{}",Ep=Be.define({combine(i){return mi(i,{afterCursor:!0,brackets:Op,maxScanDistance:Dp,renderMatch:i1})}}),t1=_e.mark({class:"cm-matchingBracket"}),n1=_e.mark({class:"cm-nonmatchingBracket"});function i1(i){let e=[],t=i.matched?t1:n1;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const s1=rn.define({create(){return _e.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(Ep);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=hi(e.state,s.head,-1,n)||s.head>0&&hi(e.state,s.head-1,1,n)||n.afterCursor&&(hi(e.state,s.head,1,n)||s.headFe.decorations.from(i)}),r1=[s1,e1];function o1(i={}){return[Ep.of(i),r1]}const l1=new ot;function qa(i,e,t){let n=i.prop(e<0?ot.openedBy:ot.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function Ua(i){let e=i.type.prop(l1);return e?e(i.node):i}function hi(i,e,t,n={}){let s=n.maxScanDistance||Dp,r=n.brackets||Op,o=sn(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=qa(a.type,t,r);if(c&&a.from0?e>=u.from&&eu.from&&e<=u.to))return a1(i,e,t,a,u,c,r)}}return c1(i,e,t,o,l.type,s,r)}function a1(i,e,t,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},c=0,u=l==null?void 0:l.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&r.indexOf(u.type.name)>-1&&u.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=i.doc.iterRange(e,t>0?i.doc.length:0),h=0;for(let f=0;!u.next().done&&f<=r;){let d=u.value;t<0&&(f+=d.length);let p=e+f*t;for(let y=t>0?0:d.length-1,b=t>0?d.length:-1;y!=b;y+=t){let m=o.indexOf(d[y]);if(!(m<0||n.resolveInner(p+y,1).type!=s))if(m%2==0==t>0)h++;else{if(h==1)return{start:c,end:{from:p+y,to:p+y+1},matched:m>>1==a>>1};h--}}t>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}function Lh(i,e,t,n=0,s=0){e==null&&(e=i.search(/[^\s\u00a0]/),e==-1&&(e=i.length));let r=s;for(let o=n;o=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.post}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPosn?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return s(r)==s(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function u1(i){return{name:i.name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||h1,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||Ac}}function h1(i){if(typeof i!="object")return i;let e={};for(let t in i){let n=i[t];e[t]=n instanceof Array?n.slice():n}return e}const $h=new WeakMap;class Sc extends _n{constructor(e){let t=dp(e.languageData),n=u1(e),s,r=new class extends vc{createParse(o,l,a){return new d1(s,o,l,a)}};super(t,r,[mp.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=g1(t),s=this,this.streamParser=n,this.stateAfter=new ot({perNode:!0}),this.tokenTable=e.tokenTable?new Np(n.tokenTable):m1}static define(e){return new Sc(e)}getIndent(e,t){let n=sn(e.state),s=n.resolve(t);for(;s&&s.type!=this.topNode;)s=s.parent;if(!s)return null;let r,{overrideIndentation:o}=e.options;o&&(r=$h.get(e.state),r!=null&&r1e4)return null;for(;a=n&&t+e.length<=s&&e.prop(i.stateAfter);if(r)return{state:i.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],c=l instanceof Tt&&a=e.length)return e;!s&&e.type==i.topNode&&(s=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],l=e.children[r],a;if(ot&&Cc(i,s.tree,0-s.offset,t,o),a;if(l&&(a=Pp(i,s.tree,t+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:a}}return{state:i.streamParser.startState(n?bs(n):4),tree:Tt.empty}}let d1=class{constructor(e,t,n,s){this.lang=e,this.input=t,this.fragments=n,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let r=Us.get(),o=s[0].from,{state:l,tree:a}=f1(e,n,o,r==null?void 0:r.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let c=0;c=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==` `&&(t="");else{let n=t.indexOf(` `);n>-1&&(t=t.slice(0,n))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let s=this.rangeIndex;;){let r=this.ranges[s].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,l=this.lineAfter(o);t+=l,n=o+l.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let s=this.ranges[this.rangeIndex].to,r=e+t;if(n>0?s>r:s>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-s}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){r=this.skipGapsTo(t,r,1),t+=r;let o=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,s+=this.chunk.length-o}return this.chunk.push(e,t,n,s),r}parseLine(e){let{line:t,end:n}=this.nextLine(),s=0,{streamParser:r}=this.lang,o=new Fp(t,e?e.state.tabSize:4,e?bs(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Bp(r.token,o,this.state);if(l&&(s=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,s)),o.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPose.start)return s}throw new Error("Stream parser failed to advance stream.")}const Ac=Object.create(null),Er=[yn.none],p1=new bl(Er),_h=[],zh=Object.create(null),Rp=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Rp[i]=Ip(Ac,e);class Np{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Rp)}resolve(e){return e?this.table[e]||(this.table[e]=Ip(this.extra,e)):0}}const m1=new Np(Ac);function Yl(i,e){_h.indexOf(i)>-1||_h.push(i)}function Ip(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let u=i[c]||X[c];u?typeof u=="function"?a.length?a=a.map(u):Yl(c,`Modifier ${c} used at start of tag`):a.length?Yl(c,`Tag ${c} used as modifier`):a=Array.isArray(u)?u:[u]:Yl(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=zh[s];if(r)return r.id;let o=zh[s]=yn.define({id:Er.length,name:n,props:[up({[n]:t})]});return Er.push(o),o.id}function g1(i){let e=yn.define({id:Er.length,name:"Document",props:[os.add(()=>i)],top:!0});return Er.push(e),e}Rt.RTL,Rt.LTR;const b1=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=Mc(i.state,t.from);return n.line?y1(i):n.block?v1(i):!1};function Tc(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}const y1=Tc(S1,0),w1=Tc(Lp,0),v1=Tc((i,e)=>Lp(i,e,x1(e)),0);function Mc(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const or=50;function k1(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-or,n),o=i.sliceDoc(s,s+or),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,c=r.length-l;if(r.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let u,h;s-n<=2*or?u=h=i.sliceDoc(n,s):(u=i.sliceDoc(n,n+or),h=i.sliceDoc(s-or,s));let f=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-t.length;return u.slice(f,f+e.length)==e&&h.slice(p,p+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function x1(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function Lp(i,e,t=e.selection.ranges){let n=t.map(r=>Mc(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>k1(e,n[o],r.from,r.to));if(i!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:n[o].open+" "},{from:r.to,insert:" "+n[o].close}]))};if(i!=1&&s.some(r=>r)){let r=[];for(let o=0,l;os&&(r==o||o>h.from)){s=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,p=h.text.slice(f,f+c.length)==c?f:-1;fr.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:c,empty:u,single:h}of n)(h||!u)&&r.push({from:l.from+c,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let c=o.from+l,u=c+a.length;o.text[u-o.from]==" "&&u++,r.push({from:c,to:u})}return{changes:r}}return null}const Ka=Si.define(),C1=Si.define(),A1=Be.define(),$p=Be.define({combine(i){return mi(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),_p=rn.define({create(){return fi.empty},update(i,e){let t=e.state.facet($p),n=e.annotation(Ka);if(n){let a=An.fromTransaction(e,n.selection),c=n.side,u=c==0?i.undone:i.done;return a?u=Qo(u,u.length,t.minDepth,a):u=Hp(u,e.startState.selection),new fi(c==0?n.rest:u,c==0?u:n.rest)}let s=e.annotation(C1);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Kt.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=An.fromTransaction(e),o=e.annotation(Kt.time),l=e.annotation(Kt.userEvent);return r?i=i.addChanges(r,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new fi(i.done.map(An.fromJSON),i.undone.map(An.fromJSON))}});function T1(i={}){return[_p,$p.of(i),Fe.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?zp:e.inputType=="historyRedo"?Ga:null;return n?(e.preventDefault(),n(t)):!1}})]}function kl(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(_p,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const zp=kl(0,!1),Ga=kl(1,!1),M1=kl(0,!0),D1=kl(1,!0);class An{constructor(e,t,n,s,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new An(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new An(e.changes&&Ut.fromJSON(e.changes),[],e.mapped&&di.fromJSON(e.mapped),e.startSelection&&ae.fromJSON(e.startSelection),e.selectionsAfter.map(ae.fromJSON))}static fromTransaction(e,t){let n=zn;for(let s of e.startState.facet(A1)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new An(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,zn)}static selection(e){return new An(void 0,zn,void 0,void 0,e)}}function Qo(i,e,t,n){let s=e+1>t+20?e-t-1:0,r=i.slice(s,e);return r.push(n),r}function O1(i,e){let t=[],n=!1;return i.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a=c&&o<=u&&(n=!0)}}),n}function E1(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function Vp(i,e){return i.length?e.length?i.concat(e):i:e}const zn=[],F1=200;function Hp(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-F1));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Qo(i,i.length-1,1e9,t.setSelAfter(n)))}else return[An.selection([e])]}function P1(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Xl(i,e){if(!i.length)return i;let t=i.length,n=zn;for(;t;){let s=B1(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let r=i.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[An.selection(n)]:zn}function B1(i,e,t){let n=Vp(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):zn,t);if(!i.changes)return An.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new An(s,et.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const R1=/^(input\.type|delete)($|\.)/;class fi{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new fi(this.done,this.undone):this}addChanges(e,t,n,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||R1.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?i.moveByChar(t,e):xl(t,e))}function un(i){return i.textDirectionAt(i.state.selection.main.head)==Rt.LTR}const jp=i=>Wp(i,!un(i)),qp=i=>Wp(i,un(i));function Up(i,e){return Zn(i,t=>t.empty?i.moveByGroup(t,e):xl(t,e))}const I1=i=>Up(i,!un(i)),L1=i=>Up(i,un(i));function $1(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function Sl(i,e,t){let n=sn(i).resolveInner(e.head),s=t?ot.closedBy:ot.openedBy;for(let a=e.head;;){let c=t?n.childAfter(a):n.childBefore(a);if(!c)break;$1(i,c,s)?n=c:a=t?c.to:c.from}let r=n.type.prop(s),o,l;return r&&(o=t?hi(i,n.from,1):hi(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,ae.cursor(l,t?-1:1)}const _1=i=>Zn(i,e=>Sl(i.state,e,!un(i))),z1=i=>Zn(i,e=>Sl(i.state,e,un(i)));function Kp(i,e){return Zn(i,t=>{if(!t.empty)return xl(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const Gp=i=>Kp(i,!1),Yp=i=>Kp(i,!0);function Xp(i){let e=i.scrollDOM.clientHeighto.empty?i.moveVertically(o,e,t.height):xl(o,e));if(s.eq(n.selection))return!1;let r;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottomJp(i,!1),Ya=i=>Jp(i,!0);function Xi(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let r=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(s=ae.cursor(n.from+r))}return s}const V1=i=>Zn(i,e=>Xi(i,e,!0)),H1=i=>Zn(i,e=>Xi(i,e,!1)),W1=i=>Zn(i,e=>Xi(i,e,!un(i))),j1=i=>Zn(i,e=>Xi(i,e,un(i))),q1=i=>Zn(i,e=>ae.cursor(i.lineBlockAt(e.head).from,1)),U1=i=>Zn(i,e=>ae.cursor(i.lineBlockAt(e.head).to,-1));function K1(i,e,t){let n=!1,s=Zs(i.selection,r=>{let o=hi(i,r.head,-1)||hi(i,r.head,1)||r.head>0&&hi(i,r.head-1,1)||r.headK1(i,e);function Un(i,e){let t=Zs(i.state.selection,n=>{let s=e(n);return ae.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(gi(i.state,t)),!0)}function Qp(i,e){return Un(i,t=>i.moveByChar(t,e))}const Zp=i=>Qp(i,!un(i)),em=i=>Qp(i,un(i));function tm(i,e){return Un(i,t=>i.moveByGroup(t,e))}const Y1=i=>tm(i,!un(i)),X1=i=>tm(i,un(i)),J1=i=>Un(i,e=>Sl(i.state,e,!un(i))),Q1=i=>Un(i,e=>Sl(i.state,e,un(i)));function nm(i,e){return Un(i,t=>i.moveVertically(t,e))}const im=i=>nm(i,!1),sm=i=>nm(i,!0);function rm(i,e){return Un(i,t=>i.moveVertically(t,e,Xp(i).height))}const Hh=i=>rm(i,!1),Wh=i=>rm(i,!0),Z1=i=>Un(i,e=>Xi(i,e,!0)),ek=i=>Un(i,e=>Xi(i,e,!1)),tk=i=>Un(i,e=>Xi(i,e,!un(i))),nk=i=>Un(i,e=>Xi(i,e,un(i))),ik=i=>Un(i,e=>ae.cursor(i.lineBlockAt(e.head).from)),sk=i=>Un(i,e=>ae.cursor(i.lineBlockAt(e.head).to)),jh=({state:i,dispatch:e})=>(e(gi(i,{anchor:0})),!0),qh=({state:i,dispatch:e})=>(e(gi(i,{anchor:i.doc.length})),!0),Uh=({state:i,dispatch:e})=>(e(gi(i,{anchor:i.selection.main.anchor,head:0})),!0),Kh=({state:i,dispatch:e})=>(e(gi(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),rk=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),ok=({state:i,dispatch:e})=>{let t=Cl(i).map(({from:n,to:s})=>ae.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:ae.create(t),userEvent:"select"})),!0},lk=({state:i,dispatch:e})=>{let t=Zs(i.selection,n=>{let s=sn(i),r=s.resolveStack(n.from,1);if(n.empty){let o=s.resolveStack(n.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return ae.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(gi(i,t)),!0)},ak=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=ae.create([t.main]):t.main.empty||(n=ae.create([ae.cursor(t.main.head)])),n?(e(gi(i,n)),!0):!1};function Kr(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);ao&&(t="delete.forward",a=go(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=go(i,o,!1),l=go(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:ae.cursor(o,os(i)))n.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}const om=(i,e,t)=>Kr(i,n=>{let s=n.from,{state:r}=i,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&som(i,!1,!0),lm=i=>om(i,!0,!1),am=(i,e)=>Kr(i,t=>{let n=t.head,{state:s}=i,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let l=null;;){if(n==(e?r.to:r.from)){n==t.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=nn(r.text,n-r.from,e)+r.from,c=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),u=o(c);if(l!=null&&u!=l)break;(c!=" "||n!=t.head)&&(l=u),n=a}return n}),cm=i=>am(i,!1),ck=i=>am(i,!0),uk=i=>Kr(i,e=>{let t=i.lineBlockAt(e.head).to;return e.headKr(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),fk=i=>Kr(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:yt.of(["",""])},range:ae.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},pk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,r=i.doc.lineAt(s),o=s==r.from?s-1:nn(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:nn(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:i.doc.slice(s,l).append(i.doc.slice(o,s))},range:ae.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Cl(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),r=i.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=i.doc.lineAt(n.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});t=r.number+1}return e}function um(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of Cl(i)){if(t?r.to==i.doc.length:r.from==0)continue;let o=i.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){n.push({from:r.to,to:o.to},{from:r.from,insert:o.text+i.lineBreak});for(let a of r.ranges)s.push(ae.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:r.from},{from:r.to,insert:i.lineBreak+o.text});for(let a of r.ranges)s.push(ae.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:ae.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const mk=({state:i,dispatch:e})=>um(i,e,!1),gk=({state:i,dispatch:e})=>um(i,e,!0);function hm(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of Cl(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const bk=({state:i,dispatch:e})=>hm(i,e,!1),yk=({state:i,dispatch:e})=>hm(i,e,!0),wk=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(Cl(e).map(({from:s,to:r})=>(s>0?s--:r{let r;if(i.lineWrapping){let o=i.lineBlockAt(s.head),l=i.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,r)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function vk(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=sn(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),r;return n&&s&&n.to<=e&&s.from>=e&&(r=n.type.prop(ot.closedBy))&&r.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const Gh=fm(!1),kk=fm(!0);function fm(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!i&&r==o&&vk(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new wl(e,{simulateBreak:r,simulateDoubleBreak:!!a}),u=kc(c,r);for(u==null&&(u=Qs(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));ol.from&&r{let s=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,s,n),t=l.number),o=l.to+1}let r=i.changes(s);return{changes:s,range:ae.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const xk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new wl(i,{overrideIndentation:r=>{let o=t[r];return o==null?-1:o}}),s=Dc(i,(r,o,l)=>{let a=kc(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],u=Or(i,a);(c!=u||l.fromi.readOnly?!1:(e(i.update(Dc(i,(t,n)=>{n.push({from:t.from,insert:i.facet(yl)})}),{userEvent:"input.indent"})),!0),pm=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Dc(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Qs(s,i.tabSize),o=0,l=Or(i,Math.max(0,r-bs(i)));for(;o(i.setTabFocusMode(),!0),Ck=[{key:"Ctrl-b",run:jp,shift:Zp,preventDefault:!0},{key:"Ctrl-f",run:qp,shift:em},{key:"Ctrl-p",run:Gp,shift:im},{key:"Ctrl-n",run:Yp,shift:sm},{key:"Ctrl-a",run:q1,shift:ik},{key:"Ctrl-e",run:U1,shift:sk},{key:"Ctrl-d",run:lm},{key:"Ctrl-h",run:Xa},{key:"Ctrl-k",run:uk},{key:"Ctrl-Alt-h",run:cm},{key:"Ctrl-o",run:dk},{key:"Ctrl-t",run:pk},{key:"Ctrl-v",run:Ya}],Ak=[{key:"ArrowLeft",run:jp,shift:Zp,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:I1,shift:Y1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:W1,shift:tk,preventDefault:!0},{key:"ArrowRight",run:qp,shift:em,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:L1,shift:X1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:j1,shift:nk,preventDefault:!0},{key:"ArrowUp",run:Gp,shift:im,preventDefault:!0},{mac:"Cmd-ArrowUp",run:jh,shift:Uh},{mac:"Ctrl-ArrowUp",run:Vh,shift:Hh},{key:"ArrowDown",run:Yp,shift:sm,preventDefault:!0},{mac:"Cmd-ArrowDown",run:qh,shift:Kh},{mac:"Ctrl-ArrowDown",run:Ya,shift:Wh},{key:"PageUp",run:Vh,shift:Hh},{key:"PageDown",run:Ya,shift:Wh},{key:"Home",run:H1,shift:ek,preventDefault:!0},{key:"Mod-Home",run:jh,shift:Uh},{key:"End",run:V1,shift:Z1,preventDefault:!0},{key:"Mod-End",run:qh,shift:Kh},{key:"Enter",run:Gh,shift:Gh},{key:"Mod-a",run:rk},{key:"Backspace",run:Xa,shift:Xa},{key:"Delete",run:lm},{key:"Mod-Backspace",mac:"Alt-Backspace",run:cm},{key:"Mod-Delete",mac:"Alt-Delete",run:ck},{mac:"Mod-Backspace",run:hk},{mac:"Mod-Delete",run:fk}].concat(Ck.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),Tk=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:_1,shift:J1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:z1,shift:Q1},{key:"Alt-ArrowUp",run:mk},{key:"Shift-Alt-ArrowUp",run:bk},{key:"Alt-ArrowDown",run:gk},{key:"Shift-Alt-ArrowDown",run:yk},{key:"Escape",run:ak},{key:"Mod-Enter",run:kk},{key:"Alt-l",mac:"Ctrl-l",run:ok},{key:"Mod-i",run:lk,preventDefault:!0},{key:"Mod-[",run:pm},{key:"Mod-]",run:dm},{key:"Mod-Alt-\\",run:xk},{key:"Shift-Mod-k",run:wk},{key:"Shift-Mod-\\",run:G1},{key:"Mod-/",run:b1},{key:"Alt-A",run:w1},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Sk}].concat(Ak),Mk={key:"Tab",run:dm,shift:pm};function Ft(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var s=t[n];typeof s=="string"?i.setAttribute(n,s):s!=null&&(i[n]=s)}e++}for(;ei.normalize("NFKD"):i=>i;class Gs{constructor(e,t,n=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=r?l=>r(Yh(l)):Yh,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return en(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=nc(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=$n(e);let s=this.normalize(t);if(s.length)for(let r=0,o=n;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==n&&rthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=Zo(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(nthis.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||s.to<=t){let l=new Is(t,e.sliceString(t,n));return Jl.set(e,l),l}if(s.from==t&&s.to==n)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this.matchPos=Zo(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Is.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol!="undefined"&&(bm.prototype[Symbol.iterator]=ym.prototype[Symbol.iterator]=function(){return this});function Dk(i){try{return new RegExp(i,Oc),!0}catch(e){return!1}}function Zo(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e=56320&&n<57344;)e++;return e}function Ja(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=Ft("input",{class:"cm-textfield",name:"line",value:e}),n=Ft("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),i.dispatch({effects:el.of(!1)}),i.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},Ft("label",i.state.phrase("Go to line"),": ",t)," ",Ft("button",{class:"cm-button",type:"submit"},i.state.phrase("go")));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=i,l=o.doc.lineAt(o.selection.main.head),[,a,c,u,h]=r,f=u?+u.slice(1):0,d=c?+c:l.number;if(c&&h){let b=d/100;a&&(b=b*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*b)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),y=ae.cursor(p.from+Math.max(0,Math.min(f,p.length)));i.dispatch({effects:[el.of(!1),Fe.scrollIntoView(y.from,{y:"center"})],selection:y}),i.focus()}return{dom:n}}const el=et.define(),Xh=rn.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(el)&&(i=t.value);return i},provide:i=>Mr.from(i,e=>e?Ja:null)}),Ok=i=>{let e=Tr(i,Ja);if(!e){let t=[el.of(!0)];i.state.field(Xh,!1)==null&&t.push(et.appendConfig.of([Xh,Ek])),i.dispatch({effects:t}),e=Tr(i,Ja)}return e&&e.dom.querySelector("input").select(),!0},Ek=Fe.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Fk={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Pk=Be.define({combine(i){return mi(i,Fk,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Bk(i){return[$k,Lk]}const Rk=_e.mark({class:"cm-selectionMatch"}),Nk=_e.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Jh(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=It.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=It.Word)}function Ik(i,e,t,n){return i(e.sliceDoc(t,t+1))==It.Word&&i(e.sliceDoc(n-1,n))==It.Word}const Lk=Vt.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(Pk),{state:t}=i,n=t.selection;if(n.ranges.length>1)return _e.none;let s=n.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return _e.none;let a=t.wordAt(s.head);if(!a)return _e.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a200)return _e.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Jh(o,t,s.from,s.to)&&Ik(o,t,s.from,s.to)))return _e.none}else if(r=t.sliceDoc(s.from,s.to),!r)return _e.none}let l=[];for(let a of i.visibleRanges){let c=new Gs(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:u,to:h}=c.value;if((!o||Jh(o,t,u,h))&&(s.empty&&u<=s.from&&h>=s.to?l.push(Nk.range(u,h)):(u>=s.to||h<=s.from)&&l.push(Rk.range(u,h)),l.length>e.maxMatches))return _e.none}}return _e.set(l)}},{decorations:i=>i.decorations}),$k=Fe.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),_k=({state:i,dispatch:e})=>{let{selection:t}=i,n=ae.create(t.ranges.map(s=>i.wordAt(s.head)||ae.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function zk(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new Gs(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Gs(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(r){let a=i.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Vk=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return _k({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(r=>i.sliceDoc(r.from,r.to)!=n))return!1;let s=zk(i,n);return s?(e(i.update({selection:i.selection.addRange(ae.range(s.from,s.to),!1),effects:Fe.scrollIntoView(s.to)})),!0):!1},er=Be.define({combine(i){return mi(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Zk(e),scrollToMatch:e=>Fe.scrollIntoView(e)})}});class wm{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Dk(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?` `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new qk(this):new Wk(this)}getCursor(e,t=0,n){let s=e.doc?e:ht.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Ts(this,s,t,n):As(this,s,t,n)}}class vm{constructor(e){this.spec=e}}function As(i,e,t,n){return new Gs(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?Hk(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Hk(i,e){return(t,n,s,r)=>((r>t||r+s.length=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=As(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Ts(i,e,t,n){return new bm(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?jk(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function tl(i,e){return i.slice(nn(i,e,!1),e)}function nl(i,e){return i.slice(e,nn(i,e))}function jk(i){return(e,t,n)=>!n[0].length||(i(tl(n.input,n.index))!=It.Word||i(nl(n.input,n.index))!=It.Word)&&(i(nl(n.input,n.index+n[0].length))!=It.Word||i(tl(n.input,n.index+n[0].length))!=It.Word)}class qk extends vm{nextMatch(e,t,n){let s=Ts(this.spec,e,n,e.doc.length).next();return s.done&&(s=Ts(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),o=Ts(this.spec,e,r,n),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Ts(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Fr=et.define(),Ec=et.define(),zi=rn.define({create(i){return new Ql(Qa(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Fr)?i=new Ql(t.value.create(),i.panel):t.is(Ec)&&(i=new Ql(i.query,t.value?Fc:null));return i},provide:i=>Mr.from(i,e=>e.panel)});class Ql{constructor(e,t){this.query=e,this.panel=t}}const Uk=_e.mark({class:"cm-searchMatch"}),Kk=_e.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Gk=Vt.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(zi))}update(i){let e=i.state.field(zi);(e!=i.startState.field(zi)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return _e.none;let{view:t}=this,n=new Wi;for(let s=0,r=t.visibleRanges,o=r.length;sr[s+1].from-2*250;)a=r[++s].to;i.highlight(t.state,l,a,(c,u)=>{let h=t.state.selection.ranges.some(f=>f.from==c&&f.to==u);n.add(c,u,h?Kk:Uk)})}return n.finish()}},{decorations:i=>i.decorations});function Gr(i){return e=>{let t=e.state.field(zi,!1);return t&&t.query.spec.valid?i(e,t):Sm(e)}}const il=Gr((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=ae.single(n.from,n.to),r=i.state.facet(er);return i.dispatch({selection:s,effects:[Pc(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),xm(i),!0}),sl=Gr((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=ae.single(s.from,s.to),o=i.state.facet(er);return i.dispatch({selection:r,effects:[Pc(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),xm(i),!0}),Yk=Gr((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:ae.create(t.map(n=>ae.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Xk=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],o=0;for(let l=new Gs(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(ae.range(l.value.from,l.value.to))}return e(i.update({selection:ae.create(r,o),userEvent:"select.search.matches"})),!0},Qh=Gr((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let o=[],l,a,c=[];if(r.from==n&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t,r.from,r.to),c.push(Fe.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),r){let u=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=ae.single(r.from-u,r.to-u),c.push(Pc(i,r)),c.push(t.facet(er).scrollToMatch(l.main,i))}return i.dispatch({changes:o,selection:l,effects:c,userEvent:"input.replace"}),!0}),Jk=Gr((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:Fe.announce.of(n),userEvent:"input.replace.all"}),!0});function Fc(i){return i.state.facet(er).createPanel(i)}function Qa(i,e){var t,n,s,r,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=i.facet(er);return new wm({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function km(i){let e=Tr(i,Fc);return e&&e.dom.querySelector("[main-field]")}function xm(i){let e=km(i);e&&e==i.root.activeElement&&e.select()}const Sm=i=>{let e=i.state.field(zi,!1);if(e&&e.panel){let t=km(i);if(t&&t!=i.root.activeElement){let n=Qa(i.state,e.query.spec);n.valid&&i.dispatch({effects:Fr.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[Ec.of(!0),e?Fr.of(Qa(i.state,e.query.spec)):et.appendConfig.of(tx)]});return!0},Cm=i=>{let e=i.state.field(zi,!1);if(!e||!e.panel)return!1;let t=Tr(i,Fc);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:Ec.of(!1)}),!0},Qk=[{key:"Mod-f",run:Sm,scope:"editor search-panel"},{key:"F3",run:il,shift:sl,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:il,shift:sl,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Cm,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Xk},{key:"Mod-Alt-g",run:Ok},{key:"Mod-d",run:Vk,preventDefault:!0}];class Zk{constructor(e){this.view=e;let t=this.query=e.state.field(zi).query.spec;this.commit=this.commit.bind(this),this.searchField=Ft("input",{value:t.search,placeholder:Fn(e,"Find"),"aria-label":Fn(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ft("input",{value:t.replace,placeholder:Fn(e,"Replace"),"aria-label":Fn(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ft("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ft("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ft("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,o){return Ft("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=Ft("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>il(e),[Fn(e,"next")]),n("prev",()=>sl(e),[Fn(e,"previous")]),n("select",()=>Yk(e),[Fn(e,"all")]),Ft("label",null,[this.caseField,Fn(e,"match case")]),Ft("label",null,[this.reField,Fn(e,"regexp")]),Ft("label",null,[this.wordField,Fn(e,"by word")]),...e.state.readOnly?[]:[Ft("br"),this.replaceField,n("replace",()=>Qh(e),[Fn(e,"replace")]),n("replaceAll",()=>Jk(e),[Fn(e,"replace all")])],Ft("button",{name:"close",onclick:()=>Cm(e),"aria-label":Fn(e,"close"),type:"button"},["×"])])}commit(){let e=new wm({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Fr.of(e)}))}keydown(e){rw(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?sl:il)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qh(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Fr)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(er).top}}function Fn(i,e){return i.state.phrase(e)}const bo=30,yo=/[\s\.,:;?!]/;function Pc(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-bo),o=Math.min(s,t+bo),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;al.length-bo;a--)if(!yo.test(l[a-1])&&yo.test(l[a])){l=l.slice(0,a);break}}return Fe.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const ex=Fe.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),tx=[zi,vs.low(Gk),ex];class Am{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=sn(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),r=s.search(Tm(e,!1));return r<0?null:{from:n+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Zh(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function nx(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:nx(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class ef{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function hs(i){return i.selection.main.from}function Tm(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",r=n[n.length-1]!="$";return!s&&!r?i:new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const Mm=Si.define();function sx(i,e,t,n){let{main:s}=i.selection,r=t-s.from,o=n-s.from;return Object.assign(Object.assign({},i.changeByRange(l=>{if(l!=s&&t!=n&&i.sliceDoc(l.from+r,l.from+o)!=i.sliceDoc(t,n))return{range:l};let a=i.toText(e);return{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:a},range:ae.cursor(l.from+r+a.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const tf=new WeakMap;function rx(i){if(!Array.isArray(i))return i;let e=tf.get(i);return e||tf.set(i,e=ix(i)),e}const rl=et.define(),Pr=et.define();class ox{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&O<=57||O>=97&&O<=122?2:O>=65&&O<=90?1:0:(D=nc(O))!=D.toLowerCase()?1:D!=D.toUpperCase()?2:0;(!x||F==1&&b||P==0&&F!=0)&&(t[h]==O||n[h]==O&&(f=!0)?o[h++]=x:o.length&&(m=!1)),P=F,x+=$n(O)}return h==a&&o[0]==0&&m?this.result(-100+(f?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(y==e.length?0:-100),[0,y]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,y]):h==a?this.result(-100+(f?-200:0)+-700+(m?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],r=0;for(let o of t){let l=o+(this.astral?$n(en(n,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-n.length,s)}}class lx{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ax,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>nf(e(n),t(n)),optionClass:(e,t)=>n=>nf(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function nf(i,e){return i?e?i+" "+e:i:e}function ax(i,e,t,n,s,r){let o=i.textDirection==Rt.RTL,l=o,a=!1,c="top",u,h,f=e.left-s.left,d=s.right-e.right,p=n.right-n.left,y=n.bottom-n.top;if(l&&f=y||x>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let b=(e.bottom-e.top)/r.offsetHeight,m=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${u/b}px; max-width: ${h/m}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function cx(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;ca&&o.appendChild(document.createTextNode(l.slice(a,u)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(u,h))),f.className="cm-completionMatchedText",a=h}return at.position-n.position).map(t=>t.render)}function Zl(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class ux{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(Jt);this.optionContent=cx(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Zl(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let u=a.target,h;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(h=/-(\d+)$/.exec(u.id))&&+h[1]{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Jt).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Pr.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:r,selected:o,disabled:l}=n.open;(!s.open||s.open.options!=r)&&(this.range=Zl(r.length,o,e.state.facet(Jt).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=Zl(t.options.length,t.selected,this.view.state.facet(Jt).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:s}=n;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(n);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>Cn(this.view.state,o,"completion info")):this.addInfoPane(r,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;n.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&fx(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottomn.from||n.from==0))if(r=f,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=f}}const u=s.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let h=this.optionClass(l);h&&(u.className=h);for(let f of this.optionContent){let d=f(l,this.view.state,this.view,a);d&&u.appendChild(d)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.tonew ux(t,i,e)}function fx(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.topt.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function sf(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function dx(i,e){let t=[],n=null,s=c=>{t.push(c);let{section:u}=c.completion;if(u){n||(n=[]);let h=typeof u=="string"?u:u.name;n.some(f=>f.name==h)||n.push(typeof u=="string"?{name:h}:u)}},r=e.facet(Jt);for(let c of i)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let h of c.result.options)s(new ef(h,c.source,u?u(h):[],1e9-t.length));else{let h=e.sliceDoc(c.from,c.to),f,d=r.filterStrict?new lx(h):new ox(h);for(let p of c.result.options)if(f=d.match(p.label)){let y=p.displayLabel?u?u(p,f.matched):[]:f.matched;s(new ef(p,c.source,y,f.score+(p.boost||0)))}}}if(n){let c=Object.create(null),u=0,h=(f,d)=>{var p,y;return((p=f.rank)!==null&&p!==void 0?p:1e9)-((y=d.rank)!==null&&y!==void 0?y:1e9)||(f.nameh.score-u.score||a(u.completion,h.completion))){let u=c.completion;!l||l.label!=u.label||l.detail!=u.detail||l.type!=null&&u.type!=null&&l.type!=u.type||l.apply!=u.apply||l.boost!=u.boost?o.push(c):sf(c.completion)>sf(l)&&(o[o.length-1]=c),l=c.completion}return o}class Es{constructor(e,t,n,s,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Es(this.options,rf(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r,o){if(s&&!o&&e.some(c=>c.isPending))return s.setDisabled();let l=dx(e,t);if(!l.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let a=t.facet(Jt).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let c=s.options[s.selected].completion;for(let u=0;uu.hasResult()?Math.min(c,u.from):c,1e8),create:wx,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new Es(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Es(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ol{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new ol(bx,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Jt),r=(n.override||t.languageDataAt("autocomplete",hs(t)).map(rx)).map(a=>(this.active.find(u=>u.source==a)||new Vn(a,this.active.some(u=>u.state!=0)?1:0)).update(e,n));r.length==this.active.length&&r.every((a,c)=>a==this.active[c])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Bc));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!px(r,this.active)||l?o=Es.build(r,t,this.id,o,n,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Vn(a.source,0):a));for(let a of e.effects)a.is(Om)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new ol(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?mx:gx}}function px(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t-1&&(t["aria-activedescendant"]=i+"-"+e),t}const bx=[];function Dm(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(Mm);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class Vn{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=Dm(e,t),s=this;(n&8||n&16&&this.touches(e))&&(s=new Vn(s.source,0)),n&4&&s.state==0&&(s=new Vn(this.source,1)),s=s.updateFor(e,n);for(let r of e.effects)if(r.is(rl))s=new Vn(s.source,1,r.value);else if(r.is(Pr))s=new Vn(s.source,0);else if(r.is(Bc))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(hs(e.state))}}class Ls extends Vn{constructor(e,t,n,s,r,o){super(e,3,t),this.limit=n,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=hs(e.state);if(l>o||!s||t&2&&(hs(e.startState)==this.from||lt.map(e))}}),Om=et.define(),kn=rn.define({create(){return ol.start()},update(i,e){return i.update(e)},provide:i=>[gc.from(i,e=>e.tooltip),Fe.contentAttributes.from(i,e=>e.attrs)]});function Rc(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(kn).active.find(s=>s.source==e.source);return n instanceof Ls?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},sx(i.state,t,n.from,n.to)),{annotations:Mm.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}const wx=hx(kn,Rc);function wo(i,e="option"){return t=>{let n=t.state.field(kn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+s*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Om.of(l)}),!0}}const vx=i=>{let e=i.state.field(kn,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampi.state.field(kn,!1)?(i.dispatch({effects:rl.of(!0)}),!0):!1,kx=i=>{let e=i.state.field(kn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Pr.of(null)}),!0)};class xx{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Sx=50,Cx=1e3,Ax=Vt.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(kn).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(kn),t=i.state.facet(Jt);if(!i.selectionSet&&!i.docChanged&&i.startState.field(kn)==e)return;let n=i.transactions.some(r=>{let o=Dm(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;rSx&&Date.now()-o.time>Cx){for(let l of o.context.abortListeners)try{l()}catch(a){Cn(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(r=>r.effects.some(o=>o.is(rl)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of i.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(kn);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Jt).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=hs(e),n=new Am(e,t,i.explicit,this.view),s=new xx(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Pr.of(null)}),Cn(this.view.state,r)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Jt).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Jt),n=this.view.state.field(kn);for(let s=0;sl.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Vn(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:Bc.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(kn,!1);if(e&&e.tooltip&&this.view.state.facet(Jt).closeOnBlur){let t=e.open&&np(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Pr.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:rl.of(!1)}),20),this.composing=0}}}),Tx=typeof navigator=="object"&&/Win/.test(navigator.platform),Mx=vs.highest(Fe.domEventHandlers({keydown(i,e){let t=e.state.field(kn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(Tx&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],s=t.active.find(o=>o.source==n.source),r=n.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(i.key)>-1&&Rc(e,n),!1}})),Dx=Fe.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Br={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ls=et.define({map(i,e){let t=e.mapPos(i,-1,mn.TrackAfter);return t==null?void 0:t}}),Nc=new class extends ds{};Nc.startSide=1;Nc.endSide=-1;const Em=rn.define({create(){return gt.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(ls)&&(i=i.update({add:[Nc.range(t.value,t.value+1)]}));return i}});function Ox(){return[Fx,Em]}const ea="()[]{}<>";function Fm(i){for(let e=0;e{if((Ex?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&$n(en(n,0))==1||e!=s.from||t!=s.to)return!1;let r=Rx(i.state,n);return r?(i.dispatch(r),!0):!1}),Px=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Pm(i,i.selection.main.head).brackets||Br.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=Nx(i.doc,o.head);for(let a of n)if(a==l&&Al(i.doc,o.head)==Fm(en(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:ae.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Bx=[{key:"Backspace",run:Px}];function Rx(i,e){let t=Pm(i,i.selection.main.head),n=t.brackets||Br.brackets;for(let s of n){let r=Fm(en(s,0));if(e==s)return r==s?$x(i,s,n.indexOf(s+s+s)>-1,t):Ix(i,s,r,t.before||Br.before);if(e==r&&Bm(i,i.selection.main.from))return Lx(i,s,r)}return null}function Bm(i,e){let t=!1;return i.field(Em).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function Al(i,e){let t=i.sliceString(e,e+2);return t.slice(0,$n(en(t,0)))}function Nx(i,e){let t=i.sliceString(e-2,e);return $n(en(t,0))==t.length?t:t.slice(1)}function Ix(i,e,t,n){let s=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:ls.of(o.to+e.length),range:ae.range(o.anchor+e.length,o.head+e.length)};let l=Al(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:ls.of(o.head+e.length),range:ae.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Lx(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&Al(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:ae.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function $x(i,e,t,n){let s=n.stringPrefixes||Br.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:ls.of(l.to+e.length),range:ae.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Al(i.doc,a),u;if(c==e){if(lf(i,a))return{changes:{insert:e+e,from:a},effects:ls.of(a+e.length),range:ae.cursor(a+e.length)};if(Bm(i,a)){let f=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:ae.cursor(a+f.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(u=af(i,a-2*e.length,s))>-1&&lf(i,u))return{changes:{insert:e+e+e+e,from:a},effects:ls.of(a+e.length),range:ae.cursor(a+e.length)};if(i.charCategorizer(a)(c)!=It.Word&&af(i,a,s)>-1&&!_x(i,a,e,s))return{changes:{insert:e+e,from:a},effects:ls.of(a+e.length),range:ae.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function lf(i,e){let t=sn(i).resolveInner(e+1);return t.parent&&t.from==e}function _x(i,e,t,n){let s=sn(i).resolveInner(e,-1),r=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let u=s.firstChild;for(;u&&u.from==s.from&&u.to-u.from>t.length+a;){if(i.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function af(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=It.Word)return e;for(let s of t){let r=e-s.length;if(i.sliceDoc(r,e)==s&&n(i.sliceDoc(r-1,r))!=It.Word)return r}return-1}function zx(i={}){return[Mx,kn,Jt.of(i),Ax,Vx,Dx]}const Rm=[{key:"Ctrl-Space",run:of},{mac:"Alt-`",run:of},{key:"Escape",run:kx},{key:"ArrowDown",run:wo(!0)},{key:"ArrowUp",run:wo(!1)},{key:"PageDown",run:wo(!0,"page")},{key:"PageUp",run:wo(!1,"page")},{key:"Enter",run:vx}],Vx=vs.highest(ml.computeN([Jt],i=>i.facet(Jt).defaultKeymap?[Rm]:[]));class Hx{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class ns{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=e,r=n.facet(Rr).markerFilter;r&&(s=r(s,n));let o=_e.set(s.map(l=>l.from==l.to||l.from==l.to-1&&n.doc.lineAt(l.from).to==l.from?_e.widget({widget:new Jx(l),diagnostic:l}).range(l.from):_e.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new ns(o,t,Ys(o))}}function Ys(i,e=null,t=0){let n=null;return i.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return n=new Hx(s,r,o.diagnostic),!1}),n}function Wx(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(Rr).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(Nm))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function jx(i,e){return i.field(Rn,!1)?e:e.concat(et.appendConfig.of(eS))}const Nm=et.define(),Ic=et.define(),Im=et.define(),Rn=rn.define({create(){return new ns(_e.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=Ys(t,i.selected.diagnostic,r)||Ys(t,null,r)}!t.size&&s&&e.state.facet(Rr).autoPanel&&(s=null),i=new ns(t,s,n)}for(let t of e.effects)if(t.is(Nm)){let n=e.state.facet(Rr).autoPanel?t.value.length?Nr.open:null:i.panel;i=ns.init(t.value,n,e.state)}else t.is(Ic)?i=new ns(i.diagnostics,t.value?Nr.open:null,i.selected):t.is(Im)&&(i=new ns(i.diagnostics,i.panel,t.value));return i},provide:i=>[Mr.from(i,e=>e.panel),Fe.decorations.from(i,e=>e.diagnostics)]}),qx=_e.mark({class:"cm-lintRange cm-lintRange-active"});function Ux(i,e,t){let{diagnostics:n}=i.state.field(Rn),s=[],r=2e8,o=0;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:u})=>{e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e$m(i,t,!1)))}const Gx=i=>{let e=i.state.field(Rn,!1);(!e||!e.panel)&&i.dispatch({effects:jx(i.state,[Ic.of(!0)])});let t=Tr(i,Nr.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},cf=i=>{let e=i.state.field(Rn,!1);return!e||!e.panel?!1:(i.dispatch({effects:Ic.of(!1)}),!0)},Yx=i=>{let e=i.state.field(Rn,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Xx=[{key:"Mod-Shift-m",run:Gx,preventDefault:!0},{key:"F8",run:Yx}],Rr=Be.define({combine(i){return Object.assign({sources:i.map(e=>e.source).filter(e=>e!=null)},mi(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))}});function Lm(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;nr.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function $m(i,e,t){var n;let s=t?Lm(e.actions):[];return Ft("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ft("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,o)=>{let l=!1,a=f=>{if(f.preventDefault(),l)return;l=!0;let d=Ys(i.state.field(Rn).diagnostics,e);d&&r.apply(i,d.from,d.to)},{name:c}=r,u=s[o]?c.indexOf(s[o]):-1,h=u<0?c:[c.slice(0,u),Ft("u",c.slice(u,u+1)),c.slice(u+1)];return Ft("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${c}${u<0?"":` (access key "${s[o]})"`}.`},h)}),e.source&&Ft("div",{class:"cm-diagnosticSource"},e.source))}class Jx extends Ci{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Ft("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class uf{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=$m(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Nr{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)cf(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Lm(r.actions);for(let l=0;l{for(let r=0;rcf(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Rn).selected;if(!e)return-1;for(let t=0;t{let c=-1,u;for(let h=n;hn&&(this.items.splice(n,c-n),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++});n({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.topl.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Rn),n=Ys(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Im.of(n)})}static open(e){return new Nr(e)}}function Qx(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(i)}')`}function vo(i){return Qx(``,'width="6" height="3"')}const Zx=Fe.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:vo("#d11")},".cm-lintRange-warning":{backgroundImage:vo("orange")},".cm-lintRange-info":{backgroundImage:vo("#999")},".cm-lintRange-hint":{backgroundImage:vo("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),eS=[Rn,Fe.decorations.compute([Rn],i=>{let{selected:e,panel:t}=i.field(Rn);return!e||!t||e.from==e.to?_e.none:_e.set([qx.range(e.from,e.to)])}),Kw(Ux,{hideOn:Wx}),Zx],tS=[sv(),lv(),xw(),T1(),Yv(),hw(),gw(),ht.allowMultipleSelections.of(!0),Nv(),Mp(Zv,{fallback:!0}),o1(),Ox(),zx(),Iw(),_w(),Dw(),Bk(),ml.of([...Bx,...Tk,...Qk,...N1,...qv,...Rm,...Xx])];/*! * VueCodemirror v6.1.1 * Copyright (c) Surmon. All rights reserved. * Released under the MIT License. * Surmon */var nS=Object.freeze({autofocus:!1,disabled:!1,indentWithTab:!0,tabSize:2,placeholder:"",autoDestroy:!0,extensions:[tS]}),iS=Symbol("vue-codemirror-global-config"),pn,sS=function(i){var e=i.onUpdate,t=i.onChange,n=i.onFocus,s=i.onBlur,r=function(o,l){var a={};for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&l.indexOf(c)<0&&(a[c]=o[c]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function"){var u=0;for(c=Object.getOwnPropertySymbols(o);u(i.JSON="json",i.YAML="yaml",i))(Ds||{}),zm=i=>{var{theme:e,settings:t={},styles:n=[]}=i,s={".cm-gutters":{}},r={};t.background&&(r.backgroundColor=t.background),t.backgroundImage&&(r.backgroundImage=t.backgroundImage),t.foreground&&(r.color=t.foreground),t.fontSize&&(r.fontSize=t.fontSize),(t.background||t.foreground)&&(s["&"]=r),t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var o={};t.gutterActiveForeground&&(o.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},o.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=o,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var l=Fe.theme(s,{dark:e==="dark"}),a=Ur.define(n),c=[l,Mp(a)];return c},hS={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},fS=[{tag:[X.standard(X.tagName),X.tagName],color:"#116329"},{tag:[X.comment,X.bracket],color:"#6a737d"},{tag:[X.className,X.propertyName],color:"#6f42c1"},{tag:[X.variableName,X.attributeName,X.number,X.operator],color:"#005cc5"},{tag:[X.keyword,X.typeName,X.typeOperator,X.typeName],color:"#d73a49"},{tag:[X.string,X.meta,X.regexp],color:"#032f62"},{tag:[X.name,X.quote],color:"#22863a"},{tag:[X.heading,X.strong],color:"#24292e",fontWeight:"bold"},{tag:[X.emphasis],color:"#24292e",fontStyle:"italic"},{tag:[X.deleted],color:"#b31d28",backgroundColor:"ffeef0"},{tag:[X.atom,X.bool,X.special(X.variableName)],color:"#e36209"},{tag:[X.url,X.escape,X.regexp,X.link],color:"#032f62"},{tag:X.link,textDecoration:"underline"},{tag:X.strikethrough,textDecoration:"line-through"},{tag:X.invalid,color:"#cb2431"}],dS=i=>{var{theme:e="light",settings:t={},styles:n=[]}={};return zm({theme:e,settings:Ef({},hS,t),styles:[...fS,...n]})},pS=dS(),mS={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},gS=[{tag:[X.standard(X.tagName),X.tagName],color:"#7ee787"},{tag:[X.comment,X.bracket],color:"#8b949e"},{tag:[X.className,X.propertyName],color:"#d2a8ff"},{tag:[X.variableName,X.attributeName,X.number,X.operator],color:"#79c0ff"},{tag:[X.keyword,X.typeName,X.typeOperator,X.typeName],color:"#ff7b72"},{tag:[X.string,X.meta,X.regexp],color:"#a5d6ff"},{tag:[X.name,X.quote],color:"#7ee787"},{tag:[X.heading,X.strong],color:"#d2a8ff",fontWeight:"bold"},{tag:[X.emphasis],color:"#d2a8ff",fontStyle:"italic"},{tag:[X.deleted],color:"#ffdcd7",backgroundColor:"ffeef0"},{tag:[X.atom,X.bool,X.special(X.variableName)],color:"#ffab70"},{tag:X.link,textDecoration:"underline"},{tag:X.strikethrough,textDecoration:"line-through"},{tag:X.invalid,color:"#f97583"}],bS=i=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return zm({theme:e,settings:Ef({},mS,t),styles:[...gS,...n]})},yS=bS(),wS=["true","false","on","off","yes","no"],vS=new RegExp("\\b(("+wS.join(")|(")+"))$","i");const kS={name:"yaml",token:function(i,e){var t=i.peek(),n=e.escaped;if(e.escaped=!1,t=="#"&&(i.pos==0||/\s/.test(i.string.charAt(i.pos-1))))return i.skipToEnd(),"comment";if(i.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(e.literal&&i.indentation()>e.keyCol)return i.skipToEnd(),"string";if(e.literal&&(e.literal=!1),i.sol()){if(e.keyCol=0,e.pair=!1,e.pairStart=!1,i.match("---")||i.match("..."))return"def";if(i.match(/^\s*-\s+/))return"meta"}if(i.match(/^(\{|\}|\[|\])/))return t=="{"?e.inlinePairs++:t=="}"?e.inlinePairs--:t=="["?e.inlineList++:e.inlineList--,"meta";if(e.inlineList>0&&!n&&t==",")return i.next(),"meta";if(e.inlinePairs>0&&!n&&t==",")return e.keyCol=0,e.pair=!1,e.pairStart=!1,i.next(),"meta";if(e.pairStart){if(i.match(/^\s*(\||\>)\s*/))return e.literal=!0,"meta";if(i.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable";if(e.inlinePairs==0&&i.match(/^\s*-?[0-9\.\,]+\s?$/)||e.inlinePairs>0&&i.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(i.match(vS))return"keyword"}return!e.pair&&i.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(e.pair=!0,e.keyCol=i.indentation(),"atom"):e.pair&&i.match(/^:\s*/)?(e.pairStart=!0,"meta"):(e.pairStart=!1,e.escaped=t=="\\",i.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},languageData:{commentTokens:{line:"#"}}};var ff={};class ll{constructor(e,t,n,s,r,o,l,a,c,u=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=u,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let s=e.parser.context;return new ll(e,[],t,n,n,0,[],0,s?new df(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,s=e&65535,{parser:r}=this.p,o=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(s,c)}storeNode(e,t,n,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==n)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=n;return}}}if(!r||this.pos==n)this.buffer.push(e,t,n,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>n;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=s}}shift(e,t,n,s){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=s,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,s,4);else{let r=e,{parser:o}=this.p;(s>this.pos||t<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,s,4)}}apply(e,t,n,s){e&65536?this.reduce(e):this.shift(e,t,n,s)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(n,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new ll(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new xS(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;ra&1&&l==o)||s.push(t[r],o)}t=s}let n=[];for(let s=0;s>19,s=t&65535,r=this.stack.length-n*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=n(o,r+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class df{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class xS{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class al{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new al(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new al(this.stack,this.pos,this.index)}}function xo(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,s=0;n=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Ro{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const pf=new Ro;class SS{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=pf,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,s=this.rangeIndex,r=this.pos+e;for(;rn.to:r>=n.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-n.to,n=o}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,s;if(t>=0&&t=this.chunk2Pos&&nl.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),s=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),s}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=pf,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(n+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return n}}class $s{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;CS(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}$s.prototype.contextual=$s.prototype.fallback=$s.prototype.extend=!1;$s.prototype.fallback=$s.prototype.extend=!1;function CS(i,e,t,n,s,r){let o=0,l=1<0){let p=i[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||AS(p,e.token.value,s,r))){e.acceptToken(p);break}}let u=e.next,h=0,f=i[o+2];if(e.next<0&&f>h&&i[c+f*3-3]==65535){o=i[c+f*3-1];continue e}for(;h>1,p=c+d+(d<<1),y=i[p],b=i[p+1]||65536;if(u=b)h=d+1;else{o=i[p+2],e.advance();continue e}}break}}function mf(i,e,t){for(let n=e,s;(s=i[n])!=65535;n++)if(s==t)return n-e;return-1}function AS(i,e,t,n){let s=mf(t,n,e);return s<0||mf(t,n,i)e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}class TS{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?gf(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?gf(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(r instanceof Tt){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class MS{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Ro)}getActions(e){let t=0,n=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;ch.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let f=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!u.extend&&(n=h,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Ro,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ro,{pos:n,p:s}=e;return t.start=n,t.end=Math.min(n+1,s.stream.end),t.value=n==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,n){let s=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(s,e),n),e.value>-1){let{parser:r}=n.p;for(let o=0;o=0&&n.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,n,s){for(let r=0;re.bufferLength*4?new TS(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)n.push(l);else{if(this.advanceStack(l,n,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!n.length){let o=s&&ES(s);if(o)return this.stackToTree(o);if(this.parser.strict)throw new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,n);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((l,a)=>a.score-l.score);n.length>o;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(s);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?r.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!c||(h.prop(ot.contextHash)||0)==u))return e.useNode(h,f),!0;if(!(h instanceof Tt)||h.children.length==0||h.positions[0]>0)break;let d=h.children[0];if(d instanceof Tt&&h.positions[0]==0)h=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;cs?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return bf(e,t),!0}}runRecovery(e,t,n){let s=null,r=!1;for(let o=0;o ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),this.advanceFully(l,n))))continue;let h=l.split(),f=u;for(let d=0;h.forceReduce()&&d<10&&!this.advanceFully(h,n);d++)Pn&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))this.advanceFully(d,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),bf(l,n)):(!s||s.scoree.topRules[l][1]),s=[];for(let l=0;l=0)r(u,a,l[c++]);else{let h=l[c+-u];for(let f=-u;f>0;f--)r(l[c++],a,h);c++}}}this.nodeSet=new bl(t.map((l,a)=>yn.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=op;let o=xo(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new $s(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let s=new DS(this,e,t,n);for(let r of this.wrappers)s=r(s,e,t,n);return s}getGoto(e,t,n=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&n)return a;for(let c=r+(o>>1);r0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),s=n?t(n):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=yi(this.data,r+2);else break;s=t(yi(this.data,r+1))}return s}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=yi(this.data,n+2);else break;if(!(this.data[n+2]&1)){let s=this.data[n+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[n],s)}}return t}configure(e){let t=Object.assign(Object.create(cl.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let s=e.tokenizers.find(r=>r.from==n);return s?s.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,s)=>{let r=e.specializers.find(l=>l.from==n.external);if(!r)return n;let o=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[s]=yf(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(n[o]=!0)}let s=null;for(let r=0;rn)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorei.external(t,n)<<1|e}return i.get}const FS=up({String:X.string,Number:X.number,"True False":X.bool,PropertyName:X.propertyName,Null:X.null,",":X.separator,"[ ]":X.squareBracket,"{ }":X.brace}),PS=cl.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[FS],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),BS=Yo.define({name:"json",parser:PS.configure({props:[gp.add({Object:Nh({except:/^\s*\}/}),Array:Nh({except:/^\s*\]/})}),yp.add({"Object Array":Lv})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function RS(){return new Tv(BS)}const NS={class:"h-full"},IS=Gt({__name:"CodeEditor",props:{value:{type:[Object,String]},mode:{type:String,default:Ds.JSON,validator(i){return Object.values(Ds).includes(i)}},autoFormat:{type:Boolean,default:!0}},emits:["change","update:value","format-error"],setup(i,{emit:e}){const t=i,n=ze("");Fg(()=>{n.value=t.value});const s=e,o=Cf().getDarkMode;let l=[];switch(o==="dark"?l.push(yS):l.push(pS),t.mode){case Ds.YAML:{l.push(Sc.define(kS));break}case Ds.JSON:l.push(RS())}function a(c){t.mode==Ds.JSON&&(c=c.replace(/(\r\n|\n|\r)/gm,"")),s("update:value",c),s("change",c)}return(c,u)=>(it(),dn("div",NS,[rt(Y(uS),{"model-value":n.value,"onUpdate:modelValue":u[0]||(u[0]=h=>n.value=h),onChange:a,extensions:Y(l),autofocus:!0,"indent-with-tab":!0,"tab-size":2},null,8,["model-value","extensions"])]))}}),LS=Af(IS);(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager"),e=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),t=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=L=>se=>se.options.get(L),s=L=>{const se=L.options.register;se("allow_html_in_named_anchor",{processor:"boolean",default:!1})},r=n("allow_html_in_named_anchor"),o="a:not([href])",l=L=>!L,a=L=>L.getAttribute("id")||L.getAttribute("name")||"",c=L=>L.nodeName.toLowerCase()==="a",u=L=>c(L)&&!L.getAttribute("href")&&a(L)!=="",h=L=>u(L)&&!L.firstChild,f=L=>{const se=L.dom;e(se).walk(L.selection.getRng(),R=>{t.each(R,ee=>{h(ee)&&se.remove(ee,!1)})})},d=L=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(L),p=L=>L.dom.getParent(L.selection.getStart(),o),y=L=>{const se=p(L);return se?a(se):""},b=(L,se)=>{L.undoManager.transact(()=>{r(L)||L.selection.collapse(!0),L.selection.isCollapsed()?L.insertContent(L.dom.createHTML("a",{id:se})):(f(L),L.formatter.remove("namedAnchor",void 0,void 0,!0),L.formatter.apply("namedAnchor",{value:se}),L.addVisual())})},m=(L,se,R)=>{R.removeAttribute("name"),R.id=se,L.addVisual(),L.undoManager.add()},x=(L,se)=>{const R=p(L);R?m(L,se,R):b(L,se),L.focus()},v=(L,se)=>d(se)?(x(L,se),!0):(L.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1),P=L=>{const se=y(L);L.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:se},onSubmit:R=>{v(L,R.getData().id)&&R.close()}})},O=L=>{L.addCommand("mceAnchor",()=>{P(L)})},D=L=>l(L.attr("href"))&&!l(L.attr("id")||L.attr("name")),F=L=>D(L)&&!L.firstChild,T=L=>se=>{for(let R=0;R{L.on("PreInit",()=>{L.parser.addNodeFilter("a",T("false")),L.serializer.addNodeFilter("a",T(null))})},W=L=>{L.formatter.register("namedAnchor",{inline:"a",selector:o,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(se,R,ee)=>u(se)})},V=L=>se=>{const R=()=>{se.setEnabled(L.selection.isEditable())};return L.on("NodeChange",R),R(),()=>{L.off("NodeChange",R)}},Q=L=>{const se=()=>L.execCommand("mceAnchor");L.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:se,onSetup:R=>{const ee=L.selection.selectorChangedWithUnbind("a:not([href])",R.setActive).unbind,$=V(L)(R);return()=>{ee(),$()}}}),L.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:se,onSetup:V(L)})};var ce=()=>{i.add("anchor",L=>{s(L),M(L),O(L),Q(L),L.on("PreInit",()=>{W(L)})})};ce()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=($,ne,ue)=>{var z;return ue($,ne.prototype)?!0:((z=$.constructor)===null||z===void 0?void 0:z.name)===ne.name},t=$=>{const ne=typeof $;return $===null?"null":ne==="object"&&Array.isArray($)?"array":ne==="object"&&e($,String,(ue,z)=>z.isPrototypeOf(ue))?"string":ne},n=$=>ne=>t(ne)===$,s=$=>ne=>$===ne,r=n("string"),o=s(void 0);var l=tinymce.util.Tools.resolve("tinymce.util.Delay"),a=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),c=tinymce.util.Tools.resolve("tinymce.util.Tools");const u=$=>$.dispatch("RestoreDraft"),h=$=>$.dispatch("StoreDraft"),f=$=>$.dispatch("RemoveDraft"),d=$=>{const ne={s:1e3,m:6e4},ue=/^(\d+)([ms]?)$/.exec($);return(ue&&ue[2]?ne[ue[2]]:1)*parseInt($,10)},p=$=>ne=>ne.options.get($),y=$=>{const ne=$.options.register,ue=z=>{const G=r(z);return G?{value:d(z),valid:G}:{valid:!1,message:"Must be a string."}};ne("autosave_ask_before_unload",{processor:"boolean",default:!0}),ne("autosave_prefix",{processor:"string",default:"tinymce-autosave-{path}{query}{hash}-{id}-"}),ne("autosave_restore_when_empty",{processor:"boolean",default:!1}),ne("autosave_interval",{processor:ue,default:"30s"}),ne("autosave_retention",{processor:ue,default:"20m"})},b=p("autosave_ask_before_unload"),m=p("autosave_restore_when_empty"),x=p("autosave_interval"),v=p("autosave_retention"),P=$=>{const ne=document.location;return $.options.get("autosave_prefix").replace(/{path}/g,ne.pathname).replace(/{query}/g,ne.search).replace(/{hash}/g,ne.hash).replace(/{id}/g,$.id)},O=($,ne)=>{if(o(ne))return $.dom.isEmpty($.getBody());{const ue=c.trim(ne);if(ue==="")return!0;{const z=new DOMParser().parseFromString(ue,"text/html");return $.dom.isEmpty(z)}}},D=$=>{var ne;const ue=parseInt((ne=a.getItem(P($)+"time"))!==null&&ne!==void 0?ne:"0",10)||0;return new Date().getTime()-ue>v($)?(F($,!1),!1):!0},F=($,ne)=>{const ue=P($);a.removeItem(ue+"draft"),a.removeItem(ue+"time"),ne!==!1&&f($)},T=$=>{const ne=P($);!O($)&&$.isDirty()&&(a.setItem(ne+"draft",$.getContent({format:"raw",no_events:!0})),a.setItem(ne+"time",new Date().getTime().toString()),h($))},M=$=>{var ne;const ue=P($);D($)&&($.setContent((ne=a.getItem(ue+"draft"))!==null&&ne!==void 0?ne:"",{format:"raw"}),u($))},W=$=>{const ne=x($);l.setEditorInterval($,()=>{T($)},ne)},V=$=>{$.undoManager.transact(()=>{M($),F($)}),$.focus()},Q=$=>({hasDraft:()=>D($),storeDraft:()=>T($),restoreDraft:()=>M($),removeDraft:ne=>F($,ne),isEmpty:ne=>O($,ne)});var ce=tinymce.util.Tools.resolve("tinymce.EditorManager");const L=$=>{$.editorManager.on("BeforeUnload",ne=>{let ue;c.each(ce.get(),z=>{z.plugins.autosave&&z.plugins.autosave.storeDraft(),!ue&&z.isDirty()&&b(z)&&(ue=z.translate("You have unsaved changes are you sure you want to navigate away?"))}),ue&&(ne.preventDefault(),ne.returnValue=ue)})},se=$=>ne=>{ne.setEnabled(D($));const ue=()=>ne.setEnabled(D($));return $.on("StoreDraft RestoreDraft RemoveDraft",ue),()=>$.off("StoreDraft RestoreDraft RemoveDraft",ue)},R=$=>{W($);const ne=()=>{V($)};$.ui.registry.addButton("restoredraft",{tooltip:"Restore last draft",icon:"restore-draft",onAction:ne,onSetup:se($)}),$.ui.registry.addMenuItem("restoredraft",{text:"Restore last draft",icon:"restore-draft",onAction:ne,onSetup:se($)})};var ee=()=>{i.add("autosave",$=>(y($),L($),R($),$.on("init",()=>{m($)&&$.dom.isEmpty($.getBody())&&M($)}),Q($)))};ee()})();(function(){const i=v=>{let P=v;return{get:()=>P,set:F=>{P=F}}};var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=v=>()=>v;var n=tinymce.util.Tools.resolve("tinymce.Env");const s=v=>v.dispatch("ResizeEditor"),r=v=>P=>P.options.get(v),o=v=>{const P=v.options.register;P("autoresize_overflow_padding",{processor:"number",default:1}),P("autoresize_bottom_margin",{processor:"number",default:50})},l=r("min_height"),a=r("max_height"),c=r("autoresize_overflow_padding"),u=r("autoresize_bottom_margin"),h=v=>v.plugins.fullscreen&&v.plugins.fullscreen.isFullscreen(),f=(v,P)=>{const O=v.getBody();O&&(O.style.overflowY=P?"":"hidden",P||(O.scrollTop=0))},d=(v,P,O,D)=>{var F;const T=parseInt((F=v.getStyle(P,O,D))!==null&&F!==void 0?F:"",10);return isNaN(T)?0:T},p=v=>{if((v==null?void 0:v.type.toLowerCase())==="setcontent"){const P=v;return P.selection===!0||P.paste===!0}else return!1},y=(v,P,O,D)=>{var F;const T=v.dom,M=v.getDoc();if(!M)return;if(h(v)){f(v,!0);return}const W=M.documentElement,V=D?D():c(v),Q=(F=l(v))!==null&&F!==void 0?F:v.getElement().offsetHeight;let ce=Q;const L=d(T,W,"margin-top",!0),se=d(T,W,"margin-bottom",!0);let R=W.offsetHeight+L+se+V;R<0&&(R=0);const ee=v.getContainer().offsetHeight,$=v.getContentAreaContainer().offsetHeight,ne=ee-$;R+ne>Q&&(ce=R+ne);const ue=a(v);if(ue&&ce>ue?(ce=ue,f(v,!0)):f(v,!1),ce!==P.get()){const z=ce-P.get();if(T.setStyle(v.getContainer(),"height",ce+"px"),P.set(ce),s(v),n.browser.isSafari()&&(n.os.isMacOS()||n.os.isiOS())){const G=v.getWin();G.scrollTo(G.pageXOffset,G.pageYOffset)}v.hasFocus()&&p(O)&&v.selection.scrollIntoView(),(n.browser.isSafari()||n.browser.isChromium())&&z<0&&y(v,P,O,D)}},b=(v,P)=>{let O=()=>u(v),D,F;v.on("init",T=>{D=0;const M=c(v),W=v.dom;W.setStyles(v.getDoc().documentElement,{height:"auto"}),n.browser.isEdge()||n.browser.isIE()?W.setStyles(v.getBody(),{paddingLeft:M,paddingRight:M,"min-height":0}):W.setStyles(v.getBody(),{paddingLeft:M,paddingRight:M}),y(v,P,T,O),D+=1}),v.on("NodeChange SetContent keyup FullscreenStateChanged ResizeContent",T=>{if(D===1)F=v.getContainer().offsetHeight,y(v,P,T,O),D+=1;else if(D===2){const M=F{v.addCommand("mceAutoResize",()=>{y(v,P)})};var x=()=>{e.add("autoresize",v=>{if(o(v),v.options.isSet("resize")||v.options.set("resize",!1),!v.inline){const P=i(0);m(v,P),b(v,P)}})};x()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(l,a)=>{l.focus(),l.undoManager.transact(()=>{l.setContent(a)}),l.selection.setCursorLocation(),l.nodeChanged()},t=l=>l.getContent({source_view:!0}),n=l=>{const a=t(l);l.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:a},onSubmit:c=>{e(l,c.getData().code),c.close()}})},s=l=>{l.addCommand("mceCodeEditor",()=>{n(l)})},r=l=>{const a=()=>l.execCommand("mceCodeEditor");l.ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:a}),l.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:a})};var o=()=>{i.add("code",l=>(s(l),r(l),{}))};o()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=R=>R==null,t=R=>!e(R),n=()=>{},s=R=>()=>R;class r{constructor(ee,$){this.tag=ee,this.value=$}static some(ee){return new r(!0,ee)}static none(){return r.singletonNone}fold(ee,$){return this.tag?$(this.value):ee()}isSome(){return this.tag}isNone(){return!this.tag}map(ee){return this.tag?r.some(ee(this.value)):r.none()}bind(ee){return this.tag?ee(this.value):r.none()}exists(ee){return this.tag&&ee(this.value)}forall(ee){return!this.tag||ee(this.value)}filter(ee){return!this.tag||ee(this.value)?this:r.none()}getOr(ee){return this.tag?this.value:ee}or(ee){return this.tag?this:ee}getOrThunk(ee){return this.tag?this.value:ee()}orThunk(ee){return this.tag?this:ee()}getOrDie(ee){if(this.tag)return this.value;throw new Error(ee!=null?ee:"Called getOrDie on None")}static from(ee){return t(ee)?r.some(ee):r.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(ee){this.tag&&ee(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}r.singletonNone=new r(!1);const o=(R,ee)=>ee>=0&&eeo(R,0);var a=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");const c=typeof window!="undefined"?window:Function("return this;")(),u=function(R,ee,$){const ne=window.Prism;window.Prism={manual:!0};var ue=typeof window!="undefined"?window:typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope?self:{},z=function(G){var be=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,we=0,Ie={},ve={manual:G.Prism&&G.Prism.manual,disableWorkerMessageHandler:G.Prism&&G.Prism.disableWorkerMessageHandler,util:{encode:function j(te){return te instanceof je?new je(te.type,j(te.content),te.alias):Array.isArray(te)?te.map(j):te.replace(/&/g,"&").replace(/"+fe.content+""};function st(j,te,le,he){j.lastIndex=te;var fe=j.exec(le);if(fe&&he&&fe[1]){var E=fe[1].length;fe.index+=E,fe[0]=fe[0].slice(E)}return fe}function Je(j,te,le,he,fe,E){for(var I in le)if(!(!le.hasOwnProperty(I)||!le[I])){var Z=le[I];Z=Array.isArray(Z)?Z:[Z];for(var xe=0;xe=E.reach);ke+=ie.value.length,ie=ie.next){var Le=ie.value;if(te.length>j.length)return;if(!(Le instanceof je)){var tt=1,We;if(kt){if(We=st(re,ke,j,bt),!We||We.index>=j.length)break;var Wt=We.index,lt=We.index+We[0].length,wt=ke;for(wt+=ie.value.length;Wt>=wt;)ie=ie.next,wt+=ie.value.length;if(wt-=ie.value.length,ke=wt,ie.value instanceof je)continue;for(var ut=ie;ut!==te.tail&&(wtE.reach&&(E.reach=on);var Dn=ie.prev;Mn&&(Dn=Xe(te,Dn,Mn),ke+=Mn.length),Lt(te,Dn,tt);var ti=new je(I,He?ve.tokenize(Qt,He):Qt,Nt,Qt);if(ie=Xe(te,Dn,ti),ei&&Xe(te,ie,ei),tt>1){var In={cause:I+","+xe,reach:on};Je(j,te,le,ie.prev,ke,In),E&&In.reach>E.reach&&(E.reach=In.reach)}}}}}}function pt(){var j={value:null,prev:null,next:null},te={value:null,prev:j,next:null};j.next=te,this.head=j,this.tail=te,this.length=0}function Xe(j,te,le){var he=te.next,fe={value:le,prev:te,next:he};return te.next=fe,he.prev=fe,j.length++,fe}function Lt(j,te,le){for(var he=te.next,fe=0;fe]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},function(G){function be(we,Ie){return"___"+we.toUpperCase()+Ie+"___"}Object.defineProperties(G.languages["markup-templating"]={},{buildPlaceholders:{value:function(we,Ie,ve,je){if(we.language===Ie){var st=we.tokenStack=[];we.code=we.code.replace(ve,function(Je){if(typeof je=="function"&&!je(Je))return Je;for(var pt=st.length,Xe;we.code.indexOf(Xe=be(Ie,pt))!==-1;)++pt;return st[pt]=Je,Xe}),we.grammar=G.languages.markup}}},tokenizePlaceholders:{value:function(we,Ie){if(we.language!==Ie||!we.tokenStack)return;we.grammar=G.languages[Ie];var ve=0,je=Object.keys(we.tokenStack);function st(Je){for(var pt=0;pt=je.length);pt++){var Xe=Je[pt];if(typeof Xe=="string"||Xe.content&&typeof Xe.content=="string"){var Lt=je[ve],Mt=we.tokenStack[Lt],oe=typeof Xe=="string"?Xe:Xe.content,ye=be(Ie,Lt),de=oe.indexOf(ye);if(de>-1){++ve;var j=oe.substring(0,de),te=new G.Token(Ie,G.tokenize(Mt,we.grammar),"language-"+Ie,Mt),le=oe.substring(de+ye.length),he=[];j&&he.push.apply(he,st([j])),he.push(te),le&&he.push.apply(he,st([le])),typeof Xe=="string"?Je.splice.apply(Je,[pt,1].concat(he)):Xe.content=he}}else Xe.content&&st(Xe.content)}return Je}st(we.tokens)}}})}(z),z.languages.c=z.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),z.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),z.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},z.languages.c.string],char:z.languages.c.char,comment:z.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:z.languages.c}}}}),z.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete z.languages.c.boolean,function(G){var be=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,we=/\b(?!)\w+(?:\s*\.\s*\w+)*\b/.source.replace(//g,function(){return be.source});G.languages.cpp=G.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!)\w+/.source.replace(//g,function(){return be.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:be,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),G.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/(?:\s*:\s*)?|:\s*/.source.replace(//g,function(){return we})+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),G.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:G.languages.cpp}}}}),G.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),G.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:G.languages.extend("cpp",{})}}),G.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},G.languages.cpp["base-clause"])}(z),function(G){function be(We,lt){return We.replace(/<<(\d+)>>/g,function(wt,ut){return"(?:"+lt[+ut]+")"})}function we(We,lt,wt){return RegExp(be(We,lt),"")}function Ie(We,lt){for(var wt=0;wt>/g,function(){return"(?:"+We+")"});return We.replace(/<>/g,"[^\\s\\S]")}var ve={type:"bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",typeDeclaration:"class enum interface record struct",contextual:"add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",other:"abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield"};function je(We){return"\\b(?:"+We.trim().replace(/ /g,"|")+")\\b"}var st=je(ve.typeDeclaration),Je=RegExp(je(ve.type+" "+ve.typeDeclaration+" "+ve.contextual+" "+ve.other)),pt=je(ve.typeDeclaration+" "+ve.contextual+" "+ve.other),Xe=je(ve.type+" "+ve.typeDeclaration+" "+ve.other),Lt=Ie(/<(?:[^<>;=+\-*/%&|^]|<>)*>/.source,2),Mt=Ie(/\((?:[^()]|<>)*\)/.source,2),oe=/@?\b[A-Za-z_]\w*\b/.source,ye=be(/<<0>>(?:\s*<<1>>)?/.source,[oe,Lt]),de=be(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source,[pt,ye]),j=/\[\s*(?:,\s*)*\]/.source,te=be(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source,[de,j]),le=be(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source,[Lt,Mt,j]),he=be(/\(<<0>>+(?:,<<0>>+)+\)/.source,[le]),fe=be(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source,[he,de,j]),E={keyword:Je,punctuation:/[<>()?,.:[\]]/},I=/'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source,Z=/"(?:\\.|[^\\"\r\n])*"/.source,xe=/@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;G.languages.csharp=G.languages.extend("clike",{string:[{pattern:we(/(^|[^$\\])<<0>>/.source,[xe]),lookbehind:!0,greedy:!0},{pattern:we(/(^|[^@$\\])<<0>>/.source,[Z]),lookbehind:!0,greedy:!0}],"class-name":[{pattern:we(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source,[de]),lookbehind:!0,inside:E},{pattern:we(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source,[oe,fe]),lookbehind:!0,inside:E},{pattern:we(/(\busing\s+)<<0>>(?=\s*=)/.source,[oe]),lookbehind:!0},{pattern:we(/(\b<<0>>\s+)<<1>>/.source,[st,ye]),lookbehind:!0,inside:E},{pattern:we(/(\bcatch\s*\(\s*)<<0>>/.source,[de]),lookbehind:!0,inside:E},{pattern:we(/(\bwhere\s+)<<0>>/.source,[oe]),lookbehind:!0},{pattern:we(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source,[te]),lookbehind:!0,inside:E},{pattern:we(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source,[fe,Xe,oe]),inside:E}],keyword:Je,number:/(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,operator:/>>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,punctuation:/\?\.?|::|[{}[\];(),.:]/}),G.languages.insertBefore("csharp","number",{range:{pattern:/\.\./,alias:"operator"}}),G.languages.insertBefore("csharp","punctuation",{"named-parameter":{pattern:we(/([(,]\s*)<<0>>(?=\s*:)/.source,[oe]),lookbehind:!0,alias:"punctuation"}}),G.languages.insertBefore("csharp","class-name",{namespace:{pattern:we(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source,[oe]),lookbehind:!0,inside:{punctuation:/\./}},"type-expression":{pattern:we(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source,[Mt]),lookbehind:!0,alias:"class-name",inside:E},"return-type":{pattern:we(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source,[fe,de]),inside:E,alias:"class-name"},"constructor-invocation":{pattern:we(/(\bnew\s+)<<0>>(?=\s*[[({])/.source,[fe]),lookbehind:!0,inside:E,alias:"class-name"},"generic-method":{pattern:we(/<<0>>\s*<<1>>(?=\s*\()/.source,[oe,Lt]),inside:{function:we(/^<<0>>/.source,[oe]),generic:{pattern:RegExp(Lt),alias:"class-name",inside:E}}},"type-list":{pattern:we(/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,[st,ye,oe,fe,Je.source,Mt,/\bnew\s*\(\s*\)/.source]),lookbehind:!0,inside:{"record-arguments":{pattern:we(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source,[ye,Mt]),lookbehind:!0,greedy:!0,inside:G.languages.csharp},keyword:Je,"class-name":{pattern:RegExp(fe),greedy:!0,inside:E},punctuation:/[,()]/}},preprocessor:{pattern:/(^[\t ]*)#.*/m,lookbehind:!0,alias:"property",inside:{directive:{pattern:/(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,lookbehind:!0,alias:"keyword"}}}});var $e=Z+"|"+I,He=be(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source,[$e]),bt=Ie(be(/[^"'/()]|<<0>>|\(<>*\)/.source,[He]),2),kt=/\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source,Nt=be(/<<0>>(?:\s*\(<<1>>*\))?/.source,[de,bt]);G.languages.insertBefore("csharp","class-name",{attribute:{pattern:we(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source,[kt,Nt]),lookbehind:!0,greedy:!0,inside:{target:{pattern:we(/^<<0>>(?=\s*:)/.source,[kt]),alias:"keyword"},"attribute-arguments":{pattern:we(/\(<<0>>*\)/.source,[bt]),inside:G.languages.csharp},"class-name":{pattern:RegExp(de),inside:{punctuation:/\./}},punctuation:/[:,]/}}});var q=/:[^}\r\n]+/.source,re=Ie(be(/[^"'/()]|<<0>>|\(<>*\)/.source,[He]),2),ie=be(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[re,q]),ke=Ie(be(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<>*\)/.source,[$e]),2),Le=be(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[ke,q]);function tt(We,lt){return{interpolation:{pattern:we(/((?:^|[^{])(?:\{\{)*)<<0>>/.source,[We]),lookbehind:!0,inside:{"format-string":{pattern:we(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source,[lt,q]),lookbehind:!0,inside:{punctuation:/^:/}},punctuation:/^\{|\}$/,expression:{pattern:/[\s\S]+/,alias:"language-csharp",inside:G.languages.csharp}}},string:/[\s\S]+/}}G.languages.insertBefore("csharp","string",{"interpolation-string":[{pattern:we(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source,[ie]),lookbehind:!0,greedy:!0,inside:tt(ie,re)},{pattern:we(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source,[Le]),lookbehind:!0,greedy:!0,inside:tt(Le,ke)}],char:{pattern:RegExp(I),greedy:!0}}),G.languages.dotnet=G.languages.cs=G.languages.csharp}(z),function(G){var be=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;G.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+be.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+be.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+be.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+be.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:be,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},G.languages.css.atrule.inside.rest=G.languages.css;var we=G.languages.markup;we&&(we.tag.addInlined("style","css"),we.tag.addAttribute("style","css"))}(z),function(G){var be=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,we=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,Ie={pattern:RegExp(/(^|[^\w.])/.source+we+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};G.languages.java=G.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[Ie,{pattern:RegExp(/(^|[^\w.])/.source+we+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:Ie.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+we+/[A-Z]\w*\b/.source),lookbehind:!0,inside:Ie.inside}],keyword:be,function:[G.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),G.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),G.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":Ie,keyword:be,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+we+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:Ie.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+we+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:Ie.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return be.source})),lookbehind:!0,inside:{punctuation:/\./}}})}(z),z.languages.javascript=z.languages.extend("clike",{"class-name":[z.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),z.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,z.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:z.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:z.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:z.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:z.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:z.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),z.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:z.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),z.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),z.languages.markup&&(z.languages.markup.tag.addInlined("script","javascript"),z.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),z.languages.js=z.languages.javascript,z.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},z.languages.markup.tag.inside["attr-value"].inside.entity=z.languages.markup.entity,z.languages.markup.doctype.inside["internal-subset"].inside=z.languages.markup,z.hooks.add("wrap",function(G){G.type==="entity"&&(G.attributes.title=G.content.replace(/&/,"&"))}),Object.defineProperty(z.languages.markup.tag,"addInlined",{value:function(be,we){var Ie={};Ie["language-"+we]={pattern:/(^$)/i,lookbehind:!0,inside:z.languages[we]},Ie.cdata=/^$/i;var ve={"included-cdata":{pattern://i,inside:Ie}};ve["language-"+we]={pattern:/[\s\S]+/,inside:z.languages[we]};var je={};je[be]={pattern:RegExp(/(<__[^>]*>)(?:))*\]\]>|(?!)/.source.replace(/__/g,function(){return be}),"i"),lookbehind:!0,greedy:!0,inside:ve},z.languages.insertBefore("markup","cdata",je)}}),Object.defineProperty(z.languages.markup.tag,"addAttribute",{value:function(G,be){z.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+G+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[be,"language-"+be],inside:z.languages[be]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),z.languages.html=z.languages.markup,z.languages.mathml=z.languages.markup,z.languages.svg=z.languages.markup,z.languages.xml=z.languages.extend("markup",{}),z.languages.ssml=z.languages.xml,z.languages.atom=z.languages.xml,z.languages.rss=z.languages.xml,function(G){var be=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,we=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],Ie=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,ve=/|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,je=/[{}\[\](),:;]/;G.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:be,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:we,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:Ie,operator:ve,punctuation:je};var st={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:G.languages.php},Je=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:st}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:st}}];G.languages.insertBefore("php","variable",{string:Je,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:be,string:Je,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:we,number:Ie,operator:ve,punctuation:je}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),G.hooks.add("before-tokenize",function(pt){if(/<\?/.test(pt.code)){var Xe=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;G.languages["markup-templating"].buildPlaceholders(pt,"php",Xe)}}),G.hooks.add("after-tokenize",function(pt){G.languages["markup-templating"].tokenizePlaceholders(pt,"php")})}(z),z.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},z.languages.python["string-interpolation"].inside.interpolation.inside.rest=z.languages.python,z.languages.py=z.languages.python,function(G){G.languages.ruby=G.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===||[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),G.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var be={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:G.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete G.languages.ruby.function;var we="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",Ie=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;G.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+we+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:be,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:be,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+Ie),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+Ie+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),G.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+we),greedy:!0,inside:{interpolation:be,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:be,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:be,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+we),greedy:!0,inside:{interpolation:be,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:be,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete G.languages.ruby.string,G.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),G.languages.rb=G.languages.ruby}(z),window.Prism=ne,z}(),h=R=>ee=>ee.options.get(R),f=R=>{const ee=R.options.register;ee("codesample_languages",{processor:"object[]"}),ee("codesample_global_prismjs",{processor:"boolean",default:!1})},d=h("codesample_languages"),p=h("codesample_global_prismjs"),y=R=>c.Prism&&p(R)?c.Prism:u,b=R=>t(R)&&R.nodeName==="PRE"&&R.className.indexOf("language-")!==-1,m=R=>{const ee=R.selection?R.selection.getNode():null;return b(ee)?r.some(ee):r.none()},x=(R,ee,$)=>{const ne=R.dom;R.undoManager.transact(()=>{const ue=m(R);return $=a.DOM.encode($),ue.fold(()=>{R.insertContent('
'+$+"
");const z=ne.select("#__new")[0];ne.setAttrib(z,"id",null),R.selection.select(z)},z=>{ne.setAttrib(z,"class","language-"+ee),z.innerHTML=$,y(R).highlightElement(z),R.selection.select(z)})})},v=R=>m(R).bind($=>r.from($.textContent)).getOr(""),P=R=>{const ee=[{text:"HTML/XML",value:"markup"},{text:"JavaScript",value:"javascript"},{text:"CSS",value:"css"},{text:"PHP",value:"php"},{text:"Ruby",value:"ruby"},{text:"Python",value:"python"},{text:"Java",value:"java"},{text:"C",value:"c"},{text:"C#",value:"csharp"},{text:"C++",value:"cpp"}],$=d(R);return $||ee},O=(R,ee)=>m(R).fold(()=>ee,ne=>{const ue=ne.className.match(/language-(\w+)/);return ue?ue[1]:ee}),D=R=>{const ee=P(R),$=l(ee).fold(s(""),z=>z.value),ne=O(R,$),ue=v(R);R.windowManager.open({title:"Insert/Edit Code Sample",size:"large",body:{type:"panel",items:[{type:"listbox",name:"language",label:"Language",items:ee},{type:"textarea",name:"code",label:"Code view"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{language:ne,code:ue},onSubmit:z=>{const G=z.getData();x(R,G.language,G.code),z.close()}})},F=R=>{R.addCommand("codesample",()=>{const ee=R.selection.getNode();R.selection.isCollapsed()||b(ee)?D(R):R.formatter.toggle("code")})},M=(R=>ee=>ee.replace(R,""))(/^\s+|\s+$/g);var W=tinymce.util.Tools.resolve("tinymce.util.Tools");const V=R=>{R.on("PreProcess",ee=>{const $=R.dom,ne=$.select("pre[contenteditable=false]",ee.node);W.each(W.grep(ne,b),ue=>{const z=ue.textContent;$.setAttrib(ue,"class",M($.getAttrib(ue,"class"))),$.setAttrib(ue,"contentEditable",null),$.setAttrib(ue,"data-mce-highlighted",null);let G;for(;G=ue.firstChild;)ue.removeChild(G);const be=$.add(ue,"code");be.textContent=z})}),R.on("SetContent",()=>{const ee=R.dom,$=W.grep(ee.select("pre"),ne=>b(ne)&&ee.getAttrib(ne,"data-mce-highlighted")!=="true");$.length&&R.undoManager.transact(()=>{W.each($,ne=>{var ue;W.each(ee.select("br",ne),z=>{ee.replace(R.getDoc().createTextNode(` `),z)}),ne.innerHTML=ee.encode((ue=ne.textContent)!==null&&ue!==void 0?ue:""),y(R).highlightElement(ne),ee.setAttrib(ne,"data-mce-highlighted",!0),ne.className=M(ne.className)})})}),R.on("PreInit",()=>{R.parser.addNodeFilter("pre",ee=>{var $;for(let ne=0,ue=ee.length;ne$=>{const ne=()=>{$.setEnabled(R.selection.isEditable()),ee($)};return R.on("NodeChange",ne),ne(),()=>{R.off("NodeChange",ne)}},ce=R=>{const ee=R.selection.getStart();return R.dom.is(ee,'pre[class*="language-"]')},L=R=>{const ee=()=>R.execCommand("codesample");R.ui.registry.addToggleButton("codesample",{icon:"code-sample",tooltip:"Insert/edit code sample",onAction:ee,onSetup:Q(R,$=>{$.setActive(ce(R))})}),R.ui.registry.addMenuItem("codesample",{text:"Code sample...",icon:"code-sample",onAction:ee,onSetup:Q(R)})};var se=()=>{i.add("codesample",R=>{f(R),V(R),L(R),F(R),R.on("dblclick",ee=>{b(ee.target)&&D(R)})})};se()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(q,re,ie)=>{var ke;return ie(q,re.prototype)?!0:((ke=q.constructor)===null||ke===void 0?void 0:ke.name)===re.name},t=q=>{const re=typeof q;return q===null?"null":re==="object"&&Array.isArray(q)?"array":re==="object"&&e(q,String,(ie,ke)=>ke.isPrototypeOf(ie))?"string":re},n=q=>re=>t(re)===q,s=q=>re=>typeof re===q,r=n("string"),o=s("boolean"),l=q=>q==null,a=q=>!l(q),c=s("function"),u=s("number"),h=(q,re)=>ie=>q(re(ie)),d=(q=>()=>q)(!1);class p{constructor(re,ie){this.tag=re,this.value=ie}static some(re){return new p(!0,re)}static none(){return p.singletonNone}fold(re,ie){return this.tag?ie(this.value):re()}isSome(){return this.tag}isNone(){return!this.tag}map(re){return this.tag?p.some(re(this.value)):p.none()}bind(re){return this.tag?re(this.value):p.none()}exists(re){return this.tag&&re(this.value)}forall(re){return!this.tag||re(this.value)}filter(re){return!this.tag||re(this.value)?this:p.none()}getOr(re){return this.tag?this.value:re}or(re){return this.tag?this:re}getOrThunk(re){return this.tag?this.value:re()}orThunk(re){return this.tag?this:re()}getOrDie(re){if(this.tag)return this.value;throw new Error(re!=null?re:"Called getOrDie on None")}static from(re){return a(re)?p.some(re):p.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(re){this.tag&&re(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}p.singletonNone=new p(!1);const y=(q,re)=>{const ie=q.length,ke=new Array(ie);for(let Le=0;Le{for(let ie=0,ke=q.length;ie{const ie=[];for(let ke=0,Le=q.length;ke{const ke=(re||document).createElement("div");if(ke.innerHTML=q,!ke.hasChildNodes()||ke.childNodes.length>1){const Le="HTML does not have a single root node";throw new Error(Le)}return M(ke.childNodes[0])},F=(q,re)=>{const ke=(re||document).createElement(q);return M(ke)},T=(q,re)=>{const ke=(re||document).createTextNode(q);return M(ke)},M=q=>{if(q==null)throw new Error("Node cannot be null or undefined");return{dom:q}},V={fromHtml:D,fromTag:F,fromText:T,fromDom:M,fromPoint:(q,re,ie)=>p.from(q.dom.elementFromPoint(re,ie)).map(M)},Q=(q,re)=>{const ie=q.dom;if(ie.nodeType!==P)return!1;{const ke=ie;if(ke.matches!==void 0)return ke.matches(re);if(ke.msMatchesSelector!==void 0)return ke.msMatchesSelector(re);if(ke.webkitMatchesSelector!==void 0)return ke.webkitMatchesSelector(re);if(ke.mozMatchesSelector!==void 0)return ke.mozMatchesSelector(re);throw new Error("Browser lacks native selectors")}};typeof window!="undefined"||Function("return this;")();const ce=q=>q.dom.nodeName.toLowerCase(),L=q=>q.dom.nodeType,se=q=>re=>L(re)===q,R=se(P),ee=se(O),$=se(x),ne=se(v),ue=q=>re=>R(re)&&ce(re)===q,z=q=>V.fromDom(q.dom.ownerDocument),G=q=>$(q)?q:z(q),be=q=>p.from(q.dom.parentNode).map(V.fromDom),we=q=>y(q.dom.childNodes,V.fromDom),Ie=(q,re,ie)=>{if(r(ie)||o(ie)||u(ie))q.setAttribute(re,ie+"");else throw new Error("Attribute value was not simple")},ve=(q,re,ie)=>{Ie(q.dom,re,ie)},je=(q,re)=>{q.dom.removeAttribute(re)},st=q=>ne(q)&&a(q.dom.host),pt=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?q=>V.fromDom(q.dom.getRootNode()):G,Xe=q=>{const re=pt(q);return st(re)?p.some(re):p.none()},Lt=q=>V.fromDom(q.dom.host),Mt=q=>{const re=ee(q)?q.dom.parentNode:q.dom;if(re==null||re.ownerDocument===null)return!1;const ie=re.ownerDocument;return Xe(V.fromDom(re)).fold(()=>ie.body.contains(re),h(Mt,Lt))},oe=(q,re,ie)=>{let ke=q.dom;const Le=c(ie)?ie:d;for(;ke.parentNode;){ke=ke.parentNode;const tt=V.fromDom(ke);if(re(tt))return p.some(tt);if(Le(tt))break}return p.none()},ye=(q,re,ie)=>oe(q,ke=>Q(ke,re),ie),de=q=>q.style!==void 0&&c(q.style.getPropertyValue),j=(q,re)=>{const ie=q.dom,Le=window.getComputedStyle(ie).getPropertyValue(re);return Le===""&&!Mt(q)?te(ie,re):Le},te=(q,re)=>de(q)?q.style.getPropertyValue(re):"",le=q=>j(q,"direction")==="rtl"?"rtl":"ltr",he=(q,re)=>m(we(q),re),fe=(q,re)=>he(q,ie=>Q(ie,re)),E=q=>be(q).filter(R),I=(q,re)=>(re?ye(q,"ol,ul"):p.some(q)).getOr(q),Z=ue("li"),xe=(q,re,ie)=>{b(re,ke=>{const Le=V.fromDom(ke),tt=Z(Le),We=I(Le,tt);E(We).each(wt=>{if(q.setStyle(We.dom,"direction",null),le(wt)===ie?je(We,"dir"):ve(We,"dir",ie),le(We)!==ie&&q.setStyle(We.dom,"direction",ie),tt){const Wt=fe(We,"li[dir],li[style]");b(Wt,Qt=>{je(Qt,"dir"),q.setStyle(Qt.dom,"direction",null)})}})})},$e=(q,re)=>{q.selection.isEditable()&&(xe(q.dom,q.selection.getSelectedBlocks(),re),q.nodeChanged())},He=q=>{q.addCommand("mceDirectionLTR",()=>{$e(q,"ltr")}),q.addCommand("mceDirectionRTL",()=>{$e(q,"rtl")})},bt=(q,re)=>ie=>{const ke=Le=>{const tt=V.fromDom(Le.element);ie.setActive(le(tt)===re),ie.setEnabled(q.selection.isEditable())};return q.on("NodeChange",ke),ie.setEnabled(q.selection.isEditable()),()=>q.off("NodeChange",ke)},kt=q=>{q.ui.registry.addToggleButton("ltr",{tooltip:"Left to right",icon:"ltr",onAction:()=>q.execCommand("mceDirectionLTR"),onSetup:bt(q,"ltr")}),q.ui.registry.addToggleButton("rtl",{tooltip:"Right to left",icon:"rtl",onAction:()=>q.execCommand("mceDirectionRTL"),onSetup:bt(q,"rtl")})};var Nt=()=>{i.add("directionality",q=>{He(q),kt(q)})};Nt()})();(function(){const i=g=>{let w=g;return{get:()=>w,set:Ae=>{w=Ae}}};var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=g=>({isFullscreen:()=>g.get()!==null}),n=(g,w,N)=>{var K;return N(g,w.prototype)?!0:((K=g.constructor)===null||K===void 0?void 0:K.name)===w.name},s=g=>{const w=typeof g;return g===null?"null":w==="object"&&Array.isArray(g)?"array":w==="object"&&n(g,String,(N,K)=>K.isPrototypeOf(N))?"string":w},r=g=>w=>s(w)===g,o=g=>w=>typeof w===g,l=g=>w=>g===w,a=r("string"),c=r("object"),u=r("array"),h=l(null),f=o("boolean"),d=l(void 0),p=g=>g==null,y=g=>!p(g),b=o("function"),m=o("number"),x=()=>{},v=(g,w)=>(...N)=>g(w.apply(null,N)),P=(g,w)=>N=>g(w(N)),O=g=>()=>g;function D(g,...w){return(...N)=>{const K=w.concat(N);return g.apply(null,K)}}const F=O(!1),T=O(!0);class M{constructor(w,N){this.tag=w,this.value=N}static some(w){return new M(!0,w)}static none(){return M.singletonNone}fold(w,N){return this.tag?N(this.value):w()}isSome(){return this.tag}isNone(){return!this.tag}map(w){return this.tag?M.some(w(this.value)):M.none()}bind(w){return this.tag?w(this.value):M.none()}exists(w){return this.tag&&w(this.value)}forall(w){return!this.tag||w(this.value)}filter(w){return!this.tag||w(this.value)?this:M.none()}getOr(w){return this.tag?this.value:w}or(w){return this.tag?this:w}getOrThunk(w){return this.tag?this.value:w()}orThunk(w){return this.tag?this:w()}getOrDie(w){if(this.tag)return this.value;throw new Error(w!=null?w:"Called getOrDie on None")}static from(w){return y(w)?M.some(w):M.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(w){this.tag&&w(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}M.singletonNone=new M(!1);const W=Array.prototype.push,V=(g,w)=>{const N=g.length,K=new Array(N);for(let Ae=0;Ae{for(let N=0,K=g.length;N{const N=[];for(let K=0,Ae=g.length;K{for(let K=0,Ae=g.length;KL(g,w,F),R=g=>{const w=[];for(let N=0,K=g.length;NR(V(g,w)),$=(g,w)=>w>=0&&w$(g,0),ue=(g,w)=>{for(let N=0;Ng.isSome()&&w.isSome()?M.some(N(g.getOrDie(),w.getOrDie())):M.none(),G=g=>{const w=i(M.none()),N=()=>w.get().each(g);return{clear:()=>{N(),w.set(M.none())},isSet:()=>w.get().isSome(),get:()=>w.get(),set:hn=>{N(),w.set(M.some(hn))}}},be=()=>G(g=>g.unbind()),we=()=>{const g=G(x),w=N=>g.get().each(N);return qt(Pe({},g),{on:w})},Ie=(g,w)=>{let N=null;return{cancel:()=>{h(N)||(clearTimeout(N),N=null)},throttle:(...Ge)=>{h(N)&&(N=setTimeout(()=>{N=null,g.apply(null,Ge)},w))}}},ve=Object.keys,je=(g,w)=>{const N=ve(g);for(let K=0,Ae=N.length;K{let N=w!=null?w:st;for(let K=0;K{const N=g.split(".");return Je(N,w)},Xe=(g,w)=>pt(g,w),Lt=(g,w)=>{const N=Xe(g,w);if(N==null)throw new Error(g+" not available on this browser");return N},Mt=Object.getPrototypeOf,oe=g=>Lt("HTMLElement",g),ye=g=>{const w=pt("ownerDocument.defaultView",g);return c(g)&&(oe(w).prototype.isPrototypeOf(g)||/^HTML\w*Element$/.test(Mt(g).constructor.name))},de=9,j=11,te=1,le=3,he=g=>g.dom.nodeType,fe=g=>w=>he(w)===g,E=g=>I(g)&&ye(g.dom),I=fe(te),Z=fe(le),xe=fe(de),$e=fe(j),He=(g,w,N)=>{if(a(N)||f(N)||m(N))g.setAttribute(w,N+"");else throw new Error("Attribute value was not simple")},bt=(g,w,N)=>{He(g.dom,w,N)},kt=(g,w)=>{const N=g.dom.getAttribute(w);return N===null?void 0:N},Nt=(g,w)=>{g.dom.removeAttribute(w)},q=g=>g.dom.classList!==void 0,re=(g,w)=>q(g)&&g.dom.classList.contains(w),ie=(g,w,N=0,K)=>{const Ae=g.indexOf(w,N);return Ae!==-1?d(K)?!0:Ae+w.length<=K:!1},ke=g=>g.style!==void 0&&b(g.style.getPropertyValue),Le=(g,w)=>{const K=(w||document).createElement("div");if(K.innerHTML=g,!K.hasChildNodes()||K.childNodes.length>1){const Ae="HTML does not have a single root node";throw new Error(Ae)}return lt(K.childNodes[0])},tt=(g,w)=>{const K=(w||document).createElement(g);return lt(K)},We=(g,w)=>{const K=(w||document).createTextNode(g);return lt(K)},lt=g=>{if(g==null)throw new Error("Node cannot be null or undefined");return{dom:g}},ut={fromHtml:Le,fromTag:tt,fromText:We,fromDom:lt,fromPoint:(g,w,N)=>M.from(g.dom.elementFromPoint(w,N)).map(lt)},Wt=(g,w)=>{const N=g.dom;if(N.nodeType!==te)return!1;{const K=N;if(K.matches!==void 0)return K.matches(w);if(K.msMatchesSelector!==void 0)return K.msMatchesSelector(w);if(K.webkitMatchesSelector!==void 0)return K.webkitMatchesSelector(w);if(K.mozMatchesSelector!==void 0)return K.mozMatchesSelector(w);throw new Error("Browser lacks native selectors")}},Qt=g=>g.nodeType!==te&&g.nodeType!==de&&g.nodeType!==j||g.childElementCount===0,Mn=(g,w)=>{const N=document;return Qt(N)?[]:V(N.querySelectorAll(g),ut.fromDom)},ei=(g,w)=>g.dom===w.dom,on=g=>ut.fromDom(g.dom.ownerDocument),Dn=g=>xe(g)?g:on(g),ti=g=>M.from(g.dom.parentNode).map(ut.fromDom),In=(g,w)=>{const N=b(w)?w:F;let K=g.dom;const Ae=[];for(;K.parentNode!==null&&K.parentNode!==void 0;){const Ge=K.parentNode,Ot=ut.fromDom(Ge);if(Ae.push(Ot),N(Ot)===!0)break;K=Ge}return Ae},Kn=g=>{const w=N=>ce(N,K=>!ei(g,K));return ti(g).map(Ti).map(w).getOr([])},Ai=g=>M.from(g.dom.nextSibling).map(ut.fromDom),Ti=g=>V(g.dom.childNodes,ut.fromDom),ni=g=>$e(g)&&y(g.dom.host),B=b(Element.prototype.attachShadow)&&b(Node.prototype.getRootNode),_=O(B),me=B?g=>ut.fromDom(g.dom.getRootNode()):Dn,Oe=g=>{const w=me(g);return ni(w)?M.some(w):M.none()},Qe=g=>ut.fromDom(g.dom.host),$t=g=>{if(_()&&y(g.target)){const w=ut.fromDom(g.target);if(I(w)&&On(w)&&g.composed&&g.composedPath){const N=g.composedPath();if(N)return ne(N)}}return M.from(g.target)},On=g=>y(g.dom.shadowRoot),jt=g=>{const w=Z(g)?g.dom.parentNode:g.dom;if(w==null||w.ownerDocument===null)return!1;const N=w.ownerDocument;return Oe(ut.fromDom(w)).fold(()=>N.body.contains(w),P(jt,Qe))},ii=g=>{const w=g.dom.body;if(w==null)throw new Error("Body is not available yet");return ut.fromDom(w)},S=(g,w,N)=>{if(!a(N))throw new Error("CSS value must be a string: "+N);ke(g)&&g.style.setProperty(w,N)},C=(g,w,N)=>{const K=g.dom;S(K,w,N)},H=(g,w)=>{const N=g.dom;je(w,(K,Ae)=>{S(N,Ae,K)})},U=(g,w)=>{const N=g.dom,Ae=window.getComputedStyle(N).getPropertyValue(w);return Ae===""&&!jt(g)?Me(N,w):Ae},Me=(g,w)=>ke(g)?g.style.getPropertyValue(w):"",Re=(g,w,N,K,Ae,Ge,Ot)=>({target:g,x:w,y:N,stop:K,prevent:Ae,kill:Ge,raw:Ot}),qe=g=>{const w=ut.fromDom($t(g).getOr(g.target)),N=()=>g.stopPropagation(),K=()=>g.preventDefault(),Ae=v(K,N);return Re(w,g.clientX,g.clientY,N,K,Ae,g)},xt=(g,w)=>N=>{g(N)&&w(qe(N))},Ze=(g,w,N,K,Ae)=>{const Ge=xt(N,K);return g.dom.addEventListener(w,Ge,Ae),{unbind:D(k,g,w,Ge,Ae)}},Ue=(g,w,N,K)=>Ze(g,w,N,K,!1),k=(g,w,N,K)=>{g.dom.removeEventListener(w,N,K)},A=T,J=(g,w,N)=>Ue(g,w,A,N),pe=g=>{let w=!1,N;return(...K)=>(w||(w=!0,N=g.apply(null,K)),N)},ge=(g,w,N,K)=>{const Ae=g.isiOS()&&/ipad/i.test(N)===!0,Ge=g.isiOS()&&!Ae,Ot=g.isiOS()||g.isAndroid(),hn=Ot||K("(pointer:coarse)"),Yt=Ae||!Ge&&Ot&&K("(min-device-width:768px)"),En=Ge||Ot&&!Yt,bi=w.isSafari()&&g.isiOS()&&/safari/i.test(N)===!1,fn=!En&&!Yt&&!bi;return{isiPad:O(Ae),isiPhone:O(Ge),isTablet:O(Yt),isPhone:O(En),isTouch:O(hn),isAndroid:g.isAndroid,isiOS:g.isiOS,isWebView:O(bi),isDesktop:O(fn)}},Ce=(g,w)=>{for(let N=0;N{const N=Ce(g,w);if(!N)return{major:0,minor:0};const K=Ae=>Number(w.replace(N,"$"+Ae));return Ke(K(1),K(2))},Se=(g,w)=>{const N=String(w).toLowerCase();return g.length===0?Ve():De(g,N)},Ve=()=>Ke(0,0),Ke=(g,w)=>({major:g,minor:w}),at={nu:Ke,detect:Se,unknown:Ve},_t=(g,w)=>ue(w.brands,N=>{const K=N.brand.toLowerCase();return se(g,Ae=>{var Ge;return K===((Ge=Ae.brand)===null||Ge===void 0?void 0:Ge.toLowerCase())}).map(Ae=>({current:Ae.name,version:at.nu(parseInt(N.version,10),0)}))}),Mi=(g,w)=>{const N=String(w).toLowerCase();return se(g,K=>K.search(N))},Ji=(g,w)=>Mi(g,w).map(N=>{const K=at.detect(N.versionRegexes,w);return{current:N.name,version:K}}),Yr=(g,w)=>Mi(g,w).map(N=>{const K=at.detect(N.versionRegexes,w);return{current:N.name,version:K}}),St=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ct=g=>w=>ie(w,g),Dt=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:g=>ie(g,"edge/")&&ie(g,"chrome")&&ie(g,"safari")&&ie(g,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,St],search:g=>ie(g,"chrome")&&!ie(g,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:g=>ie(g,"msie")||ie(g,"trident")},{name:"Opera",versionRegexes:[St,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:ct("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:ct("firefox")},{name:"Safari",versionRegexes:[St,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:g=>(ie(g,"safari")||ie(g,"mobile/"))&&ie(g,"applewebkit")}],si=[{name:"Windows",search:ct("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:g=>ie(g,"iphone")||ie(g,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:ct("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:ct("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:ct("linux"),versionRegexes:[]},{name:"Solaris",search:ct("sunos"),versionRegexes:[]},{name:"FreeBSD",search:ct("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:ct("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],Qi={browsers:O(Dt),oses:O(si)},Lc="Edge",$c="Chromium",_c="IE",zc="Opera",Vc="Firefox",Hc="Safari",jm=()=>Wc({current:void 0,version:at.unknown()}),Wc=g=>{const w=g.current,N=g.version,K=Ae=>()=>w===Ae;return{current:w,version:N,isEdge:K(Lc),isChromium:K($c),isIE:K(_c),isOpera:K(zc),isFirefox:K(Vc),isSafari:K(Hc)}},jc={unknown:jm,nu:Wc,edge:O(Lc),chromium:O($c),ie:O(_c),opera:O(zc),firefox:O(Vc),safari:O(Hc)},qc="Windows",Uc="iOS",Kc="Android",Gc="Linux",Yc="macOS",Xc="Solaris",Jc="FreeBSD",Qc="ChromeOS",qm=()=>Zc({current:void 0,version:at.unknown()}),Zc=g=>{const w=g.current,N=g.version,K=Ae=>()=>w===Ae;return{current:w,version:N,isWindows:K(qc),isiOS:K(Uc),isAndroid:K(Kc),isMacOS:K(Yc),isLinux:K(Gc),isSolaris:K(Xc),isFreeBSD:K(Jc),isChromeOS:K(Qc)}},eu={unknown:qm,nu:Zc,windows:O(qc),ios:O(Uc),android:O(Kc),linux:O(Gc),macos:O(Yc),solaris:O(Xc),freebsd:O(Jc),chromeos:O(Qc)},Um={detect:(g,w,N)=>{const K=Qi.browsers(),Ae=Qi.oses(),Ge=w.bind(Yt=>_t(K,Yt)).orThunk(()=>Ji(K,g)).fold(jc.unknown,jc.nu),Ot=Yr(Ae,g).fold(eu.unknown,eu.nu),hn=ge(Ot,Ge,g,N);return{browser:Ge,os:Ot,deviceType:hn}}},Km=g=>window.matchMedia(g).matches;let Gm=pe(()=>Um.detect(navigator.userAgent,M.from(navigator.userAgentData),Km));const Ym=()=>Gm(),tu=(g,w)=>({left:g,top:w,translate:(K,Ae)=>tu(g+K,w+Ae)}),Xm=tu,Jm=g=>{const w=g!==void 0?g.dom:document,N=w.body.scrollLeft||w.documentElement.scrollLeft,K=w.body.scrollTop||w.documentElement.scrollTop;return Xm(N,K)},Tl=g=>{const w=g===void 0?window:g;return Ym().browser.isFirefox()?M.none():M.from(w.visualViewport)},nu=(g,w,N,K)=>({x:g,y:w,width:N,height:K,right:g+N,bottom:w+K}),Qm=g=>{const w=g===void 0?window:g,N=w.document,K=Jm(ut.fromDom(N));return Tl(w).fold(()=>{const Ae=w.document.documentElement,Ge=Ae.clientWidth,Ot=Ae.clientHeight;return nu(K.left,K.top,Ge,Ot)},Ae=>nu(Math.max(Ae.pageLeft,K.left),Math.max(Ae.pageTop,K.top),Ae.width,Ae.height))},iu=(g,w,N)=>Tl(N).map(K=>{const Ae=Ge=>w(qe(Ge));return K.addEventListener(g,Ae),{unbind:()=>K.removeEventListener(g,Ae)}}).getOrThunk(()=>({unbind:x}));var Zm=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),su=tinymce.util.Tools.resolve("tinymce.Env");const ru=(g,w)=>{g.dispatch("FullscreenStateChanged",{state:w}),g.dispatch("ResizeEditor")},eg=g=>w=>w.options.get(g),tg=g=>{const w=g.options.register;w("fullscreen_native",{processor:"boolean",default:!1})},Ml=eg("fullscreen_native"),ng=g=>{const w=ut.fromDom(g.getElement());return Oe(w).map(Qe).getOrThunk(()=>ii(on(w)))},ig=g=>g.fullscreenElement!==void 0?g.fullscreenElement:g.msFullscreenElement!==void 0?g.msFullscreenElement:g.webkitFullscreenElement!==void 0?g.webkitFullscreenElement:null,sg=()=>document.fullscreenElement!==void 0?"fullscreenchange":document.msFullscreenElement!==void 0?"MSFullscreenChange":document.webkitFullscreenElement!==void 0?"webkitfullscreenchange":"fullscreenchange",rg=g=>{const w=g.dom;w.requestFullscreen?w.requestFullscreen():w.msRequestFullscreen?w.msRequestFullscreen():w.webkitRequestFullScreen&&w.webkitRequestFullScreen()},og=g=>{const w=g.dom;w.exitFullscreen?w.exitFullscreen():w.msExitFullscreen?w.msExitFullscreen():w.webkitCancelFullScreen&&w.webkitCancelFullScreen()},ou=g=>g.dom===ig(on(g).dom),lg=(g,w,N)=>ce(In(g,N),w),ag=(g,w)=>ce(Kn(g),w),cg=g=>Mn(g),ug=(g,w,N)=>lg(g,K=>Wt(K,w),N),hg=(g,w)=>ag(g,N=>Wt(N,w)),Xr="data-ephox-mobile-fullscreen-style",fg="display:none!important;",lu="position:absolute!important;",au="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",dg="background-color:rgb(255,255,255)!important;",pg=su.os.isAndroid(),mg=g=>{const w=U(g,"background-color");return w!==void 0&&w!==""?"background-color:"+w+"!important":dg},gg=(g,w,N)=>{const K=En=>hg(En,"*:not(.tox-silver-sink)"),Ae=En=>bi=>{const fn=kt(bi,"style"),ks=fn===void 0?"no-styles":fn.trim();ks!==En&&(bt(bi,Xr,ks),H(bi,g.parseStyle(En)))},Ge=ug(w,"*"),Ot=ee(Ge,K),hn=mg(N);Q(Ot,Ae(fg)),Q(Ge,Ae(lu+au+hn)),Ae((pg===!0?"":lu)+au+hn)(w)},bg=g=>{const w=cg("["+Xr+"]");Q(w,N=>{const K=kt(N,Xr);K&&K!=="no-styles"?H(N,g.parseStyle(K)):Nt(N,"style"),Nt(N,Xr)})},cu=Zm.DOM,yg=()=>Qm(window),wg=g=>window.scrollTo(g.x,g.y),uu=Tl().fold(()=>({bind:x,unbind:x}),g=>{const w=we(),N=be(),K=be(),Ae=()=>{document.body.scrollTop=0,document.documentElement.scrollTop=0},Ge=()=>{window.requestAnimationFrame(()=>{w.on(En=>H(En,{top:g.offsetTop+"px",left:g.offsetLeft+"px",height:g.height+"px",width:g.width+"px"}))})},Ot=Ie(()=>{Ae(),Ge()},50);return{bind:En=>{w.set(En),Ot.throttle(),N.set(iu("resize",Ot.throttle)),K.set(iu("scroll",Ot.throttle))},unbind:()=>{w.on(()=>{N.clear(),K.clear()}),w.clear()}}}),hu=(g,w)=>{const N=document.body,K=document.documentElement,Ae=g.getContainer(),Ge=ut.fromDom(Ae),Ot=Ai(Ge).filter(wn=>E(wn)&&re(wn,"tox-silver-sink")),hn=ng(g),Yt=w.get(),En=ut.fromDom(g.getBody()),bi=su.deviceType.isTouch(),fn=Ae.style,ks=g.iframeElement,xs=ks==null?void 0:ks.style,du=wn=>{wn(N,"tox-fullscreen"),wn(K,"tox-fullscreen"),wn(Ae,"tox-fullscreen"),Oe(Ge).map(Di=>Qe(Di).dom).each(Di=>{wn(Di,"tox-fullscreen"),wn(Di,"tox-shadowhost")})},Dl=()=>{bi&&bg(g.dom),du(cu.removeClass),uu.unbind(),M.from(w.get()).each(wn=>wn.fullscreenChangeHandler.unbind())};if(Yt)Yt.fullscreenChangeHandler.unbind(),Ml(g)&&ou(hn)&&og(on(hn)),xs.width=Yt.iframeWidth,xs.height=Yt.iframeHeight,fn.width=Yt.containerWidth,fn.height=Yt.containerHeight,fn.top=Yt.containerTop,fn.left=Yt.containerLeft,z(Ot,Yt.sinkCssPosition,(wn,Di)=>{C(wn,"position",Di)}),Dl(),wg(Yt.scrollPos),w.set(null),ru(g,!1),g.off("remove",Dl);else{const wn=J(on(hn),sg(),Jr=>{Ml(g)&&!ou(hn)&&w.get()!==null&&hu(g,w)}),Di={scrollPos:yg(),containerWidth:fn.width,containerHeight:fn.height,containerTop:fn.top,containerLeft:fn.left,iframeWidth:xs.width,iframeHeight:xs.height,fullscreenChangeHandler:wn,sinkCssPosition:Ot.map(Jr=>U(Jr,"position"))};bi&&gg(g.dom,Ge,En),xs.width=xs.height="100%",fn.width=fn.height="",du(cu.addClass),Ot.each(Jr=>{C(Jr,"position","fixed")}),uu.bind(Ge),g.on("remove",Dl),w.set(Di),Ml(g)&&rg(hn),ru(g,!0)}},vg=(g,w)=>{g.addCommand("mceFullScreen",()=>{hu(g,w)})},fu=(g,w)=>N=>{N.setActive(w.get()!==null);const K=Ae=>N.setActive(Ae.state);return g.on("FullscreenStateChanged",K),()=>g.off("FullscreenStateChanged",K)},kg=(g,w)=>{const N=()=>g.execCommand("mceFullScreen");g.ui.registry.addToggleMenuItem("fullscreen",{text:"Fullscreen",icon:"fullscreen",shortcut:"Meta+Shift+F",onAction:N,onSetup:fu(g,w)}),g.ui.registry.addToggleButton("fullscreen",{tooltip:"Fullscreen",icon:"fullscreen",onAction:N,onSetup:fu(g,w)})};var xg=()=>{e.add("fullscreen",g=>{const w=i(null);return g.inline||(tg(g),vg(g,w),kg(g,w),g.addShortcut("Meta+Shift+F","","mceFullScreen")),t(w)})};xg()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=D=>F=>F.options.get(D),t=D=>{const F=D.options.register;F("insertdatetime_dateformat",{processor:"string",default:D.translate("%Y-%m-%d")}),F("insertdatetime_timeformat",{processor:"string",default:D.translate("%H:%M:%S")}),F("insertdatetime_formats",{processor:"string[]",default:["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"]}),F("insertdatetime_element",{processor:"boolean",default:!1})},n=e("insertdatetime_dateformat"),s=e("insertdatetime_timeformat"),r=e("insertdatetime_formats"),o=e("insertdatetime_element"),l=D=>{const F=r(D);return F.length>0?F[0]:s(D)},a="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),c="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),u="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),h="January February March April May June July August September October November December".split(" "),f=(D,F)=>{if(D=""+D,D.length(F=F.replace("%D","%m/%d/%Y"),F=F.replace("%r","%I:%M:%S %p"),F=F.replace("%Y",""+T.getFullYear()),F=F.replace("%y",""+T.getYear()),F=F.replace("%m",f(T.getMonth()+1,2)),F=F.replace("%d",f(T.getDate(),2)),F=F.replace("%H",""+f(T.getHours(),2)),F=F.replace("%M",""+f(T.getMinutes(),2)),F=F.replace("%S",""+f(T.getSeconds(),2)),F=F.replace("%I",""+((T.getHours()+11)%12+1)),F=F.replace("%p",T.getHours()<12?"AM":"PM"),F=F.replace("%B",""+D.translate(h[T.getMonth()])),F=F.replace("%b",""+D.translate(u[T.getMonth()])),F=F.replace("%A",""+D.translate(c[T.getDay()])),F=F.replace("%a",""+D.translate(a[T.getDay()])),F=F.replace("%%","%"),F),p=(D,F,T,M)=>{const W=D.dom.create("time",{datetime:T},M);D.dom.replace(W,F),D.selection.select(W,!0),D.selection.collapse(!1)},y=(D,F)=>{if(o(D)){const T=d(D,F);let M;/%[HMSIp]/.test(F)?M=d(D,"%Y-%m-%dT%H:%M"):M=d(D,"%Y-%m-%d");const W=D.dom.getParent(D.selection.getStart(),"time");W?p(D,W,M,T):D.insertContent('")}else D.insertContent(d(D,F))},b=D=>{D.addCommand("mceInsertDate",(F,T)=>{y(D,T!=null?T:n(D))}),D.addCommand("mceInsertTime",(F,T)=>{y(D,T!=null?T:s(D))})},m=D=>{let F=D;return{get:()=>F,set:W=>{F=W}}};var x=tinymce.util.Tools.resolve("tinymce.util.Tools");const v=D=>F=>{const T=()=>{F.setEnabled(D.selection.isEditable())};return D.on("NodeChange",T),T(),()=>{D.off("NodeChange",T)}},P=D=>{const F=r(D),T=m(l(D)),M=V=>D.execCommand("mceInsertDate",!1,V);D.ui.registry.addSplitButton("insertdatetime",{icon:"insert-time",tooltip:"Insert date/time",select:V=>V===T.get(),fetch:V=>{V(x.map(F,Q=>({type:"choiceitem",text:d(D,Q),value:Q})))},onAction:V=>{M(T.get())},onItemAction:(V,Q)=>{T.set(Q),M(Q)},onSetup:v(D)});const W=V=>()=>{T.set(V),M(V)};D.ui.registry.addNestedMenuItem("insertdatetime",{icon:"insert-time",text:"Date/time",getSubmenuItems:()=>x.map(F,V=>({type:"menuitem",text:d(D,V),onAction:W(V)})),onSetup:v(D)})};var O=()=>{i.add("insertdatetime",D=>{t(D),b(D),P(D)})};O()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(S,C,H)=>{var U;return H(S,C.prototype)?!0:((U=S.constructor)===null||U===void 0?void 0:U.name)===C.name},t=S=>{const C=typeof S;return S===null?"null":C==="object"&&Array.isArray(S)?"array":C==="object"&&e(S,String,(H,U)=>U.isPrototypeOf(H))?"string":C},n=S=>C=>t(C)===S,s=n("string"),r=n("object"),o=n("array"),l=S=>S==null,a=S=>!l(S);class c{constructor(C,H){this.tag=C,this.value=H}static some(C){return new c(!0,C)}static none(){return c.singletonNone}fold(C,H){return this.tag?H(this.value):C()}isSome(){return this.tag}isNone(){return!this.tag}map(C){return this.tag?c.some(C(this.value)):c.none()}bind(C){return this.tag?C(this.value):c.none()}exists(C){return this.tag&&C(this.value)}forall(C){return!this.tag||C(this.value)}filter(C){return!this.tag||C(this.value)?this:c.none()}getOr(C){return this.tag?this.value:C}or(C){return this.tag?this:C}getOrThunk(C){return this.tag?this.value:C()}orThunk(C){return this.tag?this:C()}getOrDie(C){if(this.tag)return this.value;throw new Error(C!=null?C:"Called getOrDie on None")}static from(C){return a(C)?c.some(C):c.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(C){this.tag&&C(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}c.singletonNone=new c(!1);const u=Array.prototype.push,h=(S,C)=>{for(let H=0,U=S.length;H{const C=[];for(let H=0,U=S.length;H{let C=S;return{get:()=>C,set:Me=>{C=Me}}},p=Object.keys,y=Object.hasOwnProperty,b=(S,C)=>{const H=p(S);for(let U=0,Me=H.length;Ux(S,C)?c.from(S[C]):c.none(),x=(S,C)=>y.call(S,C),v=S=>C=>C.options.get(S),P=S=>{const C=S.options.register;C("audio_template_callback",{processor:"function"}),C("video_template_callback",{processor:"function"}),C("iframe_template_callback",{processor:"function"}),C("media_live_embeds",{processor:"boolean",default:!0}),C("media_filter_html",{processor:"boolean",default:!0}),C("media_url_resolver",{processor:"function"}),C("media_alt_source",{processor:"boolean",default:!0}),C("media_poster",{processor:"boolean",default:!0}),C("media_dimensions",{processor:"boolean",default:!0})},O=v("audio_template_callback"),D=v("video_template_callback"),F=v("iframe_template_callback"),T=v("media_live_embeds"),M=v("media_filter_html"),W=v("media_url_resolver"),V=v("media_alt_source"),Q=v("media_poster"),ce=v("media_dimensions");var L=tinymce.util.Tools.resolve("tinymce.util.Tools"),se=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),R=tinymce.util.Tools.resolve("tinymce.html.DomParser");const ee=se.DOM,$=S=>S.replace(/px$/,""),ne=S=>{const C=S.attr("style"),H=C?ee.parseStyle(C):{};return{type:"ephox-embed-iri",source:S.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:m(H,"max-width").map($).getOr(""),height:m(H,"max-height").map($).getOr("")}},ue=(S,C)=>{let H={};const Me=R({validate:!1,forced_root_block:!1},C).parse(S);for(let Re=Me;Re;Re=Re.walk())if(Re.type===1){const qe=Re.name;if(Re.attr("data-ephox-embed-iri")){H=ne(Re);break}else!H.source&&qe==="param"&&(H.source=Re.attr("movie")),(qe==="iframe"||qe==="object"||qe==="embed"||qe==="video"||qe==="audio")&&(H.type||(H.type=qe),H=L.extend(Re.attributes.map,H)),qe==="source"&&(H.source?H.altsource||(H.altsource=Re.attr("src")):H.source=Re.attr("src")),qe==="img"&&!H.poster&&(H.poster=Re.attr("src"))}return H.source=H.source||H.src||"",H.altsource=H.altsource||"",H.poster=H.poster||"",H},z=S=>{var C;const H={mp3:"audio/mpeg",m4a:"audio/x-m4a",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},U=(C=S.toLowerCase().split(".").pop())!==null&&C!==void 0?C:"";return m(H,U).getOr("")};var G=tinymce.util.Tools.resolve("tinymce.html.Node"),be=tinymce.util.Tools.resolve("tinymce.html.Serializer");const we=(S,C={})=>R(Pe({forced_root_block:!1,validate:!1,allow_conditional_comments:!0},C),S),Ie=se.DOM,ve=S=>/^[0-9.]+$/.test(S)?S+"px":S,je=(S,C)=>{const H=C.attr("style"),U=H?Ie.parseStyle(H):{};a(S.width)&&(U["max-width"]=ve(S.width)),a(S.height)&&(U["max-height"]=ve(S.height)),C.attr("style",Ie.serializeStyle(U))},st=["source","altsource"],Je=(S,C,H,U)=>{let Me=0,Re=0;const qe=we(U);qe.addNodeFilter("source",Ze=>Me=Ze.length);const xt=qe.parse(S);for(let Ze=xt;Ze;Ze=Ze.walk())if(Ze.type===1){const Ue=Ze.name;if(Ze.attr("data-ephox-embed-iri")){je(C,Ze);break}else{switch(Ue){case"video":case"object":case"embed":case"img":case"iframe":C.height!==void 0&&C.width!==void 0&&(Ze.attr("width",C.width),Ze.attr("height",C.height));break}if(H)switch(Ue){case"video":Ze.attr("poster",C.poster),Ze.attr("src",null);for(let A=Me;A<2;A++)if(C[st[A]]){const J=new G("source",1);J.attr("src",C[st[A]]),J.attr("type",C[st[A]+"mime"]||null),Ze.append(J)}break;case"iframe":Ze.attr("src",C.source);break;case"object":const k=Ze.getAll("img").length>0;if(C.poster&&!k){Ze.attr("src",C.poster);const A=new G("img",1);A.attr("src",C.poster),A.attr("width",C.width),A.attr("height",C.height),Ze.append(A)}break;case"source":if(Re<2&&(Ze.attr("src",C[st[Re]]),Ze.attr("type",C[st[Re]+"mime"]||null),!C[st[Re]])){Ze.remove();continue}Re++;break;case"img":C.poster||Ze.remove();break}}}return be({},U).serialize(xt)},pt=[{regex:/youtu\.be\/([\w\-_\?&=.]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$2?$4",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?h=$2&title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?h=$3&title=0&byline=0",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?title=0&byline=0",allowFullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0},{regex:/dai\.ly\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0}],Xe=S=>{const C=S.match(/^(https?:\/\/|www\.)(.+)$/i);return C&&C.length>1?C[1]==="www."?"https://":C[1]:"https://"},Lt=(S,C)=>{const H=Xe(C),U=S.regex.exec(C);let Me=H+S.url;if(a(U))for(let Re=0;ReU[Re]?U[Re]:"");return Me.replace(/\?$/,"")},Mt=S=>{const C=pt.filter(H=>H.regex.test(S));return C.length>0?L.extend({},C[0],{url:Lt(C[0],S)}):null},oe=(S,C)=>{if(C)return C(S);{const H=S.allowfullscreen?' allowFullscreen="1"':"";return'"}},ye=S=>{let C='';return S.poster&&(C+=''),C+="",C},de=(S,C)=>C?C(S):'",j=(S,C)=>C?C(S):'",te=(S,C)=>{var H;const U=L.extend({},C);if(!U.source&&(L.extend(U,ue((H=U.embed)!==null&&H!==void 0?H:"",S.schema)),!U.source))return"";U.altsource||(U.altsource=""),U.poster||(U.poster=""),U.source=S.convertURL(U.source,"source"),U.altsource=S.convertURL(U.altsource,"source"),U.sourcemime=z(U.source),U.altsourcemime=z(U.altsource),U.poster=S.convertURL(U.poster,"poster");const Me=Mt(U.source);if(Me&&(U.source=Me.url,U.type=Me.type,U.allowfullscreen=Me.allowFullscreen,U.width=U.width||String(Me.w),U.height=U.height||String(Me.h)),U.embed)return Je(U.embed,U,!0,S.schema);{const Re=O(S),qe=D(S),xt=F(S);return U.width=U.width||"300",U.height=U.height||"150",L.each(U,(Ze,Ue)=>{U[Ue]=S.dom.encode(""+Ze)}),U.type==="iframe"?oe(U,xt):U.sourcemime==="application/x-shockwave-flash"?ye(U):U.sourcemime.indexOf("audio")!==-1?de(U,Re):j(U,qe)}},le=S=>S.hasAttribute("data-mce-object")||S.hasAttribute("data-ephox-embed-iri"),he=S=>{S.on("click keyup touchend",()=>{const C=S.selection.getNode();C&&S.dom.hasClass(C,"mce-preview-object")&&S.dom.getAttrib(C,"data-mce-selected")&&C.setAttribute("data-mce-selected","2")}),S.on("ObjectResized",C=>{const H=C.target;if(H.getAttribute("data-mce-object")){let U=H.getAttribute("data-mce-html");U&&(U=unescape(U),H.setAttribute("data-mce-html",escape(Je(U,{width:String(C.width),height:String(C.height)},!1,S.schema))))}})},fe={},E=(S,C,H)=>new Promise((U,Me)=>{const Re=qe=>(qe.html&&(fe[S.source]=qe),U({url:S.source,html:qe.html?qe.html:C(S)}));fe[S.source]?Re(fe[S.source]):H({url:S.source},Re,Me)}),I=(S,C)=>Promise.resolve({html:C(S),url:S.source}),Z=S=>C=>te(S,C),xe=(S,C)=>{const H=W(S);return H?E(C,Z(S),H):I(C,Z(S))},$e=S=>x(fe,S),He=(S,C)=>m(C,S).bind(H=>m(H,"meta")),bt=(S,C,H)=>U=>{const Me=()=>m(S,U),Re=()=>m(C,U),qe=Ue=>m(Ue,"value").bind(k=>k.length>0?c.some(k):c.none()),xt=()=>Me().bind(Ue=>r(Ue)?qe(Ue).orThunk(Re):Re().orThunk(()=>c.from(Ue))),Ze=()=>Re().orThunk(()=>Me().bind(Ue=>r(Ue)?qe(Ue):c.from(Ue)));return{[U]:(U===H?xt():Ze()).getOr("")}},kt=(S,C)=>{const H={};return m(S,"dimensions").each(U=>{h(["width","height"],Me=>{m(C,Me).orThunk(()=>m(U,Me)).each(Re=>H[Me]=Re)})}),H},Nt=(S,C)=>{const H=C&&C!=="dimensions"?He(C,S).getOr({}):{},U=bt(S,H,C);return Pe(Pe(Pe(Pe(Pe({},U("source")),U("altsource")),U("poster")),U("embed")),kt(S,H))},q=S=>{const C=qt(Pe({},S),{source:{value:m(S,"source").getOr("")},altsource:{value:m(S,"altsource").getOr("")},poster:{value:m(S,"poster").getOr("")}});return h(["width","height"],H=>{m(S,H).each(U=>{const Me=C.dimensions||{};Me[H]=U,C.dimensions=Me})}),C},re=S=>C=>{const H=C&&C.msg?"Media embed handler error: "+C.msg:"Media embed handler threw unknown error.";S.notificationManager.open({type:"error",text:H})},ie=S=>{const C=S.selection.getNode(),H=le(C)?S.serializer.serialize(C,{selection:!0}):"",U=ue(H,S.schema),Re=(()=>{if(We(U.source,U.type)){const qe=S.dom.getRect(C);return{width:qe.w.toString().replace(/px$/,""),height:qe.h.toString().replace(/px$/,"")}}else return{}})();return Pe(Pe({embed:H},U),Re)},ke=(S,C)=>H=>{if(s(H.url)&&H.url.trim().length>0){const U=H.html,Me=ue(U,C.schema),Re=qt(Pe({},Me),{source:H.url,embed:U});S.setData(q(Re))}},Le=(S,C)=>{const H=S.dom.select("*[data-mce-object]");for(let U=0;U=0;Me--)C[U]===H[Me]&&H.splice(Me,1);S.selection.select(H[0])},tt=(S,C)=>{const H=S.dom.select("*[data-mce-object]");S.insertContent(C),Le(S,H),S.nodeChanged()},We=(S,C)=>a(C)&&C==="ephox-embed-iri"&&a(Mt(S)),lt=(S,C)=>((U,Me)=>U.width!==Me.width||U.height!==Me.height)(S,C)&&We(C.source,S.type),wt=(S,C,H)=>{var U;C.embed=lt(S,C)&&ce(H)?te(H,qt(Pe({},C),{embed:""})):Je((U=C.embed)!==null&&U!==void 0?U:"",C,!1,H.schema),C.embed&&(S.source===C.source||$e(C.source))?tt(H,C.embed):xe(H,C).then(Me=>{tt(H,Me.html)}).catch(re(H))},ut=S=>{const C=ie(S),H=d(C),U=q(C),Me=(Se,Ve)=>{const Ke=Nt(Ve.getData(),"source");Se.source!==Ke.source&&(ke(De,S)({url:Ke.source,html:""}),xe(S,Ke).then(ke(De,S)).catch(re(S)))},Re=Se=>{var Ve;const Ke=Nt(Se.getData()),at=ue((Ve=Ke.embed)!==null&&Ve!==void 0?Ve:"",S.schema);Se.setData(q(at))},qe=(Se,Ve,Ke)=>{const at=Nt(Se.getData(),Ve),_t=lt(Ke,at)&&ce(S)?qt(Pe({},at),{embed:""}):at,Mi=te(S,_t);Se.setData(q(qt(Pe({},_t),{embed:Mi})))},xt=[{name:"source",type:"urlinput",filetype:"media",label:"Source",picker_text:"Browse files"}],Ze=ce(S)?[{type:"sizeinput",name:"dimensions",label:"Constrain proportions",constrain:!0}]:[],Ue={title:"General",name:"general",items:f([xt,Ze])},A={title:"Embed",items:[{type:"textarea",name:"embed",label:"Paste your embed code below:"}]},J=[];V(S)&&J.push({name:"altsource",type:"urlinput",filetype:"media",label:"Alternative source URL"}),Q(S)&&J.push({name:"poster",type:"urlinput",filetype:"image",label:"Media poster (Image URL)"});const pe={title:"Advanced",name:"advanced",items:J},ge=[Ue,A];J.length>0&&ge.push(pe);const Ce={type:"tabpanel",tabs:ge},De=S.windowManager.open({title:"Insert/Edit Media",size:"normal",body:Ce,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:Se=>{const Ve=Nt(Se.getData());wt(H.get(),Ve,S),Se.close()},onChange:(Se,Ve)=>{switch(Ve.name){case"source":Me(H.get(),Se);break;case"embed":Re(Se);break;case"dimensions":case"altsource":case"poster":qe(Se,Ve.name,H.get());break}H.set(Nt(Se.getData()))},initialData:U})},Wt=S=>({showDialog:()=>{ut(S)}}),Qt=S=>{const C=()=>{ut(S)};S.addCommand("mceMedia",C)},Mn=(S,C,H)=>S.length>=C.length&&S.substr(H,H+C.length)===C,ei=(S,C)=>Mn(S,C,0);var on=tinymce.util.Tools.resolve("tinymce.Env");const Dn=S=>{const C=S.name;return C==="iframe"||C==="video"||C==="audio"},ti=(S,C,H,U=null)=>{const Me=S.attr(H);return a(Me)?Me:x(C,H)?null:U},In=(S,C,H)=>{const U=C.name==="img"||S.name==="video",Me=U?"300":null,Re=S.name==="audio"?"30":"150",qe=U?Re:null;C.attr({width:ti(S,H,"width",Me),height:ti(S,H,"height",qe)})},Kn=(S,C,H,U)=>{const Me=we(S.schema).parse(U,{context:C});for(;Me.firstChild;)H.append(Me.firstChild)},Ai=(S,C)=>{const H=C.name,U=new G("img",1);return ni(S,C,U),In(C,U,{}),U.attr({style:C.attr("style"),src:on.transparentSrc,"data-mce-object":H,class:"mce-object mce-object-"+H}),U},Ti=(S,C)=>{var H;const U=C.name,Me=new G("span",1);Me.attr({contentEditable:"false",style:C.attr("style"),"data-mce-object":U,class:"mce-preview-object mce-object-"+U}),ni(S,C,Me);const Re=S.dom.parseStyle((H=C.attr("style"))!==null&&H!==void 0?H:""),qe=new G(U,1);if(In(C,qe,Re),qe.attr({src:C.attr("src"),style:C.attr("style"),class:C.attr("class")}),U==="iframe")qe.attr({allowfullscreen:C.attr("allowfullscreen"),frameborder:"0",sandbox:C.attr("sandbox")});else{h(["controls","crossorigin","currentTime","loop","muted","poster","preload"],k=>{qe.attr(k,C.attr(k))});const Ue=Me.attr("data-mce-html");a(Ue)&&Kn(S,U,qe,unescape(Ue))}const xt=new G("span",1);return xt.attr("class","mce-shim"),Me.append(qe),Me.append(xt),Me},ni=(S,C,H)=>{var U;const Me=(U=C.attributes)!==null&&U!==void 0?U:[];let Re=Me.length;for(;Re--;){const Ue=Me[Re].name;let k=Me[Re].value;Ue!=="width"&&Ue!=="height"&&Ue!=="style"&&!ei(Ue,"data-mce-")&&((Ue==="data"||Ue==="src")&&(k=S.convertURL(k,Ue)),H.attr("data-mce-p-"+Ue,k))}const qe=be({inner:!0},S.schema),xt=new G("div",1);h(C.children(),Ue=>xt.append(Ue));const Ze=qe.serialize(xt);Ze&&(H.attr("data-mce-html",escape(Ze)),H.empty())},B=S=>{const C=S.attr("class");return s(C)&&/\btiny-pageembed\b/.test(C)},_=S=>{let C=S;for(;C=C.parent;)if(C.attr("data-ephox-embed-iri")||B(C))return!0;return!1},me=S=>C=>{let H=C.length,U;for(;H--;)U=C[H],U.parent&&(U.parent.attr("data-mce-object")||(Dn(U)&&T(S)?_(U)||U.replace(Ti(S,U)):_(U)||U.replace(Ai(S,U))))},Oe=(S,C,H)=>{const U=S.options.get,Me=U("xss_sanitization"),Re=M(S);return we(S.schema,{sanitize:Me,validate:Re}).parse(H,{context:C})},Qe=S=>{S.on("PreInit",()=>{const{schema:C,serializer:H,parser:U}=S,Me=C.getBoolAttrs();h("webkitallowfullscreen mozallowfullscreen".split(" "),Re=>{Me[Re]={}}),b({embed:["wmode"]},(Re,qe)=>{const xt=C.getElementRule(qe);xt&&h(Re,Ze=>{xt.attributes[Ze]={},xt.attributesOrder.push(Ze)})}),U.addNodeFilter("iframe,video,audio,object,embed",me(S)),H.addAttributeFilter("data-mce-object",(Re,qe)=>{var xt;let Ze=Re.length;for(;Ze--;){const Ue=Re[Ze];if(!Ue.parent)continue;const k=Ue.attr(qe),A=new G(k,1);if(k!=="audio"){const Ce=Ue.attr("class");Ce&&Ce.indexOf("mce-preview-object")!==-1&&Ue.firstChild?A.attr({width:Ue.firstChild.attr("width"),height:Ue.firstChild.attr("height")}):A.attr({width:Ue.attr("width"),height:Ue.attr("height")})}A.attr({style:Ue.attr("style")});const J=(xt=Ue.attributes)!==null&&xt!==void 0?xt:[];let pe=J.length;for(;pe--;){const Ce=J[pe].name;Ce.indexOf("data-mce-p-")===0&&A.attr(Ce.substr(11),J[pe].value)}const ge=Ue.attr("data-mce-html");if(ge){const Ce=Oe(S,k,unescape(ge));h(Ce.children(),De=>A.append(De))}Ue.replace(A)}})}),S.on("SetContent",()=>{const C=S.dom;h(C.select("span.mce-preview-object"),H=>{C.select("span.mce-shim",H).length===0&&C.add(H,"span",{class:"mce-shim"})})})},$t=S=>{S.on("ResolveName",C=>{let H;C.target.nodeType===1&&(H=C.target.getAttribute("data-mce-object"))&&(C.name=H)})},On=S=>C=>{const H=()=>{C.setEnabled(S.selection.isEditable())};return S.on("NodeChange",H),H(),()=>{S.off("NodeChange",H)}},jt=S=>{const C=()=>S.execCommand("mceMedia");S.ui.registry.addToggleButton("media",{tooltip:"Insert/edit media",icon:"embed",onAction:C,onSetup:H=>{const U=S.selection;H.setActive(le(U.getNode()));const Me=U.selectorChangedWithUnbind("img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]",H.setActive).unbind,Re=On(S)(H);return()=>{Me(),Re()}}}),S.ui.registry.addMenuItem("media",{icon:"embed",text:"Media...",onAction:C,onSetup:On(S)})};var ii=()=>{i.add("media",S=>(P(S),Qt(S),jt(S),$t(S),Qe(S),he(S),Wt(S)))};ii()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=m=>x=>typeof x===m,t=e("boolean"),n=e("number"),s=m=>x=>x.options.get(m),r=m=>{const x=m.options.register;x("nonbreaking_force_tab",{processor:v=>t(v)?{value:v?3:0,valid:!0}:n(v)?{value:v,valid:!0}:{valid:!1,message:"Must be a boolean or number."},default:!1}),x("nonbreaking_wrap",{processor:"boolean",default:!0})},o=s("nonbreaking_force_tab"),l=s("nonbreaking_wrap"),a=(m,x)=>{let v="";for(let P=0;Pm.plugins.visualchars?m.plugins.visualchars.isEnabled():!1,u=(m,x)=>{const v=()=>c(m)?"mce-nbsp-wrap mce-nbsp":"mce-nbsp-wrap",P=()=>`${a(" ",x)}`,D=l(m)||m.plugins.visualchars?P():a(" ",x);m.undoManager.transact(()=>m.insertContent(D))},h=m=>{m.addCommand("mceNonBreaking",()=>{u(m,1)})};var f=tinymce.util.Tools.resolve("tinymce.util.VK");const d=m=>{const x=o(m);x>0&&m.on("keydown",v=>{if(v.keyCode===f.TAB&&!v.isDefaultPrevented()){if(v.shiftKey)return;v.preventDefault(),v.stopImmediatePropagation(),u(m,x)}})},p=m=>x=>{const v=()=>{x.setEnabled(m.selection.isEditable())};return m.on("NodeChange",v),v(),()=>{m.off("NodeChange",v)}},y=m=>{const x=()=>m.execCommand("mceNonBreaking");m.ui.registry.addButton("nonbreaking",{icon:"non-breaking",tooltip:"Nonbreaking space",onAction:x,onSetup:p(m)}),m.ui.registry.addMenuItem("nonbreaking",{icon:"non-breaking",text:"Nonbreaking space",onAction:x,onSetup:p(m)})};var b=()=>{i.add("nonbreaking",m=>{r(m),h(m),y(m),d(m)})};b()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager"),e=tinymce.util.Tools.resolve("tinymce.Env");const t=p=>y=>y.options.get(p),n=p=>{const y=p.options.register;y("pagebreak_separator",{processor:"string",default:""}),y("pagebreak_split_block",{processor:"boolean",default:!1})},s=t("pagebreak_separator"),r=t("pagebreak_split_block"),o="mce-pagebreak",l=p=>{const y=``;return p?`

${y}

`:y},a=p=>{const y=s(p),b=()=>r(p),m=new RegExp(y.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,x=>"\\"+x),"gi");p.on("BeforeSetContent",x=>{x.content=x.content.replace(m,l(b()))}),p.on("PreInit",()=>{p.serializer.addNodeFilter("img",x=>{let v=x.length,P,O;for(;v--;)if(P=x[v],O=P.attr("class"),O&&O.indexOf(o)!==-1){const D=P.parent;if(D&&p.schema.getBlockElements()[D.name]&&b()){D.type=3,D.value=y,D.raw=!0,P.remove();continue}P.type=3,P.value=y,P.raw=!0}})})},c=p=>{p.addCommand("mcePageBreak",()=>{p.insertContent(l(r(p)))})},u=p=>{p.on("ResolveName",y=>{y.target.nodeName==="IMG"&&p.dom.hasClass(y.target,o)&&(y.name="pagebreak")})},h=p=>y=>{const b=()=>{y.setEnabled(p.selection.isEditable())};return p.on("NodeChange",b),b(),()=>{p.off("NodeChange",b)}},f=p=>{const y=()=>p.execCommand("mcePageBreak");p.ui.registry.addButton("pagebreak",{icon:"page-break",tooltip:"Page break",onAction:y,onSetup:h(p)}),p.ui.registry.addMenuItem("pagebreak",{text:"Page break",icon:"page-break",onAction:y,onSetup:h(p)})};var d=()=>{i.add("pagebreak",p=>{n(p),c(p),f(p),a(p),u(p)})};d()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager"),e=tinymce.util.Tools.resolve("tinymce.Env"),t=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=d=>p=>p.options.get(d),s=n("content_style"),r=n("content_css_cors"),o=n("body_class"),l=n("body_id"),a=d=>{var p;let y="";const b=d.dom.encode,m=(p=s(d))!==null&&p!==void 0?p:"";y+='';const x=r(d)?' crossorigin="anonymous"':"";t.each(d.contentCSS,W=>{y+='"}),m&&(y+='");const v=l(d),P=o(d),D='