@nocobase/plugin-field-code 2.1.0-alpha.10 → 2.1.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@formily/react"),require("@nocobase/flow-engine"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-code",["@formily/react","@nocobase/flow-engine","react","antd","@nocobase/client","antd-style"],e):"object"==typeof exports?exports["@nocobase/plugin-field-code"]=e(require("@formily/react"),require("@nocobase/flow-engine"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style")):t["@nocobase/plugin-field-code"]=e(t["@formily/react"],t["@nocobase/flow-engine"],t.react,t.antd,t["@nocobase/client"],t["antd-style"])}(self,function(t,e,n,i,r,s){return function(){var o,l,a,h={125:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return nt}});var i=n(155),r=n.n(i),s=n(235),o=n(230),l=n(867),a=n(492),h=n(169),c=n(80);function u(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return!!r&&(i(n.update(r)),!0)}}let f=u(function(t,e,n=e.selection.ranges){let i=[],r=-1;for(let{from:t,to:s}of n){let n=i.length,o=1e9,l=m(e,t).line;if(l){for(let n=t;n<=s;){let a=e.doc.lineAt(n);if(a.from>r&&(t==s||s>a.from)){r=a.from;let t=/^\s*/.exec(a.text)[0].length,e=t==a.length,n=a.text.slice(t,t+l.length)==l?t:-1;t<a.text.length&&t<o&&(o=t),i.push({line:a,comment:n,token:l,indent:t,empty:e,single:!1})}n=a.to+1}if(o<1e9)for(let t=n;t<i.length;t++)i[t].indent<i[t].line.text.length&&(i[t].indent=o);i.length==n+1&&(i[n].single=!0)}}if(2!=t&&i.some(t=>t.comment<0&&(!t.empty||t.single))){let t=[];for(let{line:e,token:n,indent:r,empty:s,single:o}of i)(o||!s)&&t.push({from:e.from+r,insert:n+" "});let n=e.changes(t);return{changes:n,selection:e.selection.map(n,1)}}if(1!=t&&i.some(t=>t.comment>=0)){let t=[];for(let{line:e,comment:n,token:r}of i)if(n>=0){let i=e.from+n,s=i+r.length;" "==e.text[s-e.from]&&s++,t.push({from:i,to:s})}return{changes:t}}return null},0),d=u(g,0),p=u((t,e)=>g(t,e,function(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}(e)),0);function m(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}function g(t,e,n=e.selection.ranges){let i=n.map(t=>m(e,t.from).block);if(!i.every(t=>t))return null;let r=n.map((t,n)=>(function(t,{open:e,close:n},i,r){let s,o,l=t.sliceDoc(i-50,i),a=t.sliceDoc(r,r+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,u=l.length-h;if(l.slice(u-e.length,u)==e&&a.slice(c,c+n.length)==n)return{open:{pos:i-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-i<=100?s=o=t.sliceDoc(i,r):(s=t.sliceDoc(i,i+50),o=t.sliceDoc(r-50,r));let f=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-n.length;return s.slice(f,f+e.length)==e&&o.slice(p,p+n.length)==n?{open:{pos:i+f+e.length,margin:+!!/\s/.test(s.charAt(f+e.length))},close:{pos:r-d-n.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(e,i[n],t.from,t.to));if(2!=t&&!r.every(t=>t))return{changes:e.changes(n.map((t,e)=>r[e]?[]:[{from:t.from,insert:i[e].open+" "},{from:t.to,insert:" "+i[e].close}]))};if(1!=t&&r.some(t=>t)){let t=[];for(let e=0,n;e<r.length;e++)if(n=r[e]){let r=i[e],{open:s,close:o}=n;t.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:t}}return null}let v=a.YH.define(),b=a.YH.define(),y=a.sj.define(),w=a.sj.define({combine:t=>(0,a.QR)(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(n,i)=>t(n,i)||e(n,i)})}),x=a.sU.define({create:()=>L.empty,update(t,e){let n=e.state.facet(w),i=e.annotation(v);if(i){let r=M.fromTransaction(e,i.selection),s=i.side,o=0==s?t.undone:t.done;return o=r?D(o,o.length,n.minDepth,r):E(o,e.startState.selection),new L(0==s?i.rest:o,0==s?o:i.rest)}let r=e.annotation(b);if(("full"==r||"before"==r)&&(t=t.isolate()),!1===e.annotation(a.ZX.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let s=M.fromTransaction(e),o=e.annotation(a.ZX.time),l=e.annotation(a.ZX.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),("full"==r||"after"==r)&&(t=t.isolate()),t},toJSON:t=>({done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}),fromJSON:t=>new L(t.done.map(M.fromJSON),t.undone.map(M.fromJSON))});function k(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(x,!1);if(!r)return!1;let s=r.pop(t,n,e);return!!s&&(i(s),!0)}}let S=k(0,!1),C=k(1,!1),A=k(0,!0),O=k(1,!0);class M{constructor(t,e,n,i,r){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(t){return new M(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:null==(t=this.changes)?void 0:t.toJSON(),mapped:null==(e=this.mapped)?void 0:e.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new M(t.changes&&a.VR.fromJSON(t.changes),[],t.mapped&&a.Gu.fromJSON(t.mapped),t.startSelection&&a.OF.fromJSON(t.startSelection),t.selectionsAfter.map(a.OF.fromJSON))}static fromTransaction(t,e){let n=T;for(let e of t.startState.facet(y)){let i=e(t);i.length&&(n=n.concat(i))}return!n.length&&t.changes.empty?null:new M(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,T)}static selection(t){return new M(void 0,T,void 0,void 0,t)}}function D(t,e,n,i){let r=t.slice(e+1>n+20?e-n-1:0,e);return r.push(i),r}function P(t,e){return t.length?e.length?t.concat(e):t:e}let T=[];function E(t,e){if(!t.length)return[M.selection([e])];{let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),D(t,t.length-1,1e9,n.setSelAfter(i)))}}function R(t,e){if(!t.length)return t;let n=t.length,i=T;for(;n;){let r=function(t,e,n){let i=P(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):T,n);if(!t.changes)return M.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new M(r,a.Pe.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,n);return e[n-1]=r,e}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[M.selection(i)]:T}let B=/^(input\.type|delete)($|\.)/;class L{constructor(t,e,n=0,i){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(t,e,n,i,r){var s,o;let l,h,c=this.done,u=c[c.length-1];return new L(c=u&&u.changes&&!u.changes.empty&&t.changes&&(!n||B.test(n))&&(!u.selectionsAfter.length&&e-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,(s=u.changes,o=t.changes,l=[],h=!1,s.iterChangedRanges((t,e)=>l.push(t,e)),o.iterChangedRanges((t,e,n,i)=>{for(let t=0;t<l.length;){let e=l[t++],r=l[t++];i>=e&&n<=r&&(h=!0)}}),h))||"input.type.compose"==n)?D(c,c.length-1,i.minDepth,new M(t.changes.compose(u.changes),P(a.Pe.mapEffects(t.effects,u.changes),u.effects),u.mapped,u.startSelection,T)):D(c,c.length,i.minDepth,t),T,e,n)}addSelection(t,e,n,i){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:T;return s.length>0&&e-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(r=s[s.length-1],r.ranges.length==t.ranges.length&&0===r.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length)?this:new L(E(this.done,t),this.undone,e,n)}addMapping(t){return new L(R(this.done,t),R(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let i=0==t?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||e.selection;if(n&&r.selectionsAfter.length){let n,o;return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:v.of({side:t,rest:(n=i[i.length-1],(o=i.slice())[i.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let n=1==i.length?T:i.slice(0,i.length-1);return r.mapped&&(n=R(n,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:v.of({side:t,rest:n,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}}}L.empty=new L(T,T);function N(t,e){return a.OF.create(t.ranges.map(e),t.mainIndex)}function I(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function F({state:t,dispatch:e},n){let i=N(t.selection,n);return!i.eq(t.selection,!0)&&(e(I(t,i)),!0)}function j(t,e){return a.OF.cursor(e?t.to:t.from)}function _(t,e){return F(t,n=>n.empty?t.moveByChar(n,e):j(n,e))}function z(t){return t.textDirectionAt(t.state.selection.main.head)==l.OP.LTR}let V=t=>_(t,!z(t)),H=t=>_(t,z(t));function W(t,e){return F(t,n=>n.empty?t.moveByGroup(n,e):j(n,e))}function q(t,e,n){let i,r,s=(0,h.mv)(t).resolveInner(e.head),o=n?c.uY.closedBy:c.uY.openedBy;for(let i=e.head;;){let e=n?s.childAfter(i):s.childBefore(i);if(!e)break;!function(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}(t,e,o)?i=n?e.to:e.from:s=e}return r=s.type.prop(o)&&(i=n?(0,h.jU)(t,s.from,1):(0,h.jU)(t,s.to,-1))&&i.matched?n?i.end.to:i.end.from:n?s.to:s.from,a.OF.cursor(r,n?-1:1)}function U(t,e){return F(t,n=>{if(!n.empty)return j(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}"u">typeof Intl&&Intl.Segmenter;let $=t=>U(t,!1),K=t=>U(t,!0);function J(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,i=0,r;if(e){for(let e of t.state.facet(l.Lz.scrollMargins)){let r=e(t);(null==r?void 0:r.top)&&(n=Math.max(null==r?void 0:r.top,n)),(null==r?void 0:r.bottom)&&(i=Math.max(null==r?void 0:r.bottom,i))}r=t.scrollDOM.clientHeight-n-i}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function Y(t,e){let n,i=J(t),{state:r}=t,s=N(r.selection,n=>n.empty?t.moveVertically(n,e,i.height):j(n,e));if(s.eq(r.selection))return!1;if(i.selfScroll){let e=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),a=o.top+i.marginTop,h=o.bottom-i.marginBottom;e&&e.top>a&&e.bottom<h&&(n=l.Lz.scrollIntoView(s.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(I(r,s),{effects:n}),!0}let G=t=>Y(t,!1),Z=t=>Y(t,!0);function X(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&e.head!=i.from+n&&(r=a.OF.cursor(i.from+n))}return r}function Q(t,e){let n=N(t.state.selection,t=>{let n=e(t);return a.OF.range(t.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(t.state.selection)&&(t.dispatch(I(t.state,n)),!0)}function tt(t,e){return Q(t,n=>t.moveByChar(n,e))}let te=t=>tt(t,!z(t)),tn=t=>tt(t,z(t));function ti(t,e){return Q(t,n=>t.moveByGroup(n,e))}function tr(t,e){return Q(t,n=>t.moveVertically(n,e))}let ts=t=>tr(t,!1),to=t=>tr(t,!0);function tl(t,e){return Q(t,n=>t.moveVertically(n,e,J(t).height))}let ta=t=>tl(t,!1),th=t=>tl(t,!0),tc=({state:t,dispatch:e})=>(e(I(t,{anchor:0})),!0),tu=({state:t,dispatch:e})=>(e(I(t,{anchor:t.doc.length})),!0),tf=({state:t,dispatch:e})=>(e(I(t,{anchor:t.selection.main.anchor,head:0})),!0),td=({state:t,dispatch:e})=>(e(I(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function tp(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(i=>{let{from:r,to:s}=i;if(r==s){let o=e(i);o<r?(n="delete.backward",o=tm(t,o,!1)):o>r&&(n="delete.forward",o=tm(t,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=tm(t,r,!1),s=tm(t,s,!0);return r==s?{range:i}:{changes:{from:r,to:s},range:a.OF.cursor(r,r<i.head?-1:1)}});return!r.changes.empty&&(t.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?l.Lz.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function tm(t,e,n){if(t instanceof l.Lz)for(let i of t.state.facet(l.Lz.atomicRanges).map(e=>e(t)))i.between(e,e,(t,i)=>{t<e&&i>e&&(e=n?i:t)});return e}let tg=(t,e,n)=>tp(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),l,c;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(" "==l[l.length-1])return r-1;let t=(0,a.y$)(l,s.tabSize)%(0,h.tp)(s)||(0,h.tp)(s);for(let e=0;e<t&&" "==l[l.length-1-e];e++)r--;c=r}else(c=(0,a.zK)(o.text,r-o.from,e,e)+o.from)==r&&o.number!=(e?s.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,r-o.from))&&(c=(0,a.zK)(o.text,c-o.from,!1,!1)+o.from);return c}),tv=t=>tg(t,!1,!0),tb=t=>tg(t,!0,!1),ty=(t,e)=>tp(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let t=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=(0,a.zK)(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),c=o(h);if(null!=t&&c!=t)break;(" "!=h||i!=n.head)&&(t=c),i=l}return i}),tw=t=>ty(t,!1);function tx(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(i.empty||i.to!=s.from||(s=t.doc.lineAt(i.to-1)),n>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function tk(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let e of tx(t)){if(n?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(n?e.to+1:e.from-1),o=s.length+1;if(n)for(let n of(i.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak}),e.ranges))r.push(a.OF.range(Math.min(t.doc.length,n.anchor+o),Math.min(t.doc.length,n.head+o)));else for(let n of(i.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text}),e.ranges))r.push(a.OF.range(n.anchor-o,n.head-o))}return!!i.length&&(e(t.update({changes:i,scrollIntoView:!0,selection:a.OF.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function tS(t,e,n){if(t.readOnly)return!1;let i=[];for(let e of tx(t))n?i.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):i.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}let tC=tO(!1),tA=tO(!0);function tO(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:i,to:r}=n,s=e.doc.lineAt(i),o=!t&&i==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=(0,h.mv)(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(c.uY.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}(e,i);t&&(i=r=(r<=s.to?s:e.doc.lineAt(r)).to);let l=new h.KB(e,{simulateBreak:i,simulateDoubleBreak:!!o}),u=(0,h._v)(l,i);for(null==u&&(u=(0,a.y$)(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?{from:i,to:r}=o:i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let f=["",(0,h.EI)(e,u)];return o&&f.push((0,h.EI)(e,l.lineIndent(s.from,-1))),{changes:{from:i,to:r,insert:a.EY.of(f)},range:a.OF.cursor(i+1+f[1].length)}});return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function tM(t,e){let n=-1;return t.changeByRange(i=>{let r=[];for(let s=i.from;s<=i.to;){let o=t.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(e(o,r,i),n=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:a.OF.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}let tD=[{key:"Ctrl-b",run:V,shift:te,preventDefault:!0},{key:"Ctrl-f",run:H,shift:tn},{key:"Ctrl-p",run:$,shift:ts},{key:"Ctrl-n",run:K,shift:to},{key:"Ctrl-a",run:t=>F(t,e=>a.OF.cursor(t.lineBlockAt(e.head).from,1)),shift:t=>Q(t,e=>a.OF.cursor(t.lineBlockAt(e.head).from))},{key:"Ctrl-e",run:t=>F(t,e=>a.OF.cursor(t.lineBlockAt(e.head).to,-1)),shift:t=>Q(t,e=>a.OF.cursor(t.lineBlockAt(e.head).to))},{key:"Ctrl-d",run:tb},{key:"Ctrl-h",run:tv},{key:"Ctrl-k",run:t=>tp(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)})},{key:"Ctrl-Alt-h",run:tw},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:a.EY.of(["",""])},range:a.OF.cursor(t.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let n=e.from,i=t.doc.lineAt(n),r=n==i.from?n-1:(0,a.zK)(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:(0,a.zK)(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:s,insert:t.doc.slice(n,s).append(t.doc.slice(r,n))},range:a.OF.cursor(s)}});return!n.changes.empty&&(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Z}],tP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>F(t,e=>q(t.state,e,!z(t))),shift:t=>Q(t,e=>q(t.state,e,!z(t)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>F(t,e=>q(t.state,e,z(t))),shift:t=>Q(t,e=>q(t.state,e,z(t)))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>tk(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>tS(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>tk(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>tS(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=a.OF.create([n.main]):n.main.empty||(i=a.OF.create([a.OF.cursor(n.main.head)])),!!i&&(e(I(t,i)),!0)}},{key:"Mod-Enter",run:tA},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let n=tx(t).map(({from:e,to:n})=>a.OF.range(e,Math.min(n+1,t.doc.length)));return e(t.update({selection:a.OF.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let n=N(t.selection,e=>{let n=(0,h.mv)(t),i=n.resolveStack(e.from,1);if(e.empty){let t=n.resolveStack(e.from,-1);t.node.from>=i.node.from&&t.node.to<=i.node.to&&(i=t)}for(let t=i;t;t=t.next){let{node:n}=t;if((n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&t.next)return a.OF.range(n.to,n.from)}return e});return!n.eq(t.selection)&&(e(I(t,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(tM(t,(e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=(0,a.y$)(i,t.tabSize),s=0,o=(0,h.EI)(t,Math.max(0,r-(0,h.tp)(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(tM(t,(e,n)=>{n.push({from:e.from,insert:t.facet(h.Xt)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new h.KB(t,{overrideIndentation:t=>{let e=n[t];return null==e?-1:e}}),r=tM(t,(e,r,s)=>{let o=(0,h._v)(i,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],a=(0,h.EI)(t,o);(l!=a||s.from<e.from+l.length)&&(n[e.from]=o,r.push({from:e.from,to:e.from+l.length,insert:a}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(tx(e).map(({from:t,to:n})=>(t>0?t--:n<e.doc.length&&n++,{from:t,to:n}))),i=N(e.selection,e=>{let n;if(t.lineWrapping){let i=t.lineBlockAt(e.head),r=t.coordsAtPos(e.head,e.assoc||1);r&&(n=i.bottom+t.documentTop-r.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,n)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>{let n,i;return n=!1,i=N(t.selection,e=>{let i=(0,h.jU)(t,e.head,-1)||(0,h.jU)(t,e.head,1)||e.head>0&&(0,h.jU)(t,e.head-1,1)||e.head<t.doc.length&&(0,h.jU)(t,e.head+1,-1);if(!i||!i.end)return e;n=!0;let r=i.start.from==e.head?i.end.to:i.end.from;return a.OF.cursor(r)}),!!n&&(e(I(t,i)),!0)}},{key:"Mod-/",run:t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=m(t.state,n.from);return i.line?f(t):!!i.block&&p(t)}},{key:"Alt-A",run:d},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:V,shift:te,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>W(t,!z(t)),shift:t=>ti(t,!z(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>F(t,e=>X(t,e,!z(t))),shift:t=>Q(t,e=>X(t,e,!z(t))),preventDefault:!0},{key:"ArrowRight",run:H,shift:tn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>W(t,z(t)),shift:t=>ti(t,z(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>F(t,e=>X(t,e,z(t))),shift:t=>Q(t,e=>X(t,e,z(t))),preventDefault:!0},{key:"ArrowUp",run:$,shift:ts,preventDefault:!0},{mac:"Cmd-ArrowUp",run:tc,shift:tf},{mac:"Ctrl-ArrowUp",run:G,shift:ta},{key:"ArrowDown",run:K,shift:to,preventDefault:!0},{mac:"Cmd-ArrowDown",run:tu,shift:td},{mac:"Ctrl-ArrowDown",run:Z,shift:th},{key:"PageUp",run:G,shift:ta},{key:"PageDown",run:Z,shift:th},{key:"Home",run:t=>F(t,e=>X(t,e,!1)),shift:t=>Q(t,e=>X(t,e,!1)),preventDefault:!0},{key:"Mod-Home",run:tc,shift:tf},{key:"End",run:t=>F(t,e=>X(t,e,!0)),shift:t=>Q(t,e=>X(t,e,!0)),preventDefault:!0},{key:"Mod-End",run:tu,shift:td},{key:"Enter",run:tC,shift:tC},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:tv,shift:tv},{key:"Delete",run:tb},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tw},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>ty(t,!0)},{mac:"Mod-Backspace",run:t=>tp(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)})},{mac:"Mod-Delete",run:t=>tp(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)})}].concat(tD.map(t=>({mac:t.key,run:t.run,shift:t.shift}))));function tT(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?t.setAttribute(i,r):null!=r&&(t[i]=r)}e++}for(;e<arguments.length;e++)!function t(e,n){if("string"==typeof n)e.appendChild(document.createTextNode(n));else if(null==n);else if(null!=n.nodeType)e.appendChild(n);else if(Array.isArray(n))for(var i=0;i<n.length;i++)t(e,n[i]);else throw RangeError("Unsupported child node: "+n)}(t,arguments[e]);return t}let tE="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class tR{constructor(t,e,n=0,i=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(n,i),this.bufferStart=n,this.normalize=r?t=>r(tE(t)):tE,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return(0,a.vS)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=(0,a.MK)(t),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,a.Fh)(t);let i=this.normalize(e);if(i.length)for(let t=0,r=n;;t++){let s=i.charCodeAt(t),o=this.match(s,r,this.bufferPos+this.bufferStart);if(t==i.length-1){if(o)return this.value=o,this;break}r==n&&t<e.length&&e.charCodeAt(t)==s&&r++}}}match(t,e,n){let i=null;for(let e=0;e<this.matches.length;e+=2){let r=this.matches[e],s=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?i={from:this.matches[e+1],to:n}:(this.matches[e]++,s=!0)),s||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:n}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"u">typeof Symbol&&(tR.prototype[Symbol.iterator]=function(){return this});let tB={from:-1,to:-1,match:/.*/.exec("")},tL="gm"+(null==/x/.unicode?"":"u");class tN{constructor(t,e,n,i=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=tB,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new tj(t,e,n,i,r);this.re=new RegExp(e,tL+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=t.iter();let s=t.lineAt(i);this.curLineStart=s.from,this.matchPos=t_(t,i),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let n=this.curLineStart+e.index,i=n+e[0].length;if(this.matchPos=t_(this.text,i+ +(n==i)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,e)))return this.value={from:n,to:i,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}let tI=new WeakMap;class tF{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,n){let i=tI.get(t);if(!i||i.from>=n||i.to<=e){let i=new tF(e,t.sliceString(e,n));return tI.set(t,i),i}if(i.from==e&&i.to==n)return i;let{text:r,from:s}=i;return s>e&&(r=t.sliceString(e,s)+r,s=e),i.to<n&&(r+=t.sliceString(i.to,n)),tI.set(t,new tF(s,r)),new tF(e,r.slice(e-s,n-s))}}class tj{constructor(t,e,n,i,r){this.text=t,this.to=r,this.done=!1,this.value=tB,this.matchPos=t_(t,i),this.re=new RegExp(e,tL+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=tF.get(t,i,this.chunkEnd(i+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,n=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,n,e)))return this.value={from:t,to:n,match:e},this.matchPos=t_(this.text,n+ +(t==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=tF.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function t_(t,e){if(e>=t.length)return e;let n=t.lineAt(e),i;for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function tz(t){let e=tT("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!n)return;let{state:i}=t,r=i.doc.lineAt(i.selection.main.head),[,s,o,h,c]=n,u=h?+h.slice(1):0,f=o?+o:r.number;if(o&&c){let t=f/100;s&&(t=t*("-"==s?-1:1)+r.number/i.doc.lines),f=Math.round(i.doc.lines*t)}else o&&s&&(f=f*("-"==s?-1:1)+r.number);let d=i.doc.line(Math.max(1,Math.min(i.doc.lines,f))),p=a.OF.cursor(d.from+Math.max(0,Math.min(u,d.length)));t.dispatch({effects:[tV.of(!1),l.Lz.scrollIntoView(p.from,{y:"center"})],selection:p}),t.focus()}return{dom:tT("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:tV.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),n())},onsubmit:t=>{t.preventDefault(),n()}},tT("label",t.state.phrase("Go to line"),": ",e)," ",tT("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),tT("button",{name:"close",onclick:()=>{t.dispatch({effects:tV.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["\xd7"]))}}"u">typeof Symbol&&(tN.prototype[Symbol.iterator]=tj.prototype[Symbol.iterator]=function(){return this});let tV=a.Pe.define(),tH=a.sU.define({create:()=>!0,update(t,e){for(let n of e.effects)n.is(tV)&&(t=n.value);return t},provide:t=>l.S7.from(t,t=>t?tz:null)}),tW=l.Lz.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),tq={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},tU=a.sj.define({combine:t=>(0,a.QR)(t,tq,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})}),t$=l.NZ.mark({class:"cm-selectionMatch"}),tK=l.NZ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function tJ(t,e,n,i){return(0==n||t(e.sliceDoc(n-1,n))!=a.Je.Word)&&(i==e.doc.length||t(e.sliceDoc(i,i+1))!=a.Je.Word)}let tY=l.Z9.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(tU),{state:n}=t,i=n.selection;if(i.ranges.length>1)return l.NZ.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return l.NZ.none;let t=n.wordAt(r.head);if(!t)return l.NZ.none;o=n.charCategorizer(r.head),s=n.sliceDoc(t.from,t.to)}else{let t=r.to-r.from;if(t<e.minSelectionLength||t>200)return l.NZ.none;if(e.wholeWords){var h,c,u;if(s=n.sliceDoc(r.from,r.to),!(tJ(o=n.charCategorizer(r.head),n,r.from,r.to)&&(h=o,c=r.from,u=r.to,h(n.sliceDoc(c,c+1))==a.Je.Word&&h(n.sliceDoc(u-1,u))==a.Je.Word)))return l.NZ.none}else if(!(s=n.sliceDoc(r.from,r.to)))return l.NZ.none}let f=[];for(let i of t.visibleRanges){let t=new tR(n.doc,s,i.from,i.to);for(;!t.next().done;){let{from:i,to:s}=t.value;if((!o||tJ(o,n,i,s))&&(r.empty&&i<=r.from&&s>=r.to?f.push(tK.range(i,s)):(i>=r.to||s<=r.from)&&f.push(t$.range(i,s)),f.length>e.maxMatches))return l.NZ.none}}return l.NZ.set(f)}},{decorations:t=>t.decorations}),tG=l.Lz.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),tZ=a.sj.define({combine:t=>(0,a.QR)(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new eg(t),scrollToMatch:t=>l.Lz.scrollIntoView(t)})});class tX{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,tL),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new t8(this):new t1(this)}getCursor(t,e=0,n){let i=t.doc?t:a.$t.create({doc:t});return null==n&&(n=i.doc.length),this.regexp?t2(this,i,e,n):t0(this,i,e,n)}}class tQ{constructor(t){this.spec=t}}function t0(t,e,n,i){var r,s;return new tR(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?(r=e.doc,s=e.charCategorizer(e.selection.main.head),(t,e,n,i)=>((i>t||i+n.length<e)&&(i=Math.max(0,t-2),n=r.sliceString(i,Math.min(r.length,e+2))),(s(t4(n,t-i))!=a.Je.Word||s(t3(n,t-i))!=a.Je.Word)&&(s(t3(n,e-i))!=a.Je.Word||s(t4(n,e-i))!=a.Je.Word))):void 0)}class t1 extends tQ{constructor(t){super(t)}nextMatch(t,e,n){let i=t0(this.spec,t,n,t.doc.length).nextOverlapping();if(i.done){let n=Math.min(t.doc.length,e+this.spec.unquoted.length);i=t0(this.spec,t,0,n).nextOverlapping()}return i.done||i.value.from==e&&i.value.to==n?null:i.value}prevMatchInRange(t,e,n){for(let i=n;;){let n=Math.max(e,i-1e4-this.spec.unquoted.length),r=t0(this.spec,t,n,i),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(n==e)return null;i-=1e4}}prevMatch(t,e,n){let i=this.prevMatchInRange(t,0,e);return i||(i=this.prevMatchInRange(t,Math.max(0,n-this.spec.unquoted.length),t.doc.length)),i&&(i.from!=e||i.to!=n)?i:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let n=t0(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=t0(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function t2(t,e,n,i){var r;return new tN(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,n)=>!n[0].length||(r(t4(n.input,n.index))!=a.Je.Word||r(t3(n.input,n.index))!=a.Je.Word)&&(r(t3(n.input,n.index+n[0].length))!=a.Je.Word||r(t4(n.input,n.index+n[0].length))!=a.Je.Word)):void 0},n,i)}function t4(t,e){return t.slice((0,a.zK)(t,e,!1),e)}function t3(t,e){return t.slice(e,(0,a.zK)(t,e))}class t8 extends tQ{nextMatch(t,e,n){let i=t2(this.spec,t,n,t.doc.length).next();return i.done&&(i=t2(this.spec,t,0,e).next()),i.done?null:i.value}prevMatchInRange(t,e,n){for(let i=1;;i++){let r=Math.max(e,n-1e4*i),s=t2(this.spec,t,r,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,n){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,n,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,n)=>{if("&"==n)return t.match[0];if("$"==n)return"$";for(let e=n.length;e>0;e--){let i=+n.slice(0,e);if(i>0&&i<t.match.length)return t.match[i]+n.slice(e)}return e})}matchAll(t,e){let n=t2(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=t2(this.spec,t,Math.max(0,e-250),Math.min(n+250,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}let t5=a.Pe.define(),t9=a.Pe.define(),t6=a.sU.define({create:t=>new t7(ec(t).create(),null),update(t,e){for(let n of e.effects)n.is(t5)?t=new t7(n.value.create(),t.panel):n.is(t9)&&(t=new t7(t.query,n.value?eh:null));return t},provide:t=>l.S7.from(t,t=>t.panel)});class t7{constructor(t,e){this.query=t,this.panel=e}}let et=l.NZ.mark({class:"cm-searchMatch"}),ee=l.NZ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),en=l.Z9.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(t6))}update(t){let e=t.state.field(t6);(e!=t.startState.field(t6)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return l.NZ.none;let{view:n}=this,i=new a.vB;for(let e=0,r=n.visibleRanges,s=r.length;e<s;e++){let{from:o,to:l}=r[e];for(;e<s-1&&l>r[e+1].from-500;)l=r[++e].to;t.highlight(n.state,o,l,(t,e)=>{let r=n.state.selection.ranges.some(n=>n.from==t&&n.to==e);i.add(t,e,r?ee:et)})}return i.finish()}},{decorations:t=>t.decorations});function ei(t){return e=>{let n=e.state.field(t6,!1);return n&&n.query.spec.valid?t(e,n):ed(e)}}let er=ei((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=a.OF.single(i.from,i.to),s=t.state.facet(tZ);return t.dispatch({selection:r,effects:[ey(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),ef(t),!0}),es=ei((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=a.OF.single(r.from,r.to),o=t.state.facet(tZ);return t.dispatch({selection:s,effects:[ey(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),ef(t),!0}),eo=ei((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!!n&&!!n.length&&(t.dispatch({selection:a.OF.create(n.map(t=>a.OF.range(t.from,t.to))),userEvent:"select.search.matches"}),!0)}),el=ei((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let o=s,h=[],c,u,f=[];o.from==i&&o.to==r&&(u=n.toText(e.getReplacement(o)),h.push({from:o.from,to:o.to,insert:u}),o=e.nextMatch(n,o.from,o.to),f.push(l.Lz.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let d=t.state.changes(h);return o&&(c=a.OF.single(o.from,o.to).map(d),f.push(ey(t,o)),f.push(n.facet(tZ).scrollToMatch(c.main,t))),t.dispatch({changes:d,selection:c,effects:f,userEvent:"input.replace"}),!0}),ea=ei((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(t=>{let{from:n,to:i}=t;return{from:n,to:i,insert:e.getReplacement(t)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:l.Lz.announce.of(i),userEvent:"input.replace.all"}),!0});function eh(t){return t.state.facet(tZ).createPanel(t)}function ec(t,e){var n,i,r,s,o;let l=t.selection.main,a=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=t.facet(tZ);return new tX({search:(null!=(n=null==e?void 0:e.literal)?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!=(i=null==e?void 0:e.caseSensitive)?i:h.caseSensitive,literal:null!=(r=null==e?void 0:e.literal)?r:h.literal,regexp:null!=(s=null==e?void 0:e.regexp)?s:h.regexp,wholeWord:null!=(o=null==e?void 0:e.wholeWord)?o:h.wholeWord})}function eu(t){let e=(0,l.ld)(t,eh);return e&&e.dom.querySelector("[main-field]")}function ef(t){let e=eu(t);e&&e==t.root.activeElement&&e.select()}let ed=t=>{let e=t.state.field(t6,!1);if(e&&e.panel){let n=eu(t);if(n&&n!=t.root.activeElement){let i=ec(t.state,e.query.spec);i.valid&&t.dispatch({effects:t5.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[t9.of(!0),e?t5.of(ec(t.state,e.query.spec)):a.Pe.appendConfig.of(ex)]});return!0},ep=t=>{let e=t.state.field(t6,!1);if(!e||!e.panel)return!1;let n=(0,l.ld)(t,eh);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:t9.of(!1)}),!0},em=[{key:"Mod-f",run:ed,scope:"editor search-panel"},{key:"F3",run:er,shift:es,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:er,shift:es,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ep,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let e=new tR(t.doc,t.sliceDoc(i,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==i&&(o=s.length),s.push(a.OF.range(e.value.from,e.value.to))}return e(t.update({selection:a.OF.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=(0,l.ld)(t,tz);if(!e){let n=[tV.of(!0)];null==t.state.field(tH,!1)&&n.push(a.Pe.appendConfig.of([tH,tW])),t.dispatch({effects:n}),e=(0,l.ld)(t,tz)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(t=>t.from===t.to))return(({state:t,dispatch:e})=>{let{selection:n}=t,i=a.OF.create(n.ranges.map(e=>t.wordAt(e.head)||a.OF.cursor(e.head)),n.mainIndex);return!i.eq(n)&&(e(t.update({selection:i})),!0)})({state:t,dispatch:e});let i=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=i))return!1;let r=function(t,e){let{main:n,ranges:i}=t.selection,r=t.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new tR(t.doc,e,i[i.length-1].to);;)if(r.next(),r.done){if(n)return null;r=new tR(t.doc,e,0,Math.max(0,i[i.length-1].from-1)),n=!0}else{if(n&&i.some(t=>t.from==r.value.from))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}}(t,i);return!!r&&(e(t.update({selection:t.selection.addRange(a.OF.range(r.from,r.to),!1),effects:l.Lz.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class eg{constructor(t){this.view=t;let e=this.query=t.state.field(t6).query.spec;function n(t,e,n){return tT("button",{class:"cm-button",name:t,onclick:e,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=tT("input",{value:e.search,placeholder:ev(t,"Find"),"aria-label":ev(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=tT("input",{value:e.replace,placeholder:ev(t,"Replace"),"aria-label":ev(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=tT("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=tT("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=tT("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=tT("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,n("next",()=>er(t),[ev(t,"next")]),n("prev",()=>es(t),[ev(t,"previous")]),n("select",()=>eo(t),[ev(t,"all")]),tT("label",null,[this.caseField,ev(t,"match case")]),tT("label",null,[this.reField,ev(t,"regexp")]),tT("label",null,[this.wordField,ev(t,"by word")]),...t.state.readOnly?[]:[tT("br"),this.replaceField,n("replace",()=>el(t),[ev(t,"replace")]),n("replaceAll",()=>ea(t),[ev(t,"replace all")])],tT("button",{name:"close",onclick:()=>ep(t),"aria-label":ev(t,"close"),type:"button"},["\xd7"])])}commit(){let t=new tX({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:t5.of(t)}))}keydown(t){(0,l.TS)(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?es:er)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),el(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(t5)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tZ).top}}function ev(t,e){return t.state.phrase(e)}let eb=/[\s\.,:;?!]/;function ey(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-30),o=Math.min(r,n+30),a=t.state.sliceDoc(s,o);if(s!=i.from){for(let t=0;t<30;t++)if(!eb.test(a[t+1])&&eb.test(a[t])){a=a.slice(t);break}}if(o!=r){for(let t=a.length-1;t>a.length-30;t--)if(!eb.test(a[t-1])&&eb.test(a[t])){a=a.slice(0,t);break}}return l.Lz.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${i.number}.`)}let ew=l.Lz.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ex=[t6,a.Nb.low(en),ew];var ek=n(547);class eS{constructor(t,e,n){this.from=t,this.to=e,this.diagnostic=n}}class eC{constructor(t,e,n){this.diagnostics=t,this.panel=e,this.selected=n}static init(t,e,n){let i=n.facet(eL).markerFilter;i&&(t=i(t,n));let r=t.slice().sort((t,e)=>t.from-e.from||t.to-e.to),s=new a.vB,o=[],h=0;for(let t=0;;){let e,i,a=t==r.length?null:r[t];if(!a&&!o.length)break;for(o.length?(e=h,i=o.reduce((t,e)=>Math.min(t,e.to),a&&a.from>e?a.from:1e8)):(e=a.from,i=a.to,o.push(a),t++);t<r.length;){let n=r[t];if(n.from==e&&(n.to>n.from||n.to==e))o.push(n),t++,i=Math.min(n.to,i);else{i=Math.min(n.from,i);break}}let c=function(t){let e="hint",n=1;for(let r of t){var i;let t="error"==(i=r.severity)?4:"warning"==i?3:"info"==i?2:1;t>n&&(n=t,e=r.severity)}return e}(o);if(o.some(t=>t.from==t.to||t.from==t.to-1&&n.doc.lineAt(t.from).to==t.from))s.add(e,e,l.NZ.widget({widget:new eF(c),diagnostics:o.slice()}));else{let t=o.reduce((t,e)=>e.markClass?t+" "+e.markClass:t,"");s.add(e,i,l.NZ.mark({class:"cm-lintRange cm-lintRange-"+c+t,diagnostics:o.slice(),inclusiveEnd:o.some(t=>t.to>i)}))}h=i;for(let t=0;t<o.length;t++)o[t].to<=h&&o.splice(t--,1)}let c=s.finish();return new eC(c,e,eA(c))}}function eA(t,e=null,n=0){let i=null;return t.between(n,1e9,(t,n,{spec:r})=>{if(!(e&&0>r.diagnostics.indexOf(e)))if(i){if(0>r.diagnostics.indexOf(i.diagnostic))return!1;i=new eS(i.from,n,i.diagnostic)}else i=new eS(t,n,e||r.diagnostics[0])}),i}function eO(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(eL).hideOn(t,n,i);if(null!=r)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(t=>t.is(eM))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}let eM=a.Pe.define(),eD=a.Pe.define(),eP=a.Pe.define(),eT=a.sU.define({create:()=>new eC(l.NZ.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);i=eA(n,t.selected.diagnostic,r)||eA(n,null,r)}!n.size&&r&&e.state.facet(eL).autoPanel&&(r=null),t=new eC(n,r,i)}for(let n of e.effects)if(n.is(eM)){let i=e.state.facet(eL).autoPanel?n.value.length?e_.open:null:t.panel;t=eC.init(n.value,i,e.state)}else n.is(eD)?t=new eC(t.diagnostics,n.value?e_.open:null,t.selected):n.is(eP)&&(t=new eC(t.diagnostics,t.panel,n.value));return t},provide:t=>[l.S7.from(t,t=>t.panel),l.Lz.decorations.from(t,t=>t.diagnostics)]}),eE=l.NZ.mark({class:"cm-lintRange cm-lintRange-active"}),eR=t=>{let e=t.state.field(eT,!1);return!!e&&!!e.panel&&(t.dispatch({effects:eD.of(!1)}),!0)},eB=[{key:"Mod-Shift-m",run:t=>{var e,n;let i=t.state.field(eT,!1);i&&i.panel||t.dispatch({effects:(e=t.state,n=[eD.of(!0)],e.field(eT,!1)?n:n.concat(a.Pe.appendConfig.of(eW)))});let r=(0,l.ld)(t,e_.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(eT,!1);if(!e)return!1;let n=t.state.selection.main,i=e.diagnostics.iter(n.to+1);return(!!i.value||!!(i=e.diagnostics.iter(0)).value&&(i.from!=n.from||i.to!=n.to))&&(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],eL=a.sj.define({combine:t=>Object.assign({sources:t.map(t=>t.source).filter(t=>null!=t)},(0,a.QR)(t.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?n=>t(n)||e(n):t:e}))});function eN(t){let e=[];if(t)t:for(let{name:n}of t){for(let t=0;t<n.length;t++){let i=n[t];if(/[a-zA-Z]/.test(i)&&!e.some(t=>t.toLowerCase()==i.toLowerCase())){e.push(i);continue t}}e.push("")}return e}function eI(t,e,n){var i;let r=n?eN(e.actions):[];return tT("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},tT("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null==(i=e.actions)?void 0:i.map((n,i)=>{let s=!1,o=i=>{if(i.preventDefault(),s)return;s=!0;let r=eA(t.state.field(eT).diagnostics,e);r&&n.apply(t,r.from,r.to)},{name:l}=n,a=r[i]?l.indexOf(r[i]):-1,h=a<0?l:[l.slice(0,a),tT("u",l.slice(a,a+1)),l.slice(a+1)];return tT("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${l}${a<0?"":` (access key "${r[i]})"`}.`},h)}),e.source&&tT("div",{class:"cm-diagnosticSource"},e.source))}class eF extends l.xO{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return tT("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ej{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=eI(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class e_{constructor(t){this.view=t,this.items=[];let e=e=>{if(27==e.keyCode)eR(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65)||!(e.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],i=eN(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=eA(this.view.state.field(eT).diagnostics,n);e&&n.actions[r].apply(t,e.from,e.to)}}e.preventDefault()},n=t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)};this.list=tT("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:n}),this.dom=tT("div",{class:"cm-panel-lint"},this.list,tT("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>eR(this.view)},"\xd7")),this.update()}get selectedIndex(){let t=this.view.state.field(eT).selected;if(!t)return -1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return -1}update(){let{diagnostics:t,selected:e}=this.view.state.field(eT),n=0,i=!1,r=null,s=new Set;for(t.between(0,this.view.state.doc.length,(t,o,{spec:l})=>{for(let t of l.diagnostics){if(s.has(t))continue;s.add(t);let o=-1,l;for(let e=n;e<this.items.length;e++)if(this.items[e].diagnostic==t){o=e;break}o<0?(l=new ej(this.view,t),this.items.splice(n,0,l),i=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),i=!0)),e&&l.diagnostic==e.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),r=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new ej(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let n=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/n:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;t!=n.dom;)e();t=n.dom.nextSibling}else this.list.insertBefore(n.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=eA(this.view.state.field(eT).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:eP.of(e)})}static open(t){return new e_(t)}}function ez(t){return function(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}let eV=l.Lz.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ez("#d11")},".cm-lintRange-warning":{backgroundImage:ez("orange")},".cm-lintRange-info":{backgroundImage:ez("#999")},".cm-lintRange-hint":{backgroundImage:ez("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});l.wJ;let eH=a.Pe.define(),eW=[eT,l.Lz.decorations.compute([eT],t=>{let{selected:e,panel:n}=t.field(eT);return e&&n&&e.from!=e.to?l.NZ.set([eE.range(e.from,e.to)]):l.NZ.none}),(0,l.Ux)(function(t,e,n){let{diagnostics:i}=t.state.field(eT),r,s=-1,o=-1;i.between(e-(n<0),e+ +(n>0),(t,i,{spec:l})=>{if(e>=t&&e<=i&&(t==i||(e>t||n>0)&&(e<i||n<0)))return r=l.diagnostics,s=t,o=i,!1});let l=t.state.facet(eL).tooltipFilter;return(r&&l&&(r=l(r,t.state)),r)?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>{var e;return{dom:(e=t,tT("ul",{class:"cm-tooltip-lint"},r.map(t=>eI(e,t,!1))))}}}:null},{hideOn:eO}),eV],eq=[(0,l.$K)(),(0,l.Wu)(),(0,l.N$)(),function(t={}){return[x,w.of(t),l.Lz.domEventHandlers({beforeinput(t,e){let n="historyUndo"==t.inputType?S:"historyRedo"==t.inputType?C:null;return!!n&&(t.preventDefault(),n(e))}})]}(),(0,h.Lv)(),(0,l.VH)(),(0,l.A)(),a.$t.allowMultipleSelections.of(!0),(0,h.WD)(),(0,h.y9)(h.Zt,{fallback:!0}),(0,h.SG)(),(0,ek.wm)(),(0,ek.yU)(),(0,l.D4)(),(0,l.HJ)(),(0,l.dz)(),[tG,tY],l.w4.of([...ek.Bc,...tP,...em,{key:"Mod-z",run:S,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:C,preventDefault:!0},{linux:"Ctrl-Shift-z",run:C,preventDefault:!0},{key:"Mod-u",run:A,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:O,preventDefault:!0},...h.f7,...ek.OO,...eB])],eU=a.YH.define(),e$=a.sj.define();class eK{constructor(t,e,n,i,r){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(t){return new eK(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:null==(t=this.changes)?void 0:t.toJSON(),mapped:null==(e=this.mapped)?void 0:e.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new eK(t.changes&&a.VR.fromJSON(t.changes),[],t.mapped&&a.Gu.fromJSON(t.mapped),t.startSelection&&a.OF.fromJSON(t.startSelection),t.selectionsAfter.map(a.OF.fromJSON))}static fromTransaction(t,e){let n=eG;for(let e of t.startState.facet(e$)){let i=e(t);i.length&&(n=n.concat(i))}return!n.length&&t.changes.empty?null:new eK(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,eG)}static selection(t){return new eK(void 0,eG,void 0,void 0,t)}}function eJ(t,e,n,i){let r=t.slice(e+1>n+20?e-n-1:0,e);return r.push(i),r}function eY(t,e){return t.length?e.length?t.concat(e):t:e}let eG=[];function eZ(t,e){if(!t.length)return t;let n=t.length,i=eG;for(;n;){let r=function(t,e,n){let i=eY(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):eG,n);if(!t.changes)return eK.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new eK(r,a.Pe.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,n);return e[n-1]=r,e}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[eK.selection(i)]:eG}let eX=/^(input\.type|delete)($|\.)/;class eQ{constructor(t,e,n=0,i){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new eQ(this.done,this.undone):this}addChanges(t,e,n,i,r){var s,o;let l,h,c=this.done,u=c[c.length-1];return new eQ(c=u&&u.changes&&!u.changes.empty&&t.changes&&(!n||eX.test(n))&&(!u.selectionsAfter.length&&e-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,(s=u.changes,o=t.changes,l=[],h=!1,s.iterChangedRanges((t,e)=>l.push(t,e)),o.iterChangedRanges((t,e,n,i)=>{for(let t=0;t<l.length;){let e=l[t++],r=l[t++];i>=e&&n<=r&&(h=!0)}}),h))||"input.type.compose"==n)?eJ(c,c.length-1,i.minDepth,new eK(t.changes.compose(u.changes),eY(a.Pe.mapEffects(t.effects,u.changes),u.effects),u.mapped,u.startSelection,eG)):eJ(c,c.length,i.minDepth,t),eG,e,n)}addSelection(t,e,n,i){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:eG;return s.length>0&&e-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(r=s[s.length-1],r.ranges.length==t.ranges.length&&0===r.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length)?this:new eQ(function(t,e){if(!t.length)return[eK.selection([e])];{let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),eJ(t,t.length-1,1e9,n.setSelAfter(i)))}}(this.done,t),this.undone,e,n)}addMapping(t){return new eQ(eZ(this.done,t),eZ(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let i=0==t?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):e.selection);if(n&&r.selectionsAfter.length){let n,o;return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:eU.of({side:t,rest:(n=i[i.length-1],(o=i.slice())[i.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let n=1==i.length?eG:i.slice(0,i.length-1);return r.mapped&&(n=eZ(n,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:eU.of({side:t,rest:n,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}}}eQ.empty=new eQ(eG,eG),"u">typeof Intl&&Intl.Segmenter;var e0=n(681),e1=n(581);function e2(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e4(t,e,n,i,r,s,o){try{var l=t[s](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function e3(){var t,e,n=(t=["\n display: flex;\n width: 100%;\n\n .cm-editor {\n width: 100%;\n border-radius: ","px;\n border: 1px solid ",";\n &:hover {\n border-color: ",";\n }\n overflow: hidden;\n\n &.cm-focused {\n border-color: ",";\n outline: none;\n }\n\n .cm-content {\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n }\n }\n "],e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}})));return e3=function(){return n},n}var e8=(0,s.createStyles)(function(t){var e=t.token;return{box:(0,t.css)(e3(),e.borderRadius,e.colorBorder,e.colorPrimaryHover,e.colorPrimaryHover)}}),e5=l.Lz.theme({".cm-scroller":{backgroundColor:"#f0f0f0"}}),e9=l.Lz.theme({".cm-scroller":{backgroundColor:"#fff"}});function e6(t){return t&&"auto"!==t?l.Lz.theme({"&":{height:t,minHeight:"120px"},".cm-editor":{height:"100%",minHeight:"120px"},".cm-scroller":{height:"100%",minHeight:"120px",overflow:"auto"}}):l.Lz.theme({"&":{minHeight:"120px"},".cm-editor":{minHeight:"120px"},".cm-scroller":{minHeight:"120px"}})}function e7(t){var e,n,s=t.language,o=t.height,c=t.indentUnit,u=function(t,e){if(null==t)return{};var n,i,r,s={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,n=Reflect.ownKeys(Object(t));r<n.length;r++)i=n[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(s[i]=t[i]);return s}if(s=function(t,e){if(null==t)return{};var n,i,r={},s=Object.getOwnPropertyNames(t);for(i=0;i<s.length;i++)n=s[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n]);return r}(t,e),Object.getOwnPropertySymbols)for(r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i=n[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(s[i]=t[i]);return s}(t,["language","height","indentUnit"]),f=u.value,d=u.onChange,p=u.disabled,m=e8().styles,g=function(t){if(Array.isArray(t))return t}(e=(0,i.useState)(null))||function(t){var e,n,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r=[],s=!0,o=!1;try{for(i=i.call(t);!(s=(e=i.next()).done)&&(r.push(e.value),2!==r.length);s=!0);}catch(t){o=!0,n=t}finally{try{s||null==i.return||i.return()}finally{if(o)throw n}}return r}}(e)||function(t){if(t){if("string"==typeof t)return e2(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return e2(t,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),v=g[0],b=g[1],y=(0,i.useRef)(null),w=(0,i.useRef)(null),x=(0,i.useRef)(d);x.current=d;var k=(0,i.useRef)(2),S=(0,i.useRef)(new a.xx).current,C=(0,i.useRef)(new a.xx).current,A=(0,i.useRef)(new a.xx).current,O=(0,i.useRef)(new a.xx).current,M=(0,i.useRef)(new a.xx).current,D=(0,i.useRef)(new a.xx).current,P=(0,i.useRef)(new a.xx).current,T=!Number.isFinite(n=Number(c))||n<=0?2:Math.floor(n);k.current=T;var E=function(){return a.Nb.highest(l.w4.of([{key:"Tab",run:function(t){if(!t.state.facet(l.Lz.editable))return!1;var e=" ".repeat(k.current),n=t.state.changeByRange(function(t){return{changes:{from:t.from,to:t.to,insert:e},range:a.OF.cursor(t.from+e.length)}});return t.dispatch(n),!0}},{key:"Shift-Tab",run:function(t){return(({state:t,dispatch:e})=>{var n;let i;return!t.readOnly&&(e(t.update((n=(e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=(0,a.y$)(i,t.tabSize),s=0,o=(0,h.EI)(t,Math.max(0,r-(0,h.tp)(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})},i=-1,t.changeByRange(e=>{let r=[];for(let s=e.from;s<=e.to;){let o=t.doc.lineAt(s);o.number>i&&(e.empty||e.to>o.from)&&(n(o,r,e),i=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:a.OF.range(s.mapPos(e.anchor,1),s.mapPos(e.head,1))}})),{userEvent:"delete.dedent"})),!0)})(t)}}]))};return(0,i.useEffect)(function(){var t;(t=function(){return function(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(o,"next",{value:a(0)}),l(o,"throw",{value:a(1)}),l(o,"return",{value:a(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function a(l){return function(a){var h=[l,a];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&h[0]?i.return:h[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,h[1])).done)return r;switch(i=0,r&&(h=[2&h[0],r.value]),h[0]){case 0:case 1:r=h;break;case 4:return s.label++,{value:h[1],done:!1};case 5:s.label++,i=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===h[0]||2===h[0])){s=0;continue}if(3===h[0]&&(!r||h[1]>r[0]&&h[1]<r[3])){s.label=h[1];break}if(6===h[0]&&s.label<r[1]){s.label=r[1],r=h;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(h);break}r[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(t){h=[6,t],i=0}finally{n=r=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}}(this,function(t){return e0.V[s]?[2,e0.V[s].load()]:(console.warn("Language ".concat(s," not supported.")),[2,null])})},function(){var e=this,n=arguments;return new Promise(function(i,r){var s=t.apply(e,n);function o(t){e4(s,i,r,o,l,"next",t)}function l(t){e4(s,i,r,o,l,"throw",t)}o(void 0)})})().then(function(t){b(t)}).catch(function(t){console.error("Error loading language:",t)})},[s]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:[C.reconfigure(e1.indentUnit.of(" ".repeat(T))),A.reconfigure(a.$t.tabSize.of(T)),O.reconfigure(E())]})},[T,C,O,A]),(0,i.useEffect)(function(){if(y.current&&!w.current){var t=a.$t.create({doc:f||"",extensions:[eq,S.of(v||[]),C.of(e1.indentUnit.of(" ".repeat(T))),A.of(a.$t.tabSize.of(T)),O.of(E()),M.of(l.Lz.editable.of(!p)),D.of(p?e5:e9),P.of(e6(o)),l.Lz.updateListener.of(function(t){if(t.docChanged){var e;null==(e=x.current)||e.call(x,t.state.doc.toString())}})]}),e=new l.Lz({state:t,parent:y.current});return w.current=e,function(){e.destroy(),w.current=null}}},[]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:S.reconfigure(v||[])})},[v,S]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:M.reconfigure(l.Lz.editable.of(!p))})},[p,M]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:D.reconfigure(p?e5:e9)})},[p,D]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:P.reconfigure(e6(o))})},[o,P]),(0,i.useEffect)(function(){var t=w.current;if(t){var e=f||"";t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}},[f]),r().createElement("div",{className:m.box},r().createElement("div",{ref:y,style:{width:"100%"}}))}var nt=(0,o.connect)(e7,(0,o.mapReadPretty)(function(t){var e,n;return r().createElement(e7,(e=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},t),n=n={disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e))}))},681:function(t,e,n){"use strict";n.d(e,{V:function(){return a},X:function(){return l}});var i=n(631);function r(t,e,n,i,r,s,o){try{var l=t[s](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function s(t){return function(){var e=this,n=arguments;return new Promise(function(i,s){var o=t.apply(e,n);function l(t){r(o,i,s,l,a,"next",t)}function a(t){r(o,i,s,l,a,"throw",t)}l(void 0)})}}function o(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(o,"next",{value:a(0)}),l(o,"throw",{value:a(1)}),l(o,"return",{value:a(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function a(l){return function(a){var h=[l,a];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&h[0]?i.return:h[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,h[1])).done)return r;switch(i=0,r&&(h=[2&h[0],r.value]),h[0]){case 0:case 1:r=h;break;case 4:return s.label++,{value:h[1],done:!1};case 5:s.label++,i=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===h[0]||2===h[0])){s=0;continue}if(3===h[0]&&(!r||h[1]>r[0]&&h[1]<r[3])){s.label=h[1];break}if(6===h[0]&&s.label<r[1]){s.label=r[1],r=h;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(h);break}r[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(t){h=[6,t],i=0}finally{n=r=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}}var l=[{value:"javascript",label:"JavaScript",load:function(){return s(function(){return o(this,function(t){switch(t.label){case 0:return[4,i("imported_4vss2k_component",Promise.all([n.e("214"),n.e("176")]).then(n.bind(n,187)))];case 1:return[2,(0,t.sent().javascript)()]}})})()}},{value:"java",label:"Java",load:function(){return s(function(){return o(this,function(t){switch(t.label){case 0:return[4,i("imported_-8tq2d4_component",Promise.all([n.e("214"),n.e("299")]).then(n.bind(n,982)))];case 1:return[2,(0,t.sent().java)()]}})})()}},{value:"sql",label:"SQL",load:function(){return s(function(){return o(this,function(t){switch(t.label){case 0:return[4,i("imported_-1s5b33f_component",Promise.all([n.e("214"),n.e("613")]).then(n.bind(n,124)))];case 1:return[2,(0,t.sent().sql)()]}})})()}},{value:"python",label:"Python",load:function(){return s(function(){return o(this,function(t){switch(t.label){case 0:return[4,i("imported_e67311_component",Promise.all([n.e("214"),n.e("707")]).then(n.bind(n,374)))];case 1:return[2,(0,t.sent().python)()]}})})()}},{value:"groovy",label:"Groovy",load:function(){return s(function(){var t,e;return o(this,function(r){switch(r.label){case 0:return[4,i("imported_-60lkaf_component",Promise.resolve().then(n.bind(n,581)))];case 1:return t=r.sent().StreamLanguage,[4,i("imported_17juot3_component",n.e("815").then(n.bind(n,922)))];case 2:return e=r.sent().groovy,[2,t.define(e)]}})})()}}],a=Object.fromEntries(l.map(function(t){return[t.value,t]}))},631:function(t){t.exports=function(t,e){return"u">typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(t,e),e}},230:function(e){"use strict";e.exports=t},342:function(t){"use strict";t.exports=r},694:function(t){"use strict";t.exports=e},59:function(t){"use strict";t.exports=i},235:function(t){"use strict";t.exports=s},155:function(t){"use strict";t.exports=n},547:function(t,e,n){"use strict";n.d(e,{Ar:function(){return h},Bc:function(){return ty},Gw:function(){return tl},OO:function(){return tA},et:function(){return a},wm:function(){return td},yU:function(){return tC}});var i=n(492),r=n(867),s=n(169);class o{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,s.mv)(this.state).resolveInner(this.pos,-1);for(;e&&0>t.indexOf(e.name);)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),r=i.search(f(t,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,n){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function l(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function a(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[n,i]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let t=1;t<i.length;t++)n[i[t]]=!0}let i=l(e)+l(n)+"*$";return[RegExp("^"+i),new RegExp(i)]}(e);return t=>{let r=t.matchBefore(i);return r||t.explicit?{from:r?r.from:t.pos,options:e,validFor:n}:null}}function h(t,e){return n=>{for(let e=(0,s.mv)(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class c{constructor(t,e,n,i){this.completion=t,this.source=e,this.match=n,this.score=i}}function u(t){return t.selection.main.from}function f(t,e){var n;let{source:i}=t,r=e&&"^"!=i[0],s="$"!=i[i.length-1];return r||s?RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,null!=(n=t.flags)?n:t.ignoreCase?"i":""):t}let d=i.YH.define(),p=new WeakMap;function m(t){if(!Array.isArray(t))return t;let e=p.get(t);return e||p.set(t,e=a(t)),e}let g=i.Pe.define(),v=i.Pe.define();class b{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let n=(0,i.vS)(t,e),r=(0,i.Fh)(n);this.chars.push(n);let s=t.slice(e,e+r),o=s.toUpperCase();this.folded.push((0,i.vS)(o==s?s.toLowerCase():o,0)),e+=r}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:n,any:r,precise:s,byWord:o}=this;if(1==e.length){let r=(0,i.vS)(t,0),s=(0,i.Fh)(r),o=s==t.length?0:-100;if(r==e[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,s])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,h=0;if(l<0){for(let s=0,o=Math.min(t.length,200);s<o&&h<a;){let o=(0,i.vS)(t,s);(o==e[h]||o==n[h])&&(r[h++]=s),s+=(0,i.Fh)(o)}if(h<a)return null}let c=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(t),v=!0;for(let r=0,h=Math.min(t.length,200),b=0;r<h&&u<a;){let h=(0,i.vS)(t,r);l<0&&(c<a&&h==e[c]&&(s[c++]=r),d<a&&(h==e[d]||h==n[d]?(0==d&&(p=r),m=r+1,d++):d=0));let y,w=h<255?h>=48&&h<=57||h>=97&&h<=122?2:+(h>=65&&h<=90):(y=(0,i.MK)(h))!=y.toLowerCase()?1:2*(y!=y.toUpperCase());(!r||1==w&&g||0==b&&0!=w)&&(e[u]==h||n[u]==h&&(f=!0)?o[u++]=r:o.length&&(v=!1)),b=w,r+=(0,i.Fh)(h)}return u==a&&0==o[0]&&v?this.result(-100+(f?-200:0),o,t):d==a&&0==p?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==a?this.ret(-900-t.length,[p,m]):u==a?this.result(-100+(f?-200:0)+-700+(v?0:-1100),o,t):2==e.length?null:this.result((r[0]?-700:0)+-200+-1100,r,t)}result(t,e,n){let r=[],s=0;for(let t of e){let e=t+(this.astral?(0,i.Fh)((0,i.vS)(n,t)):1);s&&r[s-1]==t?r[s-1]=e:(r[s++]=t,r[s++]=e)}return this.ret(t-n.length,r)}}class y{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}let w=i.sj.define({combine:t=>(0,i.QR)(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:k,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>x(t(n),e(n)),optionClass:(t,e)=>n=>x(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function x(t,e){return t?e?t+" "+e:t:e}function k(t,e,n,i,s,o){let l=t.textDirection==r.OP.RTL,a=l,h=!1,c="top",u,f,d=e.left-s.left,p=s.right-e.right,m=i.right-i.left,g=i.bottom-i.top;if(a&&d<Math.min(m,p)?a=!1:!a&&p<Math.min(m,d)&&(a=!0),m<=(a?d:p))u=Math.max(s.top,Math.min(n.top,s.bottom-g))-e.top,f=Math.min(400,a?d:p);else{h=!0,f=Math.min(400,(l?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=g||t>e.top?u=n.bottom-e.top:(c="bottom",u=e.bottom-n.top)}let v=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/v}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":a?"left":"right")}}function S(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class C{constructor(t,e,n){this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let i=t.state.field(e),{options:r,selected:s}=i.open,o=t.state.facet(w);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map(t=>"cm-completionIcon-"+t)),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let s=t.displayLabel||t.label,o=0;for(let t=0;t<i.length;){let e=i[t++],n=i[t++];e>o&&r.appendChild(document.createTextNode(s.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(e,n))),l.className="cm-completionMatchedText",o=n}return o<s.length&&r.appendChild(document.createTextNode(s.slice(o))),r},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((t,e)=>t.position-e.position).map(t=>t.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=S(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=t.state.field(e).open;for(let e=n.target,r;e&&e!=this.dom;e=e.parentNode)if("LI"==e.nodeName&&(r=/-(\d+)$/.exec(e.id))&&+r[1]<i.length){this.applyCompletion(t,i[+r[1]]),n.preventDefault();return}}),this.dom.addEventListener("focusout",e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(w).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:v.of(null)})}),this.showOptions(r,i.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let n=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=i){let{options:r,selected:s,disabled:o}=n.open;i.open&&i.open.options==r||(this.range=S(r.length,s,t.state.facet(w).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),o!=(null==(e=i.open)?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=S(e.options.length,e.selected,this.view.state.facet(w).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:i}=n;if(!i)return;let s="string"==typeof i?document.createTextNode(i):i(n);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)}).catch(t=>(0,r.c_)(this.view.state,t,"completion info")):this.addInfoPane(s,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:i}=t;n.appendChild(e),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){var e,n;let i,r,s,o=null;for(let e=this.list.firstChild,n=this.range.from;e;e=e.nextSibling,n++)"LI"==e.nodeName&&e.id?n==t?e.hasAttribute("aria-selected")||(e.setAttribute("aria-selected","true"),o=e):e.hasAttribute("aria-selected")&&e.removeAttribute("aria-selected"):n--;return o&&(e=this.list,n=o,i=e.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.height/e.offsetHeight,r.top<i.top?e.scrollTop-=(i.top-r.top)/s:r.bottom>i.bottom&&(e.scrollTop+=(r.bottom-i.bottom)/s)),o}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),r=this.space;if(!r){let t=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return i.top>Math.min(r.bottom,e.bottom)-10||i.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(w).positionInfo(this.view,e,i,n,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,n){let i=document.createElement("ul");i.id=e,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",t=>{t.target==i&&t.preventDefault()});let r=null;for(let s=n.from;s<n.to;s++){let{completion:o,match:l}=t[s],{section:a}=o;if(a){let t="string"==typeof a?a:a.name;t!=r&&(s>n.from||0==n.from)&&(r=t,"string"!=typeof a&&a.header?i.appendChild(a.header(a)):i.appendChild(document.createElement("completion-section")).textContent=t)}let h=i.appendChild(document.createElement("li"));h.id=e+"-"+s,h.setAttribute("role","option");let c=this.optionClass(o);for(let t of(c&&(h.className=c),this.optionContent)){let e=t(o,this.view.state,this.view,l);e&&h.appendChild(e)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function A(t){return 100*(t.boost||0)+10*!!t.apply+5*!!t.info+ +!!t.type}class O{constructor(t,e,n,i,r,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new O(this.options,T(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,i,r,s){if(i&&!s&&t.some(t=>t.isPending))return i.setDisabled();let o=function(t,e){let n=[],i=null,r=t=>{n.push(t);let{section:e}=t.completion;if(e){i||(i=[]);let t="string"==typeof e?e:e.name;i.some(e=>e.name==t)||i.push("string"==typeof e?{name:t}:e)}},s=e.facet(w);for(let i of t)if(i.hasResult()){let t=i.result.getMatch;if(!1===i.result.filter)for(let e of i.result.options)r(new c(e,i.source,t?t(e):[],1e9-n.length));else{let n=e.sliceDoc(i.from,i.to),o,l=s.filterStrict?new y(n):new b(n);for(let e of i.result.options)if(o=l.match(e.label)){let n=e.displayLabel?t?t(e,o.matched):[]:o.matched;r(new c(e,i.source,n,o.score+(e.boost||0)))}}}if(i){let t=Object.create(null),e=0;for(let n of i.sort((t,e)=>{var n,i;return(null!=(n=t.rank)?n:1e9)-(null!=(i=e.rank)?i:1e9)||(t.name<e.name?-1:1)}))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let o=[],l=null,a=s.compareCompletions;for(let t of n.sort((t,e)=>e.score-t.score||a(t.completion,e.completion))){let e=t.completion;l&&l.label==e.label&&l.detail==e.detail&&(null==l.type||null==e.type||l.type==e.type)&&l.apply==e.apply&&l.boost==e.boost?A(t.completion)>A(l)&&(o[o.length-1]=t):o.push(t),l=t.completion}return o}(t,e);if(!o.length)return i&&t.some(t=>t.isPending)?i.setDisabled():null;let l=e.facet(w).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected){let t=i.options[i.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){l=e;break}}return new O(o,T(n,l),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:_,above:r.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new O(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new O(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class M{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new M(E,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(w),i=(n.override||e.languageDataAt("autocomplete",u(e)).map(m)).map(e=>(this.active.find(t=>t.source==e)||new B(e,+!!this.active.some(t=>0!=t.state))).update(t,n));i.length==this.active.length&&i.every((t,e)=>t==this.active[e])&&(i=this.active);let r=this.open,s=t.effects.some(t=>t.is(N));for(let o of(r&&t.docChanged&&(r=r.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!function(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}(i,this.active)||s?r=O.build(i,e,this.id,r,n,s):r&&r.disabled&&!i.some(t=>t.isPending)&&(r=null),!r&&i.every(t=>!t.isPending)&&i.some(t=>t.hasResult())&&(i=i.map(t=>t.hasResult()?new B(t.source,0):t)),t.effects))o.is(I)&&(r=r&&r.setSelected(o.value,this.id));return i==this.active&&r==this.open?this:new M(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?D:P}}let D={"aria-autocomplete":"list"},P={};function T(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}let E=[];function R(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(d);if(n&&e.activateOnCompletion(n))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:16*!!t.docChanged}class B{constructor(t,e,n=!1){this.source=t,this.state=e,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let n=R(t,e),i=this;for(let e of((8&n||16&n&&this.touches(t))&&(i=new B(i.source,0)),4&n&&0==i.state&&(i=new B(this.source,1)),i=i.updateFor(t,n),t.effects))if(e.is(g))i=new B(i.source,1,e.value);else if(e.is(v))i=new B(i.source,0);else if(e.is(N))for(let t of e.value)t.source==i.source&&(i=t);return i}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(u(t.state))}}class L extends B{constructor(t,e,n,i,r,s){super(t,3,e),this.limit=n,this.result=i,this.from=r,this.to=s}hasResult(){return!0}updateFor(t,e){var n;if(!(3&e))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let r=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),l=u(t.state);if(l>s||!i||2&e&&(u(t.startState)==this.from||l<this.limit))return new B(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return!function(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return"function"==typeof t?t(r,n,i,e):f(t,!0).test(r)}(i.validFor,t.state,r,s)?i.update&&(i=i.update(i,r,s,new o(t.state,l,!1)))?new L(this.source,this.explicit,a,i,i.from,null!=(n=i.to)?n:u(t.state)):new B(this.source,1,this.explicit):new L(this.source,this.explicit,a,i,r,s)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new L(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new B(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}let N=i.Pe.define({map:(t,e)=>t.map(t=>t.map(e))}),I=i.Pe.define(),F=i.sU.define({create:()=>M.start(),update:(t,e)=>t.update(e),provide:t=>[r.DK.from(t,t=>t.tooltip),r.Lz.contentAttributes.from(t,t=>t.attrs)]});function j(t,e){let n=e.completion.apply||e.completion.label,r=t.state.field(F).active.find(t=>t.source==e.source);return r instanceof L&&("string"==typeof n?t.dispatch(Object.assign(Object.assign({},function(t,e,n,r){let{main:s}=t.selection,o=n-s.from,l=r-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&n!=r&&t.sliceDoc(a.from+o,a.from+l)!=t.sliceDoc(n,r))return{range:a};let h=t.toText(e);return{changes:{from:a.from+o,to:r==s.from?a.to:a.from+l,insert:h},range:i.OF.cursor(a.from+o+h.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,n,r.from,r.to)),{annotations:d.of(e.completion)})):n(t,e.completion,r.from,r.to),!0)}let _=t=>new C(t,F,j);function z(t,e="option"){return n=>{let i=n.state.field(F,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(w).interactionDelay)return!1;let s=1,o;"page"==e&&(o=(0,r.Eg)(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:l}=i.open.options,a=i.open.selected>-1?i.open.selected+s*(t?1:-1):t?0:l-1;return a<0?a="page"==e?0:l-1:a>=l&&(a="page"==e?l-1:0),n.dispatch({effects:I.of(a)}),!0}}let V=t=>!!t.state.field(F,!1)&&(t.dispatch({effects:g.of(!0)}),!0);class H{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}let W=r.Z9.fromClass(class{constructor(t){for(let e of(this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,t.state.field(F).active))e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(F),n=t.state.facet(w);if(!t.selectionSet&&!t.docChanged&&t.startState.field(F)==e)return;let i=t.transactions.some(t=>{let e=R(t,n);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let n=this.running[e];if(i||n.context.abortOnDocChange&&t.docChanged||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){(0,r.c_)(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(g)))&&(this.pendingStart=!0);let s=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(F);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(w).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=u(e),i=new o(e,n,t.explicit,this.view),s=new H(t,i);this.running.push(s),Promise.resolve(t.source(i)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:v.of(null)}),(0,r.c_)(this.view.state,t)})}scheduleAccept(){this.running.every(t=>void 0!==t.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(w).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(w),i=this.view.state.field(F);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(void 0===s.done)continue;if(this.running.splice(r--,1),s.done){let i=u(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(i,s.done.from+ +!s.active.explicit),o=new L(s.active.source,s.active.explicit,r,s.done,s.done.from,null!=(t=s.done.to)?t:i);for(let t of s.updates)o=o.update(t,n);if(o.hasResult()){e.push(o);continue}}let o=i.active.find(t=>t.source==s.active.source);if(o&&o.isPending)if(null==s.done){let t=new B(s.active.source,0);for(let e of s.updates)t=t.update(e,n);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:N.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(F,!1);if(e&&e.tooltip&&this.view.state.facet(w).closeOnBlur){let n=e.open&&(0,r.Eg)(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:v.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:g.of(!1)}),20),this.composing=0}}}),q="object"==typeof navigator&&/Win/.test(navigator.platform),U=i.Nb.highest(r.Lz.domEventHandlers({keydown(t,e){let n=e.state.field(F,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(q&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(t=>t.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&j(e,i),!1}})),$=r.Lz.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'\uD835\uDC65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\uD835\uDC36'"}},".cm-completionIcon-type":{"&:after":{content:"'\uD835\uDC61'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class K{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class J{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,i.iR.TrackDel),n=t.mapPos(this.to,1,i.iR.TrackDel);return null==e||null==n?null:new J(this.field,e,n)}}class Y{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],r=t.doc.lineAt(e),o=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(n.length){let n=o,l=/^\t*/.exec(r)[0].length;for(let e=0;e<l;e++)n+=t.facet(s.Xt);i.push(e+n.length-l),r=n+r.slice(l)}n.push(r),e+=r.length+1}return{text:n,ranges:this.fieldPositions.map(t=>new J(t.field,i[t.line]+t.from,i[t.line]+t.to))}}static parse(t){let e=[],n=[],i=[],r;for(let s of t.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=r[1]?+r[1]:null,o=r[2]||r[3]||"",l=-1,a=o.replace(/\\[{}]/g,t=>t[1]);for(let n=0;n<e.length;n++)(null!=t?e[n].seq==t:a&&e[n].name==a)&&(l=n);if(l<0){let n=0;for(;n<e.length&&(null==t||null!=e[n].seq&&e[n].seq<t);)n++;for(let r of(e.splice(n,0,{seq:t,name:a}),l=n,i))r.field>=l&&r.field++}i.push(new K(l,n.length,r.index,r.index+a.length)),s=s.slice(0,r.index)+o+s.slice(r.index+r[0].length)}s=s.replace(/\\([{}])/g,(t,e,r)=>{for(let t of i)t.line==n.length&&t.from>r&&(t.from--,t.to--);return e}),n.push(s)}return new Y(n,i)}}let G=r.NZ.widget({widget:new class extends r.xO{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Z=r.NZ.mark({class:"cm-snippetField"});class X{constructor(t,e){this.ranges=t,this.active=e,this.deco=r.NZ.set(t.map(t=>(t.from==t.to?G:Z).range(t.from,t.to)))}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new X(e,this.active)}selectionInsideField(t){return t.ranges.every(t=>this.ranges.some(e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))}}let Q=i.Pe.define({map:(t,e)=>t&&t.map(e)}),tt=i.Pe.define(),te=i.sU.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(Q))return n.value;if(n.is(tt)&&t)return new X(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>r.Lz.decorations.from(t,t=>t?t.deco:r.NZ.none)});function tn(t,e){return i.OF.create(t.filter(t=>t.field==e).map(t=>i.OF.range(t.from,t.to)))}function ti(t){return({state:e,dispatch:n})=>{let i=e.field(te,!1);if(!i||t<0&&0==i.active)return!1;let r=i.active+t,s=t>0&&!i.ranges.some(e=>e.field==r+t);return n(e.update({selection:tn(i.ranges,r),effects:Q.of(s?null:new X(i.ranges,r)),scrollIntoView:!0})),!0}}let tr=[{key:"Tab",run:ti(1),shift:ti(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(te,!1)&&(e(t.update({effects:Q.of(null)})),!0)}],ts=i.sj.define({combine:t=>t.length?t[0]:tr}),to=i.Nb.highest(r.w4.compute([ts],t=>t.facet(ts)));function tl(t,e){let n;return Object.assign(Object.assign({},e),{apply:(n=Y.parse(t),(t,e,r,s)=>{let{text:o,ranges:l}=n.instantiate(t.state,r),{main:a}=t.state.selection,h={changes:{from:r,to:s==a.from?a.to:s,insert:i.EY.of(o)},scrollIntoView:!0,annotations:e?[d.of(e),i.ZX.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=tn(l,0)),l.some(t=>t.field>0)){let e=new X(l,0),n=h.effects=[Q.of(e)];void 0===t.state.field(te,!1)&&n.push(i.Pe.appendConfig.of([te,to,ta,$]))}t.dispatch(t.state.update(h))})})}let ta=r.Lz.domEventHandlers({mousedown(t,e){let n=e.state.field(te,!1),i;if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let r=n.ranges.find(t=>t.from<=i&&t.to>=i);return!!r&&r.field!=n.active&&(e.dispatch({selection:tn(n.ranges,r.field),effects:Q.of(n.ranges.some(t=>t.field>r.field)?new X(n.ranges,r.field):null),scrollIntoView:!0}),!0)}}),th={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},tc=i.Pe.define({map(t,e){let n=e.mapPos(t,-1,i.iR.TrackAfter);return null==n?void 0:n}}),tu=new class extends i.FB{};tu.startSide=1,tu.endSide=-1;let tf=i.sU.define({create:()=>i.om.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(tc)&&(t=t.update({add:[tu.range(n.value,n.value+1)]}));return t}});function td(){return[tb,tf]}let tp="()[]{}<>\xab\xbb\xbb\xab[]{}";function tm(t){for(let e=0;e<tp.length;e+=2)if(tp.charCodeAt(e)==t)return tp.charAt(e+1);return(0,i.MK)(t<128?t:t+1)}function tg(t,e){return t.languageDataAt("closeBrackets",e)[0]||th}let tv="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),tb=r.Lz.inputHandler.of((t,e,n,r)=>{if((tv?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(r.length>2||2==r.length&&1==(0,i.Fh)((0,i.vS)(r,0))||e!=o.from||n!=o.to)return!1;let l=function(t,e){let n=tg(t,t.selection.main.head),r=n.brackets||th.brackets;for(let o of r){let l=tm((0,i.vS)(o,0));if(e==o)return l==o?function(t,e,n,r){let o=r.stringPrefixes||th.stringPrefixes,l=null,a=t.changeByRange(r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:e,from:r.to}],effects:tc.of(r.to+e.length),range:i.OF.range(r.anchor+e.length,r.head+e.length)};let a=r.head,h=tx(t.doc,a),c;if(h==e){if(tk(t,a))return{changes:{insert:e+e,from:a},effects:tc.of(a+e.length),range:i.OF.cursor(a+e.length)};else if(tw(t,a)){let r=n&&t.sliceDoc(a,a+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+r.length,insert:r},range:i.OF.cursor(a+r.length)}}}else if(n&&t.sliceDoc(a-2*e.length,a)==e+e&&(c=tS(t,a-2*e.length,o))>-1&&tk(t,c))return{changes:{insert:e+e+e+e,from:a},effects:tc.of(a+e.length),range:i.OF.cursor(a+e.length)};else if(t.charCategorizer(a)(h)!=i.Je.Word&&tS(t,a,o)>-1&&!function(t,e,n,i){let r=(0,s.mv)(t).resolveInner(e,-1),o=i.reduce((t,e)=>Math.max(t,e.length),0);for(let s=0;s<5;s++){let s=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+o)),l=s.indexOf(n);if(!l||l>-1&&i.indexOf(s.slice(0,l))>-1){let e=r.firstChild;for(;e&&e.from==r.from&&e.to-e.from>n.length+l;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let a=r.to==e&&r.parent;if(!a)break;r=a}return!1}(t,a,e,o))return{changes:{insert:e+e,from:a},effects:tc.of(a+e.length),range:i.OF.cursor(a+e.length)};return{range:l=r}});return l?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}(t,o,r.indexOf(o+o+o)>-1,n):function(t,e,n,r){let s=null,o=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:tc.of(o.to+e.length),range:i.OF.range(o.anchor+e.length,o.head+e.length)};let l=tx(t.doc,o.head);return!l||/\s/.test(l)||r.indexOf(l)>-1?{changes:{insert:e+n,from:o.head},effects:tc.of(o.head+e.length),range:i.OF.cursor(o.head+e.length)}:{range:s=o}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(t,o,l,n.before||th.before);if(e==l&&tw(t,t.selection.main.from))return function(t,e){let n=null,r=t.changeByRange(r=>r.empty&&tx(t.doc,r.head)==e?{changes:{from:r.head,to:r.head+e.length,insert:e},range:i.OF.cursor(r.head+e.length)}:n={range:r});return n?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(t,l)}return null}(t.state,r);return!!l&&(t.dispatch(l),!0)}),ty=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=tg(t,t.selection.main.head).brackets||th.brackets,r=null,s=t.changeByRange(e=>{if(e.empty){var s,o;let r,l=(s=t.doc,o=e.head,r=s.sliceString(o-2,o),(0,i.Fh)((0,i.vS)(r,0))==r.length?r:r.slice(1));for(let r of n)if(r==l&&tx(t.doc,e.head)==tm((0,i.vS)(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:i.OF.cursor(e.head-r.length)}}return{range:r=e}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function tw(t,e){let n=!1;return t.field(tf).between(0,t.doc.length,t=>{t==e&&(n=!0)}),n}function tx(t,e){let n=t.sliceString(e,e+2);return n.slice(0,(0,i.Fh)((0,i.vS)(n,0)))}function tk(t,e){let n=(0,s.mv)(t).resolveInner(e+1);return n.parent&&n.from==e}function tS(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=i.Je.Word)return e;for(let s of n){let n=e-s.length;if(t.sliceDoc(n,e)==s&&r(t.sliceDoc(n-1,n))!=i.Je.Word)return n}return -1}function tC(t={}){return[U,F,w.of(t),W,tO,$]}let tA=[{key:"Ctrl-Space",run:V},{mac:"Alt-`",run:V},{key:"Escape",run:t=>{let e=t.state.field(F,!1);return!!e&&!!e.active.some(t=>0!=t.state)&&(t.dispatch({effects:v.of(null)}),!0)}},{key:"ArrowDown",run:z(!0)},{key:"ArrowUp",run:z(!1)},{key:"PageDown",run:z(!0,"page")},{key:"PageUp",run:z(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(F,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(w).interactionDelay)&&j(t,e.open.options[e.open.selected])}}],tO=i.Nb.highest(r.w4.computeN([w],t=>t.facet(w).defaultKeymap?[tA]:[]))},169:function(t,e,n){"use strict";n.d(e,{Ay:function(){return I},EI:function(){return P},KB:function(){return E},Lv:function(){return th},Oh:function(){return R},Q0:function(){return u},SG:function(){return tA},WD:function(){return z},Xt:function(){return M},Yy:function(){return A},Zt:function(){return tv},_Y:function(){return j},_v:function(){return T},b_:function(){return H},bj:function(){return p},f7:function(){return tt},jU:function(){return tP},mv:function(){return m},mz:function(){return _},p9:function(){return c},tp:function(){return D},y9:function(){return tm},yd:function(){return W}});var i,r=n(80),s=n(492),o=n(867),l=n(619),a=n(690);let h=new r.uY;function c(t){return s.sj.define({combine:t?e=>e.concat(t):void 0})}let u=new r.uY;class f{constructor(t,e,n=[],i=""){this.data=t,this.name=i,s.$t.prototype.hasOwnProperty("tree")||Object.defineProperty(s.$t.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[C.of(this),s.$t.languageData.of((t,e,n)=>{let i=d(t,e,n),r=i.type.prop(h);if(!r)return[];let s=t.facet(r),o=i.type.prop(u);if(o){let r=i.resolve(e-i.from,n);for(let e of o)if(e.test(r,t)){let n=t.facet(e.facet);return"replace"==e.type?n:n.concat(s)}}return s})].concat(n)}isActiveAt(t,e,n=-1){return d(t,e,n).type.prop(h)==this.data}findRegions(t){let e=t.facet(C);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[],i=(t,e)=>{if(t.prop(h)==this.data)return void n.push({from:e,to:e+t.length});let s=t.prop(r.uY.mounted);if(s){if(s.tree.prop(h)==this.data){if(s.overlay)for(let t of s.overlay)n.push({from:t.from+e,to:t.to+e});else n.push({from:e,to:e+t.length});return}else if(s.overlay){let t=n.length;if(i(s.tree,s.overlay[0].from+e),n.length>t)return}}for(let n=0;n<t.children.length;n++){let s=t.children[n];s instanceof r.PH&&i(s,t.positions[n]+e)}};return i(m(t),0),n}get allowsNesting(){return!0}}function d(t,e,n){let i=t.facet(C),s=m(t).topNode;if(!i||i.allowsNesting)for(let t=s;t;t=t.enter(e,n,r.Qj.ExcludeBuffers))t.type.isTop&&(s=t);return s}f.setState=s.Pe.define();class p extends f{constructor(t,e,n){super(t,e,[],n),this.parser=e}static define(t){let e=c(t.languageData);return new p(e,t.parser.configure({props:[h.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new p(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(t){let e=t.field(f.state,!1);return e?e.tree:r.PH.empty}class g{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let v=null;class b{constructor(t,e,n=[],i,r,s,o,l){this.parser=t,this.state=e,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,n){return new b(t,e,[],r.PH.empty,0,n,[],null)}startParse(){return this.parser.startParse(new g(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=r.PH.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(r.rr.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(r.rr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=v;v=this;try{return t()}finally{v=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=y(t,e.from,e.to);return t}changes(t,e){let{fragments:n,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,i,r)=>e.push({fromA:t,toA:n,fromB:i,toB:r})),n=r.rr.applyChanges(n,e),i=r.PH.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length)for(let e of(l=[],this.skipped)){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);n<i&&l.push({from:n,to:i})}}return new b(this.parser,e,n,i,s,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:n,to:i}=this.skipped[e];n<t.to&&i>t.from&&(this.fragments=y(this.fragments,n,i),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends r.iX{createParse(e,n,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let e=v;if(e){for(let t of i)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new r.PH(r.Z6.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return v}}function y(t,e,n){return r.rr.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class w{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,n)||e.takeTree(),new w(e)}static init(t){let e=Math.min(3e3,t.doc.length),n=b.create(t.facet(C).parser,t,{from:0,to:e});return n.work(20,e)||n.takeTree(),new w(n)}}f.state=s.sU.define({create:w.init,update(t,e){for(let t of e.effects)if(t.is(f.setState))return t.value;return e.startState.facet(C)!=e.state.facet(C)?w.init(e.state):t.apply(e)}});let x=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"u">typeof requestIdleCallback&&(x=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});let k="u">typeof navigator&&(null==(i=navigator.scheduling)?void 0:i.isInputPending)?()=>navigator.scheduling.isInputPending():null,S=o.Z9.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(f.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(f.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=x(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(f.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!k?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work(()=>k&&k()||Date.now()>s,i+1e5*!o);this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:f.setState.of(new w(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>(0,o.c_)(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),C=s.sj.define({combine:t=>t.length?t[0]:null,enables:t=>[f.state,S,o.Lz.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class A{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}let O=s.sj.define(),M=s.sj.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function D(t){let e=t.facet(M);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function P(t,e){let n="",i=t.tabSize,r=t.facet(M)[0];if(" "==r){for(;e>=i;)n+=" ",e-=i;r=" "}for(let t=0;t<e;t++)n+=r;return n}function T(t,e){for(let n of(t instanceof s.$t&&(t=new E(t)),t.state.facet(O))){let i=n(t,e);if(void 0!==i)return i}let n=m(t.state);return n.length>=e?function(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let t=[];for(let e=r;e&&!(e.from<i.node.from||e.to>i.node.to||e.from==i.node.from&&e.type==i.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)i={node:t[e],next:i}}return B(i,t,n)}(t,n,e):null}class E{constructor(t,e={}){this.state=t,this.options=e,this.unit=D(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:r}=this.options;if(null!=i&&i>=n.from&&i<=n.to)if(r&&i==t)return{text:"",from:t};else if(e<0?i<t:i<=t)return{text:n.text.slice(i-n.from),from:i};else return{text:n.text.slice(0,i-n.from),from:n.from};return n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(t,e);return n.slice(t-i,Math.min(n.length,t+100-i))}column(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.countColumn(n,t-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(r+=s-this.countColumn(n,n.search(/\S|$/))),r}countColumn(t,e=t.length){return(0,s.y$)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(i);if(t>-1)return t}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let R=new r.uY;function B(t,e,n){for(let i=t;i;i=i.next){let t=function(t){let e=t.type.prop(R);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(r.uY.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>F(t,!0,1,void 0,n&&!(t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak)?e.from:void 0)}return null==t.parent?L:null}(i.node);if(t)return t(N.create(e,n,i))}return 0}function L(){return 0}class N extends E{constructor(t,e,n){super(t.state,t.options),this.base=t,this.pos=e,this.context=n}get node(){return this.context.node}static create(t,e,n){return new N(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(function(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return B(this.context.next,this.base,this.pos)}}function I({closing:t,align:e=!0,units:n=1}){return i=>F(i,e,n,t)}function F(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,a=e?function(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=n.to;;){let r=e.childAfter(t);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let t=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+t}}t=r.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}let j=t=>t.baseIndent;function _({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}function z(){return s.$t.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:i}=t.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return t;let s=n.sliceString(r.from,i);if(!e.some(t=>t.test(s)))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let n=T(o,e.from);if(null==n)continue;let i=/^\s*/.exec(e.text)[0],r=P(o,n);i!=r&&a.push({from:e.from,to:e.from+i.length,insert:r})}return a.length?[t,{changes:a,sequential:!0}]:t})}let V=s.sj.define(),H=new r.uY;function W(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function q(t,e,n){for(let i of t.facet(V)){let r=i(t,e,n);if(r)return r}return function(t,e,n){let i=m(t);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=n||r.from>n)continue;if(s&&r.from<e)break;let l=r.type.prop(H);if(l&&(r.to<i.length-50||i.length==t.doc.length||!function(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}(r))){let i=l(r,t);i&&i.from<=n&&i.from>=e&&i.to>n&&(s=i)}}return s}(t,e,n)}function U(t,e){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}let $=s.Pe.define({map:U}),K=s.Pe.define({map:U});function J(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(t=>t.from<=n&&t.to>=n)||e.push(t.lineBlockAt(n));return e}let Y=s.sU.define({create:()=>o.NZ.none,update(t,e){for(let n of(e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,n)=>t=G(t,e,n)),t=t.map(e.changes),e.effects))if(n.is($)&&!function(t,e,n){let i=!1;return t.between(e,e,(t,r)=>{t==e&&r==n&&(i=!0)}),i}(t,n.value.from,n.value.to)){let{preparePlaceholder:i}=e.state.facet(tn),r=i?o.NZ.replace({widget:new to(i(e.state,n.value))}):ts;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(K)&&(t=t.update({filter:(t,e)=>n.value.from!=t||n.value.to!=e,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=G(t,e.selection.main.head)),t},provide:t=>o.Lz.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(t,e)=>{n.push(t,e)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let i=t[n++],r=t[n++];if("number"!=typeof i||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");e.push(ts.range(i,r))}return o.NZ.set(e,!0)}});function G(t,e,n=e){let i=!1;return t.between(e,n,(t,r)=>{t<n&&r>e&&(i=!0)}),i?t.update({filterFrom:e,filterTo:n,filter:(t,i)=>t>=n||i<=e}):t}function Z(t,e,n){var i;let r=null;return null==(i=t.field(Y,!1))||i.between(e,n,(t,e)=>{(!r||r.from>t)&&(r={from:t,to:e})}),r}function X(t,e){return t.field(Y,!1)?e:e.concat(s.Pe.appendConfig.of(ti()))}function Q(t,e,n=!0){let i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return o.Lz.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${t.state.phrase("to")} ${r}.`)}let tt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of J(t)){let n=q(t.state,e.from,e.to);if(n)return t.dispatch({effects:X(t.state,[$.of(n),Q(t,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(Y,!1))return!1;let e=[];for(let n of J(t)){let i=Z(t.state,n.from,n.to);i&&e.push(K.of(i),Q(t,i,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,n=[];for(let i=0;i<e.doc.length;){let r=t.lineBlockAt(i),s=q(e,r.from,r.to);s&&n.push($.of(s)),i=(s?t.lineBlockAt(s.to):r).to+1}return n.length&&t.dispatch({effects:X(t.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(Y,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(t,e)=>{n.push(K.of({from:t,to:e}))}),t.dispatch({effects:n}),!0}}],te={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},tn=s.sj.define({combine:t=>(0,s.QR)(t,te)});function ti(t){let e=[Y,tc];return t&&e.push(tn.of(t)),e}function tr(t,e){let{state:n}=t,i=n.facet(tn),r=e=>{let n=t.lineBlockAt(t.posAtDOM(e.target)),i=Z(t.state,n.from,n.to);i&&t.dispatch({effects:K.of(i)}),e.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let ts=o.NZ.replace({widget:new class extends o.xO{toDOM(t){return tr(t,null)}}});class to extends o.xO{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return tr(t,this.value)}}let tl={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ta extends o.wJ{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function th(t={}){let e={...tl,...t},n=new ta(e,!0),i=new ta(e,!1),r=o.Z9.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(C)!=t.state.facet(C)||t.startState.field(Y,!1)!=t.state.field(Y,!1)||m(t.startState)!=m(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new s.vB;for(let r of t.viewportLineBlocks){let s=Z(t.state,r.from,r.to)?i:q(t.state,r.from,r.to)?n:null;s&&e.add(r.from,r.from,s)}return e.finish()}}),{domEventHandlers:l}=e;return[r,(0,o.cU)({class:"cm-foldGutter",markers(t){var e;return(null==(e=t.plugin(r))?void 0:e.markers)||s.om.empty},initialSpacer:()=>new ta(e,!1),domEventHandlers:{...l,click:(t,e,n)=>{if(l.click&&l.click(t,e,n))return!0;let i=Z(t.state,e.from,e.to);if(i)return t.dispatch({effects:K.of(i)}),!0;let r=q(t.state,e.from,e.to);return!!r&&(t.dispatch({effects:$.of(r)}),!0)}}}),ti()]}let tc=o.Lz.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class tu{constructor(t,e){let n;function i(t){let e=a.G.newName();return(n||(n=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?i(e.all):void 0,s=e.scope;this.scope=s instanceof f?t=>t.prop(h)==s.data:s?t=>t==s:void 0,this.style=(0,l.az)(t.map(t=>({tag:t.tag,class:t.class||i(Object.assign({},t,{tag:null}))})),{all:r}).style,this.module=n?new a.G(n):null,this.themeType=e.themeType}static define(t,e){return new tu(t,e||{})}}let tf=s.sj.define(),td=s.sj.define({combine:t=>t.length?[t[0]]:null});function tp(t){let e=t.facet(tf);return e.length?e:t.facet(td)}function tm(t,e){let n=[tg],i;return t instanceof tu&&(t.module&&n.push(o.Lz.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(td.of(t)):i?n.push(tf.computeN([o.Lz.darkTheme],e=>e.facet(o.Lz.darkTheme)==("dark"==i)?[t]:[])):n.push(tf.of(t)),n}let tg=s.Nb.high(o.Z9.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,tp(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),n=tp(t.state),i=n!=tp(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!i&&e.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||i)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return o.NZ.none;let n=new s.vB;for(let{from:i,to:r}of t.visibleRanges)(0,l.DM)(this.tree,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=o.NZ.mark({class:i})))},i,r);return n.finish()}},{decorations:t=>t.decorations})),tv=tu.define([{tag:l._A.meta,color:"#404740"},{tag:l._A.link,textDecoration:"underline"},{tag:l._A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:l._A.emphasis,fontStyle:"italic"},{tag:l._A.strong,fontWeight:"bold"},{tag:l._A.strikethrough,textDecoration:"line-through"},{tag:l._A.keyword,color:"#708"},{tag:[l._A.atom,l._A.bool,l._A.url,l._A.contentSeparator,l._A.labelName],color:"#219"},{tag:[l._A.literal,l._A.inserted],color:"#164"},{tag:[l._A.string,l._A.deleted],color:"#a11"},{tag:[l._A.regexp,l._A.escape,l._A.special(l._A.string)],color:"#e40"},{tag:l._A.definition(l._A.variableName),color:"#00f"},{tag:l._A.local(l._A.variableName),color:"#30a"},{tag:[l._A.typeName,l._A.namespace],color:"#085"},{tag:l._A.className,color:"#167"},{tag:[l._A.special(l._A.variableName),l._A.macroName],color:"#256"},{tag:l._A.definition(l._A.propertyName),color:"#00c"},{tag:l._A.comment,color:"#940"},{tag:l._A.invalid,color:"#f00"}]),tb=o.Lz.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ty="()[]{}",tw=s.sj.define({combine:t=>(0,s.QR)(t,{afterCursor:!0,brackets:ty,maxScanDistance:1e4,renderMatch:tS})}),tx=o.NZ.mark({class:"cm-matchingBracket"}),tk=o.NZ.mark({class:"cm-nonmatchingBracket"});function tS(t){let e=[],n=t.matched?tx:tk;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}let tC=[s.sU.define({create:()=>o.NZ.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],i=e.state.facet(tw);for(let t of e.state.selection.ranges){if(!t.empty)continue;let r=tP(e.state,t.head,-1,i)||t.head>0&&tP(e.state,t.head-1,1,i)||i.afterCursor&&(tP(e.state,t.head,1,i)||t.head<e.state.doc.length&&tP(e.state,t.head+1,-1,i));r&&(n=n.concat(i.renderMatch(r,e.state)))}return o.NZ.set(n,!0)},provide:t=>o.Lz.decorations.from(t)}),tb];function tA(t={}){return[tw.of(t),tC]}let tO=new r.uY;function tM(t,e,n){let i=t.prop(e<0?r.uY.openedBy:r.uY.closedBy);if(i)return i;if(1==t.name.length){let i=n.indexOf(t.name);if(i>-1&&i%2==+(e<0))return[n[i+e]]}return null}function tD(t){let e=t.type.prop(tO);return e?e(t.node):t}function tP(t,e,n,i={}){let r=i.maxScanDistance||1e4,s=i.brackets||ty,o=m(t),l=o.resolveInner(e,n);for(let t=l;t;t=t.parent){let i=tM(t.type,n,s);if(i&&t.from<t.to){let r=tD(t);if(r&&(n>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return function(t,e,n,i,r){let s=e.parent,o={from:n.from,to:n.to},l=0,a=null==s?void 0:s.cursor();if(a&&(t<0?a.childBefore(e.from):a.childAfter(e.to)))do if(t<0?a.to<=e.from:a.from>=e.to){if(0==l&&i.indexOf(a.type.name)>-1&&a.from<a.to){let t=tD(a);return{start:o,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}else if(tM(a.type,t,r))l++;else if(tM(a.type,-t,r)){if(0==l){let t=tD(a);return{start:o,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}l--}}while(t<0?a.prevSibling():a.nextSibling());return{start:o,matched:!1}}(n,t,r,i,s)}}return function(t,e,n,i,r,s,o){let l=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;n<0&&(t+=s.length);let l=e+t*n;for(let t=n>0?0:s.length-1,e=n>0?s.length:-1;t!=e;t+=n){let e=o.indexOf(s[t]);if(!(e<0)&&i.resolveInner(l+t,1).type==r)if(e%2==0==n>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}n>0&&(t+=s.length)}return c.done?{start:h,matched:!1}:null}(t,e,n,o,l.type,r,s)}let tT=Object.create(null),tE=[r.Z6.none],tR=[],tB=Object.create(null),tL=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tL[t]=function(t,e){let n=[];for(let i of e.split(" ")){let e=[];for(let n of i.split(".")){let i=t[n]||l._A[n];i?"function"==typeof i?e.length?e=e.map(i):tN(n,`Modifier ${n} used at start of tag`):e.length?tN(n,`Tag ${n} used as modifier`):e=Array.isArray(i)?i:[i]:tN(n,`Unknown highlighting tag ${n}`)}for(let t of e)n.push(t)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+n.map(t=>t.id),o=tB[s];if(o)return o.id;let a=tB[s]=r.Z6.define({id:tE.length,name:i,props:[(0,l.pn)({[i]:n})]});return tE.push(a),a.id}(tT,e);function tN(t,e){tR.indexOf(t)>-1||(tR.push(t),console.warn(e))}o.OP.RTL,o.OP.LTR},492:function(t,e,n){"use strict";let i;n.d(e,{ZX:function(){return tp},kn:function(){return tz},MK:function(){return C},iR:function(){return P},Fh:function(){return A},zK:function(){return k},sU:function(){return J},om:function(){return tM},OF:function(){return _},Pe:function(){return td},$t:function(){return tx},xx:function(){return X},Nb:function(){return G},vS:function(){return S},QR:function(){return tk},y$:function(){return t_},YH:function(){return tc},FB:function(){return tS},Gu:function(){return T},Je:function(){return ty},vB:function(){return tD},VR:function(){return E},EY:function(){return d},sj:function(){return H}});let r=[],s=[],o="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<o.length;t++)(t%2?s:r).push(e+=o[t]);function l(t){return t>=127462&&t<=127487}function a(t,e,n){if(e==t.length)return e;e&&c(t.charCodeAt(e))&&u(t.charCodeAt(e-1))&&e--;let i=h(t,e);for(e+=f(i);e<t.length;){let o=h(t,e);if(8205==i||8205==o||n&&function(t){if(t<768)return!1;for(let e=0,n=r.length;;){let i=e+n>>1;if(t<r[i])n=i;else{if(!(t>=s[i]))return!0;e=i+1}if(e==n)return!1}}(o))e+=f(o),i=o;else if(l(o)){let n=0,i=e-2;for(;i>=0&&l(h(t,i));)n++,i-=2;if(n%2==0)break;e+=2}else break}return e}function h(t,e){let n=t.charCodeAt(e);if(!u(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return c(i)?(n-55296<<10)+(i-56320)+65536:n}function c(t){return t>=56320&&t<57344}function u(t){return t>=55296&&t<56320}function f(t){return t<65536?1:2}class d{lineAt(t){if(t<0||t>this.length)throw RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,n){[t,e]=x(this,t,e);let i=[];return this.decompose(0,t,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(e,this.length,i,1),m.from(i,this.length-(e-t)+n.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=x(this,t,e);let n=[];return this.decompose(t,e,n,0),m.from(n,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),n=this.length-this.scanIdentical(t,-1),i=new v(this),r=new v(t);for(let t=e,s=e;;){if(i.next(t),r.next(t),t=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(s+=i.value.length,i.done||s>=n)return!0}}iter(t=1){return new v(this,t)}iterRange(t,e=this.length){return new b(this,t,e)}iterLines(t,e){let n;if(null==t)n=this.iter();else{null==e&&(e=this.lines+1);let i=this.line(t).from;n=this.iterRange(i,Math.max(i,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new y(n)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new p(t):m.from(p.split(t,[])):d.empty}}class p extends d{constructor(t,e=function(t){let e=-1;for(let n of t)e+=n.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,n,i){for(let r=0;;r++){let s=this.text[r],o=i+s.length;if((e?n:o)>=t)return new w(i,o,n,s);i=o+1,n++}}decompose(t,e,n,i){var r;let s=t<=0&&e>=this.length?this:new p((r=this.text,g(r,[""],t,e)),Math.min(e,this.length)-Math.max(0,t));if(1&i){let t=n.pop(),e=g(s.text,t.text.slice(),0,s.length);if(e.length<=32)n.push(new p(e,t.length+s.length));else{let t=e.length>>1;n.push(new p(e.slice(0,t)),new p(e.slice(t)))}}else n.push(s)}replace(t,e,n){var i;if(!(n instanceof p))return super.replace(t,e,n);[t,e]=x(this,t,e);let r=g(this.text,g(n.text,(i=this.text,g(i,[""],0,t))),e),s=this.length+n.length-(e-t);return r.length<=32?new p(r,s):m.from(p.split(r,[]),s)}sliceString(t,e=this.length,n="\n"){[t,e]=x(this,t,e);let i="";for(let r=0,s=0;r<=e&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>t&&s&&(i+=n),t<l&&e>r&&(i+=o.slice(Math.max(0,t-r),e-r)),r=l+1}return i}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let n=[],i=-1;for(let r of t)n.push(r),i+=r.length+1,32==n.length&&(e.push(new p(n,i)),n=[],i=-1);return i>-1&&e.push(new p(n,i)),e}}class m extends d{constructor(t,e){for(let n of(super(),this.children=t,this.length=e,this.lines=0,t))this.lines+=n.lines}lineInner(t,e,n,i){for(let r=0;;r++){let s=this.children[r],o=i+s.length,l=n+s.lines-1;if((e?l:o)>=t)return s.lineInner(t,e,n,i);i=o+1,n=l+1}}decompose(t,e,n,i){for(let r=0,s=0;s<=e&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(t<=l&&e>=s){let r=i&(s<=t|2*(l>=e));s>=t&&l<=e&&!r?n.push(o):o.decompose(t-s,e-s,n,r)}s=l+1}}replace(t,e,n){if([t,e]=x(this,t,e),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let s=this.children[i],o=r+s.length;if(t>=r&&e<=o){let l=s.replace(t-r,e-r,n),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[i]=l,new m(r,this.length-(e-t)+n.length)}return super.replace(r,o,l)}r=o+1}return super.replace(t,e,n)}sliceString(t,e=this.length,n="\n"){[t,e]=x(this,t,e);let i="";for(let r=0,s=0;r<this.children.length&&s<=e;r++){let o=this.children[r],l=s+o.length;s>t&&r&&(i+=n),t<l&&e>s&&(i+=o.sliceString(t-s,e-s,n)),s=l+1}return i}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof m))return 0;let n=0,[i,r,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=e,r+=e){if(i==s||r==o)return n;let l=this.children[i],a=t.children[r];if(l!=a)return n+l.scanIdentical(a,e);n+=l.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let n=0;for(let e of t)n+=e.lines;if(n<32){let n=[];for(let e of t)e.flatten(n);return new p(n,e)}let i=Math.max(32,n>>5),r=i<<1,s=i>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:m.from(h,a)),a=-1,l=h.length=0)}for(let e of t)!function t(e){let n;if(e.lines>r&&e instanceof m)for(let n of e.children)t(n);else e.lines>s&&(l>s||!l)?(c(),o.push(e)):e instanceof p&&l&&(n=h[h.length-1])instanceof p&&e.lines+n.lines<=32?(l+=e.lines,a+=e.length+1,h[h.length-1]=new p(n.text.concat(e.text),n.length+1+e.length)):(l+e.lines>i&&c(),l+=e.lines,a+=e.length+1,h.push(e))}(e);return c(),1==o.length?o[0]:new m(o,e)}}function g(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=i;s++){let l=t[s],a=r+l.length;a>=n&&(a>i&&(l=l.slice(0,i-r)),r<n&&(l=l.slice(n-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}d.empty=new p([""],0);class v{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof p?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],s=r>>1,o=i instanceof p?i.text.length:i.children.length;if(s==(e>0?o:0)){if(0==n)return this.done=!0,this.value="",this;e>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[n]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(i instanceof p){let r=i.text[s+(e<0?-1:0)];if(this.offsets[n]+=e,r.length>Math.max(0,t))return this.value=0==t?r:e>0?r.slice(t):r.slice(0,r.length-t),this;t-=r.length}else{let r=i.children[s+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[n]+=e):(e<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof p?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class b{constructor(t,e,n){this.value="",this.done=!1,this.cursor=new v(t,e>n?-1:1),this.pos=e>n?t.length:0,this.from=Math.min(e,n),this.to=Math.max(e,n)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let n=e<0?this.pos-this.from:this.to-this.pos;t>n&&(t=n),n-=t;let{value:i}=this.cursor.next(t);return this.pos+=(i.length+t)*e,this.value=i.length<=n?i:e<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class y{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:n,value:i}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"u">typeof Symbol&&(d.prototype[Symbol.iterator]=function(){return this.iter()},v.prototype[Symbol.iterator]=b.prototype[Symbol.iterator]=y.prototype[Symbol.iterator]=function(){return this});class w{constructor(t,e,n,i){this.from=t,this.to=e,this.number=n,this.text=i}get length(){return this.to-this.from}}function x(t,e,n){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,n))]}function k(t,e,n=!0,i=!0){return function(t,e,n=!0,i=!0){return(n?a:function(t,e,n){for(;e>0;){let i=a(t,e-2,n);if(i<e)return i;e--}return 0})(t,e,i)}(t,e,n,i)}function S(t,e){let n=t.charCodeAt(e);if(!(n>=55296&&n<56320)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return i>=56320&&i<57344?(n-55296<<10)+(i-56320)+65536:n}function C(t){return t<=65535?String.fromCharCode(t):String.fromCharCode(((t-=65536)>>10)+55296,(1023&t)+56320)}function A(t){return t<65536?1:2}let O=/\r\n?|\n/;var M,D,P=((M=P||(P={}))[M.Simple=0]="Simple",M[M.TrackDel=1]="TrackDel",M[M.TrackBefore=2]="TrackBefore",M[M.TrackAfter=3]="TrackAfter",M);class T{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e+1];t+=n<0?this.sections[e]:n}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,n=0,i=0;e<this.sections.length;){let r=this.sections[e++],s=this.sections[e++];s<0?(t(n,i,r),i+=r):i+=s,n+=r}}iterChangedRanges(t,e=!1){L(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],i=this.sections[e++];i<0?t.push(n,i):t.push(i,n)}return new T(t)}composeDesc(t){return this.empty?t:t.empty?this:I(this,t)}mapDesc(t,e=!1){return t.empty?this:N(this,t,e)}mapPos(t,e=-1,n=P.Simple){let i=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=i+o;if(l<0){if(a>t)return r+(t-i);r+=o}else{if(n!=P.Simple&&a>=t&&(n==P.TrackDel&&i<t&&a>t||n==P.TrackBefore&&i<t||n==P.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!o)return t==i||e<0?r:r+l;r+=l}i=a}if(t>i)throw RangeError(`Position ${t} is out of range for changeset of length ${i}`);return r}touchesRange(t,e=t){for(let n=0,i=0;n<this.sections.length&&i<=e;){let r=this.sections[n++],s=this.sections[n++],o=i+r;if(s>=0&&i<=e&&o>=t)return!(i<t)||!(o>e)||"cover";i=o}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let n=this.sections[e++],i=this.sections[e++];t+=(t?" ":"")+n+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw RangeError("Invalid JSON representation of ChangeDesc");return new T(t)}static create(t){return new T(t)}}class E extends T{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw RangeError("Applying change set to a document with the wrong length");return L(this,(e,n,i,r,s)=>t=t.replace(i,i+(n-e),s),!1),t}mapDesc(t,e=!1){return N(this,t,e,!0)}invert(t){let e=this.sections.slice(),n=[];for(let i=0,r=0;i<e.length;i+=2){let s=e[i],o=e[i+1];if(o>=0){e[i]=o,e[i+1]=s;let l=i>>1;for(;n.length<l;)n.push(d.empty);n.push(s?t.slice(r,r+s):d.empty)}r+=s}return new E(e,n)}compose(t){return this.empty?t:t.empty?this:I(this,t,!0)}map(t,e=!1){return t.empty?this:N(this,t,e,!0)}iterChanges(t,e=!1){L(this,t,e)}get desc(){return T.create(this.sections)}filter(t){let e=[],n=[],i=[],r=new F(this);e:for(let s=0,o=0;;){let l=s==t.length?1e9:t[s++];for(;o<l||o==l&&0==r.len;){if(r.done)break e;let t=Math.min(r.len,l-o);R(i,t,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;R(e,t,s),s>0&&B(n,e,r.text),r.forward(t),o+=t}let a=t[s++];for(;o<a;){if(r.done)break e;let t=Math.min(r.len,a-o);R(e,t,-1),R(i,t,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(t),o+=t}}return{changes:new E(e,n),filtered:T.create(i)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e],i=this.sections[e+1];i<0?t.push(n):0==i?t.push([n]):t.push([n].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,n){let i=[],r=[],s=0,o=null;function l(t=!1){if(!t&&!i.length)return;s<e&&R(i,e-s,-1);let n=new E(i,r);o=o?o.compose(n.map(o)):n,i=[],r=[],s=0}return!function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof E){if(a.length!=e)throw RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:t,to:o=t,insert:h}=a;if(t>o||t<0||o>e)throw RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=h?"string"==typeof h?d.of(h.split(n||O)):h:d.empty,u=c.length;if(t==o&&0==u)return;t<s&&l(),t>s&&R(i,t-s,-1),R(i,o-t,u),B(r,i,c),s=o}}(t),l(!o),o}static empty(t){return new E(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError("Invalid JSON representation of ChangeSet");let e=[],n=[];for(let i=0;i<t.length;i++){let r=t[i];if("number"==typeof r)e.push(r,-1);else if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((t,e)=>e&&"string"!=typeof t))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)e.push(r[0],0);else{for(;n.length<i;)n.push(d.empty);n[i]=d.of(r.slice(1)),e.push(r[0],n[i].length)}}return new E(e,n)}static createSet(t,e){return new E(t,e)}}function R(t,e,n,i=!1){if(0==e&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&0==e&&0==t[r]?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function B(t,e,n){if(0==n.length)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<i;)t.push(d.empty);t.push(n)}}function L(t,e,n){let i=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,u=d.empty;for(;h+=l,c+=a,a&&i&&(u=u.append(i[o-2>>1])),!n&&o!=t.sections.length&&!(t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(r,h,s,c,u),r=h,s=c}}}function N(t,e,n,i=!1){let r=[],s=i?[]:null,o=new F(t),l=new F(e);for(let t=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let t=Math.min(o.len,l.len);R(r,t,-1),o.forward(t),l.forward(t)}else if(l.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!n))){let e=l.len;for(R(r,l.ins,-1);e;){let n=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=n&&(R(r,0,o.ins),s&&B(s,r,o.text),t=o.i),o.forward(n),e-=n}l.next()}else if(o.ins>=0){let e=0,n=o.len;for(;n;)if(-1==l.ins){let t=Math.min(n,l.len);e+=t,n-=t,l.forward(t)}else if(0==l.ins&&l.len<n)n-=l.len,l.next();else break;R(r,e,t<o.i?o.ins:0),s&&t<o.i&&B(s,r,o.text),t=o.i,o.forward(o.len-n)}else if(o.done&&l.done)return s?E.createSet(r,s):T.create(r);else throw Error("Mismatched change set lengths")}function I(t,e,n=!1){let i=[],r=n?[]:null,s=new F(t),o=new F(e);for(let t=!1;;)if(s.done&&o.done)return r?E.createSet(i,r):T.create(i);else if(0==s.ins)R(i,s.len,0,t),s.next();else if(0!=o.len||o.done)if(s.done||o.done)throw Error("Mismatched change set lengths");else{let e=Math.min(s.len2,o.len),n=i.length;if(-1==s.ins){let n=-1==o.ins?-1:o.off?0:o.ins;R(i,e,n,t),r&&n&&B(r,i,o.text)}else -1==o.ins?(R(i,s.off?0:s.len,e,t),r&&B(r,i,s.textBit(e))):(R(i,s.off?0:s.len,o.off?0:o.ins,t),r&&!o.off&&B(r,i,o.text));t=(s.ins>e||o.ins>=0&&o.len>e)&&(t||i.length>n),s.forward2(e),o.forward(e)}else R(i,0,o.ins,t),r&&B(r,i,o.text),o.next()}class F{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?d.empty:t[e]}textBit(t){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length&&!t?d.empty:e[n].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class j{constructor(t,e,n){this.from=t,this.to=e,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 0xffffff==t?void 0:t}map(t,e=-1){let n,i;return this.empty?n=i=t.mapPos(this.from,e):(n=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new j(n,i,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return _.range(t,e);let n=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return _.range(this.anchor,n)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid JSON representation for SelectionRange");return _.range(t.anchor,t.head)}static create(t,e,n){return new j(t,e,n)}}class _{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:_.create(this.ranges.map(n=>n.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(t.ranges[n],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new _([this.main],0)}addRange(t,e=!0){return _.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let n=this.ranges.slice();return n[e]=t,_.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new _(t.ranges.map(t=>j.fromJSON(t)),t.main)}static single(t,e=t){return new _([_.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw RangeError("A selection needs at least one range");for(let n=0,i=0;i<t.length;i++){let r=t[i];if(r.empty?r.from<=n:r.from<n)return _.normalized(t.slice(),e);n=r.to}return new _(t,e)}static cursor(t,e=0,n,i){return j.create(t,t,(0==e?0:e<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:0xffffff)<<6)}static range(t,e,n,i){let r=(null!=n?n:0xffffff)<<6|(null==i?7:Math.min(6,i));return e<t?j.create(e,t,48|r):j.create(t,e,8*(e>t)|r)}static normalized(t,e=0){let n=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(n);for(let n=1;n<t.length;n++){let i=t[n],r=t[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let s=r.from,o=Math.max(i.to,r.to);n<=e&&e--,t.splice(--n,2,i.anchor>i.head?_.range(o,s):_.range(s,o))}}return new _(t,e)}}function z(t,e){for(let n of t.ranges)if(n.to>e)throw RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,n,i,r){this.combine=t,this.compareInput=e,this.compare=n,this.isStatic=i,this.id=V++,this.default=t([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(!t.combine?W:(t,e)=>t===e),!!t.static,t.enables)}of(t){return new q([],this,0,t)}compute(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new q(t,this,1,e)}computeN(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new q(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],n=>e(n.field(t)))}}function W(t,e){return t==e||t.length==e.length&&t.every((t,n)=>t===e[n])}class q{constructor(t,e,n,i){this.dependencies=t,this.facet=e,this.type=n,this.value=i,this.id=V++}dynamicSlot(t){var e;let n=this.value,i=this.facet.compareInput,r=this.id,s=t[r]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let n of this.dependencies)"doc"==n?l=!0:"selection"==n?a=!0:((null!=(e=t[n.id])?e:1)&1)==0&&h.push(t[n.id]);return{create:t=>(t.values[s]=n(t),1),update(t,e){if(l&&e.docChanged||a&&(e.docChanged||e.selection)||$(t,h)){let e=n(t);if(o?!U(e,t.values[s],i):!i(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let l,a=e.config.address[r];if(null!=a){let r=tn(e,a);if(this.dependencies.every(n=>n instanceof H?e.facet(n)===t.facet(n):!(n instanceof J)||e.field(n,!1)==t.field(n,!1))||(o?U(l=n(t),r,i):i(l=n(t),r)))return t.values[s]=r,0}else l=n(t);return t.values[s]=l,1}}}}function U(t,e,n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}function $(t,e){let n=!1;for(let i of e)1&te(t,i)&&(n=!0);return n}let K=H.define({static:!0});class J{constructor(t,e,n,i,r){this.id=t,this.createF=e,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}static define(t){let e=new J(V++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(K).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,n)=>{let i=t.values[e],r=this.updateF(i,n);return this.compareF(i,r)?0:(t.values[e]=r,1)},reconfigure:(t,n)=>{let i=t.facet(K),r=n.facet(K),s;return(s=i.find(t=>t.field==this))&&s!=r.find(t=>t.field==this)?(t.values[e]=s.create(t),1):null!=n.config.address[this.id]?(t.values[e]=n.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,K.of({field:this,create:t})]}get extension(){return this}}function Y(t){return e=>new Z(e,t)}let G={highest:Y(0),high:Y(1),default:Y(2),low:Y(3),lowest:Y(4)};class Z{constructor(t,e){this.inner=t,this.prec=e}}class X{of(t){return new Q(this,t)}reconfigure(t){return X.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Q{constructor(t,e){this.compartment=t,this.inner=e}}class tt{constructor(t,e,n,i,r,s){for(this.base=t,this.compartments=e,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,n){var i,r,s;let o,l,a=[],h=Object.create(null),c=new Map;for(let n of(i=t,r=e,s=c,o=[[],[],[],[],[]],l=new Map,!function t(e,n){let i=l.get(e);if(null!=i){if(i<=n)return;let t=o[i].indexOf(e);t>-1&&o[i].splice(t,1),e instanceof Q&&s.delete(e.compartment)}if(l.set(e,n),Array.isArray(e))for(let i of e)t(i,n);else if(e instanceof Q){if(s.has(e.compartment))throw RangeError("Duplicate use of compartment in extensions");let i=r.get(e.compartment)||e.inner;s.set(e.compartment,i),t(i,n)}else if(e instanceof Z)t(e.inner,e.prec);else if(e instanceof J)o[n].push(e),e.provides&&t(e.provides,n);else if(e instanceof q)o[n].push(e),e.facet.extensions&&t(e.facet.extensions,2);else{let i=e.extension;if(!i)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(i,n)}}(i,2),o.reduce((t,e)=>t.concat(e))))n instanceof J?a.push(n):(h[n.facet.id]||(h[n.facet.id]=[])).push(n);let u=Object.create(null),f=[],d=[];for(let t of a)u[t.id]=d.length<<1,d.push(e=>t.slot(e));let p=null==n?void 0:n.config.facets;for(let t in h){let e=h[t],i=e[0].facet,r=p&&p[t]||[];if(e.every(t=>0==t.type))if(u[i.id]=f.length<<1|1,W(r,e))f.push(n.facet(i));else{let t=i.combine(e.map(t=>t.value));f.push(n&&i.compare(t,n.facet(i))?n.facet(i):t)}else{for(let t of e)0==t.type?(u[t.id]=f.length<<1|1,f.push(t.value)):(u[t.id]=d.length<<1,d.push(e=>t.dynamicSlot(e)));u[i.id]=d.length<<1,d.push(t=>(function(t,e,n){let i=n.map(e=>t[e.id]),r=n.map(t=>t.type),s=i.filter(t=>!(1&t)),o=t[e.id]>>1;function l(t){let n=[];for(let e=0;e<i.length;e++){let s=tn(t,i[e]);if(2==r[e])for(let t of s)n.push(t);else n.push(s)}return e.combine(n)}return{create(t){for(let e of i)te(t,e);return t.values[o]=l(t),1},update(t,n){if(!$(t,s))return 0;let i=l(t);return e.compare(i,t.values[o])?0:(t.values[o]=i,1)},reconfigure(t,r){let s=$(t,i),a=r.config.facets[e.id],h=r.facet(e);if(a&&!s&&W(n,a))return t.values[o]=h,0;let c=l(t);return e.compare(c,h)?(t.values[o]=h,0):(t.values[o]=c,1)}}})(t,i,e))}}return new tt(t,c,d.map(t=>t(u)),u,f,h)}}function te(t,e){if(1&e)return 2;let n=e>>1,i=t.status[n];if(4==i)throw Error("Cyclic dependency between fields and/or facets");if(2&i)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function tn(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}let ti=H.define(),tr=H.define({combine:t=>t.some(t=>t),static:!0}),ts=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),to=H.define(),tl=H.define(),ta=H.define(),th=H.define({combine:t=>!!t.length&&t[0]});class tc{constructor(t,e){this.type=t,this.value=e}static define(){return new tu}}class tu{of(t){return new tc(this,t)}}class tf{constructor(t){this.map=t}of(t){return new td(this,t)}}class td{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new td(this.type,e)}is(t){return this.type==t}static define(t={}){return new tf(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let n=[];for(let i of t){let t=i.map(e);t&&n.push(t)}return n}}td.reconfigure=td.define(),td.appendConfig=td.define();class tp{constructor(t,e,n,i,r,s){this.startState=t,this.changes=e,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,n&&z(n,e.newLength),r.some(t=>t.type==tp.time)||(this.annotations=r.concat(tp.time.of(Date.now())))}static create(t,e,n,i,r,s){return new tp(t,e,n,i,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(tp.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function tm(t,e,n){var i;let r,s,o;return n?(r=e.changes,s=E.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):null==(i=t.selection)?void 0:i.map(r),effects:td.mapEffects(t.effects,r).concat(td.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function tg(t,e,n){let i=e.selection,r=tb(e.annotations);return e.userEvent&&(r=r.concat(tp.userEvent.of(e.userEvent))),{changes:e.changes instanceof E?e.changes:E.of(e.changes||[],n,t.facet(ts)),selection:i&&(i instanceof _?i:_.single(i.anchor,i.head)),effects:tb(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}tp.time=tc.define(),tp.userEvent=tc.define(),tp.addToHistory=tc.define(),tp.remote=tc.define();let tv=[];function tb(t){return null==t?tv:Array.isArray(t)?t:[t]}var ty=((D=ty||(ty={}))[D.Word=0]="Word",D[D.Space=1]="Space",D[D.Other=2]="Other",D);let tw=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{i=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class tx{constructor(t,e,n,i,r,s){this.config=t,this.doc=e,this.selection=n,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)te(this,t<<1);this.computeSlot=null}field(t,e=!0){let n=this.config.address[t.id];if(null==n){if(e)throw RangeError("Field is not present in this state");return}return te(this,n),tn(this,n)}update(...t){return function t(e,n,i){let r=tg(e,n.length?n[0]:{},e.doc.length);n.length&&!1===n[0].filter&&(i=!1);for(let t=1;t<n.length;t++){!1===n[t].filter&&(i=!1);let s=!!n[t].sequential;r=tm(r,tg(e,n[t],s?r.changes.newLength:e.doc.length),s)}let s=tp.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(t){let e=t.startState,n=e.facet(ta),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=tm(i,tg(e,s,t.changes.newLength),!0))}return i==t?t:tp.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}(i?function(e){let n=e.startState,i=!0;for(let t of n.facet(to)){let n=t(e);if(!1===n){i=!1;break}Array.isArray(n)&&(i=!0===i?n:function(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i<t.length&&(r==e.length||e[r]>=t[i]))s=t[i++],o=t[i++];else{if(!(r<e.length))return n;s=e[r++],o=e[r++]}!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(i,n))}if(!0!==i){let t,r;if(!1===i)r=e.changes.invertedDesc,t=E.empty(n.doc.length);else{let n=e.changes.filter(i);t=n.changes,r=n.filtered.mapDesc(n.changes).invertedDesc}e=tp.create(n,t,e.selection&&e.selection.map(r),td.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let r=n.facet(tl);for(let i=r.length-1;i>=0;i--){let s=r[i](e);e=s instanceof tp?s:Array.isArray(s)&&1==s.length&&s[0]instanceof tp?s[0]:t(n,tb(s),!1)}return e}(s):s)}(this,t,!0)}applyTransaction(t){let e,n=this.config,{base:i,compartments:r}=n;for(let e of t.effects)e.is(X.reconfigure)?(n&&(r=new Map,n.compartments.forEach((t,e)=>r.set(e,t)),n=null),r.set(e.value.compartment,e.value.extension)):e.is(td.reconfigure)?(n=null,i=e.value):e.is(td.appendConfig)&&(n=null,i=tb(i).concat(e.value));e=n?t.startState.values.slice():new tx(n=tt.resolve(i,r,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values;let s=t.startState.facet(tr)?t.newSelection:t.newSelection.asSingle();new tx(n,t.newDoc,s,e,(e,n)=>n.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:_.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,n=t(e.ranges[0]),i=this.changes(n.changes),r=[n.range],s=tb(n.effects);for(let n=1;n<e.ranges.length;n++){let o=t(e.ranges[n]),l=this.changes(o.changes),a=l.map(i);for(let t=0;t<n;t++)r[t]=r[t].map(a);let h=i.mapDesc(l,!0);r.push(o.range.map(h)),i=i.compose(a),s=td.mapEffects(s,a).concat(td.mapEffects(tb(o.effects),h))}return{changes:i,selection:_.create(r,e.mainIndex),effects:s}}changes(t=[]){return t instanceof E?t:E.of(t,this.doc.length,this.facet(tx.lineSeparator))}toText(t){return d.of(t.split(this.facet(tx.lineSeparator)||O))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(te(this,e),tn(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let n in t){let i=t[n];i instanceof J&&null!=this.config.address[i.id]&&(e[n]=i.spec.toJSON(this.field(t[n]),this))}return e}static fromJSON(t,e={},n){if(!t||"string"!=typeof t.doc)throw RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let e in n)if(Object.prototype.hasOwnProperty.call(t,e)){let r=n[e],s=t[e];i.push(r.init(t=>r.spec.fromJSON(s,t)))}}return tx.create({doc:t.doc,selection:_.fromJSON(t.selection),extensions:e.extensions?i.concat([e.extensions]):i})}static create(t={}){let e=tt.resolve(t.extensions||[],new Map),n=t.doc instanceof d?t.doc:d.of((t.doc||"").split(e.staticFacet(tx.lineSeparator)||O)),i=t.selection?t.selection instanceof _?t.selection:_.single(t.selection.anchor,t.selection.head):_.single(0);return z(i,n.length),e.staticFacet(tr)||(i=i.asSingle()),new tx(e,n,i,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(tx.tabSize)}get lineBreak(){return this.facet(tx.lineSeparator)||"\n"}get readOnly(){return this.facet(th)}phrase(t,...e){for(let e of this.facet(tx.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>e.length?t:e[i-1]})),t}languageDataAt(t,e,n=-1){let i=[];for(let r of this.facet(ti))for(let s of r(this,e,n))Object.prototype.hasOwnProperty.call(s,t)&&i.push(s[t]);return i}charCategorizer(t){var e;return e=this.languageDataAt("wordChars",t).join(""),t=>{if(!/\S/.test(t))return ty.Space;if(function(t){if(i)return i.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||tw.test(n)))return!0}return!1}(t))return ty.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ty.Word;return ty.Other}}wordAt(t){let{text:e,from:n,length:i}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-n,o=t-n;for(;s>0;){let t=k(e,s,!1);if(r(e.slice(t,s))!=ty.Word)break;s=t}for(;o<i;){let t=k(e,o);if(r(e.slice(o,t))!=ty.Word)break;o=t}return s==o?null:_.range(s+n,o+n)}}function tk(t,e,n={}){let i={};for(let e of t)for(let t of Object.keys(e)){let r=e[t],s=i[t];if(void 0===s)i[t]=r;else if(s===r||void 0===r);else if(Object.hasOwnProperty.call(n,t))i[t]=n[t](s,r);else throw Error("Config merge conflict for field "+t)}for(let t in e)void 0===i[t]&&(i[t]=e[t]);return i}tx.allowMultipleSelections=tr,tx.tabSize=H.define({combine:t=>t.length?t[0]:4}),tx.lineSeparator=ts,tx.readOnly=th,tx.phrases=H.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every(n=>t[n]==e[n])}}),tx.languageData=ti,tx.changeFilter=to,tx.transactionFilter=tl,tx.transactionExtender=ta,X.reconfigure=td.define();class tS{eq(t){return this==t}range(t,e=t){return tC.create(t,e,this)}}tS.prototype.startSide=tS.prototype.endSide=0,tS.prototype.point=!1,tS.prototype.mapMode=P.TrackDel;class tC{constructor(t,e,n){this.from=t,this.to=e,this.value=n}static create(t,e,n){return new tC(t,e,n)}}function tA(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class tO{constructor(t,e,n,i){this.from=t,this.to=e,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(t,e,n,i=0){let r=n?this.to:this.from;for(let s=i,o=r.length;;){if(s==o)return s;let i=s+o>>1,l=r[i]-t||(n?this.value[i].endSide:this.value[i].startSide)-e;if(i==s)return l>=0?s:o;l>=0?o=i:s=i+1}}between(t,e,n,i){for(let r=this.findIndex(e,-1e9,!0),s=this.findIndex(n,1e9,!1,r);r<s;r++)if(!1===i(this.from[r]+t,this.to[r]+t,this.value[r]))return!1}map(t,e){let n=[],i=[],r=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+t,c=this.to[l]+t,u,f;if(h==c){let t=e.mapPos(h,a.startSide,a.mapMode);if(null==t||(u=f=t,a.startSide!=a.endSide&&(f=e.mapPos(h,a.endSide))<u))continue}else if((u=e.mapPos(h,a.startSide))>(f=e.mapPos(c,a.endSide))||u==f&&a.startSide>0&&a.endSide<=0)continue;0>(f-u||a.endSide-a.startSide)||(s<0&&(s=u),a.point&&(o=Math.max(o,f-u)),n.push(a),i.push(u-s),r.push(f-s))}return{mapped:n.length?new tO(i,r,n,o):null,pos:s}}}class tM{constructor(t,e,n,i){this.chunkPos=t,this.chunk=e,this.nextLayer=n,this.maxPoint=i}static create(t,e,n,i){return new tM(t,e,n,i)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(n&&(e=e.slice().sort(tA)),this.isEmpty)return e.length?tM.of(e):this;let o=new tT(this,null,-1).goto(0),l=0,a=[],h=new tD;for(;o.value||l<e.length;)if(l<e.length&&(o.from-e[l].from||o.startSide-e[l].value.startSide)>=0){let t=e[l++];h.addInner(t.from,t.to,t.value)||a.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==e.length||this.chunkEnd(o.chunkIndex)<e[l].from)&&(!s||i>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||i>o.to||r<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(tC.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?tM.empty:this.nextLayer.update({add:a,filter:s,filterFrom:i,filterTo:r}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=t.touchesRange(s,s+o.length);if(!1===l)i=Math.max(i,o.maxPoint),e.push(o),n.push(t.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,t);r&&(i=Math.max(i,r.maxPoint),e.push(r),n.push(l))}}let r=this.nextLayer.map(t);return 0==e.length?r:new tM(n,e,r||tM.empty,i)}between(t,e,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],s=this.chunk[i];if(e>=r&&t<=r+s.length&&!1===s.between(r,t-r,e-r,n))return}this.nextLayer.between(t,e,n)}}iter(t=0){return tE.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return tE.from(t).goto(e)}static compare(t,e,n,i,r=-1){let s=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r),o=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r),l=tP(s,o,n),a=new tB(s,l,r),h=new tB(o,l,r);n.iterGaps((t,e,n)=>tL(a,t,h,e,n,i)),n.empty&&0==n.length&&tL(a,0,h,0,0,i)}static eq(t,e,n=0,i){null==i&&(i=0x3b9ac9ff);let r=t.filter(t=>!t.isEmpty&&0>e.indexOf(t)),s=e.filter(e=>!e.isEmpty&&0>t.indexOf(e));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=tP(r,s),l=new tB(r,o,0).goto(n),a=new tB(s,o,0).goto(n);for(;;){if(l.to!=a.to||!tN(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>i)return!0;l.next(),a.next()}}static spans(t,e,n,i,r=-1){let s=new tB(t,null,r).goto(e),o=e,l=s.openStart;for(;;){let t=Math.min(s.to,n);if(s.point){let n=s.activeForPoint(s.to),r=s.pointFrom<e?n.length+1:s.point.startSide<0?n.length:Math.min(n.length,l);i.point(o,t,s.point,n,r,s.pointRank),l=Math.min(s.openEnd(t),n.length)}else t>o&&(i.span(o,t,s.active,l),l=s.openEnd(t));if(s.to>n)return l+(s.point&&s.to>n?1:0);o=s.to,s.next()}}static of(t,e=!1){let n=new tD;for(let i of t instanceof tC?[t]:e?function(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let i=t[n];if(tA(e,i)>0)return t.slice().sort(tA);e=i}return t}(t):t)n.add(i.from,i.to,i.value);return n.finish()}static join(t){if(!t.length)return tM.empty;let e=t[t.length-1];for(let n=t.length-2;n>=0;n--)for(let i=t[n];i!=tM.empty;i=i.nextLayer)e=new tM(i.chunkPos,i.chunk,e,Math.max(i.maxPoint,e.maxPoint));return e}}tM.empty=new tM([],[],null,-1),tM.empty.nextLayer=tM.empty;class tD{finishChunk(t){this.chunks.push(new tO(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,t&&(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(t,e,n){this.addInner(t,e,n)||(this.nextLayer||(this.nextLayer=new tD)).add(t,e,n)}addInner(t,e,n){let i=t-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&0>(t-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=n,this.lastFrom=t,this.lastTo=e,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if(0>(t-this.lastTo||e.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let n=e.value.length-1;return this.last=e.value[n],this.lastFrom=e.from[n]+t,this.lastTo=e.to[n]+t,!0}finish(){return this.finishInner(tM.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=tM.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function tP(t,e,n){let i=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&i.set(e.chunk[t],e.chunkPos[t]);let r=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let s=i.get(t.chunk[e]);null==s||(n?n.mapPos(s):s)!=t.chunkPos[e]||(null==n?void 0:n.touchesRange(s,s+t.chunk[e].length))||r.add(t.chunk[e])}return r}class tT{constructor(t,e,n,i=0){this.layer=t,this.skip=e,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,n){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(t,e){0>(this.to-t||this.endSide-e)&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],n=t+e.from[this.rangeIndex];if(this.from=n,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==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=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class tE{constructor(t){this.heap=t}static from(t,e=null,n=-1){let i=[];for(let r=0;r<t.length;r++)for(let s=t[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&i.push(new tT(s,e,n,r));return 1==i.length?i[0]:new tE(i)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let n of this.heap)n.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)tR(this.heap,t);return this.next(),this}forward(t,e){for(let n of this.heap)n.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)tR(this.heap,t);0>(this.to-t||this.value.endSide-e)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),tR(this.heap,0)}}}function tR(t,e){for(let n=t[e];;){let i=(e<<1)+1;if(i>=t.length)break;let r=t[i];if(i+1<t.length&&r.compare(t[i+1])>=0&&(r=t[i+1],i++),0>n.compare(r))break;t[i]=n,t[e]=r,e=i}}class tB{constructor(t,e,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=tE.from(t,e,n)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e);)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){tI(this.active,t),tI(this.activeTo,t),tI(this.activeRank,t),this.minActive=tj(this.active,this.activeTo)}addActive(t){let e=0,{value:n,to:i,rank:r}=this.cursor;for(;e<this.activeRank.length&&(r-this.activeRank[e]||i-this.activeTo[e])>0;)e++;tF(this.active,e,n),tF(this.activeTo,e,i),tF(this.activeRank,e,r),t&&tF(t,e,this.cursor.from),this.minActive=tj(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&0>(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)){if(this.activeTo[i]>t){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&tI(n,i)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let t=this.cursor.value;if(t.point)if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let e=n.length-1;e>=0&&n[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>t||this.activeTo[n]==t&&this.active[n].endSide>=this.point.endSide)&&e.push(this.active[n]);return e.reverse()}openEnd(t){let e=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>t;n--)e++;return e}}function tL(t,e,n,i,r,s){t.goto(e),n.goto(i);let o=i+r,l=i,a=i-e;for(;;){let e=t.to+a-n.to,i=e||t.endSide-n.endSide,r=i<0?t.to+a:n.to,h=Math.min(r,o);if(t.point||n.point?t.point&&n.point&&(t.point==n.point||t.point.eq(n.point))&&tN(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,h,t.point,n.point):h>l&&!tN(t.active,n.active)&&s.compareRange(l,h,t.active,n.active),r>o)break;(e||t.openEnd!=n.openEnd)&&s.boundChange&&s.boundChange(r),l=r,i<=0&&t.next(),i>=0&&n.next()}}function tN(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!t[n].eq(e[n]))return!1;return!0}function tI(t,e){for(let n=e,i=t.length-1;n<i;n++)t[n]=t[n+1];t.pop()}function tF(t,e,n){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=n}function tj(t,e){let n=-1,i=1e9;for(let r=0;r<e.length;r++)0>(e[r]-i||t[r].endSide-t[n].endSide)&&(n=r,i=e[r]);return n}function t_(t,e,n=t.length){let i=0;for(let r=0;r<n&&r<t.length;)9==t.charCodeAt(r)?(i+=e-i%e,r++):(i++,r=k(t,r));return i}function tz(t,e,n,i){for(let i=0,r=0;;){if(r>=e)return i;if(i==t.length)break;r+=9==t.charCodeAt(i)?n-r%n:1,i=k(t,i)}return!0===i?-1:t.length}},867:function(t,e,n){"use strict";let i;n.d(e,{N$:function(){return it},Z9:function(){return t4},Eg:function(){return iP},Lz:function(){return nA},NZ:function(){return tf},Wu:function(){return i9},w4:function(){return nB},D4:function(){return ih},TS:function(){return nI},ld:function(){return iR},OP:function(){return tC},DK:function(){return iS},wJ:function(){return iF},S7:function(){return iI},dz:function(){return is},$K:function(){return i4},HJ:function(){return id},xO:function(){return tc},c_:function(){return tQ},cU:function(){return iH},A:function(){return n2},VH:function(){return nK},Ux:function(){return iD}});for(var r,s,o,l=n(492),a=n(690),h={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:"'"},c={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},u="u">typeof navigator&&/Mac/.test(navigator.platform),f="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),d=0;d<10;d++)h[48+d]=h[96+d]=String(d);for(var d=1;d<=24;d++)h[d+111]="F"+d;for(var d=65;d<=90;d++)h[d]=String.fromCharCode(d+32),c[d]=String.fromCharCode(d);for(var p in h)c.hasOwnProperty(p)||(c[p]=h[p]);function m(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function g(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function v(t,e){if(!e.anchorNode)return!1;try{return g(t,e.anchorNode)}catch(t){return!1}}function b(t){return 3==t.nodeType?P(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function y(t,e,n,i){return!!n&&(k(t,e,n,i,-1)||k(t,e,n,i,1))}function w(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function x(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function k(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:S(t))){if("DIV"==t.nodeName)return!1;let n=t.parentNode;if(!n||1!=n.nodeType)return!1;e=w(t)+(r<0?0:1),t=n}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(r<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=r<0?S(t):0}}}function S(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function C(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function A(t,e){let n=e.width/t.offsetWidth,i=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(e.width-t.offsetWidth))&&(n=1),(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(e.height-t.offsetHeight))&&(i=1),{scaleX:n,scaleY:i}}class O{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:n}=t;this.set(e,Math.min(t.anchorOffset,e?S(e):0),n,Math.min(t.focusOffset,n?S(n):0))}set(t,e,n,i){this.anchorNode=t,this.anchorOffset=e,this.focusNode=n,this.focusOffset=i}}let M=null;function D(t){if(t.setActive)return t.setActive();if(M)return t.focus(M);let e=[];for(let n=t;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(t.focus(null==M?{get preventScroll(){return M={preventScroll:!0},!0}}:void 0),!M){M=!1;for(let t=0;t<e.length;){let n=e[t++],i=e[t++],r=e[t++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function P(t,e,n=e){let r=i||(i=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function T(t,e,n,i){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function E(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function R(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function B(t,e){for(let n=t,i=e;;)if(3==n.nodeType&&i>0)return{node:n,offset:i};else if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;i=S(n=n.childNodes[i-1])}else{if(!n.parentNode||x(n))return null;i=w(n),n=n.parentNode}}function L(t,e){for(let n=t,i=e;;)if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};else if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||x(n))return null;i=w(n)+1,n=n.parentNode}}class N{constructor(t,e,n=!0){this.node=t,this.offset=e,this.precise=n}static before(t,e){return new N(t.parentNode,w(t),e)}static after(t,e){return new N(t.parentNode,w(t)+1,e)}}let I=[];class F{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let n of this.children){if(n==t)return e;e+=n.length+n.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let n=this.dom,i=null,r;for(let s of this.children){if(7&s.flags){if(!s.dom&&(r=i?i.nextSibling:n.firstChild)){let t=F.get(r);(!t||!t.parent&&t.canReuseDOM(s))&&s.reuseDOM(r)}s.sync(t,e),s.flags&=-8}if(r=i?i.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&r!=s.dom&&(e.written=!0),s.dom.parentNode==n)for(;r&&r!=s.dom;)r=j(r);else n.insertBefore(s.dom,r);i=s.dom}for((r=i?i.nextSibling:n.firstChild)&&e&&e.node==n&&(e.written=!0);r;)r=j(r)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(t,e),n.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let n;if(t==this.dom)n=this.dom.childNodes[e];else{let i=0==S(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==i&&e.firstChild!=e.lastChild&&(i=t==e.firstChild?-1:1),t=e}n=i<0?t:t.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!F.get(n);)n=n.nextSibling;if(!n)return this.length;for(let t=0,e=0;;t++){let i=this.children[t];if(i.dom==n)return e;e+=i.length+i.breakAfter}}domBoundsAround(t,e,n=0){let i=-1,r=-1,s=-1,o=-1;for(let l=0,a=n,h=n;l<this.children.length;l++){let n=this.children[l],c=a+n.length;if(a<t&&c>e)return n.domBoundsAround(t,e,a);if(c>=t&&-1==i&&(i=l,r=a),a>e&&n.dom.parentNode==this.dom){s=l,o=h;break}h=c,a=c+n.breakAfter}return{from:r,to:o<0?n+this.length:o,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,n=I){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&0>n.indexOf(t)&&t.destroy()}n.length<250?this.children.splice(t,e-t,...n):this.children=[].concat(this.children.slice(0,t),n,this.children.slice(e));for(let t=0;t<n.length;t++)n[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new _(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,n,i,r,s){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!((this.flags|t.flags)&8)}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function j(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}F.prototype.breakAfter=0;class _{constructor(t,e,n){this.children=t,this.pos=e,this.i=n,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function z(t,e,n,i,r,s,o,l,a){let{children:h}=t,c=h.length?h[e]:null,u=s.length?s[s.length-1]:null,f=u?u.breakAfter:o;if(!(e==i&&c&&!o&&!f&&s.length<2&&c.merge(n,r,s.length?u:null,0==n,l,a))){if(i<h.length){let t=h[i];t&&(r<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==i&&(t=t.split(r),r=0),!f&&u&&t.merge(0,r,u,!0,0,a)?s[s.length-1]=t:((r||t.children.length&&!t.children[0].length)&&t.merge(0,r,null,!1,0,a),s.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,n>0&&(!o&&s.length&&c.merge(n,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(n<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(n,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&t.replaceChildren(e,i,s)}}function V(t,e,n,i,r,s){let o=t.childCursor(),{i:l,off:a}=o.findPos(n,1),{i:h,off:c}=o.findPos(e,-1),u=e-n;for(let t of i)u+=t.length;t.length+=u,z(t,h,c,l,a,i,0,r,s)}let H="u">typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},W="u">typeof document?document:{documentElement:{style:{}}},q=/Edge\/(\d+)/.exec(H.userAgent),U=/MSIE \d/.test(H.userAgent),$=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(H.userAgent),K=!!(U||$||q),J=!K&&/gecko\/(\d+)/i.test(H.userAgent),Y=!K&&/Chrome\/(\d+)/.exec(H.userAgent),G="webkitFontSmoothing"in W.documentElement.style,Z=!K&&/Apple Computer/.test(H.vendor),X=Z&&(/Mobile\/\w+/.test(H.userAgent)||H.maxTouchPoints>2);var Q={mac:X||/Mac/.test(H.platform),windows:/Win/.test(H.platform),linux:/Linux|X11/.test(H.platform),ie:K,ie_version:U?W.documentMode||6:$?+$[1]:q?+q[1]:0,gecko:J,gecko_version:J?+(/Firefox\/(\d+)/.exec(H.userAgent)||[0,0])[1]:0,chrome:!!Y,chrome_version:Y?+Y[1]:0,ios:X,android:/Android\b/.test(H.userAgent),webkit:G,safari:Z,webkit_version:G?+(/\bAppleWebKit\/(\d+)/.exec(H.userAgent)||[0,0])[1]:0,tabSize:null!=W.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class tt extends F{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,n){return!(8&this.flags)&&(!n||n instanceof tt&&!(this.length-(e-t)+n.length>256)&&!(8&n.flags))&&(this.text=this.text.slice(0,t)+(n?n.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new tt(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new N(this.dom,t)}domBoundsAround(t,e,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,n){let i=t.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;0==e&&n<0||e==i&&n>=0?!(Q.chrome||Q.gecko)&&(e?(r--,o=1):s<i&&(s++,o=-1)):n<0?r--:s<i&&s++;let l=P(t,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:n>=0)?0:l.length-1];return Q.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(l,t=>t.width)||a),o?C(a,o<0):a||null}(this.dom,t,e)}}class te extends F{constructor(t,e=[],n=0){for(let i of(super(),this.mark=t,this.children=e,this.length=n,e))i.setParent(this)}setAttrs(t){if(E(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,n,i,r,s){return(!n||!!(n instanceof te&&n.mark.eq(this.mark))&&(!t||!(r<=0))&&(!(e<this.length)||!(s<=0)))&&(V(this,t,e,n?n.children.slice():[],r-1,s-1),this.markDirty(),!0)}split(t){let e=[],n=0,i=-1,r=0;for(let s of this.children){let o=n+s.length;o>t&&e.push(n<t?s.split(t-n):s),i<0&&n>=t&&(i=r),n=o,r++}let s=this.length-t;return this.length=t,i>-1&&(this.children.length=i,this.markDirty()),new te(this.mark,e,s)}domAtPos(t){return tr(this,t)}coordsAt(t,e){return ts(this,t,e)}}class tn extends F{static create(t,e,n){return new tn(t,e,n)}constructor(t,e,n){super(),this.widget=t,this.length=e,this.side=n,this.prevWidget=null}split(t){let e=tn.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,n,i,r,s){return(!n||n instanceof tn&&!!this.widget.compare(n.widget)&&(!(t>0)||!(r<=0))&&(!(e<this.length)||!(s<=0)))&&(this.length=t+(n?n.length:0)+(this.length-e),!0)}become(t){return t instanceof tn&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return l.EY.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,n=e&&e.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):l.EY.empty}domAtPos(t){return(this.length?0==t:this.side>0)?N.before(this.dom):N.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let n=this.widget.coordsAt(this.dom,t,e);if(n)return n;let i=this.dom.getClientRects(),r=null;if(!i.length)return null;let s=this.side?this.side<0:t>0;for(let e=s?i.length-1:0;r=i[e],t>0?0!=e:e!=i.length-1&&!(r.top<r.bottom);e+=s?-1:1);return C(r,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ti extends F{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof ti&&t.side==this.side}split(){return new ti(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?N.before(this.dom):N.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return l.EY.empty}get isHidden(){return!0}}function tr(t,e){let n=t.dom,{children:i}=t,r=0;for(let t=0;r<i.length;r++){let s=i[r],o=t+s.length;if(!(o==t&&0>=s.getSide())){if(e>t&&e<o&&s.dom.parentNode==n)return s.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=r;t>0;t--){let e=i[t-1];if(e.dom.parentNode==n)return e.domAtPos(e.length)}for(let t=r;t<i.length;t++){let e=i[t];if(e.dom.parentNode==n)return e.domAtPos(0)}return new N(n,0)}function ts(t,e,n){let i=null,r=-1,s=null,o=-1;!function t(e,l){for(let a=0,h=0;a<e.children.length&&h<=l;a++){let c=e.children[a],u=h+c.length;u>=l&&(c.children.length?t(c,l-h):(!s||s.isHidden&&(n>0||function(t,e){let n=t.coordsAt(0,1),i=e.coordsAt(0,1);return n&&i&&i.top<n.bottom}(s,c)))&&(u>l||h==u&&c.getSide()>0)?(s=c,o=l-h):(h<l||h==u&&0>c.getSide()&&!c.isHidden)&&(i=c,r=l-h)),h=u}}(t,e);let l=(n<0?i:s)||i||s;return l?l.coordsAt(Math.max(0,l==i?r:o),n):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=b(e);return n[n.length-1]||null}(t)}function to(t,e){for(let n in t)"class"==n&&e.class?e.class+=" "+t.class:"style"==n&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}tt.prototype.children=tn.prototype.children=ti.prototype.children=I;let tl=Object.create(null);function ta(t,e,n){if(t==e)return!0;t||(t=tl),e||(e=tl);let i=Object.keys(t),r=Object.keys(e);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let s of i)if(s!=n&&(-1==r.indexOf(s)||t[s]!==e[s]))return!1;return!0}function th(t,e,n){let i=!1;if(e)for(let r in e)n&&r in n||(i=!0,"style"==r?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(i=!0,"style"==r?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return i}class tc{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var tu=((r=tu||(tu={}))[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r);class tf extends l.FB{constructor(t,e,n,i){super(),this.startSide=t,this.endSide=e,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(t){return new td(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),n=!!t.block;return e+=n&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new tm(t,e,e,n,t.widget||null,!1)}static replace(t){let e=!!t.block,n,i;if(t.isBlockGap)n=-5e8,i=4e8;else{let{start:r,end:s}=tg(t,e);n=(r?e?-3e8:-1:5e8)-1,i=(s?e?2e8:1:-6e8)+1}return new tm(t,n,i,e,t.widget||null,!0)}static line(t){return new tp(t)}static set(t,e=!1){return l.om.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}tf.none=l.om.empty;class td extends tf{constructor(t){let{start:e,end:n}=tg(t);super(e?-1:5e8,n?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,n;return this==t||t instanceof td&&this.tagName==t.tagName&&(this.class||(null==(e=this.attrs)?void 0:e.class))==(t.class||(null==(n=t.attrs)?void 0:n.class))&&ta(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}td.prototype.point=!1;class tp extends tf{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof tp&&this.spec.class==t.spec.class&&ta(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}tp.prototype.mapMode=l.iR.TrackBefore,tp.prototype.point=!0;class tm extends tf{constructor(t,e,n,i,r,s){super(e,n,r,t),this.block=i,this.isReplace=s,this.mapMode=i?e<=0?l.iR.TrackBefore:l.iR.TrackAfter:l.iR.TrackDel}get type(){return this.startSide!=this.endSide?tu.WidgetRange:this.startSide<=0?tu.WidgetBefore:tu.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){var e,n;return t instanceof tm&&(e=this.widget,e==(n=t.widget)||!!(e&&n&&e.compare(n)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function tg(t,e=!1){let{inclusiveStart:n,inclusiveEnd:i}=t;return null==n&&(n=t.inclusive),null==i&&(i=t.inclusive),{start:null!=n?n:e,end:null!=i?i:e}}function tv(t,e,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}tm.prototype.point=!0;class tb extends F{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,n,i,r,s){if(n){if(!(n instanceof tb))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),V(this,t,e,n?n.children.slice():[],r,s),!0}split(t){let e=new tb;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:n,off:i}=this.childPos(t);i&&(e.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let t=n;t<this.children.length;t++)e.append(this.children[t],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){ta(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function t(e,n,i){let r,{children:s}=e;i>0&&n instanceof te&&s.length&&(r=s[s.length-1])instanceof te&&r.mark.eq(n.mark)?t(r,n.children[0],i-1):(s.push(n),n.setParent(e)),e.length+=n.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,n=t.spec.class;e&&(this.attrs=to(e,this.attrs||{})),n&&(this.attrs=to({class:n},this.attrs||{}))}domAtPos(t){return tr(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var n;this.dom?4&this.flags&&(E(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(th(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let i=this.dom.lastChild;for(;i&&F.get(i)instanceof te;)i=i.lastChild;if(!i||!this.length||"BR"!=i.nodeName&&(null==(n=F.get(i))?void 0:n.isEditable)==!1&&(!Q.ios||!this.children.some(t=>t instanceof tt))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0,e;for(let n of this.children){if(!(n instanceof tt)||/[^ -~]/.test(n.text))return null;let i=b(n.dom);if(1!=i.length)return null;t+=i[0].width,e=i[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let n=ts(this,t,e);if(!this.children.length&&n&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=n.bottom-n.top;if(2>Math.abs(e-t.lineHeight)&&t.textHeight<e){let i=(e-t.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(t){return t instanceof tb&&0==this.children.length&&0==t.children.length&&ta(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let n=0,i=0;n<t.children.length;n++){let r=t.children[n],s=i+r.length;if(s>=e){if(r instanceof tb)return r;if(s>e)break}i=s+r.breakAfter}return null}}class ty extends F{constructor(t,e,n){super(),this.widget=t,this.length=e,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(t,e,n,i,r,s){return(!n||n instanceof ty&&!!this.widget.compare(n.widget)&&(!(t>0)||!(r<=0))&&(!(e<this.length)||!(s<=0)))&&(this.length=t+(n?n.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?N.before(this.dom):N.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let n=new ty(this.widget,e,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return I}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):l.EY.empty}domBoundsAround(){return null}become(t){return t instanceof ty&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let n=this.widget.coordsAt(this.dom,t,e);return n||(this.widget instanceof tw?null:C(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:n}=this.deco;return e!=n&&(t<0?e<0:n>0)}}class tw extends tc{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class tx{constructor(t,e,n,i){this.doc=t,this.pos=e,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof ty&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new tb),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(tk(new ti(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof ty||this.getLine()}buildText(t,e,n){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let i=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-n)),this.getLine().append(tk(new tt(this.text.slice(this.textOff,this.textOff+i)),e),n),this.atCursorPos=!0,this.textOff+=i,t-=i,n=0}}span(t,e,n,i){this.buildText(e-t,n,i),this.pos=e,this.openStart<0&&(this.openStart=i)}point(t,e,n,i,r,s){if(this.disallowBlockEffectsFor[s]&&n instanceof tm){if(n.block)throw RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=e-t;if(n instanceof tm)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ty(n.widget||tS.block,o,n));else{let s=tn.create(n.widget||tS.inline,o,o?0:n.startSide),l=this.atCursorPos&&!s.isEditable&&r<=i.length&&(t<e||n.startSide>0),a=!s.isEditable&&(t<e||r>i.length||n.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),l&&(h.append(tk(new ti(1),i),r),r=i.length+Math.max(0,r-i.length)),h.append(tk(s,i),r),this.atCursorPos=a,this.pendingBuffer=a?t<e||r>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=r)}static build(t,e,n,i,r){let s=new tx(t,e,n,r);return s.openEnd=l.om.spans(i,e,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function tk(t,e){for(let n of e)t=new te(n,[t],t.length);return t}class tS extends tc{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}tS.inline=new tS("span"),tS.block=new tS("div");var tC=((s=tC||(tC={}))[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s);let tA=tC.LTR,tO=tC.RTL;function tM(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<t[n]);return e}let tD=tM("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),tP=tM("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),tT=Object.create(null),tE=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);tT[e]=n,tT[n]=-e}function tR(t){return t<=247?tD[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?tP[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}let tB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class tL{get dir(){return this.level%2?tO:tA}constructor(t,e,n){this.from=t,this.to=e,this.level=n}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,n,i){let r=-1;for(let s=0;s<t.length;s++){let o=t[s];if(o.from<=e&&o.to>=e){if(o.level==n)return s;(r<0||(0!=i?i<0?o.from<e:o.to>e:t[r].level>o.level))&&(r=s)}}if(r<0)throw RangeError("Index out of range");return r}}let tN=[];function tI(t){return[new tL(0,t,0)]}let tF="",tj=l.sj.define(),t_=l.sj.define(),tz=l.sj.define(),tV=l.sj.define(),tH=l.sj.define(),tW=l.sj.define(),tq=l.sj.define(),tU=l.sj.define(),t$=l.sj.define(),tK=l.sj.define({combine:t=>t.some(t=>t)}),tJ=l.sj.define({combine:t=>t.some(t=>t)}),tY=l.sj.define();class tG{constructor(t,e="nearest",n="nearest",i=5,r=5,s=!1){this.range=t,this.y=e,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=s}map(t){return t.empty?this:new tG(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new tG(l.OF.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let tZ=l.Pe.define({map:(t,e)=>t.map(e)}),tX=l.Pe.define();function tQ(t,e,n){let i=t.facet(tV);i.length?i[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}let t0=l.sj.define({combine:t=>!t.length||t[0]}),t1=0,t2=l.sj.define({combine:t=>t.filter((e,n)=>{for(let i=0;i<n;i++)if(t[i].plugin==e.plugin)return!1;return!0})});class t4{constructor(t,e,n,i,r){this.id=t,this.create=e,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(t2.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(t2.of({plugin:this,arg:t}))}static define(t,e){let{eventHandlers:n,eventObservers:i,provide:r,decorations:s}=e||{};return new t4(t1++,t,n,i,t=>{let e=[];return s&&e.push(t9.of(e=>{let n=e.plugin(t);return n?s(n):tf.none})),r&&e.push(r(t)),e})}static fromClass(t,e){return t4.define((e,n)=>new t(e,n),e)}}class t3{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(tQ(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){tQ(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null==(e=this.value)?void 0:e.destroy)try{this.value.destroy()}catch(e){tQ(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let t8=l.sj.define(),t5=l.sj.define(),t9=l.sj.define(),t6=l.sj.define(),t7=l.sj.define(),et=l.sj.define();function ee(t,e){let n=t.state.facet(et);if(!n.length)return n;let i=n.map(e=>e instanceof Function?e(t):e),r=[];return l.om.spans(i,e.from,e.to,{point(){},span(t,n,i,s){let o=t-e.from,l=n-e.from,a=r;for(let t=i.length-1;t>=0;t--,s--){let n=i[t].spec.bidiIsolate,r;if(null==n&&(n=function(t,e,n){for(let i=e;i<n;i++){let e=tR(t.charCodeAt(i));if(1==e)break;if(2==e||4==e)return tO}return tA}(e.text,o,l)),s>0&&a.length&&(r=a[a.length-1]).to==o&&r.direction==n)r.to=l,a=r.inner;else{let t={from:o,to:l,direction:n,inner:[]};a.push(t),a=t.inner}}}}),r}let en=l.sj.define();function ei(t){let e=0,n=0,i=0,r=0;for(let s of t.state.facet(en)){let o=s(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(i=Math.max(i,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:e,right:n,top:i,bottom:r}}let er=l.sj.define();class es{constructor(t,e,n,i){this.fromA=t,this.toA=e,this.fromB=n,this.toB=i}join(t){return new es(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,n=this;for(;e>0;e--){let i=t[e-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),t.splice(e-1,1)}}return t.splice(e,0,n),t}static extendWithRanges(t,e){if(0==e.length)return t;let n=[];for(let i=0,r=0,s=0,o=0;;i++){let l=i==t.length?null:t[i],a=s-o,h=l?l.fromB:1e9;for(;r<e.length&&e[r]<h;){let t=e[r],i=e[r+1],s=Math.max(o,t),l=Math.min(h,i);if(s<=l&&new es(s+a,l+a,s,l).addToSet(n),i>h)break;r+=2}if(!l)return n;new es(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),s=l.toA,o=l.toB}}}class eo{constructor(t,e,n){for(let i of(this.view=t,this.state=e,this.transactions=n,this.flags=0,this.startState=t.state,this.changes=l.VR.empty(this.startState.doc.length),n))this.changes=this.changes.compose(i.changes);let i=[];this.changes.iterChangedRanges((t,e,n,r)=>i.push(new es(t,e,n,r))),this.changedRanges=i}static create(t,e,n){return new eo(t,e,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class el extends F{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=tf.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new tb],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new es(0,0,0,t.state.doc.length)],0,null)}update(t){var e,n,i,r,s,o;let a,h,c=t.changedRanges;this.minWidth>0&&c.length&&(c.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let u=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null==(e=this.domChanged)?void 0:e.newSel)?u=this.domChanged.newSel.head:(n=t.changes,i=this.hasComposition,a=!1,i&&n.iterChangedRanges((t,e)=>{t<i.to&&e>i.from&&(a=!0)}),a||t.selectionSet||(u=t.state.selection.main.head)));let f=u>-1?function(t,e,n){let i=ea(t,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new es(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let e=r.parentNode;;e=e.parentNode){let n=F.get(e);if(n instanceof te)c.push({node:e,deco:n.mark});else{if(n instanceof tb||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:h,text:r,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new td({inclusive:!0,attributes:function(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=i.value}return e}(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,u):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;c=new es(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(c.slice())}this.hasComposition=f?{from:f.range.fromB,to:f.range.toB}:null,(Q.ie||Q.chrome)&&!f&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let d=(r=this.decorations,s=this.updateDeco(),o=t.changes,h=new eh,l.om.compare(r,s,o,h),h.changes);return c=es.extendWithRanges(c,d),(!!(7&this.flags)||0!=c.length)&&(this.updateInner(c,t.startState.doc.length,f),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,n);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Q.chrome||Q.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof ty&&t.widget instanceof tw&&r.push(t.dom);i.updateGaps(r)}updateChildren(t,e,n){let i=n?n.range.addToSet(t.slice()):t,r=this.childCursor(e);for(let t=i.length-1;;t--){let e=t>=0?i[t]:null;if(!e)break;let{fromA:s,toA:o,fromB:l,toB:a}=e,h,c,u,f;if(n&&n.range.fromB<a&&n.range.toB>l){let t=tx.build(this.view.state.doc,l,n.range.fromB,this.decorations,this.dynamicDecorationMap),e=tx.build(this.view.state.doc,n.range.toB,a,this.decorations,this.dynamicDecorationMap);c=t.breakAtStart,u=t.openStart,f=e.openEnd;let i=this.compositionView(n);e.breakAtStart?i.breakAfter=1:e.content.length&&i.merge(i.length,i.length,e.content[0],!1,e.openStart,0)&&(i.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&i.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),h=t.content.concat(i).concat(e.content)}else({content:h,breakAtStart:c,openStart:u,openEnd:f}=tx.build(this.view.state.doc,l,a,this.decorations,this.dynamicDecorationMap));let{i:d,off:p}=r.findPos(o,1),{i:m,off:g}=r.findPos(s,-1);z(this,m,g,d,p,h,c,u,f)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(t){for(let e of(this.editContextFormatting=this.editContextFormatting.map(t.changes),t.transactions))for(let t of e.effects)t.is(tX)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new tt(t.text.nodeValue);for(let{deco:n}of(e.flags|=8,t.marks))e=new te(n,[e],e.length);let n=new tb;return n.append(e,0),n}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|!!e.children.some(t=>7&t.flags),this.markedForComposition.add(e);let n=F.get(t);n&&n!=e&&(n.dom=null),e.setDOM(t)},n=this.childPos(t.range.fromB,1),i=this.children[n.i];e(t.line,i);for(let r=t.marks.length-1;r>=-1;r--)n=i.childPos(n.off,1),i=i.children[n.i],e(r>=0?t.marks[r].node:t.text,i)}updateSelection(t=!1,e=!1){var n;(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&!(this.view.state.facet(t0)||this.dom.tabIndex>-1)&&v(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(Q.gecko&&l.empty&&!this.hasComposition&&1==(n=a).node.nodeType&&n.node.firstChild&&(0==n.offset||"false"==n.node.childNodes[n.offset-1].contentEditable)&&(n.offset==n.node.childNodes.length||"false"==n.node.childNodes[n.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null)),a=h=new N(t,0),o=!0}let c=this.view.observer.selectionRange;!o&&c.focusNode&&(y(a.node,a.offset,c.anchorNode,c.anchorOffset)&&y(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,l))||(this.view.observer.ignore(()=>{Q.android&&Q.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=m(this.view.root);if(t)if(l.empty){if(Q.gecko){var e,n;let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|2*(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable));if(t&&3!=t){let e=(1==t?B:L)(a.node,a.offset);e&&(a=new N(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=l.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=l.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(h.node,h.offset)}catch(t){}}else{let e=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),e.setEnd(h.node,h.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new N(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new N(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&y(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,n=m(t.root),{anchorNode:i,anchorOffset:r}=t.observer.selectionRange;if(!n||!e.empty||!e.assoc||!n.modify)return;let s=tb.find(this,e.head);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);n.collapse(h.node,h.offset),n.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&n.collapse(i,r)}moveToLine(t){let e=this.dom,n;if(t.node!=e)return t;for(let i=t.offset;!n&&i<e.childNodes.length;i++){let t=F.get(e.childNodes[i]);t instanceof tb&&(n=t.domAtPos(0))}for(let i=t.offset-1;!n&&i>=0;i--){let t=F.get(e.childNodes[i]);t instanceof tb&&(n=t.domAtPos(t.length))}return n?new N(n.node,n.offset,!0):t}nearest(t){for(let e=t;e;){let t=F.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let n=this.nearest(t);if(!n)throw RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(t,e)+n.posAtStart}domAtPos(t){let{i:e,off:n}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(n<t.length||t instanceof tb)break;e++,n=0}return this.children[e].domAtPos(n)}coordsAt(t,e){let n=null,i=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],l=r-o.breakAfter,a=l-o.length;if(l<t)break;if(a<=t&&(a<t||o.covers(-1))&&(l>t||o.covers(1))&&(!n||o instanceof tb&&!(n instanceof tb&&e>=0)))n=o,i=a;else if(n&&a==t&&l==t&&o instanceof ty&&2>Math.abs(e))if(o.deco.startSide<0)break;else s&&(n=null);r=a}return n?n.coordsAt(t-i,e):null}coordsForChar(t){let{i:e,off:n}=this.childPos(t,1),i=this.children[e];if(!(i instanceof tb))return null;for(;i.children.length;){let{i:t,off:e}=i.childPos(n,1);for(;;t++){if(t==i.children.length)return null;if((i=i.children[t]).length)break}n=e}if(!(i instanceof tt))return null;let r=(0,l.zK)(i.text,n);if(r==n)return null;let s=P(i.dom,n,r).getClientRects();for(let t=0;t<s.length;t++){let e=s[t];if(t==s.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:n,to:i}=t,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==tC.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>i)break;if(t>=n){let n=h.dom.getBoundingClientRect();if(e.push(n.height),s){let e=h.dom.lastChild,i=e?b(e):[];if(i.length){let e=i[i.length-1],s=l?e.right-n.left:n.right-e.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?tC.RTL:tC.LTR}measureTextSize(){for(let t of this.children)if(t instanceof tb){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,n,i;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let r=b(t.firstChild)[0];e=t.getBoundingClientRect().height,n=r?r.width/27:7,i=r?r.height:e,t.remove()}),{lineHeight:e,charWidth:n,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new _(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let n=0,i=0;;i++){let r=i==e.viewports.length?null:e.viewports[i],s=r?r.from-1:this.length;if(s>n){let i=(e.lineBlockAt(s).bottom-e.lineBlockAt(n).top)/this.view.scaleY;t.push(tf.replace({widget:new tw(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!r)break;n=r.to+1}return tf.set(t)}updateDeco(){let t=1,e=this.view.state.facet(t9).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),n=!1,i=this.view.state.facet(t6).map((t,e)=>{let i="function"==typeof t;return i&&(n=!0),i?t(this.view):t});for(i.length&&(this.dynamicDecorationMap[t++]=n,e.push(l.om.join(i))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=e.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let e of this.view.state.facet(tY))try{if(e(this.view,t.range,t))return!0}catch(t){tQ(this.view.state,t,"scroll handler")}let{range:e}=t,n=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),i;if(!n)return;!e.empty&&(i=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(n={left:Math.min(n.left,i.left),top:Math.min(n.top,i.top),right:Math.max(n.right,i.right),bottom:Math.max(n.bottom,i.bottom)});let r=ei(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(t,e,n,i,r,s,o,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==a.body,d=1,p=1;if(f)t=function(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:p}=A(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)e.top<t.top?(g=e.top-(t.top+o),n>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+o)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+o,n<0&&e.top-g<t.top&&(g=e.top-(t.top+o)));else{let i=e.bottom-e.top,s=t.bottom-t.top;g=("center"==r&&i<=s?e.top+i/2-s/2:"start"==r||"center"==r&&n<0?e.top-o:e.bottom-s+o)-t.top}if("nearest"==i?e.left<t.left?(m=e.left-(t.left+s),n>0&&e.right>t.right+m&&(m=e.right-t.right+s)):e.right>t.right&&(m=e.right-t.right+s,n<0&&e.left<t.left+m&&(m=e.left-(t.left+s))):m=("center"==i?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==i==l?e.left-s:e.right-(t.right-t.left)+s)-t.left,m||g)if(f)h.scrollBy(m,g);else{let t=0,n=0;if(g){let t=c.scrollTop;c.scrollTop+=g/p,n=(c.scrollTop-t)*p}if(m){let e=c.scrollLeft;c.scrollLeft+=m/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-n,right:e.right-t,bottom:e.bottom-n},t&&1>Math.abs(t-m)&&(i="nearest"),n&&1>Math.abs(n-g)&&(r="nearest")}if(f)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,s,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==tC.LTR)}}function ea(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let i=B(n.focusNode,n.focusOffset),r=L(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let e=F.get(r.node);if(!e||e instanceof tt&&e.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let t=F.get(i.node);!t||t instanceof tt&&t.text!=i.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}let eh=class{constructor(){this.changes=[]}compareRange(t,e){tv(t,e,this.changes)}comparePoint(t,e){tv(t,e,this.changes)}boundChange(t){tv(t,t,this.changes)}};function ec(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function eu(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function ef(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ed(t,e,n){let i=t.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let i=P(t,l,l+1).getClientRects();for(let a=0;a<i.length;a++){let h=i[a];if(h.top==h.bottom)continue;o||(o=e-h.left);let c=(h.top>n?h.top-n:n-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<s){let n=e>=(h.left+h.right)/2,i=n;if((Q.chrome||Q.gecko)&&P(t,l).getBoundingClientRect().left==h.right&&(i=!n),c<=0)return{node:t,offset:l+ +!!i};r=l+ +!!i,s=c}}}return{node:t,offset:r>-1?r:o>0?t.nodeValue.length:0}}function ep(t,e,n,i=-1){var r,s;let o=t.contentDOM.getBoundingClientRect(),l=o.top+t.viewState.paddingTop,a,{docHeight:h}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,r=!1;(a=t.elementAtHeight(f)).type!=tu.Text;)for(;!((f=i>0?a.bottom+e:a.top-e)>=0)||!(f<=h);){if(r)return n?null:0;r=!0,i=-i}u=l+f;let d=a.from;if(d<t.viewport.from)return 0==t.viewport.from?0:n?null:em(t,o,a,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:em(t,o,a,c,u);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(c,u);g&&!t.contentDOM.contains(g)&&(g=null),!g&&(c=Math.max(o.left+1,Math.min(o.right-1,c)),(g=m.elementFromPoint(c,u))&&!t.contentDOM.contains(g)&&(g=null));let v,y=-1;if(g&&(null==(r=t.docView.nearest(g))?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:v,offset:y}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&({startContainer:v,startOffset:y}=e,(!t.contentDOM.contains(v)||Q.safari&&function(t,e,n){let i,r=t;if(3!=t.nodeType||e!=(i=t.nodeValue.length))return!1;for(;;){let t=r.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=r.parentNode;if(!t||"DIV"==t.nodeName)break;r=t}}return P(t,i-1,i).getBoundingClientRect().right>n}(v,y,c)||Q.chrome&&function(t,e,n){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return n-(1==t.nodeType?t.getBoundingClientRect():P(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,y,c))&&(v=void 0))}v&&(y=Math.min(S(v),y))}if(!v||!t.docView.dom.contains(v)){let e=tb.find(t.docView,d);if(!e)return f>a.top+a.height/2?a.to:a.from;({node:v,offset:y}=function t(e,n,i){let r,s,o,l,a,h,c,u,f=!1;for(let m=e.firstChild;m;m=m.nextSibling){let e=b(m);for(let g=0;g<e.length;g++){var d,p;let v=e[g];h&&ec(h,v)&&(v=eu(ef(v,h.bottom),h.top));let b=(d=v).left>n?d.left-n:Math.max(0,n-d.right),y=(p=v).top>i?p.top-i:Math.max(0,i-p.bottom);if(0==b&&0==y)return 3==m.nodeType?ed(m,n,i):t(m,n,i);(!a||u>y||u==y&&c>b)&&(a=m,h=v,c=b,u=y,f=!b||(n<v.left?g>0:g<e.length-1)),0==b?i>v.bottom&&(!o||o.bottom<v.bottom)?(r=m,o=v):i<v.top&&(!l||l.top>v.top)&&(s=m,l=v):o&&ec(o,v)?o=ef(o,v.bottom):l&&ec(l,v)&&(l=eu(l,v.top))}}if(o&&o.bottom>=i?(a=r,h=o):l&&l.top<=i&&(a=s,h=l),!a)return{node:e,offset:0};let m=Math.max(h.left,Math.min(h.right,n));if(3==a.nodeType)return ed(a,m,i);if(f&&"false"!=a.contentEditable)return t(a,m,i);let g=Array.prototype.indexOf.call(e.childNodes,a)+ +(n>=(h.left+h.right)/2);return{node:e,offset:g}}(e.dom,c,u))}let w=t.docView.nearest(v);if(!w)return null;if(!w.isWidget||(null==(s=w.dom)?void 0:s.nodeType)!=1)return w.localPosFromDOM(v,y)+w.posAtStart;{let t=w.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?w.posAtStart:w.posAtEnd}}function em(t,e,n,i,r){let s=Math.round((i-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((r-n.top-(t.defaultLineHeight-e)*.5)/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+(0,l.kn)(o,s,t.state.tabSize)}function eg(t,e,n){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){let t;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!t||r.type==tu.Text&&(t.type!=r.type||(n<0?r.from<e:r.to>e)))&&(t=r)}}return t||i}return i}function ev(t,e,n,i){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let a=e,h=null;;){let e=function(t,e,n,i,r){var s;let o=i.head-t.from,a=tL.find(e,o,null!=(s=i.bidiLevel)?s:-1,i.assoc),h=e[a],c=h.side(r,n);if(o==c){let t=a+=r?1:-1;if(t<0||t>=e.length)return null;o=(h=e[a=t]).side(!r,n),c=h.side(r,n)}let u=(0,l.zK)(t.text,o,h.forward(r,n));(u<h.from||u>h.to)&&(u=c),tF=t.text.slice(Math.min(o,u),Math.max(o,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+ +!r<h.level?l.OF.cursor(f.side(!r,n)+t.from,f.forward(r,n)?1:-1,f.level):l.OF.cursor(u+t.from,h.forward(r,n)?-1:1,h.level)}(r,s,o,a,n),c=tF;if(!e){if(r.number==(n?t.state.doc.lines:1))return a;c="\n",r=t.state.doc.line(r.number+(n?1:-1)),s=t.bidiSpans(r),e=t.visualLineSide(r,!n)}if(h){if(!h(c))return a}else{if(!i)return e;h=i(c)}a=e}}function eb(t,e,n){for(;;){let i=0;for(let r of t)r.between(e-1,e+1,(t,r,s)=>{if(e>t&&e<r){let s=i||n||(e-t<r-e?-1:1);e=s<0?t:r,i=s}});if(!i)return e}}function ey(t,e,n){let i=eb(t.state.facet(t7).map(e=>e(t)),n.from,e.head>n.from?-1:1);return i==n.from?n:l.OF.cursor(i,i<n.from?1:-1)}class ew{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(l.$t.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="￿"}readRange(t,e){if(!t)return this;let n=t.parentNode;for(let i=t;;){this.findPointBefore(n,i);let t=this.text.length;this.readNode(i);let r=i.nextSibling;if(r==e)break;let s=F.get(i),o=F.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:x(i))||x(r)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>t)&&this.lineBreak(),i=r}return this.findPointBefore(n,e),this}readTextNode(t){let e=t.nodeValue;for(let n of this.points)n.node==t&&(n.pos=this.text.length+Math.min(n.offset,e.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(o=i.exec(e))&&(r=o.index,s=o[0].length),this.append(e.slice(n,r<0?e.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=s-1);n=r+s}}readNode(t){if(t.cmIgnore)return;let e=F.get(t),n=e&&e.overrideDOMText;if(null!=n){this.findPointInside(t,n.length);for(let t=n.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let n of this.points)n.node==t&&t.childNodes[n.offset]==e&&(n.pos=this.text.length)}findPointInside(t,e){for(let n of this.points)(3==t.nodeType?n.node==t:t.contains(n.node))&&(n.pos=this.text.length+(!function(t,e,n){for(;;){if(!e||n<S(e))return!1;if(e==t)return!0;n=w(e)+1,e=e.parentNode}}(t,n.node,n.offset)?0:e))}}class ex{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ek{constructor(t,e,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:s}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,n,0))){let e=r||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new ex(n,i)),(r!=n||s!=i)&&e.push(new ex(r,s))),e}(t),n=new ew(e,t.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(t,e){if(0==t.length)return null;let n=t[0].pos,i=2==t.length?t[1].pos:n;return n>-1&&i>-1?l.OF.single(n+e,i+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,n=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!g(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),i=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!g(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((Q.ios||Q.chrome)&&t.state.selection.main.empty&&n!=i&&(o.from>0||o.to<t.state.doc.length)){let e=Math.min(n,i),r=Math.max(n,i),s=o.from-e,l=o.to-r;(0==s||1==s||0==e)&&(0==l||-1==l||r==t.state.doc.length)&&(n=0,i=t.state.doc.length)}this.newSel=l.OF.single(i,n)}}}function eS(t,e){let n,{newSel:i}=e,r=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:i,to:o}=e.bounds,a=r.from,h=null;(8===s||Q.android&&e.text.length<o-i)&&(a=r.to,h="end");let c=function(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if("end"==i){let t=Math.max(0,s-Math.min(o,l));n-=o+t-s}if(o<s&&t.length<e.length){let t=n<=s&&n>=o?s-n:0;s-=t,l=s+(l-o),o=s}else if(l<s){let t=n<=s&&n>=l?s-n:0;s-=t,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}(t.state.doc.sliceString(i,o,"￿"),e.text,a-i,h);c&&(Q.chrome&&13==s&&c.toB==c.from+2&&"￿￿"==e.text.slice(c.from,c.toB)&&c.toB--,n={from:i+c.from,to:i+c.toA,insert:l.EY.of(e.text.slice(c.from,c.toB).split("￿"))})}else i&&(!t.hasFocus&&t.state.facet(t0)||i.main.eq(r))&&(i=null);if(!n&&!i)return!1;if(!n&&e.typeOver&&!r.empty&&i&&i.main.empty?n={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:(Q.mac||Q.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=l.OF.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:l.EY.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,n.from).append(n.insert).append(t.state.doc.slice(n.to,r.to))}:Q.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&t.lineWrapping&&(i&&(i=l.OF.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:l.EY.of([" "])}),n)return eC(t,n,i,s);if(!i||i.main.eq(r))return!1;{let e=!1,n="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),n=t.inputState.lastSelectionOrigin),t.dispatch({selection:i,scrollIntoView:e,userEvent:n}),!0}}function eC(t,e,n,i=-1){let r;if(Q.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Q.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&T(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==i&&e.insert.length<e.to-e.from&&e.to>s.head)&&T(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&T(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>r||(r=function(t,e,n){let i,r=t.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let n=s.from<e.from?r.sliceDoc(s.from,e.from):"",o=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(n+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=r.changes(e),a=n&&n.main.to<=o.newLength?n.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=t.state.sliceDoc(e.from,e.to),c,u=n&&ea(t,n.main.head);if(u){let t=e.insert.length-(e.to-e.from);c={from:u.from,to:u.to-t}}else c=t.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;i=r.changeByRange(n=>{if(n.from==s.from&&n.to==s.to)return{changes:o,range:a||n.map(o)};let i=n.to-f,u=i-h.length;if(n.to-n.from!=d||t.state.sliceDoc(u,i)!=h||n.to>=c.from&&n.from<=c.to)return{range:n};let p=r.changes({from:u,to:i,insert:e.insert}),m=n.to-s.to;return{changes:p,range:a?l.OF.range(Math.max(0,a.anchor+m),Math.max(0,a.head+m)):n.map(p)}})}else i={changes:o,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}(t,e,n));return t.state.facet(tW).some(n=>n(t,e.from,e.to,o,a))||t.dispatch(a()),!0}class eA{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Q.safari&&t.contentDOM.addEventListener("input",()=>null),Q.gecko&&function(t){eG.has(t)||(eG.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=F.get(n))&&i.ignoreEvent(e))return!1;return!0}(this.view,t)||this.ignoreDuringComposition(t)||"keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let n=this.handlers[t];if(n){for(let t of n.observers)t(this.view,e);for(let t of n.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function n(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,i=t&&t.plugin.domEventHandlers,r=t&&t.plugin.domEventObservers;if(i)for(let t in i){let r=i[t];r&&n(t).handlers.push(eO(e.value,r))}if(r)for(let t in r){let i=r[t];i&&n(t).observers.push(eO(e.value,i))}}for(let t in eR)n(t).handlers.push(eR[t]);for(let t in eB)n(t).observers.push(eB[t]);return e}(t),n=this.handlers,i=this.view.contentDOM;for(let t in e)if("scroll"!=t){let r=!e[t].handlers.length,s=n[t];s&&!s.handlers.length!=r&&(i.removeEventListener(t,this.handleEvent),s=null),s||i.addEventListener(t,this.handleEvent,{passive:r})}for(let t in n)"scroll"==t||e[t]||i.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){let e;return this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),!!(9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=t.keyCode&&0>eP.indexOf(t.keyCode)&&(this.tabFocusMode=-1),Q.android&&Q.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))?(this.view.observer.delayAndroidKey(t.key,t.keyCode),!0):Q.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=eM.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||eD.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=t.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(t){let e=this.pendingIOSKey;return!(!e||"Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,T(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Q.safari&&!Q.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function eO(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(t){tQ(n.state,t)}}}let eM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],eD="dthko",eP=[16,17,18,20,91,92,224,225];function eT(t){return .7*Math.max(0,t)+8}class eE{constructor(t,e,n,i){this.view=t,this.startEvent=e,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e=t.ownerDocument,n,i;for(let r=t.parentNode;r;)if(r==e.body||n&&i)break;else if(1==r.nodeType)!i&&r.scrollHeight>r.clientHeight&&(i=r),!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:n,y:i}}(t.contentDOM),this.atoms=t.state.facet(t7).map(e=>e(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(l.$t.allowMultipleSelections)&&function(t,e){let n=t.state.facet(tj);return n.length?n[0](e):Q.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!!function(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=m(t.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let t=0;t<r.length;t++){let n=r[t];if(n.left<=e.clientX&&n.right>=e.clientX&&n.top<=e.clientY&&n.bottom>=e.clientY)return!0}return!1}(t,e)&&1==eq(e)&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>(e=this.startEvent,Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))))return;this.select(this.lastEvent=t);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=ei(this.view);t.clientX-a.left<=r+6?n=-eT(r-t.clientX):t.clientX+a.right>=o-6&&(n=eT(t.clientX-o)),t.clientY-a.top<=s+6?i=-eT(s-t.clientY):t.clientY+a.bottom>=l-6&&(i=eT(t.clientY-l)),this.setScrollSpeed(n,i)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let n=0;n<t.ranges.length;n++){let i=t.ranges[n],r=null;if(i.empty){let t=eb(this.atoms,i.from,0);t!=i.from&&(r=l.OF.cursor(t,-1))}else{let t=eb(this.atoms,i.from,-1),e=eb(this.atoms,i.to,1);(t!=i.from||e!=i.to)&&(r=l.OF.range(i.from==i.anchor?t:e,i.from==i.head?t:e))}r&&(e||(e=t.ranges.slice()),e[n]=r)}return e?l.OF.create(e,t.mainIndex):t}select(t){let{view:e}=this,n=this.skipAtoms(this.style.get(t,this.extend,this.multiple));(this.mustSelect||!n.eq(e.state.selection,!1===this.dragging))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}let eR=Object.create(null),eB=Object.create(null),eL=Q.ie&&Q.ie_version<15||Q.ios&&Q.webkit_version<604;function eN(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function eI(t,e){e=eN(t.state,tU,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(null!=e$&&n.selection.ranges.every(t=>t.empty)&&e$==s.toString()){let t=-1;i=n.changeByRange(i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let h=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:h},range:l.OF.cursor(i.from+h.length)}})}else i=o?n.changeByRange(t=>{let e=s.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:l.OF.cursor(t.from+e.length)}}):n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function eF(t,e,n,i){if(1==i)return l.OF.cursor(e,n);{if(2==i)return function(t,e,n=1){let i=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return l.OF.cursor(e);0==s?n=1:s==r.length&&(n=-1);let o=s,a=s;n<0?o=(0,l.zK)(r.text,s,!1):a=(0,l.zK)(r.text,s);let h=i(r.text.slice(o,a));for(;o>0;){let t=(0,l.zK)(r.text,o,!1);if(i(r.text.slice(t,o))!=h)break;o=t}for(;a<r.length;){let t=(0,l.zK)(r.text,a);if(i(r.text.slice(a,t))!=h)break;a=t}return l.OF.range(o+r.from,a+r.from)}(t.state,e,n);let r=tb.find(t.docView,e),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return a<t.state.doc.length&&a==s.to&&a++,l.OF.range(o,a)}}eB.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},eR.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),eB.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},eB.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},eR.mousedown=(t,e)=>{var n,i;let r,s,o;if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let a=null;for(let n of t.state.facet(tz))if(a=n(t,e))break;if(a||0!=e.button||(r=e_(n=t,i=e),s=eq(i),o=n.state.selection,a={update(t){t.docChanged&&(r.pos=t.changes.mapPos(r.pos),o=o.map(t.changes))},get(t,e,i){let a=e_(n,t),h,c=eF(n,a.pos,a.bias,s);if(r.pos!=a.pos&&!e){let t=eF(n,r.pos,r.bias,s),e=Math.min(t.from,c.from),i=Math.max(t.to,c.to);c=e<c.from?l.OF.range(e,i):l.OF.range(i,e)}return e?o.replaceRange(o.main.extend(c.from,c.to)):i&&1==s&&o.ranges.length>1&&(h=function(t,e){for(let n=0;n<t.ranges.length;n++){let{from:i,to:r}=t.ranges[n];if(i<=e&&r>=e)return l.OF.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n))}return null}(o,a.pos))?h:i?o.addRange(c):l.OF.create([c])}}),a){let n=!t.hasFocus;t.inputState.startMouseSelection(new eE(t,e,a,n)),n&&t.observer.ignore(()=>{D(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),!1===i.dragging}return!1};let ej=(t,e,n)=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right;function e_(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:function(t,e,n,i){let r=tb.find(t.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(0==s)return 1;if(s==r.length)return -1;let o=r.coordsAt(s,-1);if(o&&ej(n,i,o))return -1;let l=r.coordsAt(s,1);return l&&ej(n,i,l)?1:o&&o.bottom>=i?-1:1}(t,n,e.clientX,e.clientY)}}let ez=Q.ie&&Q.ie_version<=11,eV=null,eH=0,eW=0;function eq(t){if(!ez)return t.detail;let e=eV,n=eW;return eV=t,eW=Date.now(),eH=!e||n>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(eH+1)%3:1}function eU(t,e,n,i){let r;if(!(n=eN(t.state,tU,n)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,l=i&&o&&((r=t.state.facet(t_)).length?r[0](e):Q.mac?!e.altKey:!e.ctrlKey)?{from:o.from,to:o.to}:null,a={from:s,insert:n},h=t.state.changes(l?[l,a]:a);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:l?"move.drop":"input.drop"}),t.inputState.draggedContent=null}eR.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.nearest(e.target);if(i&&i.isWidget){let t=i.posAtStart,e=t+i.length;(t>=n.to||e<=n.from)&&(n=l.OF.range(t,e))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",eN(t.state,t$,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},eR.dragend=t=>(t.inputState.draggedContent=null,!1),eR.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&eU(t,e,i.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<n.length;t++){let e=new FileReader;e.onerror=s,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(i[t]=e.result),s()},e.readAsText(n[t])}return!0}{let n=e.dataTransfer.getData("Text");if(n)return eU(t,e,n,!0),!0}return!1},eR.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=eL?null:e.clipboardData;return n?(eI(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(!function(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),eI(t,n.value)},50)}(t),!1)};let e$=null;eR.copy=eR.cut=(t,e)=>{let{text:n,ranges:i,linewise:r}=function(t){let e=[],n=[],i=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let r=-1;for(let{from:i}of t.selection.ranges){let s=t.doc.lineAt(i);s.number>r&&(e.push(s.text),n.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}i=!0}return{text:eN(t,t$,e.join(t.lineBreak)),ranges:n,linewise:i}}(t.state);if(!n&&!r)return!1;e$=r?n:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=eL?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(!function(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}(t,n),!1)};let eK=l.YH.define();function eJ(t,e){let n=[];for(let i of t.facet(tq)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:eK.of(!0)}):null}function eY(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=eJ(t.state,e);n?t.dispatch(n):t.update([])}},10)}eB.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),eY(t)},eB.blur=t=>{t.observer.clearSelectionRange(),eY(t)},eB.compositionstart=eB.compositionupdate=t=>{!t.observer.editContext&&(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},eB.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Q.chrome&&Q.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},eB.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},eR.beforeinput=(t,e)=>{var n,i;let r;if("insertReplacementText"==e.inputType&&t.observer.editContext){let i=null==(n=e.dataTransfer)?void 0:n.getData("text/plain"),r=e.getTargetRanges();if(i&&r.length){let e=r[0],n=t.posAtDOM(e.startContainer,e.startOffset),s=t.posAtDOM(e.endContainer,e.endOffset);return eC(t,{from:n,to:s,insert:t.state.toText(i)},null),!0}}if(Q.chrome&&Q.android&&(r=eM.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let e=(null==(i=window.visualViewport)?void 0:i.height)||0;setTimeout(()=>{var n;((null==(n=window.visualViewport)?void 0:n.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Q.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),Q.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>eB.compositionend(t,e),20),!1};let eG=new Set,eZ=["pre-wrap","normal","pre-line","break-spaces"],eX=!1;class eQ{constructor(t){this.lineWrapping=t,this.doc=l.EY.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let n=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((e-t-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return eZ.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let n=0;n<t.length;n++){let i=t[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(e=!0,this.heightSamples[Math.floor(10*i)]=!0)}return e}refresh(t,e,n,i,r,s){let o=eZ.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=n,this.textHeight=i,this.lineLength=r,l){this.heightSamples={};for(let t=0;t<s.length;t++){let e=s[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class e0{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class e1{constructor(t,e,n,i,r){this.from=t,this.length=e,this.top=n,this.height=i,this._content=r}get type(){return"number"==typeof this._content?tu.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof tm?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e1(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var e2=((o=e2||(e2={}))[o.ByPos=0]="ByPos",o[o.ByHeight=1]="ByHeight",o[o.ByPosNoHeight=2]="ByPosNoHeight",o);class e4{constructor(t,e,n=2){this.length=t,this.height=e,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=2*!!t|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>.001&&(eX=!0),this.height=t)}replace(t,e,n){return e4.of(n)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,n,i){let r=this,s=n.doc;for(let o=i.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=i[o],u=r.lineAt(l,e2.ByPosNoHeight,n.setDoc(e),0,0),f=u.to>=a?u:r.lineAt(a,e2.ByPosNoHeight,n,0,0);for(c+=f.to-a,a=f.to;o>0&&u.from<=i[o-1].toA;)l=i[o-1].fromA,h=i[o-1].fromB,o--,l<u.from&&(u=r.lineAt(l,e2.ByPosNoHeight,n,0,0));h+=u.from-l,l=u.from;let d=nt.build(n.setDoc(s),t,h,c);r=e3(r,r.replace(l,a,d))}return r.updateHeight(n,0)}static empty(){return new e5(0,0)}static of(t){if(1==t.length)return t[0];let e=0,n=t.length,i=0,r=0;for(;;)if(e==n)if(i>2*r){let r=t[e-1];r.break?t.splice(--e,1,r.left,null,r.right):t.splice(--e,1,r.left,r.right),n+=1+r.break,i-=r.size}else if(r>2*i){let e=t[n];e.break?t.splice(n,1,e.left,null,e.right):t.splice(n,1,e.left,e.right),n+=2+e.break,r-=e.size}else break;else if(i<r){let n=t[e++];n&&(i+=n.size)}else{let e=t[--n];e&&(r+=e.size)}let s=0;return null==t[e-1]?(s=1,e--):null==t[e]&&(s=1,n++),new e6(e4.of(t.slice(0,e)),s,e4.of(t.slice(n)))}}function e3(t,e){return t==e?t:(t.constructor!=e.constructor&&(eX=!0),e)}e4.prototype.size=1;class e8 extends e4{constructor(t,e,n){super(t,e),this.deco=n}blockAt(t,e,n,i){return new e1(i,this.length,n,this.height,this.deco||0)}lineAt(t,e,n,i,r){return this.blockAt(0,n,i,r)}forEachLine(t,e,n,i,r,s){t<=r+this.length&&e>=r&&s(this.blockAt(0,n,i,r))}updateHeight(t,e=0,n=!1,i){return i&&i.from<=e&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class e5 extends e8{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,n,i){return new e1(i,this.length,n,this.height,this.breaks)}replace(t,e,n){let i=n[0];return 1==n.length&&(i instanceof e5||i instanceof e9&&4&i.flags)&&10>Math.abs(this.length-i.length)?(i instanceof e9?i=new e5(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):e4.of(n)}updateHeight(t,e=0,n=!1,i){return i&&i.from<=e&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class e9 extends e4{constructor(t){super(t,0)}heightMetrics(t,e){let n=t.doc.lineAt(e).number,i=t.doc.lineAt(e+this.length).number,r=i-n+1,s,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);s=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else s=this.height/r;return{firstLine:n,lastLine:i,perLine:s,perChar:o}}blockAt(t,e,n,i){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(e,i);if(e.lineWrapping){let r=i+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-n)/this.height))*this.length)),s=e.doc.lineAt(r),a=o+s.length*l,h=Math.max(n,t-a/2);return new e1(s.from,s.length,h,a,0)}{let i=Math.max(0,Math.min(s-r,Math.floor((t-n)/o))),{from:l,length:a}=e.doc.line(r+i);return new e1(l,a,n+o*i,o,0)}}lineAt(t,e,n,i,r){if(e==e2.ByHeight)return this.blockAt(t,n,i,r);if(e==e2.ByPosNoHeight){let{from:e,to:i}=n.doc.lineAt(t);return new e1(e,i-e,0,0,0)}let{firstLine:s,perLine:o,perChar:l}=this.heightMetrics(n,r),a=n.doc.lineAt(t),h=o+a.length*l,c=a.number-s,u=i+o*c+l*(a.from-r-c);return new e1(a.from,a.length,Math.max(i,Math.min(u,i+this.height-h)),h,0)}forEachLine(t,e,n,i,r,s){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r);for(let h=t,c=i;h<=e;){let e=n.doc.lineAt(h);if(h==t){let n=e.number-o;c+=l*n+a*(t-r-n)}let i=l+a*e.length;s(new e1(e.from,e.length,c,i,0)),c+=i,h=e.to+1}}replace(t,e,n){let i=this.length-e;if(i>0){let t=n[n.length-1];t instanceof e9?n[n.length-1]=new e9(t.length+i):n.push(null,new e9(i-1))}if(t>0){let e=n[0];e instanceof e9?n[0]=new e9(t+e.length):n.unshift(new e9(t-1),null)}return e4.of(n)}decomposeLeft(t,e){e.push(new e9(t-1),null)}decomposeRight(t,e){e.push(null,new e9(this.length-t-1))}updateHeight(t,e=0,n=!1,i){let r=e+this.length;if(i&&i.from<=e+this.length&&i.more){let n=[],s=Math.max(e,i.from),o=-1;for(i.from>e&&n.push(new e9(i.from-e-1).updateHeight(t,e));s<=r&&i.more;){let e=t.doc.lineAt(s).length;n.length&&n.push(null);let r=i.heights[i.index++];-1==o?o=r:Math.abs(r-o)>=.001&&(o=-2);let l=new e5(e,r);l.outdated=!1,n.push(l),s+=e+1}s<=r&&n.push(null,new e9(r-s).updateHeight(t,s));let l=e4.of(n);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(t,e).perLine)>=.001)&&(eX=!0),e3(this,l)}return(n||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class e6 extends e4{constructor(t,e,n){super(t.length+e+n.length,t.height+n.height,e|(t.outdated||n.outdated?2:0)),this.left=t,this.right=n,this.size=t.size+n.size}get break(){return 1&this.flags}blockAt(t,e,n,i){let r=n+this.left.height;return t<r?this.left.blockAt(t,e,n,i):this.right.blockAt(t,e,r,i+this.left.length+this.break)}lineAt(t,e,n,i,r){let s=i+this.left.height,o=r+this.left.length+this.break,l=e==e2.ByHeight?t<s:t<o,a=l?this.left.lineAt(t,e,n,i,r):this.right.lineAt(t,e,n,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=e==e2.ByPosNoHeight?e2.ByPosNoHeight:e2.ByPos;return l?a.join(this.right.lineAt(o,h,n,s,o)):this.left.lineAt(o,h,n,i,r).join(a)}forEachLine(t,e,n,i,r,s){let o=i+this.left.height,l=r+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,n,i,r,s),e>=l&&this.right.forEachLine(t,e,n,o,l,s);else{let a=this.lineAt(l,e2.ByPos,n,i,r);t<a.from&&this.left.forEachLine(t,a.from-1,n,i,r,s),a.to>=t&&a.from<=e&&s(a),e>a.to&&this.right.forEachLine(a.to+1,e,n,o,l,s)}}replace(t,e,n){let i=this.left.length+this.break;if(e<i)return this.balanced(this.left.replace(t,e,n),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-i,e-i,n));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let t of n)r.push(t);if(t>0&&e7(r,s-1),e<this.length){let t=r.length;this.decomposeRight(e,r),e7(r,t)}return e4.of(r)}decomposeLeft(t,e){let n=this.left.length;if(t<=n)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&t>=++n&&e.push(null),t>n&&this.right.decomposeLeft(t-n,e)}decomposeRight(t,e){let n=this.left.length,i=n+this.break;if(t>=i)return this.right.decomposeRight(t-i,e);t<n&&this.left.decomposeRight(t,e),this.break&&t<i&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?e4.of(this.break?[t,null,e]:[t,e]):(this.left=e3(this.left,t),this.right=e3(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,n=!1,i){let{left:r,right:s}=this,o=e+r.length+this.break,l=null;return(i&&i.from<=e+r.length&&i.more?l=r=r.updateHeight(t,e,n,i):r.updateHeight(t,e,n),i&&i.from<=o+s.length&&i.more?l=s=s.updateHeight(t,o,n,i):s.updateHeight(t,o,n),l)?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function e7(t,e){let n,i;null==t[e]&&(n=t[e-1])instanceof e9&&(i=t[e+1])instanceof e9&&t.splice(e-1,3,new e9(n.length+1+i.length))}class nt{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof e5?n.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new e5(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,n){if(t<e||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let s=e-t;n.block?this.addBlock(new e8(s,i,n)):(s||r||i>=5)&&this.addLineDeco(i,r,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new e5(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let n=new e9(e-t);return this.oracle.doc.lineAt(t).to==e&&(n.flags|=4),n}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof e5)return t;let e=new e5(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,t),i.breaks+=e,this.writtenTo=this.pos=this.pos+n}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof e5||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new e5(0,-1));let n=t;for(let t of this.nodes)t instanceof e5&&t.updateHeight(this.oracle,n),n+=t?t.length:1;return this.nodes}static build(t,e,n,i){let r=new nt(n,t);return l.om.spans(e,n,i,r,0),r.finish(n)}}class ne{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,n,i){(t<e||n&&n.heightRelevant||i&&i.heightRelevant)&&tv(t,e,this.changes,5)}}class nn{constructor(t,e,n,i){this.from=t,this.to=e,this.size=n,this.displaySize=i}static same(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let i=t[n],r=e[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(t,e){return tf.replace({widget:new ni(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class ni extends tc{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class nr{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=na,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=tC.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(t5).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new eQ(e),this.stateDeco=t.facet(t9).filter(t=>"function"!=typeof t),this.heightMap=e4.empty().applyChanges(this.stateDeco,l.EY.empty,this.heightOracle.setDoc(t.doc),[new es(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=tf.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let n=0;n<=1;n++){let i=n?e.head:e.anchor;if(!t.some(({from:t,to:e})=>i>=t&&i<=e)){let{from:e,to:n}=this.lineBlockAt(i);t.push(new ns(e,n))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?na:new nh(this.heightOracle,this.heightMap,this.viewports),2*!t.eq(this.scaler)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(nc(t,this.scaler))})}update(t,e=null){var n,i;let r;this.state=t.state;let s=this.stateDeco;this.stateDeco=this.state.facet(t9).filter(t=>"function"!=typeof t);let o=t.changedRanges,a=es.extendWithRanges(o,(n=this.stateDeco,i=t?t.changes:l.VR.empty(this.state.doc.length),r=new ne,l.om.compare(s,n,i,r,0),r.changes)),h=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);eX=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=h||eX)&&(t.flags|=2),c?(this.scrollAnchorPos=t.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=h);let u=a.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<u.from||e.range.head>u.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,e));let f=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,t.flags|=this.updateForViewport(),(f||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(tJ)&&(this.mustEnforceCursorAssoc=!0)}measure(t){var e;let n,i,r=t.contentDOM,s=window.getComputedStyle(r),o=this.heightOracle,a=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?tC.RTL:tC.LTR;let h=this.heightOracle.mustRefreshForWrapping(a),c=r.getBoundingClientRect(),u=h||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let f=0,d=0;if(c.width&&c.height){let{scaleX:t,scaleY:e}=A(r,c);(t>.005&&Math.abs(this.scaleX-t)>.005||e>.005&&Math.abs(this.scaleY-e)>.005)&&(this.scaleX=t,this.scaleY=e,f|=16,h=u=!0)}let p=(parseInt(s.paddingTop)||0)*this.scaleY,m=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=m)&&(this.paddingTop=p,this.paddingBottom=m,f|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(u=!0),this.editorWidth=t.scrollDOM.clientWidth,f|=16);let g=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=g&&(this.scrollAnchorHeight=-1,this.scrollTop=g),this.scrolledToBottom=R(t.scrollDOM);let v=(this.printing?function(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}:function(t,e){let n=t.getBoundingClientRect(),i=t.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),l=Math.max(0,n.top),a=Math.min(r.innerHeight,n.bottom);for(let e=t.parentNode;e&&e!=i.body;)if(1==e.nodeType){let n=e,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();s=Math.max(s,i.left),o=Math.min(o,i.right),l=Math.max(l,i.top),a=Math.min(e==t.parentNode?r.innerHeight:a,i.bottom)}e="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else if(11==e.nodeType)e=e.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}})(r,this.paddingTop),b=v.top-this.pixelViewport.top,y=v.bottom-this.pixelViewport.bottom;this.pixelViewport=v;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(u=!0)),!this.inView&&!this.scrollTarget&&(n=(e=t.dom).getBoundingClientRect(),i=e.ownerDocument.defaultView||window,!(n.left<i.innerWidth)||!(n.right>0)||!(n.top<i.innerHeight)||!(n.bottom>0)))return 0;let x=c.width;if((this.contentDOMWidth!=x||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=t.scrollDOM.clientHeight,f|=16),u){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(h=!0),h||o.lineWrapping&&Math.abs(x-this.contentDOMWidth)>o.charWidth){let{lineHeight:n,charWidth:i,textHeight:r}=t.docView.measureTextSize();(h=n>0&&o.refresh(a,n,i,r,x/i,e))&&(t.docView.minWidth=0,f|=16)}for(let n of(b>0&&y>0?d=Math.max(b,y):b<0&&y<0&&(d=Math.min(b,y)),eX=!1,this.viewports)){let i=n.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(n);this.heightMap=(h?e4.empty().applyChanges(this.stateDeco,l.EY.empty,this.heightOracle,[new es(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,h,new e0(n.from,i))}eX&&(f|=2)}let k=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return k&&(2&f&&(f|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),f|=this.updateForViewport()),(2&f||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(h?[]:this.lineGaps,t)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let n=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new ns(i.lineAt(s-1e3*n,e2.ByHeight,r,0,0).from,i.lineAt(o+(1-n)*1e3,e2.ByHeight,r,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(t,e2.ByPos,r,0,0),o;o="center"==e.y?(s.top+s.bottom)/2-n/2:"start"==e.y||"nearest"==e.y&&t<l.from?s.top:s.bottom-n,l=new ns(i.lineAt(o-500,e2.ByHeight,r,0,0).from,i.lineAt(o+n+500,e2.ByHeight,r,0,0).to)}}return l}mapViewport(t,e){let n=e.mapPos(t.from,-1),i=e.mapPos(t.to,1);return new ns(this.heightMap.lineAt(n,e2.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,e2.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(t,e2.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,e2.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||i<=s-Math.max(10,Math.min(-n,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(n,250)))&&i>s-2e3&&r<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let n=[];for(let i of t)e.touchesRange(i.from,i.to)||n.push(new nn(e.mapPos(i.from),e.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(t,e){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,s=i<<1;if(this.defaultTextDirection!=tC.LTR&&!n)return[];let o=[],a=(i,s,h,c)=>{if(s-i<r)return;let u=this.state.selection.main,f=[u.from];for(let t of(u.empty||f.push(u.to),f))if(t>i&&t<s){a(i,t-10,h,c),a(t+10,s,h,c);return}let d=function(t,e){for(let n of t)if(e(n))return n}(t,t=>t.from>=h.from&&t.to<=h.to&&Math.abs(t.from-i)<r&&Math.abs(t.to-s)<r&&!f.some(e=>t.from<e&&t.to>e));if(!d){if(s<h.to&&e&&n&&e.visibleRanges.some(t=>t.from<=s&&t.to>=s)){let t=e.moveToLineBoundary(l.OF.cursor(s),!1,!0).head;t>i&&(s=t)}let t=this.gapSize(h,i,s,c),r=n||t<2e6?t:2e6;d=new nn(i,s,t,r)}o.push(d)},h=e=>{var r,o,h;let c,u,f,d,p;if(e.length<s||e.type!=tu.Text)return;let m=(r=e.from,o=e.to,h=this.stateDeco,f=[],d=r,p=0,l.om.spans(h,r,o,{span(){},point(t,e){t>d&&(f.push({from:d,to:t}),p+=t-d),d=e}},20),d<o&&(f.push({from:d,to:o}),p+=o-d),{total:p,ranges:f});if(m.total<s)return;let g=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let t,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=g){let i=nl(m,g),s=((this.visibleBottom-this.visibleTop)/2+r)/e.height;t=i-s,n=i+s}else t=(this.visibleTop-e.top-r)/e.height,n=(this.visibleBottom-e.top+r)/e.height;c=no(m,t),u=no(m,n)}else{let n,r,s=m.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,l=0;if(s>2e6)for(let n of t)n.from>=e.from&&n.from<e.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=n.size-n.displaySize);let a=this.pixelViewport.left+l,h=this.pixelViewport.right+l;if(null!=g){let t=nl(m,g),e=((h-a)/2+o)/s;n=t-e,r=t+e}else n=(a-o)/s,r=(h+o)/s;c=no(m,n),u=no(m,r)}c>e.from&&a(e.from,c,e,m),u<e.to&&a(u,e.to,e,m)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(h):h(t);return o}gapSize(t,e,n,i){let r=nl(i,n)-nl(i,e);return this.heightOracle.lineWrapping?t.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(t){nn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=tf.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];l.om.spans(e,this.viewport.from,this.viewport.to,{span(t,e){n.push({from:t,to:e})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let e=0;e<n.length&&!(8&i);e++){let r=this.visibleRanges[e],s=n[e];(r.from!=s.from||r.to!=s.to)&&(i|=4,t&&t.mapPos(r.from,-1)==s.from&&t.mapPos(r.to,1)==s.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||nc(this.heightMap.lineAt(t,e2.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||nc(this.heightMap.lineAt(this.scaler.fromDOM(t),e2.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return nc(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ns{constructor(t,e){this.from=t,this.to=e}}function no({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let t=0;;t++){let{from:n,to:r}=e[t],s=r-n;if(i<=s)return n+i;i-=s}}function nl(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}let na={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class nh{constructor(t,e,n){let i=0,r=0,s=0;for(let o of(this.viewports=n.map(({from:n,to:r})=>{let s=e.lineAt(n,e2.ByPos,t,0,0).top,o=e.lineAt(r,e2.ByPos,t,0,0).bottom;return i+=o-s,{from:n,to:r,top:s,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(e.height-i),this.viewports))o.domTop=s+(o.top-r)*this.scale,s=o.domBottom=o.domTop+(o.bottom-o.top),r=o.bottom}toDOM(t){for(let e=0,n=0,i=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return i+(t-n)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);n=r.bottom,i=r.domBottom}}fromDOM(t){for(let e=0,n=0,i=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return n+(t-i)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);n=r.bottom,i=r.domBottom}}eq(t){return t instanceof nh&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to)}}function nc(t,e){if(1==e.scale)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new e1(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(t=>nc(t,e)):t._content)}let nu=l.sj.define({combine:t=>t.join(" ")}),nf=l.sj.define({combine:t=>t.indexOf(!0)>-1}),nd=a.G.newName(),np=a.G.newName(),nm=a.G.newName(),ng={"&light":"."+np,"&dark":"."+nm};function nv(t,e,n){return new a.G(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!n||!n[e])throw RangeError(`Unsupported selector: ${e}`);return n[e]}):t+" "+e})}let nb=nv("."+nd,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ng),ny={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},nw=Q.ie&&Q.ie_version<=11;class nx{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new O,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(Q.ie&&Q.ie_version<=11||Q.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Q.android&&!1!==t.constructor.EDIT_CONTEXT&&!(Q.chrome&&Q.chrome_version<126)&&(this.editContext=new nC(t),t.state.facet(t0)&&(t.contentDOM.editContext=this.editContext.editContext)),nw&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null==(t=this.view.docView)?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,n)=>e!=t[n]))){for(let e of(this.gapIntersection.disconnect(),t))this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(t0)?n.root.activeElement!=this.dom:!v(this.dom,i))return;let r=i.anchorNode&&n.docView.nearest(i.anchorNode);if(r&&r.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(Q.ie&&Q.ie_version<=11||Q.android&&Q.chrome)&&!n.state.selection.main.empty&&i.focusNode&&y(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=m(t.root);if(!e)return!1;let n=Q.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return nS(t,n)}let n=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?nS(t,n):null}(this.view,e)||e;if(!n||this.selectionRange.eq(n))return!1;let i=v(this.dom,n);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let n=e.focusNode,i=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=i)return!1;for(i=Math.min(i,S(n));;)if(i){if(1!=n.nodeType)return!1;let t=n.childNodes[i-1];"false"==t.contentEditable?i--:i=S(n=t)}else{if(n==t)return!0;i=w(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let n=this.dom;n;)if(1==n.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==n?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ny),nw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),nw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var n;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&T(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null==(n=this.delayedAndroidKey)?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,n=-1,i=!1;for(let r of t){let t=this.readMutation(r);t&&(t.typeOver&&(i=!0),-1==e?{from:e,to:n}=t:(e=Math.min(t.from,e),n=Math.max(t.to,n)))}return{from:e,to:n,typeOver:i}}readChange(){let{from:t,to:e,typeOver:n}=this.processRecords(),i=this.selectionChanged&&v(this.dom,this.selectionRange);if(t<0&&!i)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new ek(this.view,t,e,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let n=this.view.state,i=eS(this.view,e);return this.view.state==n&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let n=nk(e,t.previousSibling||t.target.previousSibling,-1),i=nk(e,t.nextSibling||t.target.nextSibling,1);return{from:n?e.posAfter(n):e.posAtStart,to:i?e.posBefore(i):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(t0)!=t.state.facet(t0)&&(t.view.contentDOM.editContext=t.state.facet(t0)?this.editContext.editContext:null))}destroy(){var t,e,n;for(let i of(this.stop(),null==(t=this.intersection)||t.disconnect(),null==(e=this.gapIntersection)||e.disconnect(),null==(n=this.resizeScroll)||n.disconnect(),this.scrollTargets))i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function nk(t,e,n){for(;e;){let i=F.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function nS(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return y(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}class nC{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});for(let n in this.handlers.textupdate=e=>{let n=t.state.selection.main,{anchor:i,head:r}=n,s=this.toEditorPos(e.updateRangeStart),o=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:s,drifted:!1});let a={from:s,to:o,insert:l.EY.of(e.text.split("\n"))};if(a.from==this.from&&i<this.from?a.from=i:a.to==this.to&&i>this.to&&(a.to=i),a.from==a.to&&!a.insert.length){let i=l.OF.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd));i.main.eq(n)||t.dispatch({selection:i,userEvent:"select"});return}if((Q.mac||Q.android)&&a.from==r-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(a={from:s,to:o,insert:l.EY.of([e.text.replace("."," ")])}),this.pendingContextChange=a,!t.state.readOnly){let n=this.to-this.from+(a.to-a.from+a.insert.length);eC(t,a,l.OF.single(this.toEditorPos(e.selectionStart,n),this.toEditorPos(e.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let e=this.toEditorPos(n.rangeStart),s=this.toEditorPos(n.rangeEnd);e<s;e++){let n=t.coordsForChar(e);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}e.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=e=>{let n=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,i=t.underlineThickness;if("None"!=e&&"None"!=i){let r=this.toEditorPos(t.rangeStart),s=this.toEditorPos(t.rangeEnd);if(r<s){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==i?1:2}px`;n.push(tf.mark({attributes:{style:t}}).range(r,s))}}}t.dispatch({effects:tX.of(tf.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}},this.handlers)e.addEventListener(n,this.handlers[n]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=m(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,n=!1,i=this.pendingContextChange;return t.changes.iterChanges((r,s,o,l,a)=>{if(n)return;let h=a.length-(s-r);if(i&&s>=i.to)if(i.from==r&&i.to==s&&i.insert.eq(a)){i=this.pendingContextChange=null,e+=h,this.to+=h;return}else i=null,this.revertPending(t.state);if(r+=e,(s+=e)<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}e+=h}),i&&!n&&this.revertPending(t.state),!n}update(t){let e=this.pendingContextChange,n=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(n.from,n.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),i=this.toContextPos(e.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(n,i)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let n=this.composing;return n&&n.drifted?n.editorBase+(t-n.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class nA{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:n}=t;for(let e of(this.dispatchTransactions=t.dispatchTransactions||n&&(t=>t.forEach(t=>n(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new nr(t.state||l.$t.create(t)),t.scrollTo&&t.scrollTo.is(tZ)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(t2).map(t=>new t3(t)),this.plugins))e.update(this);this.observer=new nx(this),this.inputState=new eA(this),this.inputState.ensureHandlers(this.plugins),this.docView=new el(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null==(e=document.fonts)?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof l.ZX?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,n=!1,i,r=this.state;for(let e of t){if(e.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,a=null;t.some(t=>t.annotation(eK))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,(a=eJ(r,s))||(o=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),((c=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(l.$t.phrases)!=this.state.facet(l.$t.phrases))return this.setState(r);i=eo.create(this,r,t),i.flags|=o;let u=this.viewState.scrollTarget;try{for(let e of(this.updateState=2,t)){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new tG(t.empty?t:l.OF.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(tZ)&&(u=t.value.clip(this.state))}this.viewState.update(i,u),this.bidiCache=nD.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),e=this.docView.update(i),this.state.facet(er)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(nu)!=i.state.facet(nu)&&(this.viewState.mustMeasureContent=!0),(e||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!i.empty)for(let t of this.state.facet(tH))try{t(i)}catch(t){tQ(this.state,t,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!eS(this,c)&&h.force&&T(this.contentDOM,h.key,h.keyCode)})}setState(t){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);for(let e of(this.viewState=new nr(t),this.plugins=t.facet(t2).map(t=>new t3(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView.destroy(),this.docView=new el(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(t2),n=t.state.facet(t2);if(e!=n){let i=[];for(let r of n){let n=e.indexOf(r);if(n<0)i.push(new t3(r));else{let e=this.plugins[n];e.mustUpdate=t,i.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){tQ(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(R(n))r=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(i);r=t.from,s=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(t=>{try{return t.read(this)}catch(t){return tQ(this.state,t),nM}}),h=eo.create(this,this.state,[]),c=!1;h.flags|=o,e?e.flags|=o:e=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(a[t]!=nM)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){tQ(this.state,t)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let t=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(t>1||t<-1){n.scrollTop=(i+=t)/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(tH))t(e)}get themeClasses(){return nd+" "+(this.state.facet(nf)?nm:np)+" "+this.state.facet(nu)}updateAttrs(){let t=nP(this,t8,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(t0)?"true":"false",class:"cm-content",style:`${Q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),nP(this,t5,e);let n=this.observer.ignore(()=>{let n=th(this.contentDOM,this.contentAttrs,e),i=th(this.dom,this.editorAttrs,t);return n||i});return this.editorAttrs=t,this.contentAttrs=e,n}showAnnouncements(t){let e=!0;for(let n of t)for(let t of n.effects)t.is(nA.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(er);let t=this.state.facet(nA.cspNonce);a.G.mount(this.root,this.styleModules.concat(nb).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if((this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t)&&!(this.measureRequests.indexOf(t)>-1)){if(null!=t.key){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,n){return ey(this,t,ev(this,t,e,n))}moveByGroup(t,e){return ey(this,t,ev(this,t,e,e=>{var n;let i,r;return n=t.head,r=(i=this.state.charCategorizer(n))(e),t=>{let e=i(t);return r==l.Je.Space&&(r=e),r==e}}))}visualLineSide(t,e){let n=this.bidiSpans(t),i=this.textDirectionAt(t.from),r=n[e?n.length-1:0];return l.OF.cursor(r.side(e,i)+t.from,r.forward(!e,i)?1:-1)}moveToLineBoundary(t,e,n=!0){return function(t,e,n,i){let r=eg(t,e.head,e.assoc||-1),s=i&&r.type==tu.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),i=t.textDirectionAt(r.from),o=t.posAtCoords({x:n==(i==tC.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=o)return l.OF.cursor(o,n?-1:1)}return l.OF.cursor(n?r.to:r.from,n?-1:1)}(this,t,e,n)}moveVertically(t,e,n){return ey(this,t,function(t,e,n,i){let r=e.head,s=n?1:-1;if(r==(n?t.state.doc.length:0))return l.OF.cursor(r,e.assoc);let o=e.goalColumn,a,h=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r,e.assoc||-1),u=t.documentTop;if(c)null==o&&(o=c.left-h.left),a=s<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(r);null==o&&(o=Math.min(h.right-h.left,t.defaultCharacterWidth*(r-e.from))),a=(s<0?e.top:e.bottom)+u}let f=h.left+o,d=null!=i?i:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let n=a+(d+e)*s,i=ep(t,{x:f,y:n},!1,s);if(n<h.top||n>h.bottom||(s<0?i<r:i>r)){let e=t.docView.coordsForChar(i),r=!e||n<e.top?-1:1;return l.OF.cursor(i,r,void 0,o)}}}(this,t,e,n))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),ep(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let n=this.docView.coordsAt(t,e);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(t),r=this.bidiSpans(i);return C(n,r[tL.find(r,t-i.from,-1,e)].dir==tC.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(tK)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>nO)return tI(t.length);let e=this.textDirectionAt(t.from),n;for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e&&(i.fresh||function t(e,n){if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!t(r.inner,s.inner))return!1}return!0}(i.isolates,n=ee(this,t))))return i.order;n||(n=ee(this,t));let i=function(t,e,n){if(!t)return[new tL(0,0,+(e==tO))];if(e==tA&&!n.length&&!tB.test(t))return tI(t.length);if(n.length)for(;t.length>tN.length;)tN[tN.length]=256;let i=[],r=+(e!=tA);return function t(e,n,i,r,s,o,l){let a=n%2?2:1;!function(t,e,n,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:n,a=s?256:r;for(let e=o,n=a,i=a;e<l;e++){let r=tR(t.charCodeAt(e));512==r?r=n:8==r&&4==i&&(r=16),tN[e]=4==r?2:r,7&r&&(i=r),n=r}for(let t=o,e=a,i=a;t<l;t++){let r=tN[t];if(128==r)t<l-1&&e==tN[t+1]&&24&e?r=tN[t]=e:tN[t]=256;else if(64==r){let r=t+1;for(;r<l&&64==tN[r];)r++;let s=t&&8==e||r<n&&8==tN[r]?1==i?1:8:256;for(let e=t;e<r;e++)tN[e]=s;t=r-1}else 8==r&&1==i&&(tN[t]=1);e=r,7&r&&(i=r)}}}(e,s,o,r,a),function(t,e,n,i,r){let s=1==r?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:n;for(let e=h,n,i,o;e<c;e++)if(i=tT[n=t.charCodeAt(e)])if(i<0){for(let t=l-3;t>=0;t-=3)if(tE[t+1]==-i){let n=tE[t+2],i=2&n?r:4&n?1&n?s:r:0;i&&(tN[e]=tN[tE[t]]=i),l=t;break}}else if(189==tE.length)break;else tE[l++]=e,tE[l++]=n,tE[l++]=a;else if(2==(o=tN[e])||1==o){let t=o==r;a=+!t;for(let e=l-3;e>=0;e-=3){let n=tE[e+2];if(2&n)break;if(t)tE[e+2]|=2;else{if(4&n)break;tE[e+2]|=4}}}}}(e,s,o,r,a),function(t,e,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:t,l=r<n.length?n[r].from:e;for(let a=o;a<l;){let o=tN[a];if(256==o){let o=a+1;for(;;)if(o==l){if(r==n.length)break;o=n[r++].to,l=r<n.length?n[r].from:e}else if(256==tN[o])o++;else break;let h=1==s,c=h==((o<e?tN[o]:i)==1)?h?1:2:i;for(let e=o,i=r,s=i?n[i-1].to:t;e>a;)e==s&&(e=n[--i].from,s=i?n[i-1].to:t),tN[--e]=c;a=o}else s=o,a++}}}(s,o,r,a),function e(n,i,r,s,o,l,a){let h=s%2?2:1;if(s%2==o%2)for(let c=i,u=0;c<r;){let i=!0,f=!1;if(u==l.length||c<l[u].from){let t=tN[c];t!=h&&(i=!1,f=16==t)}let d=i||1!=h?null:[],p=i?s:s+1,m=c;n:for(;;)if(u<l.length&&m==l[u].from){if(f)break;let e=l[u];if(!i)for(let t=e.to,n=u+1;;){if(t==r)break n;if(n<l.length&&l[n].from==t)t=l[n++].to;else if(tN[t]==h)break n;else break}u++,d?d.push(e):(e.from>c&&a.push(new tL(c,e.from,p)),t(n,e.direction==tA!=!(p%2)?s+1:s,o,e.inner,e.from,e.to,a),c=e.to),m=e.to}else if(m==r||(i?tN[m]!=h:tN[m]==h))break;else m++;d?e(n,c,m,s+1,o,d,a):c<m&&a.push(new tL(c,m,p)),c=m}else for(let c=r,u=l.length;c>i;){let r=!0,f=!1;if(!u||c>l[u-1].to){let t=tN[c-1];t!=h&&(r=!1,f=16==t)}let d=r||1!=h?null:[],p=r?s:s+1,m=c;n:for(;;)if(u&&m==l[u-1].to){if(f)break;let e=l[--u];if(!r)for(let t=e.from,n=u;;){if(t==i)break n;if(n&&l[n-1].to==t)t=l[--n].from;else if(tN[t-1]==h)break n;else break}d?d.push(e):(e.to<c&&a.push(new tL(e.to,c,p)),t(n,e.direction==tA!=!(p%2)?s+1:s,o,e.inner,e.from,e.to,a),c=e.from),m=e.from}else if(m==i||(r?tN[m-1]!=h:tN[m-1]==h))break;else m--;d?e(n,m,c,s+1,o,d,a):m<c&&a.push(new tL(m,c,p)),c=m}}(e,s,o,n,i,r,l)}(t,r,r,n,0,t.length,i),i}(t.text,e,n);return this.bidiCache.push(new nD(t.from,t.to,e,n,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Q.safari&&(null==(t=this.inputState)?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{D(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return tZ.of(new tG("number"==typeof t?l.OF.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,n=this.viewState.scrollAnchorAt(t);return tZ.of(new tG(l.OF.cursor(n.from),"start","start",n.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return t4.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return t4.define(()=>({}),{eventObservers:t})}static theme(t,e){let n=a.G.newName(),i=[nu.of(n),er.of(nv(`.${n}`,t))];return e&&e.dark&&i.push(nf.of(!0)),i}static baseTheme(t){return l.Nb.lowest(er.of(nv("."+nd,t,ng)))}static findFromDOM(t){var e;let n=t.querySelector(".cm-content"),i=n&&F.get(n)||F.get(t);return(null==(e=null==i?void 0:i.rootView)?void 0:e.view)||null}}nA.styleModule=er,nA.inputHandler=tW,nA.clipboardInputFilter=tU,nA.clipboardOutputFilter=t$,nA.scrollHandler=tY,nA.focusChangeEffect=tq,nA.perLineTextDirection=tK,nA.exceptionSink=tV,nA.updateListener=tH,nA.editable=t0,nA.mouseSelectionStyle=tz,nA.dragMovesSelection=t_,nA.clickAddsSelectionRange=tj,nA.decorations=t9,nA.outerDecorations=t6,nA.atomicRanges=t7,nA.bidiIsolatedRanges=et,nA.scrollMargins=en,nA.darkTheme=nf,nA.cspNonce=l.sj.define({combine:t=>t.length?t[0]:""}),nA.contentAttributes=t5,nA.editorAttributes=t8,nA.lineWrapping=nA.contentAttributes.of({class:"cm-lineWrapping"}),nA.announce=l.Pe.define();let nO=4096,nM={};class nD{constructor(t,e,n,i,r,s){this.from=t,this.to=e,this.dir=n,this.isolates=i,this.fresh=r,this.order=s}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let n=[],i=t.length?t[t.length-1].dir:tC.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let s=t[r];s.dir!=i||e.touchesRange(s.from,s.to)||n.push(new nD(e.mapPos(s.from,1),e.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return n}}function nP(t,e,n){for(let i=t.state.facet(e),r=i.length-1;r>=0;r--){let e=i[r],s="function"==typeof e?e(t):e;s&&to(s,n)}return n}let nT=Q.mac?"mac":Q.windows?"win":Q.linux?"linux":"key";function nE(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}let nR=l.Nb.default(nA.domEventHandlers({keydown:(t,e)=>n_(nN(e.state),t,e,"editor")})),nB=l.sj.define({enables:nR}),nL=new WeakMap;function nN(t){let e=t.facet(nB),n=nL.get(e);return n||nL.set(e,n=function(t,e=nT){let n=Object.create(null),i=Object.create(null),r=(t,e)=>{let n=i[t];if(null==n)i[t]=e;else if(n!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},s=(t,i,s,o,l)=>{var a,h;let c=n[t]||(n[t]=Object.create(null)),u=i.split(/ (?!$)/).map(t=>(function(t,e){let n,i,r,s,o=t.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let t=0;t<o.length-1;++t){let l=o[t];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))r=!0;else if(/^mod$/i.test(l))"mac"==e?s=!0:i=!0;else throw Error("Unrecognized modifier name: "+l)}return n&&(l="Alt-"+l),i&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l})(t,e));for(let e=1;e<u.length;e++){let n=u.slice(0,e).join(" ");r(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[e=>{let i=nF={view:e,prefix:n,scope:t};return setTimeout(()=>{nF==i&&(nF=null)},4e3),!0}]})}let f=u.join(" ");r(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null==(h=null==(a=c._any)?void 0:a.run)?void 0:h.slice())||[]});s&&d.run.push(s),o&&(d.preventDefault=!0),l&&(d.stopPropagation=!0)};for(let i of t){let t=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let e of t){let t=n[e]||(n[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=i;for(let e in t)t[e].run.push(t=>r(t,nj))}let r=i[e]||i.key;if(r)for(let e of t)s(e,r,i.run,i.preventDefault,i.stopPropagation),i.shift&&s(e,"Shift-"+r,i.shift,i.preventDefault,i.stopPropagation)}return n}(e.reduce((t,e)=>t.concat(e),[]))),n}function nI(t,e,n){return n_(nN(t.state),e,t,n)}let nF=null,nj=null;function n_(t,e,n,i){var r;nj=e;let s=("Esc"==(r=!(u&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||f&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?c:h)[e.keyCode]||e.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=(0,l.vS)(s,0),a=(0,l.Fh)(o)==s.length&&" "!=s,d="",p=!1,m=!1,g=!1;nF&&nF.view==n&&nF.scope==i&&(d=nF.prefix+" ",0>eP.indexOf(e.keyCode)&&(m=!0,nF=null));let v=new Set,b=t=>{if(t){for(let e of t.run)if(!v.has(e)&&(v.add(e),e(n)))return t.stopPropagation&&(g=!0),!0;t.preventDefault&&(t.stopPropagation&&(g=!0),m=!0)}return!1},y=t[i],w,x;return y&&(b(y[d+nE(s,e,!a)])?p=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Q.windows&&e.ctrlKey&&e.altKey)&&(w=h[e.keyCode])&&w!=s?b(y[d+nE(w,e,!0)])?p=!0:e.shiftKey&&(x=c[e.keyCode])!=s&&x!=w&&b(y[d+nE(x,e,!1)])&&(p=!0):a&&e.shiftKey&&b(y[d+nE(s,e,!0)])&&(p=!0),!p&&b(y._any)&&(p=!0)),m&&(p=!0),p&&g&&e.stopPropagation(),nj=null,p}class nz{constructor(t,e,n,i,r){this.className=t,this.left=e,this.top=n,this.width=i,this.height=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,n){if(!n.empty)return function(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let i=Math.max(n.from,t.viewport.from),r=Math.min(n.to,t.viewport.to),s=t.textDirection==tC.LTR,o=t.contentDOM,l=o.getBoundingClientRect(),a=nV(t),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),u=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),d=eg(t,i,1),p=eg(t,r,-1),m=d.type==tu.Text?d:null,g=p.type==tu.Text?p:null;if(m&&(t.lineWrapping||d.widgetLineBreaks)&&(m=nH(t,i,1,m)),g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=nH(t,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let e=m?y(n.from,null,m):w(d,!1),i=g?y(null,n.to,g):w(p,!0),r=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<i.top?r.push(v(u,e.bottom,f,i.top)):e.bottom<i.top&&t.elementAtHeight((e.bottom+i.top)/2).type==tu.Text&&(e.bottom=i.top=(e.bottom+i.top)/2),b(e).concat(r).concat(b(i))}function v(t,n,i,r){return new nz(e,t-a.left,n-a.top,i-t,r-n)}function b({top:t,bottom:e,horizontal:n}){let i=[];for(let r=0;r<n.length;r+=2)i.push(v(n[r],t,n[r+1],e));return i}function y(e,n,i){let r=1e9,o=-1e9,l=[];function a(e,n,a,h,c){let d=t.coordsAtPos(e,e==i.to?-2:2),p=t.coordsAtPos(a,a==i.from?2:-2);d&&p&&(r=Math.min(d.top,p.top,r),o=Math.max(d.bottom,p.bottom,o),c==tC.LTR?l.push(s&&n?u:d.left,s&&h?f:p.right):l.push(!s&&h?u:p.left,!s&&n?f:d.right))}let h=null!=e?e:i.from,c=null!=n?n:i.to;for(let i of t.visibleRanges)if(i.to>h&&i.from<c)for(let r=Math.max(i.from,h),s=Math.min(i.to,c);;){let i=t.state.doc.lineAt(r);for(let o of t.bidiSpans(i)){let t=o.from+i.from,l=o.to+i.from;if(t>=s)break;l>r&&a(Math.max(t,r),null==e&&t<=h,Math.min(l,s),null==n&&l>=c,o.dir)}if((r=i.to+1)>=s)break}return 0==l.length&&a(h,null==e,c,null==n,t.textDirection),{top:r,bottom:o,horizontal:l}}function w(t,e){let n=l.top+(e?t.top:t.bottom);return{top:n,bottom:n,horizontal:[]}}}(t,e,n);{let i=t.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let r=nV(t);return[new nz(e,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}}}function nV(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==tC.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function nH(t,e,n,i){let r=t.coordsAtPos(e,2*n);if(!r)return i;let s=t.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=t.posAtCoords({x:s.left+1,y:o}),a=t.posAtCoords({x:s.right-1,y:o});return null==l||null==a?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}class nW{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(nq)!=t.state.facet(nq)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,n=t.facet(nq);for(;e<n.length&&n[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;(t!=this.scaleX||e!=this.scaleY)&&(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{var n;return n=this.drawn[e],!(t.constructor==n.constructor&&t.eq(n))})){let e=this.dom.firstChild,n=0;for(let i of t)i.update&&e&&i.constructor&&this.drawn[n].constructor&&i.update(e,this.drawn[n])?(e=e.nextSibling,n++):this.dom.insertBefore(i.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}let nq=l.sj.define();function nU(t){return[t4.define(e=>new nW(e,t)),nq.of(t)]}let n$=l.sj.define({combine:t=>(0,l.QR)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function nK(t={}){return[n$.of(t),nY,nZ,nX,tJ.of(!0)]}function nJ(t){return t.startState.facet(n$)!=t.state.facet(n$)}let nY=nU({above:!0,markers(t){let{state:e}=t,n=e.facet(n$),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||n.drawRangeCursor){let e=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=r.empty?r:l.OF.cursor(r.head,r.head>r.anchor?-1:1);for(let r of nz.forRange(t,e,n))i.push(r)}}return i},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let n=nJ(t);return n&&nG(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){nG(e.state,t)},class:"cm-cursorLayer"});function nG(t,e){e.style.animationDuration=t.facet(n$).cursorBlinkRate+"ms"}let nZ=nU({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:nz.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||nJ(t),class:"cm-selectionLayer"}),nX=l.Nb.highest(nA.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),nQ=l.Pe.define({map:(t,e)=>null==t?null:e.mapPos(t)}),n0=l.sU.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(nQ)?e.value:t,t))}),n1=t4.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field(n0);null==n?null!=this.cursor&&(null==(e=this.cursor)||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(n0)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(n0),n=null!=e&&t.coordsAtPos(e);if(!n)return null;let i=t.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-i.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(n0)!=t&&this.view.dispatch({effects:nQ.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function n2(){return[n0,n1]}function n4(t,e,n,i,r){e.lastIndex=0;for(let s=t.iterRange(n,i),o=n,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}class n3{constructor(t){const{regexp:e,decoration:n,decorate:i,boundary:r,maxLength:s=1e3}=t;if(!e.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,i)this.addMatch=(t,e,n,r)=>i(r,n,n+t[0].length,t,e);else if("function"==typeof n)this.addMatch=(t,e,i,r)=>{let s=n(t,e,i);s&&r(i,i+t[0].length,s)};else if(n)this.addMatch=(t,e,i,r)=>r(i,i+t[0].length,n);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}createDeco(t){let e=new l.vB,n=e.add.bind(e);for(let{from:e,to:i}of function(t,e){let n=t.visibleRanges;if(1==n.length&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}(t,this.maxLength))n4(t.state.doc,this.regexp,e,i,(e,i)=>this.addMatch(i,t,e,n));return e.finish()}updateDeco(t,e){let n=1e9,i=-1;return(t.docChanged&&t.changes.iterChanges((e,r,s,o)=>{o>=t.view.viewport.from&&s<=t.view.viewport.to&&(n=Math.min(s,n),i=Math.max(o,i))}),t.viewportMoved||i-n>1e3)?this.createDeco(t.view):i>-1?this.updateRange(t.view,e.map(t.changes),n,i):e}updateRange(t,e,n,i){for(let r of t.visibleRanges){let s=Math.max(r.from,n),o=Math.min(r.to,i);if(o>=s){let n=t.state.doc.lineAt(s),i=n.to<o?t.state.doc.lineAt(o):n,l=Math.max(r.from,n.from),a=Math.min(r.to,i.to);if(this.boundary){for(;s>n.from;s--)if(this.boundary.test(n.text[s-1-n.from])){l=s;break}for(;o<i.to;o++)if(this.boundary.test(i.text[o-i.from])){a=o;break}}let h=[],c,u=(t,e,n)=>h.push(n.range(t,e));if(n==i)for(this.regexp.lastIndex=l-n.from;(c=this.regexp.exec(n.text))&&c.index<a-n.from;)this.addMatch(c,t,c.index+n.from,u);else n4(t.state.doc,this.regexp,l,a,(e,n)=>this.addMatch(n,t,e,u));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:h})}}return e}}let n8=null!=/x/.unicode?"gu":"g",n5=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]",n8),n9={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},n6=null,n7=l.sj.define({combine(t){let e=(0,l.QR)(t,{render:null,specialChars:n5,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==n6&&"u">typeof document&&document.body){let e=document.body.style;n6=(null!=(t=e.tabSize)?t:e.MozTabSize)!=null}return n6||!1}())&&(e.specialChars=RegExp(" |"+e.specialChars.source,n8)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,n8)),e}});function it(t={}){return[n7.of(t),ie||(ie=t4.fromClass(class{constructor(t){this.view=t,this.decorations=tf.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(n7)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new n3({regexp:t.specialChars,decoration:(e,n,i)=>{let{doc:r}=n.state,s=(0,l.vS)(e[0],0);if(9==s){let t=r.lineAt(i),e=n.state.tabSize,s=(0,l.y$)(t.text,e,i-t.from);return tf.replace({widget:new ir((e-s%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=tf.replace({widget:new ii(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(n7);t.startState.facet(n7)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let ie=null;class ii extends tc{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){var e;let n=(e=this.code)>=32?"•":10==e?"␤":String.fromCharCode(9216+e),i=t.state.phrase("Control character")+" "+(n9[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class ir extends tc{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function is(){return il}let io=tf.line({class:"cm-activeLine"}),il=t4.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let i of t.state.selection.ranges){let r=t.lineBlockAt(i.head);r.from>e&&(n.push(io.range(r.from)),e=r.from)}return tf.set(n)}},{decorations:t=>t.decorations});function ia(t,e){var n;let i,r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),s=t.state.doc.lineAt(r),o=r-s.from,a=o>2e3?-1:o==s.length?(n=e.clientX,(i=t.coordsAtPos(t.viewport.from))?Math.round(Math.abs((i.left-n)/t.defaultCharacterWidth)):-1):(0,l.y$)(s.text,t.state.tabSize,r-s.from);return{line:s.number,col:a,off:o}}function ih(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return nA.mouseSelectionStyle.of((t,n)=>{let i,r;return e(n)?(i=ia(t,n),r=t.state.selection,i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),n=t.state.doc.lineAt(e);i={line:n.number,col:i.col,off:Math.min(i.off,n.length)},r=r.map(t.changes)}},get(e,n,s){let o=ia(t,e);if(!o)return r;let a=function(t,e,n){let i=Math.min(e.line,n.line),r=Math.max(e.line,n.line),s=[];if(e.off>2e3||n.off>2e3||e.col<0||n.col<0){let o=Math.min(e.off,n.off),a=Math.max(e.off,n.off);for(let e=i;e<=r;e++){let n=t.doc.line(e);n.length<=a&&s.push(l.OF.range(n.from+o,n.to+a))}}else{let o=Math.min(e.col,n.col),a=Math.max(e.col,n.col);for(let e=i;e<=r;e++){let n=t.doc.line(e),i=(0,l.kn)(n.text,o,t.tabSize,!0);if(i<0)s.push(l.OF.cursor(n.to));else{let e=(0,l.kn)(n.text,a,t.tabSize);s.push(l.OF.range(n.from+i,n.from+e))}}}return s}(t.state,i,o);return a.length?s?l.OF.create(a.concat(r.ranges)):l.OF.create(a):r}}:null):null})}let ic={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},iu={style:"cursor: crosshair"};function id(t={}){let[e,n]=ic[t.key||"Alt"],i=t4.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||n(t))},keyup(t){t.keyCode!=e&&n(t)||this.set(!1)},mousemove(t){this.set(n(t))}}});return[i,nA.contentAttributes.of(t=>{var e;return(null==(e=t.plugin(i))?void 0:e.isDown)?iu:null})]}let ip="-10000px";class im{constructor(t,e,n,i){this.facet=e,this.createTooltipView=n,this.removeTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let r=null;this.tooltipViews=this.tooltips.map(t=>r=n(t,r))}update(t,e){var n;let i=t.state.facet(this.facet),r=i.filter(t=>t);if(i===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[],o=e?[]:null;for(let n=0;n<r.length;n++){let i=r[n],l=-1;if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(l=t)}if(l<0)s[n]=this.createTooltipView(i,n?s[n-1]:null),o&&(o[n]=!!i.above);else{let i=s[n]=this.tooltipViews[l];o&&(o[n]=e[l]),i.update&&i.update(t)}}}for(let t of this.tooltipViews)0>s.indexOf(t)&&(this.removeTooltipView(t),null==(n=t.destroy)||n.call(t));return e&&(o.forEach((t,n)=>e[n]=t),e.length=o.length),this.input=i,this.tooltips=r,this.tooltipViews=s,!0}}function ig(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}let iv=l.sj.define({combine:t=>{var e,n,i;return{position:Q.ios?"absolute":(null==(e=t.find(t=>t.position))?void 0:e.position)||"fixed",parent:(null==(n=t.find(t=>t.parent))?void 0:n.parent)||null,tooltipSpace:(null==(i=t.find(t=>t.tooltipSpace))?void 0:i.tooltipSpace)||ig}}}),ib=new WeakMap,iy=t4.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(iv);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new im(t,iS,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let t of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(t.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,i=t.state.facet(iv);if(i.position!=this.position&&!this.madeAbsolute){for(let t of(this.position=i.position,this.manager.tooltipViews))t.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(t.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),i=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",n.dom.appendChild(t)}return n.dom.style.position=this.position,n.dom.style.top=ip,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;for(let e of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))e.dom.remove(),null==(t=e.destroy)||t.call(e);this.parent&&this.container.remove(),null==(e=this.resizeObserver)||e.disconnect(),null==(n=this.intersectionObserver)||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(Q.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==ip&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(t=n.width/this.parent.offsetWidth,e=n.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=ei(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let n=this.manager.tooltipViews[e];return n.getCoords?n.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(iv).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute)for(let t of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))t.dom.style.position="absolute";let{visible:n,space:i,scaleX:r,scaleY:s}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,u=t.pos[l],f=t.size[l];if(!u||!1!==a.clip&&(u.bottom<=Math.max(n.top,i.top)||u.top>=Math.min(n.bottom,i.bottom)||u.right<Math.max(n.left,i.left)-.1||u.left>Math.min(n.right,i.right)+.1)){c.style.top=ip;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!d,m=f.right-f.left,g=null!=(e=ib.get(h))?e:f.bottom-f.top,v=h.offset||ik,b=this.view.textDirection==tC.LTR,y=f.width>i.right-i.left?b?i.left:i.right-f.width:b?Math.max(i.left,Math.min(u.left-14*!!d+v.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+14*!!d-v.x),i.right-m),w=this.above[l];!a.strictSide&&(w?u.top-g-p-v.y<i.top:u.bottom+g+p+v.y>i.bottom)&&w==i.bottom-u.bottom>u.top-i.top&&(w=this.above[l]=!w);let x=(w?u.top-i.top:i.bottom-u.bottom)-p;if(x<g&&!1!==h.resize){if(x<this.view.defaultLineHeight){c.style.top=ip;continue}ib.set(h,g),c.style.height=(g=x)/s+"px"}else c.style.height&&(c.style.height="");let k=w?u.top-g-p-v.y:u.bottom+p+v.y,S=y+m;if(!0!==h.overlap)for(let t of o)t.left<S&&t.right>y&&t.top<k+g&&t.bottom>k&&(k=w?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/s+"px",iw(c,(y-t.parent.left)/r)):(c.style.top=k/s+"px",iw(c,y/r)),d){let t=u.left+(b?v.x:-v.x)-(y+14-7);d.style.left=t/r+"px"}!0!==h.overlap&&o.push({left:y,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",w),c.classList.toggle("cm-tooltip-below",!w),h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView)&&(this.inView=this.view.inView,!this.inView))for(let t of this.manager.tooltipViews)t.dom.style.top=ip}},{eventObservers:{scroll(){this.maybeMeasure()}}});function iw(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}let ix=nA.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),ik={x:0,y:0},iS=l.sj.define({enables:[iy,ix]}),iC=l.sj.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class iA{static create(t){return new iA(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new im(t,iC,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let n=t.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null==(t=e.destroy)||t.call(e)}passProp(t){let e;for(let n of this.manager.tooltipViews){let i=n[t];if(void 0!==i){if(void 0===e)e=i;else if(e!==i)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}let iO=iS.compute([iC],t=>{let e=t.facet(iC);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var e;return null!=(e=t.end)?e:t.pos})),create:iA.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class iM{constructor(t,e,n,i,r){this.view=t,this.source=e,this.field=n,this.setHover=i,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,n=t.docView.nearest(e.target);if(!n)return;let i,r=1;if(n instanceof tn)i=n.posAtStart;else{if(null==(i=t.posAtCoords(e)))return;let n=t.coordsAtPos(i);if(!n||e.y<n.top||e.y>n.bottom||e.x<n.left-t.defaultCharacterWidth||e.x>n.right+t.defaultCharacterWidth)return;let s=t.bidiSpans(t.state.doc.lineAt(i)).find(t=>t.from<=i&&t.to>=i),o=s&&s.dir==tC.RTL?-1:1;r=e.x<n.left?-o:o}let s=this.source(t,i,r);if(null==s?void 0:s.then){let e=this.pending={pos:i};s.then(n=>{this.pending==e&&(this.pending=null,n&&!(Array.isArray(n)&&!n.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},e=>tQ(t.state,e,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let t=this.view.plugin(iy),e=t?t.manager.tooltips.findIndex(t=>t.create==iA.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,n;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i.length&&r&&!function(t,e){let{left:n,right:i,top:r,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let t=o.getBoundingClientRect();r=Math.min(t.top,r),s=Math.max(t.bottom,s)}return e.clientX>=n-4&&e.clientX<=i+4&&e.clientY>=r-4&&e.clientY<=s+4}(r.dom,t)||this.pending){let{pos:r}=i[0]||this.pending,s=null!=(n=null==(e=i[0])?void 0:e.end)?n:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!function(t,e,n,i,r){let s=t.scrollDOM.getBoundingClientRect(),o=t.documentTop+t.documentPadding.top+t.contentHeight;if(s.left>i||s.right<i||s.top>r||Math.min(s.bottom,o)<r)return!1;let l=t.posAtCoords({x:i,y:r},!1);return l>=e&&l<=n}(this.view,r,s,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=n=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function iD(t,e={}){let n=l.Pe.define(),i=l.sU.define({create:()=>[],update(t,i){if(t.length&&(e.hideOnChange&&(i.docChanged||i.selection)?t=[]:e.hideOn&&(t=t.filter(t=>!e.hideOn(i,t))),i.docChanged)){let e=[];for(let n of t){let t=i.changes.mapPos(n.pos,-1,l.iR.TrackDel);if(null!=t){let r=Object.assign(Object.create(null),n);r.pos=t,null!=r.end&&(r.end=i.changes.mapPos(r.end)),e.push(r)}}t=e}for(let e of i.effects)e.is(n)&&(t=e.value),e.is(iT)&&(t=[]);return t},provide:t=>iC.from(t)});return{active:i,extension:[i,t4.define(r=>new iM(r,t,i,n,e.hoverTime||300)),iO]}}function iP(t,e){let n=t.plugin(iy);if(!n)return null;let i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}let iT=l.Pe.define(),iE=l.sj.define({combine(t){let e,n;for(let i of t)e=e||i.topContainer,n=n||i.bottomContainer;return{topContainer:e,bottomContainer:n}}});function iR(t,e){let n=t.plugin(iB),i=n?n.specs.indexOf(e):-1;return i>-1?n.panels[i]:null}let iB=t4.fromClass(class{constructor(t){this.input=t.state.facet(iI),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(iE);for(let n of(this.top=new iL(t,!0,e.topContainer),this.bottom=new iL(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top)),this.panels))n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(iE);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new iL(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new iL(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(iI);if(n!=this.input){let e=n.filter(t=>t),i=[],r=[],s=[],o=[];for(let n of e){let e=this.specs.indexOf(n),l;e<0?(l=n(t.view),o.push(l)):(l=this.panels[e]).update&&l.update(t),i.push(l),(l.top?r:s).push(l)}for(let t of(this.specs=e,this.panels=i,this.top.sync(r),this.bottom.sync(s),o))t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>nA.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class iL{constructor(t,e,n){this.view=t,this.top=e,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&0>t.indexOf(e)&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=iN(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=iN(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function iN(t){let e=t.nextSibling;return t.remove(),e}let iI=l.sj.define({enables:iB});class iF extends l.FB{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}iF.prototype.elementClass="",iF.prototype.toDOM=void 0,iF.prototype.mapMode=l.iR.TrackBefore,iF.prototype.startSide=iF.prototype.endSide=-1,iF.prototype.point=!0;let ij=l.sj.define(),i_=l.sj.define(),iz={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>l.om.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},iV=l.sj.define();function iH(t){return[iq(),iV.of({...iz,...t})]}let iW=l.sj.define({combine:t=>t.some(t=>t)});function iq(t){let e=[iU];return t&&!1===t.fixed&&e.push(iW.of(!0)),e}let iU=t4.fromClass(class{constructor(t){for(let e of(this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(iV).map(e=>new iY(t,e)),this.fixed=!t.state.facet(iW),this.gutters))"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(iW)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=l.om.iter(this.view.state.facet(ij),this.view.viewport.from),i=[],r=this.gutters.map(t=>new iJ(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(t.type)){let e=!0;for(let s of t.type)if(s.type==tu.Text&&e){for(let t of(iK(n,i,s.from),r))t.line(this.view,s,i);e=!1}else if(s.widget)for(let t of r)t.widget(this.view,s)}else if(t.type==tu.Text)for(let e of(iK(n,i,t.from),r))e.line(this.view,t,i);else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(iV),n=t.state.facet(iV),i=t.docChanged||t.heightChanged||t.viewportChanged||!l.om.eq(t.startState.facet(ij),t.state.facet(ij),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let e of this.gutters)e.update(t)&&(i=!0);else{i=!0;let r=[];for(let i of n){let n=e.indexOf(i);n<0?r.push(new iY(this.view,i)):(this.gutters[n].update(t),r.push(this.gutters[n]))}for(let t of this.gutters)t.dom.remove(),0>r.indexOf(t)&&t.destroy();for(let t of r)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=r}return i}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>nA.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==tC.LTR?{left:i,right:r}:{right:i,left:r}})});function i$(t){return Array.isArray(t)?t:[t]}function iK(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class iJ{constructor(t,e,n){this.gutter=t,this.height=n,this.i=0,this.cursor=l.om.iter(t.markers,e.from)}addElement(t,e,n){let{gutter:i}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==i.elements.length){let e=new iG(t,s,r,n);i.elements.push(e),i.dom.appendChild(e.dom)}else i.elements[this.i].update(t,s,r,n);this.height=e.bottom,this.i++}line(t,e,n){let i=[];iK(this.cursor,i,e.from),n.length&&(i=i.concat(n));let r=this.gutter.config.lineMarker(t,e,i);r&&i.unshift(r);let s=this.gutter;(0!=i.length||s.config.renderEmptyElements)&&this.addElement(t,e,i)}widget(t,e){let n=this.gutter.config.widgetMarker(t,e.widget,e),i=n?[n]:null;for(let n of t.state.facet(i_)){let r=n(t,e.widget,e);r&&(i||(i=[])).push(r)}i&&this.addElement(t,e,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class iY{constructor(t,e){for(let n in this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(n,i=>{let r=i.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=i.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[n](t,o,i)&&i.preventDefault()});this.markers=i$(e.markers(t)),e.initialSpacer&&(this.spacer=new iG(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=i$(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let n=t.view.viewport;return!l.om.eq(this.markers,e,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class iG{constructor(t,e,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,n,i)}update(t,e,n,i){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),!function(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}(this.markers,i)&&this.setMarkers(t,i)}setMarkers(t,e){let n="cm-gutterElement",i=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<e.length?e[r++]:null,a=!1;if(l){let t=l.elementClass;t&&(n+=" "+t);for(let t=s;t<this.markers.length;t++)if(this.markers[t].compare(l)){o=t,a=!0;break}}else o=this.markers.length;for(;s<o;){let t=this.markers[s++];if(t.toDOM){t.destroy(i);let e=i.nextSibling;i.remove(),i=e}}if(!l)break;l.toDOM&&(a?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),a&&s++}this.dom.className=n,this.markers=e}destroy(){this.setMarkers(null,[])}}let iZ=l.sj.define(),iX=l.sj.define(),iQ=l.sj.define({combine:t=>(0,l.QR)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let n=Object.assign({},t);for(let t in e){let i=n[t],r=e[t];n[t]=i?(t,e,n)=>i(t,e,n)||r(t,e,n):r}return n}})});class i0 extends iF{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function i1(t,e){return t.state.facet(iQ).formatNumber(e,t.state)}let i2=iV.compute([iQ],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(iZ),lineMarker:(t,e,n)=>n.some(t=>t.toDOM)?null:new i0(i1(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,n)=>{for(let i of t.state.facet(iX)){let r=i(t,e,n);if(r)return r}return null},lineMarkerChange:t=>t.startState.facet(iQ)!=t.state.facet(iQ),initialSpacer:t=>new i0(i1(t,i3(t.state.doc.lines))),updateSpacer(t,e){let n=i1(e.view,i3(e.view.state.doc.lines));return n==t.number?t:new i0(n)},domEventHandlers:t.facet(iQ).domEventHandlers,side:"before"}));function i4(t={}){return[iQ.of(t),iq(),i2]}function i3(t){let e=9;for(;e<t;)e=10*e+9;return e}let i8=new class extends iF{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},i5=ij.compute(["selection"],t=>{let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.head).from;r>n&&(n=r,e.push(i8.range(r)))}return l.om.of(e)});function i9(){return i5}},80:function(t,e,n){"use strict";var i,r;n.d(e,{PH:function(){return p},Qj:function(){return i},RY:function(){return R},Z6:function(){return c},fI:function(){return u},iX:function(){return L},rr:function(){return B},uY:function(){return l}});let s=0;class o{constructor(t,e){this.from=t,this.to=e}}class l{constructor(t={}){this.id=s++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=c.match(t)),e=>{let n=t(e);return void 0===n?null:[this,n]}}}l.closedBy=new l({deserialize:t=>t.split(" ")}),l.openedBy=new l({deserialize:t=>t.split(" ")}),l.group=new l({deserialize:t=>t.split(" ")}),l.isolate=new l({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw RangeError("Invalid value for isolate: "+t);return t||"auto"}}),l.contextHash=new l({perNode:!0}),l.lookAhead=new l({perNode:!0}),l.mounted=new l({perNode:!0});class a{constructor(t,e,n){this.tree=t,this.overlay=e,this.parser=n}static get(t){return t&&t.props&&t.props[l.mounted.id]}}let h=Object.create(null);class c{constructor(t,e,n,i=0){this.name=t,this.props=e,this.id=n,this.flags=i}static define(t){let e=t.props&&t.props.length?Object.create(null):h,n=!!t.top|2*!!t.skipped|4*!!t.error|8*(null==t.name),i=new c(t.name||"",e,t.id,n);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(l.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let n in t)for(let i of n.split(" "))e[i]=t[n];return t=>{for(let n=t.prop(l.group),i=-1;i<(n?n.length:0);i++){let r=e[i<0?t.name:n[i]];if(r)return r}}}}c.none=new c("",Object.create(null),0,8);class u{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let n of this.types){let i=null;for(let e of t){let t=e(n);t&&(i||(i=Object.assign({},n.props)),i[t[0].id]=t[1])}e.push(i?new c(n.name,i,n.id,n.flags):n)}return new u(e)}}let f=new WeakMap,d=new WeakMap;(r=i||(i={}))[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays";class p{constructor(t,e,n,i,r){if(this.type=t,this.children=e,this.positions=n,this.length=i,this.props=null,r&&r.length)for(let[t,e]of(this.props=Object.create(null),r))this.props["number"==typeof t?t:t.id]=e}toString(){let t=a.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let n=t.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new M(this.topNode,t)}cursorAt(t,e=0,n=0){let i=new M(f.get(this)||this.topNode);return i.moveTo(t,e),f.set(this,i._tree),i}get topNode(){return new w(this,0,0,null)}resolve(t,e=0){let n=b(f.get(this)||this.topNode,t,e,!1);return f.set(this,n),n}resolveInner(t,e=0){let n=b(d.get(this)||this.topNode,t,e,!0);return d.set(this,n),n}resolveStack(t,e=0){return function(t,e,n){let i=t.resolveInner(e,n),r=null;for(let t=i instanceof w?i:i.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(r||(r=[i])).push(s.resolve(e,n)),t=s}else{let s=a.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new w(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[i])).push(b(o,e,n,!1))}}return r?A(r):i}(this,t,e)}iterate(t){let{enter:e,leave:n,from:r=0,to:s=this.length}=t,o=t.mode||0,l=(o&i.IncludeAnonymous)>0;for(let t=this.cursor(o|i.IncludeAnonymous);;){let i=!1;if(t.from<=s&&t.to>=r&&(!l&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;i=!0}for(;i&&n&&(l||!t.type.isAnonymous)&&n(t),!t.nextSibling();){if(!t.parent())return;i=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:E(c.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,n)=>new p(this.type,t,e,n,this.propValues),t.makeTree||((t,e,n)=>new p(c.none,t,e,n)))}static build(t){return function(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=t,a=Array.isArray(n)?new m(n,n.length):n,h=i.types,c=0,u=0;function f(t,e,n,r,s,o,l,a,h){let c=[],u=[];for(;t.length>r;)c.push(t.pop()),u.push(e.pop()+n-s);t.push(d(i.types[l],c,u,o-s,a-o,h)),e.push(s-n)}function d(t,e,n,i,r,s,o){if(s){let t=[l.contextHash,s];o=o?[t].concat(o):[t]}if(r>25){let t=[l.lookAhead,r];o=o?[t].concat(o):[t]}return new p(t,e,n,i,o)}let v=[],b=[];for(;a.pos>0;)!function t(e,n,m,v,b,y){let{id:w,start:x,end:k,size:S}=a,C=u,A=c;for(;S<0;){if(a.next(),-1==S){let t=s[w];m.push(t),v.push(x-e);return}if(-3==S){c=w;return}if(-4==S){u=w;return}else throw RangeError(`Unrecognized record size: ${S}`)}let O=h[w],M,D,P=x-e;if(k-x<=r&&(D=function(t,e){let n=a.fork(),i=0,s=0,l=0,h=n.end-r,c={size:0,start:0,skip:0};i:for(let r=n.pos-t;n.pos>r;){let t=n.size;if(n.id==e&&t>=0){c.size=i,c.start=s,c.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-t;if(t<0||a<r||n.start<h)break;let u=4*(n.id>=o),f=n.start;for(n.next();n.pos>a;){if(n.size<0)if(-3==n.size)u+=4;else break i;else n.id>=o&&(u+=4);n.next()}s=f,i+=t,l+=u}return(e<0||i==t)&&(c.size=i,c.start=s,c.skip=l),c.size>4?c:void 0}(a.pos-n,b))){let t=new Uint16Array(D.size-D.skip),n=a.pos-D.size,r=t.length;for(;a.pos>n;)r=function t(e,n,i){let{id:r,start:s,end:l,size:h}=a;if(a.next(),h>=0&&r<o){let o=i;if(h>4){let r=a.pos-(h-4);for(;a.pos>r;)i=t(e,n,i)}n[--i]=o,n[--i]=l-e,n[--i]=s-e,n[--i]=r}else -3==h?c=r:-4==h&&(u=r);return i}(D.start,t,r);M=new g(t,k-D.start,i),P=D.start-e}else{let e=a.pos-S;a.next();let n=[],s=[],h=w>=o?w:-1,c=0,u=k;for(;a.pos>e;)h>=0&&a.id==h&&a.size>=0?(a.end<=u-r&&(f(n,s,x,c,a.end,u,h,C,A),c=n.length,u=a.end),a.next()):y>2500?function(t,e,n,s){let o=[],l=0,h=-1;for(;a.pos>e;){let{id:t,start:e,end:n,size:i}=a;if(i>4)a.next();else if(h>-1&&e<h)break;else h<0&&(h=n-r),o.push(t,e,n),l++,a.next()}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,n=0;t>=0;t-=3)e[n++]=o[t],e[n++]=o[t+1]-r,e[n++]=o[t+2]-r,e[n++]=n;n.push(new g(e,o[2]-r,i)),s.push(r-t)}}(x,e,n,s):t(x,e,n,s,h,y+1);if(h>=0&&c>0&&c<n.length&&f(n,s,x,c,x,u,h,C,A),n.reverse(),s.reverse(),h>-1&&c>0){let t=function(t,e){return(n,i,r)=>{let s=0,o=n.length-1,a,h;if(o>=0&&(a=n[o])instanceof p){if(!o&&a.type==t&&a.length==r)return a;(h=a.prop(l.lookAhead))&&(s=i[o]+a.length+h)}return d(t,n,i,r,s,e)}}(O,A);M=E(O,n,s,0,n.length,0,k-x,t,t)}else M=d(O,n,s,k-x,C-k,A)}m.push(M),v.push(P)}(t.start||0,t.bufferStart||0,v,b,-1,0);let y=null!=(e=t.length)?e:v.length?b[0]+v[0].length:0;return new p(h[t.topID],v.reverse(),b.reverse(),y)}(t)}}p.empty=new p(c.none,[],[],0);class m{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new m(this.buffer,this.index)}}class g{constructor(t,e,n){this.buffer=t,this.length=e,this.set=n}get type(){return c.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],n=this.buffer[t+3],i=this.set.types[e],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(t+=4))return r;let s=[];for(;t<n;)s.push(this.childString(t)),t=this.buffer[t+3];return r+"("+s.join(",")+")"}findChild(t,e,n,i,r){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&(!v(r,i,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(t,e,n){let i=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){r[l++]=i[o++],r[l++]=i[o++]-n;let e=r[l++]=i[o++]-n;r[l++]=i[o++]-t,s=Math.max(s,e)}return new g(r,s,this.set)}}function v(t,e,n,i){switch(t){case -2:return n<e;case -1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function b(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let e=!r&&t instanceof w&&t.index<0?null:t.parent;if(!e)return t;t=e}let o=r?0:i.IgnoreOverlays;if(r)for(let i=t,r=i.parent;r;r=(i=r).parent)i instanceof w&&i.index<0&&(null==(s=r.enter(e,n,o))?void 0:s.from)!=i.from&&(t=r);for(;;){let i=t.enter(e,n,o);if(!i)return t;t=i}}class y{cursor(t=0){return new M(this,t)}getChild(t,e=null,n=null){let i=x(this,t,e,n);return i.length?i[0]:null}getChildren(t,e=null,n=null){return x(this,t,e,n)}resolve(t,e=0){return b(this,t,e,!1)}resolveInner(t,e=0){return b(this,t,e,!0)}matchContext(t){return k(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),n=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(n=e,e=t.prevSibling):e=t}return n}get node(){return this}get next(){return this.parent}}class w extends y{constructor(t,e,n,i){super(),this._tree=t,this.from=e,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,n,r,s=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,c=e>0?l.length:-1;t!=c;t+=e){let c=l[t],u=h[t]+o.from;if(v(r,n,u,u+c.length)){if(c instanceof g){if(s&i.ExcludeBuffers)continue;let l=c.findChild(0,c.buffer.length,e,n-u,r);if(l>-1)return new C(new S(o,c,t,u),null,l)}else if(s&i.IncludeAnonymous||!c.type.isAnonymous||D(c)){let l;if(!(s&i.IgnoreMounts)&&(l=a.get(c))&&!l.overlay)return new w(l.tree,u,t,o);let h=new w(c,u,t,o);return s&i.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?c.children.length-1:0,e,n,r)}}}if(s&i.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,!(o=o._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,n=0){let r;if(!(n&i.IgnoreOverlays)&&(r=a.get(this._tree))&&r.overlay){let n=t-this.from;for(let{from:t,to:i}of r.overlay)if((e>0?t<=n:t<n)&&(e<0?i>=n:i>n))return new w(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function x(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=n){for(let t=!1;!t;)if(t=r.type.is(n),!r.nextSibling())return s}for(;;){if(null!=i&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==i?s:[]}}function k(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class S{constructor(t,e,n,i){this.parent=t,this.buffer=e,this.index=n,this.start=i}}class C extends y{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,n){super(),this.context=t,this._parent=e,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,e,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.context.start,n);return r<0?null:new C(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,n=0){if(n&i.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new C(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new C(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new C(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let s=n.buffer[this.index+1];t.push(n.slice(i,r,s)),e.push(0)}return new p(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let r=t[i];(r.from>n.from||r.to<n.to)&&(n=r,e=i)}let i=n instanceof w&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new O(r,n)}class O{constructor(t,e){this.heads=t,this.node=e}get next(){return A(this.heads)}}class M{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof w)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:n,buffer:i}=this.buffer;return this.type=e||i.set.types[i.buffer[t]],this.from=n+i.buffer[t+1],this.to=n+i.buffer[t+2],!0}yield(t){return!!t&&(t instanceof w?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,n=this.mode){return this.buffer?!(n&i.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&i.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&i.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,n=this.stack.length-1;if(t<0){let t=n<0?0:this.stack[n]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(t)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,n,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(r.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:n}=r)}else({index:e,_parent:n}=this._tree);for(;n;{index:e,_parent:n}=n)if(e>-1)for(let r=e+t,s=t<0?-1:n._tree.children.length;r!=s;r+=t){let t=n._tree.children[r];if(this.mode&i.IncludeAnonymous||t instanceof g||!t.type.isAnonymous||D(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)i:for(let i=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==i){if(i==this.index)return s;e=s,n=r+1;break i}i=this.stack[--r]}for(let t=n;t<this.stack.length;t++)e=new C(this.buffer,e,this.stack[t]);return this.bufferNode=new C(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&e&&e(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(t){if(!this.buffer)return k(this.node.parent,t);let{buffer:e}=this.buffer,{types:n}=e.set;for(let i=t.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return k(this._tree,t,i);let s=n[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}}function D(t){return t.children.some(t=>t instanceof g||!t.type.isAnonymous||D(t))}let P=new WeakMap;function T(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let n=P.get(e);if(null==n){for(let i of(n=1,e.children)){if(i.type!=t||!(i instanceof p)){n=1;break}n+=T(t,i)}P.set(e,n)}return n}function E(t,e,n,i,r,s,o,l,a){let h=0;for(let n=i;n<r;n++)h+=T(t,e[n]);let c=Math.ceil(1.5*h/8),u=[],f=[];return!function e(n,i,r,o,l){for(let h=r;h<o;){let r=h,d=i[h],p=T(t,n[h]);for(h++;h<o;h++){let e=T(t,n[h]);if(p+e>=c)break;p+=e}if(h==r+1){if(p>c){let t=n[r];e(t.children,t.positions,0,t.children.length,i[r]+l);continue}u.push(n[r])}else{let e=i[h-1]+n[h-1].length-d;u.push(E(t,n,i,r,h,d,e,null,a))}f.push(d+l-s)}}(e,n,i,r,0),(l||a)(u,f,o)}class R{constructor(){this.map=new WeakMap}setBuffer(t,e,n){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(e,n)}getBuffer(t,e){let n=this.map.get(t);return n&&n.get(e)}set(t,e){t instanceof C?this.setBuffer(t.context.buffer,t.index,e):t instanceof w&&this.map.set(t.tree,e)}get(t){return t instanceof C?this.getBuffer(t.context.buffer,t.index):t instanceof w?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class B{constructor(t,e,n,i,r=!1,s=!1){this.from=t,this.to=e,this.tree=n,this.offset=i,this.open=!!r|2*!!s}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],n=!1){let i=[new B(0,t.length,t,0,!1,n)];for(let n of e)n.to>t.length&&i.push(n);return i}static applyChanges(t,e,n=128){if(!e.length)return t;let i=[],r=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let e=s;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,n=Math.min(e.to,c)-a;e=t>=n?null:new B(t,n,e.tree,e.offset+a,o>0,!!h)}if(e&&i.push(e),s.to>c)break;s=r<t.length?t[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return i}}class L{startParse(t,e,n){return"string"==typeof t&&(t=new N(t)),n=n?n.length?n.map(t=>new o(t.from,t.to)):[new o(0,0)]:[new o(0,t.length)],this.createParse(t,e||[],n)}parse(t,e,n){let i=this.startParse(t,e,n);for(;;){let t=i.advance();if(t)return t}}}class N{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new l({perNode:!0})},619:function(t,e,n){"use strict";n.d(e,{DM:function(){return f},_A:function(){return P},az:function(){return u},pn:function(){return a}});var i=n(80);let r=0;class s{constructor(t,e,n,i){this.name=t,this.set=e,this.base=n,this.modified=i,this.id=r++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){if(t instanceof s&&(e=t),null==e?void 0:e.base)throw Error("Can not derive from a modified tag");let n=new s("string"==typeof t?t:"?",[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new l(t);return t=>t.modified.indexOf(e)>-1?t:l.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let o=0;class l{constructor(t){this.name=t,this.instances=[],this.id=o++}static get(t,e){if(!e.length)return t;let n=e[0].instances.find(n=>{var i,r;return n.base==t&&(i=e,r=n.modified,i.length==r.length&&i.every((t,e)=>t==r[e]))});if(n)return n;let i=[],r=new s(t.name,i,t,e);for(let t of e)t.instances.push(r);let o=function(t){let e=[[]];for(let n=0;n<t.length;n++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[n]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)i.push(l.get(e,t));return r}}function a(t){let e=Object.create(null);for(let n in t){let i=t[n];for(let t of(Array.isArray(i)||(i=[i]),n.split(" ")))if(t){let n=[],r=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!i)throw RangeError("Invalid path: "+t);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),(e+=i[0].length)==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+t);s=t.slice(e)}let o=n.length-1,l=n[o];if(!l)throw RangeError("Invalid path: "+t);let a=new c(i,r,o>0?n.slice(0,o):null);e[l]=a.sort(e[l])}}return h.add(e)}let h=new i.uY;class c{constructor(t,e,n,i){this.tags=t,this.mode=e,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function u(t,e){let n=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)n[t.id]=e.class;else n[e.tag.id]=e.class;let{scope:i,all:r=null}=e||{};return{style:t=>{let e=r;for(let i of t)for(let t of i.set){let i=n[t.id];if(i){e=e?e+" "+i:i;break}}return e},scope:i}}function f(t,e,n,i=0,r=t.length){let s=new d(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}c.empty=new c([],2,null);class d{constructor(t,e,n){this.at=t,this.highlighters=e,this.span=n,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,n,r,s){let{type:o,from:l,to:a}=t;if(l>=n||a<=e)return;o.isTop&&(s=this.highlighters.filter(t=>!t.scope||t.scope(o)));let u=r,f=function(t){let e=t.type.prop(h);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||c.empty,d=function(t,e){let n=null;for(let i of t){let t=i.style(e);t&&(n=n?n+" "+t:t)}return n}(s,f.tags);if(d&&(u&&(u+=" "),u+=d,1==f.mode&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(e,l),u),f.opaque)return;let p=t.tree&&t.tree.prop(i.uY.mounted);if(p&&p.overlay){let i=t.node.enter(p.overlay[0].from+l,1),o=this.highlighters.filter(t=>!t.scope||t.scope(p.tree.type)),h=t.firstChild();for(let c=0,f=l;;c++){let d=c<p.overlay.length?p.overlay[c]:null,m=d?d.from+l:a,g=Math.max(e,f),v=Math.min(n,m);if(g<v&&h)for(;t.from<v&&(this.highlightRange(t,g,v,r,s),this.startSpan(Math.min(v,t.to),u),!(t.to>=m)&&t.nextSibling()););if(!d||m>n)break;(f=d.to+l)>e&&(this.highlightRange(i.cursor(),Math.max(e,d.from+l),Math.min(n,f),"",o),this.startSpan(Math.min(n,f),u))}h&&t.parent()}else if(t.firstChild()){p&&(r="");do{if(t.to<=e)continue;if(t.from>=n)break;this.highlightRange(t,e,n,r,s),this.startSpan(Math.min(n,t.to),u)}while(t.nextSibling());t.parent()}}}let p=s.define,m=p(),g=p(),v=p(g),b=p(g),y=p(),w=p(y),x=p(y),k=p(),S=p(k),C=p(),A=p(),O=p(),M=p(O),D=p(),P={comment:m,lineComment:p(m),blockComment:p(m),docComment:p(m),name:g,variableName:p(g),typeName:v,tagName:p(v),propertyName:b,attributeName:p(b),className:p(g),labelName:p(g),namespace:p(g),macroName:p(g),literal:y,string:w,docString:p(w),character:p(w),attributeValue:p(w),number:x,integer:p(x),float:p(x),bool:p(y),regexp:p(y),escape:p(y),color:p(y),url:p(y),keyword:C,self:p(C),null:p(C),atom:p(C),unit:p(C),modifier:p(C),operatorKeyword:p(C),controlKeyword:p(C),definitionKeyword:p(C),moduleKeyword:p(C),operator:A,derefOperator:p(A),arithmeticOperator:p(A),logicOperator:p(A),bitwiseOperator:p(A),compareOperator:p(A),updateOperator:p(A),definitionOperator:p(A),typeOperator:p(A),controlOperator:p(A),punctuation:O,separator:p(O),bracket:M,angleBracket:p(M),squareBracket:p(M),paren:p(M),brace:p(M),content:k,heading:S,heading1:p(S),heading2:p(S),heading3:p(S),heading4:p(S),heading5:p(S),heading6:p(S),contentSeparator:p(k),list:p(k),quote:p(k),emphasis:p(k),strong:p(k),link:p(k),monospace:p(k),strikethrough:p(k),inserted:p(),deleted:p(),changed:p(),invalid:p(),meta:D,documentMeta:p(D),annotation:p(D),processingInstruction:p(D),definition:s.defineModifier("definition"),constant:s.defineModifier("constant"),function:s.defineModifier("function"),standard:s.defineModifier("standard"),local:s.defineModifier("local"),special:s.defineModifier("special")};for(let t in P){let e=P[t];e instanceof s&&(e.name=t)}u([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}])},690:function(t,e,n){"use strict";n.d(e,{G:function(){return o}});let i="u"<typeof Symbol?"__ͼ":Symbol.for("ͼ"),r="u"<typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),s="u">typeof globalThis?globalThis:"u">typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:n}=e||{};function i(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(let e in t)!function t(e,r,s,o){let l=[],a=/^@(\w+)\b/.exec(e[0]),h=a&&"keyframes"==a[1];if(a&&null==r)return s.push(e[0]+";");for(let n in r){let o=r[n];if(/&/.test(n))t(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((t,e)=>t.concat(e)),o,s);else if(o&&"object"==typeof o){if(!a)throw RangeError("The value of a property ("+n+") should be a primitive value.");t(i(n),o,l,h)}else null!=o&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+o+";")}(l.length||h)&&s.push((n&&!a&&!o?e.map(n):e).join(", ")+" {"+l.join(" ")+"}")}(i(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=s[i]||1;return s[i]=t+1,"ͼ"+t.toString(36)}static mount(t,e,n){let i=t[r],s=n&&n.nonce;i?s&&i.setNonce(s):i=new a(t,s),i.mount(Array.isArray(e)?e:[e],t)}}let l=new Map;class a{constructor(t,e){let n=t.ownerDocument||t,i=n.defaultView;if(!t.head&&t.adoptedStyleSheets&&i.CSSStyleSheet){let e=l.get(n);if(e)return t[r]=e;this.sheet=new i.CSSStyleSheet,l.set(n,this)}else this.styleTag=n.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[r]=this}mount(t,e){let n=this.sheet,i=0,r=0;for(let e=0;e<t.length;e++){let s=t[e],o=this.modules.indexOf(s);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),n)for(let t=0;t<s.rules.length;t++)n.insertRule(s.rules[t],i++)}else{for(;r<o;)i+=this.modules[r++].rules.length;i+=s.rules.length,r++}}if(n)0>e.adoptedStyleSheets.indexOf(this.sheet)&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let n=e.head||e;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}},581:function(t,e,n){"use strict";n.r(e),n.d(e,{getIndentUnit:function(){return tc},continuedIndent:function(){return tk},LanguageDescription:function(){return tl},foldState:function(){return tR},languageDataProp:function(){return z},matchBrackets:function(){return eh},sublanguageProp:function(){return H},ParseContext:function(){return Q},TreeIndentContext:function(){return tb},bracketMatchingHandle:function(){return eo},foldAll:function(){return tz},foldService:function(){return tC},indentService:function(){return ta},foldCode:function(){return tF},syntaxParserRunning:function(){return G},indentUnit:function(){return th},ensureSyntaxTree:function(){return K},syntaxTree:function(){return $},syntaxTreeAvailable:function(){return J},toggleFold:function(){return tH},indentOnInput:function(){return tS},defineLanguageFacet:function(){return V},syntaxHighlighting:function(){return t3},unfoldCode:function(){return tj},unfoldAll:function(){return tV},HighlightStyle:function(){return t0},foldGutter:function(){return tX},foldedRanges:function(){return tL},getIndentation:function(){return tf},Language:function(){return W},bracketMatching:function(){return es},foldInside:function(){return tO},LRLanguage:function(){return U},flatIndent:function(){return tx},foldKeymap:function(){return tW},indentRange:function(){return td},unfoldEffect:function(){return tT},IndentContext:function(){return tp},codeFolding:function(){return t$},foldEffect:function(){return tP},foldNodeProp:function(){return tA},indentString:function(){return tu},language:function(){return ts},StreamLanguage:function(){return ep},DocInput:function(){return Z},LanguageSupport:function(){return to},bidiIsolates:function(){return eE},foldable:function(){return tM},StringStream:function(){return eu},defaultHighlightStyle:function(){return t9},forceParsing:function(){return Y},indentNodeProp:function(){return tm},delimitedIndent:function(){return ty},highlightingFor:function(){return t8}});let i=0;class r{constructor(t,e){this.from=t,this.to=e}}class s{constructor(t={}){this.id=i++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=a.match(t)),e=>{let n=t(e);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:t=>t.split(" ")}),s.openedBy=new s({deserialize:t=>t.split(" ")}),s.group=new s({deserialize:t=>t.split(" ")}),s.isolate=new s({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw RangeError("Invalid value for isolate: "+t);return t||"auto"}}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class o{constructor(t,e,n,i=!1){this.tree=t,this.overlay=e,this.parser=n,this.bracketed=i}static get(t){return t&&t.props&&t.props[s.mounted.id]}}let l=Object.create(null);class a{constructor(t,e,n,i=0){this.name=t,this.props=e,this.id=n,this.flags=i}static define(t){let e=t.props&&t.props.length?Object.create(null):l,n=!!t.top|2*!!t.skipped|4*!!t.error|8*(null==t.name),i=new a(t.name||"",e,t.id,n);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(s.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let n in t)for(let i of n.split(" "))e[i]=t[n];return t=>{for(let n=t.prop(s.group),i=-1;i<(n?n.length:0);i++){let r=e[i<0?t.name:n[i]];if(r)return r}}}}a.none=new a("",Object.create(null),0,8);class h{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let n of this.types){let i=null;for(let e of t){let t=e(n);if(t){i||(i=Object.assign({},n.props));let e=t[1],r=t[0];r.combine&&r.id in i&&(e=r.combine(i[r.id],e)),i[r.id]=e}}e.push(i?new a(n.name,i,n.id,n.flags):n)}return new h(e)}}let c=new WeakMap,u=new WeakMap;(B=L||(L={}))[B.ExcludeBuffers=1]="ExcludeBuffers",B[B.IncludeAnonymous=2]="IncludeAnonymous",B[B.IgnoreMounts=4]="IgnoreMounts",B[B.IgnoreOverlays=8]="IgnoreOverlays",B[B.EnterBracketed=16]="EnterBracketed";class f{constructor(t,e,n,i,r){if(this.type=t,this.children=e,this.positions=n,this.length=i,this.props=null,r&&r.length)for(let[t,e]of(this.props=Object.create(null),r))this.props["number"==typeof t?t:t.id]=e}toString(){let t=o.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let n=t.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new A(this.topNode,t)}cursorAt(t,e=0,n=0){let i=new A(c.get(this)||this.topNode);return i.moveTo(t,e),c.set(this,i._tree),i}get topNode(){return new b(this,0,0,null)}resolve(t,e=0){let n=g(c.get(this)||this.topNode,t,e,!1);return c.set(this,n),n}resolveInner(t,e=0){let n=g(u.get(this)||this.topNode,t,e,!0);return u.set(this,n),n}resolveStack(t,e=0){return function(t,e,n){let i=t.resolveInner(e,n),r=null;for(let t=i instanceof b?i:i.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(r||(r=[i])).push(s.resolve(e,n)),t=s}else{let s=o.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new b(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[i])).push(g(o,e,n,!1))}}return r?S(r):i}(this,t,e)}iterate(t){let{enter:e,leave:n,from:i=0,to:r=this.length}=t,s=t.mode||0,o=(s&L.IncludeAnonymous)>0;for(let t=this.cursor(s|L.IncludeAnonymous);;){let s=!1;if(t.from<=r&&t.to>=i&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&n&&(o||!t.type.isAnonymous)&&n(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:P(a.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,n)=>new f(this.type,t,e,n,this.propValues),t.makeTree||((t,e,n)=>new f(a.none,t,e,n)))}static build(t){return function(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=1024,reused:o=[],minRepeatType:l=i.types.length}=t,a=Array.isArray(n)?new d(n,n.length):n,h=i.types,c=0,u=0;function m(t,e,n,r,s,o,l,a,h){let c=[],u=[];for(;t.length>r;)c.push(t.pop()),u.push(e.pop()+n-s);t.push(g(i.types[l],c,u,o-s,a-o,h)),e.push(s-n)}function g(t,e,n,i,r,o,l){if(o){let t=[s.contextHash,o];l=l?[t].concat(l):[t]}if(r>25){let t=[s.lookAhead,r];l=l?[t].concat(l):[t]}return new f(t,e,n,i,l)}let v=[],b=[];for(;a.pos>0;)!function t(e,n,d,v,b,y){let{id:w,start:x,end:k,size:S}=a,C=u,A=c;if(S<0){if(a.next(),-1==S){let t=o[w];d.push(t),v.push(x-e);return}if(-3==S){c=w;return}if(-4==S){u=w;return}else throw RangeError(`Unrecognized record size: ${S}`)}let O=h[w],M,D,T=x-e;if(k-x<=r&&(D=function(t,e){let n=a.fork(),i=0,s=0,o=0,h=n.end-r,c={size:0,start:0,skip:0};i:for(let r=n.pos-t;n.pos>r;){let t=n.size;if(n.id==e&&t>=0){c.size=i,c.start=s,c.skip=o,o+=4,i+=4,n.next();continue}let a=n.pos-t;if(t<0||a<r||n.start<h)break;let u=4*(n.id>=l),f=n.start;for(n.next();n.pos>a;){if(n.size<0)if(-3==n.size||-4==n.size)u+=4;else break i;else n.id>=l&&(u+=4);n.next()}s=f,i+=t,o+=u}return(e<0||i==t)&&(c.size=i,c.start=s,c.skip=o),c.size>4?c:void 0}(a.pos-n,b))){let t=new Uint16Array(D.size-D.skip),n=a.pos-D.size,r=t.length;for(;a.pos>n;)r=function t(e,n,i){let{id:r,start:s,end:o,size:h}=a;if(a.next(),h>=0&&r<l){let l=i;if(h>4){let r=a.pos-(h-4);for(;a.pos>r;)i=t(e,n,i)}n[--i]=l,n[--i]=o-e,n[--i]=s-e,n[--i]=r}else -3==h?c=r:-4==h&&(u=r);return i}(D.start,t,r);M=new p(t,k-D.start,i),T=D.start-e}else{let e=a.pos-S;a.next();let n=[],o=[],h=w>=l?w:-1,c=0,u=k;for(;a.pos>e;)h>=0&&a.id==h&&a.size>=0?(a.end<=u-r&&(m(n,o,x,c,a.end,u,h,C,A),c=n.length,u=a.end),a.next()):y>2500?function(t,e,n,s){let o=[],l=0,h=-1;for(;a.pos>e;){let{id:t,start:e,end:n,size:i}=a;if(i>4)a.next();else if(h>-1&&e<h)break;else h<0&&(h=n-r),o.push(t,e,n),l++,a.next()}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,n=0;t>=0;t-=3)e[n++]=o[t],e[n++]=o[t+1]-r,e[n++]=o[t+2]-r,e[n++]=n;n.push(new p(e,o[2]-r,i)),s.push(r-t)}}(x,e,n,o):t(x,e,n,o,h,y+1);if(h>=0&&c>0&&c<n.length&&m(n,o,x,c,x,u,h,C,A),n.reverse(),o.reverse(),h>-1&&c>0){let t=function(t,e){return(n,i,r)=>{let o=0,l=n.length-1,a,h;if(l>=0&&(a=n[l])instanceof f){if(!l&&a.type==t&&a.length==r)return a;(h=a.prop(s.lookAhead))&&(o=i[l]+a.length+h)}return g(t,n,i,r,o,e)}}(O,A);M=P(O,n,o,0,n.length,0,k-x,t,t)}else M=g(O,n,o,k-x,C-k,A)}d.push(M),v.push(T)}(t.start||0,t.bufferStart||0,v,b,-1,0);let y=null!=(e=t.length)?e:v.length?b[0]+v[0].length:0;return new f(h[t.topID],v.reverse(),b.reverse(),y)}(t)}}f.empty=new f(a.none,[],[],0);class d{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new d(this.buffer,this.index)}}class p{constructor(t,e,n){this.buffer=t,this.length=e,this.set=n}get type(){return a.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],n=this.buffer[t+3],i=this.set.types[e],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(t+=4))return r;let s=[];for(;t<n;)s.push(this.childString(t)),t=this.buffer[t+3];return r+"("+s.join(",")+")"}findChild(t,e,n,i,r){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&(!m(r,i,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(t,e,n){let i=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){r[l++]=i[o++],r[l++]=i[o++]-n;let e=r[l++]=i[o++]-n;r[l++]=i[o++]-t,s=Math.max(s,e)}return new p(r,s,this.set)}}function m(t,e,n,i){switch(t){case -2:return n<e;case -1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function g(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let e=!i&&t instanceof b&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=i?0:L.IgnoreOverlays;if(i)for(let i=t,o=i.parent;o;o=(i=o).parent)i instanceof b&&i.index<0&&(null==(r=o.enter(e,n,s))?void 0:r.from)!=i.from&&(t=o);for(;;){let i=t.enter(e,n,s);if(!i)return t;t=i}}class v{cursor(t=0){return new A(this,t)}getChild(t,e=null,n=null){let i=y(this,t,e,n);return i.length?i[0]:null}getChildren(t,e=null,n=null){return y(this,t,e,n)}resolve(t,e=0){return g(this,t,e,!1)}resolveInner(t,e=0){return g(this,t,e,!0)}matchContext(t){return w(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),n=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(n=e,e=t.prevSibling):e=t}return n}get node(){return this}get next(){return this.parent}}class b extends v{constructor(t,e,n,i){super(),this._tree=t,this.from=e,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,n,i,r=0){for(let s=this;;){for(let{children:l,positions:a}=s._tree,h=e>0?l.length:-1;t!=h;t+=e){let h=l[t],c=a[t]+s.from,u;if(r&L.EnterBracketed&&h instanceof f&&(u=o.get(h))&&!u.overlay&&u.bracketed&&n>=c&&n<=c+h.length||m(i,n,c,c+h.length)){if(h instanceof p){if(r&L.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,e,n-c,i);if(o>-1)return new k(new x(s,h,t,c),null,o)}else if(r&L.IncludeAnonymous||!h.type.isAnonymous||O(h)){let l;if(!(r&L.IgnoreMounts)&&(l=o.get(h))&&!l.overlay)return new b(l.tree,c,t,s);let a=new b(h,c,t,s);return r&L.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?h.children.length-1:0,e,n,i,r)}}}if(r&L.IncludeAnonymous||!s.type.isAnonymous||(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,!(s=s._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,n=0){let i;if(!(n&L.IgnoreOverlays)&&(i=o.get(this._tree))&&i.overlay){let r=t-this.from,s=n&L.EnterBracketed&&i.bracketed;for(let{from:t,to:n}of i.overlay)if((e>0||s?t<=r:t<r)&&(e<0||s?n>=r:n>r))return new b(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function y(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=n){for(let t=!1;!t;)if(t=r.type.is(n),!r.nextSibling())return s}for(;;){if(null!=i&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==i?s:[]}}function w(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class x{constructor(t,e,n,i){this.parent=t,this.buffer=e,this.index=n,this.start=i}}class k extends v{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,n){super(),this.context=t,this._parent=e,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,e,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.context.start,n);return r<0?null:new k(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,n=0){if(n&L.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new k(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new k(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new k(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let s=n.buffer[this.index+1];t.push(n.slice(i,r,s)),e.push(0)}return new f(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let r=t[i];(r.from>n.from||r.to<n.to)&&(n=r,e=i)}let i=n instanceof b&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new C(r,n)}class C{constructor(t,e){this.heads=t,this.node=e}get next(){return S(this.heads)}}class A{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~L.EnterBracketed,t instanceof b)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:n,buffer:i}=this.buffer;return this.type=e||i.set.types[i.buffer[t]],this.from=n+i.buffer[t+1],this.to=n+i.buffer[t+2],!0}yield(t){return!!t&&(t instanceof b?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,n=this.mode){return this.buffer?!(n&L.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&L.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&L.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,n=this.stack.length-1;if(t<0){let t=n<0?0:this.stack[n]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(t)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,n,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(i.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:n}=i)}else({index:e,_parent:n}=this._tree);for(;n;{index:e,_parent:n}=n)if(e>-1)for(let i=e+t,r=t<0?-1:n._tree.children.length;i!=r;i+=t){let t=n._tree.children[i];if(this.mode&L.IncludeAnonymous||t instanceof p||!t.type.isAnonymous||O(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)i:for(let i=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==i){if(i==this.index)return s;e=s,n=r+1;break i}i=this.stack[--r]}for(let t=n;t<this.stack.length;t++)e=new k(this.buffer,e,this.stack[t]);return this.bufferNode=new k(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&e&&e(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(t){if(!this.buffer)return w(this.node.parent,t);let{buffer:e}=this.buffer,{types:n}=e.set;for(let i=t.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return w(this._tree,t,i);let s=n[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}}function O(t){return t.children.some(t=>t instanceof p||!t.type.isAnonymous||O(t))}let M=new WeakMap;function D(t,e){if(!t.isAnonymous||e instanceof p||e.type!=t)return 1;let n=M.get(e);if(null==n){for(let i of(n=1,e.children)){if(i.type!=t||!(i instanceof f)){n=1;break}n+=D(t,i)}M.set(e,n)}return n}function P(t,e,n,i,r,s,o,l,a){let h=0;for(let n=i;n<r;n++)h+=D(t,e[n]);let c=Math.ceil(1.5*h/8),u=[],f=[];return!function e(n,i,r,o,l){for(let h=r;h<o;){let r=h,d=i[h],p=D(t,n[h]);for(h++;h<o;h++){let e=D(t,n[h]);if(p+e>=c)break;p+=e}if(h==r+1){if(p>c){let t=n[r];e(t.children,t.positions,0,t.children.length,i[r]+l);continue}u.push(n[r])}else{let e=i[h-1]+n[h-1].length-d;u.push(P(t,n,i,r,h,d,e,null,a))}f.push(d+l-s)}}(e,n,i,r,0),(l||a)(u,f,o)}class T{constructor(t,e,n,i,r=!1,s=!1){this.from=t,this.to=e,this.tree=n,this.offset=i,this.open=!!r|2*!!s}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],n=!1){let i=[new T(0,t.length,t,0,!1,n)];for(let n of e)n.to>t.length&&i.push(n);return i}static applyChanges(t,e,n=128){if(!e.length)return t;let i=[],r=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let e=s;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,n=Math.min(e.to,c)-a;e=t>=n?null:new T(t,n,e.tree,e.offset+a,o>0,!!h)}if(e&&i.push(e),s.to>c)break;s=r<t.length?t[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return i}}class E{startParse(t,e,n){return"string"==typeof t&&(t=new R(t)),n=n?n.length?n.map(t=>new r(t.from,t.to)):[new r(0,0)]:[new r(0,t.length)],this.createParse(t,e||[],n)}parse(t,e,n){let i=this.startParse(t,e,n);for(;;){let t=i.advance();if(t)return t}}}class R{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new s({perNode:!0});var B,L,N,I=n(492),F=n(867),j=n(619),_=n(690);let z=new s;function V(t){return I.sj.define({combine:t?e=>e.concat(t):void 0})}let H=new s;class W{constructor(t,e,n=[],i=""){this.data=t,this.name=i,I.$t.prototype.hasOwnProperty("tree")||Object.defineProperty(I.$t.prototype,"tree",{get(){return $(this)}}),this.parser=e,this.extension=[ts.of(this),I.$t.languageData.of((t,e,n)=>{let i=q(t,e,n),r=i.type.prop(z);if(!r)return[];let s=t.facet(r),o=i.type.prop(H);if(o){let r=i.resolve(e-i.from,n);for(let e of o)if(e.test(r,t)){let n=t.facet(e.facet);return"replace"==e.type?n:n.concat(s)}}return s})].concat(n)}isActiveAt(t,e,n=-1){return q(t,e,n).type.prop(z)==this.data}findRegions(t){let e=t.facet(ts);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[],i=(t,e)=>{if(t.prop(z)==this.data)return void n.push({from:e,to:e+t.length});let r=t.prop(s.mounted);if(r){if(r.tree.prop(z)==this.data){if(r.overlay)for(let t of r.overlay)n.push({from:t.from+e,to:t.to+e});else n.push({from:e,to:e+t.length});return}else if(r.overlay){let t=n.length;if(i(r.tree,r.overlay[0].from+e),n.length>t)return}}for(let n=0;n<t.children.length;n++){let r=t.children[n];r instanceof f&&i(r,t.positions[n]+e)}};return i($(t),0),n}get allowsNesting(){return!0}}function q(t,e,n){let i=t.facet(ts),r=$(t).topNode;if(!i||i.allowsNesting)for(let t=r;t;t=t.enter(e,n,L.ExcludeBuffers|L.EnterBracketed))t.type.isTop&&(r=t);return r}W.setState=I.Pe.define();class U extends W{constructor(t,e,n){super(t,e,[],n),this.parser=e}static define(t){let e=V(t.languageData);return new U(e,t.parser.configure({props:[z.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new U(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function $(t){let e=t.field(W.state,!1);return e?e.tree:f.empty}function K(t,e,n=50){var i;let r=null==(i=t.field(W.state,!1))?void 0:i.context;if(!r)return null;let s=r.viewport;r.updateViewport({from:0,to:e});let o=r.isDone(e)||r.work(n,e)?r.tree:null;return r.updateViewport(s),o}function J(t,e=t.doc.length){var n;return(null==(n=t.field(W.state,!1))?void 0:n.context.isDone(e))||!1}function Y(t,e=t.viewport.to,n=100){let i=K(t.state,e,n);return i!=$(t.state)&&t.dispatch({}),!!i}function G(t){var e;return(null==(e=t.plugin(tr))?void 0:e.isWorking())||!1}class Z{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let X=null;class Q{constructor(t,e,n=[],i,r,s,o,l){this.parser=t,this.state=e,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,n){return new Q(t,e,[],f.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Z(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=f.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(T.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(T.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=X;X=this;try{return t()}finally{X=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=tt(t,e.from,e.to);return t}changes(t,e){let{fragments:n,tree:i,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,i,r)=>e.push({fromA:t,toA:n,fromB:i,toB:r})),n=T.applyChanges(n,e),i=f.empty,r=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length)for(let e of(o=[],this.skipped)){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);n<i&&o.push({from:n,to:i})}}return new Q(this.parser,e,n,i,r,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:n,to:i}=this.skipped[e];n<t.to&&i>t.from&&(this.fragments=tt(this.fragments,n,i),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends E{createParse(e,n,i){let r=i[0].from,s=i[i.length-1].to;return{parsedPos:r,advance(){let e=X;if(e){for(let t of i)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new f(a.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return X}}function tt(t,e,n){return T.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class te{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,n)||e.takeTree(),new te(e)}static init(t){let e=Math.min(3e3,t.doc.length),n=Q.create(t.facet(ts).parser,t,{from:0,to:e});return n.work(20,e)||n.takeTree(),new te(n)}}W.state=I.sU.define({create:te.init,update(t,e){for(let t of e.effects)if(t.is(W.setState))return t.value;return e.startState.facet(ts)!=e.state.facet(ts)?te.init(e.state):t.apply(e)}});let tn=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"u">typeof requestIdleCallback&&(tn=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});let ti="u">typeof navigator&&(null==(N=navigator.scheduling)?void 0:N.isInputPending)?()=>navigator.scheduling.isInputPending():null,tr=F.Z9.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(W.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(W.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=tn(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(W.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!ti?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work(()=>ti&&ti()||Date.now()>s,i+1e5*!o);this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:W.setState.of(new te(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>(0,F.c_)(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ts=I.sj.define({combine:t=>t.length?t[0]:null,enables:t=>[W.state,tr,F.Lz.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class to{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class tl{constructor(t,e,n,i,r,s){this.name=t,this.alias=e,this.extensions=n,this.filename=i,this.loadFunc=r,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:n}=t;if(!e){if(!n)throw RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(n)}return new tl(t.name,(t.alias||[]).concat(t.name).map(t=>t.toLowerCase()),t.extensions||[],t.filename,e,n)}static matchFilename(t,e){for(let n of t)if(n.filename&&n.filename.test(e))return n;let n=/\.([^.]+)$/.exec(e);if(n){for(let e of t)if(e.extensions.indexOf(n[1])>-1)return e}return null}static matchLanguageName(t,e,n=!0){for(let n of(e=e.toLowerCase(),t))if(n.alias.some(t=>t==e))return n;if(n)for(let n of t)for(let t of n.alias){let i=e.indexOf(t);if(i>-1&&(t.length>2||!/\w/.test(e[i-1])&&!/\w/.test(e[i+t.length])))return n}return null}}let ta=I.sj.define(),th=I.sj.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function tc(t){let e=t.facet(th);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function tu(t,e){let n="",i=t.tabSize,r=t.facet(th)[0];if(" "==r){for(;e>=i;)n+=" ",e-=i;r=" "}for(let t=0;t<e;t++)n+=r;return n}function tf(t,e){for(let n of(t instanceof I.$t&&(t=new tp(t)),t.state.facet(ta))){let i=n(t,e);if(void 0!==i)return i}let n=$(t.state);return n.length>=e?function(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let t=[];for(let e=r;e&&!(e.from<i.node.from||e.to>i.node.to||e.from==i.node.from&&e.type==i.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)i={node:t[e],next:i}}return tg(i,t,n)}(t,n,e):null}function td(t,e,n){let i=Object.create(null),r=new tp(t,{overrideIndentation:t=>{var e;return null!=(e=i[t])?e:-1}}),s=[];for(let o=e;o<=n;){let e=t.doc.lineAt(o);o=e.to+1;let n=tf(r,e.from);if(null==n)continue;/\S/.test(e.text)||(n=0);let l=/^\s*/.exec(e.text)[0],a=tu(t,n);l!=a&&(i[e.from]=n,s.push({from:e.from,to:e.from+l.length,insert:a}))}return t.changes(s)}class tp{constructor(t,e={}){this.state=t,this.options=e,this.unit=tc(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:r}=this.options;if(null!=i&&i>=n.from&&i<=n.to)if(r&&i==t)return{text:"",from:t};else if(e<0?i<t:i<=t)return{text:n.text.slice(i-n.from),from:i};else return{text:n.text.slice(0,i-n.from),from:n.from};return n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(t,e);return n.slice(t-i,Math.min(n.length,t+100-i))}column(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.countColumn(n,t-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(r+=s-this.countColumn(n,n.search(/\S|$/))),r}countColumn(t,e=t.length){return(0,I.y$)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(i);if(t>-1)return t}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let tm=new s;function tg(t,e,n){for(let i=t;i;i=i.next){let t=function(t){let e=t.type.prop(tm);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(s.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>tw(t,!0,1,void 0,n&&!(t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak)?e.from:void 0)}return null==t.parent?tv:null}(i.node);if(t)return t(tb.create(e,n,i))}return 0}function tv(){return 0}class tb extends tp{constructor(t,e,n){super(t.state,t.options),this.base=t,this.pos=e,this.context=n}get node(){return this.context.node}static create(t,e,n){return new tb(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(function(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return tg(this.context.next,this.base,this.pos)}}function ty({closing:t,align:e=!0,units:n=1}){return i=>tw(i,e,n,t)}function tw(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,a=e?function(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=n.to;;){let r=e.childAfter(t);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let t=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+t}}t=r.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}let tx=t=>t.baseIndent;function tk({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}function tS(){return I.$t.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:i}=t.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return t;let s=n.sliceString(r.from,i);if(!e.some(t=>t.test(s)))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let n=tf(o,e.from);if(null==n)continue;let i=/^\s*/.exec(e.text)[0],r=tu(o,n);i!=r&&a.push({from:e.from,to:e.from+i.length,insert:r})}return a.length?[t,{changes:a,sequential:!0}]:t})}let tC=I.sj.define(),tA=new s;function tO(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function tM(t,e,n){for(let i of t.facet(tC)){let r=i(t,e,n);if(r)return r}return function(t,e,n){let i=$(t);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=n||r.from>n)continue;if(s&&r.from<e)break;let l=r.type.prop(tA);if(l&&(r.to<i.length-50||i.length==t.doc.length||!function(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}(r))){let i=l(r,t);i&&i.from<=n&&i.from>=e&&i.to>n&&(s=i)}}return s}(t,e,n)}function tD(t,e){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}let tP=I.Pe.define({map:tD}),tT=I.Pe.define({map:tD});function tE(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(t=>t.from<=n&&t.to>=n)||e.push(t.lineBlockAt(n));return e}let tR=I.sU.define({create:()=>F.NZ.none,update(t,e){for(let n of(e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,n)=>t=tB(t,e,n)),t=t.map(e.changes),e.effects))if(n.is(tP)&&!function(t,e,n){let i=!1;return t.between(e,e,(t,r)=>{t==e&&r==n&&(i=!0)}),i}(t,n.value.from,n.value.to)){let{preparePlaceholder:i}=e.state.facet(tU),r=i?F.NZ.replace({widget:new tY(i(e.state,n.value))}):tJ;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(tT)&&(t=t.update({filter:(t,e)=>n.value.from!=t||n.value.to!=e,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=tB(t,e.selection.main.head)),t},provide:t=>F.Lz.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(t,e)=>{n.push(t,e)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let i=t[n++],r=t[n++];if("number"!=typeof i||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");e.push(tJ.range(i,r))}return F.NZ.set(e,!0)}});function tB(t,e,n=e){let i=!1;return t.between(e,n,(t,r)=>{t<n&&r>e&&(i=!0)}),i?t.update({filterFrom:e,filterTo:n,filter:(t,i)=>t>=n||i<=e}):t}function tL(t){return t.field(tR,!1)||I.om.empty}function tN(t,e,n){var i;let r=null;return null==(i=t.field(tR,!1))||i.between(e,n,(t,e)=>{(!r||r.from>t)&&(r={from:t,to:e})}),r}function tI(t,e){return t.field(tR,!1)?e:e.concat(I.Pe.appendConfig.of(t$()))}let tF=t=>{for(let e of tE(t)){let n=tM(t.state,e.from,e.to);if(n)return t.dispatch({effects:tI(t.state,[tP.of(n),t_(t,n)])}),!0}return!1},tj=t=>{if(!t.state.field(tR,!1))return!1;let e=[];for(let n of tE(t)){let i=tN(t.state,n.from,n.to);i&&e.push(tT.of(i),t_(t,i,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function t_(t,e,n=!0){let i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return F.Lz.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${t.state.phrase("to")} ${r}.`)}let tz=t=>{let{state:e}=t,n=[];for(let i=0;i<e.doc.length;){let r=t.lineBlockAt(i),s=tM(e,r.from,r.to);s&&n.push(tP.of(s)),i=(s?t.lineBlockAt(s.to):r).to+1}return n.length&&t.dispatch({effects:tI(t.state,n)}),!!n.length},tV=t=>{let e=t.state.field(tR,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(t,e)=>{n.push(tT.of({from:t,to:e}))}),t.dispatch({effects:n}),!0},tH=t=>{let e=[];for(let n of tE(t)){let i=tN(t.state,n.from,n.to);if(i)e.push(tT.of(i),t_(t,i,!1));else{let i=function(t,e){for(let n=e;;){let i=tM(t.state,n.from,n.to);if(i&&i.to>e.from)return i;if(!n.from)return null;n=t.lineBlockAt(n.from-1)}}(t,n);i&&e.push(tP.of(i),t_(t,i))}}return e.length>0&&t.dispatch({effects:tI(t.state,e)}),!!e.length},tW=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:tF},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:tj},{key:"Ctrl-Alt-[",run:tz},{key:"Ctrl-Alt-]",run:tV}],tq={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},tU=I.sj.define({combine:t=>(0,I.QR)(t,tq)});function t$(t){let e=[tR,tQ];return t&&e.push(tU.of(t)),e}function tK(t,e){let{state:n}=t,i=n.facet(tU),r=e=>{let n=t.lineBlockAt(t.posAtDOM(e.target)),i=tN(t.state,n.from,n.to);i&&t.dispatch({effects:tT.of(i)}),e.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let tJ=F.NZ.replace({widget:new class extends F.xO{toDOM(t){return tK(t,null)}}});class tY extends F.xO{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return tK(t,this.value)}}let tG={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class tZ extends F.wJ{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function tX(t={}){let e={...tG,...t},n=new tZ(e,!0),i=new tZ(e,!1),r=F.Z9.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(ts)!=t.state.facet(ts)||t.startState.field(tR,!1)!=t.state.field(tR,!1)||$(t.startState)!=$(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new I.vB;for(let r of t.viewportLineBlocks){let s=tN(t.state,r.from,r.to)?i:tM(t.state,r.from,r.to)?n:null;s&&e.add(r.from,r.from,s)}return e.finish()}}),{domEventHandlers:s}=e;return[r,(0,F.cU)({class:"cm-foldGutter",markers(t){var e;return(null==(e=t.plugin(r))?void 0:e.markers)||I.om.empty},initialSpacer:()=>new tZ(e,!1),domEventHandlers:{...s,click:(t,e,n)=>{if(s.click&&s.click(t,e,n))return!0;let i=tN(t.state,e.from,e.to);if(i)return t.dispatch({effects:tT.of(i)}),!0;let r=tM(t.state,e.from,e.to);return!!r&&(t.dispatch({effects:tP.of(r)}),!0)}}}),t$()]}let tQ=F.Lz.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class t0{constructor(t,e){let n;function i(t){let e=_.G.newName();return(n||(n=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?i(e.all):void 0,s=e.scope;this.scope=s instanceof W?t=>t.prop(z)==s.data:s?t=>t==s:void 0,this.style=(0,j.az)(t.map(t=>({tag:t.tag,class:t.class||i(Object.assign({},t,{tag:null}))})),{all:r}).style,this.module=n?new _.G(n):null,this.themeType=e.themeType}static define(t,e){return new t0(t,e||{})}}let t1=I.sj.define(),t2=I.sj.define({combine:t=>t.length?[t[0]]:null});function t4(t){let e=t.facet(t1);return e.length?e:t.facet(t2)}function t3(t,e){let n=[t5],i;return t instanceof t0&&(t.module&&n.push(F.Lz.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(t2.of(t)):i?n.push(t1.computeN([F.Lz.darkTheme],e=>e.facet(F.Lz.darkTheme)==("dark"==i)?[t]:[])):n.push(t1.of(t)),n}function t8(t,e,n){let i=t4(t),r=null;if(i){for(let t of i)if(!t.scope||n&&t.scope(n)){let n=t.style(e);n&&(r=r?r+" "+n:n)}}return r}let t5=I.Nb.high(F.Z9.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=$(t.state),this.decorations=this.buildDeco(t,t4(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=$(t.state),n=t4(t.state),i=n!=t4(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!i&&e.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||i)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return F.NZ.none;let n=new I.vB;for(let{from:i,to:r}of t.visibleRanges)(0,j.DM)(this.tree,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=F.NZ.mark({class:i})))},i,r);return n.finish()}},{decorations:t=>t.decorations})),t9=t0.define([{tag:j._A.meta,color:"#404740"},{tag:j._A.link,textDecoration:"underline"},{tag:j._A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:j._A.emphasis,fontStyle:"italic"},{tag:j._A.strong,fontWeight:"bold"},{tag:j._A.strikethrough,textDecoration:"line-through"},{tag:j._A.keyword,color:"#708"},{tag:[j._A.atom,j._A.bool,j._A.url,j._A.contentSeparator,j._A.labelName],color:"#219"},{tag:[j._A.literal,j._A.inserted],color:"#164"},{tag:[j._A.string,j._A.deleted],color:"#a11"},{tag:[j._A.regexp,j._A.escape,j._A.special(j._A.string)],color:"#e40"},{tag:j._A.definition(j._A.variableName),color:"#00f"},{tag:j._A.local(j._A.variableName),color:"#30a"},{tag:[j._A.typeName,j._A.namespace],color:"#085"},{tag:j._A.className,color:"#167"},{tag:[j._A.special(j._A.variableName),j._A.macroName],color:"#256"},{tag:j._A.definition(j._A.propertyName),color:"#00c"},{tag:j._A.comment,color:"#940"},{tag:j._A.invalid,color:"#f00"}]),t6=F.Lz.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),t7="()[]{}",et=I.sj.define({combine:t=>(0,I.QR)(t,{afterCursor:!0,brackets:t7,maxScanDistance:1e4,renderMatch:ei})}),ee=F.NZ.mark({class:"cm-matchingBracket"}),en=F.NZ.mark({class:"cm-nonmatchingBracket"});function ei(t){let e=[],n=t.matched?ee:en;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}let er=[I.sU.define({create:()=>F.NZ.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],i=e.state.facet(et);for(let t of e.state.selection.ranges){if(!t.empty)continue;let r=eh(e.state,t.head,-1,i)||t.head>0&&eh(e.state,t.head-1,1,i)||i.afterCursor&&(eh(e.state,t.head,1,i)||t.head<e.state.doc.length&&eh(e.state,t.head+1,-1,i));r&&(n=n.concat(i.renderMatch(r,e.state)))}return F.NZ.set(n,!0)},provide:t=>F.Lz.decorations.from(t)}),t6];function es(t={}){return[et.of(t),er]}let eo=new s;function el(t,e,n){let i=t.prop(e<0?s.openedBy:s.closedBy);if(i)return i;if(1==t.name.length){let i=n.indexOf(t.name);if(i>-1&&i%2==+(e<0))return[n[i+e]]}return null}function ea(t){let e=t.type.prop(eo);return e?e(t.node):t}function eh(t,e,n,i={}){let r=i.maxScanDistance||1e4,s=i.brackets||t7,o=$(t),l=o.resolveInner(e,n);for(let t=l;t;t=t.parent){let i=el(t.type,n,s);if(i&&t.from<t.to){let r=ea(t);if(r&&(n>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return function(t,e,n,i,r){let s=e.parent,o={from:n.from,to:n.to},l=0,a=null==s?void 0:s.cursor();if(a&&(t<0?a.childBefore(e.from):a.childAfter(e.to)))do if(t<0?a.to<=e.from:a.from>=e.to){if(0==l&&i.indexOf(a.type.name)>-1&&a.from<a.to){let t=ea(a);return{start:o,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}else if(el(a.type,t,r))l++;else if(el(a.type,-t,r)){if(0==l){let t=ea(a);return{start:o,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}l--}}while(t<0?a.prevSibling():a.nextSibling());return{start:o,matched:!1}}(n,t,r,i,s)}}return function(t,e,n,i,r,s,o){let l=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;n<0&&(t+=s.length);let l=e+t*n;for(let t=n>0?0:s.length-1,e=n>0?s.length:-1;t!=e;t+=n){let e=o.indexOf(s[t]);if(!(e<0)&&i.resolveInner(l+t,1).type==r)if(e%2==0==n>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}n>0&&(t+=s.length)}return c.done?{start:h,matched:!1}:null}(t,e,n,o,l.type,r,s)}function ec(t,e,n,i=0,r=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=r;for(let r=i;r<e;r++)9==t.charCodeAt(r)?s+=n-s%n:s++;return s}class eu{constructor(t,e,n,i){this.string=t,this.tabSize=e,this.indentUnit=n,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos);if("string"==typeof t?e==t:e&&(t instanceof RegExp?t.test(e):t(e)))return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ec(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!=(t=this.overrideIndent)?t:ec(this.string,null,this.tabSize)}match(t,e,n){if("string"==typeof t){let i=t=>n?t.toLowerCase():t;return i(this.string.substr(this.pos,t.length))==i(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let n=this.string.slice(this.pos).match(t);return n&&n.index>0?null:(n&&!1!==e&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}}function ef(t){if("object"!=typeof t)return t;let e={};for(let n in t){let i=t[n];e[n]=i instanceof Array?i.slice():i}return e}let ed=new WeakMap;class ep extends W{constructor(t){let e=V(t.languageData),n=function(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||ef,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||eb,mergeTokens:!1!==t.mergeTokens}}(t),i;super(e,new class extends E{createParse(t,e,n){return new eg(i,t,e,n)}},[],t.name),this.topNode=function(t,e){let n=a.define({id:ey.length,name:"Document",props:[z.add(()=>t),tm.add(()=>t=>e.getIndent(t))],top:!0});return ey.push(n),n}(e,this),i=this,this.streamParser=n,this.stateAfter=new s({perNode:!0}),this.tokenTable=t.tokenTable?new eC(n.tokenTable):eA}static define(t){return new ep(t)}getIndent(t){let e,{overrideIndentation:n}=t.options;n&&null!=(e=ed.get(t.state))&&e<t.pos-1e4&&(e=void 0);let i=em(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos),r,s;if(i?(s=i.state,r=i.pos+1):(s=this.streamParser.startState(t.unit),r=t.node.from),t.pos-r>1e4)return null;for(;r<t.pos;){let e=t.state.doc.lineAt(r),i=Math.min(t.pos,e.to);if(e.length){let r=n?n(e.from):-1,o=new eu(e.text,t.state.tabSize,t.unit,r<0?void 0:r);for(;o.pos<i-e.from;)ev(this.streamParser.token,o,s)}else this.streamParser.blankLine(s,t.unit);if(i==t.pos)break;r=e.to+1}let o=t.lineAt(t.pos);return n&&null==e&&ed.set(t.state,o.from),this.streamParser.indent(s,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function em(t,e,n,i,r){let s=n>=i&&n+e.length<=r&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:n+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],l=n+e.positions[s],a=o instanceof f&&l<r&&em(t,o,l,i,r);if(a)return a}return null}class eg{constructor(t,e,n,i){this.lang=t,this.input=e,this.fragments=n,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let r=Q.get(),s=i[0].from,{state:o,tree:l}=function(t,e,n,i,r){for(let r of e){let e=r.from+25*!!r.openStart,s=r.to-25*!!r.openEnd,o=e<=n&&s>n&&em(t,r.tree,0-r.offset,n,s),l;if(o&&o.pos<=i&&(l=function t(e,n,i,r,s){if(s&&i<=0&&r>=n.length)return n;s||0!=i||n.type!=e.topNode||(s=!0);for(let o=n.children.length-1;o>=0;o--){let l=n.positions[o],a=n.children[o],h;if(l<r&&a instanceof f){if(!(h=t(e,a,i-l,r-l,s)))break;return s?new f(n.type,n.children.slice(0,o).concat(h),n.positions.slice(0,o+1),l+h.length):h}}return null}(t,r.tree,n+r.offset,o.pos+r.offset,!1)))return{state:o.state,tree:l}}return{state:t.streamParser.startState(r?tc(r):4),tree:f.empty}}(t,n,s,this.to,null==r?void 0:r.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let t=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);r&&this.parsedPos<r.viewport.from-1e5&&i.some(t=>t.from<=r.viewport.from&&t.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(tc(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let t=Q.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(e,this.chunkStart+512);for(t&&(n=Math.min(n,t.viewport.to));this.parsedPos<n;)this.parseLine(t);return(this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e)?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),n=t+e.length;for(let t=this.rangeIndex;;){let i=this.ranges[t].to;if(i>=n||(e=e.slice(0,i-(n-e.length)),++t==this.ranges.length))break;let r=this.ranges[t].from,s=this.lineAfter(r);e+=s,n=r+s.length}return{line:e,end:n}}skipGapsTo(t,e,n){for(;;){let i=this.ranges[this.rangeIndex].to,r=t+e;if(n>0?i>r:i>=r)break;let s=this.ranges[++this.rangeIndex].from;e+=s-i}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,n,i){let r=4;if(this.ranges.length>1){i=this.skipGapsTo(e,i,1),e+=i;let t=this.chunk.length;i=this.skipGapsTo(n,i,-1),n+=i,r+=this.chunk.length-t}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&4==r&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==e?this.chunk[s+2]=n:this.chunk.push(t,e,n,r),i}parseLine(t){let{line:e,end:n}=this.nextLine(),i=0,{streamParser:r}=this.lang,s=new eu(e,t?t.state.tabSize:4,t?tc(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=ev(r.token,s,this.state);if(t&&(i=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,i)),s.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=f.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ew,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new f(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new f(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function ev(t,e,n){e.start=e.pos;for(let i=0;i<10;i++){let i=t(e,n);if(e.pos>e.start)return i}throw Error("Stream parser failed to advance stream.")}let eb=Object.create(null),ey=[a.none],ew=new h(ey),ex=[],ek=Object.create(null),eS=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])eS[t]=eM(eb,e);class eC{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),eS)}resolve(t){return t?this.table[t]||(this.table[t]=eM(this.extra,t)):0}}let eA=new eC(eb);function eO(t,e){ex.indexOf(t)>-1||(ex.push(t),console.warn(e))}function eM(t,e){let n=[];for(let i of e.split(" ")){let e=[];for(let n of i.split(".")){let i=t[n]||j._A[n];i?"function"==typeof i?e.length?e=e.map(i):eO(n,`Modifier ${n} used at start of tag`):e.length?eO(n,`Tag ${n} used as modifier`):e=Array.isArray(i)?i:[i]:eO(n,`Unknown highlighting tag ${n}`)}for(let t of e)n.push(t)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(t=>t.id),s=ek[r];if(s)return s.id;let o=ek[r]=a.define({id:ey.length,name:i,props:[(0,j.pn)({[i]:n})]});return ey.push(o),o.id}function eD(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function eP(t){for(let e=t.iter();!e.next().done;)if(eD(e.value))return!0;return!1}let eT=I.sj.define({combine:t=>t.some(t=>t)});function eE(t={}){let e=[eR];return t.alwaysIsolate&&e.push(eT.of(!0)),e}let eR=F.Z9.fromClass(class{constructor(t){this.always=t.state.facet(eT)||t.textDirection!=F.OP.LTR||t.state.facet(F.Lz.perLineTextDirection),this.hasRTL=!this.always&&eP(t.state.doc),this.tree=$(t.state),this.decorations=this.always||this.hasRTL?eB(t,this.tree,this.always):F.NZ.none}update(t){var e;let n,i=t.state.facet(eT)||t.view.textDirection!=F.OP.LTR||t.state.facet(F.Lz.perLineTextDirection);if(i||this.hasRTL||(e=t.changes,n=!1,e.iterChanges((t,e,i,r,s)=>{!n&&eP(s)&&(n=!0)}),!n)||(this.hasRTL=!0),!i&&!this.hasRTL)return;let r=$(t.state);(i!=this.always||r!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=r,this.always=i,this.decorations=eB(t.view,r,i))}},{provide:t=>{function e(e){var n,i;return null!=(i=null==(n=e.plugin(t))?void 0:n.decorations)?i:F.NZ.none}return[F.Lz.outerDecorations.of(e),I.Nb.lowest(F.Lz.bidiIsolatedRanges.of(e))]}});function eB(t,e,n){let i=new I.vB,r=t.visibleRanges;for(let{from:o,to:l}of(n||(r=function(t,e){let n=e.iter(),i=0,r=[],s=null;for(let{from:e,to:o}of t)if(!s||!(s.to>e)||!((e=s.to)>=o))for(i+n.value.length<e&&(n.next(e-(i+n.value.length)),i=e);;){let t=i,e=i+n.value.length;if(!n.lineBreak&&eD(n.value)&&(s&&s.to>t-10?s.to=Math.min(o,e):r.push(s={from:t,to:Math.min(o,e)})),e>=o)break;i=e,n.next()}return r}(r,t.state.doc)),r))e.iterate({enter:t=>{let e=t.type.prop(s.isolate);e&&i.add(t.from,t.to,eL[e])},from:o,to:l});return i.finish()}let eL={rtl:F.NZ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:F.OP.RTL}),ltr:F.NZ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:F.OP.LTR}),auto:F.NZ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})}}},c={};function u(t){var e=c[t];if(void 0!==e)return e.exports;var n=c[t]={exports:{}};return h[t](n,n.exports,u),n.exports}u.m=h,u.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return u.d(e,{a:e}),e},u.d=function(t,e){for(var n in e)u.o(e,n)&&!u.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},u.f={},u.e=function(t){return Promise.all(Object.keys(u.f).reduce(function(e,n){return u.f[n](t,e),e},[]))},u.u=function(t){return""+({176:"20b81aeb6a25ed02",214:"ef389a6b6d53d092",299:"ff45080a90ba8316",613:"a0119416ceb52c00",707:"3d31cfcbbe46df81",815:"79f5f1cac434ba94"})[t]+".js"},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),u.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},f={},u.l=function(t,e,n,i){if(f[t])return void f[t].push(e);if(void 0!==n)for(var r,s,o=document.getElementsByTagName("script"),l=0;l<o.length;l++){var a=o[l];if(a.getAttribute("src")==t||a.getAttribute("data-rspack")=="@nocobase/plugin-field-code:"+n){r=a;break}}r||(s=!0,(r=document.createElement("script")).timeout=120,u.nc&&r.setAttribute("nonce",u.nc),r.setAttribute("data-rspack","@nocobase/plugin-field-code:"+n),r.src=t),f[t]=[e];var h=function(e,n){r.onerror=r.onload=null,clearTimeout(c);var i=f[t];if(delete f[t],r.parentNode&&r.parentNode.removeChild(r),i&&i.forEach(function(t){return t(n)}),e)return e(n)},c=setTimeout(h.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=h.bind(null,r.onerror),r.onload=h.bind(null,r.onload),s&&document.head.appendChild(r)},u.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},u.g.importScripts&&(d=u.g.location+"");var f,d,p=u.g.document;if(!d&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(d=p.currentScript.src),!d)){var m=p.getElementsByTagName("script");if(m.length)for(var g=m.length-1;g>-1&&(!d||!/^http(s?):/.test(d));)d=m[g--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");u.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o={889:0},u.f.j=function(t,e){var n=u.o(o,t)?o[t]:void 0;if(0!==n)if(n)e.push(n[2]);else{var i=new Promise(function(e,i){n=o[t]=[e,i]});e.push(n[2]=i);var r=u.p+u.u(t),s=Error();u.l(r,function(e){if(u.o(o,t)&&(0!==(n=o[t])&&(o[t]=void 0),n)){var i=e&&("load"===e.type?"missing":e.type),r=e&&e.target&&e.target.src;s.message="Loading chunk "+t+" failed.\n("+i+": "+r+")",s.name="ChunkLoadError",s.type=i,s.request=r,n[1](s)}},"chunk-"+t,t)}},l=function(t,e){var n,i,r=e[0],s=e[1],l=e[2],a=0;if(r.some(function(t){return 0!==o[t]})){for(n in s)u.o(s,n)&&(u.m[n]=s[n]);l&&l(u)}for(t&&t(e);a<r.length;a++)i=r[a],u.o(o,i)&&o[i]&&o[i][0](),o[i]=0},(a=self.webpackChunk_nocobase_plugin_field_code=self.webpackChunk_nocobase_plugin_field_code||[]).forEach(l.bind(null,0)),a.push=l.bind(null,a.push.bind(a));var v={};return!function(){"use strict";var t=window.__webpack_public_path__||"/";"/"!==t.charAt(t.length-1)&&(t+="/"),u.p=t+"static/plugins/@nocobase/plugin-field-code/dist/client/"}(),!function(){"use strict";u.r(v),u.d(v,{codeComponentSettings:function(){return J},default:function(){return G},PluginFieldCodeClient:function(){return Y}});var t=u(155),e=u.n(t),n=u(230),i=u(342),r="@nocobase/plugin-field-code",s=u(681);function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(h=function(){return!!t})()}var c=i.interfacesProperties.defaultProps,f=i.interfacesProperties.operators,d=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function e(){var t,n,i,a,u;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");return n=e,i=arguments,n=l(n),o(t=function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,h()?Reflect.construct(n,i||[],l(this).constructor):n.apply(this,i)),"name","code"),o(t,"type","object"),o(t,"group","advanced"),o(t,"order",1),o(t,"title",'{{t("Code", { ns: "'.concat(r,'" })}}')),o(t,"description",'{{t("Programming code editor with syntax highlighting.", { ns: "'.concat(r,'" })}}')),o(t,"sortable",!0),o(t,"default",{type:"text",uiSchema:{type:"string","x-component":"CodeEditor"}}),o(t,"properties",(a=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){o(t,e,n[e])})}return t}({},c),u=u={"uiSchema.x-component-props.language":{type:"string",title:'{{t("Programming language", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!0,allowClear:!0,placeholder:'{{t("Choose language", { ns: "'.concat(r,'" })}}')},enum:s.X.map(function(t){return{label:t.label,value:t.value}}),default:"javascript"}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(u)).forEach(function(t){Object.defineProperty(a,t,Object.getOwnPropertyDescriptor(u,t))}),a)),o(t,"availableTypes",["text","string"]),o(t,"filterable",{operators:f.bigField}),o(t,"titleUsable",!1),t}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t),e}(i.CollectionFieldInterface);function p(t){var e,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i.i18n.t(t,(e=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},s),n=n={ns:r},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e))}var m=u(694),g=u(125),b=u(59);function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var s=[],o=!0,l=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);o=!0);}catch(t){l=!0,i=t}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var x=["auto","100px","200px","300px","400px","500px"],k=[2,4,6,8].map(function(t){return{label:t,value:t}}),S=function(t){return(null==t?void 0:t.trim())||"auto"},C=function(t){var e=Number(t);return Number.isFinite(e)&&e>0?Math.trunc(e):2},A=function(t){return function(e){var n,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.t(e,(n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},s),i=i={ns:r},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))}),n))}},O=function(t){var e=A(t);return x.map(function(t){return{label:"auto"===t?e("Auto"):t,value:t}})},M=function(n){var i=n.defaultValue,r=n.handleChange,s=n.setOpen,o=n.t,l=w((0,t.useState)(i),2),a=l[0],h=l[1];return e().createElement("div",{onClick:function(t){t.stopPropagation(),s(!0)},onMouseLeave:function(){s(!0)}},e().createElement(b.Space.Compact,{block:!0},e().createElement(b.Input,{placeholder:o("e.g. 300px or 50%"),value:a,onChange:function(t){return h(t.target.value)},style:{width:"100%",minWidth:200}}),e().createElement(b.Button,{type:"primary",onClick:function(){return r(S(a))}},"OK")))},D=function(n){var i=n.defaultValue,r=n.handleChange,s=n.setOpen,o=n.t,l=w((0,t.useState)(i),2),a=l[0],h=l[1];return e().createElement("div",{onClick:function(t){t.stopPropagation(),s(!0)},onMouseLeave:function(){s(!0)}},e().createElement(b.Space.Compact,{block:!0},e().createElement(b.InputNumber,{placeholder:o("Custom indent unit"),value:a,min:1,precision:0,onChange:function(t){return h(t)},style:{width:"100%",minWidth:200}}),e().createElement(b.Button,{type:"primary",onClick:function(){return r(C(a))}},"OK")))},P=function(t,n,i,r,s){var o=S(s),l=A(t);return e().createElement(e().Fragment,null,n,e().createElement(b.Divider,{style:{margin:"4px 0"}}),e().createElement(M,{setOpen:i,handleChange:r,t:l,defaultValue:x.includes(o)?null:o}))},T=function(t,n,i,r,s){var o=C(s),l=A(t);return e().createElement(e().Fragment,null,n,e().createElement(b.Divider,{style:{margin:"4px 0"}}),e().createElement(D,{setOpen:i,handleChange:r,t:l,defaultValue:k.some(function(t){return t.value===o})?null:o}))};function E(t){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function R(t,e){return(R=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function B(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(B=function(){return!!t})()}var L=function(t){var n;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function i(){var t,e;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,e=arguments,t=E(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,B()?Reflect.construct(t,e||[],E(this).constructor):t.apply(this,e))}return i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&R(i,t),n=[{key:"render",value:function(){return e().createElement(g.default,this.props)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,n),i}(i.FieldModel);(L=function(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s<3?r(o):s>3?r(e,n,o):r(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}([(0,m.largeField)()],L)).registerFlow({key:"codeFieldSettings",sort:200,title:(0,m.tExpr)("Content settings",{ns:r}),steps:{height:{title:(0,m.tExpr)("Content height",{ns:r}),defaultParams:function(t){var e,n;return{height:(null==(n=t.model)||null==(e=n.props)?void 0:e.height)||"auto"}},uiMode:function(t){var e,n,i=S(null==(n=t.model)||null==(e=n.props)?void 0:e.height);return{type:"select",key:"height",props:{options:O(t),dropdownRender:function(e,n,r){return P(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({height:S(e.height)})}},indentUnit:{title:(0,m.tExpr)("Indent unit",{ns:r}),defaultParams:function(t){var e,n;return{indentUnit:Number((null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit)||2)}},uiMode:function(t){var e,n,i=C(null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit);return{type:"select",key:"indentUnit",props:{options:k,dropdownRender:function(e,n,r){return T(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({indentUnit:C(e.indentUnit)})}}}}),m.EditableItemModel.bindModelToInterface("CodeFieldModel",["code"],{isDefault:!0}),m.FilterableItemModel.bindModelToInterface("InputFieldModel",["code"],{isDefault:!0});function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function I(t,e){return(I=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function F(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(F=function(){return!!t})()}var j=function(t){var n;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function i(){var t,e;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,e=arguments,t=N(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,F()?Reflect.construct(t,e||[],N(this).constructor):t.apply(this,e))}return i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&I(i,t),n=[{key:"render",value:function(){var t,n;return e().createElement(g.default,(t=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},this.props),n=n={disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,n),i}(i.FieldModel);(j=function(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s<3?r(o):s>3?r(e,n,o):r(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}([(0,m.largeField)()],j)).registerFlow({key:"displayCodeFieldSettings",sort:200,title:(0,m.tExpr)("Content settings",{ns:r}),steps:{height:{title:(0,m.tExpr)("Content height",{ns:r}),defaultParams:function(t){var e,n;return{height:(null==(n=t.model)||null==(e=n.props)?void 0:e.height)||"auto"}},uiMode:function(t){var e,n,i=S(null==(n=t.model)||null==(e=n.props)?void 0:e.height);return{type:"select",key:"height",props:{options:O(t),dropdownRender:function(e,n,r){return P(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({height:S(e.height)})}},indentUnit:{title:(0,m.tExpr)("Indent unit",{ns:r}),defaultParams:function(t){var e,n;return{indentUnit:Number((null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit)||2)}},uiMode:function(t){var e,n,i=C(null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit);return{type:"select",key:"indentUnit",props:{options:k,dropdownRender:function(e,n,r){return T(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({indentUnit:C(e.indentUnit)})}}}}),m.DisplayItemModel.bindModelToInterface("DisplayCodeFieldModel",["code"],{isDefault:!0});var _=u(631);function z(t,e,n,i,r,s,o){try{var l=t[s](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function V(t,e,n){return(V=$()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&q(r,n.prototype),r}).apply(null,arguments)}function H(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W(t){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function q(t,e){return(q=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function U(t){var e="function"==typeof Map?new Map:void 0;return(U=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return V(t,arguments,W(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,t)})(t)}function $(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return($=function(){return!!t})()}var K=(0,t.lazy)(function(){return _("imported_b24rcf_component",Promise.resolve().then(u.bind(u,125)))}),J=new i.SchemaSettings({name:"fieldSettings:component:CodeEditor",items:[{name:"height",type:"modal",useComponentProps:function(){var t,e=(0,n.useField)(),s=(0,n.useFieldSchema)(),o=((0,i.useColumnSchema)()||{}).fieldSchema,l=(0,i.useDesignable)().dn,a=o||s;return{title:p("Content height"),schema:{type:"object",title:p("Content height"),properties:{height:{"x-decorator":"FormItem","x-component":"Input","x-component-props":{},default:(null==s||null==(t=s["x-component-props"])?void 0:t.height)||"auto",description:'{{t(\'Could use CSS values (e.g., "300px" or "50%"). Use "auto" for automatic height adjustment based on content.\', { ns: "'.concat(r,'" })}}')}}},onSubmit:function(t){var n=t.height,i=a["x-component-props"]||{};i.height=n;var r=H({},"x-uid",a["x-uid"]);r["x-component-props"]=i,a["x-component-props"]=i,e.componentProps.height=n,l.emit("patch",{schema:r}),l.refresh()}}}},{name:"indentUnit",type:"modal",useComponentProps:function(){var t,e=(0,n.useField)(),r=(0,n.useFieldSchema)(),s=((0,i.useColumnSchema)()||{}).fieldSchema,o=(0,i.useDesignable)().dn,l=s||r;return{title:p("Indent unit"),schema:{type:"object",title:p("Indent unit"),properties:{indentUnit:{"x-decorator":"FormItem","x-component":"Input","x-component-props":{},default:(null==r||null==(t=r["x-component-props"])?void 0:t.indentUnit)||2}}},onSubmit:function(t){var n=t.indentUnit,i=l["x-component-props"]||{};i.indentUnit=n;var r=H({},"x-uid",l["x-uid"]);r["x-component-props"]=i,l["x-component-props"]=i,e.componentProps.indentUnit=n,o.emit("patch",{schema:r}),o.refresh()}}}}]}),Y=function(t){var e;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,e;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,e=arguments,t=W(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,$()?Reflect.construct(t,e||[],W(this).constructor):t.apply(this,e))}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&q(n,t),e=[{key:"load",value:function(){var t;return(t=function(){return function(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(o,"next",{value:a(0)}),l(o,"throw",{value:a(1)}),l(o,"return",{value:a(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function a(l){return function(a){var h=[l,a];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&h[0]?i.return:h[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,h[1])).done)return r;switch(i=0,r&&(h=[2&h[0],r.value]),h[0]){case 0:case 1:r=h;break;case 4:return s.label++,{value:h[1],done:!1};case 5:s.label++,i=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===h[0]||2===h[0])){s=0;continue}if(3===h[0]&&(!r||h[1]>r[0]&&h[1]<r[3])){s.label=h[1];break}if(6===h[0]&&s.label<r[1]){s.label=r[1],r=h;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(h);break}r[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(t){h=[6,t],i=0}finally{n=r=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}}(this,function(t){return this.app.addComponents({CodeEditor:K}),this.app.dataSourceManager.addFieldInterfaces([d]),this.app.schemaSettingsManager.add(J),this.flowEngine.registerModels({CodeFieldModel:L,DisplayCodeFieldModel:j}),[2]})},function(){var e=this,n=arguments;return new Promise(function(i,r){var s=t.apply(e,n);function o(t){z(s,i,r,o,l,"next",t)}function l(t){z(s,i,r,o,l,"throw",t)}o(void 0)})}).call(this)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(n.prototype,e),n}(U(i.Plugin)),G=Y}(),v}()});
10
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@formily/react"),require("@nocobase/flow-engine"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-code",["@formily/react","@nocobase/flow-engine","react","antd","@nocobase/client","antd-style"],e):"object"==typeof exports?exports["@nocobase/plugin-field-code"]=e(require("@formily/react"),require("@nocobase/flow-engine"),require("react"),require("antd"),require("@nocobase/client"),require("antd-style")):t["@nocobase/plugin-field-code"]=e(t["@formily/react"],t["@nocobase/flow-engine"],t.react,t.antd,t["@nocobase/client"],t["antd-style"])}(self,function(t,e,n,i,r,s){return function(){"use strict";var o,l,a,h={549:function(t,e,n){n.r(e),n.d(e,{default:function(){return nt}});var i=n(155),r=n.n(i),s=n(235),o=n(230),l=n(867),a=n(492),h=n(169),c=n(80);function u(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return!!r&&(i(n.update(r)),!0)}}let f=u(function(t,e,n=e.selection.ranges){let i=[],r=-1;for(let{from:t,to:s}of n){let n=i.length,o=1e9,l=m(e,t).line;if(l){for(let n=t;n<=s;){let a=e.doc.lineAt(n);if(a.from>r&&(t==s||s>a.from)){r=a.from;let t=/^\s*/.exec(a.text)[0].length,e=t==a.length,n=a.text.slice(t,t+l.length)==l?t:-1;t<a.text.length&&t<o&&(o=t),i.push({line:a,comment:n,token:l,indent:t,empty:e,single:!1})}n=a.to+1}if(o<1e9)for(let t=n;t<i.length;t++)i[t].indent<i[t].line.text.length&&(i[t].indent=o);i.length==n+1&&(i[n].single=!0)}}if(2!=t&&i.some(t=>t.comment<0&&(!t.empty||t.single))){let t=[];for(let{line:e,token:n,indent:r,empty:s,single:o}of i)(o||!s)&&t.push({from:e.from+r,insert:n+" "});let n=e.changes(t);return{changes:n,selection:e.selection.map(n,1)}}if(1!=t&&i.some(t=>t.comment>=0)){let t=[];for(let{line:e,comment:n,token:r}of i)if(n>=0){let i=e.from+n,s=i+r.length;" "==e.text[s-e.from]&&s++,t.push({from:i,to:s})}return{changes:t}}return null},0),d=u(g,0),p=u((t,e)=>g(t,e,function(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}(e)),0);function m(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}function g(t,e,n=e.selection.ranges){let i=n.map(t=>m(e,t.from).block);if(!i.every(t=>t))return null;let r=n.map((t,n)=>(function(t,{open:e,close:n},i,r){let s,o,l=t.sliceDoc(i-50,i),a=t.sliceDoc(r,r+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,u=l.length-h;if(l.slice(u-e.length,u)==e&&a.slice(c,c+n.length)==n)return{open:{pos:i-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-i<=100?s=o=t.sliceDoc(i,r):(s=t.sliceDoc(i,i+50),o=t.sliceDoc(r-50,r));let f=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-n.length;return s.slice(f,f+e.length)==e&&o.slice(p,p+n.length)==n?{open:{pos:i+f+e.length,margin:+!!/\s/.test(s.charAt(f+e.length))},close:{pos:r-d-n.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(e,i[n],t.from,t.to));if(2!=t&&!r.every(t=>t))return{changes:e.changes(n.map((t,e)=>r[e]?[]:[{from:t.from,insert:i[e].open+" "},{from:t.to,insert:" "+i[e].close}]))};if(1!=t&&r.some(t=>t)){let t=[];for(let e=0,n;e<r.length;e++)if(n=r[e]){let r=i[e],{open:s,close:o}=n;t.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:t}}return null}let v=a.YH.define(),b=a.YH.define(),y=a.sj.define(),w=a.sj.define({combine:t=>(0,a.QR)(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(n,i)=>t(n,i)||e(n,i)})}),x=a.sU.define({create:()=>L.empty,update(t,e){let n=e.state.facet(w),i=e.annotation(v);if(i){let r=M.fromTransaction(e,i.selection),s=i.side,o=0==s?t.undone:t.done;return o=r?D(o,o.length,n.minDepth,r):E(o,e.startState.selection),new L(0==s?i.rest:o,0==s?o:i.rest)}let r=e.annotation(b);if(("full"==r||"before"==r)&&(t=t.isolate()),!1===e.annotation(a.ZX.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let s=M.fromTransaction(e),o=e.annotation(a.ZX.time),l=e.annotation(a.ZX.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),("full"==r||"after"==r)&&(t=t.isolate()),t},toJSON:t=>({done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}),fromJSON:t=>new L(t.done.map(M.fromJSON),t.undone.map(M.fromJSON))});function k(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(x,!1);if(!r)return!1;let s=r.pop(t,n,e);return!!s&&(i(s),!0)}}let S=k(0,!1),C=k(1,!1),A=k(0,!0),O=k(1,!0);class M{constructor(t,e,n,i,r){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(t){return new M(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:null==(t=this.changes)?void 0:t.toJSON(),mapped:null==(e=this.mapped)?void 0:e.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new M(t.changes&&a.VR.fromJSON(t.changes),[],t.mapped&&a.Gu.fromJSON(t.mapped),t.startSelection&&a.OF.fromJSON(t.startSelection),t.selectionsAfter.map(a.OF.fromJSON))}static fromTransaction(t,e){let n=T;for(let e of t.startState.facet(y)){let i=e(t);i.length&&(n=n.concat(i))}return!n.length&&t.changes.empty?null:new M(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,T)}static selection(t){return new M(void 0,T,void 0,void 0,t)}}function D(t,e,n,i){let r=t.slice(e+1>n+20?e-n-1:0,e);return r.push(i),r}function P(t,e){return t.length?e.length?t.concat(e):t:e}let T=[];function E(t,e){if(!t.length)return[M.selection([e])];{let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),D(t,t.length-1,1e9,n.setSelAfter(i)))}}function R(t,e){if(!t.length)return t;let n=t.length,i=T;for(;n;){let r=function(t,e,n){let i=P(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):T,n);if(!t.changes)return M.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new M(r,a.Pe.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,n);return e[n-1]=r,e}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[M.selection(i)]:T}let B=/^(input\.type|delete)($|\.)/;class L{constructor(t,e,n=0,i){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(t,e,n,i,r){var s,o;let l,h,c=this.done,u=c[c.length-1];return new L(c=u&&u.changes&&!u.changes.empty&&t.changes&&(!n||B.test(n))&&(!u.selectionsAfter.length&&e-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,(s=u.changes,o=t.changes,l=[],h=!1,s.iterChangedRanges((t,e)=>l.push(t,e)),o.iterChangedRanges((t,e,n,i)=>{for(let t=0;t<l.length;){let e=l[t++],r=l[t++];i>=e&&n<=r&&(h=!0)}}),h))||"input.type.compose"==n)?D(c,c.length-1,i.minDepth,new M(t.changes.compose(u.changes),P(a.Pe.mapEffects(t.effects,u.changes),u.effects),u.mapped,u.startSelection,T)):D(c,c.length,i.minDepth,t),T,e,n)}addSelection(t,e,n,i){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:T;return s.length>0&&e-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(r=s[s.length-1],r.ranges.length==t.ranges.length&&0===r.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length)?this:new L(E(this.done,t),this.undone,e,n)}addMapping(t){return new L(R(this.done,t),R(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let i=0==t?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||e.selection;if(n&&r.selectionsAfter.length){let n,o;return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:v.of({side:t,rest:(n=i[i.length-1],(o=i.slice())[i.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let n=1==i.length?T:i.slice(0,i.length-1);return r.mapped&&(n=R(n,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:v.of({side:t,rest:n,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}}}L.empty=new L(T,T);function N(t,e){return a.OF.create(t.ranges.map(e),t.mainIndex)}function I(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function F({state:t,dispatch:e},n){let i=N(t.selection,n);return!i.eq(t.selection,!0)&&(e(I(t,i)),!0)}function j(t,e){return a.OF.cursor(e?t.to:t.from)}function _(t,e){return F(t,n=>n.empty?t.moveByChar(n,e):j(n,e))}function z(t){return t.textDirectionAt(t.state.selection.main.head)==l.OP.LTR}let V=t=>_(t,!z(t)),H=t=>_(t,z(t));function W(t,e){return F(t,n=>n.empty?t.moveByGroup(n,e):j(n,e))}function q(t,e,n){let i,r,s=(0,h.mv)(t).resolveInner(e.head),o=n?c.uY.closedBy:c.uY.openedBy;for(let i=e.head;;){let e=n?s.childAfter(i):s.childBefore(i);if(!e)break;!function(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}(t,e,o)?i=n?e.to:e.from:s=e}return r=s.type.prop(o)&&(i=n?(0,h.jU)(t,s.from,1):(0,h.jU)(t,s.to,-1))&&i.matched?n?i.end.to:i.end.from:n?s.to:s.from,a.OF.cursor(r,n?-1:1)}function U(t,e){return F(t,n=>{if(!n.empty)return j(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}"u">typeof Intl&&Intl.Segmenter;let $=t=>U(t,!1),K=t=>U(t,!0);function J(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,i=0,r;if(e){for(let e of t.state.facet(l.Lz.scrollMargins)){let r=e(t);(null==r?void 0:r.top)&&(n=Math.max(null==r?void 0:r.top,n)),(null==r?void 0:r.bottom)&&(i=Math.max(null==r?void 0:r.bottom,i))}r=t.scrollDOM.clientHeight-n-i}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function Y(t,e){let n,i=J(t),{state:r}=t,s=N(r.selection,n=>n.empty?t.moveVertically(n,e,i.height):j(n,e));if(s.eq(r.selection))return!1;if(i.selfScroll){let e=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),a=o.top+i.marginTop,h=o.bottom-i.marginBottom;e&&e.top>a&&e.bottom<h&&(n=l.Lz.scrollIntoView(s.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(I(r,s),{effects:n}),!0}let G=t=>Y(t,!1),Z=t=>Y(t,!0);function X(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&e.head!=i.from+n&&(r=a.OF.cursor(i.from+n))}return r}function Q(t,e){let n=N(t.state.selection,t=>{let n=e(t);return a.OF.range(t.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(t.state.selection)&&(t.dispatch(I(t.state,n)),!0)}function tt(t,e){return Q(t,n=>t.moveByChar(n,e))}let te=t=>tt(t,!z(t)),tn=t=>tt(t,z(t));function ti(t,e){return Q(t,n=>t.moveByGroup(n,e))}function tr(t,e){return Q(t,n=>t.moveVertically(n,e))}let ts=t=>tr(t,!1),to=t=>tr(t,!0);function tl(t,e){return Q(t,n=>t.moveVertically(n,e,J(t).height))}let ta=t=>tl(t,!1),th=t=>tl(t,!0),tc=({state:t,dispatch:e})=>(e(I(t,{anchor:0})),!0),tu=({state:t,dispatch:e})=>(e(I(t,{anchor:t.doc.length})),!0),tf=({state:t,dispatch:e})=>(e(I(t,{anchor:t.selection.main.anchor,head:0})),!0),td=({state:t,dispatch:e})=>(e(I(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function tp(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(i=>{let{from:r,to:s}=i;if(r==s){let o=e(i);o<r?(n="delete.backward",o=tm(t,o,!1)):o>r&&(n="delete.forward",o=tm(t,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=tm(t,r,!1),s=tm(t,s,!0);return r==s?{range:i}:{changes:{from:r,to:s},range:a.OF.cursor(r,r<i.head?-1:1)}});return!r.changes.empty&&(t.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?l.Lz.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function tm(t,e,n){if(t instanceof l.Lz)for(let i of t.state.facet(l.Lz.atomicRanges).map(e=>e(t)))i.between(e,e,(t,i)=>{t<e&&i>e&&(e=n?i:t)});return e}let tg=(t,e,n)=>tp(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),l,c;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(" "==l[l.length-1])return r-1;let t=(0,a.y$)(l,s.tabSize)%(0,h.tp)(s)||(0,h.tp)(s);for(let e=0;e<t&&" "==l[l.length-1-e];e++)r--;c=r}else(c=(0,a.zK)(o.text,r-o.from,e,e)+o.from)==r&&o.number!=(e?s.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,r-o.from))&&(c=(0,a.zK)(o.text,c-o.from,!1,!1)+o.from);return c}),tv=t=>tg(t,!1,!0),tb=t=>tg(t,!0,!1),ty=(t,e)=>tp(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let t=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=(0,a.zK)(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),c=o(h);if(null!=t&&c!=t)break;(" "!=h||i!=n.head)&&(t=c),i=l}return i}),tw=t=>ty(t,!1);function tx(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(i.empty||i.to!=s.from||(s=t.doc.lineAt(i.to-1)),n>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function tk(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let e of tx(t)){if(n?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(n?e.to+1:e.from-1),o=s.length+1;if(n)for(let n of(i.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak}),e.ranges))r.push(a.OF.range(Math.min(t.doc.length,n.anchor+o),Math.min(t.doc.length,n.head+o)));else for(let n of(i.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text}),e.ranges))r.push(a.OF.range(n.anchor-o,n.head-o))}return!!i.length&&(e(t.update({changes:i,scrollIntoView:!0,selection:a.OF.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function tS(t,e,n){if(t.readOnly)return!1;let i=[];for(let e of tx(t))n?i.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):i.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}let tC=tO(!1),tA=tO(!0);function tO(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:i,to:r}=n,s=e.doc.lineAt(i),o=!t&&i==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=(0,h.mv)(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(c.uY.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}(e,i);t&&(i=r=(r<=s.to?s:e.doc.lineAt(r)).to);let l=new h.KB(e,{simulateBreak:i,simulateDoubleBreak:!!o}),u=(0,h._v)(l,i);for(null==u&&(u=(0,a.y$)(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?{from:i,to:r}=o:i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let f=["",(0,h.EI)(e,u)];return o&&f.push((0,h.EI)(e,l.lineIndent(s.from,-1))),{changes:{from:i,to:r,insert:a.EY.of(f)},range:a.OF.cursor(i+1+f[1].length)}});return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function tM(t,e){let n=-1;return t.changeByRange(i=>{let r=[];for(let s=i.from;s<=i.to;){let o=t.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(e(o,r,i),n=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:a.OF.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}let tD=[{key:"Ctrl-b",run:V,shift:te,preventDefault:!0},{key:"Ctrl-f",run:H,shift:tn},{key:"Ctrl-p",run:$,shift:ts},{key:"Ctrl-n",run:K,shift:to},{key:"Ctrl-a",run:t=>F(t,e=>a.OF.cursor(t.lineBlockAt(e.head).from,1)),shift:t=>Q(t,e=>a.OF.cursor(t.lineBlockAt(e.head).from))},{key:"Ctrl-e",run:t=>F(t,e=>a.OF.cursor(t.lineBlockAt(e.head).to,-1)),shift:t=>Q(t,e=>a.OF.cursor(t.lineBlockAt(e.head).to))},{key:"Ctrl-d",run:tb},{key:"Ctrl-h",run:tv},{key:"Ctrl-k",run:t=>tp(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)})},{key:"Ctrl-Alt-h",run:tw},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:a.EY.of(["",""])},range:a.OF.cursor(t.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let n=e.from,i=t.doc.lineAt(n),r=n==i.from?n-1:(0,a.zK)(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:(0,a.zK)(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:s,insert:t.doc.slice(n,s).append(t.doc.slice(r,n))},range:a.OF.cursor(s)}});return!n.changes.empty&&(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Z}],tP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>F(t,e=>q(t.state,e,!z(t))),shift:t=>Q(t,e=>q(t.state,e,!z(t)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>F(t,e=>q(t.state,e,z(t))),shift:t=>Q(t,e=>q(t.state,e,z(t)))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>tk(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>tS(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>tk(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>tS(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=a.OF.create([n.main]):n.main.empty||(i=a.OF.create([a.OF.cursor(n.main.head)])),!!i&&(e(I(t,i)),!0)}},{key:"Mod-Enter",run:tA},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let n=tx(t).map(({from:e,to:n})=>a.OF.range(e,Math.min(n+1,t.doc.length)));return e(t.update({selection:a.OF.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let n=N(t.selection,e=>{let n=(0,h.mv)(t),i=n.resolveStack(e.from,1);if(e.empty){let t=n.resolveStack(e.from,-1);t.node.from>=i.node.from&&t.node.to<=i.node.to&&(i=t)}for(let t=i;t;t=t.next){let{node:n}=t;if((n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&t.next)return a.OF.range(n.to,n.from)}return e});return!n.eq(t.selection)&&(e(I(t,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(tM(t,(e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=(0,a.y$)(i,t.tabSize),s=0,o=(0,h.EI)(t,Math.max(0,r-(0,h.tp)(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(tM(t,(e,n)=>{n.push({from:e.from,insert:t.facet(h.Xt)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new h.KB(t,{overrideIndentation:t=>{let e=n[t];return null==e?-1:e}}),r=tM(t,(e,r,s)=>{let o=(0,h._v)(i,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],a=(0,h.EI)(t,o);(l!=a||s.from<e.from+l.length)&&(n[e.from]=o,r.push({from:e.from,to:e.from+l.length,insert:a}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(tx(e).map(({from:t,to:n})=>(t>0?t--:n<e.doc.length&&n++,{from:t,to:n}))),i=N(e.selection,e=>{let n;if(t.lineWrapping){let i=t.lineBlockAt(e.head),r=t.coordsAtPos(e.head,e.assoc||1);r&&(n=i.bottom+t.documentTop-r.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,n)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>{let n,i;return n=!1,i=N(t.selection,e=>{let i=(0,h.jU)(t,e.head,-1)||(0,h.jU)(t,e.head,1)||e.head>0&&(0,h.jU)(t,e.head-1,1)||e.head<t.doc.length&&(0,h.jU)(t,e.head+1,-1);if(!i||!i.end)return e;n=!0;let r=i.start.from==e.head?i.end.to:i.end.from;return a.OF.cursor(r)}),!!n&&(e(I(t,i)),!0)}},{key:"Mod-/",run:t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=m(t.state,n.from);return i.line?f(t):!!i.block&&p(t)}},{key:"Alt-A",run:d},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:V,shift:te,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>W(t,!z(t)),shift:t=>ti(t,!z(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>F(t,e=>X(t,e,!z(t))),shift:t=>Q(t,e=>X(t,e,!z(t))),preventDefault:!0},{key:"ArrowRight",run:H,shift:tn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>W(t,z(t)),shift:t=>ti(t,z(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>F(t,e=>X(t,e,z(t))),shift:t=>Q(t,e=>X(t,e,z(t))),preventDefault:!0},{key:"ArrowUp",run:$,shift:ts,preventDefault:!0},{mac:"Cmd-ArrowUp",run:tc,shift:tf},{mac:"Ctrl-ArrowUp",run:G,shift:ta},{key:"ArrowDown",run:K,shift:to,preventDefault:!0},{mac:"Cmd-ArrowDown",run:tu,shift:td},{mac:"Ctrl-ArrowDown",run:Z,shift:th},{key:"PageUp",run:G,shift:ta},{key:"PageDown",run:Z,shift:th},{key:"Home",run:t=>F(t,e=>X(t,e,!1)),shift:t=>Q(t,e=>X(t,e,!1)),preventDefault:!0},{key:"Mod-Home",run:tc,shift:tf},{key:"End",run:t=>F(t,e=>X(t,e,!0)),shift:t=>Q(t,e=>X(t,e,!0)),preventDefault:!0},{key:"Mod-End",run:tu,shift:td},{key:"Enter",run:tC,shift:tC},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:tv,shift:tv},{key:"Delete",run:tb},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tw},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>ty(t,!0)},{mac:"Mod-Backspace",run:t=>tp(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)})},{mac:"Mod-Delete",run:t=>tp(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)})}].concat(tD.map(t=>({mac:t.key,run:t.run,shift:t.shift}))));function tT(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?t.setAttribute(i,r):null!=r&&(t[i]=r)}e++}for(;e<arguments.length;e++)!function t(e,n){if("string"==typeof n)e.appendChild(document.createTextNode(n));else if(null==n);else if(null!=n.nodeType)e.appendChild(n);else if(Array.isArray(n))for(var i=0;i<n.length;i++)t(e,n[i]);else throw RangeError("Unsupported child node: "+n)}(t,arguments[e]);return t}let tE="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class tR{constructor(t,e,n=0,i=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(n,i),this.bufferStart=n,this.normalize=r?t=>r(tE(t)):tE,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return(0,a.vS)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=(0,a.MK)(t),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,a.Fh)(t);let i=this.normalize(e);if(i.length)for(let t=0,r=n;;t++){let s=i.charCodeAt(t),o=this.match(s,r,this.bufferPos+this.bufferStart);if(t==i.length-1){if(o)return this.value=o,this;break}r==n&&t<e.length&&e.charCodeAt(t)==s&&r++}}}match(t,e,n){let i=null;for(let e=0;e<this.matches.length;e+=2){let r=this.matches[e],s=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?i={from:this.matches[e+1],to:n}:(this.matches[e]++,s=!0)),s||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:n}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"u">typeof Symbol&&(tR.prototype[Symbol.iterator]=function(){return this});let tB={from:-1,to:-1,match:/.*/.exec("")},tL="gm"+(null==/x/.unicode?"":"u");class tN{constructor(t,e,n,i=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=tB,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new tj(t,e,n,i,r);this.re=new RegExp(e,tL+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=t.iter();let s=t.lineAt(i);this.curLineStart=s.from,this.matchPos=t_(t,i),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let n=this.curLineStart+e.index,i=n+e[0].length;if(this.matchPos=t_(this.text,i+ +(n==i)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,e)))return this.value={from:n,to:i,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}let tI=new WeakMap;class tF{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,n){let i=tI.get(t);if(!i||i.from>=n||i.to<=e){let i=new tF(e,t.sliceString(e,n));return tI.set(t,i),i}if(i.from==e&&i.to==n)return i;let{text:r,from:s}=i;return s>e&&(r=t.sliceString(e,s)+r,s=e),i.to<n&&(r+=t.sliceString(i.to,n)),tI.set(t,new tF(s,r)),new tF(e,r.slice(e-s,n-s))}}class tj{constructor(t,e,n,i,r){this.text=t,this.to=r,this.done=!1,this.value=tB,this.matchPos=t_(t,i),this.re=new RegExp(e,tL+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=tF.get(t,i,this.chunkEnd(i+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,n=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,n,e)))return this.value={from:t,to:n,match:e},this.matchPos=t_(this.text,n+ +(t==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=tF.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function t_(t,e){if(e>=t.length)return e;let n=t.lineAt(e),i;for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function tz(t){let e=tT("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!n)return;let{state:i}=t,r=i.doc.lineAt(i.selection.main.head),[,s,o,h,c]=n,u=h?+h.slice(1):0,f=o?+o:r.number;if(o&&c){let t=f/100;s&&(t=t*("-"==s?-1:1)+r.number/i.doc.lines),f=Math.round(i.doc.lines*t)}else o&&s&&(f=f*("-"==s?-1:1)+r.number);let d=i.doc.line(Math.max(1,Math.min(i.doc.lines,f))),p=a.OF.cursor(d.from+Math.max(0,Math.min(u,d.length)));t.dispatch({effects:[tV.of(!1),l.Lz.scrollIntoView(p.from,{y:"center"})],selection:p}),t.focus()}return{dom:tT("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:tV.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),n())},onsubmit:t=>{t.preventDefault(),n()}},tT("label",t.state.phrase("Go to line"),": ",e)," ",tT("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),tT("button",{name:"close",onclick:()=>{t.dispatch({effects:tV.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["\xd7"]))}}"u">typeof Symbol&&(tN.prototype[Symbol.iterator]=tj.prototype[Symbol.iterator]=function(){return this});let tV=a.Pe.define(),tH=a.sU.define({create:()=>!0,update(t,e){for(let n of e.effects)n.is(tV)&&(t=n.value);return t},provide:t=>l.S7.from(t,t=>t?tz:null)}),tW=l.Lz.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),tq={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},tU=a.sj.define({combine:t=>(0,a.QR)(t,tq,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})}),t$=l.NZ.mark({class:"cm-selectionMatch"}),tK=l.NZ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function tJ(t,e,n,i){return(0==n||t(e.sliceDoc(n-1,n))!=a.Je.Word)&&(i==e.doc.length||t(e.sliceDoc(i,i+1))!=a.Je.Word)}let tY=l.Z9.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(tU),{state:n}=t,i=n.selection;if(i.ranges.length>1)return l.NZ.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return l.NZ.none;let t=n.wordAt(r.head);if(!t)return l.NZ.none;o=n.charCategorizer(r.head),s=n.sliceDoc(t.from,t.to)}else{let t=r.to-r.from;if(t<e.minSelectionLength||t>200)return l.NZ.none;if(e.wholeWords){var h,c,u;if(s=n.sliceDoc(r.from,r.to),!(tJ(o=n.charCategorizer(r.head),n,r.from,r.to)&&(h=o,c=r.from,u=r.to,h(n.sliceDoc(c,c+1))==a.Je.Word&&h(n.sliceDoc(u-1,u))==a.Je.Word)))return l.NZ.none}else if(!(s=n.sliceDoc(r.from,r.to)))return l.NZ.none}let f=[];for(let i of t.visibleRanges){let t=new tR(n.doc,s,i.from,i.to);for(;!t.next().done;){let{from:i,to:s}=t.value;if((!o||tJ(o,n,i,s))&&(r.empty&&i<=r.from&&s>=r.to?f.push(tK.range(i,s)):(i>=r.to||s<=r.from)&&f.push(t$.range(i,s)),f.length>e.maxMatches))return l.NZ.none}}return l.NZ.set(f)}},{decorations:t=>t.decorations}),tG=l.Lz.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),tZ=a.sj.define({combine:t=>(0,a.QR)(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new eg(t),scrollToMatch:t=>l.Lz.scrollIntoView(t)})});class tX{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,tL),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new t8(this):new t1(this)}getCursor(t,e=0,n){let i=t.doc?t:a.$t.create({doc:t});return null==n&&(n=i.doc.length),this.regexp?t2(this,i,e,n):t0(this,i,e,n)}}class tQ{constructor(t){this.spec=t}}function t0(t,e,n,i){var r,s;return new tR(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?(r=e.doc,s=e.charCategorizer(e.selection.main.head),(t,e,n,i)=>((i>t||i+n.length<e)&&(i=Math.max(0,t-2),n=r.sliceString(i,Math.min(r.length,e+2))),(s(t4(n,t-i))!=a.Je.Word||s(t3(n,t-i))!=a.Je.Word)&&(s(t3(n,e-i))!=a.Je.Word||s(t4(n,e-i))!=a.Je.Word))):void 0)}class t1 extends tQ{constructor(t){super(t)}nextMatch(t,e,n){let i=t0(this.spec,t,n,t.doc.length).nextOverlapping();if(i.done){let n=Math.min(t.doc.length,e+this.spec.unquoted.length);i=t0(this.spec,t,0,n).nextOverlapping()}return i.done||i.value.from==e&&i.value.to==n?null:i.value}prevMatchInRange(t,e,n){for(let i=n;;){let n=Math.max(e,i-1e4-this.spec.unquoted.length),r=t0(this.spec,t,n,i),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(n==e)return null;i-=1e4}}prevMatch(t,e,n){let i=this.prevMatchInRange(t,0,e);return i||(i=this.prevMatchInRange(t,Math.max(0,n-this.spec.unquoted.length),t.doc.length)),i&&(i.from!=e||i.to!=n)?i:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let n=t0(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=t0(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function t2(t,e,n,i){var r;return new tN(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,n)=>!n[0].length||(r(t4(n.input,n.index))!=a.Je.Word||r(t3(n.input,n.index))!=a.Je.Word)&&(r(t3(n.input,n.index+n[0].length))!=a.Je.Word||r(t4(n.input,n.index+n[0].length))!=a.Je.Word)):void 0},n,i)}function t4(t,e){return t.slice((0,a.zK)(t,e,!1),e)}function t3(t,e){return t.slice(e,(0,a.zK)(t,e))}class t8 extends tQ{nextMatch(t,e,n){let i=t2(this.spec,t,n,t.doc.length).next();return i.done&&(i=t2(this.spec,t,0,e).next()),i.done?null:i.value}prevMatchInRange(t,e,n){for(let i=1;;i++){let r=Math.max(e,n-1e4*i),s=t2(this.spec,t,r,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,n){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,n,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(e,n)=>{if("&"==n)return t.match[0];if("$"==n)return"$";for(let e=n.length;e>0;e--){let i=+n.slice(0,e);if(i>0&&i<t.match.length)return t.match[i]+n.slice(e)}return e})}matchAll(t,e){let n=t2(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=t2(this.spec,t,Math.max(0,e-250),Math.min(n+250,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}let t5=a.Pe.define(),t9=a.Pe.define(),t6=a.sU.define({create:t=>new t7(ec(t).create(),null),update(t,e){for(let n of e.effects)n.is(t5)?t=new t7(n.value.create(),t.panel):n.is(t9)&&(t=new t7(t.query,n.value?eh:null));return t},provide:t=>l.S7.from(t,t=>t.panel)});class t7{constructor(t,e){this.query=t,this.panel=e}}let et=l.NZ.mark({class:"cm-searchMatch"}),ee=l.NZ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),en=l.Z9.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(t6))}update(t){let e=t.state.field(t6);(e!=t.startState.field(t6)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return l.NZ.none;let{view:n}=this,i=new a.vB;for(let e=0,r=n.visibleRanges,s=r.length;e<s;e++){let{from:o,to:l}=r[e];for(;e<s-1&&l>r[e+1].from-500;)l=r[++e].to;t.highlight(n.state,o,l,(t,e)=>{let r=n.state.selection.ranges.some(n=>n.from==t&&n.to==e);i.add(t,e,r?ee:et)})}return i.finish()}},{decorations:t=>t.decorations});function ei(t){return e=>{let n=e.state.field(t6,!1);return n&&n.query.spec.valid?t(e,n):ed(e)}}let er=ei((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=a.OF.single(i.from,i.to),s=t.state.facet(tZ);return t.dispatch({selection:r,effects:[ey(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),ef(t),!0}),es=ei((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=a.OF.single(r.from,r.to),o=t.state.facet(tZ);return t.dispatch({selection:s,effects:[ey(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),ef(t),!0}),eo=ei((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!!n&&!!n.length&&(t.dispatch({selection:a.OF.create(n.map(t=>a.OF.range(t.from,t.to))),userEvent:"select.search.matches"}),!0)}),el=ei((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let o=s,h=[],c,u,f=[];o.from==i&&o.to==r&&(u=n.toText(e.getReplacement(o)),h.push({from:o.from,to:o.to,insert:u}),o=e.nextMatch(n,o.from,o.to),f.push(l.Lz.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let d=t.state.changes(h);return o&&(c=a.OF.single(o.from,o.to).map(d),f.push(ey(t,o)),f.push(n.facet(tZ).scrollToMatch(c.main,t))),t.dispatch({changes:d,selection:c,effects:f,userEvent:"input.replace"}),!0}),ea=ei((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(t=>{let{from:n,to:i}=t;return{from:n,to:i,insert:e.getReplacement(t)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:l.Lz.announce.of(i),userEvent:"input.replace.all"}),!0});function eh(t){return t.state.facet(tZ).createPanel(t)}function ec(t,e){var n,i,r,s,o;let l=t.selection.main,a=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=t.facet(tZ);return new tX({search:(null!=(n=null==e?void 0:e.literal)?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!=(i=null==e?void 0:e.caseSensitive)?i:h.caseSensitive,literal:null!=(r=null==e?void 0:e.literal)?r:h.literal,regexp:null!=(s=null==e?void 0:e.regexp)?s:h.regexp,wholeWord:null!=(o=null==e?void 0:e.wholeWord)?o:h.wholeWord})}function eu(t){let e=(0,l.ld)(t,eh);return e&&e.dom.querySelector("[main-field]")}function ef(t){let e=eu(t);e&&e==t.root.activeElement&&e.select()}let ed=t=>{let e=t.state.field(t6,!1);if(e&&e.panel){let n=eu(t);if(n&&n!=t.root.activeElement){let i=ec(t.state,e.query.spec);i.valid&&t.dispatch({effects:t5.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[t9.of(!0),e?t5.of(ec(t.state,e.query.spec)):a.Pe.appendConfig.of(ex)]});return!0},ep=t=>{let e=t.state.field(t6,!1);if(!e||!e.panel)return!1;let n=(0,l.ld)(t,eh);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:t9.of(!1)}),!0},em=[{key:"Mod-f",run:ed,scope:"editor search-panel"},{key:"F3",run:er,shift:es,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:er,shift:es,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ep,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let e=new tR(t.doc,t.sliceDoc(i,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==i&&(o=s.length),s.push(a.OF.range(e.value.from,e.value.to))}return e(t.update({selection:a.OF.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=(0,l.ld)(t,tz);if(!e){let n=[tV.of(!0)];null==t.state.field(tH,!1)&&n.push(a.Pe.appendConfig.of([tH,tW])),t.dispatch({effects:n}),e=(0,l.ld)(t,tz)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(t=>t.from===t.to))return(({state:t,dispatch:e})=>{let{selection:n}=t,i=a.OF.create(n.ranges.map(e=>t.wordAt(e.head)||a.OF.cursor(e.head)),n.mainIndex);return!i.eq(n)&&(e(t.update({selection:i})),!0)})({state:t,dispatch:e});let i=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=i))return!1;let r=function(t,e){let{main:n,ranges:i}=t.selection,r=t.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new tR(t.doc,e,i[i.length-1].to);;)if(r.next(),r.done){if(n)return null;r=new tR(t.doc,e,0,Math.max(0,i[i.length-1].from-1)),n=!0}else{if(n&&i.some(t=>t.from==r.value.from))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}}(t,i);return!!r&&(e(t.update({selection:t.selection.addRange(a.OF.range(r.from,r.to),!1),effects:l.Lz.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class eg{constructor(t){this.view=t;let e=this.query=t.state.field(t6).query.spec;function n(t,e,n){return tT("button",{class:"cm-button",name:t,onclick:e,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=tT("input",{value:e.search,placeholder:ev(t,"Find"),"aria-label":ev(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=tT("input",{value:e.replace,placeholder:ev(t,"Replace"),"aria-label":ev(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=tT("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=tT("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=tT("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=tT("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,n("next",()=>er(t),[ev(t,"next")]),n("prev",()=>es(t),[ev(t,"previous")]),n("select",()=>eo(t),[ev(t,"all")]),tT("label",null,[this.caseField,ev(t,"match case")]),tT("label",null,[this.reField,ev(t,"regexp")]),tT("label",null,[this.wordField,ev(t,"by word")]),...t.state.readOnly?[]:[tT("br"),this.replaceField,n("replace",()=>el(t),[ev(t,"replace")]),n("replaceAll",()=>ea(t),[ev(t,"replace all")])],tT("button",{name:"close",onclick:()=>ep(t),"aria-label":ev(t,"close"),type:"button"},["\xd7"])])}commit(){let t=new tX({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:t5.of(t)}))}keydown(t){(0,l.TS)(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?es:er)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),el(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(t5)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tZ).top}}function ev(t,e){return t.state.phrase(e)}let eb=/[\s\.,:;?!]/;function ey(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-30),o=Math.min(r,n+30),a=t.state.sliceDoc(s,o);if(s!=i.from){for(let t=0;t<30;t++)if(!eb.test(a[t+1])&&eb.test(a[t])){a=a.slice(t);break}}if(o!=r){for(let t=a.length-1;t>a.length-30;t--)if(!eb.test(a[t-1])&&eb.test(a[t])){a=a.slice(0,t);break}}return l.Lz.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${i.number}.`)}let ew=l.Lz.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ex=[t6,a.Nb.low(en),ew];var ek=n(547);class eS{constructor(t,e,n){this.from=t,this.to=e,this.diagnostic=n}}class eC{constructor(t,e,n){this.diagnostics=t,this.panel=e,this.selected=n}static init(t,e,n){let i=n.facet(eL).markerFilter;i&&(t=i(t,n));let r=t.slice().sort((t,e)=>t.from-e.from||t.to-e.to),s=new a.vB,o=[],h=0;for(let t=0;;){let e,i,a=t==r.length?null:r[t];if(!a&&!o.length)break;for(o.length?(e=h,i=o.reduce((t,e)=>Math.min(t,e.to),a&&a.from>e?a.from:1e8)):(e=a.from,i=a.to,o.push(a),t++);t<r.length;){let n=r[t];if(n.from==e&&(n.to>n.from||n.to==e))o.push(n),t++,i=Math.min(n.to,i);else{i=Math.min(n.from,i);break}}let c=function(t){let e="hint",n=1;for(let r of t){var i;let t="error"==(i=r.severity)?4:"warning"==i?3:"info"==i?2:1;t>n&&(n=t,e=r.severity)}return e}(o);if(o.some(t=>t.from==t.to||t.from==t.to-1&&n.doc.lineAt(t.from).to==t.from))s.add(e,e,l.NZ.widget({widget:new eF(c),diagnostics:o.slice()}));else{let t=o.reduce((t,e)=>e.markClass?t+" "+e.markClass:t,"");s.add(e,i,l.NZ.mark({class:"cm-lintRange cm-lintRange-"+c+t,diagnostics:o.slice(),inclusiveEnd:o.some(t=>t.to>i)}))}h=i;for(let t=0;t<o.length;t++)o[t].to<=h&&o.splice(t--,1)}let c=s.finish();return new eC(c,e,eA(c))}}function eA(t,e=null,n=0){let i=null;return t.between(n,1e9,(t,n,{spec:r})=>{if(!(e&&0>r.diagnostics.indexOf(e)))if(i){if(0>r.diagnostics.indexOf(i.diagnostic))return!1;i=new eS(i.from,n,i.diagnostic)}else i=new eS(t,n,e||r.diagnostics[0])}),i}function eO(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(eL).hideOn(t,n,i);if(null!=r)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(t=>t.is(eM))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}let eM=a.Pe.define(),eD=a.Pe.define(),eP=a.Pe.define(),eT=a.sU.define({create:()=>new eC(l.NZ.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);i=eA(n,t.selected.diagnostic,r)||eA(n,null,r)}!n.size&&r&&e.state.facet(eL).autoPanel&&(r=null),t=new eC(n,r,i)}for(let n of e.effects)if(n.is(eM)){let i=e.state.facet(eL).autoPanel?n.value.length?e_.open:null:t.panel;t=eC.init(n.value,i,e.state)}else n.is(eD)?t=new eC(t.diagnostics,n.value?e_.open:null,t.selected):n.is(eP)&&(t=new eC(t.diagnostics,t.panel,n.value));return t},provide:t=>[l.S7.from(t,t=>t.panel),l.Lz.decorations.from(t,t=>t.diagnostics)]}),eE=l.NZ.mark({class:"cm-lintRange cm-lintRange-active"}),eR=t=>{let e=t.state.field(eT,!1);return!!e&&!!e.panel&&(t.dispatch({effects:eD.of(!1)}),!0)},eB=[{key:"Mod-Shift-m",run:t=>{var e,n;let i=t.state.field(eT,!1);i&&i.panel||t.dispatch({effects:(e=t.state,n=[eD.of(!0)],e.field(eT,!1)?n:n.concat(a.Pe.appendConfig.of(eW)))});let r=(0,l.ld)(t,e_.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(eT,!1);if(!e)return!1;let n=t.state.selection.main,i=e.diagnostics.iter(n.to+1);return(!!i.value||!!(i=e.diagnostics.iter(0)).value&&(i.from!=n.from||i.to!=n.to))&&(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],eL=a.sj.define({combine:t=>Object.assign({sources:t.map(t=>t.source).filter(t=>null!=t)},(0,a.QR)(t.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?n=>t(n)||e(n):t:e}))});function eN(t){let e=[];if(t)t:for(let{name:n}of t){for(let t=0;t<n.length;t++){let i=n[t];if(/[a-zA-Z]/.test(i)&&!e.some(t=>t.toLowerCase()==i.toLowerCase())){e.push(i);continue t}}e.push("")}return e}function eI(t,e,n){var i;let r=n?eN(e.actions):[];return tT("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},tT("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null==(i=e.actions)?void 0:i.map((n,i)=>{let s=!1,o=i=>{if(i.preventDefault(),s)return;s=!0;let r=eA(t.state.field(eT).diagnostics,e);r&&n.apply(t,r.from,r.to)},{name:l}=n,a=r[i]?l.indexOf(r[i]):-1,h=a<0?l:[l.slice(0,a),tT("u",l.slice(a,a+1)),l.slice(a+1)];return tT("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${l}${a<0?"":` (access key "${r[i]})"`}.`},h)}),e.source&&tT("div",{class:"cm-diagnosticSource"},e.source))}class eF extends l.xO{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return tT("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ej{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=eI(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class e_{constructor(t){this.view=t,this.items=[];let e=e=>{if(27==e.keyCode)eR(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65)||!(e.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],i=eN(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=eA(this.view.state.field(eT).diagnostics,n);e&&n.actions[r].apply(t,e.from,e.to)}}e.preventDefault()},n=t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)};this.list=tT("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:n}),this.dom=tT("div",{class:"cm-panel-lint"},this.list,tT("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>eR(this.view)},"\xd7")),this.update()}get selectedIndex(){let t=this.view.state.field(eT).selected;if(!t)return -1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return -1}update(){let{diagnostics:t,selected:e}=this.view.state.field(eT),n=0,i=!1,r=null,s=new Set;for(t.between(0,this.view.state.doc.length,(t,o,{spec:l})=>{for(let t of l.diagnostics){if(s.has(t))continue;s.add(t);let o=-1,l;for(let e=n;e<this.items.length;e++)if(this.items[e].diagnostic==t){o=e;break}o<0?(l=new ej(this.view,t),this.items.splice(n,0,l),i=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),i=!0)),e&&l.diagnostic==e.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),r=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new ej(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let n=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/n:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;t!=n.dom;)e();t=n.dom.nextSibling}else this.list.insertBefore(n.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=eA(this.view.state.field(eT).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:eP.of(e)})}static open(t){return new e_(t)}}function ez(t){return function(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}let eV=l.Lz.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ez("#d11")},".cm-lintRange-warning":{backgroundImage:ez("orange")},".cm-lintRange-info":{backgroundImage:ez("#999")},".cm-lintRange-hint":{backgroundImage:ez("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});l.wJ;let eH=a.Pe.define(),eW=[eT,l.Lz.decorations.compute([eT],t=>{let{selected:e,panel:n}=t.field(eT);return e&&n&&e.from!=e.to?l.NZ.set([eE.range(e.from,e.to)]):l.NZ.none}),(0,l.Ux)(function(t,e,n){let{diagnostics:i}=t.state.field(eT),r,s=-1,o=-1;i.between(e-(n<0),e+ +(n>0),(t,i,{spec:l})=>{if(e>=t&&e<=i&&(t==i||(e>t||n>0)&&(e<i||n<0)))return r=l.diagnostics,s=t,o=i,!1});let l=t.state.facet(eL).tooltipFilter;return(r&&l&&(r=l(r,t.state)),r)?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>{var e;return{dom:(e=t,tT("ul",{class:"cm-tooltip-lint"},r.map(t=>eI(e,t,!1))))}}}:null},{hideOn:eO}),eV],eq=[(0,l.$K)(),(0,l.Wu)(),(0,l.N$)(),function(t={}){return[x,w.of(t),l.Lz.domEventHandlers({beforeinput(t,e){let n="historyUndo"==t.inputType?S:"historyRedo"==t.inputType?C:null;return!!n&&(t.preventDefault(),n(e))}})]}(),(0,h.Lv)(),(0,l.VH)(),(0,l.A)(),a.$t.allowMultipleSelections.of(!0),(0,h.WD)(),(0,h.y9)(h.Zt,{fallback:!0}),(0,h.SG)(),(0,ek.wm)(),(0,ek.yU)(),(0,l.D4)(),(0,l.HJ)(),(0,l.dz)(),[tG,tY],l.w4.of([...ek.Bc,...tP,...em,{key:"Mod-z",run:S,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:C,preventDefault:!0},{linux:"Ctrl-Shift-z",run:C,preventDefault:!0},{key:"Mod-u",run:A,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:O,preventDefault:!0},...h.f7,...ek.OO,...eB])],eU=a.YH.define(),e$=a.sj.define();class eK{constructor(t,e,n,i,r){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(t){return new eK(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:null==(t=this.changes)?void 0:t.toJSON(),mapped:null==(e=this.mapped)?void 0:e.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new eK(t.changes&&a.VR.fromJSON(t.changes),[],t.mapped&&a.Gu.fromJSON(t.mapped),t.startSelection&&a.OF.fromJSON(t.startSelection),t.selectionsAfter.map(a.OF.fromJSON))}static fromTransaction(t,e){let n=eG;for(let e of t.startState.facet(e$)){let i=e(t);i.length&&(n=n.concat(i))}return!n.length&&t.changes.empty?null:new eK(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,eG)}static selection(t){return new eK(void 0,eG,void 0,void 0,t)}}function eJ(t,e,n,i){let r=t.slice(e+1>n+20?e-n-1:0,e);return r.push(i),r}function eY(t,e){return t.length?e.length?t.concat(e):t:e}let eG=[];function eZ(t,e){if(!t.length)return t;let n=t.length,i=eG;for(;n;){let r=function(t,e,n){let i=eY(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):eG,n);if(!t.changes)return eK.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new eK(r,a.Pe.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,n);return e[n-1]=r,e}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[eK.selection(i)]:eG}let eX=/^(input\.type|delete)($|\.)/;class eQ{constructor(t,e,n=0,i){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new eQ(this.done,this.undone):this}addChanges(t,e,n,i,r){var s,o;let l,h,c=this.done,u=c[c.length-1];return new eQ(c=u&&u.changes&&!u.changes.empty&&t.changes&&(!n||eX.test(n))&&(!u.selectionsAfter.length&&e-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,(s=u.changes,o=t.changes,l=[],h=!1,s.iterChangedRanges((t,e)=>l.push(t,e)),o.iterChangedRanges((t,e,n,i)=>{for(let t=0;t<l.length;){let e=l[t++],r=l[t++];i>=e&&n<=r&&(h=!0)}}),h))||"input.type.compose"==n)?eJ(c,c.length-1,i.minDepth,new eK(t.changes.compose(u.changes),eY(a.Pe.mapEffects(t.effects,u.changes),u.effects),u.mapped,u.startSelection,eG)):eJ(c,c.length,i.minDepth,t),eG,e,n)}addSelection(t,e,n,i){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:eG;return s.length>0&&e-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(r=s[s.length-1],r.ranges.length==t.ranges.length&&0===r.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length)?this:new eQ(function(t,e){if(!t.length)return[eK.selection([e])];{let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),eJ(t,t.length-1,1e9,n.setSelAfter(i)))}}(this.done,t),this.undone,e,n)}addMapping(t){return new eQ(eZ(this.done,t),eZ(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let i=0==t?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):e.selection);if(n&&r.selectionsAfter.length){let n,o;return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:eU.of({side:t,rest:(n=i[i.length-1],(o=i.slice())[i.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let n=1==i.length?eG:i.slice(0,i.length-1);return r.mapped&&(n=eZ(n,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:eU.of({side:t,rest:n,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}}}eQ.empty=new eQ(eG,eG),"u">typeof Intl&&Intl.Segmenter;var e0=n(909),e1=n(581);function e2(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e4(t,e,n,i,r,s,o){try{var l=t[s](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function e3(){var t,e,n=(t=["\n display: flex;\n width: 100%;\n\n .cm-editor {\n width: 100%;\n border-radius: ","px;\n border: 1px solid ",";\n &:hover {\n border-color: ",";\n }\n overflow: hidden;\n\n &.cm-focused {\n border-color: ",";\n outline: none;\n }\n\n .cm-content {\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n }\n }\n "],e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}})));return e3=function(){return n},n}var e8=(0,s.createStyles)(function(t){var e=t.token;return{box:(0,t.css)(e3(),e.borderRadius,e.colorBorder,e.colorPrimaryHover,e.colorPrimaryHover)}}),e5=l.Lz.theme({".cm-scroller":{backgroundColor:"#f0f0f0"}}),e9=l.Lz.theme({".cm-scroller":{backgroundColor:"#fff"}});function e6(t){return t&&"auto"!==t?l.Lz.theme({"&":{height:t,minHeight:"120px"},".cm-editor":{height:"100%",minHeight:"120px"},".cm-scroller":{height:"100%",minHeight:"120px",overflow:"auto"}}):l.Lz.theme({"&":{minHeight:"120px"},".cm-editor":{minHeight:"120px"},".cm-scroller":{minHeight:"120px"}})}function e7(t){var e,n,s=t.language,o=t.height,c=t.indentUnit,u=function(t,e){if(null==t)return{};var n,i,r,s={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,n=Reflect.ownKeys(Object(t));r<n.length;r++)i=n[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(s[i]=t[i]);return s}if(s=function(t,e){if(null==t)return{};var n,i,r={},s=Object.getOwnPropertyNames(t);for(i=0;i<s.length;i++)n=s[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n]);return r}(t,e),Object.getOwnPropertySymbols)for(r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i=n[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(s[i]=t[i]);return s}(t,["language","height","indentUnit"]),f=u.value,d=u.onChange,p=u.disabled,m=e8().styles,g=function(t){if(Array.isArray(t))return t}(e=(0,i.useState)(null))||function(t){var e,n,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r=[],s=!0,o=!1;try{for(i=i.call(t);!(s=(e=i.next()).done)&&(r.push(e.value),2!==r.length);s=!0);}catch(t){o=!0,n=t}finally{try{s||null==i.return||i.return()}finally{if(o)throw n}}return r}}(e)||function(t){if(t){if("string"==typeof t)return e2(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return e2(t,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),v=g[0],b=g[1],y=(0,i.useRef)(null),w=(0,i.useRef)(null),x=(0,i.useRef)(d);x.current=d;var k=(0,i.useRef)(2),S=(0,i.useRef)(new a.xx).current,C=(0,i.useRef)(new a.xx).current,A=(0,i.useRef)(new a.xx).current,O=(0,i.useRef)(new a.xx).current,M=(0,i.useRef)(new a.xx).current,D=(0,i.useRef)(new a.xx).current,P=(0,i.useRef)(new a.xx).current,T=!Number.isFinite(n=Number(c))||n<=0?2:Math.floor(n);k.current=T;var E=function(){return a.Nb.highest(l.w4.of([{key:"Tab",run:function(t){if(!t.state.facet(l.Lz.editable))return!1;var e=" ".repeat(k.current),n=t.state.changeByRange(function(t){return{changes:{from:t.from,to:t.to,insert:e},range:a.OF.cursor(t.from+e.length)}});return t.dispatch(n),!0}},{key:"Shift-Tab",run:function(t){return(({state:t,dispatch:e})=>{var n;let i;return!t.readOnly&&(e(t.update((n=(e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=(0,a.y$)(i,t.tabSize),s=0,o=(0,h.EI)(t,Math.max(0,r-(0,h.tp)(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})},i=-1,t.changeByRange(e=>{let r=[];for(let s=e.from;s<=e.to;){let o=t.doc.lineAt(s);o.number>i&&(e.empty||e.to>o.from)&&(n(o,r,e),i=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:a.OF.range(s.mapPos(e.anchor,1),s.mapPos(e.head,1))}})),{userEvent:"delete.dedent"})),!0)})(t)}}]))};return(0,i.useEffect)(function(){var t;(t=function(){return function(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(o,"next",{value:a(0)}),l(o,"throw",{value:a(1)}),l(o,"return",{value:a(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function a(l){return function(a){var h=[l,a];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&h[0]?i.return:h[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,h[1])).done)return r;switch(i=0,r&&(h=[2&h[0],r.value]),h[0]){case 0:case 1:r=h;break;case 4:return s.label++,{value:h[1],done:!1};case 5:s.label++,i=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===h[0]||2===h[0])){s=0;continue}if(3===h[0]&&(!r||h[1]>r[0]&&h[1]<r[3])){s.label=h[1];break}if(6===h[0]&&s.label<r[1]){s.label=r[1],r=h;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(h);break}r[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(t){h=[6,t],i=0}finally{n=r=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}}(this,function(t){return e0.V[s]?[2,e0.V[s].load()]:(console.warn("Language ".concat(s," not supported.")),[2,null])})},function(){var e=this,n=arguments;return new Promise(function(i,r){var s=t.apply(e,n);function o(t){e4(s,i,r,o,l,"next",t)}function l(t){e4(s,i,r,o,l,"throw",t)}o(void 0)})})().then(function(t){b(t)}).catch(function(t){console.error("Error loading language:",t)})},[s]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:[C.reconfigure(e1.indentUnit.of(" ".repeat(T))),A.reconfigure(a.$t.tabSize.of(T)),O.reconfigure(E())]})},[T,C,O,A]),(0,i.useEffect)(function(){if(y.current&&!w.current){var t=a.$t.create({doc:f||"",extensions:[eq,S.of(v||[]),C.of(e1.indentUnit.of(" ".repeat(T))),A.of(a.$t.tabSize.of(T)),O.of(E()),M.of(l.Lz.editable.of(!p)),D.of(p?e5:e9),P.of(e6(o)),l.Lz.updateListener.of(function(t){if(t.docChanged){var e;null==(e=x.current)||e.call(x,t.state.doc.toString())}})]}),e=new l.Lz({state:t,parent:y.current});return w.current=e,function(){e.destroy(),w.current=null}}},[]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:S.reconfigure(v||[])})},[v,S]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:M.reconfigure(l.Lz.editable.of(!p))})},[p,M]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:D.reconfigure(p?e5:e9)})},[p,D]),(0,i.useEffect)(function(){w.current&&w.current.dispatch({effects:P.reconfigure(e6(o))})},[o,P]),(0,i.useEffect)(function(){var t=w.current;if(t){var e=f||"";t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}},[f]),r().createElement("div",{className:m.box},r().createElement("div",{ref:y,style:{width:"100%"}}))}var nt=(0,o.connect)(e7,(0,o.mapReadPretty)(function(t){var e,n;return r().createElement(e7,(e=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},t),n=n={disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e))}))},909:function(t,e,n){function i(t,e,n,i,r,s,o){try{var l=t[s](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function r(t){return function(){var e=this,n=arguments;return new Promise(function(r,s){var o=t.apply(e,n);function l(t){i(o,r,s,l,a,"next",t)}function a(t){i(o,r,s,l,a,"throw",t)}l(void 0)})}}function s(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(o,"next",{value:a(0)}),l(o,"throw",{value:a(1)}),l(o,"return",{value:a(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function a(l){return function(a){var h=[l,a];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&h[0]?i.return:h[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,h[1])).done)return r;switch(i=0,r&&(h=[2&h[0],r.value]),h[0]){case 0:case 1:r=h;break;case 4:return s.label++,{value:h[1],done:!1};case 5:s.label++,i=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===h[0]||2===h[0])){s=0;continue}if(3===h[0]&&(!r||h[1]>r[0]&&h[1]<r[3])){s.label=h[1];break}if(6===h[0]&&s.label<r[1]){s.label=r[1],r=h;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(h);break}r[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(t){h=[6,t],i=0}finally{n=r=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}}n.d(e,{V:function(){return l},X:function(){return o}});var o=[{value:"javascript",label:"JavaScript",load:function(){return r(function(){return s(this,function(t){switch(t.label){case 0:return[4,Promise.all([n.e("214"),n.e("176")]).then(n.bind(n,187))];case 1:return[2,(0,t.sent().javascript)()]}})})()}},{value:"java",label:"Java",load:function(){return r(function(){return s(this,function(t){switch(t.label){case 0:return[4,Promise.all([n.e("214"),n.e("299")]).then(n.bind(n,982))];case 1:return[2,(0,t.sent().java)()]}})})()}},{value:"sql",label:"SQL",load:function(){return r(function(){return s(this,function(t){switch(t.label){case 0:return[4,Promise.all([n.e("214"),n.e("613")]).then(n.bind(n,124))];case 1:return[2,(0,t.sent().sql)()]}})})()}},{value:"python",label:"Python",load:function(){return r(function(){return s(this,function(t){switch(t.label){case 0:return[4,Promise.all([n.e("214"),n.e("707")]).then(n.bind(n,374))];case 1:return[2,(0,t.sent().python)()]}})})()}},{value:"groovy",label:"Groovy",load:function(){return r(function(){var t,e;return s(this,function(i){switch(i.label){case 0:return[4,Promise.resolve().then(n.bind(n,581))];case 1:return t=i.sent().StreamLanguage,[4,n.e("815").then(n.bind(n,922))];case 2:return e=i.sent().groovy,[2,t.define(e)]}})})()}}],l=Object.fromEntries(o.map(function(t){return[t.value,t]}))},230:function(e){e.exports=t},342:function(t){t.exports=r},694:function(t){t.exports=e},59:function(t){t.exports=i},235:function(t){t.exports=s},155:function(t){t.exports=n},547:function(t,e,n){n.d(e,{Ar:function(){return h},Bc:function(){return ty},Gw:function(){return tl},OO:function(){return tA},et:function(){return a},wm:function(){return td},yU:function(){return tC}});var i=n(492),r=n(867),s=n(169);class o{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,s.mv)(this.state).resolveInner(this.pos,-1);for(;e&&0>t.indexOf(e.name);)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),r=i.search(f(t,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,n){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function l(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function a(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[n,i]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let t=1;t<i.length;t++)n[i[t]]=!0}let i=l(e)+l(n)+"*$";return[RegExp("^"+i),new RegExp(i)]}(e);return t=>{let r=t.matchBefore(i);return r||t.explicit?{from:r?r.from:t.pos,options:e,validFor:n}:null}}function h(t,e){return n=>{for(let e=(0,s.mv)(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class c{constructor(t,e,n,i){this.completion=t,this.source=e,this.match=n,this.score=i}}function u(t){return t.selection.main.from}function f(t,e){var n;let{source:i}=t,r=e&&"^"!=i[0],s="$"!=i[i.length-1];return r||s?RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,null!=(n=t.flags)?n:t.ignoreCase?"i":""):t}let d=i.YH.define(),p=new WeakMap;function m(t){if(!Array.isArray(t))return t;let e=p.get(t);return e||p.set(t,e=a(t)),e}let g=i.Pe.define(),v=i.Pe.define();class b{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let n=(0,i.vS)(t,e),r=(0,i.Fh)(n);this.chars.push(n);let s=t.slice(e,e+r),o=s.toUpperCase();this.folded.push((0,i.vS)(o==s?s.toLowerCase():o,0)),e+=r}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:n,any:r,precise:s,byWord:o}=this;if(1==e.length){let r=(0,i.vS)(t,0),s=(0,i.Fh)(r),o=s==t.length?0:-100;if(r==e[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,s])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,h=0;if(l<0){for(let s=0,o=Math.min(t.length,200);s<o&&h<a;){let o=(0,i.vS)(t,s);(o==e[h]||o==n[h])&&(r[h++]=s),s+=(0,i.Fh)(o)}if(h<a)return null}let c=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(t),v=!0;for(let r=0,h=Math.min(t.length,200),b=0;r<h&&u<a;){let h=(0,i.vS)(t,r);l<0&&(c<a&&h==e[c]&&(s[c++]=r),d<a&&(h==e[d]||h==n[d]?(0==d&&(p=r),m=r+1,d++):d=0));let y,w=h<255?h>=48&&h<=57||h>=97&&h<=122?2:+(h>=65&&h<=90):(y=(0,i.MK)(h))!=y.toLowerCase()?1:2*(y!=y.toUpperCase());(!r||1==w&&g||0==b&&0!=w)&&(e[u]==h||n[u]==h&&(f=!0)?o[u++]=r:o.length&&(v=!1)),b=w,r+=(0,i.Fh)(h)}return u==a&&0==o[0]&&v?this.result(-100+(f?-200:0),o,t):d==a&&0==p?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==a?this.ret(-900-t.length,[p,m]):u==a?this.result(-100+(f?-200:0)+-700+(v?0:-1100),o,t):2==e.length?null:this.result((r[0]?-700:0)+-200+-1100,r,t)}result(t,e,n){let r=[],s=0;for(let t of e){let e=t+(this.astral?(0,i.Fh)((0,i.vS)(n,t)):1);s&&r[s-1]==t?r[s-1]=e:(r[s++]=t,r[s++]=e)}return this.ret(t-n.length,r)}}class y{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}let w=i.sj.define({combine:t=>(0,i.QR)(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:k,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>x(t(n),e(n)),optionClass:(t,e)=>n=>x(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function x(t,e){return t?e?t+" "+e:t:e}function k(t,e,n,i,s,o){let l=t.textDirection==r.OP.RTL,a=l,h=!1,c="top",u,f,d=e.left-s.left,p=s.right-e.right,m=i.right-i.left,g=i.bottom-i.top;if(a&&d<Math.min(m,p)?a=!1:!a&&p<Math.min(m,d)&&(a=!0),m<=(a?d:p))u=Math.max(s.top,Math.min(n.top,s.bottom-g))-e.top,f=Math.min(400,a?d:p);else{h=!0,f=Math.min(400,(l?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=g||t>e.top?u=n.bottom-e.top:(c="bottom",u=e.bottom-n.top)}let v=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/v}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":a?"left":"right")}}function S(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class C{constructor(t,e,n){this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let i=t.state.field(e),{options:r,selected:s}=i.open,o=t.state.facet(w);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map(t=>"cm-completionIcon-"+t)),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let s=t.displayLabel||t.label,o=0;for(let t=0;t<i.length;){let e=i[t++],n=i[t++];e>o&&r.appendChild(document.createTextNode(s.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(e,n))),l.className="cm-completionMatchedText",o=n}return o<s.length&&r.appendChild(document.createTextNode(s.slice(o))),r},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((t,e)=>t.position-e.position).map(t=>t.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=S(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=t.state.field(e).open;for(let e=n.target,r;e&&e!=this.dom;e=e.parentNode)if("LI"==e.nodeName&&(r=/-(\d+)$/.exec(e.id))&&+r[1]<i.length){this.applyCompletion(t,i[+r[1]]),n.preventDefault();return}}),this.dom.addEventListener("focusout",e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(w).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:v.of(null)})}),this.showOptions(r,i.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let n=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=i){let{options:r,selected:s,disabled:o}=n.open;i.open&&i.open.options==r||(this.range=S(r.length,s,t.state.facet(w).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),o!=(null==(e=i.open)?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=S(e.options.length,e.selected,this.view.state.facet(w).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:i}=n;if(!i)return;let s="string"==typeof i?document.createTextNode(i):i(n);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)}).catch(t=>(0,r.c_)(this.view.state,t,"completion info")):this.addInfoPane(s,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:i}=t;n.appendChild(e),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){var e,n;let i,r,s,o=null;for(let e=this.list.firstChild,n=this.range.from;e;e=e.nextSibling,n++)"LI"==e.nodeName&&e.id?n==t?e.hasAttribute("aria-selected")||(e.setAttribute("aria-selected","true"),o=e):e.hasAttribute("aria-selected")&&e.removeAttribute("aria-selected"):n--;return o&&(e=this.list,n=o,i=e.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.height/e.offsetHeight,r.top<i.top?e.scrollTop-=(i.top-r.top)/s:r.bottom>i.bottom&&(e.scrollTop+=(r.bottom-i.bottom)/s)),o}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),r=this.space;if(!r){let t=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return i.top>Math.min(r.bottom,e.bottom)-10||i.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(w).positionInfo(this.view,e,i,n,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,n){let i=document.createElement("ul");i.id=e,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",t=>{t.target==i&&t.preventDefault()});let r=null;for(let s=n.from;s<n.to;s++){let{completion:o,match:l}=t[s],{section:a}=o;if(a){let t="string"==typeof a?a:a.name;t!=r&&(s>n.from||0==n.from)&&(r=t,"string"!=typeof a&&a.header?i.appendChild(a.header(a)):i.appendChild(document.createElement("completion-section")).textContent=t)}let h=i.appendChild(document.createElement("li"));h.id=e+"-"+s,h.setAttribute("role","option");let c=this.optionClass(o);for(let t of(c&&(h.className=c),this.optionContent)){let e=t(o,this.view.state,this.view,l);e&&h.appendChild(e)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function A(t){return 100*(t.boost||0)+10*!!t.apply+5*!!t.info+ +!!t.type}class O{constructor(t,e,n,i,r,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new O(this.options,T(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,i,r,s){if(i&&!s&&t.some(t=>t.isPending))return i.setDisabled();let o=function(t,e){let n=[],i=null,r=t=>{n.push(t);let{section:e}=t.completion;if(e){i||(i=[]);let t="string"==typeof e?e:e.name;i.some(e=>e.name==t)||i.push("string"==typeof e?{name:t}:e)}},s=e.facet(w);for(let i of t)if(i.hasResult()){let t=i.result.getMatch;if(!1===i.result.filter)for(let e of i.result.options)r(new c(e,i.source,t?t(e):[],1e9-n.length));else{let n=e.sliceDoc(i.from,i.to),o,l=s.filterStrict?new y(n):new b(n);for(let e of i.result.options)if(o=l.match(e.label)){let n=e.displayLabel?t?t(e,o.matched):[]:o.matched;r(new c(e,i.source,n,o.score+(e.boost||0)))}}}if(i){let t=Object.create(null),e=0;for(let n of i.sort((t,e)=>{var n,i;return(null!=(n=t.rank)?n:1e9)-(null!=(i=e.rank)?i:1e9)||(t.name<e.name?-1:1)}))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let o=[],l=null,a=s.compareCompletions;for(let t of n.sort((t,e)=>e.score-t.score||a(t.completion,e.completion))){let e=t.completion;l&&l.label==e.label&&l.detail==e.detail&&(null==l.type||null==e.type||l.type==e.type)&&l.apply==e.apply&&l.boost==e.boost?A(t.completion)>A(l)&&(o[o.length-1]=t):o.push(t),l=t.completion}return o}(t,e);if(!o.length)return i&&t.some(t=>t.isPending)?i.setDisabled():null;let l=e.facet(w).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected){let t=i.options[i.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){l=e;break}}return new O(o,T(n,l),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:_,above:r.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new O(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new O(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class M{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new M(E,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(w),i=(n.override||e.languageDataAt("autocomplete",u(e)).map(m)).map(e=>(this.active.find(t=>t.source==e)||new B(e,+!!this.active.some(t=>0!=t.state))).update(t,n));i.length==this.active.length&&i.every((t,e)=>t==this.active[e])&&(i=this.active);let r=this.open,s=t.effects.some(t=>t.is(N));for(let o of(r&&t.docChanged&&(r=r.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!function(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}(i,this.active)||s?r=O.build(i,e,this.id,r,n,s):r&&r.disabled&&!i.some(t=>t.isPending)&&(r=null),!r&&i.every(t=>!t.isPending)&&i.some(t=>t.hasResult())&&(i=i.map(t=>t.hasResult()?new B(t.source,0):t)),t.effects))o.is(I)&&(r=r&&r.setSelected(o.value,this.id));return i==this.active&&r==this.open?this:new M(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?D:P}}let D={"aria-autocomplete":"list"},P={};function T(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}let E=[];function R(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(d);if(n&&e.activateOnCompletion(n))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:16*!!t.docChanged}class B{constructor(t,e,n=!1){this.source=t,this.state=e,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let n=R(t,e),i=this;for(let e of((8&n||16&n&&this.touches(t))&&(i=new B(i.source,0)),4&n&&0==i.state&&(i=new B(this.source,1)),i=i.updateFor(t,n),t.effects))if(e.is(g))i=new B(i.source,1,e.value);else if(e.is(v))i=new B(i.source,0);else if(e.is(N))for(let t of e.value)t.source==i.source&&(i=t);return i}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(u(t.state))}}class L extends B{constructor(t,e,n,i,r,s){super(t,3,e),this.limit=n,this.result=i,this.from=r,this.to=s}hasResult(){return!0}updateFor(t,e){var n;if(!(3&e))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let r=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),l=u(t.state);if(l>s||!i||2&e&&(u(t.startState)==this.from||l<this.limit))return new B(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return!function(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return"function"==typeof t?t(r,n,i,e):f(t,!0).test(r)}(i.validFor,t.state,r,s)?i.update&&(i=i.update(i,r,s,new o(t.state,l,!1)))?new L(this.source,this.explicit,a,i,i.from,null!=(n=i.to)?n:u(t.state)):new B(this.source,1,this.explicit):new L(this.source,this.explicit,a,i,r,s)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new L(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new B(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}let N=i.Pe.define({map:(t,e)=>t.map(t=>t.map(e))}),I=i.Pe.define(),F=i.sU.define({create:()=>M.start(),update:(t,e)=>t.update(e),provide:t=>[r.DK.from(t,t=>t.tooltip),r.Lz.contentAttributes.from(t,t=>t.attrs)]});function j(t,e){let n=e.completion.apply||e.completion.label,r=t.state.field(F).active.find(t=>t.source==e.source);return r instanceof L&&("string"==typeof n?t.dispatch(Object.assign(Object.assign({},function(t,e,n,r){let{main:s}=t.selection,o=n-s.from,l=r-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&n!=r&&t.sliceDoc(a.from+o,a.from+l)!=t.sliceDoc(n,r))return{range:a};let h=t.toText(e);return{changes:{from:a.from+o,to:r==s.from?a.to:a.from+l,insert:h},range:i.OF.cursor(a.from+o+h.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,n,r.from,r.to)),{annotations:d.of(e.completion)})):n(t,e.completion,r.from,r.to),!0)}let _=t=>new C(t,F,j);function z(t,e="option"){return n=>{let i=n.state.field(F,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(w).interactionDelay)return!1;let s=1,o;"page"==e&&(o=(0,r.Eg)(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:l}=i.open.options,a=i.open.selected>-1?i.open.selected+s*(t?1:-1):t?0:l-1;return a<0?a="page"==e?0:l-1:a>=l&&(a="page"==e?l-1:0),n.dispatch({effects:I.of(a)}),!0}}let V=t=>!!t.state.field(F,!1)&&(t.dispatch({effects:g.of(!0)}),!0);class H{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}let W=r.Z9.fromClass(class{constructor(t){for(let e of(this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,t.state.field(F).active))e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(F),n=t.state.facet(w);if(!t.selectionSet&&!t.docChanged&&t.startState.field(F)==e)return;let i=t.transactions.some(t=>{let e=R(t,n);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let n=this.running[e];if(i||n.context.abortOnDocChange&&t.docChanged||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){(0,r.c_)(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(g)))&&(this.pendingStart=!0);let s=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(F);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(w).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=u(e),i=new o(e,n,t.explicit,this.view),s=new H(t,i);this.running.push(s),Promise.resolve(t.source(i)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:v.of(null)}),(0,r.c_)(this.view.state,t)})}scheduleAccept(){this.running.every(t=>void 0!==t.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(w).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(w),i=this.view.state.field(F);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(void 0===s.done)continue;if(this.running.splice(r--,1),s.done){let i=u(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(i,s.done.from+ +!s.active.explicit),o=new L(s.active.source,s.active.explicit,r,s.done,s.done.from,null!=(t=s.done.to)?t:i);for(let t of s.updates)o=o.update(t,n);if(o.hasResult()){e.push(o);continue}}let o=i.active.find(t=>t.source==s.active.source);if(o&&o.isPending)if(null==s.done){let t=new B(s.active.source,0);for(let e of s.updates)t=t.update(e,n);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:N.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(F,!1);if(e&&e.tooltip&&this.view.state.facet(w).closeOnBlur){let n=e.open&&(0,r.Eg)(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:v.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:g.of(!1)}),20),this.composing=0}}}),q="object"==typeof navigator&&/Win/.test(navigator.platform),U=i.Nb.highest(r.Lz.domEventHandlers({keydown(t,e){let n=e.state.field(F,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(q&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(t=>t.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&j(e,i),!1}})),$=r.Lz.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'\uD835\uDC65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\uD835\uDC36'"}},".cm-completionIcon-type":{"&:after":{content:"'\uD835\uDC61'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class K{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class J{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,i.iR.TrackDel),n=t.mapPos(this.to,1,i.iR.TrackDel);return null==e||null==n?null:new J(this.field,e,n)}}class Y{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],r=t.doc.lineAt(e),o=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(n.length){let n=o,l=/^\t*/.exec(r)[0].length;for(let e=0;e<l;e++)n+=t.facet(s.Xt);i.push(e+n.length-l),r=n+r.slice(l)}n.push(r),e+=r.length+1}return{text:n,ranges:this.fieldPositions.map(t=>new J(t.field,i[t.line]+t.from,i[t.line]+t.to))}}static parse(t){let e=[],n=[],i=[],r;for(let s of t.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=r[1]?+r[1]:null,o=r[2]||r[3]||"",l=-1,a=o.replace(/\\[{}]/g,t=>t[1]);for(let n=0;n<e.length;n++)(null!=t?e[n].seq==t:a&&e[n].name==a)&&(l=n);if(l<0){let n=0;for(;n<e.length&&(null==t||null!=e[n].seq&&e[n].seq<t);)n++;for(let r of(e.splice(n,0,{seq:t,name:a}),l=n,i))r.field>=l&&r.field++}i.push(new K(l,n.length,r.index,r.index+a.length)),s=s.slice(0,r.index)+o+s.slice(r.index+r[0].length)}s=s.replace(/\\([{}])/g,(t,e,r)=>{for(let t of i)t.line==n.length&&t.from>r&&(t.from--,t.to--);return e}),n.push(s)}return new Y(n,i)}}let G=r.NZ.widget({widget:new class extends r.xO{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Z=r.NZ.mark({class:"cm-snippetField"});class X{constructor(t,e){this.ranges=t,this.active=e,this.deco=r.NZ.set(t.map(t=>(t.from==t.to?G:Z).range(t.from,t.to)))}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new X(e,this.active)}selectionInsideField(t){return t.ranges.every(t=>this.ranges.some(e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))}}let Q=i.Pe.define({map:(t,e)=>t&&t.map(e)}),tt=i.Pe.define(),te=i.sU.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(Q))return n.value;if(n.is(tt)&&t)return new X(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>r.Lz.decorations.from(t,t=>t?t.deco:r.NZ.none)});function tn(t,e){return i.OF.create(t.filter(t=>t.field==e).map(t=>i.OF.range(t.from,t.to)))}function ti(t){return({state:e,dispatch:n})=>{let i=e.field(te,!1);if(!i||t<0&&0==i.active)return!1;let r=i.active+t,s=t>0&&!i.ranges.some(e=>e.field==r+t);return n(e.update({selection:tn(i.ranges,r),effects:Q.of(s?null:new X(i.ranges,r)),scrollIntoView:!0})),!0}}let tr=[{key:"Tab",run:ti(1),shift:ti(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(te,!1)&&(e(t.update({effects:Q.of(null)})),!0)}],ts=i.sj.define({combine:t=>t.length?t[0]:tr}),to=i.Nb.highest(r.w4.compute([ts],t=>t.facet(ts)));function tl(t,e){let n;return Object.assign(Object.assign({},e),{apply:(n=Y.parse(t),(t,e,r,s)=>{let{text:o,ranges:l}=n.instantiate(t.state,r),{main:a}=t.state.selection,h={changes:{from:r,to:s==a.from?a.to:s,insert:i.EY.of(o)},scrollIntoView:!0,annotations:e?[d.of(e),i.ZX.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=tn(l,0)),l.some(t=>t.field>0)){let e=new X(l,0),n=h.effects=[Q.of(e)];void 0===t.state.field(te,!1)&&n.push(i.Pe.appendConfig.of([te,to,ta,$]))}t.dispatch(t.state.update(h))})})}let ta=r.Lz.domEventHandlers({mousedown(t,e){let n=e.state.field(te,!1),i;if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let r=n.ranges.find(t=>t.from<=i&&t.to>=i);return!!r&&r.field!=n.active&&(e.dispatch({selection:tn(n.ranges,r.field),effects:Q.of(n.ranges.some(t=>t.field>r.field)?new X(n.ranges,r.field):null),scrollIntoView:!0}),!0)}}),th={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},tc=i.Pe.define({map(t,e){let n=e.mapPos(t,-1,i.iR.TrackAfter);return null==n?void 0:n}}),tu=new class extends i.FB{};tu.startSide=1,tu.endSide=-1;let tf=i.sU.define({create:()=>i.om.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(tc)&&(t=t.update({add:[tu.range(n.value,n.value+1)]}));return t}});function td(){return[tb,tf]}let tp="()[]{}<>\xab\xbb\xbb\xab[]{}";function tm(t){for(let e=0;e<tp.length;e+=2)if(tp.charCodeAt(e)==t)return tp.charAt(e+1);return(0,i.MK)(t<128?t:t+1)}function tg(t,e){return t.languageDataAt("closeBrackets",e)[0]||th}let tv="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),tb=r.Lz.inputHandler.of((t,e,n,r)=>{if((tv?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(r.length>2||2==r.length&&1==(0,i.Fh)((0,i.vS)(r,0))||e!=o.from||n!=o.to)return!1;let l=function(t,e){let n=tg(t,t.selection.main.head),r=n.brackets||th.brackets;for(let o of r){let l=tm((0,i.vS)(o,0));if(e==o)return l==o?function(t,e,n,r){let o=r.stringPrefixes||th.stringPrefixes,l=null,a=t.changeByRange(r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:e,from:r.to}],effects:tc.of(r.to+e.length),range:i.OF.range(r.anchor+e.length,r.head+e.length)};let a=r.head,h=tx(t.doc,a),c;if(h==e){if(tk(t,a))return{changes:{insert:e+e,from:a},effects:tc.of(a+e.length),range:i.OF.cursor(a+e.length)};else if(tw(t,a)){let r=n&&t.sliceDoc(a,a+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+r.length,insert:r},range:i.OF.cursor(a+r.length)}}}else if(n&&t.sliceDoc(a-2*e.length,a)==e+e&&(c=tS(t,a-2*e.length,o))>-1&&tk(t,c))return{changes:{insert:e+e+e+e,from:a},effects:tc.of(a+e.length),range:i.OF.cursor(a+e.length)};else if(t.charCategorizer(a)(h)!=i.Je.Word&&tS(t,a,o)>-1&&!function(t,e,n,i){let r=(0,s.mv)(t).resolveInner(e,-1),o=i.reduce((t,e)=>Math.max(t,e.length),0);for(let s=0;s<5;s++){let s=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+o)),l=s.indexOf(n);if(!l||l>-1&&i.indexOf(s.slice(0,l))>-1){let e=r.firstChild;for(;e&&e.from==r.from&&e.to-e.from>n.length+l;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let a=r.to==e&&r.parent;if(!a)break;r=a}return!1}(t,a,e,o))return{changes:{insert:e+e,from:a},effects:tc.of(a+e.length),range:i.OF.cursor(a+e.length)};return{range:l=r}});return l?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}(t,o,r.indexOf(o+o+o)>-1,n):function(t,e,n,r){let s=null,o=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:tc.of(o.to+e.length),range:i.OF.range(o.anchor+e.length,o.head+e.length)};let l=tx(t.doc,o.head);return!l||/\s/.test(l)||r.indexOf(l)>-1?{changes:{insert:e+n,from:o.head},effects:tc.of(o.head+e.length),range:i.OF.cursor(o.head+e.length)}:{range:s=o}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(t,o,l,n.before||th.before);if(e==l&&tw(t,t.selection.main.from))return function(t,e){let n=null,r=t.changeByRange(r=>r.empty&&tx(t.doc,r.head)==e?{changes:{from:r.head,to:r.head+e.length,insert:e},range:i.OF.cursor(r.head+e.length)}:n={range:r});return n?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(t,l)}return null}(t.state,r);return!!l&&(t.dispatch(l),!0)}),ty=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=tg(t,t.selection.main.head).brackets||th.brackets,r=null,s=t.changeByRange(e=>{if(e.empty){var s,o;let r,l=(s=t.doc,o=e.head,r=s.sliceString(o-2,o),(0,i.Fh)((0,i.vS)(r,0))==r.length?r:r.slice(1));for(let r of n)if(r==l&&tx(t.doc,e.head)==tm((0,i.vS)(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:i.OF.cursor(e.head-r.length)}}return{range:r=e}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function tw(t,e){let n=!1;return t.field(tf).between(0,t.doc.length,t=>{t==e&&(n=!0)}),n}function tx(t,e){let n=t.sliceString(e,e+2);return n.slice(0,(0,i.Fh)((0,i.vS)(n,0)))}function tk(t,e){let n=(0,s.mv)(t).resolveInner(e+1);return n.parent&&n.from==e}function tS(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=i.Je.Word)return e;for(let s of n){let n=e-s.length;if(t.sliceDoc(n,e)==s&&r(t.sliceDoc(n-1,n))!=i.Je.Word)return n}return -1}function tC(t={}){return[U,F,w.of(t),W,tO,$]}let tA=[{key:"Ctrl-Space",run:V},{mac:"Alt-`",run:V},{key:"Escape",run:t=>{let e=t.state.field(F,!1);return!!e&&!!e.active.some(t=>0!=t.state)&&(t.dispatch({effects:v.of(null)}),!0)}},{key:"ArrowDown",run:z(!0)},{key:"ArrowUp",run:z(!1)},{key:"PageDown",run:z(!0,"page")},{key:"PageUp",run:z(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(F,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(w).interactionDelay)&&j(t,e.open.options[e.open.selected])}}],tO=i.Nb.highest(r.w4.computeN([w],t=>t.facet(w).defaultKeymap?[tA]:[]))},169:function(t,e,n){n.d(e,{Ay:function(){return I},EI:function(){return P},KB:function(){return E},Lv:function(){return th},Oh:function(){return R},Q0:function(){return u},SG:function(){return tA},WD:function(){return z},Xt:function(){return M},Yy:function(){return A},Zt:function(){return tv},_Y:function(){return j},_v:function(){return T},b_:function(){return H},bj:function(){return p},f7:function(){return tt},jU:function(){return tP},mv:function(){return m},mz:function(){return _},p9:function(){return c},tp:function(){return D},y9:function(){return tm},yd:function(){return W}});var i,r=n(80),s=n(492),o=n(867),l=n(619),a=n(690);let h=new r.uY;function c(t){return s.sj.define({combine:t?e=>e.concat(t):void 0})}let u=new r.uY;class f{constructor(t,e,n=[],i=""){this.data=t,this.name=i,s.$t.prototype.hasOwnProperty("tree")||Object.defineProperty(s.$t.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[C.of(this),s.$t.languageData.of((t,e,n)=>{let i=d(t,e,n),r=i.type.prop(h);if(!r)return[];let s=t.facet(r),o=i.type.prop(u);if(o){let r=i.resolve(e-i.from,n);for(let e of o)if(e.test(r,t)){let n=t.facet(e.facet);return"replace"==e.type?n:n.concat(s)}}return s})].concat(n)}isActiveAt(t,e,n=-1){return d(t,e,n).type.prop(h)==this.data}findRegions(t){let e=t.facet(C);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[],i=(t,e)=>{if(t.prop(h)==this.data)return void n.push({from:e,to:e+t.length});let s=t.prop(r.uY.mounted);if(s){if(s.tree.prop(h)==this.data){if(s.overlay)for(let t of s.overlay)n.push({from:t.from+e,to:t.to+e});else n.push({from:e,to:e+t.length});return}else if(s.overlay){let t=n.length;if(i(s.tree,s.overlay[0].from+e),n.length>t)return}}for(let n=0;n<t.children.length;n++){let s=t.children[n];s instanceof r.PH&&i(s,t.positions[n]+e)}};return i(m(t),0),n}get allowsNesting(){return!0}}function d(t,e,n){let i=t.facet(C),s=m(t).topNode;if(!i||i.allowsNesting)for(let t=s;t;t=t.enter(e,n,r.Qj.ExcludeBuffers))t.type.isTop&&(s=t);return s}f.setState=s.Pe.define();class p extends f{constructor(t,e,n){super(t,e,[],n),this.parser=e}static define(t){let e=c(t.languageData);return new p(e,t.parser.configure({props:[h.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new p(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(t){let e=t.field(f.state,!1);return e?e.tree:r.PH.empty}class g{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let v=null;class b{constructor(t,e,n=[],i,r,s,o,l){this.parser=t,this.state=e,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,n){return new b(t,e,[],r.PH.empty,0,n,[],null)}startParse(){return this.parser.startParse(new g(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=r.PH.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(r.rr.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(r.rr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=v;v=this;try{return t()}finally{v=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=y(t,e.from,e.to);return t}changes(t,e){let{fragments:n,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,i,r)=>e.push({fromA:t,toA:n,fromB:i,toB:r})),n=r.rr.applyChanges(n,e),i=r.PH.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length)for(let e of(l=[],this.skipped)){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);n<i&&l.push({from:n,to:i})}}return new b(this.parser,e,n,i,s,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:n,to:i}=this.skipped[e];n<t.to&&i>t.from&&(this.fragments=y(this.fragments,n,i),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends r.iX{createParse(e,n,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let e=v;if(e){for(let t of i)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new r.PH(r.Z6.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return v}}function y(t,e,n){return r.rr.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class w{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,n)||e.takeTree(),new w(e)}static init(t){let e=Math.min(3e3,t.doc.length),n=b.create(t.facet(C).parser,t,{from:0,to:e});return n.work(20,e)||n.takeTree(),new w(n)}}f.state=s.sU.define({create:w.init,update(t,e){for(let t of e.effects)if(t.is(f.setState))return t.value;return e.startState.facet(C)!=e.state.facet(C)?w.init(e.state):t.apply(e)}});let x=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"u">typeof requestIdleCallback&&(x=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});let k="u">typeof navigator&&(null==(i=navigator.scheduling)?void 0:i.isInputPending)?()=>navigator.scheduling.isInputPending():null,S=o.Z9.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(f.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(f.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=x(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(f.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!k?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work(()=>k&&k()||Date.now()>s,i+1e5*!o);this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:f.setState.of(new w(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>(0,o.c_)(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),C=s.sj.define({combine:t=>t.length?t[0]:null,enables:t=>[f.state,S,o.Lz.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class A{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}let O=s.sj.define(),M=s.sj.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function D(t){let e=t.facet(M);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function P(t,e){let n="",i=t.tabSize,r=t.facet(M)[0];if(" "==r){for(;e>=i;)n+=" ",e-=i;r=" "}for(let t=0;t<e;t++)n+=r;return n}function T(t,e){for(let n of(t instanceof s.$t&&(t=new E(t)),t.state.facet(O))){let i=n(t,e);if(void 0!==i)return i}let n=m(t.state);return n.length>=e?function(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let t=[];for(let e=r;e&&!(e.from<i.node.from||e.to>i.node.to||e.from==i.node.from&&e.type==i.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)i={node:t[e],next:i}}return B(i,t,n)}(t,n,e):null}class E{constructor(t,e={}){this.state=t,this.options=e,this.unit=D(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:r}=this.options;if(null!=i&&i>=n.from&&i<=n.to)if(r&&i==t)return{text:"",from:t};else if(e<0?i<t:i<=t)return{text:n.text.slice(i-n.from),from:i};else return{text:n.text.slice(0,i-n.from),from:n.from};return n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(t,e);return n.slice(t-i,Math.min(n.length,t+100-i))}column(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.countColumn(n,t-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(r+=s-this.countColumn(n,n.search(/\S|$/))),r}countColumn(t,e=t.length){return(0,s.y$)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(i);if(t>-1)return t}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let R=new r.uY;function B(t,e,n){for(let i=t;i;i=i.next){let t=function(t){let e=t.type.prop(R);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(r.uY.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>F(t,!0,1,void 0,n&&!(t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak)?e.from:void 0)}return null==t.parent?L:null}(i.node);if(t)return t(N.create(e,n,i))}return 0}function L(){return 0}class N extends E{constructor(t,e,n){super(t.state,t.options),this.base=t,this.pos=e,this.context=n}get node(){return this.context.node}static create(t,e,n){return new N(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(function(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return B(this.context.next,this.base,this.pos)}}function I({closing:t,align:e=!0,units:n=1}){return i=>F(i,e,n,t)}function F(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,a=e?function(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=n.to;;){let r=e.childAfter(t);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let t=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+t}}t=r.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}let j=t=>t.baseIndent;function _({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}function z(){return s.$t.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:i}=t.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return t;let s=n.sliceString(r.from,i);if(!e.some(t=>t.test(s)))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let n=T(o,e.from);if(null==n)continue;let i=/^\s*/.exec(e.text)[0],r=P(o,n);i!=r&&a.push({from:e.from,to:e.from+i.length,insert:r})}return a.length?[t,{changes:a,sequential:!0}]:t})}let V=s.sj.define(),H=new r.uY;function W(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function q(t,e,n){for(let i of t.facet(V)){let r=i(t,e,n);if(r)return r}return function(t,e,n){let i=m(t);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=n||r.from>n)continue;if(s&&r.from<e)break;let l=r.type.prop(H);if(l&&(r.to<i.length-50||i.length==t.doc.length||!function(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}(r))){let i=l(r,t);i&&i.from<=n&&i.from>=e&&i.to>n&&(s=i)}}return s}(t,e,n)}function U(t,e){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}let $=s.Pe.define({map:U}),K=s.Pe.define({map:U});function J(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(t=>t.from<=n&&t.to>=n)||e.push(t.lineBlockAt(n));return e}let Y=s.sU.define({create:()=>o.NZ.none,update(t,e){for(let n of(e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,n)=>t=G(t,e,n)),t=t.map(e.changes),e.effects))if(n.is($)&&!function(t,e,n){let i=!1;return t.between(e,e,(t,r)=>{t==e&&r==n&&(i=!0)}),i}(t,n.value.from,n.value.to)){let{preparePlaceholder:i}=e.state.facet(tn),r=i?o.NZ.replace({widget:new to(i(e.state,n.value))}):ts;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(K)&&(t=t.update({filter:(t,e)=>n.value.from!=t||n.value.to!=e,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=G(t,e.selection.main.head)),t},provide:t=>o.Lz.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(t,e)=>{n.push(t,e)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let i=t[n++],r=t[n++];if("number"!=typeof i||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");e.push(ts.range(i,r))}return o.NZ.set(e,!0)}});function G(t,e,n=e){let i=!1;return t.between(e,n,(t,r)=>{t<n&&r>e&&(i=!0)}),i?t.update({filterFrom:e,filterTo:n,filter:(t,i)=>t>=n||i<=e}):t}function Z(t,e,n){var i;let r=null;return null==(i=t.field(Y,!1))||i.between(e,n,(t,e)=>{(!r||r.from>t)&&(r={from:t,to:e})}),r}function X(t,e){return t.field(Y,!1)?e:e.concat(s.Pe.appendConfig.of(ti()))}function Q(t,e,n=!0){let i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return o.Lz.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${t.state.phrase("to")} ${r}.`)}let tt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of J(t)){let n=q(t.state,e.from,e.to);if(n)return t.dispatch({effects:X(t.state,[$.of(n),Q(t,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(Y,!1))return!1;let e=[];for(let n of J(t)){let i=Z(t.state,n.from,n.to);i&&e.push(K.of(i),Q(t,i,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,n=[];for(let i=0;i<e.doc.length;){let r=t.lineBlockAt(i),s=q(e,r.from,r.to);s&&n.push($.of(s)),i=(s?t.lineBlockAt(s.to):r).to+1}return n.length&&t.dispatch({effects:X(t.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(Y,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(t,e)=>{n.push(K.of({from:t,to:e}))}),t.dispatch({effects:n}),!0}}],te={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},tn=s.sj.define({combine:t=>(0,s.QR)(t,te)});function ti(t){let e=[Y,tc];return t&&e.push(tn.of(t)),e}function tr(t,e){let{state:n}=t,i=n.facet(tn),r=e=>{let n=t.lineBlockAt(t.posAtDOM(e.target)),i=Z(t.state,n.from,n.to);i&&t.dispatch({effects:K.of(i)}),e.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let ts=o.NZ.replace({widget:new class extends o.xO{toDOM(t){return tr(t,null)}}});class to extends o.xO{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return tr(t,this.value)}}let tl={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ta extends o.wJ{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function th(t={}){let e={...tl,...t},n=new ta(e,!0),i=new ta(e,!1),r=o.Z9.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(C)!=t.state.facet(C)||t.startState.field(Y,!1)!=t.state.field(Y,!1)||m(t.startState)!=m(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new s.vB;for(let r of t.viewportLineBlocks){let s=Z(t.state,r.from,r.to)?i:q(t.state,r.from,r.to)?n:null;s&&e.add(r.from,r.from,s)}return e.finish()}}),{domEventHandlers:l}=e;return[r,(0,o.cU)({class:"cm-foldGutter",markers(t){var e;return(null==(e=t.plugin(r))?void 0:e.markers)||s.om.empty},initialSpacer:()=>new ta(e,!1),domEventHandlers:{...l,click:(t,e,n)=>{if(l.click&&l.click(t,e,n))return!0;let i=Z(t.state,e.from,e.to);if(i)return t.dispatch({effects:K.of(i)}),!0;let r=q(t.state,e.from,e.to);return!!r&&(t.dispatch({effects:$.of(r)}),!0)}}}),ti()]}let tc=o.Lz.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class tu{constructor(t,e){let n;function i(t){let e=a.G.newName();return(n||(n=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?i(e.all):void 0,s=e.scope;this.scope=s instanceof f?t=>t.prop(h)==s.data:s?t=>t==s:void 0,this.style=(0,l.az)(t.map(t=>({tag:t.tag,class:t.class||i(Object.assign({},t,{tag:null}))})),{all:r}).style,this.module=n?new a.G(n):null,this.themeType=e.themeType}static define(t,e){return new tu(t,e||{})}}let tf=s.sj.define(),td=s.sj.define({combine:t=>t.length?[t[0]]:null});function tp(t){let e=t.facet(tf);return e.length?e:t.facet(td)}function tm(t,e){let n=[tg],i;return t instanceof tu&&(t.module&&n.push(o.Lz.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(td.of(t)):i?n.push(tf.computeN([o.Lz.darkTheme],e=>e.facet(o.Lz.darkTheme)==("dark"==i)?[t]:[])):n.push(tf.of(t)),n}let tg=s.Nb.high(o.Z9.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,tp(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),n=tp(t.state),i=n!=tp(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!i&&e.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||i)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return o.NZ.none;let n=new s.vB;for(let{from:i,to:r}of t.visibleRanges)(0,l.DM)(this.tree,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=o.NZ.mark({class:i})))},i,r);return n.finish()}},{decorations:t=>t.decorations})),tv=tu.define([{tag:l._A.meta,color:"#404740"},{tag:l._A.link,textDecoration:"underline"},{tag:l._A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:l._A.emphasis,fontStyle:"italic"},{tag:l._A.strong,fontWeight:"bold"},{tag:l._A.strikethrough,textDecoration:"line-through"},{tag:l._A.keyword,color:"#708"},{tag:[l._A.atom,l._A.bool,l._A.url,l._A.contentSeparator,l._A.labelName],color:"#219"},{tag:[l._A.literal,l._A.inserted],color:"#164"},{tag:[l._A.string,l._A.deleted],color:"#a11"},{tag:[l._A.regexp,l._A.escape,l._A.special(l._A.string)],color:"#e40"},{tag:l._A.definition(l._A.variableName),color:"#00f"},{tag:l._A.local(l._A.variableName),color:"#30a"},{tag:[l._A.typeName,l._A.namespace],color:"#085"},{tag:l._A.className,color:"#167"},{tag:[l._A.special(l._A.variableName),l._A.macroName],color:"#256"},{tag:l._A.definition(l._A.propertyName),color:"#00c"},{tag:l._A.comment,color:"#940"},{tag:l._A.invalid,color:"#f00"}]),tb=o.Lz.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ty="()[]{}",tw=s.sj.define({combine:t=>(0,s.QR)(t,{afterCursor:!0,brackets:ty,maxScanDistance:1e4,renderMatch:tS})}),tx=o.NZ.mark({class:"cm-matchingBracket"}),tk=o.NZ.mark({class:"cm-nonmatchingBracket"});function tS(t){let e=[],n=t.matched?tx:tk;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}let tC=[s.sU.define({create:()=>o.NZ.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],i=e.state.facet(tw);for(let t of e.state.selection.ranges){if(!t.empty)continue;let r=tP(e.state,t.head,-1,i)||t.head>0&&tP(e.state,t.head-1,1,i)||i.afterCursor&&(tP(e.state,t.head,1,i)||t.head<e.state.doc.length&&tP(e.state,t.head+1,-1,i));r&&(n=n.concat(i.renderMatch(r,e.state)))}return o.NZ.set(n,!0)},provide:t=>o.Lz.decorations.from(t)}),tb];function tA(t={}){return[tw.of(t),tC]}let tO=new r.uY;function tM(t,e,n){let i=t.prop(e<0?r.uY.openedBy:r.uY.closedBy);if(i)return i;if(1==t.name.length){let i=n.indexOf(t.name);if(i>-1&&i%2==+(e<0))return[n[i+e]]}return null}function tD(t){let e=t.type.prop(tO);return e?e(t.node):t}function tP(t,e,n,i={}){let r=i.maxScanDistance||1e4,s=i.brackets||ty,o=m(t),l=o.resolveInner(e,n);for(let t=l;t;t=t.parent){let i=tM(t.type,n,s);if(i&&t.from<t.to){let r=tD(t);if(r&&(n>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return function(t,e,n,i,r){let s=e.parent,o={from:n.from,to:n.to},l=0,a=null==s?void 0:s.cursor();if(a&&(t<0?a.childBefore(e.from):a.childAfter(e.to)))do if(t<0?a.to<=e.from:a.from>=e.to){if(0==l&&i.indexOf(a.type.name)>-1&&a.from<a.to){let t=tD(a);return{start:o,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}else if(tM(a.type,t,r))l++;else if(tM(a.type,-t,r)){if(0==l){let t=tD(a);return{start:o,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}l--}}while(t<0?a.prevSibling():a.nextSibling());return{start:o,matched:!1}}(n,t,r,i,s)}}return function(t,e,n,i,r,s,o){let l=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;n<0&&(t+=s.length);let l=e+t*n;for(let t=n>0?0:s.length-1,e=n>0?s.length:-1;t!=e;t+=n){let e=o.indexOf(s[t]);if(!(e<0)&&i.resolveInner(l+t,1).type==r)if(e%2==0==n>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}n>0&&(t+=s.length)}return c.done?{start:h,matched:!1}:null}(t,e,n,o,l.type,r,s)}let tT=Object.create(null),tE=[r.Z6.none],tR=[],tB=Object.create(null),tL=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tL[t]=function(t,e){let n=[];for(let i of e.split(" ")){let e=[];for(let n of i.split(".")){let i=t[n]||l._A[n];i?"function"==typeof i?e.length?e=e.map(i):tN(n,`Modifier ${n} used at start of tag`):e.length?tN(n,`Tag ${n} used as modifier`):e=Array.isArray(i)?i:[i]:tN(n,`Unknown highlighting tag ${n}`)}for(let t of e)n.push(t)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+n.map(t=>t.id),o=tB[s];if(o)return o.id;let a=tB[s]=r.Z6.define({id:tE.length,name:i,props:[(0,l.pn)({[i]:n})]});return tE.push(a),a.id}(tT,e);function tN(t,e){tR.indexOf(t)>-1||(tR.push(t),console.warn(e))}o.OP.RTL,o.OP.LTR},492:function(t,e,n){let i;n.d(e,{ZX:function(){return tp},kn:function(){return tz},MK:function(){return C},iR:function(){return P},Fh:function(){return A},zK:function(){return k},sU:function(){return J},om:function(){return tM},OF:function(){return _},Pe:function(){return td},$t:function(){return tx},xx:function(){return X},Nb:function(){return G},vS:function(){return S},QR:function(){return tk},y$:function(){return t_},YH:function(){return tc},FB:function(){return tS},Gu:function(){return T},Je:function(){return ty},vB:function(){return tD},VR:function(){return E},EY:function(){return d},sj:function(){return H}});let r=[],s=[],o="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<o.length;t++)(t%2?s:r).push(e+=o[t]);function l(t){return t>=127462&&t<=127487}function a(t,e,n){if(e==t.length)return e;e&&c(t.charCodeAt(e))&&u(t.charCodeAt(e-1))&&e--;let i=h(t,e);for(e+=f(i);e<t.length;){let o=h(t,e);if(8205==i||8205==o||n&&function(t){if(t<768)return!1;for(let e=0,n=r.length;;){let i=e+n>>1;if(t<r[i])n=i;else{if(!(t>=s[i]))return!0;e=i+1}if(e==n)return!1}}(o))e+=f(o),i=o;else if(l(o)){let n=0,i=e-2;for(;i>=0&&l(h(t,i));)n++,i-=2;if(n%2==0)break;e+=2}else break}return e}function h(t,e){let n=t.charCodeAt(e);if(!u(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return c(i)?(n-55296<<10)+(i-56320)+65536:n}function c(t){return t>=56320&&t<57344}function u(t){return t>=55296&&t<56320}function f(t){return t<65536?1:2}class d{lineAt(t){if(t<0||t>this.length)throw RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,n){[t,e]=x(this,t,e);let i=[];return this.decompose(0,t,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(e,this.length,i,1),m.from(i,this.length-(e-t)+n.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=x(this,t,e);let n=[];return this.decompose(t,e,n,0),m.from(n,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),n=this.length-this.scanIdentical(t,-1),i=new v(this),r=new v(t);for(let t=e,s=e;;){if(i.next(t),r.next(t),t=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(s+=i.value.length,i.done||s>=n)return!0}}iter(t=1){return new v(this,t)}iterRange(t,e=this.length){return new b(this,t,e)}iterLines(t,e){let n;if(null==t)n=this.iter();else{null==e&&(e=this.lines+1);let i=this.line(t).from;n=this.iterRange(i,Math.max(i,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new y(n)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new p(t):m.from(p.split(t,[])):d.empty}}class p extends d{constructor(t,e=function(t){let e=-1;for(let n of t)e+=n.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,n,i){for(let r=0;;r++){let s=this.text[r],o=i+s.length;if((e?n:o)>=t)return new w(i,o,n,s);i=o+1,n++}}decompose(t,e,n,i){var r;let s=t<=0&&e>=this.length?this:new p((r=this.text,g(r,[""],t,e)),Math.min(e,this.length)-Math.max(0,t));if(1&i){let t=n.pop(),e=g(s.text,t.text.slice(),0,s.length);if(e.length<=32)n.push(new p(e,t.length+s.length));else{let t=e.length>>1;n.push(new p(e.slice(0,t)),new p(e.slice(t)))}}else n.push(s)}replace(t,e,n){var i;if(!(n instanceof p))return super.replace(t,e,n);[t,e]=x(this,t,e);let r=g(this.text,g(n.text,(i=this.text,g(i,[""],0,t))),e),s=this.length+n.length-(e-t);return r.length<=32?new p(r,s):m.from(p.split(r,[]),s)}sliceString(t,e=this.length,n="\n"){[t,e]=x(this,t,e);let i="";for(let r=0,s=0;r<=e&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>t&&s&&(i+=n),t<l&&e>r&&(i+=o.slice(Math.max(0,t-r),e-r)),r=l+1}return i}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let n=[],i=-1;for(let r of t)n.push(r),i+=r.length+1,32==n.length&&(e.push(new p(n,i)),n=[],i=-1);return i>-1&&e.push(new p(n,i)),e}}class m extends d{constructor(t,e){for(let n of(super(),this.children=t,this.length=e,this.lines=0,t))this.lines+=n.lines}lineInner(t,e,n,i){for(let r=0;;r++){let s=this.children[r],o=i+s.length,l=n+s.lines-1;if((e?l:o)>=t)return s.lineInner(t,e,n,i);i=o+1,n=l+1}}decompose(t,e,n,i){for(let r=0,s=0;s<=e&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(t<=l&&e>=s){let r=i&(s<=t|2*(l>=e));s>=t&&l<=e&&!r?n.push(o):o.decompose(t-s,e-s,n,r)}s=l+1}}replace(t,e,n){if([t,e]=x(this,t,e),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let s=this.children[i],o=r+s.length;if(t>=r&&e<=o){let l=s.replace(t-r,e-r,n),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[i]=l,new m(r,this.length-(e-t)+n.length)}return super.replace(r,o,l)}r=o+1}return super.replace(t,e,n)}sliceString(t,e=this.length,n="\n"){[t,e]=x(this,t,e);let i="";for(let r=0,s=0;r<this.children.length&&s<=e;r++){let o=this.children[r],l=s+o.length;s>t&&r&&(i+=n),t<l&&e>s&&(i+=o.sliceString(t-s,e-s,n)),s=l+1}return i}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof m))return 0;let n=0,[i,r,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=e,r+=e){if(i==s||r==o)return n;let l=this.children[i],a=t.children[r];if(l!=a)return n+l.scanIdentical(a,e);n+=l.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let n=0;for(let e of t)n+=e.lines;if(n<32){let n=[];for(let e of t)e.flatten(n);return new p(n,e)}let i=Math.max(32,n>>5),r=i<<1,s=i>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:m.from(h,a)),a=-1,l=h.length=0)}for(let e of t)!function t(e){let n;if(e.lines>r&&e instanceof m)for(let n of e.children)t(n);else e.lines>s&&(l>s||!l)?(c(),o.push(e)):e instanceof p&&l&&(n=h[h.length-1])instanceof p&&e.lines+n.lines<=32?(l+=e.lines,a+=e.length+1,h[h.length-1]=new p(n.text.concat(e.text),n.length+1+e.length)):(l+e.lines>i&&c(),l+=e.lines,a+=e.length+1,h.push(e))}(e);return c(),1==o.length?o[0]:new m(o,e)}}function g(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=i;s++){let l=t[s],a=r+l.length;a>=n&&(a>i&&(l=l.slice(0,i-r)),r<n&&(l=l.slice(n-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}d.empty=new p([""],0);class v{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof p?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],s=r>>1,o=i instanceof p?i.text.length:i.children.length;if(s==(e>0?o:0)){if(0==n)return this.done=!0,this.value="",this;e>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[n]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(i instanceof p){let r=i.text[s+(e<0?-1:0)];if(this.offsets[n]+=e,r.length>Math.max(0,t))return this.value=0==t?r:e>0?r.slice(t):r.slice(0,r.length-t),this;t-=r.length}else{let r=i.children[s+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[n]+=e):(e<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof p?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class b{constructor(t,e,n){this.value="",this.done=!1,this.cursor=new v(t,e>n?-1:1),this.pos=e>n?t.length:0,this.from=Math.min(e,n),this.to=Math.max(e,n)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let n=e<0?this.pos-this.from:this.to-this.pos;t>n&&(t=n),n-=t;let{value:i}=this.cursor.next(t);return this.pos+=(i.length+t)*e,this.value=i.length<=n?i:e<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class y{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:n,value:i}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}"u">typeof Symbol&&(d.prototype[Symbol.iterator]=function(){return this.iter()},v.prototype[Symbol.iterator]=b.prototype[Symbol.iterator]=y.prototype[Symbol.iterator]=function(){return this});class w{constructor(t,e,n,i){this.from=t,this.to=e,this.number=n,this.text=i}get length(){return this.to-this.from}}function x(t,e,n){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,n))]}function k(t,e,n=!0,i=!0){return function(t,e,n=!0,i=!0){return(n?a:function(t,e,n){for(;e>0;){let i=a(t,e-2,n);if(i<e)return i;e--}return 0})(t,e,i)}(t,e,n,i)}function S(t,e){let n=t.charCodeAt(e);if(!(n>=55296&&n<56320)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return i>=56320&&i<57344?(n-55296<<10)+(i-56320)+65536:n}function C(t){return t<=65535?String.fromCharCode(t):String.fromCharCode(((t-=65536)>>10)+55296,(1023&t)+56320)}function A(t){return t<65536?1:2}let O=/\r\n?|\n/;var M,D,P=((M=P||(P={}))[M.Simple=0]="Simple",M[M.TrackDel=1]="TrackDel",M[M.TrackBefore=2]="TrackBefore",M[M.TrackAfter=3]="TrackAfter",M);class T{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e+1];t+=n<0?this.sections[e]:n}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,n=0,i=0;e<this.sections.length;){let r=this.sections[e++],s=this.sections[e++];s<0?(t(n,i,r),i+=r):i+=s,n+=r}}iterChangedRanges(t,e=!1){L(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],i=this.sections[e++];i<0?t.push(n,i):t.push(i,n)}return new T(t)}composeDesc(t){return this.empty?t:t.empty?this:I(this,t)}mapDesc(t,e=!1){return t.empty?this:N(this,t,e)}mapPos(t,e=-1,n=P.Simple){let i=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=i+o;if(l<0){if(a>t)return r+(t-i);r+=o}else{if(n!=P.Simple&&a>=t&&(n==P.TrackDel&&i<t&&a>t||n==P.TrackBefore&&i<t||n==P.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!o)return t==i||e<0?r:r+l;r+=l}i=a}if(t>i)throw RangeError(`Position ${t} is out of range for changeset of length ${i}`);return r}touchesRange(t,e=t){for(let n=0,i=0;n<this.sections.length&&i<=e;){let r=this.sections[n++],s=this.sections[n++],o=i+r;if(s>=0&&i<=e&&o>=t)return!(i<t)||!(o>e)||"cover";i=o}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let n=this.sections[e++],i=this.sections[e++];t+=(t?" ":"")+n+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw RangeError("Invalid JSON representation of ChangeDesc");return new T(t)}static create(t){return new T(t)}}class E extends T{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw RangeError("Applying change set to a document with the wrong length");return L(this,(e,n,i,r,s)=>t=t.replace(i,i+(n-e),s),!1),t}mapDesc(t,e=!1){return N(this,t,e,!0)}invert(t){let e=this.sections.slice(),n=[];for(let i=0,r=0;i<e.length;i+=2){let s=e[i],o=e[i+1];if(o>=0){e[i]=o,e[i+1]=s;let l=i>>1;for(;n.length<l;)n.push(d.empty);n.push(s?t.slice(r,r+s):d.empty)}r+=s}return new E(e,n)}compose(t){return this.empty?t:t.empty?this:I(this,t,!0)}map(t,e=!1){return t.empty?this:N(this,t,e,!0)}iterChanges(t,e=!1){L(this,t,e)}get desc(){return T.create(this.sections)}filter(t){let e=[],n=[],i=[],r=new F(this);e:for(let s=0,o=0;;){let l=s==t.length?1e9:t[s++];for(;o<l||o==l&&0==r.len;){if(r.done)break e;let t=Math.min(r.len,l-o);R(i,t,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;R(e,t,s),s>0&&B(n,e,r.text),r.forward(t),o+=t}let a=t[s++];for(;o<a;){if(r.done)break e;let t=Math.min(r.len,a-o);R(e,t,-1),R(i,t,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(t),o+=t}}return{changes:new E(e,n),filtered:T.create(i)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e],i=this.sections[e+1];i<0?t.push(n):0==i?t.push([n]):t.push([n].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,n){let i=[],r=[],s=0,o=null;function l(t=!1){if(!t&&!i.length)return;s<e&&R(i,e-s,-1);let n=new E(i,r);o=o?o.compose(n.map(o)):n,i=[],r=[],s=0}return!function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof E){if(a.length!=e)throw RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:t,to:o=t,insert:h}=a;if(t>o||t<0||o>e)throw RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=h?"string"==typeof h?d.of(h.split(n||O)):h:d.empty,u=c.length;if(t==o&&0==u)return;t<s&&l(),t>s&&R(i,t-s,-1),R(i,o-t,u),B(r,i,c),s=o}}(t),l(!o),o}static empty(t){return new E(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError("Invalid JSON representation of ChangeSet");let e=[],n=[];for(let i=0;i<t.length;i++){let r=t[i];if("number"==typeof r)e.push(r,-1);else if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((t,e)=>e&&"string"!=typeof t))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)e.push(r[0],0);else{for(;n.length<i;)n.push(d.empty);n[i]=d.of(r.slice(1)),e.push(r[0],n[i].length)}}return new E(e,n)}static createSet(t,e){return new E(t,e)}}function R(t,e,n,i=!1){if(0==e&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&0==e&&0==t[r]?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function B(t,e,n){if(0==n.length)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<i;)t.push(d.empty);t.push(n)}}function L(t,e,n){let i=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,u=d.empty;for(;h+=l,c+=a,a&&i&&(u=u.append(i[o-2>>1])),!n&&o!=t.sections.length&&!(t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(r,h,s,c,u),r=h,s=c}}}function N(t,e,n,i=!1){let r=[],s=i?[]:null,o=new F(t),l=new F(e);for(let t=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let t=Math.min(o.len,l.len);R(r,t,-1),o.forward(t),l.forward(t)}else if(l.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!n))){let e=l.len;for(R(r,l.ins,-1);e;){let n=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=n&&(R(r,0,o.ins),s&&B(s,r,o.text),t=o.i),o.forward(n),e-=n}l.next()}else if(o.ins>=0){let e=0,n=o.len;for(;n;)if(-1==l.ins){let t=Math.min(n,l.len);e+=t,n-=t,l.forward(t)}else if(0==l.ins&&l.len<n)n-=l.len,l.next();else break;R(r,e,t<o.i?o.ins:0),s&&t<o.i&&B(s,r,o.text),t=o.i,o.forward(o.len-n)}else if(o.done&&l.done)return s?E.createSet(r,s):T.create(r);else throw Error("Mismatched change set lengths")}function I(t,e,n=!1){let i=[],r=n?[]:null,s=new F(t),o=new F(e);for(let t=!1;;)if(s.done&&o.done)return r?E.createSet(i,r):T.create(i);else if(0==s.ins)R(i,s.len,0,t),s.next();else if(0!=o.len||o.done)if(s.done||o.done)throw Error("Mismatched change set lengths");else{let e=Math.min(s.len2,o.len),n=i.length;if(-1==s.ins){let n=-1==o.ins?-1:o.off?0:o.ins;R(i,e,n,t),r&&n&&B(r,i,o.text)}else -1==o.ins?(R(i,s.off?0:s.len,e,t),r&&B(r,i,s.textBit(e))):(R(i,s.off?0:s.len,o.off?0:o.ins,t),r&&!o.off&&B(r,i,o.text));t=(s.ins>e||o.ins>=0&&o.len>e)&&(t||i.length>n),s.forward2(e),o.forward(e)}else R(i,0,o.ins,t),r&&B(r,i,o.text),o.next()}class F{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?d.empty:t[e]}textBit(t){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length&&!t?d.empty:e[n].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class j{constructor(t,e,n){this.from=t,this.to=e,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 0xffffff==t?void 0:t}map(t,e=-1){let n,i;return this.empty?n=i=t.mapPos(this.from,e):(n=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new j(n,i,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return _.range(t,e);let n=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return _.range(this.anchor,n)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid JSON representation for SelectionRange");return _.range(t.anchor,t.head)}static create(t,e,n){return new j(t,e,n)}}class _{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:_.create(this.ranges.map(n=>n.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(t.ranges[n],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new _([this.main],0)}addRange(t,e=!0){return _.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let n=this.ranges.slice();return n[e]=t,_.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new _(t.ranges.map(t=>j.fromJSON(t)),t.main)}static single(t,e=t){return new _([_.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw RangeError("A selection needs at least one range");for(let n=0,i=0;i<t.length;i++){let r=t[i];if(r.empty?r.from<=n:r.from<n)return _.normalized(t.slice(),e);n=r.to}return new _(t,e)}static cursor(t,e=0,n,i){return j.create(t,t,(0==e?0:e<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:0xffffff)<<6)}static range(t,e,n,i){let r=(null!=n?n:0xffffff)<<6|(null==i?7:Math.min(6,i));return e<t?j.create(e,t,48|r):j.create(t,e,8*(e>t)|r)}static normalized(t,e=0){let n=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(n);for(let n=1;n<t.length;n++){let i=t[n],r=t[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let s=r.from,o=Math.max(i.to,r.to);n<=e&&e--,t.splice(--n,2,i.anchor>i.head?_.range(o,s):_.range(s,o))}}return new _(t,e)}}function z(t,e){for(let n of t.ranges)if(n.to>e)throw RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,n,i,r){this.combine=t,this.compareInput=e,this.compare=n,this.isStatic=i,this.id=V++,this.default=t([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(!t.combine?W:(t,e)=>t===e),!!t.static,t.enables)}of(t){return new q([],this,0,t)}compute(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new q(t,this,1,e)}computeN(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new q(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],n=>e(n.field(t)))}}function W(t,e){return t==e||t.length==e.length&&t.every((t,n)=>t===e[n])}class q{constructor(t,e,n,i){this.dependencies=t,this.facet=e,this.type=n,this.value=i,this.id=V++}dynamicSlot(t){var e;let n=this.value,i=this.facet.compareInput,r=this.id,s=t[r]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let n of this.dependencies)"doc"==n?l=!0:"selection"==n?a=!0:((null!=(e=t[n.id])?e:1)&1)==0&&h.push(t[n.id]);return{create:t=>(t.values[s]=n(t),1),update(t,e){if(l&&e.docChanged||a&&(e.docChanged||e.selection)||$(t,h)){let e=n(t);if(o?!U(e,t.values[s],i):!i(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let l,a=e.config.address[r];if(null!=a){let r=tn(e,a);if(this.dependencies.every(n=>n instanceof H?e.facet(n)===t.facet(n):!(n instanceof J)||e.field(n,!1)==t.field(n,!1))||(o?U(l=n(t),r,i):i(l=n(t),r)))return t.values[s]=r,0}else l=n(t);return t.values[s]=l,1}}}}function U(t,e,n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}function $(t,e){let n=!1;for(let i of e)1&te(t,i)&&(n=!0);return n}let K=H.define({static:!0});class J{constructor(t,e,n,i,r){this.id=t,this.createF=e,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}static define(t){let e=new J(V++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(K).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,n)=>{let i=t.values[e],r=this.updateF(i,n);return this.compareF(i,r)?0:(t.values[e]=r,1)},reconfigure:(t,n)=>{let i=t.facet(K),r=n.facet(K),s;return(s=i.find(t=>t.field==this))&&s!=r.find(t=>t.field==this)?(t.values[e]=s.create(t),1):null!=n.config.address[this.id]?(t.values[e]=n.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,K.of({field:this,create:t})]}get extension(){return this}}function Y(t){return e=>new Z(e,t)}let G={highest:Y(0),high:Y(1),default:Y(2),low:Y(3),lowest:Y(4)};class Z{constructor(t,e){this.inner=t,this.prec=e}}class X{of(t){return new Q(this,t)}reconfigure(t){return X.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Q{constructor(t,e){this.compartment=t,this.inner=e}}class tt{constructor(t,e,n,i,r,s){for(this.base=t,this.compartments=e,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,n){var i,r,s;let o,l,a=[],h=Object.create(null),c=new Map;for(let n of(i=t,r=e,s=c,o=[[],[],[],[],[]],l=new Map,!function t(e,n){let i=l.get(e);if(null!=i){if(i<=n)return;let t=o[i].indexOf(e);t>-1&&o[i].splice(t,1),e instanceof Q&&s.delete(e.compartment)}if(l.set(e,n),Array.isArray(e))for(let i of e)t(i,n);else if(e instanceof Q){if(s.has(e.compartment))throw RangeError("Duplicate use of compartment in extensions");let i=r.get(e.compartment)||e.inner;s.set(e.compartment,i),t(i,n)}else if(e instanceof Z)t(e.inner,e.prec);else if(e instanceof J)o[n].push(e),e.provides&&t(e.provides,n);else if(e instanceof q)o[n].push(e),e.facet.extensions&&t(e.facet.extensions,2);else{let i=e.extension;if(!i)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(i,n)}}(i,2),o.reduce((t,e)=>t.concat(e))))n instanceof J?a.push(n):(h[n.facet.id]||(h[n.facet.id]=[])).push(n);let u=Object.create(null),f=[],d=[];for(let t of a)u[t.id]=d.length<<1,d.push(e=>t.slot(e));let p=null==n?void 0:n.config.facets;for(let t in h){let e=h[t],i=e[0].facet,r=p&&p[t]||[];if(e.every(t=>0==t.type))if(u[i.id]=f.length<<1|1,W(r,e))f.push(n.facet(i));else{let t=i.combine(e.map(t=>t.value));f.push(n&&i.compare(t,n.facet(i))?n.facet(i):t)}else{for(let t of e)0==t.type?(u[t.id]=f.length<<1|1,f.push(t.value)):(u[t.id]=d.length<<1,d.push(e=>t.dynamicSlot(e)));u[i.id]=d.length<<1,d.push(t=>(function(t,e,n){let i=n.map(e=>t[e.id]),r=n.map(t=>t.type),s=i.filter(t=>!(1&t)),o=t[e.id]>>1;function l(t){let n=[];for(let e=0;e<i.length;e++){let s=tn(t,i[e]);if(2==r[e])for(let t of s)n.push(t);else n.push(s)}return e.combine(n)}return{create(t){for(let e of i)te(t,e);return t.values[o]=l(t),1},update(t,n){if(!$(t,s))return 0;let i=l(t);return e.compare(i,t.values[o])?0:(t.values[o]=i,1)},reconfigure(t,r){let s=$(t,i),a=r.config.facets[e.id],h=r.facet(e);if(a&&!s&&W(n,a))return t.values[o]=h,0;let c=l(t);return e.compare(c,h)?(t.values[o]=h,0):(t.values[o]=c,1)}}})(t,i,e))}}return new tt(t,c,d.map(t=>t(u)),u,f,h)}}function te(t,e){if(1&e)return 2;let n=e>>1,i=t.status[n];if(4==i)throw Error("Cyclic dependency between fields and/or facets");if(2&i)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function tn(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}let ti=H.define(),tr=H.define({combine:t=>t.some(t=>t),static:!0}),ts=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),to=H.define(),tl=H.define(),ta=H.define(),th=H.define({combine:t=>!!t.length&&t[0]});class tc{constructor(t,e){this.type=t,this.value=e}static define(){return new tu}}class tu{of(t){return new tc(this,t)}}class tf{constructor(t){this.map=t}of(t){return new td(this,t)}}class td{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new td(this.type,e)}is(t){return this.type==t}static define(t={}){return new tf(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let n=[];for(let i of t){let t=i.map(e);t&&n.push(t)}return n}}td.reconfigure=td.define(),td.appendConfig=td.define();class tp{constructor(t,e,n,i,r,s){this.startState=t,this.changes=e,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,n&&z(n,e.newLength),r.some(t=>t.type==tp.time)||(this.annotations=r.concat(tp.time.of(Date.now())))}static create(t,e,n,i,r,s){return new tp(t,e,n,i,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(tp.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function tm(t,e,n){var i;let r,s,o;return n?(r=e.changes,s=E.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):null==(i=t.selection)?void 0:i.map(r),effects:td.mapEffects(t.effects,r).concat(td.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function tg(t,e,n){let i=e.selection,r=tb(e.annotations);return e.userEvent&&(r=r.concat(tp.userEvent.of(e.userEvent))),{changes:e.changes instanceof E?e.changes:E.of(e.changes||[],n,t.facet(ts)),selection:i&&(i instanceof _?i:_.single(i.anchor,i.head)),effects:tb(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}tp.time=tc.define(),tp.userEvent=tc.define(),tp.addToHistory=tc.define(),tp.remote=tc.define();let tv=[];function tb(t){return null==t?tv:Array.isArray(t)?t:[t]}var ty=((D=ty||(ty={}))[D.Word=0]="Word",D[D.Space=1]="Space",D[D.Other=2]="Other",D);let tw=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{i=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class tx{constructor(t,e,n,i,r,s){this.config=t,this.doc=e,this.selection=n,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)te(this,t<<1);this.computeSlot=null}field(t,e=!0){let n=this.config.address[t.id];if(null==n){if(e)throw RangeError("Field is not present in this state");return}return te(this,n),tn(this,n)}update(...t){return function t(e,n,i){let r=tg(e,n.length?n[0]:{},e.doc.length);n.length&&!1===n[0].filter&&(i=!1);for(let t=1;t<n.length;t++){!1===n[t].filter&&(i=!1);let s=!!n[t].sequential;r=tm(r,tg(e,n[t],s?r.changes.newLength:e.doc.length),s)}let s=tp.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(t){let e=t.startState,n=e.facet(ta),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=tm(i,tg(e,s,t.changes.newLength),!0))}return i==t?t:tp.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}(i?function(e){let n=e.startState,i=!0;for(let t of n.facet(to)){let n=t(e);if(!1===n){i=!1;break}Array.isArray(n)&&(i=!0===i?n:function(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i<t.length&&(r==e.length||e[r]>=t[i]))s=t[i++],o=t[i++];else{if(!(r<e.length))return n;s=e[r++],o=e[r++]}!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(i,n))}if(!0!==i){let t,r;if(!1===i)r=e.changes.invertedDesc,t=E.empty(n.doc.length);else{let n=e.changes.filter(i);t=n.changes,r=n.filtered.mapDesc(n.changes).invertedDesc}e=tp.create(n,t,e.selection&&e.selection.map(r),td.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let r=n.facet(tl);for(let i=r.length-1;i>=0;i--){let s=r[i](e);e=s instanceof tp?s:Array.isArray(s)&&1==s.length&&s[0]instanceof tp?s[0]:t(n,tb(s),!1)}return e}(s):s)}(this,t,!0)}applyTransaction(t){let e,n=this.config,{base:i,compartments:r}=n;for(let e of t.effects)e.is(X.reconfigure)?(n&&(r=new Map,n.compartments.forEach((t,e)=>r.set(e,t)),n=null),r.set(e.value.compartment,e.value.extension)):e.is(td.reconfigure)?(n=null,i=e.value):e.is(td.appendConfig)&&(n=null,i=tb(i).concat(e.value));e=n?t.startState.values.slice():new tx(n=tt.resolve(i,r,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values;let s=t.startState.facet(tr)?t.newSelection:t.newSelection.asSingle();new tx(n,t.newDoc,s,e,(e,n)=>n.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:_.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,n=t(e.ranges[0]),i=this.changes(n.changes),r=[n.range],s=tb(n.effects);for(let n=1;n<e.ranges.length;n++){let o=t(e.ranges[n]),l=this.changes(o.changes),a=l.map(i);for(let t=0;t<n;t++)r[t]=r[t].map(a);let h=i.mapDesc(l,!0);r.push(o.range.map(h)),i=i.compose(a),s=td.mapEffects(s,a).concat(td.mapEffects(tb(o.effects),h))}return{changes:i,selection:_.create(r,e.mainIndex),effects:s}}changes(t=[]){return t instanceof E?t:E.of(t,this.doc.length,this.facet(tx.lineSeparator))}toText(t){return d.of(t.split(this.facet(tx.lineSeparator)||O))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(te(this,e),tn(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let n in t){let i=t[n];i instanceof J&&null!=this.config.address[i.id]&&(e[n]=i.spec.toJSON(this.field(t[n]),this))}return e}static fromJSON(t,e={},n){if(!t||"string"!=typeof t.doc)throw RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let e in n)if(Object.prototype.hasOwnProperty.call(t,e)){let r=n[e],s=t[e];i.push(r.init(t=>r.spec.fromJSON(s,t)))}}return tx.create({doc:t.doc,selection:_.fromJSON(t.selection),extensions:e.extensions?i.concat([e.extensions]):i})}static create(t={}){let e=tt.resolve(t.extensions||[],new Map),n=t.doc instanceof d?t.doc:d.of((t.doc||"").split(e.staticFacet(tx.lineSeparator)||O)),i=t.selection?t.selection instanceof _?t.selection:_.single(t.selection.anchor,t.selection.head):_.single(0);return z(i,n.length),e.staticFacet(tr)||(i=i.asSingle()),new tx(e,n,i,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(tx.tabSize)}get lineBreak(){return this.facet(tx.lineSeparator)||"\n"}get readOnly(){return this.facet(th)}phrase(t,...e){for(let e of this.facet(tx.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,n)=>{if("$"==n)return"$";let i=+(n||1);return!i||i>e.length?t:e[i-1]})),t}languageDataAt(t,e,n=-1){let i=[];for(let r of this.facet(ti))for(let s of r(this,e,n))Object.prototype.hasOwnProperty.call(s,t)&&i.push(s[t]);return i}charCategorizer(t){var e;return e=this.languageDataAt("wordChars",t).join(""),t=>{if(!/\S/.test(t))return ty.Space;if(function(t){if(i)return i.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||tw.test(n)))return!0}return!1}(t))return ty.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ty.Word;return ty.Other}}wordAt(t){let{text:e,from:n,length:i}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-n,o=t-n;for(;s>0;){let t=k(e,s,!1);if(r(e.slice(t,s))!=ty.Word)break;s=t}for(;o<i;){let t=k(e,o);if(r(e.slice(o,t))!=ty.Word)break;o=t}return s==o?null:_.range(s+n,o+n)}}function tk(t,e,n={}){let i={};for(let e of t)for(let t of Object.keys(e)){let r=e[t],s=i[t];if(void 0===s)i[t]=r;else if(s===r||void 0===r);else if(Object.hasOwnProperty.call(n,t))i[t]=n[t](s,r);else throw Error("Config merge conflict for field "+t)}for(let t in e)void 0===i[t]&&(i[t]=e[t]);return i}tx.allowMultipleSelections=tr,tx.tabSize=H.define({combine:t=>t.length?t[0]:4}),tx.lineSeparator=ts,tx.readOnly=th,tx.phrases=H.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every(n=>t[n]==e[n])}}),tx.languageData=ti,tx.changeFilter=to,tx.transactionFilter=tl,tx.transactionExtender=ta,X.reconfigure=td.define();class tS{eq(t){return this==t}range(t,e=t){return tC.create(t,e,this)}}tS.prototype.startSide=tS.prototype.endSide=0,tS.prototype.point=!1,tS.prototype.mapMode=P.TrackDel;class tC{constructor(t,e,n){this.from=t,this.to=e,this.value=n}static create(t,e,n){return new tC(t,e,n)}}function tA(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class tO{constructor(t,e,n,i){this.from=t,this.to=e,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(t,e,n,i=0){let r=n?this.to:this.from;for(let s=i,o=r.length;;){if(s==o)return s;let i=s+o>>1,l=r[i]-t||(n?this.value[i].endSide:this.value[i].startSide)-e;if(i==s)return l>=0?s:o;l>=0?o=i:s=i+1}}between(t,e,n,i){for(let r=this.findIndex(e,-1e9,!0),s=this.findIndex(n,1e9,!1,r);r<s;r++)if(!1===i(this.from[r]+t,this.to[r]+t,this.value[r]))return!1}map(t,e){let n=[],i=[],r=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+t,c=this.to[l]+t,u,f;if(h==c){let t=e.mapPos(h,a.startSide,a.mapMode);if(null==t||(u=f=t,a.startSide!=a.endSide&&(f=e.mapPos(h,a.endSide))<u))continue}else if((u=e.mapPos(h,a.startSide))>(f=e.mapPos(c,a.endSide))||u==f&&a.startSide>0&&a.endSide<=0)continue;0>(f-u||a.endSide-a.startSide)||(s<0&&(s=u),a.point&&(o=Math.max(o,f-u)),n.push(a),i.push(u-s),r.push(f-s))}return{mapped:n.length?new tO(i,r,n,o):null,pos:s}}}class tM{constructor(t,e,n,i){this.chunkPos=t,this.chunk=e,this.nextLayer=n,this.maxPoint=i}static create(t,e,n,i){return new tM(t,e,n,i)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(n&&(e=e.slice().sort(tA)),this.isEmpty)return e.length?tM.of(e):this;let o=new tT(this,null,-1).goto(0),l=0,a=[],h=new tD;for(;o.value||l<e.length;)if(l<e.length&&(o.from-e[l].from||o.startSide-e[l].value.startSide)>=0){let t=e[l++];h.addInner(t.from,t.to,t.value)||a.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==e.length||this.chunkEnd(o.chunkIndex)<e[l].from)&&(!s||i>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||i>o.to||r<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(tC.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?tM.empty:this.nextLayer.update({add:a,filter:s,filterFrom:i,filterTo:r}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=t.touchesRange(s,s+o.length);if(!1===l)i=Math.max(i,o.maxPoint),e.push(o),n.push(t.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,t);r&&(i=Math.max(i,r.maxPoint),e.push(r),n.push(l))}}let r=this.nextLayer.map(t);return 0==e.length?r:new tM(n,e,r||tM.empty,i)}between(t,e,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],s=this.chunk[i];if(e>=r&&t<=r+s.length&&!1===s.between(r,t-r,e-r,n))return}this.nextLayer.between(t,e,n)}}iter(t=0){return tE.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return tE.from(t).goto(e)}static compare(t,e,n,i,r=-1){let s=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r),o=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r),l=tP(s,o,n),a=new tB(s,l,r),h=new tB(o,l,r);n.iterGaps((t,e,n)=>tL(a,t,h,e,n,i)),n.empty&&0==n.length&&tL(a,0,h,0,0,i)}static eq(t,e,n=0,i){null==i&&(i=0x3b9ac9ff);let r=t.filter(t=>!t.isEmpty&&0>e.indexOf(t)),s=e.filter(e=>!e.isEmpty&&0>t.indexOf(e));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=tP(r,s),l=new tB(r,o,0).goto(n),a=new tB(s,o,0).goto(n);for(;;){if(l.to!=a.to||!tN(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>i)return!0;l.next(),a.next()}}static spans(t,e,n,i,r=-1){let s=new tB(t,null,r).goto(e),o=e,l=s.openStart;for(;;){let t=Math.min(s.to,n);if(s.point){let n=s.activeForPoint(s.to),r=s.pointFrom<e?n.length+1:s.point.startSide<0?n.length:Math.min(n.length,l);i.point(o,t,s.point,n,r,s.pointRank),l=Math.min(s.openEnd(t),n.length)}else t>o&&(i.span(o,t,s.active,l),l=s.openEnd(t));if(s.to>n)return l+(s.point&&s.to>n?1:0);o=s.to,s.next()}}static of(t,e=!1){let n=new tD;for(let i of t instanceof tC?[t]:e?function(t){if(t.length>1)for(let e=t[0],n=1;n<t.length;n++){let i=t[n];if(tA(e,i)>0)return t.slice().sort(tA);e=i}return t}(t):t)n.add(i.from,i.to,i.value);return n.finish()}static join(t){if(!t.length)return tM.empty;let e=t[t.length-1];for(let n=t.length-2;n>=0;n--)for(let i=t[n];i!=tM.empty;i=i.nextLayer)e=new tM(i.chunkPos,i.chunk,e,Math.max(i.maxPoint,e.maxPoint));return e}}tM.empty=new tM([],[],null,-1),tM.empty.nextLayer=tM.empty;class tD{finishChunk(t){this.chunks.push(new tO(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,t&&(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(t,e,n){this.addInner(t,e,n)||(this.nextLayer||(this.nextLayer=new tD)).add(t,e,n)}addInner(t,e,n){let i=t-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&0>(t-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=n,this.lastFrom=t,this.lastTo=e,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if(0>(t-this.lastTo||e.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let n=e.value.length-1;return this.last=e.value[n],this.lastFrom=e.from[n]+t,this.lastTo=e.to[n]+t,!0}finish(){return this.finishInner(tM.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=tM.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function tP(t,e,n){let i=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&i.set(e.chunk[t],e.chunkPos[t]);let r=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let s=i.get(t.chunk[e]);null==s||(n?n.mapPos(s):s)!=t.chunkPos[e]||(null==n?void 0:n.touchesRange(s,s+t.chunk[e].length))||r.add(t.chunk[e])}return r}class tT{constructor(t,e,n,i=0){this.layer=t,this.skip=e,this.minPoint=n,this.rank=i}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,n){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(t,e){0>(this.to-t||this.endSide-e)&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],n=t+e.from[this.rangeIndex];if(this.from=n,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==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=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class tE{constructor(t){this.heap=t}static from(t,e=null,n=-1){let i=[];for(let r=0;r<t.length;r++)for(let s=t[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&i.push(new tT(s,e,n,r));return 1==i.length?i[0]:new tE(i)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let n of this.heap)n.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)tR(this.heap,t);return this.next(),this}forward(t,e){for(let n of this.heap)n.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)tR(this.heap,t);0>(this.to-t||this.value.endSide-e)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),tR(this.heap,0)}}}function tR(t,e){for(let n=t[e];;){let i=(e<<1)+1;if(i>=t.length)break;let r=t[i];if(i+1<t.length&&r.compare(t[i+1])>=0&&(r=t[i+1],i++),0>n.compare(r))break;t[i]=n,t[e]=r,e=i}}class tB{constructor(t,e,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=tE.from(t,e,n)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e);)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){tI(this.active,t),tI(this.activeTo,t),tI(this.activeRank,t),this.minActive=tj(this.active,this.activeTo)}addActive(t){let e=0,{value:n,to:i,rank:r}=this.cursor;for(;e<this.activeRank.length&&(r-this.activeRank[e]||i-this.activeTo[e])>0;)e++;tF(this.active,e,n),tF(this.activeTo,e,i),tF(this.activeRank,e,r),t&&tF(t,e,this.cursor.from),this.minActive=tj(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&0>(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)){if(this.activeTo[i]>t){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&tI(n,i)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let t=this.cursor.value;if(t.point)if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let e=n.length-1;e>=0&&n[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>t||this.activeTo[n]==t&&this.active[n].endSide>=this.point.endSide)&&e.push(this.active[n]);return e.reverse()}openEnd(t){let e=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>t;n--)e++;return e}}function tL(t,e,n,i,r,s){t.goto(e),n.goto(i);let o=i+r,l=i,a=i-e;for(;;){let e=t.to+a-n.to,i=e||t.endSide-n.endSide,r=i<0?t.to+a:n.to,h=Math.min(r,o);if(t.point||n.point?t.point&&n.point&&(t.point==n.point||t.point.eq(n.point))&&tN(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,h,t.point,n.point):h>l&&!tN(t.active,n.active)&&s.compareRange(l,h,t.active,n.active),r>o)break;(e||t.openEnd!=n.openEnd)&&s.boundChange&&s.boundChange(r),l=r,i<=0&&t.next(),i>=0&&n.next()}}function tN(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n]&&!t[n].eq(e[n]))return!1;return!0}function tI(t,e){for(let n=e,i=t.length-1;n<i;n++)t[n]=t[n+1];t.pop()}function tF(t,e,n){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=n}function tj(t,e){let n=-1,i=1e9;for(let r=0;r<e.length;r++)0>(e[r]-i||t[r].endSide-t[n].endSide)&&(n=r,i=e[r]);return n}function t_(t,e,n=t.length){let i=0;for(let r=0;r<n&&r<t.length;)9==t.charCodeAt(r)?(i+=e-i%e,r++):(i++,r=k(t,r));return i}function tz(t,e,n,i){for(let i=0,r=0;;){if(r>=e)return i;if(i==t.length)break;r+=9==t.charCodeAt(i)?n-r%n:1,i=k(t,i)}return!0===i?-1:t.length}},867:function(t,e,n){let i;n.d(e,{N$:function(){return it},Z9:function(){return t4},Eg:function(){return iP},Lz:function(){return nA},NZ:function(){return tf},Wu:function(){return i9},w4:function(){return nB},D4:function(){return ih},TS:function(){return nI},ld:function(){return iR},OP:function(){return tC},DK:function(){return iS},wJ:function(){return iF},S7:function(){return iI},dz:function(){return is},$K:function(){return i4},HJ:function(){return id},xO:function(){return tc},c_:function(){return tQ},cU:function(){return iH},A:function(){return n2},VH:function(){return nK},Ux:function(){return iD}});for(var r,s,o,l=n(492),a=n(690),h={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:"'"},c={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},u="u">typeof navigator&&/Mac/.test(navigator.platform),f="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),d=0;d<10;d++)h[48+d]=h[96+d]=String(d);for(var d=1;d<=24;d++)h[d+111]="F"+d;for(var d=65;d<=90;d++)h[d]=String.fromCharCode(d+32),c[d]=String.fromCharCode(d);for(var p in h)c.hasOwnProperty(p)||(c[p]=h[p]);function m(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function g(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function v(t,e){if(!e.anchorNode)return!1;try{return g(t,e.anchorNode)}catch(t){return!1}}function b(t){return 3==t.nodeType?P(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function y(t,e,n,i){return!!n&&(k(t,e,n,i,-1)||k(t,e,n,i,1))}function w(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function x(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function k(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:S(t))){if("DIV"==t.nodeName)return!1;let n=t.parentNode;if(!n||1!=n.nodeType)return!1;e=w(t)+(r<0?0:1),t=n}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(r<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=r<0?S(t):0}}}function S(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function C(t,e){let n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function A(t,e){let n=e.width/t.offsetWidth,i=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(e.width-t.offsetWidth))&&(n=1),(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(e.height-t.offsetHeight))&&(i=1),{scaleX:n,scaleY:i}}class O{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:n}=t;this.set(e,Math.min(t.anchorOffset,e?S(e):0),n,Math.min(t.focusOffset,n?S(n):0))}set(t,e,n,i){this.anchorNode=t,this.anchorOffset=e,this.focusNode=n,this.focusOffset=i}}let M=null;function D(t){if(t.setActive)return t.setActive();if(M)return t.focus(M);let e=[];for(let n=t;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(t.focus(null==M?{get preventScroll(){return M={preventScroll:!0},!0}}:void 0),!M){M=!1;for(let t=0;t<e.length;){let n=e[t++],i=e[t++],r=e[t++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function P(t,e,n=e){let r=i||(i=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function T(t,e,n,i){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function E(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function R(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function B(t,e){for(let n=t,i=e;;)if(3==n.nodeType&&i>0)return{node:n,offset:i};else if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;i=S(n=n.childNodes[i-1])}else{if(!n.parentNode||x(n))return null;i=w(n),n=n.parentNode}}function L(t,e){for(let n=t,i=e;;)if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};else if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||x(n))return null;i=w(n)+1,n=n.parentNode}}class N{constructor(t,e,n=!0){this.node=t,this.offset=e,this.precise=n}static before(t,e){return new N(t.parentNode,w(t),e)}static after(t,e){return new N(t.parentNode,w(t)+1,e)}}let I=[];class F{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let n of this.children){if(n==t)return e;e+=n.length+n.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let n=this.dom,i=null,r;for(let s of this.children){if(7&s.flags){if(!s.dom&&(r=i?i.nextSibling:n.firstChild)){let t=F.get(r);(!t||!t.parent&&t.canReuseDOM(s))&&s.reuseDOM(r)}s.sync(t,e),s.flags&=-8}if(r=i?i.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&r!=s.dom&&(e.written=!0),s.dom.parentNode==n)for(;r&&r!=s.dom;)r=j(r);else n.insertBefore(s.dom,r);i=s.dom}for((r=i?i.nextSibling:n.firstChild)&&e&&e.node==n&&(e.written=!0);r;)r=j(r)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(t,e),n.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let n;if(t==this.dom)n=this.dom.childNodes[e];else{let i=0==S(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==i&&e.firstChild!=e.lastChild&&(i=t==e.firstChild?-1:1),t=e}n=i<0?t:t.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!F.get(n);)n=n.nextSibling;if(!n)return this.length;for(let t=0,e=0;;t++){let i=this.children[t];if(i.dom==n)return e;e+=i.length+i.breakAfter}}domBoundsAround(t,e,n=0){let i=-1,r=-1,s=-1,o=-1;for(let l=0,a=n,h=n;l<this.children.length;l++){let n=this.children[l],c=a+n.length;if(a<t&&c>e)return n.domBoundsAround(t,e,a);if(c>=t&&-1==i&&(i=l,r=a),a>e&&n.dom.parentNode==this.dom){s=l,o=h;break}h=c,a=c+n.breakAfter}return{from:r,to:o<0?n+this.length:o,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,n=I){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&0>n.indexOf(t)&&t.destroy()}n.length<250?this.children.splice(t,e-t,...n):this.children=[].concat(this.children.slice(0,t),n,this.children.slice(e));for(let t=0;t<n.length;t++)n[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new _(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,n,i,r,s){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!((this.flags|t.flags)&8)}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function j(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}F.prototype.breakAfter=0;class _{constructor(t,e,n){this.children=t,this.pos=e,this.i=n,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function z(t,e,n,i,r,s,o,l,a){let{children:h}=t,c=h.length?h[e]:null,u=s.length?s[s.length-1]:null,f=u?u.breakAfter:o;if(!(e==i&&c&&!o&&!f&&s.length<2&&c.merge(n,r,s.length?u:null,0==n,l,a))){if(i<h.length){let t=h[i];t&&(r<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==i&&(t=t.split(r),r=0),!f&&u&&t.merge(0,r,u,!0,0,a)?s[s.length-1]=t:((r||t.children.length&&!t.children[0].length)&&t.merge(0,r,null,!1,0,a),s.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,n>0&&(!o&&s.length&&c.merge(n,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(n<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(n,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&t.replaceChildren(e,i,s)}}function V(t,e,n,i,r,s){let o=t.childCursor(),{i:l,off:a}=o.findPos(n,1),{i:h,off:c}=o.findPos(e,-1),u=e-n;for(let t of i)u+=t.length;t.length+=u,z(t,h,c,l,a,i,0,r,s)}let H="u">typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},W="u">typeof document?document:{documentElement:{style:{}}},q=/Edge\/(\d+)/.exec(H.userAgent),U=/MSIE \d/.test(H.userAgent),$=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(H.userAgent),K=!!(U||$||q),J=!K&&/gecko\/(\d+)/i.test(H.userAgent),Y=!K&&/Chrome\/(\d+)/.exec(H.userAgent),G="webkitFontSmoothing"in W.documentElement.style,Z=!K&&/Apple Computer/.test(H.vendor),X=Z&&(/Mobile\/\w+/.test(H.userAgent)||H.maxTouchPoints>2);var Q={mac:X||/Mac/.test(H.platform),windows:/Win/.test(H.platform),linux:/Linux|X11/.test(H.platform),ie:K,ie_version:U?W.documentMode||6:$?+$[1]:q?+q[1]:0,gecko:J,gecko_version:J?+(/Firefox\/(\d+)/.exec(H.userAgent)||[0,0])[1]:0,chrome:!!Y,chrome_version:Y?+Y[1]:0,ios:X,android:/Android\b/.test(H.userAgent),webkit:G,safari:Z,webkit_version:G?+(/\bAppleWebKit\/(\d+)/.exec(H.userAgent)||[0,0])[1]:0,tabSize:null!=W.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class tt extends F{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,n){return!(8&this.flags)&&(!n||n instanceof tt&&!(this.length-(e-t)+n.length>256)&&!(8&n.flags))&&(this.text=this.text.slice(0,t)+(n?n.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new tt(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new N(this.dom,t)}domBoundsAround(t,e,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,n){let i=t.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;0==e&&n<0||e==i&&n>=0?!(Q.chrome||Q.gecko)&&(e?(r--,o=1):s<i&&(s++,o=-1)):n<0?r--:s<i&&s++;let l=P(t,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:n>=0)?0:l.length-1];return Q.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(l,t=>t.width)||a),o?C(a,o<0):a||null}(this.dom,t,e)}}class te extends F{constructor(t,e=[],n=0){for(let i of(super(),this.mark=t,this.children=e,this.length=n,e))i.setParent(this)}setAttrs(t){if(E(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,n,i,r,s){return(!n||!!(n instanceof te&&n.mark.eq(this.mark))&&(!t||!(r<=0))&&(!(e<this.length)||!(s<=0)))&&(V(this,t,e,n?n.children.slice():[],r-1,s-1),this.markDirty(),!0)}split(t){let e=[],n=0,i=-1,r=0;for(let s of this.children){let o=n+s.length;o>t&&e.push(n<t?s.split(t-n):s),i<0&&n>=t&&(i=r),n=o,r++}let s=this.length-t;return this.length=t,i>-1&&(this.children.length=i,this.markDirty()),new te(this.mark,e,s)}domAtPos(t){return tr(this,t)}coordsAt(t,e){return ts(this,t,e)}}class tn extends F{static create(t,e,n){return new tn(t,e,n)}constructor(t,e,n){super(),this.widget=t,this.length=e,this.side=n,this.prevWidget=null}split(t){let e=tn.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,n,i,r,s){return(!n||n instanceof tn&&!!this.widget.compare(n.widget)&&(!(t>0)||!(r<=0))&&(!(e<this.length)||!(s<=0)))&&(this.length=t+(n?n.length:0)+(this.length-e),!0)}become(t){return t instanceof tn&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return l.EY.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,n=e&&e.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):l.EY.empty}domAtPos(t){return(this.length?0==t:this.side>0)?N.before(this.dom):N.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let n=this.widget.coordsAt(this.dom,t,e);if(n)return n;let i=this.dom.getClientRects(),r=null;if(!i.length)return null;let s=this.side?this.side<0:t>0;for(let e=s?i.length-1:0;r=i[e],t>0?0!=e:e!=i.length-1&&!(r.top<r.bottom);e+=s?-1:1);return C(r,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ti extends F{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof ti&&t.side==this.side}split(){return new ti(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?N.before(this.dom):N.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return l.EY.empty}get isHidden(){return!0}}function tr(t,e){let n=t.dom,{children:i}=t,r=0;for(let t=0;r<i.length;r++){let s=i[r],o=t+s.length;if(!(o==t&&0>=s.getSide())){if(e>t&&e<o&&s.dom.parentNode==n)return s.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=r;t>0;t--){let e=i[t-1];if(e.dom.parentNode==n)return e.domAtPos(e.length)}for(let t=r;t<i.length;t++){let e=i[t];if(e.dom.parentNode==n)return e.domAtPos(0)}return new N(n,0)}function ts(t,e,n){let i=null,r=-1,s=null,o=-1;!function t(e,l){for(let a=0,h=0;a<e.children.length&&h<=l;a++){let c=e.children[a],u=h+c.length;u>=l&&(c.children.length?t(c,l-h):(!s||s.isHidden&&(n>0||function(t,e){let n=t.coordsAt(0,1),i=e.coordsAt(0,1);return n&&i&&i.top<n.bottom}(s,c)))&&(u>l||h==u&&c.getSide()>0)?(s=c,o=l-h):(h<l||h==u&&0>c.getSide()&&!c.isHidden)&&(i=c,r=l-h)),h=u}}(t,e);let l=(n<0?i:s)||i||s;return l?l.coordsAt(Math.max(0,l==i?r:o),n):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=b(e);return n[n.length-1]||null}(t)}function to(t,e){for(let n in t)"class"==n&&e.class?e.class+=" "+t.class:"style"==n&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}tt.prototype.children=tn.prototype.children=ti.prototype.children=I;let tl=Object.create(null);function ta(t,e,n){if(t==e)return!0;t||(t=tl),e||(e=tl);let i=Object.keys(t),r=Object.keys(e);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let s of i)if(s!=n&&(-1==r.indexOf(s)||t[s]!==e[s]))return!1;return!0}function th(t,e,n){let i=!1;if(e)for(let r in e)n&&r in n||(i=!0,"style"==r?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(i=!0,"style"==r?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return i}class tc{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var tu=((r=tu||(tu={}))[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r);class tf extends l.FB{constructor(t,e,n,i){super(),this.startSide=t,this.endSide=e,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(t){return new td(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),n=!!t.block;return e+=n&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new tm(t,e,e,n,t.widget||null,!1)}static replace(t){let e=!!t.block,n,i;if(t.isBlockGap)n=-5e8,i=4e8;else{let{start:r,end:s}=tg(t,e);n=(r?e?-3e8:-1:5e8)-1,i=(s?e?2e8:1:-6e8)+1}return new tm(t,n,i,e,t.widget||null,!0)}static line(t){return new tp(t)}static set(t,e=!1){return l.om.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}tf.none=l.om.empty;class td extends tf{constructor(t){let{start:e,end:n}=tg(t);super(e?-1:5e8,n?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,n;return this==t||t instanceof td&&this.tagName==t.tagName&&(this.class||(null==(e=this.attrs)?void 0:e.class))==(t.class||(null==(n=t.attrs)?void 0:n.class))&&ta(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}td.prototype.point=!1;class tp extends tf{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof tp&&this.spec.class==t.spec.class&&ta(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}tp.prototype.mapMode=l.iR.TrackBefore,tp.prototype.point=!0;class tm extends tf{constructor(t,e,n,i,r,s){super(e,n,r,t),this.block=i,this.isReplace=s,this.mapMode=i?e<=0?l.iR.TrackBefore:l.iR.TrackAfter:l.iR.TrackDel}get type(){return this.startSide!=this.endSide?tu.WidgetRange:this.startSide<=0?tu.WidgetBefore:tu.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){var e,n;return t instanceof tm&&(e=this.widget,e==(n=t.widget)||!!(e&&n&&e.compare(n)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function tg(t,e=!1){let{inclusiveStart:n,inclusiveEnd:i}=t;return null==n&&(n=t.inclusive),null==i&&(i=t.inclusive),{start:null!=n?n:e,end:null!=i?i:e}}function tv(t,e,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}tm.prototype.point=!0;class tb extends F{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,n,i,r,s){if(n){if(!(n instanceof tb))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),V(this,t,e,n?n.children.slice():[],r,s),!0}split(t){let e=new tb;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:n,off:i}=this.childPos(t);i&&(e.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let t=n;t<this.children.length;t++)e.append(this.children[t],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){ta(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function t(e,n,i){let r,{children:s}=e;i>0&&n instanceof te&&s.length&&(r=s[s.length-1])instanceof te&&r.mark.eq(n.mark)?t(r,n.children[0],i-1):(s.push(n),n.setParent(e)),e.length+=n.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,n=t.spec.class;e&&(this.attrs=to(e,this.attrs||{})),n&&(this.attrs=to({class:n},this.attrs||{}))}domAtPos(t){return tr(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var n;this.dom?4&this.flags&&(E(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(th(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let i=this.dom.lastChild;for(;i&&F.get(i)instanceof te;)i=i.lastChild;if(!i||!this.length||"BR"!=i.nodeName&&(null==(n=F.get(i))?void 0:n.isEditable)==!1&&(!Q.ios||!this.children.some(t=>t instanceof tt))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0,e;for(let n of this.children){if(!(n instanceof tt)||/[^ -~]/.test(n.text))return null;let i=b(n.dom);if(1!=i.length)return null;t+=i[0].width,e=i[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let n=ts(this,t,e);if(!this.children.length&&n&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=n.bottom-n.top;if(2>Math.abs(e-t.lineHeight)&&t.textHeight<e){let i=(e-t.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(t){return t instanceof tb&&0==this.children.length&&0==t.children.length&&ta(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let n=0,i=0;n<t.children.length;n++){let r=t.children[n],s=i+r.length;if(s>=e){if(r instanceof tb)return r;if(s>e)break}i=s+r.breakAfter}return null}}class ty extends F{constructor(t,e,n){super(),this.widget=t,this.length=e,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(t,e,n,i,r,s){return(!n||n instanceof ty&&!!this.widget.compare(n.widget)&&(!(t>0)||!(r<=0))&&(!(e<this.length)||!(s<=0)))&&(this.length=t+(n?n.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?N.before(this.dom):N.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let n=new ty(this.widget,e,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return I}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):l.EY.empty}domBoundsAround(){return null}become(t){return t instanceof ty&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let n=this.widget.coordsAt(this.dom,t,e);return n||(this.widget instanceof tw?null:C(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:n}=this.deco;return e!=n&&(t<0?e<0:n>0)}}class tw extends tc{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class tx{constructor(t,e,n,i){this.doc=t,this.pos=e,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof ty&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new tb),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(tk(new ti(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof ty||this.getLine()}buildText(t,e,n){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let i=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-n)),this.getLine().append(tk(new tt(this.text.slice(this.textOff,this.textOff+i)),e),n),this.atCursorPos=!0,this.textOff+=i,t-=i,n=0}}span(t,e,n,i){this.buildText(e-t,n,i),this.pos=e,this.openStart<0&&(this.openStart=i)}point(t,e,n,i,r,s){if(this.disallowBlockEffectsFor[s]&&n instanceof tm){if(n.block)throw RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=e-t;if(n instanceof tm)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ty(n.widget||tS.block,o,n));else{let s=tn.create(n.widget||tS.inline,o,o?0:n.startSide),l=this.atCursorPos&&!s.isEditable&&r<=i.length&&(t<e||n.startSide>0),a=!s.isEditable&&(t<e||r>i.length||n.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),l&&(h.append(tk(new ti(1),i),r),r=i.length+Math.max(0,r-i.length)),h.append(tk(s,i),r),this.atCursorPos=a,this.pendingBuffer=a?t<e||r>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=r)}static build(t,e,n,i,r){let s=new tx(t,e,n,r);return s.openEnd=l.om.spans(i,e,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function tk(t,e){for(let n of e)t=new te(n,[t],t.length);return t}class tS extends tc{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}tS.inline=new tS("span"),tS.block=new tS("div");var tC=((s=tC||(tC={}))[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s);let tA=tC.LTR,tO=tC.RTL;function tM(t){let e=[];for(let n=0;n<t.length;n++)e.push(1<<t[n]);return e}let tD=tM("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),tP=tM("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),tT=Object.create(null),tE=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),n=t.charCodeAt(1);tT[e]=n,tT[n]=-e}function tR(t){return t<=247?tD[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?tP[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}let tB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class tL{get dir(){return this.level%2?tO:tA}constructor(t,e,n){this.from=t,this.to=e,this.level=n}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,n,i){let r=-1;for(let s=0;s<t.length;s++){let o=t[s];if(o.from<=e&&o.to>=e){if(o.level==n)return s;(r<0||(0!=i?i<0?o.from<e:o.to>e:t[r].level>o.level))&&(r=s)}}if(r<0)throw RangeError("Index out of range");return r}}let tN=[];function tI(t){return[new tL(0,t,0)]}let tF="",tj=l.sj.define(),t_=l.sj.define(),tz=l.sj.define(),tV=l.sj.define(),tH=l.sj.define(),tW=l.sj.define(),tq=l.sj.define(),tU=l.sj.define(),t$=l.sj.define(),tK=l.sj.define({combine:t=>t.some(t=>t)}),tJ=l.sj.define({combine:t=>t.some(t=>t)}),tY=l.sj.define();class tG{constructor(t,e="nearest",n="nearest",i=5,r=5,s=!1){this.range=t,this.y=e,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=s}map(t){return t.empty?this:new tG(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new tG(l.OF.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let tZ=l.Pe.define({map:(t,e)=>t.map(e)}),tX=l.Pe.define();function tQ(t,e,n){let i=t.facet(tV);i.length?i[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}let t0=l.sj.define({combine:t=>!t.length||t[0]}),t1=0,t2=l.sj.define({combine:t=>t.filter((e,n)=>{for(let i=0;i<n;i++)if(t[i].plugin==e.plugin)return!1;return!0})});class t4{constructor(t,e,n,i,r){this.id=t,this.create=e,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(t2.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(t2.of({plugin:this,arg:t}))}static define(t,e){let{eventHandlers:n,eventObservers:i,provide:r,decorations:s}=e||{};return new t4(t1++,t,n,i,t=>{let e=[];return s&&e.push(t9.of(e=>{let n=e.plugin(t);return n?s(n):tf.none})),r&&e.push(r(t)),e})}static fromClass(t,e){return t4.define((e,n)=>new t(e,n),e)}}class t3{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(tQ(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){tQ(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null==(e=this.value)?void 0:e.destroy)try{this.value.destroy()}catch(e){tQ(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let t8=l.sj.define(),t5=l.sj.define(),t9=l.sj.define(),t6=l.sj.define(),t7=l.sj.define(),et=l.sj.define();function ee(t,e){let n=t.state.facet(et);if(!n.length)return n;let i=n.map(e=>e instanceof Function?e(t):e),r=[];return l.om.spans(i,e.from,e.to,{point(){},span(t,n,i,s){let o=t-e.from,l=n-e.from,a=r;for(let t=i.length-1;t>=0;t--,s--){let n=i[t].spec.bidiIsolate,r;if(null==n&&(n=function(t,e,n){for(let i=e;i<n;i++){let e=tR(t.charCodeAt(i));if(1==e)break;if(2==e||4==e)return tO}return tA}(e.text,o,l)),s>0&&a.length&&(r=a[a.length-1]).to==o&&r.direction==n)r.to=l,a=r.inner;else{let t={from:o,to:l,direction:n,inner:[]};a.push(t),a=t.inner}}}}),r}let en=l.sj.define();function ei(t){let e=0,n=0,i=0,r=0;for(let s of t.state.facet(en)){let o=s(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(i=Math.max(i,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:e,right:n,top:i,bottom:r}}let er=l.sj.define();class es{constructor(t,e,n,i){this.fromA=t,this.toA=e,this.fromB=n,this.toB=i}join(t){return new es(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,n=this;for(;e>0;e--){let i=t[e-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),t.splice(e-1,1)}}return t.splice(e,0,n),t}static extendWithRanges(t,e){if(0==e.length)return t;let n=[];for(let i=0,r=0,s=0,o=0;;i++){let l=i==t.length?null:t[i],a=s-o,h=l?l.fromB:1e9;for(;r<e.length&&e[r]<h;){let t=e[r],i=e[r+1],s=Math.max(o,t),l=Math.min(h,i);if(s<=l&&new es(s+a,l+a,s,l).addToSet(n),i>h)break;r+=2}if(!l)return n;new es(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),s=l.toA,o=l.toB}}}class eo{constructor(t,e,n){for(let i of(this.view=t,this.state=e,this.transactions=n,this.flags=0,this.startState=t.state,this.changes=l.VR.empty(this.startState.doc.length),n))this.changes=this.changes.compose(i.changes);let i=[];this.changes.iterChangedRanges((t,e,n,r)=>i.push(new es(t,e,n,r))),this.changedRanges=i}static create(t,e,n){return new eo(t,e,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class el extends F{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=tf.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new tb],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new es(0,0,0,t.state.doc.length)],0,null)}update(t){var e,n,i,r,s,o;let a,h,c=t.changedRanges;this.minWidth>0&&c.length&&(c.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let u=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null==(e=this.domChanged)?void 0:e.newSel)?u=this.domChanged.newSel.head:(n=t.changes,i=this.hasComposition,a=!1,i&&n.iterChangedRanges((t,e)=>{t<i.to&&e>i.from&&(a=!0)}),a||t.selectionSet||(u=t.state.selection.main.head)));let f=u>-1?function(t,e,n){let i=ea(t,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new es(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let e=r.parentNode;;e=e.parentNode){let n=F.get(e);if(n instanceof te)c.push({node:e,deco:n.mark});else{if(n instanceof tb||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:h,text:r,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new td({inclusive:!0,attributes:function(t){let e=Object.create(null);for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=i.value}return e}(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,u):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;c=new es(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(c.slice())}this.hasComposition=f?{from:f.range.fromB,to:f.range.toB}:null,(Q.ie||Q.chrome)&&!f&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let d=(r=this.decorations,s=this.updateDeco(),o=t.changes,h=new eh,l.om.compare(r,s,o,h),h.changes);return c=es.extendWithRanges(c,d),(!!(7&this.flags)||0!=c.length)&&(this.updateInner(c,t.startState.doc.length,f),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,n);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Q.chrome||Q.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof ty&&t.widget instanceof tw&&r.push(t.dom);i.updateGaps(r)}updateChildren(t,e,n){let i=n?n.range.addToSet(t.slice()):t,r=this.childCursor(e);for(let t=i.length-1;;t--){let e=t>=0?i[t]:null;if(!e)break;let{fromA:s,toA:o,fromB:l,toB:a}=e,h,c,u,f;if(n&&n.range.fromB<a&&n.range.toB>l){let t=tx.build(this.view.state.doc,l,n.range.fromB,this.decorations,this.dynamicDecorationMap),e=tx.build(this.view.state.doc,n.range.toB,a,this.decorations,this.dynamicDecorationMap);c=t.breakAtStart,u=t.openStart,f=e.openEnd;let i=this.compositionView(n);e.breakAtStart?i.breakAfter=1:e.content.length&&i.merge(i.length,i.length,e.content[0],!1,e.openStart,0)&&(i.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&i.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),h=t.content.concat(i).concat(e.content)}else({content:h,breakAtStart:c,openStart:u,openEnd:f}=tx.build(this.view.state.doc,l,a,this.decorations,this.dynamicDecorationMap));let{i:d,off:p}=r.findPos(o,1),{i:m,off:g}=r.findPos(s,-1);z(this,m,g,d,p,h,c,u,f)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(t){for(let e of(this.editContextFormatting=this.editContextFormatting.map(t.changes),t.transactions))for(let t of e.effects)t.is(tX)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new tt(t.text.nodeValue);for(let{deco:n}of(e.flags|=8,t.marks))e=new te(n,[e],e.length);let n=new tb;return n.append(e,0),n}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|!!e.children.some(t=>7&t.flags),this.markedForComposition.add(e);let n=F.get(t);n&&n!=e&&(n.dom=null),e.setDOM(t)},n=this.childPos(t.range.fromB,1),i=this.children[n.i];e(t.line,i);for(let r=t.marks.length-1;r>=-1;r--)n=i.childPos(n.off,1),i=i.children[n.i],e(r>=0?t.marks[r].node:t.text,i)}updateSelection(t=!1,e=!1){var n;(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&!(this.view.state.facet(t0)||this.dom.tabIndex>-1)&&v(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(Q.gecko&&l.empty&&!this.hasComposition&&1==(n=a).node.nodeType&&n.node.firstChild&&(0==n.offset||"false"==n.node.childNodes[n.offset-1].contentEditable)&&(n.offset==n.node.childNodes.length||"false"==n.node.childNodes[n.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null)),a=h=new N(t,0),o=!0}let c=this.view.observer.selectionRange;!o&&c.focusNode&&(y(a.node,a.offset,c.anchorNode,c.anchorOffset)&&y(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,l))||(this.view.observer.ignore(()=>{Q.android&&Q.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=m(this.view.root);if(t)if(l.empty){if(Q.gecko){var e,n;let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|2*(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable));if(t&&3!=t){let e=(1==t?B:L)(a.node,a.offset);e&&(a=new N(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=l.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=l.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(h.node,h.offset)}catch(t){}}else{let e=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),e.setEnd(h.node,h.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new N(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new N(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&y(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,n=m(t.root),{anchorNode:i,anchorOffset:r}=t.observer.selectionRange;if(!n||!e.empty||!e.assoc||!n.modify)return;let s=tb.find(this,e.head);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);n.collapse(h.node,h.offset),n.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&n.collapse(i,r)}moveToLine(t){let e=this.dom,n;if(t.node!=e)return t;for(let i=t.offset;!n&&i<e.childNodes.length;i++){let t=F.get(e.childNodes[i]);t instanceof tb&&(n=t.domAtPos(0))}for(let i=t.offset-1;!n&&i>=0;i--){let t=F.get(e.childNodes[i]);t instanceof tb&&(n=t.domAtPos(t.length))}return n?new N(n.node,n.offset,!0):t}nearest(t){for(let e=t;e;){let t=F.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let n=this.nearest(t);if(!n)throw RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(t,e)+n.posAtStart}domAtPos(t){let{i:e,off:n}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(n<t.length||t instanceof tb)break;e++,n=0}return this.children[e].domAtPos(n)}coordsAt(t,e){let n=null,i=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],l=r-o.breakAfter,a=l-o.length;if(l<t)break;if(a<=t&&(a<t||o.covers(-1))&&(l>t||o.covers(1))&&(!n||o instanceof tb&&!(n instanceof tb&&e>=0)))n=o,i=a;else if(n&&a==t&&l==t&&o instanceof ty&&2>Math.abs(e))if(o.deco.startSide<0)break;else s&&(n=null);r=a}return n?n.coordsAt(t-i,e):null}coordsForChar(t){let{i:e,off:n}=this.childPos(t,1),i=this.children[e];if(!(i instanceof tb))return null;for(;i.children.length;){let{i:t,off:e}=i.childPos(n,1);for(;;t++){if(t==i.children.length)return null;if((i=i.children[t]).length)break}n=e}if(!(i instanceof tt))return null;let r=(0,l.zK)(i.text,n);if(r==n)return null;let s=P(i.dom,n,r).getClientRects();for(let t=0;t<s.length;t++){let e=s[t];if(t==s.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:n,to:i}=t,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==tC.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>i)break;if(t>=n){let n=h.dom.getBoundingClientRect();if(e.push(n.height),s){let e=h.dom.lastChild,i=e?b(e):[];if(i.length){let e=i[i.length-1],s=l?e.right-n.left:n.right-e.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?tC.RTL:tC.LTR}measureTextSize(){for(let t of this.children)if(t instanceof tb){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,n,i;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let r=b(t.firstChild)[0];e=t.getBoundingClientRect().height,n=r?r.width/27:7,i=r?r.height:e,t.remove()}),{lineHeight:e,charWidth:n,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new _(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let n=0,i=0;;i++){let r=i==e.viewports.length?null:e.viewports[i],s=r?r.from-1:this.length;if(s>n){let i=(e.lineBlockAt(s).bottom-e.lineBlockAt(n).top)/this.view.scaleY;t.push(tf.replace({widget:new tw(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!r)break;n=r.to+1}return tf.set(t)}updateDeco(){let t=1,e=this.view.state.facet(t9).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),n=!1,i=this.view.state.facet(t6).map((t,e)=>{let i="function"==typeof t;return i&&(n=!0),i?t(this.view):t});for(i.length&&(this.dynamicDecorationMap[t++]=n,e.push(l.om.join(i))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=e.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let e of this.view.state.facet(tY))try{if(e(this.view,t.range,t))return!0}catch(t){tQ(this.view.state,t,"scroll handler")}let{range:e}=t,n=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),i;if(!n)return;!e.empty&&(i=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(n={left:Math.min(n.left,i.left),top:Math.min(n.top,i.top),right:Math.max(n.right,i.right),bottom:Math.max(n.bottom,i.bottom)});let r=ei(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(t,e,n,i,r,s,o,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==a.body,d=1,p=1;if(f)t=function(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:p}=A(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)e.top<t.top?(g=e.top-(t.top+o),n>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+o)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+o,n<0&&e.top-g<t.top&&(g=e.top-(t.top+o)));else{let i=e.bottom-e.top,s=t.bottom-t.top;g=("center"==r&&i<=s?e.top+i/2-s/2:"start"==r||"center"==r&&n<0?e.top-o:e.bottom-s+o)-t.top}if("nearest"==i?e.left<t.left?(m=e.left-(t.left+s),n>0&&e.right>t.right+m&&(m=e.right-t.right+s)):e.right>t.right&&(m=e.right-t.right+s,n<0&&e.left<t.left+m&&(m=e.left-(t.left+s))):m=("center"==i?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==i==l?e.left-s:e.right-(t.right-t.left)+s)-t.left,m||g)if(f)h.scrollBy(m,g);else{let t=0,n=0;if(g){let t=c.scrollTop;c.scrollTop+=g/p,n=(c.scrollTop-t)*p}if(m){let e=c.scrollLeft;c.scrollLeft+=m/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-n,right:e.right-t,bottom:e.bottom-n},t&&1>Math.abs(t-m)&&(i="nearest"),n&&1>Math.abs(n-g)&&(r="nearest")}if(f)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,s,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==tC.LTR)}}function ea(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let i=B(n.focusNode,n.focusOffset),r=L(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let e=F.get(r.node);if(!e||e instanceof tt&&e.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let t=F.get(i.node);!t||t instanceof tt&&t.text!=i.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}let eh=class{constructor(){this.changes=[]}compareRange(t,e){tv(t,e,this.changes)}comparePoint(t,e){tv(t,e,this.changes)}boundChange(t){tv(t,t,this.changes)}};function ec(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function eu(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function ef(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ed(t,e,n){let i=t.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let i=P(t,l,l+1).getClientRects();for(let a=0;a<i.length;a++){let h=i[a];if(h.top==h.bottom)continue;o||(o=e-h.left);let c=(h.top>n?h.top-n:n-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<s){let n=e>=(h.left+h.right)/2,i=n;if((Q.chrome||Q.gecko)&&P(t,l).getBoundingClientRect().left==h.right&&(i=!n),c<=0)return{node:t,offset:l+ +!!i};r=l+ +!!i,s=c}}}return{node:t,offset:r>-1?r:o>0?t.nodeValue.length:0}}function ep(t,e,n,i=-1){var r,s;let o=t.contentDOM.getBoundingClientRect(),l=o.top+t.viewState.paddingTop,a,{docHeight:h}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,r=!1;(a=t.elementAtHeight(f)).type!=tu.Text;)for(;!((f=i>0?a.bottom+e:a.top-e)>=0)||!(f<=h);){if(r)return n?null:0;r=!0,i=-i}u=l+f;let d=a.from;if(d<t.viewport.from)return 0==t.viewport.from?0:n?null:em(t,o,a,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:em(t,o,a,c,u);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(c,u);g&&!t.contentDOM.contains(g)&&(g=null),!g&&(c=Math.max(o.left+1,Math.min(o.right-1,c)),(g=m.elementFromPoint(c,u))&&!t.contentDOM.contains(g)&&(g=null));let v,y=-1;if(g&&(null==(r=t.docView.nearest(g))?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:v,offset:y}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&({startContainer:v,startOffset:y}=e,(!t.contentDOM.contains(v)||Q.safari&&function(t,e,n){let i,r=t;if(3!=t.nodeType||e!=(i=t.nodeValue.length))return!1;for(;;){let t=r.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=r.parentNode;if(!t||"DIV"==t.nodeName)break;r=t}}return P(t,i-1,i).getBoundingClientRect().right>n}(v,y,c)||Q.chrome&&function(t,e,n){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return n-(1==t.nodeType?t.getBoundingClientRect():P(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,y,c))&&(v=void 0))}v&&(y=Math.min(S(v),y))}if(!v||!t.docView.dom.contains(v)){let e=tb.find(t.docView,d);if(!e)return f>a.top+a.height/2?a.to:a.from;({node:v,offset:y}=function t(e,n,i){let r,s,o,l,a,h,c,u,f=!1;for(let m=e.firstChild;m;m=m.nextSibling){let e=b(m);for(let g=0;g<e.length;g++){var d,p;let v=e[g];h&&ec(h,v)&&(v=eu(ef(v,h.bottom),h.top));let b=(d=v).left>n?d.left-n:Math.max(0,n-d.right),y=(p=v).top>i?p.top-i:Math.max(0,i-p.bottom);if(0==b&&0==y)return 3==m.nodeType?ed(m,n,i):t(m,n,i);(!a||u>y||u==y&&c>b)&&(a=m,h=v,c=b,u=y,f=!b||(n<v.left?g>0:g<e.length-1)),0==b?i>v.bottom&&(!o||o.bottom<v.bottom)?(r=m,o=v):i<v.top&&(!l||l.top>v.top)&&(s=m,l=v):o&&ec(o,v)?o=ef(o,v.bottom):l&&ec(l,v)&&(l=eu(l,v.top))}}if(o&&o.bottom>=i?(a=r,h=o):l&&l.top<=i&&(a=s,h=l),!a)return{node:e,offset:0};let m=Math.max(h.left,Math.min(h.right,n));if(3==a.nodeType)return ed(a,m,i);if(f&&"false"!=a.contentEditable)return t(a,m,i);let g=Array.prototype.indexOf.call(e.childNodes,a)+ +(n>=(h.left+h.right)/2);return{node:e,offset:g}}(e.dom,c,u))}let w=t.docView.nearest(v);if(!w)return null;if(!w.isWidget||(null==(s=w.dom)?void 0:s.nodeType)!=1)return w.localPosFromDOM(v,y)+w.posAtStart;{let t=w.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?w.posAtStart:w.posAtEnd}}function em(t,e,n,i,r){let s=Math.round((i-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&n.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((r-n.top-(t.defaultLineHeight-e)*.5)/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+(0,l.kn)(o,s,t.state.tabSize)}function eg(t,e,n){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){let t;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!t||r.type==tu.Text&&(t.type!=r.type||(n<0?r.from<e:r.to>e)))&&(t=r)}}return t||i}return i}function ev(t,e,n,i){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let a=e,h=null;;){let e=function(t,e,n,i,r){var s;let o=i.head-t.from,a=tL.find(e,o,null!=(s=i.bidiLevel)?s:-1,i.assoc),h=e[a],c=h.side(r,n);if(o==c){let t=a+=r?1:-1;if(t<0||t>=e.length)return null;o=(h=e[a=t]).side(!r,n),c=h.side(r,n)}let u=(0,l.zK)(t.text,o,h.forward(r,n));(u<h.from||u>h.to)&&(u=c),tF=t.text.slice(Math.min(o,u),Math.max(o,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+ +!r<h.level?l.OF.cursor(f.side(!r,n)+t.from,f.forward(r,n)?1:-1,f.level):l.OF.cursor(u+t.from,h.forward(r,n)?-1:1,h.level)}(r,s,o,a,n),c=tF;if(!e){if(r.number==(n?t.state.doc.lines:1))return a;c="\n",r=t.state.doc.line(r.number+(n?1:-1)),s=t.bidiSpans(r),e=t.visualLineSide(r,!n)}if(h){if(!h(c))return a}else{if(!i)return e;h=i(c)}a=e}}function eb(t,e,n){for(;;){let i=0;for(let r of t)r.between(e-1,e+1,(t,r,s)=>{if(e>t&&e<r){let s=i||n||(e-t<r-e?-1:1);e=s<0?t:r,i=s}});if(!i)return e}}function ey(t,e,n){let i=eb(t.state.facet(t7).map(e=>e(t)),n.from,e.head>n.from?-1:1);return i==n.from?n:l.OF.cursor(i,i<n.from?1:-1)}class ew{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(l.$t.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="￿"}readRange(t,e){if(!t)return this;let n=t.parentNode;for(let i=t;;){this.findPointBefore(n,i);let t=this.text.length;this.readNode(i);let r=i.nextSibling;if(r==e)break;let s=F.get(i),o=F.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:x(i))||x(r)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>t)&&this.lineBreak(),i=r}return this.findPointBefore(n,e),this}readTextNode(t){let e=t.nodeValue;for(let n of this.points)n.node==t&&(n.pos=this.text.length+Math.min(n.offset,e.length));for(let n=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(o=i.exec(e))&&(r=o.index,s=o[0].length),this.append(e.slice(n,r<0?e.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=s-1);n=r+s}}readNode(t){if(t.cmIgnore)return;let e=F.get(t),n=e&&e.overrideDOMText;if(null!=n){this.findPointInside(t,n.length);for(let t=n.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let n of this.points)n.node==t&&t.childNodes[n.offset]==e&&(n.pos=this.text.length)}findPointInside(t,e){for(let n of this.points)(3==t.nodeType?n.node==t:t.contains(n.node))&&(n.pos=this.text.length+(!function(t,e,n){for(;;){if(!e||n<S(e))return!1;if(e==t)return!0;n=w(e)+1,e=e.parentNode}}(t,n.node,n.offset)?0:e))}}class ex{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ek{constructor(t,e,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:s}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,n,0))){let e=r||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new ex(n,i)),(r!=n||s!=i)&&e.push(new ex(r,s))),e}(t),n=new ew(e,t.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(t,e){if(0==t.length)return null;let n=t[0].pos,i=2==t.length?t[1].pos:n;return n>-1&&i>-1?l.OF.single(n+e,i+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,n=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!g(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),i=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!g(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((Q.ios||Q.chrome)&&t.state.selection.main.empty&&n!=i&&(o.from>0||o.to<t.state.doc.length)){let e=Math.min(n,i),r=Math.max(n,i),s=o.from-e,l=o.to-r;(0==s||1==s||0==e)&&(0==l||-1==l||r==t.state.doc.length)&&(n=0,i=t.state.doc.length)}this.newSel=l.OF.single(i,n)}}}function eS(t,e){let n,{newSel:i}=e,r=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:i,to:o}=e.bounds,a=r.from,h=null;(8===s||Q.android&&e.text.length<o-i)&&(a=r.to,h="end");let c=function(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if("end"==i){let t=Math.max(0,s-Math.min(o,l));n-=o+t-s}if(o<s&&t.length<e.length){let t=n<=s&&n>=o?s-n:0;s-=t,l=s+(l-o),o=s}else if(l<s){let t=n<=s&&n>=l?s-n:0;s-=t,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}(t.state.doc.sliceString(i,o,"￿"),e.text,a-i,h);c&&(Q.chrome&&13==s&&c.toB==c.from+2&&"￿￿"==e.text.slice(c.from,c.toB)&&c.toB--,n={from:i+c.from,to:i+c.toA,insert:l.EY.of(e.text.slice(c.from,c.toB).split("￿"))})}else i&&(!t.hasFocus&&t.state.facet(t0)||i.main.eq(r))&&(i=null);if(!n&&!i)return!1;if(!n&&e.typeOver&&!r.empty&&i&&i.main.empty?n={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:(Q.mac||Q.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=l.OF.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:l.EY.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,n.from).append(n.insert).append(t.state.doc.slice(n.to,r.to))}:Q.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&t.lineWrapping&&(i&&(i=l.OF.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:l.EY.of([" "])}),n)return eC(t,n,i,s);if(!i||i.main.eq(r))return!1;{let e=!1,n="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),n=t.inputState.lastSelectionOrigin),t.dispatch({selection:i,scrollIntoView:e,userEvent:n}),!0}}function eC(t,e,n,i=-1){let r;if(Q.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Q.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&T(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==i&&e.insert.length<e.to-e.from&&e.to>s.head)&&T(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&T(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>r||(r=function(t,e,n){let i,r=t.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let n=s.from<e.from?r.sliceDoc(s.from,e.from):"",o=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(n+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=r.changes(e),a=n&&n.main.to<=o.newLength?n.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=t.state.sliceDoc(e.from,e.to),c,u=n&&ea(t,n.main.head);if(u){let t=e.insert.length-(e.to-e.from);c={from:u.from,to:u.to-t}}else c=t.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;i=r.changeByRange(n=>{if(n.from==s.from&&n.to==s.to)return{changes:o,range:a||n.map(o)};let i=n.to-f,u=i-h.length;if(n.to-n.from!=d||t.state.sliceDoc(u,i)!=h||n.to>=c.from&&n.from<=c.to)return{range:n};let p=r.changes({from:u,to:i,insert:e.insert}),m=n.to-s.to;return{changes:p,range:a?l.OF.range(Math.max(0,a.anchor+m),Math.max(0,a.head+m)):n.map(p)}})}else i={changes:o,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}(t,e,n));return t.state.facet(tW).some(n=>n(t,e.from,e.to,o,a))||t.dispatch(a()),!0}class eA{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Q.safari&&t.contentDOM.addEventListener("input",()=>null),Q.gecko&&function(t){eG.has(t)||(eG.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=F.get(n))&&i.ignoreEvent(e))return!1;return!0}(this.view,t)||this.ignoreDuringComposition(t)||"keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let n=this.handlers[t];if(n){for(let t of n.observers)t(this.view,e);for(let t of n.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function n(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,i=t&&t.plugin.domEventHandlers,r=t&&t.plugin.domEventObservers;if(i)for(let t in i){let r=i[t];r&&n(t).handlers.push(eO(e.value,r))}if(r)for(let t in r){let i=r[t];i&&n(t).observers.push(eO(e.value,i))}}for(let t in eR)n(t).handlers.push(eR[t]);for(let t in eB)n(t).observers.push(eB[t]);return e}(t),n=this.handlers,i=this.view.contentDOM;for(let t in e)if("scroll"!=t){let r=!e[t].handlers.length,s=n[t];s&&!s.handlers.length!=r&&(i.removeEventListener(t,this.handleEvent),s=null),s||i.addEventListener(t,this.handleEvent,{passive:r})}for(let t in n)"scroll"==t||e[t]||i.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){let e;return this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),!!(9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=t.keyCode&&0>eP.indexOf(t.keyCode)&&(this.tabFocusMode=-1),Q.android&&Q.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))?(this.view.observer.delayAndroidKey(t.key,t.keyCode),!0):Q.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=eM.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||eD.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=t.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(t){let e=this.pendingIOSKey;return!(!e||"Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,T(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Q.safari&&!Q.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function eO(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(t){tQ(n.state,t)}}}let eM=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],eD="dthko",eP=[16,17,18,20,91,92,224,225];function eT(t){return .7*Math.max(0,t)+8}class eE{constructor(t,e,n,i){this.view=t,this.startEvent=e,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e=t.ownerDocument,n,i;for(let r=t.parentNode;r;)if(r==e.body||n&&i)break;else if(1==r.nodeType)!i&&r.scrollHeight>r.clientHeight&&(i=r),!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:n,y:i}}(t.contentDOM),this.atoms=t.state.facet(t7).map(e=>e(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(l.$t.allowMultipleSelections)&&function(t,e){let n=t.state.facet(tj);return n.length?n[0](e):Q.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!!function(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=m(t.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let t=0;t<r.length;t++){let n=r[t];if(n.left<=e.clientX&&n.right>=e.clientX&&n.top<=e.clientY&&n.bottom>=e.clientY)return!0}return!1}(t,e)&&1==eq(e)&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>(e=this.startEvent,Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))))return;this.select(this.lastEvent=t);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=ei(this.view);t.clientX-a.left<=r+6?n=-eT(r-t.clientX):t.clientX+a.right>=o-6&&(n=eT(t.clientX-o)),t.clientY-a.top<=s+6?i=-eT(s-t.clientY):t.clientY+a.bottom>=l-6&&(i=eT(t.clientY-l)),this.setScrollSpeed(n,i)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let n=0;n<t.ranges.length;n++){let i=t.ranges[n],r=null;if(i.empty){let t=eb(this.atoms,i.from,0);t!=i.from&&(r=l.OF.cursor(t,-1))}else{let t=eb(this.atoms,i.from,-1),e=eb(this.atoms,i.to,1);(t!=i.from||e!=i.to)&&(r=l.OF.range(i.from==i.anchor?t:e,i.from==i.head?t:e))}r&&(e||(e=t.ranges.slice()),e[n]=r)}return e?l.OF.create(e,t.mainIndex):t}select(t){let{view:e}=this,n=this.skipAtoms(this.style.get(t,this.extend,this.multiple));(this.mustSelect||!n.eq(e.state.selection,!1===this.dragging))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}let eR=Object.create(null),eB=Object.create(null),eL=Q.ie&&Q.ie_version<15||Q.ios&&Q.webkit_version<604;function eN(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function eI(t,e){e=eN(t.state,tU,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(null!=e$&&n.selection.ranges.every(t=>t.empty)&&e$==s.toString()){let t=-1;i=n.changeByRange(i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let h=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:h},range:l.OF.cursor(i.from+h.length)}})}else i=o?n.changeByRange(t=>{let e=s.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:l.OF.cursor(t.from+e.length)}}):n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function eF(t,e,n,i){if(1==i)return l.OF.cursor(e,n);{if(2==i)return function(t,e,n=1){let i=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return l.OF.cursor(e);0==s?n=1:s==r.length&&(n=-1);let o=s,a=s;n<0?o=(0,l.zK)(r.text,s,!1):a=(0,l.zK)(r.text,s);let h=i(r.text.slice(o,a));for(;o>0;){let t=(0,l.zK)(r.text,o,!1);if(i(r.text.slice(t,o))!=h)break;o=t}for(;a<r.length;){let t=(0,l.zK)(r.text,a);if(i(r.text.slice(a,t))!=h)break;a=t}return l.OF.range(o+r.from,a+r.from)}(t.state,e,n);let r=tb.find(t.docView,e),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return a<t.state.doc.length&&a==s.to&&a++,l.OF.range(o,a)}}eB.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},eR.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),eB.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},eB.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},eR.mousedown=(t,e)=>{var n,i;let r,s,o;if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let a=null;for(let n of t.state.facet(tz))if(a=n(t,e))break;if(a||0!=e.button||(r=e_(n=t,i=e),s=eq(i),o=n.state.selection,a={update(t){t.docChanged&&(r.pos=t.changes.mapPos(r.pos),o=o.map(t.changes))},get(t,e,i){let a=e_(n,t),h,c=eF(n,a.pos,a.bias,s);if(r.pos!=a.pos&&!e){let t=eF(n,r.pos,r.bias,s),e=Math.min(t.from,c.from),i=Math.max(t.to,c.to);c=e<c.from?l.OF.range(e,i):l.OF.range(i,e)}return e?o.replaceRange(o.main.extend(c.from,c.to)):i&&1==s&&o.ranges.length>1&&(h=function(t,e){for(let n=0;n<t.ranges.length;n++){let{from:i,to:r}=t.ranges[n];if(i<=e&&r>=e)return l.OF.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n))}return null}(o,a.pos))?h:i?o.addRange(c):l.OF.create([c])}}),a){let n=!t.hasFocus;t.inputState.startMouseSelection(new eE(t,e,a,n)),n&&t.observer.ignore(()=>{D(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),!1===i.dragging}return!1};let ej=(t,e,n)=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right;function e_(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:function(t,e,n,i){let r=tb.find(t.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(0==s)return 1;if(s==r.length)return -1;let o=r.coordsAt(s,-1);if(o&&ej(n,i,o))return -1;let l=r.coordsAt(s,1);return l&&ej(n,i,l)?1:o&&o.bottom>=i?-1:1}(t,n,e.clientX,e.clientY)}}let ez=Q.ie&&Q.ie_version<=11,eV=null,eH=0,eW=0;function eq(t){if(!ez)return t.detail;let e=eV,n=eW;return eV=t,eW=Date.now(),eH=!e||n>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(eH+1)%3:1}function eU(t,e,n,i){let r;if(!(n=eN(t.state,tU,n)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,l=i&&o&&((r=t.state.facet(t_)).length?r[0](e):Q.mac?!e.altKey:!e.ctrlKey)?{from:o.from,to:o.to}:null,a={from:s,insert:n},h=t.state.changes(l?[l,a]:a);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:l?"move.drop":"input.drop"}),t.inputState.draggedContent=null}eR.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.nearest(e.target);if(i&&i.isWidget){let t=i.posAtStart,e=t+i.length;(t>=n.to||e<=n.from)&&(n=l.OF.range(t,e))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",eN(t.state,t$,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},eR.dragend=t=>(t.inputState.draggedContent=null,!1),eR.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&eU(t,e,i.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<n.length;t++){let e=new FileReader;e.onerror=s,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(i[t]=e.result),s()},e.readAsText(n[t])}return!0}{let n=e.dataTransfer.getData("Text");if(n)return eU(t,e,n,!0),!0}return!1},eR.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=eL?null:e.clipboardData;return n?(eI(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(!function(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),eI(t,n.value)},50)}(t),!1)};let e$=null;eR.copy=eR.cut=(t,e)=>{let{text:n,ranges:i,linewise:r}=function(t){let e=[],n=[],i=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let r=-1;for(let{from:i}of t.selection.ranges){let s=t.doc.lineAt(i);s.number>r&&(e.push(s.text),n.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}i=!0}return{text:eN(t,t$,e.join(t.lineBreak)),ranges:n,linewise:i}}(t.state);if(!n&&!r)return!1;e$=r?n:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=eL?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(!function(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}(t,n),!1)};let eK=l.YH.define();function eJ(t,e){let n=[];for(let i of t.facet(tq)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:eK.of(!0)}):null}function eY(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=eJ(t.state,e);n?t.dispatch(n):t.update([])}},10)}eB.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),eY(t)},eB.blur=t=>{t.observer.clearSelectionRange(),eY(t)},eB.compositionstart=eB.compositionupdate=t=>{!t.observer.editContext&&(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},eB.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Q.chrome&&Q.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},eB.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},eR.beforeinput=(t,e)=>{var n,i;let r;if("insertReplacementText"==e.inputType&&t.observer.editContext){let i=null==(n=e.dataTransfer)?void 0:n.getData("text/plain"),r=e.getTargetRanges();if(i&&r.length){let e=r[0],n=t.posAtDOM(e.startContainer,e.startOffset),s=t.posAtDOM(e.endContainer,e.endOffset);return eC(t,{from:n,to:s,insert:t.state.toText(i)},null),!0}}if(Q.chrome&&Q.android&&(r=eM.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let e=(null==(i=window.visualViewport)?void 0:i.height)||0;setTimeout(()=>{var n;((null==(n=window.visualViewport)?void 0:n.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Q.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),Q.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>eB.compositionend(t,e),20),!1};let eG=new Set,eZ=["pre-wrap","normal","pre-line","break-spaces"],eX=!1;class eQ{constructor(t){this.lineWrapping=t,this.doc=l.EY.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let n=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((e-t-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return eZ.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let n=0;n<t.length;n++){let i=t[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(e=!0,this.heightSamples[Math.floor(10*i)]=!0)}return e}refresh(t,e,n,i,r,s){let o=eZ.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=n,this.textHeight=i,this.lineLength=r,l){this.heightSamples={};for(let t=0;t<s.length;t++){let e=s[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class e0{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class e1{constructor(t,e,n,i,r){this.from=t,this.length=e,this.top=n,this.height=i,this._content=r}get type(){return"number"==typeof this._content?tu.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof tm?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e1(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var e2=((o=e2||(e2={}))[o.ByPos=0]="ByPos",o[o.ByHeight=1]="ByHeight",o[o.ByPosNoHeight=2]="ByPosNoHeight",o);class e4{constructor(t,e,n=2){this.length=t,this.height=e,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=2*!!t|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>.001&&(eX=!0),this.height=t)}replace(t,e,n){return e4.of(n)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,n,i){let r=this,s=n.doc;for(let o=i.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=i[o],u=r.lineAt(l,e2.ByPosNoHeight,n.setDoc(e),0,0),f=u.to>=a?u:r.lineAt(a,e2.ByPosNoHeight,n,0,0);for(c+=f.to-a,a=f.to;o>0&&u.from<=i[o-1].toA;)l=i[o-1].fromA,h=i[o-1].fromB,o--,l<u.from&&(u=r.lineAt(l,e2.ByPosNoHeight,n,0,0));h+=u.from-l,l=u.from;let d=nt.build(n.setDoc(s),t,h,c);r=e3(r,r.replace(l,a,d))}return r.updateHeight(n,0)}static empty(){return new e5(0,0)}static of(t){if(1==t.length)return t[0];let e=0,n=t.length,i=0,r=0;for(;;)if(e==n)if(i>2*r){let r=t[e-1];r.break?t.splice(--e,1,r.left,null,r.right):t.splice(--e,1,r.left,r.right),n+=1+r.break,i-=r.size}else if(r>2*i){let e=t[n];e.break?t.splice(n,1,e.left,null,e.right):t.splice(n,1,e.left,e.right),n+=2+e.break,r-=e.size}else break;else if(i<r){let n=t[e++];n&&(i+=n.size)}else{let e=t[--n];e&&(r+=e.size)}let s=0;return null==t[e-1]?(s=1,e--):null==t[e]&&(s=1,n++),new e6(e4.of(t.slice(0,e)),s,e4.of(t.slice(n)))}}function e3(t,e){return t==e?t:(t.constructor!=e.constructor&&(eX=!0),e)}e4.prototype.size=1;class e8 extends e4{constructor(t,e,n){super(t,e),this.deco=n}blockAt(t,e,n,i){return new e1(i,this.length,n,this.height,this.deco||0)}lineAt(t,e,n,i,r){return this.blockAt(0,n,i,r)}forEachLine(t,e,n,i,r,s){t<=r+this.length&&e>=r&&s(this.blockAt(0,n,i,r))}updateHeight(t,e=0,n=!1,i){return i&&i.from<=e&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class e5 extends e8{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,n,i){return new e1(i,this.length,n,this.height,this.breaks)}replace(t,e,n){let i=n[0];return 1==n.length&&(i instanceof e5||i instanceof e9&&4&i.flags)&&10>Math.abs(this.length-i.length)?(i instanceof e9?i=new e5(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):e4.of(n)}updateHeight(t,e=0,n=!1,i){return i&&i.from<=e&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class e9 extends e4{constructor(t){super(t,0)}heightMetrics(t,e){let n=t.doc.lineAt(e).number,i=t.doc.lineAt(e+this.length).number,r=i-n+1,s,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);s=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else s=this.height/r;return{firstLine:n,lastLine:i,perLine:s,perChar:o}}blockAt(t,e,n,i){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(e,i);if(e.lineWrapping){let r=i+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-n)/this.height))*this.length)),s=e.doc.lineAt(r),a=o+s.length*l,h=Math.max(n,t-a/2);return new e1(s.from,s.length,h,a,0)}{let i=Math.max(0,Math.min(s-r,Math.floor((t-n)/o))),{from:l,length:a}=e.doc.line(r+i);return new e1(l,a,n+o*i,o,0)}}lineAt(t,e,n,i,r){if(e==e2.ByHeight)return this.blockAt(t,n,i,r);if(e==e2.ByPosNoHeight){let{from:e,to:i}=n.doc.lineAt(t);return new e1(e,i-e,0,0,0)}let{firstLine:s,perLine:o,perChar:l}=this.heightMetrics(n,r),a=n.doc.lineAt(t),h=o+a.length*l,c=a.number-s,u=i+o*c+l*(a.from-r-c);return new e1(a.from,a.length,Math.max(i,Math.min(u,i+this.height-h)),h,0)}forEachLine(t,e,n,i,r,s){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r);for(let h=t,c=i;h<=e;){let e=n.doc.lineAt(h);if(h==t){let n=e.number-o;c+=l*n+a*(t-r-n)}let i=l+a*e.length;s(new e1(e.from,e.length,c,i,0)),c+=i,h=e.to+1}}replace(t,e,n){let i=this.length-e;if(i>0){let t=n[n.length-1];t instanceof e9?n[n.length-1]=new e9(t.length+i):n.push(null,new e9(i-1))}if(t>0){let e=n[0];e instanceof e9?n[0]=new e9(t+e.length):n.unshift(new e9(t-1),null)}return e4.of(n)}decomposeLeft(t,e){e.push(new e9(t-1),null)}decomposeRight(t,e){e.push(null,new e9(this.length-t-1))}updateHeight(t,e=0,n=!1,i){let r=e+this.length;if(i&&i.from<=e+this.length&&i.more){let n=[],s=Math.max(e,i.from),o=-1;for(i.from>e&&n.push(new e9(i.from-e-1).updateHeight(t,e));s<=r&&i.more;){let e=t.doc.lineAt(s).length;n.length&&n.push(null);let r=i.heights[i.index++];-1==o?o=r:Math.abs(r-o)>=.001&&(o=-2);let l=new e5(e,r);l.outdated=!1,n.push(l),s+=e+1}s<=r&&n.push(null,new e9(r-s).updateHeight(t,s));let l=e4.of(n);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(t,e).perLine)>=.001)&&(eX=!0),e3(this,l)}return(n||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class e6 extends e4{constructor(t,e,n){super(t.length+e+n.length,t.height+n.height,e|(t.outdated||n.outdated?2:0)),this.left=t,this.right=n,this.size=t.size+n.size}get break(){return 1&this.flags}blockAt(t,e,n,i){let r=n+this.left.height;return t<r?this.left.blockAt(t,e,n,i):this.right.blockAt(t,e,r,i+this.left.length+this.break)}lineAt(t,e,n,i,r){let s=i+this.left.height,o=r+this.left.length+this.break,l=e==e2.ByHeight?t<s:t<o,a=l?this.left.lineAt(t,e,n,i,r):this.right.lineAt(t,e,n,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=e==e2.ByPosNoHeight?e2.ByPosNoHeight:e2.ByPos;return l?a.join(this.right.lineAt(o,h,n,s,o)):this.left.lineAt(o,h,n,i,r).join(a)}forEachLine(t,e,n,i,r,s){let o=i+this.left.height,l=r+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,n,i,r,s),e>=l&&this.right.forEachLine(t,e,n,o,l,s);else{let a=this.lineAt(l,e2.ByPos,n,i,r);t<a.from&&this.left.forEachLine(t,a.from-1,n,i,r,s),a.to>=t&&a.from<=e&&s(a),e>a.to&&this.right.forEachLine(a.to+1,e,n,o,l,s)}}replace(t,e,n){let i=this.left.length+this.break;if(e<i)return this.balanced(this.left.replace(t,e,n),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-i,e-i,n));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let t of n)r.push(t);if(t>0&&e7(r,s-1),e<this.length){let t=r.length;this.decomposeRight(e,r),e7(r,t)}return e4.of(r)}decomposeLeft(t,e){let n=this.left.length;if(t<=n)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&t>=++n&&e.push(null),t>n&&this.right.decomposeLeft(t-n,e)}decomposeRight(t,e){let n=this.left.length,i=n+this.break;if(t>=i)return this.right.decomposeRight(t-i,e);t<n&&this.left.decomposeRight(t,e),this.break&&t<i&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?e4.of(this.break?[t,null,e]:[t,e]):(this.left=e3(this.left,t),this.right=e3(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,n=!1,i){let{left:r,right:s}=this,o=e+r.length+this.break,l=null;return(i&&i.from<=e+r.length&&i.more?l=r=r.updateHeight(t,e,n,i):r.updateHeight(t,e,n),i&&i.from<=o+s.length&&i.more?l=s=s.updateHeight(t,o,n,i):s.updateHeight(t,o,n),l)?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function e7(t,e){let n,i;null==t[e]&&(n=t[e-1])instanceof e9&&(i=t[e+1])instanceof e9&&t.splice(e-1,3,new e9(n.length+1+i.length))}class nt{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof e5?n.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new e5(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,n){if(t<e||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let s=e-t;n.block?this.addBlock(new e8(s,i,n)):(s||r||i>=5)&&this.addLineDeco(i,r,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new e5(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let n=new e9(e-t);return this.oracle.doc.lineAt(t).to==e&&(n.flags|=4),n}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof e5)return t;let e=new e5(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,t),i.breaks+=e,this.writtenTo=this.pos=this.pos+n}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof e5||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new e5(0,-1));let n=t;for(let t of this.nodes)t instanceof e5&&t.updateHeight(this.oracle,n),n+=t?t.length:1;return this.nodes}static build(t,e,n,i){let r=new nt(n,t);return l.om.spans(e,n,i,r,0),r.finish(n)}}class ne{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,n,i){(t<e||n&&n.heightRelevant||i&&i.heightRelevant)&&tv(t,e,this.changes,5)}}class nn{constructor(t,e,n,i){this.from=t,this.to=e,this.size=n,this.displaySize=i}static same(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let i=t[n],r=e[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(t,e){return tf.replace({widget:new ni(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class ni extends tc{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class nr{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=na,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=tC.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(t5).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new eQ(e),this.stateDeco=t.facet(t9).filter(t=>"function"!=typeof t),this.heightMap=e4.empty().applyChanges(this.stateDeco,l.EY.empty,this.heightOracle.setDoc(t.doc),[new es(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=tf.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let n=0;n<=1;n++){let i=n?e.head:e.anchor;if(!t.some(({from:t,to:e})=>i>=t&&i<=e)){let{from:e,to:n}=this.lineBlockAt(i);t.push(new ns(e,n))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?na:new nh(this.heightOracle,this.heightMap,this.viewports),2*!t.eq(this.scaler)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(nc(t,this.scaler))})}update(t,e=null){var n,i;let r;this.state=t.state;let s=this.stateDeco;this.stateDeco=this.state.facet(t9).filter(t=>"function"!=typeof t);let o=t.changedRanges,a=es.extendWithRanges(o,(n=this.stateDeco,i=t?t.changes:l.VR.empty(this.state.doc.length),r=new ne,l.om.compare(s,n,i,r,0),r.changes)),h=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);eX=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=h||eX)&&(t.flags|=2),c?(this.scrollAnchorPos=t.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=h);let u=a.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<u.from||e.range.head>u.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,e));let f=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,t.flags|=this.updateForViewport(),(f||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(tJ)&&(this.mustEnforceCursorAssoc=!0)}measure(t){var e;let n,i,r=t.contentDOM,s=window.getComputedStyle(r),o=this.heightOracle,a=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?tC.RTL:tC.LTR;let h=this.heightOracle.mustRefreshForWrapping(a),c=r.getBoundingClientRect(),u=h||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let f=0,d=0;if(c.width&&c.height){let{scaleX:t,scaleY:e}=A(r,c);(t>.005&&Math.abs(this.scaleX-t)>.005||e>.005&&Math.abs(this.scaleY-e)>.005)&&(this.scaleX=t,this.scaleY=e,f|=16,h=u=!0)}let p=(parseInt(s.paddingTop)||0)*this.scaleY,m=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=m)&&(this.paddingTop=p,this.paddingBottom=m,f|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(u=!0),this.editorWidth=t.scrollDOM.clientWidth,f|=16);let g=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=g&&(this.scrollAnchorHeight=-1,this.scrollTop=g),this.scrolledToBottom=R(t.scrollDOM);let v=(this.printing?function(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}:function(t,e){let n=t.getBoundingClientRect(),i=t.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),l=Math.max(0,n.top),a=Math.min(r.innerHeight,n.bottom);for(let e=t.parentNode;e&&e!=i.body;)if(1==e.nodeType){let n=e,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();s=Math.max(s,i.left),o=Math.min(o,i.right),l=Math.max(l,i.top),a=Math.min(e==t.parentNode?r.innerHeight:a,i.bottom)}e="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else if(11==e.nodeType)e=e.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}})(r,this.paddingTop),b=v.top-this.pixelViewport.top,y=v.bottom-this.pixelViewport.bottom;this.pixelViewport=v;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(u=!0)),!this.inView&&!this.scrollTarget&&(n=(e=t.dom).getBoundingClientRect(),i=e.ownerDocument.defaultView||window,!(n.left<i.innerWidth)||!(n.right>0)||!(n.top<i.innerHeight)||!(n.bottom>0)))return 0;let x=c.width;if((this.contentDOMWidth!=x||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=t.scrollDOM.clientHeight,f|=16),u){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(h=!0),h||o.lineWrapping&&Math.abs(x-this.contentDOMWidth)>o.charWidth){let{lineHeight:n,charWidth:i,textHeight:r}=t.docView.measureTextSize();(h=n>0&&o.refresh(a,n,i,r,x/i,e))&&(t.docView.minWidth=0,f|=16)}for(let n of(b>0&&y>0?d=Math.max(b,y):b<0&&y<0&&(d=Math.min(b,y)),eX=!1,this.viewports)){let i=n.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(n);this.heightMap=(h?e4.empty().applyChanges(this.stateDeco,l.EY.empty,this.heightOracle,[new es(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,h,new e0(n.from,i))}eX&&(f|=2)}let k=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return k&&(2&f&&(f|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),f|=this.updateForViewport()),(2&f||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(h?[]:this.lineGaps,t)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let n=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),i=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new ns(i.lineAt(s-1e3*n,e2.ByHeight,r,0,0).from,i.lineAt(o+(1-n)*1e3,e2.ByHeight,r,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(t,e2.ByPos,r,0,0),o;o="center"==e.y?(s.top+s.bottom)/2-n/2:"start"==e.y||"nearest"==e.y&&t<l.from?s.top:s.bottom-n,l=new ns(i.lineAt(o-500,e2.ByHeight,r,0,0).from,i.lineAt(o+n+500,e2.ByHeight,r,0,0).to)}}return l}mapViewport(t,e){let n=e.mapPos(t.from,-1),i=e.mapPos(t.to,1);return new ns(this.heightMap.lineAt(n,e2.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,e2.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(t,e2.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,e2.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||i<=s-Math.max(10,Math.min(-n,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(n,250)))&&i>s-2e3&&r<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let n=[];for(let i of t)e.touchesRange(i.from,i.to)||n.push(new nn(e.mapPos(i.from),e.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(t,e){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,s=i<<1;if(this.defaultTextDirection!=tC.LTR&&!n)return[];let o=[],a=(i,s,h,c)=>{if(s-i<r)return;let u=this.state.selection.main,f=[u.from];for(let t of(u.empty||f.push(u.to),f))if(t>i&&t<s){a(i,t-10,h,c),a(t+10,s,h,c);return}let d=function(t,e){for(let n of t)if(e(n))return n}(t,t=>t.from>=h.from&&t.to<=h.to&&Math.abs(t.from-i)<r&&Math.abs(t.to-s)<r&&!f.some(e=>t.from<e&&t.to>e));if(!d){if(s<h.to&&e&&n&&e.visibleRanges.some(t=>t.from<=s&&t.to>=s)){let t=e.moveToLineBoundary(l.OF.cursor(s),!1,!0).head;t>i&&(s=t)}let t=this.gapSize(h,i,s,c),r=n||t<2e6?t:2e6;d=new nn(i,s,t,r)}o.push(d)},h=e=>{var r,o,h;let c,u,f,d,p;if(e.length<s||e.type!=tu.Text)return;let m=(r=e.from,o=e.to,h=this.stateDeco,f=[],d=r,p=0,l.om.spans(h,r,o,{span(){},point(t,e){t>d&&(f.push({from:d,to:t}),p+=t-d),d=e}},20),d<o&&(f.push({from:d,to:o}),p+=o-d),{total:p,ranges:f});if(m.total<s)return;let g=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let t,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=g){let i=nl(m,g),s=((this.visibleBottom-this.visibleTop)/2+r)/e.height;t=i-s,n=i+s}else t=(this.visibleTop-e.top-r)/e.height,n=(this.visibleBottom-e.top+r)/e.height;c=no(m,t),u=no(m,n)}else{let n,r,s=m.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,l=0;if(s>2e6)for(let n of t)n.from>=e.from&&n.from<e.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=n.size-n.displaySize);let a=this.pixelViewport.left+l,h=this.pixelViewport.right+l;if(null!=g){let t=nl(m,g),e=((h-a)/2+o)/s;n=t-e,r=t+e}else n=(a-o)/s,r=(h+o)/s;c=no(m,n),u=no(m,r)}c>e.from&&a(e.from,c,e,m),u<e.to&&a(u,e.to,e,m)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(h):h(t);return o}gapSize(t,e,n,i){let r=nl(i,n)-nl(i,e);return this.heightOracle.lineWrapping?t.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(t){nn.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=tf.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];l.om.spans(e,this.viewport.from,this.viewport.to,{span(t,e){n.push({from:t,to:e})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let e=0;e<n.length&&!(8&i);e++){let r=this.visibleRanges[e],s=n[e];(r.from!=s.from||r.to!=s.to)&&(i|=4,t&&t.mapPos(r.from,-1)==s.from&&t.mapPos(r.to,1)==s.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||nc(this.heightMap.lineAt(t,e2.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||nc(this.heightMap.lineAt(this.scaler.fromDOM(t),e2.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return nc(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ns{constructor(t,e){this.from=t,this.to=e}}function no({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let t=0;;t++){let{from:n,to:r}=e[t],s=r-n;if(i<=s)return n+i;i-=s}}function nl(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}let na={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class nh{constructor(t,e,n){let i=0,r=0,s=0;for(let o of(this.viewports=n.map(({from:n,to:r})=>{let s=e.lineAt(n,e2.ByPos,t,0,0).top,o=e.lineAt(r,e2.ByPos,t,0,0).bottom;return i+=o-s,{from:n,to:r,top:s,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(e.height-i),this.viewports))o.domTop=s+(o.top-r)*this.scale,s=o.domBottom=o.domTop+(o.bottom-o.top),r=o.bottom}toDOM(t){for(let e=0,n=0,i=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return i+(t-n)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);n=r.bottom,i=r.domBottom}}fromDOM(t){for(let e=0,n=0,i=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return n+(t-i)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);n=r.bottom,i=r.domBottom}}eq(t){return t instanceof nh&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to)}}function nc(t,e){if(1==e.scale)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new e1(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(t=>nc(t,e)):t._content)}let nu=l.sj.define({combine:t=>t.join(" ")}),nf=l.sj.define({combine:t=>t.indexOf(!0)>-1}),nd=a.G.newName(),np=a.G.newName(),nm=a.G.newName(),ng={"&light":"."+np,"&dark":"."+nm};function nv(t,e,n){return new a.G(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!n||!n[e])throw RangeError(`Unsupported selector: ${e}`);return n[e]}):t+" "+e})}let nb=nv("."+nd,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ng),ny={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},nw=Q.ie&&Q.ie_version<=11;class nx{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new O,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(Q.ie&&Q.ie_version<=11||Q.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Q.android&&!1!==t.constructor.EDIT_CONTEXT&&!(Q.chrome&&Q.chrome_version<126)&&(this.editContext=new nC(t),t.state.facet(t0)&&(t.contentDOM.editContext=this.editContext.editContext)),nw&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null==(t=this.view.docView)?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,n)=>e!=t[n]))){for(let e of(this.gapIntersection.disconnect(),t))this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(t0)?n.root.activeElement!=this.dom:!v(this.dom,i))return;let r=i.anchorNode&&n.docView.nearest(i.anchorNode);if(r&&r.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(Q.ie&&Q.ie_version<=11||Q.android&&Q.chrome)&&!n.state.selection.main.empty&&i.focusNode&&y(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=m(t.root);if(!e)return!1;let n=Q.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return nS(t,n)}let n=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?nS(t,n):null}(this.view,e)||e;if(!n||this.selectionRange.eq(n))return!1;let i=v(this.dom,n);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let n=e.focusNode,i=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=i)return!1;for(i=Math.min(i,S(n));;)if(i){if(1!=n.nodeType)return!1;let t=n.childNodes[i-1];"false"==t.contentEditable?i--:i=S(n=t)}else{if(n==t)return!0;i=w(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let n=this.dom;n;)if(1==n.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==n?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ny),nw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),nw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var n;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&T(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null==(n=this.delayedAndroidKey)?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,n=-1,i=!1;for(let r of t){let t=this.readMutation(r);t&&(t.typeOver&&(i=!0),-1==e?{from:e,to:n}=t:(e=Math.min(t.from,e),n=Math.max(t.to,n)))}return{from:e,to:n,typeOver:i}}readChange(){let{from:t,to:e,typeOver:n}=this.processRecords(),i=this.selectionChanged&&v(this.dom,this.selectionRange);if(t<0&&!i)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new ek(this.view,t,e,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let n=this.view.state,i=eS(this.view,e);return this.view.state==n&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let n=nk(e,t.previousSibling||t.target.previousSibling,-1),i=nk(e,t.nextSibling||t.target.nextSibling,1);return{from:n?e.posAfter(n):e.posAtStart,to:i?e.posBefore(i):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(t0)!=t.state.facet(t0)&&(t.view.contentDOM.editContext=t.state.facet(t0)?this.editContext.editContext:null))}destroy(){var t,e,n;for(let i of(this.stop(),null==(t=this.intersection)||t.disconnect(),null==(e=this.gapIntersection)||e.disconnect(),null==(n=this.resizeScroll)||n.disconnect(),this.scrollTargets))i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function nk(t,e,n){for(;e;){let i=F.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function nS(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return y(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}class nC{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});for(let n in this.handlers.textupdate=e=>{let n=t.state.selection.main,{anchor:i,head:r}=n,s=this.toEditorPos(e.updateRangeStart),o=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:s,drifted:!1});let a={from:s,to:o,insert:l.EY.of(e.text.split("\n"))};if(a.from==this.from&&i<this.from?a.from=i:a.to==this.to&&i>this.to&&(a.to=i),a.from==a.to&&!a.insert.length){let i=l.OF.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd));i.main.eq(n)||t.dispatch({selection:i,userEvent:"select"});return}if((Q.mac||Q.android)&&a.from==r-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(a={from:s,to:o,insert:l.EY.of([e.text.replace("."," ")])}),this.pendingContextChange=a,!t.state.readOnly){let n=this.to-this.from+(a.to-a.from+a.insert.length);eC(t,a,l.OF.single(this.toEditorPos(e.selectionStart,n),this.toEditorPos(e.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let e=this.toEditorPos(n.rangeStart),s=this.toEditorPos(n.rangeEnd);e<s;e++){let n=t.coordsForChar(e);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}e.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=e=>{let n=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,i=t.underlineThickness;if("None"!=e&&"None"!=i){let r=this.toEditorPos(t.rangeStart),s=this.toEditorPos(t.rangeEnd);if(r<s){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==i?1:2}px`;n.push(tf.mark({attributes:{style:t}}).range(r,s))}}}t.dispatch({effects:tX.of(tf.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}},this.handlers)e.addEventListener(n,this.handlers[n]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=m(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,n=!1,i=this.pendingContextChange;return t.changes.iterChanges((r,s,o,l,a)=>{if(n)return;let h=a.length-(s-r);if(i&&s>=i.to)if(i.from==r&&i.to==s&&i.insert.eq(a)){i=this.pendingContextChange=null,e+=h,this.to+=h;return}else i=null,this.revertPending(t.state);if(r+=e,(s+=e)<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}e+=h}),i&&!n&&this.revertPending(t.state),!n}update(t){let e=this.pendingContextChange,n=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(n.from,n.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),i=this.toContextPos(e.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(n,i)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let n=this.composing;return n&&n.drifted?n.editorBase+(t-n.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class nA{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:n}=t;for(let e of(this.dispatchTransactions=t.dispatchTransactions||n&&(t=>t.forEach(t=>n(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new nr(t.state||l.$t.create(t)),t.scrollTo&&t.scrollTo.is(tZ)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(t2).map(t=>new t3(t)),this.plugins))e.update(this);this.observer=new nx(this),this.inputState=new eA(this),this.inputState.ensureHandlers(this.plugins),this.docView=new el(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null==(e=document.fonts)?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof l.ZX?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,n=!1,i,r=this.state;for(let e of t){if(e.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,a=null;t.some(t=>t.annotation(eK))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,(a=eJ(r,s))||(o=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),((c=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(l.$t.phrases)!=this.state.facet(l.$t.phrases))return this.setState(r);i=eo.create(this,r,t),i.flags|=o;let u=this.viewState.scrollTarget;try{for(let e of(this.updateState=2,t)){if(u&&(u=u.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;u=new tG(t.empty?t:l.OF.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(tZ)&&(u=t.value.clip(this.state))}this.viewState.update(i,u),this.bidiCache=nD.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),e=this.docView.update(i),this.state.facet(er)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(nu)!=i.state.facet(nu)&&(this.viewState.mustMeasureContent=!0),(e||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!i.empty)for(let t of this.state.facet(tH))try{t(i)}catch(t){tQ(this.state,t,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!eS(this,c)&&h.force&&T(this.contentDOM,h.key,h.keyCode)})}setState(t){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);for(let e of(this.viewState=new nr(t),this.plugins=t.facet(t2).map(t=>new t3(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView.destroy(),this.docView=new el(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(t2),n=t.state.facet(t2);if(e!=n){let i=[];for(let r of n){let n=e.indexOf(r);if(n<0)i.push(new t3(r));else{let e=this.plugins[n];e.mustUpdate=t,i.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){tQ(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(R(n))r=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(i);r=t.from,s=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(t=>{try{return t.read(this)}catch(t){return tQ(this.state,t),nM}}),h=eo.create(this,this.state,[]),c=!1;h.flags|=o,e?e.flags|=o:e=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(a[t]!=nM)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){tQ(this.state,t)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let t=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(t>1||t<-1){n.scrollTop=(i+=t)/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(tH))t(e)}get themeClasses(){return nd+" "+(this.state.facet(nf)?nm:np)+" "+this.state.facet(nu)}updateAttrs(){let t=nP(this,t8,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(t0)?"true":"false",class:"cm-content",style:`${Q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),nP(this,t5,e);let n=this.observer.ignore(()=>{let n=th(this.contentDOM,this.contentAttrs,e),i=th(this.dom,this.editorAttrs,t);return n||i});return this.editorAttrs=t,this.contentAttrs=e,n}showAnnouncements(t){let e=!0;for(let n of t)for(let t of n.effects)t.is(nA.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(er);let t=this.state.facet(nA.cspNonce);a.G.mount(this.root,this.styleModules.concat(nb).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if((this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t)&&!(this.measureRequests.indexOf(t)>-1)){if(null!=t.key){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,n){return ey(this,t,ev(this,t,e,n))}moveByGroup(t,e){return ey(this,t,ev(this,t,e,e=>{var n;let i,r;return n=t.head,r=(i=this.state.charCategorizer(n))(e),t=>{let e=i(t);return r==l.Je.Space&&(r=e),r==e}}))}visualLineSide(t,e){let n=this.bidiSpans(t),i=this.textDirectionAt(t.from),r=n[e?n.length-1:0];return l.OF.cursor(r.side(e,i)+t.from,r.forward(!e,i)?1:-1)}moveToLineBoundary(t,e,n=!0){return function(t,e,n,i){let r=eg(t,e.head,e.assoc||-1),s=i&&r.type==tu.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),i=t.textDirectionAt(r.from),o=t.posAtCoords({x:n==(i==tC.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=o)return l.OF.cursor(o,n?-1:1)}return l.OF.cursor(n?r.to:r.from,n?-1:1)}(this,t,e,n)}moveVertically(t,e,n){return ey(this,t,function(t,e,n,i){let r=e.head,s=n?1:-1;if(r==(n?t.state.doc.length:0))return l.OF.cursor(r,e.assoc);let o=e.goalColumn,a,h=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(r,e.assoc||-1),u=t.documentTop;if(c)null==o&&(o=c.left-h.left),a=s<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(r);null==o&&(o=Math.min(h.right-h.left,t.defaultCharacterWidth*(r-e.from))),a=(s<0?e.top:e.bottom)+u}let f=h.left+o,d=null!=i?i:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let n=a+(d+e)*s,i=ep(t,{x:f,y:n},!1,s);if(n<h.top||n>h.bottom||(s<0?i<r:i>r)){let e=t.docView.coordsForChar(i),r=!e||n<e.top?-1:1;return l.OF.cursor(i,r,void 0,o)}}}(this,t,e,n))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),ep(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let n=this.docView.coordsAt(t,e);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(t),r=this.bidiSpans(i);return C(n,r[tL.find(r,t-i.from,-1,e)].dir==tC.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(tK)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>nO)return tI(t.length);let e=this.textDirectionAt(t.from),n;for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e&&(i.fresh||function t(e,n){if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!t(r.inner,s.inner))return!1}return!0}(i.isolates,n=ee(this,t))))return i.order;n||(n=ee(this,t));let i=function(t,e,n){if(!t)return[new tL(0,0,+(e==tO))];if(e==tA&&!n.length&&!tB.test(t))return tI(t.length);if(n.length)for(;t.length>tN.length;)tN[tN.length]=256;let i=[],r=+(e!=tA);return function t(e,n,i,r,s,o,l){let a=n%2?2:1;!function(t,e,n,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:n,a=s?256:r;for(let e=o,n=a,i=a;e<l;e++){let r=tR(t.charCodeAt(e));512==r?r=n:8==r&&4==i&&(r=16),tN[e]=4==r?2:r,7&r&&(i=r),n=r}for(let t=o,e=a,i=a;t<l;t++){let r=tN[t];if(128==r)t<l-1&&e==tN[t+1]&&24&e?r=tN[t]=e:tN[t]=256;else if(64==r){let r=t+1;for(;r<l&&64==tN[r];)r++;let s=t&&8==e||r<n&&8==tN[r]?1==i?1:8:256;for(let e=t;e<r;e++)tN[e]=s;t=r-1}else 8==r&&1==i&&(tN[t]=1);e=r,7&r&&(i=r)}}}(e,s,o,r,a),function(t,e,n,i,r){let s=1==r?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:n;for(let e=h,n,i,o;e<c;e++)if(i=tT[n=t.charCodeAt(e)])if(i<0){for(let t=l-3;t>=0;t-=3)if(tE[t+1]==-i){let n=tE[t+2],i=2&n?r:4&n?1&n?s:r:0;i&&(tN[e]=tN[tE[t]]=i),l=t;break}}else if(189==tE.length)break;else tE[l++]=e,tE[l++]=n,tE[l++]=a;else if(2==(o=tN[e])||1==o){let t=o==r;a=+!t;for(let e=l-3;e>=0;e-=3){let n=tE[e+2];if(2&n)break;if(t)tE[e+2]|=2;else{if(4&n)break;tE[e+2]|=4}}}}}(e,s,o,r,a),function(t,e,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:t,l=r<n.length?n[r].from:e;for(let a=o;a<l;){let o=tN[a];if(256==o){let o=a+1;for(;;)if(o==l){if(r==n.length)break;o=n[r++].to,l=r<n.length?n[r].from:e}else if(256==tN[o])o++;else break;let h=1==s,c=h==((o<e?tN[o]:i)==1)?h?1:2:i;for(let e=o,i=r,s=i?n[i-1].to:t;e>a;)e==s&&(e=n[--i].from,s=i?n[i-1].to:t),tN[--e]=c;a=o}else s=o,a++}}}(s,o,r,a),function e(n,i,r,s,o,l,a){let h=s%2?2:1;if(s%2==o%2)for(let c=i,u=0;c<r;){let i=!0,f=!1;if(u==l.length||c<l[u].from){let t=tN[c];t!=h&&(i=!1,f=16==t)}let d=i||1!=h?null:[],p=i?s:s+1,m=c;n:for(;;)if(u<l.length&&m==l[u].from){if(f)break;let e=l[u];if(!i)for(let t=e.to,n=u+1;;){if(t==r)break n;if(n<l.length&&l[n].from==t)t=l[n++].to;else if(tN[t]==h)break n;else break}u++,d?d.push(e):(e.from>c&&a.push(new tL(c,e.from,p)),t(n,e.direction==tA!=!(p%2)?s+1:s,o,e.inner,e.from,e.to,a),c=e.to),m=e.to}else if(m==r||(i?tN[m]!=h:tN[m]==h))break;else m++;d?e(n,c,m,s+1,o,d,a):c<m&&a.push(new tL(c,m,p)),c=m}else for(let c=r,u=l.length;c>i;){let r=!0,f=!1;if(!u||c>l[u-1].to){let t=tN[c-1];t!=h&&(r=!1,f=16==t)}let d=r||1!=h?null:[],p=r?s:s+1,m=c;n:for(;;)if(u&&m==l[u-1].to){if(f)break;let e=l[--u];if(!r)for(let t=e.from,n=u;;){if(t==i)break n;if(n&&l[n-1].to==t)t=l[--n].from;else if(tN[t-1]==h)break n;else break}d?d.push(e):(e.to<c&&a.push(new tL(e.to,c,p)),t(n,e.direction==tA!=!(p%2)?s+1:s,o,e.inner,e.from,e.to,a),c=e.from),m=e.from}else if(m==i||(r?tN[m-1]!=h:tN[m-1]==h))break;else m--;d?e(n,m,c,s+1,o,d,a):m<c&&a.push(new tL(m,c,p)),c=m}}(e,s,o,n,i,r,l)}(t,r,r,n,0,t.length,i),i}(t.text,e,n);return this.bidiCache.push(new nD(t.from,t.to,e,n,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Q.safari&&(null==(t=this.inputState)?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{D(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return tZ.of(new tG("number"==typeof t?l.OF.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,n=this.viewState.scrollAnchorAt(t);return tZ.of(new tG(l.OF.cursor(n.from),"start","start",n.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return t4.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return t4.define(()=>({}),{eventObservers:t})}static theme(t,e){let n=a.G.newName(),i=[nu.of(n),er.of(nv(`.${n}`,t))];return e&&e.dark&&i.push(nf.of(!0)),i}static baseTheme(t){return l.Nb.lowest(er.of(nv("."+nd,t,ng)))}static findFromDOM(t){var e;let n=t.querySelector(".cm-content"),i=n&&F.get(n)||F.get(t);return(null==(e=null==i?void 0:i.rootView)?void 0:e.view)||null}}nA.styleModule=er,nA.inputHandler=tW,nA.clipboardInputFilter=tU,nA.clipboardOutputFilter=t$,nA.scrollHandler=tY,nA.focusChangeEffect=tq,nA.perLineTextDirection=tK,nA.exceptionSink=tV,nA.updateListener=tH,nA.editable=t0,nA.mouseSelectionStyle=tz,nA.dragMovesSelection=t_,nA.clickAddsSelectionRange=tj,nA.decorations=t9,nA.outerDecorations=t6,nA.atomicRanges=t7,nA.bidiIsolatedRanges=et,nA.scrollMargins=en,nA.darkTheme=nf,nA.cspNonce=l.sj.define({combine:t=>t.length?t[0]:""}),nA.contentAttributes=t5,nA.editorAttributes=t8,nA.lineWrapping=nA.contentAttributes.of({class:"cm-lineWrapping"}),nA.announce=l.Pe.define();let nO=4096,nM={};class nD{constructor(t,e,n,i,r,s){this.from=t,this.to=e,this.dir=n,this.isolates=i,this.fresh=r,this.order=s}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let n=[],i=t.length?t[t.length-1].dir:tC.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let s=t[r];s.dir!=i||e.touchesRange(s.from,s.to)||n.push(new nD(e.mapPos(s.from,1),e.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return n}}function nP(t,e,n){for(let i=t.state.facet(e),r=i.length-1;r>=0;r--){let e=i[r],s="function"==typeof e?e(t):e;s&&to(s,n)}return n}let nT=Q.mac?"mac":Q.windows?"win":Q.linux?"linux":"key";function nE(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}let nR=l.Nb.default(nA.domEventHandlers({keydown:(t,e)=>n_(nN(e.state),t,e,"editor")})),nB=l.sj.define({enables:nR}),nL=new WeakMap;function nN(t){let e=t.facet(nB),n=nL.get(e);return n||nL.set(e,n=function(t,e=nT){let n=Object.create(null),i=Object.create(null),r=(t,e)=>{let n=i[t];if(null==n)i[t]=e;else if(n!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},s=(t,i,s,o,l)=>{var a,h;let c=n[t]||(n[t]=Object.create(null)),u=i.split(/ (?!$)/).map(t=>(function(t,e){let n,i,r,s,o=t.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let t=0;t<o.length-1;++t){let l=o[t];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))r=!0;else if(/^mod$/i.test(l))"mac"==e?s=!0:i=!0;else throw Error("Unrecognized modifier name: "+l)}return n&&(l="Alt-"+l),i&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l})(t,e));for(let e=1;e<u.length;e++){let n=u.slice(0,e).join(" ");r(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[e=>{let i=nF={view:e,prefix:n,scope:t};return setTimeout(()=>{nF==i&&(nF=null)},4e3),!0}]})}let f=u.join(" ");r(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null==(h=null==(a=c._any)?void 0:a.run)?void 0:h.slice())||[]});s&&d.run.push(s),o&&(d.preventDefault=!0),l&&(d.stopPropagation=!0)};for(let i of t){let t=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let e of t){let t=n[e]||(n[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=i;for(let e in t)t[e].run.push(t=>r(t,nj))}let r=i[e]||i.key;if(r)for(let e of t)s(e,r,i.run,i.preventDefault,i.stopPropagation),i.shift&&s(e,"Shift-"+r,i.shift,i.preventDefault,i.stopPropagation)}return n}(e.reduce((t,e)=>t.concat(e),[]))),n}function nI(t,e,n){return n_(nN(t.state),e,t,n)}let nF=null,nj=null;function n_(t,e,n,i){var r;nj=e;let s=("Esc"==(r=!(u&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||f&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?c:h)[e.keyCode]||e.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=(0,l.vS)(s,0),a=(0,l.Fh)(o)==s.length&&" "!=s,d="",p=!1,m=!1,g=!1;nF&&nF.view==n&&nF.scope==i&&(d=nF.prefix+" ",0>eP.indexOf(e.keyCode)&&(m=!0,nF=null));let v=new Set,b=t=>{if(t){for(let e of t.run)if(!v.has(e)&&(v.add(e),e(n)))return t.stopPropagation&&(g=!0),!0;t.preventDefault&&(t.stopPropagation&&(g=!0),m=!0)}return!1},y=t[i],w,x;return y&&(b(y[d+nE(s,e,!a)])?p=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Q.windows&&e.ctrlKey&&e.altKey)&&(w=h[e.keyCode])&&w!=s?b(y[d+nE(w,e,!0)])?p=!0:e.shiftKey&&(x=c[e.keyCode])!=s&&x!=w&&b(y[d+nE(x,e,!1)])&&(p=!0):a&&e.shiftKey&&b(y[d+nE(s,e,!0)])&&(p=!0),!p&&b(y._any)&&(p=!0)),m&&(p=!0),p&&g&&e.stopPropagation(),nj=null,p}class nz{constructor(t,e,n,i,r){this.className=t,this.left=e,this.top=n,this.width=i,this.height=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,n){if(!n.empty)return function(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let i=Math.max(n.from,t.viewport.from),r=Math.min(n.to,t.viewport.to),s=t.textDirection==tC.LTR,o=t.contentDOM,l=o.getBoundingClientRect(),a=nV(t),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),u=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),d=eg(t,i,1),p=eg(t,r,-1),m=d.type==tu.Text?d:null,g=p.type==tu.Text?p:null;if(m&&(t.lineWrapping||d.widgetLineBreaks)&&(m=nH(t,i,1,m)),g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=nH(t,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let e=m?y(n.from,null,m):w(d,!1),i=g?y(null,n.to,g):w(p,!0),r=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<i.top?r.push(v(u,e.bottom,f,i.top)):e.bottom<i.top&&t.elementAtHeight((e.bottom+i.top)/2).type==tu.Text&&(e.bottom=i.top=(e.bottom+i.top)/2),b(e).concat(r).concat(b(i))}function v(t,n,i,r){return new nz(e,t-a.left,n-a.top,i-t,r-n)}function b({top:t,bottom:e,horizontal:n}){let i=[];for(let r=0;r<n.length;r+=2)i.push(v(n[r],t,n[r+1],e));return i}function y(e,n,i){let r=1e9,o=-1e9,l=[];function a(e,n,a,h,c){let d=t.coordsAtPos(e,e==i.to?-2:2),p=t.coordsAtPos(a,a==i.from?2:-2);d&&p&&(r=Math.min(d.top,p.top,r),o=Math.max(d.bottom,p.bottom,o),c==tC.LTR?l.push(s&&n?u:d.left,s&&h?f:p.right):l.push(!s&&h?u:p.left,!s&&n?f:d.right))}let h=null!=e?e:i.from,c=null!=n?n:i.to;for(let i of t.visibleRanges)if(i.to>h&&i.from<c)for(let r=Math.max(i.from,h),s=Math.min(i.to,c);;){let i=t.state.doc.lineAt(r);for(let o of t.bidiSpans(i)){let t=o.from+i.from,l=o.to+i.from;if(t>=s)break;l>r&&a(Math.max(t,r),null==e&&t<=h,Math.min(l,s),null==n&&l>=c,o.dir)}if((r=i.to+1)>=s)break}return 0==l.length&&a(h,null==e,c,null==n,t.textDirection),{top:r,bottom:o,horizontal:l}}function w(t,e){let n=l.top+(e?t.top:t.bottom);return{top:n,bottom:n,horizontal:[]}}}(t,e,n);{let i=t.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let r=nV(t);return[new nz(e,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}}}function nV(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==tC.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function nH(t,e,n,i){let r=t.coordsAtPos(e,2*n);if(!r)return i;let s=t.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=t.posAtCoords({x:s.left+1,y:o}),a=t.posAtCoords({x:s.right-1,y:o});return null==l||null==a?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}class nW{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(nq)!=t.state.facet(nq)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,n=t.facet(nq);for(;e<n.length&&n[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;(t!=this.scaleX||e!=this.scaleY)&&(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{var n;return n=this.drawn[e],!(t.constructor==n.constructor&&t.eq(n))})){let e=this.dom.firstChild,n=0;for(let i of t)i.update&&e&&i.constructor&&this.drawn[n].constructor&&i.update(e,this.drawn[n])?(e=e.nextSibling,n++):this.dom.insertBefore(i.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}let nq=l.sj.define();function nU(t){return[t4.define(e=>new nW(e,t)),nq.of(t)]}let n$=l.sj.define({combine:t=>(0,l.QR)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function nK(t={}){return[n$.of(t),nY,nZ,nX,tJ.of(!0)]}function nJ(t){return t.startState.facet(n$)!=t.state.facet(n$)}let nY=nU({above:!0,markers(t){let{state:e}=t,n=e.facet(n$),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||n.drawRangeCursor){let e=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=r.empty?r:l.OF.cursor(r.head,r.head>r.anchor?-1:1);for(let r of nz.forRange(t,e,n))i.push(r)}}return i},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let n=nJ(t);return n&&nG(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){nG(e.state,t)},class:"cm-cursorLayer"});function nG(t,e){e.style.animationDuration=t.facet(n$).cursorBlinkRate+"ms"}let nZ=nU({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:nz.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||nJ(t),class:"cm-selectionLayer"}),nX=l.Nb.highest(nA.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),nQ=l.Pe.define({map:(t,e)=>null==t?null:e.mapPos(t)}),n0=l.sU.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(nQ)?e.value:t,t))}),n1=t4.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field(n0);null==n?null!=this.cursor&&(null==(e=this.cursor)||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(n0)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(n0),n=null!=e&&t.coordsAtPos(e);if(!n)return null;let i=t.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-i.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(n0)!=t&&this.view.dispatch({effects:nQ.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function n2(){return[n0,n1]}function n4(t,e,n,i,r){e.lastIndex=0;for(let s=t.iterRange(n,i),o=n,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}class n3{constructor(t){const{regexp:e,decoration:n,decorate:i,boundary:r,maxLength:s=1e3}=t;if(!e.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,i)this.addMatch=(t,e,n,r)=>i(r,n,n+t[0].length,t,e);else if("function"==typeof n)this.addMatch=(t,e,i,r)=>{let s=n(t,e,i);s&&r(i,i+t[0].length,s)};else if(n)this.addMatch=(t,e,i,r)=>r(i,i+t[0].length,n);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}createDeco(t){let e=new l.vB,n=e.add.bind(e);for(let{from:e,to:i}of function(t,e){let n=t.visibleRanges;if(1==n.length&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}(t,this.maxLength))n4(t.state.doc,this.regexp,e,i,(e,i)=>this.addMatch(i,t,e,n));return e.finish()}updateDeco(t,e){let n=1e9,i=-1;return(t.docChanged&&t.changes.iterChanges((e,r,s,o)=>{o>=t.view.viewport.from&&s<=t.view.viewport.to&&(n=Math.min(s,n),i=Math.max(o,i))}),t.viewportMoved||i-n>1e3)?this.createDeco(t.view):i>-1?this.updateRange(t.view,e.map(t.changes),n,i):e}updateRange(t,e,n,i){for(let r of t.visibleRanges){let s=Math.max(r.from,n),o=Math.min(r.to,i);if(o>=s){let n=t.state.doc.lineAt(s),i=n.to<o?t.state.doc.lineAt(o):n,l=Math.max(r.from,n.from),a=Math.min(r.to,i.to);if(this.boundary){for(;s>n.from;s--)if(this.boundary.test(n.text[s-1-n.from])){l=s;break}for(;o<i.to;o++)if(this.boundary.test(i.text[o-i.from])){a=o;break}}let h=[],c,u=(t,e,n)=>h.push(n.range(t,e));if(n==i)for(this.regexp.lastIndex=l-n.from;(c=this.regexp.exec(n.text))&&c.index<a-n.from;)this.addMatch(c,t,c.index+n.from,u);else n4(t.state.doc,this.regexp,l,a,(e,n)=>this.addMatch(n,t,e,u));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:h})}}return e}}let n8=null!=/x/.unicode?"gu":"g",n5=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]",n8),n9={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},n6=null,n7=l.sj.define({combine(t){let e=(0,l.QR)(t,{render:null,specialChars:n5,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==n6&&"u">typeof document&&document.body){let e=document.body.style;n6=(null!=(t=e.tabSize)?t:e.MozTabSize)!=null}return n6||!1}())&&(e.specialChars=RegExp(" |"+e.specialChars.source,n8)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,n8)),e}});function it(t={}){return[n7.of(t),ie||(ie=t4.fromClass(class{constructor(t){this.view=t,this.decorations=tf.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(n7)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new n3({regexp:t.specialChars,decoration:(e,n,i)=>{let{doc:r}=n.state,s=(0,l.vS)(e[0],0);if(9==s){let t=r.lineAt(i),e=n.state.tabSize,s=(0,l.y$)(t.text,e,i-t.from);return tf.replace({widget:new ir((e-s%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=tf.replace({widget:new ii(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(n7);t.startState.facet(n7)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let ie=null;class ii extends tc{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){var e;let n=(e=this.code)>=32?"•":10==e?"␤":String.fromCharCode(9216+e),i=t.state.phrase("Control character")+" "+(n9[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class ir extends tc{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function is(){return il}let io=tf.line({class:"cm-activeLine"}),il=t4.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let i of t.state.selection.ranges){let r=t.lineBlockAt(i.head);r.from>e&&(n.push(io.range(r.from)),e=r.from)}return tf.set(n)}},{decorations:t=>t.decorations});function ia(t,e){var n;let i,r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),s=t.state.doc.lineAt(r),o=r-s.from,a=o>2e3?-1:o==s.length?(n=e.clientX,(i=t.coordsAtPos(t.viewport.from))?Math.round(Math.abs((i.left-n)/t.defaultCharacterWidth)):-1):(0,l.y$)(s.text,t.state.tabSize,r-s.from);return{line:s.number,col:a,off:o}}function ih(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return nA.mouseSelectionStyle.of((t,n)=>{let i,r;return e(n)?(i=ia(t,n),r=t.state.selection,i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),n=t.state.doc.lineAt(e);i={line:n.number,col:i.col,off:Math.min(i.off,n.length)},r=r.map(t.changes)}},get(e,n,s){let o=ia(t,e);if(!o)return r;let a=function(t,e,n){let i=Math.min(e.line,n.line),r=Math.max(e.line,n.line),s=[];if(e.off>2e3||n.off>2e3||e.col<0||n.col<0){let o=Math.min(e.off,n.off),a=Math.max(e.off,n.off);for(let e=i;e<=r;e++){let n=t.doc.line(e);n.length<=a&&s.push(l.OF.range(n.from+o,n.to+a))}}else{let o=Math.min(e.col,n.col),a=Math.max(e.col,n.col);for(let e=i;e<=r;e++){let n=t.doc.line(e),i=(0,l.kn)(n.text,o,t.tabSize,!0);if(i<0)s.push(l.OF.cursor(n.to));else{let e=(0,l.kn)(n.text,a,t.tabSize);s.push(l.OF.range(n.from+i,n.from+e))}}}return s}(t.state,i,o);return a.length?s?l.OF.create(a.concat(r.ranges)):l.OF.create(a):r}}:null):null})}let ic={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},iu={style:"cursor: crosshair"};function id(t={}){let[e,n]=ic[t.key||"Alt"],i=t4.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||n(t))},keyup(t){t.keyCode!=e&&n(t)||this.set(!1)},mousemove(t){this.set(n(t))}}});return[i,nA.contentAttributes.of(t=>{var e;return(null==(e=t.plugin(i))?void 0:e.isDown)?iu:null})]}let ip="-10000px";class im{constructor(t,e,n,i){this.facet=e,this.createTooltipView=n,this.removeTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let r=null;this.tooltipViews=this.tooltips.map(t=>r=n(t,r))}update(t,e){var n;let i=t.state.facet(this.facet),r=i.filter(t=>t);if(i===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[],o=e?[]:null;for(let n=0;n<r.length;n++){let i=r[n],l=-1;if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(l=t)}if(l<0)s[n]=this.createTooltipView(i,n?s[n-1]:null),o&&(o[n]=!!i.above);else{let i=s[n]=this.tooltipViews[l];o&&(o[n]=e[l]),i.update&&i.update(t)}}}for(let t of this.tooltipViews)0>s.indexOf(t)&&(this.removeTooltipView(t),null==(n=t.destroy)||n.call(t));return e&&(o.forEach((t,n)=>e[n]=t),e.length=o.length),this.input=i,this.tooltips=r,this.tooltipViews=s,!0}}function ig(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}let iv=l.sj.define({combine:t=>{var e,n,i;return{position:Q.ios?"absolute":(null==(e=t.find(t=>t.position))?void 0:e.position)||"fixed",parent:(null==(n=t.find(t=>t.parent))?void 0:n.parent)||null,tooltipSpace:(null==(i=t.find(t=>t.tooltipSpace))?void 0:i.tooltipSpace)||ig}}}),ib=new WeakMap,iy=t4.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(iv);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new im(t,iS,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let t of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(t.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,i=t.state.facet(iv);if(i.position!=this.position&&!this.madeAbsolute){for(let t of(this.position=i.position,this.manager.tooltipViews))t.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(t.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),i=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",n.dom.appendChild(t)}return n.dom.style.position=this.position,n.dom.style.top=ip,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;for(let e of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))e.dom.remove(),null==(t=e.destroy)||t.call(e);this.parent&&this.container.remove(),null==(e=this.resizeObserver)||e.disconnect(),null==(n=this.intersectionObserver)||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(Q.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==ip&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(t=n.width/this.parent.offsetWidth,e=n.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=ei(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let n=this.manager.tooltipViews[e];return n.getCoords?n.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(iv).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute)for(let t of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))t.dom.style.position="absolute";let{visible:n,space:i,scaleX:r,scaleY:s}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,u=t.pos[l],f=t.size[l];if(!u||!1!==a.clip&&(u.bottom<=Math.max(n.top,i.top)||u.top>=Math.min(n.bottom,i.bottom)||u.right<Math.max(n.left,i.left)-.1||u.left>Math.min(n.right,i.right)+.1)){c.style.top=ip;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!d,m=f.right-f.left,g=null!=(e=ib.get(h))?e:f.bottom-f.top,v=h.offset||ik,b=this.view.textDirection==tC.LTR,y=f.width>i.right-i.left?b?i.left:i.right-f.width:b?Math.max(i.left,Math.min(u.left-14*!!d+v.x,i.right-m)):Math.min(Math.max(i.left,u.left-m+14*!!d-v.x),i.right-m),w=this.above[l];!a.strictSide&&(w?u.top-g-p-v.y<i.top:u.bottom+g+p+v.y>i.bottom)&&w==i.bottom-u.bottom>u.top-i.top&&(w=this.above[l]=!w);let x=(w?u.top-i.top:i.bottom-u.bottom)-p;if(x<g&&!1!==h.resize){if(x<this.view.defaultLineHeight){c.style.top=ip;continue}ib.set(h,g),c.style.height=(g=x)/s+"px"}else c.style.height&&(c.style.height="");let k=w?u.top-g-p-v.y:u.bottom+p+v.y,S=y+m;if(!0!==h.overlap)for(let t of o)t.left<S&&t.right>y&&t.top<k+g&&t.bottom>k&&(k=w?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/s+"px",iw(c,(y-t.parent.left)/r)):(c.style.top=k/s+"px",iw(c,y/r)),d){let t=u.left+(b?v.x:-v.x)-(y+14-7);d.style.left=t/r+"px"}!0!==h.overlap&&o.push({left:y,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",w),c.classList.toggle("cm-tooltip-below",!w),h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView)&&(this.inView=this.view.inView,!this.inView))for(let t of this.manager.tooltipViews)t.dom.style.top=ip}},{eventObservers:{scroll(){this.maybeMeasure()}}});function iw(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}let ix=nA.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),ik={x:0,y:0},iS=l.sj.define({enables:[iy,ix]}),iC=l.sj.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class iA{static create(t){return new iA(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new im(t,iC,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let n=t.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null==(t=e.destroy)||t.call(e)}passProp(t){let e;for(let n of this.manager.tooltipViews){let i=n[t];if(void 0!==i){if(void 0===e)e=i;else if(e!==i)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}let iO=iS.compute([iC],t=>{let e=t.facet(iC);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var e;return null!=(e=t.end)?e:t.pos})),create:iA.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class iM{constructor(t,e,n,i,r){this.view=t,this.source=e,this.field=n,this.setHover=i,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,n=t.docView.nearest(e.target);if(!n)return;let i,r=1;if(n instanceof tn)i=n.posAtStart;else{if(null==(i=t.posAtCoords(e)))return;let n=t.coordsAtPos(i);if(!n||e.y<n.top||e.y>n.bottom||e.x<n.left-t.defaultCharacterWidth||e.x>n.right+t.defaultCharacterWidth)return;let s=t.bidiSpans(t.state.doc.lineAt(i)).find(t=>t.from<=i&&t.to>=i),o=s&&s.dir==tC.RTL?-1:1;r=e.x<n.left?-o:o}let s=this.source(t,i,r);if(null==s?void 0:s.then){let e=this.pending={pos:i};s.then(n=>{this.pending==e&&(this.pending=null,n&&!(Array.isArray(n)&&!n.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},e=>tQ(t.state,e,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let t=this.view.plugin(iy),e=t?t.manager.tooltips.findIndex(t=>t.create==iA.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,n;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i.length&&r&&!function(t,e){let{left:n,right:i,top:r,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let t=o.getBoundingClientRect();r=Math.min(t.top,r),s=Math.max(t.bottom,s)}return e.clientX>=n-4&&e.clientX<=i+4&&e.clientY>=r-4&&e.clientY<=s+4}(r.dom,t)||this.pending){let{pos:r}=i[0]||this.pending,s=null!=(n=null==(e=i[0])?void 0:e.end)?n:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!function(t,e,n,i,r){let s=t.scrollDOM.getBoundingClientRect(),o=t.documentTop+t.documentPadding.top+t.contentHeight;if(s.left>i||s.right<i||s.top>r||Math.min(s.bottom,o)<r)return!1;let l=t.posAtCoords({x:i,y:r},!1);return l>=e&&l<=n}(this.view,r,s,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=n=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function iD(t,e={}){let n=l.Pe.define(),i=l.sU.define({create:()=>[],update(t,i){if(t.length&&(e.hideOnChange&&(i.docChanged||i.selection)?t=[]:e.hideOn&&(t=t.filter(t=>!e.hideOn(i,t))),i.docChanged)){let e=[];for(let n of t){let t=i.changes.mapPos(n.pos,-1,l.iR.TrackDel);if(null!=t){let r=Object.assign(Object.create(null),n);r.pos=t,null!=r.end&&(r.end=i.changes.mapPos(r.end)),e.push(r)}}t=e}for(let e of i.effects)e.is(n)&&(t=e.value),e.is(iT)&&(t=[]);return t},provide:t=>iC.from(t)});return{active:i,extension:[i,t4.define(r=>new iM(r,t,i,n,e.hoverTime||300)),iO]}}function iP(t,e){let n=t.plugin(iy);if(!n)return null;let i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}let iT=l.Pe.define(),iE=l.sj.define({combine(t){let e,n;for(let i of t)e=e||i.topContainer,n=n||i.bottomContainer;return{topContainer:e,bottomContainer:n}}});function iR(t,e){let n=t.plugin(iB),i=n?n.specs.indexOf(e):-1;return i>-1?n.panels[i]:null}let iB=t4.fromClass(class{constructor(t){this.input=t.state.facet(iI),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(iE);for(let n of(this.top=new iL(t,!0,e.topContainer),this.bottom=new iL(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top)),this.panels))n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(iE);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new iL(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new iL(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(iI);if(n!=this.input){let e=n.filter(t=>t),i=[],r=[],s=[],o=[];for(let n of e){let e=this.specs.indexOf(n),l;e<0?(l=n(t.view),o.push(l)):(l=this.panels[e]).update&&l.update(t),i.push(l),(l.top?r:s).push(l)}for(let t of(this.specs=e,this.panels=i,this.top.sync(r),this.bottom.sync(s),o))t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>nA.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class iL{constructor(t,e,n){this.view=t,this.top=e,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&0>t.indexOf(e)&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=iN(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=iN(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function iN(t){let e=t.nextSibling;return t.remove(),e}let iI=l.sj.define({enables:iB});class iF extends l.FB{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}iF.prototype.elementClass="",iF.prototype.toDOM=void 0,iF.prototype.mapMode=l.iR.TrackBefore,iF.prototype.startSide=iF.prototype.endSide=-1,iF.prototype.point=!0;let ij=l.sj.define(),i_=l.sj.define(),iz={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>l.om.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},iV=l.sj.define();function iH(t){return[iq(),iV.of({...iz,...t})]}let iW=l.sj.define({combine:t=>t.some(t=>t)});function iq(t){let e=[iU];return t&&!1===t.fixed&&e.push(iW.of(!0)),e}let iU=t4.fromClass(class{constructor(t){for(let e of(this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(iV).map(e=>new iY(t,e)),this.fixed=!t.state.facet(iW),this.gutters))"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(iW)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=l.om.iter(this.view.state.facet(ij),this.view.viewport.from),i=[],r=this.gutters.map(t=>new iJ(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(t.type)){let e=!0;for(let s of t.type)if(s.type==tu.Text&&e){for(let t of(iK(n,i,s.from),r))t.line(this.view,s,i);e=!1}else if(s.widget)for(let t of r)t.widget(this.view,s)}else if(t.type==tu.Text)for(let e of(iK(n,i,t.from),r))e.line(this.view,t,i);else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(iV),n=t.state.facet(iV),i=t.docChanged||t.heightChanged||t.viewportChanged||!l.om.eq(t.startState.facet(ij),t.state.facet(ij),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let e of this.gutters)e.update(t)&&(i=!0);else{i=!0;let r=[];for(let i of n){let n=e.indexOf(i);n<0?r.push(new iY(this.view,i)):(this.gutters[n].update(t),r.push(this.gutters[n]))}for(let t of this.gutters)t.dom.remove(),0>r.indexOf(t)&&t.destroy();for(let t of r)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=r}return i}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>nA.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==tC.LTR?{left:i,right:r}:{right:i,left:r}})});function i$(t){return Array.isArray(t)?t:[t]}function iK(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class iJ{constructor(t,e,n){this.gutter=t,this.height=n,this.i=0,this.cursor=l.om.iter(t.markers,e.from)}addElement(t,e,n){let{gutter:i}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==i.elements.length){let e=new iG(t,s,r,n);i.elements.push(e),i.dom.appendChild(e.dom)}else i.elements[this.i].update(t,s,r,n);this.height=e.bottom,this.i++}line(t,e,n){let i=[];iK(this.cursor,i,e.from),n.length&&(i=i.concat(n));let r=this.gutter.config.lineMarker(t,e,i);r&&i.unshift(r);let s=this.gutter;(0!=i.length||s.config.renderEmptyElements)&&this.addElement(t,e,i)}widget(t,e){let n=this.gutter.config.widgetMarker(t,e.widget,e),i=n?[n]:null;for(let n of t.state.facet(i_)){let r=n(t,e.widget,e);r&&(i||(i=[])).push(r)}i&&this.addElement(t,e,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class iY{constructor(t,e){for(let n in this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(n,i=>{let r=i.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=i.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[n](t,o,i)&&i.preventDefault()});this.markers=i$(e.markers(t)),e.initialSpacer&&(this.spacer=new iG(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=i$(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let n=t.view.viewport;return!l.om.eq(this.markers,e,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class iG{constructor(t,e,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,n,i)}update(t,e,n,i){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),!function(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}(this.markers,i)&&this.setMarkers(t,i)}setMarkers(t,e){let n="cm-gutterElement",i=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<e.length?e[r++]:null,a=!1;if(l){let t=l.elementClass;t&&(n+=" "+t);for(let t=s;t<this.markers.length;t++)if(this.markers[t].compare(l)){o=t,a=!0;break}}else o=this.markers.length;for(;s<o;){let t=this.markers[s++];if(t.toDOM){t.destroy(i);let e=i.nextSibling;i.remove(),i=e}}if(!l)break;l.toDOM&&(a?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),a&&s++}this.dom.className=n,this.markers=e}destroy(){this.setMarkers(null,[])}}let iZ=l.sj.define(),iX=l.sj.define(),iQ=l.sj.define({combine:t=>(0,l.QR)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let n=Object.assign({},t);for(let t in e){let i=n[t],r=e[t];n[t]=i?(t,e,n)=>i(t,e,n)||r(t,e,n):r}return n}})});class i0 extends iF{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function i1(t,e){return t.state.facet(iQ).formatNumber(e,t.state)}let i2=iV.compute([iQ],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(iZ),lineMarker:(t,e,n)=>n.some(t=>t.toDOM)?null:new i0(i1(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,n)=>{for(let i of t.state.facet(iX)){let r=i(t,e,n);if(r)return r}return null},lineMarkerChange:t=>t.startState.facet(iQ)!=t.state.facet(iQ),initialSpacer:t=>new i0(i1(t,i3(t.state.doc.lines))),updateSpacer(t,e){let n=i1(e.view,i3(e.view.state.doc.lines));return n==t.number?t:new i0(n)},domEventHandlers:t.facet(iQ).domEventHandlers,side:"before"}));function i4(t={}){return[iQ.of(t),iq(),i2]}function i3(t){let e=9;for(;e<t;)e=10*e+9;return e}let i8=new class extends iF{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},i5=ij.compute(["selection"],t=>{let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.head).from;r>n&&(n=r,e.push(i8.range(r)))}return l.om.of(e)});function i9(){return i5}},80:function(t,e,n){var i,r;n.d(e,{PH:function(){return p},Qj:function(){return i},RY:function(){return R},Z6:function(){return c},fI:function(){return u},iX:function(){return L},rr:function(){return B},uY:function(){return l}});let s=0;class o{constructor(t,e){this.from=t,this.to=e}}class l{constructor(t={}){this.id=s++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=c.match(t)),e=>{let n=t(e);return void 0===n?null:[this,n]}}}l.closedBy=new l({deserialize:t=>t.split(" ")}),l.openedBy=new l({deserialize:t=>t.split(" ")}),l.group=new l({deserialize:t=>t.split(" ")}),l.isolate=new l({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw RangeError("Invalid value for isolate: "+t);return t||"auto"}}),l.contextHash=new l({perNode:!0}),l.lookAhead=new l({perNode:!0}),l.mounted=new l({perNode:!0});class a{constructor(t,e,n){this.tree=t,this.overlay=e,this.parser=n}static get(t){return t&&t.props&&t.props[l.mounted.id]}}let h=Object.create(null);class c{constructor(t,e,n,i=0){this.name=t,this.props=e,this.id=n,this.flags=i}static define(t){let e=t.props&&t.props.length?Object.create(null):h,n=!!t.top|2*!!t.skipped|4*!!t.error|8*(null==t.name),i=new c(t.name||"",e,t.id,n);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(l.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let n in t)for(let i of n.split(" "))e[i]=t[n];return t=>{for(let n=t.prop(l.group),i=-1;i<(n?n.length:0);i++){let r=e[i<0?t.name:n[i]];if(r)return r}}}}c.none=new c("",Object.create(null),0,8);class u{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let n of this.types){let i=null;for(let e of t){let t=e(n);t&&(i||(i=Object.assign({},n.props)),i[t[0].id]=t[1])}e.push(i?new c(n.name,i,n.id,n.flags):n)}return new u(e)}}let f=new WeakMap,d=new WeakMap;(r=i||(i={}))[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays";class p{constructor(t,e,n,i,r){if(this.type=t,this.children=e,this.positions=n,this.length=i,this.props=null,r&&r.length)for(let[t,e]of(this.props=Object.create(null),r))this.props["number"==typeof t?t:t.id]=e}toString(){let t=a.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let n=t.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new M(this.topNode,t)}cursorAt(t,e=0,n=0){let i=new M(f.get(this)||this.topNode);return i.moveTo(t,e),f.set(this,i._tree),i}get topNode(){return new w(this,0,0,null)}resolve(t,e=0){let n=b(f.get(this)||this.topNode,t,e,!1);return f.set(this,n),n}resolveInner(t,e=0){let n=b(d.get(this)||this.topNode,t,e,!0);return d.set(this,n),n}resolveStack(t,e=0){return function(t,e,n){let i=t.resolveInner(e,n),r=null;for(let t=i instanceof w?i:i.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(r||(r=[i])).push(s.resolve(e,n)),t=s}else{let s=a.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new w(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[i])).push(b(o,e,n,!1))}}return r?A(r):i}(this,t,e)}iterate(t){let{enter:e,leave:n,from:r=0,to:s=this.length}=t,o=t.mode||0,l=(o&i.IncludeAnonymous)>0;for(let t=this.cursor(o|i.IncludeAnonymous);;){let i=!1;if(t.from<=s&&t.to>=r&&(!l&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;i=!0}for(;i&&n&&(l||!t.type.isAnonymous)&&n(t),!t.nextSibling();){if(!t.parent())return;i=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:E(c.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,n)=>new p(this.type,t,e,n,this.propValues),t.makeTree||((t,e,n)=>new p(c.none,t,e,n)))}static build(t){return function(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=t,a=Array.isArray(n)?new m(n,n.length):n,h=i.types,c=0,u=0;function f(t,e,n,r,s,o,l,a,h){let c=[],u=[];for(;t.length>r;)c.push(t.pop()),u.push(e.pop()+n-s);t.push(d(i.types[l],c,u,o-s,a-o,h)),e.push(s-n)}function d(t,e,n,i,r,s,o){if(s){let t=[l.contextHash,s];o=o?[t].concat(o):[t]}if(r>25){let t=[l.lookAhead,r];o=o?[t].concat(o):[t]}return new p(t,e,n,i,o)}let v=[],b=[];for(;a.pos>0;)!function t(e,n,m,v,b,y){let{id:w,start:x,end:k,size:S}=a,C=u,A=c;for(;S<0;){if(a.next(),-1==S){let t=s[w];m.push(t),v.push(x-e);return}if(-3==S){c=w;return}if(-4==S){u=w;return}else throw RangeError(`Unrecognized record size: ${S}`)}let O=h[w],M,D,P=x-e;if(k-x<=r&&(D=function(t,e){let n=a.fork(),i=0,s=0,l=0,h=n.end-r,c={size:0,start:0,skip:0};i:for(let r=n.pos-t;n.pos>r;){let t=n.size;if(n.id==e&&t>=0){c.size=i,c.start=s,c.skip=l,l+=4,i+=4,n.next();continue}let a=n.pos-t;if(t<0||a<r||n.start<h)break;let u=4*(n.id>=o),f=n.start;for(n.next();n.pos>a;){if(n.size<0)if(-3==n.size)u+=4;else break i;else n.id>=o&&(u+=4);n.next()}s=f,i+=t,l+=u}return(e<0||i==t)&&(c.size=i,c.start=s,c.skip=l),c.size>4?c:void 0}(a.pos-n,b))){let t=new Uint16Array(D.size-D.skip),n=a.pos-D.size,r=t.length;for(;a.pos>n;)r=function t(e,n,i){let{id:r,start:s,end:l,size:h}=a;if(a.next(),h>=0&&r<o){let o=i;if(h>4){let r=a.pos-(h-4);for(;a.pos>r;)i=t(e,n,i)}n[--i]=o,n[--i]=l-e,n[--i]=s-e,n[--i]=r}else -3==h?c=r:-4==h&&(u=r);return i}(D.start,t,r);M=new g(t,k-D.start,i),P=D.start-e}else{let e=a.pos-S;a.next();let n=[],s=[],h=w>=o?w:-1,c=0,u=k;for(;a.pos>e;)h>=0&&a.id==h&&a.size>=0?(a.end<=u-r&&(f(n,s,x,c,a.end,u,h,C,A),c=n.length,u=a.end),a.next()):y>2500?function(t,e,n,s){let o=[],l=0,h=-1;for(;a.pos>e;){let{id:t,start:e,end:n,size:i}=a;if(i>4)a.next();else if(h>-1&&e<h)break;else h<0&&(h=n-r),o.push(t,e,n),l++,a.next()}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,n=0;t>=0;t-=3)e[n++]=o[t],e[n++]=o[t+1]-r,e[n++]=o[t+2]-r,e[n++]=n;n.push(new g(e,o[2]-r,i)),s.push(r-t)}}(x,e,n,s):t(x,e,n,s,h,y+1);if(h>=0&&c>0&&c<n.length&&f(n,s,x,c,x,u,h,C,A),n.reverse(),s.reverse(),h>-1&&c>0){let t=function(t,e){return(n,i,r)=>{let s=0,o=n.length-1,a,h;if(o>=0&&(a=n[o])instanceof p){if(!o&&a.type==t&&a.length==r)return a;(h=a.prop(l.lookAhead))&&(s=i[o]+a.length+h)}return d(t,n,i,r,s,e)}}(O,A);M=E(O,n,s,0,n.length,0,k-x,t,t)}else M=d(O,n,s,k-x,C-k,A)}m.push(M),v.push(P)}(t.start||0,t.bufferStart||0,v,b,-1,0);let y=null!=(e=t.length)?e:v.length?b[0]+v[0].length:0;return new p(h[t.topID],v.reverse(),b.reverse(),y)}(t)}}p.empty=new p(c.none,[],[],0);class m{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new m(this.buffer,this.index)}}class g{constructor(t,e,n){this.buffer=t,this.length=e,this.set=n}get type(){return c.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],n=this.buffer[t+3],i=this.set.types[e],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(t+=4))return r;let s=[];for(;t<n;)s.push(this.childString(t)),t=this.buffer[t+3];return r+"("+s.join(",")+")"}findChild(t,e,n,i,r){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&(!v(r,i,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(t,e,n){let i=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){r[l++]=i[o++],r[l++]=i[o++]-n;let e=r[l++]=i[o++]-n;r[l++]=i[o++]-t,s=Math.max(s,e)}return new g(r,s,this.set)}}function v(t,e,n,i){switch(t){case -2:return n<e;case -1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function b(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let e=!r&&t instanceof w&&t.index<0?null:t.parent;if(!e)return t;t=e}let o=r?0:i.IgnoreOverlays;if(r)for(let i=t,r=i.parent;r;r=(i=r).parent)i instanceof w&&i.index<0&&(null==(s=r.enter(e,n,o))?void 0:s.from)!=i.from&&(t=r);for(;;){let i=t.enter(e,n,o);if(!i)return t;t=i}}class y{cursor(t=0){return new M(this,t)}getChild(t,e=null,n=null){let i=x(this,t,e,n);return i.length?i[0]:null}getChildren(t,e=null,n=null){return x(this,t,e,n)}resolve(t,e=0){return b(this,t,e,!1)}resolveInner(t,e=0){return b(this,t,e,!0)}matchContext(t){return k(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),n=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(n=e,e=t.prevSibling):e=t}return n}get node(){return this}get next(){return this.parent}}class w extends y{constructor(t,e,n,i){super(),this._tree=t,this.from=e,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,n,r,s=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,c=e>0?l.length:-1;t!=c;t+=e){let c=l[t],u=h[t]+o.from;if(v(r,n,u,u+c.length)){if(c instanceof g){if(s&i.ExcludeBuffers)continue;let l=c.findChild(0,c.buffer.length,e,n-u,r);if(l>-1)return new C(new S(o,c,t,u),null,l)}else if(s&i.IncludeAnonymous||!c.type.isAnonymous||D(c)){let l;if(!(s&i.IgnoreMounts)&&(l=a.get(c))&&!l.overlay)return new w(l.tree,u,t,o);let h=new w(c,u,t,o);return s&i.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?c.children.length-1:0,e,n,r)}}}if(s&i.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,!(o=o._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,n=0){let r;if(!(n&i.IgnoreOverlays)&&(r=a.get(this._tree))&&r.overlay){let n=t-this.from;for(let{from:t,to:i}of r.overlay)if((e>0?t<=n:t<n)&&(e<0?i>=n:i>n))return new w(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function x(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=n){for(let t=!1;!t;)if(t=r.type.is(n),!r.nextSibling())return s}for(;;){if(null!=i&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==i?s:[]}}function k(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class S{constructor(t,e,n,i){this.parent=t,this.buffer=e,this.index=n,this.start=i}}class C extends y{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,n){super(),this.context=t,this._parent=e,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,e,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.context.start,n);return r<0?null:new C(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,n=0){if(n&i.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new C(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new C(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new C(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let s=n.buffer[this.index+1];t.push(n.slice(i,r,s)),e.push(0)}return new p(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let r=t[i];(r.from>n.from||r.to<n.to)&&(n=r,e=i)}let i=n instanceof w&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new O(r,n)}class O{constructor(t,e){this.heads=t,this.node=e}get next(){return A(this.heads)}}class M{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof w)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:n,buffer:i}=this.buffer;return this.type=e||i.set.types[i.buffer[t]],this.from=n+i.buffer[t+1],this.to=n+i.buffer[t+2],!0}yield(t){return!!t&&(t instanceof w?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,n=this.mode){return this.buffer?!(n&i.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&i.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&i.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,n=this.stack.length-1;if(t<0){let t=n<0?0:this.stack[n]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(t)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,n,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(r.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:n}=r)}else({index:e,_parent:n}=this._tree);for(;n;{index:e,_parent:n}=n)if(e>-1)for(let r=e+t,s=t<0?-1:n._tree.children.length;r!=s;r+=t){let t=n._tree.children[r];if(this.mode&i.IncludeAnonymous||t instanceof g||!t.type.isAnonymous||D(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)i:for(let i=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==i){if(i==this.index)return s;e=s,n=r+1;break i}i=this.stack[--r]}for(let t=n;t<this.stack.length;t++)e=new C(this.buffer,e,this.stack[t]);return this.bufferNode=new C(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&e&&e(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(t){if(!this.buffer)return k(this.node.parent,t);let{buffer:e}=this.buffer,{types:n}=e.set;for(let i=t.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return k(this._tree,t,i);let s=n[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}}function D(t){return t.children.some(t=>t instanceof g||!t.type.isAnonymous||D(t))}let P=new WeakMap;function T(t,e){if(!t.isAnonymous||e instanceof g||e.type!=t)return 1;let n=P.get(e);if(null==n){for(let i of(n=1,e.children)){if(i.type!=t||!(i instanceof p)){n=1;break}n+=T(t,i)}P.set(e,n)}return n}function E(t,e,n,i,r,s,o,l,a){let h=0;for(let n=i;n<r;n++)h+=T(t,e[n]);let c=Math.ceil(1.5*h/8),u=[],f=[];return!function e(n,i,r,o,l){for(let h=r;h<o;){let r=h,d=i[h],p=T(t,n[h]);for(h++;h<o;h++){let e=T(t,n[h]);if(p+e>=c)break;p+=e}if(h==r+1){if(p>c){let t=n[r];e(t.children,t.positions,0,t.children.length,i[r]+l);continue}u.push(n[r])}else{let e=i[h-1]+n[h-1].length-d;u.push(E(t,n,i,r,h,d,e,null,a))}f.push(d+l-s)}}(e,n,i,r,0),(l||a)(u,f,o)}class R{constructor(){this.map=new WeakMap}setBuffer(t,e,n){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(e,n)}getBuffer(t,e){let n=this.map.get(t);return n&&n.get(e)}set(t,e){t instanceof C?this.setBuffer(t.context.buffer,t.index,e):t instanceof w&&this.map.set(t.tree,e)}get(t){return t instanceof C?this.getBuffer(t.context.buffer,t.index):t instanceof w?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class B{constructor(t,e,n,i,r=!1,s=!1){this.from=t,this.to=e,this.tree=n,this.offset=i,this.open=!!r|2*!!s}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],n=!1){let i=[new B(0,t.length,t,0,!1,n)];for(let n of e)n.to>t.length&&i.push(n);return i}static applyChanges(t,e,n=128){if(!e.length)return t;let i=[],r=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let e=s;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,n=Math.min(e.to,c)-a;e=t>=n?null:new B(t,n,e.tree,e.offset+a,o>0,!!h)}if(e&&i.push(e),s.to>c)break;s=r<t.length?t[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return i}}class L{startParse(t,e,n){return"string"==typeof t&&(t=new N(t)),n=n?n.length?n.map(t=>new o(t.from,t.to)):[new o(0,0)]:[new o(0,t.length)],this.createParse(t,e||[],n)}parse(t,e,n){let i=this.startParse(t,e,n);for(;;){let t=i.advance();if(t)return t}}}class N{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new l({perNode:!0})},619:function(t,e,n){n.d(e,{DM:function(){return f},_A:function(){return P},az:function(){return u},pn:function(){return a}});var i=n(80);let r=0;class s{constructor(t,e,n,i){this.name=t,this.set=e,this.base=n,this.modified=i,this.id=r++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){if(t instanceof s&&(e=t),null==e?void 0:e.base)throw Error("Can not derive from a modified tag");let n=new s("string"==typeof t?t:"?",[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new l(t);return t=>t.modified.indexOf(e)>-1?t:l.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let o=0;class l{constructor(t){this.name=t,this.instances=[],this.id=o++}static get(t,e){if(!e.length)return t;let n=e[0].instances.find(n=>{var i,r;return n.base==t&&(i=e,r=n.modified,i.length==r.length&&i.every((t,e)=>t==r[e]))});if(n)return n;let i=[],r=new s(t.name,i,t,e);for(let t of e)t.instances.push(r);let o=function(t){let e=[[]];for(let n=0;n<t.length;n++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[n]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)i.push(l.get(e,t));return r}}function a(t){let e=Object.create(null);for(let n in t){let i=t[n];for(let t of(Array.isArray(i)||(i=[i]),n.split(" ")))if(t){let n=[],r=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!i)throw RangeError("Invalid path: "+t);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),(e+=i[0].length)==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+t);s=t.slice(e)}let o=n.length-1,l=n[o];if(!l)throw RangeError("Invalid path: "+t);let a=new c(i,r,o>0?n.slice(0,o):null);e[l]=a.sort(e[l])}}return h.add(e)}let h=new i.uY;class c{constructor(t,e,n,i){this.tags=t,this.mode=e,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function u(t,e){let n=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)n[t.id]=e.class;else n[e.tag.id]=e.class;let{scope:i,all:r=null}=e||{};return{style:t=>{let e=r;for(let i of t)for(let t of i.set){let i=n[t.id];if(i){e=e?e+" "+i:i;break}}return e},scope:i}}function f(t,e,n,i=0,r=t.length){let s=new d(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}c.empty=new c([],2,null);class d{constructor(t,e,n){this.at=t,this.highlighters=e,this.span=n,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,n,r,s){let{type:o,from:l,to:a}=t;if(l>=n||a<=e)return;o.isTop&&(s=this.highlighters.filter(t=>!t.scope||t.scope(o)));let u=r,f=function(t){let e=t.type.prop(h);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||c.empty,d=function(t,e){let n=null;for(let i of t){let t=i.style(e);t&&(n=n?n+" "+t:t)}return n}(s,f.tags);if(d&&(u&&(u+=" "),u+=d,1==f.mode&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(e,l),u),f.opaque)return;let p=t.tree&&t.tree.prop(i.uY.mounted);if(p&&p.overlay){let i=t.node.enter(p.overlay[0].from+l,1),o=this.highlighters.filter(t=>!t.scope||t.scope(p.tree.type)),h=t.firstChild();for(let c=0,f=l;;c++){let d=c<p.overlay.length?p.overlay[c]:null,m=d?d.from+l:a,g=Math.max(e,f),v=Math.min(n,m);if(g<v&&h)for(;t.from<v&&(this.highlightRange(t,g,v,r,s),this.startSpan(Math.min(v,t.to),u),!(t.to>=m)&&t.nextSibling()););if(!d||m>n)break;(f=d.to+l)>e&&(this.highlightRange(i.cursor(),Math.max(e,d.from+l),Math.min(n,f),"",o),this.startSpan(Math.min(n,f),u))}h&&t.parent()}else if(t.firstChild()){p&&(r="");do{if(t.to<=e)continue;if(t.from>=n)break;this.highlightRange(t,e,n,r,s),this.startSpan(Math.min(n,t.to),u)}while(t.nextSibling());t.parent()}}}let p=s.define,m=p(),g=p(),v=p(g),b=p(g),y=p(),w=p(y),x=p(y),k=p(),S=p(k),C=p(),A=p(),O=p(),M=p(O),D=p(),P={comment:m,lineComment:p(m),blockComment:p(m),docComment:p(m),name:g,variableName:p(g),typeName:v,tagName:p(v),propertyName:b,attributeName:p(b),className:p(g),labelName:p(g),namespace:p(g),macroName:p(g),literal:y,string:w,docString:p(w),character:p(w),attributeValue:p(w),number:x,integer:p(x),float:p(x),bool:p(y),regexp:p(y),escape:p(y),color:p(y),url:p(y),keyword:C,self:p(C),null:p(C),atom:p(C),unit:p(C),modifier:p(C),operatorKeyword:p(C),controlKeyword:p(C),definitionKeyword:p(C),moduleKeyword:p(C),operator:A,derefOperator:p(A),arithmeticOperator:p(A),logicOperator:p(A),bitwiseOperator:p(A),compareOperator:p(A),updateOperator:p(A),definitionOperator:p(A),typeOperator:p(A),controlOperator:p(A),punctuation:O,separator:p(O),bracket:M,angleBracket:p(M),squareBracket:p(M),paren:p(M),brace:p(M),content:k,heading:S,heading1:p(S),heading2:p(S),heading3:p(S),heading4:p(S),heading5:p(S),heading6:p(S),contentSeparator:p(k),list:p(k),quote:p(k),emphasis:p(k),strong:p(k),link:p(k),monospace:p(k),strikethrough:p(k),inserted:p(),deleted:p(),changed:p(),invalid:p(),meta:D,documentMeta:p(D),annotation:p(D),processingInstruction:p(D),definition:s.defineModifier("definition"),constant:s.defineModifier("constant"),function:s.defineModifier("function"),standard:s.defineModifier("standard"),local:s.defineModifier("local"),special:s.defineModifier("special")};for(let t in P){let e=P[t];e instanceof s&&(e.name=t)}u([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}])},690:function(t,e,n){n.d(e,{G:function(){return o}});let i="u"<typeof Symbol?"__ͼ":Symbol.for("ͼ"),r="u"<typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),s="u">typeof globalThis?globalThis:"u">typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:n}=e||{};function i(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(let e in t)!function t(e,r,s,o){let l=[],a=/^@(\w+)\b/.exec(e[0]),h=a&&"keyframes"==a[1];if(a&&null==r)return s.push(e[0]+";");for(let n in r){let o=r[n];if(/&/.test(n))t(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((t,e)=>t.concat(e)),o,s);else if(o&&"object"==typeof o){if(!a)throw RangeError("The value of a property ("+n+") should be a primitive value.");t(i(n),o,l,h)}else null!=o&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+o+";")}(l.length||h)&&s.push((n&&!a&&!o?e.map(n):e).join(", ")+" {"+l.join(" ")+"}")}(i(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=s[i]||1;return s[i]=t+1,"ͼ"+t.toString(36)}static mount(t,e,n){let i=t[r],s=n&&n.nonce;i?s&&i.setNonce(s):i=new a(t,s),i.mount(Array.isArray(e)?e:[e],t)}}let l=new Map;class a{constructor(t,e){let n=t.ownerDocument||t,i=n.defaultView;if(!t.head&&t.adoptedStyleSheets&&i.CSSStyleSheet){let e=l.get(n);if(e)return t[r]=e;this.sheet=new i.CSSStyleSheet,l.set(n,this)}else this.styleTag=n.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[r]=this}mount(t,e){let n=this.sheet,i=0,r=0;for(let e=0;e<t.length;e++){let s=t[e],o=this.modules.indexOf(s);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),n)for(let t=0;t<s.rules.length;t++)n.insertRule(s.rules[t],i++)}else{for(;r<o;)i+=this.modules[r++].rules.length;i+=s.rules.length,r++}}if(n)0>e.adoptedStyleSheets.indexOf(this.sheet)&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let n=e.head||e;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}},581:function(t,e,n){n.r(e),n.d(e,{getIndentUnit:function(){return tc},continuedIndent:function(){return tk},LanguageDescription:function(){return tl},foldState:function(){return tR},languageDataProp:function(){return z},matchBrackets:function(){return eh},sublanguageProp:function(){return H},ParseContext:function(){return Q},TreeIndentContext:function(){return tb},bracketMatchingHandle:function(){return eo},foldAll:function(){return tz},foldService:function(){return tC},indentService:function(){return ta},foldCode:function(){return tF},syntaxParserRunning:function(){return G},indentUnit:function(){return th},ensureSyntaxTree:function(){return K},syntaxTree:function(){return $},syntaxTreeAvailable:function(){return J},toggleFold:function(){return tH},indentOnInput:function(){return tS},defineLanguageFacet:function(){return V},syntaxHighlighting:function(){return t3},unfoldCode:function(){return tj},unfoldAll:function(){return tV},HighlightStyle:function(){return t0},foldGutter:function(){return tX},foldedRanges:function(){return tL},getIndentation:function(){return tf},Language:function(){return W},bracketMatching:function(){return es},foldInside:function(){return tO},LRLanguage:function(){return U},flatIndent:function(){return tx},foldKeymap:function(){return tW},indentRange:function(){return td},unfoldEffect:function(){return tT},IndentContext:function(){return tp},codeFolding:function(){return t$},foldEffect:function(){return tP},foldNodeProp:function(){return tA},indentString:function(){return tu},language:function(){return ts},StreamLanguage:function(){return ep},DocInput:function(){return Z},LanguageSupport:function(){return to},bidiIsolates:function(){return eE},foldable:function(){return tM},StringStream:function(){return eu},defaultHighlightStyle:function(){return t9},forceParsing:function(){return Y},indentNodeProp:function(){return tm},delimitedIndent:function(){return ty},highlightingFor:function(){return t8}});let i=0;class r{constructor(t,e){this.from=t,this.to=e}}class s{constructor(t={}){this.id=i++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=a.match(t)),e=>{let n=t(e);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:t=>t.split(" ")}),s.openedBy=new s({deserialize:t=>t.split(" ")}),s.group=new s({deserialize:t=>t.split(" ")}),s.isolate=new s({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw RangeError("Invalid value for isolate: "+t);return t||"auto"}}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class o{constructor(t,e,n,i=!1){this.tree=t,this.overlay=e,this.parser=n,this.bracketed=i}static get(t){return t&&t.props&&t.props[s.mounted.id]}}let l=Object.create(null);class a{constructor(t,e,n,i=0){this.name=t,this.props=e,this.id=n,this.flags=i}static define(t){let e=t.props&&t.props.length?Object.create(null):l,n=!!t.top|2*!!t.skipped|4*!!t.error|8*(null==t.name),i=new a(t.name||"",e,t.id,n);if(t.props){for(let n of t.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");e[n[0].id]=n[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(s.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let n in t)for(let i of n.split(" "))e[i]=t[n];return t=>{for(let n=t.prop(s.group),i=-1;i<(n?n.length:0);i++){let r=e[i<0?t.name:n[i]];if(r)return r}}}}a.none=new a("",Object.create(null),0,8);class h{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let n of this.types){let i=null;for(let e of t){let t=e(n);if(t){i||(i=Object.assign({},n.props));let e=t[1],r=t[0];r.combine&&r.id in i&&(e=r.combine(i[r.id],e)),i[r.id]=e}}e.push(i?new a(n.name,i,n.id,n.flags):n)}return new h(e)}}let c=new WeakMap,u=new WeakMap;(B=L||(L={}))[B.ExcludeBuffers=1]="ExcludeBuffers",B[B.IncludeAnonymous=2]="IncludeAnonymous",B[B.IgnoreMounts=4]="IgnoreMounts",B[B.IgnoreOverlays=8]="IgnoreOverlays",B[B.EnterBracketed=16]="EnterBracketed";class f{constructor(t,e,n,i,r){if(this.type=t,this.children=e,this.positions=n,this.length=i,this.props=null,r&&r.length)for(let[t,e]of(this.props=Object.create(null),r))this.props["number"==typeof t?t:t.id]=e}toString(){let t=o.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let n=t.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new A(this.topNode,t)}cursorAt(t,e=0,n=0){let i=new A(c.get(this)||this.topNode);return i.moveTo(t,e),c.set(this,i._tree),i}get topNode(){return new b(this,0,0,null)}resolve(t,e=0){let n=g(c.get(this)||this.topNode,t,e,!1);return c.set(this,n),n}resolveInner(t,e=0){let n=g(u.get(this)||this.topNode,t,e,!0);return u.set(this,n),n}resolveStack(t,e=0){return function(t,e,n){let i=t.resolveInner(e,n),r=null;for(let t=i instanceof b?i:i.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(r||(r=[i])).push(s.resolve(e,n)),t=s}else{let s=o.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new b(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[i])).push(g(o,e,n,!1))}}return r?S(r):i}(this,t,e)}iterate(t){let{enter:e,leave:n,from:i=0,to:r=this.length}=t,s=t.mode||0,o=(s&L.IncludeAnonymous)>0;for(let t=this.cursor(s|L.IncludeAnonymous);;){let s=!1;if(t.from<=r&&t.to>=i&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&n&&(o||!t.type.isAnonymous)&&n(t),!t.nextSibling();){if(!t.parent())return;s=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:P(a.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,n)=>new f(this.type,t,e,n,this.propValues),t.makeTree||((t,e,n)=>new f(a.none,t,e,n)))}static build(t){return function(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=1024,reused:o=[],minRepeatType:l=i.types.length}=t,a=Array.isArray(n)?new d(n,n.length):n,h=i.types,c=0,u=0;function m(t,e,n,r,s,o,l,a,h){let c=[],u=[];for(;t.length>r;)c.push(t.pop()),u.push(e.pop()+n-s);t.push(g(i.types[l],c,u,o-s,a-o,h)),e.push(s-n)}function g(t,e,n,i,r,o,l){if(o){let t=[s.contextHash,o];l=l?[t].concat(l):[t]}if(r>25){let t=[s.lookAhead,r];l=l?[t].concat(l):[t]}return new f(t,e,n,i,l)}let v=[],b=[];for(;a.pos>0;)!function t(e,n,d,v,b,y){let{id:w,start:x,end:k,size:S}=a,C=u,A=c;if(S<0){if(a.next(),-1==S){let t=o[w];d.push(t),v.push(x-e);return}if(-3==S){c=w;return}if(-4==S){u=w;return}else throw RangeError(`Unrecognized record size: ${S}`)}let O=h[w],M,D,T=x-e;if(k-x<=r&&(D=function(t,e){let n=a.fork(),i=0,s=0,o=0,h=n.end-r,c={size:0,start:0,skip:0};i:for(let r=n.pos-t;n.pos>r;){let t=n.size;if(n.id==e&&t>=0){c.size=i,c.start=s,c.skip=o,o+=4,i+=4,n.next();continue}let a=n.pos-t;if(t<0||a<r||n.start<h)break;let u=4*(n.id>=l),f=n.start;for(n.next();n.pos>a;){if(n.size<0)if(-3==n.size||-4==n.size)u+=4;else break i;else n.id>=l&&(u+=4);n.next()}s=f,i+=t,o+=u}return(e<0||i==t)&&(c.size=i,c.start=s,c.skip=o),c.size>4?c:void 0}(a.pos-n,b))){let t=new Uint16Array(D.size-D.skip),n=a.pos-D.size,r=t.length;for(;a.pos>n;)r=function t(e,n,i){let{id:r,start:s,end:o,size:h}=a;if(a.next(),h>=0&&r<l){let l=i;if(h>4){let r=a.pos-(h-4);for(;a.pos>r;)i=t(e,n,i)}n[--i]=l,n[--i]=o-e,n[--i]=s-e,n[--i]=r}else -3==h?c=r:-4==h&&(u=r);return i}(D.start,t,r);M=new p(t,k-D.start,i),T=D.start-e}else{let e=a.pos-S;a.next();let n=[],o=[],h=w>=l?w:-1,c=0,u=k;for(;a.pos>e;)h>=0&&a.id==h&&a.size>=0?(a.end<=u-r&&(m(n,o,x,c,a.end,u,h,C,A),c=n.length,u=a.end),a.next()):y>2500?function(t,e,n,s){let o=[],l=0,h=-1;for(;a.pos>e;){let{id:t,start:e,end:n,size:i}=a;if(i>4)a.next();else if(h>-1&&e<h)break;else h<0&&(h=n-r),o.push(t,e,n),l++,a.next()}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,n=0;t>=0;t-=3)e[n++]=o[t],e[n++]=o[t+1]-r,e[n++]=o[t+2]-r,e[n++]=n;n.push(new p(e,o[2]-r,i)),s.push(r-t)}}(x,e,n,o):t(x,e,n,o,h,y+1);if(h>=0&&c>0&&c<n.length&&m(n,o,x,c,x,u,h,C,A),n.reverse(),o.reverse(),h>-1&&c>0){let t=function(t,e){return(n,i,r)=>{let o=0,l=n.length-1,a,h;if(l>=0&&(a=n[l])instanceof f){if(!l&&a.type==t&&a.length==r)return a;(h=a.prop(s.lookAhead))&&(o=i[l]+a.length+h)}return g(t,n,i,r,o,e)}}(O,A);M=P(O,n,o,0,n.length,0,k-x,t,t)}else M=g(O,n,o,k-x,C-k,A)}d.push(M),v.push(T)}(t.start||0,t.bufferStart||0,v,b,-1,0);let y=null!=(e=t.length)?e:v.length?b[0]+v[0].length:0;return new f(h[t.topID],v.reverse(),b.reverse(),y)}(t)}}f.empty=new f(a.none,[],[],0);class d{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new d(this.buffer,this.index)}}class p{constructor(t,e,n){this.buffer=t,this.length=e,this.set=n}get type(){return a.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],n=this.buffer[t+3],i=this.set.types[e],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(t+=4))return r;let s=[];for(;t<n;)s.push(this.childString(t)),t=this.buffer[t+3];return r+"("+s.join(",")+")"}findChild(t,e,n,i,r){let{buffer:s}=this,o=-1;for(let l=t;l!=e&&(!m(r,i,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(t,e,n){let i=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,l=0;o<e;){r[l++]=i[o++],r[l++]=i[o++]-n;let e=r[l++]=i[o++]-n;r[l++]=i[o++]-t,s=Math.max(s,e)}return new p(r,s,this.set)}}function m(t,e,n,i){switch(t){case -2:return n<e;case -1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function g(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let e=!i&&t instanceof b&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=i?0:L.IgnoreOverlays;if(i)for(let i=t,o=i.parent;o;o=(i=o).parent)i instanceof b&&i.index<0&&(null==(r=o.enter(e,n,s))?void 0:r.from)!=i.from&&(t=o);for(;;){let i=t.enter(e,n,s);if(!i)return t;t=i}}class v{cursor(t=0){return new A(this,t)}getChild(t,e=null,n=null){let i=y(this,t,e,n);return i.length?i[0]:null}getChildren(t,e=null,n=null){return y(this,t,e,n)}resolve(t,e=0){return g(this,t,e,!1)}resolveInner(t,e=0){return g(this,t,e,!0)}matchContext(t){return w(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),n=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(n=e,e=t.prevSibling):e=t}return n}get node(){return this}get next(){return this.parent}}class b extends v{constructor(t,e,n,i){super(),this._tree=t,this.from=e,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,n,i,r=0){for(let s=this;;){for(let{children:l,positions:a}=s._tree,h=e>0?l.length:-1;t!=h;t+=e){let h=l[t],c=a[t]+s.from,u;if(r&L.EnterBracketed&&h instanceof f&&(u=o.get(h))&&!u.overlay&&u.bracketed&&n>=c&&n<=c+h.length||m(i,n,c,c+h.length)){if(h instanceof p){if(r&L.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,e,n-c,i);if(o>-1)return new k(new x(s,h,t,c),null,o)}else if(r&L.IncludeAnonymous||!h.type.isAnonymous||O(h)){let l;if(!(r&L.IgnoreMounts)&&(l=o.get(h))&&!l.overlay)return new b(l.tree,c,t,s);let a=new b(h,c,t,s);return r&L.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?h.children.length-1:0,e,n,i,r)}}}if(r&L.IncludeAnonymous||!s.type.isAnonymous||(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,!(s=s._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,n=0){let i;if(!(n&L.IgnoreOverlays)&&(i=o.get(this._tree))&&i.overlay){let r=t-this.from,s=n&L.EnterBracketed&&i.bracketed;for(let{from:t,to:n}of i.overlay)if((e>0||s?t<=r:t<r)&&(e<0||s?n>=r:n>r))return new b(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function y(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=n){for(let t=!1;!t;)if(t=r.type.is(n),!r.nextSibling())return s}for(;;){if(null!=i&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==i?s:[]}}function w(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class x{constructor(t,e,n,i){this.parent=t,this.buffer=e,this.index=n,this.start=i}}class k extends v{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,n){super(),this.context=t,this._parent=e,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,e,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.context.start,n);return r<0?null:new k(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,n=0){if(n&L.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new k(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new k(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new k(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let s=n.buffer[this.index+1];t.push(n.slice(i,r,s)),e.push(0)}return new f(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let r=t[i];(r.from>n.from||r.to<n.to)&&(n=r,e=i)}let i=n instanceof b&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new C(r,n)}class C{constructor(t,e){this.heads=t,this.node=e}get next(){return S(this.heads)}}class A{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~L.EnterBracketed,t instanceof b)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:n,buffer:i}=this.buffer;return this.type=e||i.set.types[i.buffer[t]],this.from=n+i.buffer[t+1],this.to=n+i.buffer[t+2],!0}yield(t){return!!t&&(t instanceof b?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,n=this.mode){return this.buffer?!(n&L.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&L.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&L.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,n=this.stack.length-1;if(t<0){let t=n<0?0:this.stack[n]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(t)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,n,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(i.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:n}=i)}else({index:e,_parent:n}=this._tree);for(;n;{index:e,_parent:n}=n)if(e>-1)for(let i=e+t,r=t<0?-1:n._tree.children.length;i!=r;i+=t){let t=n._tree.children[i];if(this.mode&L.IncludeAnonymous||t instanceof p||!t.type.isAnonymous||O(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)i:for(let i=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==i){if(i==this.index)return s;e=s,n=r+1;break i}i=this.stack[--r]}for(let t=n;t<this.stack.length;t++)e=new k(this.buffer,e,this.stack[t]);return this.bufferNode=new k(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&e&&e(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(t){if(!this.buffer)return w(this.node.parent,t);let{buffer:e}=this.buffer,{types:n}=e.set;for(let i=t.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return w(this._tree,t,i);let s=n[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}}function O(t){return t.children.some(t=>t instanceof p||!t.type.isAnonymous||O(t))}let M=new WeakMap;function D(t,e){if(!t.isAnonymous||e instanceof p||e.type!=t)return 1;let n=M.get(e);if(null==n){for(let i of(n=1,e.children)){if(i.type!=t||!(i instanceof f)){n=1;break}n+=D(t,i)}M.set(e,n)}return n}function P(t,e,n,i,r,s,o,l,a){let h=0;for(let n=i;n<r;n++)h+=D(t,e[n]);let c=Math.ceil(1.5*h/8),u=[],f=[];return!function e(n,i,r,o,l){for(let h=r;h<o;){let r=h,d=i[h],p=D(t,n[h]);for(h++;h<o;h++){let e=D(t,n[h]);if(p+e>=c)break;p+=e}if(h==r+1){if(p>c){let t=n[r];e(t.children,t.positions,0,t.children.length,i[r]+l);continue}u.push(n[r])}else{let e=i[h-1]+n[h-1].length-d;u.push(P(t,n,i,r,h,d,e,null,a))}f.push(d+l-s)}}(e,n,i,r,0),(l||a)(u,f,o)}class T{constructor(t,e,n,i,r=!1,s=!1){this.from=t,this.to=e,this.tree=n,this.offset=i,this.open=!!r|2*!!s}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],n=!1){let i=[new T(0,t.length,t,0,!1,n)];for(let n of e)n.to>t.length&&i.push(n);return i}static applyChanges(t,e,n=128){if(!e.length)return t;let i=[],r=1,s=t.length?t[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let e=s;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,n=Math.min(e.to,c)-a;e=t>=n?null:new T(t,n,e.tree,e.offset+a,o>0,!!h)}if(e&&i.push(e),s.to>c)break;s=r<t.length?t[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return i}}class E{startParse(t,e,n){return"string"==typeof t&&(t=new R(t)),n=n?n.length?n.map(t=>new r(t.from,t.to)):[new r(0,0)]:[new r(0,t.length)],this.createParse(t,e||[],n)}parse(t,e,n){let i=this.startParse(t,e,n);for(;;){let t=i.advance();if(t)return t}}}class R{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new s({perNode:!0});var B,L,N,I=n(492),F=n(867),j=n(619),_=n(690);let z=new s;function V(t){return I.sj.define({combine:t?e=>e.concat(t):void 0})}let H=new s;class W{constructor(t,e,n=[],i=""){this.data=t,this.name=i,I.$t.prototype.hasOwnProperty("tree")||Object.defineProperty(I.$t.prototype,"tree",{get(){return $(this)}}),this.parser=e,this.extension=[ts.of(this),I.$t.languageData.of((t,e,n)=>{let i=q(t,e,n),r=i.type.prop(z);if(!r)return[];let s=t.facet(r),o=i.type.prop(H);if(o){let r=i.resolve(e-i.from,n);for(let e of o)if(e.test(r,t)){let n=t.facet(e.facet);return"replace"==e.type?n:n.concat(s)}}return s})].concat(n)}isActiveAt(t,e,n=-1){return q(t,e,n).type.prop(z)==this.data}findRegions(t){let e=t.facet(ts);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[],i=(t,e)=>{if(t.prop(z)==this.data)return void n.push({from:e,to:e+t.length});let r=t.prop(s.mounted);if(r){if(r.tree.prop(z)==this.data){if(r.overlay)for(let t of r.overlay)n.push({from:t.from+e,to:t.to+e});else n.push({from:e,to:e+t.length});return}else if(r.overlay){let t=n.length;if(i(r.tree,r.overlay[0].from+e),n.length>t)return}}for(let n=0;n<t.children.length;n++){let r=t.children[n];r instanceof f&&i(r,t.positions[n]+e)}};return i($(t),0),n}get allowsNesting(){return!0}}function q(t,e,n){let i=t.facet(ts),r=$(t).topNode;if(!i||i.allowsNesting)for(let t=r;t;t=t.enter(e,n,L.ExcludeBuffers|L.EnterBracketed))t.type.isTop&&(r=t);return r}W.setState=I.Pe.define();class U extends W{constructor(t,e,n){super(t,e,[],n),this.parser=e}static define(t){let e=V(t.languageData);return new U(e,t.parser.configure({props:[z.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new U(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function $(t){let e=t.field(W.state,!1);return e?e.tree:f.empty}function K(t,e,n=50){var i;let r=null==(i=t.field(W.state,!1))?void 0:i.context;if(!r)return null;let s=r.viewport;r.updateViewport({from:0,to:e});let o=r.isDone(e)||r.work(n,e)?r.tree:null;return r.updateViewport(s),o}function J(t,e=t.doc.length){var n;return(null==(n=t.field(W.state,!1))?void 0:n.context.isDone(e))||!1}function Y(t,e=t.viewport.to,n=100){let i=K(t.state,e,n);return i!=$(t.state)&&t.dispatch({}),!!i}function G(t){var e;return(null==(e=t.plugin(tr))?void 0:e.isWorking())||!1}class Z{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let X=null;class Q{constructor(t,e,n=[],i,r,s,o,l){this.parser=t,this.state=e,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,n){return new Q(t,e,[],f.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Z(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=f.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(T.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(T.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=X;X=this;try{return t()}finally{X=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=tt(t,e.from,e.to);return t}changes(t,e){let{fragments:n,tree:i,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,i,r)=>e.push({fromA:t,toA:n,fromB:i,toB:r})),n=T.applyChanges(n,e),i=f.empty,r=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length)for(let e of(o=[],this.skipped)){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);n<i&&o.push({from:n,to:i})}}return new Q(this.parser,e,n,i,r,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:n,to:i}=this.skipped[e];n<t.to&&i>t.from&&(this.fragments=tt(this.fragments,n,i),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends E{createParse(e,n,i){let r=i[0].from,s=i[i.length-1].to;return{parsedPos:r,advance(){let e=X;if(e){for(let t of i)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new f(a.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return X}}function tt(t,e,n){return T.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class te{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,n)||e.takeTree(),new te(e)}static init(t){let e=Math.min(3e3,t.doc.length),n=Q.create(t.facet(ts).parser,t,{from:0,to:e});return n.work(20,e)||n.takeTree(),new te(n)}}W.state=I.sU.define({create:te.init,update(t,e){for(let t of e.effects)if(t.is(W.setState))return t.value;return e.startState.facet(ts)!=e.state.facet(ts)?te.init(e.state):t.apply(e)}});let tn=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"u">typeof requestIdleCallback&&(tn=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});let ti="u">typeof navigator&&(null==(N=navigator.scheduling)?void 0:N.isInputPending)?()=>navigator.scheduling.isInputPending():null,tr=F.Z9.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(W.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(W.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=tn(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(W.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!ti?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work(()=>ti&&ti()||Date.now()>s,i+1e5*!o);this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:W.setState.of(new te(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>(0,F.c_)(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ts=I.sj.define({combine:t=>t.length?t[0]:null,enables:t=>[W.state,tr,F.Lz.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class to{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class tl{constructor(t,e,n,i,r,s){this.name=t,this.alias=e,this.extensions=n,this.filename=i,this.loadFunc=r,this.support=s,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:n}=t;if(!e){if(!n)throw RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(n)}return new tl(t.name,(t.alias||[]).concat(t.name).map(t=>t.toLowerCase()),t.extensions||[],t.filename,e,n)}static matchFilename(t,e){for(let n of t)if(n.filename&&n.filename.test(e))return n;let n=/\.([^.]+)$/.exec(e);if(n){for(let e of t)if(e.extensions.indexOf(n[1])>-1)return e}return null}static matchLanguageName(t,e,n=!0){for(let n of(e=e.toLowerCase(),t))if(n.alias.some(t=>t==e))return n;if(n)for(let n of t)for(let t of n.alias){let i=e.indexOf(t);if(i>-1&&(t.length>2||!/\w/.test(e[i-1])&&!/\w/.test(e[i+t.length])))return n}return null}}let ta=I.sj.define(),th=I.sj.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function tc(t){let e=t.facet(th);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function tu(t,e){let n="",i=t.tabSize,r=t.facet(th)[0];if(" "==r){for(;e>=i;)n+=" ",e-=i;r=" "}for(let t=0;t<e;t++)n+=r;return n}function tf(t,e){for(let n of(t instanceof I.$t&&(t=new tp(t)),t.state.facet(ta))){let i=n(t,e);if(void 0!==i)return i}let n=$(t.state);return n.length>=e?function(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let t=[];for(let e=r;e&&!(e.from<i.node.from||e.to>i.node.to||e.from==i.node.from&&e.type==i.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)i={node:t[e],next:i}}return tg(i,t,n)}(t,n,e):null}function td(t,e,n){let i=Object.create(null),r=new tp(t,{overrideIndentation:t=>{var e;return null!=(e=i[t])?e:-1}}),s=[];for(let o=e;o<=n;){let e=t.doc.lineAt(o);o=e.to+1;let n=tf(r,e.from);if(null==n)continue;/\S/.test(e.text)||(n=0);let l=/^\s*/.exec(e.text)[0],a=tu(t,n);l!=a&&(i[e.from]=n,s.push({from:e.from,to:e.from+l.length,insert:a}))}return t.changes(s)}class tp{constructor(t,e={}){this.state=t,this.options=e,this.unit=tc(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:r}=this.options;if(null!=i&&i>=n.from&&i<=n.to)if(r&&i==t)return{text:"",from:t};else if(e<0?i<t:i<=t)return{text:n.text.slice(i-n.from),from:i};else return{text:n.text.slice(0,i-n.from),from:n.from};return n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(t,e);return n.slice(t-i,Math.min(n.length,t+100-i))}column(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.countColumn(n,t-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(r+=s-this.countColumn(n,n.search(/\S|$/))),r}countColumn(t,e=t.length){return(0,I.y$)(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:i}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(i);if(t>-1)return t}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let tm=new s;function tg(t,e,n){for(let i=t;i;i=i.next){let t=function(t){let e=t.type.prop(tm);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(s.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>tw(t,!0,1,void 0,n&&!(t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak)?e.from:void 0)}return null==t.parent?tv:null}(i.node);if(t)return t(tb.create(e,n,i))}return 0}function tv(){return 0}class tb extends tp{constructor(t,e,n){super(t.state,t.options),this.base=t,this.pos=e,this.context=n}get node(){return this.context.node}static create(t,e,n){return new tb(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(function(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return tg(this.context.next,this.base,this.pos)}}function ty({closing:t,align:e=!0,units:n=1}){return i=>tw(i,e,n,t)}function tw(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,a=e?function(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=n.to;;){let r=e.childAfter(t);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let t=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+t}}t=r.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}let tx=t=>t.baseIndent;function tk({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}function tS(){return I.$t.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:i}=t.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return t;let s=n.sliceString(r.from,i);if(!e.some(t=>t.test(s)))return t;let{state:o}=t,l=-1,a=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==l)continue;l=e.from;let n=tf(o,e.from);if(null==n)continue;let i=/^\s*/.exec(e.text)[0],r=tu(o,n);i!=r&&a.push({from:e.from,to:e.from+i.length,insert:r})}return a.length?[t,{changes:a,sequential:!0}]:t})}let tC=I.sj.define(),tA=new s;function tO(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function tM(t,e,n){for(let i of t.facet(tC)){let r=i(t,e,n);if(r)return r}return function(t,e,n){let i=$(t);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=n||r.from>n)continue;if(s&&r.from<e)break;let l=r.type.prop(tA);if(l&&(r.to<i.length-50||i.length==t.doc.length||!function(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}(r))){let i=l(r,t);i&&i.from<=n&&i.from>=e&&i.to>n&&(s=i)}}return s}(t,e,n)}function tD(t,e){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}let tP=I.Pe.define({map:tD}),tT=I.Pe.define({map:tD});function tE(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(t=>t.from<=n&&t.to>=n)||e.push(t.lineBlockAt(n));return e}let tR=I.sU.define({create:()=>F.NZ.none,update(t,e){for(let n of(e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,n)=>t=tB(t,e,n)),t=t.map(e.changes),e.effects))if(n.is(tP)&&!function(t,e,n){let i=!1;return t.between(e,e,(t,r)=>{t==e&&r==n&&(i=!0)}),i}(t,n.value.from,n.value.to)){let{preparePlaceholder:i}=e.state.facet(tU),r=i?F.NZ.replace({widget:new tY(i(e.state,n.value))}):tJ;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(tT)&&(t=t.update({filter:(t,e)=>n.value.from!=t||n.value.to!=e,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=tB(t,e.selection.main.head)),t},provide:t=>F.Lz.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(t,e)=>{n.push(t,e)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let i=t[n++],r=t[n++];if("number"!=typeof i||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");e.push(tJ.range(i,r))}return F.NZ.set(e,!0)}});function tB(t,e,n=e){let i=!1;return t.between(e,n,(t,r)=>{t<n&&r>e&&(i=!0)}),i?t.update({filterFrom:e,filterTo:n,filter:(t,i)=>t>=n||i<=e}):t}function tL(t){return t.field(tR,!1)||I.om.empty}function tN(t,e,n){var i;let r=null;return null==(i=t.field(tR,!1))||i.between(e,n,(t,e)=>{(!r||r.from>t)&&(r={from:t,to:e})}),r}function tI(t,e){return t.field(tR,!1)?e:e.concat(I.Pe.appendConfig.of(t$()))}let tF=t=>{for(let e of tE(t)){let n=tM(t.state,e.from,e.to);if(n)return t.dispatch({effects:tI(t.state,[tP.of(n),t_(t,n)])}),!0}return!1},tj=t=>{if(!t.state.field(tR,!1))return!1;let e=[];for(let n of tE(t)){let i=tN(t.state,n.from,n.to);i&&e.push(tT.of(i),t_(t,i,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function t_(t,e,n=!0){let i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return F.Lz.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${t.state.phrase("to")} ${r}.`)}let tz=t=>{let{state:e}=t,n=[];for(let i=0;i<e.doc.length;){let r=t.lineBlockAt(i),s=tM(e,r.from,r.to);s&&n.push(tP.of(s)),i=(s?t.lineBlockAt(s.to):r).to+1}return n.length&&t.dispatch({effects:tI(t.state,n)}),!!n.length},tV=t=>{let e=t.state.field(tR,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(t,e)=>{n.push(tT.of({from:t,to:e}))}),t.dispatch({effects:n}),!0},tH=t=>{let e=[];for(let n of tE(t)){let i=tN(t.state,n.from,n.to);if(i)e.push(tT.of(i),t_(t,i,!1));else{let i=function(t,e){for(let n=e;;){let i=tM(t.state,n.from,n.to);if(i&&i.to>e.from)return i;if(!n.from)return null;n=t.lineBlockAt(n.from-1)}}(t,n);i&&e.push(tP.of(i),t_(t,i))}}return e.length>0&&t.dispatch({effects:tI(t.state,e)}),!!e.length},tW=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:tF},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:tj},{key:"Ctrl-Alt-[",run:tz},{key:"Ctrl-Alt-]",run:tV}],tq={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},tU=I.sj.define({combine:t=>(0,I.QR)(t,tq)});function t$(t){let e=[tR,tQ];return t&&e.push(tU.of(t)),e}function tK(t,e){let{state:n}=t,i=n.facet(tU),r=e=>{let n=t.lineBlockAt(t.posAtDOM(e.target)),i=tN(t.state,n.from,n.to);i&&t.dispatch({effects:tT.of(i)}),e.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let tJ=F.NZ.replace({widget:new class extends F.xO{toDOM(t){return tK(t,null)}}});class tY extends F.xO{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return tK(t,this.value)}}let tG={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class tZ extends F.wJ{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function tX(t={}){let e={...tG,...t},n=new tZ(e,!0),i=new tZ(e,!1),r=F.Z9.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(ts)!=t.state.facet(ts)||t.startState.field(tR,!1)!=t.state.field(tR,!1)||$(t.startState)!=$(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new I.vB;for(let r of t.viewportLineBlocks){let s=tN(t.state,r.from,r.to)?i:tM(t.state,r.from,r.to)?n:null;s&&e.add(r.from,r.from,s)}return e.finish()}}),{domEventHandlers:s}=e;return[r,(0,F.cU)({class:"cm-foldGutter",markers(t){var e;return(null==(e=t.plugin(r))?void 0:e.markers)||I.om.empty},initialSpacer:()=>new tZ(e,!1),domEventHandlers:{...s,click:(t,e,n)=>{if(s.click&&s.click(t,e,n))return!0;let i=tN(t.state,e.from,e.to);if(i)return t.dispatch({effects:tT.of(i)}),!0;let r=tM(t.state,e.from,e.to);return!!r&&(t.dispatch({effects:tP.of(r)}),!0)}}}),t$()]}let tQ=F.Lz.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class t0{constructor(t,e){let n;function i(t){let e=_.G.newName();return(n||(n=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?i(e.all):void 0,s=e.scope;this.scope=s instanceof W?t=>t.prop(z)==s.data:s?t=>t==s:void 0,this.style=(0,j.az)(t.map(t=>({tag:t.tag,class:t.class||i(Object.assign({},t,{tag:null}))})),{all:r}).style,this.module=n?new _.G(n):null,this.themeType=e.themeType}static define(t,e){return new t0(t,e||{})}}let t1=I.sj.define(),t2=I.sj.define({combine:t=>t.length?[t[0]]:null});function t4(t){let e=t.facet(t1);return e.length?e:t.facet(t2)}function t3(t,e){let n=[t5],i;return t instanceof t0&&(t.module&&n.push(F.Lz.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(t2.of(t)):i?n.push(t1.computeN([F.Lz.darkTheme],e=>e.facet(F.Lz.darkTheme)==("dark"==i)?[t]:[])):n.push(t1.of(t)),n}function t8(t,e,n){let i=t4(t),r=null;if(i){for(let t of i)if(!t.scope||n&&t.scope(n)){let n=t.style(e);n&&(r=r?r+" "+n:n)}}return r}let t5=I.Nb.high(F.Z9.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=$(t.state),this.decorations=this.buildDeco(t,t4(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=$(t.state),n=t4(t.state),i=n!=t4(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!i&&e.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||i)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return F.NZ.none;let n=new I.vB;for(let{from:i,to:r}of t.visibleRanges)(0,j.DM)(this.tree,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=F.NZ.mark({class:i})))},i,r);return n.finish()}},{decorations:t=>t.decorations})),t9=t0.define([{tag:j._A.meta,color:"#404740"},{tag:j._A.link,textDecoration:"underline"},{tag:j._A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:j._A.emphasis,fontStyle:"italic"},{tag:j._A.strong,fontWeight:"bold"},{tag:j._A.strikethrough,textDecoration:"line-through"},{tag:j._A.keyword,color:"#708"},{tag:[j._A.atom,j._A.bool,j._A.url,j._A.contentSeparator,j._A.labelName],color:"#219"},{tag:[j._A.literal,j._A.inserted],color:"#164"},{tag:[j._A.string,j._A.deleted],color:"#a11"},{tag:[j._A.regexp,j._A.escape,j._A.special(j._A.string)],color:"#e40"},{tag:j._A.definition(j._A.variableName),color:"#00f"},{tag:j._A.local(j._A.variableName),color:"#30a"},{tag:[j._A.typeName,j._A.namespace],color:"#085"},{tag:j._A.className,color:"#167"},{tag:[j._A.special(j._A.variableName),j._A.macroName],color:"#256"},{tag:j._A.definition(j._A.propertyName),color:"#00c"},{tag:j._A.comment,color:"#940"},{tag:j._A.invalid,color:"#f00"}]),t6=F.Lz.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),t7="()[]{}",et=I.sj.define({combine:t=>(0,I.QR)(t,{afterCursor:!0,brackets:t7,maxScanDistance:1e4,renderMatch:ei})}),ee=F.NZ.mark({class:"cm-matchingBracket"}),en=F.NZ.mark({class:"cm-nonmatchingBracket"});function ei(t){let e=[],n=t.matched?ee:en;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}let er=[I.sU.define({create:()=>F.NZ.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],i=e.state.facet(et);for(let t of e.state.selection.ranges){if(!t.empty)continue;let r=eh(e.state,t.head,-1,i)||t.head>0&&eh(e.state,t.head-1,1,i)||i.afterCursor&&(eh(e.state,t.head,1,i)||t.head<e.state.doc.length&&eh(e.state,t.head+1,-1,i));r&&(n=n.concat(i.renderMatch(r,e.state)))}return F.NZ.set(n,!0)},provide:t=>F.Lz.decorations.from(t)}),t6];function es(t={}){return[et.of(t),er]}let eo=new s;function el(t,e,n){let i=t.prop(e<0?s.openedBy:s.closedBy);if(i)return i;if(1==t.name.length){let i=n.indexOf(t.name);if(i>-1&&i%2==+(e<0))return[n[i+e]]}return null}function ea(t){let e=t.type.prop(eo);return e?e(t.node):t}function eh(t,e,n,i={}){let r=i.maxScanDistance||1e4,s=i.brackets||t7,o=$(t),l=o.resolveInner(e,n);for(let t=l;t;t=t.parent){let i=el(t.type,n,s);if(i&&t.from<t.to){let r=ea(t);if(r&&(n>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return function(t,e,n,i,r){let s=e.parent,o={from:n.from,to:n.to},l=0,a=null==s?void 0:s.cursor();if(a&&(t<0?a.childBefore(e.from):a.childAfter(e.to)))do if(t<0?a.to<=e.from:a.from>=e.to){if(0==l&&i.indexOf(a.type.name)>-1&&a.from<a.to){let t=ea(a);return{start:o,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}else if(el(a.type,t,r))l++;else if(el(a.type,-t,r)){if(0==l){let t=ea(a);return{start:o,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}l--}}while(t<0?a.prevSibling():a.nextSibling());return{start:o,matched:!1}}(n,t,r,i,s)}}return function(t,e,n,i,r,s,o){let l=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;n<0&&(t+=s.length);let l=e+t*n;for(let t=n>0?0:s.length-1,e=n>0?s.length:-1;t!=e;t+=n){let e=o.indexOf(s[t]);if(!(e<0)&&i.resolveInner(l+t,1).type==r)if(e%2==0==n>0)u++;else{if(1==u)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};u--}}n>0&&(t+=s.length)}return c.done?{start:h,matched:!1}:null}(t,e,n,o,l.type,r,s)}function ec(t,e,n,i=0,r=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=r;for(let r=i;r<e;r++)9==t.charCodeAt(r)?s+=n-s%n:s++;return s}class eu{constructor(t,e,n,i){this.string=t,this.tabSize=e,this.indentUnit=n,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos);if("string"==typeof t?e==t:e&&(t instanceof RegExp?t.test(e):t(e)))return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ec(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!=(t=this.overrideIndent)?t:ec(this.string,null,this.tabSize)}match(t,e,n){if("string"==typeof t){let i=t=>n?t.toLowerCase():t;return i(this.string.substr(this.pos,t.length))==i(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let n=this.string.slice(this.pos).match(t);return n&&n.index>0?null:(n&&!1!==e&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}}function ef(t){if("object"!=typeof t)return t;let e={};for(let n in t){let i=t[n];e[n]=i instanceof Array?i.slice():i}return e}let ed=new WeakMap;class ep extends W{constructor(t){let e=V(t.languageData),n=function(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||ef,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||eb,mergeTokens:!1!==t.mergeTokens}}(t),i;super(e,new class extends E{createParse(t,e,n){return new eg(i,t,e,n)}},[],t.name),this.topNode=function(t,e){let n=a.define({id:ey.length,name:"Document",props:[z.add(()=>t),tm.add(()=>t=>e.getIndent(t))],top:!0});return ey.push(n),n}(e,this),i=this,this.streamParser=n,this.stateAfter=new s({perNode:!0}),this.tokenTable=t.tokenTable?new eC(n.tokenTable):eA}static define(t){return new ep(t)}getIndent(t){let e,{overrideIndentation:n}=t.options;n&&null!=(e=ed.get(t.state))&&e<t.pos-1e4&&(e=void 0);let i=em(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos),r,s;if(i?(s=i.state,r=i.pos+1):(s=this.streamParser.startState(t.unit),r=t.node.from),t.pos-r>1e4)return null;for(;r<t.pos;){let e=t.state.doc.lineAt(r),i=Math.min(t.pos,e.to);if(e.length){let r=n?n(e.from):-1,o=new eu(e.text,t.state.tabSize,t.unit,r<0?void 0:r);for(;o.pos<i-e.from;)ev(this.streamParser.token,o,s)}else this.streamParser.blankLine(s,t.unit);if(i==t.pos)break;r=e.to+1}let o=t.lineAt(t.pos);return n&&null==e&&ed.set(t.state,o.from),this.streamParser.indent(s,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function em(t,e,n,i,r){let s=n>=i&&n+e.length<=r&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:n+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],l=n+e.positions[s],a=o instanceof f&&l<r&&em(t,o,l,i,r);if(a)return a}return null}class eg{constructor(t,e,n,i){this.lang=t,this.input=e,this.fragments=n,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let r=Q.get(),s=i[0].from,{state:o,tree:l}=function(t,e,n,i,r){for(let r of e){let e=r.from+25*!!r.openStart,s=r.to-25*!!r.openEnd,o=e<=n&&s>n&&em(t,r.tree,0-r.offset,n,s),l;if(o&&o.pos<=i&&(l=function t(e,n,i,r,s){if(s&&i<=0&&r>=n.length)return n;s||0!=i||n.type!=e.topNode||(s=!0);for(let o=n.children.length-1;o>=0;o--){let l=n.positions[o],a=n.children[o],h;if(l<r&&a instanceof f){if(!(h=t(e,a,i-l,r-l,s)))break;return s?new f(n.type,n.children.slice(0,o).concat(h),n.positions.slice(0,o+1),l+h.length):h}}return null}(t,r.tree,n+r.offset,o.pos+r.offset,!1)))return{state:o.state,tree:l}}return{state:t.streamParser.startState(r?tc(r):4),tree:f.empty}}(t,n,s,this.to,null==r?void 0:r.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let t=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);r&&this.parsedPos<r.viewport.from-1e5&&i.some(t=>t.from<=r.viewport.from&&t.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(tc(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let t=Q.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(e,this.chunkStart+512);for(t&&(n=Math.min(n,t.viewport.to));this.parsedPos<n;)this.parseLine(t);return(this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e)?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),n=t+e.length;for(let t=this.rangeIndex;;){let i=this.ranges[t].to;if(i>=n||(e=e.slice(0,i-(n-e.length)),++t==this.ranges.length))break;let r=this.ranges[t].from,s=this.lineAfter(r);e+=s,n=r+s.length}return{line:e,end:n}}skipGapsTo(t,e,n){for(;;){let i=this.ranges[this.rangeIndex].to,r=t+e;if(n>0?i>r:i>=r)break;let s=this.ranges[++this.rangeIndex].from;e+=s-i}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,n,i){let r=4;if(this.ranges.length>1){i=this.skipGapsTo(e,i,1),e+=i;let t=this.chunk.length;i=this.skipGapsTo(n,i,-1),n+=i,r+=this.chunk.length-t}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&4==r&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==e?this.chunk[s+2]=n:this.chunk.push(t,e,n,r),i}parseLine(t){let{line:e,end:n}=this.nextLine(),i=0,{streamParser:r}=this.lang,s=new eu(e,t?t.state.tabSize:4,t?tc(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=ev(r.token,s,this.state);if(t&&(i=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,i)),s.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=f.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ew,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new f(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new f(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function ev(t,e,n){e.start=e.pos;for(let i=0;i<10;i++){let i=t(e,n);if(e.pos>e.start)return i}throw Error("Stream parser failed to advance stream.")}let eb=Object.create(null),ey=[a.none],ew=new h(ey),ex=[],ek=Object.create(null),eS=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])eS[t]=eM(eb,e);class eC{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),eS)}resolve(t){return t?this.table[t]||(this.table[t]=eM(this.extra,t)):0}}let eA=new eC(eb);function eO(t,e){ex.indexOf(t)>-1||(ex.push(t),console.warn(e))}function eM(t,e){let n=[];for(let i of e.split(" ")){let e=[];for(let n of i.split(".")){let i=t[n]||j._A[n];i?"function"==typeof i?e.length?e=e.map(i):eO(n,`Modifier ${n} used at start of tag`):e.length?eO(n,`Tag ${n} used as modifier`):e=Array.isArray(i)?i:[i]:eO(n,`Unknown highlighting tag ${n}`)}for(let t of e)n.push(t)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(t=>t.id),s=ek[r];if(s)return s.id;let o=ek[r]=a.define({id:ey.length,name:i,props:[(0,j.pn)({[i]:n})]});return ey.push(o),o.id}function eD(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function eP(t){for(let e=t.iter();!e.next().done;)if(eD(e.value))return!0;return!1}let eT=I.sj.define({combine:t=>t.some(t=>t)});function eE(t={}){let e=[eR];return t.alwaysIsolate&&e.push(eT.of(!0)),e}let eR=F.Z9.fromClass(class{constructor(t){this.always=t.state.facet(eT)||t.textDirection!=F.OP.LTR||t.state.facet(F.Lz.perLineTextDirection),this.hasRTL=!this.always&&eP(t.state.doc),this.tree=$(t.state),this.decorations=this.always||this.hasRTL?eB(t,this.tree,this.always):F.NZ.none}update(t){var e;let n,i=t.state.facet(eT)||t.view.textDirection!=F.OP.LTR||t.state.facet(F.Lz.perLineTextDirection);if(i||this.hasRTL||(e=t.changes,n=!1,e.iterChanges((t,e,i,r,s)=>{!n&&eP(s)&&(n=!0)}),!n)||(this.hasRTL=!0),!i&&!this.hasRTL)return;let r=$(t.state);(i!=this.always||r!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=r,this.always=i,this.decorations=eB(t.view,r,i))}},{provide:t=>{function e(e){var n,i;return null!=(i=null==(n=e.plugin(t))?void 0:n.decorations)?i:F.NZ.none}return[F.Lz.outerDecorations.of(e),I.Nb.lowest(F.Lz.bidiIsolatedRanges.of(e))]}});function eB(t,e,n){let i=new I.vB,r=t.visibleRanges;for(let{from:o,to:l}of(n||(r=function(t,e){let n=e.iter(),i=0,r=[],s=null;for(let{from:e,to:o}of t)if(!s||!(s.to>e)||!((e=s.to)>=o))for(i+n.value.length<e&&(n.next(e-(i+n.value.length)),i=e);;){let t=i,e=i+n.value.length;if(!n.lineBreak&&eD(n.value)&&(s&&s.to>t-10?s.to=Math.min(o,e):r.push(s={from:t,to:Math.min(o,e)})),e>=o)break;i=e,n.next()}return r}(r,t.state.doc)),r))e.iterate({enter:t=>{let e=t.type.prop(s.isolate);e&&i.add(t.from,t.to,eL[e])},from:o,to:l});return i.finish()}let eL={rtl:F.NZ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:F.OP.RTL}),ltr:F.NZ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:F.OP.LTR}),auto:F.NZ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})}}},c={};function u(t){var e=c[t];if(void 0!==e)return e.exports;var n=c[t]={exports:{}};return h[t](n,n.exports,u),n.exports}u.m=h,u.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return u.d(e,{a:e}),e},u.d=function(t,e){for(var n in e)u.o(e,n)&&!u.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},u.f={},u.e=function(t){return Promise.all(Object.keys(u.f).reduce(function(e,n){return u.f[n](t,e),e},[]))},u.u=function(t){return""+({176:"20b81aeb6a25ed02",214:"ef389a6b6d53d092",299:"ff45080a90ba8316",613:"a0119416ceb52c00",707:"3d31cfcbbe46df81",815:"79f5f1cac434ba94"})[t]+".js"},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),u.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},f={},u.l=function(t,e,n,i){if(f[t])return void f[t].push(e);if(void 0!==n)for(var r,s,o=document.getElementsByTagName("script"),l=0;l<o.length;l++){var a=o[l];if(a.getAttribute("src")==t||a.getAttribute("data-rspack")=="@nocobase/plugin-field-code:"+n){r=a;break}}r||(s=!0,(r=document.createElement("script")).timeout=120,u.nc&&r.setAttribute("nonce",u.nc),r.setAttribute("data-rspack","@nocobase/plugin-field-code:"+n),r.src=t),f[t]=[e];var h=function(e,n){r.onerror=r.onload=null,clearTimeout(c);var i=f[t];if(delete f[t],r.parentNode&&r.parentNode.removeChild(r),i&&i.forEach(function(t){return t(n)}),e)return e(n)},c=setTimeout(h.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=h.bind(null,r.onerror),r.onload=h.bind(null,r.onload),s&&document.head.appendChild(r)},u.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},u.g.importScripts&&(d=u.g.location+"");var f,d,p=u.g.document;if(!d&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(d=p.currentScript.src),!d)){var m=p.getElementsByTagName("script");if(m.length)for(var g=m.length-1;g>-1&&(!d||!/^http(s?):/.test(d));)d=m[g--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");u.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o={889:0},u.f.j=function(t,e){var n=u.o(o,t)?o[t]:void 0;if(0!==n)if(n)e.push(n[2]);else{var i=new Promise(function(e,i){n=o[t]=[e,i]});e.push(n[2]=i);var r=u.p+u.u(t),s=Error();u.l(r,function(e){if(u.o(o,t)&&(0!==(n=o[t])&&(o[t]=void 0),n)){var i=e&&("load"===e.type?"missing":e.type),r=e&&e.target&&e.target.src;s.message="Loading chunk "+t+" failed.\n("+i+": "+r+")",s.name="ChunkLoadError",s.type=i,s.request=r,n[1](s)}},"chunk-"+t,t)}},l=function(t,e){var n,i,r=e[0],s=e[1],l=e[2],a=0;if(r.some(function(t){return 0!==o[t]})){for(n in s)u.o(s,n)&&(u.m[n]=s[n]);l&&l(u)}for(t&&t(e);a<r.length;a++)i=r[a],u.o(o,i)&&o[i]&&o[i][0](),o[i]=0},(a=self.webpackChunk_nocobase_plugin_field_code=self.webpackChunk_nocobase_plugin_field_code||[]).forEach(l.bind(null,0)),a.push=l.bind(null,a.push.bind(a));var v={},b=window.__nocobase_public_path__||"";if(!b&&window.location&&window.location.pathname){var y=window.location.pathname||"/",w=y.indexOf("/v2/");b=w>=0?y.slice(0,w+1):"/"}return b&&(b=b.replace(/\/v2\/?$/,"/")),b||(b="/"),"/"!==b.charAt(b.length-1)&&(b+="/"),u.p=b+"static/plugins/@nocobase/plugin-field-code/dist/client/",!function(){u.r(v),u.d(v,{codeComponentSettings:function(){return K},default:function(){return Y},PluginFieldCodeClient:function(){return J}});var t=u(155),e=u.n(t),n=u(230),i=u(342),r="@nocobase/plugin-field-code",s=u(909);function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(h=function(){return!!t})()}var c=i.interfacesProperties.defaultProps,f=i.interfacesProperties.operators,d=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function e(){var t,n,i,a,u;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");return n=e,i=arguments,n=l(n),o(t=function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,h()?Reflect.construct(n,i||[],l(this).constructor):n.apply(this,i)),"name","code"),o(t,"type","object"),o(t,"group","advanced"),o(t,"order",1),o(t,"title",'{{t("Code", { ns: "'.concat(r,'" })}}')),o(t,"description",'{{t("Programming code editor with syntax highlighting.", { ns: "'.concat(r,'" })}}')),o(t,"sortable",!0),o(t,"default",{type:"text",uiSchema:{type:"string","x-component":"CodeEditor"}}),o(t,"properties",(a=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){o(t,e,n[e])})}return t}({},c),u=u={"uiSchema.x-component-props.language":{type:"string",title:'{{t("Programming language", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!0,allowClear:!0,placeholder:'{{t("Choose language", { ns: "'.concat(r,'" })}}')},enum:s.X.map(function(t){return{label:t.label,value:t.value}}),default:"javascript"}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(u)).forEach(function(t){Object.defineProperty(a,t,Object.getOwnPropertyDescriptor(u,t))}),a)),o(t,"availableTypes",["text","string"]),o(t,"filterable",{operators:f.bigField}),o(t,"titleUsable",!1),t}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t),e}(i.CollectionFieldInterface);function p(t){var e,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i.i18n.t(t,(e=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},s),n=n={ns:r},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e))}var m=u(694),g=u(549),b=u(59);function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,i,r=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var s=[],o=!0,l=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);o=!0);}catch(t){l=!0,i=t}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var x=["auto","100px","200px","300px","400px","500px"],k=[2,4,6,8].map(function(t){return{label:t,value:t}}),S=function(t){return(null==t?void 0:t.trim())||"auto"},C=function(t){var e=Number(t);return Number.isFinite(e)&&e>0?Math.trunc(e):2},A=function(t){return function(e){var n,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.t(e,(n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},s),i=i={ns:r},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))}),n))}},O=function(t){var e=A(t);return x.map(function(t){return{label:"auto"===t?e("Auto"):t,value:t}})},M=function(n){var i=n.defaultValue,r=n.handleChange,s=n.setOpen,o=n.t,l=w((0,t.useState)(i),2),a=l[0],h=l[1];return e().createElement("div",{onClick:function(t){t.stopPropagation(),s(!0)},onMouseLeave:function(){s(!0)}},e().createElement(b.Space.Compact,{block:!0},e().createElement(b.Input,{placeholder:o("e.g. 300px or 50%"),value:a,onChange:function(t){return h(t.target.value)},style:{width:"100%",minWidth:200}}),e().createElement(b.Button,{type:"primary",onClick:function(){return r(S(a))}},"OK")))},D=function(n){var i=n.defaultValue,r=n.handleChange,s=n.setOpen,o=n.t,l=w((0,t.useState)(i),2),a=l[0],h=l[1];return e().createElement("div",{onClick:function(t){t.stopPropagation(),s(!0)},onMouseLeave:function(){s(!0)}},e().createElement(b.Space.Compact,{block:!0},e().createElement(b.InputNumber,{placeholder:o("Custom indent unit"),value:a,min:1,precision:0,onChange:function(t){return h(t)},style:{width:"100%",minWidth:200}}),e().createElement(b.Button,{type:"primary",onClick:function(){return r(C(a))}},"OK")))},P=function(t,n,i,r,s){var o=S(s),l=A(t);return e().createElement(e().Fragment,null,n,e().createElement(b.Divider,{style:{margin:"4px 0"}}),e().createElement(M,{setOpen:i,handleChange:r,t:l,defaultValue:x.includes(o)?null:o}))},T=function(t,n,i,r,s){var o=C(s),l=A(t);return e().createElement(e().Fragment,null,n,e().createElement(b.Divider,{style:{margin:"4px 0"}}),e().createElement(D,{setOpen:i,handleChange:r,t:l,defaultValue:k.some(function(t){return t.value===o})?null:o}))};function E(t){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function R(t,e){return(R=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function B(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(B=function(){return!!t})()}var L=function(t){var n;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function i(){var t,e;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,e=arguments,t=E(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,B()?Reflect.construct(t,e||[],E(this).constructor):t.apply(this,e))}return i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&R(i,t),n=[{key:"render",value:function(){return e().createElement(g.default,this.props)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,n),i}(i.FieldModel);(L=function(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s<3?r(o):s>3?r(e,n,o):r(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}([(0,m.largeField)()],L)).registerFlow({key:"codeFieldSettings",sort:200,title:(0,m.tExpr)("Content settings",{ns:r}),steps:{height:{title:(0,m.tExpr)("Content height",{ns:r}),defaultParams:function(t){var e,n;return{height:(null==(n=t.model)||null==(e=n.props)?void 0:e.height)||"auto"}},uiMode:function(t){var e,n,i=S(null==(n=t.model)||null==(e=n.props)?void 0:e.height);return{type:"select",key:"height",props:{options:O(t),dropdownRender:function(e,n,r){return P(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({height:S(e.height)})}},indentUnit:{title:(0,m.tExpr)("Indent unit",{ns:r}),defaultParams:function(t){var e,n;return{indentUnit:Number((null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit)||2)}},uiMode:function(t){var e,n,i=C(null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit);return{type:"select",key:"indentUnit",props:{options:k,dropdownRender:function(e,n,r){return T(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({indentUnit:C(e.indentUnit)})}}}}),m.EditableItemModel.bindModelToInterface("CodeFieldModel",["code"],{isDefault:!0}),m.FilterableItemModel.bindModelToInterface("InputFieldModel",["code"],{isDefault:!0});function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function I(t,e){return(I=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function F(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(F=function(){return!!t})()}var j=function(t){var n;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function i(){var t,e;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,e=arguments,t=N(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,F()?Reflect.construct(t,e||[],N(this).constructor):t.apply(this,e))}return i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&I(i,t),n=[{key:"render",value:function(){var t,n;return e().createElement(g.default,(t=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(e){var i;i=n[e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i})}return t}({},this.props),n=n={disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,n),i}(i.FieldModel);function _(t,e,n,i,r,s,o){try{var l=t[s](o),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(i,r)}function z(t,e,n){return(z=U()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&W(r,n.prototype),r}).apply(null,arguments)}(j=function(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s<3?r(o):s>3?r(e,n,o):r(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}([(0,m.largeField)()],j)).registerFlow({key:"displayCodeFieldSettings",sort:200,title:(0,m.tExpr)("Content settings",{ns:r}),steps:{height:{title:(0,m.tExpr)("Content height",{ns:r}),defaultParams:function(t){var e,n;return{height:(null==(n=t.model)||null==(e=n.props)?void 0:e.height)||"auto"}},uiMode:function(t){var e,n,i=S(null==(n=t.model)||null==(e=n.props)?void 0:e.height);return{type:"select",key:"height",props:{options:O(t),dropdownRender:function(e,n,r){return P(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({height:S(e.height)})}},indentUnit:{title:(0,m.tExpr)("Indent unit",{ns:r}),defaultParams:function(t){var e,n;return{indentUnit:Number((null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit)||2)}},uiMode:function(t){var e,n,i=C(null==(n=t.model)||null==(e=n.props)?void 0:e.indentUnit);return{type:"select",key:"indentUnit",props:{options:k,dropdownRender:function(e,n,r){return T(t,e,n,r,i)}}}},handler:function(t,e){t.model.setProps({indentUnit:C(e.indentUnit)})}}}}),m.DisplayItemModel.bindModelToInterface("DisplayCodeFieldModel",["code"],{isDefault:!0});function V(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H(t){return(H=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function W(t,e){return(W=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function q(t){var e="function"==typeof Map?new Map:void 0;return(q=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return z(t,arguments,H(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),W(n,t)})(t)}function U(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(U=function(){return!!t})()}var $=(0,t.lazy)(function(){return Promise.resolve().then(u.bind(u,549))}),K=new i.SchemaSettings({name:"fieldSettings:component:CodeEditor",items:[{name:"height",type:"modal",useComponentProps:function(){var t,e=(0,n.useField)(),s=(0,n.useFieldSchema)(),o=((0,i.useColumnSchema)()||{}).fieldSchema,l=(0,i.useDesignable)().dn,a=o||s;return{title:p("Content height"),schema:{type:"object",title:p("Content height"),properties:{height:{"x-decorator":"FormItem","x-component":"Input","x-component-props":{},default:(null==s||null==(t=s["x-component-props"])?void 0:t.height)||"auto",description:'{{t(\'Could use CSS values (e.g., "300px" or "50%"). Use "auto" for automatic height adjustment based on content.\', { ns: "'.concat(r,'" })}}')}}},onSubmit:function(t){var n=t.height,i=a["x-component-props"]||{};i.height=n;var r=V({},"x-uid",a["x-uid"]);r["x-component-props"]=i,a["x-component-props"]=i,e.componentProps.height=n,l.emit("patch",{schema:r}),l.refresh()}}}},{name:"indentUnit",type:"modal",useComponentProps:function(){var t,e=(0,n.useField)(),r=(0,n.useFieldSchema)(),s=((0,i.useColumnSchema)()||{}).fieldSchema,o=(0,i.useDesignable)().dn,l=s||r;return{title:p("Indent unit"),schema:{type:"object",title:p("Indent unit"),properties:{indentUnit:{"x-decorator":"FormItem","x-component":"Input","x-component-props":{},default:(null==r||null==(t=r["x-component-props"])?void 0:t.indentUnit)||2}}},onSubmit:function(t){var n=t.indentUnit,i=l["x-component-props"]||{};i.indentUnit=n;var r=V({},"x-uid",l["x-uid"]);r["x-component-props"]=i,l["x-component-props"]=i,e.componentProps.indentUnit=n,o.emit("patch",{schema:r}),o.refresh()}}}}]}),J=function(t){var e;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,e;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,e=arguments,t=H(t),function(t,e){var n;if(e&&("object"==((n=e)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,U()?Reflect.construct(t,e||[],H(this).constructor):t.apply(this,e))}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&W(n,t),e=[{key:"load",value:function(){var t;return(t=function(){return function(t,e){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(o,"next",{value:a(0)}),l(o,"throw",{value:a(1)}),l(o,"return",{value:a(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function a(l){return function(a){var h=[l,a];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&h[0]?i.return:h[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,h[1])).done)return r;switch(i=0,r&&(h=[2&h[0],r.value]),h[0]){case 0:case 1:r=h;break;case 4:return s.label++,{value:h[1],done:!1};case 5:s.label++,i=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===h[0]||2===h[0])){s=0;continue}if(3===h[0]&&(!r||h[1]>r[0]&&h[1]<r[3])){s.label=h[1];break}if(6===h[0]&&s.label<r[1]){s.label=r[1],r=h;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(h);break}r[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(t){h=[6,t],i=0}finally{n=r=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}}(this,function(t){return this.app.addComponents({CodeEditor:$}),this.app.dataSourceManager.addFieldInterfaces([d]),this.app.schemaSettingsManager.add(K),this.flowEngine.registerModels({CodeFieldModel:L,DisplayCodeFieldModel:j}),[2]})},function(){var e=this,n=arguments;return new Promise(function(i,r){var s=t.apply(e,n);function o(t){_(s,i,r,o,l,"next",t)}function l(t){_(s,i,r,o,l,"throw",t)}o(void 0)})}).call(this)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(n.prototype,e),n}(q(i.Plugin)),Y=J}(),v}()});