@notmrabhi/flowforge 0.1.20 → 0.1.21

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.
Files changed (53) hide show
  1. package/package.json +1 -1
  2. package/dist/GatewayBranchEdge-BdUVHQJc.js +0 -1263
  3. package/dist/GatewayBranchEdge-DK6kuCK2.js +0 -1
  4. package/dist/SchemaBuilderDrawer-157p-2Vj.js +0 -1136
  5. package/dist/SchemaBuilderDrawer-Wje7pVrn.js +0 -1
  6. package/dist/bpmn-CcuE2X_Q.js +0 -2
  7. package/dist/bpmn-CtfWDaOY.js +0 -33
  8. package/dist/canvas.cjs +0 -1
  9. package/dist/canvas.d.ts +0 -809
  10. package/dist/canvas.js +0 -28
  11. package/dist/canvasTokens-CAD6G24b.js +0 -32
  12. package/dist/canvasTokens-gKNYrPl4.js +0 -1
  13. package/dist/core.cjs +0 -1
  14. package/dist/core.d.ts +0 -374
  15. package/dist/core.js +0 -24
  16. package/dist/defaultUi.cjs +0 -1
  17. package/dist/defaultUi.d.ts +0 -83
  18. package/dist/defaultUi.js +0 -18
  19. package/dist/form.cjs +0 -1
  20. package/dist/form.d.ts +0 -857
  21. package/dist/form.js +0 -44
  22. package/dist/index-B31-Y5uO.js +0 -11
  23. package/dist/index-B3aHpb84.js +0 -13
  24. package/dist/index-BU09HbVh.js +0 -10176
  25. package/dist/index-BnzttJ4w.js +0 -13758
  26. package/dist/index-BysKSEtZ.js +0 -1
  27. package/dist/index-CQ0cVcHp.js +0 -2
  28. package/dist/index-CkjEllpd.js +0 -1
  29. package/dist/index-Codx5QwP.js +0 -41
  30. package/dist/index-Cw9DC-tf.js +0 -76
  31. package/dist/index-CzPi8KQC.js +0 -1310
  32. package/dist/index-D14V8rKX.js +0 -1
  33. package/dist/index-Da5NHCS2.js +0 -8132
  34. package/dist/index-a1IOaYsW.js +0 -9
  35. package/dist/index-a3QMaedZ.js +0 -2553
  36. package/dist/index-gtgq_241.js +0 -3
  37. package/dist/index-l6kvDx-m.js +0 -1360
  38. package/dist/index-lcviy90e.js +0 -613
  39. package/dist/index-wOnYb3DO.js +0 -567
  40. package/dist/index.cjs +0 -1
  41. package/dist/index.d.ts +0 -1409
  42. package/dist/index.js +0 -107
  43. package/dist/messages-CO299wPN.js +0 -22
  44. package/dist/messages-O9Tw_XXR.js +0 -1
  45. package/dist/nodeRegistry.cjs +0 -1
  46. package/dist/nodeRegistry.d.ts +0 -334
  47. package/dist/nodeRegistry.js +0 -555
  48. package/dist/style.css +0 -6
  49. package/dist/templateRegistry.cjs +0 -1
  50. package/dist/templateRegistry.d.ts +0 -83
  51. package/dist/templateRegistry.js +0 -43
  52. package/dist/templateSkeletons--Ol7Sg7H.js +0 -1
  53. package/dist/templateSkeletons-DcvDac7_.js +0 -2954
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-D14V8rKX.js"),O=require("./index-B31-Y5uO.js"),s=O.styleTags({String:O.tags.string,Number:O.tags.number,"True False":O.tags.bool,PropertyName:O.tags.propertyName,Null:O.tags.null,", :":O.tags.separator,"[ ]":O.tags.squareBracket,"{ }":O.tags.brace}),o=a.LRParser.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[s],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),P=()=>r=>{try{JSON.parse(r.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=i(e,r.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function i(r,e){let t;return(t=r.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=r.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const n=O.LRLanguage.define({name:"json",parser:o.configure({props:[O.indentNodeProp.add({Object:O.continuedIndent({except:/^\s*\}/}),Array:O.continuedIndent({except:/^\s*\]/})}),O.foldNodeProp.add({"Object Array":O.foldInside})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Q(){return new O.LanguageSupport(n)}exports.json=Q;exports.jsonLanguage=n;exports.jsonParseLinter=P;
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const je=require("./index-a1IOaYsW.js"),b=require("react"),l=require("./index-B31-Y5uO.js"),ce=require("./index-CkjEllpd.js"),Sn=require("react/jsx-runtime"),kn=t=>{let{state:e}=t,r=e.doc.lineAt(e.selection.main.from),n=Ue(t.state,r.from);return n.line?xn(t):n.block?bn(t):!1};function He(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let i=t(e,r);return i?(n(r.update(i)),!0):!1}}const xn=He(Mn,0),Cn=He(yt,0),bn=He((t,e)=>yt(t,e,En(e)),0);function Ue(t,e){let r=t.languageDataAt("commentTokens",e,1);return r.length?r[0]:{}}const te=50;function vn(t,{open:e,close:r},n,i){let o=t.sliceDoc(n-te,n),s=t.sliceDoc(i,i+te),a=/\s*$/.exec(o)[0].length,c=/^\s*/.exec(s)[0].length,h=o.length-a;if(o.slice(h-e.length,h)==e&&s.slice(c,c+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:i+c,margin:c&&1}};let u,f;i-n<=2*te?u=f=t.sliceDoc(n,i):(u=t.sliceDoc(n,n+te),f=t.sliceDoc(i-te,i));let d=/^\s*/.exec(u)[0].length,m=/\s*$/.exec(f)[0].length,g=f.length-m-r.length;return u.slice(d,d+e.length)==e&&f.slice(g,g+r.length)==r?{open:{pos:n+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:i-m-r.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function En(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),i=r.to<=n.to?n:t.doc.lineAt(r.to);i.from>n.from&&i.from==r.to&&(i=r.to==n.to+1?n:t.doc.lineAt(r.to-1));let o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=i.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:i.to})}return e}function yt(t,e,r=e.selection.ranges){let n=r.map(o=>Ue(e,o.from).block);if(!n.every(o=>o))return null;let i=r.map((o,s)=>vn(e,n[s],o.from,o.to));if(t!=2&&!i.every(o=>o))return{changes:e.changes(r.map((o,s)=>i[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let c=n[s],{open:h,close:u}=a;o.push({from:h.pos-c.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+c.close.length})}return{changes:o}}return null}function Mn(t,e,r=e.selection.ranges){let n=[],i=-1;e:for(let{from:o,to:s}of r){let a=n.length,c=1e9,h;for(let u=o;u<=s;){let f=e.doc.lineAt(u);if(h==null&&(h=Ue(e,f.from).line,!h))continue e;if(f.from>i&&(o==s||s>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,m=d==f.length,g=f.text.slice(d,d+h.length)==h?d:-1;d<f.text.length&&d<c&&(c=d),n.push({line:f,comment:g,token:h,indent:d,empty:m,single:!1})}u=f.to+1}if(c<1e9)for(let u=a;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=c);n.length==a+1&&(n[a].single=!0)}if(t!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:c,indent:h,empty:u,single:f}of n)(f||!u)&&o.push({from:a.from+h,insert:c+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:c}of n)if(a>=0){let h=s.from+a,u=h+c.length;s.text[u-s.from]==" "&&u++,o.push({from:h,to:u})}return{changes:o}}return null}const Pe=l.Annotation.define(),An=l.Annotation.define(),Dn=l.Facet.define(),St=l.Facet.define({combine(t){return l.combineConfig(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,r)=>(n,i)=>e(n,i)||r(n,i)})}}),kt=l.StateField.define({create(){return R.empty},update(t,e){let r=e.state.facet(St),n=e.annotation(Pe);if(n){let c=v.fromTransaction(e,n.selection),h=n.side,u=h==0?t.undone:t.done;return c?u=ge(u,u.length,r.minDepth,c):u=bt(u,e.startState.selection),new R(h==0?n.rest:u,h==0?u:n.rest)}let i=e.annotation(An);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(l.Transaction.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=v.fromTransaction(e),s=e.annotation(l.Transaction.time),a=e.annotation(l.Transaction.userEvent);return o?t=t.addChanges(o,s,a,r,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,r.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new R(t.done.map(v.fromJSON),t.undone.map(v.fromJSON))}});function Bn(t={}){return[kt,St.of(t),l.EditorView.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?xt:e.inputType=="historyRedo"?Ie:null;return n?(e.preventDefault(),n(r)):!1}})]}function Ce(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let i=r.field(kt,!1);if(!i)return!1;let o=i.pop(t,r,e);return o?(n(o),!0):!1}}const xt=Ce(0,!1),Ie=Ce(1,!1),Ln=Ce(0,!0),wn=Ce(1,!0);class v{constructor(e,r,n,i,o){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new v(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new v(e.changes&&l.ChangeSet.fromJSON(e.changes),[],e.mapped&&l.ChangeDesc.fromJSON(e.mapped),e.startSelection&&l.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(l.EditorSelection.fromJSON))}static fromTransaction(e,r){let n=D;for(let i of e.startState.facet(Dn)){let o=i(e);o.length&&(n=n.concat(o))}return!n.length&&e.changes.empty?null:new v(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,D)}static selection(e){return new v(void 0,D,void 0,void 0,e)}}function ge(t,e,r,n){let i=e+1>r+20?e-r-1:0,o=t.slice(i,e);return o.push(n),o}function Tn(t,e){let r=[],n=!1;return t.iterChangedRanges((i,o)=>r.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let c=0;c<r.length;){let h=r[c++],u=r[c++];a>=h&&s<=u&&(n=!0)}}),n}function Rn(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function Ct(t,e){return t.length?e.length?t.concat(e):t:e}const D=[],Pn=200;function bt(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-Pn));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),ge(t,t.length-1,1e9,r.setSelAfter(n)))}else return[v.selection([e])]}function In(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function Be(t,e){if(!t.length)return t;let r=t.length,n=D;for(;r;){let i=On(t[r-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let o=t.slice(0,r);return o[r-1]=i,o}else e=i.mapped,r--,n=i.selectionsAfter}return n.length?[v.selection(n)]:D}function On(t,e,r){let n=Ct(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):D,r);if(!t.changes)return v.selection(n);let i=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new v(i,l.StateEffect.mapEffects(t.effects,e),s,t.startSelection.map(o),n)}const Wn=/^(input\.type|delete)($|\.)/;class R{constructor(e,r,n=0,i=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new R(this.done,this.undone):this}addChanges(e,r,n,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||Wn.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,Tn(a.changes,e.changes))||n=="input.type.compose")?s=ge(s,s.length-1,i.minDepth,new v(e.changes.compose(a.changes),Ct(l.StateEffect.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,D)):s=ge(s,s.length,i.minDepth,e),new R(s,D,r,n)}addSelection(e,r,n,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:D;return o.length>0&&r-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Rn(o[o.length-1],e)?this:new R(bt(this.done,e),this.undone,r,n)}addMapping(e){return new R(Be(this.done,e),Be(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,r,n){let i=e==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:Pe.of({side:e,rest:In(i),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?D:i.slice(0,i.length-1);return o.mapped&&(a=Be(a,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:Pe.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}R.empty=new R(D,D);const Vn=[{key:"Mod-z",run:xt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ie,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ie,preventDefault:!0},{key:"Mod-u",run:Ln,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wn,preventDefault:!0}];function Y(t,e){return l.EditorSelection.create(t.ranges.map(e),t.mainIndex)}function L(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function w({state:t,dispatch:e},r){let n=Y(t.selection,r);return n.eq(t.selection,!0)?!1:(e(L(t,n)),!0)}function be(t,e){return l.EditorSelection.cursor(e?t.to:t.from)}function vt(t,e){return w(t,r=>r.empty?t.moveByChar(r,e):be(r,e))}function x(t){return t.textDirectionAt(t.state.selection.main.head)==l.Direction.LTR}const Et=t=>vt(t,!x(t)),Mt=t=>vt(t,x(t));function At(t,e){return w(t,r=>r.empty?t.moveByGroup(r,e):be(r,e))}const Fn=t=>At(t,!x(t)),Nn=t=>At(t,x(t));function qn(t,e,r){if(e.type.prop(r))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function ve(t,e,r){let n=l.syntaxTree(t).resolveInner(e.head),i=r?l.NodeProp.closedBy:l.NodeProp.openedBy;for(let c=e.head;;){let h=r?n.childAfter(c):n.childBefore(c);if(!h)break;qn(t,h,i)?n=h:c=r?h.to:h.from}let o=n.type.prop(i),s,a;return o&&(s=r?l.matchBrackets(t,n.from,1):l.matchBrackets(t,n.to,-1))&&s.matched?a=r?s.end.to:s.end.from:a=r?n.to:n.from,l.EditorSelection.cursor(a,r?-1:1)}const Hn=t=>w(t,e=>ve(t.state,e,!x(t))),Un=t=>w(t,e=>ve(t.state,e,x(t)));function Dt(t,e){return w(t,r=>{if(!r.empty)return be(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}const Bt=t=>Dt(t,!1),Lt=t=>Dt(t,!0);function wt(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,r=0,n=0,i;if(e){for(let o of t.state.facet(l.EditorView.scrollMargins)){let s=o(t);s!=null&&s.top&&(r=Math.max(s==null?void 0:s.top,r)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}i=t.scrollDOM.clientHeight-r-n}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function Tt(t,e){let r=wt(t),{state:n}=t,i=Y(n.selection,s=>s.empty?t.moveVertically(s,e,r.height):be(s,e));if(i.eq(n.selection))return!1;let o;if(r.selfScroll){let s=t.coordsAtPos(n.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),c=a.top+r.marginTop,h=a.bottom-r.marginBottom;s&&s.top>c&&s.bottom<h&&(o=l.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-c}))}return t.dispatch(L(n,i),{effects:o}),!0}const Qe=t=>Tt(t,!1),Oe=t=>Tt(t,!0);function V(t,e,r){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,r);if(i.head==e.head&&i.head!=(r?n.to:n.from)&&(i=t.moveToLineBoundary(e,r,!1)),!r&&i.head==n.from&&n.length){let o=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&e.head!=n.from+o&&(i=l.EditorSelection.cursor(n.from+o))}return i}const zn=t=>w(t,e=>V(t,e,!0)),Gn=t=>w(t,e=>V(t,e,!1)),Kn=t=>w(t,e=>V(t,e,!x(t))),$n=t=>w(t,e=>V(t,e,x(t))),Jn=t=>w(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).from,1)),_n=t=>w(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).to,-1));function jn(t,e,r){let n=!1,i=Y(t.selection,o=>{let s=l.matchBrackets(t,o.head,-1)||l.matchBrackets(t,o.head,1)||o.head>0&&l.matchBrackets(t,o.head-1,1)||o.head<t.doc.length&&l.matchBrackets(t,o.head+1,-1);if(!s||!s.end)return o;n=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return l.EditorSelection.cursor(a)});return n?(e(L(t,i)),!0):!1}const Qn=({state:t,dispatch:e})=>jn(t,e);function B(t,e){let r=Y(t.state.selection,n=>{let i=e(n);return l.EditorSelection.range(n.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(L(t.state,r)),!0)}function Rt(t,e){return B(t,r=>t.moveByChar(r,e))}const Pt=t=>Rt(t,!x(t)),It=t=>Rt(t,x(t));function Ot(t,e){return B(t,r=>t.moveByGroup(r,e))}const Yn=t=>Ot(t,!x(t)),Zn=t=>Ot(t,x(t)),Xn=t=>B(t,e=>ve(t.state,e,!x(t))),er=t=>B(t,e=>ve(t.state,e,x(t)));function Wt(t,e){return B(t,r=>t.moveVertically(r,e))}const Vt=t=>Wt(t,!1),Ft=t=>Wt(t,!0);function Nt(t,e){return B(t,r=>t.moveVertically(r,e,wt(t).height))}const Ye=t=>Nt(t,!1),Ze=t=>Nt(t,!0),tr=t=>B(t,e=>V(t,e,!0)),nr=t=>B(t,e=>V(t,e,!1)),rr=t=>B(t,e=>V(t,e,!x(t))),ir=t=>B(t,e=>V(t,e,x(t))),or=t=>B(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).from)),lr=t=>B(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).to)),Xe=({state:t,dispatch:e})=>(e(L(t,{anchor:0})),!0),et=({state:t,dispatch:e})=>(e(L(t,{anchor:t.doc.length})),!0),tt=({state:t,dispatch:e})=>(e(L(t,{anchor:t.selection.main.anchor,head:0})),!0),nt=({state:t,dispatch:e})=>(e(L(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),sr=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ar=({state:t,dispatch:e})=>{let r=Ee(t).map(({from:n,to:i})=>l.EditorSelection.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:l.EditorSelection.create(r),userEvent:"select"})),!0},cr=({state:t,dispatch:e})=>{let r=Y(t.selection,n=>{let i=l.syntaxTree(t),o=i.resolveStack(n.from,1);if(n.empty){let s=i.resolveStack(n.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&s.next)return l.EditorSelection.range(a.to,a.from)}return n});return r.eq(t.selection)?!1:(e(L(t,r)),!0)};function qt(t,e){let{state:r}=t,n=r.selection,i=r.selection.ranges.slice();for(let o of r.selection.ranges){let s=r.doc.lineAt(o.head);if(e?s.to<t.state.doc.length:s.from>0)for(let a=o;;){let c=t.moveVertically(a,e);if(c.head<s.from||c.head>s.to){i.some(h=>h.head==c.head)||i.push(c);break}else{if(c.head==a.head)break;a=c}}}return i.length==n.ranges.length?!1:(t.dispatch(L(r,l.EditorSelection.create(i,i.length-1))),!0)}const hr=t=>qt(t,!1),ur=t=>qt(t,!0),fr=({state:t,dispatch:e})=>{let r=t.selection,n=null;return r.ranges.length>1?n=l.EditorSelection.create([r.main]):r.main.empty||(n=l.EditorSelection.create([l.EditorSelection.cursor(r.main.head)])),n?(e(L(t,n)),!0):!1};function oe(t,e){if(t.state.readOnly)return!1;let r="delete.selection",{state:n}=t,i=n.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let c=e(o);c<s?(r="delete.backward",c=he(t,c,!1)):c>s&&(r="delete.forward",c=he(t,c,!0)),s=Math.min(s,c),a=Math.max(a,c)}else s=he(t,s,!1),a=he(t,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:l.EditorSelection.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(n.update(i,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?l.EditorView.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function he(t,e,r){if(t instanceof l.EditorView)for(let n of t.state.facet(l.EditorView.atomicRanges).map(i=>i(t)))n.between(e,e,(i,o)=>{i<e&&o>e&&(e=r?o:i)});return e}const Ht=(t,e,r)=>oe(t,n=>{let i=n.from,{state:o}=t,s=o.doc.lineAt(i),a,c;if(r&&!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,i-s.from))){if(a[a.length-1]==" ")return i-1;let h=l.countColumn(a,o.tabSize),u=h%l.getIndentUnit(o)||l.getIndentUnit(o);for(let f=0;f<u&&a[a.length-1-f]==" ";f++)i--;c=i}else c=l.findClusterBreak(s.text,i-s.from,e,e)+s.from,c==i&&s.number!=(e?o.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(c-s.from,i-s.from))&&(c=l.findClusterBreak(s.text,c-s.from,!1,!1)+s.from);return c}),We=t=>Ht(t,!1,!0),Ut=t=>Ht(t,!0,!1),zt=(t,e)=>oe(t,r=>{let n=r.head,{state:i}=t,o=i.doc.lineAt(n),s=i.charCategorizer(n);for(let a=null;;){if(n==(e?o.to:o.from)){n==r.head&&o.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let c=l.findClusterBreak(o.text,n-o.from,e)+o.from,h=o.text.slice(Math.min(n,c)-o.from,Math.max(n,c)-o.from),u=s(h);if(a!=null&&u!=a)break;(h!=" "||n!=r.head)&&(a=u),n=c}return n}),Gt=t=>zt(t,!1),dr=t=>zt(t,!0),mr=t=>oe(t,e=>{let r=t.lineBlockAt(e.head).to;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),gr=t=>oe(t,e=>{let r=t.moveToLineBoundary(e,!1).head;return e.head>r?r:Math.max(0,e.head-1)}),pr=t=>oe(t,e=>{let r=t.moveToLineBoundary(e,!0).head;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),yr=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:l.Text.of(["",""])},range:l.EditorSelection.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Sr=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let i=n.from,o=t.doc.lineAt(i),s=i==o.from?i-1:l.findClusterBreak(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:l.findClusterBreak(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(s,i))},range:l.EditorSelection.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ee(t){let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=t.doc.lineAt(n.to-1)),r>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(n)}else e.push({from:i.from,to:o.to,ranges:[n]});r=o.number+1}return e}function Kt(t,e,r){if(t.readOnly)return!1;let n=[],i=[];for(let o of Ee(t)){if(r?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(r?o.to+1:o.from-1),a=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let c of o.ranges)i.push(l.EditorSelection.range(Math.min(t.doc.length,c.anchor+a),Math.min(t.doc.length,c.head+a)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let c of o.ranges)i.push(l.EditorSelection.range(c.anchor-a,c.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:l.EditorSelection.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const kr=({state:t,dispatch:e})=>Kt(t,e,!1),xr=({state:t,dispatch:e})=>Kt(t,e,!0);function $t(t,e,r){if(t.readOnly)return!1;let n=[];for(let o of Ee(t))r?n.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):n.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let i=t.changes(n);return e(t.update({changes:i,selection:t.selection.map(i,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Cr=({state:t,dispatch:e})=>$t(t,e,!1),br=({state:t,dispatch:e})=>$t(t,e,!0),vr=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(Ee(e).map(({from:i,to:o})=>(i>0?i--:o<e.doc.length&&o++,{from:i,to:o}))),n=Y(e.selection,i=>{let o;if(t.lineWrapping){let s=t.lineBlockAt(i.head),a=t.coordsAtPos(i.head,i.assoc||1);a&&(o=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,o)}).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Er(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=l.syntaxTree(t).resolveInner(e),n=r.childBefore(e),i=r.childAfter(e),o;return n&&i&&n.to<=e&&i.from>=e&&(o=n.type.prop(l.NodeProp.closedBy))&&o.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(n.to,i.from))?{from:n.to,to:i.from}:null}const rt=Jt(!1),Mr=Jt(!0);function Jt(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),c=!t&&o==s&&Er(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let h=new l.IndentContext(e,{simulateBreak:o,simulateDoubleBreak:!!c}),u=l.getIndentation(h,o);for(u==null&&(u=l.countColumn(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;c?{from:o,to:s}=c:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",l.indentString(e,u)];return c&&f.push(l.indentString(e,h.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:l.Text.of(f)},range:l.EditorSelection.cursor(o+1+f[1].length)}});return r(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ze(t,e){let r=-1;return t.changeByRange(n=>{let i=[];for(let s=n.from;s<=n.to;){let a=t.doc.lineAt(s);a.number>r&&(n.empty||n.to>a.from)&&(e(a,i,n),r=a.number),s=a.to+1}let o=t.changes(i);return{changes:i,range:l.EditorSelection.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const Ar=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Object.create(null),n=new l.IndentContext(t,{overrideIndentation:o=>{let s=r[o];return s??-1}}),i=ze(t,(o,s,a)=>{let c=l.getIndentation(n,o.from);if(c==null)return;/\S/.test(o.text)||(c=0);let h=/^\s*/.exec(o.text)[0],u=l.indentString(t,c);(h!=u||a.from<o.from+h.length)&&(r[o.from]=c,s.push({from:o.from,to:o.from+h.length,insert:u}))});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),!0},_t=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ze(t,(r,n)=>{n.push({from:r.from,insert:t.facet(l.indentUnit)})}),{userEvent:"input.indent"})),!0),jt=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ze(t,(r,n)=>{let i=/^\s*/.exec(r.text)[0];if(!i)return;let o=l.countColumn(i,t.tabSize),s=0,a=l.indentString(t,Math.max(0,o-l.getIndentUnit(t)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;n.push({from:r.from+s,to:r.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),Dr=t=>(t.setTabFocusMode(),!0),Br=[{key:"Ctrl-b",run:Et,shift:Pt,preventDefault:!0},{key:"Ctrl-f",run:Mt,shift:It},{key:"Ctrl-p",run:Bt,shift:Vt},{key:"Ctrl-n",run:Lt,shift:Ft},{key:"Ctrl-a",run:Jn,shift:or},{key:"Ctrl-e",run:_n,shift:lr},{key:"Ctrl-d",run:Ut},{key:"Ctrl-h",run:We},{key:"Ctrl-k",run:mr},{key:"Ctrl-Alt-h",run:Gt},{key:"Ctrl-o",run:yr},{key:"Ctrl-t",run:Sr},{key:"Ctrl-v",run:Oe}],Lr=[{key:"ArrowLeft",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Fn,shift:Yn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Kn,shift:rr,preventDefault:!0},{key:"ArrowRight",run:Mt,shift:It,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Nn,shift:Zn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:$n,shift:ir,preventDefault:!0},{key:"ArrowUp",run:Bt,shift:Vt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Xe,shift:tt},{mac:"Ctrl-ArrowUp",run:Qe,shift:Ye},{key:"ArrowDown",run:Lt,shift:Ft,preventDefault:!0},{mac:"Cmd-ArrowDown",run:et,shift:nt},{mac:"Ctrl-ArrowDown",run:Oe,shift:Ze},{key:"PageUp",run:Qe,shift:Ye},{key:"PageDown",run:Oe,shift:Ze},{key:"Home",run:Gn,shift:nr,preventDefault:!0},{key:"Mod-Home",run:Xe,shift:tt},{key:"End",run:zn,shift:tr,preventDefault:!0},{key:"Mod-End",run:et,shift:nt},{key:"Enter",run:rt,shift:rt},{key:"Mod-a",run:sr},{key:"Backspace",run:We,shift:We,preventDefault:!0},{key:"Delete",run:Ut,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Gt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:dr,preventDefault:!0},{mac:"Mod-Backspace",run:gr,preventDefault:!0},{mac:"Mod-Delete",run:pr,preventDefault:!0}].concat(Br.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),wr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hn,shift:Xn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Un,shift:er},{key:"Alt-ArrowUp",run:kr},{key:"Shift-Alt-ArrowUp",run:Cr},{key:"Alt-ArrowDown",run:xr},{key:"Shift-Alt-ArrowDown",run:br},{key:"Mod-Alt-ArrowUp",run:hr},{key:"Mod-Alt-ArrowDown",run:ur},{key:"Escape",run:fr},{key:"Mod-Enter",run:Mr},{key:"Alt-l",mac:"Ctrl-l",run:ar},{key:"Mod-i",run:cr,preventDefault:!0},{key:"Mod-[",run:jt},{key:"Mod-]",run:_t},{key:"Mod-Alt-\\",run:Ar},{key:"Shift-Mod-k",run:vr},{key:"Shift-Mod-\\",run:Qn},{key:"Mod-/",run:kn},{key:"Alt-A",run:Cn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Dr}].concat(Lr),Tr={key:"Tab",run:_t,shift:jt},it=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class Q{constructor(e,r,n=0,i=e.length,o,s){this.test=s,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=o?a=>o(it(a)):it,this.query=this.normalize(r)}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 l.codePointAt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=l.fromCodePoint(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=l.codePointSize(e);let i=this.normalize(r);if(i.length)for(let o=0,s=n,a=!0;;o++){let c=i.charCodeAt(o),h=this.match(c,s,a,this.bufferPos+this.bufferStart,o==i.length-1);if(h)return this.value=h,this;if(o==i.length-1)break;a&&o<r.length&&r.charCodeAt(o)==c?s++:a=!1}}}match(e,r,n,i,o){let s=null;for(let a=0;a<this.matches.length;){let c=this.matches[a],h=!1;this.query.charCodeAt(c.index)==e&&(c.index==this.query.length-1?s={from:c.from,to:i,precise:o&&c.precise}:(c.index++,h=!0)),h?a++:this.matches.splice(a,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:r,to:i,precise:n&&o}:this.matches.push({from:r,index:1,precise:n})),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(Q.prototype[Symbol.iterator]=function(){return this});const Qt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Ge="gm"+(/x/.unicode==null?"":"u");class Yt{constructor(e,r,n,i=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=Qt,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new Zt(e,r,n,i,o);this.re=new RegExp(r,Ge+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=pe(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=pe(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Le=new WeakMap;class j{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let i=Le.get(e);if(!i||i.from>=n||i.to<=r){let a=new j(r,e.sliceString(r,n));return Le.set(e,a),a}if(i.from==r&&i.to==n)return i;let{text:o,from:s}=i;return s>r&&(o=e.sliceString(r,s)+o,s=r),i.to<n&&(o+=e.sliceString(i.to,n)),Le.set(e,new j(s,o)),new j(r,o.slice(r-s,n-s))}}class Zt{constructor(e,r,n,i,o){this.text=e,this.to=o,this.done=!1,this.value=Qt,this.matchPos=pe(e,i),this.re=new RegExp(r,Ge+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=j.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,i=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this.matchPos=pe(this.text,i+(n==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=j.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Yt.prototype[Symbol.iterator]=Zt.prototype[Symbol.iterator]=function(){return this});function Rr(t){try{return new RegExp(t,Ge),!0}catch{return!1}}function pe(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}const Pr=t=>{let{state:e}=t,r=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:i}=l.showDialog(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:e.phrase("go")});return i.then(o=>{let s=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!s){t.dispatch({effects:n});return}let a=e.doc.lineAt(e.selection.main.head),[,c,h,u,f]=s,d=u?+u.slice(1):0,m=h?+h:a.number;if(h&&f){let y=m/100;c&&(y=y*(c=="-"?-1:1)+a.number/e.doc.lines),m=Math.round(e.doc.lines*y)}else h&&c&&(m=m*(c=="-"?-1:1)+a.number);let g=e.doc.line(Math.max(1,Math.min(e.doc.lines,m))),S=l.EditorSelection.cursor(g.from+Math.max(0,Math.min(d,g.length)));t.dispatch({effects:[n,l.EditorView.scrollIntoView(S.from,{y:"center"})],selection:S})}),!0},Ir={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Or=l.Facet.define({combine(t){return l.combineConfig(t,Ir,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function Wr(t){return[Hr,qr]}const Vr=l.Decoration.mark({class:"cm-selectionMatch"}),Fr=l.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function ot(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=l.CharCategory.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=l.CharCategory.Word)}function Nr(t,e,r,n){return t(e.sliceDoc(r,r+1))==l.CharCategory.Word&&t(e.sliceDoc(n-1,n))==l.CharCategory.Word}const qr=l.ViewPlugin.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(Or),{state:r}=t,n=r.selection;if(n.ranges.length>1)return l.Decoration.none;let i=n.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return l.Decoration.none;let c=r.wordAt(i.head);if(!c)return l.Decoration.none;s=r.charCategorizer(i.head),o=r.sliceDoc(c.from,c.to)}else{let c=i.to-i.from;if(c<e.minSelectionLength||c>200)return l.Decoration.none;if(e.wholeWords){if(o=r.sliceDoc(i.from,i.to),s=r.charCategorizer(i.head),!(ot(s,r,i.from,i.to)&&Nr(s,r,i.from,i.to)))return l.Decoration.none}else if(o=r.sliceDoc(i.from,i.to),!o)return l.Decoration.none}let a=[];for(let c of t.visibleRanges){let h=new Q(r.doc,o,c.from,c.to);for(;!h.next().done;){let{from:u,to:f}=h.value;if((!s||ot(s,r,u,f))&&(i.empty&&u<=i.from&&f>=i.to?a.push(Fr.range(u,f)):(u>=i.to||f<=i.from)&&a.push(Vr.range(u,f)),a.length>e.maxMatches))return l.Decoration.none}}return l.Decoration.set(a)}},{decorations:t=>t.decorations}),Hr=l.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Ur=({state:t,dispatch:e})=>{let{selection:r}=t,n=l.EditorSelection.create(r.ranges.map(i=>t.wordAt(i.head)||l.EditorSelection.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function zr(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),o=i&&i.from==r.from&&i.to==r.to;for(let s=!1,a=new Q(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Q(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),s=!0}else{if(s&&n.some(c=>c.from==a.value.from))continue;if(o){let c=t.wordAt(a.value.from);if(!c||c.from!=a.value.from||c.to!=a.value.to)continue}return a.value}}const Gr=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(o=>o.from===o.to))return Ur({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=n))return!1;let i=zr(t,n);return i?(e(t.update({selection:t.selection.addRange(l.EditorSelection.range(i.from,i.to),!1),effects:l.EditorView.scrollIntoView(i.to)})),!0):!1},Z=l.Facet.define({combine(t){return l.combineConfig(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ii(e),scrollToMatch:e=>l.EditorView.scrollIntoView(e)})}});class Xt{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Rr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
2
- `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Qr(this):new Jr(this)}getCursor(e,r=0,n){let i=e.doc?e:l.EditorState.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?_(this,i,r,n):J(this,i,r,n)}}class en{constructor(e){this.spec=e}}function Kr(t,e,r){return(n,i,o,s)=>{if(r&&!r(n,i,o,s))return!1;let a=n>=s&&i<=s+o.length?o.slice(n-s,i-s):e.doc.sliceString(n,i);return t(a,e,n,i)}}function J(t,e,r,n){let i;return t.wholeWord&&(i=$r(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=Kr(t.test,e,i)),new Q(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:o=>o.toLowerCase(),i)}function $r(t,e){return(r,n,i,o)=>((o>r||o+i.length<n)&&(o=Math.max(0,r-2),i=t.sliceString(o,Math.min(t.length,n+2))),(e(ye(i,r-o))!=l.CharCategory.Word||e(Se(i,r-o))!=l.CharCategory.Word)&&(e(Se(i,n-o))!=l.CharCategory.Word||e(ye(i,n-o))!=l.CharCategory.Word))}class Jr extends en{constructor(e){super(e)}nextMatch(e,r,n){let i=J(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let o=Math.min(e.doc.length,r+this.spec.unquoted.length);i=J(this.spec,e,0,o).nextOverlapping()}return i.done||i.value.from==r&&i.value.to==n?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let o=Math.max(r,i-1e4-this.spec.unquoted.length),s=J(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==r)return null;i-=1e4}}prevMatch(e,r,n){let i=this.prevMatchInRange(e,0,r);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=r||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=J(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=J(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}function _r(t,e,r){return(n,i,o)=>(!r||r(n,i,o))&&t(o[0],e,n,i)}function _(t,e,r,n){let i;return t.wholeWord&&(i=jr(e.charCategorizer(e.selection.main.head))),t.test&&(i=_r(t.test,e,i)),new Yt(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},r,n)}function ye(t,e){return t.slice(l.findClusterBreak(t,e,!1),e)}function Se(t,e){return t.slice(e,l.findClusterBreak(t,e))}function jr(t){return(e,r,n)=>!n[0].length||(t(ye(n.input,n.index))!=l.CharCategory.Word||t(Se(n.input,n.index))!=l.CharCategory.Word)&&(t(Se(n.input,n.index+n[0].length))!=l.CharCategory.Word||t(ye(n.input,n.index+n[0].length))!=l.CharCategory.Word)}class Qr extends en{nextMatch(e,r,n){let i=_(this.spec,e,n,e.doc.length).next();return i.done&&(i=_(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let o=Math.max(r,n-i*1e4),s=_(this.spec,e,o,n),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==r||a.from>o+10))return a;if(o==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let o=+n.slice(0,i);if(o>0&&o<e.match.length)return e.match[o]+n.slice(i)}return r})}matchAll(e,r){let n=_(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=_(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}const ne=l.StateEffect.define(),Ke=l.StateEffect.define(),O=l.StateField.define({create(t){return new we(Ve(t).create(),null)},update(t,e){for(let r of e.effects)r.is(ne)?t=new we(r.value.create(),t.panel):r.is(Ke)&&(t=new we(t.query,r.value?$e:null));return t},provide:t=>l.showPanel.from(t,e=>e.panel)});class we{constructor(e,r){this.query=e,this.panel=r}}const Yr=l.Decoration.mark({class:"cm-searchMatch"}),Zr=l.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Xr=l.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(O))}update(t){let e=t.state.field(O);(e!=t.startState.field(O)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return l.Decoration.none;let{view:r}=this,n=new l.RangeSetBuilder;for(let i=0,o=r.visibleRanges,s=o.length;i<s;i++){let{from:a,to:c}=o[i];for(;i<s-1&&c>o[i+1].from-2*250;)c=o[++i].to;t.highlight(r.state,a,c,(h,u)=>{let f=r.state.selection.ranges.some(d=>d.from==h&&d.to==u);n.add(h,u,f?Zr:Yr)})}return n.finish()}},{decorations:t=>t.decorations});function le(t){return e=>{let r=e.state.field(O,!1);return r&&r.query.spec.valid?t(e,r):rn(e)}}const ke=le((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let i=l.EditorSelection.single(n.from,n.to),o=t.state.facet(Z);return t.dispatch({selection:i,effects:[Je(t,n),o.scrollToMatch(i.main,t)],userEvent:"select.search"}),nn(t),!0}),xe=le((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,i=e.prevMatch(r,n,n);if(!i)return!1;let o=l.EditorSelection.single(i.from,i.to),s=t.state.facet(Z);return t.dispatch({selection:o,effects:[Je(t,i),s.scrollToMatch(o.main,t)],userEvent:"select.search"}),nn(t),!0}),ei=le((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:l.EditorSelection.create(r.map(n=>l.EditorSelection.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),ti=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,o=[],s=0;for(let a=new Q(t.doc,t.sliceDoc(n,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==n&&(s=o.length),o.push(l.EditorSelection.range(a.value.from,a.value.to))}return e(t.update({selection:l.EditorSelection.create(o,s),userEvent:"select.search.matches"})),!0},lt=le((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let o=e.nextMatch(r,n,n);if(!o)return!1;let s=o,a=[],c,h,u=[];s.precise?s.from==n&&s.to==i&&(h=r.toText(e.getReplacement(s)),a.push({from:s.from,to:s.to,insert:h}),u.push(l.EditorView.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+"."))):s=e.nextMatch(r,s.from,s.to);let f=t.state.changes(a);return s&&(c=l.EditorSelection.single(s.from,s.to).map(f),u.push(Je(t,s)),u.push(r.facet(Z).scrollToMatch(c.main,t))),t.dispatch({changes:f,selection:c,effects:u,userEvent:"input.replace"}),!0}),ni=le((t,{query:e})=>{if(t.state.readOnly)return!1;let r=[];for(let i of e.matchAll(t.state,1e9)){let{from:o,to:s,precise:a}=i;a&&r.push({from:o,to:s,insert:e.getReplacement(i)})}if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:l.EditorView.announce.of(n),userEvent:"input.replace.all"}),!0});function $e(t){return t.state.facet(Z).createPanel(t)}function Ve(t,e){var r,n,i,o,s;let a=t.selection.main,c=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!c)return e;let h=t.facet(Z);return new Xt({search:((r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:h.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:h.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:h.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:h.wholeWord})}function tn(t){let e=l.getPanel(t,$e);return e&&e.dom.querySelector("[main-field]")}function nn(t){let e=tn(t);e&&e==t.root.activeElement&&e.select()}const rn=t=>{let e=t.state.field(O,!1);if(e&&e.panel){let r=tn(t);if(r&&r!=t.root.activeElement){let n=Ve(t.state,e.query.spec);n.valid&&t.dispatch({effects:ne.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[Ke.of(!0),e?ne.of(Ve(t.state,e.query.spec)):l.StateEffect.appendConfig.of(li)]});return!0},on=t=>{let e=t.state.field(O,!1);if(!e||!e.panel)return!1;let r=l.getPanel(t,$e);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Ke.of(!1)}),!0},ri=[{key:"Mod-f",run:rn,scope:"editor search-panel"},{key:"F3",run:ke,shift:xe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ke,shift:xe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:on,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ti},{key:"Mod-Alt-g",run:Pr},{key:"Mod-d",run:Gr,preventDefault:!0}];class ii{constructor(e){this.view=e;let r=this.query=e.state.field(O).query.spec;this.commit=this.commit.bind(this),this.searchField=l.crelt("input",{value:r.search,placeholder:E(e,"Find"),"aria-label":E(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=l.crelt("input",{value:r.replace,placeholder:E(e,"Replace"),"aria-label":E(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=l.crelt("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=l.crelt("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=l.crelt("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(i,o,s){return l.crelt("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=l.crelt("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>ke(e),[E(e,"next")]),n("prev",()=>xe(e),[E(e,"previous")]),n("select",()=>ei(e),[E(e,"all")]),l.crelt("label",null,[this.caseField,E(e,"match case")]),l.crelt("label",null,[this.reField,E(e,"regexp")]),l.crelt("label",null,[this.wordField,E(e,"by word")]),...e.state.readOnly?[]:[l.crelt("br"),this.replaceField,n("replace",()=>lt(e),[E(e,"replace")]),n("replaceAll",()=>ni(e),[E(e,"replace all")])],l.crelt("button",{name:"close",onclick:()=>on(e),"aria-label":E(e,"close"),type:"button"},["×"])])}commit(){let e=new Xt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ne.of(e)}))}keydown(e){l.runScopeHandlers(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?xe:ke)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),lt(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(ne)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Z).top}}function E(t,e){return t.state.phrase(e)}const ue=30,fe=/[\s\.,:;?!]/;function Je(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),i=t.state.doc.lineAt(r).to,o=Math.max(n.from,e-ue),s=Math.min(i,r+ue),a=t.state.sliceDoc(o,s);if(o!=n.from){for(let c=0;c<ue;c++)if(!fe.test(a[c+1])&&fe.test(a[c])){a=a.slice(c);break}}if(s!=i){for(let c=a.length-1;c>a.length-ue;c--)if(!fe.test(a[c-1])&&fe.test(a[c])){a=a.slice(0,c);break}}return l.EditorView.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const oi=l.EditorView.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"}}),li=[O,l.Prec.low(Xr),oi];class st{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}}class U{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=n.facet(re).markerFilter;i&&(e=i(e,n));let o=e.slice().sort((m,g)=>m.from-g.from||m.to-g.to),s=new l.RangeSetBuilder,a=[],c=0,h=n.doc.iter(),u=0,f=n.doc.length;for(let m=0;;){let g=m==o.length?null:o[m];if(!g&&!a.length)break;let S,y;if(a.length)S=c,y=a.reduce((p,C)=>Math.min(p,C.to),g&&g.from>S?g.from:1e8);else{if(S=g.from,S>f)break;y=g.to,a.push(g),m++}for(;m<o.length;){let p=o[m];if(p.from==S&&(p.to>p.from||p.to==S))a.push(p),m++,y=Math.min(p.to,y);else{y=Math.min(p.from,y);break}}y=Math.min(y,f);let P=!1;if(a.some(p=>p.from==S&&(p.to==y||y==f))&&(P=S==y,!P&&y-S<10)){let p=S-(u+h.value.length);p>0&&(h.next(p),u=S);for(let C=S;;){if(C>=y){P=!0;break}if(!h.lineBreak&&u+h.value.length>C)break;C=u+h.value.length,u+=h.value.length,h.next()}}let F=ki(a);if(P)s.add(S,S,l.Decoration.widget({widget:new gi(F),diagnostics:a.slice()}));else{let p=a.reduce((C,z)=>z.markClass?C+" "+z.markClass:C,"");s.add(S,y,l.Decoration.mark({class:"cm-lintRange cm-lintRange-"+F+p,diagnostics:a.slice(),inclusiveEnd:a.some(C=>C.to>y)}))}if(c=y,c==f)break;for(let p=0;p<a.length;p++)a[p].to<=c&&a.splice(p--,1)}let d=s.finish();return new U(d,r,W(d))}}function W(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!n)n=new st(i,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new st(n.from,o,n.diagnostic)}}),n}function si(t,e){let r=e.pos,n=e.end||r,i=t.state.facet(re).hideOn(t,r,n);if(i!=null)return i;let o=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(ln))||t.changes.touchesRange(o.from,Math.max(o.to,n)))}function ai(t,e){return t.field(M,!1)?e:e.concat(l.StateEffect.appendConfig.of(xi))}const ln=l.StateEffect.define(),_e=l.StateEffect.define(),sn=l.StateEffect.define(),M=l.StateField.define({create(){return new U(l.Decoration.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let r=t.diagnostics.map(e.changes),n=null,i=t.panel;if(t.selected){let o=e.changes.mapPos(t.selected.from,1);n=W(r,t.selected.diagnostic,o)||W(r,null,o)}!r.size&&i&&e.state.facet(re).autoPanel&&(i=null),t=new U(r,i,n)}for(let r of e.effects)if(r.is(ln)){let n=e.state.facet(re).autoPanel?r.value.length?ie.open:null:t.panel;t=U.init(r.value,n,e.state)}else r.is(_e)?t=new U(t.diagnostics,r.value?ie.open:null,t.selected):r.is(sn)&&(t=new U(t.diagnostics,t.panel,r.value));return t},provide:t=>[l.showPanel.from(t,e=>e.panel),l.EditorView.decorations.from(t,e=>e.diagnostics)]}),ci=l.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function hi(t,e,r){let{diagnostics:n}=t.state.field(M),i,o=-1,s=-1;n.between(e-(r<0?1:0),e+(r>0?1:0),(c,h,{spec:u})=>{if(e>=c&&e<=h&&(c==h||(e>c||r>0)&&(e<h||r<0)))return i=u.diagnostics,o=c,s=h,!1});let a=t.state.facet(re).tooltipFilter;return i&&a&&(i=a(i,t.state)),i?{pos:o,end:s,above:t.state.doc.lineAt(o).to<s,create(){return{dom:ui(t,i)}}}:null}function ui(t,e){return l.crelt("ul",{class:"cm-tooltip-lint"},e.map(r=>cn(t,r,!1)))}const fi=t=>{let e=t.state.field(M,!1);(!e||!e.panel)&&t.dispatch({effects:ai(t.state,[_e.of(!0)])});let r=l.getPanel(t,ie.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},at=t=>{let e=t.state.field(M,!1);return!e||!e.panel?!1:(t.dispatch({effects:_e.of(!1)}),!0)},di=t=>{let e=t.state.field(M,!1);if(!e)return!1;let r=t.state.selection.main,n=W(e.diagnostics,null,r.to+1);return!n&&(n=W(e.diagnostics,null,0),!n||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},mi=[{key:"Mod-Shift-m",run:fi,preventDefault:!0},{key:"F8",run:di}],re=l.Facet.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...l.combineConfig(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ct,tooltipFilter:ct,needsRefresh:(e,r)=>e?r?n=>e(n)||r(n):e:r,hideOn:(e,r)=>e?r?(n,i,o)=>e(n,i,o)||r(n,i,o):e:r,autoPanel:(e,r)=>e||r})}}});function ct(t,e){return t?e?(r,n)=>e(t(r,n),n):t:e}function an(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;n<r.length;n++){let i=r[n];if(/[a-zA-Z]/.test(i)&&!e.some(o=>o.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function cn(t,e,r){var n;let i=r?an(e.actions):[];return l.crelt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},l.crelt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((o,s)=>{let a=!1,c=m=>{if(m.preventDefault(),a)return;a=!0;let g=W(t.state.field(M).diagnostics,e);g&&o.apply(t,g.from,g.to)},{name:h}=o,u=i[s]?h.indexOf(i[s]):-1,f=u<0?h:[h.slice(0,u),l.crelt("u",h.slice(u,u+1)),h.slice(u+1)],d=o.markClass?" "+o.markClass:"";return l.crelt("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:c,onmousedown:c,"aria-label":` Action: ${h}${u<0?"":` (access key "${i[s]})"`}.`},f)}),e.source&&l.crelt("div",{class:"cm-diagnosticSource"},e.source))}class gi extends l.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return l.crelt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ht{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=cn(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ie{constructor(e){this.view=e,this.items=[];let r=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)at(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=an(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let c=W(this.view.state.field(M).diagnostics,o);c&&o.actions[a].apply(e,c.from,c.to)}}else return;i.preventDefault()}},n=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=l.crelt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:n}),this.dom=l.crelt("div",{class:"cm-panel-lint"},this.list,l.crelt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>at(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(M).selected;if(!e)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==e.diagnostic)return r;return-1}update(){let{diagnostics:e,selected:r}=this.view.state.field(M),n=0,i=!1,o=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,c,{spec:h})=>{for(let u of h.diagnostics){if(s.has(u))continue;s.add(u);let f=-1,d;for(let m=n;m<this.items.length;m++)if(this.items[m].diagnostic==u){f=m;break}f<0?(d=new ht(this.view,u),this.items.splice(n,0,d),i=!0):(d=this.items[f],f>n&&(this.items.splice(n,f-n),i=!0)),r&&d.diagnostic==r.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),o=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new ht(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:c})=>{let h=c.height/this.list.offsetHeight;a.top<c.top?this.list.scrollTop-=(c.top-a.top)/h:a.bottom>c.bottom&&(this.list.scrollTop+=(a.bottom-c.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(M),n=W(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:sn.of(n)})}static open(e){return new ie(e)}}function pi(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>')`}function de(t){return pi(`<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"')}const yi=l.EditorView.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:de("#d11")},".cm-lintRange-warning":{backgroundImage:de("orange")},".cm-lintRange-info":{backgroundImage:de("#999")},".cm-lintRange-hint":{backgroundImage:de("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Si(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function ki(t){let e="hint",r=1;for(let n of t){let i=Si(n.severity);i>r&&(r=i,e=n.severity)}return e}const xi=[M,l.EditorView.decorations.compute([M],t=>{let{selected:e,panel:r}=t.field(M);return!e||!r||e.from==e.to?l.Decoration.none:l.Decoration.set([ci.range(e.from,e.to)])}),l.hoverTooltip(hi,{hideOn:si}),yi];var Fe=function(e){e===void 0&&(e={});var{crosshairCursor:r=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(ce.closeBracketsKeymap)),e.defaultKeymap!==!1&&(n=n.concat(wr)),e.searchKeymap!==!1&&(n=n.concat(ri)),e.historyKeymap!==!1&&(n=n.concat(Vn)),e.foldKeymap!==!1&&(n=n.concat(l.foldKeymap)),e.completionKeymap!==!1&&(n=n.concat(ce.completionKeymap)),e.lintKeymap!==!1&&(n=n.concat(mi));var i=[];return e.lineNumbers!==!1&&i.push(l.lineNumbers()),e.highlightActiveLineGutter!==!1&&i.push(l.highlightActiveLineGutter()),e.highlightSpecialChars!==!1&&i.push(l.highlightSpecialChars()),e.history!==!1&&i.push(Bn()),e.foldGutter!==!1&&i.push(l.foldGutter()),e.drawSelection!==!1&&i.push(l.drawSelection()),e.dropCursor!==!1&&i.push(l.dropCursor()),e.allowMultipleSelections!==!1&&i.push(l.EditorState.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(l.indentOnInput()),e.syntaxHighlighting!==!1&&i.push(l.syntaxHighlighting(l.defaultHighlightStyle,{fallback:!0})),e.bracketMatching!==!1&&i.push(l.bracketMatching()),e.closeBrackets!==!1&&i.push(ce.closeBrackets()),e.autocompletion!==!1&&i.push(ce.autocompletion()),e.rectangularSelection!==!1&&i.push(l.rectangularSelection()),r!==!1&&i.push(l.crosshairCursor()),e.highlightActiveLine!==!1&&i.push(l.highlightActiveLine()),e.highlightSelectionMatches!==!1&&i.push(Wr()),e.tabSize&&typeof e.tabSize=="number"&&i.push(l.indentUnit.of(" ".repeat(e.tabSize))),i.concat([l.keymap.of(n.flat())]).filter(Boolean)};const Ci="#e5c07b",ut="#e06c75",bi="#56b6c2",vi="#ffffff",me="#abb2bf",Ne="#7d8799",Ei="#61afef",Mi="#98c379",ft="#d19a66",Ai="#c678dd",Di="#21252b",dt="#2c313a",mt="#282c34",Te="#353a42",Bi="#3E4451",gt="#528bff",hn=l.EditorView.theme({"&":{color:me,backgroundColor:mt},".cm-content":{caretColor:gt},".cm-cursor, .cm-dropCursor":{borderLeftColor:gt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Bi},".cm-panels":{backgroundColor:Di,color:me},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:mt,color:Ne,border:"none"},".cm-activeLineGutter":{backgroundColor:dt},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Te},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Te,borderBottomColor:Te},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:dt,color:me}}},{dark:!0}),un=l.HighlightStyle.define([{tag:l.tags.keyword,color:Ai},{tag:[l.tags.name,l.tags.deleted,l.tags.character,l.tags.propertyName,l.tags.macroName],color:ut},{tag:[l.tags.function(l.tags.variableName),l.tags.labelName],color:Ei},{tag:[l.tags.color,l.tags.constant(l.tags.name),l.tags.standard(l.tags.name)],color:ft},{tag:[l.tags.definition(l.tags.name),l.tags.separator],color:me},{tag:[l.tags.typeName,l.tags.className,l.tags.number,l.tags.changed,l.tags.annotation,l.tags.modifier,l.tags.self,l.tags.namespace],color:Ci},{tag:[l.tags.operator,l.tags.operatorKeyword,l.tags.url,l.tags.escape,l.tags.regexp,l.tags.link,l.tags.special(l.tags.string)],color:bi},{tag:[l.tags.meta,l.tags.comment],color:Ne},{tag:l.tags.strong,fontWeight:"bold"},{tag:l.tags.emphasis,fontStyle:"italic"},{tag:l.tags.strikethrough,textDecoration:"line-through"},{tag:l.tags.link,color:Ne,textDecoration:"underline"},{tag:l.tags.heading,fontWeight:"bold",color:ut},{tag:[l.tags.atom,l.tags.bool,l.tags.special(l.tags.variableName)],color:ft},{tag:[l.tags.processingInstruction,l.tags.string,l.tags.inserted],color:Mi},{tag:l.tags.invalid,color:vi}]),fn=[hn,l.syntaxHighlighting(un)];var dn=l.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),mn=function(e){e===void 0&&(e={});var{indentWithTab:r=!0,editable:n=!0,readOnly:i=!1,theme:o="light",placeholder:s="",basicSetup:a=!0}=e,c=[];switch(r&&c.unshift(l.keymap.of([Tr])),a&&(typeof a=="boolean"?c.unshift(Fe()):c.unshift(Fe(a))),s&&c.unshift(l.placeholder(s)),o){case"light":c.push(dn);break;case"dark":c.push(fn);break;case"none":break;default:c.push(o);break}return n===!1&&c.push(l.EditorView.editable.of(!1)),i&&c.push(l.EditorState.readOnly.of(!0)),[...c]},gn=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Li{constructor(e,r){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=r,this.timeoutMS=r,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(r=>{try{r()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class pt{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Re=null,wi=()=>typeof window>"u"?new pt:(Re||(Re=new pt),Re),qe=l.Annotation.define(),Ti=200,Ri=[];function pn(t){var{value:e,selection:r,onChange:n,onStatistics:i,onCreateEditor:o,onUpdate:s,extensions:a=Ri,autoFocus:c,theme:h="light",height:u=null,minHeight:f=null,maxHeight:d=null,width:m=null,minWidth:g=null,maxWidth:S=null,placeholder:y="",editable:P=!0,readOnly:F=!1,indentWithTab:p=!0,basicSetup:C=!0,root:z,initialState:X}=t,[G,se]=b.useState(),[k,I]=b.useState(),[K,$]=b.useState(),A=b.useState(()=>({current:null}))[0],N=b.useState(()=>({current:null}))[0],Me=l.EditorView.theme({"&":{height:u,minHeight:f,maxHeight:d,width:m,minWidth:g,maxWidth:S},"& .cm-scroller":{height:"100% !important"}}),Ae=l.EditorView.updateListener.of(T=>{if(T.docChanged&&typeof n=="function"&&!T.transactions.some(De=>De.annotation(qe))){A.current?A.current.reset():(A.current=new Li(()=>{if(N.current){var De=N.current;N.current=null,De()}A.current=null},Ti),wi().add(A.current));var q=T.state.doc,H=q.toString();n(H,T)}i&&i(gn(T))}),ae=mn({theme:h,editable:P,readOnly:F,placeholder:y,indentWithTab:p,basicSetup:C}),ee=[Ae,Me,...ae];return s&&typeof s=="function"&&ee.push(l.EditorView.updateListener.of(s)),ee=ee.concat(a),b.useLayoutEffect(()=>{if(G&&!K){var T={doc:e,selection:r,extensions:ee},q=X?l.EditorState.fromJSON(X.json,T,X.fields):l.EditorState.create(T);if($(q),!k){var H=new l.EditorView({state:q,parent:G,root:z});I(H),o&&o(H,q)}}return()=>{k&&($(void 0),I(void 0))}},[G,K]),b.useEffect(()=>{t.container&&se(t.container)},[t.container]),b.useEffect(()=>()=>{k&&(k.destroy(),I(void 0)),A.current&&(A.current.cancel(),A.current=null)},[k]),b.useEffect(()=>{c&&k&&k.focus()},[c,k]),b.useEffect(()=>{k&&k.dispatch({effects:l.StateEffect.reconfigure.of(ee)})},[h,a,u,f,d,m,g,S,y,P,F,p,C,n,s]),b.useEffect(()=>{if(e!==void 0){var T=k?k.state.doc.toString():"";if(k&&e!==T){var q=A.current&&!A.current.isDone,H=()=>{k&&e!==k.state.doc.toString()&&k.dispatch({changes:{from:0,to:k.state.doc.toString().length,insert:e||""},annotations:[qe.of(!0)]})};q?N.current=H:H()}}},[e,k]),{state:K,setState:$,view:k,setView:I,container:G,setContainer:se}}var Pi=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],yn=b.forwardRef((t,e)=>{var{className:r,value:n="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:c,onUpdate:h,autoFocus:u,theme:f="light",height:d,minHeight:m,maxHeight:g,width:S,minWidth:y,maxWidth:P,basicSetup:F,placeholder:p,indentWithTab:C,editable:z,readOnly:X,root:G,initialState:se}=t,k=je._objectWithoutPropertiesLoose(t,Pi),I=b.useRef(null),{state:K,view:$,container:A,setContainer:N}=pn({root:G,value:n,autoFocus:u,theme:f,height:d,minHeight:m,maxHeight:g,width:S,minWidth:y,maxWidth:P,basicSetup:F,placeholder:p,indentWithTab:C,editable:z,readOnly:X,selection:i,onChange:s,onStatistics:a,onCreateEditor:c,onUpdate:h,extensions:o,initialState:se});b.useImperativeHandle(e,()=>({editor:I.current,state:K,view:$}),[I,A,K,$]);var Me=b.useCallback(ae=>{I.current=ae,N(ae)},[N]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var Ae=typeof f=="string"?"cm-theme-"+f:"cm-theme";return Sn.jsx("div",je._extends({ref:Me,className:""+Ae+(r?" "+r:"")},k))});yn.displayName="CodeMirror";exports.Annotation=l.Annotation;exports.AnnotationType=l.AnnotationType;exports.BidiSpan=l.BidiSpan;exports.BlockInfo=l.BlockInfo;Object.defineProperty(exports,"BlockType",{enumerable:!0,get:()=>l.BlockType});exports.BlockWrapper=l.BlockWrapper;exports.ChangeDesc=l.ChangeDesc;exports.ChangeSet=l.ChangeSet;Object.defineProperty(exports,"CharCategory",{enumerable:!0,get:()=>l.CharCategory});exports.Compartment=l.Compartment;exports.Decoration=l.Decoration;Object.defineProperty(exports,"Direction",{enumerable:!0,get:()=>l.Direction});exports.EditorSelection=l.EditorSelection;exports.EditorState=l.EditorState;exports.EditorView=l.EditorView;exports.Facet=l.Facet;exports.GutterMarker=l.GutterMarker;exports.Line=l.Line;Object.defineProperty(exports,"MapMode",{enumerable:!0,get:()=>l.MapMode});exports.MatchDecorator=l.MatchDecorator;exports.Prec=l.Prec;exports.Range=l.Range;exports.RangeSet=l.RangeSet;exports.RangeSetBuilder=l.RangeSetBuilder;exports.RangeValue=l.RangeValue;exports.RectangleMarker=l.RectangleMarker;exports.SelectionRange=l.SelectionRange;exports.StateEffect=l.StateEffect;exports.StateEffectType=l.StateEffectType;exports.StateField=l.StateField;exports.Text=l.Text;exports.Transaction=l.Transaction;exports.ViewPlugin=l.ViewPlugin;exports.ViewUpdate=l.ViewUpdate;exports.WidgetType=l.WidgetType;exports.codePointAt=l.codePointAt;exports.codePointSize=l.codePointSize;exports.combineConfig=l.combineConfig;exports.countColumn=l.countColumn;exports.crosshairCursor=l.crosshairCursor;exports.drawSelection=l.drawSelection;exports.dropCursor=l.dropCursor;exports.findClusterBreak=l.findClusterBreak;exports.findColumn=l.findColumn;exports.fromCodePoint=l.fromCodePoint;exports.getPanel=l.getPanel;exports.getTooltip=l.getTooltip;exports.gutter=l.gutter;exports.gutterLineClass=l.gutterLineClass;exports.gutterWidgetClass=l.gutterWidgetClass;exports.gutters=l.gutters;exports.highlightActiveLine=l.highlightActiveLine;exports.highlightActiveLineGutter=l.highlightActiveLineGutter;exports.highlightSpecialChars=l.highlightSpecialChars;exports.hoverTooltip=l.hoverTooltip;exports.keymap=l.keymap;exports.layer=l.layer;exports.lineNumberMarkers=l.lineNumberMarkers;exports.lineNumberWidgetMarker=l.lineNumberWidgetMarker;exports.lineNumbers=l.lineNumbers;exports.logException=l.logException;exports.placeholder=l.placeholder;exports.rectangularSelection=l.rectangularSelection;exports.runScopeHandlers=l.runScopeHandlers;exports.showDialog=l.showDialog;exports.showPanel=l.showPanel;exports.showTooltip=l.showTooltip;exports.ExternalChange=qe;exports.basicSetup=Fe;exports.default=yn;exports.defaultLightThemeOption=dn;exports.getDefaultExtensions=mn;exports.getStatistics=gn;exports.oneDark=fn;exports.oneDarkHighlightStyle=un;exports.oneDarkTheme=hn;exports.useCodeMirror=pn;
@@ -1 +0,0 @@
1
- "use strict";const f=require("./index-B31-Y5uO.js");class re{constructor(e,t,n,o){this.state=e,this.pos=t,this.explicit=n,this.view=o,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=f.syntaxTree(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),o=t.text.slice(n-t.from,this.pos-t.from),s=o.search(ae(e,!1));return s<0?null:{from:n+s,to:this.pos,text:o.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Z(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function be(i){let e=Object.create(null),t=Object.create(null);for(let{label:o}of i){e[o[0]]=!0;for(let s=1;s<o.length;s++)t[o[s]]=!0}let n=Z(e)+Z(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function ce(i){let e=i.map(o=>typeof o=="string"?{label:o}:o),[t,n]=e.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:be(e);return o=>{let s=o.matchBefore(n);return s||o.explicit?{from:s?s.from:o.pos,options:e,validFor:t}:null}}function xe(i,e){return t=>{for(let n=f.syntaxTree(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class _{constructor(e,t,n,o){this.completion=e,this.source=t,this.match=n,this.score=o}}function I(i){return i.selection.main.from}function ae(i,e){var t;let{source:n}=i,o=e&&n[0]!="^",s=n[n.length-1]!="$";return!o&&!s?i:new RegExp(`${o?"^":""}(?:${n})${s?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const H=f.Annotation.define();function Ce(i,e,t,n){let{main:o}=i.selection,s=t-o.from,l=n-o.from;return{...i.changeByRange(c=>{if(c!=o&&t!=n&&i.sliceDoc(c.from+s,c.from+l)!=i.sliceDoc(t,n))return{range:c};let r=i.toText(e);return{changes:{from:c.from+s,to:n==o.from?c.to:c.from+l,insert:r},range:f.EditorSelection.cursor(c.from+s+r.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const ee=new WeakMap;function we(i){if(!Array.isArray(i))return i;let e=ee.get(i);return e||ee.set(i,e=ce(i)),e}const $=f.StateEffect.define(),R=f.StateEffect.define();class Se{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=f.codePointAt(e,t),o=f.codePointSize(n);this.chars.push(n);let s=e.slice(t,t+o),l=s.toUpperCase();this.folded.push(f.codePointAt(l==s?s.toLowerCase():l,0)),t+=o}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:o,precise:s,byWord:l}=this;if(t.length==1){let m=f.codePointAt(e,0),P=f.codePointSize(m),S=P==e.length?0:-100;if(m!=t[0])if(m==n[0])S+=-200;else return null;return this.ret(S,[0,P])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let r=t.length,p=0;if(c<0){for(let m=0,P=Math.min(e.length,200);m<P&&p<r;){let S=f.codePointAt(e,m);(S==t[p]||S==n[p])&&(o[p++]=m),m+=f.codePointSize(S)}if(p<r)return null}let a=0,h=0,d=!1,u=0,g=-1,b=-1,D=/[a-z]/.test(e),v=!0;for(let m=0,P=Math.min(e.length,200),S=0;m<P&&h<r;){let x=f.codePointAt(e,m);c<0&&(a<r&&x==t[a]&&(s[a++]=m),u<r&&(x==t[u]||x==n[u]?(u==0&&(g=m),b=m+1,u++):u=0));let B,V=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(B=f.fromCodePoint(x))!=B.toLowerCase()?1:B!=B.toUpperCase()?2:0;(!m||V==1&&D||S==0&&V!=0)&&(t[h]==x||n[h]==x&&(d=!0)?l[h++]=m:l.length&&(v=!1)),S=V,m+=f.codePointSize(x)}return h==r&&l[0]==0&&v?this.result(-100+(d?-200:0),l,e):u==r&&g==0?this.ret(-200-e.length+(b==e.length?0:-100),[0,b]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):u==r?this.ret(-900-e.length,[g,b]):h==r?this.result(-100+(d?-200:0)+-700+(v?0:-1100),l,e):t.length==2?null:this.result((o[0]?-700:0)+-200+-1100,o,e)}result(e,t,n){let o=[],s=0;for(let l of t){let c=l+(this.astral?f.codePointSize(f.codePointAt(n,l)):1);s&&o[s-1]==l?o[s-1]=c:(o[s++]=l,o[s++]=c)}return this.ret(e-n.length,o)}}class ve{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const y=f.Facet.define({combine(i){return f.combineConfig(i,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ee,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>te(e(n),t(n)),optionClass:(e,t)=>n=>te(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function te(i,e){return i?e?i+" "+e:i:e}function Ee(i,e,t,n,o,s){let l=i.textDirection==f.Direction.RTL,c=l,r=!1,p="top",a,h,d=e.left-o.left,u=o.right-e.right,g=n.right-n.left,b=n.bottom-n.top;if(c&&d<Math.min(g,u)?c=!1:!c&&u<Math.min(g,d)&&(c=!0),g<=(c?d:u))a=Math.max(o.top,Math.min(t.top,o.bottom-b))-e.top,h=Math.min(400,c?d:u);else{r=!0,h=Math.min(400,(l?e.right:o.right-e.left)-30);let m=o.bottom-e.bottom;m>=b||m>e.top?a=t.bottom-e.top:(p="bottom",a=e.bottom-t.top)}let D=(e.bottom-e.top)/s.offsetHeight,v=(e.right-e.left)/s.offsetWidth;return{style:`${p}: ${a/D}px; max-width: ${h/v}px`,class:"cm-completionInfo-"+(r?l?"left-narrow":"right-narrow":c?"left":"right")}}const K=f.StateEffect.define();function Ie(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(o=>"cm-completionIcon-"+o)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,o,s){let l=document.createElement("span");l.className="cm-completionLabel";let c=t.displayLabel||t.label,r=0;for(let p=0;p<s.length;){let a=s[p++],h=s[p++];a>r&&l.appendChild(document.createTextNode(c.slice(r,a)));let d=l.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(c.slice(a,h))),d.className="cm-completionMatchedText",r=h}return r<c.length&&l.appendChild(document.createTextNode(c.slice(r))),l},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function U(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let o=Math.floor(e/t);return{from:o*t,to:(o+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class Pe{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:r=>this.placeInfo(r),key:this},this.space=null,this.currentClass="";let o=e.state.field(t),{options:s,selected:l}=o.open,c=e.state.facet(y);this.optionContent=Ie(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=U(s.length,l,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",r=>{let{options:p}=e.state.field(t).open;for(let a=r.target,h;a&&a!=this.dom;a=a.parentNode)if(a.nodeName=="LI"&&(h=/-(\d+)$/.exec(a.id))&&+h[1]<p.length){this.applyCompletion(e,p[+h[1]]),r.preventDefault();return}if(r.target==this.list){let a=this.list.classList.contains("cm-completionListIncompleteTop")&&r.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&r.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;a!=null&&(e.dispatch({effects:K.of(a)}),r.preventDefault())}}),this.dom.addEventListener("focusout",r=>{let p=e.state.field(this.stateField,!1);p&&p.tooltip&&e.state.facet(y).closeOnBlur&&r.relatedTarget!=e.contentDOM&&e.dispatch({effects:R.of(null)})}),this.showOptions(s,o.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),o=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=o){let{options:s,selected:l,disabled:c}=n.open;(!o.open||o.open.options!=s)&&(this.range=U(s.length,l,e.state.facet(y).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),c!=((t=o.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=U(t.options.length,t.selected,this.view.state.facet(y).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:o}=t.options[t.selected],{info:s}=o;if(!s)return;let l=typeof s=="string"?document.createTextNode(s):s(o);if(!l)return;"then"in l?l.then(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,o)}).catch(c=>f.logException(this.view.state,c,"completion info")):(this.addInfoPane(l,o),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:o,destroy:s}=e;n.appendChild(o),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,o=this.range.from;n;n=n.nextSibling,o++)n.nodeName!="LI"||!n.id?o--:o==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&Ae(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),o=e.getBoundingClientRect(),s=this.space;if(!s){let l=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:l.clientWidth,bottom:l.clientHeight}}return o.top>Math.min(s.bottom,t.bottom)-10||o.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(y).positionInfo(this.view,t,o,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const o=document.createElement("ul");o.id=t,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions")),o.addEventListener("mousedown",l=>{l.target==o&&l.preventDefault()});let s=null;for(let l=n.from;l<n.to;l++){let{completion:c,match:r}=e[l],{section:p}=c;if(p){let d=typeof p=="string"?p:p.name;if(d!=s&&(l>n.from||n.from==0))if(s=d,typeof p!="string"&&p.header)o.appendChild(p.header(p));else{let u=o.appendChild(document.createElement("completion-section"));u.textContent=d}}const a=o.appendChild(document.createElement("li"));a.id=t+"-"+l,a.setAttribute("role","option");let h=this.optionClass(c);h&&(a.className=h);for(let d of this.optionContent){let u=d(c,this.view.state,this.view,r);u&&a.appendChild(u)}}return n.from&&o.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Te(i,e){return t=>new Pe(t,i,e)}function Ae(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),o=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/o:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/o)}function ie(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function Oe(i,e){let t=[],n=null,o=null,s=a=>{t.push(a);let{section:h}=a.completion;if(h){n||(n=[]);let d=typeof h=="string"?h:h.name;n.some(u=>u.name==d)||n.push(typeof h=="string"?{name:d}:h)}},l=e.facet(y);for(let a of i)if(a.hasResult()){let h=a.result.getMatch;if(a.result.filter===!1)for(let d of a.result.options)s(new _(d,a.source,h?h(d):[],1e9-t.length));else{let d=e.sliceDoc(a.from,a.to),u,g=l.filterStrict?new ve(d):new Se(d);for(let b of a.result.options)if(u=g.match(b.label)){let D=b.displayLabel?h?h(b,u.matched):[]:u.matched,v=u.score+(b.boost||0);if(s(new _(b,a.source,D,v)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:m}=b.section;o||(o=Object.create(null)),o[m]=Math.max(v,o[m]||-1e9)}}}}if(n){let a=Object.create(null),h=0,d=(u,g)=>(u.rank==="dynamic"&&g.rank==="dynamic"?o[g.name]-o[u.name]:0)||(typeof u.rank=="number"?u.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(u.name<g.name?-1:1);for(let u of n.sort(d))h-=1e5,a[u.name]=h;for(let u of t){let{section:g}=u.completion;g&&(u.score+=a[typeof g=="string"?g:g.name])}}let c=[],r=null,p=l.compareCompletions;for(let a of t.sort((h,d)=>d.score-h.score||p(h.completion,d.completion))){let h=a.completion;!r||r.label!=h.label||r.detail!=h.detail||r.type!=null&&h.type!=null&&r.type!=h.type||r.apply!=h.apply||r.boost!=h.boost?c.push(a):ie(a.completion)>ie(r)&&(c[c.length-1]=a),r=a.completion}return c}class T{constructor(e,t,n,o,s,l){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=o,this.selected=s,this.disabled=l}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new T(this.options,ne(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,o,s,l){if(o&&!l&&e.some(p=>p.isPending))return o.setDisabled();let c=Oe(e,t);if(!c.length)return o&&e.some(p=>p.isPending)?o.setDisabled():null;let r=t.facet(y).selectOnOpen?0:-1;if(o&&o.selected!=r&&o.selected!=-1){let p=o.options[o.selected].completion;for(let a=0;a<c.length;a++)if(c[a].completion==p){r=a;break}}return new T(c,ne(n,r),{pos:e.reduce((p,a)=>a.hasResult()?Math.min(p,a.from):p,1e8),create:Be,above:s.aboveCursor},o?o.timestamp:Date.now(),r,!1)}map(e){return new T(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new T(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class z{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new z(Le,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(y),s=(n.override||t.languageDataAt("autocomplete",I(t)).map(we)).map(r=>(this.active.find(a=>a.source==r)||new w(r,this.active.some(a=>a.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((r,p)=>r==this.active[p])&&(s=this.active);let l=this.open,c=e.effects.some(r=>r.is(q));l&&e.docChanged&&(l=l.map(e.changes)),e.selection||s.some(r=>r.hasResult()&&e.changes.touchesRange(r.from,r.to))||!De(s,this.active)||c?l=T.build(s,t,this.id,l,n,c):l&&l.disabled&&!s.some(r=>r.isPending)&&(l=null),!l&&s.every(r=>!r.isPending)&&s.some(r=>r.hasResult())&&(s=s.map(r=>r.hasResult()?new w(r.source,0):r));for(let r of e.effects)r.is(K)&&(l=l&&l.setSelected(r.value,this.id));return s==this.active&&l==this.open?this:new z(s,this.id,l)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Re:Me}}function De(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let o=t==i.length,s=n==e.length;if(o||s)return o==s;if(i[t++].result!=e[n++].result)return!1}}const Re={"aria-autocomplete":"list"},Me={};function ne(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const Le=[];function fe(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(H);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class w{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=fe(e,t),o=this;(n&8||n&16&&this.touches(e))&&(o=new w(o.source,0)),n&4&&o.state==0&&(o=new w(this.source,1)),o=o.updateFor(e,n);for(let s of e.effects)if(s.is($))o=new w(o.source,1,s.value);else if(s.is(R))o=new w(o.source,0);else if(s.is(q))for(let l of s.value)l.source==o.source&&(o=l);return o}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(I(e.state))}}class A extends w{constructor(e,t,n,o,s,l){super(e,3,t),this.limit=n,this.result=o,this.from=s,this.to=l}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let o=this.result;o.map&&!e.changes.empty&&(o=o.map(o,e.changes));let s=e.changes.mapPos(this.from),l=e.changes.mapPos(this.to,1),c=I(e.state);if(c>l||!o||t&2&&(I(e.startState)==this.from||c<this.limit))return new w(this.source,t&4?1:0);let r=e.changes.mapPos(this.limit);return ke(o.validFor,e.state,s,l)?new A(this.source,this.explicit,r,o,s,l):o.update&&(o=o.update(o,s,l,new re(e.state,c,!1)))?new A(this.source,this.explicit,r,o,o.from,(n=o.to)!==null&&n!==void 0?n:I(e.state)):new w(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new A(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new w(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function ke(i,e,t,n){if(!i)return!1;let o=e.sliceDoc(t,n);return typeof i=="function"?i(o,t,n,e):ae(i,!0).test(o)}const q=f.StateEffect.define({map(i,e){return i.map(t=>t.map(e))}}),C=f.StateField.define({create(){return z.start()},update(i,e){return i.update(e)},provide:i=>[f.showTooltip.from(i,e=>e.tooltip),f.EditorView.contentAttributes.from(i,e=>e.attrs)]});function Q(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(C).active.find(o=>o.source==e.source);return n instanceof A?(typeof t=="string"?i.dispatch({...Ce(i.state,t,n.from,n.to),annotations:H.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const Be=Te(C,Q);function F(i,e="option"){return t=>{let n=t.state.field(C,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(y).interactionDelay)return!1;let o=1,s;e=="page"&&(s=f.getTooltip(t,n.open.tooltip))&&(o=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:l}=n.open.options,c=n.open.selected>-1?n.open.selected+o*(i?1:-1):i?0:l-1;return c<0?c=e=="page"?0:l-1:c>=l&&(c=e=="page"?l-1:0),t.dispatch({effects:K.of(c)}),!0}}const Fe=i=>{let e=i.state.field(C,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(y).interactionDelay?!1:Q(i,e.open.options[e.open.selected])},W=i=>i.state.field(C,!1)?(i.dispatch({effects:$.of(!0)}),!0):!1,$e=i=>{let e=i.state.field(C,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:R.of(null)}),!0)};class ze{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ne=50,Ve=1e3,Ue=f.ViewPlugin.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(C).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(C),t=i.state.facet(y);if(!i.selectionSet&&!i.docChanged&&i.startState.field(C)==e)return;let n=i.transactions.some(s=>{let l=fe(s,t);return l&8||(s.selection||s.docChanged)&&!(l&3)});for(let s=0;s<this.running.length;s++){let l=this.running[s];if(n||l.context.abortOnDocChange&&i.docChanged||l.updates.length+i.transactions.length>Ne&&Date.now()-l.time>Ve){for(let c of l.context.abortListeners)try{c()}catch(r){f.logException(this.view.state,r)}l.context.abortListeners=null,this.running.splice(s--,1)}else l.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(l=>l.is($)))&&(this.pendingStart=!0);let o=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(l=>l.active.source==s.source))?setTimeout(()=>this.startUpdate(),o):-1,this.composing!=0)for(let s of i.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(C);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(y).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=I(e),n=new re(e,t,i.explicit,this.view),o=new ze(i,n);this.running.push(o),Promise.resolve(i.source(n)).then(s=>{o.context.aborted||(o.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:R.of(null)}),f.logException(this.view.state,s)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(y).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(y),n=this.view.state.field(C);for(let o=0;o<this.running.length;o++){let s=this.running[o];if(s.done===void 0)continue;if(this.running.splice(o--,1),s.done){let c=I(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(c,s.done.from+(s.active.explicit?0:1)),p=new A(s.active.source,s.active.explicit,r,s.done,s.done.from,(i=s.done.to)!==null&&i!==void 0?i:c);for(let a of s.updates)p=p.update(a,t);if(p.hasResult()){e.push(p);continue}}let l=n.active.find(c=>c.source==s.active.source);if(l&&l.isPending)if(s.done==null){let c=new w(s.active.source,0);for(let r of s.updates)c=c.update(r,t);c.isPending||e.push(c)}else this.startQuery(l)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:q.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(C,!1);if(e&&e.tooltip&&this.view.state.facet(y).closeOnBlur){let t=e.open&&f.getTooltip(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:R.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$.of(!1)}),20),this.composing=0}}}),We=typeof navigator=="object"&&/Win/.test(navigator.platform),je=f.Prec.highest(f.EditorView.domEventHandlers({keydown(i,e){let t=e.state.field(C,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(We&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],o=t.active.find(l=>l.source==n.source),s=n.completion.commitCharacters||o.result.commitCharacters;return s&&s.indexOf(i.key)>-1&&Q(e,n),!1}})),he=f.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class He{constructor(e,t,n,o){this.field=e,this.line=t,this.from=n,this.to=o}}class Y{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,f.MapMode.TrackDel),n=e.mapPos(this.to,1,f.MapMode.TrackDel);return t==null||n==null?null:new Y(this.field,t,n)}}class X{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],o=[t],s=e.doc.lineAt(t),l=/^\s*/.exec(s.text)[0];for(let r of this.lines){if(n.length){let p=l,a=/^\t*/.exec(r)[0].length;for(let h=0;h<a;h++)p+=e.facet(f.indentUnit);o.push(t+p.length-a),r=p+r.slice(a)}n.push(r),t+=r.length+1}let c=this.fieldPositions.map(r=>new Y(r.field,o[r.line]+r.from,o[r.line]+r.to));return{text:n,ranges:c}}static parse(e){let t=[],n=[],o=[],s;for(let l of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(l);){let c=s[1]?+s[1]:null,r=s[2]||s[3]||"",p=-1,a=r.replace(/\\[{}]/g,h=>h[1]);for(let h=0;h<t.length;h++)(c!=null?t[h].seq==c:a&&t[h].name==a)&&(p=h);if(p<0){let h=0;for(;h<t.length&&(c==null||t[h].seq!=null&&t[h].seq<c);)h++;t.splice(h,0,{seq:c,name:a}),p=h;for(let d of o)d.field>=p&&d.field++}for(let h of o)if(h.line==n.length&&h.from>s.index){let d=s[2]?3+(s[1]||"").length:2;h.from-=d,h.to-=d}o.push(new He(p,n.length,s.index,s.index+a.length)),l=l.slice(0,s.index)+r+l.slice(s.index+s[0].length)}l=l.replace(/\\([{}])/g,(c,r,p)=>{for(let a of o)a.line==n.length&&a.from>p&&(a.from--,a.to--);return r}),n.push(l)}return new X(n,o)}}let Ke=f.Decoration.widget({widget:new class extends f.WidgetType{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),qe=f.Decoration.mark({class:"cm-snippetField"});class O{constructor(e,t){this.ranges=e,this.active=t,this.deco=f.Decoration.set(e.map(n=>(n.from==n.to?Ke:qe).range(n.from,n.to)),!0)}map(e){let t=[];for(let n of this.ranges){let o=n.map(e);if(!o)return null;t.push(o)}return new O(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}}const k=f.StateEffect.define({map(i,e){return i&&i.map(e)}}),Qe=f.StateEffect.define(),M=f.StateField.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is(k))return t.value;if(t.is(Qe)&&i)return new O(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>f.EditorView.decorations.from(i,e=>e?e.deco:f.Decoration.none)});function G(i,e){return f.EditorSelection.create(i.filter(t=>t.field==e).map(t=>f.EditorSelection.range(t.from,t.to)))}function Ye(i){let e=X.parse(i);return(t,n,o,s)=>{let{text:l,ranges:c}=e.instantiate(t.state,o),{main:r}=t.state.selection,p={changes:{from:o,to:s==r.from?r.to:s,insert:f.Text.of(l)},scrollIntoView:!0,annotations:n?[H.of(n),f.Transaction.userEvent.of("input.complete")]:void 0};if(c.length&&(p.selection=G(c,0)),c.some(a=>a.field>0)){let a=new O(c,0),h=p.effects=[k.of(a)];t.state.field(M,!1)===void 0&&h.push(f.StateEffect.appendConfig.of([M,_e,tt,he]))}t.dispatch(t.state.update(p))}}function pe(i){return({state:e,dispatch:t})=>{let n=e.field(M,!1);if(!n||i<0&&n.active==0)return!1;let o=n.active+i,s=i>0&&!n.ranges.some(l=>l.field==o+i);return t(e.update({selection:G(n.ranges,o),effects:k.of(s?null:new O(n.ranges,o)),scrollIntoView:!0})),!0}}const Xe=({state:i,dispatch:e})=>i.field(M,!1)?(e(i.update({effects:k.of(null)})),!0):!1,Ge=pe(1),Je=pe(-1),Ze=[{key:"Tab",run:Ge,shift:Je},{key:"Escape",run:Xe}],oe=f.Facet.define({combine(i){return i.length?i[0]:Ze}}),_e=f.Prec.highest(f.keymap.compute([oe],i=>i.facet(oe)));function et(i,e){return{...e,apply:Ye(i)}}const tt=f.EditorView.domEventHandlers({mousedown(i,e){let t=e.state.field(M,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let o=t.ranges.find(s=>s.from<=n&&s.to>=n);return!o||o.field==t.active?!1:(e.dispatch({selection:G(t.ranges,o.field),effects:k.of(t.ranges.some(s=>s.field>o.field)?new O(t.ranges,o.field):null),scrollIntoView:!0}),!0)}}),L={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},E=f.StateEffect.define({map(i,e){let t=e.mapPos(i,-1,f.MapMode.TrackAfter);return t??void 0}}),J=new class extends f.RangeValue{};J.startSide=1;J.endSide=-1;const de=f.StateField.define({create(){return f.RangeSet.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(E)&&(i=i.update({add:[J.range(t.value,t.value+1)]}));return i}});function it(){return[ot,de]}const j="()[]{}<>«»»«[]{}";function ue(i){for(let e=0;e<j.length;e+=2)if(j.charCodeAt(e)==i)return j.charAt(e+1);return f.fromCodePoint(i<128?i:i+1)}function me(i,e){return i.languageDataAt("closeBrackets",e)[0]||L}const nt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ot=f.EditorView.inputHandler.of((i,e,t,n)=>{if((nt?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let o=i.state.selection.main;if(n.length>2||n.length==2&&f.codePointSize(f.codePointAt(n,0))==1||e!=o.from||t!=o.to)return!1;let s=rt(i.state,n);return s?(i.dispatch(s),!0):!1}),st=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=me(i,i.selection.main.head).brackets||L.brackets,o=null,s=i.changeByRange(l=>{if(l.empty){let c=ct(i.doc,l.head);for(let r of n)if(r==c&&N(i.doc,l.head)==ue(f.codePointAt(r,0)))return{changes:{from:l.head-r.length,to:l.head+r.length},range:f.EditorSelection.cursor(l.head-r.length)}}return{range:o=l}});return o||e(i.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!o},lt=[{key:"Backspace",run:st}];function rt(i,e){let t=me(i,i.selection.main.head),n=t.brackets||L.brackets;for(let o of n){let s=ue(f.codePointAt(o,0));if(e==o)return s==o?ht(i,o,n.indexOf(o+o+o)>-1,t):at(i,o,s,t.before||L.before);if(e==s&&ge(i,i.selection.main.from))return ft(i,o,s)}return null}function ge(i,e){let t=!1;return i.field(de).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function N(i,e){let t=i.sliceString(e,e+2);return t.slice(0,f.codePointSize(f.codePointAt(t,0)))}function ct(i,e){let t=i.sliceString(e-2,e);return f.codePointSize(f.codePointAt(t,0))==t.length?t:t.slice(1)}function at(i,e,t,n){let o=null,s=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:t,from:l.to}],effects:E.of(l.to+e.length),range:f.EditorSelection.range(l.anchor+e.length,l.head+e.length)};let c=N(i.doc,l.head);return!c||/\s/.test(c)||n.indexOf(c)>-1?{changes:{insert:e+t,from:l.head},effects:E.of(l.head+e.length),range:f.EditorSelection.cursor(l.head+e.length)}:{range:o=l}});return o?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ft(i,e,t){let n=null,o=i.changeByRange(s=>s.empty&&N(i.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:f.EditorSelection.cursor(s.head+t.length)}:n={range:s});return n?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ht(i,e,t,n){let o=n.stringPrefixes||L.stringPrefixes,s=null,l=i.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:E.of(c.to+e.length),range:f.EditorSelection.range(c.anchor+e.length,c.head+e.length)};let r=c.head,p=N(i.doc,r),a;if(p==e){if(se(i,r))return{changes:{insert:e+e,from:r},effects:E.of(r+e.length),range:f.EditorSelection.cursor(r+e.length)};if(ge(i,r)){let d=t&&i.sliceDoc(r,r+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:r,to:r+d.length,insert:d},range:f.EditorSelection.cursor(r+d.length)}}}else{if(t&&i.sliceDoc(r-2*e.length,r)==e+e&&(a=le(i,r-2*e.length,o))>-1&&se(i,a))return{changes:{insert:e+e+e+e,from:r},effects:E.of(r+e.length),range:f.EditorSelection.cursor(r+e.length)};if(i.charCategorizer(r)(p)!=f.CharCategory.Word&&le(i,r,o)>-1&&!pt(i,r,e,o))return{changes:{insert:e+e,from:r},effects:E.of(r+e.length),range:f.EditorSelection.cursor(r+e.length)}}return{range:s=c}});return s?null:i.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function se(i,e){let t=f.syntaxTree(i).resolveInner(e+1);return t.parent&&t.from==e}function pt(i,e,t,n){let o=f.syntaxTree(i).resolveInner(e,-1),s=n.reduce((l,c)=>Math.max(l,c.length),0);for(let l=0;l<5;l++){let c=i.sliceDoc(o.from,Math.min(o.to,o.from+t.length+s)),r=c.indexOf(t);if(!r||r>-1&&n.indexOf(c.slice(0,r))>-1){let a=o.firstChild;for(;a&&a.from==o.from&&a.to-a.from>t.length+r;){if(i.sliceDoc(a.to-t.length,a.to)==t)return!1;a=a.firstChild}return!0}let p=o.to==e&&o.parent;if(!p)break;o=p}return!1}function le(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=f.CharCategory.Word)return e;for(let o of t){let s=e-o.length;if(i.sliceDoc(s,e)==o&&n(i.sliceDoc(s-1,s))!=f.CharCategory.Word)return s}return-1}function dt(i={}){return[je,C,y.of(i),Ue,ut,he]}const ye=[{key:"Ctrl-Space",run:W},{mac:"Alt-`",run:W},{mac:"Alt-i",run:W},{key:"Escape",run:$e},{key:"ArrowDown",run:F(!0)},{key:"ArrowUp",run:F(!1)},{key:"PageDown",run:F(!0,"page")},{key:"PageUp",run:F(!1,"page")},{key:"Enter",run:Fe}],ut=f.Prec.highest(f.keymap.computeN([y],i=>i.facet(y).defaultKeymap?[ye]:[]));exports.autocompletion=dt;exports.closeBrackets=it;exports.closeBracketsKeymap=lt;exports.completeFromList=ce;exports.completionKeymap=ye;exports.ifNotIn=xe;exports.snippetCompletion=et;