(e,A=this.mainIndex)
| 246 | `){[e,A]=qB(this,e,A);let n="";for(let o=0,a=0;o<=A&&a<this.text.length;a++){let r=this.text[a],s=o+r.length;o>e&&a&&(n+=t),e<s&&A>o&&(n+=r.slice(Math.max(0,e-o),A-o)),o=s+1}return n}flatten(e){for(let A of this.text)e.push(A)}scanIdentical(){return 0}static split(e,A){let t=[],n=-1;for(let o of e)t.push(o),n+=o.length+1,t.length==32&&(A.push(new i(t,n)),t=[],n=-1);return n>-1&&A.push(new i(t,n)),A}},PB=class i extends On{constructor(e,A){super(),this.children=e,this.length=A,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,A,t,n){for(let o=0;;o++){let a=this.children[o],r=n+a.length,s=t+a.lines-1;if((A?s:r)>=e)return a.lineInner(e,A,t,n);n=r+1,t=s+1}}decompose(e,A,t,n){for(let o=0,a=0;a<=A&&o<this.children.length;o++){let r=this.children[o],s=a+r.length;if(e<=s&&A>=a){let l=n&((a<=e?1:0)|(s>=A?2:0));a>=e&&s<=A&&!l?t.push(r):r.decompose(e-a,A-a,t,l)}a=s+1}}replace(e,A,t){if([e,A]=qB(this,e,A),t.lines<this.lines)for(let n=0,o=0;n<this.children.length;n++){let a=this.children[n],r=o+a.length;if(e>=o&&A<=r){let s=a.replace(e-o,A-o,t),l=this.lines-a.lines+s.lines;if(s.lines<l>>4&&s.lines>l>>6){let g=this.children.slice();return g[n]=s,new i(g,this.length-(A-e)+t.length)}return super.replace(o,r,s)}o=r+1}return super.replace(e,A,t)}sliceString(e,A=this.length,t=` |
| 247 | `){[e,A]=qB(this,e,A);let n="";for(let o=0,a=0;o<this.children.length&&a<=A;o++){let r=this.children[o],s=a+r.length;a>e&&o&&(n+=t),e<s&&A>a&&(n+=r.sliceString(e-a,A-a,t)),a=s+1}return n}flatten(e){for(let A of this.children)A.flatten(e)}scanIdentical(e,A){if(!(e instanceof i))return 0;let t=0,[n,o,a,r]=A>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=A,o+=A){if(n==a||o==r)return t;let s=this.children[n],l=e.children[o];if(s!=l)return t+s.scanIdentical(l,A);t+=s.length+1}}static from(e,A=e.reduce((t,n)=>t+n.length+1,-1)){let t=0;for(let B of e)t+=B.lines;if(t<32){let B=[];for(let u of e)u.flatten(B);return new xl(B,A)}let n=Math.max(32,t>>5),o=n<<1,a=n>>1,r=[],s=0,l=-1,g=[];function C(B){let u;if(B.lines>o&&B instanceof i)for(let E of B.children)C(E);else B.lines>a&&(s>a||!s)?(d(),r.push(B)):B instanceof xl&&s&&(u=g[g.length-1])instanceof xl&&B.lines+u.lines<=32?(s+=B.lines,l+=B.length+1,g[g.length-1]=new xl(u.text.concat(B.text),u.length+1+B.length)):(s+B.lines>n&&d(),s+=B.lines,l+=B.length+1,g.push(B))}function d(){s!=0&&(r.push(g.length==1?g[0]:i.from(g,l)),l=-1,s=g.length=0)}for(let B of e)C(B);return d(),r.length==1?r[0]:new i(r,A)}};On.empty=new xl([""],0);function _gA(i){let e=-1;for(let A of i)e+=A.length+1;return e}function k6(i,e,A=0,t=1e9){for(let n=0,o=0,a=!0;o<i.length&&n<=t;o++){let r=i[o],s=n+r.length;s>=A&&(s>t&&(r=r.slice(0,t-n)),n<A&&(r=r.slice(A-n)),a?(e[e.length-1]+=r,a=!1):e.push(r)),n=s+1}return e}function bJ(i,e,A){return k6(i,[""],e,A)}var Qd=class{constructor(e,A=1){this.dir=A,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[A>0?1:(e instanceof xl?e.text.length:e.children.length)<<1]}nextInner(e,A){for(this.done=this.lineBreak=!1;;){let t=this.nodes.length-1,n=this.nodes[t],o=this.offsets[t],a=o>>1,r=n instanceof xl?n.text.length:n.children.length;if(a==(A>0?r:0)){if(t==0)return this.done=!0,this.value="",this;A>0&&this.offsets[t-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(A>0?0:1)){if(this.offsets[t]+=A,e==0)return this.lineBreak=!0,this.value=` |
| 248 | `,this;e--}else if(n instanceof xl){let s=n.text[a+(A<0?-1:0)];if(this.offsets[t]+=A,s.length>Math.max(0,e))return this.value=e==0?s:A>0?s.slice(e):s.slice(0,s.length-e),this;e-=s.length}else{let s=n.children[a+(A<0?-1:0)];e>s.length?(e-=s.length,this.offsets[t]+=A):(A<0&&this.offsets[t]--,this.nodes.push(s),this.offsets.push(A>0?1:(s instanceof xl?s.text.length:s.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},_6=class{constructor(e,A,t){this.value="",this.done=!1,this.cursor=new Qd(e,A>t?-1:1),this.pos=A>t?e.length:0,this.from=Math.min(A,t),this.to=Math.max(A,t)}nextInner(e,A){if(A<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,A<0?this.pos-this.to:this.from-this.pos);let t=A<0?this.pos-this.from:this.to-this.pos;e>t&&(e=t),t-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*A,this.value=n.length<=t?n:A<0?n.slice(n.length-t):n.slice(0,t),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!=""}},x6=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:A,lineBreak:t,value:n}=this.inner.next(e);return A&&this.afterBreak?(this.value="",this.afterBreak=!1):A?(this.done=!0,this.value=""):t?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(On.prototype[Symbol.iterator]=function(){return this.iter()},Qd.prototype[Symbol.iterator]=_6.prototype[Symbol.iterator]=x6.prototype[Symbol.iterator]=function(){return this});var PM=class{constructor(e,A,t,n){this.from=e,this.to=A,this.number=t,this.text=n}get length(){return this.to-this.from}};function qB(i,e,A){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,A))]}function tr(i,e,A=!0,t=!0){return wJ(i,e,A,t)}function xgA(i){return i>=56320&&i<57344}function RgA(i){return i>=55296&&i<56320}function $r(i,e){let A=i.charCodeAt(e);if(!RgA(A)||e+1==i.length)return A;let t=i.charCodeAt(e+1);return xgA(t)?(A-55296<<10)+(t-56320)+65536:A}function qu(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Rl(i){return i<65536?1:2}var jM=/\r\n?|\n/,Wr=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(Wr||(Wr={})),v2=class i{constructor(e){this.sections=e}get length(){let e=0;for(let A=0;A<this.sections.length;A+=2)e+=this.sections[A];return e}get newLength(){let e=0;for(let A=0;A<this.sections.length;A+=2){let t=this.sections[A+1];e+=t<0?this.sections[A]:t}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let A=0,t=0,n=0;A<this.sections.length;){let o=this.sections[A++],a=this.sections[A++];a<0?(e(t,n,o),n+=o):n+=a,t+=o}}iterChangedRanges(e,A=!1){VM(this,e,A)}get invertedDesc(){let e=[];for(let A=0;A<this.sections.length;){let t=this.sections[A++],n=this.sections[A++];n<0?e.push(t,n):e.push(n,t)}return new i(e)}composeDesc(e){return this.empty?e:e.empty?this:NJ(this,e)}mapDesc(e,A=!1){return e.empty?this:qM(this,e,A)}mapPos(e,A=-1,t=Wr.Simple){let n=0,o=0;for(let a=0;a<this.sections.length;){let r=this.sections[a++],s=this.sections[a++],l=n+r;if(s<0){if(l>e)return o+(e-n);o+=r}else{if(t!=Wr.Simple&&l>=e&&(t==Wr.TrackDel&&n<e&&l>e||t==Wr.TrackBefore&&n<e||t==Wr.TrackAfter&&l>e))return null;if(l>e||l==e&&A<0&&!r)return e==n||A<0?o:o+s;o+=s}n=l}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return o}touchesRange(e,A=e){for(let t=0,n=0;t<this.sections.length&&n<=A;){let o=this.sections[t++],a=this.sections[t++],r=n+o;if(a>=0&&n<=A&&r>=e)return n<e&&r>A?"cover":!0;n=r}return!1}toString(){let e="";for(let A=0;A<this.sections.length;){let t=this.sections[A++],n=this.sections[A++];e+=(e?" ":"")+t+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(A=>typeof A!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new i(e)}static create(e){return new i(e)}},Zr=class i extends v2{constructor(e,A){super(e),this.inserted=A}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return VM(this,(A,t,n,o,a)=>e=e.replace(n,n+(t-A),a),!1),e}mapDesc(e,A=!1){return qM(this,e,A,!0)}invert(e){let A=this.sections.slice(),t=[];for(let n=0,o=0;n<A.length;n+=2){let a=A[n],r=A[n+1];if(r>=0){A[n]=r,A[n+1]=a;let s=n>>1;for(;t.length<s;)t.push(On.empty);t.push(a?e.slice(o,o+a):On.empty)}o+=a}return new i(A,t)}compose(e){return this.empty?e:e.empty?this:NJ(this,e,!0)}map(e,A=!1){return e.empty?this:qM(this,e,A,!0)}iterChanges(e,A=!1){VM(this,e,A)}get desc(){return v2.create(this.sections)}filter(e){let A=[],t=[],n=[],o=new ud(this);A:for(let a=0,r=0;;){let s=a==e.length?1e9:e[a++];for(;r<s||r==s&&o.len==0;){if(o.done)break A;let g=Math.min(o.len,s-r);ws(n,g,-1);let C=o.ins==-1?-1:o.off==0?o.ins:0;ws(A,g,C),C>0&&D2(t,A,o.text),o.forward(g),r+=g}let l=e[a++];for(;r<l;){if(o.done)break A;let g=Math.min(o.len,l-r);ws(A,g,-1),ws(n,g,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(g),r+=g}}return{changes:new i(A,t),filtered:v2.create(n)}}toJSON(){let e=[];for(let A=0;A<this.sections.length;A+=2){let t=this.sections[A],n=this.sections[A+1];n<0?e.push(t):n==0?e.push([t]):e.push([t].concat(this.inserted[A>>1].toJSON()))}return e}static of(e,A,t){let n=[],o=[],a=0,r=null;function s(g=!1){if(!g&&!n.length)return;a<A&&ws(n,A-a,-1);let C=new i(n,o);r=r?r.compose(C.map(r)):C,n=[],o=[],a=0}function l(g){if(Array.isArray(g))for(let C of g)l(C);else if(g instanceof i){if(g.length!=A)throw new RangeError(`Mismatched change set length (got ${g.length}, expected ${A})`);s(),r=r?r.compose(g.map(r)):g}else{let{from:C,to:d=C,insert:B}=g;if(C>d||C<0||d>A)throw new RangeError(`Invalid change range ${C} to ${d} (in doc of length ${A})`);let u=B?typeof B=="string"?On.of(B.split(t||jM)):B:On.empty,E=u.length;if(C==d&&E==0)return;C<a&&s(),C>a&&ws(n,C-a,-1),ws(n,d-C,E),D2(o,n,u),a=d}}return l(e),s(!r),r}static empty(e){return new i(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let A=[],t=[];for(let n=0;n<e.length;n++){let o=e[n];if(typeof o=="number")A.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((a,r)=>r&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)A.push(o[0],0);else{for(;t.length<n;)t.push(On.empty);t[n]=On.of(o.slice(1)),A.push(o[0],t[n].length)}}}return new i(A,t)}static createSet(e,A){return new i(e,A)}};function ws(i,e,A,t=!1){if(e==0&&A<=0)return;let n=i.length-2;n>=0&&A<=0&&A==i[n+1]?i[n]+=e:n>=0&&e==0&&i[n]==0?i[n+1]+=A:t?(i[n]+=e,i[n+1]+=A):i.push(e,A)}function D2(i,e,A){if(A.length==0)return;let t=e.length-2>>1;if(t<i.length)i[i.length-1]=i[i.length-1].append(A);else{for(;i.length<t;)i.push(On.empty);i.push(A)}}function VM(i,e,A){let t=i.inserted;for(let n=0,o=0,a=0;a<i.sections.length;){let r=i.sections[a++],s=i.sections[a++];if(s<0)n+=r,o+=r;else{let l=n,g=o,C=On.empty;for(;l+=r,g+=s,s&&t&&(C=C.append(t[a-2>>1])),!(A||a==i.sections.length||i.sections[a+1]<0);)r=i.sections[a++],s=i.sections[a++];e(n,l,o,g,C),n=l,o=g}}}function qM(i,e,A,t=!1){let n=[],o=t?[]:null,a=new ud(i),r=new ud(e);for(let s=-1;;){if(a.done&&r.len||r.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&r.ins==-1){let l=Math.min(a.len,r.len);ws(n,l,-1),a.forward(l),r.forward(l)}else if(r.ins>=0&&(a.ins<0||s==a.i||a.off==0&&(r.len<a.len||r.len==a.len&&!A))){let l=r.len;for(ws(n,r.ins,-1);l;){let g=Math.min(a.len,l);a.ins>=0&&s<a.i&&a.len<=g&&(ws(n,0,a.ins),o&&D2(o,n,a.text),s=a.i),a.forward(g),l-=g}r.next()}else if(a.ins>=0){let l=0,g=a.len;for(;g;)if(r.ins==-1){let C=Math.min(g,r.len);l+=C,g-=C,r.forward(C)}else if(r.ins==0&&r.len<g)g-=r.len,r.next();else break;ws(n,l,s<a.i?a.ins:0),o&&s<a.i&&D2(o,n,a.text),s=a.i,a.forward(a.len-g)}else{if(a.done&&r.done)return o?Zr.createSet(n,o):v2.create(n);throw new Error("Mismatched change set lengths")}}}function NJ(i,e,A=!1){let t=[],n=A?[]:null,o=new ud(i),a=new ud(e);for(let r=!1;;){if(o.done&&a.done)return n?Zr.createSet(t,n):v2.create(t);if(o.ins==0)ws(t,o.len,0,r),o.next();else if(a.len==0&&!a.done)ws(t,0,a.ins,r),n&&D2(n,t,a.text),a.next();else{if(o.done||a.done)throw new Error("Mismatched change set lengths");{let s=Math.min(o.len2,a.len),l=t.length;if(o.ins==-1){let g=a.ins==-1?-1:a.off?0:a.ins;ws(t,s,g,r),n&&g&&D2(n,t,a.text)}else a.ins==-1?(ws(t,o.off?0:o.len,s,r),n&&D2(n,t,o.textBit(s))):(ws(t,o.off?0:o.len,a.off?0:a.ins,r),n&&!a.off&&D2(n,t,a.text));r=(o.ins>s||a.ins>=0&&a.len>s)&&(r||t.length>l),o.forward2(s),a.forward(s)}}}}var ud=class{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,A=this.i-2>>1;return A>=e.length?On.empty:e[A]}textBit(e){let{inserted:A}=this.set,t=this.i-2>>1;return t>=A.length&&!e?On.empty:A[t].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)}},zB=class i{constructor(e,A,t){this.from=e,this.to=A,this.flags=t}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,A=-1){let t,n;return this.empty?t=n=e.mapPos(this.from,A):(t=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),t==this.from&&n==this.to?this:new i(t,n,this.flags)}extend(e,A=e,t=0){if(e<=this.anchor&&A>=this.anchor)return Be.range(e,A,void 0,void 0,t);let n=Math.abs(e-this.anchor)>Math.abs(A-this.anchor)?e:A;return Be.range(this.anchor,n,void 0,void 0,t)}eq(e,A=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!A||!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 Be.range(e.anchor,e.head)}static create(e,A,t){return new i(e,A,t)}},Be=class i{constructor(e,A){this.ranges=e,this.mainIndex=A}map(e,A=-1){return e.empty?this:i.create(this.ranges.map(t=>t.map(e,A)),this.mainIndex)}eq(e,A=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t],A))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new i([this.main],0)}addRange(e,A=!0){return i.create([e].concat(this.ranges),A?0:this.mainIndex+1)}replaceRange(e,A=this.mainIndex){let t=this.ranges.slice();return t[A]=e,i.create(t,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 i(e.ranges.map(A=>zB.fromJSON(A)),e.main)}static single(e,A=e){return new i([i.range(e,A)],0)}static create(e,A=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let t=0,n=0;n<e.length;n++){let o=e[n];if(o.empty?o.from<=t:o.from<t)return i.normalized(e.slice(),A);t=o.to}return new i(e,A)}static cursor(e,A=0,t,n){return zB.create(e,e,(A==0?0:A<0?8:16)|(t==null?7:Math.min(6,t))|(n??16777215)<<6)}static range(e,A,t,n,o){let a=(t??16777215)<<6|(n==null?7:Math.min(6,n));return!o&&e!=A&&(o=A<e?1:-1),A<e?zB.create(A,e,48|a):zB.create(e,A,(o?o<0?8:16:0)|a)}static normalized(e,A=0){let t=e[A];e.sort((n,o)=>n.from-o.from),A=e.indexOf(t);for(let n=1;n<e.length;n++){let o=e[n],a=e[n-1];if(o.empty?o.from<=a.to:o.from<a.to){let r=a.from,s=Math.max(o.to,a.to);n<=A&&A--,e.splice(--n,2,o.anchor>o.head?i.range(s,r):i.range(r,s))}}return new i(e,A)}};function FJ(i,e){for(let A of i.ranges)if(A.to>e)throw new RangeError("Selection points outside of document")}var n9=0,nt=class i{constructor(e,A,t,n,o){this.combine=e,this.compareInput=A,this.compare=t,this.isStatic=n,this.id=n9++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new i(e.combine||(A=>A),e.compareInput||((A,t)=>A===t),e.compare||(e.combine?(A,t)=>A===t:o9),!!e.static,e.enables)}of(e){return new jB([],this,0,e)}compute(e,A){if(this.isStatic)throw new Error("Can't compute a static facet");return new jB(e,this,1,A)}computeN(e,A){if(this.isStatic)throw new Error("Can't compute a static facet");return new jB(e,this,2,A)}from(e,A){return A||(A=t=>t),this.compute([e],t=>A(t.field(e)))}};function o9(i,e){return i==e||i.length==e.length&&i.every((A,t)=>A===e[t])}var jB=class{constructor(e,A,t,n){this.dependencies=e,this.facet=A,this.type=t,this.value=n,this.id=n9++}dynamicSlot(e){var A;let t=this.value,n=this.facet.compareInput,o=this.id,a=e[o]>>1,r=this.type==2,s=!1,l=!1,g=[];for(let C of this.dependencies)C=="doc"?s=!0:C=="selection"?l=!0:(((A=e[C.id])!==null&&A!==void 0?A:1)&1)==0&&g.push(e[C.id]);return{create(C){return C.values[a]=t(C),1},update(C,d){if(s&&d.docChanged||l&&(d.docChanged||d.selection)||WM(C,g)){let B=t(C);if(r?!MJ(B,C.values[a],n):!n(B,C.values[a]))return C.values[a]=B,1}return 0},reconfigure:(C,d)=>{let B,u=d.config.address[o];if(u!=null){let E=F6(d,u);if(this.dependencies.every(f=>f instanceof nt?d.facet(f)===C.facet(f):f instanceof La?d.field(f,!1)==C.field(f,!1):!0)||(r?MJ(B=t(C),E,n):n(B=t(C),E)))return C.values[a]=E,0}else B=t(C);return C.values[a]=B,1}}}};function MJ(i,e,A){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!A(i[t],e[t]))return!1;return!0}function WM(i,e){let A=!1;for(let t of e)zu(i,t)&1&&(A=!0);return A}function NgA(i,e,A){let t=A.map(s=>i[s.id]),n=A.map(s=>s.type),o=t.filter(s=>!(s&1)),a=i[e.id]>>1;function r(s){let l=[];for(let g=0;g<t.length;g++){let C=F6(s,t[g]);if(n[g]==2)for(let d of C)l.push(d);else l.push(C)}return e.combine(l)}return{create(s){for(let l of t)zu(s,l);return s.values[a]=r(s),1},update(s,l){if(!WM(s,o))return 0;let g=r(s);return e.compare(g,s.values[a])?0:(s.values[a]=g,1)},reconfigure(s,l){let g=WM(s,t),C=l.config.facets[e.id],d=l.facet(e);if(C&&!g&&o9(A,C))return s.values[a]=d,0;let B=r(s);return e.compare(B,d)?(s.values[a]=d,0):(s.values[a]=B,1)}}}var b6=nt.define({static:!0}),La=class i{constructor(e,A,t,n,o){this.id=e,this.createF=A,this.updateF=t,this.compareF=n,this.spec=o,this.provides=void 0}static define(e){let A=new i(n9++,e.create,e.update,e.compare||((t,n)=>t===n),e);return e.provide&&(A.provides=e.provide(A)),A}create(e){let A=e.facet(b6).find(t=>t.field==this);return(A?.create||this.createF)(e)}slot(e){let A=e[this.id]>>1;return{create:t=>(t.values[A]=this.create(t),1),update:(t,n)=>{let o=t.values[A],a=this.updateF(o,n);return this.compareF(o,a)?0:(t.values[A]=a,1)},reconfigure:(t,n)=>{let o=t.facet(b6),a=n.facet(b6),r;return(r=o.find(s=>s.field==this))&&r!=a.find(s=>s.field==this)?(t.values[A]=r.create(t),1):n.config.address[this.id]!=null?(t.values[A]=n.field(this),0):(t.values[A]=this.create(t),1)}}}init(e){return[this,b6.of({field:this,create:e})]}get extension(){return this}},hd={lowest:4,low:3,default:2,high:1,highest:0};function Hu(i){return e=>new R6(e,i)}var oc={highest:Hu(hd.highest),high:Hu(hd.high),default:Hu(hd.default),low:Hu(hd.low),lowest:Hu(hd.lowest)},R6=class{constructor(e,A){this.inner=e,this.prec=A}},g0=class i{of(e){return new Pu(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Pu=class{constructor(e,A){this.compartment=e,this.inner=A}},N6=class i{constructor(e,A,t,n,o,a){for(this.base=e,this.compartments=A,this.dynamicSlots=t,this.address=n,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<t.length;)this.statusTemplate.push(0)}staticFacet(e){let A=this.address[e.id];return A==null?e.default:this.staticValues[A>>1]}static resolve(e,A,t){let n=[],o=Object.create(null),a=new Map;for(let d of FgA(e,A,a))d instanceof La?n.push(d):(o[d.facet.id]||(o[d.facet.id]=[])).push(d);let r=Object.create(null),s=[],l=[];for(let d of n)r[d.id]=l.length<<1,l.push(B=>d.slot(B));let g=t?.config.facets;for(let d in o){let B=o[d],u=B[0].facet,E=g&&g[d]||[];if(B.every(f=>f.type==0))if(r[u.id]=s.length<<1|1,o9(E,B))s.push(t.facet(u));else{let f=u.combine(B.map(m=>m.value));s.push(t&&u.compare(f,t.facet(u))?t.facet(u):f)}else{for(let f of B)f.type==0?(r[f.id]=s.length<<1|1,s.push(f.value)):(r[f.id]=l.length<<1,l.push(m=>f.dynamicSlot(m)));r[u.id]=l.length<<1,l.push(f=>NgA(f,u,B))}}let C=l.map(d=>d(r));return new i(e,a,C,r,s,o)}};function FgA(i,e,A){let t=[[],[],[],[],[]],n=new Map;function o(a,r){let s=n.get(a);if(s!=null){if(s<=r)return;let l=t[s].indexOf(a);l>-1&&t[s].splice(l,1),a instanceof Pu&&A.delete(a.compartment)}if(n.set(a,r),Array.isArray(a))for(let l of a)o(l,r);else if(a instanceof Pu){if(A.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let l=e.get(a.compartment)||a.inner;A.set(a.compartment,l),o(l,r)}else if(a instanceof R6)o(a.inner,a.prec);else if(a instanceof La)t[r].push(a),a.provides&&o(a.provides,r);else if(a instanceof jB)t[r].push(a),a.facet.extensions&&o(a.facet.extensions,hd.default);else{let l=a.extension;if(!l)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(l,r)}}return o(i,hd.default),t.reduce((a,r)=>a.concat(r))}function zu(i,e){if(e&1)return 2;let A=e>>1,t=i.status[A];if(t==4)throw new Error("Cyclic dependency between fields and/or facets");if(t&2)return t;i.status[A]=4;let n=i.computeSlot(i,i.config.dynamicSlots[A]);return i.status[A]=2|n}function F6(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var SJ=nt.define(),HM=nt.define({combine:i=>i.some(e=>e),static:!0}),LJ=nt.define({combine:i=>i.length?i[0]:void 0,static:!0}),GJ=nt.define(),KJ=nt.define(),UJ=nt.define(),kJ=nt.define({combine:i=>i.length?i[0]:!1}),sl=class{constructor(e,A){this.type=e,this.value=A}static define(){return new ZM}},ZM=class{of(e){return new sl(this,e)}},XM=class{constructor(e){this.map=e}of(e){return new ln(this,e)}},ln=(()=>{class i{constructor(A,t){this.type=A,this.value=t}map(A){let t=this.type.map(this.value,A);return t===void 0?void 0:t==this.value?this:new i(this.type,t)}is(A){return this.type==A}static define(A={}){return new XM(A.map||(t=>t))}static mapEffects(A,t){if(!A.length)return A;let n=[];for(let o of A){let a=o.map(t);a&&n.push(a)}return n}}return i.reconfigure=i.define(),i.appendConfig=i.define(),i})(),l0=(()=>{class i{constructor(A,t,n,o,a,r){this.startState=A,this.changes=t,this.selection=n,this.effects=o,this.annotations=a,this.scrollIntoView=r,this._doc=null,this._state=null,n&&FJ(n,t.newLength),a.some(s=>s.type==i.time)||(this.annotations=a.concat(i.time.of(Date.now())))}static create(A,t,n,o,a,r){return new i(A,t,n,o,a,r)}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(A){for(let t of this.annotations)if(t.type==A)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(A){let t=this.annotation(i.userEvent);return!!(t&&(t==A||t.length>A.length&&t.slice(0,A.length)==A&&t[A.length]=="."))}}return i.time=sl.define(),i.userEvent=sl.define(),i.addToHistory=sl.define(),i.remote=sl.define(),i})();function LgA(i,e){let A=[];for(let t=0,n=0;;){let o,a;if(t<i.length&&(n==e.length||e[n]>=i[t]))o=i[t++],a=i[t++];else if(n<e.length)o=e[n++],a=e[n++];else return A;!A.length||A[A.length-1]<o?A.push(o,a):A[A.length-1]<a&&(A[A.length-1]=a)}}function TJ(i,e,A){var t;let n,o,a;return A?(n=e.changes,o=Zr.empty(e.changes.length),a=i.changes.compose(e.changes)):(n=e.changes.map(i.changes),o=i.changes.mapDesc(e.changes,!0),a=i.changes.compose(n)),{changes:a,selection:e.selection?e.selection.map(o):(t=i.selection)===null||t===void 0?void 0:t.map(n),effects:ln.mapEffects(i.effects,n).concat(ln.mapEffects(e.effects,o)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function $M(i,e,A){let t=e.selection,n=VB(e.annotations);return e.userEvent&&(n=n.concat(l0.userEvent.of(e.userEvent))),{changes:e.changes instanceof Zr?e.changes:Zr.of(e.changes||[],A,i.facet(LJ)),selection:t&&(t instanceof Be?t:Be.single(t.anchor,t.head)),effects:VB(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function OJ(i,e,A){let t=$M(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(A=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(A=!1);let a=!!e[o].sequential;t=TJ(t,$M(i,e[o],a?t.changes.newLength:i.doc.length),a)}let n=l0.create(i,t.changes,t.selection,t.effects,t.annotations,t.scrollIntoView);return KgA(A?GgA(n):n)}function GgA(i){let e=i.startState,A=!0;for(let n of e.facet(GJ)){let o=n(i);if(o===!1){A=!1;break}Array.isArray(o)&&(A=A===!0?o:LgA(A,o))}if(A!==!0){let n,o;if(A===!1)o=i.changes.invertedDesc,n=Zr.empty(e.doc.length);else{let a=i.changes.filter(A);n=a.changes,o=a.filtered.mapDesc(a.changes).invertedDesc}i=l0.create(e,n,i.selection&&i.selection.map(o),ln.mapEffects(i.effects,o),i.annotations,i.scrollIntoView)}let t=e.facet(KJ);for(let n=t.length-1;n>=0;n--){let o=t[n](i);o instanceof l0?i=o:Array.isArray(o)&&o.length==1&&o[0]instanceof l0?i=o[0]:i=OJ(e,VB(o),!1)}return i}function KgA(i){let e=i.startState,A=e.facet(UJ),t=i;for(let n=A.length-1;n>=0;n--){let o=A[n](i);o&&Object.keys(o).length&&(t=TJ(t,$M(e,o,i.changes.newLength),!0))}return t==i?i:l0.create(e,i.changes,i.selection,t.effects,t.annotations,t.scrollIntoView)}var UgA=[];function VB(i){return i==null?UgA:Array.isArray(i)?i:[i]}var $o=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})($o||($o={})),TgA=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,A9;try{A9=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(i){}function OgA(i){if(A9)return A9.test(i);for(let e=0;e<i.length;e++){let A=i[e];if(/\w/.test(A)||A>"\x80"&&(A.toUpperCase()!=A.toLowerCase()||TgA.test(A)))return!0}return!1}function JgA(i){return e=>{if(!/\S/.test(e))return $o.Space;if(OgA(e))return $o.Word;for(let A=0;A<i.length;A++)if(e.indexOf(i[A])>-1)return $o.Word;return $o.Other}}var ir=(()=>{class i{constructor(A,t,n,o,a,r){this.config=A,this.doc=t,this.selection=n,this.values=o,this.status=A.statusTemplate.slice(),this.computeSlot=a,r&&(r._state=this);for(let s=0;s<this.config.dynamicSlots.length;s++)zu(this,s<<1);this.computeSlot=null}field(A,t=!0){let n=this.config.address[A.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return zu(this,n),F6(this,n)}update(...A){return OJ(this,A,!0)}applyTransaction(A){let t=this.config,{base:n,compartments:o}=t;for(let s of A.effects)s.is(g0.reconfigure)?(t&&(o=new Map,t.compartments.forEach((l,g)=>o.set(g,l)),t=null),o.set(s.value.compartment,s.value.extension)):s.is(ln.reconfigure)?(t=null,n=s.value):s.is(ln.appendConfig)&&(t=null,n=VB(n).concat(s.value));let a;t?a=A.startState.values.slice():(t=N6.resolve(n,o,this),a=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,g)=>g.reconfigure(l,this),null).values);let r=A.startState.facet(HM)?A.newSelection:A.newSelection.asSingle();new i(t,A.newDoc,r,a,(s,l)=>l.update(s,A),A)}replaceSelection(A){return typeof A=="string"&&(A=this.toText(A)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:A},range:Be.cursor(t.from+A.length)}))}changeByRange(A){let t=this.selection,n=A(t.ranges[0]),o=this.changes(n.changes),a=[n.range],r=VB(n.effects);for(let s=1;s<t.ranges.length;s++){let l=A(t.ranges[s]),g=this.changes(l.changes),C=g.map(o);for(let B=0;B<s;B++)a[B]=a[B].map(C);let d=o.mapDesc(g,!0);a.push(l.range.map(d)),o=o.compose(C),r=ln.mapEffects(r,C).concat(ln.mapEffects(VB(l.effects),d))}return{changes:o,selection:Be.create(a,t.mainIndex),effects:r}}changes(A=[]){return A instanceof Zr?A:Zr.of(A,this.doc.length,this.facet(i.lineSeparator))}toText(A){return On.of(A.split(this.facet(i.lineSeparator)||jM))}sliceDoc(A=0,t=this.doc.length){return this.doc.sliceString(A,t,this.lineBreak)}facet(A){let t=this.config.address[A.id];return t==null?A.default:(zu(this,t),F6(this,t))}toJSON(A){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(A)for(let n in A){let o=A[n];o instanceof La&&this.config.address[o.id]!=null&&(t[n]=o.spec.toJSON(this.field(A[n]),this))}return t}static fromJSON(A,t={},n){if(!A||typeof A.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(n){for(let a in n)if(Object.prototype.hasOwnProperty.call(A,a)){let r=n[a],s=A[a];o.push(r.init(l=>r.spec.fromJSON(s,l)))}}return i.create({doc:A.doc,selection:Be.fromJSON(A.selection),extensions:t.extensions?o.concat([t.extensions]):o})}static create(A={}){let t=N6.resolve(A.extensions||[],new Map),n=A.doc instanceof On?A.doc:On.of((A.doc||"").split(t.staticFacet(i.lineSeparator)||jM)),o=A.selection?A.selection instanceof Be?A.selection:Be.single(A.selection.anchor,A.selection.head):Be.single(0);return FJ(o,n.length),t.staticFacet(HM)||(o=o.asSingle()),new i(t,n,o,t.dynamicSlots.map(()=>null),(a,r)=>r.create(a),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||` |
| 249 | `}get readOnly(){return this.facet(kJ)}phrase(A,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,A)){A=n[A];break}return t.length&&(A=A.replace(/\$(\$|\d*)/g,(n,o)=>{if(o=="$")return"$";let a=+(o||1);return!a||a>t.length?n:t[a-1]})),A}languageDataAt(A,t,n=-1){let o=[];for(let a of this.facet(SJ))for(let r of a(this,t,n))Object.prototype.hasOwnProperty.call(r,A)&&o.push(r[A]);return o}charCategorizer(A){let t=this.languageDataAt("wordChars",A);return JgA(t.length?t[0]:"")}wordAt(A){let{text:t,from:n,length:o}=this.doc.lineAt(A),a=this.charCategorizer(A),r=A-n,s=A-n;for(;r>0;){let l=tr(t,r,!1);if(a(t.slice(l,r))!=$o.Word)break;r=l}for(;s<o;){let l=tr(t,s);if(a(t.slice(s,l))!=$o.Word)break;s=l}return r==s?null:Be.range(r+n,s+n)}}return i.allowMultipleSelections=HM,i.tabSize=nt.define({combine:e=>e.length?e[0]:4}),i.lineSeparator=LJ,i.readOnly=kJ,i.phrases=nt.define({compare(e,A){let t=Object.keys(e),n=Object.keys(A);return t.length==n.length&&t.every(o=>e[o]==A[o])}}),i.languageData=SJ,i.changeFilter=GJ,i.transactionFilter=KJ,i.transactionExtender=UJ,i})();g0.reconfigure=ln.define();function Lr(i,e,A={}){let t={};for(let n of i)for(let o of Object.keys(n)){let a=n[o],r=t[o];if(r===void 0)t[o]=a;else if(!(r===a||a===void 0))if(Object.hasOwnProperty.call(A,o))t[o]=A[o](r,a);else throw new Error("Config merge conflict for field "+o)}for(let n in e)t[n]===void 0&&(t[n]=e[n]);return t}var cg=class{eq(e){return this==e}range(e,A=e){return ju.create(e,A,this)}};cg.prototype.startSide=cg.prototype.endSide=0;cg.prototype.point=!1;cg.prototype.mapMode=Wr.TrackDel;function a9(i,e){return i==e||i.constructor==e.constructor&&i.eq(e)}var ju=class i{constructor(e,A,t){this.from=e,this.to=A,this.value=t}static create(e,A,t){return new i(e,A,t)}};function e9(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var t9=class i{constructor(e,A,t,n){this.from=e,this.to=A,this.value=t,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,A,t,n=0){let o=t?this.to:this.from;for(let a=n,r=o.length;;){if(a==r)return a;let s=a+r>>1,l=o[s]-e||(t?this.value[s].endSide:this.value[s].startSide)-A;if(s==a)return l>=0?a:r;l>=0?r=s:a=s+1}}between(e,A,t,n){for(let o=this.findIndex(A,-1e9,!0),a=this.findIndex(t,1e9,!1,o);o<a;o++)if(n(this.from[o]+e,this.to[o]+e,this.value[o])===!1)return!1}map(e,A){let t=[],n=[],o=[],a=-1,r=-1;for(let s=0;s<this.value.length;s++){let l=this.value[s],g=this.from[s]+e,C=this.to[s]+e,d,B;if(g==C){let u=A.mapPos(g,l.startSide,l.mapMode);if(u==null||(d=B=u,l.startSide!=l.endSide&&(B=A.mapPos(g,l.endSide),B<d)))continue}else if(d=A.mapPos(g,l.startSide),B=A.mapPos(C,l.endSide),d>B||d==B&&l.startSide>0&&l.endSide<=0)continue;(B-d||l.endSide-l.startSide)<0||(a<0&&(a=d),l.point&&(r=Math.max(r,B-d)),t.push(l),n.push(d-a),o.push(B-a))}return{mapped:t.length?new i(n,o,t,r):null,pos:a}}},uo=(()=>{class i{constructor(A,t,n,o){this.chunkPos=A,this.chunk=t,this.nextLayer=n,this.maxPoint=o}static create(A,t,n,o){return new i(A,t,n,o)}get length(){let A=this.chunk.length-1;return A<0?0:Math.max(this.chunkEnd(A),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let A=this.nextLayer.size;for(let t of this.chunk)A+=t.value.length;return A}chunkEnd(A){return this.chunkPos[A]+this.chunk[A].length}update(A){let{add:t=[],sort:n=!1,filterFrom:o=0,filterTo:a=this.length}=A,r=A.filter;if(t.length==0&&!r)return this;if(n&&(t=t.slice().sort(e9)),this.isEmpty)return t.length?i.of(t):this;let s=new L6(this,null,-1).goto(0),l=0,g=[],C=new Xr;for(;s.value||l<t.length;)if(l<t.length&&(s.from-t[l].from||s.startSide-t[l].value.startSide)>=0){let d=t[l++];C.addInner(d.from,d.to,d.value)||g.push(d)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(s.chunkIndex)<t[l].from)&&(!r||o>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&C.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!r||o>s.to||a<s.from||r(s.from,s.to,s.value))&&(C.addInner(s.from,s.to,s.value)||g.push(ju.create(s.from,s.to,s.value))),s.next());return C.finishInner(this.nextLayer.isEmpty&&!g.length?i.empty:this.nextLayer.update({add:g,filter:r,filterFrom:o,filterTo:a}))}map(A){if(A.empty||this.isEmpty)return this;let t=[],n=[],o=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],l=this.chunk[r],g=A.touchesRange(s,s+l.length);if(g===!1)o=Math.max(o,l.maxPoint),t.push(l),n.push(A.mapPos(s));else if(g===!0){let{mapped:C,pos:d}=l.map(s,A);C&&(o=Math.max(o,C.maxPoint),t.push(C),n.push(d))}}let a=this.nextLayer.map(A);return t.length==0?a:new i(n,t,a||i.empty,o)}between(A,t,n){if(!this.isEmpty){for(let o=0;o<this.chunk.length;o++){let a=this.chunkPos[o],r=this.chunk[o];if(t>=a&&A<=a+r.length&&r.between(a,A-a,t-a,n)===!1)return}this.nextLayer.between(A,t,n)}}iter(A=0){return Vu.from([this]).goto(A)}get isEmpty(){return this.nextLayer==this}static iter(A,t=0){return Vu.from(A).goto(t)}static compare(A,t,n,o,a=-1){let r=A.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=a),s=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=a),l=_J(r,s,n),g=new Ed(r,l,a),C=new Ed(s,l,a);n.iterGaps((d,B,u)=>xJ(g,d,C,B,u,o)),n.empty&&n.length==0&&xJ(g,0,C,0,0,o)}static eq(A,t,n=0,o){o==null&&(o=999999999);let a=A.filter(C=>!C.isEmpty&&t.indexOf(C)<0),r=t.filter(C=>!C.isEmpty&&A.indexOf(C)<0);if(a.length!=r.length)return!1;if(!a.length)return!0;let s=_J(a,r),l=new Ed(a,s,0).goto(n),g=new Ed(r,s,0).goto(n);for(;;){if(l.to!=g.to||!i9(l.active,g.active)||l.point&&(!g.point||!a9(l.point,g.point)))return!1;if(l.to>o)return!0;l.next(),g.next()}}static spans(A,t,n,o,a=-1){let r=new Ed(A,null,a).goto(t),s=t,l=r.openStart;for(;;){let g=Math.min(r.to,n);if(r.point){let C=r.activeForPoint(r.to),d=r.pointFrom<t?C.length+1:r.point.startSide<0?C.length:Math.min(C.length,l);o.point(s,g,r.point,C,d,r.pointRank),l=Math.min(r.openEnd(g),C.length)}else g>s&&(o.span(s,g,r.active,l),l=r.openEnd(g));if(r.to>n)return l+(r.point&&r.to>n?1:0);s=r.to,r.next()}}static of(A,t=!1){let n=new Xr;for(let o of A instanceof ju?[A]:t?YgA(A):A)n.add(o.from,o.to,o.value);return n.finish()}static join(A){if(!A.length)return i.empty;let t=A[A.length-1];for(let n=A.length-2;n>=0;n--)for(let o=A[n];o!=i.empty;o=o.nextLayer)t=new i(o.chunkPos,o.chunk,t,Math.max(o.maxPoint,t.maxPoint));return t}}return i.empty=new i([],[],null,-1),i})();function YgA(i){if(i.length>1)for(let e=i[0],A=1;A<i.length;A++){let t=i[A];if(e9(e,t)>0)return i.slice().sort(e9);e=t}return i}uo.empty.nextLayer=uo.empty;var Xr=class i{finishChunk(e){this.chunks.push(new t9(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,A,t){this.addInner(e,A,t)||(this.nextLayer||(this.nextLayer=new i)).add(e,A,t)}addInner(e,A,t){let n=e-this.lastTo||t.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||t.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return n<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(A-this.chunkStart),this.last=t,this.lastFrom=e,this.lastTo=A,this.value.push(t),t.point&&(this.maxPoint=Math.max(this.maxPoint,A-e)),!0)}addChunk(e,A){if((e-this.lastTo||A.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,A.maxPoint),this.chunks.push(A),this.chunkPos.push(e);let t=A.value.length-1;return this.last=A.value[t],this.lastFrom=A.from[t]+e,this.lastTo=A.to[t]+e,!0}finish(){return this.finishInner(uo.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let A=uo.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,A}};function _J(i,e,A){let t=new Map;for(let o of i)for(let a=0;a<o.chunk.length;a++)o.chunk[a].maxPoint<=0&&t.set(o.chunk[a],o.chunkPos[a]);let n=new Set;for(let o of e)for(let a=0;a<o.chunk.length;a++){let r=t.get(o.chunk[a]);r!=null&&(A?A.mapPos(r):r)==o.chunkPos[a]&&!A?.touchesRange(r,r+o.chunk[a].length)&&n.add(o.chunk[a])}return n}var L6=class{constructor(e,A,t,n=0){this.layer=e,this.skip=A,this.minPoint=t,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,A=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,A,!1),this}gotoInner(e,A,t){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<e||n.maxPoint<this.minPoint))break;this.chunkIndex++,t=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],A,!0);(!t||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,A){(this.to-e||this.endSide-A)<0&&this.gotoInner(e,A,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],A=this.layer.chunk[this.chunkIndex],t=e+A.from[this.rangeIndex];if(this.from=t,this.to=e+A.to[this.rangeIndex],this.value=A.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Vu=class i{constructor(e){this.heap=e}static from(e,A=null,t=-1){let n=[];for(let o=0;o<e.length;o++)for(let a=e[o];!a.isEmpty;a=a.nextLayer)a.maxPoint>=t&&n.push(new L6(a,A,t,o));return n.length==1?n[0]:new i(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,A=-1e9){for(let t of this.heap)t.goto(e,A);for(let t=this.heap.length>>1;t>=0;t--)zM(this.heap,t);return this.next(),this}forward(e,A){for(let t of this.heap)t.forward(e,A);for(let t=this.heap.length>>1;t>=0;t--)zM(this.heap,t);(this.to-e||this.value.endSide-A)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),zM(this.heap,0)}}};function zM(i,e){for(let A=i[e];;){let t=(e<<1)+1;if(t>=i.length)break;let n=i[t];if(t+1<i.length&&n.compare(i[t+1])>=0&&(n=i[t+1],t++),A.compare(n)<0)break;i[t]=A,i[e]=n,e=t}}var Ed=class{constructor(e,A,t){this.minPoint=t,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Vu.from(e,A,t)}goto(e,A=-1e9){return this.cursor.goto(e,A),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=A,this.openStart=-1,this.next(),this}forward(e,A){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-A)<0;)this.removeActive(this.minActive);this.cursor.forward(e,A)}removeActive(e){M6(this.active,e),M6(this.activeTo,e),M6(this.activeRank,e),this.minActive=RJ(this.active,this.activeTo)}addActive(e){let A=0,{value:t,to:n,rank:o}=this.cursor;for(;A<this.activeRank.length&&(o-this.activeRank[A]||n-this.activeTo[A])>0;)A++;S6(this.active,A,t),S6(this.activeTo,A,n),S6(this.activeRank,A,o),e&&S6(e,A,this.cursor.from),this.minActive=RJ(this.active,this.activeTo)}next(){let e=this.to,A=this.point;this.point=null;let t=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),t&&M6(t,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(t),this.cursor.next();else if(A&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=o,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=o.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(t){this.openStart=0;for(let n=t.length-1;n>=0&&t[n]<e;n--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let A=[];for(let t=this.active.length-1;t>=0&&!(this.activeRank[t]<this.pointRank);t--)(this.activeTo[t]>e||this.activeTo[t]==e&&this.active[t].endSide>=this.point.endSide)&&A.push(this.active[t]);return A.reverse()}openEnd(e){let A=0;for(let t=this.activeTo.length-1;t>=0&&this.activeTo[t]>e;t--)A++;return A}};function xJ(i,e,A,t,n,o){i.goto(e),A.goto(t);let a=t+n,r=t,s=t-e,l=!!o.boundChange;for(let g=!1;;){let C=i.to+s-A.to,d=C||i.endSide-A.endSide,B=d<0?i.to+s:A.to,u=Math.min(B,a);if(i.point||A.point?(i.point&&A.point&&a9(i.point,A.point)&&i9(i.activeForPoint(i.to),A.activeForPoint(A.to))||o.comparePoint(r,u,i.point,A.point),g=!1):(g&&o.boundChange(r),u>r&&!i9(i.active,A.active)&&o.compareRange(r,u,i.active,A.active),l&&u<a&&(C||i.openEnd(B)!=A.openEnd(B))&&(g=!0)),B>a)break;r=B,d<=0&&i.next(),d>=0&&A.next()}}function i9(i,e){if(i.length!=e.length)return!1;for(let A=0;A<i.length;A++)if(i[A]!=e[A]&&!a9(i[A],e[A]))return!1;return!0}function M6(i,e){for(let A=e,t=i.length-1;A<t;A++)i[A]=i[A+1];i.pop()}function S6(i,e,A){for(let t=i.length-1;t>=e;t--)i[t+1]=i[t];i[e]=A}function RJ(i,e){let A=-1,t=1e9;for(let n=0;n<e.length;n++)(e[n]-t||i[n].endSide-i[A].endSide)<0&&(A=n,t=e[n]);return A}function rC(i,e,A=i.length){let t=0;for(let n=0;n<A&&n<i.length;)i.charCodeAt(n)==9?(t+=e-t%e,n++):(t++,n=tr(i,n));return t}function G6(i,e,A,t){for(let n=0,o=0;;){if(o>=e)return n;if(n==i.length)break;o+=i.charCodeAt(n)==9?A-o%A:1,n=tr(i,n)}return t===!0?-1:i.length}var JJ=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),r9=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),YJ=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Cg=class{constructor(e,A){this.rules=[];let{finish:t}=A||{};function n(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function o(a,r,s,l){let g=[],C=/^@(\w+)\b/.exec(a[0]),d=C&&C[1]=="keyframes";if(C&&r==null)return s.push(a[0]+";");for(let B in r){let u=r[B];if(/&/.test(B))o(B.split(/,\s*/).map(E=>a.map(f=>E.replace(/&/,f))).reduce((E,f)=>E.concat(f)),u,s);else if(u&&typeof u=="object"){if(!C)throw new RangeError("The value of a property ("+B+") should be a primitive value.");o(n(B),u,g,d)}else u!=null&&g.push(B.replace(/_.*/,"").replace(/[A-Z]/g,E=>"-"+E.toLowerCase())+": "+u+";")}(g.length||d)&&s.push((t&&!C&&!l?a.map(t):a).join(", ")+" {"+g.join(" ")+"}")}for(let a in e)o(n(a),e[a],this.rules)}getRules(){return this.rules.join(` |
| 250 | `)}static newName(){let e=YJ[JJ]||1;return YJ[JJ]=e+1,"\u037C"+e.toString(36)}static mount(e,A,t){let n=e[r9],o=t&&t.nonce;n?o&&n.setNonce(o):n=new s9(e,o),n.mount(Array.isArray(A)?A:[A],e)}},HJ=new Map,s9=class{constructor(e,A){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let o=HJ.get(t);if(o)return e[r9]=o;this.sheet=new n.CSSStyleSheet,HJ.set(t,this)}else this.styleTag=t.createElement("style"),A&&this.styleTag.setAttribute("nonce",A);this.modules=[],e[r9]=this}mount(e,A){let t=this.sheet,n=0,o=0;for(let a=0;a<e.length;a++){let r=e[a],s=this.modules.indexOf(r);if(s<o&&s>-1&&(this.modules.splice(s,1),o--,s=-1),s==-1){if(this.modules.splice(o++,0,r),t)for(let l=0;l<r.rules.length;l++)t.insertRule(r.rules[l],n++)}else{for(;o<s;)n+=this.modules[o++].rules.length;n+=r.rules.length,o++}}if(t)A.adoptedStyleSheets.indexOf(this.sheet)<0&&(A.adoptedStyleSheets=[this.sheet,...A.adoptedStyleSheets]);else{let a="";for(let s=0;s<this.modules.length;s++)a+=this.modules[s].getRules()+` |
| 251 | `;this.styleTag.textContent=a;let r=A.head||A;this.styleTag.parentNode!=r&&r.insertBefore(this.styleTag,r.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var sC={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},WB={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HgA=typeof navigator<"u"&&/Mac/.test(navigator.platform),zgA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(lr=0;lr<10;lr++)sC[48+lr]=sC[96+lr]=String(lr);var lr;for(lr=1;lr<=24;lr++)sC[lr+111]="F"+lr;var lr;for(lr=65;lr<=90;lr++)sC[lr]=String.fromCharCode(lr+32),WB[lr]=String.fromCharCode(lr);var lr;for(K6 in sC)WB.hasOwnProperty(K6)||(WB[K6]=sC[K6]);var K6;function zJ(i){var e=HgA&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||zgA&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",A=!e&&i.key||(i.shiftKey?WB:sC)[i.keyCode]||i.key||"Unidentified";return A=="Esc"&&(A="Escape"),A=="Del"&&(A="Delete"),A=="Left"&&(A="ArrowLeft"),A=="Up"&&(A="ArrowUp"),A=="Right"&&(A="ArrowRight"),A=="Down"&&(A="ArrowDown"),A}function po(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,A=arguments[1];if(A&&typeof A=="object"&&A.nodeType==null&&!Array.isArray(A)){for(var t in A)if(Object.prototype.hasOwnProperty.call(A,t)){var n=A[t];typeof n=="string"?i.setAttribute(t,n):n!=null&&(i[t]=n)}e++}for(;e<arguments.length;e++)PJ(i,arguments[e]);return i}function PJ(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var A=0;A<e.length;A++)PJ(i,e[A]);else throw new RangeError("Unsupported child node: "+e)}var Us=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},p9=typeof document<"u"?document:{documentElement:{style:{}}},f9=/Edge\/(\d+)/.exec(Us.userAgent),NY=/MSIE \d/.test(Us.userAgent),m9=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Us.userAgent),E8=!!(NY||m9||f9),jJ=!E8&&/gecko\/(\d+)/i.test(Us.userAgent),l9=!E8&&/Chrome\/(\d+)/.exec(Us.userAgent),VJ="webkitFontSmoothing"in p9.documentElement.style,w9=!E8&&/Apple Computer/.test(Us.vendor),qJ=w9&&(/Mobile\/\w+/.test(Us.userAgent)||Us.maxTouchPoints>2),Ct={mac:qJ||/Mac/.test(Us.platform),windows:/Win/.test(Us.platform),linux:/Linux|X11/.test(Us.platform),ie:E8,ie_version:NY?p9.documentMode||6:m9?+m9[1]:f9?+f9[1]:0,gecko:jJ,gecko_version:jJ?+(/Firefox\/(\d+)/.exec(Us.userAgent)||[0,0])[1]:0,chrome:!!l9,chrome_version:l9?+l9[1]:0,ios:qJ,android:/Android\b/.test(Us.userAgent),webkit:VJ,webkit_version:VJ?+(/\bAppleWebKit\/(\d+)/.exec(Us.userAgent)||[0,0])[1]:0,safari:w9,safari_version:w9?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Us.userAgent)||[0,0])[1]:0,tabSize:p9.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function IS(i,e){for(let A in i)A=="class"&&e.class?e.class+=" "+i.class:A=="style"&&e.style?e.style+=";"+i.style:e[A]=i[A];return e}var $6=Object.create(null);function BS(i,e,A){if(i==e)return!0;i||(i=$6),e||(e=$6);let t=Object.keys(i),n=Object.keys(e);if(t.length-(A&&t.indexOf(A)>-1?1:0)!=n.length-(A&&n.indexOf(A)>-1?1:0))return!1;for(let o of t)if(o!=A&&(n.indexOf(o)==-1||i[o]!==e[o]))return!1;return!0}function PgA(i,e){for(let A=i.attributes.length-1;A>=0;A--){let t=i.attributes[A].name;e[t]==null&&i.removeAttribute(t)}for(let A in e){let t=e[A];A=="style"?i.style.cssText=t:i.getAttribute(A)!=t&&i.setAttribute(A,t)}}function WJ(i,e,A){let t=!1;if(e)for(let n in e)A&&n in A||(t=!0,n=="style"?i.style.cssText="":i.removeAttribute(n));if(A)for(let n in A)e&&e[n]==A[n]||(t=!0,n=="style"?i.style.cssText=A[n]:i.setAttribute(n,A[n]));return t}function jgA(i){let e=Object.create(null);for(let A=0;A<i.attributes.length;A++){let t=i.attributes[A];e[t.name]=t.value}return e}var gl=class{eq(e){return!1}updateDOM(e,A,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,A,t){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},As=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(As||(As={})),Lt=class extends cg{constructor(e,A,t,n){super(),this.startSide=e,this.endSide=A,this.widget=t,this.spec=n}get heightRelevant(){return!1}static mark(e){return new s4(e)}static widget(e){let A=Math.max(-1e4,Math.min(1e4,e.side||0)),t=!!e.block;return A+=t&&!e.inlineOrder?A>0?3e8:-4e8:A>0?1e8:-1e8,new wd(e,A,A,t,e.widget||null,!1)}static replace(e){let A=!!e.block,t,n;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:o,end:a}=FY(e,A);t=(o?A?-3e8:-1:5e8)-1,n=(a?A?2e8:1:-6e8)+1}return new wd(e,t,n,A,e.widget||null,!0)}static line(e){return new l4(e)}static set(e,A=!1){return uo.of(e,A)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Lt.none=uo.empty;var s4=class i extends Lt{constructor(e){let{start:A,end:t}=FY(e);super(A?-1:5e8,t?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?IS(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||$6}eq(e){return this==e||e instanceof i&&this.tagName==e.tagName&&BS(this.attrs,e.attrs)}range(e,A=e){if(e>=A)throw new RangeError("Mark decorations may not be empty");return super.range(e,A)}};s4.prototype.point=!1;var l4=class i extends Lt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&BS(this.spec.attributes,e.spec.attributes)}range(e,A=e){if(A!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,A)}};l4.prototype.mapMode=Wr.TrackBefore;l4.prototype.point=!0;var wd=class i extends Lt{constructor(e,A,t,n,o,a){super(A,t,o,e),this.block=n,this.isReplace=a,this.mapMode=n?A<=0?Wr.TrackBefore:Wr.TrackAfter:Wr.TrackDel}get type(){return this.startSide!=this.endSide?As.WidgetRange:this.startSide<=0?As.WidgetBefore:As.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&VgA(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,A=e){if(this.isReplace&&(e>A||e==A&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&A!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,A)}};wd.prototype.point=!0;function FY(i,e=!1){let{inclusiveStart:A,inclusiveEnd:t}=i;return A==null&&(A=i.inclusive),t==null&&(t=i.inclusive),{start:A??e,end:t??e}}function VgA(i,e){return i==e||!!(i&&e&&i.compare(e))}function th(i,e,A,t=0){let n=A.length-1;n>=0&&A[n]+t>=i?A[n]=Math.max(A[n],e):A.push(i,e)}var A8=class i extends cg{constructor(e,A){super(),this.tagName=e,this.attributes=A}eq(e){return e==this||e instanceof i&&this.tagName==e.tagName&&BS(this.attributes,e.attributes)}static create(e){return new i(e.tagName,e.attributes||$6)}static set(e,A=!1){return uo.of(e,A)}};A8.prototype.startSide=A8.prototype.endSide=-1;function g4(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function y9(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function $u(i,e){if(!e.anchorNode)return!1;try{return y9(i,e.anchorNode)}catch(A){return!1}}function V6(i){return i.nodeType==3?c4(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function A4(i,e,A,t){return A?ZJ(i,e,A,t,-1)||ZJ(i,e,A,t,1):!1}function S2(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function e8(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function ZJ(i,e,A,t,n){for(;;){if(i==A&&e==t)return!0;if(e==(n<0?0:cC(i))){if(i.nodeName=="DIV")return!1;let o=i.parentNode;if(!o||o.nodeType!=1)return!1;e=S2(i)+(n<0?0:1),i=o}else if(i.nodeType==1){if(i=i.childNodes[e+(n<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=n<0?cC(i):0}else return!1}}function cC(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function t8(i,e){let A=e?i.left:i.right;return{left:A,right:A,top:i.top,bottom:i.bottom}}function qgA(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function LY(i,e){let A=e.width/i.offsetWidth,t=e.height/i.offsetHeight;return(A>.995&&A<1.005||!isFinite(A)||Math.abs(e.width-i.offsetWidth)<1)&&(A=1),(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.height-i.offsetHeight)<1)&&(t=1),{scaleX:A,scaleY:t}}function WgA(i,e,A,t,n,o,a,r){let s=i.ownerDocument,l=s.defaultView||window;for(let g=i,C=!1;g&&!C;)if(g.nodeType==1){let d,B=g==s.body,u=1,E=1;if(B)d=qgA(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(C=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let v=g.getBoundingClientRect();({scaleX:u,scaleY:E}=LY(g,v)),d={left:v.left,right:v.left+g.clientWidth*u,top:v.top,bottom:v.top+g.clientHeight*E}}let f=0,m=0;if(n=="nearest")e.top<d.top?(m=e.top-(d.top+a),A>0&&e.bottom>d.bottom+m&&(m=e.bottom-d.bottom+a)):e.bottom>d.bottom&&(m=e.bottom-d.bottom+a,A<0&&e.top-m<d.top&&(m=e.top-(d.top+a)));else{let v=e.bottom-e.top,S=d.bottom-d.top;m=(n=="center"&&v<=S?e.top+v/2-S/2:n=="start"||n=="center"&&A<0?e.top-a:e.bottom-S+a)-d.top}if(t=="nearest"?e.left<d.left?(f=e.left-(d.left+o),A>0&&e.right>d.right+f&&(f=e.right-d.right+o)):e.right>d.right&&(f=e.right-d.right+o,A<0&&e.left<d.left+f&&(f=e.left-(d.left+o))):f=(t=="center"?e.left+(e.right-e.left)/2-(d.right-d.left)/2:t=="start"==r?e.left-o:e.right-(d.right-d.left)+o)-d.left,f||m)if(B)l.scrollBy(f,m);else{let v=0,S=0;if(m){let k=g.scrollTop;g.scrollTop+=m/E,S=(g.scrollTop-k)*E}if(f){let k=g.scrollLeft;g.scrollLeft+=f/u,v=(g.scrollLeft-k)*u}e={left:e.left-v,top:e.top-S,right:e.right-v,bottom:e.bottom-S},v&&Math.abs(v-f)<1&&(t="nearest"),S&&Math.abs(S-m)<1&&(n="nearest")}if(B)break;(e.top<d.top||e.bottom>d.bottom||e.left<d.left||e.right>d.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function GY(i,e=!0){let A=i.ownerDocument,t=null,n=null;for(let o=i.parentNode;o&&!(o==A.body||(!e||t)&&n);)if(o.nodeType==1)!n&&o.scrollHeight>o.clientHeight&&(n=o),e&&!t&&o.scrollWidth>o.clientWidth&&(t=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:t,y:n}}var D9=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:A,focusNode:t}=e;this.set(A,Math.min(e.anchorOffset,A?cC(A):0),t,Math.min(e.focusOffset,t?cC(t):0))}set(e,A,t,n){this.anchorNode=e,this.anchorOffset=A,this.focusNode=t,this.focusOffset=n}},pd=null;Ct.safari&&Ct.safari_version>=26&&(pd=!1);function KY(i){if(i.setActive)return i.setActive();if(pd)return i.focus(pd);let e=[];for(let A=i;A&&(e.push(A,A.scrollTop,A.scrollLeft),A!=A.ownerDocument);A=A.parentNode);if(i.focus(pd==null?{get preventScroll(){return pd={preventScroll:!0},!0}}:void 0),!pd){pd=!1;for(let A=0;A<e.length;){let t=e[A++],n=e[A++],o=e[A++];t.scrollTop!=n&&(t.scrollTop=n),t.scrollLeft!=o&&(t.scrollLeft=o)}}}var XJ;function c4(i,e,A=e){let t=XJ||(XJ=document.createRange());return t.setEnd(i,A),t.setStart(i,e),t}function ih(i,e,A,t){let n={key:e,code:e,keyCode:A,which:A,cancelable:!0};t&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=t);let o=new KeyboardEvent("keydown",n);o.synthetic=!0,i.dispatchEvent(o);let a=new KeyboardEvent("keyup",n);return a.synthetic=!0,i.dispatchEvent(a),o.defaultPrevented||a.defaultPrevented}function ZgA(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function XgA(i,e){let A=e.focusNode,t=e.focusOffset;if(!A||e.anchorNode!=A||e.anchorOffset!=t)return!1;for(t=Math.min(t,cC(A));;)if(t){if(A.nodeType!=1)return!1;let n=A.childNodes[t-1];n.contentEditable=="false"?t--:(A=n,t=cC(A))}else{if(A==i)return!0;t=S2(A),A=A.parentNode}}function UY(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function TY(i,e){for(let A=i,t=e;;){if(A.nodeType==3&&t>0)return{node:A,offset:t};if(A.nodeType==1&&t>0){if(A.contentEditable=="false")return null;A=A.childNodes[t-1],t=cC(A)}else if(A.parentNode&&!e8(A))t=S2(A),A=A.parentNode;else return null}}function OY(i,e){for(let A=i,t=e;;){if(A.nodeType==3&&t<A.nodeValue.length)return{node:A,offset:t};if(A.nodeType==1&&t<A.childNodes.length){if(A.contentEditable=="false")return null;A=A.childNodes[t],t=0}else if(A.parentNode&&!e8(A))t=S2(A)+1,A=A.parentNode;else return null}}var C0=class i{constructor(e,A,t=!0){this.node=e,this.offset=A,this.precise=t}static before(e,A){return new i(e.parentNode,S2(e),A)}static after(e,A){return new i(e.parentNode,S2(e)+1,A)}},Lo=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(Lo||(Lo={})),yd=Lo.LTR,hS=Lo.RTL;function JY(i){let e=[];for(let A=0;A<i.length;A++)e.push(1<<+i[A]);return e}var $gA=JY("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),AcA=JY("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),v9=Object.create(null),c0=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),A=i.charCodeAt(1);v9[e]=A,v9[A]=-e}function YY(i){return i<=247?$gA[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?AcA[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}var ecA=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Bg=class{get dir(){return this.level%2?hS:yd}constructor(e,A,t){this.from=e,this.to=A,this.level=t}side(e,A){return this.dir==A==e?this.to:this.from}forward(e,A){return e==(this.dir==A)}static find(e,A,t,n){let o=-1;for(let a=0;a<e.length;a++){let r=e[a];if(r.from<=A&&r.to>=A){if(r.level==t)return a;(o<0||(n!=0?n<0?r.from<A:r.to>A:e[o].level>r.level))&&(o=a)}}if(o<0)throw new RangeError("Index out of range");return o}};function HY(i,e){if(i.length!=e.length)return!1;for(let A=0;A<i.length;A++){let t=i[A],n=e[A];if(t.from!=n.from||t.to!=n.to||t.direction!=n.direction||!HY(t.inner,n.inner))return!1}return!0}var la=[];function tcA(i,e,A,t,n){for(let o=0;o<=t.length;o++){let a=o?t[o-1].to:e,r=o<t.length?t[o].from:A,s=o?256:n;for(let l=a,g=s,C=s;l<r;l++){let d=YY(i.charCodeAt(l));d==512?d=g:d==8&&C==4&&(d=16),la[l]=d==4?2:d,d&7&&(C=d),g=d}for(let l=a,g=s,C=s;l<r;l++){let d=la[l];if(d==128)l<r-1&&g==la[l+1]&&g&24?d=la[l]=g:la[l]=256;else if(d==64){let B=l+1;for(;B<r&&la[B]==64;)B++;let u=l&&g==8||B<A&&la[B]==8?C==1?1:8:256;for(let E=l;E<B;E++)la[E]=u;l=B-1}else d==8&&C==1&&(la[l]=1);g=d,d&7&&(C=d)}}}function icA(i,e,A,t,n){let o=n==1?2:1;for(let a=0,r=0,s=0;a<=t.length;a++){let l=a?t[a-1].to:e,g=a<t.length?t[a].from:A;for(let C=l,d,B,u;C<g;C++)if(B=v9[d=i.charCodeAt(C)])if(B<0){for(let E=r-3;E>=0;E-=3)if(c0[E+1]==-B){let f=c0[E+2],m=f&2?n:f&4?f&1?o:n:0;m&&(la[C]=la[c0[E]]=m),r=E;break}}else{if(c0.length==189)break;c0[r++]=C,c0[r++]=d,c0[r++]=s}else if((u=la[C])==2||u==1){let E=u==n;s=E?0:1;for(let f=r-3;f>=0;f-=3){let m=c0[f+2];if(m&2)break;if(E)c0[f+2]|=2;else{if(m&4)break;c0[f+2]|=4}}}}}function ncA(i,e,A,t){for(let n=0,o=t;n<=A.length;n++){let a=n?A[n-1].to:i,r=n<A.length?A[n].from:e;for(let s=a;s<r;){let l=la[s];if(l==256){let g=s+1;for(;;)if(g==r){if(n==A.length)break;g=A[n++].to,r=n<A.length?A[n].from:e}else if(la[g]==256)g++;else break;let C=o==1,d=(g<e?la[g]:t)==1,B=C==d?C?1:2:t;for(let u=g,E=n,f=E?A[E-1].to:i;u>s;)u==f&&(u=A[--E].from,f=E?A[E-1].to:i),la[--u]=B;s=g}else o=l,s++}}}function b9(i,e,A,t,n,o,a){let r=t%2?2:1;if(t%2==n%2)for(let s=e,l=0;s<A;){let g=!0,C=!1;if(l==o.length||s<o[l].from){let E=la[s];E!=r&&(g=!1,C=E==16)}let d=!g&&r==1?[]:null,B=g?t:t+1,u=s;A:for(;;)if(l<o.length&&u==o[l].from){if(C)break A;let E=o[l];if(!g)for(let f=E.to,m=l+1;;){if(f==A)break A;if(m<o.length&&o[m].from==f)f=o[m++].to;else{if(la[f]==r)break A;break}}if(l++,d)d.push(E);else{E.from>s&&a.push(new Bg(s,E.from,B));let f=E.direction==yd!=!(B%2);M9(i,f?t+1:t,n,E.inner,E.from,E.to,a),s=E.to}u=E.to}else{if(u==A||(g?la[u]!=r:la[u]==r))break;u++}d?b9(i,s,u,t+1,n,d,a):s<u&&a.push(new Bg(s,u,B)),s=u}else for(let s=A,l=o.length;s>e;){let g=!0,C=!1;if(!l||s>o[l-1].to){let E=la[s-1];E!=r&&(g=!1,C=E==16)}let d=!g&&r==1?[]:null,B=g?t:t+1,u=s;A:for(;;)if(l&&u==o[l-1].to){if(C)break A;let E=o[--l];if(!g)for(let f=E.from,m=l;;){if(f==e)break A;if(m&&o[m-1].to==f)f=o[--m].from;else{if(la[f-1]==r)break A;break}}if(d)d.push(E);else{E.to<s&&a.push(new Bg(E.to,s,B));let f=E.direction==yd!=!(B%2);M9(i,f?t+1:t,n,E.inner,E.from,E.to,a),s=E.from}u=E.from}else{if(u==e||(g?la[u-1]!=r:la[u-1]==r))break;u--}d?b9(i,u,s,t+1,n,d,a):u<s&&a.push(new Bg(u,s,B)),s=u}}function M9(i,e,A,t,n,o,a){let r=e%2?2:1;tcA(i,n,o,t,r),icA(i,n,o,t,r),ncA(n,o,t,r),b9(i,n,o,e,A,t,a)}function ocA(i,e,A){if(!i)return[new Bg(0,0,e==hS?1:0)];if(e==yd&&!A.length&&!ecA.test(i))return zY(i.length);if(A.length)for(;i.length>la.length;)la[la.length]=256;let t=[],n=e==yd?0:1;return M9(i,n,n,A,0,i.length,t),t}function zY(i){return[new Bg(0,i,0)]}var PY="";function acA(i,e,A,t,n){var o;let a=t.head-i.from,r=Bg.find(e,a,(o=t.bidiLevel)!==null&&o!==void 0?o:-1,t.assoc),s=e[r],l=s.side(n,A);if(a==l){let d=r+=n?1:-1;if(d<0||d>=e.length)return null;s=e[r=d],a=s.side(!n,A),l=s.side(n,A)}let g=tr(i.text,a,s.forward(n,A));(g<s.from||g>s.to)&&(g=l),PY=i.text.slice(Math.min(a,g),Math.max(a,g));let C=r==(n?e.length-1:0)?null:e[r+(n?1:-1)];return C&&g==l&&C.level+(n?0:1)<s.level?Be.cursor(C.side(!n,A)+i.from,C.forward(n,A)?1:-1,C.level):Be.cursor(g+i.from,s.forward(n,A)?-1:1,s.level)}function rcA(i,e,A){for(let t=e;t<A;t++){let n=YY(i.charCodeAt(t));if(n==1)return yd;if(n==2||n==4)return hS}return yd}var jY=nt.define(),VY=nt.define(),qY=nt.define(),WY=nt.define(),g9=nt.define(),ZY=nt.define(),XY=nt.define(),ES=nt.define(),QS=nt.define(),$J=nt.define({combine:i=>i.some(e=>e)}),$Y=nt.define({combine:i=>i.some(e=>e)}),AH=nt.define(),e4=class i{constructor(e,A="nearest",t="nearest",n=5,o=5,a=!1){this.range=e,this.y=A,this.x=t,this.yMargin=n,this.xMargin=o,this.isSnapshot=a}map(e){return e.empty?this:new i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new i(Be.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},U6=ln.define({map:(i,e)=>i.map(e)}),eH=ln.define();function Gr(i,e,A){let t=i.facet(WY);t.length?t[0](e):window.onerror&&window.onerror(String(e),A,void 0,void 0,e)||(A?console.error(A+":",e):console.error(e))}var lC=nt.define({combine:i=>i.length?i[0]:!0}),scA=0,XB=nt.define({combine(i){return i.filter((e,A)=>{for(let t=0;t<A;t++)if(i[t].plugin==e.plugin)return!1;return!0})}}),Po=class i{constructor(e,A,t,n,o){this.id=e,this.create=A,this.domEventHandlers=t,this.domEventObservers=n,this.baseExtensions=o(this),this.extension=this.baseExtensions.concat(XB.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(XB.of({plugin:this,arg:e}))}static define(e,A){let{eventHandlers:t,eventObservers:n,provide:o,decorations:a}=A||{};return new i(scA++,e,t,n,r=>{let s=[];return a&&s.push(Q8.of(l=>{let g=l.plugin(r);return g?a(g):Lt.none})),o&&s.push(o(r)),s})}static fromClass(e,A){return i.define((t,n)=>new e(t,n),A)}},t4=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let A=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(A)}catch(t){if(Gr(A.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(n){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(A){Gr(e.state,A,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var A;if(!((A=this.value)===null||A===void 0)&&A.destroy)try{this.value.destroy()}catch(t){Gr(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},AY=nt.define(),S9=nt.define(),Q8=nt.define(),tH=nt.define(),uS=nt.define(),C4=nt.define(),iH=nt.define();function eY(i,e){let A=i.state.facet(iH);if(!A.length)return A;let t=A.map(o=>o instanceof Function?o(i):o),n=[];return uo.spans(t,e.from,e.to,{point(){},span(o,a,r,s){let l=o-e.from,g=a-e.from,C=n;for(let d=r.length-1;d>=0;d--,s--){let B=r[d].spec.bidiIsolate,u;if(B==null&&(B=rcA(e.text,l,g)),s>0&&C.length&&(u=C[C.length-1]).to==l&&u.direction==B)u.to=g,C=u.inner;else{let E={from:l,to:g,direction:B,inner:[]};C.push(E),C=E.inner}}}}),n}var nH=nt.define();function pS(i){let e=0,A=0,t=0,n=0;for(let o of i.state.facet(nH)){let a=o(i);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(A=Math.max(A,a.right)),a.top!=null&&(t=Math.max(t,a.top)),a.bottom!=null&&(n=Math.max(n,a.bottom)))}return{left:e,right:A,top:t,bottom:n}}var Wu=nt.define(),rc=class i{constructor(e,A,t,n){this.fromA=e,this.toA=A,this.fromB=t,this.toB=n}join(e){return new i(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let A=e.length,t=this;for(;A>0;A--){let n=e[A-1];if(!(n.fromA>t.toA)){if(n.toA<t.fromA)break;t=t.join(n),e.splice(A-1,1)}}return e.splice(A,0,t),e}static extendWithRanges(e,A){if(A.length==0)return e;let t=[];for(let n=0,o=0,a=0;;){let r=n<e.length?e[n].fromB:1e9,s=o<A.length?A[o]:1e9,l=Math.min(r,s);if(l==1e9)break;let g=l+a,C=l,d=g;for(;;)if(o<A.length&&A[o]<=C){let B=A[o+1];o+=2,C=Math.max(C,B);for(let u=n;u<e.length&&e[u].fromB<=C;u++)a=e[u].toA-e[u].toB;d=Math.max(d,B+a)}else if(n<e.length&&e[n].fromB<=C){let B=e[n++];C=Math.max(C,B.toB),d=Math.max(d,B.toA),a=B.toA-B.toB}else break;t.push(new i(g,d,l,C))}return t}},i8=class i{constructor(e,A,t){this.view=e,this.state=A,this.transactions=t,this.flags=0,this.startState=e.state,this.changes=Zr.empty(this.startState.doc.length);for(let o of t)this.changes=this.changes.compose(o.changes);let n=[];this.changes.iterChangedRanges((o,a,r,s)=>n.push(new rc(o,a,r,s))),this.changedRanges=n}static create(e,A,t){return new i(e,A,t)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},lcA=[],_a=class{constructor(e,A,t=0){this.dom=e,this.length=A,this.flags=t,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return lcA}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let A=this.domAttrs;A&&PgA(this.dom,A)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,A=this.posAtStart){let t=A;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,A){return null}domPosFor(e,A){let t=S2(this.dom),n=this.length?e>0:A>0;return new C0(this.parent.dom,t+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof oh)return e;return null}static get(e){return e.cmTile}},nh=class extends _a{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let A=this.dom,t=null,n,o=e?.node==A?e:null,a=0;for(let r of this.children){if(r.sync(e),a+=r.length+r.breakAfter,n=t?t.nextSibling:A.firstChild,o&&n!=r.dom&&(o.written=!0),r.dom.parentNode==A)for(;n&&n!=r.dom;)n=tY(n);else A.insertBefore(r.dom,n);t=r.dom}for(n=t?t.nextSibling:A.firstChild,o&&n&&(o.written=!0);n;)n=tY(n);this.length=a}};function tY(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}var oh=class extends nh{constructor(e,A){super(A),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let A=_a.get(e);if(A&&this.owns(A))return A;e=e.parentNode}}blockTiles(e){for(let A=[],t=this,n=0,o=0;;)if(n==t.children.length){if(!A.length)return;t=t.parent,t.breakAfter&&o++,n=A.pop()}else{let a=t.children[n++];if(a instanceof gC)A.push(n),t=a,n=0;else{let r=o+a.length,s=e(a,o);if(s!==void 0)return s;o=r+a.breakAfter}}}resolveBlock(e,A){let t,n=-1,o,a=-1;if(this.blockTiles((r,s)=>{let l=s+r.length;if(e>=s&&e<=l){if(r.isWidget()&&A>=-1&&A<=1){if(r.flags&32)return!0;r.flags&16&&(t=void 0)}(s<e||e==l&&(A<-1?r.length:r.covers(1)))&&(!t||!r.isWidget()&&t.isWidget())&&(t=r,n=e-s),(l>e||e==s&&(A>1?r.length:r.covers(-1)))&&(!o||!r.isWidget()&&o.isWidget())&&(o=r,a=e-s)}}),!t&&!o)throw new Error("No tile at position "+e);return t&&A<0||!o?{tile:t,offset:n}:{tile:o,offset:a}}},gC=class i extends nh{constructor(e,A){super(e),this.wrapper=A}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,A){let t=new i(A||document.createElement(e.tagName),e);return A||(t.flags|=4),t}},ah=class i extends nh{constructor(e,A){super(e),this.attrs=A}isLine(){return!0}static start(e,A,t){let n=new i(A||document.createElement("div"),e);return(!A||!t)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,A,t){let n=null,o=-1,a=null,r=-1;function s(g,C){for(let d=0,B=0;d<g.children.length&&B<=C;d++){let u=g.children[d],E=B+u.length;E>=C&&(u.isComposite()?s(u,C-B):(!a||a.isHidden&&(A>0||t&&ccA(a,u)))&&(E>C||u.flags&32)?(a=u,r=C-B):(B<C||u.flags&16&&!u.isHidden)&&(n=u,o=C-B)),B=E}}s(this,e);let l=(A<0?n:a)||n||a;return l?{tile:l,offset:l==n?o:r}:null}coordsIn(e,A){let t=this.resolveInline(e,A,!0);return t?t.tile.coordsIn(Math.max(0,t.offset),A):gcA(this)}domIn(e,A){let t=this.resolveInline(e,A);if(t){let{tile:n,offset:o}=t;if(this.dom.contains(n.dom))return n.isText()?new C0(n.dom,Math.min(n.dom.nodeValue.length,o)):n.domPosFor(o,n.flags&16?1:n.flags&32?-1:A);let a=t.tile.parent,r=!1;for(let s of a.children){if(r)return new C0(s.dom,0);s==t.tile&&(r=!0)}}return new C0(this.dom,0)}};function gcA(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let A=V6(e);return A[A.length-1]||null}function ccA(i,e){let A=i.coordsIn(0,1),t=e.coordsIn(0,1);return A&&t&&t.top<A.bottom}var ll=class i extends nh{constructor(e,A){super(e),this.mark=A}get domAttrs(){return this.mark.attrs}static of(e,A){let t=new i(A||document.createElement(e.tagName),e);return A||(t.flags|=4),t}},fd=class i extends _a{constructor(e,A){super(e,A.length),this.text=A}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,A){let t=this.dom.nodeValue.length;e>t&&(e=t);let n=e,o=e,a=0;e==0&&A<0||e==t&&A>=0?Ct.chrome||Ct.gecko||(e?(n--,a=1):o<t&&(o++,a=-1)):A<0?n--:o<t&&o++;let r=c4(this.dom,n,o).getClientRects();if(!r.length)return null;let s=r[(a?a<0:A>=0)?0:r.length-1];return Ct.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(r,l=>l.width)||s),a?t8(s,a<0):s||null}static of(e,A){let t=new i(A||document.createTextNode(e),e);return A||(t.flags|=2),t}},Dd=class i extends _a{constructor(e,A,t,n){super(e,A,n),this.widget=t}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,A){return this.coordsInWidget(e,A,!1)}coordsInWidget(e,A,t){let n=this.widget.coordsAt(this.dom,e,A);if(n)return n;if(t)return t8(this.dom.getBoundingClientRect(),this.length?e==0:A<=0);{let o=this.dom.getClientRects(),a=null;if(!o.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let s=r?o.length-1:0;a=o[s],!(e>0?s==0:s==o.length-1||a.top<a.bottom);s+=r?-1:1);return t8(a,!r)}}get overrideDOMText(){if(!this.length)return On.empty;let{root:e}=this;if(!e)return On.empty;let A=this.posAtStart;return e.view.state.doc.slice(A,A+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,A,t,n,o){return o||(o=e.toDOM(A),e.editable||(o.contentEditable="false")),new i(o,t,e,n)}},rh=class extends _a{constructor(e){let A=document.createElement("img");A.className="cm-widgetBuffer",A.setAttribute("aria-hidden","true"),super(A,0,e)}get isHidden(){return!0}get overrideDOMText(){return On.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},k9=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,A,t){let{tile:n,index:o,beforeBreak:a,parents:r}=this;for(;e||A>0;)if(n.isComposite())if(a){if(!e)break;t&&t.break(),e--,a=!1}else if(o==n.children.length){if(!e&&!r.length)break;t&&t.leave(n),a=!!n.breakAfter,{tile:n,index:o}=r.pop(),o++}else{let s=n.children[o],l=s.breakAfter;(A>0?s.length<=e:s.length<e)&&(!t||t.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!l,o++,e-=s.length):(r.push({tile:n,index:o}),n=s,o=0,t&&s.isComposite()&&t.enter(s))}else if(o==n.length)a=!!n.breakAfter,{tile:n,index:o}=r.pop(),o++;else if(e){let s=Math.min(e,n.length-o);t&&t.skip(n,o,o+s),e-=s,o+=s}else break;return this.tile=n,this.index=o,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},_9=class{constructor(e,A,t,n){this.from=e,this.to=A,this.wrapper=t,this.rank=n}},x9=class{constructor(e,A,t){this.cache=e,this.root=A,this.blockWrappers=t,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,A,t,n){var o;this.flushBuffer();let a=this.ensureMarks(A,t),r=a.lastChild;if(r&&r.isText()&&!(r.flags&8)&&r.length+e.length<512){this.cache.reused.set(r,2);let s=a.children[a.children.length-1]=new fd(r.dom,r.text+e);s.parent=a}else a.append(n||fd.of(e,(o=this.cache.find(fd))===null||o===void 0?void 0:o.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,A){let t=this.curLine;t.dom!=A.line.dom&&(t.setDOM(this.cache.reused.has(A.line)?c9(A.line.dom):A.line.dom),this.cache.reused.set(A.line,2));let n=t;for(let r=A.marks.length-1;r>=0;r--){let s=A.marks[r],l=n.lastChild;if(l instanceof ll&&l.mark.eq(s.mark))l.dom!=s.dom&&l.setDOM(c9(s.dom)),n=l;else{if(this.cache.reused.get(s)){let C=_a.get(s.dom);C&&C.setDOM(c9(s.dom))}let g=ll.of(s.mark,s.dom);n.append(g),n=g}this.cache.reused.set(s,2)}let o=_a.get(e.text);o&&this.cache.reused.set(o,2);let a=new fd(e.text,e.text.nodeValue);a.flags|=8,n.append(a)}addInlineWidget(e,A,t){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let o=this.ensureMarks(A,t);!n&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,A,t){this.flushBuffer(),this.ensureMarks(A,t).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let A=this.afterWidget||this.lastBlock;A.length+=e,this.pos+=e}addLineStart(e,A){var t;e||(e=oH);let n=ah.start(e,A||((t=this.cache.find(ah))===null||t===void 0?void 0:t.dom),!!A);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,A){var t;let n=this.curLine;for(let o=e.length-1;o>=0;o--){let a=e[o],r;if(A>0&&(r=n.lastChild)&&r instanceof ll&&r.mark.eq(a))n=r,A--;else{let s=ll.of(a,(t=this.cache.find(ll,l=>l.mark.eq(a)))===null||t===void 0?void 0:t.dom);n.append(s),n=s,A=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!iY(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ct.ios&&iY(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(C9,0,32)||new Dd(C9.toDOM(),0,C9,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let A=new _9(e.from,e.to,e.value,e.rank),t=this.wrappers.length;for(;t>0&&(this.wrappers[t-1].rank-A.rank||this.wrappers[t-1].to-A.to)<0;)t--;this.wrappers.splice(t,0,A)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let A=this.root;for(let t of this.wrappers){let n=A.lastChild;if(t.from<this.pos&&n instanceof gC&&n.wrapper.eq(t.wrapper))A=n;else{let o=gC.of(t.wrapper,(e=this.cache.find(gC,a=>a.wrapper.eq(t.wrapper)))===null||e===void 0?void 0:e.dom);A.append(o),A=o}}return A}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let A=2|(e<0?16:32),t=this.cache.find(rh,void 0,1);return t&&(t.flags=A),t||new rh(A)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},R9=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:n,lineBreak:o,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=n;let r=this.textOff=Math.min(e,n.length);return o?null:n.slice(0,r)}let A=Math.min(this.text.length,this.textOff+e),t=this.text.slice(this.textOff,A);return this.textOff=A,t}},n8=[Dd,ah,fd,ll,rh,gC,oh];for(let i=0;i<n8.length;i++)n8[i].bucket=i;var N9=class{constructor(e){this.view=e,this.buckets=n8.map(()=>[]),this.index=n8.map(()=>0),this.reused=new Map}add(e){let A=e.constructor.bucket,t=this.buckets[A];t.length<6?t.push(e):t[this.index[A]=(this.index[A]+1)%6]=e}find(e,A,t=2){let n=e.bucket,o=this.buckets[n],a=this.index[n];for(let r=o.length-1;r>=0;r--){let s=(r+a)%o.length,l=o[s];if((!A||A(l))&&!this.reused.has(l))return o.splice(s,1),s<a&&this.index[n]--,this.reused.set(l,t),l}return null}findWidget(e,A,t){let n=this.buckets[0];if(n.length)for(let o=0,a=0;;o++){if(o==n.length){if(a)return null;a=1,o=0}let r=n[o];if(!this.reused.has(r)&&(a==0?r.widget.compare(e):r.widget.constructor==e.constructor&&e.updateDOM(r.dom,this.view,r.widget)))return n.splice(o,1),o<this.index[0]&&this.index[0]--,r.widget==e&&r.length==A&&(r.flags&497)==t?(this.reused.set(r,1),r):(this.reused.set(r,2),new Dd(r.dom,A,e,r.flags&-498|t))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,A=2){if(!this.reused.has(e))return this.reused.set(e,A),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},F9=class{constructor(e,A,t,n,o){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=o,this.openWidget=!1,this.openMarks=0,this.cache=new N9(e),this.text=new R9(e.state.doc),this.builder=new x9(this.cache,new oh(e,e.contentDOM),uo.iter(t)),this.cache.reused.set(A,2),this.old=new k9(A),this.reuseWalker={skip:(a,r,s)=>{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,A){let t=A&&this.getCompositionContext(A.text);for(let n=0,o=0,a=0;;){let r=a<e.length?e[a++]:null,s=r?r.fromA:this.old.root.length;if(s>n){let l=s-n;this.preserve(l,!a,!r),n=s,o+=l}if(!r)break;A&&r.fromA<=A.range.fromA&&r.toA>=A.range.toA?(this.forward(r.fromA,A.range.fromA,A.range.fromA<A.range.toA?1:-1),this.emit(o,A.range.fromB),this.cache.clear(),this.builder.addComposition(A,t),this.text.skip(A.range.toB-A.range.fromB),this.forward(A.range.fromA,r.toA),this.emit(A.range.toB,r.toB)):(this.forward(r.fromA,r.toA),this.emit(o,r.toB)),o=r.toB,n=r.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,A,t){let n=IcA(this.old),o=this.openMarks;this.old.advance(e,t?1:-1,{skip:(a,r,s)=>{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(s-r);else{let l=s>0||r<a.length?Dd.of(a.widget,this.view,s-r,a.flags&496,this.cache.maybeReuse(a)):this.cache.reuse(a);l.flags&256?(l.flags&=-2,this.builder.addBlockWidget(l)):(this.builder.ensureLine(null),this.builder.addInlineWidget(l,n,o),o=n.length)}else if(a.isText())this.builder.ensureLine(null),!r&&s==a.length&&!this.cache.reused.has(a)?this.builder.addText(a.text,n,o,this.cache.reuse(a)):(this.cache.add(a),this.builder.addText(a.text.slice(r,s),n,o)),o=n.length;else if(a.isLine())a.flags&=-2,this.cache.reused.set(a,1),this.builder.addLine(a);else if(a instanceof rh)this.cache.add(a);else if(a instanceof ll)this.builder.ensureLine(null),this.builder.addMark(a,n,o),this.cache.reused.set(a,1),o=n.length;else return!1;this.openWidget=!1},enter:a=>{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof ll&&n.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?n.length&&(n.length=o=0):a instanceof ll&&(n.shift(),o=Math.min(o,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,A){let t=null,n=this.builder,o=0,a=uo.spans(this.decorations,e,A,{point:(r,s,l,g,C,d)=>{if(l instanceof wd){if(this.disallowBlockEffectsFor[d]){if(l.block)throw new RangeError("Block decorations may not be specified via plugins");if(s>this.view.state.doc.lineAt(r).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,C>g.length)n.continueWidget(s-r);else{let B=l.widget||(l.block?nY.block:nY.inline),u=CcA(l),E=this.cache.findWidget(B,s-r,u)||Dd.of(B,this.view,s-r,u);l.block?(l.startSide>0&&n.addLineStartIfNotCovered(t),n.addBlockWidget(E)):(n.ensureLine(t),n.addInlineWidget(E,g,C))}t=null}else t=dcA(t,l);s>r&&this.text.skip(s-r)},span:(r,s,l,g)=>{for(let C=r;C<s;){let d=this.text.next(Math.min(512,s-C));d==null?(n.addLineStartIfNotCovered(t),n.addBreak(),C++):(n.ensureLine(t),n.addText(d,l,C==r?g:l.length),C+=d.length),t=null}}});n.addLineStartIfNotCovered(t),this.openWidget=a>o,this.openMarks=a}forward(e,A,t=1){A-e<=10?this.old.advance(A-e,t,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(A-e-10,-1),this.old.advance(5,t,this.reuseWalker))}getCompositionContext(e){let A=[],t=null;for(let n=e.parentNode;;n=n.parentNode){let o=_a.get(n);if(n==this.view.contentDOM)break;o instanceof ll?A.push(o):o?.isLine()?t=o:o instanceof gC||(n.nodeName=="DIV"&&!t&&n!=this.view.contentDOM?t=new ah(n,oH):t||A.push(ll.of(new s4({tagName:n.nodeName.toLowerCase(),attributes:jgA(n)}),n)))}return{line:t,marks:A}}};function iY(i,e){let A=t=>{for(let n of t.children)if((e?n.isText():n.length)||A(n))return!0;return!1};return A(i)}function CcA(i){let e=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(e|=256),e}var oH={class:"cm-line"};function dcA(i,e){let A=e.spec.attributes,t=e.spec.class;return!A&&!t||(i||(i={class:"cm-line"}),A&&IS(A,i),t&&(i.class+=" "+t)),i}function IcA(i){let e=[];for(let A=i.parents.length;A>1;A--){let t=A==i.parents.length?i.tile:i.parents[A].tile;t instanceof ll&&e.push(t.mark)}return e}function c9(i){let e=_a.get(i);return e&&e.setDOM(i.cloneNode()),i}var nY=(()=>{class i extends gl{constructor(A){super(),this.tag=A}eq(A){return A.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(A){return A.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}return i.inline=new i("span"),i.block=new i("div"),i})(),C9=new class extends gl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},o8=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Lt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new oh(e,e.contentDOM),this.updateInner([new rc(0,0,0,e.state.doc.length)],null)}update(e){var A;let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:g,toA:C})=>C<this.minWidthFrom||g>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((A=this.domChanged)===null||A===void 0)&&A.newSel?n=this.domChanged.newSel.head:!mcA(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let o=n>-1?hcA(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:C}=this.hasComposition;t=new rc(g,C,e.changes.mapPos(g,-1),e.changes.mapPos(C,1)).addToSet(t.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Ct.ie||Ct.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,r=this.blockWrappers;this.updateDeco();let s=ucA(a,this.decorations,e.changes);s.length&&(t=rc.extendWithRanges(t,s));let l=pcA(r,this.blockWrappers,e.changes);return l.length&&(t=rc.extendWithRanges(t,l)),o&&!t.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(t=o.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,A){this.view.viewState.mustMeasureContent=!0;let{observer:t}=this.view;t.ignore(()=>{if(A||e.length){let a=this.tile,r=new F9(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);A&&_a.get(A.text)&&r.cache.reused.set(_a.get(A.text),2),this.tile=r.run(e,A),L9(a,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=Ct.chrome||Ct.ios?{node:t.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||t.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.tile.children)o.isWidget()&&o.widget instanceof i4&&n.push(o.dom);t.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let A of e.transactions)for(let t of A.effects)t.is(eH)&&(this.editContextFormatting=t.value)}updateSelection(e=!1,A=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:t}=this.tile,n=this.view.root.activeElement,o=n==t,a=!o&&!(this.view.state.facet(lC)||t.tabIndex>-1)&&$u(t,this.view.observer.selectionRange)&&!(n&&t.contains(n));if(!(o||A||a))return;let r=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,l,g;if(s.empty?g=l=this.inlineDOMNearPos(s.anchor,s.assoc||1):(g=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),l=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),Ct.gecko&&s.empty&&!this.hasComposition&&BcA(l)){let d=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(d,l.node.childNodes[l.offset]||null)),l=g=new C0(d,0),r=!0}let C=this.view.observer.selectionRange;(r||!C.focusNode||(!A4(l.node,l.offset,C.anchorNode,C.anchorOffset)||!A4(g.node,g.offset,C.focusNode,C.focusOffset))&&!this.suppressWidgetCursorChange(C,s))&&(this.view.observer.ignore(()=>{Ct.android&&Ct.chrome&&t.contains(C.focusNode)&&fcA(C.focusNode,t)&&(t.blur(),t.focus({preventScroll:!0}));let d=g4(this.view.root);if(d)if(s.empty){if(Ct.gecko){let B=EcA(l.node,l.offset);if(B&&B!=3){let u=(B==1?TY:OY)(l.node,l.offset);u&&(l=new C0(u.node,u.offset))}}d.collapse(l.node,l.offset),s.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=s.bidiLevel)}else if(d.extend){d.collapse(l.node,l.offset);try{d.extend(g.node,g.offset)}catch(B){}}else{let B=document.createRange();s.anchor>s.head&&([l,g]=[g,l]),B.setEnd(g.node,g.offset),B.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(B)}a&&this.view.root.activeElement==t&&(t.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(l,g)),this.impreciseAnchor=l.precise?null:new C0(C.anchorNode,C.anchorOffset),this.impreciseHead=g.precise?null:new C0(C.focusNode,C.focusOffset)}suppressWidgetCursorChange(e,A){return this.hasComposition&&A.empty&&A4(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==A.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,A=e.state.selection.main,t=g4(e.root),{anchorNode:n,anchorOffset:o}=e.observer.selectionRange;if(!t||!A.empty||!A.assoc||!t.modify)return;let a=this.lineAt(A.head,A.assoc);if(!a)return;let r=a.posAtStart;if(A.head==r||A.head==r+a.length)return;let s=this.coordsAt(A.head,-1),l=this.coordsAt(A.head,1);if(!s||!l||s.bottom>l.top)return;let g=this.domAtPos(A.head+A.assoc,A.assoc);t.collapse(g.node,g.offset),t.modify("move",A.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let C=e.observer.selectionRange;e.docView.posFromDOM(C.anchorNode,C.anchorOffset)!=A.from&&t.collapse(n,o)}posFromDOM(e,A){let t=this.tile.nearest(e);if(!t)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=t.posAtStart;if(t.isComposite()){let o;if(e==t.dom)o=t.dom.childNodes[A];else{let a=cC(e)==0?0:A==0?-1:1;for(;;){let r=e.parentNode;if(r==t.dom)break;a==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?a=-1:a=1),e=r}a<0?o=e:o=e.nextSibling}if(o==t.dom.firstChild)return n;for(;o&&!_a.get(o);)o=o.nextSibling;if(!o)return n+t.length;for(let a=0,r=n;;a++){let s=t.children[a];if(s.dom==o)return r;r+=s.length+s.breakAfter}}else return t.isText()?e==t.dom?n+A:n+(A?t.length:0):n}domAtPos(e,A){let{tile:t,offset:n}=this.tile.resolveBlock(e,A);return t.isWidget()?t.domPosFor(e,A):t.domIn(n,A)}inlineDOMNearPos(e,A){let t,n=-1,o=!1,a,r=-1,s=!1;return this.tile.blockTiles((l,g)=>{if(l.isWidget()){if(l.flags&32&&g>=e)return!0;l.flags&16&&(o=!0)}else{let C=g+l.length;if(g<=e&&(t=l,n=e-g,o=C<e),C>=e&&!a&&(a=l,r=e-g,s=g>e),g>e&&a)return!0}}),!t&&!a?this.domAtPos(e,A):(o&&a?t=null:s&&t&&(a=null),t&&A<0||!a?t.domIn(n,A):a.domIn(r,A))}coordsAt(e,A){let{tile:t,offset:n}=this.tile.resolveBlock(e,A);return t.isWidget()?t.widget instanceof i4?null:t.coordsInWidget(n,A,!0):t.coordsIn(n,A)}lineAt(e,A){let{tile:t}=this.tile.resolveBlock(e,A);return t.isLine()?t:null}coordsForChar(e){let{tile:A,offset:t}=this.tile.resolveBlock(e,1);if(!A.isLine())return null;function n(o,a){if(o.isComposite())for(let r of o.children){if(r.length>=a){let s=n(r,a);if(s)return s}if(a-=r.length,a<0)break}else if(o.isText()&&a<o.length){let r=tr(o.text,a);if(r==a)return null;let s=c4(o.dom,a,r).getClientRects();for(let l=0;l<s.length;l++){let g=s[l];if(l==s.length-1||g.top<g.bottom&&g.left<g.right)return g}}return null}return n(A,t)}measureVisibleLineHeights(e){let A=[],{from:t,to:n}=e,o=this.view.contentDOM.clientWidth,a=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,s=this.view.textDirection==Lo.LTR,l=0,g=(C,d,B)=>{for(let u=0;u<C.children.length&&!(d>n);u++){let E=C.children[u],f=d+E.length,m=E.dom.getBoundingClientRect(),{height:v}=m;if(B&&!u&&(l+=m.top-B.top),E instanceof gC)f>t&&g(E,d,m);else if(d>=t&&(l>0&&A.push(-l),A.push(v+l),l=0,a)){let S=E.dom.lastChild,k=S?V6(S):[];if(k.length){let M=k[k.length-1],x=s?M.right-m.left:m.right-M.left;x>r&&(r=x,this.minWidth=o,this.minWidthFrom=d,this.minWidthTo=f)}}B&&u==C.children.length-1&&(l+=B.bottom-m.bottom),d=f+E.breakAfter}};return g(this.tile,0,null),A}textDirectionAt(e){let{tile:A}=this.tile.resolveBlock(e,1);return getComputedStyle(A.dom).direction=="rtl"?Lo.RTL:Lo.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let r=0,s;for(let l of a.children){if(!l.isText()||/[^ -~]/.test(l.text))return;let g=V6(l.dom);if(g.length!=1)return;r+=g[0].width,s=g[0].height}if(r)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:r/a.length,textHeight:s}}});if(e)return e;let A=document.createElement("div"),t,n,o;return A.className="cm-line",A.style.width="99999px",A.style.position="absolute",A.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(A);let a=V6(A.firstChild)[0];t=A.getBoundingClientRect().height,n=a&&a.width?a.width/27:7,o=a&&a.height?a.height:t,A.remove()}),{lineHeight:t,charWidth:n,textHeight:o}}computeBlockGapDeco(){let e=[],A=this.view.viewState;for(let t=0,n=0;;n++){let o=n==A.viewports.length?null:A.viewports[n],a=o?o.from-1:this.view.state.doc.length;if(a>t){let r=(A.lineBlockAt(a).bottom-A.lineBlockAt(t).top)/this.view.scaleY;e.push(Lt.replace({widget:new i4(r),block:!0,inclusive:!0,isBlockGap:!0}).range(t,a))}if(!o)break;t=o.to+1}return Lt.set(e)}updateDeco(){let e=1,A=this.view.state.facet(Q8).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),t=!1,n=this.view.state.facet(uS).map((o,a)=>{let r=typeof o=="function";return r&&(t=!0),r?o(this.view):o});for(n.length&&(this.dynamicDecorationMap[e++]=t,A.push(uo.join(n))),this.decorations=[this.editContextFormatting,...A,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(tH).map(o=>typeof o=="function"?o(this.view):o)}scrollIntoView(e){var A;if(e.isSnapshot){let g=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=g.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let g of this.view.state.facet(AH))try{if(g(this.view,e.range,e))return!0}catch(C){Gr(this.view.state,C,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,(A=t.assoc)!==null&&A!==void 0?A:t.empty?0:t.head>t.anchor?-1:1),o;if(!n)return;!t.empty&&(o=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,o.left),top:Math.min(n.top,o.top),right:Math.max(n.right,o.right),bottom:Math.max(n.bottom,o.bottom)});let a=pS(this.view),r={left:n.left-a.left,top:n.top-a.top,right:n.right+a.right,bottom:n.bottom+a.bottom},{offsetWidth:s,offsetHeight:l}=this.view.scrollDOM;if(WgA(this.view.scrollDOM,r,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Lo.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let g=this.view.docView.lineAt(t.head,1);g&&g.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let A=t=>t.isWidget()||t.children.some(A);return A(this.tile.resolveBlock(e,1).tile)}destroy(){L9(this.tile)}};function L9(i,e){let A=e?.get(i);if(A!=1){A==null&&i.destroy();for(let t of i.children)L9(t,e)}}function BcA(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function aH(i,e){let A=i.observer.selectionRange;if(!A.focusNode)return null;let t=TY(A.focusNode,A.focusOffset),n=OY(A.focusNode,A.focusOffset),o=t||n;if(n&&t&&n.node!=t.node){let r=_a.get(n.node);if(!r||r.isText()&&r.text!=n.node.nodeValue)o=n;else if(i.docView.lastCompositionAfterCursor){let s=_a.get(t.node);!s||s.isText()&&s.text!=t.node.nodeValue||(o=n)}}if(i.docView.lastCompositionAfterCursor=o!=t,!o)return null;let a=e-o.offset;return{from:a,to:a+o.node.nodeValue.length,node:o.node}}function hcA(i,e,A){let t=aH(i,A);if(!t)return null;let{node:n,from:o,to:a}=t,r=n.nodeValue;if(/[\n\r]/.test(r)||i.state.doc.sliceString(t.from,t.to)!=r)return null;let s=e.invertedDesc;return{range:new rc(s.mapPos(o),s.mapPos(a),o,a),text:n}}function EcA(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}var QcA=class{constructor(){this.changes=[]}compareRange(e,A){th(e,A,this.changes)}comparePoint(e,A){th(e,A,this.changes)}boundChange(e){th(e,e,this.changes)}};function ucA(i,e,A){let t=new QcA;return uo.compare(i,e,A,t),t.changes}var G9=class{constructor(){this.changes=[]}compareRange(e,A){th(e,A,this.changes)}comparePoint(){}boundChange(e){th(e,e,this.changes)}};function pcA(i,e,A){let t=new G9;return uo.compare(i,e,A,t),t.changes}function fcA(i,e){for(let A=i;A&&A!=e;A=A.assignedSlot||A.parentNode)if(A.nodeType==1&&A.contentEditable=="false")return!0;return!1}function mcA(i,e){let A=!1;return e&&i.iterChangedRanges((t,n)=>{t<e.to&&n>e.from&&(A=!0)}),A}var i4=class extends gl{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function wcA(i,e,A=1){let t=i.charCategorizer(e),n=i.doc.lineAt(e),o=e-n.from;if(n.length==0)return Be.cursor(e);o==0?A=1:o==n.length&&(A=-1);let a=o,r=o;A<0?a=tr(n.text,o,!1):r=tr(n.text,o);let s=t(n.text.slice(a,r));for(;a>0;){let l=tr(n.text,a,!1);if(t(n.text.slice(l,a))!=s)break;a=l}for(;r<n.length;){let l=tr(n.text,r);if(t(n.text.slice(r,l))!=s)break;r=l}return Be.range(a+n.from,r+n.from)}function ycA(i,e,A,t,n){let o=Math.round((t-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&A.height>i.defaultLineHeight*1.5){let r=i.viewState.heightOracle.textHeight,s=Math.floor((n-A.top-(i.defaultLineHeight-r)*.5)/r);o+=s*i.viewState.heightOracle.lineLength}let a=i.state.sliceDoc(A.from,A.to);return A.from+G6(a,o,i.state.tabSize)}function K9(i,e,A){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){let n;for(let o of t.type){if(o.from>e)break;if(!(o.to<e)){if(o.from<e&&o.to>e)return o;(!n||o.type==As.Text&&(n.type!=o.type||(A<0?o.from<e:o.to>e)))&&(n=o)}}return n||t}return t}function DcA(i,e,A,t){let n=K9(i,e.head,e.assoc||-1),o=!t||n.type!=As.Text||!(i.lineWrapping||n.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(o){let a=i.dom.getBoundingClientRect(),r=i.textDirectionAt(n.from),s=i.posAtCoords({x:A==(r==Lo.LTR)?a.right-1:a.left+1,y:(o.top+o.bottom)/2});if(s!=null)return Be.cursor(s,A?-1:1)}return Be.cursor(A?n.to:n.from,A?-1:1)}function oY(i,e,A,t){let n=i.state.doc.lineAt(e.head),o=i.bidiSpans(n),a=i.textDirectionAt(n.from);for(let r=e,s=null;;){let l=acA(n,o,a,r,A),g=PY;if(!l){if(n.number==(A?i.state.doc.lines:1))return r;g=` |
no test coverage detected