@standardagents/builder 0.45.8 → 0.45.9
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 +1 -0
- package/dist/built-in-routes.js +1 -1
- package/dist/client/{ApiKeysView-BcqUvH1N.js → ApiKeysView-BwDYd2nU.js} +1 -1
- package/dist/client/{CodeEditor-C9bQ4Z3b.js → CodeEditor-xwWkV1-c.js} +3 -3
- package/dist/client/CompositionView-D1bxg5aS.js +72 -0
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-DX9-shOV.js → CopyButton.vue_vue_type_script_setup_true_lang-CLj4kYi5.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-B85c2lO4.js → DataTable.vue_vue_type_script_setup_true_lang-CkugFRtR.js} +1 -1
- package/dist/client/{DefinitionSource-Bpge2u90.js → DefinitionSource-BbqSJUnU.js} +3 -3
- package/dist/client/{DefinitionUsedBy.vue_vue_type_script_setup_true_lang-BVz1zKTE.js → DefinitionUsedBy.vue_vue_type_script_setup_true_lang-BMGuiEk7.js} +1 -1
- package/dist/client/{LoginView-rym24zTR.js → LoginView-0OVTMU2S.js} +1 -1
- package/dist/client/{MarketplaceView-iAUImVOg.js → MarketplaceView-BuQxQaUp.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-DOTIR3w5.js → Modal.vue_vue_type_script_setup_true_lang-UlrwSOT8.js} +1 -1
- package/dist/client/{ModelsView-D-GX47Hw.js → ModelsView-B9nRyP5Y.js} +1 -1
- package/dist/client/{PromptView-C_KoH5Mj.js → PromptView-3MXx3DhS.js} +1 -1
- package/dist/client/{PromptsView-CDiHQ75x.js → PromptsView-CaS5lNVN.js} +1 -1
- package/dist/client/{ProvidersView-COIzWC9J.js → ProvidersView-jwLDm5PC.js} +1 -1
- package/dist/client/{ToolsView-DgQIHbKB.js → ToolsView-DfaKB3DJ.js} +1 -1
- package/dist/client/{UiButton.vue_vue_type_script_setup_true_lang-BezveAaR.js → UiButton.vue_vue_type_script_setup_true_lang-CVyrFcWg.js} +1 -1
- package/dist/client/{UiEmptyState.vue_vue_type_script_setup_true_lang-n9hcWKvI.js → UiEmptyState.vue_vue_type_script_setup_true_lang-BD_dt9VV.js} +1 -1
- package/dist/client/{UiFilterMenu.vue_vue_type_script_setup_true_lang-CcYZv4bj.js → UiFilterMenu.vue_vue_type_script_setup_true_lang-BE1kHACC.js} +1 -1
- package/dist/client/{UiPageFrame-CeuT1rer.js → UiPageFrame-CP9KRIIM.js} +1 -1
- package/dist/client/{UsersView-C0283pU_.js → UsersView-SCr3Ls5P.js} +1 -1
- package/dist/client/{VariablesView-DljSo_RS.js → VariablesView-DGyxj9Ow.js} +1 -1
- package/dist/client/assets/{index-BBzCGX26.css → index-D0bcj_gk.css} +1 -1
- package/dist/client/{form-errors-cxIParHK.js → form-errors-D9RXsjd2.js} +1 -1
- package/dist/client/{index-CgCqkjVa.js → index-BkfWiMo-.js} +1 -1
- package/dist/client/index-BwlCQIem.js +5 -0
- package/dist/client/{index-er6dD-sT.js → index-C4-LP0pJ.js} +1 -1
- package/dist/client/{index-BEnYvzGi.js → index-CDCQWHe2.js} +1 -1
- package/dist/client/{index-CzsbmDuv.js → index-ChLk4ONU.js} +1 -1
- package/dist/client/{index-BFKj1V0c.js → index-CmfTs1yz.js} +1 -1
- package/dist/client/{index-C7gIQnkU.js → index-CwBC9sTn.js} +1 -1
- package/dist/client/{index-Dj5tjGFV.js → index-D4_R8FnR.js} +1 -1
- package/dist/client/{index-DfVgpfCm.js → index-DcCqDioc.js} +1 -1
- package/dist/client/{index-BcQ5zdWM.js → index-b4VUAUvJ.js} +1 -1
- package/dist/client/{index-DvSYq8lz.js → index-jI_N1y04.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/{schemaArguments-B2ppewpv.js → schemaArguments-DnkXBmpq.js} +1 -1
- package/dist/client/{toolReference-B96xiDXn.js → toolReference-Dnhl8D6k.js} +1 -1
- package/dist/client/{useDefinitionUsage-BxmZT4nk.js → useDefinitionUsage-CkISuMRg.js} +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +10 -0
- package/dist/plugin.js +20 -0
- package/dist/plugin.js.map +1 -1
- package/package.json +7 -6
- package/dist/client/CompositionView-GlnAWxhl.js +0 -72
- package/dist/client/index-DnlG7hIl.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["index-
|
|
2
|
-
import{f as fc,S as ut,k as uc,g as dc,h as pc,i as ee}from"./vendor-L6I0G397.js";import{u as gc}from"./Modal.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["index-b4VUAUvJ.js","index-CDCQWHe2.js","vendor-L6I0G397.js","Modal.vue_vue_type_script_setup_true_lang-UlrwSOT8.js","vue-CnrejLtC.js","formkit-B1fIUqP-.js","syntax-XeetdF8c.js","index-BwlCQIem.js","assets/index-D0bcj_gk.css","UiFilterMenu.vue_vue_type_script_setup_true_lang-BE1kHACC.js","UiButton.vue_vue_type_script_setup_true_lang-CVyrFcWg.js","index-jI_N1y04.js","index-CwBC9sTn.js","index-C4-LP0pJ.js","index-DcCqDioc.js","index-D4_R8FnR.js","index-CmfTs1yz.js","index-ChLk4ONU.js","index-BkfWiMo-.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as fc,S as ut,k as uc,g as dc,h as pc,i as ee}from"./vendor-L6I0G397.js";import{u as gc}from"./Modal.vue_vue_type_script_setup_true_lang-UlrwSOT8.js";import{bf as Ee,e as mc,_ as yc}from"./index-BwlCQIem.js";import{d as bc,r as _r,c as jr,o as xc,w as Xn,a as wc,b as Ur,e as Gr,f as Jr,q as kc,h as Sc,n as vc,z as Cc,A as Ac}from"./vue-CnrejLtC.js";class W{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Ut(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),$e.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ut(this,e,t);let i=[];return this.decompose(e,t,i,0),$e.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new gi(this),r=new gi(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new gi(this,e)}iterRange(e,t=this.length){return new kl(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Sl(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?W.empty:e.length<=32?new X(e):$e.from(X.split(e,[]))}}class X extends W{constructor(e,t=Mc(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new Dc(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new X(Yr(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=cn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new X(l,o.length+r.length));else{let a=l.length>>1;i.push(new X(l.slice(0,a)),new X(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof X))return super.replace(e,t,i);[e,t]=Ut(this,e,t);let n=cn(this.text,cn(i.text,Yr(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new X(n,r):$e.from(X.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=Ut(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new X(i,n)),i=[],n=-1);return n>-1&&t.push(new X(i,n)),t}}class $e extends W{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=Ut(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,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 $e(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
4
4
|
`){[e,t]=Ut(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof $e))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new X(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof $e)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof X&&a&&(p=c[c.length-1])instanceof X&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new X(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]:$e.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new $e(l,t)}}W.empty=new X([""],0);function Mc(s){let e=-1;for(let t of s)e+=t.length+1;return e}function cn(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=t&&(a>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function Yr(s,e,t){return cn(s,[""],e,t)}class gi{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof X?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof X?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
5
5
|
`,this;e--}else if(n instanceof X){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof X?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class kl{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new gi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Sl{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(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()},gi.prototype[Symbol.iterator]=kl.prototype[Symbol.iterator]=Sl.prototype[Symbol.iterator]=function(){return this});class Dc{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Ut(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function te(s,e,t=!0,i=!0){return fc(s,e,t,i)}function Oc(s){return s>=56320&&s<57344}function Tc(s){return s>=55296&&s<56320}function Et(s,e){let t=s.charCodeAt(e);if(!Tc(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Oc(i)?(t-55296<<10)+(i-56320)+65536:t}function vl(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function Ii(s){return s<65536?1:2}const ws=/\r\n?|\n/;var he=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(he||(he={}));class Xe{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){ks(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new Xe(e)}composeDesc(e){return this.empty?e:e.empty?this:Cl(this,e)}mapDesc(e,t=!1){return e.empty?this:Ss(this,e,t)}mapPos(e,t=-1,i=he.Simple){let n=0,r=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>e)return r+(e-n);r+=l}else{if(i!=he.Simple&&h>=e&&(i==he.TrackDel&&n<e&&h>e||i==he.TrackBefore&&n<e||i==he.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Xe(e)}static create(e){return new Xe(e)}}class Z extends Xe{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ks(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return Ss(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(W.empty);i.push(o?e.slice(r,r+o):W.empty)}r+=o}return new Z(t,i)}compose(e){return this.empty?e:e.empty?this:Cl(this,e,!0)}map(e,t=!1){return e.empty?this:Ss(this,e,t,!0)}iterChanges(e,t=!1){ks(this,e,t)}get desc(){return Xe.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new Si(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);ae(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;ae(t,c,f),f>0&&ht(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);ae(t,c,-1),ae(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new Z(t,i),filtered:Xe.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<t&&ae(n,t-o,-1);let f=new Z(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof Z){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);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>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?W.of(d.split(i||ws)):d:W.empty,g=p.length;if(f==u&&g==0)return;f<o&&a(),f>o&&ae(n,f-o,-1),ae(n,u-f,g),ht(r,n,p),o=u}}return h(e),a(!l),l}static empty(e){return new Z(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(W.empty);i[n]=W.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new Z(t,i)}static createSet(e,t){return new Z(e,t)}}function ae(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function ht(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(W.empty);s.push(t)}}function ks(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=W.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,c,f),n=h,r=c}}}function Ss(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Si(s),l=new Si(e);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);ae(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&&!t))){let h=l.len;for(ae(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ae(n,0,o.ins),r&&ht(r,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;ae(n,h,a<o.i?o.ins:0),r&&a<o.i&&ht(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?Z.createSet(n,r):Xe.create(n);throw new Error("Mismatched change set lengths")}}}function Cl(s,e,t=!1){let i=[],n=t?[]:null,r=new Si(s),o=new Si(e);for(let l=!1;;){if(r.done&&o.done)return n?Z.createSet(i,n):Xe.create(i);if(r.ins==0)ae(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)ae(i,0,o.ins,l),n&&ht(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ae(i,a,c,l),n&&c&&ht(n,i,o.text)}else o.ins==-1?(ae(i,r.off?0:r.len,a,l),n&&ht(n,i,r.textBit(a))):(ae(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&ht(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Si{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?W.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?W.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class lt{constructor(e,t,i,n){this.from=e,this.to=t,this.flags=i,this.goalColumn=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new lt(i,n,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i,n){return new lt(e,t,i,n)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>lt.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,n){return lt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(e,t,i,n,r){let o=n==null?7:Math.min(6,n);return!r&&e!=t&&(r=t<e?1:-1),r&&(o|=r<0?8:16),t<e?lt.create(t,e,o|32,i):lt.create(e,t,o,i)}static undirectionalRange(e,t){return lt.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function Al(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let hr=0;class D{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=hr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new D(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:cr),!!e.static,e.enables)}of(e){return new fn([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fn(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fn(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function cr(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class fn{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=hr++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||vs(f,c)){let d=i(f);if(l?!Xr(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[r];if(p!=null){let g=yn(u,p);if(this.dependencies.every(m=>m instanceof D?u.facet(m)===f.facet(m):m instanceof ve?u.field(m,!1)==f.field(m,!1):!0)||(l?Xr(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}}}get extension(){return this}}function Xr(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function vs(s,e){let t=!1;for(let i of e)mi(s,i)&1&&(t=!0);return t}function Bc(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=yn(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)mi(a,h);return a.values[o]=l(a),1},update(a,h){if(!vs(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=vs(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&cr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const $i=D.define({static:!0});class ve{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new ve(hr++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet($i).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet($i),o=n.facet($i),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,$i.of({field:this,create:e})]}get extension(){return this}}const St={lowest:4,low:3,default:2,high:1,highest:0};function ai(s){return e=>new Ml(e,s)}const ni={highest:ai(St.highest),high:ai(St.high),default:ai(St.default),low:ai(St.low),lowest:ai(St.lowest)};class Ml{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Mt{of(e){return new Cs(this,e)}reconfigure(e){return Mt.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Cs{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class mn{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of Lc(e,t,o))u instanceof ve?n.push(u):(r[u.facet.id]||(r[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 r){let d=r[u],p=d[0].facet,g=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,cr(g,d))a.push(i.facet(p));else{let m=p.combine(d.map(y=>y.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(y=>m.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(m=>Bc(m,p,d))}}let f=h.map(u=>u(l));return new mn(e,o,f,l,a,r)}}function Lc(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(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 Cs&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Cs){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Ml)r(o.inner,o.prec);else if(o instanceof ve)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof fn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,St.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,St.default),i.reduce((o,l)=>o.concat(l))}function mi(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function yn(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const Dl=D.define(),As=D.define({combine:s=>s.some(e=>e),static:!0}),Ol=D.define({combine:s=>s.length?s[0]:void 0,static:!0}),Tl=D.define(),Bl=D.define(),Ll=D.define(),El=D.define({combine:s=>s.length?s[0]:!1});class st{constructor(e,t){this.type=e,this.value=t}static define(){return new Ec}}class Ec{of(e){return new st(this,e)}}class Pc{constructor(e){this.map=e}of(e){return new F(this,e)}}class F{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new F(this.type,t)}is(e){return this.type==e}static define(e={}){return new Pc(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}F.reconfigure=F.define();F.appendConfig=F.define();class Q{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Al(i,t.newLength),r.some(l=>l.type==Q.time)||(this.annotations=r.concat(Q.time.of(Date.now())))}static create(e,t,i,n,r,o){return new Q(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Q.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Q.time=st.define();Q.userEvent=st.define();Q.addToHistory=st.define();Q.remote=st.define();function Rc(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Pl(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=Z.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:F.mapEffects(s.effects,n).concat(F.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function Ms(s,e,t){let i=e.selection,n=zt(e.annotations);return e.userEvent&&(n=n.concat(Q.userEvent.of(e.userEvent))),{changes:e.changes instanceof Z?e.changes:Z.of(e.changes||[],t,s.facet(Ol)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:zt(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Rl(s,e,t){let i=Ms(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Pl(i,Ms(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=Q.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Nc(t?Ic(n):n)}function Ic(s){let e=s.startState,t=!0;for(let n of e.facet(Tl)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Rc(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=Z.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=Q.create(e,n,s.selection&&s.selection.map(r),F.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(Bl);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof Q?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Q?s=r[0]:s=Rl(e,zt(r),!1)}return s}function Nc(s){let e=s.startState,t=e.facet(Ll),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=Pl(i,Ms(e,r,s.changes.newLength),!0))}return i==s?s:Q.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const Wc=[];function zt(s){return s==null?Wc:Array.isArray(s)?s:[s]}var J=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(J||(J={}));const Fc=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ds;try{Ds=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Hc(s){if(Ds)return Ds.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Fc.test(t)))return!0}return!1}function Vc(s){return e=>{if(!/\S/.test(e))return J.Space;if(Hc(e))return J.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return J.Word;return J.Other}}class N{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)mi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return mi(this,i),yn(this,i)}update(...e){return Rl(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(Mt.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(F.reconfigure)?(t=null,i=l.value):l.is(F.appendConfig)&&(t=null,i=zt(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=mn.resolve(i,n,this),r=new N(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(As)?e.newSelection:e.newSelection.asSingle();new N(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=zt(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=F.mapEffects(o,c).concat(F.mapEffects(zt(a.effects),f))}return{changes:n,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Z?e:Z.of(e,this.doc.length,this.facet(N.lineSeparator))}toText(e){return W.of(e.split(this.facet(N.lineSeparator)||ws))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(mi(this,t),yn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof ve&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return N.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=mn.resolve(e.extensions||[],new Map),i=e.doc instanceof W?e.doc:W.of((e.doc||"").split(t.staticFacet(N.lineSeparator)||ws)),n=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return Al(n,i.length),t.staticFacet(As)||(n=n.asSingle()),new N(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(N.tabSize)}get lineBreak(){return this.facet(N.lineSeparator)||`
|
|
@@ -9,4 +9,4 @@ import{f as fc,S as ut,k as uc,g as dc,h as pc,i as ee}from"./vendor-L6I0G397.js
|
|
|
9
9
|
`))};if((S.mac||S.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:W.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);wr(e,f,b.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.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(L.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:la.of(L.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=Ai(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let c=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,t+=c,this.to+=c;return}else n=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class M{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(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Jc(e.parent)||document,this.viewState=new Co(this,e.state||N.create(e)),e.scrollTo&&e.scrollTo.is(Ui)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ht).map(n=>new es(n));for(let n of this.plugins)n.update(this);this.observer=new wu(this),this.inputState=new qf(this),this.inputState.ensureHandlers(this.plugins),this.docView=new co(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Q?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Aa))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ma(r,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(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(N.phrases)!=this.state.facet(N.phrases))return this.setState(r);n=wn.create(this,r,e),n.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:g}=this.state.facet(M.cursorScrollMargin);f=new $t(d.empty?d:b.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of u.effects)d.is(Ui)&&(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)),t=this.docView.update(n),this.state.facet(di)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Zi)!=n.state.facet(Zi)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(Hs))try{u(n)}catch(d){Ue(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!ba(this,c)&&h.force&&Kt(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Co(this,e),this.plugins=e.facet(Ht).map(i=>new es(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new co(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ht),i=e.state.facet(Ht);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new es(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){Ue(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if($l(i||this.win))r=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(n);r=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];h&4||([this.measureRequests,c]=[c,this.measureRequests]);let f=c.map(p=>{try{return p.read(this)}catch(g){return Ue(this.state,g),Oo}}),u=wn.create(this,this.state,[]),d=!1;u.flags|=h,t?t.flags|=h:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(f[p]!=Oo)try{let g=c[p];g.write&&g.write(f[p],this)}catch(g){Ue(this.state,g)}if(d&&this.docView.updateSelection(!0),!u.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 g=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)/this.viewState.scaleY-o/l;if((g>1||g<-1)&&!(S.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+g,i?r<0?i.scrollTop=i.scrollHeight:i.scrollTop+=g:this.win.scrollBy(0,g),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Hs))a(t)}get themeClasses(){return Us+" "+(this.state.facet(js)?Ba:Ta)+" "+this.state.facet(Zi)}updateAttrs(){let e=To(this,aa,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(et)?"true":"false",class:"cm-content",style:`${S.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),To(this,br,t);let i=this.observer.ignore(()=>{let n=so(this.contentDOM,this.contentAttrs,t),r=so(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(M.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(di);let e=this.state.facet(M.cspNonce);ut.mount(this.root,this.styleModules.concat(bu).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return ss(this,e,fo(this,e,t,i))}moveByGroup(e,t){return ss(this,e,fo(this,e,t,i=>Ef(this,e.head,i)))}visualLineSide(e,t){return t?b.cursor(e.to,1):b.cursor(e.from,-1)}moveToLineBoundary(e,t,i=!0){return Lf(this,e,t,i)}moveVertically(e,t,i){return ss(this,e,Pf(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=qs(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),qs(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),n=this.bidiSpans(i),r=n[je.find(n,e-i.from,-1,t)];return i.length&&(e==i.from&&t<0||e==i.to&&t>0)&&r.dir!=this.textDirectionAt(i.from)&&(e==i.to?(e=i.from+r.from,t=1):(e=i.from+r.to,t=-1)),this.docView.coordsAt(e,t,r.dir==G.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sa)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>vu)return Yl(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Jl(r.isolates,i=lo(this,e))))return r.order;i||(i=lo(this,e));let n=sf(e.text,t,i);return this.bidiCache.push(new An(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||S.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Kl(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,n,r,o;return Ui.of(new $t(typeof e=="number"?b.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(n=t.x)!==null&&n!==void 0?n:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Ui.of(new $t(b.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return fe.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return fe.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ut.newName(),n=[Zi.of(i),di.of(Gs(`.${i}`,e))];return t&&t.dark&&n.push(js.of(!0)),n}static baseTheme(e){return ni.lowest(di.of(Gs("."+Us,e,La)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&Y.get(i)||Y.get(e);return((t=n?.root)===null||t===void 0?void 0:t.view)||null}}M.styleModule=di;M.inputHandler=ia;M.clipboardInputFilter=mr;M.clipboardOutputFilter=yr;M.scrollHandler=oa;M.focusChangeEffect=na;M.perLineTextDirection=sa;M.exceptionSink=ta;M.updateListener=Hs;M.editable=et;M.mouseSelectionStyle=ea;M.dragMovesSelection=Zl;M.clickAddsSelectionRange=Ql;M.decorations=Hn;M.blockWrappers=ha;M.outerDecorations=xr;M.atomicRanges=Fi;M.bidiIsolatedRanges=ca;M.cursorScrollMargin=D.define({combine:s=>{let e=5,t=5;for(let i of s)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});M.scrollMargins=ua;M.darkTheme=js;M.cspNonce=D.define({combine:s=>s.length?s[0]:""});M.contentAttributes=br;M.editorAttributes=aa;M.lineWrapping=M.contentAttributes.of({class:"cm-lineWrapping"});M.announce=F.define();const vu=4096,Oo={};class An{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:G.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==n&&!t.touchesRange(o.from,o.to)&&i.push(new An(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function To(s,e,t){for(let i=s.state.facet(e),n=i.length-1;n>=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&dr(o,t)}return t}const Cu=S.mac?"mac":S.windows?"win":S.linux?"linux":"key";function Au(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let a=0;a<t.length-1;++a){const h=t[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))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function en(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const Mu=ni.default(M.domEventHandlers({keydown(s,e){return Pa(Ea(e.state),s,e,"editor")}})),Sr=D.define({enables:Mu}),Bo=new WeakMap;function Ea(s){let e=s.facet(Sr),t=Bo.get(e);return t||Bo.set(e,t=Tu(e.reduce((i,n)=>i.concat(n),[]))),t}function Du(s,e,t){return Pa(Ea(s.state),e,s,t)}let at=null;const Ou=4e3;function Tu(s,e=Cu){let t=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")},r=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>Au(y,e));for(let y=1;y<p.length;y++){let A=p.slice(0,y).join(" ");n(A,!0),d[A]||(d[A]={preventDefault:!0,stopPropagation:!1,run:[w=>{let O=at={view:w,prefix:A,scope:o};return setTimeout(()=>{at==O&&(at=null)},Ou),!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 s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[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,Js))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Js=null;function Pa(s,e,t,i){Js=e;let n=uc(e),r=Et(n,0),o=Ii(r)==n.length&&n!=" ",l="",a=!1,h=!1,c=!1;at&&at.view==t&&at.scope==i&&(l=at.prefix+" ",ka.indexOf(e.keyCode)<0&&(h=!0,at=null));let f=new Set,u=m=>{if(m){for(let y of m.run)if(!f.has(y)&&(f.add(y),y(t)))return m.stopPropagation&&(c=!0),!0;m.preventDefault&&(m.stopPropagation&&(c=!0),h=!0)}return!1},d=s[i],p,g;return d&&(u(d[l+en(n,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(S.windows&&e.ctrlKey&&e.altKey)&&!(S.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=dc[e.keyCode])&&p!=n?(u(d[l+en(p,e,!0)])||e.shiftKey&&(g=pc[e.keyCode])!=n&&g!=p&&u(d[l+en(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+en(n,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),Js=null,a}class Dt{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=Ra(e);return[new Dt(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}else return Bu(e,t,i)}}function Ra(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==G.LTR?e.left:e.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:e.top-s.scrollDOM.scrollTop*s.scaleY}}function Lo(s,e,t,i){let n=s.coordsAtPos(e,t*2);if(!n)return i;let r=s.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,l=s.posAtCoords({x:r.left+1,y:o}),a=s.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Bu(s,e,t){if(t.to<=s.viewport.from||t.from>=s.viewport.to)return[];let i=Math.max(t.from,s.viewport.from),n=Math.min(t.to,s.viewport.to),r=s.textDirection==G.LTR,o=s.contentDOM,l=o.getBoundingClientRect(),a=Ra(s),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=zs(s,i,1),p=zs(s,n,-1),g=d.type==re.Text?d:null,m=p.type==re.Text?p:null;if(g&&(s.lineWrapping||d.widgetLineBreaks)&&(g=Lo(s,i,1,g)),m&&(s.lineWrapping||p.widgetLineBreaks)&&(m=Lo(s,n,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return A(w(t.from,t.to,g));{let x=g?w(t.from,null,g):O(d,!1),v=m?w(null,t.to,m):O(p,!0),C=[];return(g||d).to<(m||p).from-(g&&m?1:0)||d.widgetLineBreaks>1&&x.bottom+s.defaultLineHeight/2<v.top?C.push(y(f,x.bottom,u,v.top)):x.bottom<v.top&&s.elementAtHeight((x.bottom+v.top)/2).type==re.Text&&(x.bottom=v.top=(x.bottom+v.top)/2),A(x).concat(C).concat(A(v))}function y(x,v,C,H){return new Dt(e,x-a.left,v-a.top,Math.max(0,C-x),H-v)}function A({top:x,bottom:v,horizontal:C}){let H=[];for(let R=0;R<C.length;R+=2)H.push(y(C[R],x,C[R+1],v));return H}function w(x,v,C){let H=1e9,R=-1e9,K=[];function P(V,U,le,we,Fe){let ne=s.coordsAtPos(V,V==C.to?-2:2),Ce=s.coordsAtPos(le,le==C.from?2:-2);!ne||!Ce||(H=Math.min(ne.top,Ce.top,H),R=Math.max(ne.bottom,Ce.bottom,R),Fe==G.LTR?K.push(r&&U?f:ne.left,r&&we?u:Ce.right):K.push(!r&&we?f:Ce.left,!r&&U?u:ne.right))}let B=x??C.from,q=v??C.to;for(let V of s.visibleRanges)if(V.to>B&&V.from<q)for(let U=Math.max(V.from,B),le=Math.min(V.to,q);;){let we=s.state.doc.lineAt(U);for(let Fe of s.bidiSpans(we)){let ne=Fe.from+we.from,Ce=Fe.to+we.from;if(ne>=le)break;Ce>U&&P(Math.max(ne,U),x==null&&ne<=B,Math.min(Ce,le),v==null&&Ce>=q,Fe.dir)}if(U=we.to+1,U>=le)break}return K.length==0&&P(B,x==null,q,v==null,s.textDirection),{top:H,bottom:R,horizontal:K}}function O(x,v){let C=l.top+(v?x.top:x.bottom);return{top:C,bottom:C,horizontal:[]}}}function Lu(s,e){return s.constructor==e.constructor&&s.eq(e)}class Eu{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(dn)!=e.state.facet(dn)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(dn);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Lu(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e,S.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const dn=D.define();function Ia(s){return[fe.define(e=>new Eu(e,s)),dn.of(s)]}const Ys=!S.ios,Zt=D.define({combine(s){return Pt(s,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Pu(s={}){return[Zt.of(s),Ru,Iu,Wu,ra.of(!0)]}function Na(s){return s.startState.facet(Zt)!=s.state.facet(Zt)}const Ru=Ia({above:!0,markers(s){let{state:e}=s,t=e.facet(Zt),i=[];for(let n of e.selection.ranges){let r=n==e.selection.main;if(n.empty||t.drawRangeCursor&&!(r&&S.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:b.cursor(n.head,n.assoc);for(let a of Dt.forRange(s,o,l))i.push(a)}}return i},update(s,e){s.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Na(s);return t&&Eo(s.state,e),s.docChanged||s.selectionSet||t},mount(s,e){Eo(e.state,s)},class:"cm-cursorLayer"});function Eo(s,e){e.style.animationDuration=s.facet(Zt).cursorBlinkRate+"ms"}const Iu=Ia({above:!1,markers(s){let e=[],{main:t,ranges:i}=s.state.selection;for(let n of i)if(!n.empty&&(Ys||n!=t))for(let r of Dt.forRange(s,"cm-selectionBackground",n))e.push(r);if(S.ios&&!t.empty&&s.state.facet(Zt).iosSelectionHandles){for(let n of Dt.forRange(s,"cm-selectionHandle cm-selectionHandle-start",b.cursor(t.from,1)))e.push(n);for(let n of Dt.forRange(s,"cm-selectionHandle cm-selectionHandle-end",b.cursor(t.to,1)))e.push(n)}return e},update(s,e){return s.docChanged||s.selectionSet||s.viewportChanged||Na(s)},class:"cm-selectionLayer"}),Nu=S.gecko&&S.gecko_version==153?"#ffffff01":"transparent",Wu=ni.highest(M.theme({".cm-line":{...Ys?{"& ::selection, &::selection":{backgroundColor:`${Nu} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...Ys?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}}));function Fu(){return Vu}const Hu=L.line({class:"cm-activeLine"}),Vu=fe.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.docChanged||s.selectionSet)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=-1,t=[];for(let i of s.state.selection.ranges){let n=s.lineBlockAt(i.head);n.from>e&&(t.push(Hu.range(n.from)),e=n.from)}return L.set(t)}},{decorations:s=>s.decorations});class zu extends bt{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?bi(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),n=Mi(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return n.bottom-n.top>r*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+r}:n}ignoreEvent(){return!1}}function qu(s){let e=fe.fromClass(class{constructor(t){this.view=t,this.placeholder=s?L.set([L.widget({widget:new zu(s),side:1}).range(0)]):L.none}get decorations(){return this.view.state.doc.length?L.none:this.placeholder}},{decorations:t=>t.decorations});return typeof s=="string"?[e,M.contentAttributes.of({"aria-placeholder":s})]:e}const Po=D.define({combine(s){let e,t;for(let i of s)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function vr(s,e){let t=s.plugin(Wa),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Wa=fe.fromClass(class{constructor(s){this.input=s.state.facet(Mn),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(s));let e=s.state.facet(Po);this.top=new tn(s,!0,e.topContainer),this.bottom=new tn(s,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(s){let e=s.state.facet(Po);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new tn(s.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new tn(s.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=s.state.facet(Mn);if(t!=this.input){let i=t.filter(a=>a),n=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(s.view),l.push(c)):(c=this.panels[h],c.update&&c.update(s)),n.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=n,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>M.scrollMargins.of(e=>{let t=e.plugin(s);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class tn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Ro(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Ro(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Ro(s){let e=s.nextSibling;return s.remove(),e}const Mn=D.define({enables:Wa});function Ku(s,e){let t,i=new Promise(o=>t=o),n=o=>_u(o,e,t);s.state.field(pn,!1)?s.dispatch({effects:Fa.of(n)}):s.dispatch({effects:F.appendConfig.of(pn.init(()=>[n]))});let r=Ha.of(n);return{close:r,result:i.then(o=>((s.win.queueMicrotask||(a=>s.win.setTimeout(a,10)))(()=>{s.state.field(pn).indexOf(n)>-1&&s.dispatch({effects:r})}),o))}}function $u(s,e){let t=s.state.field(pn,!1)||[];for(let i of t){let n=vr(s,i);if(n&&n.dom.classList.contains(e))return n}return null}const pn=ve.define({create(){return[]},update(s,e){for(let t of e.effects)t.is(Fa)?s=[t.value].concat(s):t.is(Ha)&&(s=s.filter(i=>i!=t.value));return s},provide:s=>Mn.computeN([s],e=>e.field(s))}),Fa=F.define(),Ha=F.define();function _u(s,e,t){let i=e.content?e.content(s,()=>l(null)):null;if(!i){if(i=ee("form"),e.input){let a=ee("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),i.appendChild(ee("label",(e.label||"")+": ",a))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(ee("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let n=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let a=0;a<n.length;a++){let h=n[a];h.addEventListener("keydown",c=>{c.keyCode==27?(c.preventDefault(),l(null)):c.keyCode==13&&(c.preventDefault(),l(h))}),h.addEventListener("submit",c=>{c.preventDefault(),l(h)})}let r=ee("div",i,ee("button",{onclick:()=>l(null),"aria-label":s.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");let o=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function l(a){r.contains(r.ownerDocument.activeElement)&&s.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{o&&("select"in o?o.select():"focus"in o&&o.focus())},destroy:()=>t(null)}}class gt extends dt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}gt.prototype.elementClass="";gt.prototype.toDOM=void 0;gt.prototype.mapMode=he.TrackBefore;gt.prototype.startSide=gt.prototype.endSide=-1;gt.prototype.point=!0;const ls=D.define(),ju=D.define(),Uu={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>I.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},ki=D.define();function Gu(s){return[Va(),ki.of({...Uu,...s})]}const Io=D.define({combine:s=>s.some(e=>e)});function Va(s){return[Ju]}const Ju=fe.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.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=s.state.facet(ki).map(e=>new Wo(s,e)),this.fixed=!s.state.facet(Io);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),s.scrollDOM.insertBefore(this.dom,s.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(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(s.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Io)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=I.iter(this.view.state.facet(ls),this.view.viewport.from),i=[],n=this.gutters.map(r=>new Yu(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==re.Text&&o){Xs(t,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(r.type==re.Text){Xs(t,i,r.from);for(let o of n)o.line(this.view,r,i)}else if(r.widget)for(let o of n)o.widget(this.view,r);for(let r of n)r.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(ki),t=s.state.facet(ki),i=s.docChanged||s.heightChanged||s.viewportChanged||!I.eq(s.startState.facet(ls),s.state.facet(ls),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(s)&&(i=!0);else{i=!0;let n=[];for(let r of t){let o=e.indexOf(r);o<0?n.push(new Wo(this.view,r)):(this.gutters[o].update(s),n.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),n.indexOf(r)<0&&r.destroy();for(let r of n)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=n}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>M.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==G.LTR?{left:i,right:n}:{right:i,left:n}})});function No(s){return Array.isArray(s)?s:[s]}function Xs(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class Yu{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=I.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let l=new za(e,o,r,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];Xs(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let r of e.state.facet(ju)){let o=r(e,t.widget,t);o&&(n||(n=[])).push(o)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Wo{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=n.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,n)&&n.preventDefault()});this.markers=No(t.markers(e)),t.initialSpacer&&(this.spacer=new za(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=No(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!I.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class za{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Xu(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]: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(e),n)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function Xu(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const Qu=D.define(),Zu=D.define(),Vt=D.define({combine(s){return Pt(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let r=i[n],o=t[n];i[n]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class as extends gt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function hs(s,e){return s.state.facet(Vt).formatNumber(e,s.state)}const ed=ki.compute([Vt],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Qu)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new as(hs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(Zu)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Vt)!=e.state.facet(Vt),initialSpacer(e){return new as(hs(e,Fo(e.state.doc.lines)))},updateSpacer(e,t){let i=hs(t.view,Fo(t.view.state.doc.lines));return i==e.number?e:new as(i)},domEventHandlers:s.facet(Vt).domEventHandlers,side:"before"}));function td(s={}){return[Vt.of(s),Va(),ed]}function Fo(s){let e=9;for(;e<s;)e=e*10+9;return e}const id=1024;let nd=0;class De{constructor(e,t){this.from=e,this.to=t}}class E{constructor(e={}){this.id=nd++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ye.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}E.closedBy=new E({deserialize:s=>s.split(" ")});E.openedBy=new E({deserialize:s=>s.split(" ")});E.group=new E({deserialize:s=>s.split(" ")});E.isolate=new E({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});E.contextHash=new E({perNode:!0});E.lookAhead=new E({perNode:!0});E.mounted=new E({perNode:!0});class _t{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[E.mounted.id]}}const sd=Object.create(null);class ye{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):sd,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new ye(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(E.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(E.group),r=-1;r<(n?n.length:0);r++){let o=t[r<0?i.name:n[r]];if(o)return o}}}}ye.none=new ye("",Object.create(null),0,8);class Cr{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let r of e){let o=r(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}}t.push(n?new ye(i.name,n,i.id,i.flags):i)}return new Cr(t)}}const nn=new WeakMap,Ho=new WeakMap;var z;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(z||(z={}));class _{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=_t.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Dn(this.topNode,e)}cursorAt(e,t=0,i=0){let n=nn.get(this)||this.topNode,r=new Dn(n);return r.moveTo(e,t),nn.set(this,r._tree),r}get topNode(){return new ce(this,0,0,null)}resolve(e,t=0){let i=Oi(nn.get(this)||this.topNode,e,t,!1);return nn.set(this,i),i}resolveInner(e,t=0){let i=Oi(Ho.get(this)||this.topNode,e,t,!0);return Ho.set(this,i),i}resolveStack(e,t=0){return ld(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,o=e.mode||0,l=(o&z.IncludeAnonymous)>0;for(let a=this.cursor(o|z.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||t(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(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Dr(ye.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new _(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new _(ye.none,t,i,n)))}static build(e){return ad(e)}}_.empty=new _(ye.none,[],[],0);class Ar{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ar(this.buffer,this.index)}}class mt{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return ye.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,n,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(qa(r,n,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=n[l++],r[a++]=n[l++]-i;let h=r[a++]=n[l++]-i;r[a++]=n[l++]-e,o=Math.max(o,h)}return new mt(r,o,this.set)}}function qa(s,e,t,i){switch(s){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Oi(s,e,t,i){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let o=!i&&s instanceof ce&&s.index<0?null:s.parent;if(!o)return s;s=o}let r=i?0:z.IgnoreOverlays;if(i)for(let o=s,l=o.parent;l;o=l,l=o.parent)o instanceof ce&&o.index<0&&((n=l.enter(e,t,r))===null||n===void 0?void 0:n.from)!=o.from&&(s=l);for(;;){let o=s.enter(e,t,r);if(!o)return s;s=o}}class Ka{cursor(e=0){return new Dn(this,e)}getChild(e,t=null,i=null){let n=Vo(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return Vo(this,e,t,i)}resolve(e,t=0){return Oi(this,e,t,!1)}resolveInner(e,t=0){return Oi(this,e,t,!0)}matchContext(e){return Qs(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}get node(){return this}get next(){return this.parent}}class ce extends Ka{constructor(e,t,i,n){super(),this._tree=e,this.from=t,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(e,t,i,n,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(r&z.EnterBracketed&&c instanceof _&&(u=_t.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!qa(n,i,f,f+c.length))){if(c instanceof mt){if(r&z.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,n);if(d>-1)return new Ge(new rd(o,c,e,f),null,d)}else if(r&z.IncludeAnonymous||!c.type.isAnonymous||Mr(c)){let d;if(!(r&z.IgnoreMounts)&&(d=_t.get(c))&&!d.overlay)return new ce(d.tree,f,e,o);let p=new ce(c,f,e,o);return r&z.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,n,r)}}}if(r&z.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&z.IgnoreOverlays)&&(n=_t.get(this._tree))&&n.overlay){let r=e-this.from,o=i&z.EnterBracketed&&n.bracketed;for(let{from:l,to:a}of n.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new ce(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Vo(s,e,t,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function Qs(s,e,t=e.length-1){for(let i=s;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class rd{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class Ge extends Ka{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new Ge(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&z.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Ge(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ge(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Ge(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];e.push(i.slice(n,r,o)),t.push(0)}return new _(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function $a(s){if(!s.length)return null;let e=0,t=s[0];for(let r=1;r<s.length;r++){let o=s[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let i=t instanceof ce&&t.index<0?null:t.parent,n=s.slice();return i?n[e]=i:n.splice(e,1),new od(n,t)}class od{constructor(e,t){this.heads=e,this.node=t}get next(){return $a(this.heads)}}function ld(s,e,t){let i=s.resolveInner(e,t),n=null;for(let r=i instanceof ce?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(n||(n=[i])).push(o.resolve(e,t)),r=o}else{let o=_t.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ce(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(Oi(l,e,t,!1))}}return n?$a(n):i}class Dn{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~z.EnterBracketed,e instanceof ce)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof ce?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&z.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&z.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&z.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(n.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&z.IncludeAnonymous||l instanceof mt||!l.type.isAnonymous||Mr(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let n=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=r+1;break e}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)t=new Ge(this.buffer,t,this.stack[n]);return this.bufferNode=new Ge(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return Qs(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return Qs(this._tree,e,n);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}}function Mr(s){return s.children.some(e=>e instanceof mt||!e.type.isAnonymous||Mr(e))}function ad(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=id,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(t)?new Ar(t,t.length):t,a=i.types,h=0,c=0;function f(x,v,C,H,R,K){let{id:P,start:B,end:q,size:V}=l,U=c,le=h;if(V<0)if(l.next(),V==-1){let Qe=r[P];C.push(Qe),H.push(B-x);return}else if(V==-3){h=P;return}else if(V==-4){c=P;return}else throw new RangeError(`Unrecognized record size: ${V}`);let we=a[P],Fe,ne,Ce=B-x;if(q-B<=n&&(ne=m(l.pos-v,R))){let Qe=new Uint16Array(ne.size-ne.skip),de=l.pos-ne.size,Le=Qe.length;for(;l.pos>de;)Le=y(ne.start,Qe,Le);Fe=new mt(Qe,q-ne.start,i),Ce=ne.start-x}else{let Qe=l.pos-V;l.next();let de=[],Le=[],He=P>=o?P:-1,Ze=0,Rt=q,li=U;for(;l.pos>Qe;)He>=0&&l.id==He&&l.size>=0?(l.end<=Rt-n&&(p(de,Le,B,Ze,l.end,Rt,He,li,le),Ze=de.length,Rt=l.end,li=c),l.next()):K>2500?u(B,Qe,de,Le):(He>=0&&l.size==-1&&r[l.id].type==i.types[He]&&(Ze<de.length&&p(de,Le,B,Ze,l.end,Rt,He,li,le),Ze=de.length+1,Rt=l.start,li=c),f(B,Qe,de,Le,He,K+1));if(He>=0&&Ze>0&&Ze<de.length&&p(de,Le,B,Ze,B,Rt,He,li,le),de.reverse(),Le.reverse(),He>-1&&Ze>0){let $r=d(we,le);Fe=Dr(we,de,Le,0,de.length,0,q-B,$r,$r)}else Fe=g(we,de,Le,q-B,U-q,le)}C.push(Fe),H.push(Ce)}function u(x,v,C,H){let R=[],K=0,P=-1;for(;l.pos>v;){let{id:B,start:q,end:V,size:U}=l;if(U>4)l.next();else{if(P>-1&&q<P)break;P<0&&(P=V-n),R.push(B,q,V),K++,l.next()}}if(K){let B=new Uint16Array(K*4),q=R[R.length-2];for(let V=R.length-3,U=0;V>=0;V-=3)B[U++]=R[V],B[U++]=R[V+1]-q,B[U++]=R[V+2]-q,B[U++]=U;C.push(new mt(B,R[2]-q,i)),H.push(q-x)}}function d(x,v){return(C,H,R)=>{let K=0,P=C.length-1,B,q;if(P>=0&&(B=C[P])instanceof _){if(!P&&B.type==x&&B.length==R)return B;(q=B.prop(E.lookAhead))&&(K=H[P]+B.length+q-R)}return g(x,C,H,R,K,v)}}function p(x,v,C,H,R,K,P,B,q){let V=[],U=[];for(;x.length>H;)V.push(x.pop()),U.push(v.pop()+C-R);x.push(g(i.types[P],V,U,K-R,B-K,q)),v.push(R-C)}function g(x,v,C,H,R,K,P){if(K){let B=[E.contextHash,K];P=P?[B].concat(P):[B]}if(R>25){let B=[E.lookAhead,R];P=P?[B].concat(P):[B]}return new _(x,v,C,H,P)}function m(x,v){let C=l.fork(),H=0,R=0,K=0,P=C.end-n,B={size:0,start:0,skip:0};e:for(let q=C.pos-x;C.pos>q;){let V=C.size;if(C.id==v&&V>=0){B.size=H,B.start=R,B.skip=K,K+=4,H+=4,C.next();continue}let U=C.pos-V;if(V<0||U<q||C.start<P)break;let le=C.id>=o?4:0,we=C.start;for(C.next();C.pos>U;){if(C.size<0)if(C.size==-3||C.size==-4)le+=4;else break e;else C.id>=o&&(le+=4);C.next()}R=we,H+=V,K+=le}return(v<0||H==x)&&(B.size=H,B.start=R,B.skip=K),B.size>4?B:void 0}function y(x,v,C){let{id:H,start:R,end:K,size:P}=l;if(l.next(),P>=0&&H<o){let B=C;if(P>4){let q=l.pos-(P-4);for(;l.pos>q;)C=y(x,v,C)}v[--C]=B,v[--C]=K-x,v[--C]=R-x,v[--C]=H}else P==-3?h=H:P==-4&&(c=H);return C}let A=[],w=[];for(;l.pos>0;)f(s.start||0,s.bufferStart||0,A,w,-1,0);let O=(e=s.length)!==null&&e!==void 0?e:A.length?w[0]+A[0].length:0;return new _(a[s.topID],A.reverse(),w.reverse(),O)}const zo=new WeakMap;function gn(s,e){if(!s.isAnonymous||e instanceof mt||e.type!=s)return 1;let t=zo.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof _)){t=1;break}t+=gn(s,i)}zo.set(e,t)}return t}function Dr(s,e,t,i,n,r,o,l,a){let h=0;for(let p=i;p<n;p++)h+=gn(s,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,g,m,y,A){for(let w=m;w<y;){let O=w,x=g[w],v=gn(s,p[w]);for(w++;w<y;w++){let C=gn(s,p[w]);if(v+C>=c)break;v+=C}if(w==O+1){if(v>c){let C=p[O];d(C.children,C.positions,0,C.children.length,g[O]+A);continue}f.push(p[O])}else{let C=g[w-1]+p[w-1].length-x;f.push(Dr(s,p,g,O,w,x,C,null,a))}u.push(x+A-r)}}return d(e,t,i,n,0),(l||a)(f,u,o)}class _m{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Ge?this.setBuffer(e.context.buffer,e.index,t):e instanceof ce&&this.map.set(e.tree,t)}get(e){return e instanceof Ge?this.getBuffer(e.context.buffer,e.index):e instanceof ce?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class it{constructor(e,t,i,n,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new it(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[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 it(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&n.push(u),o.to>f)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return n}}class _a{startParse(e,t,i){return typeof e=="string"&&(e=new hd(e)),i=i?i.length?i.map(n=>new De(n.from,n.to)):[new De(0,0)]:[new De(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let r=n.advance();if(r)return r}}}class hd{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function jm(s){return(e,t,i,n)=>new fd(e,s,t,i,n)}class qo{constructor(e,t,i,n,r,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=n,this.target=r,this.from=o}}function Ko(s){if(!s.length||s.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}class cd{constructor(e,t,i,n,r,o,l,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=n,this.start=r,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const ja=new E({perNode:!0});class fd{constructor(e,t,i,n,r){this.nest=t,this.input=i,this.fragments=n,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}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 _(i.type,i.children,i.positions,i.length,i.propValues.concat([[ja,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[E.mounted.id]=new _t(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new pd(this.fragments),t=null,i=null,n=new Dn(new ce(this.baseTree,this.ranges[0].from,0,null),z.IncludeAnonymous|z.IgnoreMounts);e:for(let r,o;;){let l=!0,a;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=!1;else if(e.hasNode(n)){if(t){let h=t.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&&!t.ranges.some(d=>d.from<u&&d.to>f)&&t.ranges.push({from:f,to:u})}}l=!1}else if(i&&(o=ud(i.ranges,n.from,n.to)))l=o!=2;else if(!n.type.isAnonymous&&(r=this.nest(n,this.input))&&(n.from<n.to||!r.overlay)){n.tree||(dd(n),t&&t.depth++,i&&i.depth++);let h=e.findMounts(n.from,r.parser);if(typeof r.overlay=="function")t=new cd(r.parser,r.overlay,h,this.inner.length,n.from,!!r.bracketed,n.tree,t);else{let c=Uo(this.ranges,r.overlay||(n.from<n.to?[new De(n.from,n.to)]:[]));c.length&&Ko(c),(c.length||!r.overlay)&&this.inner.push(new qo(r.parser,c.length?r.parser.startParse(this.input,Go(h,c),c):r.parser.startParse(""),r.overlay?r.overlay.map(f=>new De(f.from-n.from,f.to-n.from)):null,!!r.bracketed,n.tree,c.length?c[0].from:n.from)),r.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):l=!1}}else if(t&&(a=t.predicate(n))&&(a===!0&&(a=new De(n.from,n.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&n.firstChild())t&&t.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(t&&!--t.depth){let h=Uo(this.ranges,t.ranges);h.length&&(Ko(h),this.inner.splice(t.index,0,new qo(t.parser,t.parser.startParse(this.input,Go(t.mounts,h),h),t.ranges.map(c=>new De(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function ud(s,e,t){for(let i of s){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function $o(s,e,t,i,n,r){if(e<t){let o=s.buffer[e+1];i.push(s.slice(e,t,o)),n.push(o-r)}}function dd(s){let{node:e}=s,t=[],i=e.context.buffer;do t.push(s.index),s.parent();while(!s.tree);let n=s.tree,r=n.children.indexOf(i),o=n.children[r],l=o.buffer,a=[r];function h(c,f,u,d,p,g){let m=t[g],y=[],A=[];$o(o,c,m,y,A,d);let w=l[m+1],O=l[m+2];a.push(y.length);let x=g?h(m+4,l[m+3],o.set.types[l[m]],w,O-w,g-1):e.toTree();return y.push(x),A.push(w-d),$o(o,l[m+3],f,y,A,d),new _(u,y,A,p)}n.children[r]=h(0,l.length,ye.none,0,o.length,t.length-1);for(let c of a){let f=s.tree.children[c],u=s.tree.positions[c];s.yield(new ce(f,u+s.from,c,s._tree))}}class _o{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(z.IncludeAnonymous|z.IgnoreMounts|z.ExcludeBuffers)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)if(!(t.to>=i&&t.enter(i,1,z.IncludeAnonymous|z.IgnoreMounts|z.IgnoreOverlays|z.ExcludeBuffers)))if(t.to<=i)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof _)t=t.children[0];else break}return!1}}function jo(s){let e=s.tree.prop(ja);return e==null?s.to:Math.min(s.to,e-s.offset)}class pd{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=jo(t),this.inner=new _o(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=jo(e),this.inner=new _o(e.tree,-e.offset)}}findMounts(e,t){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(E.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=r.to)break;a.tree==this.curFrag.tree&&n.push({frag:a,pos:r.from-a.offset,mount:o})}}}return n}}function Uo(s,e){let t=null,i=e;for(let n=1,r=0;n<s.length;n++){let o=s[n-1].to,l=s[n].from;for(;r<i.length;r++){let a=i[r];if(a.from>=l)break;a.to<=o||(t||(i=t=e.slice()),a.from<o?(t[r]=new De(a.from,o),a.to>l&&t.splice(r+1,0,new De(l,a.to))):a.to>l?t[r--]=new De(l,a.to):t.splice(r--,1))}}return i}function gd(s,e,t,i){let n=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=n==s.length?1e9:o?s[n].to:s[n].from,f=r==e.length?1e9:l?e[r].to:e[r].from;if(o!=l){let u=Math.max(a,t),d=Math.min(c,f,i);u<d&&h.push(new De(u,d))}if(a=Math.min(c,f),a==1e9)break;c==a&&(o?(o=!1,n++):o=!0),f==a&&(l?(l=!1,r++):l=!0)}return h}function Go(s,e){let t=[];for(let{pos:i,mount:n,frag:r}of s){let o=i+(n.overlay?n.overlay[0].from:0),l=o+n.tree.length,a=Math.max(r.from,o),h=Math.min(r.to,l);if(n.overlay){let c=n.overlay.map(u=>new De(u.from+i,u.to+i)),f=gd(e,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,g=p?h:f[u].from;if(g>d&&t.push(new it(d,g,n.tree,-o,r.from>=d||r.openStart,r.to<=g||r.openEnd)),p)break;d=f[u].to}}else t.push(new it(a,h,n.tree,-o,r.from>=o||r.openStart,r.to<=l||r.openEnd))}return t}let md=0;class Ae{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=md++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Ae&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new Ae(i,[],null,[]);if(n.set.push(n),t)for(let r of t.set)n.set.push(r);return n}static defineModifier(e){let t=new On(e);return i=>i.modified.indexOf(t)>-1?i:On.get(i.base||i,i.modified.concat(t).sort((n,r)=>n.id-r.id))}}let yd=0;class On{constructor(e){this.name=e,this.instances=[],this.id=yd++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&bd(t,l.modified));if(i)return i;let n=[],r=new Ae(e.name,n,e,t);for(let l of t)l.instances.push(r);let o=xd(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push(On.get(l,a));return r}}function bd(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function xd(s){let e=[[]];for(let t=0;t<s.length;t++)for(let i=0,n=e.length;i<n;i++)e.push(e[i].concat(s[t]));return e.sort((t,i)=>i.length-t.length)}function wd(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let r=[],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(r.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=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let c=new Ti(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return Ua.add(e)}const Ua=new E({combine(s,e){let t,i,n;for(;s||e;){if(!s||e&&s.depth<=e.depth?(n=e,e=e.next):(n=s,s=s.next),t&&t.mode==n.mode&&!n.context&&!t.context)continue;let r=new Ti(n.tags,n.mode,n.context);t?t.next=r:i=r,t=r}return i}});class Ti{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Ti.empty=new Ti([],2,null);function Ga(s,e){let t=Object.create(null);for(let r of s)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:n=null}=e||{};return{style:r=>{let o=n;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function kd(s,e){let t=null;for(let i of s){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function Sd(s,e,t,i=0,n=s.length){let r=new vd(i,Array.isArray(e)?e:[e],t);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}class vd{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,c=Cd(e)||Ti.empty,f=kd(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(E.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=e.firstChild();for(let m=0,y=l;;m++){let A=m<u.overlay.length?u.overlay[m]:null,w=A?A.from+l:a,O=Math.max(t,y),x=Math.min(i,w);if(O<x&&g)for(;e.from<x&&(this.highlightRange(e,O,x,n,r),this.startSpan(Math.min(x,e.to),h),!(e.to>=w||!e.nextSibling())););if(!A||w>i)break;y=A.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,A.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}g&&e.parent()}else if(e.firstChild()){u&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function Cd(s){let e=s.type.prop(Ua);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}const k=Ae.define,sn=k(),rt=k(),Jo=k(rt),Yo=k(rt),ot=k(),rn=k(ot),cs=k(ot),Ke=k(),wt=k(Ke),ze=k(),qe=k(),Zs=k(),ci=k(Zs),on=k(),T={comment:sn,lineComment:k(sn),blockComment:k(sn),docComment:k(sn),name:rt,variableName:k(rt),typeName:Jo,tagName:k(Jo),propertyName:Yo,attributeName:k(Yo),className:k(rt),labelName:k(rt),namespace:k(rt),macroName:k(rt),literal:ot,string:rn,docString:k(rn),character:k(rn),attributeValue:k(rn),number:cs,integer:k(cs),float:k(cs),bool:k(ot),regexp:k(ot),escape:k(ot),color:k(ot),url:k(ot),keyword:ze,self:k(ze),null:k(ze),atom:k(ze),unit:k(ze),modifier:k(ze),operatorKeyword:k(ze),controlKeyword:k(ze),definitionKeyword:k(ze),moduleKeyword:k(ze),operator:qe,derefOperator:k(qe),arithmeticOperator:k(qe),logicOperator:k(qe),bitwiseOperator:k(qe),compareOperator:k(qe),updateOperator:k(qe),definitionOperator:k(qe),typeOperator:k(qe),controlOperator:k(qe),punctuation:Zs,separator:k(Zs),bracket:ci,angleBracket:k(ci),squareBracket:k(ci),paren:k(ci),brace:k(ci),content:Ke,heading:wt,heading1:k(wt),heading2:k(wt),heading3:k(wt),heading4:k(wt),heading5:k(wt),heading6:k(wt),contentSeparator:k(Ke),list:k(Ke),quote:k(Ke),emphasis:k(Ke),strong:k(Ke),link:k(Ke),monospace:k(Ke),strikethrough:k(Ke),inserted:k(),deleted:k(),changed:k(),invalid:k(),meta:on,documentMeta:k(on),annotation:k(on),processingInstruction:k(on),definition:Ae.defineModifier("definition"),constant:Ae.defineModifier("constant"),function:Ae.defineModifier("function"),standard:Ae.defineModifier("standard"),local:Ae.defineModifier("local"),special:Ae.defineModifier("special")};for(let s in T){let e=T[s];e instanceof Ae&&(e.name=s)}Ga([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);function Xo(s,e,t,i=0,n=0){e==null&&(e=s.search(/[^\s\u00a0]/),e==-1&&(e=s.length));let r=n;for(let o=i;o<e;o++)s.charCodeAt(o)==9?r+=t-r%t:r++;return r}class Ja{constructor(e,t,i,n){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Xo(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Xo(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let n=o=>i?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return n(r)==n(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}}var fs;const Ct=new E;function Ya(s){return D.define({combine:s?e=>e.concat(s):void 0})}const Ad=new E;class Oe{constructor(e,t,i=[],n=""){this.data=e,this.name=n,N.prototype.hasOwnProperty("tree")||Object.defineProperty(N.prototype,"tree",{get(){return oe(this)}}),this.parser=t,this.extension=[yt.of(this),N.languageData.of((r,o,l)=>{let a=Qo(r,o,l),h=a.type.prop(Ct);if(!h)return[];let c=r.facet(h),f=a.type.prop(Ad);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Qo(e,t,i).type.prop(Ct)==this.data}findRegions(e){let t=e.facet(yt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(Ct)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(E.mounted);if(l){if(l.tree.prop(Ct)==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+r.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<r.children.length;a++){let h=r.children[a];h instanceof _&&n(h,r.positions[a]+o)}};return n(oe(e),0),i}get allowsNesting(){return!0}}Oe.setState=F.define();function Qo(s,e,t){let i=s.facet(yt),n=oe(s).topNode;if(!i||i.allowsNesting)for(let r=n;r;r=r.enter(e,t,z.ExcludeBuffers|z.EnterBracketed))r.type.isTop&&(n=r);return n}class er extends Oe{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Ya(e.languageData);return new er(t,e.parser.configure({props:[Ct.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new er(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function oe(s){let e=s.field(Oe.state,!1);return e?e.tree:_.empty}class Md{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let fi=null;class ei{constructor(e,t,i=[],n,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new ei(e,t,[],_.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Md(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=_.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(it.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<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(it.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=fi;fi=this;try{return e()}finally{fi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Zo(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=it.applyChanges(i,a),n=_.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new ei(this.parser,t,i,n,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:r}=this.skipped[i];n<e.to&&r>e.from&&(this.fragments=Zo(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends _a{createParse(t,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=fi;if(a){for(let h of n)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new _(ye.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return fi}}function Zo(s,e,t){return it.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}class ti{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ti(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=ei.create(e.facet(yt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ti(i)}}Oe.state=ve.define({create:ti.init,update(s,e){for(let t of e.effects)if(t.is(Oe.setState))return t.value;return e.startState.facet(yt)!=e.state.facet(yt)?ti.init(e.state):s.apply(e)}});let Xa=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Xa=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const us=typeof navigator<"u"&&(!((fs=navigator.scheduling)===null||fs===void 0)&&fs.isInputPending)?()=>navigator.scheduling.isInputPending():null,Dd=fe.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Oe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Oe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Xa(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(Oe.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!us?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work(()=>us&&us()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Oe.setState.of(new ti(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ue(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),yt=D.define({combine(s){return s.length?s[0]:null},enables:s=>[Oe.state,Dd,M.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});class Gm{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Qa{constructor(e,t,i,n,r,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=r,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Qa(e.name,(e.alias||[]).concat(e.name).map(n=>n.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let i=/\.([^.]+)$/.exec(t);if(i){for(let n of e)if(n.extensions.indexOf(i[1])>-1)return n}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(r=>r==t))return n;if(i)for(let n of e)for(let r of n.alias){let o=t.indexOf(r);if(o>-1&&(r.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+r.length])))return n}return null}}const Od=D.define(),Hi=D.define({combine:s=>{if(!s.length)return" ";let e=s[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return e}});function Bt(s){let e=s.facet(Hi);return e.charCodeAt(0)==9?s.tabSize*e.length:e.length}function Bi(s,e){let t="",i=s.tabSize,n=s.facet(Hi)[0];if(n==" "){for(;e>=i;)t+=" ",e-=i;n=" "}for(let r=0;r<e;r++)t+=n;return t}function Or(s,e){s instanceof N&&(s=new Kn(s));for(let i of s.state.facet(Od)){let n=i(s,e);if(n!==void 0)return n}let t=oe(s.state);return t.length>=e?Td(s,t,e):null}class Kn{constructor(e,t={}){this.state=e,this.options=t,this.unit=Bt(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.countColumn(i,e-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Wn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Za=new E;function Td(s,e,t){let i=e.resolveStack(t),n=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(n!=i.node){let r=[];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)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return eh(i,s,t)}function eh(s,e,t){for(let i=s;i;i=i.next){let n=Ld(i.node);if(n)return n(Tr.create(e,t,i))}return 0}function Bd(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function Ld(s){let e=s.type.prop(Za);if(e)return e;let t=s.firstChild,i;if(t&&(i=t.type.prop(E.closedBy))){let n=s.lastChild,r=n&&i.indexOf(n.name)>-1;return o=>th(o,!0,1,void 0,r&&!Bd(o)?n.from:void 0)}return s.parent==null?Ed:null}function Ed(){return 0}class Tr extends Kn{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Tr(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Pd(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return eh(this.context.next,this.base,this.pos)}}function Pd(s,e){for(let t=e;t;t=t.parent)if(s==t)return!0;return!1}function Rd(s){let e=s.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let n=s.options.simulateBreak,r=s.state.doc.lineAt(t.from),o=n==null||n<=r.from?r.to:Math.min(r.to,n);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function Jm({closing:s,align:e=!0,units:t=1}){return i=>th(i,e,t,s)}function th(s,e,t,i,n){let r=s.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||n==s.pos+o,a=e?Rd(s):null;return a?l?s.column(a.from):s.column(a.to):s.baseIndent+(l?0:s.unit*t)}const Ym=s=>s.baseIndent;function Xm({except:s,units:e=1}={}){return t=>{let i=s&&s.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Id=200;function Nd(){return N.transactionFilter.of(s=>{if(!s.docChanged||!s.isUserEvent("input.type")&&!s.isUserEvent("input.complete"))return s;let e=s.startState.languageDataAt("indentOnInput",s.startState.selection.main.head);if(!e.length)return s;let t=s.newDoc,{head:i}=s.newSelection.main,n=t.lineAt(i);if(i>n.from+Id)return s;let r=t.sliceString(n.from,i);if(!e.some(h=>h.test(r)))return s;let{state:o}=s,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=Or(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=Bi(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[s,{changes:a,sequential:!0}]:s})}const Wd=D.define(),Fd=new E;function Qm(s){let e=s.firstChild,t=s.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?s.to:t.from}:null}function Hd(s,e,t){let i=oe(s);if(i.length<t)return null;let n=i.resolveStack(t,1),r=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(Fd);if(a&&(l.to<i.length-50||i.length==s.doc.length||!Vd(l))){let h=a(l,s);h&&h.from<=t&&h.from>=e&&h.to>t&&(r=h)}}return r}function Vd(s){let e=s.lastChild;return e&&e.to==s.to&&e.type.isError}function Tn(s,e,t){for(let i of s.facet(Wd)){let n=i(s,e,t);if(n)return n}return Hd(s,e,t)}function ih(s,e){let t=e.mapPos(s.from,1),i=e.mapPos(s.to,-1);return t>=i?void 0:{from:t,to:i}}const $n=F.define({map:ih}),Vi=F.define({map:ih});function nh(s){let e=[];for(let{head:t}of s.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(s.lineBlockAt(t));return e}const Lt=ve.define({create(){return L.none},update(s,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,n)=>s=el(s,i,n)),s=s.map(e.changes);let t=[];for(let i of e.effects)i.is($n)&&!zd(s,i.value.from,i.value.to)?t.push(i.value):i.is(Vi)&&(s=s.update({filter:(n,r)=>i.value.from!=n||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(oh),n=t.map(r=>(i?L.replace({widget:new Gd(i(e.state,r))}):tl).range(r.from,r.to));s=s.update({add:n})}return e.selection&&(s=el(s,e.selection.main.head)),s},provide:s=>M.decorations.from(s),toJSON(s,e){let t=[];return s.between(0,e.doc.length,(i,n)=>{t.push(i,n)}),t},fromJSON(s){if(!Array.isArray(s)||s.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<s.length;){let i=s[t++],n=s[t++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");e.push(tl.range(i,n))}return L.set(e,!0)}});function el(s,e,t=e){let i=!1;return s.between(e,t,(n,r)=>{n<t&&r>e&&(i=!0)}),i?s.update({filterFrom:e,filterTo:t,filter:(n,r)=>n>=t||r<=e}):s}function Bn(s,e,t){var i;let n=null;return(i=s.field(Lt,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!n||n.from>r)&&(n={from:r,to:o})}),n}function zd(s,e,t){let i=!1;return s.between(e,e,(n,r)=>{n==e&&r==t&&(i=!0)}),i}function sh(s,e){return s.field(Lt,!1)?e:e.concat(F.appendConfig.of(lh()))}const qd=s=>{for(let e of nh(s)){let t=Tn(s.state,e.from,e.to);if(t)return s.dispatch({effects:sh(s.state,[$n.of(t),rh(s,t)])}),!0}return!1},Kd=s=>{if(!s.state.field(Lt,!1))return!1;let e=[];for(let t of nh(s)){let i=Bn(s.state,t.from,t.to);i&&e.push(Vi.of(i),rh(s,i,!1))}return e.length&&s.dispatch({effects:e}),e.length>0};function rh(s,e,t=!0){let i=s.state.doc.lineAt(e.from).number,n=s.state.doc.lineAt(e.to).number;return M.announce.of(`${s.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${s.state.phrase("to")} ${n}.`)}const $d=s=>{let{state:e}=s,t=[];for(let i=0;i<e.doc.length;){let n=s.lineBlockAt(i),r=Tn(e,n.from,n.to);r&&t.push($n.of(r)),i=(r?s.lineBlockAt(r.to):n).to+1}return t.length&&s.dispatch({effects:sh(s.state,t)}),!!t.length},_d=s=>{let e=s.state.field(Lt,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,s.state.doc.length,(i,n)=>{t.push(Vi.of({from:i,to:n}))}),s.dispatch({effects:t}),!0},jd=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:qd},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Kd},{key:"Ctrl-Alt-[",run:$d},{key:"Ctrl-Alt-]",run:_d}],Ud={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},oh=D.define({combine(s){return Pt(s,Ud)}});function lh(s){return[Lt,Xd]}function ah(s,e){let{state:t}=s,i=t.facet(oh),n=o=>{let l=s.lineBlockAt(s.posAtDOM(o.target)),a=Bn(s.state,l.from,l.to);a&&s.dispatch({effects:Vi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(s,n,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}const tl=L.replace({widget:new class extends bt{toDOM(s){return ah(s,null)}}});class Gd extends bt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ah(e,this.value)}}const Jd={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ds extends gt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Yd(s={}){let e={...Jd,...s},t=new ds(e,!0),i=new ds(e,!1),n=fe.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(yt)!=o.state.facet(yt)||o.startState.field(Lt,!1)!=o.state.field(Lt,!1)||oe(o.startState)!=oe(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new ct;for(let a of o.viewportLineBlocks){let h=Bn(o.state,a.from,a.to)?i:Tn(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[n,Gu({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(n))===null||l===void 0?void 0:l.markers)||I.empty},initialSpacer(){return new ds(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=Bn(o.state,l.from,l.to);if(h)return o.dispatch({effects:Vi.of(h)}),!0;let c=Tn(o.state,l.from,l.to);return c?(o.dispatch({effects:$n.of(c)}),!0):!1}}}),lh()]}const Xd=M.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 _n{constructor(e,t){this.specs=e;let i;function n(l){let a=ut.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof Oe?l=>l.prop(Ct)==o.data:o?l=>l==o:void 0,this.style=Ga(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new ut(i):null,this.themeType=t.themeType}static define(e,t){return new _n(e,t||{})}}const tr=D.define(),Qd=D.define({combine(s){return s.length?[s[0]]:null}});function ps(s){let e=s.facet(tr);return e.length?e:s.facet(Qd)}function Zd(s,e){let t=[tp],i;return s instanceof _n&&(s.module&&t.push(M.styleModule.of(s.module)),i=s.themeType),i?t.push(tr.computeN([M.darkTheme],n=>n.facet(M.darkTheme)==(i=="dark")?[s]:[])):t.push(tr.of(s)),t}class ep{constructor(e){this.markCache=Object.create(null),this.tree=oe(e.state),this.decorations=this.buildDeco(e,ps(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=oe(e.state),i=ps(e.state),n=i!=ps(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!n&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return L.none;let i=new ct;for(let{from:n,to:r}of e.visibleRanges)Sd(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=L.mark({class:a})))},n,r);return i.finish()}}const tp=ni.high(fe.fromClass(ep,{decorations:s=>s.decorations})),ip=M.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),hh=1e4,ch="()[]{}",fh=D.define({combine(s){return Pt(s,{afterCursor:!0,brackets:ch,maxScanDistance:hh,renderMatch:rp})}}),np=L.mark({class:"cm-matchingBracket"}),sp=L.mark({class:"cm-nonmatchingBracket"});function rp(s){let e=[],t=s.matched?np:sp;return e.push(t.range(s.start.from,s.start.to)),s.end&&e.push(t.range(s.end.from,s.end.to)),e}function il(s){let e=[],t=s.facet(fh);for(let i of s.selection.ranges){if(!i.empty)continue;let n=Je(s,i.head,-1,t)||i.head>0&&Je(s,i.head-1,1,t)||t.afterCursor&&(Je(s,i.head,1,t)||i.head<s.doc.length&&Je(s,i.head+1,-1,t));n&&(e=e.concat(t.renderMatch(n,s)))}return L.set(e,!0)}const op=fe.fromClass(class{constructor(s){this.paused=!1,this.decorations=il(s.state)}update(s){(s.docChanged||s.selectionSet||this.paused)&&(s.view.composing?(this.decorations=this.decorations.map(s.changes),this.paused=!0):(this.decorations=il(s.state),this.paused=!1))}},{decorations:s=>s.decorations}),lp=[op,ip];function ap(s={}){return[fh.of(s),lp]}const hp=new E;function ir(s,e,t){let i=s.prop(e<0?E.openedBy:E.closedBy);if(i)return i;if(s.name.length==1){let n=t.indexOf(s.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function nr(s){let e=s.type.prop(hp);return e?e(s.node):s}function Je(s,e,t,i={}){let n=i.maxScanDistance||hh,r=i.brackets||ch,o=oe(s),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=ir(a.type,t,r);if(h&&a.from<a.to){let c=nr(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return cp(s,e,t,a,c,h,r)}}return fp(s,e,t,o,l.type,n,r)}function cp(s,e,t,i,n,r,o){let l=i.parent,a={from:n.from,to:n.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let f=nr(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(ir(c.type,t,o))h++;else if(ir(c.type,-t,o)){if(h==0){let f=nr(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function fp(s,e,t,i,n,r,o){if(t<0?!e:e==s.doc.length)return null;let l=t<0?s.sliceDoc(e-1,e):s.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=s.doc.iterRange(e,t>0?s.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let g=t>0?0:d.length-1,m=t>0?d.length:-1;g!=m;g+=t){let y=o.indexOf(d[g]);if(!(y<0||i.resolveInner(p+g,1).type!=n))if(y%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+g,to:p+g+1},matched:y>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}function up(s){return{name:s.name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||dp,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||Er,mergeTokens:s.mergeTokens!==!1}}function dp(s){if(typeof s!="object")return s;let e={};for(let t in s){let i=s[t];e[t]=i instanceof Array?i.slice():i}return e}const nl=new WeakMap;class Br extends Oe{constructor(e){let t=Ya(e.languageData),i=up(e),n,r=new class extends _a{createParse(o,l,a){return new gp(n,o,l,a)}};super(t,r,[],e.name),this.topNode=bp(t,this),n=this,this.streamParser=i,this.stateAfter=new E({perNode:!0}),this.tokenTable=e.tokenTable?new gh(i.tokenTable):yp}static define(e){return new Br(e)}getIndent(e){let t,{overrideIndentation:i}=e.options;i&&(t=nl.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let n=Lr(this,e.node.tree,e.node.from,e.node.from,t??e.pos),r,o;if(n?(o=n.state,r=n.pos+1):(o=this.streamParser.startState(e.unit),r=e.node.from),e.pos-r>1e4)return null;for(;r<e.pos;){let a=e.state.doc.lineAt(r),h=Math.min(e.pos,a.to);if(a.length){let c=i?i(a.from):-1,f=new Ja(a.text,e.state.tabSize,e.unit,c<0?void 0:c);for(;f.pos<h-a.from;)dh(this.streamParser.token,f,o)}else this.streamParser.blankLine(o,e.unit);if(h==e.pos)break;r=a.to+1}let l=e.lineAt(e.pos);return i&&t==null&&nl.set(e.state,l.from),this.streamParser.indent(o,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}}function Lr(s,e,t,i,n){let r=t>=i&&t+e.length<=n&&e.prop(s.stateAfter);if(r)return{state:s.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof _&&a<n&&Lr(s,l,a,i,n);if(h)return h}return null}function uh(s,e,t,i,n){if(n&&t<=0&&i>=e.length)return e;!n&&t==0&&e.type==s.topNode&&(n=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],l=e.children[r],a;if(o<i&&l instanceof _){if(!(a=uh(s,l,t-o,i-o,n)))break;return n?new _(e.type,e.children.slice(0,r).concat(a),e.positions.slice(0,r+1),o+a.length):a}}return null}function pp(s,e,t,i,n){for(let r of e){let o=r.from+(r.openStart?25:0),l=r.to-(r.openEnd?25:0),a=o<=t&&l>t&&Lr(s,r.tree,0-r.offset,t,l),h;if(a&&a.pos<=i&&(h=uh(s,r.tree,t+r.offset,a.pos+r.offset,!1)))return{state:a.state,tree:h}}return{state:s.streamParser.startState(n?Bt(n):4),tree:_.empty}}class gp{constructor(e,t,i,n){this.lang=e,this.input=t,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let r=ei.get(),o=n[0].from,{state:l,tree:a}=pp(e,i,o,this.to,r?.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);r&&this.parsedPos<r.viewport.from-1e5&&n.some(h=>h.from<=r.viewport.from&&h.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(Bt(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=ei.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+512);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
10
10
|
`&&(t="");else{let i=t.indexOf(`
|
|
11
11
|
`);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let n=this.rangeIndex;;){let r=this.ranges[n].to;if(r>=i||(t=t.slice(0,r-(i-t.length)),n++,n==this.ranges.length))break;let o=this.ranges[n].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let n=this.ranges[this.rangeIndex].to,r=e+t;if(i>0?n>r:n>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-n}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,n){let r=4;if(this.ranges.length>1){n=this.skipGapsTo(t,n,1),t+=n;let l=this.chunk.length;n=this.skipGapsTo(i,n,-1),i+=n,r+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=i:this.chunk.push(e,t,i,r),n}parseLine(e){let{line:t,end:i}=this.nextLine(),n=0,{streamParser:r}=this.lang,o=new Ja(t,e?e.state.tabSize:4,e?Bt(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=dh(r.token,o,this.state);if(l&&(n=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,n)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=_.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:mp,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new _(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new _(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function dh(s,e,t){e.start=e.pos;for(let i=0;i<10;i++){let n=s(e,t);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const Er=Object.create(null),Li=[ye.none],mp=new Cr(Li),sl=[],rl=Object.create(null),ph=Object.create(null);for(let[s,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ph[s]=mh(Er,e);class gh{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),ph)}resolve(e){return e?this.table[e]||(this.table[e]=mh(this.extra,e)):0}}const yp=new gh(Er);function gs(s,e){sl.indexOf(s)>-1||(sl.push(s),console.warn(e))}function mh(s,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=s[h]||T[h];c?typeof c=="function"?a.length?a=a.map(c):gs(h,`Modifier ${h} used at start of tag`):a.length?gs(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:gs(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),r=rl[n];if(r)return r.id;let o=rl[n]=ye.define({id:Li.length,name:i,props:[wd({[i]:t})]});return Li.push(o),o.id}function bp(s,e){let t=ye.define({id:Li.length,name:"Document",props:[Ct.add(()=>s),Za.add(()=>i=>e.getIndent(i))],top:!0});return Li.push(t),t}G.RTL,G.LTR;const xp=s=>{let{state:e}=s,t=e.doc.lineAt(e.selection.main.from),i=Rr(s.state,t.from);return i.line?wp(s):i.block?Sp(s):!1};function Pr(s,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=s(e,t);return n?(i(t.update(n)),!0):!1}}const wp=Pr(Ap,0),kp=Pr(yh,0),Sp=Pr((s,e)=>yh(s,e,Cp(e)),0);function Rr(s,e){let t=s.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const ui=50;function vp(s,{open:e,close:t},i,n){let r=s.sliceDoc(i-ui,i),o=s.sliceDoc(n,n+ui),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:n+a,margin:a&&1}};let c,f;n-i<=2*ui?c=f=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+ui),f=s.sliceDoc(n-ui,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:n-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function Cp(s){let e=[];for(let t of s.selection.ranges){let i=s.doc.lineAt(t.from),n=t.to<=i.to?i:s.doc.lineAt(t.to);n.from>i.from&&n.from==t.to&&(n=t.to==i.to+1?i:s.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=n.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return e}function yh(s,e,t=e.selection.ranges){let i=t.map(r=>Rr(e,r.from).block);if(!i.every(r=>r))return null;let n=t.map((r,o)=>vp(e,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:e.changes(t.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let a=i[o],{open:h,close:c}=l;r.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:r}}return null}function Ap(s,e,t=e.selection.ranges){let i=[],n=-1;e:for(let{from:r,to:o}of t){let l=i.length,a=1e9,h;for(let c=r;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=Rr(e,f.from).line,!h))continue e;if(f.from>n&&(r==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(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];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++,r.push({from:h,to:c})}return{changes:r}}return null}const sr=st.define(),Mp=st.define(),Dp=D.define(),bh=D.define({combine(s){return Pt(s,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}}),xh=ve.define({create(){return Ye.empty},update(s,e){let t=e.state.facet(bh),i=e.annotation(sr);if(i){let a=xe.fromTransaction(e,i.selection),h=i.side,c=h==0?s.undone:s.done;return a?c=Ln(c,c.length,t.minDepth,a):c=Sh(c,e.startState.selection),new Ye(h==0?i.rest:c,h==0?c:i.rest)}let n=e.annotation(Mp);if((n=="full"||n=="before")&&(s=s.isolate()),e.annotation(Q.addToHistory)===!1)return e.changes.empty?s:s.addMapping(e.changes.desc);let r=xe.fromTransaction(e),o=e.annotation(Q.time),l=e.annotation(Q.userEvent);return r?s=s.addChanges(r,o,l,t,e):e.selection&&(s=s.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(e=>e.toJSON()),undone:s.undone.map(e=>e.toJSON())}},fromJSON(s){return new Ye(s.done.map(xe.fromJSON),s.undone.map(xe.fromJSON))}});function Op(s={}){return[xh,bh.of(s),M.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?wh:e.inputType=="historyRedo"?rr:null;return i?(e.preventDefault(),i(t)):!1}})]}function jn(s,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let n=t.field(xh,!1);if(!n)return!1;let r=n.pop(s,t,e);return r?(i(r),!0):!1}}const wh=jn(0,!1),rr=jn(1,!1),Tp=jn(0,!0),Bp=jn(1,!0);class xe{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new xe(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new xe(e.changes&&Z.fromJSON(e.changes),[],e.mapped&&Xe.fromJSON(e.mapped),e.startSelection&&b.fromJSON(e.startSelection),e.selectionsAfter.map(b.fromJSON))}static fromTransaction(e,t){let i=Te;for(let n of e.startState.facet(Dp)){let r=n(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new xe(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Te)}static selection(e){return new xe(void 0,Te,void 0,void 0,e)}}function Ln(s,e,t,i){let n=e+1>t+20?e-t-1:0,r=s.slice(n,e);return r.push(i),r}function Lp(s,e){let t=[],i=!1;return s.iterChangedRanges((n,r)=>t.push(n,r)),e.iterChangedRanges((n,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function Ep(s,e){return s.ranges.length==e.ranges.length&&s.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function kh(s,e){return s.length?e.length?s.concat(e):s:e}const Te=[],Pp=200;function Sh(s,e){if(s.length){let t=s[s.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Pp));return i.length&&i[i.length-1].eq(e)?s:(i.push(e),Ln(s,s.length-1,1e9,t.setSelAfter(i)))}else return[xe.selection([e])]}function Rp(s){let e=s[s.length-1],t=s.slice();return t[s.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ms(s,e){if(!s.length)return s;let t=s.length,i=Te;for(;t;){let n=Ip(s[t-1],e,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,t);return r[t-1]=n,r}else e=n.mapped,t--,i=n.selectionsAfter}return i.length?[xe.selection(i)]:Te}function Ip(s,e,t){let i=kh(s.selectionsAfter.length?s.selectionsAfter.map(l=>l.map(e)):Te,t);if(!s.changes)return xe.selection(i);let n=s.changes.map(e),r=e.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new xe(n,F.mapEffects(s.effects,e),o,s.startSelection.map(r),i)}const Np=/^(input\.type|delete)($|\.)/;class Ye{constructor(e,t,i=0,n=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Ye(this.done,this.undone):this}addChanges(e,t,i,n,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||Np.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,Lp(l.changes,e.changes))||i=="input.type.compose")?o=Ln(o,o.length-1,n.minDepth,new xe(e.changes.compose(l.changes),kh(F.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Te)):o=Ln(o,o.length,n.minDepth,e),new Ye(o,Te,t,i)}addSelection(e,t,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Te;return r.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Ep(r[r.length-1],e)?this:new Ye(Sh(this.done,e),this.undone,t,i)}addMapping(e){return new Ye(ms(this.done,e),ms(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=e==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:sr.of({side:e,rest:Rp(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=n.length==1?Te:n.slice(0,n.length-1);return r.mapped&&(l=ms(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:sr.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Ye.empty=new Ye(Te,Te);const Wp=[{key:"Mod-z",run:wh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:rr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:rr,preventDefault:!0},{key:"Mod-u",run:Tp,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Bp,preventDefault:!0}];function si(s,e){return b.create(s.ranges.map(e),s.mainIndex)}function Ne(s,e){return s.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function We({state:s,dispatch:e},t){let i=si(s.selection,t);return i.eq(s.selection,!0)?!1:(e(Ne(s,i)),!0)}function Un(s,e){return b.cursor(e?s.to:s.from)}function vh(s,e){return We(s,t=>t.empty?s.moveByChar(t,e):Un(t,e))}function ue(s){return s.textDirectionAt(s.state.selection.main.head)==G.LTR}const Ch=s=>vh(s,!ue(s)),Ah=s=>vh(s,ue(s));function Mh(s,e){return We(s,t=>t.empty?s.moveByGroup(t,e):Un(t,e))}const Fp=s=>Mh(s,!ue(s)),Hp=s=>Mh(s,ue(s));function Vp(s,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(e.from,e.to)))||e.firstChild}function Gn(s,e,t){let i=oe(s).resolveInner(e.head),n=t?E.closedBy:E.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Vp(s,h,n)?i=h:a=t?h.to:h.from}let r=i.type.prop(n),o,l;return r&&(o=t?Je(s,i.from,1):Je(s,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,b.cursor(l,t?-1:1)}const zp=s=>We(s,e=>Gn(s.state,e,!ue(s))),qp=s=>We(s,e=>Gn(s.state,e,ue(s)));function Dh(s,e){return We(s,t=>{if(!t.empty)return Un(t,e);let i=s.moveVertically(t,e);return i.head!=t.head?i:s.moveToLineBoundary(t,e)})}const Oh=s=>Dh(s,!1),Th=s=>Dh(s,!0);function Bh(s){let e=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,t=0,i=0,n;if(e){for(let r of s.state.facet(M.scrollMargins)){let o=r(s);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=s.scrollDOM.clientHeight-t-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(s.defaultLineHeight,n-5)}}function Lh(s,e){let t=Bh(s),{state:i}=s,n=si(i.selection,o=>o.empty?s.moveVertically(o,e,t.height):Un(o,e));if(n.eq(i.selection))return!1;let r;if(t.selfScroll){let o=s.coordsAtPos(i.selection.main.head),l=s.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=M.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-a}))}return s.dispatch(Ne(i,n),{effects:r}),!0}const ol=s=>Lh(s,!1),or=s=>Lh(s,!0);function xt(s,e,t){let i=s.lineBlockAt(e.head),n=s.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?i.to:i.from)&&(n=s.moveToLineBoundary(e,t,!1)),!t&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(n=b.cursor(i.from+r))}return n}const Kp=s=>We(s,e=>xt(s,e,!0)),$p=s=>We(s,e=>xt(s,e,!1)),_p=s=>We(s,e=>xt(s,e,!ue(s))),jp=s=>We(s,e=>xt(s,e,ue(s))),Up=s=>We(s,e=>s.moveToLineBoundary(e,!1,!1)),Gp=s=>We(s,e=>s.moveToLineBoundary(e,!0,!1));function Jp(s,e,t){let i=!1,n=si(s.selection,r=>{let o=Je(s,r.head,-1)||Je(s,r.head,1)||r.head>0&&Je(s,r.head-1,1)||r.head<s.doc.length&&Je(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return b.cursor(l)});return i?(e(Ne(s,n)),!0):!1}const Yp=({state:s,dispatch:e})=>Jp(s,e);function Be(s,e,t){let i=si(s.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=e&&(n=b.range(n.head,n.anchor));let r=t(n);return b.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch(Ne(s.state,i)),!0)}function Eh(s,e){return Be(s,e,t=>s.moveByChar(t,e))}const Ph=s=>Eh(s,!ue(s)),Rh=s=>Eh(s,ue(s));function Ih(s,e){return Be(s,e,t=>s.moveByGroup(t,e))}const Xp=s=>Ih(s,!ue(s)),Qp=s=>Ih(s,ue(s)),Zp=s=>{let e=!ue(s);return Be(s,e,t=>Gn(s.state,t,e))},eg=s=>{let e=ue(s);return Be(s,e,t=>Gn(s.state,t,e))};function Nh(s,e){return Be(s,e,t=>s.moveVertically(t,e))}const Wh=s=>Nh(s,!1),Fh=s=>Nh(s,!0);function Hh(s,e){return Be(s,e,t=>s.moveVertically(t,e,Bh(s).height))}const ll=s=>Hh(s,!1),al=s=>Hh(s,!0),tg=s=>Be(s,!0,e=>xt(s,e,!0)),ig=s=>Be(s,!1,e=>xt(s,e,!1)),ng=s=>{let e=!ue(s);return Be(s,e,t=>xt(s,t,e))},sg=s=>{let e=ue(s);return Be(s,e,t=>xt(s,t,e))},rg=s=>Be(s,!1,e=>b.cursor(s.lineBlockAt(e.head).from)),og=s=>Be(s,!0,e=>b.cursor(s.lineBlockAt(e.head).to)),hl=({state:s,dispatch:e})=>(e(Ne(s,{anchor:0})),!0),cl=({state:s,dispatch:e})=>(e(Ne(s,{anchor:s.doc.length})),!0),fl=({state:s,dispatch:e})=>(e(Ne(s,{anchor:s.selection.main.anchor,head:0})),!0),ul=({state:s,dispatch:e})=>(e(Ne(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),lg=({state:s,dispatch:e})=>(e(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),ag=({state:s,dispatch:e})=>{let t=Jn(s).map(({from:i,to:n})=>b.undirectionalRange(i,Math.min(n+1,s.doc.length)));return e(s.update({selection:b.create(t),userEvent:"select"})),!0},hg=({state:s,dispatch:e})=>{let t=si(s.selection,i=>{let n=oe(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return b.undirectionalRange(l.from,l.to)}return i});return t.eq(s.selection)?!1:(e(Ne(s,t)),!0)};function Vh(s,e){let{state:t}=s,i=t.selection,n=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<s.state.doc.length:o.from>0)for(let l=r;;){let a=s.moveVertically(l,e);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:(s.dispatch(Ne(t,b.create(n,n.length-1))),!0)}const cg=s=>Vh(s,!1),fg=s=>Vh(s,!0),ug=({state:s,dispatch:e})=>{let t=s.selection,i=null;return t.ranges.length>1?i=b.create([t.main]):t.main.empty||(i=b.create([b.cursor(t.main.head)])),i?(e(Ne(s,i)),!0):!1};function zi(s,e){if(s.state.readOnly)return!1;let t="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=ln(s,a,!1)):a>o&&(t="delete.forward",a=ln(s,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=ln(s,o,!1),l=ln(s,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:b.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?M.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function ln(s,e,t){if(s instanceof M)for(let i of s.state.facet(M.atomicRanges).map(n=>n(s)))i.between(e,e,(n,r)=>{n<e&&r>e&&(e=t?r:n)});return e}const zh=(s,e,t)=>zi(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),l,a;if(t&&!e&&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=Wn(l,r.tabSize),c=h%Bt(r)||Bt(r);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)n--;a=n}else a=te(o.text,n-o.from,e,e)+o.from,a==n&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=te(o.text,a-o.from,!1,!1)+o.from);return a}),lr=s=>zh(s,!1,!0),qh=s=>zh(s,!0,!1),Kh=(s,e)=>zi(s,t=>{let i=t.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);break}let a=te(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),$h=s=>Kh(s,!1),dg=s=>Kh(s,!0),pg=s=>zi(s,e=>{let t=s.lineBlockAt(e.head).to;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),gg=s=>zi(s,e=>{let t=s.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),mg=s=>zi(s,e=>{let t=s.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),yg=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:W.of(["",""])},range:b.cursor(i.from)}));return e(s.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},bg=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:te(r.text,n-r.from,!1)+r.from,l=n==r.to?n+1:te(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:s.doc.slice(n,l).append(s.doc.slice(o,n))},range:b.cursor(l)}});return t.changes.empty?!1:(e(s.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Jn(s){let e=[],t=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),t>=n.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:n.from,to:r.to,ranges:[i]});t=r.number+1}return e}function _h(s,e,t){if(s.readOnly)return!1;let i=[],n=[];for(let r of Jn(s)){if(t?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let a of r.ranges)n.push(b.range(Math.min(s.doc.length,a.anchor+l),Math.min(s.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let a of r.ranges)n.push(b.range(a.anchor-l,a.head-l))}}return i.length?(e(s.update({changes:i,scrollIntoView:!0,selection:b.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const xg=({state:s,dispatch:e})=>_h(s,e,!1),wg=({state:s,dispatch:e})=>_h(s,e,!0);function jh(s,e,t){if(s.readOnly)return!1;let i=[];for(let r of Jn(s))t?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return e(s.update({changes:n,selection:s.selection.map(n,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const kg=({state:s,dispatch:e})=>jh(s,e,!1),Sg=({state:s,dispatch:e})=>jh(s,e,!0),vg=s=>{if(s.state.readOnly)return!1;let{state:e}=s,t=e.changes(Jn(e).map(({from:n,to:r})=>(n>0?n--:r<e.doc.length&&r++,{from:n,to:r}))),i=si(e.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),l=s.coordsAtPos(n.head,n.assoc||1);l&&(r=o.bottom+s.documentTop-l.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(t);return s.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Cg(s,e){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=oe(s).resolveInner(e),i=t.childBefore(e),n=t.childAfter(e),r;return i&&n&&i.to<=e&&n.from>=e&&(r=i.type.prop(E.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const dl=Uh(!1),Ag=Uh(!0);function Uh(s){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:r,to:o}=n,l=e.doc.lineAt(r),a=!s&&r==o&&Cg(e,r);s&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Kn(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Or(h,r);for(c==null&&(c=Wn(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Bi(e,c)];return a&&f.push(Bi(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:W.of(f)},range:b.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ir(s,e){let t=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=s.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,n,i),t=l.number),o=l.to+1}let r=s.changes(n);return{changes:n,range:b.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Mg=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=Object.create(null),i=new Kn(s,{overrideIndentation:r=>{let o=t[r];return o??-1}}),n=Ir(s,(r,o,l)=>{let a=Or(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=Bi(s,a);(h!=c||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:c}))});return n.changes.empty||e(s.update(n,{userEvent:"indent"})),!0},Gh=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(Ir(s,(t,i)=>{i.push({from:t.from,insert:s.facet(Hi)})}),{userEvent:"input.indent"})),!0),Jh=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(Ir(s,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=Wn(n,s.tabSize),o=0,l=Bi(s,Math.max(0,r-Bt(s)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Dg=s=>(s.setTabFocusMode(),!0),Og=[{key:"Ctrl-b",run:Ch,shift:Ph,preventDefault:!0},{key:"Ctrl-f",run:Ah,shift:Rh},{key:"Ctrl-p",run:Oh,shift:Wh},{key:"Ctrl-n",run:Th,shift:Fh},{key:"Ctrl-a",run:Up,shift:rg},{key:"Ctrl-e",run:Gp,shift:og},{key:"Ctrl-d",run:qh},{key:"Ctrl-h",run:lr},{key:"Ctrl-k",run:pg},{key:"Ctrl-Alt-h",run:$h},{key:"Ctrl-o",run:yg},{key:"Ctrl-t",run:bg},{key:"Ctrl-v",run:or}],Tg=[{key:"ArrowLeft",run:Ch,shift:Ph,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Fp,shift:Xp,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:_p,shift:ng,preventDefault:!0},{key:"ArrowRight",run:Ah,shift:Rh,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Hp,shift:Qp,preventDefault:!0},{mac:"Cmd-ArrowRight",run:jp,shift:sg,preventDefault:!0},{key:"ArrowUp",run:Oh,shift:Wh,preventDefault:!0},{mac:"Cmd-ArrowUp",run:hl,shift:fl},{mac:"Ctrl-ArrowUp",run:ol,shift:ll},{key:"ArrowDown",run:Th,shift:Fh,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cl,shift:ul},{mac:"Ctrl-ArrowDown",run:or,shift:al},{key:"PageUp",run:ol,shift:ll},{key:"PageDown",run:or,shift:al},{key:"Home",run:$p,shift:ig,preventDefault:!0},{key:"Mod-Home",run:hl,shift:fl},{key:"End",run:Kp,shift:tg,preventDefault:!0},{key:"Mod-End",run:cl,shift:ul},{key:"Enter",run:dl,shift:dl},{key:"Mod-a",run:lg},{key:"Backspace",run:lr,shift:lr,preventDefault:!0},{key:"Delete",run:qh,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:$h,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:dg,preventDefault:!0},{mac:"Mod-Backspace",run:gg,preventDefault:!0},{mac:"Mod-Delete",run:mg,preventDefault:!0}].concat(Og.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),Bg=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:zp,shift:Zp},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:qp,shift:eg},{key:"Alt-ArrowUp",run:xg},{key:"Shift-Alt-ArrowUp",run:kg},{key:"Alt-ArrowDown",run:wg},{key:"Shift-Alt-ArrowDown",run:Sg},{key:"Mod-Alt-ArrowUp",run:cg},{key:"Mod-Alt-ArrowDown",run:fg},{key:"Escape",run:ug},{key:"Mod-Enter",run:Ag},{key:"Alt-l",mac:"Ctrl-l",run:ag},{key:"Mod-i",run:hg,preventDefault:!0},{key:"Mod-[",run:Jh},{key:"Mod-]",run:Gh},{key:"Mod-Alt-\\",run:Mg},{key:"Shift-Mod-k",run:vg},{key:"Shift-Mod-\\",run:Yp},{key:"Mod-/",run:xp},{key:"Alt-A",mac:"Ctrl-A",run:kp},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Dg}].concat(Tg),Lg={key:"Tab",run:Gh,shift:Jh};class Zm{constructor(e,t,i,n){this.state=e,this.pos=t,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=oe(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),n=t.text.slice(i-t.from,this.pos-t.from),r=n.search(Pg(e));return r<0?null:{from:i+r,to:this.pos,text:n.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function pl(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Eg(s){let e=Object.create(null),t=Object.create(null);for(let{label:n}of s){e[n[0]]=!0;for(let r=1;r<n.length;r++)t[n[r]]=!0}let i=pl(e)+pl(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function e0(s){let e=s.map(n=>typeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:Eg(e);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:e,validFor:t}:null}}function t0(s,e){return t=>{for(let i=oe(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(s.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}function Pg(s,e){var t;let{source:i}=s,n=i[i.length-1]!="$";return n?new RegExp(`(?:${i})${n?"$":""}`,(t=s.flags)!==null&&t!==void 0?t:s.ignoreCase?"i":""):s}const Rg=st.define(),Ig=M.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Ng{constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class Nr{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,he.TrackDel),i=e.mapPos(this.to,1,he.TrackDel);return t==null||i==null?null:new Nr(this.field,t,i)}}class Wr{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;f<c;f++)h+=e.facet(Hi);n.push(t+h.length-c),a=h+a.slice(c)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new Nr(a.field,n[a.line]+a.from,n[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],n=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1;l===0&&(l=1e9);let c=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(l!=null?t[f].seq==l:c&&t[f].name==c)&&(h=f);if(h<0){let f=0;for(;f<t.length&&(l==null||t[f].seq!=null&&t[f].seq<l);)f++;t.splice(f,0,{seq:l,name:c}),h=f;for(let u of n)u.field>=h&&u.field++}for(let f of n)if(f.line==i.length&&f.from>r.index){let u=r[2]?3+(r[1]||"").length:2;f.from-=u,f.to-=u}n.push(new Ng(h,i.length,r.index,r.index+c.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let c of n)c.line==i.length&&c.from>h&&(c.from--,c.to--);return a}),i.push(o)}return new Wr(i,n)}}let Wg=L.widget({widget:new class extends bt{toDOM(){let s=document.createElement("span");return s.className="cm-snippetFieldPosition",s}ignoreEvent(){return!1}}}),Fg=L.mark({class:"cm-snippetField"});class ri{constructor(e,t){this.ranges=e,this.active=t,this.deco=L.set(e.map(i=>(i.from==i.to?Wg:Fg).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let n=i.map(e);if(!n)return null;t.push(n)}return new ri(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const qi=F.define({map(s,e){return s&&s.map(e)}}),Hg=F.define(),Ei=ve.define({create(){return null},update(s,e){for(let t of e.effects){if(t.is(qi))return t.value;if(t.is(Hg)&&s)return new ri(s.ranges,t.value)}return s&&e.docChanged&&(s=s.map(e.changes)),s&&e.selection&&!s.selectionInsideField(e.selection)&&(s=null),s},provide:s=>M.decorations.from(s,e=>e?e.deco:L.none)});function Fr(s,e){return b.create(s.filter(t=>t.field==e).map(t=>b.range(t.from,t.to)))}function Vg(s){let e=Wr.parse(s);return(t,i,n,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,n),{main:a}=t.state.selection,h={changes:{from:n,to:r==a.from?a.to:r,insert:W.of(o)},scrollIntoView:!0,annotations:i?[Rg.of(i),Q.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=Fr(l,0)),l.some(c=>c.field>0)){let c=new ri(l,0),f=h.effects=[qi.of(c)];t.state.field(Ei,!1)===void 0&&f.push(F.appendConfig.of([Ei,_g,jg,Ig]))}t.dispatch(t.state.update(h))}}function Yh(s){return({state:e,dispatch:t})=>{let i=e.field(Ei,!1);if(!i||s<0&&i.active==0)return!1;let n=i.active+s,r=s>0&&!i.ranges.some(o=>o.field==n+s);return t(e.update({selection:Fr(i.ranges,n),effects:qi.of(r?null:new ri(i.ranges,n)),scrollIntoView:!0})),!0}}const zg=({state:s,dispatch:e})=>s.field(Ei,!1)?(e(s.update({effects:qi.of(null)})),!0):!1,qg=Yh(1),Kg=Yh(-1),$g=[{key:"Tab",run:qg,shift:Kg},{key:"Escape",run:zg}],gl=D.define({combine(s){return s.length?s[0]:$g}}),_g=ni.highest(Sr.compute([gl],s=>s.facet(gl)));function i0(s,e){return{...e,apply:Vg(s)}}const jg=M.domEventHandlers({mousedown(s,e){let t=e.state.field(Ei,!1),i;if(!t||(i=e.posAtCoords({x:s.clientX,y:s.clientY}))==null)return!1;let n=t.ranges.find(r=>r.from<=i&&r.to>=i);return!n||n.field==t.active?!1:(e.dispatch({selection:Fr(t.ranges,n.field),effects:qi.of(t.ranges.some(r=>r.field>n.field)?new ri(t.ranges,n.field):null),scrollIntoView:!0}),!0)}}),Pi={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},At=F.define({map(s,e){let t=e.mapPos(s,-1,he.TrackAfter);return t??void 0}}),Hr=new class extends dt{};Hr.startSide=1;Hr.endSide=-1;const Xh=ve.define({create(){return I.empty},update(s,e){if(s=s.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);s=s.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(At)&&(s=s.update({add:[Hr.range(t.value,t.value+1)]}));return s}});function Ug(){return[Jg,Xh]}const ys="()[]{}<>«»»«[]{}";function Qh(s){for(let e=0;e<ys.length;e+=2)if(ys.charCodeAt(e)==s)return ys.charAt(e+1);return vl(s<128?s:s+1)}function Zh(s,e){return s.languageDataAt("closeBrackets",e)[0]||Pi}const Gg=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Jg=M.inputHandler.of((s,e,t,i)=>{if((Gg?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let n=s.state.selection.main;if(i.length>2||i.length==2&&Ii(Et(i,0))==1||e!=n.from||t!=n.to)return!1;let r=Qg(s.state,i);return r?(s.dispatch(r),!0):!1}),Yg=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let i=Zh(s,s.selection.main.head).brackets||Pi.brackets,n=null,r=s.changeByRange(o=>{if(o.empty){let l=Zg(s.doc,o.head);for(let a of i)if(a==l&&Yn(s.doc,o.head)==Qh(Et(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:b.cursor(o.head-a.length)}}return{range:n=o}});return n||e(s.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},Xg=[{key:"Backspace",run:Yg}];function Qg(s,e){let t=Zh(s,s.selection.main.head),i=t.brackets||Pi.brackets;for(let n of i){let r=Qh(Et(n,0));if(e==n)return r==n?im(s,n,i.indexOf(n+n+n)>-1,t):em(s,n,r,t.before||Pi.before);if(e==r&&ec(s,s.selection.main.from))return tm(s,n,r)}return null}function ec(s,e){let t=!1;return s.field(Xh).between(0,s.doc.length,i=>{i==e&&(t=!0)}),t}function Yn(s,e){let t=s.sliceString(e,e+2);return t.slice(0,Ii(Et(t,0)))}function Zg(s,e){let t=s.sliceString(e-2,e);return Ii(Et(t,0))==t.length?t:t.slice(1)}function em(s,e,t,i){let n=null,r=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:At.of(o.to+e.length),range:b.range(o.anchor+e.length,o.head+e.length)};let l=Yn(s.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:At.of(o.head+e.length),range:b.cursor(o.head+e.length)}:{range:n=o}});return n?null:s.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function tm(s,e,t){let i=null,n=s.changeByRange(r=>r.empty&&Yn(s.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:b.cursor(r.head+t.length)}:i={range:r});return i?null:s.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function im(s,e,t,i){let n=i.stringPrefixes||Pi.stringPrefixes,r=null,o=s.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:At.of(l.to+e.length),range:b.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Yn(s.doc,a),c;if(h==e){if(ml(s,a))return{changes:{insert:e+e,from:a},effects:At.of(a+e.length),range:b.cursor(a+e.length)};if(ec(s,a)){let u=t&&s.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:b.cursor(a+u.length)}}}else{if(t&&s.sliceDoc(a-2*e.length,a)==e+e&&(c=yl(s,a-2*e.length,n))>-1&&ml(s,c))return{changes:{insert:e+e+e+e,from:a},effects:At.of(a+e.length),range:b.cursor(a+e.length)};if(s.charCategorizer(a)(h)!=J.Word&&yl(s,a,n)>-1&&!nm(s,a,e,n))return{changes:{insert:e+e,from:a},effects:At.of(a+e.length),range:b.cursor(a+e.length)}}return{range:r=l}});return r?null:s.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ml(s,e){let t=oe(s).resolveInner(e+1);return t.parent&&t.from==e}function nm(s,e,t,i){let n=oe(s).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=s.sliceDoc(n.from,Math.min(n.to,n.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=n.firstChild;for(;c&&c.from==n.from&&c.to-c.from>t.length+a;){if(s.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=n.to==e&&n.parent;if(!h)break;n=h}return!1}function yl(s,e,t){let i=s.charCategorizer(e);if(i(s.sliceDoc(e-1,e))!=J.Word)return e;for(let n of t){let r=e-n.length;if(s.sliceDoc(r,e)==n&&i(s.sliceDoc(r-1,r))!=J.Word)return r}return-1}const bl=typeof String.prototype.normalize=="function"?s=>s.normalize("NFKD"):s=>s;class ii{constructor(e,t,i=0,n=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=r?l=>r(bl(l)):bl,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Et(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=vl(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ii(e);let n=this.normalize(t);if(n.length)for(let r=0,o=i,l=!0;;r++){let a=n.charCodeAt(r),h=this.match(a,o,l,this.bufferPos+this.bufferStart,r==n.length-1);if(h)return this.value=h,this;if(r==n.length-1)break;l&&r<t.length&&t.charCodeAt(r)==a?o++:l=!1}}}match(e,t,i,n,r){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:n,precise:r&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:n,precise:i&&r}:this.matches.push({from:t,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(ii.prototype[Symbol.iterator]=function(){return this});const tc={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Vr="gm"+(/x/.unicode==null?"":"u");class ic{constructor(e,t,i,n=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=tc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new nc(e,t,i,n,r);this.re=new RegExp(t,Vr+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(n);this.curLineStart=o.from,this.matchPos=En(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=En(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,t)))return this.value={from:i,to:n,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const bs=new WeakMap;class jt{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=bs.get(e);if(!n||n.from>=i||n.to<=t){let l=new jt(t,e.sliceString(t,i));return bs.set(e,l),l}if(n.from==t&&n.to==i)return n;let{text:r,from:o}=n;return o>t&&(r=e.sliceString(t,o)+r,o=t),n.to<i&&(r+=e.sliceString(n.to,i)),bs.set(e,new jt(o,r)),new jt(t,r.slice(t-o,i-o))}}class nc{constructor(e,t,i,n,r){this.text=e,this.to=r,this.done=!1,this.value=tc,this.matchPos=En(e,n),this.re=new RegExp(t,Vr+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=jt.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,n=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this.matchPos=En(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=jt.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(ic.prototype[Symbol.iterator]=nc.prototype[Symbol.iterator]=function(){return this});function sm(s){try{return new RegExp(s,Vr),!0}catch{return!1}}function En(s,e){if(e>=s.length)return e;let t=s.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}const rm=s=>{let e=$u(s,"cm-goto-line");if(e){let o=e.dom.querySelector("input[type=text]");return o&&o.select(),!0}let{state:t}=s,i=String(t.doc.lineAt(s.state.selection.main.head).number),{close:n,result:r}=Ku(s,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return r.then(o=>{let l=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!l){s.dispatch({effects:n});return}let a=t.doc.lineAt(t.selection.main.head),[,h,c,f,u]=l,d=f?+f.slice(1):0,p=c?+c:a.number;if(c&&u){let y=p/100;h&&(y=y*(h=="-"?-1:1)+a.number/t.doc.lines),p=Math.round(t.doc.lines*y)}else c&&h&&(p=p*(h=="-"?-1:1)+a.number);let g=t.doc.line(Math.max(1,Math.min(t.doc.lines,p))),m=b.cursor(g.from+Math.max(0,Math.min(d,g.length)));s.dispatch({effects:[n,M.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},om={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},lm=D.define({combine(s){return Pt(s,om,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function am(s){return[dm,um]}const hm=L.mark({class:"cm-selectionMatch"}),cm=L.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function xl(s,e,t,i){return(t==0||s(e.sliceDoc(t-1,t))!=J.Word)&&(i==e.doc.length||s(e.sliceDoc(i,i+1))!=J.Word)}function fm(s,e,t,i){return s(e.sliceDoc(t,t+1))==J.Word&&s(e.sliceDoc(i-1,i))==J.Word}const um=fe.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.selectionSet||s.docChanged||s.viewportChanged)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=s.state.facet(lm),{state:t}=s,i=t.selection;if(i.ranges.length>1)return L.none;let n=i.main,r,o=null;if(n.empty){if(!e.highlightWordAroundCursor)return L.none;let a=t.wordAt(n.head);if(!a)return L.none;o=t.charCategorizer(n.head),r=t.sliceDoc(a.from,a.to)}else{let a=n.to-n.from;if(a<e.minSelectionLength||a>200)return L.none;if(e.wholeWords){if(r=t.sliceDoc(n.from,n.to),o=t.charCategorizer(n.head),!(xl(o,t,n.from,n.to)&&fm(o,t,n.from,n.to)))return L.none}else if(r=t.sliceDoc(n.from,n.to),!r)return L.none}let l=[];for(let a of s.visibleRanges){let h=new ii(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||xl(o,t,c,f))&&(n.empty&&c<=n.from&&f>=n.to?l.push(cm.range(c,f)):(c>=n.to||f<=n.from)&&l.push(hm.range(c,f)),l.length>e.maxMatches))return L.none}}return L.set(l)}},{decorations:s=>s.decorations}),dm=M.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),pm=({state:s,dispatch:e})=>{let{selection:t}=s,i=b.create(t.ranges.map(n=>s.wordAt(n.head)||b.cursor(n.head)),t.mainIndex);return i.eq(t)?!1:(e(s.update({selection:i})),!0)};function gm(s,e){let{main:t,ranges:i}=s.selection,n=s.wordAt(t.head),r=n&&n.from==t.from&&n.to==t.to;for(let o=!1,l=new ii(s.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new ii(s.doc,e,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(r){let a=s.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const mm=({state:s,dispatch:e})=>{let{ranges:t}=s.selection;if(t.some(r=>r.from===r.to))return pm({state:s,dispatch:e});let i=s.sliceDoc(t[0].from,t[0].to);if(s.selection.ranges.some(r=>s.sliceDoc(r.from,r.to)!=i))return!1;let n=gm(s,i);return n?(e(s.update({selection:s.selection.addRange(b.range(n.from,n.to),!1),effects:M.scrollIntoView(n.to)})),!0):!1},oi=D.define({combine(s){return Pt(s,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Bm(e),scrollToMatch:e=>M.scrollIntoView(e)})}});class sc{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||sm(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
12
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Sm(this):new xm(this)}getCursor(e,t=0,i){let n=e.doc?e:N.create({doc:e});return i==null&&(i=n.doc.length),this.regexp?Ft(this,n,t,i):Wt(this,n,t,i)}}class rc{constructor(e){this.spec=e}}function ym(s,e,t){return(i,n,r,o)=>{if(t&&!t(i,n,r,o))return!1;let l=i>=o&&n<=o+r.length?r.slice(i-o,n-o):e.doc.sliceString(i,n);return s(l,e,i,n)}}function Wt(s,e,t,i){let n;return s.wholeWord&&(n=bm(e.doc,e.charCategorizer(e.selection.main.head))),s.test&&(n=ym(s.test,e,n)),new ii(e.doc,s.unquoted,t,i,s.caseSensitive?void 0:r=>r.toLowerCase(),n)}function bm(s,e){return(t,i,n,r)=>((r>t||r+n.length<i)&&(r=Math.max(0,t-2),n=s.sliceString(r,Math.min(s.length,i+2))),(e(Pn(n,t-r))!=J.Word||e(Rn(n,t-r))!=J.Word)&&(e(Rn(n,i-r))!=J.Word||e(Pn(n,i-r))!=J.Word))}class xm extends rc{constructor(e){super(e)}nextMatch(e,t,i){let n=Wt(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);n=Wt(this.spec,e,0,r).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let r=Math.max(t,n-1e4-this.spec.unquoted.length),o=Wt(this.spec,e,r,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Wt(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Wt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function wm(s,e,t){return(i,n,r)=>(!t||t(i,n,r))&&s(r[0],e,i,n)}function Ft(s,e,t,i){let n;return s.wholeWord&&(n=km(e.charCategorizer(e.selection.main.head))),s.test&&(n=wm(s.test,e,n)),new ic(e.doc,s.search,{ignoreCase:!s.caseSensitive,test:n},t,i)}function Pn(s,e){return s.slice(te(s,e,!1),e)}function Rn(s,e){return s.slice(e,te(s,e))}function km(s){return(e,t,i)=>!i[0].length||(s(Pn(i.input,i.index))!=J.Word||s(Rn(i.input,i.index))!=J.Word)&&(s(Rn(i.input,i.index+i[0].length))!=J.Word||s(Pn(i.input,i.index+i[0].length))!=J.Word)}class Sm extends rc{nextMatch(e,t,i){let n=Ft(this.spec,e,i,e.doc.length).next();return n.done&&(n=Ft(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-n*1e4),o=Ft(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let r=+i.slice(0,n);if(r>0&&r<e.match.length)return e.match[r]+i.slice(n)}return t})}matchAll(e,t){let i=Ft(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Ft(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const Ri=F.define(),zr=F.define(),ft=ve.define({create(s){return new xs(ar(s).create(),null)},update(s,e){for(let t of e.effects)t.is(Ri)?s=new xs(t.value.create(),s.panel):t.is(zr)&&(s=new xs(s.query,t.value?qr:null));return s},provide:s=>Mn.from(s,e=>e.panel)});class xs{constructor(e,t){this.query=e,this.panel=t}}const vm=L.mark({class:"cm-searchMatch"}),Cm=L.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Am=fe.fromClass(class{constructor(s){this.view=s,this.decorations=this.highlight(s.state.field(ft))}update(s){let e=s.state.field(ft);(e!=s.startState.field(ft)||s.docChanged||s.selectionSet||s.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:s,panel:e}){if(!e||!s.spec.valid)return L.none;let{view:t}=this,i=new ct;for(let n=0,r=t.visibleRanges,o=r.length;n<o;n++){let{from:l,to:a}=r[n];for(;n<o-1&&a>r[n+1].from-500;)a=r[++n].to;s.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?Cm:vm)})}return i.finish()}},{decorations:s=>s.decorations});function Ki(s){return e=>{let t=e.state.field(ft,!1);return t&&t.query.spec.valid?s(e,t):ac(e)}}const In=Ki((s,{query:e})=>{let{to:t}=s.state.selection.main,i=e.nextMatch(s.state,t,t);if(!i)return!1;let n=b.single(i.from,i.to),r=s.state.facet(oi);return s.dispatch({selection:n,effects:[Kr(s,i),r.scrollToMatch(n.main,s)],userEvent:"select.search"}),lc(s),!0}),Nn=Ki((s,{query:e})=>{let{state:t}=s,{from:i}=t.selection.main,n=e.prevMatch(t,i,i);if(!n)return!1;let r=b.single(n.from,n.to),o=s.state.facet(oi);return s.dispatch({selection:r,effects:[Kr(s,n),o.scrollToMatch(r.main,s)],userEvent:"select.search"}),lc(s),!0}),Mm=Ki((s,{query:e})=>{let t=e.matchAll(s.state,1e3);return!t||!t.length?!1:(s.dispatch({selection:b.create(t.map(i=>b.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Dm=({state:s,dispatch:e})=>{let t=s.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:n}=t.main,r=[],o=0;for(let l=new ii(s.doc,s.sliceDoc(i,n));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(b.range(l.value.from,l.value.to))}return e(s.update({selection:b.create(r,o),userEvent:"select.search.matches"})),!0},wl=Ki((s,{query:e})=>{let{state:t}=s,{from:i,to:n}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==n&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(M.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=s.state.changes(l);return o&&(a=b.single(o.from,o.to).map(f),c.push(Kr(s,o)),c.push(t.facet(oi).scrollToMatch(a.main,s))),s.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),Om=Ki((s,{query:e})=>{if(s.state.readOnly)return!1;let t=[];for(let n of e.matchAll(s.state,1e9)){let{from:r,to:o,precise:l}=n;l&&t.push({from:r,to:o,insert:e.getReplacement(n)})}if(!t.length)return!1;let i=s.state.phrase("replaced $ matches",t.length)+".";return s.dispatch({changes:t,effects:M.announce.of(i),userEvent:"input.replace.all"}),!0});function qr(s){return s.state.facet(oi).createPanel(s)}function ar(s,e){var t,i,n,r,o;let l=s.selection.main,a=l.empty||l.to>l.from+100?"":s.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=s.facet(oi);return new sc({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(n=e?.literal)!==null&&n!==void 0?n:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function oc(s){let e=vr(s,qr);return e&&e.dom.querySelector("[main-field]")}function lc(s){let e=oc(s);e&&e==s.root.activeElement&&e.select()}const ac=s=>{let e=s.state.field(ft,!1);if(e&&e.panel){let t=oc(s);if(t&&t!=s.root.activeElement){let i=ar(s.state,e.query.spec);i.valid&&s.dispatch({effects:Ri.of(i)}),t.focus(),t.select()}}else s.dispatch({effects:[zr.of(!0),e?Ri.of(ar(s.state,e.query.spec)):F.appendConfig.of(Em)]});return!0},hc=s=>{let e=s.state.field(ft,!1);if(!e||!e.panel)return!1;let t=vr(s,qr);return t&&t.dom.contains(s.root.activeElement)&&s.focus(),s.dispatch({effects:zr.of(!1)}),!0},Tm=[{key:"Mod-f",run:ac,scope:"editor search-panel"},{key:"F3",run:In,shift:Nn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:In,shift:Nn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Dm},{key:"Mod-Alt-g",run:rm},{key:"Mod-d",run:mm,preventDefault:!0}];class Bm{constructor(e){this.view=e;let t=this.query=e.state.field(ft).query.spec;this.commit=this.commit.bind(this),this.searchField=ee("input",{value:t.search,placeholder:ke(e,"Find"),"aria-label":ke(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ee("input",{value:t.replace,placeholder:ke(e,"Replace"),"aria-label":ke(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ee("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ee("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ee("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(n,r,o){return ee("button",{class:"cm-button",name:n,onclick:r,type:"button"},o)}this.dom=ee("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>In(e),[ke(e,"next")]),i("prev",()=>Nn(e),[ke(e,"previous")]),i("select",()=>Mm(e),[ke(e,"all")]),ee("label",null,[this.caseField,ke(e,"match case")]),ee("label",null,[this.reField,ke(e,"regexp")]),ee("label",null,[this.wordField,ke(e,"by word")]),...e.state.readOnly?[]:[ee("br"),this.replaceField,i("replace",()=>wl(e),[ke(e,"replace")]),i("replaceAll",()=>Om(e),[ke(e,"replace all")])],ee("button",{name:"close",onclick:()=>hc(e),"aria-label":ke(e,"close"),type:"button"},["×"])])}commit(){let e=new sc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ri.of(e)}))}keydown(e){Du(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Nn:In)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),wl(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Ri)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(oi).top}}function ke(s,e){return s.state.phrase(e)}const an=30,hn=/[\s\.,:;?!]/;function Kr(s,{from:e,to:t}){let i=s.state.doc.lineAt(e),n=s.state.doc.lineAt(t).to,r=Math.max(i.from,e-an),o=Math.min(n,t+an),l=s.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<an;a++)if(!hn.test(l[a+1])&&hn.test(l[a])){l=l.slice(a);break}}if(o!=n){for(let a=l.length-1;a>l.length-an;a--)if(!hn.test(l[a-1])&&hn.test(l[a])){l=l.slice(0,a);break}}return M.announce.of(`${s.state.phrase("current match")}. ${l} ${s.state.phrase("on line")} ${i.number}.`)}const Lm=M.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"}}),Em=[ft,ni.low(Am),Lm],Pm={bash:"shell",sh:"shell",js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",md:"markdown",yml:"yaml",vue:"html",text:"plaintext",txt:"plaintext"};function cc(s){const e=s.trim().toLowerCase();return Pm[e]??e}async function Rm(s){switch(cc(s)){case"json":return(await Ee(async()=>{const{json:e}=await import("./index-BcQ5zdWM.js");return{json:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).json();case"markdown":return(await Ee(async()=>{const{markdown:e}=await import("./index-DvSYq8lz.js");return{markdown:e}},__vite__mapDeps([11,12,1,13,2,3,4,5,6,7,8,9,10,14]))).markdown();case"javascript":return(await Ee(async()=>{const{javascript:e}=await import("./index-DfVgpfCm.js");return{javascript:e}},__vite__mapDeps([14,1,2,3,4,5,6,7,8,9,10]))).javascript({jsx:!0});case"typescript":return(await Ee(async()=>{const{javascript:e}=await import("./index-DfVgpfCm.js");return{javascript:e}},__vite__mapDeps([14,1,2,3,4,5,6,7,8,9,10]))).javascript({typescript:!0,jsx:!0});case"css":return(await Ee(async()=>{const{css:e}=await import("./index-er6dD-sT.js");return{css:e}},__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10]))).css();case"scss":return(await Ee(async()=>{const{sass:e}=await import("./index-Dj5tjGFV.js");return{sass:e}},__vite__mapDeps([15,1,13,2,3,4,5,6,7,8,9,10]))).sass();case"html":return(await Ee(async()=>{const{html:e}=await import("./index-C7gIQnkU.js");return{html:e}},__vite__mapDeps([12,1,13,2,3,4,5,6,7,8,9,10,14]))).html();case"yaml":return(await Ee(async()=>{const{yaml:e}=await import("./index-BFKj1V0c.js");return{yaml:e}},__vite__mapDeps([16,1,2,3,4,5,6,7,8,9,10]))).yaml();case"python":return(await Ee(async()=>{const{python:e}=await import("./index-CzsbmDuv.js");return{python:e}},__vite__mapDeps([17,1,2,3,4,5,6,7,8,9,10]))).python();case"xml":return(await Ee(async()=>{const{xml:e}=await import("./index-CgCqkjVa.js");return{xml:e}},__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,10]))).xml();case"shell":return Br.define((await Ee(async()=>{const{shell:e}=await import("./shell-CjFT_Tl9.js");return{shell:e}},[])).shell);default:return[]}}const Im=[M.theme({"&":{height:"100%",backgroundColor:"transparent",color:"var(--color-heading)"},"&.cm-focused":{outline:"none"},".cm-scroller":{overflow:"auto",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"13px",lineHeight:"21px"},".cm-content":{padding:"10px 0",caretColor:"var(--accent-600)"},".cm-line":{padding:"0 10px"},".cm-gutters":{backgroundColor:"transparent",color:"var(--editor-muted)",border:"none"},".cm-activeLineGutter":{backgroundColor:"var(--color-background-soft)"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--color-background-soft) 60%, transparent)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--accent-600)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, & > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent-500) 25%, transparent)"},".cm-panels, .cm-tooltip":{backgroundColor:"var(--color-background)",color:"var(--color-heading)",borderColor:"var(--color-border)"},".cm-textfield, .cm-button":{background:"var(--color-background-soft)",color:"var(--color-heading)",border:"1px solid var(--color-border)",borderRadius:"4px"},".cm-searchMatch":{backgroundColor:"color-mix(in srgb, var(--accent-500) 20%, transparent)",outline:"1px solid var(--accent-500)"},".cm-searchMatch-selected":{backgroundColor:"color-mix(in srgb, var(--accent-500) 40%, transparent)"},".cm-placeholder":{color:"var(--editor-muted)"}}),Zd(_n.define([{tag:T.comment,color:"var(--editor-muted)",fontStyle:"italic"},{tag:[T.keyword,T.modifier,T.operator],color:"var(--editor-keyword)"},{tag:[T.string,T.regexp,T.attributeValue],color:"var(--editor-string)"},{tag:[T.number,T.bool,T.null],color:"var(--editor-number)"},{tag:[T.typeName,T.className,T.attributeName],color:"var(--editor-type)"},{tag:[T.tagName,T.heading],color:"var(--editor-string)"},{tag:T.link,color:"var(--editor-number)",textDecoration:"underline"}]))],Nm={class:"code-editor flex min-h-0 flex-col","data-code-editor":""},Wm={key:0,role:"status",class:"mt-1 text-sm text-red-500"},Fm=bc({__name:"CodeEditor",props:{modelValue:{},language:{default:"plaintext"},readonly:{type:Boolean,default:!1},error:{default:null},rows:{},height:{},placeholder:{},lineNumbers:{default:"on"},wordWrap:{default:"off"},formatOnBlur:{type:Boolean,default:!1},framed:{type:Boolean,default:!0},label:{default:"Code editor"}},emits:["update:modelValue","blur"],setup(s,{emit:e}){const t=s,i=e,n=_r(null),r=_r(null),o=jr(()=>cc(t.language)),l=jr(()=>t.height??(t.rows?`${t.rows*1.5}rem`:"100%")),a=new Mt,h=new Mt,c=new Mt;let f=null,u=0,d=[],p=null;const g=()=>[Im,M.darkTheme.of(document.documentElement.classList.contains("dark"))];gc({getValue:()=>t.modelValue,isReadonly:()=>t.readonly});const m=()=>[N.readOnly.of(t.readonly),M.editable.of(!t.readonly),M.contentAttributes.of({"aria-label":t.label,"aria-readonly":String(t.readonly),tabindex:"0"}),t.lineNumbers==="off"?[]:td(),t.wordWrap==="on"?M.lineWrapping:[],t.placeholder?qu(t.placeholder):[]];async function y(){const O=++u;r.value=null;try{const x=await Rm(o.value);f&&O===u&&(d=x,f.dispatch({effects:h.reconfigure(x)}))}catch{f&&O===u&&(r.value="Syntax highlighting could not load.")}}function A(){if(!(!f||t.readonly||o.value!=="json"))try{const O=f.state.doc.toString(),x=JSON.stringify(JSON.parse(O),null,2);O!==x&&f.dispatch({changes:{from:0,to:f.state.doc.length,insert:x}})}catch{}}function w(O){return N.create({doc:O,extensions:[c.of(g()),a.of(m()),h.of(d),Op(),N.tabSize.of(2),Hi.of(" "),N.allowMultipleSelections.of(!0),Pu(),Fu(),ap(),Ug(),Nd(),Yd(),am(),Sr.of([...Xg,...Bg,...Wp,...Tm,...jd,Lg]),M.updateListener.of(x=>{x.docChanged&&i("update:modelValue",x.state.doc.toString())}),M.domEventHandlers({blur:()=>{t.formatOnBlur&&A(),i("blur")}})]})}return xc(()=>{n.value&&(f=new M({parent:n.value,state:w(t.modelValue)}),y(),p=new MutationObserver(()=>{f?.dispatch({effects:c.reconfigure(g())})}),p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}),Xn(()=>t.modelValue,O=>{!f||f.state.doc.toString()===O||f.setState(w(O))}),Xn(o,()=>{f&&y()}),Xn(()=>[t.readonly,t.lineNumbers,t.wordWrap,t.placeholder,t.label],()=>{f?.dispatch({effects:a.reconfigure(m())})}),wc(()=>{++u,p?.disconnect(),p=null,f?.destroy(),f=null}),(O,x)=>(Gr(),Ur("div",Nm,[Jr("div",{class:vc(["min-h-0 flex-1 overflow-hidden bg-white dark:bg-neutral-950",[s.framed?"rounded border":"",s.framed&&s.error?"border-red-500":"",s.framed&&!s.error?"border-neutral-200 dark:border-neutral-800":""]]),style:Sc({height:l.value})},[Jr("div",{ref_key:"containerRef",ref:n,class:"h-full w-full"},null,512)],6),s.error||r.value?(Gr(),Ur("div",Wm,Cc(Ac(mc)(s.error||r.value)),1)):kc("",!0)]))}}),Hm=yc(Fm,[["__scopeId","data-v-e0053b5d"]]),n0=Object.freeze(Object.defineProperty({__proto__:null,default:Hm},Symbol.toStringTag,{value:"Module"}));export{i0 as A,t0 as B,Zm as C,id as D,b as E,e0 as F,Jm as G,Ym as H,z as I,Ad as J,n0 as K,Gm as L,Cr as N,_a as P,_ as T,er as a,Qm as b,Xm as c,ye as d,E as e,Fd as f,Ae as g,Wd as h,Za as i,ni as j,Sr as k,Oe as l,Ya as m,oe as n,Wn as o,jm as p,Hi as q,N as r,wd as s,T as t,Ct as u,M as v,Qa as w,ei as x,hp as y,_m as z};
|
|
12
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Sm(this):new xm(this)}getCursor(e,t=0,i){let n=e.doc?e:N.create({doc:e});return i==null&&(i=n.doc.length),this.regexp?Ft(this,n,t,i):Wt(this,n,t,i)}}class rc{constructor(e){this.spec=e}}function ym(s,e,t){return(i,n,r,o)=>{if(t&&!t(i,n,r,o))return!1;let l=i>=o&&n<=o+r.length?r.slice(i-o,n-o):e.doc.sliceString(i,n);return s(l,e,i,n)}}function Wt(s,e,t,i){let n;return s.wholeWord&&(n=bm(e.doc,e.charCategorizer(e.selection.main.head))),s.test&&(n=ym(s.test,e,n)),new ii(e.doc,s.unquoted,t,i,s.caseSensitive?void 0:r=>r.toLowerCase(),n)}function bm(s,e){return(t,i,n,r)=>((r>t||r+n.length<i)&&(r=Math.max(0,t-2),n=s.sliceString(r,Math.min(s.length,i+2))),(e(Pn(n,t-r))!=J.Word||e(Rn(n,t-r))!=J.Word)&&(e(Rn(n,i-r))!=J.Word||e(Pn(n,i-r))!=J.Word))}class xm extends rc{constructor(e){super(e)}nextMatch(e,t,i){let n=Wt(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);n=Wt(this.spec,e,0,r).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let r=Math.max(t,n-1e4-this.spec.unquoted.length),o=Wt(this.spec,e,r,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Wt(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Wt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function wm(s,e,t){return(i,n,r)=>(!t||t(i,n,r))&&s(r[0],e,i,n)}function Ft(s,e,t,i){let n;return s.wholeWord&&(n=km(e.charCategorizer(e.selection.main.head))),s.test&&(n=wm(s.test,e,n)),new ic(e.doc,s.search,{ignoreCase:!s.caseSensitive,test:n},t,i)}function Pn(s,e){return s.slice(te(s,e,!1),e)}function Rn(s,e){return s.slice(e,te(s,e))}function km(s){return(e,t,i)=>!i[0].length||(s(Pn(i.input,i.index))!=J.Word||s(Rn(i.input,i.index))!=J.Word)&&(s(Rn(i.input,i.index+i[0].length))!=J.Word||s(Pn(i.input,i.index+i[0].length))!=J.Word)}class Sm extends rc{nextMatch(e,t,i){let n=Ft(this.spec,e,i,e.doc.length).next();return n.done&&(n=Ft(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-n*1e4),o=Ft(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let r=+i.slice(0,n);if(r>0&&r<e.match.length)return e.match[r]+i.slice(n)}return t})}matchAll(e,t){let i=Ft(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Ft(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const Ri=F.define(),zr=F.define(),ft=ve.define({create(s){return new xs(ar(s).create(),null)},update(s,e){for(let t of e.effects)t.is(Ri)?s=new xs(t.value.create(),s.panel):t.is(zr)&&(s=new xs(s.query,t.value?qr:null));return s},provide:s=>Mn.from(s,e=>e.panel)});class xs{constructor(e,t){this.query=e,this.panel=t}}const vm=L.mark({class:"cm-searchMatch"}),Cm=L.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Am=fe.fromClass(class{constructor(s){this.view=s,this.decorations=this.highlight(s.state.field(ft))}update(s){let e=s.state.field(ft);(e!=s.startState.field(ft)||s.docChanged||s.selectionSet||s.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:s,panel:e}){if(!e||!s.spec.valid)return L.none;let{view:t}=this,i=new ct;for(let n=0,r=t.visibleRanges,o=r.length;n<o;n++){let{from:l,to:a}=r[n];for(;n<o-1&&a>r[n+1].from-500;)a=r[++n].to;s.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?Cm:vm)})}return i.finish()}},{decorations:s=>s.decorations});function Ki(s){return e=>{let t=e.state.field(ft,!1);return t&&t.query.spec.valid?s(e,t):ac(e)}}const In=Ki((s,{query:e})=>{let{to:t}=s.state.selection.main,i=e.nextMatch(s.state,t,t);if(!i)return!1;let n=b.single(i.from,i.to),r=s.state.facet(oi);return s.dispatch({selection:n,effects:[Kr(s,i),r.scrollToMatch(n.main,s)],userEvent:"select.search"}),lc(s),!0}),Nn=Ki((s,{query:e})=>{let{state:t}=s,{from:i}=t.selection.main,n=e.prevMatch(t,i,i);if(!n)return!1;let r=b.single(n.from,n.to),o=s.state.facet(oi);return s.dispatch({selection:r,effects:[Kr(s,n),o.scrollToMatch(r.main,s)],userEvent:"select.search"}),lc(s),!0}),Mm=Ki((s,{query:e})=>{let t=e.matchAll(s.state,1e3);return!t||!t.length?!1:(s.dispatch({selection:b.create(t.map(i=>b.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Dm=({state:s,dispatch:e})=>{let t=s.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:n}=t.main,r=[],o=0;for(let l=new ii(s.doc,s.sliceDoc(i,n));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(b.range(l.value.from,l.value.to))}return e(s.update({selection:b.create(r,o),userEvent:"select.search.matches"})),!0},wl=Ki((s,{query:e})=>{let{state:t}=s,{from:i,to:n}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==n&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(M.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=s.state.changes(l);return o&&(a=b.single(o.from,o.to).map(f),c.push(Kr(s,o)),c.push(t.facet(oi).scrollToMatch(a.main,s))),s.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),Om=Ki((s,{query:e})=>{if(s.state.readOnly)return!1;let t=[];for(let n of e.matchAll(s.state,1e9)){let{from:r,to:o,precise:l}=n;l&&t.push({from:r,to:o,insert:e.getReplacement(n)})}if(!t.length)return!1;let i=s.state.phrase("replaced $ matches",t.length)+".";return s.dispatch({changes:t,effects:M.announce.of(i),userEvent:"input.replace.all"}),!0});function qr(s){return s.state.facet(oi).createPanel(s)}function ar(s,e){var t,i,n,r,o;let l=s.selection.main,a=l.empty||l.to>l.from+100?"":s.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=s.facet(oi);return new sc({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(n=e?.literal)!==null&&n!==void 0?n:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function oc(s){let e=vr(s,qr);return e&&e.dom.querySelector("[main-field]")}function lc(s){let e=oc(s);e&&e==s.root.activeElement&&e.select()}const ac=s=>{let e=s.state.field(ft,!1);if(e&&e.panel){let t=oc(s);if(t&&t!=s.root.activeElement){let i=ar(s.state,e.query.spec);i.valid&&s.dispatch({effects:Ri.of(i)}),t.focus(),t.select()}}else s.dispatch({effects:[zr.of(!0),e?Ri.of(ar(s.state,e.query.spec)):F.appendConfig.of(Em)]});return!0},hc=s=>{let e=s.state.field(ft,!1);if(!e||!e.panel)return!1;let t=vr(s,qr);return t&&t.dom.contains(s.root.activeElement)&&s.focus(),s.dispatch({effects:zr.of(!1)}),!0},Tm=[{key:"Mod-f",run:ac,scope:"editor search-panel"},{key:"F3",run:In,shift:Nn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:In,shift:Nn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Dm},{key:"Mod-Alt-g",run:rm},{key:"Mod-d",run:mm,preventDefault:!0}];class Bm{constructor(e){this.view=e;let t=this.query=e.state.field(ft).query.spec;this.commit=this.commit.bind(this),this.searchField=ee("input",{value:t.search,placeholder:ke(e,"Find"),"aria-label":ke(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ee("input",{value:t.replace,placeholder:ke(e,"Replace"),"aria-label":ke(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ee("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ee("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ee("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(n,r,o){return ee("button",{class:"cm-button",name:n,onclick:r,type:"button"},o)}this.dom=ee("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>In(e),[ke(e,"next")]),i("prev",()=>Nn(e),[ke(e,"previous")]),i("select",()=>Mm(e),[ke(e,"all")]),ee("label",null,[this.caseField,ke(e,"match case")]),ee("label",null,[this.reField,ke(e,"regexp")]),ee("label",null,[this.wordField,ke(e,"by word")]),...e.state.readOnly?[]:[ee("br"),this.replaceField,i("replace",()=>wl(e),[ke(e,"replace")]),i("replaceAll",()=>Om(e),[ke(e,"replace all")])],ee("button",{name:"close",onclick:()=>hc(e),"aria-label":ke(e,"close"),type:"button"},["×"])])}commit(){let e=new sc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ri.of(e)}))}keydown(e){Du(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Nn:In)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),wl(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Ri)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(oi).top}}function ke(s,e){return s.state.phrase(e)}const an=30,hn=/[\s\.,:;?!]/;function Kr(s,{from:e,to:t}){let i=s.state.doc.lineAt(e),n=s.state.doc.lineAt(t).to,r=Math.max(i.from,e-an),o=Math.min(n,t+an),l=s.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<an;a++)if(!hn.test(l[a+1])&&hn.test(l[a])){l=l.slice(a);break}}if(o!=n){for(let a=l.length-1;a>l.length-an;a--)if(!hn.test(l[a-1])&&hn.test(l[a])){l=l.slice(0,a);break}}return M.announce.of(`${s.state.phrase("current match")}. ${l} ${s.state.phrase("on line")} ${i.number}.`)}const Lm=M.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"}}),Em=[ft,ni.low(Am),Lm],Pm={bash:"shell",sh:"shell",js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",md:"markdown",yml:"yaml",vue:"html",text:"plaintext",txt:"plaintext"};function cc(s){const e=s.trim().toLowerCase();return Pm[e]??e}async function Rm(s){switch(cc(s)){case"json":return(await Ee(async()=>{const{json:e}=await import("./index-b4VUAUvJ.js");return{json:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).json();case"markdown":return(await Ee(async()=>{const{markdown:e}=await import("./index-jI_N1y04.js");return{markdown:e}},__vite__mapDeps([11,12,1,13,2,3,4,5,6,7,8,9,10,14]))).markdown();case"javascript":return(await Ee(async()=>{const{javascript:e}=await import("./index-DcCqDioc.js");return{javascript:e}},__vite__mapDeps([14,1,2,3,4,5,6,7,8,9,10]))).javascript({jsx:!0});case"typescript":return(await Ee(async()=>{const{javascript:e}=await import("./index-DcCqDioc.js");return{javascript:e}},__vite__mapDeps([14,1,2,3,4,5,6,7,8,9,10]))).javascript({typescript:!0,jsx:!0});case"css":return(await Ee(async()=>{const{css:e}=await import("./index-C4-LP0pJ.js");return{css:e}},__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10]))).css();case"scss":return(await Ee(async()=>{const{sass:e}=await import("./index-D4_R8FnR.js");return{sass:e}},__vite__mapDeps([15,1,13,2,3,4,5,6,7,8,9,10]))).sass();case"html":return(await Ee(async()=>{const{html:e}=await import("./index-CwBC9sTn.js");return{html:e}},__vite__mapDeps([12,1,13,2,3,4,5,6,7,8,9,10,14]))).html();case"yaml":return(await Ee(async()=>{const{yaml:e}=await import("./index-CmfTs1yz.js");return{yaml:e}},__vite__mapDeps([16,1,2,3,4,5,6,7,8,9,10]))).yaml();case"python":return(await Ee(async()=>{const{python:e}=await import("./index-ChLk4ONU.js");return{python:e}},__vite__mapDeps([17,1,2,3,4,5,6,7,8,9,10]))).python();case"xml":return(await Ee(async()=>{const{xml:e}=await import("./index-BkfWiMo-.js");return{xml:e}},__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,10]))).xml();case"shell":return Br.define((await Ee(async()=>{const{shell:e}=await import("./shell-CjFT_Tl9.js");return{shell:e}},[])).shell);default:return[]}}const Im=[M.theme({"&":{height:"100%",backgroundColor:"transparent",color:"var(--color-heading)"},"&.cm-focused":{outline:"none"},".cm-scroller":{overflow:"auto",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"13px",lineHeight:"21px"},".cm-content":{padding:"10px 0",caretColor:"var(--accent-600)"},".cm-line":{padding:"0 10px"},".cm-gutters":{backgroundColor:"transparent",color:"var(--editor-muted)",border:"none"},".cm-activeLineGutter":{backgroundColor:"var(--color-background-soft)"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--color-background-soft) 60%, transparent)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--accent-600)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, & > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent-500) 25%, transparent)"},".cm-panels, .cm-tooltip":{backgroundColor:"var(--color-background)",color:"var(--color-heading)",borderColor:"var(--color-border)"},".cm-textfield, .cm-button":{background:"var(--color-background-soft)",color:"var(--color-heading)",border:"1px solid var(--color-border)",borderRadius:"4px"},".cm-searchMatch":{backgroundColor:"color-mix(in srgb, var(--accent-500) 20%, transparent)",outline:"1px solid var(--accent-500)"},".cm-searchMatch-selected":{backgroundColor:"color-mix(in srgb, var(--accent-500) 40%, transparent)"},".cm-placeholder":{color:"var(--editor-muted)"}}),Zd(_n.define([{tag:T.comment,color:"var(--editor-muted)",fontStyle:"italic"},{tag:[T.keyword,T.modifier,T.operator],color:"var(--editor-keyword)"},{tag:[T.string,T.regexp,T.attributeValue],color:"var(--editor-string)"},{tag:[T.number,T.bool,T.null],color:"var(--editor-number)"},{tag:[T.typeName,T.className,T.attributeName],color:"var(--editor-type)"},{tag:[T.tagName,T.heading],color:"var(--editor-string)"},{tag:T.link,color:"var(--editor-number)",textDecoration:"underline"}]))],Nm={class:"code-editor flex min-h-0 flex-col","data-code-editor":""},Wm={key:0,role:"status",class:"mt-1 text-sm text-red-500"},Fm=bc({__name:"CodeEditor",props:{modelValue:{},language:{default:"plaintext"},readonly:{type:Boolean,default:!1},error:{default:null},rows:{},height:{},placeholder:{},lineNumbers:{default:"on"},wordWrap:{default:"off"},formatOnBlur:{type:Boolean,default:!1},framed:{type:Boolean,default:!0},label:{default:"Code editor"}},emits:["update:modelValue","blur"],setup(s,{emit:e}){const t=s,i=e,n=_r(null),r=_r(null),o=jr(()=>cc(t.language)),l=jr(()=>t.height??(t.rows?`${t.rows*1.5}rem`:"100%")),a=new Mt,h=new Mt,c=new Mt;let f=null,u=0,d=[],p=null;const g=()=>[Im,M.darkTheme.of(document.documentElement.classList.contains("dark"))];gc({getValue:()=>t.modelValue,isReadonly:()=>t.readonly});const m=()=>[N.readOnly.of(t.readonly),M.editable.of(!t.readonly),M.contentAttributes.of({"aria-label":t.label,"aria-readonly":String(t.readonly),tabindex:"0"}),t.lineNumbers==="off"?[]:td(),t.wordWrap==="on"?M.lineWrapping:[],t.placeholder?qu(t.placeholder):[]];async function y(){const O=++u;r.value=null;try{const x=await Rm(o.value);f&&O===u&&(d=x,f.dispatch({effects:h.reconfigure(x)}))}catch{f&&O===u&&(r.value="Syntax highlighting could not load.")}}function A(){if(!(!f||t.readonly||o.value!=="json"))try{const O=f.state.doc.toString(),x=JSON.stringify(JSON.parse(O),null,2);O!==x&&f.dispatch({changes:{from:0,to:f.state.doc.length,insert:x}})}catch{}}function w(O){return N.create({doc:O,extensions:[c.of(g()),a.of(m()),h.of(d),Op(),N.tabSize.of(2),Hi.of(" "),N.allowMultipleSelections.of(!0),Pu(),Fu(),ap(),Ug(),Nd(),Yd(),am(),Sr.of([...Xg,...Bg,...Wp,...Tm,...jd,Lg]),M.updateListener.of(x=>{x.docChanged&&i("update:modelValue",x.state.doc.toString())}),M.domEventHandlers({blur:()=>{t.formatOnBlur&&A(),i("blur")}})]})}return xc(()=>{n.value&&(f=new M({parent:n.value,state:w(t.modelValue)}),y(),p=new MutationObserver(()=>{f?.dispatch({effects:c.reconfigure(g())})}),p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}),Xn(()=>t.modelValue,O=>{!f||f.state.doc.toString()===O||f.setState(w(O))}),Xn(o,()=>{f&&y()}),Xn(()=>[t.readonly,t.lineNumbers,t.wordWrap,t.placeholder,t.label],()=>{f?.dispatch({effects:a.reconfigure(m())})}),wc(()=>{++u,p?.disconnect(),p=null,f?.destroy(),f=null}),(O,x)=>(Gr(),Ur("div",Nm,[Jr("div",{class:vc(["min-h-0 flex-1 overflow-hidden bg-white dark:bg-neutral-950",[s.framed?"rounded border":"",s.framed&&s.error?"border-red-500":"",s.framed&&!s.error?"border-neutral-200 dark:border-neutral-800":""]]),style:Sc({height:l.value})},[Jr("div",{ref_key:"containerRef",ref:n,class:"h-full w-full"},null,512)],6),s.error||r.value?(Gr(),Ur("div",Wm,Cc(Ac(mc)(s.error||r.value)),1)):kc("",!0)]))}}),Hm=yc(Fm,[["__scopeId","data-v-e0053b5d"]]),n0=Object.freeze(Object.defineProperty({__proto__:null,default:Hm},Symbol.toStringTag,{value:"Module"}));export{i0 as A,t0 as B,Zm as C,id as D,b as E,e0 as F,Jm as G,Ym as H,z as I,Ad as J,n0 as K,Gm as L,Cr as N,_a as P,_ as T,er as a,Qm as b,Xm as c,ye as d,E as e,Fd as f,Ae as g,Wd as h,Za as i,ni as j,Sr as k,Oe as l,Ya as m,oe as n,Wn as o,jm as p,Hi as q,N as r,wd as s,T as t,Ct as u,M as v,Qa as w,ei as x,hp as y,_m as z};
|