1234567891011121314151617181920212223242526 |
- var gg=Object.defineProperty,bg=Object.defineProperties;var yg=Object.getOwnPropertyDescriptors;var lu=Object.getOwnPropertySymbols;var wg=Object.prototype.hasOwnProperty,vg=Object.prototype.propertyIsEnumerable;var au=(i,e,t)=>e in i?gg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Fe=(i,e)=>{for(var t in e||(e={}))wg.call(e,t)&&au(i,t,e[t]);if(lu)for(var t of lu(e))vg.call(e,t)&&au(i,t,e[t]);return i},qt=(i,e)=>bg(i,yg(e));var tt=(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,u as G,h as Ys,w as mt,a6 as vt,_ as it,a7 as Bt,a8 as ft,$ as dn,F as _s,a9 as Gn,G as Vn,a2 as Yn,aa as cn,ab as Hi,ac as Sn,ae as Wi,af as fs,k as rt,a1 as $i,o as Nr,H as kg,a0 as rs,a3 as Bo,ad as Xa,s as Tl,e as xg,J as ea,j as ff,l as Sg,L as Cg,Q as Ag,y as Ir,m as df,A as pf,I as Tg,i as Mg,g as Dg,ap as Og,r as cu,am as Eg,b as Fg}from"./vue-CmlY4eyV.js";import{u as Xi,C as Pg}from"./index-D5QnXKgB.js";import{p as Ee,aJ as ws,b as In,_ as Mn,aF as cs,f as ll,aM as uu,I as hu,z as Ja,i as mf,ak as gf,Z as Bg,c as Rg,O as Ng,aB as fu,s as Ig,t as Lg,ao as $g,x as Bi,aN as yi,an as _g,aO as du,aL as xo,d as bf,aK as zg,aP as Vg}from"./entry/index-CP6zkLsN-1726190694502.js";import{ak as Fs,o as Lr,e as Et,al as Cn,l as hr,am as al,an as zs,ao as Hg,ap as yf,aq as wf,ar as vf,as as $r,at as Qa,au as Wg,n as Kn,av as jg,t as Xs,N as qg,aw as Ug,ax as Kg,_ as kf,ay as Gg,a2 as cl,az as Yg,aA as Xg,a9 as Jg,ad as xf,aB as Qg,aC as Zg,F as Sf,O as Cs,H as Ro,aa as No,f as _i,aD as e0,aE as t0,s as us,aF as pu,d as fr,aG as mu,Z as n0,R as i0}from"./antd-Bp5u6ujY.js";import{b as s0}from"./tree-Cz4SXb17.js";import{u as r0,c as o0}from"./copyTextToClipboard-o-L2h2rZ.js";import{I as l0,B as a0}from"./index-BPgn07DB.js";import{S as c0}from"./index-BAxfTGAN.js";import{S as u0,B as Cf,a as h0,b as f0}from"./index-caYAhZot.js";import{C as d0}from"./index-Ci1vkPDT.js";import{t as Ml}from"./plugin-BdCvh_fX.js";import{b as gu}from"./uuid-BUBnBT7J.js";import{o as p0}from"./onMountedOrActivated-C4hclMrd.js";import{u as m0}from"./index-5JuY20kX.js";function g0(i){return"slot"in i}function b0(i){return!g0(i)}const y0=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}=In(),[a]=Xi(i,"value","change",r),c=dt(()=>{const{labelField:d,valueField:p,numberToString:y}=i;return G(t).reduce((b,m)=>{if(m){const A=m[p];b.push(Fe({label:m[d],value:y?`${A}`:A},Lr(m,[d,p])))}return b},[])});Ys(()=>{i.immediate&&u()}),mt(()=>i.params,()=>{!G(s)&&u()},{deep:!0});function u(){return tt(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=Cn(p,i.resultField)||[]),h()}catch(p){}finally{n.value=!1}}})}function h(){e("options-change",G(c))}function f(...d){r.value=d}return{state:a,getOptions:c,attrs:o,loading:n,t:l,handleClick:f,props:i}}});function w0(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,Gn(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(()=>[Vn(Yn(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(()=>[Vn(Yn(c.label),1)]),_:2},1032,["value","disabled","onClick"]))],64))),128))]),_:1},16,["value"])}const v0=Mn(y0,[["render",w0]]),k0=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]=Xi(i,"value","change",t),s=dt(()=>{const{options:o}=i;return!o||(o==null?void 0:o.length)===0?[]:o.some(a=>hr(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 x0(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,Gn(i.getOptions,a=>(it(),Bt(o,{key:`${a.value}`,value:a.value,disabled:a.disabled,onClick:c=>i.handleClick(a)},{default:ft(()=>[Vn(Yn(a.label),1)]),_:2},1032,["value","disabled","onClick"]))),128))]),_:1},16,["value"])}const S0=Mn(k0,[["render",x0]]),C0=Gt({name:"ApiSelect",components:{Select:al,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}=In(),a=i.isSearch,c=ze();a&&(c.value=d);const[u]=Xi(i,"value","change",r),h=dt(()=>{const{labelField:m,valueField:A,numberToString:v}=i;let F=G(t).reduce((D,E)=>{if(E){const P=Cn(E,A);D.push(qt(Fe({},Lr(E,[m,A])),{label:Cn(E,m),value:v?`${P}`:P}))}return D},[]);return F.length>0?F:i.options});mt(()=>u.value,m=>{e("update:value",m)}),mt(()=>i.params,()=>{a==!1&&!G(s)&&f()},{deep:!0,immediate:i.immediate});function f(){return tt(this,null,function*(){const m=i.api;if(!(!m||!Et(m)||n.value)){t.value=[];try{n.value=!0;const A=yield m(i.params);if(s.value=!0,Array.isArray(A)){t.value=A,y();return}i.resultField&&(t.value=Cn(A,i.resultField)||[]),y()}catch(A){}finally{n.value=!1,s.value=!1}}})}function d(m){return tt(this,null,function*(){const A=i.api;if(!(!A||!Et(A)||n.value)){t.value=[];try{n.value=!0;let v={};i.searchField!=null&&(v[i.searchField]=m),v.page=1,v.pageSize=10;const F=yield A(v);if(Array.isArray(F)){t.value=F,y();return}i.resultField&&(t.value=Cn(F,i.resultField)||[]),y()}catch(v){}finally{n.value=!1}}})}function p(m){return tt(this,null,function*(){m&&!a&&(i.alwaysLoad?yield f():!i.immediate&&!G(s)&&(yield f()))})}function y(){e("options-change",G(h))}function b(m,...A){r.value=A,e("change",A)}return{state:u,attrs:o,getOptions:h,loading:n,t:l,handleFetch:p,handleChange:b,useSearch:a,searchFun:c}}});function A0(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}),Hi({_:2},[Gn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[Sn(i.$slots,a,Wi(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"}),Vn(" "+Yn(i.t("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1040,["onDropdownVisibleChange","onChange","options","value","show-search","onSearch"])}const T0=Mn(C0,[["render",A0]]),M0=Gt({name:"ApiTree",components:{ATree:Hg},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(()=>Fe(Fe({},i.api?{treeData:G(n)}:{}),e));function l(...c){t("change",...c)}mt(()=>i.params,()=>{!G(s)&&a()},{deep:!0}),mt(()=>i.immediate,c=>{c&&!s.value&&a()}),Nr(()=>{i.immediate&&a()});function a(){return tt(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&&(cs(h)||(h=Cn(h,i.resultField)),n.value=h||[],s.value=!0,t("options-change",n.value))})}return{getAttrs:o,loading:r,handleChange:l}}});function D0(i,e,t,n,s,r){const o=vt("ATree");return it(),Bt(o,cn(i.getAttrs,{onChange:i.handleChange}),Hi({_:2},[Gn(Object.keys(i.$slots),l=>({name:l,fn:ft(a=>[Sn(i.$slots,l,Wi(fs(a||{})))])}))]),1040,["onChange"])}const O0=Mn(M0,[["render",D0]]),E0=Gt({name:"ApiTreeSelect",components:{ATreeSelect:yf,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(()=>Fe(Fe({},i.api?{treeData:G(n)}:{}),e));function l(...c){t("change",...c)}mt(()=>i.params,()=>{!G(s)&&a()},{deep:!0}),mt(()=>i.immediate,c=>{c&&!s.value&&a()}),Nr(()=>{i.immediate&&a()});function a(){return tt(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&&(cs(u)||(u=Cn(u,i.resultField)),n.value=s0(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 F0(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}),Hi({_:2},[Gn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[Sn(i.$slots,a,Wi(fs(c||{})))])})),i.loading?{name:"suffixIcon",fn:ft(()=>[rt(o,{spin:""})]),key:"0"}:void 0]),1040,["onChange","onDropdownVisibleChange"])}const P0=Mn(E0,[["render",F0]]),B0=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}=In(),[u]=Xi(t,"value","change",l);mt(s,b=>{const m=h(b);r.value=m},{deep:!0});function h(b){const{labelField:m,valueField:A,numberToString:v,childrenField:F,isLeaf:D}=t;return b.reduce((E,P)=>{if(P){const T=P[A],M=qt(Fe({},Lr(P,[m,A])),{label:P[m],value:v?`${T}`:T,isLeaf:D&&typeof D=="function"?D(P):!1}),V=Reflect.get(P,F);V&&Reflect.set(M,F,h(V)),E.push(M)}return E},[])}function f(){return tt(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=Cn(m,t.resultField)||[])}catch(m){}finally{o.value=!1}}})}const d=b=>tt(this,null,function*(){const m=b[b.length-1];m.loading=!0;const A=t.api;if(!(!A||!Et(A)))try{const v=yield A({[t.apiParamKey]:Reflect.get(m,"value")});if(Array.isArray(v)){const F=h(v);m.children=F;return}if(t.resultField){const F=h(Cn(v,t.resultField)||[]);m.children=F}}catch(v){}finally{m.loading=!1}});Ys(()=>{t.immediate&&f()}),mt(()=>t.initFetchParams,()=>{!G(a)&&f()},{deep:!0});function p(b,m){l.value=m,n("defaultChange",b,m)}const y=({labels:b,selectedOptions:m})=>G(l).length===(m==null?void 0:m.length)?b.join(" / "):t.displayRenderArray?t.displayRenderArray.join(" / "):"";return(b,m)=>(it(),Bt(G(wf),{value:G(u),"onUpdate:value":m[0]||(m[0]=A=>kg(u)?u.value=A:null),options:r.value,"load-data":d,"change-on-select":"",onChange:p,displayRender:y},Hi({_:2},[o.value?{name:"suffixIcon",fn:ft(()=>[rt(G(zs),{spin:""})]),key:"0"}:void 0,o.value?{name:"notFoundContent",fn:ft(()=>[$i("span",null,[rt(G(zs),{spin:"",class:"mr-1"}),Vn(" "+Yn(G(c)("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1032,["value","options"]))}}),R0=Gt({name:"ApiTransfer",components:{Transfer:vf},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}=In(),o=dt(()=>Fe(Fe({},i.api?{}:{dataSource:G(n)}),e)),l=dt(()=>{const{labelField:f,valueField:d}=i;return G(n).reduce((p,y)=>(y&&p.push(qt(Fe({},Lr(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)}Ys(()=>{i.immediate&&!i.alwaysLoad&&u()}),mt(()=>i.params,()=>{u()},{deep:!0});function u(){return tt(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=Cn(d,i.resultField)||[]),h()}catch(d){}})}function h(){t("options-change",G(l))}return{getTargetKeys:a,getdataSource:l,t:r,getAttrs:o,handleChange:c}}});function N0(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 I0=Mn(R0,[["render",N0]]),L0=Gt({name:"SimpleTimePicker",components:{DatePicker:$r,TimePicker:Qa,FormItemRest:Wg},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}=In(),r=ze(),o=ze(),l=ze();i.timeMode==="datetime"?l.value=!0:l.value=!1;const[a]=Xi(i,"value","change",t);mt(()=>a.value,u=>{u!==null&&u!=null&&(i.valueFormat==="unixmilli"?(r.value=Kn(u),o.value=Kn(u)):u!==void 0&&(r.value=Kn.unix(u),o.value=Kn.unix(u))),e("update:value",u),e("change",u)});function c(u){var h;if(u!==null){let f=Kn();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 $0(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"])):rs("",!0)]),_:1})],64)}const _0=Mn(L0,[["render",$0]]),z0=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}=In(),r=ze(),o=ze();i.timeMode==="datetime"?o.value=!0:o.value=!1;const[l]=Xi(i,"value","change",t);mt(()=>l.value,c=>{c!==null&&c!=null&&(i.valueFormat==="unixmilli"?r.value=[Kn(c[0]),Kn(c[1])]:c!==void 0&&(r.value=[Kn.unix(c[0]),Kn.unix(c[1])])),e("update:value",c),e("change",c)});function a(c){var u,h;if(c!==null){let f=[Kn(),Kn()];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 V0(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 H0=Mn(z0,[["render",V0]]),W0=Gt({name:"ApiMultipleSelect",components:{Select:al,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}=In(),[a]=Xi(i,"value","change",r),c=dt(()=>{const{labelField:p,valueField:y,numberToString:b}=i;return G(t).reduce((m,A)=>{if(A){const v=A[y];m.push(qt(Fe({},Lr(A,[p,y])),{label:A[p],value:b?`${v}`:v}))}return m},[])});Ys(()=>{i.immediate&&!i.alwaysLoad&&u()}),mt(()=>a.value,p=>{e("update:value",p)}),mt(()=>i.params,()=>{!G(s)&&u()},{deep:!0});function u(){return tt(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=Cn(y,i.resultField)||[]),f()}catch(y){}finally{n.value=!1}}})}function h(p){return tt(this,null,function*(){p&&(i.alwaysLoad?yield u():!i.immediate&&G(s)&&(yield u(),s.value=!1))})}function f(){e("options-change",G(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)}),Hi({_:2},[Gn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[Sn(i.$slots,a,Wi(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"}),Vn(" "+Yn(i.t("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1040,["onDropdownVisibleChange","onChange","options","value"])}const q0=Mn(W0,[["render",j0]]),U0=Gt({name:"DictionarySelect",components:{Select:al,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}=In(),o=ze(),[l]=Xi(i,"value","change",n);Nr(()=>{a()}),mt(()=>l.value,u=>{e("update:value",u)});function a(){return tt(this,null,function*(){t.value=!0;const h=yield r0().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 K0(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)}),Hi({_:2},[Gn(Object.keys(i.$slots),a=>({name:a,fn:ft(c=>[Sn(i.$slots,a,Wi(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"}),Vn(" "+Yn(i.t("component.form.apiSelectNotFound")),1)])]),key:"1"}:void 0]),1040,["onChange","options","value"])}const G0=Mn(U0,[["render",K0]]),bu={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 Y0(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 X0(i,e){const t=ze(1),n=ze(e),s=dt(()=>Y0(G(i),G(t),G(n))),r=dt(()=>G(i).length);function o(a){t.value=a}function l(a){n.value=a}return{setCurrentPage:o,getTotal:r,setPageSize:l,getPaginationList:s}}const J0=["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"],Q0={class:"flex justify-between"},Z0={key:0},eb={class:"flex flex-wrap px-2"},tb=["onClick","title"],nb={key:0,class:"flex py-2 items-center justify-center"},ib={key:1,class:"p-5"},sb={key:0,class:"cursor-pointer px-2 py-1 flex items-center"},rb=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=Xs,n=qg,s=Ug,r=Kg;function o(){const V=bu.prefix;return bu.icons.map(H=>`${V}:${H}`)}function l(){return J0.map(V=>V.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}=In(),{prefixCls:A}=ll("icon-picker"),v=Ja(M,100),{getPaginationList:F,getTotal:D,setCurrentPage:E}=X0(p,a.pageSize);Ys(()=>{f.value=a.value}),mt(()=>f.value,V=>{c("update:value",V),c("change",V)});function P(V){E(V)}function T(V){f.value=V,a.copy&&o0(V,m("component.icon.copy"))}function M(V){const H=V.target.value;if(!H){E(1),p.value=h;return}f.value=H,p.value=h.filter(te=>te.includes(H))}return(V,H)=>(it(),Bt(G(t),{readonly:"",style:Xa({width:V.width}),placeholder:G(m)("component.icon.placeholder"),class:Bo(G(A)),value:f.value,"onUpdate:value":H[1]||(H[1]=te=>f.value=te),onClick:b},{addonAfter:ft(()=>[rt(G(n),{placement:"bottomLeft",trigger:"click",modelValue:d.value,"onUpdate:modelValue":H[0]||(H[0]=te=>d.value=te),overlayClassName:`${G(A)}-popover`},{title:ft(()=>[$i("div",Q0,[rt(G(t),{placeholder:G(m)("component.icon.search"),onChange:G(v),allowClear:""},null,8,["placeholder","onChange"])])]),content:ft(()=>[G(F).length?(it(),dn("div",Z0,[rt(G(u0),{class:"border border-solid border-t-0"},{default:ft(()=>[$i("ul",eb,[(it(!0),dn(_s,null,Gn(G(F),te=>(it(),dn("li",{key:te,class:Bo([f.value===te?"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:ue=>T(te),title:te},[u?(it(),Bt(uu,{key:0,name:te},null,8,["name"])):(it(),Bt(hu,{key:1,icon:te},null,8,["icon"]))],10,tb))),128))])]),_:1}),G(D)>=V.pageSize?(it(),dn("div",nb,[rt(G(s),{showLessItems:"",size:"small",pageSize:V.pageSize,total:G(D),onChange:P},null,8,["pageSize","total"])])):rs("",!0)])):(it(),dn("div",ib,[rt(G(r))]))]),default:ft(()=>[$i("div",{ref_key:"trigger",ref:y},[u&&f.value?(it(),dn("span",sb,[rt(uu,{name:f.value},null,8,["name"])])):(it(),Bt(hu,{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 dr(this),r=new dr(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 dr(this,e)}iterRange(e,t=this.length){return new Af(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 Tf(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=ob(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 lb(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new zt(yu(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=So(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=So(this.text,So(n.text,yu(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&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=n),e<a&&t>r&&(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<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=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<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,n),c=this.lines-o.lines+a.lines;if(a.lines<c>>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;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=n),e<a&&t>o&&(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 ob(i){let e=-1;for(let t of i)e+=t.length+1;return e}function So(i,e,t=0,n=1e9){for(let s=0,r=0,o=!0;r<i.length&&s<=n;r++){let l=i[r],a=s+l.length;a>=t&&(a>n&&(l=l.slice(0,n-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function yu(i,e,t){return So(i,[""],e,t)}class dr{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?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 Af{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new dr(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 Tf{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()},dr.prototype[Symbol.iterator]=Af.prototype[Symbol.iterator]=Tf.prototype[Symbol.iterator]=function(){return this});class lb{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;i<Ps.length;i++)Ps[i]+=Ps[i-1];function ab(i){for(let e=1;e<Ps.length;e+=2)if(Ps[e]>i)return Ps[e-1]<=i;return!1}function wu(i){return i>=127462&&i<=127487}const vu=8205;function nn(i,e,t=!0,n=!0){return(t?Mf:cb)(i,e,n)}function Mf(i,e,t){if(e==i.length)return e;e&&Df(i.charCodeAt(e))&&Of(i.charCodeAt(e-1))&&e--;let n=Zt(i,e);for(e+=$n(n);e<i.length;){let s=Zt(i,e);if(n==vu||s==vu||t&&ab(s))e+=$n(s),n=s;else if(wu(s)){let r=0,o=e-2;for(;o>=0&&wu(Zt(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function cb(i,e,t){for(;e>0;){let n=Mf(i,e-2,t);if(n<e)return n;e--}return 0}function Df(i){return i>=56320&&i<57344}function Of(i){return i>=55296&&i<56320}function Zt(i,e){let t=i.charCodeAt(e);if(!Of(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Df(n)?(t-55296<<10)+(n-56320)+65536:t}function Za(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 ta=/\r\n?|\n/;var gn=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(gn||(gn={}));class di{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,s,r),s+=r):s+=o,n+=r}}iterChangedRanges(e,t=!1){na(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];s<0?e.push(n,s):e.push(s,n)}return new di(e)}composeDesc(e){return this.empty?e:e.empty?this:Ef(this,e)}mapDesc(e,t=!1){return e.empty?this:ia(this,e,t)}mapPos(e,t=-1,n=gn.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=s+l;if(a<0){if(c>e)return r+(e-s);r+=l}else{if(n!=gn.Simple&&c>=e&&(n==gn.TrackDel&&s<e&&c>e||n==gn.TrackBefore&&s<e||n==gn.TrackAfter&&c>e))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<this.sections.length&&s<=t;){let r=this.sections[n++],o=this.sections[n++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+n+(s>=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 na(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return ia(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;n.length<a;)n.push(yt.empty);n.push(o?e.slice(r,r+o):yt.empty)}r+=o}return new Ut(t,n)}compose(e){return this.empty?e:e.empty?this:Ef(this,e,!0)}map(e,t=!1){return e.empty?this:ia(this,e,t,!0)}iterChanges(e,t=!1){na(this,e,t)}get desc(){return di.create(this.sections)}filter(e){let t=[],n=[],s=[],r=new wr(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let u=Math.min(r.len,a-l);ln(s,u,-1);let h=r.ins==-1?-1:r.off==0?r.ins:0;ln(t,u,h),h>0&&Ri(n,t,r.text),r.forward(u),l+=u}let c=e[o++];for(;l<c;){if(r.done)break e;let u=Math.min(r.len,c-l);ln(t,u,-1),ln(s,u,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(u),l+=u}}return{changes:new Ut(t,n),filtered:di.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],s=this.sections[t+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[t>>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;o<t&&ln(s,t-o,-1);let h=new Ut(s,r);l=l?l.compose(h.map(l)):h,s=[],r=[],o=0}function c(u){if(Array.isArray(u))for(let h of u)c(h);else if(u instanceof Ut){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);a(),l=l?l.compose(u.map(l)):u}else{let{from:h,to:f=h,insert:d}=u;if(h>f||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||ta)):d:yt.empty,y=p.length;if(h==f&&y==0)return;h<o&&a(),h>o&&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;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;n.length<s;)n.push(yt.empty);n[s]=yt.of(r.slice(1)),t.push(r[0],n[s].length)}}}return new Ut(t,n)}static createSet(e,t){return new Ut(e,t)}}function ln(i,e,t,n=!1){if(e==0&&t<=0)return;let s=i.length-2;s>=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<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(yt.empty);i.push(t)}}function na(i,e,t){let n=i.inserted;for(let s=0,r=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)s+=l,r+=l;else{let c=s,u=r,h=yt.empty;for(;c+=l,u+=a,a&&n&&(h=h.append(n[o-2>>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 ia(i,e,t,n=!1){let s=[],r=n?[]:null,o=new wr(i),l=new wr(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<o.len||l.len==o.len&&!t))){let c=l.len;for(ln(s,l.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=u&&(ln(s,0,o.ins),r&&Ri(r,s,o.text),a=o.i),o.forward(u),c-=u}l.next()}else if(o.ins>=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.len<u)u-=l.len,l.next();else break;ln(s,c,a<o.i?o.ins:0),r&&a<o.i&&Ri(r,s,o.text),a=o.i,o.forward(o.len-u)}else{if(o.done&&l.done)return r?Ut.createSet(s,r):di.create(s);throw new Error("Mismatched change set lengths")}}function Ef(i,e,t=!1){let n=[],s=t?[]:null,r=new wr(i),o=new wr(e);for(let l=!1;;){if(r.done&&o.done)return s?Ut.createSet(n,s):di.create(n);if(r.ins==0)ln(n,r.len,0,l),r.next();else if(o.len==0&&!o.done)ln(n,0,o.ins,l),s&&Ri(s,n,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),c=n.length;if(r.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;ln(n,a,u,l),s&&u&&Ri(s,n,o.text)}else o.ins==-1?(ln(n,r.off?0:r.len,a,l),s&&Ri(s,n,r.textBit(a))):(ln(n,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&Ri(s,n,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>c),r.forward2(a),o.forward(a)}}}}class wr{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>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 os{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 os(n,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return ce.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ce.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 ce.range(e.anchor,e.head)}static create(e,t,n){return new os(e,t,n)}}class ce{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ce.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;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ce([this.main],0)}addRange(e,t=!0){return ce.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,ce.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.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 ce(e.ranges.map(t=>os.fromJSON(t)),e.main)}static single(e,t=e){return new ce([ce.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;s<e.length;s++){let r=e[s];if(r.empty?r.from<=n:r.from<n)return ce.normalized(e.slice(),t);n=r.to}return new ce(e,t)}static cursor(e,t=0,n,s){return os.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(s!=null?s:16777215)<<6)}static range(e,t,n,s){let r=(n!=null?n:16777215)<<6|(s==null?7:Math.min(6,s));return t<e?os.create(t,e,48|r):os.create(e,t,(t>e?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;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?ce.range(a,l):ce.range(l,a))}}return new ce(e,t)}}function Ff(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let ec=0;class Ne{constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=ec++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new Ne(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:tc),!!e.static,e.enables)}of(e){return new Co([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Co(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Co(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function tc(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class Co{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=ec++}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)||sa(h,u)){let d=n(h);if(l?!ku(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=Lo(f,p);if(this.dependencies.every(b=>b instanceof Ne?f.facet(b)===h.facet(b):b instanceof rn?f.field(b,!1)==h.field(b,!1):!0)||(l?ku(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 ku(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function sa(i,e){let t=!1;for(let n of e)pr(i,n)&1&&(t=!0);return t}function ub(i,e,t){let n=t.map(a=>i[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;u<n.length;u++){let h=Lo(a,n[u]);if(s[u]==2)for(let f of h)c.push(f);else c.push(h)}return e.combine(c)}return{create(a){for(let c of n)pr(a,c);return a.values[o]=l(a),1},update(a,c){if(!sa(a,r))return 0;let u=l(a);return e.compare(u,a.values[o])?0:(a.values[o]=u,1)},reconfigure(a,c){let u=sa(a,n),h=c.config.facets[e.id],f=c.facet(e);if(h&&!u&&tc(t,h))return a.values[o]=f,0;let d=l(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const xu=Ne.define({static:!0});class rn{constructor(e,t,n,s,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new rn(ec++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(xu).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,xu.of({field:this,create:e})]}get extension(){return this}}const ns={lowest:4,low:3,default:2,high:1,highest:0};function er(i){return e=>new Pf(e,i)}const vs={highest:er(ns.highest),high:er(ns.high),default:er(ns.default),low:er(ns.low),lowest:er(ns.lowest)};class Pf{constructor(e,t){this.inner=e,this.prec=t}}class _r{of(e){return new ra(this,e)}reconfigure(e){return _r.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ra{constructor(e,t){this.compartment=e,this.inner=t}}class Io{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<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let s=[],r=Object.create(null),o=new Map;for(let f of hb(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,tc(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=>ub(b,p,d))}}let h=c.map(f=>f(l));return new Io(e,o,h,l,a,r)}}function hb(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 ra&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let c of o)r(c,l);else if(o instanceof ra){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 Pf)r(o.inner,o.prec);else if(o instanceof rn)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Co)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,ns.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,ns.default),n.reduce((o,l)=>o.concat(l))}function pr(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 Lo(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const Bf=Ne.define(),oa=Ne.define({combine:i=>i.some(e=>e),static:!0}),Rf=Ne.define({combine:i=>i.length?i[0]:void 0,static:!0}),Nf=Ne.define(),If=Ne.define(),Lf=Ne.define(),$f=Ne.define({combine:i=>i.length?i[0]:!1});class Si{constructor(e,t){this.type=e,this.value=t}static define(){return new fb}}class fb{of(e){return new Si(this,e)}}class db{constructor(e){this.map=e}of(e){return new nt(this,e)}}class nt{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 nt(this.type,t)}is(e){return this.type==e}static define(e={}){return new db(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}}nt.reconfigure=nt.define();nt.appendConfig=nt.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&&Ff(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 pb(i,e){let t=[];for(let n=0,s=0;;){let r,o;if(n<i.length&&(s==e.length||e[s]>=i[n]))r=i[n++],o=i[n++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function _f(i,e,t){var n;let s,r,o;return t?(s=e.changes,r=Ut.empty(e.changes.length),o=i.changes.compose(e.changes)):(s=e.changes.map(i.changes),r=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(n=i.selection)===null||n===void 0?void 0:n.map(s),effects:nt.mapEffects(i.effects,s).concat(nt.mapEffects(e.effects,r)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function la(i,e,t){let n=e.selection,s=Bs(e.annotations);return e.userEvent&&(s=s.concat(Kt.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ut?e.changes:Ut.of(e.changes||[],t,i.facet(Rf)),selection:n&&(n instanceof ce?n:ce.single(n.anchor,n.head)),effects:Bs(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function zf(i,e,t){let n=la(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;n=_f(n,la(i,e[r],o?n.changes.newLength:i.doc.length),o)}let s=Kt.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return gb(t?mb(s):s)}function mb(i){let e=i.startState,t=!0;for(let s of e.facet(Nf)){let r=s(i);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:pb(t,r))}if(t!==!0){let s,r;if(t===!1)r=i.changes.invertedDesc,s=Ut.empty(e.doc.length);else{let o=i.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}i=Kt.create(e,s,i.selection&&i.selection.map(r),nt.mapEffects(i.effects,r),i.annotations,i.scrollIntoView)}let n=e.facet(If);for(let s=n.length-1;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=zf(e,Bs(r),!1)}return i}function gb(i){let e=i.startState,t=e.facet(Lf),n=i;for(let s=t.length-1;s>=0;s--){let r=t[s](i);r&&Object.keys(r).length&&(n=_f(n,la(e,r,i.changes.newLength),!0))}return n==i?i:Kt.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const bb=[];function Bs(i){return i==null?bb: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 yb=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let aa;try{aa=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(i){}function wb(i){if(aa)return aa.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||yb.test(t)))return!0}return!1}function vb(i){return e=>{if(!/\S/.test(e))return It.Space;if(wb(e))return It.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[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;l<this.config.dynamicSlots.length;l++)pr(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return pr(this,n),Lo(this,n)}update(...e){return zf(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:s}=t;for(let l of e.effects)l.is(_r.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,c)=>s.set(c,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(nt.reconfigure)?(t=null,n=l.value):l.is(nt.appendConfig)&&(t=null,n=Bs(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=Io.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(oa)?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:ce.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;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),u=c.map(s);for(let f=0;f<l;f++)r[f]=r[f].map(u);let h=s.mapDesc(c,!0);r.push(a.range.map(h)),s=s.compose(u),o=nt.mapEffects(o,u).concat(nt.mapEffects(Bs(a.effects),h))}return{changes:s,selection:ce.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ut?e:Ut.of(e,this.doc.length,this.facet(ht.lineSeparator))}toText(e){return yt.of(e.split(this.facet(ht.lineSeparator)||ta))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(pr(this,t),Lo(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof rn&&this.config.address[s.id]!=null&&(t[n]=s.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let r in n)if(Object.prototype.hasOwnProperty.call(e,r)){let o=n[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return ht.create({doc:e.doc,selection:ce.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Io.resolve(e.extensions||[],new Map),n=e.doc instanceof yt?e.doc:yt.of((e.doc||"").split(t.staticFacet(ht.lineSeparator)||ta)),s=e.selection?e.selection instanceof ce?e.selection:ce.single(e.selection.anchor,e.selection.head):ce.single(0);return Ff(s,n.length),t.staticFacet(oa)||(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($f)}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(Bf))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return vb(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(;l<s;){let a=nn(t,l);if(r(t.slice(l,a))!=It.Word)break;l=a}return o==l?null:ce.range(o+n,l+n)}}ht.allowMultipleSelections=oa;ht.tabSize=Ne.define({combine:i=>i.length?i[0]:4});ht.lineSeparator=Rf;ht.readOnly=$f;ht.phrases=Ne.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=Bf;ht.changeFilter=Nf;ht.transactionFilter=If;ht.transactionExtender=Lf;_r.reconfigure=nt.define();function pi(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 ca.create(e,t,this)}}ds.prototype.startSide=ds.prototype.endSide=0;ds.prototype.point=!1;ds.prototype.mapMode=gn.TrackDel;let ca=class Vf{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Vf(e,t,n)}};function ua(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class nc{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);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t){let n=[],s=[],r=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],u=this.from[a]+e,h=this.to[a]+e,f,d;if(u==h){let p=t.mapPos(u,c.startSide,c.mapMode);if(p==null||(f=d=p,c.startSide!=c.endSide&&(d=t.mapPos(u,c.endSide),d<f)))continue}else if(f=t.mapPos(u,c.startSide),d=t.mapPos(h,c.endSide),f>d||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 nc(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(ua)),this.isEmpty)return t.length?gt.of(t):this;let l=new Hf(this,null,-1).goto(0),a=0,c=[],u=new ji;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let h=t[a++];u.addInner(h.from,h.to,h.value)||c.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||s>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&u.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||s>l.to||r<l.from||o(l.from,l.to,l.value))&&(u.addInner(l.from,l.to,l.value)||c.push(ca.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?gt.empty:this.nextLayer.update({add:c,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],s=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],c=e.touchesRange(l,l+a.length);if(c===!1)s=Math.max(s,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:u,pos:h}=a.map(l,e);u&&(s=Math.max(s,u.maxPoint),t.push(u),n.push(h))}}let r=this.nextLayer.map(e);return t.length==0?r:new gt(n,t,r||gt.empty,s)}between(e,t,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(t>=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 vr.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return vr.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=Su(o,l,n),c=new tr(o,a,r),u=new tr(l,a,r);n.iterGaps((h,f,d)=>Cu(c,h,u,f,d,s)),n.empty&&n.length==0&&Cu(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=Su(r,o),a=new tr(r,l,0).goto(n),c=new tr(o,l,0).goto(n);for(;;){if(a.to!=c.to||!ha(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 tr(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.pointFrom<t?u.length+1:o.point.startSide<0?u.length:Math.min(u.length,a);s.point(l,c,o.point,u,h,o.pointRank),a=Math.min(o.openEnd(c),u.length)}else c>l&&(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 ji;for(let s of e instanceof ca?[e]:t?kb(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 kb(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(ua(e,n)>0)return i.slice().sort(ua);e=n}return i}gt.empty.nextLayer=gt.empty;class ji{finishChunk(e){this.chunks.push(new nc(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 ji)).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 Su(i,e,t){let n=new Map;for(let r of i)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&n.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=n.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+r.chunk[o].length))&&s.add(r.chunk[o])}return s}class Hf{constructor(e,t,n,s=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class vr{constructor(e){this.heap=e}static from(e,t=null,n=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&s.push(new Hf(o,t,n,r));return s.length==1?s[0]:new vr(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--)Dl(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--)Dl(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(),Dl(this.heap,0)}}}function Dl(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let s=i[n];if(n+1<i.length&&s.compare(i[n+1])>=0&&(s=i[n+1],n++),t.compare(s)<0)break;i[n]=t,i[e]=s,e=n}}class tr{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=vr.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){Xr(this.active,e),Xr(this.activeTo,e),Xr(this.activeRank,e),this.minActive=Au(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;Jr(this.active,t,n),Jr(this.activeTo,t,s),Jr(this.activeRank,t,r),e&&Jr(e,t,this.cursor.from),this.minActive=Au(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&&Xr(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<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[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 Cu(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))&&ha(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,h,i.point,t.point):h>l&&!ha(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 ha(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!i[t].eq(e[t]))return!1;return!0}function Xr(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function Jr(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Au(i,e){let t=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||i[s].endSide-i[t].endSide)<0&&(t=s,n=e[s]);return t}function Js(i,e,t=i.length){let n=0;for(let s=0;s<t;)i.charCodeAt(s)==9?(n+=e-n%e,s++):(n++,s=nn(i,s));return n}function fa(i,e,t,n){for(let s=0,r=0;;){if(r>=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 da="ͼ",Tu=typeof Symbol=="undefined"?"__"+da:Symbol.for(da),pa=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Mu=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{};class qi{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=Mu[Tu]||1;return Mu[Tu]=e+1,da+e.toString(36)}static mount(e,t,n){let s=e[pa],r=n&&n.nonce;s?r&&s.setNonce(r):s=new xb(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let Du=new Map;class xb{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=Du.get(n);if(r)return e[pa]=r;this.sheet=new s.CSSStyleSheet,Du.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[pa]=this}mount(e,t){let n=this.sheet,s=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),n)for(let c=0;c<l.rules.length;c++)n.insertRule(l.rules[c],s++)}else{for(;r<a;)s+=this.modules[r++].rules.length;s+=l.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
- `;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Ui={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},kr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Sb=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Cb=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var en=0;en<10;en++)Ui[48+en]=Ui[96+en]=String(en);for(var en=1;en<=24;en++)Ui[en+111]="F"+en;for(var en=65;en<=90;en++)Ui[en]=String.fromCharCode(en+32),kr[en]=String.fromCharCode(en);for(var Ol in Ui)kr.hasOwnProperty(Ol)||(kr[Ol]=Ui[Ol]);function Ab(i){var e=Sb&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Cb&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?kr:Ui)[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 xr(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function ma(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Tb(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ao(i,e){if(!e.anchorNode)return!1;try{return ma(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 mr(i,e,t,n){return t?Ou(i,e,t,n,-1)||Ou(i,e,t,n,1):!1}function ps(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function $o(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function Ou(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:vi(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?vi(i):0}else return!1}}function vi(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function ul(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Mb(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 Wf(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 Db(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=Mb(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 A=u.getBoundingClientRect();({scaleX:p,scaleY:y}=Wf(u,A)),f={left:A.left,right:A.left+u.clientWidth*p,top:A.top,bottom:A.top+u.clientHeight*y}}let b=0,m=0;if(s=="nearest")e.top<f.top?(m=-(f.top-e.top+o),t>0&&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-m<f.top&&(m=-(f.top+m-e.top+o)));else{let A=e.bottom-e.top,v=f.bottom-f.top;m=(s=="center"&&A<=v?e.top+A/2-v/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-v+o)-f.top}if(n=="nearest"?e.left<f.left?(b=-(f.left-e.left+r),t>0&&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.left<f.left+b&&(b=-(f.left+b-e.left+r))):b=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==l?e.left-r:e.right-(f.right-f.left)+r)-f.left,b||m)if(d)c.scrollBy(b,m);else{let A=0,v=0;if(m){let F=u.scrollTop;u.scrollTop+=m/y,v=(u.scrollTop-F)*y}if(b){let F=u.scrollLeft;u.scrollLeft+=b/p,A=(u.scrollLeft-F)*p}e={left:e.left-A,top:e.top-v,right:e.right-A,bottom:e.bottom-v},A&&Math.abs(A-b)<1&&(n="nearest"),v&&Math.abs(v-m)<1&&(s="nearest")}if(d)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Ob(i){let e=i.ownerDocument;for(let t=i.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class Eb{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?vi(t):0),n,Math.min(e.focusOffset,n?vi(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let Ss=null;function jf(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;t<e.length;){let n=e[t++],s=e[t++],r=e[t++];n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}}}let Eu;function ms(i,e,t=e){let n=Eu||(Eu=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function Rs(i,e,t,n){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,i.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,i.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Fb(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function qf(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function Pb(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,vi(t));;)if(n){if(t.nodeType!=1)return!1;let s=t.childNodes[n-1];s.contentEditable=="false"?n--:(t=s,n=vi(t))}else{if(t==i)return!0;n=ps(t),t=t.parentNode}}function Uf(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function Kf(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=vi(t)}else if(t.parentNode&&!$o(t))n=ps(t),t=t.parentNode;else return null}}function Gf(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!$o(t))n=ps(t)+1,t=t.parentNode;else return null}}class an{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new an(e.parentNode,ps(e),t)}static after(e,t){return new an(e.parentNode,ps(e)+1,t)}}const ic=[];class At{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,s=null,r;for(let o of this.children){if(o.flags&7){if(!o.dom&&(r=s?s.nextSibling:n.firstChild)){let l=At.get(r);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(r)}o.sync(e,t),o.flags&=-8}if(r=s?s.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&r!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;r&&r!=o.dom;)r=Fu(r);else n.insertBefore(o.dom,r);s=o.dom}for(r=s?s.nextSibling:n.firstChild,r&&t&&t.node==n&&(t.written=!0);r;)r=Fu(r)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let s=vi(e)==0?0:t==0?-1:1;for(;;){let r=e.parentNode;if(r==this.dom)break;s==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?s=-1:s=1),e=r}s<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!At.get(n);)n=n.nextSibling;if(!n)return this.length;for(let s=0,r=0;;s++){let o=this.children[s];if(o.dom==n)return r;r+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let s=-1,r=-1,o=-1,l=-1;for(let a=0,c=n,u=n;a<this.children.length;a++){let h=this.children[a],f=c+h.length;if(c<e&&f>t)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<this.children.length&&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=ic){this.markDirty();for(let s=e;s<t;s++){let r=this.children[s];r.parent==this&&n.indexOf(r)<0&&r.destroy()}this.children.splice(e,t-e,...n);for(let s=0;s<n.length;s++)n[s].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Yf(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,s,r,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}At.prototype.breakAfter=0;function Fu(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class Yf{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.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 Xf(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(n<c.length){let d=c[n];d&&(s<d.length||d.breakAfter&&(h!=null&&h.breakAfter))?(e==n&&(d=d.split(s),s=0),!f&&h&&d.merge(0,s,h,!0,0,a)?r[r.length-1]=d:((s||d.children.length&&!d.children[0].length)&&d.merge(0,s,null,!1,0,a),r.push(d))):d!=null&&d.breakAfter&&(h?h.breakAfter=1:o=1),n++}for(u&&(u.breakAfter=o,t>0&&(!o&&r.length&&u.merge(t,u.length,r[0],!1,l,0)?u.breakAfter=r.shift().breakAfter:(t<u.length||u.children.length&&u.children[u.children.length-1].length==0)&&u.merge(t,u.length,null,!1,l,0),e++));e<n&&r.length;)if(c[n-1].become(r[r.length-1]))n--,r.pop(),a=r.length?0:l;else if(c[e].become(r[0]))e++,r.shift(),l=r.length?0:a;else break;!r.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||r.length)&&i.replaceChildren(e,n,r)}}function Jf(i,e,t,n,s,r){let o=i.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:c,off:u}=o.findPos(e,-1),h=e-t;for(let f of n)h+=f.length;i.length+=h,Xf(i,c,u,l,a,n,0,s,r)}let kn=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},ga=typeof document!="undefined"?document:{documentElement:{style:{}}};const ba=/Edge\/(\d+)/.exec(kn.userAgent),Qf=/MSIE \d/.test(kn.userAgent),ya=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kn.userAgent),hl=!!(Qf||ya||ba),Pu=!hl&&/gecko\/(\d+)/i.test(kn.userAgent),El=!hl&&/Chrome\/(\d+)/.exec(kn.userAgent),Bu="webkitFontSmoothing"in ga.documentElement.style,Zf=!hl&&/Apple Computer/.test(kn.vendor),Ru=Zf&&(/Mobile\/\w+/.test(kn.userAgent)||kn.maxTouchPoints>2);var Re={mac:Ru||/Mac/.test(kn.platform),windows:/Win/.test(kn.platform),linux:/Linux|X11/.test(kn.platform),ie:hl,ie_version:Qf?ga.documentMode||6:ya?+ya[1]:ba?+ba[1]:0,gecko:Pu,gecko_version:Pu?+(/Firefox\/(\d+)/.exec(kn.userAgent)||[0,0])[1]:0,chrome:!!El,chrome_version:El?+El[1]:0,ios:Ru,android:/Android\b/.test(kn.userAgent),webkit:Bu,safari:Zf,webkit_version:Bu?+(/\bAppleWebKit\/(\d+)/.exec(kn.userAgent)||[0,0])[1]:0,tabSize:ga.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Bb=256;class Xn 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 Xn)||this.length-(t-e)+n.length>Bb||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 Xn(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 Rb(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(qf(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||t<this.length&&o<=0)?!1:(Jf(this,e,t,n?n.children.slice():[],r-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,s=-1,r=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),s<0&&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 ed(this,e)}coordsAt(e,t){return nd(this,e,t)}}function Rb(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?Re.chrome||Re.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):t<0?s--:r<n&&r++;let l=ms(i,s,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return Re.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),o?ul(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||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof Ni&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return yt.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,s=this.posAtStart;return n?n.slice(s,s+this.length):yt.empty}domAtPos(e){return(this.length?e==0:this.side>0)?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.top<r.bottom);l+=o?-1:1);return ul(r,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ws extends At{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Ws&&e.side==this.side}split(){return new Ws(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?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}}Xn.prototype.children=Ni.prototype.children=Ws.prototype.children=ic;function ed(i,e){let t=i.dom,{children:n}=i,s=0;for(let r=0;s<n.length;s++){let o=n[s],l=r+o.length;if(!(l==r&&o.getSide()<=0)){if(e>r&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-r);if(e<=r)break;r=l}}for(let r=s;r>0;r--){let o=n[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r<n.length;r++){let o=n[r];if(o.dom.parentNode==t)return o.domAtPos(0)}return new an(t,0)}function td(i,e,t){let n,{children:s}=i;t>0&&e instanceof ki&&s.length&&(n=s[s.length-1])instanceof ki&&n.mark.eq(e.mark)?td(n,e.children[0],t-1):(s.push(e),e.setParent(i)),i.length+=e.length}function nd(i,e,t){let n=null,s=-1,r=null,o=-1;function l(c,u){for(let h=0,f=0;h<c.children.length&&f<=u;h++){let d=c.children[h],p=f+d.length;p>=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<u||f==p&&d.getSide()<0&&!d.isHidden)&&(n=d,s=u-f)),f=p}}l(i,e);let a=(t<0?n:r)||n||r;return a?a.coordsAt(Math.max(0,a==n?s:o),t):Nb(i)}function Nb(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=Hs(e);return t[t.length-1]||null}function wa(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}const Nu=Object.create(null);function _o(i,e,t){if(i==e)return!0;i||(i=Nu),e||(e=Nu);let n=Object.keys(i),s=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-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 va(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 Ib(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return 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),Jf(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;r<this.children.length;r++)t.append(this.children[r],0);for(;n>0&&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){_o(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){td(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=wa(t,this.attrs||{})),n&&(this.attrs=wa({class:n},this.attrs||{}))}domAtPos(e){return ed(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(qf(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&&(va(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&&(!Re.ios||!this.children.some(r=>r instanceof Xn))){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 Xn)||/[^ -~]/.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=nd(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<r){let o=(r-s.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof Ht&&this.children.length==0&&e.children.length==0&&_o(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,s=0;n<e.children.length;n++){let r=e.children[n],o=s+r.length;if(o>=t){if(r instanceof Ht)return r;if(o>t)break}s=o+r.breakAfter}return null}}class wi 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 wi)||!this.widget.compare(n.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?an.before(this.dom):an.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new wi(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return ic}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"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):yt.empty}domBoundsAround(){return null}become(e){return e instanceof wi&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}}class Ci{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var bn=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(bn||(bn={}));class _e extends ds{constructor(e,t,n,s){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=s}get heightRelevant(){return!1}static mark(e){return new zr(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Ki(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}=id(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ki(e,n,s,t,e.widget||null,!0)}static line(e){return new Vr(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 zr extends _e{constructor(e){let{start:t,end:n}=id(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 zr&&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))&&_o(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)}}zr.prototype.point=!1;class Vr extends _e{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Vr&&this.spec.class==e.spec.class&&_o(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)}}Vr.prototype.mapMode=gn.TrackBefore;Vr.prototype.point=!0;class Ki 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?gn.TrackBefore:gn.TrackAfter:gn.TrackDel}get type(){return this.startSide!=this.endSide?bn.WidgetRange:this.startSide<=0?bn.WidgetBefore:bn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ki&&Lb(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)}}Ki.prototype.point=!0;function id(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 Lb(i,e){return i==e||!!(i&&e&&i.compare(e))}function ka(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 gr{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 wi&&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(Qr(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 wi)&&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(Qr(new Xn(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 Ki){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 Ki)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new wi(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&&(e<t||n.startSide>0),u=!a.isEditable&&(e<t||r>s.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),c&&(h.append(Qr(new Ws(1),s),r),r=s.length+Math.max(0,r-s.length)),h.append(Qr(a,s),r),this.atCursorPos=u,this.pendingBuffer=u?e<t||r>s.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 gr(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 Qr(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,sc=Rt.RTL;function sd(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const $b=sd("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),_b=sd("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),xa=Object.create(null),si=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);xa[e]=t,xa[t]=-e}function rd(i){return i<=247?$b[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?_b[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const zb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ii{get dir(){return this.level%2?sc:gs}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==n)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function od(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],s=e[t];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!od(n.inner,s.inner))return!1}return!0}const Ct=[];function Vb(i,e,t,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,l=r<n.length?n[r].from:t,a=r?256:s;for(let c=o,u=a,h=a;c<l;c++){let f=rd(i.charCodeAt(c));f==512?f=u:f==8&&h==4&&(f=16),Ct[c]=f==4?2:f,f&7&&(h=f),u=f}for(let c=o,u=a,h=a;c<l;c++){let f=Ct[c];if(f==128)c<l-1&&u==Ct[c+1]&&u&24?f=Ct[c]=u:Ct[c]=256;else if(f==64){let d=c+1;for(;d<l&&Ct[d]==64;)d++;let p=c&&u==8||d<t&&Ct[d]==8?h==1?1:8:256;for(let y=c;y<d;y++)Ct[y]=p;c=d-1}else f==8&&h==1&&(Ct[c]=1);u=f,f&7&&(h=f)}}}function Hb(i,e,t,n,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let c=o?n[o-1].to:e,u=o<n.length?n[o].from:t;for(let h=c,f,d,p;h<u;h++)if(d=xa[f=i.charCodeAt(h)])if(d<0){for(let y=l-3;y>=0;y-=3)if(si[y+1]==-d){let b=si[y+2],m=b&2?s:b&4?b&1?r:s:0;m&&(Ct[h]=Ct[si[y]]=m),l=y;break}}else{if(si.length==189)break;si[l++]=h,si[l++]=f,si[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=si[b+2];if(m&2)break;if(y)si[b+2]|=2;else{if(m&4)break;si[b+2]|=4}}}}}function Wb(i,e,t,n){for(let s=0,r=n;s<=t.length;s++){let o=s?t[s-1].to:i,l=s<t.length?t[s].from:e;for(let a=o;a<l;){let c=Ct[a];if(c==256){let u=a+1;for(;;)if(u==l){if(s==t.length)break;u=t[s++].to,l=s<t.length?t[s].from:e}else if(Ct[u]==256)u++;else break;let h=r==1,f=(u<e?Ct[u]:n)==1,d=h==f?h?1:2:n;for(let p=u,y=s,b=y?t[y-1].to:i;p>a;)p==b&&(p=t[--y].from,b=y?t[y-1].to:i),Ct[--p]=d;a=u}else r=c,a++}}}function Sa(i,e,t,n,s,r,o){let l=n%2?2:1;if(n%2==s%2)for(let a=e,c=0;a<t;){let u=!0,h=!1;if(c==r.length||a<r[c].from){let y=Ct[a];y!=l&&(u=!1,h=y==16)}let f=!u&&l==1?[]:null,d=u?n:n+1,p=a;e:for(;;)if(c<r.length&&p==r[c].from){if(h)break e;let y=r[c];if(!u)for(let b=y.to,m=c+1;;){if(b==t)break e;if(m<r.length&&r[m].from==b)b=r[m++].to;else{if(Ct[b]==l)break e;break}}if(c++,f)f.push(y);else{y.from>a&&o.push(new Ii(a,y.from,d));let b=y.direction==gs!=!(d%2);Ca(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?Sa(i,a,p,n+1,s,f,o):a<p&&o.push(new Ii(a,p,d)),a=p}else for(let a=t,c=r.length;a>e;){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.to<a&&o.push(new Ii(y.to,a,d));let b=y.direction==gs!=!(d%2);Ca(i,b?n+1:n,s,y.inner,y.from,y.to,o),a=y.from}p=y.from}else{if(p==e||(u?Ct[p-1]!=l:Ct[p-1]==l))break;p--}f?Sa(i,p,a,n+1,s,f,o):p<a&&o.push(new Ii(p,a,d)),a=p}}function Ca(i,e,t,n,s,r,o){let l=e%2?2:1;Vb(i,s,r,n,l),Hb(i,s,r,n,l),Wb(s,r,n,l),Sa(i,s,r,e,t,n,o)}function jb(i,e,t){if(!i)return[new Ii(0,0,e==sc?1:0)];if(e==gs&&!t.length&&!zb.test(i))return ld(i.length);if(t.length)for(;i.length>Ct.length;)Ct[Ct.length]=256;let n=[],s=e==gs?0:1;return Ca(i,s,s,t,0,i.length,n),n}function ld(i){return[new Ii(0,i,0)]}let ad="";function qb(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));(u<a.from||u>a.to)&&(u=c),ad=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)<a.level?ce.cursor(h.side(!s,t)+i.from,h.forward(s,t)?1:-1,h.level):ce.cursor(u+i.from,a.forward(s,t)?-1:1,a.level)}function Ub(i,e,t){for(let n=e;n<t;n++){let s=rd(i.charCodeAt(n));if(s==1)return gs;if(s==2||s==4)return sc}return gs}const cd=Ne.define(),ud=Ne.define(),hd=Ne.define(),fd=Ne.define(),Aa=Ne.define(),dd=Ne.define(),pd=Ne.define(),md=Ne.define({combine:i=>i.some(e=>e)}),gd=Ne.define({combine:i=>i.some(e=>e)}),bd=Ne.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(ce.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Zr=nt.define({map:(i,e)=>i.map(e)}),yd=nt.define();function An(i,e,t){let n=i.facet(fd);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)}const Fi=Ne.define({combine:i=>i.length?i[0]:!0});let Kb=0;const or=Ne.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(Kb++,e,n,s,l=>{let a=[or.of(l)];return o&&a.push(Sr.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 Fl{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(An(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){An(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){An(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const wd=Ne.define(),rc=Ne.define(),Sr=Ne.define(),vd=Ne.define(),oc=Ne.define(),kd=Ne.define();function Iu(i,e){let t=i.state.facet(kd);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=Ub(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 xd=Ne.define();function Sd(i){let e=0,t=0,n=0,s=0;for(let r of i.state.facet(xd)){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 lr=Ne.define();class Hn{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new Hn(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.toA<n.fromA)break;n=n.join(s),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let s=0,r=0,o=0,l=0;;s++){let a=s==e.length?null:e[s],c=o-l,u=a?a.fromB:1e9;for(;r<t.length&&t[r]<u;){let h=t[r],f=t[r+1],d=Math.max(l,h),p=Math.min(u,f);if(d<=p&&new Hn(d+c,p+c,d,p).addToSet(n),f>u)break;r+=2}if(!a)return n;new Hn(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}}class zo{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 Hn(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new zo(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 Lu 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 Hn(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})=>u<this.minWidthFrom||c>this.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:!ey(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?Yb(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:c,to:u}=this.hasComposition;n=new Hn(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,(Re.ie||Re.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Qb(o,l,e.changes);return n=Hn.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=Re.chrome||Re.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<this.view.state.doc.length)for(let o of this.children)o instanceof wi&&o.widget instanceof $u&&r.push(o.dom);s.updateGaps(r)}updateChildren(e,t,n){let s=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let o=s.length-1;;o--){let l=o>=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.fromB<h&&n.range.toB>u){let F=gr.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),D=gr.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);d=F.breakAtStart,p=F.openStart,y=D.openEnd;let E=this.compositionView(n);D.breakAtStart?E.breakAfter=1:D.content.length&&E.merge(E.length,E.length,D.content[0],!1,D.openStart,0)&&(E.breakAfter=D.content[0].breakAfter,D.content.shift()),F.content.length&&E.merge(0,0,F.content[F.content.length-1],!0,0,F.openEnd)&&F.content.pop(),f=F.content.concat(E).concat(D.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:y}=gr.build(this.view.state.doc,u,h,this.decorations,this.dynamicDecorationMap));let{i:b,off:m}=r.findPos(c,1),{i:A,off:v}=r.findPos(a,-1);Xf(this,A,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(yd)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new Xn(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&&Ao(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(Re.gecko&&l.empty&&!this.hasComposition&&Gb(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||(!mr(a.node,a.offset,u.anchorNode,u.anchorOffset)||!mr(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{Re.android&&Re.chrome&&this.dom.contains(u.focusNode)&&Zb(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=xr(this.view.root);if(h)if(l.empty){if(Re.gecko){let f=Xb(a.node,a.offset);if(f&&f!=3){let d=(f==1?Kf:Gf)(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&&mr(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=xr(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<t.childNodes.length;s++){let r=At.get(t.childNodes[s]);r instanceof Ht&&(n=r.domAtPos(0))}for(let s=e.offset-1;!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<this.children.length-1;){let s=this.children[t];if(n<s.length||s instanceof Ht)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,s=0;for(let r=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=r-l.breakAfter,c=a-l.length;if(a<e)break;if(c<=e&&(c<e||l.covers(-1))&&(a>e||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 wi&&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 Xn))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;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Rt.LTR;for(let c=0,u=0;u<this.children.length;u++){let h=this.children[u],f=c+h.length;if(f>s)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 Yf(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 $u(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(Sr).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(vd).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];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(bd))try{if(c(this.view,e.range,e))return!0}catch(u){An(this.view.state,u,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.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=Sd(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;Db(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Rt.LTR)}}function Gb(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}class $u 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}}function Cd(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=Kf(t.focusNode,t.focusOffset),s=Gf(t.focusNode,t.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let l=At.get(s.node);if(!l||l instanceof Xn&&l.text!=s.node.nodeValue)r=s;else if(i.docView.lastCompositionAfterCursor){let a=At.get(n.node);!a||a instanceof Xn&&a.text!=n.node.nodeValue||(r=s)}}if(i.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Yb(i,e,t){let n=Cd(i,t);if(!n)return null;let{node:s,from:r,to:o}=n,l=s.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,c=new Hn(a.mapPos(r),a.mapPos(o),r,o),u=[];for(let h=s.parentNode;;h=h.parentNode){let f=At.get(h);if(f instanceof ki)u.push({node:h,deco:f.mark});else{if(f instanceof Ht||h.nodeName=="DIV"&&h.parentNode==i.contentDOM)return{range:c,text:s,marks:u,line:h};if(h!=i.contentDOM)u.push({node:h,deco:new zr({inclusive:!0,attributes:Ib(h),tagName:h.tagName.toLowerCase()})});else return null}}}function Xb(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}let Jb=class{constructor(){this.changes=[]}compareRange(e,t){ka(e,t,this.changes)}comparePoint(e,t){ka(e,t,this.changes)}};function Qb(i,e,t){let n=new Jb;return gt.compare(i,e,t,n),n.changes}function Zb(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function ey(i,e){let t=!1;return e&&i.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(t=!0)}),t}function ty(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return ce.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(;l<s.length;){let c=nn(s.text,l);if(n(s.text.slice(l,c))!=a)break;l=c}return ce.range(o+s.from,l+s.from)}function ny(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function iy(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function Pl(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function _u(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function zu(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Ta(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;b<y.length;b++){let m=y[b];s&&Pl(s,m)&&(m=_u(zu(m,s.bottom),s.top));let A=ny(e,m),v=iy(t,m);if(A==0&&v==0)return p.nodeType==3?Vu(p,e,t):Ta(p,e,t);if(!n||o>v||o==v&&r>A){n=p,s=m,r=A,o=v;let F=v?t<m.top?-1:1:A?e<m.left?-1:1:0;l=!F||(F>0?b<y.length-1:b>0)}A==0?t>m.bottom&&(!u||u.bottom<m.bottom)?(a=p,u=m):t<m.top&&(!h||h.top>m.top)&&(c=p,h=m):u&&Pl(u,m)?u=zu(u,m.bottom):h&&Pl(h,m)&&(h=_u(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 Vu(n,f,t);if(l&&n.contentEditable!="false")return Ta(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 Vu(i,e,t){let n=i.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let a=ms(i,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(u.top==u.bottom)continue;o||(o=e-u.left);let h=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&h<r){let f=e>=(u.left+u.right)/2,d=f;if((Re.chrome||Re.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 Ad(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 F=i.viewState.heightOracle.textHeight/2,D=!1;a=i.elementAtHeight(f),a.type!=bn.Text;)for(;f=n>0?a.bottom+F:a.top-F,!(f>=0&&f<=c);){if(D)return t?null:0;D=!0,n=-n}h=l+f;let d=a.from;if(d<i.viewport.from)return i.viewport.from==0?0:t?null:Hu(i,o,a,u,h);if(d>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Hu(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,A=-1;if(b&&((s=i.docView.nearest(b))===null||s===void 0?void 0:s.isEditable)!=!1){if(p.caretPositionFromPoint){let F=p.caretPositionFromPoint(u,h);F&&({offsetNode:m,offset:A}=F)}else if(p.caretRangeFromPoint){let F=p.caretRangeFromPoint(u,h);F&&({startContainer:m,startOffset:A}=F,(!i.contentDOM.contains(m)||Re.safari&&sy(m,A,u)||Re.chrome&&ry(m,A,u))&&(m=void 0))}}if(!m||!i.docView.dom.contains(m)){let F=Ht.find(i.docView,d);if(!F)return f>a.top+a.height/2?a.to:a.from;({node:m,offset:A}=Ta(F.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 F=v.dom.getBoundingClientRect();return e.y<F.top||e.y<=F.bottom&&e.x<=(F.left+F.right)/2?v.posAtStart:v.posAtEnd}else return v.localPosFromDOM(m,A)+v.posAtStart}function Hu(i,e,t,n,s){let r=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.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+fa(o,r,i.state.tabSize)}function sy(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 ry(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 Ma(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==bn.Text))return n}return t}function oy(i,e,t,n){let s=Ma(i,e.head),r=!n||s.type!=bn.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 ce.cursor(a,t?-1:1)}return ce.cursor(t?s.to:s.from,t?-1:1)}function Wu(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=qb(s,r,o,l,t),u=ad;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 ly(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 ay(i,e,t,n){let s=e.head,r=t?1:-1;if(s==(t?i.state.doc.length:0))return ce.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=Ad(i,{x:h,y:p},!1,r);if(p<a.top||p>a.bottom||(r<0?y<s:y>s)){let b=i.docView.coordsForChar(y),m=!b||p<b.top?-1:1;return ce.cursor(y,m,void 0,o)}}}function To(i,e,t){for(;;){let n=0;for(let s of i)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=n||t||(e-r<o-e?-1:1);e=a<0?r:o,n=a}});if(!n)return e}}function Bl(i,e,t){let n=To(i.state.facet(oc).map(s=>s(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:ce.cursor(n,n<t.from?1:-1)}class cy{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,Re.safari&&e.contentDOM.addEventListener("input",()=>null),Re.gecko&&Ay(e.contentDOM.ownerDocument)}handleEvent(e){!by(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=uy(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&&Md.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Re.android&&Re.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return Re.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Td.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||hy.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.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Rs(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:Re.safari&&!Re.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){An(t.state,s)}}}function uy(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 Jn)t(n).handlers.push(Jn[n]);for(let n in jn)t(n).observers.push(jn[n]);return e}const Td=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],hy="dthko",Md=[16,17,18,20,91,92,224,225],eo=6;function to(i){return Math.max(0,i)*.7+8}function fy(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class dy{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.scrollParent=Ob(e.contentDOM),this.atoms=e.state.facet(oc).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)&&py(e,t),this.dragging=gy(e,t)&&Fd(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&fy(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,s=0,r=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=Sd(this.view);e.clientX-o.left<=r.left+eo?n=-to(r.left-e.clientX):e.clientX+o.right>=r.right-eo&&(n=to(e.clientX-r.right)),e.clientY-o.top<=r.top+eo?s=-to(r.top-e.clientY):e.clientY+o.bottom>=r.bottom-eo&&(s=to(e.clientY-r.bottom)),this.setScrollSpeed(n,s)}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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],r=null;if(s.empty){let o=To(this.atoms,s.from,0);o!=s.from&&(r=ce.cursor(o,-1))}else{let o=To(this.atoms,s.from,-1),l=To(this.atoms,s.to,1);(o!=s.from||l!=s.to)&&(r=ce.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?ce.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function py(i,e){let t=i.state.facet(cd);return t.length?t[0](e):Re.mac?e.metaKey:e.ctrlKey}function my(i,e){let t=i.state.facet(ud);return t.length?t[0](e):Re.mac?!e.altKey:!e.ctrlKey}function gy(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=xr(i.root);if(!n||n.rangeCount==0)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function by(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 Jn=Object.create(null),jn=Object.create(null),Dd=Re.ie&&Re.ie_version<15||Re.ios&&Re.webkit_version<604;function yy(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(),Od(i,t.value)},50)}function Od(i,e){let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Da!=null&&t.selection.ranges.every(a=>a.empty)&&Da==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:ce.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:ce.cursor(a.from+c.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}jn.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Jn.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);jn.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};jn.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Jn.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(hd))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=ky(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new dy(i,e,t,n)),n&&i.observer.ignore(()=>{jf(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 ce.cursor(e,t);if(n==2)return ty(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 l<i.state.doc.length&&l==r.to&&l++,ce.range(o,l)}}let Ed=(i,e)=>i>=e.top&&i<=e.bottom,Uu=(i,e,t)=>Ed(e,t)&&i>=t.left&&i<=t.right;function wy(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&&Uu(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&Uu(t,n,l)?1:o&&Ed(n,o)?-1:1}function Ku(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:wy(i,t,e.clientX,e.clientY)}}const vy=Re.ie&&Re.ie_version<=11;let Gu=null,Yu=0,Xu=0;function Fd(i){if(!vy)return i.detail;let e=Gu,t=Xu;return Gu=i,Xu=Date.now(),Yu=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Yu+1)%3:1}function ky(i,e){let t=Ku(i,e),n=Fd(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=Ku(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=f<u.from?ce.range(f,d):ce.range(d,f)}return o?s.replaceRange(s.main.extend(u.from,u.to)):l&&n==1&&s.ranges.length>1&&(c=xy(s,a.pos))?c:l?s.addRange(u):ce.create([u])}}}function xy(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:s}=i.ranges[t];if(n<=e&&s>=e)return ce.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}Jn.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=ce.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",i.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};Jn.dragend=i=>(i.inputState.draggedContent=null,!1);function Ju(i,e,t,n){if(!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&my(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}Jn.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&&Ju(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\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 Ju(i,e,n,!0),!0}return!1};Jn.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Dd?null:e.clipboardData;return t?(Od(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(yy(i),!1)};function Sy(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 Cy(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:e.join(i.lineBreak),ranges:t,linewise:n}}let Da=null;Jn.copy=Jn.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=Cy(i.state);if(!t&&!s)return!1;Da=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Dd?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Sy(i,t),!1)};const Pd=Si.define();function Bd(i,e){let t=[];for(let n of i.facet(pd)){let s=n(i,e);s&&t.push(s)}return t?i.update({effects:t,annotations:Pd.of(!0)}):null}function Rd(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Bd(i.state,e);t?i.dispatch(t):i.update([])}},10)}jn.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),Rd(i)};jn.blur=i=>{i.observer.clearSelectionRange(),Rd(i)};jn.compositionstart=jn.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};jn.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,Re.chrome&&Re.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};jn.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Jn.beforeinput=(i,e)=>{var t;let n;if(Re.chrome&&Re.android&&(n=Td.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let s=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return Re.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),Re.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>jn.compositionend(i,e),20),!1};const Qu=new Set;function Ay(i){Qu.has(i)||(Qu.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const Zu=["pre-wrap","normal","pre-line","break-spaces"];class Ty{constructor(e){this.lineWrapping=e,this.doc=yt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}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 Zu.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,n,s,r,o){let l=Zu.indexOf(e)>-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;c<o.length;c++){let u=o[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return a}}class My{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class ui{constructor(e,t,n,s,r){this.from=e,this.length=t,this.top=n,this.height=s,this._content=r}get type(){return typeof this._content=="number"?bn.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ki?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new ui(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Pt=function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i}(Pt||(Pt={}));const Mo=.001;class yn{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Mo&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return yn.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--,a<f.from&&(f=r.lineAt(a,Pt.ByPosNoHeight,n,0,0));u+=f.from-a,a=f.from;let p=lc.build(n.setDoc(o),e,u,h);r=r.replace(a,c,p)}return r.updateHeight(n,0)}static empty(){return new Rn(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,s=0,r=0;for(;;)if(t==n)if(s>r*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){let l=e[t++];l&&(s+=l.size)}else{let l=e[--n];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new Dy(yn.of(e.slice(0,t)),o,yn.of(e.slice(n)))}}yn.prototype.size=1;class Nd extends yn{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,s){return new ui(s,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,s,r){return this.blockAt(0,n,s,r)}forEachLine(e,t,n,s,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,n,s,r))}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(e,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Rn extends Nd{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 Rn||s instanceof Qt&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Qt?s=new Rn(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):yn.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setHeight(e,s.heights[s.index++]):(n||this.outdated)&&this.setHeight(e,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 Qt extends yn{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+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),u=t.doc.lineAt(c),h=l+u.length*a,f=Math.max(n,e-h/2);return new ui(u.from,u.length,f,h,0)}else{let c=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:u,length:h}=t.doc.line(r+c);return new ui(u,h,n+l*c,l,0)}}lineAt(e,t,n,s,r){if(t==Pt.ByHeight)return this.blockAt(e,n,s,r);if(t==Pt.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new ui(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r),c=n.doc.lineAt(e),u=l+c.length*a,h=c.number-o,f=s+l*h+a*(c.from-r-h);return new ui(c.from,c.length,Math.max(s,Math.min(f,s+this.height-u)),u,0)}forEachLine(e,t,n,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,r);for(let u=e,h=s;u<=t;){let f=n.doc.lineAt(u);if(u==e){let p=f.number-l;h+=a*p+c*(e-r-p)}let d=a+c*f.length;o(new ui(f.from,f.length,h,d,0)),h+=d,u=f.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let r=n[n.length-1];r instanceof Qt?n[n.length-1]=new Qt(r.length+s):n.push(null,new Qt(s-1))}if(e>0){let r=n[0];r instanceof Qt?n[0]=new Qt(e+r.length):n.unshift(new Qt(e-1),null)}return yn.of(n)}decomposeLeft(e,t){t.push(new Qt(e-1),null)}decomposeRight(e,t){t.push(null,new Qt(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 Qt(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)>=Mo&&(a=-2);let f=new Rn(u,h);f.outdated=!1,o.push(f),l+=u+1}l<=r&&o.push(null,new Qt(r-l).updateHeight(e,l));let c=yn.of(o);return(a<0||Math.abs(c.height-this.height)>=Mo||Math.abs(a-this.heightMetrics(e,t).perLine)>=Mo)&&(e.heightChanged=!0),c}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Dy extends yn{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 e<r?this.left.blockAt(e,t,n,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,n,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==Pt.ByHeight?e<o:e<l,c=a?this.left.lineAt(e,t,n,s,r):this.right.lineAt(e,t,n,o,l);if(this.break||(a?c.to<l:c.from>l))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.left.forEachLine(e,t,n,s,r,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let c=this.lineAt(a,Pt.ByPos,n,s,r);e<c.from&&this.left.forEachLine(e,c.from-1,n,s,r,o),c.to>=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(t<s)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.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&&eh(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),eh(r,l)}return yn.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=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);e<n&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?yn.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=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 eh(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Qt&&(n=i[e+1])instanceof Qt&&i.splice(e-1,3,new Qt(t.length+1+n.length))}const Oy=5;class lc{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 Rn?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Rn(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<t||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Nd(o,s,n)):(o||r||s>=Oy)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Rn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Qt(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 Rn)return e;let t=new Rn(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 Rn)&&!this.isCovered?this.nodes.push(new Rn(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let s of this.nodes)s instanceof Rn&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new lc(n,e);return gt.spans(t,n,s,r,0),r.finish(n)}}function Ey(i,e,t){let n=new Fy;return gt.compare(i,e,t,n,0),n.changes}class Fy{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&ka(e,t,this.changes,5)}}function Py(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,s=n.defaultView||window,r=Math.max(0,t.left),o=Math.min(s.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(s.innerHeight,t.bottom);for(let c=i.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.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=c==i.parentNode?f.bottom:Math.min(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 By(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Rl{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],r=t[n];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return _e.replace({widget:new Ry(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Ry extends Ci{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class th{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=nh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Rt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(rc).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Ty(t),this.stateDeco=e.facet(Sr).filter(n=>typeof n!="function"),this.heightMap=yn.empty().applyChanges(this.stateDeco,yt.empty,this.heightOracle.setDoc(e.doc),[new Hn(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 no(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?nh:new ac(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(ar(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Sr).filter(u=>typeof u!="function");let s=e.changedRanges,r=Hn.extendWithRanges(s,Ey(n,this.stateDeco,e?e.changes:Ut.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(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.head<a.from||t.range.head>a.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(gd)&&(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:F,scaleY:D}=Wf(t,l);(F>.005&&Math.abs(this.scaleX-F)>.005||D>.005&&Math.abs(this.scaleY-D)>.005)&&(this.scaleX=F,this.scaleY=D,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=Uf(e.scrollDOM);let p=(this.printing?By:Py)(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 A=l.width;if((this.contentDOMWidth!=A||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),a){let F=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(F)&&(o=!0),o||s.lineWrapping&&Math.abs(A-this.contentDOMWidth)>s.charWidth){let{lineHeight:D,charWidth:E,textHeight:P}=e.docView.measureTextSize();o=D>0&&s.refresh(r,D,E,P,A/E,F),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)),s.heightChanged=!1;for(let D of this.viewports){let E=D.from==this.viewport.from?F:e.docView.measureVisibleLineHeights(D);this.heightMap=(o?yn.empty().applyChanges(this.stateDeco,yt.empty,this.heightOracle,[new Hn(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new My(D.from,E))}s.heightChanged&&(c|=2)}let v=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.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 no(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(c<a.from||c>a.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<a.from?f=h.top:f=h.bottom-u,a=new no(s.lineAt(f-1e3/2,Pt.ByHeight,r,0,0).from,s.lineAt(f+u+1e3/2,Pt.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new no(this.heightMap.lineAt(n,Pt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,Pt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,Pt.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,Pt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let s of e)t.touchesRange(s.from,s.to)||n.push(new Rl(t.mapPos(s.from),t.mapPos(s.to),s.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=Rt.LTR&&!n)return[];let l=[],a=(u,h,f,d)=>{if(h-u<r)return;let p=this.state.selection.main,y=[p.from];p.empty||y.push(p.to);for(let m of y)if(m>u&&m<h){a(u,m-10,f,d),a(m+10,h,f,d);return}let b=Iy(e,m=>m.from>=f.from&&m.to<=f.to&&Math.abs(m.from-u)<r&&Math.abs(m.to-h)<r&&!y.some(A=>m.from<A&&m.to>A));if(!b){if(h<f.to&&t&&n&&t.visibleRanges.some(m=>m.from<=h&&m.to>=h)){let m=t.moveToLineBoundary(ce.cursor(h),!1,!0).head;m>u&&(h=m)}b=new Rl(u,h,this.gapSize(f,u,h,d))}l.push(b)},c=u=>{if(u.length<o||u.type!=bn.Text)return;let h=Ny(u.from,u.to,this.stateDeco);if(h.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(n){let y=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,b,m;if(f!=null){let A=so(h,f),v=((this.visibleBottom-this.visibleTop)/2+y)/u.height;b=A-v,m=A+v}else b=(this.visibleTop-u.top-y)/u.height,m=(this.visibleBottom-u.top+y)/u.height;d=io(h,b),p=io(h,m)}else{let y=h.total*this.heightOracle.charWidth,b=s*this.heightOracle.charWidth,m,A;if(f!=null){let v=so(h,f),F=((this.pixelViewport.right-this.pixelViewport.left)/2+b)/y;m=v-F,A=v+F}else m=(this.pixelViewport.left-b)/y,A=(this.pixelViewport.right+b)/y;d=io(h,m),p=io(h,A)}d>u.from&&a(u.from,d,u,h),p<u.to&&a(p,u.to,u,h)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return l}gapSize(e,t,n,s){let r=so(s,n)-so(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){Rl.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=_e.set(e.map(t=>t.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)||ar(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)||ar(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 ar(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 no{constructor(e,t){this.from=e,this.to=t}}function Ny(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<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function io({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=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 so(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 Iy(i,e){for(let t of i)if(e(t))return t}const nh={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class ac{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=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,s=r.domBottom}}eq(e){return e instanceof ac?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function ar(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=>ar(s,e)):i._content)}const ro=Ne.define({combine:i=>i.join(" ")}),Oa=Ne.define({combine:i=>i.indexOf(!0)>-1}),Ea=qi.newName(),Id=qi.newName(),Ld=qi.newName(),$d={"&light":"."+Id,"&dark":"."+Ld};function Fa(i,e,t){return new qi(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 Ly=Fa("."+Ea,{"&":{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},".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:"#444"},".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},"&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:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,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"}},$d),cr="";class $y{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(ht.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=cr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let s=e;;){this.findPointBefore(n,s);let r=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==t)break;let l=At.get(s),a=At.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:$o(s))||$o(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&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+(_y(e,n.node,n.offset)?t:0))}}function _y(i,e,t){for(;;){if(!e||t<vi(e))return!1;if(e==i)return!0;t=ps(e)+1,e=e.parentNode}}class ih{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class zy{constructor(e,t,n,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=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?[]:Wy(e),a=new $y(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=jy(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!ma(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||!ma(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((Re.ios||Re.chrome)&&e.state.selection.main.empty&&a!=c&&(u.from>0||u.to<e.state.doc.length)){let h=Math.min(a,c),f=Math.max(a,c),d=u.from-h,p=u.to-f;(d==0||d==1||h==0)&&(p==0||p==-1||f==e.state.doc.length)&&(a=0,c=e.state.doc.length)}this.newSel=ce.single(c,a)}}}function _d(i,e){let t,{newSel:n}=e,s=i.state.selection.main,r=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,c=null;(r===8||Re.android&&e.text.length<l-o)&&(a=s.to,c="end");let u=Hy(i.state.doc.sliceString(o,l,cr),e.text,a-o,c);u&&(Re.chrome&&r==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==cr+cr&&u.toB--,t={from:o+u.from,to:o+u.toA,insert:yt.of(e.text.slice(u.from,u.toB).split(cr))})}else n&&(!i.hasFocus&&i.state.facet(Fi)||n.main.eq(s))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!s.empty&&n&&n.main.empty?t={from:s.from,to:s.to,insert:i.state.doc.slice(s.from,s.to)}:t&&t.from>=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))}:(Re.mac||Re.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=ce.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:yt.of([" "])}):Re.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
- `&&i.lineWrapping&&(n&&(n=ce.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:yt.of([" "])}),t)return zd(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 zd(i,e,t,n=-1){if(Re.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(Re.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.length<e.to-e.from&&e.to>s.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=Vy(i,e,t));return i.state.facet(dd).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function Vy(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.from<e.from?s.sliceDoc(r.from,e.from):"",a=r.to>e.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&&Cd(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}),A=p.to-r.to;return{changes:m,range:a?ce.range(Math.max(0,a.anchor+A),Math.max(0,a.head+A)):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 Hy(i,e,t,n){let s=Math.min(i.length,e.length),r=0;for(;r<s&&i.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&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<r&&i.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Wy(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 ih(t,n)),(s!=t||r!=n)&&e.push(new ih(s,r))),e}function jy(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?ce.single(t+e,n+e):null}const qy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Nl=Re.ie&&Re.ie_version<=11;class Uy{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Eb,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);(Re.ie&&Re.ie_version<=11||Re.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&&!(Re.chrome&&Re.chrome_version<126)&&(this.editContext=new Gy(e),e.state.facet(Fi)&&(e.contentDOM.editContext=this.editContext.editContext)),Nl&&(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)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{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.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:!Ao(n.dom,s))return;let r=s.anchorNode&&n.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Re.ie&&Re.ie_version<=11||Re.android&&Re.chrome)&&!n.state.selection.main.empty&&s.focusNode&&mr(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=xr(e.root);if(!t)return!1;let n=Re.safari&&e.root.nodeType==11&&Tb(this.dom.ownerDocument)==this.dom&&Ky(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=Ao(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Pb(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,qy),Nl&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Nl&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let s=()=>{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<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{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&&Ao(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 zy(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=_d(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=sh(t,e.previousSibling||e.target.previousSibling,-1),s=sh(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("change",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("change",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)}}function sh(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 rh(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 mr(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function Ky(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return rh(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?rh(i,t):null}class Gy{constructor(e){this.from=0,this.to=0,this.pendingContextChange=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)});t.addEventListener("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&&s<this.from?r.from=s:r.to==this.to&&s>this.to&&(r.to=s),!(r.from==r.to&&!r.insert.length)&&(this.pendingContextChange=r,zd(e,r,ce.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd))),this.pendingContextChange&&this.revertPending(e.state))}),t.addEventListener("characterboundsupdate",n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(n.rangeStart,s)}),t.addEventListener("textformatupdate",n=>{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:yd.of(_e.set(s))})}),t.addEventListener("compositionstart",()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)}),t.addEventListener("compositionend",()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null}),this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=xr(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;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(r<this.to){if(r<this.from||o>this.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){!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)&&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.to+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.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}}class Pe{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={}){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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(n=>n.forEach(s=>t(s,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Fb(e.parent)||document,this.viewState=new th(e.state||ht.create(e)),e.scrollTo&&e.scrollTo.is(Zr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(or).map(n=>new Fl(n));for(let n of this.plugins)n.update(this);this.observer=new Uy(this),this.inputState=new cy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Lu(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,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(Pd))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Bd(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=zo.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:ce.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(Zr)&&(h=d.value.clip(this.state))}this.viewState.update(s,h),this.bidiCache=Vo.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(lr)!=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(ro)!=s.state.facet(ro)&&(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(Aa))try{f(s)}catch(d){An(this.state,d,"update listener")}(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!_d(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 th(e),this.plugins=e.facet(or).map(n=>new Fl(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Lu(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(or),n=e.state.facet(or);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new Fl(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<this.plugins.length;s++)this.plugins[s].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){An(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-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(Uf(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 An(this.state,p),oh}}),h=zo.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;d<c.length;d++)if(u[d]!=oh)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){An(this.state,p)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(p>1||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(Aa))l(t)}get themeClasses(){return Ea+" "+(this.state.facet(Oa)?Ld:Id)+" "+this.state.facet(ro)}updateAttrs(){let e=lh(this,wd,{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:`${Re.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),lh(this,rc,t);let n=this.observer.ignore(()=>{let s=va(this.contentDOM,this.contentAttrs,t),r=va(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(Pe.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(lr);let e=this.state.facet(Pe.cspNonce);qi.mount(this.root,this.styleModules.concat(Ly).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;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.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 Bl(this,e,Wu(this,e,t,n))}moveByGroup(e,t){return Bl(this,e,Wu(this,e,t,n=>ly(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 ce.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return oy(this,e,t,n)}moveVertically(e,t,n){return Bl(this,e,ay(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(),Ad(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 ul(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(md)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Yy)return ld(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||od(r.isolates,n=Iu(this,e))))return r.order;n||(n=Iu(this,e));let s=jb(e.text,t,n);return this.bidiCache.push(new Vo(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Re.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{jf(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 Zr.of(new Ns(typeof e=="number"?ce.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 Zr.of(new Ns(ce.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=qi.newName(),s=[ro.of(n),lr.of(Fa(`.${n}`,e))];return t&&t.dark&&s.push(Oa.of(!0)),s}static baseTheme(e){return vs.lowest(lr.of(Fa("."+Ea,e,$d)))}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}}Pe.styleModule=lr;Pe.inputHandler=dd;Pe.scrollHandler=bd;Pe.focusChangeEffect=pd;Pe.perLineTextDirection=md;Pe.exceptionSink=fd;Pe.updateListener=Aa;Pe.editable=Fi;Pe.mouseSelectionStyle=hd;Pe.dragMovesSelection=ud;Pe.clickAddsSelectionRange=cd;Pe.decorations=Sr;Pe.outerDecorations=vd;Pe.atomicRanges=oc;Pe.bidiIsolatedRanges=kd;Pe.scrollMargins=xd;Pe.darkTheme=Oa;Pe.cspNonce=Ne.define({combine:i=>i.length?i[0]:""});Pe.contentAttributes=rc;Pe.editorAttributes=wd;Pe.lineWrapping=Pe.contentAttributes.of({class:"cm-lineWrapping"});Pe.announce=nt.define();const Yy=4096,oh={};class Vo{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<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&n.push(new Vo(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function lh(i,e,t){for(let n=i.state.facet(e),s=n.length-1;s>=0;s--){let r=n[s],o=typeof r=="function"?r(i):r;o&&wa(o,t)}return t}const Xy=Re.mac?"mac":Re.windows?"win":Re.linux?"linux":"key";function Jy(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function oo(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}const Qy=vs.default(Pe.domEventHandlers({keydown(i,e){return Hd(Vd(e.state),i,e,"editor")}})),fl=Ne.define({enables:Qy}),ah=new WeakMap;function Vd(i){let e=i.facet(fl),t=ah.get(e);return t||ah.set(e,t=tw(e.reduce((n,s)=>n.concat(s),[]))),t}function Zy(i,e,t){return Hd(Vd(i.state),e,i,t)}let Pi=null;const ew=4e3;function tw(i,e=Xy){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=>Jy(m,e));for(let m=1;m<p.length;m++){let A=p.slice(0,m).join(" ");s(A,!0),d[A]||(d[A]={preventDefault:!0,stopPropagation:!1,run:[v=>{let F=Pi={view:v,prefix:A,scope:o};return setTimeout(()=>{Pi==F&&(Pi=null)},ew),!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,Pa))}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 Pa=null;function Hd(i,e,t,n){Pa=e;let s=Ab(e),r=Zt(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+" ",Md.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+oo(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Re.windows&&e.ctrlKey&&e.altKey)&&(p=Ui[e.keyCode])&&p!=s?(f(d[l+oo(p,e,!0)])||e.shiftKey&&(y=kr[e.keyCode])!=s&&y!=p&&f(d[l+oo(y,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[l+oo(s,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),Pa=null,a}class Hr{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=Wd(e);return[new Hr(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return nw(e,t,n)}}function Wd(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 ch(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 nw(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=Wd(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=Ma(i,n),p=Ma(i,s),y=d.type==bn.Text?d:null,b=p.type==bn.Text?p:null;if(y&&(i.lineWrapping||d.widgetLineBreaks)&&(y=ch(i,n,1,y)),b&&(i.lineWrapping||p.widgetLineBreaks)&&(b=ch(i,s,-1,b)),y&&b&&y.from==b.from&&y.to==b.to)return A(v(t.from,t.to,y));{let D=y?v(t.from,null,y):F(d,!1),E=b?v(null,t.to,b):F(p,!0),P=[];return(y||d).to<(b||p).from-(y&&b?1:0)||d.widgetLineBreaks>1&&D.bottom+i.defaultLineHeight/2<E.top?P.push(m(h,D.bottom,f,E.top)):D.bottom<E.top&&i.elementAtHeight((D.bottom+E.top)/2).type==bn.Text&&(D.bottom=E.top=(D.bottom+E.top)/2),A(D).concat(P).concat(A(E))}function m(D,E,P,T){return new Hr(e,D-a.left,E-a.top-.01,P-D,T-E+.01)}function A({top:D,bottom:E,horizontal:P}){let T=[];for(let M=0;M<P.length;M+=2)T.push(m(P[M],D,P[M+1],E));return T}function v(D,E,P){let T=1e9,M=-1e9,V=[];function H(L,re,N,Q,$){let ie=i.coordsAtPos(L,L==P.to?-2:2),le=i.coordsAtPos(N,N==P.from?2:-2);!ie||!le||(T=Math.min(ie.top,le.top,T),M=Math.max(ie.bottom,le.bottom,M),$==Rt.LTR?V.push(r&&re?h:ie.left,r&&Q?f:le.right):V.push(!r&&Q?h:le.left,!r&&re?f:ie.right))}let te=D!=null?D:P.from,ue=E!=null?E:P.to;for(let L of i.visibleRanges)if(L.to>te&&L.from<ue)for(let re=Math.max(L.from,te),N=Math.min(L.to,ue);;){let Q=i.state.doc.lineAt(re);for(let $ of i.bidiSpans(Q)){let ie=$.from+Q.from,le=$.to+Q.from;if(ie>=N)break;le>re&&H(Math.max(ie,re),D==null&&ie<=te,Math.min(le,N),E==null&&le>=ue,$.dir)}if(re=Q.to+1,re>=N)break}return V.length==0&&H(te,D==null,ue,E==null,i.textDirection),{top:T,bottom:M,horizontal:V}}function F(D,E){let P=l.top+(E?D.top:D.bottom);return{top:P,bottom:P,horizontal:[]}}}function iw(i,e){return i.constructor==e.constructor&&i.eq(e)}class sw{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(Do)!=e.state.facet(Do)&&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(Do);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!iw(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 Do=Ne.define();function jd(i){return[Vt.define(e=>new sw(e,i)),Do.of(i)]}const qd=!Re.ios,Cr=Ne.define({combine(i){return pi(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function rw(i={}){return[Cr.of(i),ow,lw,aw,gd.of(!0)]}function Ud(i){return i.startState.facet(Cr)!=i.state.facet(Cr)}const ow=jd({above:!0,markers(i){let{state:e}=i,t=e.facet(Cr),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:ce.cursor(s.head,s.head>s.anchor?-1:1);for(let a of Hr.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=Ud(i);return t&&uh(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){uh(e.state,i)},class:"cm-cursorLayer"});function uh(i,e){e.style.animationDuration=i.facet(Cr).cursorBlinkRate+"ms"}const lw=jd({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:Hr.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Ud(i)},class:"cm-selectionLayer"}),Ba={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};qd&&(Ba[".cm-line"].caretColor=Ba[".cm-content"].caretColor="transparent !important");const aw=vs.highest(Pe.theme(Ba)),Kd=nt.define({map(i,e){return i==null?null:e.mapPos(i)}}),ur=rn.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(Kd)?n.value:t,i)}}),cw=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(ur);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(ur)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(ur),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(ur)!=i&&this.view.dispatch({effects:Kd.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 uw(){return[ur,cw]}function hh(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 hw(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 fw{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 ji,n=t.add.bind(t);for(let{from:s,to:r}of hw(e,this.maxLength))hh(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&&l<e.view.viewport.to&&(n=Math.min(l,n),s=Math.max(a,s))}),e.viewportChanged||s-n>1e3?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.to<l?e.state.doc.lineAt(l):a,u=Math.max(r.from,a.from),h=Math.min(r.to,c.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){u=o;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){h=l;break}}let f=[],d,p=(y,b,m)=>f.push(m.range(y,b));if(a==c)for(this.regexp.lastIndex=u-a.from;(d=this.regexp.exec(a.text))&&d.index<h-a.from;)this.addMatch(d,e,d.index+a.from,p);else hh(e.state.doc,this.regexp,u,h,(y,b)=>this.addMatch(b,e,y,p));t=t.update({filterFrom:u,filterTo:h,filter:(y,b)=>y<u||b>h,add:f})}}return t}}const Ra=/x/.unicode!=null?"gu":"g",dw=new RegExp(`[\0-\b
- --\u2028\u2029\uFEFF-]`,Ra),pw={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 Il=null;function mw(){var i;if(Il==null&&typeof document!="undefined"&&document.body){let e=document.body.style;Il=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Il||!1}const Oo=Ne.define({combine(i){let e=pi(i,{render:null,specialChars:dw,addSpecialChars:null});return(e.replaceTabs=!mw())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Ra)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Ra)),e}});function gw(i={}){return[Oo.of(i),bw()]}let fh=null;function bw(){return fh||(fh=Vt.fromClass(class{constructor(i){this.view=i,this.decorations=_e.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(Oo)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new fw({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=Zt(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=Js(o.text,l,n-o.from);return _e.replace({widget:new kw((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=_e.replace({widget:new vw(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(Oo);i.startState.facet(Oo)!=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 yw="•";function ww(i){return i>=32?yw:i==10?"":String.fromCharCode(9216+i)}class vw extends Ci{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=ww(this.code),n=e.state.phrase("Control character")+" "+(pw[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 kw 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 xw(){return Cw}const Sw=_e.line({class:"cm-activeLine"}),Cw=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(Sw.range(s.from)),e=s.from)}return _e.set(t)}},{decorations:i=>i.decorations});class Aw extends Ci{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?Hs(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=ul(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 Tw(i){return Vt.fromClass(class{constructor(e){this.view=e,this.placeholder=i?_e.set([_e.widget({widget:new Aw(i),side:1}).range(0)]):_e.none}get decorations(){return this.view.state.doc.length?_e.none:this.placeholder}},{decorations:e=>e.decorations})}const Na=2e3;function Mw(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Na||t.off>Na||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(ce.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=fa(c.text,o,i.tabSize,!0);if(u<0)r.push(ce.cursor(c.to));else{let h=fa(c.text,l,i.tabSize);r.push(ce.range(c.from+u,c.from+h))}}}return r}function Dw(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function dh(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>Na?-1:s==n.length?Dw(i,e.clientX):Js(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function Ow(i,e){let t=dh(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=dh(i,s);if(!l)return n;let a=Mw(i.state,t,l);return a.length?o?ce.create(a.concat(n.ranges)):ce.create(a):n}}:null}function Ew(i){let e=t=>t.altKey&&t.button==0;return Pe.mouseSelectionStyle.of((t,n)=>e(n)?Ow(t,n):null)}const Fw={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},Pw={style:"cursor: crosshair"};function Bw(i={}){let[e,t]=Fw[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,Pe.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?Pw:null})]}const nr="-10000px";class Gd{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;a<r.length;a++){let c=r[a],u=-1;if(c){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==c.create&&(u=h)}if(u<0)o[a]=this.createTooltipView(c,a?o[a-1]:null),l&&(l[a]=!!c.above);else{let h=o[a]=this.tooltipViews[u];l&&(l[a]=t[u]),h.update&&h.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,c)=>t[c]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function Rw(i){let{win:e}=i;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Ll=Ne.define({combine:i=>{var e,t,n;return{position:Re.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)||Rw}}}),ph=new WeakMap,cc=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(Ll);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 Gd(i,uc,(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(Ll);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=nr,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(Re.gecko)n=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==nr&&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(Ll).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<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],c=this.manager.tooltipViews[l],{dom:u}=c,h=i.pos[l],f=i.size[l];if(!h||h.bottom<=Math.max(t.top,n.top)||h.top>=Math.min(t.bottom,n.bottom)||h.right<Math.max(t.left,n.left)-.1||h.left>Math.min(t.right,n.right)+.1){u.style.top=nr;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,y=f.right-f.left,b=(e=ph.get(c))!==null&&e!==void 0?e:f.bottom-f.top,m=c.offset||Iw,A=this.view.textDirection==Rt.LTR,v=f.width>n.right-n.left?A?n.left:n.right-f.width:A?Math.min(h.left-(d?14:0)+m.x,n.right-y):Math.max(n.left,h.left-y+(d?14:0)-m.x),F=this.above[l];!a.strictSide&&(F?h.top-(f.bottom-f.top)-m.y<n.top:h.bottom+(f.bottom-f.top)+m.y>n.bottom)&&F==n.bottom-h.bottom>h.top-n.top&&(F=this.above[l]=!F);let D=(F?h.top-n.top:n.bottom-h.bottom)-p;if(D<b&&c.resize!==!1){if(D<this.view.defaultLineHeight){u.style.top=nr;continue}ph.set(c,b),u.style.height=(b=D)/r+"px"}else u.style.height&&(u.style.height="");let E=F?h.top-b-p-m.y:h.bottom+p+m.y,P=v+y;if(c.overlap!==!0)for(let T of o)T.left<P&&T.right>v&&T.top<E+b&&T.bottom>E&&(E=F?T.top-b-2-p:T.bottom+p+2);if(this.position=="absolute"?(u.style.top=(E-i.parent.top)/r+"px",u.style.left=(v-i.parent.left)/s+"px"):(u.style.top=E/r+"px",u.style.left=v/s+"px"),d){let T=h.left+(A?m.x:-m.x)-(v+14-7);d.style.left=T/s+"px"}c.overlap!==!0&&o.push({left:v,top:E,right:P,bottom:E+b}),u.classList.toggle("cm-tooltip-above",F),u.classList.toggle("cm-tooltip-below",!F),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=nr}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Nw=Pe.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"}}}),Iw={x:0,y:0},uc=Ne.define({enables:[cc,Nw]}),Ho=Ne.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class dl{static create(e){return new dl(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gd(e,Ho,(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 Lw=uc.compute([Ho],i=>{let e=i.facet(Ho);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:dl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class $w{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;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let s,r=1;if(n instanceof Ni)s=n.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let l=e.coordsAtPos(s);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.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<l.left?-c:c}let o=this.source(e,s,r);if(o!=null&&o.then){let l=this.pending={pos:s};o.then(a=>{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>An(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(cc),t=e?e.manager.tooltips.findIndex(n=>n.create==dl.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&&!_w(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:!zw(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 lo=4;function _w(i,e){let t=i.getBoundingClientRect();return e.clientX>=t.left-lo&&e.clientX<=t.right+lo&&e.clientY>=t.top-lo&&e.clientY<=t.bottom+lo}function zw(i,e,t,n,s,r){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=i.posAtCoords({x:n,y:s},!1);return a>=e&&a<=t}function Vw(i,e={}){let t=nt.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,gn.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(Hw)&&(s=[]);return s},provide:s=>Ho.from(s)});return[n,Vt.define(s=>new $w(s,i,n,t,e.hoverTime||300)),Lw]}function Yd(i,e){let t=i.plugin(cc);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const Hw=nt.define(),mh=Ne.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 Ar(i,e){let t=i.plugin(Xd),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const Xd=Vt.fromClass(class{constructor(i){this.input=i.state.facet(Tr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(mh);this.top=new ao(i,!0,e.topContainer),this.bottom=new ao(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(mh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ao(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ao(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Tr);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=>Pe.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class ao{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=gh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=gh(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 gh(i){let e=i.nextSibling;return i.remove(),e}const Tr=Ne.define({enables:Xd});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=gn.TrackBefore;xi.prototype.startSide=xi.prototype.endSide=-1;xi.prototype.point=!0;const Eo=Ne.define(),Ww={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>gt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},br=Ne.define();function jw(i){return[Jd(),br.of(Object.assign(Object.assign({},Ww),i))]}const bh=Ne.define({combine:i=>i.some(e=>e)});function Jd(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(br).map(e=>new wh(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(bh),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(bh)!=!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(Eo),this.view.viewport.from),n=[],s=this.gutters.map(r=>new Uw(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==bn.Text&&o){Ia(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==bn.Text){Ia(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(br),t=i.state.facet(br),n=i.docChanged||i.heightChanged||i.viewportChanged||!gt.eq(i.startState.facet(Eo),i.state.facet(Eo),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 wh(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=>Pe.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 yh(i){return Array.isArray(i)?i:[i]}function Ia(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class Uw{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 Qd(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=[];Ia(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);n&&this.addElement(e,t,[n])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class wh{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=yh(t.markers(e)),t.initialSpacer&&(this.spacer=new Qd(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=yh(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 Qd{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":""),Kw(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=r<t.length?t[r++]:null,c=!1;if(a){let u=a.elementClass;u&&(n+=" "+u);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(a)){l=h,c=!0;break}}else l=this.markers.length;for(;o<l;){let u=this.markers[o++];if(u.toDOM){u.destroy(s);let h=s.nextSibling;s.remove(),s=h}}if(!a)break;a.toDOM&&(c?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),c&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function Kw(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}const Gw=Ne.define(),Os=Ne.define({combine(i){return pi(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let s in t){let r=n[s],o=t[s];n[s]=r?(l,a,c)=>r(l,a,c)||o(l,a,c):o}return n}})}});class $l extends xi{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function _l(i,e){return i.state.facet(Os).formatNumber(e,i.state)}const Yw=br.compute([Os],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Gw)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new $l(_l(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Os)!=e.state.facet(Os),initialSpacer(e){return new $l(_l(e,vh(e.state.doc.lines)))},updateSpacer(e,t){let n=_l(t.view,vh(t.view.state.doc.lines));return n==e.number?e:new $l(n)},domEventHandlers:i.facet(Os).domEventHandlers}));function Xw(i={}){return[Os.of(i),Jd(),Yw]}function vh(i){let e=9;for(;e<i;)e=e*10+9;return e}const Jw=new class extends xi{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Qw=Eo.compute(["selection"],i=>{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(Jw.range(s)))}return gt.of(e)});function Zw(){return Qw}const Zd=1024;let ev=0;class zl{constructor(e,t){this.from=e,this.to=t}}class ot{constructor(e={}){this.id=ev++,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=wn.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 Wo{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 tv=Object.create(null);class wn{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):tv,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new wn(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}}}}wn.none=new wn("",Object.create(null),0,8);class pl{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let s=null;for(let r of e){let o=r(n);o&&(s||(s=Object.assign({},n.props)),s[o[0].id]=o[1])}t.push(s?new wn(n.name,s,n.id,n.flags):n)}return new pl(t)}}const co=new WeakMap,kh=new WeakMap;var Xt;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(Xt||(Xt={}));class Tt{constructor(e,t,n,s,r){if(this.type=e,this.children=t,this.positions=n,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Wo.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let s=n.toString();s&&(t&&(t+=","),t+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new $a(this.topNode,e)}cursorAt(e,t=0,n=0){let s=co.get(this)||this.topNode,r=new $a(s);return r.moveTo(e,t),co.set(this,r._tree),r}get topNode(){return new Wn(this,0,0,null)}resolve(e,t=0){let n=Mr(co.get(this)||this.topNode,e,t,!1);return co.set(this,n),n}resolveInner(e,t=0){let n=Mr(kh.get(this)||this.topNode,e,t,!0);return kh.set(this,n),n}resolveStack(e,t=0){return sv(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&Xt.IncludeAnonymous)>0;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:dc(wn.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(wn.none,t,n,s)))}static build(e){return rv(e)}}Tt.empty=new Tt(wn.none,[],[],0);class hc{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 hc(this.buffer,this.index)}}class Gi{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return wn.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,n==e)return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(ep(r,s,o[a+1],o[a+2])&&(l=a,n>0));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<t;){r[a++]=s[l++],r[a++]=s[l++]-n;let c=r[a++]=s[l++]-n;r[a++]=s[l++]-e,o=Math.max(o,c)}return new Gi(r,o,this.set)}}function ep(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Mr(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.to<e);){let o=!n&&i instanceof Wn&&i.index<0?null:i.parent;if(!o)return i;i=o}let r=n?0:Xt.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof Wn&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(i=l);for(;;){let o=i.enter(e,t,r);if(!o)return i;i=o}}class tp{cursor(e=0){return new $a(this,e)}getChild(e,t=null,n=null){let s=xh(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return xh(this,e,t,n)}resolve(e,t=0){return Mr(this,e,t,!1)}resolveInner(e,t=0){return Mr(this,e,t,!0)}matchContext(e){return La(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(n=t,t=s.prevSibling):t=s}return n}get node(){return this}get next(){return this.parent}}class Wn extends tp{constructor(e,t,n,s){super(),this._tree=e,this.from=t,this.index=n,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=t>0?l.length:-1;e!=c;e+=t){let u=l[e],h=a[e]+o.from;if(ep(s,n,h,h+u.length)){if(u instanceof Gi){if(r&Xt.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-h,s);if(f>-1)return new Li(new nv(o,u,e,h),null,f)}else if(r&Xt.IncludeAnonymous||!u.type.isAnonymous||fc(u)){let f;if(!(r&Xt.IgnoreMounts)&&(f=Wo.get(u))&&!f.overlay)return new Wn(f.tree,h,e,o);let d=new Wn(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=Wo.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)&&(t<0?l>=r:l>r))return new Wn(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 xh(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 La(i,e,t=e.length-1){for(let n=i.parent;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 nv{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class Li extends tp{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 np(i){if(!i.length)return null;let e=0,t=i[0];for(let r=1;r<i.length;r++){let o=i[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let n=t instanceof Wn&&t.index<0?null:t.parent,s=i.slice();return n?s[e]=n:s.splice(e,1),new iv(s,t)}class iv{constructor(e,t){this.heads=e,this.node=t}get next(){return np(this.heads)}}function sv(i,e,t){let n=i.resolveInner(e,t),s=null;for(let r=n instanceof Wn?n:n.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[n])).push(o.resolve(e,t)),r=o}else{let o=Wo.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Wn(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(Mr(l,e,t,!1))}}return s?np(s):n}class $a{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 Wn)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 Wn?(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<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:n}=s)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-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 Gi||!l.type.isAnonymous||fc(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<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=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<this.stack.length;s++)t=new Li(this.buffer,t,this.stack[s]);return this.bufferNode=new Li(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(s=!0)}for(;s&&t&&t(this),s=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,s=!0}}}matchContext(e){if(!this.buffer)return La(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return La(this.node,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 fc(i){return i.children.some(e=>e instanceof Gi||!e.type.isAnonymous||fc(e))}function rv(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=Zd,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new hc(t,t.length):t,a=n.types,c=0,u=0;function h(D,E,P,T,M,V){let{id:H,start:te,end:ue,size:L}=l,re=u;for(;L<0;)if(l.next(),L==-1){let le=r[H];P.push(le),T.push(te-D);return}else if(L==-3){c=H;return}else if(L==-4){u=H;return}else throw new RangeError(`Unrecognized record size: ${L}`);let N=a[H],Q,$,ie=te-D;if(ue-te<=s&&($=b(l.pos-E,M))){let le=new Uint16Array($.size-$.skip),_=l.pos-$.size,Y=le.length;for(;l.pos>_;)Y=m($.start,le,Y);Q=new Gi(le,ue-$.start,n),ie=$.start-D}else{let le=l.pos-L;l.next();let _=[],Y=[],ye=H>=o?H:-1,we=0,Le=ue;for(;l.pos>le;)ye>=0&&l.id==ye&&l.size>=0?(l.end<=Le-s&&(p(_,Y,te,we,l.end,Le,ye,re),we=_.length,Le=l.end),l.next()):V>2500?f(te,le,_,Y):h(te,le,_,Y,ye,V+1);if(ye>=0&&we>0&&we<_.length&&p(_,Y,te,we,te,Le,ye,re),_.reverse(),Y.reverse(),ye>-1&&we>0){let ve=d(N);Q=dc(N,_,Y,0,_.length,0,ue-te,ve,ve)}else Q=y(N,_,Y,ue-te,re-ue)}P.push(Q),T.push(ie)}function f(D,E,P,T){let M=[],V=0,H=-1;for(;l.pos>E;){let{id:te,start:ue,end:L,size:re}=l;if(re>4)l.next();else{if(H>-1&&ue<H)break;H<0&&(H=L-s),M.push(te,ue,L),V++,l.next()}}if(V){let te=new Uint16Array(V*4),ue=M[M.length-2];for(let L=M.length-3,re=0;L>=0;L-=3)te[re++]=M[L],te[re++]=M[L+1]-ue,te[re++]=M[L+2]-ue,te[re++]=re;P.push(new Gi(te,M[2]-ue,n)),T.push(ue-D)}}function d(D){return(E,P,T)=>{let M=0,V=E.length-1,H,te;if(V>=0&&(H=E[V])instanceof Tt){if(!V&&H.type==D&&H.length==T)return H;(te=H.prop(ot.lookAhead))&&(M=P[V]+H.length+te)}return y(D,E,P,T,M)}}function p(D,E,P,T,M,V,H,te){let ue=[],L=[];for(;D.length>T;)ue.push(D.pop()),L.push(E.pop()+P-M);D.push(y(n.types[H],ue,L,V-M,te-V)),E.push(M-P)}function y(D,E,P,T,M=0,V){if(c){let H=[ot.contextHash,c];V=V?[H].concat(V):[H]}if(M>25){let H=[ot.lookAhead,M];V=V?[H].concat(V):[H]}return new Tt(D,E,P,T,V)}function b(D,E){let P=l.fork(),T=0,M=0,V=0,H=P.end-s,te={size:0,start:0,skip:0};e:for(let ue=P.pos-D;P.pos>ue;){let L=P.size;if(P.id==E&&L>=0){te.size=T,te.start=M,te.skip=V,V+=4,T+=4,P.next();continue}let re=P.pos-L;if(L<0||re<ue||P.start<H)break;let N=P.id>=o?4:0,Q=P.start;for(P.next();P.pos>re;){if(P.size<0)if(P.size==-3)N+=4;else break e;else P.id>=o&&(N+=4);P.next()}M=Q,T+=L,V+=N}return(E<0||T==D)&&(te.size=T,te.start=M,te.skip=V),te.size>4?te:void 0}function m(D,E,P){let{id:T,start:M,end:V,size:H}=l;if(l.next(),H>=0&&T<o){let te=P;if(H>4){let ue=l.pos-(H-4);for(;l.pos>ue;)P=m(D,E,P)}E[--P]=te,E[--P]=V-D,E[--P]=M-D,E[--P]=T}else H==-3?c=T:H==-4&&(u=T);return P}let A=[],v=[];for(;l.pos>0;)h(i.start||0,i.bufferStart||0,A,v,-1,0);let F=(e=i.length)!==null&&e!==void 0?e:A.length?v[0]+A[0].length:0;return new Tt(a[i.topID],A.reverse(),v.reverse(),F)}const Sh=new WeakMap;function Fo(i,e){if(!i.isAnonymous||e instanceof Gi||e.type!=i)return 1;let t=Sh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Tt)){t=1;break}t+=Fo(i,n)}Sh.set(e,t)}return t}function dc(i,e,t,n,s,r,o,l,a){let c=0;for(let p=n;p<s;p++)c+=Fo(i,e[p]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(p,y,b,m,A){for(let v=b;v<m;){let F=v,D=y[v],E=Fo(i,p[v]);for(v++;v<m;v++){let P=Fo(i,p[v]);if(E+P>=u)break;E+=P}if(v==F+1){if(E>u){let P=p[F];d(P.children,P.positions,0,P.children.length,y[F]+A);continue}h.push(p[F])}else{let P=y[v-1]+p[v-1].length-D;h.push(dc(i,p,y,F,v,D,P,null,a))}f.push(D+A-r)}}return d(e,t,n,s,0),(l||a)(h,f,o)}class hs{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 hs(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<t.length?t[l]:null,h=u?u.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let f=o;if(a>=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 hs(d,p,f.tree,f.offset+c,l>0,!!u)}if(f&&s.push(f),o.to>h)break;o=r<e.length?e[r++]:null}if(!u)break;a=u.toA,c=u.toA-u.toB}return s}}class pc{startParse(e,t,n){return typeof e=="string"&&(e=new ov(e)),n=n?n.length?n.map(s=>new zl(s.from,s.to)):[new zl(0,0)]:[new zl(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 ov{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 lv=0;class ai{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=lv++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new ai([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new jo;return t=>t.modified.indexOf(e)>-1?t:jo.get(t.base||t,t.modified.concat(e).sort((n,s)=>n.id-s.id))}}let av=0;class jo{constructor(){this.instances=[],this.id=av++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&cv(t,l.modified));if(n)return n;let s=[],r=new ai(s,e,t);for(let l of t)l.instances.push(r);let o=uv(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(jo.get(l,a));return r}}function cv(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function uv(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function ip(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 qo(n,o,a>0?r.slice(0,a):null);e[c]=u.sort(e[c])}}return sp.add(e)}const sp=new ot;class qo{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<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}qo.empty=new qo([],2,null);function rp(i,e){let t=Object.create(null);for(let r of i)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:r=>{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 hv(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function fv(i,e,t,n=0,s=i.length){let r=new dv(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}class dv{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=pv(e)||qo.empty,h=hv(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 A=b<f.overlay.length?f.overlay[b]:null,v=A?A.from+l:a,F=Math.max(t,m),D=Math.min(n,v);if(F<D&&y)for(;e.from<D&&(this.highlightRange(e,F,D,s,r),this.startSpan(Math.min(D,e.to),c),!(e.to>=v||!e.nextSibling())););if(!A||v>n)break;m=A.to+l,m>t&&(this.highlightRange(d.cursor(),Math.max(t,A.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 pv(i){let e=i.type.prop(sp);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const Te=ai.define,uo=Te(),Oi=Te(),Ch=Te(Oi),Ah=Te(Oi),Ei=Te(),ho=Te(Ei),Vl=Te(Ei),li=Te(),es=Te(li),ri=Te(),oi=Te(),_a=Te(),ir=Te(_a),fo=Te(),X={comment:uo,lineComment:Te(uo),blockComment:Te(uo),docComment:Te(uo),name:Oi,variableName:Te(Oi),typeName:Ch,tagName:Te(Ch),propertyName:Ah,attributeName:Te(Ah),className:Te(Oi),labelName:Te(Oi),namespace:Te(Oi),macroName:Te(Oi),literal:Ei,string:ho,docString:Te(ho),character:Te(ho),attributeValue:Te(ho),number:Vl,integer:Te(Vl),float:Te(Vl),bool:Te(Ei),regexp:Te(Ei),escape:Te(Ei),color:Te(Ei),url:Te(Ei),keyword:ri,self:Te(ri),null:Te(ri),atom:Te(ri),unit:Te(ri),modifier:Te(ri),operatorKeyword:Te(ri),controlKeyword:Te(ri),definitionKeyword:Te(ri),moduleKeyword:Te(ri),operator:oi,derefOperator:Te(oi),arithmeticOperator:Te(oi),logicOperator:Te(oi),bitwiseOperator:Te(oi),compareOperator:Te(oi),updateOperator:Te(oi),definitionOperator:Te(oi),typeOperator:Te(oi),controlOperator:Te(oi),punctuation:_a,separator:Te(_a),bracket:ir,angleBracket:Te(ir),squareBracket:Te(ir),paren:Te(ir),brace:Te(ir),content:li,heading:es,heading1:Te(es),heading2:Te(es),heading3:Te(es),heading4:Te(es),heading5:Te(es),heading6:Te(es),contentSeparator:Te(li),list:Te(li),quote:Te(li),emphasis:Te(li),strong:Te(li),link:Te(li),monospace:Te(li),strikethrough:Te(li),inserted:Te(),deleted:Te(),changed:Te(),invalid:Te(),meta:fo,documentMeta:Te(fo),annotation:Te(fo),processingInstruction:Te(fo),definition:ai.defineModifier(),constant:ai.defineModifier(),function:ai.defineModifier(),standard:ai.defineModifier(),local:ai.defineModifier(),special:ai.defineModifier()};rp([{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 Hl;const ls=new ot;function op(i){return Ne.define({combine:i?e=>e.concat(i):void 0})}const mv=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=[Yi.of(this),ht.languageData.of((r,o,l)=>{let a=Th(r,o,l),c=a.type.prop(ls);if(!c)return[];let u=r.facet(c),h=a.type.prop(mv);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 Th(e,t,n).type.prop(ls)==this.data}findRegions(e){let t=e.facet(Yi);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(ls)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(ot.mounted);if(l){if(l.tree.prop(ls)==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;a<r.children.length;a++){let c=r.children[a];c instanceof Tt&&s(c,r.positions[a]+o)}};return s(sn(e),0),n}get allowsNesting(){return!0}}_n.setState=nt.define();function Th(i,e,t){let n=i.facet(Yi),s=sn(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Xt.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Uo extends _n{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=op(e.languageData);return new Uo(t,e.parser.configure({props:[ls.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Uo(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 gv{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<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let sr=null;class qs{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 qs(e,t,[],Tt.empty,0,n,[],null)}startParse(){return this.parser.startParse(new gv(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.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(hs.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(hs.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=sr;sr=this;try{return e()}finally{sr=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Mh(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=hs.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);u<h&&l.push({from:u,to:h})}}}return new qs(this.parser,t,n,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=Mh(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 pc{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=sr;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(wn.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 sr}}function Mh(i,e,t){return hs.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Us{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 Us(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=qs.create(e.facet(Yi).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Us(n)}}_n.state=rn.define({create:Us.init,update(i,e){for(let t of e.effects)if(t.is(_n.setState))return t.value;return e.startState.facet(Yi)!=e.state.facet(Yi)?Us.init(e.state):i.apply(e)}});let lp=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(lp=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Wl=typeof navigator!="undefined"&&(!((Hl=navigator.scheduling)===null||Hl===void 0)&&Hl.isInputPending)?()=>navigator.scheduling.isInputPending():null,bv=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=lp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:s}}=this.view,r=n.field(_n.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Wl?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>Wl&&Wl()||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 Us(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=>An(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()}}}),Yi=Ne.define({combine(i){return i.length?i[0]:null},enables:i=>[_n.state,bv,Pe.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class yv{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const ap=Ne.define(),ml=Ne.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(ml);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Dr(i,e){let t="",n=i.tabSize,s=i.facet(ml)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function mc(i,e){i instanceof ht&&(i=new gl(i));for(let n of i.state.facet(ap)){let s=n(i,e);if(s!==void 0)return s}let t=sn(i.state);return t.length>=e?wv(i,t,e):null}class gl{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<e:s<=e)?{text:n.text.slice(s-n.from),from:s}:{text:n.text.slice(0,s-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,t);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.countColumn(n,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return Js(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 cp=new ot;function wv(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 up(n,i,t)}function up(i,e,t){for(let n=i;n;n=n.next){let s=kv(n.node);if(s)return s(gc.create(e,t,n))}return 0}function vv(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function kv(i){let e=i.type.prop(cp);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=>Av(o,!0,1,void 0,r&&!vv(o)?s.from:void 0)}return i.parent==null?xv:null}function xv(){return 0}class gc extends gl{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 gc(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(Sv(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return up(this.context.next,this.base,this.pos)}}function Sv(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Cv(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)return a.from<o?t:null;l=a.to}}function Av(i,e,t,n,s){let r=i.textAfter,o=r.match(/^\s*/)[0].length,l=s==i.pos+o,a=Cv(i);return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}function Dh({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const Tv=200;function Mv(){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+Tv)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=mc(o,u.from);if(h==null)continue;let f=/^\s*/.exec(u.text)[0],d=Dr(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 Dv=Ne.define(),hp=new ot;function Ov(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}function Ev(i,e,t){let n=sn(i);if(n.length<t)return null;let s=n.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(hp);if(a&&(l.to<n.length-50||n.length==i.doc.length||!Fv(l))){let c=a(l,i);c&&c.from<=t&&c.from>=e&&c.to>t&&(r=c)}}return r}function Fv(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Ko(i,e,t){for(let n of i.facet(Dv)){let s=n(i,e,t);if(s)return s}return Ev(i,e,t)}function fp(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 bl=nt.define({map:fp}),Wr=nt.define({map:fp});function dp(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(bl)&&!Pv(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(gp),s=n?_e.replace({widget:new _v(n(e.state,t.value))}):Oh;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(Wr)&&(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)=>{s<n&&r>n&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(s,r)=>r<=n||s>=n}))}return i},provide:i=>Pe.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<i.length;){let n=i[t++],s=i[t++];if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(Oh.range(n,s))}return _e.set(e,!0)}});function Go(i,e,t){var n;let s=null;return(n=i.field(ys,!1))===null||n===void 0||n.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Pv(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function pp(i,e){return i.field(ys,!1)?e:e.concat(nt.appendConfig.of(bp()))}const Bv=i=>{for(let e of dp(i)){let t=Ko(i.state,e.from,e.to);if(t)return i.dispatch({effects:pp(i.state,[bl.of(t),mp(i,t)])}),!0}return!1},Rv=i=>{if(!i.state.field(ys,!1))return!1;let e=[];for(let t of dp(i)){let n=Go(i.state,t.from,t.to);n&&e.push(Wr.of(n),mp(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function mp(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return Pe.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const Nv=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let s=i.lineBlockAt(n),r=Ko(e,s.from,s.to);r&&t.push(bl.of(r)),n=(r?i.lineBlockAt(r.to):s).to+1}return t.length&&i.dispatch({effects:pp(i.state,t)}),!!t.length},Iv=i=>{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(Wr.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},Lv=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Bv},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Rv},{key:"Ctrl-Alt-[",run:Nv},{key:"Ctrl-Alt-]",run:Iv}],$v={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},gp=Ne.define({combine(i){return pi(i,$v)}});function bp(i){return[ys,Hv]}function yp(i,e){let{state:t}=i,n=t.facet(gp),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Go(i.state,l.from,l.to);a&&i.dispatch({effects:Wr.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 Oh=_e.replace({widget:new class extends Ci{toDOM(i){return yp(i,null)}}});class _v extends Ci{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return yp(e,this.value)}}const zv={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class jl 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 Vv(i={}){let e=Object.assign(Object.assign({},zv),i),t=new jl(e,!0),n=new jl(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(Yi)!=o.state.facet(Yi)||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 ji;for(let a of o.viewportLineBlocks){let c=Go(o.state,a.from,a.to)?n:Ko(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 jl(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let c=Go(o.state,l.from,l.to);if(c)return o.dispatch({effects:Wr.of(c)}),!0;let u=Ko(o.state,l.from,l.to);return u?(o.dispatch({effects:bl.of(u)}),!0):!1}})}),bp()]}const Hv=Pe.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 jr{constructor(e,t){this.specs=e;let n;function s(l){let a=qi.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(ls)==o.data:o?l=>l==o:void 0,this.style=rp(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new qi(n):null,this.themeType=t.themeType}static define(e,t){return new jr(e,t||{})}}const za=Ne.define(),wp=Ne.define({combine(i){return i.length?[i[0]]:null}});function ql(i){let e=i.facet(za);return e.length?e:i.facet(wp)}function vp(i,e){let t=[jv],n;return i instanceof jr&&(i.module&&t.push(Pe.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(wp.of(i)):n?t.push(za.computeN([Pe.darkTheme],s=>s.facet(Pe.darkTheme)==(n=="dark")?[i]:[])):t.push(za.of(i)),t}class Wv{constructor(e){this.markCache=Object.create(null),this.tree=sn(e.state),this.decorations=this.buildDeco(e,ql(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=sn(e.state),n=ql(e.state),s=n!=ql(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=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 ji;for(let{from:s,to:r}of e.visibleRanges)fv(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 jv=vs.high(Vt.fromClass(Wv,{decorations:i=>i.decorations})),qv=jr.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"}]),Uv=Pe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),kp=1e4,xp="()[]{}",Sp=Ne.define({combine(i){return pi(i,{afterCursor:!0,brackets:xp,maxScanDistance:kp,renderMatch:Yv})}}),Kv=_e.mark({class:"cm-matchingBracket"}),Gv=_e.mark({class:"cm-nonmatchingBracket"});function Yv(i){let e=[],t=i.matched?Kv:Gv;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 Xv=rn.define({create(){return _e.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(Sp);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.head<e.state.doc.length&&hi(e.state,s.head+1,-1,n));r&&(t=t.concat(n.renderMatch(r,e.state)))}return _e.set(t,!0)},provide:i=>Pe.decorations.from(i)}),Jv=[Xv,Uv];function Qv(i={}){return[Sp.of(i),Jv]}const Zv=new ot;function Va(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 Ha(i){let e=i.type.prop(Zv);return e?e(i.node):i}function hi(i,e,t,n={}){let s=n.maxScanDistance||kp,r=n.brackets||xp,o=sn(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Va(a.type,t,r);if(c&&a.from<a.to){let u=Ha(a);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return e1(i,e,t,a,u,c,r)}}return t1(i,e,t,o,l.type,s,r)}function e1(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.from<u.to){let h=Ha(u);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Va(u.type,t,o))c++;else if(Va(u.type,-t,o)){if(c==0){let h=Ha(u);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:a,matched:!1}}function t1(i,e,t,n,s,r,o){let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)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 Eh(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<e;o++)i.charCodeAt(o)==9?r+=t-r%t:r++;return r}class Cp{constructor(e,t,n,s){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}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.lastColumnPos<this.start&&(this.lastColumnValue=Eh(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Eh(this.string,null,this.tabSize)}match(e,t,n){if(typeof e=="string"){let s=o=>n?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 n1(i){return{name:i.name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||i1,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||wc}}function i1(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 Fh=new WeakMap;class bc extends _n{constructor(e){let t=op(e.languageData),n=n1(e),s,r=new class extends pc{createParse(o,l,a){return new r1(s,o,l,a)}};super(t,r,[ap.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=a1(t),s=this,this.streamParser=n,this.stateAfter=new ot({perNode:!0}),this.tokenTable=e.tokenTable?new Dp(n.tokenTable):l1}static define(e){return new bc(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=Fh.get(e.state),r!=null&&r<t-1e4&&(r=void 0));let l=yc(this,n,0,s.from,r!=null?r:t),a,c;if(l?(c=l.state,a=l.pos+1):(c=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let h=e.state.doc.lineAt(a),f=Math.min(t,h.to);if(h.length){let d=o?o(h.from):-1,p=new Cp(h.text,e.state.tabSize,e.unit,d<0?void 0:d);for(;p.pos<f-h.from;)Tp(this.streamParser.token,p,c)}else this.streamParser.blankLine(c,e.unit);if(f==t)break;a=h.to+1}let u=e.lineAt(t);return o&&r==null&&Fh.set(e.state,u.from),this.streamParser.indent(c,/^\s*(.*)/.exec(u.text)[1],e)}get allowsNesting(){return!1}}function yc(i,e,t,n,s){let r=t>=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<s&&yc(i,l,a,n,s);if(c)return c}return null}function Ap(i,e,t,n,s){if(s&&t<=0&&n>=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(o<n&&l instanceof Tt){if(!(a=Ap(i,l,t-o,n-o,s)))break;return s?new Tt(e.type,e.children.slice(0,r).concat(a),e.positions.slice(0,r+1),o+a.length):a}}return null}function s1(i,e,t,n){for(let s of e){let r=s.from+(s.openStart?25:0),o=s.to-(s.openEnd?25:0),l=r<=t&&o>t&&yc(i,s.tree,0-s.offset,t,o),a;if(l&&(a=Ap(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 r1=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=qs.get(),o=s[0].from,{state:l,tree:a}=s1(e,n,o,r==null?void 0:r.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let c=0;c<a.children.length;c++)this.chunks.push(a.children[c]),this.chunkPos.push(a.positions[c]);r&&this.parsedPos<r.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(bs(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=qs.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+2048);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=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].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,s,r){if(this.ranges.length>1){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 Cp(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=Tp(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.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=Tt.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:o1,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new Tt(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new Tt(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Tp(i,e,t){e.start=e.pos;for(let n=0;n<10;n++){let s=i(e,t);if(e.pos>e.start)return s}throw new Error("Stream parser failed to advance stream.")}const wc=Object.create(null),Or=[wn.none],o1=new pl(Or),Ph=[],Bh=Object.create(null),Mp=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"]])Mp[i]=Op(wc,e);class Dp{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Mp)}resolve(e){return e?this.table[e]||(this.table[e]=Op(this.extra,e)):0}}const l1=new Dp(wc);function Ul(i,e){Ph.indexOf(i)>-1||Ph.push(i)}function Op(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):Ul(c,`Modifier ${c} used at start of tag`):a.length?Ul(c,`Tag ${c} used as modifier`):a=Array.isArray(u)?u:[u]:Ul(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=Bh[s];if(r)return r.id;let o=Bh[s]=wn.define({id:Or.length,name:n,props:[ip({[n]:t})]});return Or.push(o),o.id}function a1(i){let e=wn.define({id:Or.length,name:"Document",props:[ls.add(()=>i)],top:!0});return Or.push(e),e}Rt.RTL,Rt.LTR;const c1=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=kc(i.state,t.from);return n.line?u1(i):n.block?f1(i):!1};function vc(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 u1=vc(m1,0),h1=vc(Ep,0),f1=vc((i,e)=>Ep(i,e,p1(e)),0);function kc(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const rr=50;function d1(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-rr,n),o=i.sliceDoc(s,s+rr),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*rr?u=h=i.sliceDoc(n,s):(u=i.sliceDoc(n,n+rr),h=i.sliceDoc(s-rr,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 p1(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),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 Ep(i,e,t=e.selection.ranges){let n=t.map(r=>kc(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>d1(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;o<s.length;o++)if(l=s[o]){let a=n[o],{open:c,close:u}=l;r.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:r}}return null}function m1(i,e,t=e.selection.ranges){let n=[],s=-1;for(let{from:r,to:o}of t){let l=n.length,a=1e9,c=kc(e,r).line;if(c){for(let u=r;u<=o;){let h=e.doc.lineAt(u);if(h.from>s&&(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;f<h.text.length&&f<a&&(a=f),n.push({line:h,comment:p,token:c,indent:f,empty:d,single:!1})}u=h.to+1}if(a<1e9)for(let u=l;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=a);n.length==l+1&&(n[l].single=!0)}}if(i!=2&&n.some(r=>r.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 Wa=Si.define(),g1=Si.define(),b1=Ne.define(),Fp=Ne.define({combine(i){return pi(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)})}}),Pp=rn.define({create(){return fi.empty},update(i,e){let t=e.state.facet(Fp),n=e.annotation(Wa);if(n){let a=Tn.fromTransaction(e,n.selection),c=n.side,u=c==0?i.undone:i.done;return a?u=Yo(u,u.length,t.minDepth,a):u=Np(u,e.startState.selection),new fi(c==0?n.rest:u,c==0?u:n.rest)}let s=e.annotation(g1);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=Tn.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(Tn.fromJSON),i.undone.map(Tn.fromJSON))}});function y1(i={}){return[Pp,Fp.of(i),Pe.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?Bp:e.inputType=="historyRedo"?ja:null;return n?(e.preventDefault(),n(t)):!1}})]}function yl(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(Pp,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const Bp=yl(0,!1),ja=yl(1,!1),w1=yl(0,!0),v1=yl(1,!0);class Tn{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 Tn(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 Tn(e.changes&&Ut.fromJSON(e.changes),[],e.mapped&&di.fromJSON(e.mapped),e.startSelection&&ce.fromJSON(e.startSelection),e.selectionsAfter.map(ce.fromJSON))}static fromTransaction(e,t){let n=zn;for(let s of e.startState.facet(b1)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new Tn(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,zn)}static selection(e){return new Tn(void 0,zn,void 0,void 0,e)}}function Yo(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 k1(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<t.length;){let c=t[a++],u=t[a++];l>=c&&o<=u&&(n=!0)}}),n}function x1(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function Rp(i,e){return i.length?e.length?i.concat(e):i:e}const zn=[],S1=200;function Np(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-S1));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Yo(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Tn.selection([e])]}function C1(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 Kl(i,e){if(!i.length)return i;let t=i.length,n=zn;for(;t;){let s=A1(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?[Tn.selection(n)]:zn}function A1(i,e,t){let n=Rp(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):zn,t);if(!i.changes)return Tn.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new Tn(s,nt.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const T1=/^(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||T1.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,k1(l.changes,e.changes))||n=="input.type.compose")?o=Yo(o,o.length-1,s.minDepth,new Tn(e.changes.compose(l.changes),Rp(e.effects,l.effects),l.mapped,l.startSelection,zn)):o=Yo(o,o.length,s.minDepth,e),new fi(o,zn,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:zn;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&x1(r[r.length-1],e)?this:new fi(Np(this.done,e),this.undone,t,n)}addMapping(e){return new fi(Kl(this.done,e),Kl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Wa.of({side:e,rest:C1(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?zn:s.slice(0,s.length-1);return r.mapped&&(l=Kl(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Wa.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}fi.empty=new fi(zn,zn);const M1=[{key:"Mod-z",run:Bp,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ja,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ja,preventDefault:!0},{key:"Mod-u",run:w1,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:v1,preventDefault:!0}];function Qs(i,e){return ce.create(i.ranges.map(e),i.mainIndex)}function mi(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Qn({state:i,dispatch:e},t){let n=Qs(i.selection,t);return n.eq(i.selection,!0)?!1:(e(mi(i,n)),!0)}function wl(i,e){return ce.cursor(e?i.to:i.from)}function Ip(i,e){return Qn(i,t=>t.empty?i.moveByChar(t,e):wl(t,e))}function un(i){return i.textDirectionAt(i.state.selection.main.head)==Rt.LTR}const Lp=i=>Ip(i,!un(i)),$p=i=>Ip(i,un(i));function _p(i,e){return Qn(i,t=>t.empty?i.moveByGroup(t,e):wl(t,e))}const D1=i=>_p(i,!un(i)),O1=i=>_p(i,un(i));function E1(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 vl(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;E1(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,ce.cursor(l,t?-1:1)}const F1=i=>Qn(i,e=>vl(i.state,e,!un(i))),P1=i=>Qn(i,e=>vl(i.state,e,un(i)));function zp(i,e){return Qn(i,t=>{if(!t.empty)return wl(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const Vp=i=>zp(i,!1),Hp=i=>zp(i,!0);function Wp(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,s;if(e){for(let r of i.state.facet(Pe.scrollMargins)){let o=r(i);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}s=i.scrollDOM.clientHeight-t-n}else s=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,s-5)}}function jp(i,e){let t=Wp(i),{state:n}=i,s=Qs(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):wl(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.bottom<c&&(r=Pe.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(mi(n,s),{effects:r}),!0}const Rh=i=>jp(i,!1),qa=i=>jp(i,!0);function Ji(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=ce.cursor(n.from+r))}return s}const B1=i=>Qn(i,e=>Ji(i,e,!0)),R1=i=>Qn(i,e=>Ji(i,e,!1)),N1=i=>Qn(i,e=>Ji(i,e,!un(i))),I1=i=>Qn(i,e=>Ji(i,e,un(i))),L1=i=>Qn(i,e=>ce.cursor(i.lineBlockAt(e.head).from,1)),$1=i=>Qn(i,e=>ce.cursor(i.lineBlockAt(e.head).to,-1));function _1(i,e,t){let n=!1,s=Qs(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.head<i.doc.length&&hi(i,r.head+1,-1);if(!o||!o.end)return r;n=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return ce.cursor(l)});return n?(e(mi(i,s)),!0):!1}const z1=({state:i,dispatch:e})=>_1(i,e);function qn(i,e){let t=Qs(i.state.selection,n=>{let s=e(n);return ce.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(mi(i.state,t)),!0)}function qp(i,e){return qn(i,t=>i.moveByChar(t,e))}const Up=i=>qp(i,!un(i)),Kp=i=>qp(i,un(i));function Gp(i,e){return qn(i,t=>i.moveByGroup(t,e))}const V1=i=>Gp(i,!un(i)),H1=i=>Gp(i,un(i)),W1=i=>qn(i,e=>vl(i.state,e,!un(i))),j1=i=>qn(i,e=>vl(i.state,e,un(i)));function Yp(i,e){return qn(i,t=>i.moveVertically(t,e))}const Xp=i=>Yp(i,!1),Jp=i=>Yp(i,!0);function Qp(i,e){return qn(i,t=>i.moveVertically(t,e,Wp(i).height))}const Nh=i=>Qp(i,!1),Ih=i=>Qp(i,!0),q1=i=>qn(i,e=>Ji(i,e,!0)),U1=i=>qn(i,e=>Ji(i,e,!1)),K1=i=>qn(i,e=>Ji(i,e,!un(i))),G1=i=>qn(i,e=>Ji(i,e,un(i))),Y1=i=>qn(i,e=>ce.cursor(i.lineBlockAt(e.head).from)),X1=i=>qn(i,e=>ce.cursor(i.lineBlockAt(e.head).to)),Lh=({state:i,dispatch:e})=>(e(mi(i,{anchor:0})),!0),$h=({state:i,dispatch:e})=>(e(mi(i,{anchor:i.doc.length})),!0),_h=({state:i,dispatch:e})=>(e(mi(i,{anchor:i.selection.main.anchor,head:0})),!0),zh=({state:i,dispatch:e})=>(e(mi(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),J1=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),Q1=({state:i,dispatch:e})=>{let t=kl(i).map(({from:n,to:s})=>ce.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:ce.create(t),userEvent:"select"})),!0},Z1=({state:i,dispatch:e})=>{let t=Qs(i.selection,n=>{var s;let r=sn(i).resolveStack(n.from,1);for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&(!((s=l.parent)===null||s===void 0)&&s.parent))return ce.range(l.to,l.from)}return n});return e(mi(i,t)),!0},ek=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=ce.create([t.main]):t.main.empty||(n=ce.create([ce.cursor(t.main.head)])),n?(e(mi(i,n)),!0):!1};function qr(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);a<o?(t="delete.backward",a=po(i,a,!1)):a>o&&(t="delete.forward",a=po(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=po(i,o,!1),l=po(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:ce.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(i.dispatch(n.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?Pe.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function po(i,e,t){if(i instanceof Pe)for(let n of i.state.facet(Pe.atomicRanges).map(s=>s(i)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Zp=(i,e,t)=>qr(i,n=>{let s=n.from,{state:r}=i,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let c=Js(l,r.tabSize),u=c%bs(r)||bs(r);for(let h=0;h<u&&l[l.length-1-h]==" ";h++)s--;a=s}else a=nn(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=nn(o.text,a-o.from,!1,!1)+o.from);return a}),Ua=i=>Zp(i,!1,!0),em=i=>Zp(i,!0,!1),tm=(i,e)=>qr(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}),nm=i=>tm(i,!1),tk=i=>tm(i,!0),nk=i=>qr(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),ik=i=>qr(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),sk=i=>qr(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),rk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:yt.of(["",""])},range:ce.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},ok=({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:ce.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function kl(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 im(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of kl(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(ce.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(ce.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:ce.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const lk=({state:i,dispatch:e})=>im(i,e,!1),ak=({state:i,dispatch:e})=>im(i,e,!0);function sm(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of kl(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 ck=({state:i,dispatch:e})=>sm(i,e,!1),uk=({state:i,dispatch:e})=>sm(i,e,!0),hk=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(kl(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=Qs(e.selection,s=>{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 fk(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 dk=rm(!1),pk=rm(!0);function rm(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&&fk(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new gl(e,{simulateBreak:r,simulateDoubleBreak:!!a}),u=mc(c,r);for(u==null&&(u=Js(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let h=["",Dr(e,u)];return a&&h.push(Dr(e,c.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:yt.of(h)},range:ce.cursor(r+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function xc(i,e){let t=-1;return i.changeByRange(n=>{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:ce.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const mk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new gl(i,{overrideIndentation:r=>{let o=t[r];return o==null?-1:o}}),s=xc(i,(r,o,l)=>{let a=mc(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],u=Dr(i,a);(c!=u||l.from<r.from+c.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+c.length,insert:u}))});return s.changes.empty||e(i.update(s,{userEvent:"indent"})),!0},om=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(xc(i,(t,n)=>{n.push({from:t.from,insert:i.facet(ml)})}),{userEvent:"input.indent"})),!0),lm=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(xc(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Js(s,i.tabSize),o=0,l=Dr(i,Math.max(0,r-bs(i)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),gk=i=>(i.setTabFocusMode(),!0),bk=[{key:"Ctrl-b",run:Lp,shift:Up,preventDefault:!0},{key:"Ctrl-f",run:$p,shift:Kp},{key:"Ctrl-p",run:Vp,shift:Xp},{key:"Ctrl-n",run:Hp,shift:Jp},{key:"Ctrl-a",run:L1,shift:Y1},{key:"Ctrl-e",run:$1,shift:X1},{key:"Ctrl-d",run:em},{key:"Ctrl-h",run:Ua},{key:"Ctrl-k",run:nk},{key:"Ctrl-Alt-h",run:nm},{key:"Ctrl-o",run:rk},{key:"Ctrl-t",run:ok},{key:"Ctrl-v",run:qa}],yk=[{key:"ArrowLeft",run:Lp,shift:Up,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:D1,shift:V1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:N1,shift:K1,preventDefault:!0},{key:"ArrowRight",run:$p,shift:Kp,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:O1,shift:H1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:I1,shift:G1,preventDefault:!0},{key:"ArrowUp",run:Vp,shift:Xp,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Lh,shift:_h},{mac:"Ctrl-ArrowUp",run:Rh,shift:Nh},{key:"ArrowDown",run:Hp,shift:Jp,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$h,shift:zh},{mac:"Ctrl-ArrowDown",run:qa,shift:Ih},{key:"PageUp",run:Rh,shift:Nh},{key:"PageDown",run:qa,shift:Ih},{key:"Home",run:R1,shift:U1,preventDefault:!0},{key:"Mod-Home",run:Lh,shift:_h},{key:"End",run:B1,shift:q1,preventDefault:!0},{key:"Mod-End",run:$h,shift:zh},{key:"Enter",run:dk},{key:"Mod-a",run:J1},{key:"Backspace",run:Ua,shift:Ua},{key:"Delete",run:em},{key:"Mod-Backspace",mac:"Alt-Backspace",run:nm},{key:"Mod-Delete",mac:"Alt-Delete",run:tk},{mac:"Mod-Backspace",run:ik},{mac:"Mod-Delete",run:sk}].concat(bk.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),wk=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:F1,shift:W1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:P1,shift:j1},{key:"Alt-ArrowUp",run:lk},{key:"Shift-Alt-ArrowUp",run:ck},{key:"Alt-ArrowDown",run:ak},{key:"Shift-Alt-ArrowDown",run:uk},{key:"Escape",run:ek},{key:"Mod-Enter",run:pk},{key:"Alt-l",mac:"Ctrl-l",run:Q1},{key:"Mod-i",run:Z1,preventDefault:!0},{key:"Mod-[",run:lm},{key:"Mod-]",run:om},{key:"Mod-Alt-\\",run:mk},{key:"Shift-Mod-k",run:hk},{key:"Shift-Mod-\\",run:z1},{key:"Mod-/",run:c1},{key:"Alt-A",run:h1},{key:"Ctrl-m",mac:"Shift-Alt-m",run:gk}].concat(yk),vk={key:"Tab",run:om,shift:lm};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(;e<arguments.length;e++)am(i,arguments[e]);return i}function am(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)am(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}const Vh=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class Ks{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(Vh(l)):Vh,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 Zt(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=Za(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=$n(e);let s=this.normalize(t);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&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,n){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:n}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:n}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol!="undefined"&&(Ks.prototype[Symbol.iterator]=function(){return this});const cm={from:-1,to:-1,match:/.*/.exec("")},Sc="gm"+(/x/.unicode==null?"":"u");class um{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=cm,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new hm(e,t,n,s,r);this.re=new RegExp(t,Sc+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=Xo(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.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=Xo(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.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<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Gl=new WeakMap;class Is{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=Gl.get(e);if(!s||s.from>=n||s.to<=t){let l=new Is(t,e.sliceString(t,n));return Gl.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<n&&(r+=e.sliceString(s.to,n)),Gl.set(e,new Is(o,r)),new Is(t,r.slice(t-o,n-o))}}class hm{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=cm,this.matchPos=Xo(e,s),this.re=new RegExp(t,Sc+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=Is.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=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=Xo(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"&&(um.prototype[Symbol.iterator]=hm.prototype[Symbol.iterator]=function(){return this});function kk(i){try{return new RegExp(i,Sc),!0}catch(e){return!1}}function Xo(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}function Ka(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:Jo.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=ce.cursor(p.from+Math.max(0,Math.min(f,p.length)));i.dispatch({effects:[Jo.of(!1),Pe.scrollIntoView(y.from,{y:"center"})],selection:y}),i.focus()}return{dom:n}}const Jo=nt.define(),Hh=rn.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(Jo)&&(i=t.value);return i},provide:i=>Tr.from(i,e=>e?Ka:null)}),xk=i=>{let e=Ar(i,Ka);if(!e){let t=[Jo.of(!0)];i.state.field(Hh,!1)==null&&t.push(nt.appendConfig.of([Hh,Sk])),i.dispatch({effects:t}),e=Ar(i,Ka)}return e&&e.dom.querySelector("input").select(),!0},Sk=Pe.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Ck={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ak=Ne.define({combine(i){return pi(i,Ck,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Tk(i){return[Fk,Ek]}const Mk=_e.mark({class:"cm-selectionMatch"}),Dk=_e.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Wh(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 Ok(i,e,t,n){return i(e.sliceDoc(t,t+1))==It.Word&&i(e.sliceDoc(n-1,n))==It.Word}const Ek=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(Ak),{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(a<e.minSelectionLength||a>200)return _e.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Wh(o,t,s.from,s.to)&&Ok(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 Ks(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:u,to:h}=c.value;if((!o||Wh(o,t,u,h))&&(s.empty&&u<=s.from&&h>=s.to?l.push(Dk.range(u,h)):(u>=s.to||h<=s.from)&&l.push(Mk.range(u,h)),l.length>e.maxMatches))return _e.none}}return _e.set(l)}},{decorations:i=>i.decorations}),Fk=Pe.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Pk=({state:i,dispatch:e})=>{let{selection:t}=i,n=ce.create(t.ranges.map(s=>i.wordAt(s.head)||ce.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function Bk(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 Ks(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Ks(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 Rk=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return Pk({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=Bk(i,n);return s?(e(i.update({selection:i.selection.addRange(ce.range(s.from,s.to),!1),effects:Pe.scrollIntoView(s.to)})),!0):!1},Zs=Ne.define({combine(i){return pi(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Uk(e),scrollToMatch:e=>Pe.scrollIntoView(e)})}});class fm{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||kk(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 $k(this):new Ik(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 dm{constructor(e){this.spec=e}}function As(i,e,t,n){return new Ks(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?Nk(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Nk(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(Qo(s,t-r))!=It.Word||e(Zo(s,t-r))!=It.Word)&&(e(Zo(s,n-r))!=It.Word||e(Qo(s,n-r))!=It.Word))}class Ik extends dm{constructor(e){super(e)}nextMatch(e,t,n){let s=As(this.spec,e,n,e.doc.length).nextOverlapping();return s.done&&(s=As(this.spec,e,0,t).nextOverlapping()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=As(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}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)}matchAll(e,t){let n=As(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(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 um(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?Lk(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function Qo(i,e){return i.slice(nn(i,e,!1),e)}function Zo(i,e){return i.slice(e,nn(i,e))}function Lk(i){return(e,t,n)=>!n[0].length||(i(Qo(n.input,n.index))!=It.Word||i(Zo(n.input,n.index))!=It.Word)&&(i(Zo(n.input,n.index+n[0].length))!=It.Word||i(Qo(n.input,n.index+n[0].length))!=It.Word)}class $k extends dm{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<e.match.length?e.match[n]:t)}matchAll(e,t){let n=Ts(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=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 Er=nt.define(),Cc=nt.define(),zi=rn.define({create(i){return new Yl(Ga(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Er)?i=new Yl(t.value.create(),i.panel):t.is(Cc)&&(i=new Yl(i.query,t.value?Ac:null));return i},provide:i=>Tr.from(i,e=>e.panel)});class Yl{constructor(e,t){this.query=e,this.panel=t}}const _k=_e.mark({class:"cm-searchMatch"}),zk=_e.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Vk=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 ji;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[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?zk:_k)})}return n.finish()}},{decorations:i=>i.decorations});function Ur(i){return e=>{let t=e.state.field(zi,!1);return t&&t.query.spec.valid?i(e,t):gm(e)}}const el=Ur((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=ce.single(n.from,n.to),r=i.state.facet(Zs);return i.dispatch({selection:s,effects:[Tc(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),mm(i),!0}),tl=Ur((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=ce.single(s.from,s.to),o=i.state.facet(Zs);return i.dispatch({selection:r,effects:[Tc(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),mm(i),!0}),Hk=Ur((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:ce.create(t.map(n=>ce.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Wk=({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 Ks(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(ce.range(l.value.from,l.value.to))}return e(i.update({selection:ce.create(r,o),userEvent:"select.search.matches"})),!0},jh=Ur((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(Pe.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=ce.single(r.from-u,r.to-u),c.push(Tc(i,r)),c.push(t.facet(Zs).scrollToMatch(l.main,i))}return i.dispatch({changes:o,selection:l,effects:c,userEvent:"input.replace"}),!0}),jk=Ur((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:Pe.announce.of(n),userEvent:"input.replace.all"}),!0});function Ac(i){return i.state.facet(Zs).createPanel(i)}function Ga(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(Zs);return new fm({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 pm(i){let e=Ar(i,Ac);return e&&e.dom.querySelector("[main-field]")}function mm(i){let e=pm(i);e&&e==i.root.activeElement&&e.select()}const gm=i=>{let e=i.state.field(zi,!1);if(e&&e.panel){let t=pm(i);if(t&&t!=i.root.activeElement){let n=Ga(i.state,e.query.spec);n.valid&&i.dispatch({effects:Er.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[Cc.of(!0),e?Er.of(Ga(i.state,e.query.spec)):nt.appendConfig.of(Gk)]});return!0},bm=i=>{let e=i.state.field(zi,!1);if(!e||!e.panel)return!1;let t=Ar(i,Ac);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:Cc.of(!1)}),!0},qk=[{key:"Mod-f",run:gm,scope:"editor search-panel"},{key:"F3",run:el,shift:tl,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:el,shift:tl,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:bm,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Wk},{key:"Mod-Alt-g",run:xk},{key:"Mod-d",run:Rk,preventDefault:!0}];class Uk{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:Pn(e,"Find"),"aria-label":Pn(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:Pn(e,"Replace"),"aria-label":Pn(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",()=>el(e),[Pn(e,"next")]),n("prev",()=>tl(e),[Pn(e,"previous")]),n("select",()=>Hk(e),[Pn(e,"all")]),Ft("label",null,[this.caseField,Pn(e,"match case")]),Ft("label",null,[this.reField,Pn(e,"regexp")]),Ft("label",null,[this.wordField,Pn(e,"by word")]),...e.state.readOnly?[]:[Ft("br"),this.replaceField,n("replace",()=>jh(e),[Pn(e,"replace")]),n("replaceAll",()=>jk(e),[Pn(e,"replace all")])],Ft("button",{name:"close",onclick:()=>bm(e),"aria-label":Pn(e,"close"),type:"button"},["×"])])}commit(){let e=new fm({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:Er.of(e)}))}keydown(e){Zy(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?tl:el)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),jh(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Er)&&!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(Zs).top}}function Pn(i,e){return i.state.phrase(e)}const mo=30,go=/[\s\.,:;?!]/;function Tc(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-mo),o=Math.min(s,t+mo),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<mo;a++)if(!go.test(l[a+1])&&go.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-mo;a--)if(!go.test(l[a-1])&&go.test(l[a])){l=l.slice(0,a);break}}return Pe.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const Kk=Pe.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"}}),Gk=[zi,vs.low(Vk),Kk];class ym{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}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(wm(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){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function qh(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 Yk(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let n=qh(e)+qh(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function Xk(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Yk(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class Uh{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function Vi(i){return i.selection.main.from}function wm(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 vm=Si.define();function Jk(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=>l!=s&&t!=n&&i.sliceDoc(l.from+r,l.from+o)!=i.sliceDoc(t,n)?{range:l}:{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:e},range:ce.cursor(l.from+r+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const Kh=new WeakMap;function Qk(i){if(!Array.isArray(i))return i;let e=Kh.get(i);return e||Kh.set(i,e=Xk(i)),e}const nl=nt.define(),Fr=nt.define();class Zk{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<e.length;){let n=Zt(e,t),s=$n(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(Zt(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:s,precise:r,byWord:o}=this;if(t.length==1){let A=Zt(e,0),v=$n(A),F=v==e.length?0:-100;if(A!=t[0])if(A==n[0])F+=-200;else return null;return this.ret(F,[0,v])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let A=0,v=Math.min(e.length,200);A<v&&c<a;){let F=Zt(e,A);(F==t[c]||F==n[c])&&(s[c++]=A),A+=$n(F)}if(c<a)return null}let u=0,h=0,f=!1,d=0,p=-1,y=-1,b=/[a-z]/.test(e),m=!0;for(let A=0,v=Math.min(e.length,200),F=0;A<v&&h<a;){let D=Zt(e,A);l<0&&(u<a&&D==t[u]&&(r[u++]=A),d<a&&(D==t[d]||D==n[d]?(d==0&&(p=A),y=A+1,d++):d=0));let E,P=D<255?D>=48&&D<=57||D>=97&&D<=122?2:D>=65&&D<=90?1:0:(E=Za(D))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!A||P==1&&b||F==0&&P!=0)&&(t[h]==D||n[h]==D&&(f=!0)?o[h++]=A:o.length&&(m=!1)),F=P,A+=$n(D)}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(Zt(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 ex{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const tn=Ne.define({combine(i){return pi(i,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:tx,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=>Gh(e(n),t(n)),optionClass:(e,t)=>n=>Gh(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Gh(i,e){return i?e?i+" "+e:i:e}function tx(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<Math.min(p,d)?l=!1:!l&&d<Math.min(p,f)&&(l=!0),p<=(l?f:d))u=Math.max(s.top,Math.min(t.top,s.bottom-y))-e.top,h=Math.min(400,l?f:d);else{a=!0,h=Math.min(400,(o?e.right:s.right-e.left)-30);let A=s.bottom-e.bottom;A>=y||A>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 nx(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;c<r.length;){let u=r[c++],h=r[c++];u>a&&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 a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function Xl(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 ix{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(tn);this.optionContent=nx(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Xl(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]<c.length){this.applyCompletion(e,c[+h[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(tn).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Fr.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=Xl(r.length,o,e.state.facet(tn).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.from||t.selected>=this.range.to)&&(this.range=Xl(t.options.length,t.selected,this.view.state.facet(tn).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=>An(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&&rx(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.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(tn).positionInfo(this.view,t,s,n,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));let r=null;for(let o=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:c}=l;if(c){let f=typeof c=="string"?c:c.name;if(f!=r&&(o>n.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.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function sx(i,e){return t=>new ix(t,i,e)}function rx(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/s:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function Yh(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function ox(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(tn);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 Uh(h,c.source,u?u(h):[],1e9-t.length));else{let h=e.sliceDoc(c.from,c.to),f,d=r.filterStrict?new ex(h):new Zk(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 Uh(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.name<d.name?-1:1)};for(let f of n.sort(h))u-=1e5,c[f.name]=u;for(let f of t){let{section:d}=f.completion;d&&(f.score+=c[typeof d=="string"?d:d.name])}}let o=[],l=null,a=r.compareCompletions;for(let c of t.sort((u,h)=>h.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):Yh(c.completion)>Yh(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,Xh(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r){let o=ox(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new Es(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(tn).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let c=0;c<o.length;c++)if(o[c].completion==a){l=c;break}}return new Es(o,Xh(n,l),{pos:e.reduce((a,c)=>c.hasResult()?Math.min(a,c.from):a,1e8),create:fx,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!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)}}class il{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new il(ux,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(tn),r=(n.override||t.languageDataAt("autocomplete",Vi(t)).map(Qk)).map(l=>(this.active.find(c=>c.source==l)||new pn(l,this.active.some(c=>c.state!=0)?1:0)).update(e,n));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!lx(r,this.active)?o=Es.build(r,t,this.id,o,n):o&&o.disabled&&!r.some(l=>l.state==1)&&(o=null),!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new pn(l.source,0):l));for(let l of e.effects)l.is(xm)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new il(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ax:cx}}function lx(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult;)t++;for(;n<e.length&&!e[n].hasResult;)n++;let s=t==i.length,r=n==e.length;if(s||r)return s==r;if(i[t++].result!=e[n++].result)return!1}}const ax={"aria-autocomplete":"list"},cx={};function Xh(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const ux=[];function Ya(i,e){if(i.isUserEvent("input.complete")){let t=i.annotation(vm);if(t&&e.activateOnCompletion(t))return"input"}return i.isUserEvent("input.type")?"input":i.isUserEvent("delete.backward")?"delete":null}class pn{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Ya(e,t),s=this;n?s=s.handleUserEvent(e,n,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new pn(s.source,0));for(let r of e.effects)if(r.is(nl))s=new pn(s.source,1,r.value?Vi(e.state):-1);else if(r.is(Fr))s=new pn(s.source,0);else if(r.is(km))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,n){return t=="delete"||!n.activateOnTyping?this.map(e.changes):new pn(this.source,1)}handleChange(e){return e.changes.touchesRange(Vi(e.startState))?new pn(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new pn(this.source,this.state,e.mapPos(this.explicitPos))}}class Ls extends pn{constructor(e,t,n,s,r){super(e,2,t),this.result=n,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,n){var s;let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let o=e.changes.mapPos(this.from),l=e.changes.mapPos(this.to,1),a=Vi(e.state);if((this.explicitPos<0?a<=o:a<this.from)||a>l||!r||t=="delete"&&Vi(e.startState)==this.from)return new pn(this.source,t=="input"&&n.activateOnTyping?1:0);let c=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return hx(r.validFor,e.state,o,l)?new Ls(this.source,c,r,o,l):r.update&&(r=r.update(r,o,l,new ym(e.state,a,c>=0)))?new Ls(this.source,c,r,r.from,(s=r.to)!==null&&s!==void 0?s:Vi(e.state)):new pn(this.source,1,c)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new pn(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Ls(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new pn(this.source,0)}}function hx(i,e,t,n){if(!i)return!1;let s=e.sliceDoc(t,n);return typeof i=="function"?i(s,t,n,e):wm(i,!0).test(s)}const km=nt.define({map(i,e){return i.map(t=>t.map(e))}}),xm=nt.define(),xn=rn.define({create(){return il.start()},update(i,e){return i.update(e)},provide:i=>[uc.from(i,e=>e.tooltip),Pe.contentAttributes.from(i,e=>e.attrs)]});function Mc(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(xn).active.find(s=>s.source==e.source);return n instanceof Ls?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},Jk(i.state,t,n.from,n.to)),{annotations:vm.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}const fx=sx(xn,Mc);function bo(i,e="option"){return t=>{let n=t.state.field(xn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(tn).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Yd(t,n.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-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:xm.of(l)}),!0}}const dx=i=>{let e=i.state.field(xn,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(tn).interactionDelay?!1:Mc(i,e.open.options[e.open.selected])},px=i=>i.state.field(xn,!1)?(i.dispatch({effects:nl.of(!0)}),!0):!1,mx=i=>{let e=i.state.field(xn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Fr.of(null)}),!0)};class gx{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const bx=50,yx=1e3,wx=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(xn).active)e.state==1&&this.startQuery(e)}update(i){let e=i.state.field(xn),t=i.state.facet(tn);if(!i.selectionSet&&!i.docChanged&&i.startState.field(xn)==e)return;let n=i.transactions.some(r=>(r.selection||r.docChanged)&&!Ya(r,t));for(let r=0;r<this.running.length;r++){let o=this.running[r];if(n||o.updates.length+i.transactions.length>bx&&Date.now()-o.time>yx){for(let l of o.context.abortListeners)try{l()}catch(a){An(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(nl)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.state==1&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of i.transactions)Ya(r,t)=="input"?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(xn);for(let t of e.active)t.state==1&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t)}startQuery(i){let{state:e}=this.view,t=Vi(e),n=new ym(e,t,i.explicitPos==t),s=new gx(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:Fr.of(null)}),An(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(tn).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(tn);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(s.done===void 0)continue;if(this.running.splice(n--,1),s.done){let o=new Ls(s.active.source,s.active.explicitPos,s.done,s.done.from,(i=s.done.to)!==null&&i!==void 0?i:Vi(s.updates.length?s.updates[0].startState:this.view.state));for(let l of s.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let r=this.view.state.field(xn).active.find(o=>o.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new pn(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:km.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(xn,!1);if(e&&e.tooltip&&this.view.state.facet(tn).closeOnBlur){let t=e.open&&Yd(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Fr.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nl.of(!1)}),20),this.composing=0}}}),vx=typeof navigator=="object"&&/Win/.test(navigator.platform),kx=vs.highest(Pe.domEventHandlers({keydown(i,e){let t=e.state.field(xn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(vx&&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&&Mc(e,n),!1}})),xx=Pe.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"},".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"}}}),Pr={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},as=nt.define({map(i,e){let t=e.mapPos(i,-1,gn.TrackAfter);return t==null?void 0:t}}),Dc=new class extends ds{};Dc.startSide=1;Dc.endSide=-1;const Sm=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(as)&&(i=i.update({add:[Dc.range(t.value,t.value+1)]}));return i}});function Sx(){return[Ax,Sm]}const Jl="()[]{}<>";function Cm(i){for(let e=0;e<Jl.length;e+=2)if(Jl.charCodeAt(e)==i)return Jl.charAt(e+1);return Za(i<128?i:i+1)}function Am(i,e){return i.languageDataAt("closeBrackets",e)[0]||Pr}const Cx=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Ax=Pe.inputHandler.of((i,e,t,n)=>{if((Cx?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&$n(Zt(n,0))==1||e!=s.from||t!=s.to)return!1;let r=Dx(i.state,n);return r?(i.dispatch(r),!0):!1}),Tx=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Am(i,i.selection.main.head).brackets||Pr.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=Ox(i.doc,o.head);for(let a of n)if(a==l&&xl(i.doc,o.head)==Cm(Zt(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:ce.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Mx=[{key:"Backspace",run:Tx}];function Dx(i,e){let t=Am(i,i.selection.main.head),n=t.brackets||Pr.brackets;for(let s of n){let r=Cm(Zt(s,0));if(e==s)return r==s?Px(i,s,n.indexOf(s+s+s)>-1,t):Ex(i,s,r,t.before||Pr.before);if(e==r&&Tm(i,i.selection.main.from))return Fx(i,s,r)}return null}function Tm(i,e){let t=!1;return i.field(Sm).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function xl(i,e){let t=i.sliceString(e,e+2);return t.slice(0,$n(Zt(t,0)))}function Ox(i,e){let t=i.sliceString(e-2,e);return $n(Zt(t,0))==t.length?t:t.slice(1)}function Ex(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:as.of(o.to+e.length),range:ce.range(o.anchor+e.length,o.head+e.length)};let l=xl(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:as.of(o.head+e.length),range:ce.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Fx(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&xl(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:ce.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Px(i,e,t,n){let s=n.stringPrefixes||Pr.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:as.of(l.to+e.length),range:ce.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=xl(i.doc,a),u;if(c==e){if(Jh(i,a))return{changes:{insert:e+e,from:a},effects:as.of(a+e.length),range:ce.cursor(a+e.length)};if(Tm(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:ce.cursor(a+f.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(u=Qh(i,a-2*e.length,s))>-1&&Jh(i,u))return{changes:{insert:e+e+e+e,from:a},effects:as.of(a+e.length),range:ce.cursor(a+e.length)};if(i.charCategorizer(a)(c)!=It.Word&&Qh(i,a,s)>-1&&!Bx(i,a,e,s))return{changes:{insert:e+e,from:a},effects:as.of(a+e.length),range:ce.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Jh(i,e){let t=sn(i).resolveInner(e+1);return t.parent&&t.from==e}function Bx(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 Qh(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 Rx(i={}){return[kx,xn,tn.of(i),wx,Nx,xx]}const Mm=[{key:"Ctrl-Space",run:px},{key:"Escape",run:mx},{key:"ArrowDown",run:bo(!0)},{key:"ArrowUp",run:bo(!1)},{key:"PageDown",run:bo(!0,"page")},{key:"PageUp",run:bo(!1,"page")},{key:"Enter",run:dx}],Nx=vs.highest(fl.computeN([tn],i=>i.facet(tn).defaultKeymap?[Mm]:[]));class Ix{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class is{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=e,r=n.facet(Br).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 qx(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 is(o,t,Gs(o))}}function Gs(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 Ix(s,r,o.diagnostic),!1}),n}function Lx(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(Br).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(Dm))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function $x(i,e){return i.field(Nn,!1)?e:e.concat(nt.appendConfig.of(Gx))}const Dm=nt.define(),Oc=nt.define(),Om=nt.define(),Nn=rn.define({create(){return new is(_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=Gs(t,i.selected.diagnostic,r)||Gs(t,null,r)}!t.size&&s&&e.state.facet(Br).autoPanel&&(s=null),i=new is(t,s,n)}for(let t of e.effects)if(t.is(Dm)){let n=e.state.facet(Br).autoPanel?t.value.length?Rr.open:null:i.panel;i=is.init(t.value,n,e.state)}else t.is(Oc)?i=new is(i.diagnostics,t.value?Rr.open:null,i.selected):t.is(Om)&&(i=new is(i.diagnostics,i.panel,t.value));return i},provide:i=>[Tr.from(i,e=>e.panel),Pe.decorations.from(i,e=>e.diagnostics)]}),_x=_e.mark({class:"cm-lintRange cm-lintRange-active"});function zx(i,e,t){let{diagnostics:n}=i.state.field(Nn),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<c||t<0))&&(s.push(u.diagnostic),r=Math.min(a,r),o=Math.max(c,o))});let l=i.state.facet(Br).tooltipFilter;return l&&(s=l(s,i.state)),s.length?{pos:r,end:o,above:i.state.doc.lineAt(r).to<o,create(){return{dom:Vx(i,s)}}}:null}function Vx(i,e){return Ft("ul",{class:"cm-tooltip-lint"},e.map(t=>Fm(i,t,!1)))}const Hx=i=>{let e=i.state.field(Nn,!1);(!e||!e.panel)&&i.dispatch({effects:$x(i.state,[Oc.of(!0)])});let t=Ar(i,Rr.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Zh=i=>{let e=i.state.field(Nn,!1);return!e||!e.panel?!1:(i.dispatch({effects:Oc.of(!1)}),!0)},Wx=i=>{let e=i.state.field(Nn,!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)},jx=[{key:"Mod-Shift-m",run:Hx,preventDefault:!0},{key:"F8",run:Wx}],Br=Ne.define({combine(i){return Object.assign({sources:i.map(e=>e.source).filter(e=>e!=null)},pi(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 Em(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let s=t[n];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Fm(i,e,t){var n;let s=t?Em(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=Gs(i.state.field(Nn).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 qx 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 ef{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Fm(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Rr{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)Zh(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=Em(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Gs(this.view.state.field(Nn).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},n=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=Ft("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=Ft("div",{class:"cm-panel-lint"},this.list,Ft("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Zh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Nn).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Nn),n=0,s=!1,r=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let c=-1,u;for(let h=n;h<this.items.length;h++)if(this.items[h].diagnostic==a.diagnostic){c=h;break}c<0?(u=new ef(this.view,a.diagnostic),this.items.splice(n,0,u),s=!0):(u=this.items[c],c>n&&(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<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new ef(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.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(Nn),n=Gs(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Om.of(n)})}static open(e){return new Rr(e)}}function Ux(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function yo(i){return Ux(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Kx=Pe.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:yo("#d11")},".cm-lintRange-warning":{backgroundImage:yo("orange")},".cm-lintRange-info":{backgroundImage:yo("#999")},".cm-lintRange-hint":{backgroundImage:yo("#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}}}),Gx=[Nn,Pe.decorations.compute([Nn],i=>{let{selected:e,panel:t}=i.field(Nn);return!e||!t||e.from==e.to?_e.none:_e.set([_x.range(e.from,e.to)])}),Vw(zx,{hideOn:Lx}),Kx],Yx=[Xw(),Zw(),gw(),y1(),Vv(),rw(),uw(),ht.allowMultipleSelections.of(!0),Mv(),vp(qv,{fallback:!0}),Qv(),Sx(),Rx(),Ew(),Bw(),xw(),Tk(),fl.of([...Mx,...wk,...qk,...M1,...Lv,...Mm,...jx])];/*!
- * VueCodemirror v6.1.1
- * Copyright (c) Surmon. All rights reserved.
- * Released under the MIT License.
- * Surmon
- */var Xx=Object.freeze({autofocus:!1,disabled:!1,indentWithTab:!0,tabSize:2,placeholder:"",autoDestroy:!0,extensions:[Yx]}),Jx=Symbol("vue-codemirror-global-config"),mn,Qx=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<c.length;u++)l.indexOf(c[u])<0&&Object.prototype.propertyIsEnumerable.call(o,c[u])&&(a[c[u]]=o[c[u]])}return a}(i,["onUpdate","onChange","onFocus","onBlur"]);return ht.create({doc:r.doc,selection:r.selection,extensions:(Array.isArray(r.extensions)?r.extensions:[r.extensions]).concat([Pe.updateListener.of(function(o){e(o),o.docChanged&&t(o.state.doc.toString(),o),o.focusChanged&&(o.view.hasFocus?n(o):s(o))})])})},Ms=function(i){var e=new _r;return{compartment:e,run:function(t){e.get(i.state)?i.dispatch({effects:e.reconfigure(t)}):i.dispatch({effects:nt.appendConfig.of(e.of(t))})}}},tf=function(i,e){var t=Ms(i),n=t.compartment,s=t.run;return function(r){var o=n.get(i.state);s((r!=null?r:o!==e)?e:[])}},wo={type:Boolean,default:void 0},Zx={autofocus:wo,disabled:wo,indentWithTab:wo,tabSize:Number,placeholder:String,style:Object,autoDestroy:wo,phrases:Object,root:Object,extensions:Array,selection:Object},eS={modelValue:{type:String,default:""}},tS=Object.assign(Object.assign({},Zx),eS);(function(i){i.Change="change",i.Update="update",i.Focus="focus",i.Blur="blur",i.Ready="ready",i.ModelUpdate="update:modelValue"})(mn||(mn={}));var ss={};ss[mn.Change]=function(i,e){return!0},ss[mn.Update]=function(i){return!0},ss[mn.Focus]=function(i){return!0},ss[mn.Blur]=function(i){return!0},ss[mn.Ready]=function(i){return!0};var Pm={};Pm[mn.ModelUpdate]=ss[mn.Change];var nS=Object.assign(Object.assign({},ss),Pm),iS=Gt({name:"VueCodemirror",props:Object.assign({},tS),emits:Object.assign({},nS),setup:function(i,e){var t=Tl(),n=Tl(),s=Tl(),r=Object.assign(Object.assign({},Xx),xg(Jx,{})),o=dt(function(){var l={};return Object.keys(ea(i)).forEach(function(a){var c;a!=="modelValue"&&(l[a]=(c=i[a])!==null&&c!==void 0?c:r[a])}),l});return Nr(function(){var l;n.value=Qx({doc:i.modelValue,selection:o.value.selection,extensions:(l=r.extensions)!==null&&l!==void 0?l:[],onFocus:function(c){return e.emit(mn.Focus,c)},onBlur:function(c){return e.emit(mn.Blur,c)},onUpdate:function(c){return e.emit(mn.Update,c)},onChange:function(c,u){c!==i.modelValue&&(e.emit(mn.Change,c,u),e.emit(mn.ModelUpdate,c,u))}}),s.value=function(c){return new Pe(Object.assign({},c))}({state:n.value,parent:t.value,root:o.value.root});var a=function(c){var u=function(){return c.state.doc.toString()},h=Ms(c).run,f=tf(c,[Pe.editable.of(!1),ht.readOnly.of(!0)]),d=tf(c,fl.of([vk])),p=Ms(c).run,y=Ms(c).run,b=Ms(c).run,m=Ms(c).run;return{focus:function(){return c.focus()},getDoc:u,setDoc:function(A){A!==u()&&c.dispatch({changes:{from:0,to:c.state.doc.length,insert:A}})},reExtensions:h,toggleDisabled:f,toggleIndentWithTab:d,setTabSize:function(A){p([ht.tabSize.of(A),ml.of(" ".repeat(A))])},setPhrases:function(A){y([ht.phrases.of(A)])},setPlaceholder:function(A){b(Tw(A))},setStyle:function(A){A===void 0&&(A={}),m(Pe.theme({"&":Object.assign({},A)}))}}}(s.value);mt(function(){return i.modelValue},function(c){c!==a.getDoc()&&a.setDoc(c)}),mt(function(){return i.extensions},function(c){return a.reExtensions(c||[])},{immediate:!0}),mt(function(){return o.value.disabled},function(c){return a.toggleDisabled(c)},{immediate:!0}),mt(function(){return o.value.indentWithTab},function(c){return a.toggleIndentWithTab(c)},{immediate:!0}),mt(function(){return o.value.tabSize},function(c){return a.setTabSize(c)},{immediate:!0}),mt(function(){return o.value.phrases},function(c){return a.setPhrases(c||{})},{immediate:!0}),mt(function(){return o.value.placeholder},function(c){return a.setPlaceholder(c)},{immediate:!0}),mt(function(){return o.value.style},function(c){return a.setStyle(c)},{immediate:!0}),o.value.autofocus&&a.focus(),e.emit(mn.Ready,{state:n.value,view:s.value,container:t.value})}),ff(function(){o.value.autoDestroy&&s.value&&function(l){l.destroy()}(s.value)}),function(){return Sg("div",{class:"v-codemirror",style:{display:"contents"},ref:t})}}}),sS=iS,Ds=(i=>(i.JSON="json",i.YAML="yaml",i))(Ds||{}),Bm=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=Pe.theme(s,{dark:e==="dark"}),a=jr.define(n),c=[l,vp(a)];return c},rS={background:"#fff",foreground:"#24292e",selection:"#BBDFFF",selectionMatch:"#BBDFFF",gutterBackground:"#fff",gutterForeground:"#6e7781"},oS=i=>{var{theme:e="light",settings:t={},styles:n=[]}={};return Bm({theme:e,settings:kf({},rS,t),styles:[{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"},...n]})},lS=oS(),aS={background:"#0d1117",foreground:"#c9d1d9",caret:"#c9d1d9",selection:"#003d73",selectionMatch:"#003d73",lineHighlight:"#36334280"},cS=i=>{var{theme:e="dark",settings:t={},styles:n=[]}={};return Bm({theme:e,settings:kf({},aS,t),styles:[{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"},...n]})},uS=cS(),hS=["true","false","on","off","yes","no"],fS=new RegExp("\\b(("+hS.join(")|(")+"))$","i");const dS={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(fS))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 nf={};class sl{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 sl(e,[],t,n,n,0,[],0,s?new sf(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;this.reducePos<this.pos-25&&this.setLookAhead(this.pos);let o=r.dynamicPrecedence(s);if(o&&(this.score+=o),n==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,4,!0),this.reduceContext(s,this.reducePos);return}let l=this.stack.length-(n-1)*3-(e&262144?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-a;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=c));let u=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-u;if(s<r.minRepeatTerm||e&131072){let f=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,a,f,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=r.getGoto(f,s,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(s,a)}storeNode(e,t,n,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>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)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 sl(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 pS(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;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let n=[];for(let s=0;s<t.length&&n.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>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;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new sf(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class sf{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class pS{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 rl{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 rl(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 rl(this.stack,this.pos,this.index)}}function vo(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,s=0;n<i.length;){let r=0;for(;;){let o=i.charCodeAt(n++),l=!1;if(o==126){r=65535;break}o>=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 Po{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const rf=new Po;class mS{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=rf,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(;r<n.from;){if(!s)return null;let o=this.ranges[--s];r-=n.from-o.to,n=o}for(;t<0?r>n.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&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,s;if(t>=0&&t<this.chunk.length)n=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(n=r,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.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.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.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=rf,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(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;gS(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 gS(i,e,t,n,s,r){let o=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;l&i[o];){let c=i[o+1];for(let d=o+3;d<c;d+=2)if((i[d+1]&l)>0){let p=i[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||bS(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<f;){let d=h+f>>1,p=c+d+(d<<1),y=i[p],b=i[p+1]||65536;if(u<y)f=d;else if(u>=b)h=d+1;else{o=i[p+2],e.advance();continue e}}break}}function of(i,e,t){for(let n=e,s;(s=i[n])!=65535;n++)if(s==t)return n-e;return-1}function bS(i,e,t,n){let s=of(t,n,e);return s<0||of(t,n,i)<s}const Bn=typeof process!="undefined"&&nf&&/\bparse\b/.test(nf.LOG);let Ql=null;function lf(i,e,t){let n=i.cursor(Xt.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>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 yS{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?lf(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?lf(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(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],s=this.index[t];if(s==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[s],o=this.start[t]+n.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof Tt){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(ot.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=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 wS{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Po)}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;c<r.length;c++){if(!(1<<c&o))continue;let u=r[c],h=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||h.start!=e.pos||h.mask!=o||h.context!=l)&&(this.updateCachedToken(h,u,e),h.mask=o,h.context=l),h.lookAhead>h.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 Po,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 Po,{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<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.specializers[o](this.stream.read(e.start,e.end),n);if(l>=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;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=n,s}addActions(e,t,n,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let c=o.stateSlot(r,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=bi(l,c+2);else{s==0&&l[c+1]==2&&(s=this.putAction(bi(l,c+2),t,n,s));break}l[c]==t&&(s=this.putAction(bi(l,c+1),t,n,s))}return s}}class vS{constructor(e,t,n,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new mS(t,s),this.tokens=new wS(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[sl.start(this,e.top[0],r)],this.fragments=n.length&&this.stream.end-r>e.bufferLength*4?new yS(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;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)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&&xS(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;o<n.length-1;o++){let l=n[o];for(let a=o+1;a<n.length;a++){let c=n[a];if(l.sameState(c)||l.buffer.length>500&&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<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let s=e.pos,{parser:r}=this,o=Bn?this.stackID(e)+" -> ":"";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;c<a.length;){let u=a[c++],h=a[c++],f=a[c++],d=c==a.length||!n,p=d?e:e.split(),y=this.tokens.mainToken;if(p.apply(u,h,y?y.start:p.pos,f),d)return!0;p.pos>s?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 af(e,t),!0}}runRecovery(e,t,n){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],c=t[(o<<1)+1],u=Bn?this.stackID(l)+" -> ":"";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++)Bn&&(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),af(l,n)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Tt.build({buffer:rl.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Ql||(Ql=new WeakMap)).get(e);return t||Ql.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function af(i,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==i.pos&&n.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}class kS{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class ol extends pc{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,c){s[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=ot[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=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 pl(t.map((l,a)=>wn.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=Zd;let o=vo(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(cf),this.states=vo(e.states,Uint32Array),this.data=vo(e.stateData),this.goto=vo(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof 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 vS(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);r<c;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=n[r])==65535)if(n[r+1]==1)o=n[r=bi(n,r+2)];else{if(n[r+1]==2)return bi(n,r+2);break}if(o==t||o==0)return bi(n,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}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=bi(this.data,r+2);else break;s=t(bi(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=bi(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(ol.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]=cf(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;r<t.length;r++)if(!n[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new kS(e,n,s)}static deserialize(e){return new ol(e)}}function bi(i,e){return i[e]|i[e+1]<<16}function xS(i){let e=null;for(let t of i){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function cf(i){if(i.external){let e=i.extend?1:0;return(t,n)=>i.external(t,n)<<1|e}return i.get}const SS=ip({String:X.string,Number:X.number,"True False":X.bool,PropertyName:X.propertyName,Null:X.null,",":X.separator,"[ ]":X.squareBracket,"{ }":X.brace}),CS=ol.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:[SS],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}),AS=Uo.define({name:"json",parser:CS.configure({props:[cp.add({Object:Dh({except:/^\s*\}/}),Array:Dh({except:/^\s*\]/})}),hp.add({"Object Array":Ov})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function TS(){return new yv(AS)}const MS={class:"h-full"},DS=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("");Cg(()=>{n.value=t.value});const s=e,o=mf().getDarkMode;let l=[];switch(o==="dark"?l.push(uS):l.push(lS),t.mode){case Ds.YAML:{l.push(bc.define(dS));break}case Ds.JSON:l.push(TS())}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",MS,[rt(G(sS),{"model-value":n.value,"onUpdate:modelValue":u[0]||(u[0]=h=>n.value=h),onChange:a,extensions:G(l),autofocus:!0,"indent-with-tab":!0,"tab-size":2},null,8,["model-value","extensions"])]))}}),OS=gf(DS);(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=>re=>re.options.get(L),s=L=>{const re=L.options.register;re("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 re=L.dom;e(re).walk(L.selection.getRng(),N=>{t.each(N,Q=>{h(Q)&&re.remove(Q,!1)})})},d=L=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(L),p=L=>L.dom.getParent(L.selection.getStart(),o),y=L=>{const re=p(L);return re?a(re):""},b=(L,re)=>{L.undoManager.transact(()=>{r(L)||L.selection.collapse(!0),L.selection.isCollapsed()?L.insertContent(L.dom.createHTML("a",{id:re})):(f(L),L.formatter.remove("namedAnchor",void 0,void 0,!0),L.formatter.apply("namedAnchor",{value:re}),L.addVisual())})},m=(L,re,N)=>{N.removeAttribute("name"),N.id=re,L.addVisual(),L.undoManager.add()},A=(L,re)=>{const N=p(L);N?m(L,re,N):b(L,re),L.focus()},v=(L,re)=>d(re)?(A(L,re),!0):(L.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1),F=L=>{const re=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:re},onSubmit:N=>{v(L,N.getData().id)&&N.close()}})},D=L=>{L.addCommand("mceAnchor",()=>{F(L)})},E=L=>l(L.attr("href"))&&!l(L.attr("id")||L.attr("name")),P=L=>E(L)&&!L.firstChild,T=L=>re=>{for(let N=0;N<re.length;N++){const Q=re[N];P(Q)&&Q.attr("contenteditable",L)}},M=L=>{L.on("PreInit",()=>{L.parser.addNodeFilter("a",T("false")),L.serializer.addNodeFilter("a",T(null))})},V=L=>{L.formatter.register("namedAnchor",{inline:"a",selector:o,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(re,N,Q)=>u(re)})},H=L=>re=>{const N=()=>{re.setEnabled(L.selection.isEditable())};return L.on("NodeChange",N),N(),()=>{L.off("NodeChange",N)}},te=L=>{const re=()=>L.execCommand("mceAnchor");L.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:re,onSetup:N=>{const Q=L.selection.selectorChangedWithUnbind("a:not([href])",N.setActive).unbind,$=H(L)(N);return()=>{Q(),$()}}}),L.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:re,onSetup:H(L)})};var ue=()=>{i.add("anchor",L=>{s(L),M(L),D(L),te(L),L.on("PreInit",()=>{V(L)})})};ue()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=($,ie,le)=>{var _;return le($,ie.prototype)?!0:((_=$.constructor)===null||_===void 0?void 0:_.name)===ie.name},t=$=>{const ie=typeof $;return $===null?"null":ie==="object"&&Array.isArray($)?"array":ie==="object"&&e($,String,(le,_)=>_.isPrototypeOf(le))?"string":ie},n=$=>ie=>t(ie)===$,s=$=>ie=>$===ie,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 ie={s:1e3,m:6e4},le=/^(\d+)([ms]?)$/.exec($);return(le&&le[2]?ie[le[2]]:1)*parseInt($,10)},p=$=>ie=>ie.options.get($),y=$=>{const ie=$.options.register,le=_=>{const Y=r(_);return Y?{value:d(_),valid:Y}:{valid:!1,message:"Must be a string."}};ie("autosave_ask_before_unload",{processor:"boolean",default:!0}),ie("autosave_prefix",{processor:"string",default:"tinymce-autosave-{path}{query}{hash}-{id}-"}),ie("autosave_restore_when_empty",{processor:"boolean",default:!1}),ie("autosave_interval",{processor:le,default:"30s"}),ie("autosave_retention",{processor:le,default:"20m"})},b=p("autosave_ask_before_unload"),m=p("autosave_restore_when_empty"),A=p("autosave_interval"),v=p("autosave_retention"),F=$=>{const ie=document.location;return $.options.get("autosave_prefix").replace(/{path}/g,ie.pathname).replace(/{query}/g,ie.search).replace(/{hash}/g,ie.hash).replace(/{id}/g,$.id)},D=($,ie)=>{if(o(ie))return $.dom.isEmpty($.getBody());{const le=c.trim(ie);if(le==="")return!0;{const _=new DOMParser().parseFromString(le,"text/html");return $.dom.isEmpty(_)}}},E=$=>{var ie;const le=parseInt((ie=a.getItem(F($)+"time"))!==null&&ie!==void 0?ie:"0",10)||0;return new Date().getTime()-le>v($)?(P($,!1),!1):!0},P=($,ie)=>{const le=F($);a.removeItem(le+"draft"),a.removeItem(le+"time"),ie!==!1&&f($)},T=$=>{const ie=F($);!D($)&&$.isDirty()&&(a.setItem(ie+"draft",$.getContent({format:"raw",no_events:!0})),a.setItem(ie+"time",new Date().getTime().toString()),h($))},M=$=>{var ie;const le=F($);E($)&&($.setContent((ie=a.getItem(le+"draft"))!==null&&ie!==void 0?ie:"",{format:"raw"}),u($))},V=$=>{const ie=A($);l.setEditorInterval($,()=>{T($)},ie)},H=$=>{$.undoManager.transact(()=>{M($),P($)}),$.focus()},te=$=>({hasDraft:()=>E($),storeDraft:()=>T($),restoreDraft:()=>M($),removeDraft:ie=>P($,ie),isEmpty:ie=>D($,ie)});var ue=tinymce.util.Tools.resolve("tinymce.EditorManager");const L=$=>{$.editorManager.on("BeforeUnload",ie=>{let le;c.each(ue.get(),_=>{_.plugins.autosave&&_.plugins.autosave.storeDraft(),!le&&_.isDirty()&&b(_)&&(le=_.translate("You have unsaved changes are you sure you want to navigate away?"))}),le&&(ie.preventDefault(),ie.returnValue=le)})},re=$=>ie=>{ie.setEnabled(E($));const le=()=>ie.setEnabled(E($));return $.on("StoreDraft RestoreDraft RemoveDraft",le),()=>$.off("StoreDraft RestoreDraft RemoveDraft",le)},N=$=>{V($);const ie=()=>{H($)};$.ui.registry.addButton("restoredraft",{tooltip:"Restore last draft",icon:"restore-draft",onAction:ie,onSetup:re($)}),$.ui.registry.addMenuItem("restoredraft",{text:"Restore last draft",icon:"restore-draft",onAction:ie,onSetup:re($)})};var Q=()=>{i.add("autosave",$=>(y($),L($),N($),$.on("init",()=>{m($)&&$.dom.isEmpty($.getBody())&&M($)}),te($)))};Q()})();(function(){const i=v=>{let F=v;return{get:()=>F,set:P=>{F=P}}};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=>F=>F.options.get(v),o=v=>{const F=v.options.register;F("autoresize_overflow_padding",{processor:"number",default:1}),F("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,F)=>{const D=v.getBody();D&&(D.style.overflowY=F?"":"hidden",F||(D.scrollTop=0))},d=(v,F,D,E)=>{var P;const T=parseInt((P=v.getStyle(F,D,E))!==null&&P!==void 0?P:"",10);return isNaN(T)?0:T},p=v=>{if((v==null?void 0:v.type.toLowerCase())==="setcontent"){const F=v;return F.selection===!0||F.paste===!0}else return!1},y=(v,F,D,E)=>{var P;const T=v.dom,M=v.getDoc();if(!M)return;if(h(v)){f(v,!0);return}const V=M.documentElement,H=E?E():c(v),te=(P=l(v))!==null&&P!==void 0?P:v.getElement().offsetHeight;let ue=te;const L=d(T,V,"margin-top",!0),re=d(T,V,"margin-bottom",!0);let N=V.offsetHeight+L+re+H;N<0&&(N=0);const Q=v.getContainer().offsetHeight,$=v.getContentAreaContainer().offsetHeight,ie=Q-$;N+ie>te&&(ue=N+ie);const le=a(v);if(le&&ue>le?(ue=le,f(v,!0)):f(v,!1),ue!==F.get()){const _=ue-F.get();if(T.setStyle(v.getContainer(),"height",ue+"px"),F.set(ue),s(v),n.browser.isSafari()&&(n.os.isMacOS()||n.os.isiOS())){const Y=v.getWin();Y.scrollTo(Y.pageXOffset,Y.pageYOffset)}v.hasFocus()&&p(D)&&v.selection.scrollIntoView(),(n.browser.isSafari()||n.browser.isChromium())&&_<0&&y(v,F,D,E)}},b=(v,F)=>{let D=()=>u(v),E,P;v.on("init",T=>{E=0;const M=c(v),V=v.dom;V.setStyles(v.getDoc().documentElement,{height:"auto"}),n.browser.isEdge()||n.browser.isIE()?V.setStyles(v.getBody(),{paddingLeft:M,paddingRight:M,"min-height":0}):V.setStyles(v.getBody(),{paddingLeft:M,paddingRight:M}),y(v,F,T,D),E+=1}),v.on("NodeChange SetContent keyup FullscreenStateChanged ResizeContent",T=>{if(E===1)P=v.getContainer().offsetHeight,y(v,F,T,D),E+=1;else if(E===2){const M=P<v.getContainer().offsetHeight;if(M){const V=v.dom,H=v.getDoc();V.setStyles(H.documentElement,{"min-height":0}),V.setStyles(v.getBody(),{"min-height":"inherit"})}D=M?t(0):D,E+=1}else y(v,F,T,D)})},m=(v,F)=>{v.addCommand("mceAutoResize",()=>{y(v,F)})};var A=()=>{e.add("autoresize",v=>{if(o(v),v.options.isSet("resize")||v.options.set("resize",!1),!v.inline){const F=i(0);m(v,F),b(v,F)}})};A()})();(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=N=>N==null,t=N=>!e(N),n=()=>{},s=N=>()=>N;class r{constructor(Q,$){this.tag=Q,this.value=$}static some(Q){return new r(!0,Q)}static none(){return r.singletonNone}fold(Q,$){return this.tag?$(this.value):Q()}isSome(){return this.tag}isNone(){return!this.tag}map(Q){return this.tag?r.some(Q(this.value)):r.none()}bind(Q){return this.tag?Q(this.value):r.none()}exists(Q){return this.tag&&Q(this.value)}forall(Q){return!this.tag||Q(this.value)}filter(Q){return!this.tag||Q(this.value)?this:r.none()}getOr(Q){return this.tag?this.value:Q}or(Q){return this.tag?this:Q}getOrThunk(Q){return this.tag?this.value:Q()}orThunk(Q){return this.tag?this:Q()}getOrDie(Q){if(this.tag)return this.value;throw new Error(Q!=null?Q:"Called getOrDie on None")}static from(Q){return t(Q)?r.some(Q):r.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(Q){this.tag&&Q(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}r.singletonNone=new r(!1);const o=(N,Q)=>Q>=0&&Q<N.length?r.some(N[Q]):r.none(),l=N=>o(N,0);var a=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");const c=typeof window!="undefined"?window:Function("return this;")(),u=function(N,Q,$){const ie=window.Prism;window.Prism={manual:!0};var le=typeof window!="undefined"?window:typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope?self:{},_=function(Y){var ye=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,we=0,Le={},ve={manual:Y.Prism&&Y.Prism.manual,disableWorkerMessageHandler:Y.Prism&&Y.Prism.disableWorkerMessageHandler,util:{encode:function j(ee){return ee instanceof qe?new qe(ee.type,j(ee.content),ee.alias):Array.isArray(ee)?ee.map(j):ee.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(j){return Object.prototype.toString.call(j).slice(8,-1)},objId:function(j){return j.__id||Object.defineProperty(j,"__id",{value:++we}),j.__id},clone:function j(ee,ae){ae=ae||{};var he,fe;switch(ve.util.type(ee)){case"Object":if(fe=ve.util.objId(ee),ae[fe])return ae[fe];he={},ae[fe]=he;for(var O in ee)ee.hasOwnProperty(O)&&(he[O]=j(ee[O],ae));return he;case"Array":return fe=ve.util.objId(ee),ae[fe]?ae[fe]:(he=[],ae[fe]=he,ee.forEach(function(I,Z){he[Z]=j(I,ae)}),he);default:return ee}},getLanguage:function(j){for(;j;){var ee=ye.exec(j.className);if(ee)return ee[1].toLowerCase();j=j.parentElement}return"none"},setLanguage:function(j,ee){j.className=j.className.replace(RegExp(ye,"gi"),""),j.classList.add("language-"+ee)},currentScript:function(){if(typeof document=="undefined")return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(he){var j=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(he.stack)||[])[1];if(j){var ee=document.getElementsByTagName("script");for(var ae in ee)if(ee[ae].src==j)return ee[ae]}return null}},isActive:function(j,ee,ae){for(var he="no-"+ee;j;){var fe=j.classList;if(fe.contains(ee))return!0;if(fe.contains(he))return!1;j=j.parentElement}return!!ae}},languages:{plain:Le,plaintext:Le,text:Le,txt:Le,extend:function(j,ee){var ae=ve.util.clone(ve.languages[j]);for(var he in ee)ae[he]=ee[he];return ae},insertBefore:function(j,ee,ae,he){he=he||ve.languages;var fe=he[j],O={};for(var I in fe)if(fe.hasOwnProperty(I)){if(I==ee)for(var Z in ae)ae.hasOwnProperty(Z)&&(O[Z]=ae[Z]);ae.hasOwnProperty(I)||(O[I]=fe[I])}var xe=he[j];return he[j]=O,ve.languages.DFS(ve.languages,function($e,He){He===xe&&$e!=j&&(this[$e]=O)}),O},DFS:function j(ee,ae,he,fe){fe=fe||{};var O=ve.util.objId;for(var I in ee)if(ee.hasOwnProperty(I)){ae.call(ee,I,ee[I],he||I);var Z=ee[I],xe=ve.util.type(Z);xe==="Object"&&!fe[O(Z)]?(fe[O(Z)]=!0,j(Z,ae,null,fe)):xe==="Array"&&!fe[O(Z)]&&(fe[O(Z)]=!0,j(Z,ae,I,fe))}}},plugins:{},highlightAll:function(j,ee){ve.highlightAllUnder(document,j,ee)},highlightAllUnder:function(j,ee,ae){var he={callback:ae,container:j,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};ve.hooks.run("before-highlightall",he),he.elements=Array.prototype.slice.apply(he.container.querySelectorAll(he.selector)),ve.hooks.run("before-all-elements-highlight",he);for(var fe=0,O;O=he.elements[fe++];)ve.highlightElement(O,ee===!0,he.callback)},highlightElement:function(j,ee,ae){var he=ve.util.getLanguage(j),fe=ve.languages[he];ve.util.setLanguage(j,he);var O=j.parentElement;O&&O.nodeName.toLowerCase()==="pre"&&ve.util.setLanguage(O,he);var I=j.textContent,Z={element:j,language:he,grammar:fe,code:I};function xe(He){Z.highlightedCode=He,ve.hooks.run("before-insert",Z),Z.element.innerHTML=Z.highlightedCode,ve.hooks.run("after-highlight",Z),ve.hooks.run("complete",Z),ae&&ae.call(Z.element)}if(ve.hooks.run("before-sanity-check",Z),O=Z.element.parentElement,O&&O.nodeName.toLowerCase()==="pre"&&!O.hasAttribute("tabindex")&&O.setAttribute("tabindex","0"),!Z.code){ve.hooks.run("complete",Z),ae&&ae.call(Z.element);return}if(ve.hooks.run("before-highlight",Z),!Z.grammar){xe(ve.util.encode(Z.code));return}if(ee&&Y.Worker){var $e=new Worker(ve.filename);$e.onmessage=function(He){xe(He.data)},$e.postMessage(JSON.stringify({language:Z.language,code:Z.code,immediateClose:!0}))}else xe(ve.highlight(Z.code,Z.grammar,Z.language))},highlight:function(j,ee,ae){var he={code:j,grammar:ee,language:ae};if(ve.hooks.run("before-tokenize",he),!he.grammar)throw new Error('The language "'+he.language+'" has no grammar.');return he.tokens=ve.tokenize(he.code,he.grammar),ve.hooks.run("after-tokenize",he),qe.stringify(ve.util.encode(he.tokens),he.language)},tokenize:function(j,ee){var ae=ee.rest;if(ae){for(var he in ae)ee[he]=ae[he];delete ee.rest}var fe=new pt;return Xe(fe,fe.head,j),Je(j,fe,ee,fe.head,0),Mt(fe)},hooks:{all:{},add:function(j,ee){var ae=ve.hooks.all;ae[j]=ae[j]||[],ae[j].push(ee)},run:function(j,ee){var ae=ve.hooks.all[j];if(!(!ae||!ae.length))for(var he=0,fe;fe=ae[he++];)fe(ee)}},Token:qe};Y.Prism=ve;function qe(j,ee,ae,he){this.type=j,this.content=ee,this.alias=ae,this.length=(he||"").length|0}qe.stringify=function j(ee,ae){if(typeof ee=="string")return ee;if(Array.isArray(ee)){var he="";return ee.forEach(function(xe){he+=j(xe,ae)}),he}var fe={type:ee.type,content:j(ee.content,ae),tag:"span",classes:["token",ee.type],attributes:{},language:ae},O=ee.alias;O&&(Array.isArray(O)?Array.prototype.push.apply(fe.classes,O):fe.classes.push(O)),ve.hooks.run("wrap",fe);var I="";for(var Z in fe.attributes)I+=" "+Z+'="'+(fe.attributes[Z]||"").replace(/"/g,""")+'"';return"<"+fe.tag+' class="'+fe.classes.join(" ")+'"'+I+">"+fe.content+"</"+fe.tag+">"};function st(j,ee,ae,he){j.lastIndex=ee;var fe=j.exec(ae);if(fe&&he&&fe[1]){var O=fe[1].length;fe.index+=O,fe[0]=fe[0].slice(O)}return fe}function Je(j,ee,ae,he,fe,O){for(var I in ae)if(!(!ae.hasOwnProperty(I)||!ae[I])){var Z=ae[I];Z=Array.isArray(Z)?Z:[Z];for(var xe=0;xe<Z.length;++xe){if(O&&O.cause==I+","+xe)return;var $e=Z[xe],He=$e.inside,bt=!!$e.lookbehind,kt=!!$e.greedy,Nt=$e.alias;if(kt&&!$e.pattern.global){var q=$e.pattern.toString().match(/[imsuy]*$/)[0];$e.pattern=RegExp($e.pattern.source,q+"g")}for(var se=$e.pattern||$e,ne=he.next,ke=fe;ne!==ee.tail&&!(O&&ke>=O.reach);ke+=ne.value.length,ne=ne.next){var Ie=ne.value;if(ee.length>j.length)return;if(!(Ie instanceof qe)){var et=1,We;if(kt){if(We=st(se,ke,j,bt),!We||We.index>=j.length)break;var Wt=We.index,lt=We.index+We[0].length,wt=ke;for(wt+=ne.value.length;Wt>=wt;)ne=ne.next,wt+=ne.value.length;if(wt-=ne.value.length,ke=wt,ne.value instanceof qe)continue;for(var ut=ne;ut!==ee.tail&&(wt<lt||typeof ut.value=="string");ut=ut.next)et++,wt+=ut.value.length;et--,Ie=j.slice(ke,wt),We.index-=ke}else if(We=st(se,0,Ie,bt),!We)continue;var Wt=We.index,Jt=We[0],Dn=Ie.slice(0,Wt),Zn=Ie.slice(Wt+Jt.length),on=ke+Ie.length;O&&on>O.reach&&(O.reach=on);var On=ne.prev;Dn&&(On=Xe(ee,On,Dn),ke+=Dn.length),Lt(ee,On,et);var ei=new qe(I,He?ve.tokenize(Jt,He):Jt,Nt,Jt);if(ne=Xe(ee,On,ei),Zn&&Xe(ee,ne,Zn),et>1){var Ln={cause:I+","+xe,reach:on};Je(j,ee,ae,ne.prev,ke,Ln),O&&Ln.reach>O.reach&&(O.reach=Ln.reach)}}}}}}function pt(){var j={value:null,prev:null,next:null},ee={value:null,prev:j,next:null};j.next=ee,this.head=j,this.tail=ee,this.length=0}function Xe(j,ee,ae){var he=ee.next,fe={value:ae,prev:ee,next:he};return ee.next=fe,he.prev=fe,j.length++,fe}function Lt(j,ee,ae){for(var he=ee.next,fe=0;fe<ae&&he!==j.tail;fe++)he=he.next;ee.next=he,he.prev=ee,j.length-=fe}function Mt(j){for(var ee=[],ae=j.head.next;ae!==j.tail;)ee.push(ae.value),ae=ae.next;return ee}if(!Y.document)return Y.addEventListener&&(ve.disableWorkerMessageHandler||Y.addEventListener("message",function(j){var ee=JSON.parse(j.data),ae=ee.language,he=ee.code,fe=ee.immediateClose;Y.postMessage(ve.highlight(he,ve.languages[ae],ae)),fe&&Y.close()},!1)),ve;var oe=ve.util.currentScript();oe&&(ve.filename=oe.src,oe.hasAttribute("data-manual")&&(ve.manual=!0));function be(){ve.manual||ve.highlightAll()}if(!ve.manual){var de=document.readyState;de==="loading"||de==="interactive"&&oe&&oe.defer?document.addEventListener("DOMContentLoaded",be):window.requestAnimationFrame?window.requestAnimationFrame(be):window.setTimeout(be,16)}return ve}(le);return _.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},function(Y){function ye(we,Le){return"___"+we.toUpperCase()+Le+"___"}Object.defineProperties(Y.languages["markup-templating"]={},{buildPlaceholders:{value:function(we,Le,ve,qe){if(we.language===Le){var st=we.tokenStack=[];we.code=we.code.replace(ve,function(Je){if(typeof qe=="function"&&!qe(Je))return Je;for(var pt=st.length,Xe;we.code.indexOf(Xe=ye(Le,pt))!==-1;)++pt;return st[pt]=Je,Xe}),we.grammar=Y.languages.markup}}},tokenizePlaceholders:{value:function(we,Le){if(we.language!==Le||!we.tokenStack)return;we.grammar=Y.languages[Le];var ve=0,qe=Object.keys(we.tokenStack);function st(Je){for(var pt=0;pt<Je.length&&!(ve>=qe.length);pt++){var Xe=Je[pt];if(typeof Xe=="string"||Xe.content&&typeof Xe.content=="string"){var Lt=qe[ve],Mt=we.tokenStack[Lt],oe=typeof Xe=="string"?Xe:Xe.content,be=ye(Le,Lt),de=oe.indexOf(be);if(de>-1){++ve;var j=oe.substring(0,de),ee=new Y.Token(Le,Y.tokenize(Mt,we.grammar),"language-"+Le,Mt),ae=oe.substring(de+be.length),he=[];j&&he.push.apply(he,st([j])),he.push(ee),ae&&he.push.apply(he,st([ae])),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)}}})}(_),_.languages.c=_.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|[?:~]|[-+*/%&|^!=<>]=?/}),_.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),_.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},_.languages.c.string],char:_.languages.c.char,comment:_.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:_.languages.c}}}}),_.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 _.languages.c.boolean,function(Y){var ye=/\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(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g,function(){return ye.source});Y.languages.cpp=Y.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g,function(){return ye.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:ye,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/}),Y.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/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}}),Y.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:Y.languages.cpp}}}}),Y.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),Y.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:Y.languages.extend("cpp",{})}}),Y.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},Y.languages.cpp["base-clause"])}(_),function(Y){function ye(We,lt){return We.replace(/<<(\d+)>>/g,function(wt,ut){return"(?:"+lt[+ut]+")"})}function we(We,lt,wt){return RegExp(ye(We,lt),"")}function Le(We,lt){for(var wt=0;wt<lt;wt++)We=We.replace(/<<self>>/g,function(){return"(?:"+We+")"});return We.replace(/<<self>>/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 qe(We){return"\\b(?:"+We.trim().replace(/ /g,"|")+")\\b"}var st=qe(ve.typeDeclaration),Je=RegExp(qe(ve.type+" "+ve.typeDeclaration+" "+ve.contextual+" "+ve.other)),pt=qe(ve.typeDeclaration+" "+ve.contextual+" "+ve.other),Xe=qe(ve.type+" "+ve.typeDeclaration+" "+ve.other),Lt=Le(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source,2),Mt=Le(/\((?:[^()]|<<self>>)*\)/.source,2),oe=/@?\b[A-Za-z_]\w*\b/.source,be=ye(/<<0>>(?:\s*<<1>>)?/.source,[oe,Lt]),de=ye(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source,[pt,be]),j=/\[\s*(?:,\s*)*\]/.source,ee=ye(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source,[de,j]),ae=ye(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source,[Lt,Mt,j]),he=ye(/\(<<0>>+(?:,<<0>>+)+\)/.source,[ae]),fe=ye(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source,[he,de,j]),O={keyword:Je,punctuation:/[<>()?,.:[\]]/},I=/'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source,Z=/"(?:\\.|[^\\"\r\n])*"/.source,xe=/@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;Y.languages.csharp=Y.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:O},{pattern:we(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source,[oe,fe]),lookbehind:!0,inside:O},{pattern:we(/(\busing\s+)<<0>>(?=\s*=)/.source,[oe]),lookbehind:!0},{pattern:we(/(\b<<0>>\s+)<<1>>/.source,[st,be]),lookbehind:!0,inside:O},{pattern:we(/(\bcatch\s*\(\s*)<<0>>/.source,[de]),lookbehind:!0,inside:O},{pattern:we(/(\bwhere\s+)<<0>>/.source,[oe]),lookbehind:!0},{pattern:we(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source,[ee]),lookbehind:!0,inside:O},{pattern:we(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source,[fe,Xe,oe]),inside:O}],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:/\?\.?|::|[{}[\];(),.:]/}),Y.languages.insertBefore("csharp","number",{range:{pattern:/\.\./,alias:"operator"}}),Y.languages.insertBefore("csharp","punctuation",{"named-parameter":{pattern:we(/([(,]\s*)<<0>>(?=\s*:)/.source,[oe]),lookbehind:!0,alias:"punctuation"}}),Y.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:O},"return-type":{pattern:we(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source,[fe,de]),inside:O,alias:"class-name"},"constructor-invocation":{pattern:we(/(\bnew\s+)<<0>>(?=\s*[[({])/.source,[fe]),lookbehind:!0,inside:O,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:O}}},"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,be,oe,fe,Je.source,Mt,/\bnew\s*\(\s*\)/.source]),lookbehind:!0,inside:{"record-arguments":{pattern:we(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source,[be,Mt]),lookbehind:!0,greedy:!0,inside:Y.languages.csharp},keyword:Je,"class-name":{pattern:RegExp(fe),greedy:!0,inside:O},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=ye(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source,[$e]),bt=Le(ye(/[^"'/()]|<<0>>|\(<<self>>*\)/.source,[He]),2),kt=/\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source,Nt=ye(/<<0>>(?:\s*\(<<1>>*\))?/.source,[de,bt]);Y.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:Y.languages.csharp},"class-name":{pattern:RegExp(de),inside:{punctuation:/\./}},punctuation:/[:,]/}}});var q=/:[^}\r\n]+/.source,se=Le(ye(/[^"'/()]|<<0>>|\(<<self>>*\)/.source,[He]),2),ne=ye(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[se,q]),ke=Le(ye(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source,[$e]),2),Ie=ye(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[ke,q]);function et(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:Y.languages.csharp}}},string:/[\s\S]+/}}Y.languages.insertBefore("csharp","string",{"interpolation-string":[{pattern:we(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source,[ne]),lookbehind:!0,greedy:!0,inside:et(ne,se)},{pattern:we(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source,[Ie]),lookbehind:!0,greedy:!0,inside:et(Ie,ke)}],char:{pattern:RegExp(I),greedy:!0}}),Y.languages.dotnet=Y.languages.cs=Y.languages.csharp}(_),function(Y){var ye=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;Y.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+ye.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\\((?:"+ye.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+ye.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+ye.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:ye,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:/[(){};:,]/},Y.languages.css.atrule.inside.rest=Y.languages.css;var we=Y.languages.markup;we&&(we.tag.addInlined("style","css"),we.tag.addAttribute("style","css"))}(_),function(Y){var ye=/\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,Le={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:/\./}};Y.languages.java=Y.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[Le,{pattern:RegExp(/(^|[^\w.])/.source+we+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:Le.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+we+/[A-Z]\w*\b/.source),lookbehind:!0,inside:Le.inside}],keyword:ye,function:[Y.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/}),Y.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),Y.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":Le,keyword:ye,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+we+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:Le.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+we+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:Le.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+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,function(){return ye.source})),lookbehind:!0,inside:{punctuation:/\./}}})}(_),_.languages.javascript=_.languages.extend("clike",{"class-name":[_.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}|\?\?=?|\?\.?|[~:]/}),_.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,_.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:_.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:_.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:_.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:_.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:_.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),_.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:_.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"}}),_.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),_.languages.markup&&(_.languages.markup.tag.addInlined("script","javascript"),_.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")),_.languages.js=_.languages.javascript,_.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\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:/<!\[CDATA\[[\s\S]*?\]\]>/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]},_.languages.markup.tag.inside["attr-value"].inside.entity=_.languages.markup.entity,_.languages.markup.doctype.inside["internal-subset"].inside=_.languages.markup,_.hooks.add("wrap",function(Y){Y.type==="entity"&&(Y.attributes.title=Y.content.replace(/&/,"&"))}),Object.defineProperty(_.languages.markup.tag,"addInlined",{value:function(ye,we){var Le={};Le["language-"+we]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:_.languages[we]},Le.cdata=/^<!\[CDATA\[|\]\]>$/i;var ve={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:Le}};ve["language-"+we]={pattern:/[\s\S]+/,inside:_.languages[we]};var qe={};qe[ye]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return ye}),"i"),lookbehind:!0,greedy:!0,inside:ve},_.languages.insertBefore("markup","cdata",qe)}}),Object.defineProperty(_.languages.markup.tag,"addAttribute",{value:function(Y,ye){_.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+Y+")"+/\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:[ye,"language-"+ye],inside:_.languages[ye]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),_.languages.html=_.languages.markup,_.languages.mathml=_.languages.markup,_.languages.svg=_.languages.markup,_.languages.xml=_.languages.extend("markup",{}),_.languages.ssml=_.languages.xml,_.languages.atom=_.languages.xml,_.languages.rss=_.languages.xml,function(Y){var ye=/\/\*[\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*\()/],Le=/\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}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,qe=/[{}\[\](),:;]/;Y.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:ye,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:Le,operator:ve,punctuation:qe};var st={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:Y.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}}];Y.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:ye,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:Le,operator:ve,punctuation:qe}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),Y.hooks.add("before-tokenize",function(pt){if(/<\?/.test(pt.code)){var Xe=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;Y.languages["markup-templating"].buildPlaceholders(pt,"php",Xe)}}),Y.hooks.add("after-tokenize",function(pt){Y.languages["markup-templating"].tokenizePlaceholders(pt,"php")})}(_),_.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://,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:/[{}[\];(),.:]/},_.languages.python["string-interpolation"].inside.interpolation.inside.rest=_.languages.python,_.languages.py=_.languages.python,function(Y){Y.languages.ruby=Y.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:/[(){}[\].,;]/}),Y.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var ye={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:Y.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete Y.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("|")+")",Le=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;Y.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+we+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:ye,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:ye,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+Le),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+Le+/(?=:(?!:))/.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:/\./}}}),Y.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+we),greedy:!0,inside:{interpolation:ye,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:ye,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:ye,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:ye,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:ye,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete Y.languages.ruby.string,Y.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)/}),Y.languages.rb=Y.languages.ruby}(_),window.Prism=ie,_}(),h=N=>Q=>Q.options.get(N),f=N=>{const Q=N.options.register;Q("codesample_languages",{processor:"object[]"}),Q("codesample_global_prismjs",{processor:"boolean",default:!1})},d=h("codesample_languages"),p=h("codesample_global_prismjs"),y=N=>c.Prism&&p(N)?c.Prism:u,b=N=>t(N)&&N.nodeName==="PRE"&&N.className.indexOf("language-")!==-1,m=N=>{const Q=N.selection?N.selection.getNode():null;return b(Q)?r.some(Q):r.none()},A=(N,Q,$)=>{const ie=N.dom;N.undoManager.transact(()=>{const le=m(N);return $=a.DOM.encode($),le.fold(()=>{N.insertContent('<pre id="__new" class="language-'+Q+'">'+$+"</pre>");const _=ie.select("#__new")[0];ie.setAttrib(_,"id",null),N.selection.select(_)},_=>{ie.setAttrib(_,"class","language-"+Q),_.innerHTML=$,y(N).highlightElement(_),N.selection.select(_)})})},v=N=>m(N).bind($=>r.from($.textContent)).getOr(""),F=N=>{const Q=[{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(N);return $||Q},D=(N,Q)=>m(N).fold(()=>Q,ie=>{const le=ie.className.match(/language-(\w+)/);return le?le[1]:Q}),E=N=>{const Q=F(N),$=l(Q).fold(s(""),_=>_.value),ie=D(N,$),le=v(N);N.windowManager.open({title:"Insert/Edit Code Sample",size:"large",body:{type:"panel",items:[{type:"listbox",name:"language",label:"Language",items:Q},{type:"textarea",name:"code",label:"Code view"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{language:ie,code:le},onSubmit:_=>{const Y=_.getData();A(N,Y.language,Y.code),_.close()}})},P=N=>{N.addCommand("codesample",()=>{const Q=N.selection.getNode();N.selection.isCollapsed()||b(Q)?E(N):N.formatter.toggle("code")})},M=(N=>Q=>Q.replace(N,""))(/^\s+|\s+$/g);var V=tinymce.util.Tools.resolve("tinymce.util.Tools");const H=N=>{N.on("PreProcess",Q=>{const $=N.dom,ie=$.select("pre[contenteditable=false]",Q.node);V.each(V.grep(ie,b),le=>{const _=le.textContent;$.setAttrib(le,"class",M($.getAttrib(le,"class"))),$.setAttrib(le,"contentEditable",null),$.setAttrib(le,"data-mce-highlighted",null);let Y;for(;Y=le.firstChild;)le.removeChild(Y);const ye=$.add(le,"code");ye.textContent=_})}),N.on("SetContent",()=>{const Q=N.dom,$=V.grep(Q.select("pre"),ie=>b(ie)&&Q.getAttrib(ie,"data-mce-highlighted")!=="true");$.length&&N.undoManager.transact(()=>{V.each($,ie=>{var le;V.each(Q.select("br",ie),_=>{Q.replace(N.getDoc().createTextNode(`
- `),_)}),ie.innerHTML=Q.encode((le=ie.textContent)!==null&&le!==void 0?le:""),y(N).highlightElement(ie),Q.setAttrib(ie,"data-mce-highlighted",!0),ie.className=M(ie.className)})})}),N.on("PreInit",()=>{N.parser.addNodeFilter("pre",Q=>{var $;for(let ie=0,le=Q.length;ie<le;ie++){const _=Q[ie];(($=_.attr("class"))!==null&&$!==void 0?$:"").indexOf("language-")!==-1&&(_.attr("contenteditable","false"),_.attr("data-mce-highlighted","false"))}})})},te=(N,Q=n)=>$=>{const ie=()=>{$.setEnabled(N.selection.isEditable()),Q($)};return N.on("NodeChange",ie),ie(),()=>{N.off("NodeChange",ie)}},ue=N=>{const Q=N.selection.getStart();return N.dom.is(Q,'pre[class*="language-"]')},L=N=>{const Q=()=>N.execCommand("codesample");N.ui.registry.addToggleButton("codesample",{icon:"code-sample",tooltip:"Insert/edit code sample",onAction:Q,onSetup:te(N,$=>{$.setActive(ue(N))})}),N.ui.registry.addMenuItem("codesample",{text:"Code sample...",icon:"code-sample",onAction:Q,onSetup:te(N)})};var re=()=>{i.add("codesample",N=>{f(N),H(N),L(N),P(N),N.on("dblclick",Q=>{b(Q.target)&&E(N)})})};re()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(q,se,ne)=>{var ke;return ne(q,se.prototype)?!0:((ke=q.constructor)===null||ke===void 0?void 0:ke.name)===se.name},t=q=>{const se=typeof q;return q===null?"null":se==="object"&&Array.isArray(q)?"array":se==="object"&&e(q,String,(ne,ke)=>ke.isPrototypeOf(ne))?"string":se},n=q=>se=>t(se)===q,s=q=>se=>typeof se===q,r=n("string"),o=s("boolean"),l=q=>q==null,a=q=>!l(q),c=s("function"),u=s("number"),h=(q,se)=>ne=>q(se(ne)),d=(q=>()=>q)(!1);class p{constructor(se,ne){this.tag=se,this.value=ne}static some(se){return new p(!0,se)}static none(){return p.singletonNone}fold(se,ne){return this.tag?ne(this.value):se()}isSome(){return this.tag}isNone(){return!this.tag}map(se){return this.tag?p.some(se(this.value)):p.none()}bind(se){return this.tag?se(this.value):p.none()}exists(se){return this.tag&&se(this.value)}forall(se){return!this.tag||se(this.value)}filter(se){return!this.tag||se(this.value)?this:p.none()}getOr(se){return this.tag?this.value:se}or(se){return this.tag?this:se}getOrThunk(se){return this.tag?this.value:se()}orThunk(se){return this.tag?this:se()}getOrDie(se){if(this.tag)return this.value;throw new Error(se!=null?se:"Called getOrDie on None")}static from(se){return a(se)?p.some(se):p.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(se){this.tag&&se(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}p.singletonNone=new p(!1);const y=(q,se)=>{const ne=q.length,ke=new Array(ne);for(let Ie=0;Ie<ne;Ie++){const et=q[Ie];ke[Ie]=se(et,Ie)}return ke},b=(q,se)=>{for(let ne=0,ke=q.length;ne<ke;ne++){const Ie=q[ne];se(Ie,ne)}},m=(q,se)=>{const ne=[];for(let ke=0,Ie=q.length;ke<Ie;ke++){const et=q[ke];se(et,ke)&&ne.push(et)}return ne},A=9,v=11,F=1,D=3,E=(q,se)=>{const ke=(se||document).createElement("div");if(ke.innerHTML=q,!ke.hasChildNodes()||ke.childNodes.length>1){const Ie="HTML does not have a single root node";throw new Error(Ie)}return M(ke.childNodes[0])},P=(q,se)=>{const ke=(se||document).createElement(q);return M(ke)},T=(q,se)=>{const ke=(se||document).createTextNode(q);return M(ke)},M=q=>{if(q==null)throw new Error("Node cannot be null or undefined");return{dom:q}},H={fromHtml:E,fromTag:P,fromText:T,fromDom:M,fromPoint:(q,se,ne)=>p.from(q.dom.elementFromPoint(se,ne)).map(M)},te=(q,se)=>{const ne=q.dom;if(ne.nodeType!==F)return!1;{const ke=ne;if(ke.matches!==void 0)return ke.matches(se);if(ke.msMatchesSelector!==void 0)return ke.msMatchesSelector(se);if(ke.webkitMatchesSelector!==void 0)return ke.webkitMatchesSelector(se);if(ke.mozMatchesSelector!==void 0)return ke.mozMatchesSelector(se);throw new Error("Browser lacks native selectors")}};typeof window!="undefined"||Function("return this;")();const ue=q=>q.dom.nodeName.toLowerCase(),L=q=>q.dom.nodeType,re=q=>se=>L(se)===q,N=re(F),Q=re(D),$=re(A),ie=re(v),le=q=>se=>N(se)&&ue(se)===q,_=q=>H.fromDom(q.dom.ownerDocument),Y=q=>$(q)?q:_(q),ye=q=>p.from(q.dom.parentNode).map(H.fromDom),we=q=>y(q.dom.childNodes,H.fromDom),Le=(q,se,ne)=>{if(r(ne)||o(ne)||u(ne))q.setAttribute(se,ne+"");else throw new Error("Attribute value was not simple")},ve=(q,se,ne)=>{Le(q.dom,se,ne)},qe=(q,se)=>{q.dom.removeAttribute(se)},st=q=>ie(q)&&a(q.dom.host),pt=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?q=>H.fromDom(q.dom.getRootNode()):Y,Xe=q=>{const se=pt(q);return st(se)?p.some(se):p.none()},Lt=q=>H.fromDom(q.dom.host),Mt=q=>{const se=Q(q)?q.dom.parentNode:q.dom;if(se==null||se.ownerDocument===null)return!1;const ne=se.ownerDocument;return Xe(H.fromDom(se)).fold(()=>ne.body.contains(se),h(Mt,Lt))},oe=(q,se,ne)=>{let ke=q.dom;const Ie=c(ne)?ne:d;for(;ke.parentNode;){ke=ke.parentNode;const et=H.fromDom(ke);if(se(et))return p.some(et);if(Ie(et))break}return p.none()},be=(q,se,ne)=>oe(q,ke=>te(ke,se),ne),de=q=>q.style!==void 0&&c(q.style.getPropertyValue),j=(q,se)=>{const ne=q.dom,Ie=window.getComputedStyle(ne).getPropertyValue(se);return Ie===""&&!Mt(q)?ee(ne,se):Ie},ee=(q,se)=>de(q)?q.style.getPropertyValue(se):"",ae=q=>j(q,"direction")==="rtl"?"rtl":"ltr",he=(q,se)=>m(we(q),se),fe=(q,se)=>he(q,ne=>te(ne,se)),O=q=>ye(q).filter(N),I=(q,se)=>(se?be(q,"ol,ul"):p.some(q)).getOr(q),Z=le("li"),xe=(q,se,ne)=>{b(se,ke=>{const Ie=H.fromDom(ke),et=Z(Ie),We=I(Ie,et);O(We).each(wt=>{if(q.setStyle(We.dom,"direction",null),ae(wt)===ne?qe(We,"dir"):ve(We,"dir",ne),ae(We)!==ne&&q.setStyle(We.dom,"direction",ne),et){const Wt=fe(We,"li[dir],li[style]");b(Wt,Jt=>{qe(Jt,"dir"),q.setStyle(Jt.dom,"direction",null)})}})})},$e=(q,se)=>{q.selection.isEditable()&&(xe(q.dom,q.selection.getSelectedBlocks(),se),q.nodeChanged())},He=q=>{q.addCommand("mceDirectionLTR",()=>{$e(q,"ltr")}),q.addCommand("mceDirectionRTL",()=>{$e(q,"rtl")})},bt=(q,se)=>ne=>{const ke=Ie=>{const et=H.fromDom(Ie.element);ne.setActive(ae(et)===se),ne.setEnabled(q.selection.isEditable())};return q.on("NodeChange",ke),ne.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,R)=>{var K;return R(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,(R,K)=>K.isPrototypeOf(R))?"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"),A=()=>{},v=(g,w)=>(...R)=>g(w.apply(null,R)),F=(g,w)=>R=>g(w(R)),D=g=>()=>g;function E(g,...w){return(...R)=>{const K=w.concat(R);return g.apply(null,K)}}const P=D(!1),T=D(!0);class M{constructor(w,R){this.tag=w,this.value=R}static some(w){return new M(!0,w)}static none(){return M.singletonNone}fold(w,R){return this.tag?R(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 V=Array.prototype.push,H=(g,w)=>{const R=g.length,K=new Array(R);for(let Ae=0;Ae<R;Ae++){const Ge=g[Ae];K[Ae]=w(Ge,Ae)}return K},te=(g,w)=>{for(let R=0,K=g.length;R<K;R++){const Ae=g[R];w(Ae,R)}},ue=(g,w)=>{const R=[];for(let K=0,Ae=g.length;K<Ae;K++){const Ge=g[K];w(Ge,K)&&R.push(Ge)}return R},L=(g,w,R)=>{for(let K=0,Ae=g.length;K<Ae;K++){const Ge=g[K];if(w(Ge,K))return M.some(Ge);if(R(Ge,K))break}return M.none()},re=(g,w)=>L(g,w,P),N=g=>{const w=[];for(let R=0,K=g.length;R<K;++R){if(!u(g[R]))throw new Error("Arr.flatten item "+R+" was not an array, input: "+g);V.apply(w,g[R])}return w},Q=(g,w)=>N(H(g,w)),$=(g,w)=>w>=0&&w<g.length?M.some(g[w]):M.none(),ie=g=>$(g,0),le=(g,w)=>{for(let R=0;R<g.length;R++){const K=w(g[R],R);if(K.isSome())return K}return M.none()},_=(g,w,R)=>g.isSome()&&w.isSome()?M.some(R(g.getOrDie(),w.getOrDie())):M.none(),Y=g=>{const w=i(M.none()),R=()=>w.get().each(g);return{clear:()=>{R(),w.set(M.none())},isSet:()=>w.get().isSome(),get:()=>w.get(),set:hn=>{R(),w.set(M.some(hn))}}},ye=()=>Y(g=>g.unbind()),we=()=>{const g=Y(A),w=R=>g.get().each(R);return qt(Fe({},g),{on:w})},Le=(g,w)=>{let R=null;return{cancel:()=>{h(R)||(clearTimeout(R),R=null)},throttle:(...Ge)=>{h(R)&&(R=setTimeout(()=>{R=null,g.apply(null,Ge)},w))}}},ve=Object.keys,qe=(g,w)=>{const R=ve(g);for(let K=0,Ae=R.length;K<Ae;K++){const Ge=R[K],Ot=g[Ge];w(Ot,Ge)}},st=typeof window!="undefined"?window:Function("return this;")(),Je=(g,w)=>{let R=w!=null?w:st;for(let K=0;K<g.length&&R!==void 0&&R!==null;++K)R=R[g[K]];return R},pt=(g,w)=>{const R=g.split(".");return Je(R,w)},Xe=(g,w)=>pt(g,w),Lt=(g,w)=>{const R=Xe(g,w);if(R==null)throw new Error(g+" not available on this browser");return R},Mt=Object.getPrototypeOf,oe=g=>Lt("HTMLElement",g),be=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,ee=1,ae=3,he=g=>g.dom.nodeType,fe=g=>w=>he(w)===g,O=g=>I(g)&&be(g.dom),I=fe(ee),Z=fe(ae),xe=fe(de),$e=fe(j),He=(g,w,R)=>{if(a(R)||f(R)||m(R))g.setAttribute(w,R+"");else throw new Error("Attribute value was not simple")},bt=(g,w,R)=>{He(g.dom,w,R)},kt=(g,w)=>{const R=g.dom.getAttribute(w);return R===null?void 0:R},Nt=(g,w)=>{g.dom.removeAttribute(w)},q=g=>g.dom.classList!==void 0,se=(g,w)=>q(g)&&g.dom.classList.contains(w),ne=(g,w,R=0,K)=>{const Ae=g.indexOf(w,R);return Ae!==-1?d(K)?!0:Ae+w.length<=K:!1},ke=g=>g.style!==void 0&&b(g.style.getPropertyValue),Ie=(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])},et=(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:Ie,fromTag:et,fromText:We,fromDom:lt,fromPoint:(g,w,R)=>M.from(g.dom.elementFromPoint(w,R)).map(lt)},Wt=(g,w)=>{const R=g.dom;if(R.nodeType!==ee)return!1;{const K=R;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")}},Jt=g=>g.nodeType!==ee&&g.nodeType!==de&&g.nodeType!==j||g.childElementCount===0,Dn=(g,w)=>{const R=document;return Jt(R)?[]:H(R.querySelectorAll(g),ut.fromDom)},Zn=(g,w)=>g.dom===w.dom,on=g=>ut.fromDom(g.dom.ownerDocument),On=g=>xe(g)?g:on(g),ei=g=>M.from(g.dom.parentNode).map(ut.fromDom),Ln=(g,w)=>{const R=b(w)?w:P;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),R(Ot)===!0)break;K=Ge}return Ae},Un=g=>{const w=R=>ue(R,K=>!Zn(g,K));return ei(g).map(Ti).map(w).getOr([])},Ai=g=>M.from(g.dom.nextSibling).map(ut.fromDom),Ti=g=>H(g.dom.childNodes,ut.fromDom),ti=g=>$e(g)&&y(g.dom.host),B=b(Element.prototype.attachShadow)&&b(Node.prototype.getRootNode),z=D(B),me=B?g=>ut.fromDom(g.dom.getRootNode()):On,Oe=g=>{const w=me(g);return ti(w)?M.some(w):M.none()},Qe=g=>ut.fromDom(g.dom.host),$t=g=>{if(z()&&y(g.target)){const w=ut.fromDom(g.target);if(I(w)&&En(w)&&g.composed&&g.composedPath){const R=g.composedPath();if(R)return ie(R)}}return M.from(g.target)},En=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 R=w.ownerDocument;return Oe(ut.fromDom(w)).fold(()=>R.body.contains(w),F(jt,Qe))},ni=g=>{const w=g.dom.body;if(w==null)throw new Error("Body is not available yet");return ut.fromDom(w)},x=(g,w,R)=>{if(!a(R))throw new Error("CSS value must be a string: "+R);ke(g)&&g.style.setProperty(w,R)},S=(g,w,R)=>{const K=g.dom;x(K,w,R)},W=(g,w)=>{const R=g.dom;qe(w,(K,Ae)=>{x(R,Ae,K)})},U=(g,w)=>{const R=g.dom,Ae=window.getComputedStyle(R).getPropertyValue(w);return Ae===""&&!jt(g)?Me(R,w):Ae},Me=(g,w)=>ke(g)?g.style.getPropertyValue(w):"",Be=(g,w,R,K,Ae,Ge,Ot)=>({target:g,x:w,y:R,stop:K,prevent:Ae,kill:Ge,raw:Ot}),je=g=>{const w=ut.fromDom($t(g).getOr(g.target)),R=()=>g.stopPropagation(),K=()=>g.preventDefault(),Ae=v(K,R);return Be(w,g.clientX,g.clientY,R,K,Ae,g)},xt=(g,w)=>R=>{g(R)&&w(je(R))},Ze=(g,w,R,K,Ae)=>{const Ge=xt(R,K);return g.dom.addEventListener(w,Ge,Ae),{unbind:E(k,g,w,Ge,Ae)}},Ue=(g,w,R,K)=>Ze(g,w,R,K,!1),k=(g,w,R,K)=>{g.dom.removeEventListener(w,R,K)},C=T,J=(g,w,R)=>Ue(g,w,C,R),pe=g=>{let w=!1,R;return(...K)=>(w||(w=!0,R=g.apply(null,K)),R)},ge=(g,w,R,K)=>{const Ae=g.isiOS()&&/ipad/i.test(R)===!0,Ge=g.isiOS()&&!Ae,Ot=g.isiOS()||g.isAndroid(),hn=Ot||K("(pointer:coarse)"),Yt=Ae||!Ge&&Ot&&K("(min-device-width:768px)"),Fn=Ge||Ot&&!Yt,gi=w.isSafari()&&g.isiOS()&&/safari/i.test(R)===!1,fn=!Fn&&!Yt&&!gi;return{isiPad:D(Ae),isiPhone:D(Ge),isTablet:D(Yt),isPhone:D(Fn),isTouch:D(hn),isAndroid:g.isAndroid,isiOS:g.isiOS,isWebView:D(gi),isDesktop:D(fn)}},Ce=(g,w)=>{for(let R=0;R<g.length;R++){const K=g[R];if(K.test(w))return K}},De=(g,w)=>{const R=Ce(g,w);if(!R)return{major:0,minor:0};const K=Ae=>Number(w.replace(R,"$"+Ae));return Ke(K(1),K(2))},Se=(g,w)=>{const R=String(w).toLowerCase();return g.length===0?Ve():De(g,R)},Ve=()=>Ke(0,0),Ke=(g,w)=>({major:g,minor:w}),at={nu:Ke,detect:Se,unknown:Ve},_t=(g,w)=>le(w.brands,R=>{const K=R.brand.toLowerCase();return re(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(R.version,10),0)}))}),Mi=(g,w)=>{const R=String(w).toLowerCase();return re(g,K=>K.search(R))},Qi=(g,w)=>Mi(g,w).map(R=>{const K=at.detect(R.versionRegexes,w);return{current:R.name,version:K}}),Kr=(g,w)=>Mi(g,w).map(R=>{const K=at.detect(R.versionRegexes,w);return{current:R.name,version:K}}),St=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ct=g=>w=>ne(w,g),Dt=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:g=>ne(g,"edge/")&&ne(g,"chrome")&&ne(g,"safari")&&ne(g,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,St],search:g=>ne(g,"chrome")&&!ne(g,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:g=>ne(g,"msie")||ne(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=>(ne(g,"safari")||ne(g,"mobile/"))&&ne(g,"applewebkit")}],ii=[{name:"Windows",search:ct("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:g=>ne(g,"iphone")||ne(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]+).*/]}],Zi={browsers:D(Dt),oses:D(ii)},Ec="Edge",Fc="Chromium",Pc="IE",Bc="Opera",Rc="Firefox",Nc="Safari",Lm=()=>Ic({current:void 0,version:at.unknown()}),Ic=g=>{const w=g.current,R=g.version,K=Ae=>()=>w===Ae;return{current:w,version:R,isEdge:K(Ec),isChromium:K(Fc),isIE:K(Pc),isOpera:K(Bc),isFirefox:K(Rc),isSafari:K(Nc)}},Lc={unknown:Lm,nu:Ic,edge:D(Ec),chromium:D(Fc),ie:D(Pc),opera:D(Bc),firefox:D(Rc),safari:D(Nc)},$c="Windows",_c="iOS",zc="Android",Vc="Linux",Hc="macOS",Wc="Solaris",jc="FreeBSD",qc="ChromeOS",$m=()=>Uc({current:void 0,version:at.unknown()}),Uc=g=>{const w=g.current,R=g.version,K=Ae=>()=>w===Ae;return{current:w,version:R,isWindows:K($c),isiOS:K(_c),isAndroid:K(zc),isMacOS:K(Hc),isLinux:K(Vc),isSolaris:K(Wc),isFreeBSD:K(jc),isChromeOS:K(qc)}},Kc={unknown:$m,nu:Uc,windows:D($c),ios:D(_c),android:D(zc),linux:D(Vc),macos:D(Hc),solaris:D(Wc),freebsd:D(jc),chromeos:D(qc)},_m={detect:(g,w,R)=>{const K=Zi.browsers(),Ae=Zi.oses(),Ge=w.bind(Yt=>_t(K,Yt)).orThunk(()=>Qi(K,g)).fold(Lc.unknown,Lc.nu),Ot=Kr(Ae,g).fold(Kc.unknown,Kc.nu),hn=ge(Ot,Ge,g,R);return{browser:Ge,os:Ot,deviceType:hn}}},zm=g=>window.matchMedia(g).matches;let Vm=pe(()=>_m.detect(navigator.userAgent,M.from(navigator.userAgentData),zm));const Hm=()=>Vm(),Gc=(g,w)=>({left:g,top:w,translate:(K,Ae)=>Gc(g+K,w+Ae)}),Wm=Gc,jm=g=>{const w=g!==void 0?g.dom:document,R=w.body.scrollLeft||w.documentElement.scrollLeft,K=w.body.scrollTop||w.documentElement.scrollTop;return Wm(R,K)},Sl=g=>{const w=g===void 0?window:g;return Hm().browser.isFirefox()?M.none():M.from(w.visualViewport)},Yc=(g,w,R,K)=>({x:g,y:w,width:R,height:K,right:g+R,bottom:w+K}),qm=g=>{const w=g===void 0?window:g,R=w.document,K=jm(ut.fromDom(R));return Sl(w).fold(()=>{const Ae=w.document.documentElement,Ge=Ae.clientWidth,Ot=Ae.clientHeight;return Yc(K.left,K.top,Ge,Ot)},Ae=>Yc(Math.max(Ae.pageLeft,K.left),Math.max(Ae.pageTop,K.top),Ae.width,Ae.height))},Xc=(g,w,R)=>Sl(R).map(K=>{const Ae=Ge=>w(je(Ge));return K.addEventListener(g,Ae),{unbind:()=>K.removeEventListener(g,Ae)}}).getOrThunk(()=>({unbind:A}));var Um=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),Jc=tinymce.util.Tools.resolve("tinymce.Env");const Qc=(g,w)=>{g.dispatch("FullscreenStateChanged",{state:w}),g.dispatch("ResizeEditor")},Km=g=>w=>w.options.get(g),Gm=g=>{const w=g.options.register;w("fullscreen_native",{processor:"boolean",default:!1})},Cl=Km("fullscreen_native"),Ym=g=>{const w=ut.fromDom(g.getElement());return Oe(w).map(Qe).getOrThunk(()=>ni(on(w)))},Xm=g=>g.fullscreenElement!==void 0?g.fullscreenElement:g.msFullscreenElement!==void 0?g.msFullscreenElement:g.webkitFullscreenElement!==void 0?g.webkitFullscreenElement:null,Jm=()=>document.fullscreenElement!==void 0?"fullscreenchange":document.msFullscreenElement!==void 0?"MSFullscreenChange":document.webkitFullscreenElement!==void 0?"webkitfullscreenchange":"fullscreenchange",Qm=g=>{const w=g.dom;w.requestFullscreen?w.requestFullscreen():w.msRequestFullscreen?w.msRequestFullscreen():w.webkitRequestFullScreen&&w.webkitRequestFullScreen()},Zm=g=>{const w=g.dom;w.exitFullscreen?w.exitFullscreen():w.msExitFullscreen?w.msExitFullscreen():w.webkitCancelFullScreen&&w.webkitCancelFullScreen()},Zc=g=>g.dom===Xm(on(g).dom),eg=(g,w,R)=>ue(Ln(g,R),w),tg=(g,w)=>ue(Un(g),w),ng=g=>Dn(g),ig=(g,w,R)=>eg(g,K=>Wt(K,w),R),sg=(g,w)=>tg(g,R=>Wt(R,w)),Gr="data-ephox-mobile-fullscreen-style",rg="display:none!important;",eu="position:absolute!important;",tu="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",og="background-color:rgb(255,255,255)!important;",lg=Jc.os.isAndroid(),ag=g=>{const w=U(g,"background-color");return w!==void 0&&w!==""?"background-color:"+w+"!important":og},cg=(g,w,R)=>{const K=Fn=>sg(Fn,"*:not(.tox-silver-sink)"),Ae=Fn=>gi=>{const fn=kt(gi,"style"),ks=fn===void 0?"no-styles":fn.trim();ks!==Fn&&(bt(gi,Gr,ks),W(gi,g.parseStyle(Fn)))},Ge=ig(w,"*"),Ot=Q(Ge,K),hn=ag(R);te(Ot,Ae(rg)),te(Ge,Ae(eu+tu+hn)),Ae((lg===!0?"":eu)+tu+hn)(w)},ug=g=>{const w=ng("["+Gr+"]");te(w,R=>{const K=kt(R,Gr);K&&K!=="no-styles"?W(R,g.parseStyle(K)):Nt(R,"style"),Nt(R,Gr)})},nu=Um.DOM,hg=()=>qm(window),fg=g=>window.scrollTo(g.x,g.y),iu=Sl().fold(()=>({bind:A,unbind:A}),g=>{const w=we(),R=ye(),K=ye(),Ae=()=>{document.body.scrollTop=0,document.documentElement.scrollTop=0},Ge=()=>{window.requestAnimationFrame(()=>{w.on(Fn=>W(Fn,{top:g.offsetTop+"px",left:g.offsetLeft+"px",height:g.height+"px",width:g.width+"px"}))})},Ot=Le(()=>{Ae(),Ge()},50);return{bind:Fn=>{w.set(Fn),Ot.throttle(),R.set(Xc("resize",Ot.throttle)),K.set(Xc("scroll",Ot.throttle))},unbind:()=>{w.on(()=>{R.clear(),K.clear()}),w.clear()}}}),su=(g,w)=>{const R=document.body,K=document.documentElement,Ae=g.getContainer(),Ge=ut.fromDom(Ae),Ot=Ai(Ge).filter(vn=>O(vn)&&se(vn,"tox-silver-sink")),hn=Ym(g),Yt=w.get(),Fn=ut.fromDom(g.getBody()),gi=Jc.deviceType.isTouch(),fn=Ae.style,ks=g.iframeElement,xs=ks==null?void 0:ks.style,ou=vn=>{vn(R,"tox-fullscreen"),vn(K,"tox-fullscreen"),vn(Ae,"tox-fullscreen"),Oe(Ge).map(Di=>Qe(Di).dom).each(Di=>{vn(Di,"tox-fullscreen"),vn(Di,"tox-shadowhost")})},Al=()=>{gi&&ug(g.dom),ou(nu.removeClass),iu.unbind(),M.from(w.get()).each(vn=>vn.fullscreenChangeHandler.unbind())};if(Yt)Yt.fullscreenChangeHandler.unbind(),Cl(g)&&Zc(hn)&&Zm(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,_(Ot,Yt.sinkCssPosition,(vn,Di)=>{S(vn,"position",Di)}),Al(),fg(Yt.scrollPos),w.set(null),Qc(g,!1),g.off("remove",Al);else{const vn=J(on(hn),Jm(),Yr=>{Cl(g)&&!Zc(hn)&&w.get()!==null&&su(g,w)}),Di={scrollPos:hg(),containerWidth:fn.width,containerHeight:fn.height,containerTop:fn.top,containerLeft:fn.left,iframeWidth:xs.width,iframeHeight:xs.height,fullscreenChangeHandler:vn,sinkCssPosition:Ot.map(Yr=>U(Yr,"position"))};gi&&cg(g.dom,Ge,Fn),xs.width=xs.height="100%",fn.width=fn.height="",ou(nu.addClass),Ot.each(Yr=>{S(Yr,"position","fixed")}),iu.bind(Ge),g.on("remove",Al),w.set(Di),Cl(g)&&Qm(hn),Qc(g,!0)}},dg=(g,w)=>{g.addCommand("mceFullScreen",()=>{su(g,w)})},ru=(g,w)=>R=>{R.setActive(w.get()!==null);const K=Ae=>R.setActive(Ae.state);return g.on("FullscreenStateChanged",K),()=>g.off("FullscreenStateChanged",K)},pg=(g,w)=>{const R=()=>g.execCommand("mceFullScreen");g.ui.registry.addToggleMenuItem("fullscreen",{text:"Fullscreen",icon:"fullscreen",shortcut:"Meta+Shift+F",onAction:R,onSetup:ru(g,w)}),g.ui.registry.addToggleButton("fullscreen",{tooltip:"Fullscreen",icon:"fullscreen",onAction:R,onSetup:ru(g,w)})};var mg=()=>{e.add("fullscreen",g=>{const w=i(null);return g.inline||(Gm(g),dg(g,w),pg(g,w),g.addShortcut("Meta+Shift+F","","mceFullScreen")),t(w)})};mg()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=E=>P=>P.options.get(E),t=E=>{const P=E.options.register;P("insertdatetime_dateformat",{processor:"string",default:E.translate("%Y-%m-%d")}),P("insertdatetime_timeformat",{processor:"string",default:E.translate("%H:%M:%S")}),P("insertdatetime_formats",{processor:"string[]",default:["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"]}),P("insertdatetime_element",{processor:"boolean",default:!1})},n=e("insertdatetime_dateformat"),s=e("insertdatetime_timeformat"),r=e("insertdatetime_formats"),o=e("insertdatetime_element"),l=E=>{const P=r(E);return P.length>0?P[0]:s(E)},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=(E,P)=>{if(E=""+E,E.length<P)for(let T=0;T<P-E.length;T++)E="0"+E;return E},d=(E,P,T=new Date)=>(P=P.replace("%D","%m/%d/%Y"),P=P.replace("%r","%I:%M:%S %p"),P=P.replace("%Y",""+T.getFullYear()),P=P.replace("%y",""+T.getYear()),P=P.replace("%m",f(T.getMonth()+1,2)),P=P.replace("%d",f(T.getDate(),2)),P=P.replace("%H",""+f(T.getHours(),2)),P=P.replace("%M",""+f(T.getMinutes(),2)),P=P.replace("%S",""+f(T.getSeconds(),2)),P=P.replace("%I",""+((T.getHours()+11)%12+1)),P=P.replace("%p",T.getHours()<12?"AM":"PM"),P=P.replace("%B",""+E.translate(h[T.getMonth()])),P=P.replace("%b",""+E.translate(u[T.getMonth()])),P=P.replace("%A",""+E.translate(c[T.getDay()])),P=P.replace("%a",""+E.translate(a[T.getDay()])),P=P.replace("%%","%"),P),p=(E,P,T,M)=>{const V=E.dom.create("time",{datetime:T},M);E.dom.replace(V,P),E.selection.select(V,!0),E.selection.collapse(!1)},y=(E,P)=>{if(o(E)){const T=d(E,P);let M;/%[HMSIp]/.test(P)?M=d(E,"%Y-%m-%dT%H:%M"):M=d(E,"%Y-%m-%d");const V=E.dom.getParent(E.selection.getStart(),"time");V?p(E,V,M,T):E.insertContent('<time datetime="'+M+'">'+T+"</time>")}else E.insertContent(d(E,P))},b=E=>{E.addCommand("mceInsertDate",(P,T)=>{y(E,T!=null?T:n(E))}),E.addCommand("mceInsertTime",(P,T)=>{y(E,T!=null?T:s(E))})},m=E=>{let P=E;return{get:()=>P,set:V=>{P=V}}};var A=tinymce.util.Tools.resolve("tinymce.util.Tools");const v=E=>P=>{const T=()=>{P.setEnabled(E.selection.isEditable())};return E.on("NodeChange",T),T(),()=>{E.off("NodeChange",T)}},F=E=>{const P=r(E),T=m(l(E)),M=H=>E.execCommand("mceInsertDate",!1,H);E.ui.registry.addSplitButton("insertdatetime",{icon:"insert-time",tooltip:"Insert date/time",select:H=>H===T.get(),fetch:H=>{H(A.map(P,te=>({type:"choiceitem",text:d(E,te),value:te})))},onAction:H=>{M(T.get())},onItemAction:(H,te)=>{T.set(te),M(te)},onSetup:v(E)});const V=H=>()=>{T.set(H),M(H)};E.ui.registry.addNestedMenuItem("insertdatetime",{icon:"insert-time",text:"Date/time",getSubmenuItems:()=>A.map(P,H=>({type:"menuitem",text:d(E,H),onAction:V(H)})),onSetup:v(E)})};var D=()=>{i.add("insertdatetime",E=>{t(E),b(E),F(E)})};D()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(x,S,W)=>{var U;return W(x,S.prototype)?!0:((U=x.constructor)===null||U===void 0?void 0:U.name)===S.name},t=x=>{const S=typeof x;return x===null?"null":S==="object"&&Array.isArray(x)?"array":S==="object"&&e(x,String,(W,U)=>U.isPrototypeOf(W))?"string":S},n=x=>S=>t(S)===x,s=n("string"),r=n("object"),o=n("array"),l=x=>x==null,a=x=>!l(x);class c{constructor(S,W){this.tag=S,this.value=W}static some(S){return new c(!0,S)}static none(){return c.singletonNone}fold(S,W){return this.tag?W(this.value):S()}isSome(){return this.tag}isNone(){return!this.tag}map(S){return this.tag?c.some(S(this.value)):c.none()}bind(S){return this.tag?S(this.value):c.none()}exists(S){return this.tag&&S(this.value)}forall(S){return!this.tag||S(this.value)}filter(S){return!this.tag||S(this.value)?this:c.none()}getOr(S){return this.tag?this.value:S}or(S){return this.tag?this:S}getOrThunk(S){return this.tag?this.value:S()}orThunk(S){return this.tag?this:S()}getOrDie(S){if(this.tag)return this.value;throw new Error(S!=null?S:"Called getOrDie on None")}static from(S){return a(S)?c.some(S):c.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(S){this.tag&&S(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=(x,S)=>{for(let W=0,U=x.length;W<U;W++){const Me=x[W];S(Me,W)}},f=x=>{const S=[];for(let W=0,U=x.length;W<U;++W){if(!o(x[W]))throw new Error("Arr.flatten item "+W+" was not an array, input: "+x);u.apply(S,x[W])}return S},d=x=>{let S=x;return{get:()=>S,set:Me=>{S=Me}}},p=Object.keys,y=Object.hasOwnProperty,b=(x,S)=>{const W=p(x);for(let U=0,Me=W.length;U<Me;U++){const Be=W[U],je=x[Be];S(je,Be)}},m=(x,S)=>A(x,S)?c.from(x[S]):c.none(),A=(x,S)=>y.call(x,S),v=x=>S=>S.options.get(x),F=x=>{const S=x.options.register;S("audio_template_callback",{processor:"function"}),S("video_template_callback",{processor:"function"}),S("iframe_template_callback",{processor:"function"}),S("media_live_embeds",{processor:"boolean",default:!0}),S("media_filter_html",{processor:"boolean",default:!0}),S("media_url_resolver",{processor:"function"}),S("media_alt_source",{processor:"boolean",default:!0}),S("media_poster",{processor:"boolean",default:!0}),S("media_dimensions",{processor:"boolean",default:!0})},D=v("audio_template_callback"),E=v("video_template_callback"),P=v("iframe_template_callback"),T=v("media_live_embeds"),M=v("media_filter_html"),V=v("media_url_resolver"),H=v("media_alt_source"),te=v("media_poster"),ue=v("media_dimensions");var L=tinymce.util.Tools.resolve("tinymce.util.Tools"),re=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),N=tinymce.util.Tools.resolve("tinymce.html.DomParser");const Q=re.DOM,$=x=>x.replace(/px$/,""),ie=x=>{const S=x.attr("style"),W=S?Q.parseStyle(S):{};return{type:"ephox-embed-iri",source:x.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:m(W,"max-width").map($).getOr(""),height:m(W,"max-height").map($).getOr("")}},le=(x,S)=>{let W={};const Me=N({validate:!1,forced_root_block:!1},S).parse(x);for(let Be=Me;Be;Be=Be.walk())if(Be.type===1){const je=Be.name;if(Be.attr("data-ephox-embed-iri")){W=ie(Be);break}else!W.source&&je==="param"&&(W.source=Be.attr("movie")),(je==="iframe"||je==="object"||je==="embed"||je==="video"||je==="audio")&&(W.type||(W.type=je),W=L.extend(Be.attributes.map,W)),je==="source"&&(W.source?W.altsource||(W.altsource=Be.attr("src")):W.source=Be.attr("src")),je==="img"&&!W.poster&&(W.poster=Be.attr("src"))}return W.source=W.source||W.src||"",W.altsource=W.altsource||"",W.poster=W.poster||"",W},_=x=>{var S;const W={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=(S=x.toLowerCase().split(".").pop())!==null&&S!==void 0?S:"";return m(W,U).getOr("")};var Y=tinymce.util.Tools.resolve("tinymce.html.Node"),ye=tinymce.util.Tools.resolve("tinymce.html.Serializer");const we=(x,S={})=>N(Fe({forced_root_block:!1,validate:!1,allow_conditional_comments:!0},S),x),Le=re.DOM,ve=x=>/^[0-9.]+$/.test(x)?x+"px":x,qe=(x,S)=>{const W=S.attr("style"),U=W?Le.parseStyle(W):{};a(x.width)&&(U["max-width"]=ve(x.width)),a(x.height)&&(U["max-height"]=ve(x.height)),S.attr("style",Le.serializeStyle(U))},st=["source","altsource"],Je=(x,S,W,U)=>{let Me=0,Be=0;const je=we(U);je.addNodeFilter("source",Ze=>Me=Ze.length);const xt=je.parse(x);for(let Ze=xt;Ze;Ze=Ze.walk())if(Ze.type===1){const Ue=Ze.name;if(Ze.attr("data-ephox-embed-iri")){qe(S,Ze);break}else{switch(Ue){case"video":case"object":case"embed":case"img":case"iframe":S.height!==void 0&&S.width!==void 0&&(Ze.attr("width",S.width),Ze.attr("height",S.height));break}if(W)switch(Ue){case"video":Ze.attr("poster",S.poster),Ze.attr("src",null);for(let C=Me;C<2;C++)if(S[st[C]]){const J=new Y("source",1);J.attr("src",S[st[C]]),J.attr("type",S[st[C]+"mime"]||null),Ze.append(J)}break;case"iframe":Ze.attr("src",S.source);break;case"object":const k=Ze.getAll("img").length>0;if(S.poster&&!k){Ze.attr("src",S.poster);const C=new Y("img",1);C.attr("src",S.poster),C.attr("width",S.width),C.attr("height",S.height),Ze.append(C)}break;case"source":if(Be<2&&(Ze.attr("src",S[st[Be]]),Ze.attr("type",S[st[Be]+"mime"]||null),!S[st[Be]])){Ze.remove();continue}Be++;break;case"img":S.poster||Ze.remove();break}}}return ye({},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=x=>{const S=x.match(/^(https?:\/\/|www\.)(.+)$/i);return S&&S.length>1?S[1]==="www."?"https://":S[1]:"https://"},Lt=(x,S)=>{const W=Xe(S),U=x.regex.exec(S);let Me=W+x.url;if(a(U))for(let Be=0;Be<U.length;Be++)Me=Me.replace("$"+Be,()=>U[Be]?U[Be]:"");return Me.replace(/\?$/,"")},Mt=x=>{const S=pt.filter(W=>W.regex.test(x));return S.length>0?L.extend({},S[0],{url:Lt(S[0],x)}):null},oe=(x,S)=>{if(S)return S(x);{const W=x.allowfullscreen?' allowFullscreen="1"':"";return'<iframe src="'+x.source+'" width="'+x.width+'" height="'+x.height+'"'+W+"></iframe>"}},be=x=>{let S='<object data="'+x.source+'" width="'+x.width+'" height="'+x.height+'" type="application/x-shockwave-flash">';return x.poster&&(S+='<img src="'+x.poster+'" width="'+x.width+'" height="'+x.height+'" />'),S+="</object>",S},de=(x,S)=>S?S(x):'<audio controls="controls" src="'+x.source+'">'+(x.altsource?`
- <source src="`+x.altsource+'"'+(x.altsourcemime?' type="'+x.altsourcemime+'"':"")+` />
- `:"")+"</audio>",j=(x,S)=>S?S(x):'<video width="'+x.width+'" height="'+x.height+'"'+(x.poster?' poster="'+x.poster+'"':"")+` controls="controls">
- <source src="`+x.source+'"'+(x.sourcemime?' type="'+x.sourcemime+'"':"")+` />
- `+(x.altsource?'<source src="'+x.altsource+'"'+(x.altsourcemime?' type="'+x.altsourcemime+'"':"")+` />
- `:"")+"</video>",ee=(x,S)=>{var W;const U=L.extend({},S);if(!U.source&&(L.extend(U,le((W=U.embed)!==null&&W!==void 0?W:"",x.schema)),!U.source))return"";U.altsource||(U.altsource=""),U.poster||(U.poster=""),U.source=x.convertURL(U.source,"source"),U.altsource=x.convertURL(U.altsource,"source"),U.sourcemime=_(U.source),U.altsourcemime=_(U.altsource),U.poster=x.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,x.schema);{const Be=D(x),je=E(x),xt=P(x);return U.width=U.width||"300",U.height=U.height||"150",L.each(U,(Ze,Ue)=>{U[Ue]=x.dom.encode(""+Ze)}),U.type==="iframe"?oe(U,xt):U.sourcemime==="application/x-shockwave-flash"?be(U):U.sourcemime.indexOf("audio")!==-1?de(U,Be):j(U,je)}},ae=x=>x.hasAttribute("data-mce-object")||x.hasAttribute("data-ephox-embed-iri"),he=x=>{x.on("click keyup touchend",()=>{const S=x.selection.getNode();S&&x.dom.hasClass(S,"mce-preview-object")&&x.dom.getAttrib(S,"data-mce-selected")&&S.setAttribute("data-mce-selected","2")}),x.on("ObjectResized",S=>{const W=S.target;if(W.getAttribute("data-mce-object")){let U=W.getAttribute("data-mce-html");U&&(U=unescape(U),W.setAttribute("data-mce-html",escape(Je(U,{width:String(S.width),height:String(S.height)},!1,x.schema))))}})},fe={},O=(x,S,W)=>new Promise((U,Me)=>{const Be=je=>(je.html&&(fe[x.source]=je),U({url:x.source,html:je.html?je.html:S(x)}));fe[x.source]?Be(fe[x.source]):W({url:x.source},Be,Me)}),I=(x,S)=>Promise.resolve({html:S(x),url:x.source}),Z=x=>S=>ee(x,S),xe=(x,S)=>{const W=V(x);return W?O(S,Z(x),W):I(S,Z(x))},$e=x=>A(fe,x),He=(x,S)=>m(S,x).bind(W=>m(W,"meta")),bt=(x,S,W)=>U=>{const Me=()=>m(x,U),Be=()=>m(S,U),je=Ue=>m(Ue,"value").bind(k=>k.length>0?c.some(k):c.none()),xt=()=>Me().bind(Ue=>r(Ue)?je(Ue).orThunk(Be):Be().orThunk(()=>c.from(Ue))),Ze=()=>Be().orThunk(()=>Me().bind(Ue=>r(Ue)?je(Ue):c.from(Ue)));return{[U]:(U===W?xt():Ze()).getOr("")}},kt=(x,S)=>{const W={};return m(x,"dimensions").each(U=>{h(["width","height"],Me=>{m(S,Me).orThunk(()=>m(U,Me)).each(Be=>W[Me]=Be)})}),W},Nt=(x,S)=>{const W=S&&S!=="dimensions"?He(S,x).getOr({}):{},U=bt(x,W,S);return Fe(Fe(Fe(Fe(Fe({},U("source")),U("altsource")),U("poster")),U("embed")),kt(x,W))},q=x=>{const S=qt(Fe({},x),{source:{value:m(x,"source").getOr("")},altsource:{value:m(x,"altsource").getOr("")},poster:{value:m(x,"poster").getOr("")}});return h(["width","height"],W=>{m(x,W).each(U=>{const Me=S.dimensions||{};Me[W]=U,S.dimensions=Me})}),S},se=x=>S=>{const W=S&&S.msg?"Media embed handler error: "+S.msg:"Media embed handler threw unknown error.";x.notificationManager.open({type:"error",text:W})},ne=x=>{const S=x.selection.getNode(),W=ae(S)?x.serializer.serialize(S,{selection:!0}):"",U=le(W,x.schema),Be=(()=>{if(We(U.source,U.type)){const je=x.dom.getRect(S);return{width:je.w.toString().replace(/px$/,""),height:je.h.toString().replace(/px$/,"")}}else return{}})();return Fe(Fe({embed:W},U),Be)},ke=(x,S)=>W=>{if(s(W.url)&&W.url.trim().length>0){const U=W.html,Me=le(U,S.schema),Be=qt(Fe({},Me),{source:W.url,embed:U});x.setData(q(Be))}},Ie=(x,S)=>{const W=x.dom.select("*[data-mce-object]");for(let U=0;U<S.length;U++)for(let Me=W.length-1;Me>=0;Me--)S[U]===W[Me]&&W.splice(Me,1);x.selection.select(W[0])},et=(x,S)=>{const W=x.dom.select("*[data-mce-object]");x.insertContent(S),Ie(x,W),x.nodeChanged()},We=(x,S)=>a(S)&&S==="ephox-embed-iri"&&a(Mt(x)),lt=(x,S)=>((U,Me)=>U.width!==Me.width||U.height!==Me.height)(x,S)&&We(S.source,x.type),wt=(x,S,W)=>{var U;S.embed=lt(x,S)&&ue(W)?ee(W,qt(Fe({},S),{embed:""})):Je((U=S.embed)!==null&&U!==void 0?U:"",S,!1,W.schema),S.embed&&(x.source===S.source||$e(S.source))?et(W,S.embed):xe(W,S).then(Me=>{et(W,Me.html)}).catch(se(W))},ut=x=>{const S=ne(x),W=d(S),U=q(S),Me=(Se,Ve)=>{const Ke=Nt(Ve.getData(),"source");Se.source!==Ke.source&&(ke(De,x)({url:Ke.source,html:""}),xe(x,Ke).then(ke(De,x)).catch(se(x)))},Be=Se=>{var Ve;const Ke=Nt(Se.getData()),at=le((Ve=Ke.embed)!==null&&Ve!==void 0?Ve:"",x.schema);Se.setData(q(at))},je=(Se,Ve,Ke)=>{const at=Nt(Se.getData(),Ve),_t=lt(Ke,at)&&ue(x)?qt(Fe({},at),{embed:""}):at,Mi=ee(x,_t);Se.setData(q(qt(Fe({},_t),{embed:Mi})))},xt=[{name:"source",type:"urlinput",filetype:"media",label:"Source",picker_text:"Browse files"}],Ze=ue(x)?[{type:"sizeinput",name:"dimensions",label:"Constrain proportions",constrain:!0}]:[],Ue={title:"General",name:"general",items:f([xt,Ze])},C={title:"Embed",items:[{type:"textarea",name:"embed",label:"Paste your embed code below:"}]},J=[];H(x)&&J.push({name:"altsource",type:"urlinput",filetype:"media",label:"Alternative source URL"}),te(x)&&J.push({name:"poster",type:"urlinput",filetype:"image",label:"Media poster (Image URL)"});const pe={title:"Advanced",name:"advanced",items:J},ge=[Ue,C];J.length>0&&ge.push(pe);const Ce={type:"tabpanel",tabs:ge},De=x.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(W.get(),Ve,x),Se.close()},onChange:(Se,Ve)=>{switch(Ve.name){case"source":Me(W.get(),Se);break;case"embed":Be(Se);break;case"dimensions":case"altsource":case"poster":je(Se,Ve.name,W.get());break}W.set(Nt(Se.getData()))},initialData:U})},Wt=x=>({showDialog:()=>{ut(x)}}),Jt=x=>{const S=()=>{ut(x)};x.addCommand("mceMedia",S)},Dn=(x,S,W)=>x.length>=S.length&&x.substr(W,W+S.length)===S,Zn=(x,S)=>Dn(x,S,0);var on=tinymce.util.Tools.resolve("tinymce.Env");const On=x=>{const S=x.name;return S==="iframe"||S==="video"||S==="audio"},ei=(x,S,W,U=null)=>{const Me=x.attr(W);return a(Me)?Me:A(S,W)?null:U},Ln=(x,S,W)=>{const U=S.name==="img"||x.name==="video",Me=U?"300":null,Be=x.name==="audio"?"30":"150",je=U?Be:null;S.attr({width:ei(x,W,"width",Me),height:ei(x,W,"height",je)})},Un=(x,S,W,U)=>{const Me=we(x.schema).parse(U,{context:S});for(;Me.firstChild;)W.append(Me.firstChild)},Ai=(x,S)=>{const W=S.name,U=new Y("img",1);return ti(x,S,U),Ln(S,U,{}),U.attr({style:S.attr("style"),src:on.transparentSrc,"data-mce-object":W,class:"mce-object mce-object-"+W}),U},Ti=(x,S)=>{var W;const U=S.name,Me=new Y("span",1);Me.attr({contentEditable:"false",style:S.attr("style"),"data-mce-object":U,class:"mce-preview-object mce-object-"+U}),ti(x,S,Me);const Be=x.dom.parseStyle((W=S.attr("style"))!==null&&W!==void 0?W:""),je=new Y(U,1);if(Ln(S,je,Be),je.attr({src:S.attr("src"),style:S.attr("style"),class:S.attr("class")}),U==="iframe")je.attr({allowfullscreen:S.attr("allowfullscreen"),frameborder:"0",sandbox:S.attr("sandbox")});else{h(["controls","crossorigin","currentTime","loop","muted","poster","preload"],k=>{je.attr(k,S.attr(k))});const Ue=Me.attr("data-mce-html");a(Ue)&&Un(x,U,je,unescape(Ue))}const xt=new Y("span",1);return xt.attr("class","mce-shim"),Me.append(je),Me.append(xt),Me},ti=(x,S,W)=>{var U;const Me=(U=S.attributes)!==null&&U!==void 0?U:[];let Be=Me.length;for(;Be--;){const Ue=Me[Be].name;let k=Me[Be].value;Ue!=="width"&&Ue!=="height"&&Ue!=="style"&&!Zn(Ue,"data-mce-")&&((Ue==="data"||Ue==="src")&&(k=x.convertURL(k,Ue)),W.attr("data-mce-p-"+Ue,k))}const je=ye({inner:!0},x.schema),xt=new Y("div",1);h(S.children(),Ue=>xt.append(Ue));const Ze=je.serialize(xt);Ze&&(W.attr("data-mce-html",escape(Ze)),W.empty())},B=x=>{const S=x.attr("class");return s(S)&&/\btiny-pageembed\b/.test(S)},z=x=>{let S=x;for(;S=S.parent;)if(S.attr("data-ephox-embed-iri")||B(S))return!0;return!1},me=x=>S=>{let W=S.length,U;for(;W--;)U=S[W],U.parent&&(U.parent.attr("data-mce-object")||(On(U)&&T(x)?z(U)||U.replace(Ti(x,U)):z(U)||U.replace(Ai(x,U))))},Oe=(x,S,W)=>{const U=x.options.get,Me=U("xss_sanitization"),Be=M(x);return we(x.schema,{sanitize:Me,validate:Be}).parse(W,{context:S})},Qe=x=>{x.on("PreInit",()=>{const{schema:S,serializer:W,parser:U}=x,Me=S.getBoolAttrs();h("webkitallowfullscreen mozallowfullscreen".split(" "),Be=>{Me[Be]={}}),b({embed:["wmode"]},(Be,je)=>{const xt=S.getElementRule(je);xt&&h(Be,Ze=>{xt.attributes[Ze]={},xt.attributesOrder.push(Ze)})}),U.addNodeFilter("iframe,video,audio,object,embed",me(x)),W.addAttributeFilter("data-mce-object",(Be,je)=>{var xt;let Ze=Be.length;for(;Ze--;){const Ue=Be[Ze];if(!Ue.parent)continue;const k=Ue.attr(je),C=new Y(k,1);if(k!=="audio"){const Ce=Ue.attr("class");Ce&&Ce.indexOf("mce-preview-object")!==-1&&Ue.firstChild?C.attr({width:Ue.firstChild.attr("width"),height:Ue.firstChild.attr("height")}):C.attr({width:Ue.attr("width"),height:Ue.attr("height")})}C.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&&C.attr(Ce.substr(11),J[pe].value)}const ge=Ue.attr("data-mce-html");if(ge){const Ce=Oe(x,k,unescape(ge));h(Ce.children(),De=>C.append(De))}Ue.replace(C)}})}),x.on("SetContent",()=>{const S=x.dom;h(S.select("span.mce-preview-object"),W=>{S.select("span.mce-shim",W).length===0&&S.add(W,"span",{class:"mce-shim"})})})},$t=x=>{x.on("ResolveName",S=>{let W;S.target.nodeType===1&&(W=S.target.getAttribute("data-mce-object"))&&(S.name=W)})},En=x=>S=>{const W=()=>{S.setEnabled(x.selection.isEditable())};return x.on("NodeChange",W),W(),()=>{x.off("NodeChange",W)}},jt=x=>{const S=()=>x.execCommand("mceMedia");x.ui.registry.addToggleButton("media",{tooltip:"Insert/edit media",icon:"embed",onAction:S,onSetup:W=>{const U=x.selection;W.setActive(ae(U.getNode()));const Me=U.selectorChangedWithUnbind("img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]",W.setActive).unbind,Be=En(x)(W);return()=>{Me(),Be()}}}),x.ui.registry.addMenuItem("media",{icon:"embed",text:"Media...",onAction:S,onSetup:En(x)})};var ni=()=>{i.add("media",x=>(F(x),Jt(x),jt(x),$t(x),Qe(x),he(x),Wt(x)))};ni()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=m=>A=>typeof A===m,t=e("boolean"),n=e("number"),s=m=>A=>A.options.get(m),r=m=>{const A=m.options.register;A("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}),A("nonbreaking_wrap",{processor:"boolean",default:!0})},o=s("nonbreaking_force_tab"),l=s("nonbreaking_wrap"),a=(m,A)=>{let v="";for(let F=0;F<A;F++)v+=m;return v},c=m=>m.plugins.visualchars?m.plugins.visualchars.isEnabled():!1,u=(m,A)=>{const v=()=>c(m)?"mce-nbsp-wrap mce-nbsp":"mce-nbsp-wrap",F=()=>`<span class="${v()}" contenteditable="false">${a(" ",A)}</span>`,E=l(m)||m.plugins.visualchars?F():a(" ",A);m.undoManager.transact(()=>m.insertContent(E))},h=m=>{m.addCommand("mceNonBreaking",()=>{u(m,1)})};var f=tinymce.util.Tools.resolve("tinymce.util.VK");const d=m=>{const A=o(m);A>0&&m.on("keydown",v=>{if(v.keyCode===f.TAB&&!v.isDefaultPrevented()){if(v.shiftKey)return;v.preventDefault(),v.stopImmediatePropagation(),u(m,A)}})},p=m=>A=>{const v=()=>{A.setEnabled(m.selection.isEditable())};return m.on("NodeChange",v),v(),()=>{m.off("NodeChange",v)}},y=m=>{const A=()=>m.execCommand("mceNonBreaking");m.ui.registry.addButton("nonbreaking",{icon:"non-breaking",tooltip:"Nonbreaking space",onAction:A,onSetup:p(m)}),m.ui.registry.addMenuItem("nonbreaking",{icon:"non-breaking",text:"Nonbreaking space",onAction:A,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:"<!-- pagebreak -->"}),y("pagebreak_split_block",{processor:"boolean",default:!1})},s=t("pagebreak_separator"),r=t("pagebreak_split_block"),o="mce-pagebreak",l=p=>{const y=`<img src="${e.transparentSrc}" class="${o}" data-mce-resize="false" data-mce-placeholder />`;return p?`<p>${y}</p>`:y},a=p=>{const y=s(p),b=()=>r(p),m=new RegExp(y.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,A=>"\\"+A),"gi");p.on("BeforeSetContent",A=>{A.content=A.content.replace(m,l(b()))}),p.on("PreInit",()=>{p.serializer.addNodeFilter("img",A=>{let v=A.length,F,D;for(;v--;)if(F=A[v],D=F.attr("class"),D&&D.indexOf(o)!==-1){const E=F.parent;if(E&&p.schema.getBlockElements()[E.name]&&b()){E.type=3,E.value=y,E.raw=!0,F.remove();continue}F.type=3,F.value=y,F.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+='<base href="'+b(d.documentBaseURI.getURI())+'">';const A=r(d)?' crossorigin="anonymous"':"";t.each(d.contentCSS,V=>{y+='<link type="text/css" rel="stylesheet" href="'+b(d.documentBaseURI.toAbsolute(V))+'"'+A+">"}),m&&(y+='<style type="text/css">'+m+"</style>");const v=l(d),F=o(d),E='<script>document.addEventListener && document.addEventListener("click", function(e) {for (var elm = e.target; elm; elm = elm.parentNode) {if (elm.nodeName === "A" && !('+(e.os.isMacOS()||e.os.isiOS()?"e.metaKey":"e.ctrlKey && !e.altKey")+")) {e.preventDefault();}}}, false);<\/script> ",P=d.getBody().dir,T=P?' dir="'+b(P)+'"':"";return"<!DOCTYPE html><html><head>"+y+'</head><body id="'+b(v)+'" class="mce-content-body '+b(F)+'"'+T+">"+d.getContent()+E+"</body></html>"},c=d=>{const p=a(d);d.windowManager.open({title:"Preview",size:"large",body:{type:"panel",items:[{name:"preview",type:"iframe",sandboxed:!0,transparent:!1}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{preview:p}}).focus("close")},u=d=>{d.addCommand("mcePreview",()=>{c(d)})},h=d=>{const p=()=>d.execCommand("mcePreview");d.ui.registry.addButton("preview",{icon:"preview",tooltip:"Preview",onAction:p}),d.ui.registry.addMenuItem("preview",{icon:"preview",text:"Preview",onAction:p})};var f=()=>{i.add("preview",d=>{u(d),h(d)})};f()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(m=>A=>typeof A===m)("function");var n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=tinymce.util.Tools.resolve("tinymce.util.Tools");const r=m=>A=>A.options.get(m),o=m=>{const A=m.options.register;A("save_enablewhendirty",{processor:"boolean",default:!0}),A("save_onsavecallback",{processor:"function"}),A("save_oncancelcallback",{processor:"function"})},l=r("save_enablewhendirty"),a=r("save_onsavecallback"),c=r("save_oncancelcallback"),u=(m,A)=>{m.notificationManager.open({text:A,type:"error"})},h=m=>{const A=n.DOM.getParent(m.id,"form");if(l(m)&&!m.isDirty())return;m.save();const v=a(m);if(t(v)){v.call(m,m),m.nodeChanged();return}A?(m.setDirty(!1),(!A.onsubmit||A.onsubmit())&&(typeof A.submit=="function"?A.submit():u(m,"Error: Form submit field collision.")),m.nodeChanged()):u(m,"Error: No form element found.")},f=m=>{const A=s.trim(m.startContent),v=c(m);if(t(v)){v.call(m,m);return}m.resetContent(A)},d=m=>{m.addCommand("mceSave",()=>{h(m)}),m.addCommand("mceCancel",()=>{f(m)})},p=m=>A=>{const v=()=>{A.setEnabled(!l(m)||m.isDirty())};return v(),m.on("NodeChange dirty",v),()=>m.off("NodeChange dirty",v)},y=m=>{m.ui.registry.addButton("save",{icon:"save",tooltip:"Save",enabled:!1,onAction:()=>m.execCommand("mceSave"),onSetup:p(m)}),m.ui.registry.addButton("cancel",{icon:"cancel",tooltip:"Cancel",enabled:!1,onAction:()=>m.execCommand("mceCancel"),onSetup:p(m)}),m.addShortcut("Meta+S","","mceSave")};var b=()=>{i.add("save",m=>{o(m),y(m),d(m)})};b()})();(function(){const i=k=>{let C=k;return{get:()=>C,set:ge=>{C=ge}}};var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(k,C,J)=>{var pe;return J(k,C.prototype)?!0:((pe=k.constructor)===null||pe===void 0?void 0:pe.name)===C.name},n=k=>{const C=typeof k;return k===null?"null":C==="object"&&Array.isArray(k)?"array":C==="object"&&t(k,String,(J,pe)=>pe.isPrototypeOf(J))?"string":C},s=k=>C=>n(C)===k,r=k=>C=>typeof C===k,o=s("string"),l=s("array"),a=r("boolean"),c=k=>k==null,u=k=>!c(k),h=r("number"),f=()=>{},d=k=>()=>k,p=d(!0),b=d("[~№|!-*+-\\/:;?@\\[-`{}¡«·»¿;·՚-՟։֊־׀׃׆׳״؉؊،؍؛؞؟٪-٭۔܀-܍߷-߹࠰-࠾࡞।॥॰෴๏๚๛༄-༒༺-༽྅࿐-࿔࿙࿚၊-၏჻፡-፨᐀᙭᙮᚛᚜᛫-᛭᜵᜶។-៖៘-៚᠀-᠊᥄᥅᨞᨟᪠-᪦᪨-᪭᭚-᭠᯼-᯿᰻-᰿᱾᱿᳓‐-‧‰-⁃⁅-⁑⁓-⁞⁽⁾₍₎〈〉❨-❵⟅⟆⟦-⟯⦃-⦘⧘-⧛⧼⧽⳹-⳼⳾⳿⵰⸀-⸮⸰⸱、-〃〈-】〔-〟〰〽゠・꓾꓿꘍-꘏꙳꙾꛲-꛷꡴-꡷꣎꣏꣸-꣺꤮꤯꥟꧁-꧍꧞꧟꩜-꩟꫞꫟꯫﴾﴿︐-︙︰-﹒﹔-﹡﹣﹨﹪﹫!-#%-*,-/:;?@[-]_{}⦅-・]");class m{constructor(C,J){this.tag=C,this.value=J}static some(C){return new m(!0,C)}static none(){return m.singletonNone}fold(C,J){return this.tag?J(this.value):C()}isSome(){return this.tag}isNone(){return!this.tag}map(C){return this.tag?m.some(C(this.value)):m.none()}bind(C){return this.tag?C(this.value):m.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:m.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 u(C)?m.some(C):m.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()"}}m.singletonNone=new m(!1);const A=b;var v=tinymce.util.Tools.resolve("tinymce.Env"),F=tinymce.util.Tools.resolve("tinymce.util.Tools");const D=Array.prototype.slice,E=Array.prototype.push,P=(k,C)=>{const J=k.length,pe=new Array(J);for(let ge=0;ge<J;ge++){const Ce=k[ge];pe[ge]=C(Ce,ge)}return pe},T=(k,C)=>{for(let J=0,pe=k.length;J<pe;J++){const ge=k[J];C(ge,J)}},M=(k,C)=>{for(let J=k.length-1;J>=0;J--){const pe=k[J];C(pe,J)}},V=(k,C)=>{if(k.length===0)return[];{let J=C(k[0]);const pe=[];let ge=[];for(let Ce=0,De=k.length;Ce<De;Ce++){const Se=k[Ce],Ve=C(Se);Ve!==J&&(pe.push(ge),ge=[]),J=Ve,ge.push(Se)}return ge.length!==0&&pe.push(ge),pe}},H=(k,C,J)=>(T(k,(pe,ge)=>{J=C(J,pe,ge)}),J),te=k=>{const C=[];for(let J=0,pe=k.length;J<pe;++J){if(!l(k[J]))throw new Error("Arr.flatten item "+J+" was not an array, input: "+k);E.apply(C,k[J])}return C},ue=(k,C)=>te(P(k,C)),L=(k,C)=>{const J=D.call(k,0);return J.sort(C),J},re=Object.hasOwnProperty,N=(k,C)=>re.call(k,C);typeof window!="undefined"||Function("return this;")();const Q=9,$=11,ie=1,le=3,_=k=>k.dom.nodeType,ye=(k=>C=>_(C)===k)(le),we=(k,C,J)=>{if(o(J)||a(J)||h(J))k.setAttribute(C,J+"");else throw new Error("Attribute value was not simple")},Le=(k,C,J)=>{we(k.dom,C,J)},ve=(k,C)=>{const pe=(C||document).createElement("div");if(pe.innerHTML=k,!pe.hasChildNodes()||pe.childNodes.length>1){const ge="HTML does not have a single root node";throw new Error(ge)}return Je(pe.childNodes[0])},qe=(k,C)=>{const pe=(C||document).createElement(k);return Je(pe)},st=(k,C)=>{const pe=(C||document).createTextNode(k);return Je(pe)},Je=k=>{if(k==null)throw new Error("Node cannot be null or undefined");return{dom:k}},Xe={fromHtml:ve,fromTag:qe,fromText:st,fromDom:Je,fromPoint:(k,C,J)=>m.from(k.dom.elementFromPoint(C,J)).map(Je)},Lt=k=>k.nodeType!==ie&&k.nodeType!==Q&&k.nodeType!==$||k.childElementCount===0,Mt=(k,C)=>{const J=C===void 0?document:C.dom;return Lt(J)?[]:P(J.querySelectorAll(k),Xe.fromDom)},oe=k=>m.from(k.dom.parentNode).map(Xe.fromDom),be=k=>P(k.dom.childNodes,Xe.fromDom),de=(k,C)=>({element:k,offset:C}),j=(k,C)=>{const J=be(k);return J.length>0&&C<J.length?de(J[C],0):de(k,C)},ee=(k,C)=>{oe(k).each(pe=>{pe.dom.insertBefore(C.dom,k.dom)})},ae=(k,C)=>{k.dom.appendChild(C.dom)},he=(k,C)=>{ee(k,C),ae(C,k)},O=((k,C)=>{const J=Ce=>{if(!k(Ce))throw new Error("Can only get "+C+" value of a "+C+" node");return pe(Ce).getOr("")},pe=Ce=>k(Ce)?m.from(Ce.dom.nodeValue):m.none();return{get:J,getOption:pe,set:(Ce,De)=>{if(!k(Ce))throw new Error("Can only set raw "+C+" value of a "+C+" node");Ce.dom.nodeValue=De}}})(ye,"text"),I=k=>O.get(k),Z=(k,C,J)=>(k.compareDocumentPosition(C)&J)!==0,xe=(k,C)=>Z(k,C,Node.DOCUMENT_POSITION_PRECEDING),$e=(k,C)=>Mt(C,k);var He=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");const bt=(k,C)=>k.isBlock(C)||N(k.schema.getVoidElements(),C.nodeName),kt=(k,C)=>!k.isEditable(C),Nt=(k,C)=>k.getContentEditable(C)==="true"&&C.parentNode&&!k.isEditable(C.parentNode),q=(k,C)=>!k.isBlock(C)&&N(k.schema.getWhitespaceElements(),C.nodeName),se=(k,C)=>bt(k,C)||kt(k,C)||q(k,C)||Nt(k,C),ne=k=>k.nodeType===3,ke=()=>({sOffset:0,fOffset:0,elements:[]}),Ie=(k,C)=>j(Xe.fromDom(k),C),et=(k,C,J,pe,ge,Ce=!0)=>{let De=Ce?C(!1):J;for(;De;){const Se=kt(k,De);if(Se||q(k,De)){if(Se?pe.cef(De):pe.boundary(De))break;De=C(!0);continue}else if(bt(k,De)){if(pe.boundary(De))break}else ne(De)&&pe.text(De);if(De===ge)break;De=C(!1)}},We=(k,C,J,pe,ge)=>{var Ce;if(se(k,J))return;const De=(Ce=k.getParent(pe,k.isBlock))!==null&&Ce!==void 0?Ce:k.getRoot(),Se=new He(J,De),Ve=ge?Se.next.bind(Se):Se.prev.bind(Se);et(k,Ve,J,{boundary:p,cef:p,text:Ke=>{ge?C.fOffset+=Ke.length:C.sOffset+=Ke.length,C.elements.push(Xe.fromDom(Ke))}})},lt=(k,C,J,pe,ge,Ce=!0)=>{const De=new He(J,C),Se=[];let Ve=ke();We(k,Ve,J,C,!1);const Ke=()=>(Ve.elements.length>0&&(Se.push(Ve),Ve=ke()),!1);return et(k,De.next.bind(De),J,{boundary:Ke,cef:at=>(Ke(),ge&&Se.push(...ge.cef(at)),!1),text:at=>{Ve.elements.push(Xe.fromDom(at)),ge&&ge.text(at,Ve)}},pe,Ce),pe&&We(k,Ve,pe,C,!0),Ke(),Se},wt=(k,C)=>{const J=Ie(C.startContainer,C.startOffset),pe=J.element.dom,ge=Ie(C.endContainer,C.endOffset),Ce=ge.element.dom;return lt(k,C.commonAncestorContainer,pe,Ce,{text:(De,Se)=>{De===Ce?Se.fOffset+=De.length-ge.offset:De===pe&&(Se.sOffset+=J.offset)},cef:De=>{const Se=ue($e(Xe.fromDom(De),"*[contenteditable=true]"),Ve=>{const Ke=Ve.dom;return lt(k,Ke,Ke)});return L(Se,(Ve,Ke)=>xe(Ve.elements[0].dom,Ke.elements[0].dom)?1:-1)}},!1)},ut=(k,C)=>C.collapsed?[]:wt(k,C),Wt=(k,C)=>{const J=k.createRng();return J.selectNode(C),ut(k,J)},Jt=(k,C)=>ue(C,J=>Wt(k,J)),Dn=(k,C,J=0,pe=k.length)=>{const ge=C.regex;ge.lastIndex=J;const Ce=[];let De;for(;De=ge.exec(k);){const Se=De[C.matchIndex],Ve=De.index+De[0].indexOf(Se),Ke=Ve+Se.length;if(Ke>pe)break;Ce.push({start:Ve,finish:Ke}),ge.lastIndex=Ke}return Ce},Zn=(k,C)=>{const J=H(k,(pe,ge)=>{const Ce=I(ge),De=pe.last,Se=De+Ce.length,Ve=ue(C,(Ke,at)=>Ke.start<Se&&Ke.finish>De?[{element:ge,start:Math.max(De,Ke.start)-De,finish:Math.min(Se,Ke.finish)-De,matchId:at}]:[]);return{results:pe.results.concat(Ve),last:Se}},{results:[],last:0}).results;return V(J,pe=>pe.matchId)},on=(k,C)=>ue(C,J=>{const pe=J.elements,ge=P(pe,I).join(""),Ce=Dn(ge,k,J.sOffset,ge.length-J.fOffset);return Zn(pe,Ce)}),On=(k,C)=>{M(k,(J,pe)=>{M(J,ge=>{const Ce=Xe.fromDom(C.cloneNode(!1));Le(Ce,"data-mce-index",pe);const De=ge.element.dom;if(De.length===ge.finish&&ge.start===0)he(ge.element,Ce);else{De.length!==ge.finish&&De.splitText(ge.finish);const Se=De.splitText(ge.start);he(Xe.fromDom(Se),Ce)}})})},ei=(k,C,J,pe)=>{const ge=Wt(k,J),Ce=on(C,ge);return On(Ce,pe),Ce.length},Ln=(k,C,J,pe)=>{const ge=J.getBookmark(),Ce=k.select("td[data-mce-selected],th[data-mce-selected]"),De=Ce.length>0?Jt(k,Ce):ut(k,J.getRng()),Se=on(C,De);return On(Se,pe),J.moveToBookmark(ge),Se.length},Un=k=>k.getAttribute("data-mce-index"),Ai=(k,C,J,pe)=>{const ge=k.dom.create("span",{"data-mce-bogus":1});ge.className="mce-match-marker";const Ce=k.getBody();return ni(k,C,!1),pe?Ln(k.dom,J,k.selection,ge):ei(k.dom,J,Ce,ge)},Ti=k=>{var C;const J=k.parentNode;k.firstChild&&J.insertBefore(k.firstChild,k),(C=k.parentNode)===null||C===void 0||C.removeChild(k)},ti=(k,C)=>{const J=[],pe=F.toArray(k.getBody().getElementsByTagName("span"));if(pe.length)for(let ge=0;ge<pe.length;ge++){const Ce=Un(pe[ge]);Ce===null||!Ce.length||Ce===C.toString()&&J.push(pe[ge])}return J},B=(k,C,J)=>{const pe=C.get();let ge=pe.index;const Ce=k.dom;J?ge+1===pe.count?ge=0:ge++:ge-1===-1?ge=pe.count-1:ge--,Ce.removeClass(ti(k,pe.index),"mce-match-marker-selected");const De=ti(k,ge);return De.length?(Ce.addClass(ti(k,ge),"mce-match-marker-selected"),k.selection.scrollIntoView(De[0]),ge):-1},z=(k,C)=>{const J=C.parentNode;k.remove(C),J&&k.isEmpty(J)&&k.remove(J)},me=(k,C)=>{const pe="("+k.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&").replace(/\s/g,"[^\\S\\r\\n\\uFEFF]")+")";return C?`(?:^|\\s|${A()})`+pe+`(?=$|\\s|${A()})`:pe},Oe=(k,C,J,pe,ge,Ce)=>{const De=k.selection,Se=me(J,ge),Ve=De.isForward(),Ke={regex:new RegExp(Se,pe?"g":"gi"),matchIndex:1},at=Ai(k,C,Ke,Ce);if(v.browser.isSafari()&&De.setRng(De.getRng(),Ve),at){const _t=B(k,C,!0);C.set({index:_t,count:at,text:J,matchCase:pe,wholeWord:ge,inSelection:Ce})}return at},Qe=(k,C)=>{const J=B(k,C,!0);C.set(qt(Fe({},C.get()),{index:J}))},$t=(k,C)=>{const J=B(k,C,!1);C.set(qt(Fe({},C.get()),{index:J}))},En=k=>{const C=Un(k);return C!==null&&C.length>0},jt=(k,C,J,pe,ge)=>{const Ce=C.get(),De=Ce.index;let Se,Ve=De;pe=pe!==!1;const Ke=k.getBody(),at=F.grep(F.toArray(Ke.getElementsByTagName("span")),En);for(let _t=0;_t<at.length;_t++){const Mi=Un(at[_t]);let Qi=Se=parseInt(Mi,10);if(ge||Qi===Ce.index){for(J.length?(at[_t].innerText=J,Ti(at[_t])):z(k.dom,at[_t]);at[++_t];)if(Qi=parseInt(Un(at[_t]),10),Qi===Se)z(k.dom,at[_t]);else{_t--;break}pe&&Ve--}else Se>De&&at[_t].setAttribute("data-mce-index",String(Se-1))}return C.set(qt(Fe({},Ce),{count:ge?0:Ce.count-1,index:Ve})),pe?Qe(k,C):$t(k,C),!ge&&C.get().count>0},ni=(k,C,J)=>{let pe,ge;const Ce=C.get(),De=F.toArray(k.getBody().getElementsByTagName("span"));for(let Se=0;Se<De.length;Se++){const Ve=Un(De[Se]);Ve!==null&&Ve.length&&(Ve===Ce.index.toString()&&(pe||(pe=De[Se].firstChild),ge=De[Se].firstChild),Ti(De[Se]))}if(C.set(qt(Fe({},Ce),{index:-1,count:0,text:""})),pe&&ge){const Se=k.dom.createRng();return Se.setStart(pe,0),Se.setEnd(ge,ge.data.length),J!==!1&&k.selection.setRng(Se),Se}else return},x=(k,C)=>C.get().count>1,S=(k,C)=>C.get().count>1,W=(k,C)=>({done:Se=>ni(k,C,Se),find:(Se,Ve,Ke,at=!1)=>Oe(k,C,Se,Ve,Ke,at),next:()=>Qe(k,C),prev:()=>$t(k,C),replace:(Se,Ve,Ke)=>jt(k,C,Se,Ve,Ke)}),U=k=>{const C=i(m.none()),J=()=>C.get().each(k);return{clear:()=>{J(),C.set(m.none())},isSet:()=>C.get().isSome(),get:()=>C.get(),set:Se=>{J(),C.set(m.some(Se))}}},Me=()=>{const k=U(f),C=J=>k.get().each(J);return qt(Fe({},k),{on:C})},Be=(k,C)=>{const J=Me();k.undoManager.add();const pe=F.trim(k.selection.getContent({format:"text"})),ge=St=>{St.setEnabled("next",x(k,C)),St.setEnabled("prev",S(k,C))},Ce=St=>{const ct=St.getData(),Dt=C.get();C.set(qt(Fe({},Dt),{matchCase:ct.matchcase,wholeWord:ct.wholewords,inSelection:ct.inselection}))},De=(St,ct)=>{T(["replace","replaceall","prev","next"],Zi=>St.setEnabled(Zi,!ct))},Se=(St,ct)=>{ct.redial(Kr(St,ct.getData()))},Ve=(St,ct)=>{v.browser.isSafari()&&v.deviceType.isTouch()&&(ct==="find"||ct==="replace"||ct==="replaceall")&&St.focus(ct)},Ke=St=>{ni(k,C,!1),De(St,!0),ge(St)},at=St=>{const ct=St.getData(),Dt=C.get();if(!ct.findtext.length){Ke(St);return}if(Dt.text===ct.findtext&&Dt.matchCase===ct.matchcase&&Dt.wholeWord===ct.wholewords)Qe(k,C);else{const ii=Oe(k,C,ct.findtext,ct.matchcase,ct.wholewords,ct.inselection);ii<=0&&Se(!0,St),De(St,ii===0)}ge(St)},_t=C.get(),Mi={findtext:pe,replacetext:"",wholewords:_t.wholeWord,matchcase:_t.matchCase,inselection:_t.inSelection},Qi=St=>{const ct=[{type:"bar",items:[{type:"input",name:"findtext",placeholder:"Find",maximized:!0,inputMode:"search"},{type:"button",name:"prev",text:"Previous",icon:"action-prev",enabled:!1,borderless:!0},{type:"button",name:"next",text:"Next",icon:"action-next",enabled:!1,borderless:!0}]},{type:"input",name:"replacetext",placeholder:"Replace with",inputMode:"search"}];return St&&ct.push({type:"alertbanner",level:"error",text:"Could not find the specified string.",icon:"warning"}),ct},Kr=(St,ct)=>({title:"Find and Replace",size:"normal",body:{type:"panel",items:Qi(St)},buttons:[{type:"menu",name:"options",icon:"preferences",tooltip:"Preferences",align:"start",items:[{type:"togglemenuitem",name:"matchcase",text:"Match case"},{type:"togglemenuitem",name:"wholewords",text:"Find whole words only"},{type:"togglemenuitem",name:"inselection",text:"Find in selection"}]},{type:"custom",name:"find",text:"Find",primary:!0},{type:"custom",name:"replace",text:"Replace",enabled:!1},{type:"custom",name:"replaceall",text:"Replace all",enabled:!1}],initialData:ct,onChange:(Dt,ii)=>{St&&Se(!1,Dt),ii.name==="findtext"&&C.get().count>0&&Ke(Dt)},onAction:(Dt,ii)=>{const Zi=Dt.getData();switch(ii.name){case"find":at(Dt);break;case"replace":jt(k,C,Zi.replacetext)?ge(Dt):Ke(Dt);break;case"replaceall":jt(k,C,Zi.replacetext,!0,!0),Ke(Dt);break;case"prev":$t(k,C),ge(Dt);break;case"next":Qe(k,C),ge(Dt);break;case"matchcase":case"wholewords":case"inselection":Se(!1,Dt),Ce(Dt),Ke(Dt);break}Ve(Dt,ii.name)},onSubmit:Dt=>{at(Dt),Ve(Dt,"find")},onClose:()=>{k.focus(),ni(k,C),k.undoManager.add()}});J.set(k.windowManager.open(Kr(!1,Mi),{inline:"toolbar"}))},je=(k,C)=>{k.addCommand("SearchReplace",()=>{Be(k,C)})},xt=(k,C)=>()=>{Be(k,C)},Ze=(k,C)=>{k.ui.registry.addMenuItem("searchreplace",{text:"Find and replace...",shortcut:"Meta+F",onAction:xt(k,C),icon:"search"}),k.ui.registry.addButton("searchreplace",{tooltip:"Find and replace",onAction:xt(k,C),icon:"search"}),k.shortcuts.add("Meta+F","",xt(k,C))};var Ue=()=>{e.add("searchreplace",k=>{const C=i({index:-1,count:0,text:"",matchCase:!1,wholeWord:!1,inSelection:!1});return je(k,C),Ze(k,C),W(k,C)})};Ue()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(O,I,Z)=>{var xe;return Z(O,I.prototype)?!0:((xe=O.constructor)===null||xe===void 0?void 0:xe.name)===I.name},t=O=>{const I=typeof O;return O===null?"null":I==="object"&&Array.isArray(O)?"array":I==="object"&&e(O,String,(Z,xe)=>xe.isPrototypeOf(Z))?"string":I},n=O=>I=>t(I)===O,s=O=>I=>typeof I===O,r=n("string"),o=n("object"),l=n("array"),a=O=>O==null,c=O=>!a(O),u=s("function"),h=(O,I)=>{if(l(O)){for(let Z=0,xe=O.length;Z<xe;++Z)if(!I(O[Z]))return!1;return!0}return!1},f=O=>()=>O;function d(O,...I){return(...Z)=>{const xe=I.concat(Z);return O.apply(null,xe)}}const p=f(!1),y=O=>O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");var b=tinymce.util.Tools.resolve("tinymce.util.Tools");const m=O=>I=>I.options.get(O),A=O=>{const I=O.options.register;I("template_cdate_classes",{processor:"string",default:"cdate"}),I("template_mdate_classes",{processor:"string",default:"mdate"}),I("template_selected_content_classes",{processor:"string",default:"selcontent"}),I("template_preview_replace_values",{processor:"object"}),I("template_replace_values",{processor:"object"}),I("templates",{processor:Z=>r(Z)||h(Z,o)||u(Z),default:[]}),I("template_cdate_format",{processor:"string",default:O.translate("%Y-%m-%d")}),I("template_mdate_format",{processor:"string",default:O.translate("%Y-%m-%d")})},v=m("template_cdate_classes"),F=m("template_mdate_classes"),D=m("template_selected_content_classes"),E=m("template_preview_replace_values"),P=m("template_replace_values"),T=m("templates"),M=m("template_cdate_format"),V=m("template_mdate_format"),H=m("content_style"),te=m("content_css_cors"),ue=m("body_class"),L=(O,I)=>{if(O=""+O,O.length<I)for(let Z=0;Z<I-O.length;Z++)O="0"+O;return O},re=(O,I,Z=new Date)=>{const xe="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),$e="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),He="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),bt="January February March April May June July August September October November December".split(" ");return I=I.replace("%D","%m/%d/%Y"),I=I.replace("%r","%I:%M:%S %p"),I=I.replace("%Y",""+Z.getFullYear()),I=I.replace("%y",""+Z.getYear()),I=I.replace("%m",L(Z.getMonth()+1,2)),I=I.replace("%d",L(Z.getDate(),2)),I=I.replace("%H",""+L(Z.getHours(),2)),I=I.replace("%M",""+L(Z.getMinutes(),2)),I=I.replace("%S",""+L(Z.getSeconds(),2)),I=I.replace("%I",""+((Z.getHours()+11)%12+1)),I=I.replace("%p",Z.getHours()<12?"AM":"PM"),I=I.replace("%B",""+O.translate(bt[Z.getMonth()])),I=I.replace("%b",""+O.translate(He[Z.getMonth()])),I=I.replace("%A",""+O.translate($e[Z.getDay()])),I=I.replace("%a",""+O.translate(xe[Z.getDay()])),I=I.replace("%%","%"),I};class N{constructor(I,Z){this.tag=I,this.value=Z}static some(I){return new N(!0,I)}static none(){return N.singletonNone}fold(I,Z){return this.tag?Z(this.value):I()}isSome(){return this.tag}isNone(){return!this.tag}map(I){return this.tag?N.some(I(this.value)):N.none()}bind(I){return this.tag?I(this.value):N.none()}exists(I){return this.tag&&I(this.value)}forall(I){return!this.tag||I(this.value)}filter(I){return!this.tag||I(this.value)?this:N.none()}getOr(I){return this.tag?this.value:I}or(I){return this.tag?this:I}getOrThunk(I){return this.tag?this.value:I()}orThunk(I){return this.tag?this:I()}getOrDie(I){if(this.tag)return this.value;throw new Error(I!=null?I:"Called getOrDie on None")}static from(I){return c(I)?N.some(I):N.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(I){this.tag&&I(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}N.singletonNone=new N(!1);const Q=(O,I)=>{for(let Z=0,xe=O.length;Z<xe;Z++){const $e=O[Z];if(I($e,Z))return!0}return!1},$=(O,I)=>{const Z=O.length,xe=new Array(Z);for(let $e=0;$e<Z;$e++){const He=O[$e];xe[$e]=I(He,$e)}return xe},ie=(O,I,Z)=>{for(let xe=0,$e=O.length;xe<$e;xe++){const He=O[xe];if(I(He,xe))return N.some(He);if(Z(He,xe))break}return N.none()},le=(O,I)=>ie(O,I,p),_=Object.hasOwnProperty,Y=(O,I)=>ye(O,I)?N.from(O[I]):N.none(),ye=(O,I)=>_.call(O,I);var we=tinymce.util.Tools.resolve("tinymce.html.Serializer");const Le={'"':""","<":"<",">":">","&":"&","'":"'"},ve=O=>O.replace(/["'<>&]/g,I=>Y(Le,I).getOr(I)),qe=(O,I,Z)=>Q(Z.split(/\s+/),xe=>O.hasClass(I,xe)),st=(O,I)=>we({validate:!0},O.schema).serialize(O.parser.parse(I,{insert:!0})),Je=(O,I)=>()=>{const Z=T(O);u(Z)?Z(I):r(Z)?fetch(Z).then(xe=>{xe.ok&&xe.json().then(I)}):I(Z)},pt=(O,I)=>(b.each(I,(Z,xe)=>{u(Z)&&(Z=Z(xe)),O=O.replace(new RegExp("\\{\\$"+y(xe)+"\\}","g"),Z)}),O),Xe=(O,I)=>{const Z=O.dom,xe=P(O);b.each(Z.select("*",I),$e=>{b.each(xe,(He,bt)=>{Z.hasClass($e,bt)&&u(He)&&He($e)})})},Lt=(O,I,Z)=>{const xe=O.dom,$e=O.selection.getContent();Z=pt(Z,P(O));let He=xe.create("div",{},st(O,Z));const bt=xe.select(".mceTmpl",He);bt&&bt.length>0&&(He=xe.create("div"),He.appendChild(bt[0].cloneNode(!0))),b.each(xe.select("*",He),kt=>{qe(xe,kt,v(O))&&(kt.innerHTML=re(O,M(O))),qe(xe,kt,F(O))&&(kt.innerHTML=re(O,V(O))),qe(xe,kt,D(O))&&(kt.innerHTML=$e)}),Xe(O,He),O.execCommand("mceInsertContent",!1,He.innerHTML),O.addVisual()};var Mt=tinymce.util.Tools.resolve("tinymce.Env");const oe=(O,I)=>{var Z;let xe=st(O,I);if(I.indexOf("<html>")===-1){let $e="";const He=(Z=H(O))!==null&&Z!==void 0?Z:"",bt=te(O)?' crossorigin="anonymous"':"";b.each(O.contentCSS,Ie=>{$e+='<link type="text/css" rel="stylesheet" href="'+O.documentBaseURI.toAbsolute(Ie)+'"'+bt+">"}),He&&($e+='<style type="text/css">'+He+"</style>");const kt=ue(O),Nt=O.dom.encode,se='<script>document.addEventListener && document.addEventListener("click", function(e) {for (var elm = e.target; elm; elm = elm.parentNode) {if (elm.nodeName === "A" && !('+(Mt.os.isMacOS()||Mt.os.isiOS()?"e.metaKey":"e.ctrlKey && !e.altKey")+")) {e.preventDefault();}}}, false);<\/script> ",ne=O.getBody().dir,ke=ne?' dir="'+Nt(ne)+'"':"";xe='<!DOCTYPE html><html><head><base href="'+Nt(O.documentBaseURI.getURI())+'">'+$e+se+'</head><body class="'+Nt(kt)+'"'+ke+">"+xe+"</body></html>"}return pt(xe,E(O))},be=(O,I)=>{const Z=()=>{if(!I||I.length===0){const ne=O.translate("No templates defined.");return O.notificationManager.open({text:ne,type:"info"}),N.none()}return N.from(b.map(I,(ne,ke)=>{const Ie=et=>et.url!==void 0;return{selected:ke===0,text:ne.title,value:{url:Ie(ne)?N.from(ne.url):N.none(),content:Ie(ne)?N.none():N.from(ne.content),description:ne.description}}}))},xe=ne=>$(ne,ke=>({text:ke.text,value:ke.text})),$e=(ne,ke)=>le(ne,Ie=>Ie.text===ke),He=ne=>{O.windowManager.alert("Could not load the specified template.",()=>ne.focus("template"))},bt=ne=>ne.value.url.fold(()=>Promise.resolve(ne.value.content.getOr("")),ke=>fetch(ke).then(Ie=>Ie.ok?Ie.text():Promise.reject())),kt=(ne,ke)=>(Ie,et)=>{if(et.name==="template"){const We=Ie.getData().template;$e(ne,We).each(lt=>{Ie.block("Loading..."),bt(lt).then(wt=>{ke(Ie,lt,wt)}).catch(()=>{ke(Ie,lt,""),Ie.setEnabled("save",!1),He(Ie)})})}},Nt=ne=>ke=>{const Ie=ke.getData();$e(ne,Ie.template).each(et=>{bt(et).then(We=>{O.execCommand("mceInsertTemplate",!1,We),ke.close()}).catch(()=>{ke.setEnabled("save",!1),He(ke)})})},q=ne=>{const ke=xe(ne),Ie=(lt,wt)=>({title:"Insert Template",size:"large",body:{type:"panel",items:lt},initialData:wt,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:Nt(ne),onChange:kt(ne,et)}),et=(lt,wt,ut)=>{const Wt=oe(O,ut),Jt=[{type:"listbox",name:"template",label:"Templates",items:ke},{type:"htmlpanel",html:`<p aria-live="polite">${ve(wt.value.description)}</p>`},{label:"Preview",type:"iframe",name:"preview",sandboxed:!1,transparent:!1}],Dn={template:wt.text,preview:Wt};lt.unblock(),lt.redial(Ie(Jt,Dn)),lt.focus("template")},We=O.windowManager.open(Ie([],{template:"",preview:""}));We.block("Loading..."),bt(ne[0]).then(lt=>{et(We,ne[0],lt)}).catch(()=>{et(We,ne[0],""),We.setEnabled("save",!1),He(We)})};Z().each(q)},de=O=>I=>{be(O,I)},j=O=>{O.addCommand("mceInsertTemplate",d(Lt,O)),O.addCommand("mceTemplate",Je(O,de(O)))},ee=O=>{O.on("PreProcess",I=>{const Z=O.dom,xe=V(O);b.each(Z.select("div",I.node),$e=>{Z.hasClass($e,"mceTmpl")&&(b.each(Z.select("*",$e),He=>{qe(Z,He,F(O))&&(He.innerHTML=re(O,xe))}),Xe(O,$e))})})},ae=O=>I=>{const Z=()=>{I.setEnabled(O.selection.isEditable())};return O.on("NodeChange",Z),Z(),()=>{O.off("NodeChange",Z)}},he=O=>{const I=()=>O.execCommand("mceTemplate");O.ui.registry.addButton("template",{icon:"template",tooltip:"Insert template",onSetup:ae(O),onAction:I}),O.ui.registry.addMenuItem("template",{icon:"template",text:"Insert template...",onSetup:ae(O),onAction:I})};var fe=()=>{i.add("template",O=>{A(O),he(O),j(O),ee(O)})};fe()})();(function(){const i=f=>{let d=f;return{get:()=>d,set:b=>{d=b}}};var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(f,d)=>{f.dispatch("VisualBlocks",{state:d})},n=(f,d,p)=>{f.dom.toggleClass(f.getBody(),"mce-visualblocks"),p.set(!p.get()),t(f,p.get())},s=(f,d,p)=>{f.addCommand("mceVisualBlocks",()=>{n(f,d,p)})},r=f=>d=>d.options.get(f),o=f=>{const d=f.options.register;d("visualblocks_default_state",{processor:"boolean",default:!1})},l=r("visualblocks_default_state"),a=(f,d,p)=>{f.on("PreviewFormats AfterPreviewFormats",y=>{p.get()&&f.dom.toggleClass(f.getBody(),"mce-visualblocks",y.type==="afterpreviewformats")}),f.on("init",()=>{l(f)&&n(f,d,p)})},c=(f,d)=>p=>{p.setActive(d.get());const y=b=>p.setActive(b.state);return f.on("VisualBlocks",y),()=>f.off("VisualBlocks",y)},u=(f,d)=>{const p=()=>f.execCommand("mceVisualBlocks");f.ui.registry.addToggleButton("visualblocks",{icon:"visualblocks",tooltip:"Show blocks",onAction:p,onSetup:c(f,d)}),f.ui.registry.addToggleMenuItem("visualblocks",{text:"Show blocks",icon:"visualblocks",onAction:p,onSetup:c(f,d)})};var h=()=>{e.add("visualblocks",(f,d)=>{o(f);const p=i(!1);s(f,d,p),u(f,p),a(f,d,p)})};h()})();(function(){const i=B=>{let z=B;return{get:()=>z,set:Qe=>{z=Qe}}};var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=B=>({isEnabled:()=>B.get()}),n=(B,z)=>B.dispatch("VisualChars",{state:z}),s=(B,z,me)=>{var Oe;return me(B,z.prototype)?!0:((Oe=B.constructor)===null||Oe===void 0?void 0:Oe.name)===z.name},r=B=>{const z=typeof B;return B===null?"null":z==="object"&&Array.isArray(B)?"array":z==="object"&&s(B,String,(me,Oe)=>Oe.isPrototypeOf(me))?"string":z},o=B=>z=>r(z)===B,l=B=>z=>typeof z===B,a=B=>z=>B===z,c=o("string"),u=o("object"),h=a(null),f=l("boolean"),d=B=>B==null,p=B=>!d(B),y=l("number");class b{constructor(z,me){this.tag=z,this.value=me}static some(z){return new b(!0,z)}static none(){return b.singletonNone}fold(z,me){return this.tag?me(this.value):z()}isSome(){return this.tag}isNone(){return!this.tag}map(z){return this.tag?b.some(z(this.value)):b.none()}bind(z){return this.tag?z(this.value):b.none()}exists(z){return this.tag&&z(this.value)}forall(z){return!this.tag||z(this.value)}filter(z){return!this.tag||z(this.value)?this:b.none()}getOr(z){return this.tag?this.value:z}or(z){return this.tag?this:z}getOrThunk(z){return this.tag?this.value:z()}orThunk(z){return this.tag?this:z()}getOrDie(z){if(this.tag)return this.value;throw new Error(z!=null?z:"Called getOrDie on None")}static from(z){return p(z)?b.some(z):b.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(z){this.tag&&z(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}b.singletonNone=new b(!1);const m=(B,z)=>{const me=B.length,Oe=new Array(me);for(let Qe=0;Qe<me;Qe++){const $t=B[Qe];Oe[Qe]=z($t,Qe)}return Oe},A=(B,z)=>{for(let me=0,Oe=B.length;me<Oe;me++){const Qe=B[me];z(Qe,me)}},v=(B,z)=>{const me=[];for(let Oe=0,Qe=B.length;Oe<Qe;Oe++){const $t=B[Oe];z($t,Oe)&&me.push($t)}return me},F=Object.keys,D=(B,z)=>{const me=F(B);for(let Oe=0,Qe=me.length;Oe<Qe;Oe++){const $t=me[Oe],En=B[$t];z(En,$t)}},E=typeof window!="undefined"?window:Function("return this;")(),P=(B,z)=>{let me=z!=null?z:E;for(let Oe=0;Oe<B.length&&me!==void 0&&me!==null;++Oe)me=me[B[Oe]];return me},T=(B,z)=>{const me=B.split(".");return P(me,z)},M=(B,z)=>T(B,z),V=(B,z)=>{const me=M(B,z);if(me==null)throw new Error(B+" not available on this browser");return me},H=Object.getPrototypeOf,te=B=>V("HTMLElement",B),ue=B=>{const z=T("ownerDocument.defaultView",B);return u(B)&&(te(z).prototype.isPrototypeOf(B)||/^HTML\w*Element$/.test(H(B).constructor.name))},L=1,re=3,N=B=>B.dom.nodeType,Q=B=>B.dom.nodeValue,$=B=>z=>N(z)===B,ie=B=>le(B)&&ue(B.dom),le=$(L),_=$(re),Y=(B,z,me)=>{if(c(me)||f(me)||y(me))B.setAttribute(z,me+"");else throw new Error("Attribute value was not simple")},ye=(B,z,me)=>{Y(B.dom,z,me)},we=(B,z)=>{const me=B.dom.getAttribute(z);return me===null?void 0:me},Le=(B,z)=>{B.dom.removeAttribute(z)},ve=(B,z)=>{const me=we(B,z);return me===void 0||me===""?[]:me.split(" ")},qe=(B,z,me)=>{const Qe=ve(B,z).concat([me]);return ye(B,z,Qe.join(" ")),!0},st=(B,z,me)=>{const Oe=v(ve(B,z),Qe=>Qe!==me);return Oe.length>0?ye(B,z,Oe.join(" ")):Le(B,z),!1},Je=B=>B.dom.classList!==void 0,pt=B=>ve(B,"class"),Xe=(B,z)=>qe(B,"class",z),Lt=(B,z)=>st(B,"class",z),Mt=(B,z)=>{Je(B)?B.dom.classList.add(z):Xe(B,z)},oe=B=>{(Je(B)?B.dom.classList:pt(B)).length===0&&Le(B,"class")},be=(B,z)=>{Je(B)?B.dom.classList.remove(z):Lt(B,z),oe(B)},de=(B,z)=>{const Oe=(z||document).createElement("div");if(Oe.innerHTML=B,!Oe.hasChildNodes()||Oe.childNodes.length>1){const Qe="HTML does not have a single root node";throw new Error(Qe)}return ae(Oe.childNodes[0])},j=(B,z)=>{const Oe=(z||document).createElement(B);return ae(Oe)},ee=(B,z)=>{const Oe=(z||document).createTextNode(B);return ae(Oe)},ae=B=>{if(B==null)throw new Error("Node cannot be null or undefined");return{dom:B}},fe={fromHtml:de,fromTag:j,fromText:ee,fromDom:ae,fromPoint:(B,z,me)=>b.from(B.dom.elementFromPoint(z,me)).map(ae)},O={" ":"nbsp","":"shy"},I=(B,z)=>{let me="";return D(B,(Oe,Qe)=>{me+=Qe}),new RegExp("["+me+"]",z?"g":"")},Z=B=>{let z="";return D(B,me=>{z&&(z+=","),z+="span.mce-"+me}),z},xe=I(O),$e=I(O,!0),He=Z(O),bt="mce-nbsp",kt=B=>B.dom.contentEditable,Nt=B=>'<span data-mce-bogus="1" class="mce-'+O[B]+'">'+B+"</span>",q=B=>B.nodeName.toLowerCase()==="span"&&B.classList.contains("mce-nbsp-wrap"),se=B=>{const z=Q(B);return _(B)&&c(z)&&xe.test(z)},ne=B=>ie(B)&&kt(B)==="false",ke=(B,z)=>{if(ie(B)&&!q(B.dom)){const me=kt(B);if(me==="true")return!0;if(me==="false")return!1}return z},Ie=(B,z,me)=>{let Oe=[];const Qe=B.dom,$t=m(Qe.childNodes,fe.fromDom),En=jt=>q(jt.dom)||!ne(jt);return A($t,jt=>{me&&En(jt)&&z(jt)&&(Oe=Oe.concat([jt])),Oe=Oe.concat(Ie(jt,z,ke(jt,me)))}),Oe},et=(B,z)=>{for(;B.parentNode;){if(B.parentNode===z)return z;B=B.parentNode}},We=B=>B.replace($e,Nt),lt=(B,z)=>{const me=B.dom,Oe=Ie(fe.fromDom(z),se,B.dom.isEditable(z));A(Oe,Qe=>{var $t;const En=Qe.dom.parentNode;if(q(En))Mt(fe.fromDom(En),bt);else{const jt=We(me.encode(($t=Q(Qe))!==null&&$t!==void 0?$t:"")),ni=me.create("div",{},jt);let x;for(;x=ni.lastChild;)me.insertAfter(x,Qe.dom);B.dom.remove(Qe.dom)}})},wt=(B,z)=>{const me=B.dom.select(He,z);A(me,Oe=>{q(Oe)?be(fe.fromDom(Oe),bt):B.dom.remove(Oe,!0)})},ut=B=>{const z=B.getBody(),me=B.selection.getBookmark();let Oe=et(B.selection.getNode(),z);Oe=Oe!==void 0?Oe:z,wt(B,Oe),lt(B,Oe),B.selection.moveToBookmark(me)},Wt=(B,z)=>{n(B,z.get());const me=B.getBody();z.get()===!0?lt(B,me):wt(B,me)},Jt=(B,z)=>{z.set(!z.get());const me=B.selection.getBookmark();Wt(B,z),B.selection.moveToBookmark(me)},Dn=(B,z)=>{B.addCommand("mceVisualChars",()=>{Jt(B,z)})},Zn=B=>z=>z.options.get(B),on=B=>{const z=B.options.register;z("visualchars_default_state",{processor:"boolean",default:!1})},On=Zn("visualchars_default_state"),ei=(B,z)=>{B.on("init",()=>{Wt(B,z)})},Ln=(B,z)=>{let me=null;return{cancel:()=>{h(me)||(clearTimeout(me),me=null)},throttle:(...$t)=>{h(me)&&(me=setTimeout(()=>{me=null,B.apply(null,$t)},z))}}},Un=(B,z)=>{const me=Ln(()=>{ut(B)},300);B.on("keydown",Oe=>{z.get()===!0&&(Oe.keyCode===13?ut(B):me.throttle())}),B.on("remove",me.cancel)},Ai=(B,z)=>me=>{me.setActive(z.get());const Oe=Qe=>me.setActive(Qe.state);return B.on("VisualChars",Oe),()=>B.off("VisualChars",Oe)},Ti=(B,z)=>{const me=()=>B.execCommand("mceVisualChars");B.ui.registry.addToggleButton("visualchars",{tooltip:"Show invisible characters",icon:"visualchars",onAction:me,onSetup:Ai(B,z)}),B.ui.registry.addToggleMenuItem("visualchars",{text:"Show invisible characters",icon:"visualchars",onAction:me,onSetup:Ai(B,z)})};var ti=()=>{e.add("visualchars",B=>{on(B);const z=i(On(B));return Dn(B,z),Ti(B,z),Un(B,z),ei(B,z),t(z)})};ti()})();(function(){var i=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(oe=>be=>oe===be)(null),n=oe=>oe,s=(oe,be)=>{const de=oe.length,j=new Array(de);for(let ee=0;ee<de;ee++){const ae=oe[ee];j[ee]=be(ae,ee)}return j},o={aletter:"[A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-׳ؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆༀཀ-ཇཉ-ཬྈ-ྌႠ-Ⴥა-ჺჼᄀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᨀ-ᨖᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᯀ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⒶ-ⓩⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〻〼ㄅ-ㄭㄱ-ㆎㆠ-ㆺꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐꞑꞠ-ꞩꟺ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zᅠ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]",midnumlet:"[-'\\.‘’․﹒'.]",midletter:"[:··״‧︓﹕:]",midnum:"[±+*/,;;։،؍٬߸⁄︐︔﹐﹔,;]",numeric:"[0-9٠-٩٫۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹]",cr:"\\r",lf:"\\n",newline:"[\v\f
\u2028\u2029]",extend:"[̀-ͯ҃-҉֑-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ऀ-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఁ-ఃా-ౄె-ైొ-్ౕౖౢౣಂಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣംഃാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳា-៓៝᠋-᠍ᢩᤠ-ᤫᤰ-᤻ᦰ-ᧀᧈᧉᨗ-ᨛᩕ-ᩞ᩠-᩿᩼ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-᯦᮪-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ᷀-ᷦ᷼-᷿⃐-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯-꙲꙼꙽꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣠-꣱ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꨩ-ꨶꩃꩌꩍꩻꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꯣ-ꯪ꯬꯭ﬞ︀-️︠-゙゚︦]",format:"[-឴឵---\uFEFF-]",katakana:"[〱-〵゛゜゠-ヺー-ヿㇰ-ㇿ㋐-㋾㌀-㍗ヲ-ン]",extendnumlet:"[=_‿⁀⁔︳︴﹍-﹏_∀-⋿<>]",punctuation:"[~№|!-*+-\\/:;?@\\[-`{}¡«·»¿;·՚-՟։֊־׀׃׆׳״؉؊،؍؛؞؟٪-٭۔܀-܍߷-߹࠰-࠾࡞।॥॰෴๏๚๛༄-༒༺-༽྅࿐-࿔࿙࿚၊-၏჻፡-፨᐀᙭᙮᚛᚜᛫-᛭᜵᜶។-៖៘-៚᠀-᠊᥄᥅᨞᨟᪠-᪦᪨-᪭᭚-᭠᯼-᯿᰻-᰿᱾᱿᳓‐-‧‰-⁃⁅-⁑⁓-⁞⁽⁾₍₎〈〉❨-❵⟅⟆⟦-⟯⦃-⦘⧘-⧛⧼⧽⳹-⳼⳾⳿⵰⸀-⸮⸰⸱、-〃〈-】〔-〟〰〽゠・꓾꓿꘍-꘏꙳꙾꛲-꛷꡴-꡷꣎꣏꣸-꣺꤮꤯꥟꧁-꧍꧞꧟꩜-꩟꫞꫟꯫﴾﴿︐-︙︰-﹒﹔-﹡﹣﹨﹪﹫!-#%-*,-/:;?@[-]_{}⦅-・]"},l={ALETTER:0,MIDNUMLET:1,MIDLETTER:2,MIDNUM:3,NUMERIC:4,CR:5,LF:6,NEWLINE:7,EXTEND:8,FORMAT:9,KATAKANA:10,EXTENDNUMLET:11,AT:12,OTHER:13},a=[new RegExp(o.aletter),new RegExp(o.midnumlet),new RegExp(o.midletter),new RegExp(o.midnum),new RegExp(o.numeric),new RegExp(o.cr),new RegExp(o.lf),new RegExp(o.newline),new RegExp(o.extend),new RegExp(o.format),new RegExp(o.katakana),new RegExp(o.extendnumlet),new RegExp("@")],c="",u=new RegExp("^"+o.punctuation+"$"),h=/^\s+$/,f=a,d=l.OTHER,p=oe=>{let be=d;const de=f.length;for(let j=0;j<de;++j){const ee=f[j];if(ee&&ee.test(oe)){be=j;break}}return be},y=oe=>{const be={};return de=>{if(be[de])return be[de];{const j=oe(de);return be[de]=j,j}}},b=oe=>{const be=y(p);return s(oe,be)},m=(oe,be)=>{const de=oe[be],j=oe[be+1];if(be<0||be>oe.length-1&&be!==0||de===l.ALETTER&&j===l.ALETTER)return!1;const ee=oe[be+2];if(de===l.ALETTER&&(j===l.MIDLETTER||j===l.MIDNUMLET||j===l.AT)&&ee===l.ALETTER)return!1;const ae=oe[be-1];return(de===l.MIDLETTER||de===l.MIDNUMLET||j===l.AT)&&j===l.ALETTER&&ae===l.ALETTER||(de===l.NUMERIC||de===l.ALETTER)&&(j===l.NUMERIC||j===l.ALETTER)||(de===l.MIDNUM||de===l.MIDNUMLET)&&j===l.NUMERIC&&ae===l.NUMERIC||de===l.NUMERIC&&(j===l.MIDNUM||j===l.MIDNUMLET)&&ee===l.NUMERIC||(de===l.EXTEND||de===l.FORMAT)&&(j===l.ALETTER||j===l.NUMERIC||j===l.KATAKANA||j===l.EXTEND||j===l.FORMAT)||(j===l.EXTEND||j===l.FORMAT&&(ee===l.ALETTER||ee===l.NUMERIC||ee===l.KATAKANA||ee===l.EXTEND||ee===l.FORMAT))&&(de===l.ALETTER||de===l.NUMERIC||de===l.KATAKANA||de===l.EXTEND||de===l.FORMAT)||de===l.CR&&j===l.LF?!1:de===l.NEWLINE||de===l.CR||de===l.LF||j===l.NEWLINE||j===l.CR||j===l.LF?!0:!(de===l.KATAKANA&&j===l.KATAKANA||j===l.EXTENDNUMLET&&(de===l.ALETTER||de===l.NUMERIC||de===l.KATAKANA||de===l.EXTENDNUMLET)||de===l.EXTENDNUMLET&&(j===l.ALETTER||j===l.NUMERIC||j===l.KATAKANA)||de===l.AT)},A=c,v=h,F=u,D=oe=>oe==="http"||oe==="https",E=(oe,be)=>{let de;for(de=be;de<oe.length&&!v.test(oe[de]);de++);return de},P=(oe,be)=>{const de=E(oe,be+1);return oe.slice(be+1,de).join(A).substr(0,3)==="://"?de:be},T=(oe,be,de,j)=>{const ee=[],ae=[];let he=[];for(let fe=0;fe<de.length;++fe)if(he.push(oe[fe]),m(de,fe)){const O=be[fe];if((j.includeWhitespace||!v.test(O))&&(j.includePunctuation||!F.test(O))){const I=fe-he.length+1,Z=fe+1,xe=be.slice(I,Z).join(A);if(D(xe)){const $e=P(be,fe),He=oe.slice(Z,$e);Array.prototype.push.apply(he,He),fe=$e}ee.push(he),ae.push({start:I,end:Z})}he=[]}return{words:ee,indices:ae}},M=()=>({includeWhitespace:!1,includePunctuation:!1}),V=(oe,be,de)=>{de=Fe(Fe({},M()),de);const j=s(oe,be),ee=b(j);return T(oe,j,ee,de)},te=(oe,be,de)=>V(oe,be,de).words,ue=oe=>oe.replace(/\uFEFF/g,"");var L=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");const re=(oe,be)=>{const de=be.getBlockElements(),j=be.getVoidElements(),ee=I=>de[I.nodeName]||j[I.nodeName],ae=[];let he="";const fe=new L(oe,oe);let O;for(;O=fe.next();)O.nodeType===3?he+=ue(O.data):ee(O)&&he.length&&(ae.push(he),he="");return he.length&&ae.push(he),ae},N=oe=>oe.replace(/\u200B/g,""),Q=oe=>oe.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"_").length,$=(oe,be)=>{const de=N(re(oe,be).join(`
- `));return te(de.split(""),n).length},ie=(oe,be)=>{const de=re(oe,be).join("");return Q(de)},le=(oe,be)=>{const de=re(oe,be).join("").replace(/\s/g,"");return Q(de)},_=(oe,be)=>()=>be(oe.getBody(),oe.schema),Y=(oe,be)=>()=>be(oe.selection.getRng().cloneContents(),oe.schema),ye=oe=>_(oe,$),we=oe=>({body:{getWordCount:ye(oe),getCharacterCount:_(oe,ie),getCharacterCountWithoutSpaces:_(oe,le)},selection:{getWordCount:Y(oe,$),getCharacterCount:Y(oe,ie),getCharacterCountWithoutSpaces:Y(oe,le)},getCount:ye(oe)}),Le=(oe,be)=>{oe.windowManager.open({title:"Word Count",body:{type:"panel",items:[{type:"table",header:["Count","Document","Selection"],cells:[["Words",String(be.body.getWordCount()),String(be.selection.getWordCount())],["Characters (no spaces)",String(be.body.getCharacterCountWithoutSpaces()),String(be.selection.getCharacterCountWithoutSpaces())],["Characters",String(be.body.getCharacterCount()),String(be.selection.getCharacterCount())]]}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}]})},ve=(oe,be)=>{oe.addCommand("mceWordCount",()=>Le(oe,be))},qe=(oe,be)=>{let de=null;return{cancel:()=>{t(de)||(clearTimeout(de),de=null)},throttle:(...ae)=>{t(de)&&(de=setTimeout(()=>{de=null,oe.apply(null,ae)},be))}}};var st=tinymce.util.Tools.resolve("tinymce.util.Delay");const Je=(oe,be)=>{oe.dispatch("wordCountUpdate",{wordCount:{words:be.body.getWordCount(),characters:be.body.getCharacterCount(),charactersWithoutSpaces:be.body.getCharacterCountWithoutSpaces()}})},pt=(oe,be)=>{Je(oe,be)},Xe=(oe,be,de)=>{const j=qe(()=>pt(oe,be),de);oe.on("init",()=>{pt(oe,be),st.setEditorTimeout(oe,()=>{oe.on("SetContent BeforeAddUndo Undo Redo ViewUpdate keyup",j.throttle)},0),oe.on("remove",j.cancel)})},Lt=oe=>{const be=()=>oe.execCommand("mceWordCount");oe.ui.registry.addButton("wordcount",{tooltip:"Word count",icon:"character-count",onAction:be}),oe.ui.registry.addMenuItem("wordcount",{text:"Word count",icon:"character-count",onAction:be})};var Mt=(oe=300)=>{i.add("wordcount",be=>{const de=we(be);return ve(be,de),Lt(be),Xe(be,de,oe),de})};Mt()})();const ES=Gt({name:"TinymceImageUpload",components:{Upload:Gg},props:{fullscreen:{type:Boolean},disabled:{type:Boolean,default:!1}},emits:["uploading","done","error"],setup(i,{emit:e}){let t=!1;const{uploadUrl:n}=Bg(),s=Rg(),{t:r}=In(),{prefixCls:o}=ll("tinymce-img-upload"),l=dt(()=>{const{disabled:u}=i;return{disabled:u}}),a={Authorization:s.getToken};function c(u){var y,b;const h=u.file,f=h==null?void 0:h.status,d=(b=(y=h==null?void 0:h.response)==null?void 0:y.data)==null?void 0:b.url,p=h==null?void 0:h.name;f==="uploading"?t||(e("uploading",p),t=!0):f==="done"?(e("done",p,d),t=!1):f==="error"&&(e("error"),t=!1)}return{prefixCls:o,handleChange:c,uploadUrl:n,headerData:a,t:r,getButtonProps:l}}});function FS(i,e,t,n,s,r){const o=vt("a-button"),l=vt("Upload");return it(),dn("div",{class:Bo([i.prefixCls,{fullscreen:i.fullscreen}])},[rt(l,{name:"file",multiple:"",onChange:i.handleChange,action:i.uploadUrl,headers:i.headerData,showUploadList:!1,accept:".jpg,.jpeg,.gif,.png,.webp"},{default:ft(()=>[rt(o,cn({type:"primary",preIcon:"material-symbols:image-sharp",class:"mt-1",iconSize:14},Fe({},i.getButtonProps)),{default:ft(()=>[Vn(Yn(i.t("component.upload.imgUpload")),1)]),_:1},16)]),_:1},8,["onChange","action","headers"])],2)}const PS=Mn(ES,[["render",FS],["__scopeId","data-v-5bf13606"]]),BS=["advlist","anchor","autolink","autosave","autoresize","code","codesample","directionality","fullscreen","insertdatetime","link","lists","media","nonbreaking","pagebreak","preview","save","searchreplace","visualblocks","visualchars","wordcount","image"],RS=["fontsizeselect lineheight searchreplace bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample","hr bullist numlist link preview anchor pagebreak insertdatetime media image forecolor backcolor fullscreen"],NS=["onActivate","onAddUndo","onBeforeAddUndo","onBeforeExecCommand","onBeforeGetContent","onBeforeRenderUI","onBeforeSetContent","onBeforePaste","onBlur","onChange","onClearUndos","onClick","onContextMenu","onCopy","onCut","onDblclick","onDeactivate","onDirty","onDrag","onDragDrop","onDragEnd","onDragGesture","onDragOver","onDrop","onExecCommand","onFocus","onFocusIn","onFocusOut","onGetContent","onHide","onInit","onKeyDown","onKeyPress","onKeyUp","onLoadContent","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onNodeChange","onObjectResizeStart","onObjectResized","onObjectSelected","onPaste","onPostProcess","onPostRender","onPreProcess","onProgressState","onRedo","onRemove","onReset","onSaveContent","onSelectionChange","onSetAttrib","onSetContent","onShow","onSubmit","onUndo","onVisualAid"],IS=i=>NS.indexOf(i)!==-1,LS=(i,e,t)=>{Object.keys(e).filter(IS).forEach(n=>{const s=e[n];typeof s=="function"&&(n==="onInit"?s(i,t):t.on(n.substring(2),r=>s(r,t)))})},$S={options:{type:Object,default:()=>({})},value:{type:String},toolbar:{type:Array,default:RS},plugins:{type:Array,default:BS},modelValue:{type:String},height:{type:[Number,String],required:!1,default:400},width:{type:[Number,String],required:!1,default:"auto"},showImageUpload:{type:Boolean,default:!0}},_S=Gt({name:"Tinymce",components:{ImgUpload:PS},inheritAttrs:!1,props:$S,emits:["change","update:modelValue","inited","init-error"],setup(i,{emit:e,attrs:t}){const n=ze(null),s=ze(!1),r=ze(gu("tiny-vue")),o=ze(null),{prefixCls:l}=ll("tinymce-container"),a=mf(),c=dt(()=>i.modelValue),u=dt(()=>{const T=i.width;return cl(T)?`${T}px`:T}),h=dt(()=>a.getDarkMode==="light"?"oxide":"oxide-dark"),f=dt(()=>a.getDarkMode==="light"?"default":"dark"),d=dt(()=>{const T=Ng().getLocale.value;return T==="zh_CN"?"zh-Hans":T}),p=dt(()=>{const{height:T,options:M,toolbar:V,plugins:H}=i,te="/";return qt(Fe({selector:`#${G(r)}`,height:T,toolbar:V,menubar:"file edit insert view format table",plugins:H,language_url:te+"resource/tinymce/langs/"+d.value+".js",language:d.value,branding:!1,default_link_target:"_blank",link_title:!1,object_resizing:!1,auto_focus:!0,skin:h.value,promotion:!1,model_url:te+"resource/tinymce/models/dom/model.min.js",skin_url:te+"resource/tinymce/skins/ui/"+h.value,content_css:te+"resource/tinymce/skins/content/"+f.value+"/content.min.css"},M),{setup:ue=>{n.value=ue,ue.on("init",L=>A(L))}})}),y=dt(()=>{const{options:T}=i,M=T&&Reflect.get(T,"readonly"),V=G(n);return V&&V.mode.set(M?"readonly":"design"),M!=null?M:!1});mt(()=>t.disabled,()=>{const T=G(n);T&&T.mode.set(t.disabled?"readonly":"design")}),p0(()=>{p.value.inline||(r.value=gu("tiny-vue")),Ir(()=>{setTimeout(()=>{m()},30)})}),ff(()=>{b()}),Ag(()=>{b()});function b(){var T,M;Ml!==null&&((M=(T=Ml)==null?void 0:T.remove)==null||M.call(T,G(p).selector))}function m(){const T=G(o);T&&(T.style.visibility=""),Ml.init(G(p)).then(M=>{e("inited",M)}).catch(M=>{e("init-error",M)})}function A(T){const M=G(n);if(!M)return;const V=i.modelValue||"";M.setContent(V),F(M),LS(T,t,G(n))}function v(T,M,V){T&&typeof M=="string"&&M!==V&&M!==T.getContent({format:t.outputFormat})&&T.setContent(M)}function F(T){const M=t.modelEvents?t.modelEvents:null,V=Array.isArray(M)?M.join(" "):M;mt(()=>i.modelValue,(H,te)=>{v(T,H,te)}),mt(()=>i.value,(H,te)=>{v(T,H,te)},{immediate:!0}),T.on(V||"change keyup undo redo",()=>{const H=T.getContent({format:t.outputFormat});e("update:modelValue",H),e("change",H)}),T.on("FullscreenStateChanged",H=>{s.value=H.state})}function D(T){var H;const M=G(n);if(!M)return;M.execCommand("mceInsertContent",!1,P(T));const V=(H=M==null?void 0:M.getContent())!=null?H:"";v(M,V)}function E(T,M){var ue,L;const V=G(n);if(!V)return;const H=(ue=V==null?void 0:V.getContent())!=null?ue:"",te=(L=H==null?void 0:H.replace(P(T),`<img src="${M}"/>`))!=null?L:"";v(V,te)}function P(T){return`[uploading:${T}]`}return{prefixCls:l,containerWidth:u,initOptions:p,tinymceContent:c,elRef:o,tinymceId:r,handleImageUploading:D,handleDone:E,editorRef:n,fullscreen:s,disabled:y}}}),zS=["id"];function VS(i,e,t,n,s,r){const o=vt("ImgUpload");return it(),dn("div",{class:Bo(i.prefixCls),style:Xa({width:i.containerWidth})},[i.showImageUpload?df((it(),Bt(o,{key:0,fullscreen:i.fullscreen,onUploading:i.handleImageUploading,onDone:i.handleDone,disabled:i.disabled},null,8,["fullscreen","onUploading","onDone","disabled"])),[[pf,i.editorRef]]):rs("",!0),i.initOptions.inline?Sn(i.$slots,"default",{key:2}):(it(),dn("textarea",{key:1,id:i.tinymceId,ref:"elRef",style:{visibility:"hidden"}},null,8,zS))],6)}const HS=Mn(_S,[["render",VS]]),WS=gf(HS),Ye=new Map;Ye.set("Input",Xs);Ye.set("InputGroup",Xs.Group);Ye.set("InputPassword",Xs.Password);Ye.set("InputSearch",Xs.Search);Ye.set("InputTextArea",Xs.TextArea);Ye.set("InputNumber",Yg);Ye.set("AutoComplete",Xg);Ye.set("ImageUpload",l0);Ye.set("Select",al);Ye.set("ApiSelect",T0);Ye.set("ApiTree",O0);Ye.set("TreeSelect",yf);Ye.set("ApiTreeSelect",P0);Ye.set("ApiRadioGroup",v0);Ye.set("Switch",Jg);Ye.set("RadioButtonGroup",S0);Ye.set("RadioGroup",Fs.Group);Ye.set("Checkbox",xf);Ye.set("CheckboxGroup",xf.Group);Ye.set("ApiCascader",B0);Ye.set("Cascader",wf);Ye.set("Slider",Qg);Ye.set("Rate",Zg);Ye.set("Transfer",vf);Ye.set("ApiTransfer",I0);Ye.set("DatePicker",$r);Ye.set("MonthPicker",$r.MonthPicker);Ye.set("RangePicker",$r.RangePicker);Ye.set("WeekPicker",$r.WeekPicker);Ye.set("TimePicker",Qa);Ye.set("TimeRangePicker",Qa.TimeRangePicker);Ye.set("StrengthMeter",c0);Ye.set("IconPicker",rb);Ye.set("InputCountDown",Pg);Ye.set("Upload",a0);Ye.set("Divider",Sf);Ye.set("CropperAvatar",d0);Ye.set("BasicTitle",Cf);Ye.set("ApiMultipleSelect",q0);Ye.set("DictionarySelect",G0);Ye.set("CodeEditor",OS);Ye.set("Tinymce",WS);Ye.set("SimpleTimePicker",_0);Ye.set("SimpleRangePicker",H0);const{t:Zl}=In();function uf(i){return i.includes("Input")||i.includes("Complete")?Zl("common.inputText"):i.includes("Picker")||i.includes("Select")||i.includes("Cascader")||i.includes("Checkbox")||i.includes("Radio")||i.includes("Switch")?Zl("common.chooseText"):""}const jS=["DatePicker","MonthPicker","WeekPicker","TimePicker"];function qS(){return[...jS,"RangePicker"]}function US(i,e,t){Reflect.has(i,"type")||(["DatePicker","MonthPicker","WeekPicker","TimePicker"].includes(e)?i.type=t?"string":"object":["RangePicker","Upload","CheckboxGroup","TimePicker"].includes(e)?i.type="array":["InputNumber"].includes(e)&&(i.type="number"))}const Rm=["Input","InputPassword","InputNumber","InputSearch","InputTextArea"];function KS(i,e){return i&&Rm.includes(i)&&i!=="InputNumber"&&e&&cl(e)?`${e}`:e}const Nm=qS(),hf=["Upload","ApiTransfer","ApiTree","ApiSelect","ApiMultipleSelect","ApiTreeSelect","ApiRadioGroup","ApiCascader","AutoComplete","RadioButtonGroup","ImageUpload","SimpleTimePicker","SimpleRangePicker"],GS=["Divider","BasicTitle"];function yr(i){return GS.includes(i||"")}function YS(i,e){return dt(()=>{const t=G(i),{labelCol:n={},wrapperCol:s={}}=t.itemProps||{},{labelWidth:r,disabledLabelWidth:o}=t,{labelWidth:l,labelCol:a,wrapperCol:c,layout:u}=G(e);if(!l&&!r&&!a||o)return n.style={textAlign:"left"},{labelCol:n,wrapperCol:s};let h=r||l;const f=Fe(Fe({},a),n),d=Fe(Fe({},c),s);return h&&(h=cl(h)?`${h}px`:h),{labelCol:Fe({style:{width:h}},f),wrapperCol:Fe({style:{width:u==="vertical"?"100%":`calc(100% - ${h})`}},d)}})}function ko(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Object]"&&!Mg(i)}const XS=Gt({name:"BasicFormItem",inheritAttrs:!1,props:{schema:{type:Object,default:()=>({})},formProps:{type:Object,default:()=>({})},allDefaultValues:{type:Object,default:()=>({})},formModel:{type:Object,default:()=>({})},setFormModel:{type:Function,default:null},tableAction:{type:Object},formActionType:{type:Object},isAdvanced:{type:Boolean}},setup(i,{slots:e}){const{t}=In(),{schema:n,formProps:s}=Tg(i),r=YS(n,s),o=dt(()=>{const{allDefaultValues:y,formModel:b,schema:m}=i,{mergeDynamicData:A}=i.formProps;return{field:m.field,model:b,values:Fe(Fe(Fe({},A),y),b),schema:m}}),l=dt(()=>{var F;const{schema:y,tableAction:b,formModel:m,formActionType:A}=i;let{componentProps:v={}}=y;return Et(v)&&(v=(F=v({schema:y,tableAction:b,formModel:m,formActionType:A}))!=null?F:{}),yr(y.component)&&(v=Object.assign({type:"horizontal"},{orientation:"left",plain:!0},v)),v}),a=dt(()=>{const{disabled:y}=i.formProps,{dynamicDisabled:b}=i.schema,{disabled:m=!1}=G(l);let A=!!y||m;return Cs(b)&&(A=b),Et(b)&&(A=b(G(o))),A}),c=dt(()=>{const{readonly:y}=i.formProps,{dynamicReadonly:b}=i.schema,{readonly:m=!1}=G(l);let A=y||m;return Cs(b)&&(A=b),Et(b)&&(A=b(G(o))),A});function u(){const{show:y,ifShow:b}=i.schema,{showAdvancedButton:m}=i.formProps,A=m&&Cs(i.isAdvanced)?i.isAdvanced:!0;let v=!0,F=!0;return Cs(y)&&(v=y),Cs(b)&&(F=b),Et(y)&&(v=y(G(o))),Et(b)&&(F=b(G(o))),v=v&&A,{isShow:v,isIfShow:F}}function h(){var L;const{rules:y=[],component:b,rulesMessageJoinLabel:m,label:A,dynamicRules:v,required:F}=i.schema;if(Et(v))return v(G(o));let D=_i(y);const{rulesMessageJoinLabel:E}=i.formProps,T=(Reflect.has(i.schema,"rulesMessageJoinLabel")?m:E)?Et(A)?"":A:"",M=b?uf(b)+T:T;function V(re,N){const Q=re.message||M;return N===void 0||e0(N)||Array.isArray(N)&&N.length===0||typeof N=="string"&&N.trim()===""||typeof N=="object"&&Reflect.has(N,"checked")&&Reflect.has(N,"halfChecked")&&Array.isArray(N.checked)&&Array.isArray(N.halfChecked)&&N.checked.length===0&&N.halfChecked.length===0?Promise.reject(Q):Promise.resolve()}const H=Et(F)?F(G(o)):F;if(H)if(!D||D.length===0){const re=hf.includes(b||"Input")?"blur":"change";D=[{required:H,validator:V,trigger:re}]}else D.findIndex(N=>Reflect.has(N,"required"))===-1&&D.push({required:H,validator:V});const te=D.findIndex(re=>Reflect.has(re,"required")&&!Reflect.has(re,"validator"));if(te!==-1){const re=D[te],{isShow:N}=u();if(N||(re.required=!1),b){re.message=re.message||M,(b.includes("Input")||b.includes("Textarea"))&&(re.whitespace=!0);const Q=(L=G(l))==null?void 0:L.valueFormat;US(re,b,Q)}}const ue=D.findIndex(re=>re.max);return ue!==-1&&!D[ue].validator&&(D[ue].message=D[ue].message||t("component.form.maxTip",[D[ue].max])),D}function f(){var re;if(!b0(i.schema))return null;const{renderComponentContent:y,component:b,field:m,changeEvent:A="change",valueField:v}=i.schema,F=b&&["Switch","Checkbox"].includes(b),D=`on${t0(A)}`,E={[D]:(...N)=>{const[Q]=N;V[D]&&V[D](...N);const $=Q?Q.target:null,ie=$?F?$.checked:$.value:Q;i.setFormModel(m,ie,i.schema)}},P=Ye.get(b),{autoSetPlaceHolder:T,size:M}=i.formProps,V=qt(Fe({allowClear:!0,size:M},G(l)),{disabled:G(a),readonly:G(c)});!V.disabled&&T&&b!=="RangePicker"&&b&&(V.placeholder=((re=G(l))==null?void 0:re.placeholder)||uf(b)),V.codeField=m,V.formValues=G(o);const te={[v||(F?"checked":"value")]:i.formModel[m]},ue=Fe(Fe(Fe({},V),E),te);if(!y)return rt(P,ue,null);const L=Et(y)?Fe({},y(G(o),{disabled:G(a),readonly:G(c)})):{default:()=>y};return rt(P,ue,ko(L)?L:{default:()=>[L]})}function d(){const{label:y,helpMessage:b,helpComponentProps:m,subLabel:A}=i.schema,v=Et(y)?y(G(o)):y,F=A?rt("span",null,[v,Vn(" "),rt("span",{class:"text-secondary"},[A])]):v,D=Et(b)?b(G(o)):b;return!D||Array.isArray(D)&&D.length===0?F:rt("span",null,[F,rt(h0,cn({placement:"top",class:"mx-1",text:D},m),null)])}function p(){const{itemProps:y,slot:b,render:m,field:A,suffix:v,component:F}=i.schema,{labelCol:D,wrapperCol:E}=G(r),{colon:P}=i.formProps,T={disabled:G(a),readonly:G(c)};if(F==="Divider"){let M;return rt(Ro,{span:24},{default:()=>[rt(Sf,G(l),ko(M=d())?M:{default:()=>[M]})]})}else if(F==="BasicTitle"){let M;return rt(No.Item,{labelCol:D,wrapperCol:E,name:A,class:{"suffix-item":!!v}},{default:()=>[rt(Cf,G(l),ko(M=d())?M:{default:()=>[M]})]})}else{const M=()=>b?fu(e,b,G(o),T):m?m(G(o),T):f(),V=!!v,H=Et(v)?v(G(o)):v;return F&&hf.includes(F)&&i.schema&&(i.schema.itemProps=Fe({autoLink:!1},i.schema.itemProps)),rt(No.Item,cn({name:A,colon:P,class:{"suffix-item":V}},y,{label:d(),rules:h(),labelCol:D,wrapperCol:E}),{default:()=>[rt("div",{style:"display:flex"},[rt("div",{style:"flex:1;"},[M()]),V&&rt("span",{class:"suffix"},[H])])]})}}return()=>{let y;const{colProps:b={},colSlot:m,renderColContent:A,component:v,slot:F}=i.schema;if(!(v&&Ye.has(v)||F))return null;const{baseColProps:D={}}=i.formProps,E=Fe(Fe({},D),b),{isIfShow:P,isShow:T}=u(),M=G(o),V={disabled:G(a),readonly:G(c)};return P&&df(rt(Ro,E,ko(y=m?fu(e,m,M,V):A?A(M,V):p())?y:{default:()=>[y]}),[[pf,T]])}}}),Im=Symbol();function JS(i){return Ig(i,Im)}function QS(){return Lg(Im)}const ZS=Gt({name:"BasicFormAction",components:{FormItem:No.Item,Button:$g,BasicArrow:f0,[Ro.name]:Ro},props:{showActionButtonGroup:Ee.bool.def(!0),showResetButton:Ee.bool.def(!0),showSubmitButton:Ee.bool.def(!0),showAdvancedButton:Ee.bool.def(!0),resetButtonOptions:{type:Object,default:()=>({})},submitButtonOptions:{type:Object,default:()=>({})},actionColOptions:{type:Object,default:()=>({})},actionSpan:Ee.number.def(6),isAdvanced:Ee.bool,hideAdvanceBtn:Ee.bool},emits:["toggle-advanced"],setup(i,{emit:e}){const{t}=In(),n=dt(()=>{const{showAdvancedButton:l,actionSpan:a,actionColOptions:c}=i,u=24-a,h=l?{span:u<6?24:u}:{};return Fe(Fe({style:{textAlign:"right"},span:l?6:4},h),c)}),s=dt(()=>Object.assign({text:t("common.resetText")},i.resetButtonOptions)),r=dt(()=>Object.assign({text:t("common.queryText")},i.submitButtonOptions));function o(){e("toggle-advanced")}return Fe({t,actionColOpt:n,getResetBtnOptions:s,getSubmitBtnOptions:r,toggleAdvanced:o},QS())}});function eC(i,e,t,n,s,r){const o=vt("Button"),l=vt("BasicArrow"),a=vt("FormItem"),c=vt("a-col");return i.showActionButtonGroup?(it(),Bt(c,Wi(cn({key:0},i.actionColOpt)),{default:ft(()=>[$i("div",{style:Xa([{width:"100%"},{textAlign:i.actionColOpt.style.textAlign}])},[rt(a,null,{default:ft(()=>[Sn(i.$slots,"resetBefore"),i.showResetButton?(it(),Bt(o,cn({key:0,type:"default",class:"mr-2"},i.getResetBtnOptions,{onClick:i.resetAction}),{default:ft(()=>[Vn(Yn(i.getResetBtnOptions.text),1)]),_:1},16,["onClick"])):rs("",!0),Sn(i.$slots,"submitBefore"),i.showSubmitButton?(it(),Bt(o,cn({key:1,type:"primary",class:"mr-2"},i.getSubmitBtnOptions,{onClick:i.submitAction}),{default:ft(()=>[Vn(Yn(i.getSubmitBtnOptions.text),1)]),_:1},16,["onClick"])):rs("",!0),Sn(i.$slots,"advanceBefore"),i.showAdvancedButton&&!i.hideAdvanceBtn?(it(),Bt(o,{key:2,type:"link",size:"small",onClick:i.toggleAdvanced},{default:ft(()=>[Vn(Yn(i.isAdvanced?i.t("component.form.putAway"):i.t("component.form.unfold"))+" ",1),rt(l,{class:"ml-1",expand:!i.isAdvanced,up:""},null,8,["expand"])]),_:1},8,["onClick"])):rs("",!0),Sn(i.$slots,"advanceAfter")]),_:3})],4)]),_:3},16)):rs("",!0)}const tC=Mn(ZS,[["render",eC]]);function nC(i,e,t){const n=/^\[(.+)\]$/;if(n.test(i)){const s=i.match(n);if(s&&s[1]){const r=s[1].split(",");return e=Array.isArray(e)?e:[e],r.forEach((o,l)=>{us(t,o.trim(),e[l])}),!0}}}function iC(i,e,t){const n=/^\{(.+)\}$/;if(n.test(i)){const s=i.match(n);if(s&&s[1]){const r=s[1].split(",");return e=Bi(e)?e:{},r.forEach(o=>{us(t,o.trim(),e[o.trim()])}),!0}}}function sC({defaultValueRef:i,getSchema:e,formModel:t,getProps:n}){function s(a){var u,h;if(!Bi(a))return{};const c={};for(const f of Object.entries(a)){let[,d]=f;const[p]=f;if(!p||cs(d)&&d.length===0||Et(d))continue;const y=G(n).transformDateFunc;Bi(d)&&(d=y==null?void 0:y(d)),cs(d)&&((u=d[0])!=null&&u.format)&&((h=d[1])!=null&&h.format)&&(d=d.map(b=>y==null?void 0:y(b))),hr(d)&&(d=d.trim()),!nC(p,d,c)&&!iC(p,d,c)&&us(c,p,d)}return r(c)}function r(a){const c=G(n).fieldMapToTime;if(!c||!Array.isArray(c))return a;for(const[u,[h,f],d="YYYY-MM-DD"]of c){if(!u||!h||!f)continue;if(!Cn(a,u)){pu(a,u);continue}const[p,y]=Cn(a,u),[b,m]=Array.isArray(d)?d:[d,d];!fr(p)&&!mu(p)&&us(a,h,o(p,b)),!fr(y)&&!mu(y)&&us(a,f,o(y,m)),pu(a,u)}return a}function o(a,c){return c==="timestamp"?yi(a).unix():c==="timestampStartDay"?yi(a).startOf("day").unix():yi(a).format(c)}function l(){const a=G(e),c={};a.forEach(u=>{const{defaultValue:h,defaultValueObj:f}=u,d=Object.keys(f||{});d.length&&d.map(p=>{c[p]=f[p],t[p]===void 0&&(t[p]=f[p])}),fr(h)||(c[u.field]=h,t[u.field]===void 0&&(t[u.field]=h))}),i.value=_i(c)}return{handleFormValues:s,initDefault:l}}const ts=24;function rC({advanceState:i,emit:e,getProps:t,getSchema:n,formModel:s,defaultValueRef:r}){const o=Dg(),{realWidthRef:l,screenEnum:a,screenRef:c}=_g(),u=dt(()=>{if(!i.isAdvanced)return 0;const b=G(t).emptySpan||0;if(cl(b))return b;if(Bi(b)){const{span:m=0}=b,A=G(c);return b[A.toLowerCase()]||m||0}return 0}),h=Ja(p,30);mt([()=>G(n),()=>i.isAdvanced,()=>G(l)],()=>{const{showAdvancedButton:b}=G(t);b&&h()},{immediate:!0});function f(b,m=0,A=!1){const v=G(l),F=parseInt(b.md)||parseInt(b.xs)||parseInt(b.sm)||b.span||ts,D=parseInt(b.lg)||F,E=parseInt(b.xl)||D,P=parseInt(b.xxl)||E;return v<=a.LG?m+=F:v<a.XL?m+=D:v<a.XXL?m+=E:m+=P,A?(i.hideAdvanceBtn=!1,m<=ts*2?(i.hideAdvanceBtn=!0,i.isAdvanced=!0):m>ts*2&&m<=ts*(G(t).autoAdvancedLine||3)?i.hideAdvanceBtn=!1:i.isLoad||(i.isLoad=!0,i.isAdvanced=!i.isAdvanced),{isAdvanced:i.isAdvanced,itemColSum:m}):m>ts*(G(t).alwaysShowLines||1)?{isAdvanced:i.isAdvanced,itemColSum:m}:{isAdvanced:!0,itemColSum:m}}const d=Og({});function p(){var v;let b=0,m=0;const{baseColProps:A={}}=G(t);for(const F of G(n)){const{show:D,colProps:E}=F;let P=!0;if(Cs(D)&&(P=D),Et(D)&&(P=D({schema:F,model:s,field:F.field,values:Fe(Fe({},G(r)),s)})),P&&(E||A)){const{itemColSum:T,isAdvanced:M}=f(Fe(Fe({},A),E),b);b=T||0,M&&(m=b),d[F.field]=M}}(v=o==null?void 0:o.proxy)==null||v.$forceUpdate(),i.actionSpan=m%ts+G(u),f(G(t).actionColOptions||{span:ts},b,!0),e("advanced-change")}function y(){i.isAdvanced=!i.isAdvanced}return{handleToggleAdvanced:y,fieldsIsAdvancedMap:d}}function oC(i,e={}){const t=/^\[(.+)\]$/;if(t.test(i)){const n=i.match(t);if(n&&n[1]){const s=n[1].split(",");if(!s.length)return;const r=[];return s.forEach((o,l)=>{us(r,l,e[o.trim()])}),r.filter(Boolean).length?r:void 0}}}function lC(i,e={}){const t=/^\{(.+)\}$/;if(t.test(i)){const n=i.match(t);if(n&&n[1]){const s=n[1].split(",");if(!s.length)return;const r={};return s.forEach(o=>{us(r,o.trim(),e[o.trim()])}),Object.values(r).filter(Boolean).length?r:void 0}}}function aC({emit:i,getProps:e,formModel:t,getSchema:n,defaultValueRef:s,formElRef:r,schemaRef:o,handleFormValues:l}){function a(){return tt(this,null,function*(){const{resetFunc:T,submitOnReset:M}=G(e);T&&Et(T)&&(yield T()),G(r)&&(Object.keys(t).forEach(H=>{const te=G(n).find(re=>re.field===H),ue=te==null?void 0:te.defaultValueObj,L=Object.keys(ue||{});L.length&&L.map(re=>{t[re]=ue[re]}),t[H]=cC(te,s,H)}),Ir(()=>D()),i("reset",ea(t)),M&&P())})}const c=()=>G(n).map(T=>[...T.fields||[],T.field]).flat(1).filter(Boolean);function u(T){return tt(this,null,function*(){if(Object.keys(T).length===0)return;const M=c(),V=".",H=M.filter(ue=>String(ue).indexOf(V)>=0),te=[];M.forEach(ue=>{const L=G(n).find(le=>le.field===ue);let re=Cn(T,ue);const N=Reflect.has(T,ue);re=KS(L==null?void 0:L.component,re);const{componentProps:Q}=L||{};let $=Q;typeof Q=="function"&&($=$({formModel:G(t)}));const ie=oC(ue,T)||lC(ue,T);if(N||ie){const le=ie||re;if(A(ue))if(Array.isArray(le)){const _=[];for(const Y of le)_.push(Y?yi(Y):null);G(t)[ue]=_}else G(t)[ue]=le?$!=null&&$.valueFormat?le:yi(le):null;else G(t)[ue]=le;$!=null&&$.onChange&&($==null||$.onChange(le)),te.push(ue)}else H.forEach(le=>{try{const _=le.split(".").reduce((Y,ye)=>Y[ye],T);du(_)&&(G(t)[le]=G(_),te.push(le))}catch(_){du(s.value[le])&&(G(t)[le]=_i(G(s.value[le])))}})}),v(te).catch(ue=>{})})}function h(T){return tt(this,null,function*(){const M=_i(G(n));if(!T)return;let V=hr(T)?[T]:T;hr(T)&&(V=[T]);for(const H of V)f(H,M);o.value=M})}function f(T,M){if(hr(T)){const V=M.findIndex(H=>H.field===T);V!==-1&&(delete t[T],M.splice(V,1))}}function d(T,M,V=!1){return tt(this,null,function*(){const H=_i(G(n)),te=Array.isArray(T)?T.map(re=>re.field):[T.field];if(H.find(re=>te.includes(re.field))){xo("There are schemas that have already been added");return}const ue=H.findIndex(re=>re.field===M),L=Bi(T)?[T]:T;!M||ue===-1||V?V?H.unshift(...L):H.push(...L):ue!==-1&&H.splice(ue+1,0,...L),o.value=H,b(T)})}function p(T){return tt(this,null,function*(){let M=[];if(Bi(T)&&M.push(T),cs(T)&&(M=[...T]),!M.every(H=>yr(H.component)||Reflect.has(H,"field")&&H.field)){xo("All children of the form Schema array that need to be updated must contain the `field` field");return}o.value=M})}function y(T){return tt(this,null,function*(){let M=[];if(Bi(T)&&M.push(T),cs(T)&&(M=[...T]),!M.every(te=>yr(te.component)||Reflect.has(te,"field")&&te.field)){xo("All children of the form Schema array that need to be updated must contain the `field` field");return}const H=[];G(n).forEach(te=>{let ue;if(M.forEach(L=>{te.field===L.field&&(ue=L)}),ue!==void 0&&te.field===ue.field){const L=bf(te,ue);H.push(L)}else H.push(te)}),b(H),o.value=n0(H,"field")})}function b(T){let M=[];Bi(T)&&M.push(T),cs(T)&&(M=[...T]);const V={},H=m();M.forEach(te=>{!yr(te.component)&&Reflect.has(te,"field")&&te.field&&!fr(te.defaultValue)&&(!(te.field in H)||fr(H[te.field]))&&(V[te.field]=te.defaultValue)}),u(V)}function m(){return G(r)?l(ea(G(t))):{}}function A(T){return G(n).some(M=>M.field===T&&M.component?Nm.includes(M.component):!1)}function v(T){return tt(this,null,function*(){var V;const M=yield(V=G(r))==null?void 0:V.validateFields(T);return l(M)})}function F(T){return tt(this,null,function*(){var H;let M;T===void 0?M=c():M=T===Array.isArray(T)?T:void 0;const V=yield(H=G(r))==null?void 0:H.validate(M);return l(V)})}function D(T){return tt(this,null,function*(){var M;yield(M=G(r))==null?void 0:M.clearValidate(T)})}function E(T,M){return tt(this,null,function*(){var V;yield(V=G(r))==null?void 0:V.scrollToField(T,M)})}function P(T){return tt(this,null,function*(){T&&T.preventDefault();const{submitFunc:M}=G(e);if(M&&Et(M)){yield M();return}if(G(r))try{const H=yield F();i("submit",H)}catch(H){if((H==null?void 0:H.outOfDate)===!1&&(H!=null&&H.errorFields))return;throw new Error(H)}})}return{handleSubmit:P,clearValidate:D,validate:F,validateFields:v,getFieldsValue:m,updateSchema:y,resetSchema:p,appendSchemaByField:d,removeSchemaByField:h,resetFields:a,setFieldsValue:u,scrollToField:E}}function cC(i,e,t){let n=_i(e.value[t]);return hC(i)?n||void 0:(!n&&i&&uC(i)&&(n=[0,0]),!n&&i&&i.component==="ApiTree"&&(n=[]),n)}function uC(i){if(i.component==="Slider"&&i.componentProps&&"range"in i.componentProps)return!0}function hC(i){return(i==null?void 0:i.component)&&Rm.includes(i.component)}function fC(s){return tt(this,arguments,function*({getSchema:i,getProps:e,formElRef:t,isInitedDefault:n}){Ys(()=>tt(this,null,function*(){if(G(n)||!G(e).autoFocusFirstItem)return;yield Ir();const r=G(i),o=G(t),l=o==null?void 0:o.$el;if(!o||!l||!r||r.length===0)return;const a=r[0];if(!a.component||!a.component.includes("Input"))return;const c=l.querySelector(".ant-row:first-child input");c&&(c==null||c.focus())}))})}const dC={model:{type:Object,default:()=>({})},labelWidth:{type:[Number,String],default:0},fieldMapToTime:{type:Array,default:()=>[]},compact:Ee.bool,schemas:{type:Array,default:()=>[]},mergeDynamicData:{type:Object,default:null},baseRowStyle:{type:Object},baseColProps:{type:Object},autoSetPlaceHolder:Ee.bool.def(!0),autoSubmitOnEnter:Ee.bool.def(!1),submitOnReset:Ee.bool,submitOnChange:Ee.bool,size:Ee.oneOf(["default","small","large"]).def("default"),disabled:Ee.bool,emptySpan:{type:[Number,Object],default:0},showAdvancedButton:Ee.bool,transformDateFunc:{type:Function,default:i=>{var e,t;return(t=(e=i==null?void 0:i.format)==null?void 0:e.call(i,"YYYY-MM-DD HH:mm:ss"))!=null?t:i}},rulesMessageJoinLabel:Ee.bool.def(!0),autoAdvancedLine:Ee.number.def(3),alwaysShowLines:Ee.number.def(1),showActionButtonGroup:Ee.bool.def(!0),actionColOptions:Object,showResetButton:Ee.bool.def(!0),autoFocusFirstItem:Ee.bool,resetButtonOptions:Object,showSubmitButton:Ee.bool.def(!0),submitButtonOptions:Object,resetFunc:Function,submitFunc:Function,hideRequiredMark:Ee.bool,labelCol:Object,layout:Ee.oneOf(["horizontal","vertical","inline"]).def("horizontal"),tableAction:{type:Object},wrapperCol:Object,colon:Ee.bool,labelAlign:Ee.string,rowProps:Object},pC=Gt({name:"BasicForm",components:{FormItem:XS,Form:No,Row:i0,FormAction:tC},props:dC,emits:["advanced-change","reset","submit","register","field-value-change"],setup(i,{emit:e,attrs:t}){const n=cu({}),s=m0(),r=cu({isAdvanced:!0,hideAdvanceBtn:!1,isLoad:!1,actionSpan:6}),o=ze({}),l=ze(!1),a=ze(),c=ze(null),u=ze(null),{prefixCls:h}=ll("basic-form"),f=dt(()=>Fe(Fe({},i),G(a))),d=dt(()=>[h,{[`${h}--compact`]:G(f).compact}]),p=dt(()=>{const{baseRowStyle:_={},rowProps:Y}=G(f);return Fe({style:_},Y)}),y=dt(()=>Fe(Fe(Fe({},t),i),G(f))),b=dt(()=>{const _=G(c)||G(f).schemas;for(const Y of _){const{defaultValue:ye,component:we,componentProps:Le,isHandleDateDefaultValue:ve=!0}=Y;if(ve&&ye&&we&&Nm.includes(we)){const qe=Le?Le.valueFormat:null;if(!Array.isArray(ye))Y.defaultValue=qe?yi(ye).format(qe):yi(ye);else{const st=[];ye.forEach(Je=>{st.push(qe?yi(Je).format(qe):yi(Je))}),Y.defaultValue=st}}}return G(f).showAdvancedButton?_i(_.filter(Y=>!yr(Y.component))):_i(_)}),{handleToggleAdvanced:m,fieldsIsAdvancedMap:A}=rC({advanceState:r,emit:e,getProps:f,getSchema:b,formModel:n,defaultValueRef:o}),{handleFormValues:v,initDefault:F}=sC({getProps:f,defaultValueRef:o,getSchema:b,formModel:n});fC({getSchema:b,getProps:f,isInitedDefault:l,formElRef:u});const{handleSubmit:D,setFieldsValue:E,clearValidate:P,validate:T,validateFields:M,getFieldsValue:V,updateSchema:H,resetSchema:te,appendSchemaByField:ue,removeSchemaByField:L,resetFields:re,scrollToField:N}=aC({emit:e,getProps:f,formModel:n,getSchema:b,defaultValueRef:o,formElRef:u,schemaRef:c,handleFormValues:v});JS({resetAction:re,submitAction:D}),mt(()=>G(f).model,()=>{const{model:_}=G(f);_&&E(_)},{immediate:!0}),mt(()=>i.schemas,_=>{te(_!=null?_:[])}),mt(()=>b.value,_=>{Ir(()=>{var Y;(Y=s==null?void 0:s.redoModalHeight)==null||Y.call(s)}),!G(l)&&_!=null&&_.length&&(F(),l.value=!0)}),mt(()=>n,Ja(()=>{G(f).submitOnChange&&D()},300),{deep:!0});function Q(_){return tt(this,null,function*(){a.value=bf(G(a)||{},_)})}function $(_,Y,ye){n[_]=Y,e("field-value-change",_,Y),ye&&ye.itemProps&&!ye.itemProps.autoLink&&M([_]).catch(we=>{})}function ie(_){const{autoSubmitOnEnter:Y}=G(f);if(Y&&_.key==="Enter"&&_.target&&_.target instanceof HTMLElement){const ye=_.target;ye&&ye.tagName&&ye.tagName.toUpperCase()=="INPUT"&&D()}}const le={getFieldsValue:V,setFieldsValue:E,resetFields:re,updateSchema:H,resetSchema:te,setProps:Q,removeSchemaByField:L,appendSchemaByField:ue,clearValidate:P,validateFields:M,validate:T,submit:D,scrollToField:N};return Nr(()=>{F(),e("register",le)}),Fe({getBindValue:y,handleToggleAdvanced:m,handleEnterPress:ie,formModel:n,defaultValueRef:o,advanceState:r,getRow:p,getProps:f,formElRef:u,getSchema:b,formActionType:le,setFormModel:$,getFormClass:d,getFormActionBindProps:dt(()=>Fe(Fe({},f.value),r)),fieldsIsAdvancedMap:A},le)}});function mC(i,e,t,n,s,r){const o=vt("FormItem"),l=vt("FormAction"),a=vt("Row"),c=vt("Form");return it(),Bt(c,cn(i.getBindValue,{class:i.getFormClass,ref:"formElRef",model:i.formModel,onKeypress:Eg(i.handleEnterPress,["enter"])}),{default:ft(()=>[rt(a,Wi(fs(i.getRow)),{default:ft(()=>[Sn(i.$slots,"formHeader"),(it(!0),dn(_s,null,Gn(i.getSchema,u=>(it(),Bt(o,{key:u.field,isAdvanced:i.fieldsIsAdvancedMap[u.field],tableAction:i.tableAction,formActionType:i.formActionType,schema:u,formProps:i.getProps,allDefaultValues:i.defaultValueRef,formModel:i.formModel,setFormModel:i.setFormModel},Hi({_:2},[Gn(Object.keys(i.$slots),h=>({name:h,fn:ft(f=>[Sn(i.$slots,h,cn({ref_for:!0},f||{}))])}))]),1032,["isAdvanced","tableAction","formActionType","schema","formProps","allDefaultValues","formModel","setFormModel"]))),128)),rt(l,cn(i.getFormActionBindProps,{onToggleAdvanced:i.handleToggleAdvanced}),Hi({_:2},[Gn(["resetBefore","submitBefore","advanceBefore","advanceAfter"],u=>({name:u,fn:ft(h=>[Sn(i.$slots,u,Wi(fs(h||{})))])}))]),1040,["onToggleAdvanced"]),Sn(i.$slots,"formFooter")]),_:3},16)]),_:3},16,["class","model","onKeypress"])}const NC=Mn(pC,[["render",mC]]);function IC(i){const e=ze(null),t=ze(!1);function n(){return tt(this,null,function*(){const o=G(e);return o||xo("The form instance has not been obtained, please make sure that the form has been rendered when performing the form operation!"),yield Ir(),o})}function s(o){Fg(()=>{e.value=null,t.value=null}),!(G(t)&&zg()&&o===G(e))&&(e.value=o,t.value=!0,mt(()=>i,()=>{i&&o.setProps(Vg(i))},{immediate:!0,deep:!0}))}return[s,{scrollToField:(o,l)=>tt(this,null,function*(){(yield n()).scrollToField(o,l)}),setProps:o=>tt(this,null,function*(){(yield n()).setProps(o)}),updateSchema:o=>tt(this,null,function*(){(yield n()).updateSchema(o)}),resetSchema:o=>tt(this,null,function*(){(yield n()).resetSchema(o)}),clearValidate:o=>tt(this,null,function*(){(yield n()).clearValidate(o)}),resetFields:()=>tt(this,null,function*(){n().then(o=>tt(this,null,function*(){yield o.resetFields()}))}),removeSchemaByField:o=>tt(this,null,function*(){var l;(l=G(e))==null||l.removeSchemaByField(o)}),getFieldsValue:()=>{var o;return(o=G(e))==null?void 0:o.getFieldsValue()},setFieldsValue:o=>tt(this,null,function*(){(yield n()).setFieldsValue(o)}),appendSchemaByField:(o,l,a)=>tt(this,null,function*(){(yield n()).appendSchemaByField(o,l,a)}),submit:()=>tt(this,null,function*(){return(yield n()).submit()}),validate:o=>tt(this,null,function*(){return(yield n()).validate(o)}),validateFields:o=>tt(this,null,function*(){return(yield n()).validateFields(o)})}]}export{T0 as A,NC as B,S0 as R,P0 as a,v0 as b,IC as u};
|