comp-hub 0.31.2 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/bin/lib/startup.js +1 -1
- package/dist/index.js +3 -3
- package/dist/master.js +23 -23
- package/dist/website/container/assets/{index-BR_ZVtEf.js → index-BF46-8S8.js} +13 -13
- package/dist/website/container/assets/{index-Y--RAA6W.css → index-DN-EG3Qh.css} +1 -1
- package/dist/website/container/index.html +3 -2
- package/dist/website/container/js/react-jsx-loader.js +233 -0
- package/dist/website/item/assets/index-C4D-8nqe.js +62 -0
- package/dist/website/item/assets/index-iYpmJN_Z.css +1 -0
- package/dist/website/item/index.html +2 -2
- package/dist/website/main/assets/{AuthCodeSendBtn.vue_vue_type_script_setup_true_lang-C5to3ZQC.js → AuthCodeSendBtn.vue_vue_type_script_setup_true_lang-XaDuBXZe.js} +1 -1
- package/dist/website/main/assets/{BaseBadge-DUuZfvYd.js → BaseBadge-CwPduDSy.js} +1 -1
- package/dist/website/main/assets/{BaseDialog.vue_vue_type_script_setup_true_lang-DhPHn879.js → BaseDialog.vue_vue_type_script_setup_true_lang-CkNHSg5g.js} +1 -1
- package/dist/website/main/assets/{BaseSegmented.vue_vue_type_script_setup_true_lang-D46cMrVi.js → BaseSegmented.vue_vue_type_script_setup_true_lang-QoRVS1cj.js} +1 -1
- package/dist/website/main/assets/{CanvasAnimation.vue_vue_type_script_setup_true_lang-CisWACfW.js → CanvasAnimation.vue_vue_type_script_setup_true_lang-C4ID6BIz.js} +1 -1
- package/dist/website/main/assets/{CodeMirrorEditor-Cqow8ROO-DMgFI1zV.js → CodeMirrorEditor-Cqow8ROO-Cb1F80wf.js} +3 -3
- package/dist/website/main/assets/{EmptyStatusContainer.vue_vue_type_script_setup_true_lang-CAB4mEGu.js → EmptyStatusContainer.vue_vue_type_script_setup_true_lang-D9ipEmGE.js} +1 -1
- package/dist/website/main/assets/GithubCallback-CvYaECQV.js +1 -0
- package/dist/website/main/assets/ReplyForm.vue_vue_type_script_setup_true_lang-Cg6jGDaf.js +1 -0
- package/dist/website/main/assets/{core-DIlcfMir.js → core-yetgou6F.js} +1 -1
- package/dist/website/main/assets/{el-table-column-DUFMPIr5.js → el-table-column-BpgDq_WF.js} +1 -1
- package/dist/website/main/assets/index-3zCQDZnh.js +2 -0
- package/dist/website/main/assets/{index-72rReQ2I-sU_re5gS.js → index-72rReQ2I-BUkUG78x.js} +1 -1
- package/dist/website/main/assets/index-74ZEuWc8.js +1 -0
- package/dist/website/main/assets/index-9wcpsZe1.js +1 -0
- package/dist/website/main/assets/index-BCpgCtua.js +1 -0
- package/dist/website/main/assets/{index-HnLIbMTX.js → index-BJKOBdMx.js} +1 -1
- package/dist/website/main/assets/index-BMOsY3cQ.js +2 -0
- package/dist/website/main/assets/index-BMVmqejS.js +1 -0
- package/dist/website/main/assets/{index-BiQ2dJm4.js → index-BcfC5qCh.js} +1 -1
- package/dist/website/main/assets/{index-DwDo8mID.js → index-BnX30az1.js} +1 -1
- package/dist/website/main/assets/{index-Ct_U5I7y.js → index-BouHS9Ky.js} +1 -1
- package/dist/website/main/assets/index-Bp79GOY4.js +1 -0
- package/dist/website/main/assets/{index-Cbpqtmwk.js → index-BsZl8udl.js} +1 -1
- package/dist/website/main/assets/{index-B-fZjRMn.js → index-Bucicr-O.js} +1 -1
- package/dist/website/main/assets/index-CXKzXFNq.js +1 -0
- package/dist/website/main/assets/{index-DlU_hLR3.js → index-CbpqTP74.js} +1 -1
- package/dist/website/main/assets/{index-CxLzXF-b.js → index-CgJn84pE.js} +1 -1
- package/dist/website/main/assets/{index-CvGH1xqJ.css → index-CioMG7I6.css} +1 -1
- package/dist/website/main/assets/index-ClqLWOrM.js +1 -0
- package/dist/website/main/assets/index-CopP0_Oh.js +1 -0
- package/dist/website/main/assets/{index-Da5ZhB-r.js → index-CxeWFTBn.js} +1 -1
- package/dist/website/main/assets/index-CzxUr7HV.js +1 -0
- package/dist/website/main/assets/{index-CjE-geY_.css → index-D-8GYlU8.css} +1 -1
- package/dist/website/main/assets/{index-Jp4YN25a.js → index-D4WFMTSP.js} +1 -1
- package/dist/website/main/assets/{index-D76eWsZ1-BUecZt4E.js → index-D76eWsZ1-7KvuCuMg.js} +1 -1
- package/dist/website/main/assets/index-DCet9p8Y.js +1 -0
- package/dist/website/main/assets/{index-Cz3keLmq.js → index-DMO6XTC0.js} +1 -1
- package/dist/website/main/assets/{index-DKv4dFPY.js → index-DP0Xav0B.js} +1 -1
- package/dist/website/main/assets/index-DXY5BNS4.js +1 -0
- package/dist/website/main/assets/{index-Dms7ZQ2h-DY4-ZFKr.js → index-Dms7ZQ2h-BXeasSDQ.js} +1 -1
- package/dist/website/main/assets/{index-DqiFCfGx-BY8MJk0B.js → index-DqiFCfGx-4HZIi15Y.js} +1 -1
- package/dist/website/main/assets/{index-DxypSQ0K-CDh8t7kw.js → index-DxypSQ0K-DsBZbAQO.js} +1 -1
- package/dist/website/main/assets/{index-CnhaF7r3.js → index-FOvWqIoM.js} +1 -1
- package/dist/website/main/assets/{index-CQSvO48y.js → index-HvNFjpLq.js} +1 -1
- package/dist/website/main/assets/{index-Cu1aNpBv.js → index-KZ5xMbrf.js} +1 -1
- package/dist/website/main/assets/index-PtEeGBK6.js +1 -0
- package/dist/website/main/assets/{index-T76vWLBU-Bpnxnyfv.js → index-T76vWLBU-C2L4ZR6a.js} +1 -1
- package/dist/website/main/assets/{index-CnTuJQbj.js → index-YvDl_1WK.js} +23 -23
- package/dist/website/main/assets/{index-fZBcgzqR-QE1WZxps.js → index-fZBcgzqR-DZ4VEjtI.js} +1 -1
- package/dist/website/main/assets/{index-mqeGrL6B-DZ51JJUI.js → index-mqeGrL6B-zaO8HgOa.js} +1 -1
- package/dist/website/main/assets/{index-QDS7dx0M.js → index-rm7l2BT_.js} +1 -1
- package/dist/website/main/assets/{index.vue_vue_type_script_setup_true_lang-B5HoY3_0.js → index.vue_vue_type_script_setup_true_lang-2Z80ry6F.js} +1 -1
- package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-C7h-Ycpm.js +1 -0
- package/dist/website/main/assets/{index.vue_vue_type_script_setup_true_lang-BBmEjb-A.js → index.vue_vue_type_script_setup_true_lang-CHyooj4T.js} +1 -1
- package/dist/website/main/assets/{index.vue_vue_type_script_setup_true_lang-t73JgDYM.js → index.vue_vue_type_script_setup_true_lang-ChXDjhzT.js} +2 -2
- package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-Cy3ZPsfb.js +1 -0
- package/dist/website/main/assets/{index.vue_vue_type_script_setup_true_lang-87WT-7PF.js → index.vue_vue_type_script_setup_true_lang-DHWblo58.js} +1 -1
- package/dist/website/main/assets/{index.vue_vue_type_style_index_0_lang-SpJl7c7B.js → index.vue_vue_type_style_index_0_lang-Bsi5S1XY.js} +1 -1
- package/dist/website/main/assets/{index.vue_vue_type_style_index_0_lang-C30OZgOy.js → index.vue_vue_type_style_index_0_lang-DfBu8zdC.js} +1 -1
- package/dist/website/main/assets/{index.vue_vue_type_style_index_0_lang-YYZCGIEM.js → index.vue_vue_type_style_index_0_lang-Digz_UdY.js} +1 -1
- package/dist/website/main/assets/{md5-BaIvdSuD.js → md5-CWhVn6LA.js} +1 -1
- package/dist/website/main/assets/{useCacheOssStore-B5wqgiBM.js → useCacheOssStore-KoEbWj57.js} +1 -1
- package/dist/website/main/assets/useCompEditStore-Ch5sDzy4.js +1 -0
- package/dist/website/main/assets/useCompEditStore-GUrodzAV.css +1 -0
- package/dist/website/main/assets/{useKeyword-BygMrCvJ.js → useKeyword-Bmq02ywx.js} +1 -1
- package/dist/website/main/assets/{useMessage-CHhLVawp.js → useMessage-BLwQdu5o.js} +1 -1
- package/dist/website/main/assets/{useTeamHeaders-a-XSRO3U.css → useTeamHeaders-BMHQzwDq.css} +1 -1
- package/dist/website/main/assets/{useTeamHeaders-C1Nwzx4f.js → useTeamHeaders-Bttl7tEb.js} +2 -2
- package/dist/website/main/assets/{useUnreadStore-D50CXC_9.js → useUnreadStore-kWR1ykK7.js} +1 -1
- package/dist/website/main/assets/{useVscodeOpen-CJ-3bg9h.js → useVscodeOpen-DyvB87xz.js} +1 -1
- package/dist/website/main/assets/{vendor-ui-BAx7vAkH.js → vendor-ui-KquZSIP0.js} +10 -10
- package/dist/website/main/index.html +3 -3
- package/package.json +1 -1
- package/dist/website/item/assets/index-BxlM4TBc.js +0 -60
- package/dist/website/item/assets/index-Cg5t9Ndz.css +0 -1
- package/dist/website/main/assets/GithubCallback-DP3YU9rH.js +0 -1
- package/dist/website/main/assets/ReplyForm.vue_vue_type_script_setup_true_lang-BnN1jBiO.js +0 -1
- package/dist/website/main/assets/index--J05rNIX.js +0 -1
- package/dist/website/main/assets/index-B2rWNHgy.js +0 -1
- package/dist/website/main/assets/index-B6fwGRmY.js +0 -1
- package/dist/website/main/assets/index-B8TdXR68.js +0 -1
- package/dist/website/main/assets/index-BBzEF7CC.js +0 -1
- package/dist/website/main/assets/index-BQKN7xQr.js +0 -2
- package/dist/website/main/assets/index-BWKB83Cd.js +0 -1
- package/dist/website/main/assets/index-BjKOeMxH.js +0 -1
- package/dist/website/main/assets/index-D03XtNqB.js +0 -1
- package/dist/website/main/assets/index-DEvtplax.js +0 -2
- package/dist/website/main/assets/index-DQTRYmEL.js +0 -1
- package/dist/website/main/assets/index-DRytU1Iu.js +0 -1
- package/dist/website/main/assets/index-DcfKevFQ.js +0 -1
- package/dist/website/main/assets/index-tSn-zTTf.js +0 -1
- package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-C1EYwhRp.js +0 -1
- package/dist/website/main/assets/index.vue_vue_type_script_setup_true_lang-Dl1KwcTe.js +0 -1
- package/dist/website/main/assets/useCompEditStore-Br3x5A7Q.css +0 -1
- package/dist/website/main/assets/useCompEditStore-rtFXUPNg.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-D76eWsZ1-
|
|
2
|
-
import{O as Th,q as Rt}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-D76eWsZ1-7KvuCuMg.js","./index-DqiFCfGx-4HZIi15Y.js","./index-YvDl_1WK.js","./vendor-core-Do-oxgl9.js","./vendor-ui-KquZSIP0.js","./index-D-8GYlU8.css","./index-T76vWLBU-C2L4ZR6a.js","./index-Dms7ZQ2h-BXeasSDQ.js","./index-fZBcgzqR-DZ4VEjtI.js","./index-72rReQ2I-BUkUG78x.js","./index-mqeGrL6B-zaO8HgOa.js","./index-DxypSQ0K-DsBZbAQO.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{O as Th,q as Rt}from"./index-YvDl_1WK.js";import{I as Dh,a as As,f as Eh,w as In,B as Bh,O as Lh,P as Rh,R as Ms,aP as Ph,u as Wn,U as Cs}from"./vendor-core-Do-oxgl9.js";import"./vendor-ui-KquZSIP0.js";let lr=[],Xo=[];(()=>{let r="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(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<r.length;t++)(t%2?Xo:lr).push(e=e+r[t])})();function Nh(r){if(r<768)return!1;for(let t=0,e=lr.length;;){let i=t+e>>1;if(r<lr[i])e=i;else if(r>=Xo[i])t=i+1;else return!0;if(t==e)return!1}}function Os(r){return r>=127462&&r<=127487}const Ts=8205;function Ih(r,t,e=!0,i=!0){return(e?Qo:Wh)(r,t,i)}function Qo(r,t,e){if(t==r.length)return t;t&&Zo(r.charCodeAt(t))&&tl(r.charCodeAt(t-1))&&t--;let i=Hn(r,t);for(t+=Ds(i);t<r.length;){let n=Hn(r,t);if(i==Ts||n==Ts||e&&Nh(n))t+=Ds(n),i=n;else if(Os(n)){let s=0,o=t-2;for(;o>=0&&Os(Hn(r,o));)s++,o-=2;if(s%2==0)break;t+=2}else break}return t}function Wh(r,t,e){for(;t>0;){let i=Qo(r,t-2,e);if(i<t)return i;t--}return 0}function Hn(r,t){let e=r.charCodeAt(t);if(!tl(e)||t+1==r.length)return e;let i=r.charCodeAt(t+1);return Zo(i)?(e-55296<<10)+(i-56320)+65536:e}function Zo(r){return r>=56320&&r<57344}function tl(r){return r>=55296&&r<56320}function Ds(r){return r<65536?1:2}class W{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=He(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Ht.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=He(this,t,e);let i=[];return this.decompose(t,e,i,0),Ht.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new ii(this),s=new ii(t);for(let o=e,l=e;;){if(n.next(o),s.next(o),o=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(t=1){return new ii(this,t)}iterRange(t,e=this.length){return new el(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new il(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?W.empty:t.length<=32?new J(t):Ht.from(J.split(t,[]))}}class J extends W{constructor(t,e=Hh(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.text[s],l=n+o.length;if((e?i:l)>=t)return new Vh(n,l,i,o);n=l+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new J(Es(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(n&1){let o=i.pop(),l=$i(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new J(l,o.length+s.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof J))return super.replace(t,e,i);[t,e]=He(this,t,e);let n=$i(this.text,$i(i.text,Es(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new J(n,s):Ht.from(J.split(n,[]),s)}sliceString(t,e=this.length,i=`
|
|
3
3
|
`){[t,e]=He(this,t,e);let n="";for(let s=0,o=0;s<=e&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>t&&o&&(n+=i),t<a&&e>s&&(n+=l.slice(Math.max(0,t-s),e-s)),s=a+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,i.length==32&&(e.push(new J(i,n)),i=[],n=-1);return n>-1&&e.push(new J(i,n)),e}}class Ht extends W{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.children[s],l=n+o.length,a=i+o.lines-1;if((e?a:l)>=t)return o.lineInner(t,e,i,n);n=l+1,i=a+1}}decompose(t,e,i,n){for(let s=0,o=0;o<=e&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(t<=a&&e>=o){let h=n&((o<=t?1:0)|(a>=e?2:0));o>=t&&a<=e&&!h?i.push(l):l.decompose(t-o,e-o,i,h)}o=a+1}}replace(t,e,i){if([t,e]=He(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.length;if(t>=s&&e<=l){let a=o.replace(t-s,e-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Ht(c,this.length-(e-t)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=`
|
|
4
4
|
`){[t,e]=He(this,t,e);let n="";for(let s=0,o=0;s<this.children.length&&o<=e;s++){let l=this.children[s],a=o+l.length;o>t&&s&&(n+=i),t<a&&e>o&&(n+=l.sliceString(t-o,e-o,i)),o=a+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Ht))return 0;let i=0,[n,s,o,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==l)return i;let a=this.children[n],h=t.children[s];if(a!=h)return i+a.scanIdentical(h,e);i+=a.length+1}}static from(t,e=t.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of t)i+=d.lines;if(i<32){let d=[];for(let p of t)p.flatten(d);return new J(d,e)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Ht)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof J&&a&&(p=c[c.length-1])instanceof J&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new J(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Ht.from(c,h)),h=-1,a=c.length=0)}for(let d of t)f(d);return u(),l.length==1?l[0]:new Ht(l,e)}}W.empty=new J([""],0);function Hh(r){let t=-1;for(let e of r)t+=e.length+1;return t}function $i(r,t,e=0,i=1e9){for(let n=0,s=0,o=!0;s<r.length&&n<=i;s++){let l=r[s],a=n+l.length;a>=e&&(a>i&&(l=l.slice(0,i-n)),n<e&&(l=l.slice(e-n)),o?(t[t.length-1]+=l,o=!1):t.push(l)),n=a+1}return t}function Es(r,t,e){return $i(r,[""],t,e)}class ii{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof J?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,l=n instanceof J?n.text.length:n.children.length;if(o==(e>0?l:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
|
|
5
5
|
`,this;t--}else if(n instanceof J){let a=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,a.length>Math.max(0,t))return this.value=t==0?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{let a=n.children[o+(e<0?-1:0)];t>a.length?(t-=a.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(e>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class el{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new ii(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class il{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(W.prototype[Symbol.iterator]=function(){return this.iter()},ii.prototype[Symbol.iterator]=el.prototype[Symbol.iterator]=il.prototype[Symbol.iterator]=function(){return this});class Vh{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function He(r,t,e){return t=Math.max(0,Math.min(r.length,t)),[t,Math.max(t,Math.min(r.length,e))]}function tt(r,t,e=!0,i=!0){return Ih(r,t,e,i)}function Fh(r){return r>=56320&&r<57344}function qh(r){return r>=55296&&r<56320}function nl(r,t){let e=r.charCodeAt(t);if(!qh(e)||t+1==r.length)return e;let i=r.charCodeAt(t+1);return Fh(i)?(e-55296<<10)+(i-56320)+65536:e}function zh(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function rl(r){return r<65536?1:2}const ar=/\r\n?|\n/;var mt=(function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r})(mt||(mt={}));class $t{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(t,e=!1){hr(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new $t(t)}composeDesc(t){return this.empty?t:t.empty?this:sl(this,t)}mapDesc(t,e=!1){return t.empty?this:cr(this,t,e)}mapPos(t,e=-1,i=mt.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>t)return s+(t-n);s+=l}else{if(i!=mt.Simple&&h>=t&&(i==mt.TrackDel&&n<t&&h>t||i==mt.TrackBefore&&n<t||i==mt.TrackAfter&&h>t))return null;if(h>t||h==t&&e<0&&!l)return t==n||e<0?s:s+a;s+=a}n=h}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=this.sections[i++],o=this.sections[i++],l=n+s;if(o>=0&&n<=e&&l>=t)return n<t&&l>e?"cover":!0;n=l}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new $t(t)}static create(t){return new $t(t)}}class X extends $t{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return hr(this,(e,i,n,s,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return cr(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let o=e[n],l=e[n+1];if(l>=0){e[n]=l,e[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(W.empty);i.push(o?t.slice(s,s+o):W.empty)}s+=o}return new X(e,i)}compose(t){return this.empty?t:t.empty?this:sl(this,t,!0)}map(t,e=!1){return t.empty?this:cr(this,t,e,!0)}iterChanges(t,e=!1){hr(this,t,e)}get desc(){return $t.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new ai(this);t:for(let o=0,l=0;;){let a=o==t.length?1e9:t[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break t;let c=Math.min(s.len,a-l);rt(n,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;rt(e,c,f),f>0&&ie(i,e,s.text),s.forward(c),l+=c}let h=t[o++];for(;l<h;){if(s.done)break t;let c=Math.min(s.len,h-l);rt(e,c,-1),rt(n,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new X(e,i),filtered:$t.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):n==0?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<e&&rt(n,e-o,-1);let f=new X(n,s);l=l?l.compose(f.map(l)):f,n=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof X){if(c.length!=e)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${e})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>e)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${e})`);let p=d?typeof d=="string"?W.of(d.split(i||ar)):d:W.empty,g=p.length;if(f==u&&g==0)return;f<o&&a(),f>o&&rt(n,f-o,-1),rt(n,u-f,g),ie(s,n,p),o=u}}return h(t),a(!l),l}static empty(t){return new X(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if(typeof s=="number")e.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)e.push(s[0],0);else{for(;i.length<n;)i.push(W.empty);i[n]=W.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new X(e,i)}static createSet(t,e){return new X(t,e)}}function rt(r,t,e,i=!1){if(t==0&&e<=0)return;let n=r.length-2;n>=0&&e<=0&&e==r[n+1]?r[n]+=t:n>=0&&t==0&&r[n]==0?r[n+1]+=e:i?(r[n]+=t,r[n+1]+=e):r.push(t,e)}function ie(r,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i<r.length)r[r.length-1]=r[r.length-1].append(e);else{for(;r.length<i;)r.push(W.empty);r.push(e)}}function hr(r,t,e){let i=r.inserted;for(let n=0,s=0,o=0;o<r.sections.length;){let l=r.sections[o++],a=r.sections[o++];if(a<0)n+=l,s+=l;else{let h=n,c=s,f=W.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(e||o==r.sections.length||r.sections[o+1]<0);)l=r.sections[o++],a=r.sections[o++];t(n,h,s,c,f),n=h,s=c}}}function cr(r,t,e,i=!1){let n=[],s=i?[]:null,o=new ai(r),l=new ai(t);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);rt(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!e))){let h=l.len;for(rt(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(rt(n,0,o.ins),s&&ie(s,n,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;rt(n,h,a<o.i?o.ins:0),s&&a<o.i&&ie(s,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?X.createSet(n,s):$t.create(n);throw new Error("Mismatched change set lengths")}}}function sl(r,t,e=!1){let i=[],n=e?[]:null,s=new ai(r),o=new ai(t);for(let l=!1;;){if(s.done&&o.done)return n?X.createSet(i,n):$t.create(i);if(s.ins==0)rt(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)rt(i,0,o.ins,l),n&&ie(n,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;rt(i,a,c,l),n&&c&&ie(n,i,o.text)}else o.ins==-1?(rt(i,s.off?0:s.len,a,l),n&&ie(n,i,s.textBit(a))):(rt(i,s.off?0:s.len,o.off?0:o.ins,l),n&&!o.off&&ie(n,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}class ai{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[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:t}=this.set,e=this.i-2>>1;return e>=t.length?W.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?W.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class me{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}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 t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new me(i,n,this.flags)}extend(t,e=t,i=0){if(t<=this.anchor&&e>=this.anchor)return v.range(t,e,void 0,void 0,i);let n=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return v.range(this.anchor,n,void 0,void 0,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return v.range(t.anchor,t.head)}static create(t,e,i){return new me(t,e,i)}}class v{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:v.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new v([this.main],0)}addRange(t,e=!0){return v.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,v.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new v(t.ranges.map(e=>me.fromJSON(e)),t.main)}static single(t,e=t){return new v([v.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return v.normalized(t.slice(),e);i=s.to}return new v(t,e)}static cursor(t,e=0,i,n){return me.create(t,t,(e==0?0:e<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(t,e,i,n,s){let o=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!s&&t!=e&&(s=e<t?1:-1),e<t?me.create(e,t,48|o):me.create(t,e,(s?s<0?8:16:0)|o)}static normalized(t,e=0){let i=t[e];t.sort((n,s)=>n.from-s.from),e=t.indexOf(i);for(let n=1;n<t.length;n++){let s=t[n],o=t[n-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);n<=e&&e--,t.splice(--n,2,s.anchor>s.head?v.range(a,l):v.range(l,a))}}return new v(t,e)}}function ol(r,t){for(let e of r.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}let _r=0;class O{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=_r++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new O(t.combine||(e=>e),t.compareInput||((e,i)=>e===i),t.compare||(t.combine?(e,i)=>e===i:Yr),!!t.static,t.enables)}of(t){return new Ui([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ui(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ui(t,this,2,e)}from(t,e){return e||(e=i=>i),this.compute([t],i=>e(i.field(t)))}}function Yr(r,t){return r==t||r.length==t.length&&r.every((e,i)=>e===t[i])}class Ui{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=_r++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,o=t[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((e=t[f.id])!==null&&e!==void 0?e:1)&1)==0&&c.push(t[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||fr(f,c)){let d=i(f);if(l?!Bs(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[s];if(p!=null){let g=Qi(u,p);if(this.dependencies.every(m=>m instanceof O?u.facet(m)===f.facet(m):m instanceof Dt?u.field(m,!1)==f.field(m,!1):!0)||(l?Bs(d=i(f),g,n):n(d=i(f),g)))return f.values[o]=g,0}else d=i(f);return f.values[o]=d,1}}}}function Bs(r,t,e){if(r.length!=t.length)return!1;for(let i=0;i<r.length;i++)if(!e(r[i],t[i]))return!1;return!0}function fr(r,t){let e=!1;for(let i of t)ni(r,i)&1&&(e=!0);return e}function jh(r,t,e){let i=e.map(a=>r[a.id]),n=e.map(a=>a.type),s=i.filter(a=>!(a&1)),o=r[t.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Qi(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return t.combine(h)}return{create(a){for(let h of i)ni(a,h);return a.values[o]=l(a),1},update(a,h){if(!fr(a,s))return 0;let c=l(a);return t.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=fr(a,i),f=h.config.facets[t.id],u=h.facet(t);if(f&&!c&&Yr(e,f))return a.values[o]=u,0;let d=l(a);return t.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Ci=O.define({static:!0});class Dt{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new Dt(_r++,t.create,t.update,t.compare||((i,n)=>i===n),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){return(t.facet(Ci).find(i=>i.field==this)?.create||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:i=>(i.values[e]=this.create(i),1),update:(i,n)=>{let s=i.values[e],o=this.updateF(s,n);return this.compareF(s,o)?0:(i.values[e]=o,1)},reconfigure:(i,n)=>{let s=i.facet(Ci),o=n.facet(Ci),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[e]=l.create(i),1):n.config.address[this.id]!=null?(i.values[e]=n.field(this),0):(i.values[e]=this.create(i),1)}}}init(t){return[this,Ci.of({field:this,create:t})]}get extension(){return this}}const ge={lowest:4,low:3,default:2,high:1,highest:0};function _e(r){return t=>new ll(t,r)}const kn={highest:_e(ge.highest),high:_e(ge.high),default:_e(ge.default),low:_e(ge.low),lowest:_e(ge.lowest)};class ll{constructor(t,e){this.inner=t,this.prec=e}}class ve{of(t){return new ur(this,t)}reconfigure(t){return ve.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ur{constructor(t,e){this.compartment=t,this.inner=e}}class Xi{constructor(t,e,i,n,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),o=new Map;for(let u of Kh(t,e,o))u instanceof Dt?n.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in s){let d=s[u],p=d[0].facet,g=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,Yr(g,d))a.push(i.facet(p));else{let m=p.combine(d.map(w=>w.value));a.push(i&&p.compare(m,i.facet(p))?i.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(w=>m.dynamicSlot(w)));l[p.id]=h.length<<1,h.push(m=>jh(m,p,d))}}let f=h.map(u=>u(l));return new Xi(t,o,f,l,a,s)}}function Kh(r,t,e){let i=[[],[],[],[],[]],n=new Map;function s(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof ur&&e.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof ur){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=t.get(o.compartment)||o.inner;e.set(o.compartment,h),s(h,l)}else if(o instanceof ll)s(o.inner,o.prec);else if(o instanceof Dt)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Ui)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ge.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(r,ge.default),i.reduce((o,l)=>o.concat(l))}function ni(r,t){if(t&1)return 2;let e=t>>1,i=r.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;r.status[e]=4;let n=r.computeSlot(r,r.config.dynamicSlots[e]);return r.status[e]=2|n}function Qi(r,t){return t&1?r.config.staticValues[t>>1]:r.values[t>>1]}const al=O.define(),dr=O.define({combine:r=>r.some(t=>t),static:!0}),hl=O.define({combine:r=>r.length?r[0]:void 0,static:!0}),cl=O.define(),fl=O.define(),ul=O.define(),dl=O.define({combine:r=>r.length?r[0]:!1});class he{constructor(t,e){this.type=t,this.value=e}static define(){return new $h}}class $h{of(t){return new he(this,t)}}class Uh{constructor(t){this.map=t}of(t){return new H(this,t)}}class H{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new H(this.type,e)}is(t){return this.type==t}static define(t={}){return new Uh(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let s=n.map(e);s&&i.push(s)}return i}}H.reconfigure=H.define();H.appendConfig=H.define();class Q{constructor(t,e,i,n,s,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&ol(i,e.newLength),s.some(l=>l.type==Q.time)||(this.annotations=s.concat(Q.time.of(Date.now())))}static create(t,e,i,n,s,o){return new Q(t,e,i,n,s,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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Q.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}}Q.time=he.define();Q.userEvent=he.define();Q.addToHistory=he.define();Q.remote=he.define();function Jh(r,t){let e=[];for(let i=0,n=0;;){let s,o;if(i<r.length&&(n==t.length||t[n]>=r[i]))s=r[i++],o=r[i++];else if(n<t.length)s=t[n++],o=t[n++];else return e;!e.length||e[e.length-1]<s?e.push(s,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function pl(r,t,e){var i;let n,s,o;return e?(n=t.changes,s=X.empty(t.changes.length),o=r.changes.compose(t.changes)):(n=t.changes.map(r.changes),s=r.changes.mapDesc(t.changes,!0),o=r.changes.compose(n)),{changes:o,selection:t.selection?t.selection.map(s):(i=r.selection)===null||i===void 0?void 0:i.map(n),effects:H.mapEffects(r.effects,n).concat(H.mapEffects(t.effects,s)),annotations:r.annotations.length?r.annotations.concat(t.annotations):t.annotations,scrollIntoView:r.scrollIntoView||t.scrollIntoView}}function pr(r,t,e){let i=t.selection,n=Le(t.annotations);return t.userEvent&&(n=n.concat(Q.userEvent.of(t.userEvent))),{changes:t.changes instanceof X?t.changes:X.of(t.changes||[],e,r.facet(hl)),selection:i&&(i instanceof v?i:v.single(i.anchor,i.head)),effects:Le(t.effects),annotations:n,scrollIntoView:!!t.scrollIntoView}}function gl(r,t,e){let i=pr(r,t.length?t[0]:{},r.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(e=!1);let o=!!t[s].sequential;i=pl(i,pr(r,t[s],o?i.changes.newLength:r.doc.length),o)}let n=Q.create(r,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return _h(e?Gh(n):n)}function Gh(r){let t=r.startState,e=!0;for(let n of t.facet(cl)){let s=n(r);if(s===!1){e=!1;break}Array.isArray(s)&&(e=e===!0?s:Jh(e,s))}if(e!==!0){let n,s;if(e===!1)s=r.changes.invertedDesc,n=X.empty(t.doc.length);else{let o=r.changes.filter(e);n=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}r=Q.create(t,n,r.selection&&r.selection.map(s),H.mapEffects(r.effects,s),r.annotations,r.scrollIntoView)}let i=t.facet(fl);for(let n=i.length-1;n>=0;n--){let s=i[n](r);s instanceof Q?r=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Q?r=s[0]:r=gl(t,Le(s),!1)}return r}function _h(r){let t=r.startState,e=t.facet(ul),i=r;for(let n=e.length-1;n>=0;n--){let s=e[n](r);s&&Object.keys(s).length&&(i=pl(i,pr(t,s,r.changes.newLength),!0))}return i==r?r:Q.create(t,r.changes,r.selection,i.effects,i.annotations,i.scrollIntoView)}const Yh=[];function Le(r){return r==null?Yh:Array.isArray(r)?r:[r]}var G=(function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r})(G||(G={}));const Xh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let gr;try{gr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Qh(r){if(gr)return gr.test(r);for(let t=0;t<r.length;t++){let e=r[t];if(/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Xh.test(e)))return!0}return!1}function Zh(r){return t=>{if(!/\S/.test(t))return G.Space;if(Qh(t))return G.Word;for(let e=0;e<r.length;e++)if(t.indexOf(r[e])>-1)return G.Word;return G.Other}}class I{constructor(t,e,i,n,s,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)ni(this,l<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(i==null){if(e)throw new RangeError("Field is not present in this state");return}return ni(this,i),Qi(this,i)}update(...t){return gl(this,t,!0)}applyTransaction(t){let e=this.config,{base:i,compartments:n}=e;for(let l of t.effects)l.is(ve.reconfigure)?(e&&(n=new Map,e.compartments.forEach((a,h)=>n.set(h,a)),e=null),n.set(l.value.compartment,l.value.extension)):l.is(H.reconfigure)?(e=null,i=l.value):l.is(H.appendConfig)&&(e=null,i=Le(i).concat(l.value));let s;e?s=t.startState.values.slice():(e=Xi.resolve(i,n,this),s=new I(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values);let o=t.startState.facet(dr)?t.newSelection:t.newSelection.asSingle();new I(e,t.newDoc,o,s,(l,a)=>a.update(l,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:v.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],o=Le(i.effects);for(let l=1;l<e.ranges.length;l++){let a=t(e.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=n.mapDesc(h,!0);s.push(a.range.map(f)),n=n.compose(c),o=H.mapEffects(o,c).concat(H.mapEffects(Le(a.effects),f))}return{changes:n,selection:v.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof X?t:X.of(t,this.doc.length,this.facet(I.lineSeparator))}toText(t){return W.of(t.split(this.facet(I.lineSeparator)||ar))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return e==null?t.default:(ni(this,e),Qi(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof Dt&&this.config.address[n.id]!=null&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(t,s)){let o=i[s],l=t[s];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return I.create({doc:t.doc,selection:v.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Xi.resolve(t.extensions||[],new Map),i=t.doc instanceof W?t.doc:W.of((t.doc||"").split(e.staticFacet(I.lineSeparator)||ar)),n=t.selection?t.selection instanceof v?t.selection:v.single(t.selection.anchor,t.selection.head):v.single(0);return ol(n,i.length),e.staticFacet(dr)||(n=n.asSingle()),new I(e,i,n,e.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(I.tabSize)}get lineBreak(){return this.facet(I.lineSeparator)||`
|
|
@@ -9,4 +9,4 @@ import{O as Th,q as Rt}from"./index-CnTuJQbj.js";import{I as Dh,a as As,f as Eh,
|
|
|
9
9
|
`,n=r.state.doc.line(n.number+(e?1:-1)),s=r.bidiSpans(n),h=r.visualLineSide(n,!e)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function Xc(r,t,e){let i=r.state.charCategorizer(t),n=i(e);return s=>{let o=i(s);return n==G.Space&&(n=o),n==o}}function Qc(r,t,e,i){let n=t.head,s=e?1:-1;if(n==(e?r.state.doc.length:0))return v.cursor(n,t.assoc);let o=t.goalColumn,l,a=r.contentDOM.getBoundingClientRect(),h=r.coordsAtPos(n,t.assoc||((t.empty?e:t.head==t.from)?1:-1)),c=r.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=r.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,r.defaultCharacterWidth*(n-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=r.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let g=l+(d+p)*s,m=Br(r,{x:f,y:g},!1,s);if(e?g>a.bottom:g<a.top)return v.cursor(m.pos,m.assoc);let w=r.coordsAtPos(m.pos,m.assoc),y=w?(w.top+w.bottom)/2:0;if(!w||(e?y>l:y<l))return v.cursor(m.pos,m.assoc,void 0,o)}}function oi(r,t,e){for(;;){let i=0;for(let n of r)n.between(t-1,t+1,(s,o,l)=>{if(t>s&&t<o){let a=i||e||(t-s<o-t?-1:1);t=a<0?s:o,i=a}});if(!i)return t}}function Gl(r,t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let o=oi(r,n.from,0);o!=n.from&&(s=v.cursor(o,-1))}else{let o=oi(r,n.from,-1),l=oi(r,n.to,1);(o!=n.from||l!=n.to)&&(s=v.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?v.create(e,t.mainIndex):t}function Un(r,t,e){let i=oi(r.state.facet(bi).map(n=>n(r)),e.from,t.head>e.from?-1:1);return i==e.from?e:v.cursor(i,i<e.from?1:-1)}class Vt{constructor(t,e){this.pos=t,this.assoc=e}}function Br(r,t,e,i){let n=r.contentDOM.getBoundingClientRect(),s=n.top+r.viewState.paddingTop,{x:o,y:l}=t,a=l-s,h;for(;;){if(a<0)return new Vt(0,1);if(a>r.viewState.docHeight)return new Vt(r.state.doc.length,-1);if(h=r.elementAtHeight(a),i==null)break;if(h.type==ft.Text){if(i<0?h.to<r.viewport.from:h.from>r.viewport.to)break;let u=r.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+s:u.bottom>=a+s))break}let f=r.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(r.viewport.from>=h.to||r.viewport.to<=h.from){if(e)return null;if(h.type==ft.Text){let f=Gc(r,n,h,o,l);return new Vt(f,f==h.from?1:-1)}}if(h.type!=ft.Text)return a<(h.top+h.bottom)/2?new Vt(h.from,1):new Vt(h.to,-1);let c=r.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=r.docView.lineAt(h.from,-2)),new Zc(r,o,l,r.textDirectionAt(h.from)).scanTile(c,h.from)}class Zc{constructor(t,e,i,n){this.view=t,this.x=e,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:i,spans:n}=this.bidiSpansAt(t);return n[Ft.find(n,t-i.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:i,spans:n}=this.bidiSpansAt(t);return n[Ft.find(n,t-i.from,-1,e)].dir}bidiIn(t,e){let{spans:i,line:n}=this.bidiSpansAt(t);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<e)}scan(t,e,i=!1){let n=0,s=t.length-1,o=new Set,l=this.bidiIn(t[0],t[s]),a,h,c=-1,f=1e9,u;t:for(;n<s;){let p=s-n,g=n+s>>1;e:if(o.has(g)){let w=n+Math.floor(Math.random()*p);for(let y=0;y<p;y++){if(!o.has(w)){g=w;break e}w++,w==s&&(w=n)}break t}o.add(g);let m=e(g);if(m)for(let w=0;w<m.length;w++){let y=m[w],C=0;if(!(y.width==0&&m.length>1)){if(y.bottom<this.y)(!a||a.bottom<y.bottom)&&(a=y),C=1;else if(y.top>this.y)(!h||h.top>y.top)&&(h=y),C=-1;else{let T=y.left>this.x?this.x-y.left:y.right<this.x?this.x-y.right:0,S=Math.abs(T);S<f&&(c=g,f=S,u=y),T&&(C=T<0==(this.baseDir==_.LTR)?-1:1)}C==-1&&(!l||this.baseDirAt(t[g],1))?s=g:C==1&&(!l||this.baseDirAt(t[g+1],-1))&&(n=g+1)}}}if(!u){let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(t,e,!0)}if(f&&!i){let{top:p,bottom:g}=u;if(a&&a.bottom>(p+p+g)/3)return this.y=a.bottom-1,this.scan(t,e,!0);if(h&&h.top<(p+g+g)/3)return this.y=h.top+1,this.scan(t,e,!0)}let d=(l?this.dirAt(t[c],1):this.baseDir)==_.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(t,e){let i=[];for(let s=0;s<t.length;s=tt(t.text,s))i.push(e+s);i.push(e+t.length);let n=this.scan(i,s=>{let o=i[s]-e,l=i[s+1]-e;return di(t.dom,o,l).getClientRects()});return n.after?new Vt(i[n.i+1],-1):new Vt(i[n.i],1)}scanTile(t,e){if(!t.length)return new Vt(e,1);if(t.children.length==1){let l=t.children[0];if(l.isText())return this.scanText(l,e);if(l.isComposite())return this.scanTile(l,e)}let i=[e];for(let l=0,a=e;l<t.children.length;l++)i.push(a+=t.children[l].length);let n=this.scan(i,l=>{let a=t.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:di(a.dom,0,a.length)).getClientRects()}),s=t.children[n.i],o=i[n.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):n.after?new Vt(i[n.i+1],-1):new Vt(o,1)}}const Ce="";class tf{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(I.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Ce}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let s=this.text.length;this.readNode(n);let o=U.get(n),l=n.nextSibling;if(l==e){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=U.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:tn(n))||tn(l)&&(n.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!nf(l,e)&&this.lineBreak(),n=l}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(e))&&(s=l.index,o=l[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==t&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(t){let e=U.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(ef(t,i.node,i.offset)?e:0))}}function ef(r,t,e){for(;;){if(!t||e<Yt(t))return!1;if(t==r)return!0;e=oe(t)+1,t=t.parentNode}}function nf(r,t){let e;for(;!(r==t||!r);r=r.nextSibling){let i=U.get(r);if(!i?.isWidget())return!1;i&&(e||(e=[])).push(i)}if(e){for(let i of e)if(i.overrideDOMText?.length)return!1}return!0}class Gs{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class rf{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView,l=t.state.selection;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=_l(t.docView.tile,e,i,0))){let a=s||o?[]:of(t),h=new tf(a,t);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=lf(a,this.bounds.from)}else{let a=t.observer.selectionRange,h=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Mr(t.contentDOM,a.focusNode)?l.main.head:t.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Mr(t.contentDOM,a.anchorNode)?l.main.anchor:t.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=t.viewport;if((M.ios||M.chrome)&&l.main.empty&&h!=c&&(f.from>0||f.to<t.state.doc.length)){let u=Math.min(h,c),d=Math.max(h,c),p=f.from-u,g=f.to-d;(p==0||p==1||u==0)&&(g==0||g==-1||d==t.state.doc.length)&&(h=0,c=t.state.doc.length)}if(t.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(v.range(c,h));else if(t.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&t.inputState.lastTouchTime>Date.now()-100){let u=t.coordsAtPos(h,-1),d=0;u&&(d=t.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=v.create([v.cursor(h,d)])}else this.newSel=v.single(c,h)}}}function _l(r,t,e,i){if(r.isComposite()){let n=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<r.children.length;a++){let f=r.children[a],u=h+f.length;if(h<t&&u>e)return _l(f,t,e,h);if(u>=t&&n==-1&&(n=a,s=h),h>e&&f.dom.parentNode==r.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+r.length:l,startDOM:(n?r.children[n-1].dom.nextSibling:null)||r.dom.firstChild,endDOM:o<r.children.length&&o>=0?r.children[o].dom:null}}else return r.isText()?{from:i,to:i+r.length,startDOM:r.dom,endDOM:r.dom.nextSibling}:null}function Yl(r,t){let e,{newSel:i}=t,{state:n}=r,s=n.selection.main,o=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(t.bounds){let{from:l,to:a}=t.bounds,h=s.from,c=null;(o===8||M.android&&t.text.length<a-l)&&(h=s.to,c="end");let f=n.doc.sliceString(l,a,Ce),u,d;!s.empty&&s.from>=l&&s.to<=a&&(t.typeOver||f!=t.text)&&f.slice(0,s.from-l)==t.text.slice(0,s.from-l)&&f.slice(s.to-l)==t.text.slice(u=t.text.length-(f.length-(s.to-l)))?e={from:s.from,to:s.to,insert:W.of(t.text.slice(s.from-l,u).split(Ce))}:(d=Xl(f,t.text,h-l,c))&&(M.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==Ce+Ce&&d.toB--,e={from:l+d.from,to:l+d.toA,insert:W.of(t.text.slice(d.from,d.toB).split(Ce))})}else i&&(!r.hasFocus&&n.facet(Jt)||on(i,s))&&(i=null);if(!e&&!i)return!1;if((M.mac||M.android)&&e&&e.from==e.to&&e.from==s.head-1&&/^\. ?$/.test(e.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=v.single(i.main.anchor-1,i.main.head-1)),e={from:e.from,to:e.to,insert:W.of([e.insert.toString().replace("."," ")])}):n.doc.lineAt(s.from).to<s.to&&r.docView.lineHasWidget(s.to)&&r.inputState.insertingTextAt>Date.now()-50?e={from:s.from,to:s.to,insert:n.toText(r.inputState.insertingText)}:M.chrome&&e&&e.from==e.to&&e.from==s.head&&e.insert.toString()==`
|
|
10
10
|
`&&r.lineWrapping&&(i&&(i=v.single(i.main.anchor-1,i.main.head-1)),e={from:s.from,to:s.to,insert:W.of([" "])}),e)return os(r,e,i,o);if(i&&!on(i,s)){let l=!1,a="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(l=!0),a=r.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=Gl(n.facet(bi).map(h=>h(r)),i))),r.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function os(r,t,e,i=-1){if(M.ios&&r.inputState.flushIOSKey(t))return!0;let n=r.state.selection.main;if(M.android&&(t.to==n.to&&(t.from==n.from||t.from==n.from-1&&r.state.sliceDoc(t.from,n.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Pe(r.contentDOM,"Enter",13)||(t.from==n.from-1&&t.to==n.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from&&t.to>n.head)&&Pe(r.contentDOM,"Backspace",8)||t.from==n.from&&t.to==n.to+1&&t.insert.length==0&&Pe(r.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let o,l=()=>o||(o=sf(r,t,e));return r.state.facet(Il).some(a=>a(r,t.from,t.to,s,l))||r.dispatch(l()),!0}function sf(r,t,e){let i,n=r.state,s=n.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let a=t.from<s.from?-1:1,h=a<0?s.from:s.to,c=oi(n.facet(bi).map(f=>f(r)),h,a);t.from==c&&(o=c)}if(o>-1)i={changes:t,selection:v.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&r.inputState.composing<0){let a=s.from<t.from?n.sliceDoc(s.from,t.from):"",h=s.to>t.to?n.sliceDoc(t.to,s.to):"";i=n.replaceSelection(r.state.toText(a+t.insert.sliceString(0,void 0,r.state.lineBreak)+h))}else{let a=n.changes(t),h=e&&e.main.to<=a.newLength?e.main:void 0;if(n.selection.ranges.length>1&&(r.inputState.composing>=0||r.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let c=r.state.sliceDoc(t.from,t.to),f,u=e&&Jl(r,e.main.head);if(u){let p=t.insert.length-(t.to-t.from);f={from:u.from,to:u.to-p}}else f=r.state.doc.lineAt(s.head);let d=s.to-t.to;i=n.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:h||p.map(a)};let g=p.to-d,m=g-c.length;if(r.state.sliceDoc(m,g)!=c||g>=f.from&&m<=f.to)return{range:p};let w=n.changes({from:m,to:g,insert:t.insert}),y=p.to-s.to;return{changes:w,range:h?v.range(Math.max(0,h.anchor+y),Math.max(0,h.head+y)):p.map(w)}})}else i={changes:a,selection:h&&n.selection.replaceRange(h)}}let l="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,l+=".compose",r.inputState.compositionFirstChange&&(l+=".start",r.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function Xl(r,t,e,i){let n=Math.min(r.length,t.length),s=0;for(;s<n&&r.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==n&&r.length==t.length)return null;let o=r.length,l=t.length;for(;o>0&&l>0&&r.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));e-=o+a-s}if(o<s&&r.length<t.length){let a=e<=s&&e>=o?s-e:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=e<=s&&e>=l?s-e:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function of(r){let t=[];if(r.root.activeElement!=r.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:s}=r.observer.selectionRange;return e&&(t.push(new Gs(e,i)),(n!=e||s!=i)&&t.push(new Gs(n,s))),t}function lf(r,t){if(r.length==0)return null;let e=r[0].pos,i=r.length==2?r[1].pos:e;return e>-1&&i>-1?v.single(e+t,i+t):null}function on(r,t){return t.head==r.main.head&&t.anchor==r.main.anchor}class af{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=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.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,M.safari&&t.contentDOM.addEventListener("input",()=>null),M.gecko&&Sf(t.contentDOM.ownerDocument)}handleEvent(t){!mf(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let n of i.observers)n(this.view,e);for(let n of i.handlers){if(e.defaultPrevented)break;if(n(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=hf(t),i=this.handlers,n=this.view.contentDOM;for(let s in e)if(s!="scroll"){let o=!e[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(n.removeEventListener(s,this.handleEvent),l=null),l||n.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!e[s]&&n.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&Zl.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),M.android&&M.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return M.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&!t.shiftKey&&((e=Ql.find(i=>i.keyCode==t.keyCode))&&!t.ctrlKey||cf.indexOf(t.key)>-1&&t.ctrlKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,Pe(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:M.safari&&!M.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function _s(r,t){return(e,i)=>{try{return t.call(r,i,e)}catch(n){qt(e.state,n)}}}function hf(r){let t=Object.create(null);function e(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of r){let n=i.spec,s=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&e(l).handlers.push(_s(i.value,a))}if(o)for(let l in o){let a=o[l];a&&e(l).observers.push(_s(i.value,a))}}for(let i in Tt)e(i).handlers.push(Tt[i]);for(let i in ut)e(i).observers.push(ut[i]);return t}const Ql=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],cf="dthko",Zl=[16,17,18,20,91,92,224,225],Ei=6;function Bi(r){return Math.max(0,r)*.7+8}function ff(r,t){return Math.max(Math.abs(r.clientX-t.clientX),Math.abs(r.clientY-t.clientY))}class uf{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=kl(t.contentDOM),this.atoms=t.state.facet(bi).map(o=>o(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(I.allowMultipleSelections)&&df(t,e),this.dragging=gf(t,e)&&ia(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&ff(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,n=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=$l(this.view);t.clientX-a.left<=n+Ei?e=-Bi(n-t.clientX):t.clientX+a.right>=o-Ei&&(e=Bi(t.clientX-o)),t.clientY-a.top<=s+Ei?i=-Bi(s-t.clientY):t.clientY+a.bottom>=l-Ei&&(i=Bi(t.clientY-l)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=Gl(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function df(r,t){let e=r.state.facet(Ll);return e.length?e[0](t):M.mac?t.metaKey:t.ctrlKey}function pf(r,t){let e=r.state.facet(Rl);return e.length?e[0](t):M.mac?!t.altKey:!t.ctrlKey}function gf(r,t){let{main:e}=r.state.selection;if(e.empty)return!1;let i=ui(r.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let s=0;s<n.length;s++){let o=n[s];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function mf(r,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=r.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=U.get(e))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0}const Tt=Object.create(null),ut=Object.create(null),ta=M.ie&&M.ie_version<15||M.ios&&M.webkit_version<604;function wf(r){let t=r.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{r.focus(),e.remove(),ea(r,e.value)},50)}function Tn(r,t,e){for(let i of r.facet(t))e=i(e,r);return e}function ea(r,t){t=Tn(r.state,is,t);let{state:e}=r,i,n=1,s=e.toText(t),o=s.lines==e.selection.ranges.length;if(Lr!=null&&e.selection.ranges.every(l=>l.empty)&&Lr==s.toString()){let l=-1;i=e.changeByRange(a=>{let h=e.doc.lineAt(a.from);if(h.from==l)return{range:a};l=h.from;let c=e.toText((o?s.line(n++).text:t)+e.lineBreak);return{changes:{from:h.from,insert:c},range:v.cursor(a.from+c.length)}})}else o?i=e.changeByRange(l=>{let a=s.line(n++);return{changes:{from:l.from,to:l.to,insert:a.text},range:v.cursor(l.from+a.length)}}):i=e.replaceSelection(s);r.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ut.scroll=r=>{r.inputState.lastScrollTop=r.scrollDOM.scrollTop,r.inputState.lastScrollLeft=r.scrollDOM.scrollLeft};ut.wheel=ut.mousewheel=r=>{r.inputState.lastWheelEvent=Date.now()};Tt.keydown=(r,t)=>(r.inputState.setSelectionOrigin("select"),t.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);ut.touchstart=(r,t)=>{let e=r.inputState,i=t.targetTouches[0];e.lastTouchTime=Date.now(),i&&(e.lastTouchX=i.clientX,e.lastTouchY=i.clientY),e.setSelectionOrigin("select.pointer")};ut.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};Tt.mousedown=(r,t)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let i of r.state.facet(Pl))if(e=i(r,t),e)break;if(!e&&t.button==0&&(e=yf(r,t)),e){let i=!r.hasFocus;r.inputState.startMouseSelection(new uf(r,t,e,i)),i&&r.observer.ignore(()=>{Sl(r.contentDOM);let s=r.root.activeElement;s&&!s.contains(r.contentDOM)&&s.blur()});let n=r.inputState.mouseSelection;if(n)return n.start(t),n.dragging===!1}else r.inputState.setSelectionOrigin("select.pointer");return!1};function Ys(r,t,e,i){if(i==1)return v.cursor(t,e);if(i==2)return Jc(r.state,t,e);{let n=r.docView.lineAt(t,e),s=r.state.doc.lineAt(n?n.posAtEnd:t),o=n?n.posAtStart:s.from,l=n?n.posAtEnd:s.to;return l<r.state.doc.length&&l==s.to&&l++,v.range(o,l)}}const vf=M.ie&&M.ie_version<=11;let Xs=null,Qs=0,Zs=0;function ia(r){if(!vf)return r.detail;let t=Xs,e=Zs;return Xs=r,Zs=Date.now(),Qs=!t||e>Date.now()-400&&Math.abs(t.clientX-r.clientX)<2&&Math.abs(t.clientY-r.clientY)<2?(Qs+1)%3:1}function yf(r,t){let e=r.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=ia(t),n=r.state.selection;return{update(s){s.docChanged&&(e.pos=s.changes.mapPos(e.pos),n=n.map(s.changes))},get(s,o,l){let a=r.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,c=Ys(r,a.pos,a.assoc,i);if(e.pos!=a.pos&&!o){let f=Ys(r,e.pos,e.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?v.range(u,d,c.assoc):v.range(d,u,c.assoc)}return o?n.replaceRange(n.main.extend(c.from,c.to,c.assoc)):l&&i==1&&n.ranges.length>1&&(h=bf(n,a.pos))?h:l?n.addRange(c):v.create([c])}}}function bf(r,t){for(let e=0;e<r.ranges.length;e++){let{from:i,to:n}=r.ranges[e];if(i<=t&&n>=t)return v.create(r.ranges.slice(0,e).concat(r.ranges.slice(e+1)),r.mainIndex==e?0:r.mainIndex-(r.mainIndex>e?1:0))}return null}Tt.dragstart=(r,t)=>{let{selection:{main:e}}=r.state;if(t.target.draggable){let n=r.docView.tile.nearest(t.target);if(n&&n.isWidget()){let s=n.posAtStart,o=s+n.length;(s>=e.to||o<=e.from)&&(e=v.range(s,o))}}let{inputState:i}=r;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",Tn(r.state,ns,r.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};Tt.dragend=r=>(r.inputState.draggedContent=null,!1);function to(r,t,e,i){if(e=Tn(r.state,is,e),!e)return;let n=r.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=r.inputState,o=i&&s&&pf(r,t)?{from:s.from,to:s.to}:null,l={from:n,insert:e},a=r.state.changes(o?[o,l]:l);r.focus(),r.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),r.inputState.draggedContent=null}Tt.drop=(r,t)=>{if(!t.dataTransfer)return!1;if(r.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let i=Array(e.length),n=0,s=()=>{++n==e.length&&to(r,t,i.filter(o=>o!=null).join(r.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(e[o])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return to(r,t,i,!0),!0}return!1};Tt.paste=(r,t)=>{if(r.state.readOnly)return!0;r.observer.flush();let e=ta?null:t.clipboardData;return e?(ea(r,e.getData("text/plain")||e.getData("text/uri-list")),!0):(wf(r),!1)};function xf(r,t){let e=r.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),r.focus()},50)}function kf(r){let t=[],e=[],i=!1;for(let n of r.selection.ranges)n.empty||(t.push(r.sliceDoc(n.from,n.to)),e.push(n));if(!t.length){let n=-1;for(let{from:s}of r.selection.ranges){let o=r.doc.lineAt(s);o.number>n&&(t.push(o.text),e.push({from:o.from,to:Math.min(r.doc.length,o.to+1)})),n=o.number}i=!0}return{text:Tn(r,ns,t.join(r.lineBreak)),ranges:e,linewise:i}}let Lr=null;Tt.copy=Tt.cut=(r,t)=>{if(!ri(r.contentDOM,r.observer.selectionRange))return!1;let{text:e,ranges:i,linewise:n}=kf(r.state);if(!e&&!n)return!1;Lr=n?e:null,t.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=ta?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",e),!0):(xf(r,e),!1)};const na=he.define();function ra(r,t){let e=[];for(let i of r.facet(Wl)){let n=i(r,t);n&&e.push(n)}return e.length?r.update({effects:e,annotations:na.of(!0)}):null}function sa(r){setTimeout(()=>{let t=r.hasFocus;if(t!=r.inputState.notifiedFocused){let e=ra(r.state,t);e?r.dispatch(e):r.update([])}},10)}ut.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),sa(r)};ut.blur=r=>{r.observer.clearSelectionRange(),sa(r)};ut.compositionstart=ut.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))};ut.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,M.chrome&&M.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};ut.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};Tt.beforeinput=(r,t)=>{var e,i;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(r.inputState.insertingText=t.data,r.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&r.observer.editContext){let s=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),o=t.getTargetRanges();if(s&&o.length){let l=o[0],a=r.posAtDOM(l.startContainer,l.startOffset),h=r.posAtDOM(l.endContainer,l.endOffset);return os(r,{from:a,to:h,insert:r.state.toText(s)},null),!0}}let n;if(M.chrome&&M.android&&(n=Ql.find(s=>s.inputType==t.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return M.ios&&t.inputType=="deleteContentForward"&&r.observer.flushSoon(),M.safari&&t.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>ut.compositionend(r,t),20),!1};const eo=new Set;function Sf(r){eo.has(r)||(eo.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const io=["pre-wrap","normal","pre-line","break-spaces"];let qe=!1;function no(){qe=!1}class Af{constructor(t){this.lineWrapping=t,this.doc=W.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return io.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(e=!0,this.heightSamples[Math.floor(n*10)]=!0)}return e}refresh(t,e,i,n,s,o){let l=io.indexOf(t)>-1,a=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class Mf{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Mt{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return typeof this._content=="number"?ft.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 xe?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Mt(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var z=(function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r})(z||(z={}));const Gi=.001;class at{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>Gi&&(qe=!0),this.height=t)}replace(t,e,i){return at.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=n[l],u=s.lineAt(a,z.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=h?u:s.lineAt(h,z.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,c=n[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,z.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let p=ls.build(i.setDoc(o),t,c,f);s=ln(s,s.replace(a,h,p))}return s.updateHeight(i,0)}static empty(){return new gt(0,0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>s*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(s>n*2){let l=t[i];l.break?t.splice(i,1,l.left,null,l.right):t.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(n<s){let l=t[e++];l&&(n+=l.size)}else{let l=t[--i];l&&(s+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,i++),new Of(at.of(t.slice(0,e)),o,at.of(t.slice(i)))}}function ln(r,t){return r==t?r:(r.constructor!=t.constructor&&(qe=!0),t)}at.prototype.size=1;const Cf=P.replace({});class oa extends at{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new Mt(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,n){return this.spaceAbove&&t<i+this.spaceAbove?new Mt(n,0,i,this.spaceAbove,Cf):this.mainBlock(i,n)}lineAt(t,e,i,n,s){let o=this.mainBlock(n,s);return this.spaceAbove?this.blockAt(0,i,n,s).join(o):o}forEachLine(t,e,i,n,s,o){t<=s+this.length&&e>=s&&o(this.lineAt(0,z.ByPos,i,n,s))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class gt extends oa{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new Mt(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let n=i[0];return i.length==1&&(n instanceof gt||n instanceof it&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof it?n=new gt(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):at.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class it extends at{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,s=n-i+1,o,l=0;if(t.lineWrapping){let a=Math.min(this.height,t.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(t,e,i,n){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(e,n);if(e.lineWrapping){let h=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),c=e.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,t-f/2);return new Mt(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((t-i)/l))),{from:c,length:f}=e.doc.line(s+h);return new Mt(c,f,i+l*h,l,0)}}lineAt(t,e,i,n,s){if(e==z.ByHeight)return this.blockAt(t,i,n,s);if(e==z.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(t);return new Mt(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(t),c=l+h.length*a,f=h.number-o,u=n+l*f+a*(h.from-s-f);return new Mt(h.from,h.length,Math.max(n,Math.min(u,n+this.height-c)),c,0)}forEachLine(t,e,i,n,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=t,f=n;c<=e;){let u=i.doc.lineAt(c);if(c==t){let p=u.number-l;f+=a*p+h*(t-s-p)}let d=a+h*u.length;o(new Mt(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let s=i[i.length-1];s instanceof it?i[i.length-1]=new it(s.length+n):i.push(null,new it(n-1))}if(t>0){let s=i[0];s instanceof it?i[0]=new it(t+s.length):i.unshift(new it(t-1),null)}return at.of(i)}decomposeLeft(t,e){e.push(new it(t-1),null)}decomposeRight(t,e){e.push(null,new it(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let o=[],l=Math.max(e,n.from),a=-1;for(n.from>e&&o.push(new it(n.from-e-1).updateHeight(t,e));l<=s&&n.more;){let c=t.doc.lineAt(l).length;o.length&&o.push(null);let f=n.heights[n.index++],u=0;f<0&&(u=-f,f=n.heights[n.index++]),a==-1?a=f:Math.abs(f-a)>=Gi&&(a=-2);let d=new gt(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new it(s-l).updateHeight(t,l));let h=at.of(o);return(a<0||Math.abs(h.height-this.height)>=Gi||Math.abs(a-this.heightMetrics(t,e).perLine)>=Gi)&&(qe=!0),ln(this,h)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Of extends at{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let o=n+this.left.height,l=s+this.left.length+this.break,a=e==z.ByHeight?t<o:t<l,h=a?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=e==z.ByPosNoHeight?z.ByPosNoHeight:z.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,n,s).join(h)}forEachLine(t,e,i,n,s,o){let l=n+this.left.height,a=s+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,n,s,o),e>=a&&this.right.forEachLine(t,e,i,l,a,o);else{let h=this.lineAt(a,z.ByPos,i,n,s);t<h.from&&this.left.forEachLine(t,h.from-1,i,n,s,o),h.to>=t&&h.from<=e&&o(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,l,a,o)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let l of i)s.push(l);if(t>0&&ro(s,o-1),e<this.length){let l=s.length;this.decomposeRight(e,s),ro(s,l)}return at.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?at.of(this.break?[t,null,e]:[t,e]):(this.left=ln(this.left,t),this.right=ln(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:o}=this,l=e+s.length+this.break,a=null;return n&&n.from<=e+s.length&&n.more?a=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(t,l,i,n):o.updateHeight(t,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ro(r,t){let e,i;r[t]==null&&(e=r[t-1])instanceof it&&(i=r[t+1])instanceof it&&r.splice(t-1,3,new it(e.length+1+i.length))}const Tf=5;class ls{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let i=Math.min(e,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof gt?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new gt(i-this.pos,-1,0)),this.writtenTo=i,e>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new oa(o,n,i)):(o||s||n>=Tf)&&this.addLineDeco(n,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new gt(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new it(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof gt)return t;let e=new gt(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof gt)&&!this.isCovered?this.nodes.push(new gt(0,-1,0)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=t;for(let n of this.nodes)n instanceof gt&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let s=new ls(i,t);return R.spans(e,i,n,s,0),s.finish(i)}}function Df(r,t,e){let i=new Ef;return R.compare(r,t,e,i,0),i.changes}class Ef{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Re(t,e,this.changes,5)}}function Bf(r,t){let e=r.getBoundingClientRect(),i=r.ownerDocument,n=i.defaultView||window,s=Math.max(0,e.left),o=Math.min(n.innerWidth,e.right),l=Math.max(0,e.top),a=Math.min(n.innerHeight,e.bottom);for(let h=r.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==r.parentNode?n.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-e.left,right:Math.max(s,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,a)-(e.top+t)}}function Lf(r){let t=r.getBoundingClientRect(),e=r.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function Rf(r,t){let e=r.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class Jn{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return P.replace({widget:new Pf(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Pf extends $e{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class so{constructor(t,e){this.view=t,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.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=oo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=_.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=e.facet(rs).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Af(i),this.stateDeco=lo(e),this.heightMap=at.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle.setDoc(e.doc),[new xt(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=P.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:s,to:o})=>n>=s&&n<=o)){let{from:s,to:o}=this.lineBlockAt(n);t.push(new Li(s,o))}}return this.viewports=t.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?oo:new as(this.heightOracle,this.heightMap,this.viewports),t.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,t=>{this.viewportLines.push(ei(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=lo(this.state);let n=t.changedRanges,s=xt.extendWithRanges(n,Df(i,this.stateDeco,t?t.changes:X.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);no(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||qe)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(h||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Ac)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?_.RTL:_.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:S,scaleY:A}=xl(e,l);(S>.005&&Math.abs(this.scaleX-S)>.005||A>.005&&Math.abs(this.scaleY-A)>.005)&&(this.scaleX=S,this.scaleY=A,h|=16,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=16);let d=kl(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Al(this.scrollParent||t.win);let g=(this.printing?Rf:Bf)(e,this.paddingTop),m=g.top-this.pixelViewport.top,w=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!Lf(t.dom))return 0;let C=l.width;if((this.contentDOMWidth!=C||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,h|=16),a){let S=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(S)&&(o=!0),o||n.lineWrapping&&Math.abs(C-this.contentDOMWidth)>n.charWidth){let{lineHeight:A,charWidth:x,textHeight:E}=t.docView.measureTextSize();o=A>0&&n.refresh(s,A,x,E,Math.max(5,C/x),S),o&&(t.docView.minWidth=0,h|=16)}m>0&&w>0?c=Math.max(m,w):m<0&&w<0&&(c=Math.min(m,w)),no();for(let A of this.viewports){let x=A.from==this.viewport.from?S:t.docView.measureVisibleLineHeights(A);this.heightMap=(o?at.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle,[new xt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Mf(A.from,x))}qe&&(h|=2)}let T=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return T&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||T)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Li(n.lineAt(o-i*1e3,z.ByHeight,s,0,0).from,n.lineAt(l+(1-i)*1e3,z.ByHeight,s,0,0).to);if(e){let{head:h}=e.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=n.lineAt(h,z.ByPos,s,0,0),u;e.y=="center"?u=(f.top+f.bottom)/2-c/2:e.y=="start"||e.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Li(n.lineAt(u-1e3/2,z.ByHeight,s,0,0).from,n.lineAt(u+c+1e3/2,z.ByHeight,s,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Li(this.heightMap.lineAt(i,z.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,z.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,z.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,z.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&s<l+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new Jn(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=_.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-c<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let w of g)if(w>c&&w<f){a(c,w-10,u,d),a(w+10,f,u,d);return}let m=If(t,w=>w.from>=u.from&&w.to<=u.to&&Math.abs(w.from-c)<s&&Math.abs(w.to-f)<s&&!g.some(y=>w.from<y&&w.to>y));if(!m){if(f<u.to&&e&&i&&e.visibleRanges.some(C=>C.from<=f&&C.to>=f)){let C=e.moveToLineBoundary(v.cursor(f),!1,!0).head;C>c&&(f=C)}let w=this.gapSize(u,c,f,d),y=i||w<2e6?w:2e6;m=new Jn(c,f,w,y)}l.push(m)},h=c=>{if(c.length<o||c.type!=ft.Text)return;let f=Nf(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,w;if(u!=null){let y=Pi(f,u),C=((this.visibleBottom-this.visibleTop)/2+g)/c.height;m=y-C,w=y+C}else m=(this.visibleTop-c.top-g)/c.height,w=(this.visibleBottom-c.top+g)/c.height;d=Ri(f,m),p=Ri(f,w)}else{let g=f.total*this.heightOracle.charWidth,m=n*this.heightOracle.charWidth,w=0;if(g>2e6)for(let A of t)A.from>=c.from&&A.from<c.to&&A.size!=A.displaySize&&A.from*this.heightOracle.charWidth+w<this.pixelViewport.left&&(w=A.size-A.displaySize);let y=this.pixelViewport.left+w,C=this.pixelViewport.right+w,T,S;if(u!=null){let A=Pi(f,u),x=((C-y)/2+m)/g;T=A-x,S=A+x}else T=(y-m)/g,S=(C+m)/g;d=Ri(f,T),p=Ri(f,S)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(t,e,i,n){let s=Pi(n,i)-Pi(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Jn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=P.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];R.spans(e,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let s=0;s<i.length&&!(n&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(n|=4,t&&t.mapPos(o.from,-1)==l.from&&t.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||ei(this.heightMap.lineAt(t,z.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||ei(this.heightMap.lineAt(this.scaler.fromDOM(t),z.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return ei(this.heightMap.blockAt(this.scaler.fromDOM(t),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 Li{constructor(t,e){this.from=t,this.to=e}}function Nf(r,t,e){let i=[],n=r,s=0;return R.spans(e,r,t,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),s+=o-n),n=l}},20),n<t&&(i.push({from:n,to:t}),s+=t-n),{total:s,ranges:i}}function Ri({total:r,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let i=Math.floor(r*e);for(let n=0;;n++){let{from:s,to:o}=t[n],l=o-s;if(i<=l)return s+i;i-=l}}function Pi(r,t){let e=0;for(let{from:i,to:n}of r.ranges){if(t<=n){e+=t-i;break}e+=n-i}return e/r.total}function If(r,t){for(let e of r)if(t(e))return e}const oo={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};function lo(r){let t=r.facet(Mn).filter(i=>typeof i!="function"),e=r.facet(ss).filter(i=>typeof i!="function");return e.length&&t.push(R.join(e)),t}class as{constructor(t,e,i){let n=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=e.lineAt(l,z.ByPos,t,0,0).top,c=e.lineAt(a,z.ByPos,t,0,0).bottom;return n+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof as?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to):!1}}function ei(r,t){if(t.scale==1)return r;let e=t.toDOM(r.top),i=t.toDOM(r.bottom);return new Mt(r.from,r.length,e,i-e,Array.isArray(r._content)?r._content.map(n=>ei(n,t)):r._content)}const Ni=O.define({combine:r=>r.join(" ")}),Rr=O.define({combine:r=>r.indexOf(!0)>-1}),Pr=re.newName(),la=re.newName(),aa=re.newName(),ha={"&light":"."+la,"&dark":"."+aa};function Nr(r,t,e){return new re(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return r;if(!e||!e[n])throw new RangeError(`Unsupported selector: ${n}`);return e[n]}):r+" "+i}})}const Wf=Nr("."+Pr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".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",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".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",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".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"}},ha),Hf={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Gn=M.ie&&M.ie_version<=11;class Vf{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new uc,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=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(M.ie&&M.ie_version<=11||M.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&M.android&&t.constructor.EDIT_CONTEXT!==!1&&!(M.chrome&&M.chrome_version<126)&&(this.editContext=new qf(t),t.state.facet(Jt)&&(t.contentDOM.editContext=this.editContext.editContext)),Gn&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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 e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Jt)?i.root.activeElement!=this.dom:!ri(this.dom,n))return;let s=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(M.ie&&M.ie_version<=11||M.android&&M.chrome)&&!i.state.selection.main.empty&&n.focusNode&&si(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ui(t.root);if(!e)return!1;let i=M.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&Ff(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=ri(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&pc(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Hf),Gn&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Gn&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let n=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Pe(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.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 t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let o=this.readMutation(s);o&&(o.typeOver&&(n=!0),e==-1?{from:e,to:i}=o:(e=Math.min(o.from,e),i=Math.max(o.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&ri(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new rf(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Yl(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!on(this.view.state.selection,e.newSel.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let i=ao(e,t.previousSibling||t.target.previousSibling,-1),n=ao(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Jt)!=t.state.facet(Jt)&&(t.view.contentDOM.editContext=t.state.facet(Jt)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ao(r,t,e){for(;t;){let i=U.get(t);if(i&&i.parent==r)return i;let n=t.parentNode;t=n!=r.dom?n:e>0?t.nextSibling:t.previousSibling}return null}function ho(r,t){let e=t.startContainer,i=t.startOffset,n=t.endContainer,s=t.endOffset,o=r.docView.domAtPos(r.state.selection.main.anchor,1);return si(o.node,o.offset,n,s)&&([e,i,n,s]=[n,s,e,i]),{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:s}}function Ff(r,t){if(t.getComposedRanges){let n=t.getComposedRanges(r.root)[0];if(n)return ho(r,n)}let e=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),e=n.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",i,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",i,!0),e?ho(r,e):null}class qf{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:s,head:o}=n,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=Xl(t.state.sliceDoc(l,a),i.text,(h?n.from:n.to)-l,h?"end":null);if(!c){let u=v.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));on(u,n)||t.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:W.of(i.text.slice(c.from,c.toB).split(`
|
|
11
11
|
`))};if((M.mac||M.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:W.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);os(t,f,v.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from<f.to&&!f.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=t.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(P.mark({attributes:{style:c}}).range(a,h))}}}t.dispatch({effects:Fl.of(P.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=ui(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((s,o,l,a,h)=>{if(i)return;let c=h.length-(o-s);if(n&&o>=n.to)if(n.from==s&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,e+=c,this.to+=c;return}else n=null,this.revertPending(t.state);if(s+=e,o+=e,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=c}e+=c}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class D{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var 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),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(n=>n.forEach(s=>i(s,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=t.root||dc(t.parent)||document,this.viewState=new so(this,t.state||I.create(t)),t.scrollTo&&t.scrollTo.is(Di)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(De).map(n=>new zn(n));for(let n of this.plugins)n.update(this);this.observer=new Vf(this),this.inputState=new af(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Us(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof Q?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,n,s=this.state;for(let u of t){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;t.some(u=>u.annotation(na))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=ra(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(I.phrases)!=this.state.facet(I.phrases))return this.setState(s);n=nn.create(this,s,t),n.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:g}=this.state.facet(D.cursorScrollMargin);f=new Ne(d.empty?d:v.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of u.effects)d.is(Di)&&(f=d.value.clip(this.state))}this.viewState.update(n,f),this.bidiCache=an.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),e=this.docView.update(n),this.state.facet(ti)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Ni)!=n.state.facet(Ni)&&(this.viewState.mustMeasureContent=!0),(e||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(Dr))try{u(n)}catch(d){qt(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Yl(this,c)&&h.force&&Pe(this.contentDOM,h.key,h.keyCode)})}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new so(this,t),this.plugins=t.facet(De).map(i=>new zn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Us(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(De),i=t.state.facet(De);if(e!=i){let n=[];for(let s of i){let o=e.indexOf(s);if(o<0)n.push(new zn(s));else{let l=this.plugins[o];l.mustUpdate=t,n.push(l)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){qt(this.state,i,"doc view update listener")}}}measure(t=!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,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Al(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(n);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return qt(this.state,p),co}}),f=nn.create(this,this.state,[]),u=!1;f.flags|=a,e?e.flags|=a:e=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(c[d]!=co)try{let p=h[d];p.write&&p.write(c[d],this)}catch(p){qt(this.state,p)}if(u&&this.docView.updateSelection(!0),!f.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 d=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((d>1||d<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+d,i?i.scrollTop+=d:this.win.scrollBy(0,d),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(Dr))l(e)}get themeClasses(){return Pr+" "+(this.state.facet(Rr)?aa:la)+" "+this.state.facet(Ni)}updateAttrs(){let t=fo(this,ql,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Jt)?"true":"false",class:"cm-content",style:`${M.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),fo(this,rs,e);let i=this.observer.ignore(()=>{let n=Fs(this.contentDOM,this.contentAttrs,e),s=Fs(this.dom,this.editorAttrs,t);return n||s});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let n of i.effects)if(n.is(D.announce)){e&&(this.announceDOM.textContent=""),e=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(ti);let t=this.state.facet(D.cspNonce);re.mount(this.root,this.styleModules.concat(Wf).reverse(),t?{nonce:t}: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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==t)||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Un(this,t,Js(this,t,e,i))}moveByGroup(t,e){return Un(this,t,Js(this,t,e,i=>Xc(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return v.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return Yc(this,t,e,i)}moveVertically(t,e,i){return Un(this,t,Qc(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=Br(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),Br(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n),o=s[Ft.find(s,t-n.from,-1,e)];return en(i,o.dir==_.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Hl)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>zf)return El(t.length);let e=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||Dl(s.isolates,i=js(this,t))))return s.order;i||(i=js(this,t));let n=xc(t.text,e,i);return this.bidiCache.push(new an(t.from,t.to,e,i,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||M.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Sl(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.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(t,e={}){var i,n,s,o;return Di.of(new Ne(typeof t=="number"?v.cursor(t):t,(i=e.y)!==null&&i!==void 0?i:"nearest",(n=e.x)!==null&&n!==void 0?n:"nearest",(s=e.yMargin)!==null&&s!==void 0?s:5,(o=e.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Di.of(new Ne(v.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return wt.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return wt.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=re.newName(),n=[Ni.of(i),ti.of(Nr(`.${i}`,t))];return e&&e.dark&&n.push(Rr.of(!0)),n}static baseTheme(t){return kn.lowest(ti.of(Nr("."+Pr,t,ha)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content");return((e=(i&&U.get(i)||U.get(t))?.root)===null||e===void 0?void 0:e.view)||null}}D.styleModule=ti;D.inputHandler=Il;D.clipboardInputFilter=is;D.clipboardOutputFilter=ns;D.scrollHandler=Vl;D.focusChangeEffect=Wl;D.perLineTextDirection=Hl;D.exceptionSink=Nl;D.updateListener=Dr;D.editable=Jt;D.mouseSelectionStyle=Pl;D.dragMovesSelection=Rl;D.clickAddsSelectionRange=Ll;D.decorations=Mn;D.blockWrappers=zl;D.outerDecorations=ss;D.atomicRanges=bi;D.bidiIsolatedRanges=jl;D.cursorScrollMargin=O.define({combine:r=>{let t=5,e=5;for(let i of r)typeof i=="number"?t=e=i:{x:t,y:e}=i;return{x:t,y:e}}});D.scrollMargins=Kl;D.darkTheme=Rr;D.cspNonce=O.define({combine:r=>r.length?r[0]:""});D.contentAttributes=rs;D.editorAttributes=ql;D.lineWrapping=D.contentAttributes.of({class:"cm-lineWrapping"});D.announce=H.define();const zf=4096,co={};class an{constructor(t,e,i,n,s,o){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(s=>s.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:_.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir==n&&!e.touchesRange(o.from,o.to)&&i.push(new an(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function fo(r,t,e){for(let i=r.state.facet(t),n=i.length-1;n>=0;n--){let s=i[n],o=typeof s=="function"?s(r):s;o&&Zr(o,e)}return e}const jf=M.mac?"mac":M.windows?"win":M.linux?"linux":"key";function Kf(r,t){const e=r.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let n,s,o,l;for(let a=0;a<e.length-1;++a){const h=e[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))t=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return n&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Ii(r,t,e){return t.altKey&&(r="Alt-"+r),t.ctrlKey&&(r="Ctrl-"+r),t.metaKey&&(r="Meta-"+r),e!==!1&&t.shiftKey&&(r="Shift-"+r),r}const $f=kn.default(D.domEventHandlers({keydown(r,t){return ua(fa(t.state),r,t,"editor")}})),ca=O.define({enables:$f}),uo=new WeakMap;function fa(r){let t=r.facet(ca),e=uo.get(t);return e||uo.set(t,e=Gf(t.reduce((i,n)=>i.concat(n),[]))),e}function Uf(r,t,e){return ua(fa(r.state),t,r,e)}let ee=null;const Jf=4e3;function Gf(r,t=jf){let e=Object.create(null),i=Object.create(null),n=(o,l)=>{let a=i[o];if(a==null)i[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")},s=(o,l,a,h,c)=>{var f,u;let d=e[o]||(e[o]=Object.create(null)),p=l.split(/ (?!$)/).map(w=>Kf(w,t));for(let w=1;w<p.length;w++){let y=p.slice(0,w).join(" ");n(y,!0),d[y]||(d[y]={preventDefault:!0,stopPropagation:!1,run:[C=>{let T=ee={view:C,prefix:y,scope:o};return setTimeout(()=>{ee==T&&(ee=null)},Jf),!0}]})}let g=p.join(" ");n(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),c&&(m.stopPropagation=!0)};for(let o of r){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=e[h]||(e[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,Ir))}let a=o[t]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return e}let Ir=null;function ua(r,t,e,i){Ir=t;let n=sc(t),s=nl(n,0),o=rl(s)==n.length&&n!=" ",l="",a=!1,h=!1,c=!1;ee&&ee.view==e&&ee.scope==i&&(l=ee.prefix+" ",Zl.indexOf(t.keyCode)<0&&(h=!0,ee=null));let f=new Set,u=m=>{if(m){for(let w of m.run)if(!f.has(w)&&(f.add(w),w(e)))return m.stopPropagation&&(c=!0),!0;m.preventDefault&&(m.stopPropagation&&(c=!0),h=!0)}return!1},d=r[i],p,g;return d&&(u(d[l+Ii(n,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(M.windows&&t.ctrlKey&&t.altKey)&&!(M.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=se[t.keyCode])&&p!=n?(u(d[l+Ii(p,t,!0)])||t.shiftKey&&(g=ci[t.keyCode])!=n&&g!=p&&u(d[l+Ii(g,t,!1)]))&&(a=!0):o&&t.shiftKey&&u(d[l+Ii(n,t,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),Ir=null,a}const po=O.define({combine(r){let t,e;for(let i of r)t=t||i.topContainer,e=e||i.bottomContainer;return{topContainer:t,bottomContainer:e}}});function da(r,t){let e=r.plugin(pa),i=e?e.specs.indexOf(t):-1;return i>-1?e.panels[i]:null}const pa=wt.fromClass(class{constructor(r){this.input=r.state.facet(hn),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(r));let t=r.state.facet(po);this.top=new Wi(r,!0,t.topContainer),this.bottom=new Wi(r,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(r){let t=r.state.facet(po);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Wi(r.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Wi(r.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=r.state.facet(hn);if(e!=this.input){let i=e.filter(a=>a),n=[],s=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(r.view),l.push(c)):(c=this.panels[h],c.update&&c.update(r)),n.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>D.scrollMargins.of(t=>{let e=t.plugin(r);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class Wi{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=go(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=go(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function go(r){let t=r.nextSibling;return r.remove(),t}const hn=O.define({enables:pa});function _f(r,t){let e,i=new Promise(o=>e=o),n=o=>Yf(o,t,e);r.state.field(_n,!1)?r.dispatch({effects:ga.of(n)}):r.dispatch({effects:H.appendConfig.of(_n.init(()=>[n]))});let s=ma.of(n);return{close:s,result:i.then(o=>((r.win.queueMicrotask||(l=>r.win.setTimeout(l,10)))(()=>{r.state.field(_n).indexOf(n)>-1&&r.dispatch({effects:s})}),o))}}const _n=Dt.define({create(){return[]},update(r,t){for(let e of t.effects)e.is(ga)?r=[e.value].concat(r):e.is(ma)&&(r=r.filter(i=>i!=e.value));return r},provide:r=>hn.computeN([r],t=>t.field(r))}),ga=H.define(),ma=H.define();function Yf(r,t,e){let i=t.content?t.content(r,()=>o(null)):null;if(!i){if(i=Z("form"),t.input){let l=Z("input",t.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),i.appendChild(Z("label",(t.label||"")+": ",l))}else i.appendChild(document.createTextNode(t.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Z("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let n=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let l=0;l<n.length;l++){let a=n[l];a.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(a))}),a.addEventListener("submit",h=>{h.preventDefault(),o(a)})}let s=Z("div",i,Z("button",{onclick:()=>o(null),"aria-label":r.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(s.className=t.class),s.classList.add("cm-dialog");function o(l){s.contains(s.ownerDocument.activeElement)&&r.focus(),e(l)}return{dom:s,top:t.top,mount:()=>{if(t.focus){let l;typeof t.focus=="string"?l=i.querySelector(t.focus):l=i.querySelector("input")||i.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class Xt extends ye{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Xt.prototype.elementClass="";Xt.prototype.toDOM=void 0;Xt.prototype.mapMode=mt.TrackBefore;Xt.prototype.startSide=Xt.prototype.endSide=-1;Xt.prototype.point=!0;const _i=O.define(),Xf=O.define(),Qf={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>R.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},li=O.define();function Zf(r){return[wa(),li.of({...Qf,...r})]}const mo=O.define({combine:r=>r.some(t=>t)});function wa(r){return[tu]}const tu=wt.fromClass(class{constructor(r){this.view=r,this.domAfter=null,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(li).map(t=>new vo(r,t)),this.fixed=!r.state.facet(mo);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(r){if(this.updateGutters(r)){let t=this.prevViewport,e=r.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8)}if(r.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(mo)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=r.view.viewport}syncGutters(r){let t=this.dom.nextSibling;r&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let e=R.iter(this.view.state.facet(_i),this.view.viewport.from),i=[],n=this.gutters.map(s=>new eu(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==ft.Text&&o){Wr(e,i,l.from);for(let a of n)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of n)a.widget(this.view,l)}else if(s.type==ft.Text){Wr(e,i,s.from);for(let o of n)o.line(this.view,s,i)}else if(s.widget)for(let o of n)o.widget(this.view,s);for(let s of n)s.finish();r&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(r){let t=r.startState.facet(li),e=r.state.facet(li),i=r.docChanged||r.heightChanged||r.viewportChanged||!R.eq(r.startState.facet(_i),r.state.facet(_i),r.view.viewport.from,r.view.viewport.to);if(t==e)for(let n of this.gutters)n.update(r)&&(i=!0);else{i=!0;let n=[];for(let s of e){let o=t.indexOf(s);o<0?n.push(new vo(this.view,s)):(this.gutters[o].update(r),n.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),n.indexOf(s)<0&&s.destroy();for(let s of n)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=n}return i}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:r=>D.scrollMargins.of(t=>{let e=t.plugin(r);if(!e||e.gutters.length==0||!e.fixed)return null;let i=e.dom.offsetWidth*t.scaleX,n=e.domAfter?e.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==_.LTR?{left:i,right:n}:{right:i,left:n}})});function wo(r){return Array.isArray(r)?r:[r]}function Wr(r,t,e){for(;r.value&&r.from<=e;)r.from==e&&t.push(r.value),r.next()}class eu{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=R.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==n.elements.length){let l=new va(t,o,s,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(t,o,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Wr(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let s of t.state.facet(Xf)){let o=s(t,e.widget,e);o&&(n||(n=[])).push(o)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class vo{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let s=n.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=n.clientY;let l=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,l,n)&&n.preventDefault()});this.markers=wo(e.markers(t)),e.initialSpacer&&(this.spacer=new va(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=wo(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}let i=t.view.viewport;return!R.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class va{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),iu(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<e.length?e[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(n);let f=n.nextSibling;n.remove(),n=f}}if(!a)break;a.toDOM&&(h?n=n.nextSibling:this.dom.insertBefore(a.toDOM(t),n)),h&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function iu(r,t){if(r.length!=t.length)return!1;for(let e=0;e<r.length;e++)if(!r[e].compare(t[e]))return!1;return!0}const nu=O.define(),ru=O.define(),Ee=O.define({combine(r){return Ke(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let n in e){let s=i[n],o=e[n];i[n]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}});class Yn extends Xt{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Xn(r,t){return r.state.facet(Ee).formatNumber(t,r.state)}const su=li.compute([Ee],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(nu)},lineMarker(t,e,i){return i.some(n=>n.toDOM)?null:new Yn(Xn(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let n of t.state.facet(ru)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Ee)!=t.state.facet(Ee),initialSpacer(t){return new Yn(Xn(t,yo(t.state.doc.lines)))},updateSpacer(t,e){let i=Xn(e.view,yo(e.view.state.doc.lines));return i==t.number?t:new Yn(i)},domEventHandlers:r.facet(Ee).domEventHandlers,side:"before"}));function ou(r={}){return[Ee.of(r),wa(),su]}function yo(r){let t=9;for(;t<r;)t=t*10+9;return t}const lu=new class extends Xt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},au=_i.compute(["selection"],r=>{let t=[],e=-1;for(let i of r.selection.ranges){let n=r.doc.lineAt(i.head).from;n>e&&(e=n,t.push(lu.range(n)))}return R.of(t)});function hu(){return au}const cu=1024;let fu=0;class kt{constructor(t,e){this.from=t,this.to=e}}class L{constructor(t={}){this.id=fu++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=dt.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}L.closedBy=new L({deserialize:r=>r.split(" ")});L.openedBy=new L({deserialize:r=>r.split(" ")});L.group=new L({deserialize:r=>r.split(" ")});L.isolate=new L({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});L.contextHash=new L({perNode:!0});L.lookAhead=new L({perNode:!0});L.mounted=new L({perNode:!0});class Ie{constructor(t,e,i,n=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=n}static get(t){return t&&t.props&&t.props[L.mounted.id]}}const uu=Object.create(null);class dt{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):uu,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),n=new dt(t.name||"",e,t.id,i);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[s[0].id]=s[1]}}return n}prop(t){return this.props[t.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(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(L.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return i=>{for(let n=i.prop(L.group),s=-1;s<(n?n.length:0);s++){let o=e[s<0?i.name:n[s]];if(o)return o}}}}dt.none=new dt("",Object.create(null),0,8);class ya{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let s of t){let o=s(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in n&&(l=a.combine(n[a.id],l)),n[a.id]=l}}e.push(n?new dt(i.name,n,i.id,i.flags):i)}return new ya(e)}}const Hi=new WeakMap,bo=new WeakMap;var F;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays",r[r.EnterBracketed=16]="EnterBracketed"})(F||(F={}));class Y{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=Ie.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let n=i.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new cn(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Hi.get(this)||this.topNode,s=new cn(n);return s.moveTo(t,e),Hi.set(this,s._tree),s}get topNode(){return new st(this,0,0,null)}resolve(t,e=0){let i=pi(Hi.get(this)||this.topNode,t,e,!1);return Hi.set(this,i),i}resolveInner(t,e=0){let i=pi(bo.get(this)||this.topNode,t,e,!0);return bo.set(this,i),i}resolveStack(t,e=0){return gu(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,o=t.mode||0,l=(o&F.IncludeAnonymous)>0;for(let a=this.cursor(o|F.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=n&&(!l&&a.type.isAnonymous||e(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:fs(dt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,n)=>new Y(this.type,e,i,n,this.propValues),t.makeTree||((e,i,n)=>new Y(dt.none,e,i,n)))}static build(t){return mu(t)}}Y.empty=new Y(dt.none,[],[],0);class hs{constructor(t,e){this.buffer=t,this.index=e}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 hs(this.buffer,this.index)}}class le{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return dt.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),t+=4,i==t)return s;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,i,n,s){let{buffer:o}=this,l=-1;for(let a=t;a!=e&&!(ba(s,n,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),o=0;for(let l=t,a=0;l<e;){s[a++]=n[l++],s[a++]=n[l++]-i;let h=s[a++]=n[l++]-i;s[a++]=n[l++]-t,o=Math.max(o,h)}return new le(s,o,this.set)}}function ba(r,t,e,i){switch(r){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function pi(r,t,e,i){for(var n;r.from==r.to||(e<1?r.from>=t:r.from>t)||(e>-1?r.to<=t:r.to<t);){let o=!i&&r instanceof st&&r.index<0?null:r.parent;if(!o)return r;r=o}let s=i?0:F.IgnoreOverlays;if(i)for(let o=r,l=o.parent;l;o=l,l=o.parent)o instanceof st&&o.index<0&&((n=l.enter(t,e,s))===null||n===void 0?void 0:n.from)!=o.from&&(r=l);for(;;){let o=r.enter(t,e,s);if(!o)return r;r=o}}class xa{cursor(t=0){return new cn(this,t)}getChild(t,e=null,i=null){let n=xo(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return xo(this,t,e,i)}resolve(t,e=0){return pi(this,t,e,!1)}resolveInner(t,e=0){return pi(this,t,e,!0)}matchContext(t){return Hr(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let n=e.lastChild;if(!n||n.to!=e.to)break;n.type.isError&&n.from==n.to?(i=e,e=n.prevSibling):e=n}return i}get node(){return this}get next(){return this.parent}}class st extends xa{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=e>0?l.length:-1;t!=h;t+=e){let c=l[t],f=a[t]+o.from,u;if(!(!(s&F.EnterBracketed&&c instanceof Y&&(u=Ie.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!ba(n,i,f,f+c.length))){if(c instanceof le){if(s&F.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,e,i-f,n);if(d>-1)return new zt(new du(o,c,t,f),null,d)}else if(s&F.IncludeAnonymous||!c.type.isAnonymous||cs(c)){let d;if(!(s&F.IgnoreMounts)&&(d=Ie.get(c))&&!d.overlay)return new st(d.tree,f,t,o);let p=new st(c,f,t,o);return s&F.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?c.children.length-1:0,e,i,n,s)}}}if(s&F.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let n;if(!(i&F.IgnoreOverlays)&&(n=Ie.get(this._tree))&&n.overlay){let s=t-this.from,o=i&F.EnterBracketed&&n.bracketed;for(let{from:l,to:a}of n.overlay)if((e>0||o?l<=s:l<s)&&(e<0||o?a>=s:a>s))return new st(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 xo(r,t,e,i){let n=r.cursor(),s=[];if(!n.firstChild())return s;if(e!=null){for(let o=!1;!o;)if(o=n.type.is(e),!n.nextSibling())return s}for(;;){if(i!=null&&n.type.is(i))return s;if(n.type.is(t)&&s.push(n.node),!n.nextSibling())return i==null?s:[]}}function Hr(r,t,e=t.length-1){for(let i=r;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class du{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class zt extends xa{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(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new zt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&F.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new zt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new zt(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new zt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];t.push(i.slice(n,s,o)),e.push(0)}return new Y(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ka(r){if(!r.length)return null;let t=0,e=r[0];for(let s=1;s<r.length;s++){let o=r[s];(o.from>e.from||o.to<e.to)&&(e=o,t=s)}let i=e instanceof st&&e.index<0?null:e.parent,n=r.slice();return i?n[t]=i:n.splice(t,1),new pu(n,e)}class pu{constructor(t,e){this.heads=t,this.node=e}get next(){return ka(this.heads)}}function gu(r,t,e){let i=r.resolveInner(t,e),n=null;for(let s=i instanceof st?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(n||(n=[i])).push(o.resolve(t,e)),s=o}else{let o=Ie.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new st(o.tree,o.overlay[0].from+s.from,-1,s);(n||(n=[i])).push(pi(l,t,e,!1))}}return n?ka(n):i}class cn{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~F.EnterBracketed,t instanceof st)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return t?t instanceof st?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&F.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&F.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&F.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(n.buffer.buffer[s+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let s=e+t,o=t<0?-1:i._tree.children.length;s!=o;s+=t){let l=i._tree.children[s];if(this.mode&F.IncludeAnonymous||l instanceof le||!l.type.isAnonymous||cs(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=s+1;break t}n=this.stack[--s]}for(let n=i;n<this.stack.length;n++)e=new zt(this.buffer,e,this.stack[n]);return this.bufferNode=new zt(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Hr(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Hr(this._tree,t,n);let o=i[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}}function cs(r){return r.children.some(t=>t instanceof le||!t.type.isAnonymous||cs(t))}function mu(r){var t;let{buffer:e,nodeSet:i,maxBufferLength:n=cu,reused:s=[],minRepeatType:o=i.types.length}=r,l=Array.isArray(e)?new hs(e,e.length):e,a=i.types,h=0,c=0;function f(S,A,x,E,q,$){let{id:N,start:B,end:j,size:K}=l,et=c,Qt=h;if(K<0)if(l.next(),K==-1){let Ut=s[N];x.push(Ut),E.push(B-S);return}else if(K==-3){h=N;return}else if(K==-4){c=N;return}else throw new RangeError(`Unrecognized record size: ${K}`);let Ge=a[N],Ai,fe,ks=B-S;if(j-B<=n&&(fe=m(l.pos-A,q))){let Ut=new Uint16Array(fe.size-fe.skip),yt=l.pos-fe.size,Lt=Ut.length;for(;l.pos>yt;)Lt=w(fe.start,Ut,Lt);Ai=new le(Ut,j-fe.start,i),ks=fe.start-S}else{let Ut=l.pos-K;l.next();let yt=[],Lt=[],ue=N>=o?N:-1,Me=0,Mi=j;for(;l.pos>Ut;)ue>=0&&l.id==ue&&l.size>=0?(l.end<=Mi-n&&(p(yt,Lt,B,Me,l.end,Mi,ue,et,Qt),Me=yt.length,Mi=l.end),l.next()):$>2500?u(B,Ut,yt,Lt):f(B,Ut,yt,Lt,ue,$+1);if(ue>=0&&Me>0&&Me<yt.length&&p(yt,Lt,B,Me,B,Mi,ue,et,Qt),yt.reverse(),Lt.reverse(),ue>-1&&Me>0){let Ss=d(Ge,Qt);Ai=fs(Ge,yt,Lt,0,yt.length,0,j-B,Ss,Ss)}else Ai=g(Ge,yt,Lt,j-B,et-j,Qt)}x.push(Ai),E.push(ks)}function u(S,A,x,E){let q=[],$=0,N=-1;for(;l.pos>A;){let{id:B,start:j,end:K,size:et}=l;if(et>4)l.next();else{if(N>-1&&j<N)break;N<0&&(N=K-n),q.push(B,j,K),$++,l.next()}}if($){let B=new Uint16Array($*4),j=q[q.length-2];for(let K=q.length-3,et=0;K>=0;K-=3)B[et++]=q[K],B[et++]=q[K+1]-j,B[et++]=q[K+2]-j,B[et++]=et;x.push(new le(B,q[2]-j,i)),E.push(j-S)}}function d(S,A){return(x,E,q)=>{let $=0,N=x.length-1,B,j;if(N>=0&&(B=x[N])instanceof Y){if(!N&&B.type==S&&B.length==q)return B;(j=B.prop(L.lookAhead))&&($=E[N]+B.length+j)}return g(S,x,E,q,$,A)}}function p(S,A,x,E,q,$,N,B,j){let K=[],et=[];for(;S.length>E;)K.push(S.pop()),et.push(A.pop()+x-q);S.push(g(i.types[N],K,et,$-q,B-$,j)),A.push(q-x)}function g(S,A,x,E,q,$,N){if($){let B=[L.contextHash,$];N=N?[B].concat(N):[B]}if(q>25){let B=[L.lookAhead,q];N=N?[B].concat(N):[B]}return new Y(S,A,x,E,N)}function m(S,A){let x=l.fork(),E=0,q=0,$=0,N=x.end-n,B={size:0,start:0,skip:0};t:for(let j=x.pos-S;x.pos>j;){let K=x.size;if(x.id==A&&K>=0){B.size=E,B.start=q,B.skip=$,$+=4,E+=4,x.next();continue}let et=x.pos-K;if(K<0||et<j||x.start<N)break;let Qt=x.id>=o?4:0,Ge=x.start;for(x.next();x.pos>et;){if(x.size<0)if(x.size==-3||x.size==-4)Qt+=4;else break t;else x.id>=o&&(Qt+=4);x.next()}q=Ge,E+=K,$+=Qt}return(A<0||E==S)&&(B.size=E,B.start=q,B.skip=$),B.size>4?B:void 0}function w(S,A,x){let{id:E,start:q,end:$,size:N}=l;if(l.next(),N>=0&&E<o){let B=x;if(N>4){let j=l.pos-(N-4);for(;l.pos>j;)x=w(S,A,x)}A[--x]=B,A[--x]=$-S,A[--x]=q-S,A[--x]=E}else N==-3?h=E:N==-4&&(c=E);return x}let y=[],C=[];for(;l.pos>0;)f(r.start||0,r.bufferStart||0,y,C,-1,0);let T=(t=r.length)!==null&&t!==void 0?t:y.length?C[0]+y[0].length:0;return new Y(a[r.topID],y.reverse(),C.reverse(),T)}const ko=new WeakMap;function Yi(r,t){if(!r.isAnonymous||t instanceof le||t.type!=r)return 1;let e=ko.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=r||!(i instanceof Y)){e=1;break}e+=Yi(r,i)}ko.set(t,e)}return e}function fs(r,t,e,i,n,s,o,l,a){let h=0;for(let p=i;p<n;p++)h+=Yi(r,t[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,g,m,w,y){for(let C=m;C<w;){let T=C,S=g[C],A=Yi(r,p[C]);for(C++;C<w;C++){let x=Yi(r,p[C]);if(A+x>=c)break;A+=x}if(C==T+1){if(A>c){let x=p[T];d(x.children,x.positions,0,x.children.length,g[T]+y);continue}f.push(p[T])}else{let x=g[C-1]+p[C-1].length-S;f.push(fs(r,p,g,T,C,S,x,null,a))}u.push(S+y-s)}}return d(t,e,i,n,0),(l||a)(f,u,o)}class xg{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof zt?this.setBuffer(t.context.buffer,t.index,e):t instanceof st&&this.map.set(t.tree,e)}get(t){return t instanceof zt?this.getBuffer(t.context.buffer,t.index):t instanceof st?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class _t{constructor(t,e,i,n,s=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let n=[new _t(0,t.length,t,0,!1,i)];for(let s of e)s.to>t.length&&n.push(s);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,o=t.length?t[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<e.length?e[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new _t(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&n.push(u),o.to>f)break;o=s<t.length?t[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return n}}class wu{startParse(t,e,i){return typeof t=="string"&&(t=new vu(t)),i=i?i.length?i.map(n=>new kt(n.from,n.to)):[new kt(0,0)]:[new kt(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let s=n.advance();if(s)return s}}}class vu{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function kg(r){return(t,e,i,n)=>new bu(t,r,e,i,n)}class So{constructor(t,e,i,n,s,o){this.parser=t,this.parse=e,this.overlay=i,this.bracketed=n,this.target=s,this.from=o}}function Ao(r){if(!r.length||r.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(r))}class yu{constructor(t,e,i,n,s,o,l,a){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Vr=new L({perNode:!0});class bu{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let n of this.inner)n.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Y(i.type,i.children,i.positions,i.length,i.propValues.concat([[Vr,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[L.mounted.id]=new Ie(e,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new Su(this.fragments),e=null,i=null,n=new cn(new st(this.baseTree,this.ranges[0].from,0,null),F.IncludeAnonymous|F.IgnoreMounts);t:for(let s,o;;){let l=!0,a;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=!1;else if(t.hasNode(n)){if(e){let h=e.mounts.find(c=>c.frag.from<=n.from&&c.frag.to>=n.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=n.from&&u<=n.to&&!e.ranges.some(d=>d.from<u&&d.to>f)&&e.ranges.push({from:f,to:u})}}l=!1}else if(i&&(o=xu(i.ranges,n.from,n.to)))l=o!=2;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.from<n.to||!s.overlay)){n.tree||(ku(n),e&&e.depth++,i&&i.depth++);let h=t.findMounts(n.from,s.parser);if(typeof s.overlay=="function")e=new yu(s.parser,s.overlay,h,this.inner.length,n.from,!!s.bracketed,n.tree,e);else{let c=Oo(this.ranges,s.overlay||(n.from<n.to?[new kt(n.from,n.to)]:[]));c.length&&Ao(c),(c.length||!s.overlay)&&this.inner.push(new So(s.parser,c.length?s.parser.startParse(this.input,To(h,c),c):s.parser.startParse(""),s.overlay?s.overlay.map(f=>new kt(f.from-n.from,f.to-n.from)):null,!!s.bracketed,n.tree,c.length?c[0].from:n.from)),s.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):l=!1}}else if(e&&(a=e.predicate(n))&&(a===!0&&(a=new kt(n.from,n.to)),a.from<a.to)){let h=e.ranges.length-1;h>=0&&e.ranges[h].to==a.from?e.ranges[h]={from:e.ranges[h].from,to:a.to}:e.ranges.push(a)}if(l&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break t;if(e&&!--e.depth){let h=Oo(this.ranges,e.ranges);h.length&&(Ao(h),this.inner.splice(e.index,0,new So(e.parser,e.parser.startParse(this.input,To(e.mounts,h),h),e.ranges.map(c=>new kt(c.from-e.start,c.to-e.start)),e.bracketed,e.target,h[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}}function xu(r,t,e){for(let i of r){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function Mo(r,t,e,i,n,s){if(t<e){let o=r.buffer[t+1];i.push(r.slice(t,e,o)),n.push(o-s)}}function ku(r){let{node:t}=r,e=[],i=t.context.buffer;do e.push(r.index),r.parent();while(!r.tree);let n=r.tree,s=n.children.indexOf(i),o=n.children[s],l=o.buffer,a=[s];function h(c,f,u,d,p,g){let m=e[g],w=[],y=[];Mo(o,c,m,w,y,d);let C=l[m+1],T=l[m+2];a.push(w.length);let S=g?h(m+4,l[m+3],o.set.types[l[m]],C,T-C,g-1):t.toTree();return w.push(S),y.push(C-d),Mo(o,l[m+3],f,w,y,d),new Y(u,w,y,p)}n.children[s]=h(0,l.length,dt.none,0,o.length,e.length-1);for(let c of a){let f=r.tree.children[c],u=r.tree.positions[c];r.yield(new st(f,u+r.from,c,r._tree))}}class Co{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(F.IncludeAnonymous|F.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)if(!(e.to>=t&&e.enter(i,1,F.IgnoreOverlays|F.ExcludeBuffers)))if(e.to<=t)e.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof Y)e=e.children[0];else break}return!1}}class Su{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(Vr))!==null&&e!==void 0?e:i.to,this.inner=new Co(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Vr))!==null&&t!==void 0?t:e.to,this.inner=new Co(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(L.mounted);if(o&&o.parser==e)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&n.push({frag:a,pos:s.from-a.offset,mount:o})}}}return n}}function Oo(r,t){let e=null,i=t;for(let n=1,s=0;n<r.length;n++){let o=r[n-1].to,l=r[n].from;for(;s<i.length;s++){let a=i[s];if(a.from>=l)break;a.to<=o||(e||(i=e=t.slice()),a.from<o?(e[s]=new kt(a.from,o),a.to>l&&e.splice(s+1,0,new kt(l,a.to))):a.to>l?e[s--]=new kt(l,a.to):e.splice(s--,1))}}return i}function Au(r,t,e,i){let n=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=n==r.length?1e9:o?r[n].to:r[n].from,f=s==t.length?1e9:l?t[s].to:t[s].from;if(o!=l){let u=Math.max(a,e),d=Math.min(c,f,i);u<d&&h.push(new kt(u,d))}if(a=Math.min(c,f),a==1e9)break;c==a&&(o?(o=!1,n++):o=!0),f==a&&(l?(l=!1,s++):l=!0)}return h}function To(r,t){let e=[];for(let{pos:i,mount:n,frag:s}of r){let o=i+(n.overlay?n.overlay[0].from:0),l=o+n.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,l);if(n.overlay){let c=n.overlay.map(u=>new kt(u.from+i,u.to+i)),f=Au(t,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,g=p?h:f[u].from;if(g>d&&e.push(new _t(d,g,n.tree,-o,s.from>=d||s.openStart,s.to<=g||s.openEnd)),p)break;d=f[u].to}}else e.push(new _t(a,h,n.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return e}let Mu=0;class bt{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=Mu++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof bt&&(e=t),e?.base)throw new Error("Can not derive from a modified tag");let n=new bt(i,[],null,[]);if(n.set.push(n),e)for(let s of e.set)n.set.push(s);return n}static defineModifier(t){let e=new fn(t);return i=>i.modified.indexOf(e)>-1?i:fn.get(i.base||i,i.modified.concat(e).sort((n,s)=>n.id-s.id))}}let Cu=0;class fn{constructor(t){this.name=t,this.instances=[],this.id=Cu++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&Ou(e,l.modified));if(i)return i;let n=[],s=new bt(t.name,n,t,e);for(let l of e)l.instances.push(s);let o=Tu(e);for(let l of t.set)if(!l.modified.length)for(let a of o)n.push(fn.get(l,a));return s}}function Ou(r,t){return r.length==t.length&&r.every((e,i)=>e==t[i])}function Tu(r){let t=[[]];for(let e=0;e<r.length;e++)for(let i=0,n=t.length;i<n;i++)t.push(t[i].concat(r[e]));return t.sort((e,i)=>i.length-e.length)}function Du(r){let t=Object.create(null);for(let e in r){let i=r[e];Array.isArray(i)||(i=[i]);for(let n of e.split(" "))if(n){let s=[],o=2,l=n;for(let f=0;;){if(l=="..."&&f>0&&f+3==n.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==n.length)break;let d=n[f++];if(f==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+n);let c=new gi(i,o,a>0?s.slice(0,a):null);t[h]=c.sort(t[h])}}return Sa.add(t)}const Sa=new L({combine(r,t){let e,i,n;for(;r||t;){if(!r||t&&r.depth>=t.depth?(n=t,t=t.next):(n=r,r=r.next),e&&e.mode==n.mode&&!n.context&&!e.context)continue;let s=new gi(n.tags,n.mode,n.context);e?e.next=s:i=s,e=s}return i}});class gi{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}gi.empty=new gi([],2,null);function Aa(r,t){let e=Object.create(null);for(let s of r)if(!Array.isArray(s.tag))e[s.tag.id]=s.class;else for(let o of s.tag)e[o.id]=s.class;let{scope:i,all:n=null}=t||{};return{style:s=>{let o=n;for(let l of s)for(let a of l.set){let h=e[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Eu(r,t){let e=null;for(let i of r){let n=i.style(t);n&&(e=e?e+" "+n:n)}return e}function Bu(r,t,e,i=0,n=r.length){let s=new Lu(i,Array.isArray(t)?t:[t],e);s.highlightRange(r.cursor(),i,n,"",s.highlighters),s.flush(n)}class Lu{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:o,from:l,to:a}=t;if(l>=i||a<=e)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,c=Ru(t)||gi.empty,f=Eu(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,l),h),c.opaque)return;let u=t.tree&&t.tree.prop(L.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=t.firstChild();for(let m=0,w=l;;m++){let y=m<u.overlay.length?u.overlay[m]:null,C=y?y.from+l:a,T=Math.max(e,w),S=Math.min(i,C);if(T<S&&g)for(;t.from<S&&(this.highlightRange(t,T,S,n,s),this.startSpan(Math.min(S,t.to),h),!(t.to>=C||!t.nextSibling())););if(!y||C>i)break;w=y.to+l,w>e&&(this.highlightRange(d.cursor(),Math.max(e,y.from+l),Math.min(i,w),"",p),this.startSpan(Math.min(i,w),h))}g&&t.parent()}else if(t.firstChild()){u&&(n="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling());t.parent()}}}function Ru(r){let t=r.type.prop(Sa);for(;t&&t.context&&!r.matchContext(t.context);)t=t.next;return t||null}const b=bt.define,Vi=b(),Zt=b(),Do=b(Zt),Eo=b(Zt),te=b(),Fi=b(te),Qn=b(te),Wt=b(),de=b(Wt),Nt=b(),It=b(),Fr=b(),Xe=b(Fr),qi=b(),k={comment:Vi,lineComment:b(Vi),blockComment:b(Vi),docComment:b(Vi),name:Zt,variableName:b(Zt),typeName:Do,tagName:b(Do),propertyName:Eo,attributeName:b(Eo),className:b(Zt),labelName:b(Zt),namespace:b(Zt),macroName:b(Zt),literal:te,string:Fi,docString:b(Fi),character:b(Fi),attributeValue:b(Fi),number:Qn,integer:b(Qn),float:b(Qn),bool:b(te),regexp:b(te),escape:b(te),color:b(te),url:b(te),keyword:Nt,self:b(Nt),null:b(Nt),atom:b(Nt),unit:b(Nt),modifier:b(Nt),operatorKeyword:b(Nt),controlKeyword:b(Nt),definitionKeyword:b(Nt),moduleKeyword:b(Nt),operator:It,derefOperator:b(It),arithmeticOperator:b(It),logicOperator:b(It),bitwiseOperator:b(It),compareOperator:b(It),updateOperator:b(It),definitionOperator:b(It),typeOperator:b(It),controlOperator:b(It),punctuation:Fr,separator:b(Fr),bracket:Xe,angleBracket:b(Xe),squareBracket:b(Xe),paren:b(Xe),brace:b(Xe),content:Wt,heading:de,heading1:b(de),heading2:b(de),heading3:b(de),heading4:b(de),heading5:b(de),heading6:b(de),contentSeparator:b(Wt),list:b(Wt),quote:b(Wt),emphasis:b(Wt),strong:b(Wt),link:b(Wt),monospace:b(Wt),strikethrough:b(Wt),inserted:b(),deleted:b(),changed:b(),invalid:b(),meta:qi,documentMeta:b(qi),annotation:b(qi),processingInstruction:b(qi),definition:bt.defineModifier("definition"),constant:bt.defineModifier("constant"),function:bt.defineModifier("function"),standard:bt.defineModifier("standard"),local:bt.defineModifier("local"),special:bt.defineModifier("special")};for(let r in k){let t=k[r];t instanceof bt&&(t.name=r)}Aa([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);var Zn;const Be=new L;function Pu(r){return O.define({combine:r?t=>t.concat(r):void 0})}const Nu=new L;class Ot{constructor(t,e,i=[],n=""){this.data=t,this.name=n,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return vt(this)}}),this.parser=e,this.extension=[ae.of(this),I.languageData.of((s,o,l)=>{let a=Bo(s,o,l),h=a.type.prop(Be);if(!h)return[];let c=s.facet(h),f=a.type.prop(Nu);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(t,e,i=-1){return Bo(t,e,i).type.prop(Be)==this.data}findRegions(t){let e=t.facet(ae);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(s,o)=>{if(s.prop(Be)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(L.mounted);if(l){if(l.tree.prop(Be)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof Y&&n(h,s.positions[a]+o)}};return n(vt(t),0),i}get allowsNesting(){return!0}}Ot.setState=H.define();function Bo(r,t,e){let i=r.facet(ae),n=vt(r).topNode;if(!i||i.allowsNesting)for(let s=n;s;s=s.enter(t,e,F.ExcludeBuffers|F.EnterBracketed))s.type.isTop&&(n=s);return n}class qr extends Ot{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Pu(t.languageData);return new qr(e,t.parser.configure({props:[Be.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new qr(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function vt(r){let t=r.field(Ot.state,!1);return t?t.tree:Y.empty}class Iu{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Qe=null;class un{constructor(t,e,i=[],n,s,o,l,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new un(t,e,[],Y.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Iu(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=Y.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let n=Date.now()+t;t=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(_t.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(_t.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Qe;Qe=this;try{return t()}finally{Qe=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Lo(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let a=[];if(t.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=_t.applyChanges(i,a),n=Y.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=t.mapPos(h.from,1),f=t.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new un(this.parser,e,i,n,s,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:s}=this.skipped[i];n<t.to&&s>t.from&&(this.fragments=Lo(this.fragments,n,s),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends wu{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let l=Qe;if(l){for(let a of n)l.tempSkipped.push(a);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new Y(dt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return Qe}}function Lo(r,t,e){return _t.applyChanges(r,[{fromA:t,toA:e,fromB:t,toB:e}])}class ze{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new ze(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=un.create(t.facet(ae).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new ze(i)}}Ot.state=Dt.define({create:ze.init,update(r,t){for(let e of t.effects)if(e.is(Ot.setState))return e.value;return t.startState.facet(ae)!=t.state.facet(ae)?ze.init(t.state):r.apply(t)}});let Ma=r=>{let t=setTimeout(()=>r(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Ma=r=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(r,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const tr=typeof navigator<"u"&&!((Zn=navigator.scheduling)===null||Zn===void 0)&&Zn.isInputPending?()=>navigator.scheduling.isInputPending():null,Wu=wt.fromClass(class{constructor(r){this.view=r,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(r){let t=this.view.state.field(Ot.state).context;(t.updateViewport(r.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(r.docChanged||r.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:r}=this.view,t=r.field(Ot.state);(t.tree!=t.context.tree||!t.context.isDone(r.doc.length))&&(this.working=Ma(this.work))}work(r){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:e,viewport:{to:i}}=this.view,n=e.field(Ot.state);if(n.tree==n.context.tree&&n.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,r&&!tr?Math.max(25,r.timeRemaining()-5):1e9),o=n.context.treeLen<i&&e.doc.length>i+1e3,l=n.context.work(()=>tr&&tr()||Date.now()>s,i+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:Ot.setState.of(new ze(n.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(r){r.scheduleOn&&(this.workScheduled++,r.scheduleOn.then(()=>this.scheduleWork()).catch(t=>qt(this.view.state,t)).then(()=>this.workScheduled--),r.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ae=O.define({combine(r){return r.length?r[0]:null},enables:r=>[Ot.state,Wu,D.contentAttributes.compute([r],t=>{let e=t.facet(r);return e&&e.name?{"data-language":e.name}:{}})]});class Sg{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ca{constructor(t,e,i,n,s,o=void 0){this.name=t,this.alias=e,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new Ca(t.name,(t.alias||[]).concat(t.name).map(n=>n.toLowerCase()),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let n of t)if(n.filename&&n.filename.test(e))return n;let i=/\.([^.]+)$/.exec(e);if(i){for(let n of t)if(n.extensions.indexOf(i[1])>-1)return n}return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let n of t)if(n.alias.some(s=>s==e))return n;if(i)for(let n of t)for(let s of n.alias){let o=e.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+s.length])))return n}return null}}const Hu=O.define(),us=O.define({combine:r=>{if(!r.length)return" ";let t=r[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return t}});function dn(r){let t=r.facet(us);return t.charCodeAt(0)==9?r.tabSize*t.length:t.length}function mi(r,t){let e="",i=r.tabSize,n=r.facet(us)[0];if(n==" "){for(;t>=i;)e+=" ",t-=i;n=" "}for(let s=0;s<t;s++)e+=n;return e}function ds(r,t){r instanceof I&&(r=new Dn(r));for(let i of r.state.facet(Hu)){let n=i(r,t);if(n!==void 0)return n}let e=vt(r.state);return e.length>=t?Fu(r,e,t):null}class Dn{constructor(t,e={}){this.state=t,this.options=e,this.unit=dn(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return n!=null&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return Sn(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let o=s(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vu=new L;function Fu(r,t,e){let i=t.resolveStack(e),n=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(n!=i.node){let s=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Oa(i,r,e)}function Oa(r,t,e){for(let i=r;i;i=i.next){let n=zu(i.node);if(n)return n(ps.create(t,e,i))}return 0}function qu(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function zu(r){let t=r.type.prop(Vu);if(t)return t;let e=r.firstChild,i;if(e&&(i=e.type.prop(L.closedBy))){let n=r.lastChild,s=n&&i.indexOf(n.name)>-1;return o=>Ta(o,!0,1,void 0,s&&!qu(o)?n.from:void 0)}return r.parent==null?ju:null}function ju(){return 0}class ps extends Dn{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new ps(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Ku(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Oa(this.context.next,this.base,this.pos)}}function Ku(r,t){for(let e=t;e;e=e.parent)if(r==e)return!0;return!1}function $u(r){let t=r.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let n=r.options.simulateBreak,s=r.state.doc.lineAt(e.from),o=n==null||n<=s.from?s.to:Math.min(s.to,n);for(let l=e.to;;){let a=t.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(e.to-s.from))[0].length;return{from:e.from,to:e.to+h}}l=a.to}}function Ag({closing:r,align:t=!0,units:e=1}){return i=>Ta(i,t,e,r)}function Ta(r,t,e,i,n){let s=r.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||n==r.pos+o,a=t?$u(r):null;return a?l?r.column(a.from):r.column(a.to):r.baseIndent+(l?0:r.unit*e)}const Mg=r=>r.baseIndent;function Cg({except:r,units:t=1}={}){return e=>{let i=r&&r.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const Uu=200;function Ju(){return I.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let t=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!t.length)return r;let e=r.newDoc,{head:i}=r.newSelection.main,n=e.lineAt(i);if(i>n.from+Uu)return r;let s=e.sliceString(n.from,i);if(!t.some(h=>h.test(s)))return r;let{state:o}=r,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=ds(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=mi(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[r,{changes:a,sequential:!0}]:r})}const Gu=O.define(),_u=new L;function Og(r){let t=r.firstChild,e=r.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?r.to:e.from}:null}function Yu(r,t,e){let i=vt(r);if(i.length<e)return null;let n=i.resolveStack(e,1),s=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=e||l.from>e)continue;if(s&&l.from<t)break;let a=l.type.prop(_u);if(a&&(l.to<i.length-50||i.length==r.doc.length||!Xu(l))){let h=a(l,r);h&&h.from<=e&&h.from>=t&&h.to>e&&(s=h)}}return s}function Xu(r){let t=r.lastChild;return t&&t.to==r.to&&t.type.isError}function pn(r,t,e){for(let i of r.facet(Gu)){let n=i(r,t,e);if(n)return n}return Yu(r,t,e)}function Da(r,t){let e=t.mapPos(r.from,1),i=t.mapPos(r.to,-1);return e>=i?void 0:{from:e,to:i}}const En=H.define({map:Da}),xi=H.define({map:Da});function Ea(r){let t=[];for(let{head:e}of r.state.selection.ranges)t.some(i=>i.from<=e&&i.to>=e)||t.push(r.lineBlockAt(e));return t}const Ae=Dt.define({create(){return P.none},update(r,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((e,i)=>r=Ro(r,e,i)),r=r.map(t.changes);for(let e of t.effects)if(e.is(En)&&!Qu(r,e.value.from,e.value.to)){let{preparePlaceholder:i}=t.state.facet(Ra),n=i?P.replace({widget:new sd(i(t.state,e.value))}):Po;r=r.update({add:[n.range(e.value.from,e.value.to)]})}else e.is(xi)&&(r=r.update({filter:(i,n)=>e.value.from!=i||e.value.to!=n,filterFrom:e.value.from,filterTo:e.value.to}));return t.selection&&(r=Ro(r,t.selection.main.head)),r},provide:r=>D.decorations.from(r),toJSON(r,t){let e=[];return r.between(0,t.doc.length,(i,n)=>{e.push(i,n)}),e},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<r.length;){let i=r[e++],n=r[e++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");t.push(Po.range(i,n))}return P.set(t,!0)}});function Ro(r,t,e=t){let i=!1;return r.between(t,e,(n,s)=>{n<e&&s>t&&(i=!0)}),i?r.update({filterFrom:t,filterTo:e,filter:(n,s)=>n>=e||s<=t}):r}function gn(r,t,e){var i;let n=null;return(i=r.field(Ae,!1))===null||i===void 0||i.between(t,e,(s,o)=>{(!n||n.from>s)&&(n={from:s,to:o})}),n}function Qu(r,t,e){let i=!1;return r.between(t,t,(n,s)=>{n==t&&s==e&&(i=!0)}),i}function Ba(r,t){return r.field(Ae,!1)?t:t.concat(H.appendConfig.of(Pa()))}const Zu=r=>{for(let t of Ea(r)){let e=pn(r.state,t.from,t.to);if(e)return r.dispatch({effects:Ba(r.state,[En.of(e),La(r,e)])}),!0}return!1},td=r=>{if(!r.state.field(Ae,!1))return!1;let t=[];for(let e of Ea(r)){let i=gn(r.state,e.from,e.to);i&&t.push(xi.of(i),La(r,i,!1))}return t.length&&r.dispatch({effects:t}),t.length>0};function La(r,t,e=!0){let i=r.state.doc.lineAt(t.from).number,n=r.state.doc.lineAt(t.to).number;return D.announce.of(`${r.state.phrase(e?"Folded lines":"Unfolded lines")} ${i} ${r.state.phrase("to")} ${n}.`)}const ed=r=>{let{state:t}=r,e=[];for(let i=0;i<t.doc.length;){let n=r.lineBlockAt(i),s=pn(t,n.from,n.to);s&&e.push(En.of(s)),i=(s?r.lineBlockAt(s.to):n).to+1}return e.length&&r.dispatch({effects:Ba(r.state,e)}),!!e.length},id=r=>{let t=r.state.field(Ae,!1);if(!t||!t.size)return!1;let e=[];return t.between(0,r.state.doc.length,(i,n)=>{e.push(xi.of({from:i,to:n}))}),r.dispatch({effects:e}),!0},nd=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Zu},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:td},{key:"Ctrl-Alt-[",run:ed},{key:"Ctrl-Alt-]",run:id}],rd={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ra=O.define({combine(r){return Ke(r,rd)}});function Pa(r){return[Ae,ad]}function Na(r,t){let{state:e}=r,i=e.facet(Ra),n=o=>{let l=r.lineBlockAt(r.posAtDOM(o.target)),a=gn(r.state,l.from,l.to);a&&r.dispatch({effects:xi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(r,n,t);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}const Po=P.replace({widget:new class extends $e{toDOM(r){return Na(r,null)}}});class sd extends $e{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Na(t,this.value)}}const od={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class er extends Xt{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function ld(r={}){let t={...od,...r},e=new er(t,!0),i=new er(t,!1),n=wt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ae)!=o.state.facet(ae)||o.startState.field(Ae,!1)!=o.state.field(Ae,!1)||vt(o.startState)!=vt(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new be;for(let a of o.viewportLineBlocks){let h=gn(o.state,a.from,a.to)?i:pn(o.state,a.from,a.to)?e:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:s}=t;return[n,Zf({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(n))===null||l===void 0?void 0:l.markers)||R.empty},initialSpacer(){return new er(t,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let h=gn(o.state,l.from,l.to);if(h)return o.dispatch({effects:xi.of(h)}),!0;let c=pn(o.state,l.from,l.to);return c?(o.dispatch({effects:En.of(c)}),!0):!1}}}),Pa()]}const ad=D.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 Bn{constructor(t,e){this.specs=t;let i;function n(l){let a=re.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const s=typeof e.all=="string"?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof Ot?l=>l.prop(Be)==o.data:o?l=>l==o:void 0,this.style=Aa(t.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new re(i):null,this.themeType=e.themeType}static define(t,e){return new Bn(t,e||{})}}const hd=O.define(),Ia=O.define({combine(r){return r.length?[r[0]]:null}});function ir(r){let t=r.facet(hd);return t.length?t:r.facet(Ia)}function cd(r,t){let e=[ud];return r instanceof Bn&&(r.module&&e.push(D.styleModule.of(r.module)),r.themeType),e.push(Ia.of(r)),e}class fd{constructor(t){this.markCache=Object.create(null),this.tree=vt(t.state),this.decorations=this.buildDeco(t,ir(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=vt(t.state),i=ir(t.state),n=i!=ir(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return P.none;let i=new be;for(let{from:n,to:s}of t.visibleRanges)Bu(this.tree,e,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=P.mark({class:a})))},n,s);return i.finish()}}const ud=kn.high(wt.fromClass(fd,{decorations:r=>r.decorations})),dd=Bn.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]),pd=D.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Wa=1e4,Ha="()[]{}",Va=O.define({combine(r){return Ke(r,{afterCursor:!0,brackets:Ha,maxScanDistance:Wa,renderMatch:wd})}}),gd=P.mark({class:"cm-matchingBracket"}),md=P.mark({class:"cm-nonmatchingBracket"});function wd(r){let t=[],e=r.matched?gd:md;return t.push(e.range(r.start.from,r.start.to)),r.end&&t.push(e.range(r.end.from,r.end.to)),t}function No(r){let t=[],e=r.facet(Va);for(let i of r.selection.ranges){if(!i.empty)continue;let n=jt(r,i.head,-1,e)||i.head>0&&jt(r,i.head-1,1,e)||e.afterCursor&&(jt(r,i.head,1,e)||i.head<r.doc.length&&jt(r,i.head+1,-1,e));n&&(t=t.concat(e.renderMatch(n,r)))}return P.set(t,!0)}const vd=wt.fromClass(class{constructor(r){this.paused=!1,this.decorations=No(r.state)}update(r){(r.docChanged||r.selectionSet||this.paused)&&(r.view.composing?(this.decorations=this.decorations.map(r.changes),this.paused=!0):(this.decorations=No(r.state),this.paused=!1))}},{decorations:r=>r.decorations}),yd=[vd,pd];function bd(r={}){return[Va.of(r),yd]}const xd=new L;function zr(r,t,e){let i=r.prop(t<0?L.openedBy:L.closedBy);if(i)return i;if(r.name.length==1){let n=e.indexOf(r.name);if(n>-1&&n%2==(t<0?1:0))return[e[n+t]]}return null}function jr(r){let t=r.type.prop(xd);return t?t(r.node):r}function jt(r,t,e,i={}){let n=i.maxScanDistance||Wa,s=i.brackets||Ha,o=vt(r),l=o.resolveInner(t,e);for(let a=l;a;a=a.parent){let h=zr(a.type,e,s);if(h&&a.from<a.to){let c=jr(a);if(c&&(e>0?t>=c.from&&t<c.to:t>c.from&&t<=c.to))return kd(r,t,e,a,c,h,s)}}return Sd(r,t,e,o,l.type,n,s)}function kd(r,t,e,i,n,s,o){let l=i.parent,a={from:n.from,to:n.to},h=0,c=l?.cursor();if(c&&(e<0?c.childBefore(i.from):c.childAfter(i.to)))do if(e<0?c.to<=i.from:c.from>=i.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=jr(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(zr(c.type,e,o))h++;else if(zr(c.type,-e,o)){if(h==0){let f=jr(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(e<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Sd(r,t,e,i,n,s,o){if(e<0?!t:t==r.doc.length)return null;let l=e<0?r.sliceDoc(t-1,t):r.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},c=r.doc.iterRange(t,e>0?r.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let d=c.value;e<0&&(u+=d.length);let p=t+u*e;for(let g=e>0?0:d.length-1,m=e>0?d.length:-1;g!=m;g+=e){let w=o.indexOf(d[g]);if(!(w<0||i.resolveInner(p+g,1).type!=n))if(w%2==0==e>0)f++;else{if(f==1)return{start:h,end:{from:p+g,to:p+g+1},matched:w>>1==a>>1};f--}}e>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const Ad=Object.create(null),Io=[dt.none],Wo=[],Ho=Object.create(null),Md=Object.create(null);for(let[r,t]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"]])Md[r]=Cd(Ad,t);function nr(r,t){Wo.indexOf(r)>-1||(Wo.push(r),console.warn(t))}function Cd(r,t){let e=[];for(let l of t.split(" ")){let a=[];for(let h of l.split(".")){let c=r[h]||k[h];c?typeof c=="function"?a.length?a=a.map(c):nr(h,`Modifier ${h} used at start of tag`):a.length?nr(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:nr(h,`Unknown highlighting tag ${h}`)}for(let h of a)e.push(h)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),n=i+" "+e.map(l=>l.id),s=Ho[n];if(s)return s.id;let o=Ho[n]=dt.define({id:Io.length,name:i,props:[Du({[i]:e})]});return Io.push(o),o.id}_.RTL,_.LTR;const Od=r=>{let{state:t}=r,e=t.doc.lineAt(t.selection.main.from),i=ms(r.state,e.from);return i.line?Td(r):i.block?Ed(r):!1};function gs(r,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=r(t,e);return n?(i(e.update(n)),!0):!1}}const Td=gs(Rd,0),Dd=gs(Fa,0),Ed=gs((r,t)=>Fa(r,t,Ld(t)),0);function ms(r,t){let e=r.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const Ze=50;function Bd(r,{open:t,close:e},i,n){let s=r.sliceDoc(i-Ze,i),o=r.sliceDoc(n,n+Ze),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-t.length,h)==t&&o.slice(a,a+e.length)==e)return{open:{pos:i-l,margin:l&&1},close:{pos:n+a,margin:a&&1}};let c,f;n-i<=2*Ze?c=f=r.sliceDoc(i,n):(c=r.sliceDoc(i,i+Ze),f=r.sliceDoc(n-Ze,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-e.length;return c.slice(u,u+t.length)==t&&f.slice(p,p+e.length)==e?{open:{pos:i+u+t.length,margin:/\s/.test(c.charAt(u+t.length))?1:0},close:{pos:n-d-e.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function Ld(r){let t=[];for(let e of r.selection.ranges){let i=r.doc.lineAt(e.from),n=e.to<=i.to?i:r.doc.lineAt(e.to);n.from>i.from&&n.from==e.to&&(n=e.to==i.to+1?i:r.doc.lineAt(e.to-1));let s=t.length-1;s>=0&&t[s].to>i.from?t[s].to=n.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return t}function Fa(r,t,e=t.selection.ranges){let i=e.map(s=>ms(t,s.from).block);if(!i.every(s=>s))return null;let n=e.map((s,o)=>Bd(t,i[o],s.from,s.to));if(r!=2&&!n.every(s=>s))return{changes:t.changes(e.map((s,o)=>n[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(r!=1&&n.some(s=>s)){let s=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function Rd(r,t,e=t.selection.ranges){let i=[],n=-1;t:for(let{from:s,to:o}of e){let l=i.length,a=1e9,h;for(let c=s;c<=o;){let f=t.doc.lineAt(c);if(h==null&&(h=ms(t,f.from).line,!h))continue t;if(f.from>n&&(s==o||o>f.from)){n=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(r!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=t.changes(s);return{changes:o,selection:t.selection.map(o,1)}}else if(r!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}const Kr=he.define(),Pd=he.define(),Nd=O.define(),qa=O.define({combine(r){return Ke(r,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}}),za=Dt.define({create(){return Kt.empty},update(r,t){let e=t.state.facet(qa),i=t.annotation(Kr);if(i){let a=ct.fromTransaction(t,i.selection),h=i.side,c=h==0?r.undone:r.done;return a?c=mn(c,c.length,e.minDepth,a):c=$a(c,t.startState.selection),new Kt(h==0?i.rest:c,h==0?c:i.rest)}let n=t.annotation(Pd);if((n=="full"||n=="before")&&(r=r.isolate()),t.annotation(Q.addToHistory)===!1)return t.changes.empty?r:r.addMapping(t.changes.desc);let s=ct.fromTransaction(t),o=t.annotation(Q.time),l=t.annotation(Q.userEvent);return s?r=r.addChanges(s,o,l,e,t):t.selection&&(r=r.addSelection(t.startState.selection,o,l,e.newGroupDelay)),(n=="full"||n=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(t=>t.toJSON()),undone:r.undone.map(t=>t.toJSON())}},fromJSON(r){return new Kt(r.done.map(ct.fromJSON),r.undone.map(ct.fromJSON))}});function Id(r={}){return[za,qa.of(r),D.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?ja:t.inputType=="historyRedo"?$r:null;return i?(t.preventDefault(),i(e)):!1}})]}function Ln(r,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(za,!1);if(!n)return!1;let s=n.pop(r,e,t);return s?(i(s),!0):!1}}const ja=Ln(0,!1),$r=Ln(1,!1),Wd=Ln(0,!0),Hd=Ln(1,!0);class ct{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new ct(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(t){return new ct(t.changes&&X.fromJSON(t.changes),[],t.mapped&&$t.fromJSON(t.mapped),t.startSelection&&v.fromJSON(t.startSelection),t.selectionsAfter.map(v.fromJSON))}static fromTransaction(t,e){let i=St;for(let n of t.startState.facet(Nd)){let s=n(t);s.length&&(i=i.concat(s))}return!i.length&&t.changes.empty?null:new ct(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,St)}static selection(t){return new ct(void 0,St,void 0,void 0,t)}}function mn(r,t,e,i){let n=t+1>e+20?t-e-1:0,s=r.slice(n,t);return s.push(i),s}function Vd(r,t){let e=[],i=!1;return r.iterChangedRanges((n,s)=>e.push(n,s)),t.iterChangedRanges((n,s,o,l)=>{for(let a=0;a<e.length;){let h=e[a++],c=e[a++];l>=h&&o<=c&&(i=!0)}}),i}function Fd(r,t){return r.ranges.length==t.ranges.length&&r.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Ka(r,t){return r.length?t.length?r.concat(t):r:t}const St=[],qd=200;function $a(r,t){if(r.length){let e=r[r.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-qd));return i.length&&i[i.length-1].eq(t)?r:(i.push(t),mn(r,r.length-1,1e9,e.setSelAfter(i)))}else return[ct.selection([t])]}function zd(r){let t=r[r.length-1],e=r.slice();return e[r.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function rr(r,t){if(!r.length)return r;let e=r.length,i=St;for(;e;){let n=jd(r[e-1],t,i);if(n.changes&&!n.changes.empty||n.effects.length){let s=r.slice(0,e);return s[e-1]=n,s}else t=n.mapped,e--,i=n.selectionsAfter}return i.length?[ct.selection(i)]:St}function jd(r,t,e){let i=Ka(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(t)):St,e);if(!r.changes)return ct.selection(i);let n=r.changes.map(t),s=t.mapDesc(r.changes,!0),o=r.mapped?r.mapped.composeDesc(s):s;return new ct(n,H.mapEffects(r.effects,t),o,r.startSelection.map(s),i)}const Kd=/^(input\.type|delete)($|\.)/;class Kt{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Kt(this.done,this.undone):this}addChanges(t,e,i,n,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!i||Kd.test(i))&&(!l.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,Vd(l.changes,t.changes))||i=="input.type.compose")?o=mn(o,o.length-1,n.minDepth,new ct(t.changes.compose(l.changes),Ka(H.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,St)):o=mn(o,o.length,n.minDepth,t),new Kt(o,St,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:St;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Fd(s[s.length-1],t)?this:new Kt($a(this.done,t),this.undone,e,i)}addMapping(t){return new Kt(rr(this.done,t),rr(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=t==0?this.done:this.undone;if(n.length==0)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):e.selection);if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Kr.of({side:t,rest:zd(n),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=n.length==1?St:n.slice(0,n.length-1);return s.mapped&&(l=rr(l,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Kr.of({side:t,rest:l,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}Kt.empty=new Kt(St,St);const $d=[{key:"Mod-z",run:ja,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:$r,preventDefault:!0},{linux:"Ctrl-Shift-z",run:$r,preventDefault:!0},{key:"Mod-u",run:Wd,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Hd,preventDefault:!0}];function Ue(r,t){return v.create(r.ranges.map(t),r.mainIndex)}function Et(r,t){return r.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Bt({state:r,dispatch:t},e){let i=Ue(r.selection,e);return i.eq(r.selection,!0)?!1:(t(Et(r,i)),!0)}function Rn(r,t){return v.cursor(t?r.to:r.from)}function Ua(r,t){return Bt(r,e=>e.empty?r.moveByChar(e,t):Rn(e,t))}function ot(r){return r.textDirectionAt(r.state.selection.main.head)==_.LTR}const Ja=r=>Ua(r,!ot(r)),Ga=r=>Ua(r,ot(r));function _a(r,t){return Bt(r,e=>e.empty?r.moveByGroup(e,t):Rn(e,t))}const Ud=r=>_a(r,!ot(r)),Jd=r=>_a(r,ot(r));function Gd(r,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(r.sliceDoc(t.from,t.to)))||t.firstChild}function Pn(r,t,e){let i=vt(r).resolveInner(t.head),n=e?L.closedBy:L.openedBy;for(let a=t.head;;){let h=e?i.childAfter(a):i.childBefore(a);if(!h)break;Gd(r,h,n)?i=h:a=e?h.to:h.from}let s=i.type.prop(n),o,l;return s&&(o=e?jt(r,i.from,1):jt(r,i.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?i.to:i.from,v.cursor(l,e?-1:1)}const _d=r=>Bt(r,t=>Pn(r.state,t,!ot(r))),Yd=r=>Bt(r,t=>Pn(r.state,t,ot(r)));function Ya(r,t){return Bt(r,e=>{if(!e.empty)return Rn(e,t);let i=r.moveVertically(e,t);return i.head!=e.head?i:r.moveToLineBoundary(e,t)})}const Xa=r=>Ya(r,!1),Qa=r=>Ya(r,!0);function Za(r){let t=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let s of r.state.facet(D.scrollMargins)){let o=s(r);o?.top&&(e=Math.max(o?.top,e)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=r.scrollDOM.clientHeight-e-i}else n=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(r.defaultLineHeight,n-5)}}function th(r,t){let e=Za(r),{state:i}=r,n=Ue(i.selection,o=>o.empty?r.moveVertically(o,t,e.height):Rn(o,t));if(n.eq(i.selection))return!1;let s;if(e.selfScroll){let o=r.coordsAtPos(i.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),a=l.top+e.marginTop,h=l.bottom-e.marginBottom;o&&o.top>a&&o.bottom<h&&(s=D.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-a}))}return r.dispatch(Et(i,n),{effects:s}),!0}const Vo=r=>th(r,!1),Ur=r=>th(r,!0);function ce(r,t,e){let i=r.lineBlockAt(t.head),n=r.moveToLineBoundary(t,e);if(n.head==t.head&&n.head!=(e?i.to:i.from)&&(n=r.moveToLineBoundary(t,e,!1)),!e&&n.head==i.from&&i.length){let s=/^\s*/.exec(r.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&t.head!=i.from+s&&(n=v.cursor(i.from+s))}return n}const Xd=r=>Bt(r,t=>ce(r,t,!0)),Qd=r=>Bt(r,t=>ce(r,t,!1)),Zd=r=>Bt(r,t=>ce(r,t,!ot(r))),tp=r=>Bt(r,t=>ce(r,t,ot(r))),ep=r=>Bt(r,t=>v.cursor(r.lineBlockAt(t.head).from,1)),ip=r=>Bt(r,t=>v.cursor(r.lineBlockAt(t.head).to,-1));function np(r,t,e){let i=!1,n=Ue(r.selection,s=>{let o=jt(r,s.head,-1)||jt(r,s.head,1)||s.head>0&&jt(r,s.head-1,1)||s.head<r.doc.length&&jt(r,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return v.cursor(l)});return i?(t(Et(r,n)),!0):!1}const rp=({state:r,dispatch:t})=>np(r,t);function At(r,t){let e=Ue(r.state.selection,i=>{let n=t(i);return v.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return e.eq(r.state.selection)?!1:(r.dispatch(Et(r.state,e)),!0)}function eh(r,t){return At(r,e=>r.moveByChar(e,t))}const ih=r=>eh(r,!ot(r)),nh=r=>eh(r,ot(r));function rh(r,t){return At(r,e=>r.moveByGroup(e,t))}const sp=r=>rh(r,!ot(r)),op=r=>rh(r,ot(r)),lp=r=>At(r,t=>Pn(r.state,t,!ot(r))),ap=r=>At(r,t=>Pn(r.state,t,ot(r)));function sh(r,t){return At(r,e=>r.moveVertically(e,t))}const oh=r=>sh(r,!1),lh=r=>sh(r,!0);function ah(r,t){return At(r,e=>r.moveVertically(e,t,Za(r).height))}const Fo=r=>ah(r,!1),qo=r=>ah(r,!0),hp=r=>At(r,t=>ce(r,t,!0)),cp=r=>At(r,t=>ce(r,t,!1)),fp=r=>At(r,t=>ce(r,t,!ot(r))),up=r=>At(r,t=>ce(r,t,ot(r))),dp=r=>At(r,t=>v.cursor(r.lineBlockAt(t.head).from)),pp=r=>At(r,t=>v.cursor(r.lineBlockAt(t.head).to)),zo=({state:r,dispatch:t})=>(t(Et(r,{anchor:0})),!0),jo=({state:r,dispatch:t})=>(t(Et(r,{anchor:r.doc.length})),!0),Ko=({state:r,dispatch:t})=>(t(Et(r,{anchor:r.selection.main.anchor,head:0})),!0),$o=({state:r,dispatch:t})=>(t(Et(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),gp=({state:r,dispatch:t})=>(t(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),mp=({state:r,dispatch:t})=>{let e=Nn(r).map(({from:i,to:n})=>v.range(i,Math.min(n+1,r.doc.length)));return t(r.update({selection:v.create(e),userEvent:"select"})),!0},wp=({state:r,dispatch:t})=>{let e=Ue(r.selection,i=>{let n=vt(r),s=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return v.range(l.to,l.from)}return i});return e.eq(r.selection)?!1:(t(Et(r,e)),!0)};function hh(r,t){let{state:e}=r,i=e.selection,n=e.selection.ranges.slice();for(let s of e.selection.ranges){let o=e.doc.lineAt(s.head);if(t?o.to<r.state.doc.length:o.from>0)for(let l=s;;){let a=r.moveVertically(l,t);if(a.head<o.from||a.head>o.to){n.some(h=>h.head==a.head)||n.push(a);break}else{if(a.head==l.head)break;l=a}}}return n.length==i.ranges.length?!1:(r.dispatch(Et(e,v.create(n,n.length-1))),!0)}const vp=r=>hh(r,!1),yp=r=>hh(r,!0),bp=({state:r,dispatch:t})=>{let e=r.selection,i=null;return e.ranges.length>1?i=v.create([e.main]):e.main.empty||(i=v.create([v.cursor(e.main.head)])),i?(t(Et(r,i)),!0):!1};function ki(r,t){if(r.state.readOnly)return!1;let e="delete.selection",{state:i}=r,n=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=t(s);a<o?(e="delete.backward",a=zi(r,a,!1)):a>o&&(e="delete.forward",a=zi(r,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=zi(r,o,!1),l=zi(r,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:v.cursor(o,o<s.head?-1:1)}});return n.changes.empty?!1:(r.dispatch(i.update(n,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?D.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function zi(r,t,e){if(r instanceof D)for(let i of r.state.facet(D.atomicRanges).map(n=>n(r)))i.between(t,t,(n,s)=>{n<t&&s>t&&(t=e?s:n)});return t}const ch=(r,t,e)=>ki(r,i=>{let n=i.from,{state:s}=r,o=s.doc.lineAt(n),l,a;if(e&&!t&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let h=Sn(l,s.tabSize),c=h%dn(s)||dn(s);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)n--;a=n}else a=tt(o.text,n-o.from,t,t)+o.from,a==n&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=tt(o.text,a-o.from,!1,!1)+o.from);return a}),Jr=r=>ch(r,!1,!0),fh=r=>ch(r,!0,!1),uh=(r,t)=>ki(r,e=>{let i=e.head,{state:n}=r,s=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(t?s.to:s.from)){i==e.head&&s.number!=(t?n.doc.lines:1)&&(i+=t?1:-1);break}let a=tt(s.text,i-s.from,t)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=e.head)&&(l=c),i=a}return i}),dh=r=>uh(r,!1),xp=r=>uh(r,!0),kp=r=>ki(r,t=>{let e=r.lineBlockAt(t.head).to;return t.head<e?e:Math.min(r.state.doc.length,t.head+1)}),Sp=r=>ki(r,t=>{let e=r.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),Ap=r=>ki(r,t=>{let e=r.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(r.state.doc.length,t.head+1)}),Mp=({state:r,dispatch:t})=>{if(r.readOnly)return!1;let e=r.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:W.of(["",""])},range:v.cursor(i.from)}));return t(r.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},Cp=({state:r,dispatch:t})=>{if(r.readOnly)return!1;let e=r.changeByRange(i=>{if(!i.empty||i.from==0||i.from==r.doc.length)return{range:i};let n=i.from,s=r.doc.lineAt(n),o=n==s.from?n-1:tt(s.text,n-s.from,!1)+s.from,l=n==s.to?n+1:tt(s.text,n-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:r.doc.slice(n,l).append(r.doc.slice(o,n))},range:v.cursor(l)}});return e.changes.empty?!1:(t(r.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Nn(r){let t=[],e=-1;for(let i of r.selection.ranges){let n=r.doc.lineAt(i.from),s=r.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=r.doc.lineAt(i.to-1)),e>=n.number){let o=t[t.length-1];o.to=s.to,o.ranges.push(i)}else t.push({from:n.from,to:s.to,ranges:[i]});e=s.number+1}return t}function ph(r,t,e){if(r.readOnly)return!1;let i=[],n=[];for(let s of Nn(r)){if(e?s.to==r.doc.length:s.from==0)continue;let o=r.doc.lineAt(e?s.to+1:s.from-1),l=o.length+1;if(e){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+r.lineBreak});for(let a of s.ranges)n.push(v.range(Math.min(r.doc.length,a.anchor+l),Math.min(r.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:r.lineBreak+o.text});for(let a of s.ranges)n.push(v.range(a.anchor-l,a.head-l))}}return i.length?(t(r.update({changes:i,scrollIntoView:!0,selection:v.create(n,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Op=({state:r,dispatch:t})=>ph(r,t,!1),Tp=({state:r,dispatch:t})=>ph(r,t,!0);function gh(r,t,e){if(r.readOnly)return!1;let i=[];for(let s of Nn(r))e?i.push({from:s.from,insert:r.doc.slice(s.from,s.to)+r.lineBreak}):i.push({from:s.to,insert:r.lineBreak+r.doc.slice(s.from,s.to)});let n=r.changes(i);return t(r.update({changes:n,selection:r.selection.map(n,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Dp=({state:r,dispatch:t})=>gh(r,t,!1),Ep=({state:r,dispatch:t})=>gh(r,t,!0),Bp=r=>{if(r.state.readOnly)return!1;let{state:t}=r,e=t.changes(Nn(t).map(({from:n,to:s})=>(n>0?n--:s<t.doc.length&&s++,{from:n,to:s}))),i=Ue(t.selection,n=>{let s;if(r.lineWrapping){let o=r.lineBlockAt(n.head),l=r.coordsAtPos(n.head,n.assoc||1);l&&(s=o.bottom+r.documentTop-l.bottom+r.defaultLineHeight/2)}return r.moveVertically(n,!0,s)}).map(e);return r.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Lp(r,t){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=vt(r).resolveInner(t),i=e.childBefore(t),n=e.childAfter(t),s;return i&&n&&i.to<=t&&n.from>=t&&(s=i.type.prop(L.closedBy))&&s.indexOf(n.name)>-1&&r.doc.lineAt(i.to).from==r.doc.lineAt(n.from).from&&!/\S/.test(r.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const Uo=mh(!1),Rp=mh(!0);function mh(r){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:s,to:o}=n,l=t.doc.lineAt(s),a=!r&&s==o&&Lp(t,s);r&&(s=o=(o<=l.to?l:t.doc.lineAt(o)).to);let h=new Dn(t,{simulateBreak:s,simulateDoubleBreak:!!a}),c=ds(h,s);for(c==null&&(c=Sn(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",mi(t,c)];return a&&f.push(mi(t,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:W.of(f)},range:v.cursor(s+1+f[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function ws(r,t){let e=-1;return r.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=r.doc.lineAt(o);l.number>e&&(i.empty||i.to>l.from)&&(t(l,n,i),e=l.number),o=l.to+1}let s=r.changes(n);return{changes:n,range:v.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const Pp=({state:r,dispatch:t})=>{if(r.readOnly)return!1;let e=Object.create(null),i=new Dn(r,{overrideIndentation:s=>e[s]??-1}),n=ws(r,(s,o,l)=>{let a=ds(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=mi(r,a);(h!=c||l.from<s.from+h.length)&&(e[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return n.changes.empty||t(r.update(n,{userEvent:"indent"})),!0},wh=({state:r,dispatch:t})=>r.readOnly?!1:(t(r.update(ws(r,(e,i)=>{i.push({from:e.from,insert:r.facet(us)})}),{userEvent:"input.indent"})),!0),vh=({state:r,dispatch:t})=>r.readOnly?!1:(t(r.update(ws(r,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=Sn(n,r.tabSize),o=0,l=mi(r,Math.max(0,s-dn(r)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Np=r=>(r.setTabFocusMode(),!0),Ip=[{key:"Ctrl-b",run:Ja,shift:ih,preventDefault:!0},{key:"Ctrl-f",run:Ga,shift:nh},{key:"Ctrl-p",run:Xa,shift:oh},{key:"Ctrl-n",run:Qa,shift:lh},{key:"Ctrl-a",run:ep,shift:dp},{key:"Ctrl-e",run:ip,shift:pp},{key:"Ctrl-d",run:fh},{key:"Ctrl-h",run:Jr},{key:"Ctrl-k",run:kp},{key:"Ctrl-Alt-h",run:dh},{key:"Ctrl-o",run:Mp},{key:"Ctrl-t",run:Cp},{key:"Ctrl-v",run:Ur}],Wp=[{key:"ArrowLeft",run:Ja,shift:ih,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ud,shift:sp,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Zd,shift:fp,preventDefault:!0},{key:"ArrowRight",run:Ga,shift:nh,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Jd,shift:op,preventDefault:!0},{mac:"Cmd-ArrowRight",run:tp,shift:up,preventDefault:!0},{key:"ArrowUp",run:Xa,shift:oh,preventDefault:!0},{mac:"Cmd-ArrowUp",run:zo,shift:Ko},{mac:"Ctrl-ArrowUp",run:Vo,shift:Fo},{key:"ArrowDown",run:Qa,shift:lh,preventDefault:!0},{mac:"Cmd-ArrowDown",run:jo,shift:$o},{mac:"Ctrl-ArrowDown",run:Ur,shift:qo},{key:"PageUp",run:Vo,shift:Fo},{key:"PageDown",run:Ur,shift:qo},{key:"Home",run:Qd,shift:cp,preventDefault:!0},{key:"Mod-Home",run:zo,shift:Ko},{key:"End",run:Xd,shift:hp,preventDefault:!0},{key:"Mod-End",run:jo,shift:$o},{key:"Enter",run:Uo,shift:Uo},{key:"Mod-a",run:gp},{key:"Backspace",run:Jr,shift:Jr,preventDefault:!0},{key:"Delete",run:fh,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:dh,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:xp,preventDefault:!0},{mac:"Mod-Backspace",run:Sp,preventDefault:!0},{mac:"Mod-Delete",run:Ap,preventDefault:!0}].concat(Ip.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),Hp=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:_d,shift:lp},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Yd,shift:ap},{key:"Alt-ArrowUp",run:Op},{key:"Shift-Alt-ArrowUp",run:Dp},{key:"Alt-ArrowDown",run:Tp},{key:"Shift-Alt-ArrowDown",run:Ep},{key:"Mod-Alt-ArrowUp",run:vp},{key:"Mod-Alt-ArrowDown",run:yp},{key:"Escape",run:bp},{key:"Mod-Enter",run:Rp},{key:"Alt-l",mac:"Ctrl-l",run:mp},{key:"Mod-i",run:wp,preventDefault:!0},{key:"Mod-[",run:vh},{key:"Mod-]",run:wh},{key:"Mod-Alt-\\",run:Pp},{key:"Shift-Mod-k",run:Bp},{key:"Shift-Mod-\\",run:rp},{key:"Mod-/",run:Od},{key:"Alt-A",run:Dd},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Np}].concat(Wp),Vp={key:"Tab",run:wh,shift:vh},Jo=typeof String.prototype.normalize=="function"?r=>r.normalize("NFKD"):r=>r;class je{constructor(t,e,i=0,n=t.length,s,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?l=>s(Jo(l)):Jo,this.query=this.normalize(e)}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 nl(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=zh(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=rl(t);let n=this.normalize(e);if(n.length)for(let s=0,o=i,l=!0;;s++){let a=n.charCodeAt(s),h=this.match(a,o,l,this.bufferPos+this.bufferStart,s==n.length-1);if(h)return this.value=h,this;if(s==n.length-1)break;l&&s<e.length&&e.charCodeAt(s)==a?o++:l=!1}}}match(t,e,i,n,s){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==t&&(a.index==this.query.length-1?o={from:a.from,to:n,precise:s&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==t&&(this.query.length==1?o={from:e,to:n,precise:i&&s}:this.matches.push({from:e,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(je.prototype[Symbol.iterator]=function(){return this});const yh={from:-1,to:-1,match:/.*/.exec(""),precise:!0},vs="gm"+(/x/.unicode==null?"":"u");class bh{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=yh,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new xh(t,e,i,n,s);this.re=new RegExp(e,vs+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=t.iter();let o=t.lineAt(n);this.curLineStart=o.from,this.matchPos=wn(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),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 t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=wn(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,precise:!0,match:e},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const sr=new WeakMap;class We{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=sr.get(t);if(!n||n.from>=i||n.to<=e){let l=new We(e,t.sliceString(e,i));return sr.set(t,l),l}if(n.from==e&&n.to==i)return n;let{text:s,from:o}=n;return o>e&&(s=t.sliceString(e,o)+s,o=e),n.to<i&&(s+=t.sliceString(n.to,i)),sr.set(t,new We(o,s)),new We(e,s.slice(e-o,i-o))}}class xh{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=yh,this.matchPos=wn(t,n),this.re=new RegExp(e,vs+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=We.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let i=this.flat.from+e.index,n=i+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,precise:!0,match:e},this.matchPos=wn(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=We.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(bh.prototype[Symbol.iterator]=xh.prototype[Symbol.iterator]=function(){return this});function Fp(r){try{return new RegExp(r,vs),!0}catch{return!1}}function wn(r,t){if(t>=r.length)return t;let e=r.lineAt(t),i;for(;t<e.to&&(i=e.text.charCodeAt(t-e.from))>=56320&&i<57344;)t++;return t}const qp=r=>{let{state:t}=r,e=String(t.doc.lineAt(r.state.selection.main.head).number),{close:i,result:n}=_f(r,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:e},focus:!0,submitLabel:t.phrase("go")});return n.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){r.dispatch({effects:i});return}let l=t.doc.lineAt(t.selection.main.head),[,a,h,c,f]=o,u=c?+c.slice(1):0,d=h?+h:l.number;if(h&&f){let m=d/100;a&&(m=m*(a=="-"?-1:1)+l.number/t.doc.lines),d=Math.round(t.doc.lines*m)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),g=v.cursor(p.from+Math.max(0,Math.min(u,p.length)));r.dispatch({effects:[i,D.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},zp={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},jp=O.define({combine(r){return Ke(r,zp,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})}});function Kp(r){return[_p,Gp]}const $p=P.mark({class:"cm-selectionMatch"}),Up=P.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Go(r,t,e,i){return(e==0||r(t.sliceDoc(e-1,e))!=G.Word)&&(i==t.doc.length||r(t.sliceDoc(i,i+1))!=G.Word)}function Jp(r,t,e,i){return r(t.sliceDoc(e,e+1))==G.Word&&r(t.sliceDoc(i-1,i))==G.Word}const Gp=wt.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let t=r.state.facet(jp),{state:e}=r,i=e.selection;if(i.ranges.length>1)return P.none;let n=i.main,s,o=null;if(n.empty){if(!t.highlightWordAroundCursor)return P.none;let a=e.wordAt(n.head);if(!a)return P.none;o=e.charCategorizer(n.head),s=e.sliceDoc(a.from,a.to)}else{let a=n.to-n.from;if(a<t.minSelectionLength||a>200)return P.none;if(t.wholeWords){if(s=e.sliceDoc(n.from,n.to),o=e.charCategorizer(n.head),!(Go(o,e,n.from,n.to)&&Jp(o,e,n.from,n.to)))return P.none}else if(s=e.sliceDoc(n.from,n.to),!s)return P.none}let l=[];for(let a of r.visibleRanges){let h=new je(e.doc,s,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||Go(o,e,c,f))&&(n.empty&&c<=n.from&&f>=n.to?l.push(Up.range(c,f)):(c>=n.to||f<=n.from)&&l.push($p.range(c,f)),l.length>t.maxMatches))return P.none}}return P.set(l)}},{decorations:r=>r.decorations}),_p=D.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Yp=({state:r,dispatch:t})=>{let{selection:e}=r,i=v.create(e.ranges.map(n=>r.wordAt(n.head)||v.cursor(n.head)),e.mainIndex);return i.eq(e)?!1:(t(r.update({selection:i})),!0)};function Xp(r,t){let{main:e,ranges:i}=r.selection,n=r.wordAt(e.head),s=n&&n.from==e.from&&n.to==e.to;for(let o=!1,l=new je(r.doc,t,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new je(r.doc,t,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(s){let a=r.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Qp=({state:r,dispatch:t})=>{let{ranges:e}=r.selection;if(e.some(s=>s.from===s.to))return Yp({state:r,dispatch:t});let i=r.sliceDoc(e[0].from,e[0].to);if(r.selection.ranges.some(s=>r.sliceDoc(s.from,s.to)!=i))return!1;let n=Xp(r,i);return n?(t(r.update({selection:r.selection.addRange(v.range(n.from,n.to),!1),effects:D.scrollIntoView(n.to)})),!0):!1},Je=O.define({combine(r){return Ke(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new ug(t),scrollToMatch:t=>D.scrollIntoView(t)})}});class kh{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||Fp(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(e,i)=>i=="n"?`
|
|
12
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new rg(this):new eg(this)}getCursor(t,e=0,i){let n=t.doc?t:I.create({doc:t});return i==null&&(i=n.doc.length),this.regexp?Te(this,n,e,i):Oe(this,n,e,i)}}class Sh{constructor(t){this.spec=t}}function Zp(r,t,e){return(i,n,s,o)=>{if(e&&!e(i,n,s,o))return!1;let l=i>=o&&n<=o+s.length?s.slice(i-o,n-o):t.doc.sliceString(i,n);return r(l,t,i,n)}}function Oe(r,t,e,i){let n;return r.wholeWord&&(n=tg(t.doc,t.charCategorizer(t.selection.main.head))),r.test&&(n=Zp(r.test,t,n)),new je(t.doc,r.unquoted,e,i,r.caseSensitive?void 0:s=>s.toLowerCase(),n)}function tg(r,t){return(e,i,n,s)=>((s>e||s+n.length<i)&&(s=Math.max(0,e-2),n=r.sliceString(s,Math.min(r.length,i+2))),(t(vn(n,e-s))!=G.Word||t(yn(n,e-s))!=G.Word)&&(t(yn(n,i-s))!=G.Word||t(vn(n,i-s))!=G.Word))}class eg extends Sh{constructor(t){super(t)}nextMatch(t,e,i){let n=Oe(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let s=Math.min(t.doc.length,e+this.spec.unquoted.length);n=Oe(this.spec,t,0,s).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let s=Math.max(e,n-1e4-this.spec.unquoted.length),o=Oe(this.spec,t,s,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),n&&(n.from!=e||n.to!=i)?n:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=Oe(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=Oe(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function ig(r,t,e){return(i,n,s)=>(!e||e(i,n,s))&&r(s[0],t,i,n)}function Te(r,t,e,i){let n;return r.wholeWord&&(n=ng(t.charCategorizer(t.selection.main.head))),r.test&&(n=ig(r.test,t,n)),new bh(t.doc,r.search,{ignoreCase:!r.caseSensitive,test:n},e,i)}function vn(r,t){return r.slice(tt(r,t,!1),t)}function yn(r,t){return r.slice(t,tt(r,t))}function ng(r){return(t,e,i)=>!i[0].length||(r(vn(i.input,i.index))!=G.Word||r(yn(i.input,i.index))!=G.Word)&&(r(yn(i.input,i.index+i[0].length))!=G.Word||r(vn(i.input,i.index+i[0].length))!=G.Word)}class rg extends Sh{nextMatch(t,e,i){let n=Te(this.spec,t,i,t.doc.length).next();return n.done&&(n=Te(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-n*1e4),o=Te(this.spec,t,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==e||l.from>s+10))return l;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,i)=>{if(i=="&")return t.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let s=+i.slice(0,n);if(s>0&&s<t.match.length)return t.match[s]+i.slice(n)}return e})}matchAll(t,e){let i=Te(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=Te(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const wi=H.define(),ys=H.define(),ne=Dt.define({create(r){return new or(Gr(r).create(),null)},update(r,t){for(let e of t.effects)e.is(wi)?r=new or(e.value.create(),r.panel):e.is(ys)&&(r=new or(r.query,e.value?bs:null));return r},provide:r=>hn.from(r,t=>t.panel)});class or{constructor(t,e){this.query=t,this.panel=e}}const sg=P.mark({class:"cm-searchMatch"}),og=P.mark({class:"cm-searchMatch cm-searchMatch-selected"}),lg=wt.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(ne))}update(r){let t=r.state.field(ne);(t!=r.startState.field(ne)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:r,panel:t}){if(!t||!r.spec.valid)return P.none;let{view:e}=this,i=new be;for(let n=0,s=e.visibleRanges,o=s.length;n<o;n++){let{from:l,to:a}=s[n];for(;n<o-1&&a>s[n+1].from-500;)a=s[++n].to;r.highlight(e.state,l,a,(h,c)=>{let f=e.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?og:sg)})}return i.finish()}},{decorations:r=>r.decorations});function Si(r){return t=>{let e=t.state.field(ne,!1);return e&&e.query.spec.valid?r(t,e):Ch(t)}}const bn=Si((r,{query:t})=>{let{to:e}=r.state.selection.main,i=t.nextMatch(r.state,e,e);if(!i)return!1;let n=v.single(i.from,i.to),s=r.state.facet(Je);return r.dispatch({selection:n,effects:[xs(r,i),s.scrollToMatch(n.main,r)],userEvent:"select.search"}),Mh(r),!0}),xn=Si((r,{query:t})=>{let{state:e}=r,{from:i}=e.selection.main,n=t.prevMatch(e,i,i);if(!n)return!1;let s=v.single(n.from,n.to),o=r.state.facet(Je);return r.dispatch({selection:s,effects:[xs(r,n),o.scrollToMatch(s.main,r)],userEvent:"select.search"}),Mh(r),!0}),ag=Si((r,{query:t})=>{let e=t.matchAll(r.state,1e3);return!e||!e.length?!1:(r.dispatch({selection:v.create(e.map(i=>v.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),hg=({state:r,dispatch:t})=>{let e=r.selection;if(e.ranges.length>1||e.main.empty)return!1;let{from:i,to:n}=e.main,s=[],o=0;for(let l=new je(r.doc,r.sliceDoc(i,n));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(v.range(l.value.from,l.value.to))}return t(r.update({selection:v.create(s,o),userEvent:"select.search.matches"})),!0},_o=Si((r,{query:t})=>{let{state:e}=r,{from:i,to:n}=e.selection.main;if(e.readOnly)return!1;let s=t.nextMatch(e,i,i);if(!s)return!1;let o=s,l=[],a,h,c=[];o.precise?o.from==i&&o.to==n&&(h=e.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),c.push(D.announce.of(e.phrase("replaced match on line $",e.doc.lineAt(i).number)+"."))):o=t.nextMatch(e,o.from,o.to);let f=r.state.changes(l);return o&&(a=v.single(o.from,o.to).map(f),c.push(xs(r,o)),c.push(e.facet(Je).scrollToMatch(a.main,r))),r.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),cg=Si((r,{query:t})=>{if(r.state.readOnly)return!1;let e=[];for(let n of t.matchAll(r.state,1e9)){let{from:s,to:o,precise:l}=n;l&&e.push({from:s,to:o,insert:t.getReplacement(n)})}if(!e.length)return!1;let i=r.state.phrase("replaced $ matches",e.length)+".";return r.dispatch({changes:e,effects:D.announce.of(i),userEvent:"input.replace.all"}),!0});function bs(r){return r.state.facet(Je).createPanel(r)}function Gr(r,t){var e,i,n,s,o;let l=r.selection.main,a=l.empty||l.to>l.from+100?"":r.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=r.facet(Je);return new kh({search:((e=t?.literal)!==null&&e!==void 0?e:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=t?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(n=t?.literal)!==null&&n!==void 0?n:h.literal,regexp:(s=t?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=t?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Ah(r){let t=da(r,bs);return t&&t.dom.querySelector("[main-field]")}function Mh(r){let t=Ah(r);t&&t==r.root.activeElement&&t.select()}const Ch=r=>{let t=r.state.field(ne,!1);if(t&&t.panel){let e=Ah(r);if(e&&e!=r.root.activeElement){let i=Gr(r.state,t.query.spec);i.valid&&r.dispatch({effects:wi.of(i)}),e.focus(),e.select()}}else r.dispatch({effects:[ys.of(!0),t?wi.of(Gr(r.state,t.query.spec)):H.appendConfig.of(pg)]});return!0},Oh=r=>{let t=r.state.field(ne,!1);if(!t||!t.panel)return!1;let e=da(r,bs);return e&&e.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:ys.of(!1)}),!0},fg=[{key:"Mod-f",run:Ch,scope:"editor search-panel"},{key:"F3",run:bn,shift:xn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:bn,shift:xn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Oh,scope:"editor search-panel"},{key:"Mod-Shift-l",run:hg},{key:"Mod-Alt-g",run:qp},{key:"Mod-d",run:Qp,preventDefault:!0}];class ug{constructor(t){this.view=t;let e=this.query=t.state.field(ne).query.spec;this.commit=this.commit.bind(this),this.searchField=Z("input",{value:e.search,placeholder:pt(t,"Find"),"aria-label":pt(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Z("input",{value:e.replace,placeholder:pt(t,"Replace"),"aria-label":pt(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Z("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Z("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Z("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit});function i(n,s,o){return Z("button",{class:"cm-button",name:n,onclick:s,type:"button"},o)}this.dom=Z("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>bn(t),[pt(t,"next")]),i("prev",()=>xn(t),[pt(t,"previous")]),i("select",()=>ag(t),[pt(t,"all")]),Z("label",null,[this.caseField,pt(t,"match case")]),Z("label",null,[this.reField,pt(t,"regexp")]),Z("label",null,[this.wordField,pt(t,"by word")]),...t.state.readOnly?[]:[Z("br"),this.replaceField,i("replace",()=>_o(t),[pt(t,"replace")]),i("replaceAll",()=>cg(t),[pt(t,"replace all")])],Z("button",{name:"close",onclick:()=>Oh(t),"aria-label":pt(t,"close"),type:"button"},["×"])])}commit(){let t=new kh({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:wi.of(t)}))}keydown(t){Uf(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?xn:bn)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),_o(this.view))}update(t){for(let e of t.transactions)for(let i of e.effects)i.is(wi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Je).top}}function pt(r,t){return r.state.phrase(t)}const ji=30,Ki=/[\s\.,:;?!]/;function xs(r,{from:t,to:e}){let i=r.state.doc.lineAt(t),n=r.state.doc.lineAt(e).to,s=Math.max(i.from,t-ji),o=Math.min(n,e+ji),l=r.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<ji;a++)if(!Ki.test(l[a+1])&&Ki.test(l[a])){l=l.slice(a);break}}if(o!=n){for(let a=l.length-1;a>l.length-ji;a--)if(!Ki.test(l[a-1])&&Ki.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${r.state.phrase("current match")}. ${l} ${r.state.phrase("on line")} ${i.number}.`)}const dg=D.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"}}),pg=[ne,kn.low(lg),dg],gg={class:"vuefinder__codemirror-wrapper"},mg=["title","aria-label","aria-pressed"],Yo="vuefinder:codemirror-wrap",wg=Dh({name:"CodeMirrorEditor",__name:"CodeMirrorEditor",props:{modelValue:{},readonly:{type:Boolean},filename:{}},emits:["update:modelValue"],setup(r,{emit:t}){const e=r,i=t,n=Th(),{t:s}=n.i18n,o=()=>{if(typeof window>"u")return!0;try{const T=window.localStorage.getItem(Yo);return T===null?!0:T==="1"}catch{return!0}},l=T=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Yo,T?"1":"0")}catch{}},a=As(null),h=As(o());let c=null;const f=new ve,u=new ve,d=new ve,p=new Map;function g(T){const S=T.split("/").pop()??"",A=S.lastIndexOf(".");return A>=0?S.slice(A+1).toLowerCase():""}async function m(T){const S=p.get(T);if(S)return S;let A=[];switch(T){case"json":case"jsonc":case"lock":{const{json:x}=await Rt(async()=>{const{json:E}=await import("./index-D76eWsZ1-BUecZt4E.js");return{json:E}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url);A=x();break}case"js":case"mjs":case"cjs":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-Bpnxnyfv.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x();break}case"jsx":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-Bpnxnyfv.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x({jsx:!0});break}case"ts":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-Bpnxnyfv.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x({typescript:!0});break}case"tsx":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-Bpnxnyfv.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x({typescript:!0,jsx:!0});break}case"vue":case"svelte":case"html":case"htm":{const{html:x}=await Rt(async()=>{const{html:E}=await import("./index-Dms7ZQ2h-DY4-ZFKr.js");return{html:E}},__vite__mapDeps([7,1,8,2,3,4,5,6]),import.meta.url);A=x();break}case"css":case"scss":case"sass":case"less":{const{css:x}=await Rt(async()=>{const{css:E}=await import("./index-fZBcgzqR-QE1WZxps.js");return{css:E}},__vite__mapDeps([8,1,2,3,4,5]),import.meta.url);A=x();break}case"md":case"markdown":{const{markdown:x}=await Rt(async()=>{const{markdown:E}=await import("./index-72rReQ2I-sU_re5gS.js");return{markdown:E}},__vite__mapDeps([9,6,1,2,3,4,5,7,8]),import.meta.url);A=x();break}case"yml":case"yaml":{const{yaml:x}=await Rt(async()=>{const{yaml:E}=await import("./index-mqeGrL6B-DZ51JJUI.js");return{yaml:E}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url);A=x();break}case"xml":case"svg":{const{xml:x}=await Rt(async()=>{const{xml:E}=await import("./index-DxypSQ0K-CDh8t7kw.js");return{xml:E}},__vite__mapDeps([11,1,2,3,4,5]),import.meta.url);A=x();break}default:A=[]}return p.set(T,A),A}function w(){return[ou(),hu(),Id(),ld(),Ju(),bd(),Kp(),cd(dd),ca.of([...Hp,...$d,...nd,...fg,Vp]),D.updateListener.of(T=>{if(!T.docChanged)return;const S=T.state.doc.toString();S!==e.modelValue&&i("update:modelValue",S)})]}const y=T=>T?D.lineWrapping:[],C=()=>{h.value=!h.value,l(h.value),c?.dispatch({effects:d.reconfigure(y(h.value))})};return Eh(async()=>{if(!a.value)return;const T=e.filename?await m(g(e.filename)):[],S=I.create({doc:e.modelValue??"",extensions:[...w(),f.of(I.readOnly.of(!!e.readonly)),u.of(T),d.of(y(h.value))]});c=new D({state:S,parent:a.value})}),In(()=>e.readonly,T=>{c?.dispatch({effects:f.reconfigure(I.readOnly.of(!!T))})}),In(()=>e.filename,async T=>{if(!c)return;const S=T?g(T):"",A=S?await m(S):[];c.dispatch({effects:u.reconfigure(A)})}),In(()=>e.modelValue,T=>{if(!c)return;const S=c.state.doc.toString();T!==S&&c.dispatch({changes:{from:0,to:S.length,insert:T??""}})}),Bh(()=>{c?.destroy(),c=null}),(T,S)=>(Lh(),Rh("div",gg,[Ms("button",{type:"button",class:Cs(["vuefinder__codemirror-wrap-toggle",{"vuefinder__codemirror-wrap-toggle--active":h.value}]),title:h.value?Wn(s)("Word wrap on — click to disable"):Wn(s)("Word wrap off — click to enable"),"aria-label":Wn(s)("Toggle word wrap"),"aria-pressed":h.value,onClick:C},[...S[0]||(S[0]=[Ph('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"></path><path d="M3 12h13a4 4 0 010 8h-3"></path><polyline points="16,16 13,20 16,24"></polyline><path d="M3 18h6"></path></svg>',1)])],10,mg),Ms("div",{ref_key:"container",ref:a,class:Cs(["vuefinder__codemirror-editor",{"vuefinder__codemirror-editor--readonly":r.readonly}])},null,2)]))}}),Tg=Object.freeze(Object.defineProperty({__proto__:null,default:wg},Symbol.toStringTag,{value:"Module"}));export{he as A,ca as B,Tg as C,P as D,v as E,O as F,Be as G,kg as H,F as I,Du as J,Nu as K,qr as L,mt as M,L as N,vt as O,un as P,k as Q,ye as R,H as S,bt as T,$e as W,cu as a,I as b,D as c,Ot as d,Ca as e,Sg as f,ya as g,dt as h,xg as i,wu as j,kn as k,Dt as l,W as m,Q as n,Y as o,xd as p,Cg as q,Sn as r,Pu as s,Ag as t,Mg as u,Og as v,_u as w,Gu as x,Vu as y,us as z};
|
|
12
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new rg(this):new eg(this)}getCursor(t,e=0,i){let n=t.doc?t:I.create({doc:t});return i==null&&(i=n.doc.length),this.regexp?Te(this,n,e,i):Oe(this,n,e,i)}}class Sh{constructor(t){this.spec=t}}function Zp(r,t,e){return(i,n,s,o)=>{if(e&&!e(i,n,s,o))return!1;let l=i>=o&&n<=o+s.length?s.slice(i-o,n-o):t.doc.sliceString(i,n);return r(l,t,i,n)}}function Oe(r,t,e,i){let n;return r.wholeWord&&(n=tg(t.doc,t.charCategorizer(t.selection.main.head))),r.test&&(n=Zp(r.test,t,n)),new je(t.doc,r.unquoted,e,i,r.caseSensitive?void 0:s=>s.toLowerCase(),n)}function tg(r,t){return(e,i,n,s)=>((s>e||s+n.length<i)&&(s=Math.max(0,e-2),n=r.sliceString(s,Math.min(r.length,i+2))),(t(vn(n,e-s))!=G.Word||t(yn(n,e-s))!=G.Word)&&(t(yn(n,i-s))!=G.Word||t(vn(n,i-s))!=G.Word))}class eg extends Sh{constructor(t){super(t)}nextMatch(t,e,i){let n=Oe(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let s=Math.min(t.doc.length,e+this.spec.unquoted.length);n=Oe(this.spec,t,0,s).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let s=Math.max(e,n-1e4-this.spec.unquoted.length),o=Oe(this.spec,t,s,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),n&&(n.from!=e||n.to!=i)?n:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=Oe(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=Oe(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function ig(r,t,e){return(i,n,s)=>(!e||e(i,n,s))&&r(s[0],t,i,n)}function Te(r,t,e,i){let n;return r.wholeWord&&(n=ng(t.charCategorizer(t.selection.main.head))),r.test&&(n=ig(r.test,t,n)),new bh(t.doc,r.search,{ignoreCase:!r.caseSensitive,test:n},e,i)}function vn(r,t){return r.slice(tt(r,t,!1),t)}function yn(r,t){return r.slice(t,tt(r,t))}function ng(r){return(t,e,i)=>!i[0].length||(r(vn(i.input,i.index))!=G.Word||r(yn(i.input,i.index))!=G.Word)&&(r(yn(i.input,i.index+i[0].length))!=G.Word||r(vn(i.input,i.index+i[0].length))!=G.Word)}class rg extends Sh{nextMatch(t,e,i){let n=Te(this.spec,t,i,t.doc.length).next();return n.done&&(n=Te(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-n*1e4),o=Te(this.spec,t,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==e||l.from>s+10))return l;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,i)=>{if(i=="&")return t.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let s=+i.slice(0,n);if(s>0&&s<t.match.length)return t.match[s]+i.slice(n)}return e})}matchAll(t,e){let i=Te(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=Te(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const wi=H.define(),ys=H.define(),ne=Dt.define({create(r){return new or(Gr(r).create(),null)},update(r,t){for(let e of t.effects)e.is(wi)?r=new or(e.value.create(),r.panel):e.is(ys)&&(r=new or(r.query,e.value?bs:null));return r},provide:r=>hn.from(r,t=>t.panel)});class or{constructor(t,e){this.query=t,this.panel=e}}const sg=P.mark({class:"cm-searchMatch"}),og=P.mark({class:"cm-searchMatch cm-searchMatch-selected"}),lg=wt.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(ne))}update(r){let t=r.state.field(ne);(t!=r.startState.field(ne)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:r,panel:t}){if(!t||!r.spec.valid)return P.none;let{view:e}=this,i=new be;for(let n=0,s=e.visibleRanges,o=s.length;n<o;n++){let{from:l,to:a}=s[n];for(;n<o-1&&a>s[n+1].from-500;)a=s[++n].to;r.highlight(e.state,l,a,(h,c)=>{let f=e.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?og:sg)})}return i.finish()}},{decorations:r=>r.decorations});function Si(r){return t=>{let e=t.state.field(ne,!1);return e&&e.query.spec.valid?r(t,e):Ch(t)}}const bn=Si((r,{query:t})=>{let{to:e}=r.state.selection.main,i=t.nextMatch(r.state,e,e);if(!i)return!1;let n=v.single(i.from,i.to),s=r.state.facet(Je);return r.dispatch({selection:n,effects:[xs(r,i),s.scrollToMatch(n.main,r)],userEvent:"select.search"}),Mh(r),!0}),xn=Si((r,{query:t})=>{let{state:e}=r,{from:i}=e.selection.main,n=t.prevMatch(e,i,i);if(!n)return!1;let s=v.single(n.from,n.to),o=r.state.facet(Je);return r.dispatch({selection:s,effects:[xs(r,n),o.scrollToMatch(s.main,r)],userEvent:"select.search"}),Mh(r),!0}),ag=Si((r,{query:t})=>{let e=t.matchAll(r.state,1e3);return!e||!e.length?!1:(r.dispatch({selection:v.create(e.map(i=>v.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),hg=({state:r,dispatch:t})=>{let e=r.selection;if(e.ranges.length>1||e.main.empty)return!1;let{from:i,to:n}=e.main,s=[],o=0;for(let l=new je(r.doc,r.sliceDoc(i,n));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(v.range(l.value.from,l.value.to))}return t(r.update({selection:v.create(s,o),userEvent:"select.search.matches"})),!0},_o=Si((r,{query:t})=>{let{state:e}=r,{from:i,to:n}=e.selection.main;if(e.readOnly)return!1;let s=t.nextMatch(e,i,i);if(!s)return!1;let o=s,l=[],a,h,c=[];o.precise?o.from==i&&o.to==n&&(h=e.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),c.push(D.announce.of(e.phrase("replaced match on line $",e.doc.lineAt(i).number)+"."))):o=t.nextMatch(e,o.from,o.to);let f=r.state.changes(l);return o&&(a=v.single(o.from,o.to).map(f),c.push(xs(r,o)),c.push(e.facet(Je).scrollToMatch(a.main,r))),r.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),cg=Si((r,{query:t})=>{if(r.state.readOnly)return!1;let e=[];for(let n of t.matchAll(r.state,1e9)){let{from:s,to:o,precise:l}=n;l&&e.push({from:s,to:o,insert:t.getReplacement(n)})}if(!e.length)return!1;let i=r.state.phrase("replaced $ matches",e.length)+".";return r.dispatch({changes:e,effects:D.announce.of(i),userEvent:"input.replace.all"}),!0});function bs(r){return r.state.facet(Je).createPanel(r)}function Gr(r,t){var e,i,n,s,o;let l=r.selection.main,a=l.empty||l.to>l.from+100?"":r.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=r.facet(Je);return new kh({search:((e=t?.literal)!==null&&e!==void 0?e:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=t?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(n=t?.literal)!==null&&n!==void 0?n:h.literal,regexp:(s=t?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=t?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Ah(r){let t=da(r,bs);return t&&t.dom.querySelector("[main-field]")}function Mh(r){let t=Ah(r);t&&t==r.root.activeElement&&t.select()}const Ch=r=>{let t=r.state.field(ne,!1);if(t&&t.panel){let e=Ah(r);if(e&&e!=r.root.activeElement){let i=Gr(r.state,t.query.spec);i.valid&&r.dispatch({effects:wi.of(i)}),e.focus(),e.select()}}else r.dispatch({effects:[ys.of(!0),t?wi.of(Gr(r.state,t.query.spec)):H.appendConfig.of(pg)]});return!0},Oh=r=>{let t=r.state.field(ne,!1);if(!t||!t.panel)return!1;let e=da(r,bs);return e&&e.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:ys.of(!1)}),!0},fg=[{key:"Mod-f",run:Ch,scope:"editor search-panel"},{key:"F3",run:bn,shift:xn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:bn,shift:xn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Oh,scope:"editor search-panel"},{key:"Mod-Shift-l",run:hg},{key:"Mod-Alt-g",run:qp},{key:"Mod-d",run:Qp,preventDefault:!0}];class ug{constructor(t){this.view=t;let e=this.query=t.state.field(ne).query.spec;this.commit=this.commit.bind(this),this.searchField=Z("input",{value:e.search,placeholder:pt(t,"Find"),"aria-label":pt(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Z("input",{value:e.replace,placeholder:pt(t,"Replace"),"aria-label":pt(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Z("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Z("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Z("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit});function i(n,s,o){return Z("button",{class:"cm-button",name:n,onclick:s,type:"button"},o)}this.dom=Z("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>bn(t),[pt(t,"next")]),i("prev",()=>xn(t),[pt(t,"previous")]),i("select",()=>ag(t),[pt(t,"all")]),Z("label",null,[this.caseField,pt(t,"match case")]),Z("label",null,[this.reField,pt(t,"regexp")]),Z("label",null,[this.wordField,pt(t,"by word")]),...t.state.readOnly?[]:[Z("br"),this.replaceField,i("replace",()=>_o(t),[pt(t,"replace")]),i("replaceAll",()=>cg(t),[pt(t,"replace all")])],Z("button",{name:"close",onclick:()=>Oh(t),"aria-label":pt(t,"close"),type:"button"},["×"])])}commit(){let t=new kh({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:wi.of(t)}))}keydown(t){Uf(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?xn:bn)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),_o(this.view))}update(t){for(let e of t.transactions)for(let i of e.effects)i.is(wi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Je).top}}function pt(r,t){return r.state.phrase(t)}const ji=30,Ki=/[\s\.,:;?!]/;function xs(r,{from:t,to:e}){let i=r.state.doc.lineAt(t),n=r.state.doc.lineAt(e).to,s=Math.max(i.from,t-ji),o=Math.min(n,e+ji),l=r.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<ji;a++)if(!Ki.test(l[a+1])&&Ki.test(l[a])){l=l.slice(a);break}}if(o!=n){for(let a=l.length-1;a>l.length-ji;a--)if(!Ki.test(l[a-1])&&Ki.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${r.state.phrase("current match")}. ${l} ${r.state.phrase("on line")} ${i.number}.`)}const dg=D.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"}}),pg=[ne,kn.low(lg),dg],gg={class:"vuefinder__codemirror-wrapper"},mg=["title","aria-label","aria-pressed"],Yo="vuefinder:codemirror-wrap",wg=Dh({name:"CodeMirrorEditor",__name:"CodeMirrorEditor",props:{modelValue:{},readonly:{type:Boolean},filename:{}},emits:["update:modelValue"],setup(r,{emit:t}){const e=r,i=t,n=Th(),{t:s}=n.i18n,o=()=>{if(typeof window>"u")return!0;try{const T=window.localStorage.getItem(Yo);return T===null?!0:T==="1"}catch{return!0}},l=T=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Yo,T?"1":"0")}catch{}},a=As(null),h=As(o());let c=null;const f=new ve,u=new ve,d=new ve,p=new Map;function g(T){const S=T.split("/").pop()??"",A=S.lastIndexOf(".");return A>=0?S.slice(A+1).toLowerCase():""}async function m(T){const S=p.get(T);if(S)return S;let A=[];switch(T){case"json":case"jsonc":case"lock":{const{json:x}=await Rt(async()=>{const{json:E}=await import("./index-D76eWsZ1-7KvuCuMg.js");return{json:E}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url);A=x();break}case"js":case"mjs":case"cjs":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-C2L4ZR6a.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x();break}case"jsx":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-C2L4ZR6a.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x({jsx:!0});break}case"ts":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-C2L4ZR6a.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x({typescript:!0});break}case"tsx":{const{javascript:x}=await Rt(()=>import("./index-T76vWLBU-C2L4ZR6a.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(E=>E.i);A=x({typescript:!0,jsx:!0});break}case"vue":case"svelte":case"html":case"htm":{const{html:x}=await Rt(async()=>{const{html:E}=await import("./index-Dms7ZQ2h-BXeasSDQ.js");return{html:E}},__vite__mapDeps([7,1,8,2,3,4,5,6]),import.meta.url);A=x();break}case"css":case"scss":case"sass":case"less":{const{css:x}=await Rt(async()=>{const{css:E}=await import("./index-fZBcgzqR-DZ4VEjtI.js");return{css:E}},__vite__mapDeps([8,1,2,3,4,5]),import.meta.url);A=x();break}case"md":case"markdown":{const{markdown:x}=await Rt(async()=>{const{markdown:E}=await import("./index-72rReQ2I-BUkUG78x.js");return{markdown:E}},__vite__mapDeps([9,6,1,2,3,4,5,7,8]),import.meta.url);A=x();break}case"yml":case"yaml":{const{yaml:x}=await Rt(async()=>{const{yaml:E}=await import("./index-mqeGrL6B-zaO8HgOa.js");return{yaml:E}},__vite__mapDeps([10,1,2,3,4,5]),import.meta.url);A=x();break}case"xml":case"svg":{const{xml:x}=await Rt(async()=>{const{xml:E}=await import("./index-DxypSQ0K-DsBZbAQO.js");return{xml:E}},__vite__mapDeps([11,1,2,3,4,5]),import.meta.url);A=x();break}default:A=[]}return p.set(T,A),A}function w(){return[ou(),hu(),Id(),ld(),Ju(),bd(),Kp(),cd(dd),ca.of([...Hp,...$d,...nd,...fg,Vp]),D.updateListener.of(T=>{if(!T.docChanged)return;const S=T.state.doc.toString();S!==e.modelValue&&i("update:modelValue",S)})]}const y=T=>T?D.lineWrapping:[],C=()=>{h.value=!h.value,l(h.value),c?.dispatch({effects:d.reconfigure(y(h.value))})};return Eh(async()=>{if(!a.value)return;const T=e.filename?await m(g(e.filename)):[],S=I.create({doc:e.modelValue??"",extensions:[...w(),f.of(I.readOnly.of(!!e.readonly)),u.of(T),d.of(y(h.value))]});c=new D({state:S,parent:a.value})}),In(()=>e.readonly,T=>{c?.dispatch({effects:f.reconfigure(I.readOnly.of(!!T))})}),In(()=>e.filename,async T=>{if(!c)return;const S=T?g(T):"",A=S?await m(S):[];c.dispatch({effects:u.reconfigure(A)})}),In(()=>e.modelValue,T=>{if(!c)return;const S=c.state.doc.toString();T!==S&&c.dispatch({changes:{from:0,to:S.length,insert:T??""}})}),Bh(()=>{c?.destroy(),c=null}),(T,S)=>(Lh(),Rh("div",gg,[Ms("button",{type:"button",class:Cs(["vuefinder__codemirror-wrap-toggle",{"vuefinder__codemirror-wrap-toggle--active":h.value}]),title:h.value?Wn(s)("Word wrap on — click to disable"):Wn(s)("Word wrap off — click to enable"),"aria-label":Wn(s)("Toggle word wrap"),"aria-pressed":h.value,onClick:C},[...S[0]||(S[0]=[Ph('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"></path><path d="M3 12h13a4 4 0 010 8h-3"></path><polyline points="16,16 13,20 16,24"></polyline><path d="M3 18h6"></path></svg>',1)])],10,mg),Ms("div",{ref_key:"container",ref:a,class:Cs(["vuefinder__codemirror-editor",{"vuefinder__codemirror-editor--readonly":r.readonly}])},null,2)]))}}),Tg=Object.freeze(Object.defineProperty({__proto__:null,default:wg},Symbol.toStringTag,{value:"Module"}));export{he as A,ca as B,Tg as C,P as D,v as E,O as F,Be as G,kg as H,F as I,Du as J,Nu as K,qr as L,mt as M,L as N,vt as O,un as P,k as Q,ye as R,H as S,bt as T,$e as W,cu as a,I as b,D as c,Ot as d,Ca as e,Sg as f,ya as g,dt as h,xg as i,wu as j,kn as k,Dt as l,W as m,Q as n,Y as o,xd as p,Cg as q,Sn as r,Pu as s,Ag as t,Mg as u,Og as v,_u as w,Gu as x,Vu as y,us as z};
|