@pyscript/core 0.5.2 → 0.5.3-rc1

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 (33) hide show
  1. package/dist/{codemirror-D5H78LwF.js → codemirror-DP2LKuBT.js} +2 -2
  2. package/dist/{codemirror-D5H78LwF.js.map → codemirror-DP2LKuBT.js.map} +1 -1
  3. package/dist/{codemirror_commands-BS7VlXdv.js → codemirror_commands-Dtn37S2-.js} +2 -2
  4. package/dist/{codemirror_commands-BS7VlXdv.js.map → codemirror_commands-Dtn37S2-.js.map} +1 -1
  5. package/dist/{codemirror_lang-python-BNKMM3aS.js → codemirror_lang-python-CD-6L-Uh.js} +2 -2
  6. package/dist/{codemirror_lang-python-BNKMM3aS.js.map → codemirror_lang-python-CD-6L-Uh.js.map} +1 -1
  7. package/dist/{codemirror_language-CBQniB_I.js → codemirror_language-D6ce_yTr.js} +2 -2
  8. package/dist/{codemirror_language-CBQniB_I.js.map → codemirror_language-D6ce_yTr.js.map} +1 -1
  9. package/dist/codemirror_view-byykwGDe.js +2 -0
  10. package/dist/codemirror_view-byykwGDe.js.map +1 -0
  11. package/dist/core-CAHVPjK9.js +2 -0
  12. package/dist/core-CAHVPjK9.js.map +1 -0
  13. package/dist/core.js +1 -1
  14. package/dist/{deprecations-manager-7QcXHGFa.js → deprecations-manager-CeicOp-C.js} +2 -2
  15. package/dist/{deprecations-manager-7QcXHGFa.js.map → deprecations-manager-CeicOp-C.js.map} +1 -1
  16. package/dist/{error-TXLNLhiL.js → error-bhRxUJ0H.js} +2 -2
  17. package/dist/{error-TXLNLhiL.js.map → error-bhRxUJ0H.js.map} +1 -1
  18. package/dist/{index-CKVCnmMK.js → index-CdWlITxy.js} +2 -2
  19. package/dist/{index-CKVCnmMK.js.map → index-CdWlITxy.js.map} +1 -1
  20. package/dist/{mpy-Bk2Gn8sr.js → mpy-Cgg31iaC.js} +2 -2
  21. package/dist/{mpy-Bk2Gn8sr.js.map → mpy-Cgg31iaC.js.map} +1 -1
  22. package/dist/{py-LariLnuJ.js → py-D5PpdbCy.js} +2 -2
  23. package/dist/{py-LariLnuJ.js.map → py-D5PpdbCy.js.map} +1 -1
  24. package/dist/{py-editor-BiqntXFZ.js → py-editor-BDuee0vY.js} +2 -2
  25. package/dist/{py-editor-BiqntXFZ.js.map → py-editor-BDuee0vY.js.map} +1 -1
  26. package/dist/{py-terminal-Bb5ZeysW.js → py-terminal-BBpf7LFW.js} +2 -2
  27. package/dist/{py-terminal-Bb5ZeysW.js.map → py-terminal-BBpf7LFW.js.map} +1 -1
  28. package/package.json +3 -3
  29. package/src/core.js +7 -8
  30. package/dist/codemirror_view-BNvLVbLs.js +0 -2
  31. package/dist/codemirror_view-BNvLVbLs.js.map +0 -1
  32. package/dist/core-BWvprkAU.js +0 -2
  33. package/dist/core-BWvprkAU.js.map +0 -1
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- export{g as MPWorker,f as PyWorker,T as TYPES,h as config,e as hooks,i as inputFailure,o as offline_interpreter,b as optional,r as relative_url,s as stdlib,j as whenDefined}from"./core-BWvprkAU.js";
1
+ export{g as MPWorker,f as PyWorker,T as TYPES,h as config,e as hooks,i as inputFailure,o as offline_interpreter,b as optional,r as relative_url,s as stdlib,j as whenDefined}from"./core-CAHVPjK9.js";
2
2
  //# sourceMappingURL=core.js.map
@@ -1,2 +1,2 @@
1
- import{e}from"./core-BWvprkAU.js";import{notify as o}from"./error-TXLNLhiL.js";function r(){const e=document.querySelectorAll("script");for(const o of e)s(o.src)}function s(e){/\/pyscript\.net\/latest/.test(e)&&o("Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.")}e.main.onReady.add(r),e.main.onWorker.add(r);
2
- //# sourceMappingURL=deprecations-manager-7QcXHGFa.js.map
1
+ import{e}from"./core-CAHVPjK9.js";import{notify as o}from"./error-bhRxUJ0H.js";function r(){const e=document.querySelectorAll("script");for(const o of e)s(o.src)}function s(e){/\/pyscript\.net\/latest/.test(e)&&o("Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.")}e.main.onReady.add(r),e.main.onWorker.add(r);
2
+ //# sourceMappingURL=deprecations-manager-CeicOp-C.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deprecations-manager-7QcXHGFa.js","sources":["../src/plugins/deprecations-manager.js"],"sourcesContent":["// PyScript Derepcations Plugin\nimport { hooks } from \"../core.js\";\nimport { notify } from \"./error.js\";\n\n// react lazily on PyScript bootstrap\nhooks.main.onReady.add(checkDeprecations);\nhooks.main.onWorker.add(checkDeprecations);\n\n/**\n * Check that there are no scripts loading from pyscript.net/latest\n */\nfunction checkDeprecations() {\n const scripts = document.querySelectorAll(\"script\");\n for (const script of scripts) checkLoadingScriptsFromLatest(script.src);\n}\n\n/**\n * Check if src being loaded from pyscript.net/latest and display a notification if true\n * * @param {string} src\n */\nfunction checkLoadingScriptsFromLatest(src) {\n if (/\\/pyscript\\.net\\/latest/.test(src)) {\n notify(\n \"Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.\",\n );\n }\n}\n"],"names":["checkDeprecations","scripts","document","querySelectorAll","script","checkLoadingScriptsFromLatest","src","test","notify","hooks","main","onReady","add","onWorker"],"mappings":"+EAWA,SAASA,IACL,MAAMC,EAAUC,SAASC,iBAAiB,UAC1C,IAAK,MAAMC,KAAUH,EAASI,EAA8BD,EAAOE,IACvE,CAMA,SAASD,EAA8BC,GAC/B,0BAA0BC,KAAKD,IAC/BE,EACI,6GAGZ,CArBAC,EAAMC,KAAKC,QAAQC,IAAIZ,GACvBS,EAAMC,KAAKG,SAASD,IAAIZ"}
1
+ {"version":3,"file":"deprecations-manager-CeicOp-C.js","sources":["../src/plugins/deprecations-manager.js"],"sourcesContent":["// PyScript Derepcations Plugin\nimport { hooks } from \"../core.js\";\nimport { notify } from \"./error.js\";\n\n// react lazily on PyScript bootstrap\nhooks.main.onReady.add(checkDeprecations);\nhooks.main.onWorker.add(checkDeprecations);\n\n/**\n * Check that there are no scripts loading from pyscript.net/latest\n */\nfunction checkDeprecations() {\n const scripts = document.querySelectorAll(\"script\");\n for (const script of scripts) checkLoadingScriptsFromLatest(script.src);\n}\n\n/**\n * Check if src being loaded from pyscript.net/latest and display a notification if true\n * * @param {string} src\n */\nfunction checkLoadingScriptsFromLatest(src) {\n if (/\\/pyscript\\.net\\/latest/.test(src)) {\n notify(\n \"Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.\",\n );\n }\n}\n"],"names":["checkDeprecations","scripts","document","querySelectorAll","script","checkLoadingScriptsFromLatest","src","test","notify","hooks","main","onReady","add","onWorker"],"mappings":"+EAWA,SAASA,IACL,MAAMC,EAAUC,SAASC,iBAAiB,UAC1C,IAAK,MAAMC,KAAUH,EAASI,EAA8BD,EAAOE,IACvE,CAMA,SAASD,EAA8BC,GAC/B,0BAA0BC,KAAKD,IAC/BE,EACI,6GAGZ,CArBAC,EAAMC,KAAKC,QAAQC,IAAIZ,GACvBS,EAAMC,KAAKG,SAASD,IAAIZ"}
@@ -1,2 +1,2 @@
1
- import{e}from"./core-BWvprkAU.js";function n(e){const n=document.createElement("div");n.className="py-error",n.textContent=e,n.style.cssText="\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n ",document.body.append(n)}e.main.onReady.add((function o(r){e.main.onReady.delete(o);const{stderr:t}=r.io;r.io.stderr=(e,...o)=>(n(e.message||e),t(e,...o)),addEventListener("error",(({message:e})=>{e.startsWith("Uncaught PythonError")&&n(e)}))}));export{n as notify};
2
- //# sourceMappingURL=error-TXLNLhiL.js.map
1
+ import{e}from"./core-CAHVPjK9.js";function n(e){const n=document.createElement("div");n.className="py-error",n.textContent=e,n.style.cssText="\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n ",document.body.append(n)}e.main.onReady.add((function o(r){e.main.onReady.delete(o);const{stderr:t}=r.io;r.io.stderr=(e,...o)=>(n(e.message||e),t(e,...o)),addEventListener("error",(({message:e})=>{e.startsWith("Uncaught PythonError")&&n(e)}))}));export{n as notify};
2
+ //# sourceMappingURL=error-bhRxUJ0H.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-TXLNLhiL.js","sources":["../src/plugins/error.js"],"sourcesContent":["// PyScript Error Plugin\nimport { hooks } from \"../core.js\";\n\nhooks.main.onReady.add(function override(pyScript) {\n // be sure this override happens only once\n hooks.main.onReady.delete(override);\n\n // trap generic `stderr` to propagate to it regardless\n const { stderr } = pyScript.io;\n\n // override it with our own logic\n pyScript.io.stderr = (error, ...rest) => {\n notify(error.message || error);\n // let other plugins or stderr hook, if any, do the rest\n return stderr(error, ...rest);\n };\n\n // be sure uncaught Python errors are also visible\n addEventListener(\"error\", ({ message }) => {\n if (message.startsWith(\"Uncaught PythonError\")) notify(message);\n });\n});\n\n// Error hook utilities\n\n// Custom function to show notifications\n\n/**\n * Add a banner to the top of the page, notifying the user of an error\n * @param {string} message\n */\nexport function notify(message) {\n const div = document.createElement(\"div\");\n div.className = \"py-error\";\n div.textContent = message;\n div.style.cssText = `\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n `;\n document.body.append(div);\n}\n"],"names":["notify","message","div","document","createElement","className","textContent","style","cssText","body","append","hooks","main","onReady","add","override","pyScript","delete","stderr","io","error","rest","addEventListener","startsWith"],"mappings":"kCA+BO,SAASA,EAAOC,GACnB,MAAMC,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,WAChBH,EAAII,YAAcL,EAClBC,EAAIK,MAAMC,QAAU,6MAUpBL,SAASM,KAAKC,OAAOR,EACzB,CA3CAS,EAAMC,KAAKC,QAAQC,KAAI,SAASC,EAASC,GAErCL,EAAMC,KAAKC,QAAQI,OAAOF,GAG1B,MAAMG,OAAEA,GAAWF,EAASG,GAG5BH,EAASG,GAAGD,OAAS,CAACE,KAAUC,KAC5BrB,EAAOoB,EAAMnB,SAAWmB,GAEjBF,EAAOE,KAAUC,IAI5BC,iBAAiB,SAAS,EAAGrB,cACrBA,EAAQsB,WAAW,yBAAyBvB,EAAOC,EAAQ,GAEvE"}
1
+ {"version":3,"file":"error-bhRxUJ0H.js","sources":["../src/plugins/error.js"],"sourcesContent":["// PyScript Error Plugin\nimport { hooks } from \"../core.js\";\n\nhooks.main.onReady.add(function override(pyScript) {\n // be sure this override happens only once\n hooks.main.onReady.delete(override);\n\n // trap generic `stderr` to propagate to it regardless\n const { stderr } = pyScript.io;\n\n // override it with our own logic\n pyScript.io.stderr = (error, ...rest) => {\n notify(error.message || error);\n // let other plugins or stderr hook, if any, do the rest\n return stderr(error, ...rest);\n };\n\n // be sure uncaught Python errors are also visible\n addEventListener(\"error\", ({ message }) => {\n if (message.startsWith(\"Uncaught PythonError\")) notify(message);\n });\n});\n\n// Error hook utilities\n\n// Custom function to show notifications\n\n/**\n * Add a banner to the top of the page, notifying the user of an error\n * @param {string} message\n */\nexport function notify(message) {\n const div = document.createElement(\"div\");\n div.className = \"py-error\";\n div.textContent = message;\n div.style.cssText = `\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n `;\n document.body.append(div);\n}\n"],"names":["notify","message","div","document","createElement","className","textContent","style","cssText","body","append","hooks","main","onReady","add","override","pyScript","delete","stderr","io","error","rest","addEventListener","startsWith"],"mappings":"kCA+BO,SAASA,EAAOC,GACnB,MAAMC,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,WAChBH,EAAII,YAAcL,EAClBC,EAAIK,MAAMC,QAAU,6MAUpBL,SAASM,KAAKC,OAAOR,EACzB,CA3CAS,EAAMC,KAAKC,QAAQC,KAAI,SAASC,EAASC,GAErCL,EAAMC,KAAKC,QAAQI,OAAOF,GAG1B,MAAMG,OAAEA,GAAWF,EAASG,GAG5BH,EAASG,GAAGD,OAAS,CAACE,KAAUC,KAC5BrB,EAAOoB,EAAMnB,SAAWmB,GAEjBF,EAAOE,KAAUC,IAI5BC,iBAAiB,SAAS,EAAGrB,cACrBA,EAAQsB,WAAW,yBAAyBvB,EAAOC,EAAQ,GAEvE"}
@@ -1,2 +1,2 @@
1
- import{codePointSize as t,codePointAt as e,EditorSelection as n,CharCategory as o,Prec as i,Facet as s,combineConfig as l,StateField as r,StateEffect as a,MapMode as c,RangeValue as h,RangeSet as p,fromCodePoint as f,Annotation as u,Text as d,Transaction as m}from"./codemirror_state-D1qTXrff.js";import{E as g,k as v,D as b,s as w,g as y,V as x,l as C,a as I,W as O}from"./codemirror_view-BNvLVbLs.js";import{s as k,i as D}from"./codemirror_language-CBQniB_I.js";class T{constructor(t,e,n){this.state=t,this.pos=e,this.explicit=n,this.abortListeners=[]}tokenBefore(t){let e=k(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),o=e.text.slice(n-e.from,this.pos-e.from),i=o.search(P(t,!1));return i<0?null:{from:n+i,to:this.pos,text:o.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(t,e){"abort"==t&&this.abortListeners&&this.abortListeners.push(e)}}function S(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function A(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[n,o]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:o}of t){e[o[0]]=!0;for(let t=1;t<o.length;t++)n[o[t]]=!0}let o=S(e)+S(n)+"*$";return[new RegExp("^"+o),new RegExp(o)]}(e);return t=>{let i=t.matchBefore(o);return i||t.explicit?{from:i?i.from:t.pos,options:e,validFor:n}:null}}function E(t,e){return n=>{for(let e=k(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class L{constructor(t,e,n,o){this.completion=t,this.source=e,this.match=n,this.score=o}}function R(t){return t.selection.main.from}function P(t,e){var n;let{source:o}=t,i=e&&"^"!=o[0],s="$"!=o[o.length-1];return i||s?new RegExp(`${i?"^":""}(?:${o})${s?"$":""}`,null!==(n=t.flags)&&void 0!==n?n:t.ignoreCase?"i":""):t}const M=u.define();const B=new WeakMap;function j(t){if(!Array.isArray(t))return t;let e=B.get(t);return e||B.set(t,e=A(t)),e}const U=a.define(),$=a.define();class F{constructor(n){this.pattern=n,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let o=0;o<n.length;){let i=e(n,o),s=t(i);this.chars.push(i);let l=n.slice(o,o+s),r=l.toUpperCase();this.folded.push(e(r==l?l.toLowerCase():r,0)),o+=s}this.astral=n.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(n){if(0==this.pattern.length)return this.ret(-100,[]);if(n.length<this.pattern.length)return null;let{chars:o,folded:i,any:s,precise:l,byWord:r}=this;if(1==o.length){let s=e(n,0),l=t(s),r=l==n.length?0:-100;if(s==o[0]);else{if(s!=i[0])return null;r+=-200}return this.ret(r,[0,l])}let a=n.indexOf(this.pattern);if(0==a)return this.ret(n.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=o.length,h=0;if(a<0){for(let l=0,r=Math.min(n.length,200);l<r&&h<c;){let r=e(n,l);r!=o[h]&&r!=i[h]||(s[h++]=l),l+=t(r)}if(h<c)return null}let p=0,u=0,d=!1,m=0,g=-1,v=-1,b=/[a-z]/.test(n),w=!0;for(let s=0,h=Math.min(n.length,200),y=0;s<h&&u<c;){let h=e(n,s);a<0&&(p<c&&h==o[p]&&(l[p++]=s),m<c&&(h==o[m]||h==i[m]?(0==m&&(g=s),v=s+1,m++):m=0));let x,C=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(x=f(h))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!s||1==C&&b||0==y&&0!=C)&&(o[u]==h||i[u]==h&&(d=!0)?r[u++]=s:r.length&&(w=!1)),y=C,s+=t(h)}return u==c&&0==r[0]&&w?this.result((d?-200:0)-100,r,n):m==c&&0==g?this.ret(-200-n.length+(v==n.length?0:-100),[0,v]):a>-1?this.ret(-700-n.length,[a,a+this.pattern.length]):m==c?this.ret(-900-n.length,[g,v]):u==c?this.result((d?-200:0)-100-700+(w?0:-1100),r,n):2==o.length?null:this.result((s[0]?-700:0)-200-1100,s,n)}result(n,o,i){let s=[],l=0;for(let n of o){let o=n+(this.astral?t(e(i,n)):1);l&&s[l-1]==n?s[l-1]=o:(s[l++]=n,s[l++]=o)}return this.ret(n-i.length,s)}}class N{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}const W=s.define({combine:t=>l(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:H,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>q(t(n),e(n)),optionClass:(t,e)=>n=>q(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function q(t,e){return t?e?t+" "+e:t:e}function H(t,e,n,o,i,s){let l,r,a=t.textDirection==b.RTL,c=a,h=!1,p="top",f=e.left-i.left,u=i.right-e.right,d=o.right-o.left,m=o.bottom-o.top;if(c&&f<Math.min(d,u)?c=!1:!c&&u<Math.min(d,f)&&(c=!0),d<=(c?f:u))l=Math.max(i.top,Math.min(n.top,i.bottom-m))-e.top,r=Math.min(400,c?f:u);else{h=!0,r=Math.min(400,(a?e.right:i.right-e.left)-30);let t=i.bottom-e.bottom;t>=m||t>e.top?l=n.bottom-e.top:(p="bottom",l=e.bottom-n.top)}return{style:`${p}: ${l/((e.bottom-e.top)/s.offsetHeight)}px; max-width: ${r/((e.right-e.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(h?a?"left-narrow":"right-narrow":c?"left":"right")}}function V(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let o=Math.floor((t-e)/n);return{from:t-(o+1)*n,to:t-o*n}}class z{constructor(t,e,n){this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let o=t.state.field(e),{options:i,selected:s}=o.open,l=t.state.facet(W);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,n,o){let i=document.createElement("span");i.className="cm-completionLabel";let s=t.displayLabel||t.label,l=0;for(let t=0;t<o.length;){let e=o[t++],n=o[t++];e>l&&i.appendChild(document.createTextNode(s.slice(l,e)));let r=i.appendChild(document.createElement("span"));r.appendChild(document.createTextNode(s.slice(e,n))),r.className="cm-completionMatchedText",l=n}return l<s.length&&i.appendChild(document.createTextNode(s.slice(l))),i},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=V(i.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(n=>{let{options:o}=t.state.field(e).open;for(let e,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(e=/-(\d+)$/.exec(i.id))&&+e[1]<o.length)return this.applyCompletion(t,o[+e[1]]),void n.preventDefault()})),this.dom.addEventListener("focusout",(e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(W).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:$.of(null)})})),this.showOptions(i,o.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let n=t.state.field(this.stateField),o=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=o){let{options:i,selected:s,disabled:l}=n.open;o.open&&o.open.options==i||(this.range=V(i.length,s,t.state.facet(W).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),l!=(null===(e=o.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=V(e.options.length,e.selected,this.view.state.facet(W).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let i="string"==typeof o?document.createTextNode(o):o(n);if(!i)return;"then"in i?i.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>C(this.view.state,t,"completion info"))):this.addInfoPane(i,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:o}=t;n.appendChild(e),this.infoDestroy=o||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let n=this.list.firstChild,o=this.range.from;n;n=n.nextSibling,o++)"LI"==n.nodeName&&n.id?o==t?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),e=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):o--;return e&&function(t,e){let n=t.getBoundingClientRect(),o=e.getBoundingClientRect(),i=n.height/t.offsetHeight;o.top<n.top?t.scrollTop-=(n.top-o.top)/i:o.bottom>n.bottom&&(t.scrollTop+=(o.bottom-n.bottom)/i)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),o=t.getBoundingClientRect(),i=this.space;if(!i){let t=this.dom.ownerDocument.defaultView||window;i={left:0,top:0,right:t.innerWidth,bottom:t.innerHeight}}return o.top>Math.min(i.bottom,e.bottom)-10||o.bottom<Math.max(i.top,e.top)+10?null:this.view.state.facet(W).positionInfo(this.view,e,o,n,i,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,n){const o=document.createElement("ul");o.id=e,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions"));let i=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:r}=t[s],{section:a}=l;if(a){let t="string"==typeof a?a:a.name;if(t!=i&&(s>n.from||0==n.from))if(i=t,"string"!=typeof a&&a.header)o.appendChild(a.header(a));else{o.appendChild(document.createElement("completion-section")).textContent=t}}const c=o.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let t of this.optionContent){let e=t(l,this.view.state,this.view,r);e&&c.appendChild(e)}}return n.from&&o.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function K(t,e){return n=>new z(n,t,e)}function Q(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class _{constructor(t,e,n,o,i,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=o,this.selected=i,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new _(this.options,J(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,o,i){let s=function(t,e){let n=[],o=null,i=t=>{n.push(t);let{section:e}=t.completion;if(e){o||(o=[]);let t="string"==typeof e?e:e.name;o.some((e=>e.name==t))||o.push("string"==typeof e?{name:t}:e)}},s=e.facet(W);for(let o of t)if(o.hasResult()){let t=o.result.getMatch;if(!1===o.result.filter)for(let e of o.result.options)i(new L(e,o.source,t?t(e):[],1e9-n.length));else{let n,l=e.sliceDoc(o.from,o.to),r=s.filterStrict?new N(l):new F(l);for(let e of o.result.options)if(n=r.match(e.label)){let s=e.displayLabel?t?t(e,n.matched):[]:n.matched;i(new L(e,o.source,s,n.score+(e.boost||0)))}}}if(o){let t=Object.create(null),e=0,i=(t,e)=>{var n,o;return(null!==(n=t.rank)&&void 0!==n?n:1e9)-(null!==(o=e.rank)&&void 0!==o?o:1e9)||(t.name<e.name?-1:1)};for(let n of o.sort(i))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let l=[],r=null,a=s.compareCompletions;for(let t of n.sort(((t,e)=>e.score-t.score||a(t.completion,e.completion)))){let e=t.completion;!r||r.label!=e.label||r.detail!=e.detail||null!=r.type&&null!=e.type&&r.type!=e.type||r.apply!=e.apply||r.boost!=e.boost?l.push(t):Q(t.completion)>Q(r)&&(l[l.length-1]=t),r=t.completion}return l}(t,e);if(!s.length)return o&&t.some((t=>1==t.state))?new _(o.options,o.attrs,o.tooltip,o.timestamp,o.selected,!0):null;let l=e.facet(W).selectOnOpen?0:-1;if(o&&o.selected!=l&&-1!=o.selected){let t=o.options[o.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new _(s,J(n,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:rt,above:i.aboveCursor},o?o.timestamp:Date.now(),l,!1)}map(t){return new _(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class X{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new X(Z,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(W),o=(n.override||e.languageDataAt("autocomplete",R(e)).map(j)).map((e=>(this.active.find((t=>t.source==e))||new et(e,this.active.some((t=>0!=t.state))?1:0)).update(t,n)));o.length==this.active.length&&o.every(((t,e)=>t==this.active[e]))&&(o=this.active);let i=this.open;i&&t.docChanged&&(i=i.map(t.changes)),t.selection||o.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let n=0,o=0;;){for(;n<t.length&&!t[n].hasResult;)n++;for(;o<e.length&&!e[o].hasResult;)o++;let i=n==t.length,s=o==e.length;if(i||s)return i==s;if(t[n++].result!=e[o++].result)return!1}}(o,this.active)?i=_.build(o,e,this.id,i,n):i&&i.disabled&&!o.some((t=>1==t.state))&&(i=null),!i&&o.every((t=>1!=t.state))&&o.some((t=>t.hasResult()))&&(o=o.map((t=>t.hasResult()?new et(t.source,0):t)));for(let e of t.effects)e.is(it)&&(i=i&&i.setSelected(e.value,this.id));return o==this.active&&i==this.open?this:new X(o,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Y:G}}const Y={"aria-autocomplete":"list"},G={};function J(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Z=[];function tt(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(M);if(n&&e.activateOnCompletion(n))return"input"}return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class et{constructor(t,e,n=-1){this.source=t,this.state=e,this.explicitPos=n}hasResult(){return!1}update(t,e){let n=tt(t,e),o=this;n?o=o.handleUserEvent(t,n,e):t.docChanged?o=o.handleChange(t):t.selection&&0!=o.state&&(o=new et(o.source,0));for(let e of t.effects)if(e.is(U))o=new et(o.source,1,e.value?R(t.state):-1);else if(e.is($))o=new et(o.source,0);else if(e.is(ot))for(let t of e.value)t.source==o.source&&(o=t);return o}handleUserEvent(t,e,n){return"delete"!=e&&n.activateOnTyping?new et(this.source,1):this.map(t.changes)}handleChange(t){return t.changes.touchesRange(R(t.startState))?new et(this.source,0):this.map(t.changes)}map(t){return t.empty||this.explicitPos<0?this:new et(this.source,this.state,t.mapPos(this.explicitPos))}}class nt extends et{constructor(t,e,n,o,i){super(t,2,e),this.result=n,this.from=o,this.to=i}hasResult(){return!0}handleUserEvent(t,e,n){var o;let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let s=t.changes.mapPos(this.from),l=t.changes.mapPos(this.to,1),r=R(t.state);if((this.explicitPos<0?r<=s:r<this.from)||r>l||!i||"delete"==e&&R(t.startState)==this.from)return new et(this.source,"input"==e&&n.activateOnTyping?1:0);let a=this.explicitPos<0?-1:t.changes.mapPos(this.explicitPos);return function(t,e,n,o){if(!t)return!1;let i=e.sliceDoc(n,o);return"function"==typeof t?t(i,n,o,e):P(t,!0).test(i)}(i.validFor,t.state,s,l)?new nt(this.source,a,i,s,l):i.update&&(i=i.update(i,s,l,new T(t.state,r,a>=0)))?new nt(this.source,a,i,i.from,null!==(o=i.to)&&void 0!==o?o:R(t.state)):new et(this.source,1,a)}handleChange(t){return t.changes.touchesRange(this.from,this.to)?new et(this.source,0):this.map(t.changes)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new nt(this.source,this.explicitPos<0?-1:t.mapPos(this.explicitPos),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new et(this.source,0)}}const ot=a.define({map:(t,e)=>t.map((t=>t.map(e)))}),it=a.define(),st=r.define({create:()=>X.start(),update:(t,e)=>t.update(e),provide:t=>[w.from(t,(t=>t.tooltip)),g.contentAttributes.from(t,(t=>t.attrs))]});function lt(t,e){const o=e.completion.apply||e.completion.label;let i=t.state.field(st).active.find((t=>t.source==e.source));return i instanceof nt&&("string"==typeof o?t.dispatch(Object.assign(Object.assign({},function(t,e,o,i){let{main:s}=t.selection,l=o-s.from,r=i-s.from;return Object.assign(Object.assign({},t.changeByRange((a=>a!=s&&o!=i&&t.sliceDoc(a.from+l,a.from+r)!=t.sliceDoc(o,i)?{range:a}:{changes:{from:a.from+l,to:i==s.from?a.to:a.from+r,insert:e},range:n.cursor(a.from+l+e.length)}))),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,o,i.from,i.to)),{annotations:M.of(e.completion)})):o(t,e.completion,i.from,i.to),!0)}const rt=K(st,lt);function at(t,e="option"){return n=>{let o=n.state.field(st,!1);if(!o||!o.open||o.open.disabled||Date.now()-o.open.timestamp<n.state.facet(W).interactionDelay)return!1;let i,s=1;"page"==e&&(i=y(n,o.open.tooltip))&&(s=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:l}=o.open.options,r=o.open.selected>-1?o.open.selected+s*(t?1:-1):t?0:l-1;return r<0?r="page"==e?0:l-1:r>=l&&(r="page"==e?l-1:0),n.dispatch({effects:it.of(r)}),!0}}class ct{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const ht=x.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(st).active)1==e.state&&this.startQuery(e)}update(t){let e=t.state.field(st),n=t.state.facet(W);if(!t.selectionSet&&!t.docChanged&&t.startState.field(st)==e)return;let o=t.transactions.some((t=>(t.selection||t.docChanged)&&!tt(t,n)));for(let e=0;e<this.running.length;e++){let n=this.running[e];if(o||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){C(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(U)))))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>1==t.state&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),i):-1,0!=this.composing)for(let e of t.transactions)"input"==tt(e,n)?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(st);for(let t of e.active)1!=t.state||this.running.some((e=>e.active.source==t.source))||this.startQuery(t)}startQuery(t){let{state:e}=this.view,n=R(e),o=new T(e,n,t.explicitPos==n),i=new ct(t,o);this.running.push(i),Promise.resolve(t.source(o)).then((t=>{i.context.aborted||(i.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:$.of(null)}),C(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(W).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(W);for(let o=0;o<this.running.length;o++){let i=this.running[o];if(void 0===i.done)continue;if(this.running.splice(o--,1),i.done){let o=new nt(i.active.source,i.active.explicitPos,i.done,i.done.from,null!==(t=i.done.to)&&void 0!==t?t:R(i.updates.length?i.updates[0].startState:this.view.state));for(let t of i.updates)o=o.update(t,n);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(st).active.find((t=>t.source==i.active.source));if(s&&1==s.state)if(null==i.done){let t=new et(i.active.source,0);for(let e of i.updates)t=t.update(e,n);1!=t.state&&e.push(t)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:ot.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(st,!1);if(e&&e.tooltip&&this.view.state.facet(W).closeOnBlur){let n=e.open&&y(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:$.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:U.of(!1)})),20),this.composing=0}}}),pt="object"==typeof navigator&&/Win/.test(navigator.platform),ft=i.highest(g.domEventHandlers({keydown(t,e){let n=e.state.field(st,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&(!pt||!t.altKey)||t.metaKey)return!1;let o=n.open.options[n.open.selected],i=n.active.find((t=>t.source==o.source)),s=o.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&lt(e,o),!1}})),ut=g.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"},".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 dt{constructor(t,e,n,o){this.field=t,this.line=e,this.from=n,this.to=o}}class mt{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,c.TrackDel),n=t.mapPos(this.to,1,c.TrackDel);return null==e||null==n?null:new mt(this.field,e,n)}}class gt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],o=[e],i=t.doc.lineAt(e),s=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=s,l=/^\t*/.exec(i)[0].length;for(let e=0;e<l;e++)n+=t.facet(D);o.push(e+n.length-l),i=n+i.slice(l)}n.push(i),e+=i.length+1}let l=this.fieldPositions.map((t=>new mt(t.field,o[t.line]+t.from,o[t.line]+t.to)));return{text:n,ranges:l}}static parse(t){let e,n=[],o=[],i=[];for(let s of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=e[1]?+e[1]:null,l=e[2]||e[3]||"",r=-1,a=l.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<n.length;e++)(null!=t?n[e].seq==t:a&&n[e].name==a)&&(r=e);if(r<0){let e=0;for(;e<n.length&&(null==t||null!=n[e].seq&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:a}),r=e;for(let t of i)t.field>=r&&t.field++}i.push(new dt(r,o.length,e.index,e.index+a.length)),s=s.slice(0,e.index)+l+s.slice(e.index+e[0].length)}s=s.replace(/\\([{}])/g,((t,e,n)=>{for(let t of i)t.line==o.length&&t.from>n&&(t.from--,t.to--);return e})),o.push(s)}return new gt(o,i)}}let vt=I.widget({widget:new class extends O{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),bt=I.mark({class:"cm-snippetField"});class wt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?vt:bt).range(t.from,t.to))))}map(t){let e=[];for(let n of this.ranges){let o=n.map(t);if(!o)return null;e.push(o)}return new wt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const yt=a.define({map:(t,e)=>t&&t.map(e)}),xt=a.define(),Ct=r.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(yt))return n.value;if(n.is(xt)&&t)return new wt(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>g.decorations.from(t,(t=>t?t.deco:I.none))});function It(t,e){return n.create(t.filter((t=>t.field==e)).map((t=>n.range(t.from,t.to))))}function Ot(t){let e=gt.parse(t);return(t,n,o,i)=>{let{text:s,ranges:l}=e.instantiate(t.state,o),r={changes:{from:o,to:i,insert:d.of(s)},scrollIntoView:!0,annotations:n?[M.of(n),m.userEvent.of("input.complete")]:void 0};if(l.length&&(r.selection=It(l,0)),l.some((t=>t.field>0))){let e=new wt(l,0),n=r.effects=[yt.of(e)];void 0===t.state.field(Ct,!1)&&n.push(a.appendConfig.of([Ct,St,Et,ut]))}t.dispatch(t.state.update(r))}}function kt(t){return({state:e,dispatch:n})=>{let o=e.field(Ct,!1);if(!o||t<0&&0==o.active)return!1;let i=o.active+t,s=t>0&&!o.ranges.some((e=>e.field==i+t));return n(e.update({selection:It(o.ranges,i),effects:yt.of(s?null:new wt(o.ranges,i)),scrollIntoView:!0})),!0}}const Dt=[{key:"Tab",run:kt(1),shift:kt(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(Ct,!1)&&(e(t.update({effects:yt.of(null)})),!0)}],Tt=s.define({combine:t=>t.length?t[0]:Dt}),St=i.highest(v.compute([Tt],(t=>t.facet(Tt))));function At(t,e){return Object.assign(Object.assign({},e),{apply:Ot(t)})}const Et=g.domEventHandlers({mousedown(t,e){let n,o=e.state.field(Ct,!1);if(!o||null==(n=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let i=o.ranges.find((t=>t.from<=n&&t.to>=n));return!(!i||i.field==o.active)&&(e.dispatch({selection:It(o.ranges,i.field),effects:yt.of(o.ranges.some((t=>t.field>i.field))?new wt(o.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Lt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Rt=a.define({map(t,e){let n=e.mapPos(t,-1,c.TrackAfter);return null==n?void 0:n}}),Pt=new class extends h{};Pt.startSide=1,Pt.endSide=-1;const Mt=r.define({create:()=>p.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(Rt)&&(t=t.update({add:[Pt.range(n.value,n.value+1)]}));return t}});function Bt(){return[Nt,Mt]}const jt="()[]{}<>";function Ut(t){for(let e=0;e<jt.length;e+=2)if(jt.charCodeAt(e)==t)return jt.charAt(e+1);return f(t<128?t:t+1)}function $t(t,e){return t.languageDataAt("closeBrackets",e)[0]||Lt}const Ft="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Nt=g.inputHandler.of(((n,o,i,s)=>{if((Ft?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let l=n.state.selection.main;if(s.length>2||2==s.length&&1==t(e(s,0))||o!=l.from||i!=l.to)return!1;let r=function(t,n){let o=$t(t,t.selection.main.head),i=o.brackets||Lt.brackets;for(let s of i){let l=Ut(e(s,0));if(n==s)return l==s?Kt(t,s,i.indexOf(s+s+s)>-1,o):Vt(t,s,l,o.before||Lt.before);if(n==l&&qt(t,t.selection.main.from))return zt(t,s,l)}return null}(n.state,s);return!!r&&(n.dispatch(r),!0)})),Wt=[{key:"Backspace",run:({state:o,dispatch:i})=>{if(o.readOnly)return!1;let s=$t(o,o.selection.main.head).brackets||Lt.brackets,l=null,r=o.changeByRange((i=>{if(i.empty){let l=function(n,o){let i=n.sliceString(o-2,o);return t(e(i,0))==i.length?i:i.slice(1)}(o.doc,i.head);for(let t of s)if(t==l&&Ht(o.doc,i.head)==Ut(e(t,0)))return{changes:{from:i.head-t.length,to:i.head+t.length},range:n.cursor(i.head-t.length)}}return{range:l=i}}));return l||i(o.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!l}}];function qt(t,e){let n=!1;return t.field(Mt).between(0,t.doc.length,(t=>{t==e&&(n=!0)})),n}function Ht(n,o){let i=n.sliceString(o,o+2);return i.slice(0,t(e(i,0)))}function Vt(t,e,o,i){let s=null,l=t.changeByRange((l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:o,from:l.to}],effects:Rt.of(l.to+e.length),range:n.range(l.anchor+e.length,l.head+e.length)};let r=Ht(t.doc,l.head);return!r||/\s/.test(r)||i.indexOf(r)>-1?{changes:{insert:e+o,from:l.head},effects:Rt.of(l.head+e.length),range:n.cursor(l.head+e.length)}:{range:s=l}}));return s?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function zt(t,e,o){let i=null,s=t.changeByRange((e=>e.empty&&Ht(t.doc,e.head)==o?{changes:{from:e.head,to:e.head+o.length,insert:o},range:n.cursor(e.head+o.length)}:i={range:e}));return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Kt(t,e,i,s){let l=s.stringPrefixes||Lt.stringPrefixes,r=null,a=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:e,from:s.to}],effects:Rt.of(s.to+e.length),range:n.range(s.anchor+e.length,s.head+e.length)};let a,c=s.head,h=Ht(t.doc,c);if(h==e){if(Qt(t,c))return{changes:{insert:e+e,from:c},effects:Rt.of(c+e.length),range:n.cursor(c+e.length)};if(qt(t,c)){let o=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+o.length,insert:o},range:n.cursor(c+o.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(a=_t(t,c-2*e.length,l))>-1&&Qt(t,a))return{changes:{insert:e+e+e+e,from:c},effects:Rt.of(c+e.length),range:n.cursor(c+e.length)};if(t.charCategorizer(c)(h)!=o.Word&&_t(t,c,l)>-1&&!function(t,e,n,o){let i=k(t).resolveInner(e,-1),s=o.reduce(((t,e)=>Math.max(t,e.length)),0);for(let l=0;l<5;l++){let l=t.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),r=l.indexOf(n);if(!r||r>-1&&o.indexOf(l.slice(0,r))>-1){let e=i.firstChild;for(;e&&e.from==i.from&&e.to-e.from>n.length+r;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let a=i.to==e&&i.parent;if(!a)break;i=a}return!1}(t,c,e,l))return{changes:{insert:e+e,from:c},effects:Rt.of(c+e.length),range:n.cursor(c+e.length)}}return{range:r=s}}));return r?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Qt(t,e){let n=k(t).resolveInner(e+1);return n.parent&&n.from==e}function _t(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=o.Word)return e;for(let s of n){let n=e-s.length;if(t.sliceDoc(n,e)==s&&i(t.sliceDoc(n-1,n))!=o.Word)return n}return-1}function Xt(t={}){return[ft,st,W.of(t),ht,Gt,ut]}const Yt=[{key:"Ctrl-Space",run:t=>!!t.state.field(st,!1)&&(t.dispatch({effects:U.of(!0)}),!0)},{key:"Escape",run:t=>{let e=t.state.field(st,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:$.of(null)}),!0)}},{key:"ArrowDown",run:at(!0)},{key:"ArrowUp",run:at(!1)},{key:"PageDown",run:at(!0,"page")},{key:"PageUp",run:at(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(st,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(W).interactionDelay)&&lt(t,e.open.options[e.open.selected])}}],Gt=i.highest(v.computeN([W],(t=>t.facet(W).defaultKeymap?[Yt]:[])));export{Bt as a,Xt as b,A as c,Wt as d,Yt as e,E as i,At as s};
2
- //# sourceMappingURL=index-CKVCnmMK.js.map
1
+ import{codePointSize as t,codePointAt as e,EditorSelection as n,CharCategory as o,Prec as i,Facet as s,combineConfig as l,StateField as r,StateEffect as a,MapMode as c,RangeValue as h,RangeSet as p,fromCodePoint as f,Annotation as u,Text as d,Transaction as m}from"./codemirror_state-D1qTXrff.js";import{E as g,k as v,D as b,s as w,g as y,V as x,l as C,a as I,W as O}from"./codemirror_view-byykwGDe.js";import{s as k,i as D}from"./codemirror_language-D6ce_yTr.js";class T{constructor(t,e,n){this.state=t,this.pos=e,this.explicit=n,this.abortListeners=[]}tokenBefore(t){let e=k(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),o=e.text.slice(n-e.from,this.pos-e.from),i=o.search(P(t,!1));return i<0?null:{from:n+i,to:this.pos,text:o.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(t,e){"abort"==t&&this.abortListeners&&this.abortListeners.push(e)}}function S(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function A(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[n,o]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:o}of t){e[o[0]]=!0;for(let t=1;t<o.length;t++)n[o[t]]=!0}let o=S(e)+S(n)+"*$";return[new RegExp("^"+o),new RegExp(o)]}(e);return t=>{let i=t.matchBefore(o);return i||t.explicit?{from:i?i.from:t.pos,options:e,validFor:n}:null}}function E(t,e){return n=>{for(let e=k(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class L{constructor(t,e,n,o){this.completion=t,this.source=e,this.match=n,this.score=o}}function R(t){return t.selection.main.from}function P(t,e){var n;let{source:o}=t,i=e&&"^"!=o[0],s="$"!=o[o.length-1];return i||s?new RegExp(`${i?"^":""}(?:${o})${s?"$":""}`,null!==(n=t.flags)&&void 0!==n?n:t.ignoreCase?"i":""):t}const M=u.define();const B=new WeakMap;function j(t){if(!Array.isArray(t))return t;let e=B.get(t);return e||B.set(t,e=A(t)),e}const U=a.define(),$=a.define();class F{constructor(n){this.pattern=n,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let o=0;o<n.length;){let i=e(n,o),s=t(i);this.chars.push(i);let l=n.slice(o,o+s),r=l.toUpperCase();this.folded.push(e(r==l?l.toLowerCase():r,0)),o+=s}this.astral=n.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(n){if(0==this.pattern.length)return this.ret(-100,[]);if(n.length<this.pattern.length)return null;let{chars:o,folded:i,any:s,precise:l,byWord:r}=this;if(1==o.length){let s=e(n,0),l=t(s),r=l==n.length?0:-100;if(s==o[0]);else{if(s!=i[0])return null;r+=-200}return this.ret(r,[0,l])}let a=n.indexOf(this.pattern);if(0==a)return this.ret(n.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=o.length,h=0;if(a<0){for(let l=0,r=Math.min(n.length,200);l<r&&h<c;){let r=e(n,l);r!=o[h]&&r!=i[h]||(s[h++]=l),l+=t(r)}if(h<c)return null}let p=0,u=0,d=!1,m=0,g=-1,v=-1,b=/[a-z]/.test(n),w=!0;for(let s=0,h=Math.min(n.length,200),y=0;s<h&&u<c;){let h=e(n,s);a<0&&(p<c&&h==o[p]&&(l[p++]=s),m<c&&(h==o[m]||h==i[m]?(0==m&&(g=s),v=s+1,m++):m=0));let x,C=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(x=f(h))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!s||1==C&&b||0==y&&0!=C)&&(o[u]==h||i[u]==h&&(d=!0)?r[u++]=s:r.length&&(w=!1)),y=C,s+=t(h)}return u==c&&0==r[0]&&w?this.result((d?-200:0)-100,r,n):m==c&&0==g?this.ret(-200-n.length+(v==n.length?0:-100),[0,v]):a>-1?this.ret(-700-n.length,[a,a+this.pattern.length]):m==c?this.ret(-900-n.length,[g,v]):u==c?this.result((d?-200:0)-100-700+(w?0:-1100),r,n):2==o.length?null:this.result((s[0]?-700:0)-200-1100,s,n)}result(n,o,i){let s=[],l=0;for(let n of o){let o=n+(this.astral?t(e(i,n)):1);l&&s[l-1]==n?s[l-1]=o:(s[l++]=n,s[l++]=o)}return this.ret(n-i.length,s)}}class N{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}const W=s.define({combine:t=>l(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:H,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>q(t(n),e(n)),optionClass:(t,e)=>n=>q(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function q(t,e){return t?e?t+" "+e:t:e}function H(t,e,n,o,i,s){let l,r,a=t.textDirection==b.RTL,c=a,h=!1,p="top",f=e.left-i.left,u=i.right-e.right,d=o.right-o.left,m=o.bottom-o.top;if(c&&f<Math.min(d,u)?c=!1:!c&&u<Math.min(d,f)&&(c=!0),d<=(c?f:u))l=Math.max(i.top,Math.min(n.top,i.bottom-m))-e.top,r=Math.min(400,c?f:u);else{h=!0,r=Math.min(400,(a?e.right:i.right-e.left)-30);let t=i.bottom-e.bottom;t>=m||t>e.top?l=n.bottom-e.top:(p="bottom",l=e.bottom-n.top)}return{style:`${p}: ${l/((e.bottom-e.top)/s.offsetHeight)}px; max-width: ${r/((e.right-e.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(h?a?"left-narrow":"right-narrow":c?"left":"right")}}function V(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let o=Math.floor((t-e)/n);return{from:t-(o+1)*n,to:t-o*n}}class z{constructor(t,e,n){this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let o=t.state.field(e),{options:i,selected:s}=o.open,l=t.state.facet(W);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,n,o){let i=document.createElement("span");i.className="cm-completionLabel";let s=t.displayLabel||t.label,l=0;for(let t=0;t<o.length;){let e=o[t++],n=o[t++];e>l&&i.appendChild(document.createTextNode(s.slice(l,e)));let r=i.appendChild(document.createElement("span"));r.appendChild(document.createTextNode(s.slice(e,n))),r.className="cm-completionMatchedText",l=n}return l<s.length&&i.appendChild(document.createTextNode(s.slice(l))),i},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=V(i.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(n=>{let{options:o}=t.state.field(e).open;for(let e,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(e=/-(\d+)$/.exec(i.id))&&+e[1]<o.length)return this.applyCompletion(t,o[+e[1]]),void n.preventDefault()})),this.dom.addEventListener("focusout",(e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(W).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:$.of(null)})})),this.showOptions(i,o.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let n=t.state.field(this.stateField),o=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=o){let{options:i,selected:s,disabled:l}=n.open;o.open&&o.open.options==i||(this.range=V(i.length,s,t.state.facet(W).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),l!=(null===(e=o.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=V(e.options.length,e.selected,this.view.state.facet(W).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let i="string"==typeof o?document.createTextNode(o):o(n);if(!i)return;"then"in i?i.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>C(this.view.state,t,"completion info"))):this.addInfoPane(i,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:o}=t;n.appendChild(e),this.infoDestroy=o||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let n=this.list.firstChild,o=this.range.from;n;n=n.nextSibling,o++)"LI"==n.nodeName&&n.id?o==t?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),e=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):o--;return e&&function(t,e){let n=t.getBoundingClientRect(),o=e.getBoundingClientRect(),i=n.height/t.offsetHeight;o.top<n.top?t.scrollTop-=(n.top-o.top)/i:o.bottom>n.bottom&&(t.scrollTop+=(o.bottom-n.bottom)/i)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),o=t.getBoundingClientRect(),i=this.space;if(!i){let t=this.dom.ownerDocument.defaultView||window;i={left:0,top:0,right:t.innerWidth,bottom:t.innerHeight}}return o.top>Math.min(i.bottom,e.bottom)-10||o.bottom<Math.max(i.top,e.top)+10?null:this.view.state.facet(W).positionInfo(this.view,e,o,n,i,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,n){const o=document.createElement("ul");o.id=e,o.setAttribute("role","listbox"),o.setAttribute("aria-expanded","true"),o.setAttribute("aria-label",this.view.state.phrase("Completions"));let i=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:r}=t[s],{section:a}=l;if(a){let t="string"==typeof a?a:a.name;if(t!=i&&(s>n.from||0==n.from))if(i=t,"string"!=typeof a&&a.header)o.appendChild(a.header(a));else{o.appendChild(document.createElement("completion-section")).textContent=t}}const c=o.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let t of this.optionContent){let e=t(l,this.view.state,this.view,r);e&&c.appendChild(e)}}return n.from&&o.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&o.classList.add("cm-completionListIncompleteBottom"),o}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function K(t,e){return n=>new z(n,t,e)}function Q(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class _{constructor(t,e,n,o,i,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=o,this.selected=i,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new _(this.options,J(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,o,i){let s=function(t,e){let n=[],o=null,i=t=>{n.push(t);let{section:e}=t.completion;if(e){o||(o=[]);let t="string"==typeof e?e:e.name;o.some((e=>e.name==t))||o.push("string"==typeof e?{name:t}:e)}},s=e.facet(W);for(let o of t)if(o.hasResult()){let t=o.result.getMatch;if(!1===o.result.filter)for(let e of o.result.options)i(new L(e,o.source,t?t(e):[],1e9-n.length));else{let n,l=e.sliceDoc(o.from,o.to),r=s.filterStrict?new N(l):new F(l);for(let e of o.result.options)if(n=r.match(e.label)){let s=e.displayLabel?t?t(e,n.matched):[]:n.matched;i(new L(e,o.source,s,n.score+(e.boost||0)))}}}if(o){let t=Object.create(null),e=0,i=(t,e)=>{var n,o;return(null!==(n=t.rank)&&void 0!==n?n:1e9)-(null!==(o=e.rank)&&void 0!==o?o:1e9)||(t.name<e.name?-1:1)};for(let n of o.sort(i))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let l=[],r=null,a=s.compareCompletions;for(let t of n.sort(((t,e)=>e.score-t.score||a(t.completion,e.completion)))){let e=t.completion;!r||r.label!=e.label||r.detail!=e.detail||null!=r.type&&null!=e.type&&r.type!=e.type||r.apply!=e.apply||r.boost!=e.boost?l.push(t):Q(t.completion)>Q(r)&&(l[l.length-1]=t),r=t.completion}return l}(t,e);if(!s.length)return o&&t.some((t=>1==t.state))?new _(o.options,o.attrs,o.tooltip,o.timestamp,o.selected,!0):null;let l=e.facet(W).selectOnOpen?0:-1;if(o&&o.selected!=l&&-1!=o.selected){let t=o.options[o.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new _(s,J(n,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:rt,above:i.aboveCursor},o?o.timestamp:Date.now(),l,!1)}map(t){return new _(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class X{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new X(Z,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(W),o=(n.override||e.languageDataAt("autocomplete",R(e)).map(j)).map((e=>(this.active.find((t=>t.source==e))||new et(e,this.active.some((t=>0!=t.state))?1:0)).update(t,n)));o.length==this.active.length&&o.every(((t,e)=>t==this.active[e]))&&(o=this.active);let i=this.open;i&&t.docChanged&&(i=i.map(t.changes)),t.selection||o.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let n=0,o=0;;){for(;n<t.length&&!t[n].hasResult;)n++;for(;o<e.length&&!e[o].hasResult;)o++;let i=n==t.length,s=o==e.length;if(i||s)return i==s;if(t[n++].result!=e[o++].result)return!1}}(o,this.active)?i=_.build(o,e,this.id,i,n):i&&i.disabled&&!o.some((t=>1==t.state))&&(i=null),!i&&o.every((t=>1!=t.state))&&o.some((t=>t.hasResult()))&&(o=o.map((t=>t.hasResult()?new et(t.source,0):t)));for(let e of t.effects)e.is(it)&&(i=i&&i.setSelected(e.value,this.id));return o==this.active&&i==this.open?this:new X(o,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Y:G}}const Y={"aria-autocomplete":"list"},G={};function J(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Z=[];function tt(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(M);if(n&&e.activateOnCompletion(n))return"input"}return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class et{constructor(t,e,n=-1){this.source=t,this.state=e,this.explicitPos=n}hasResult(){return!1}update(t,e){let n=tt(t,e),o=this;n?o=o.handleUserEvent(t,n,e):t.docChanged?o=o.handleChange(t):t.selection&&0!=o.state&&(o=new et(o.source,0));for(let e of t.effects)if(e.is(U))o=new et(o.source,1,e.value?R(t.state):-1);else if(e.is($))o=new et(o.source,0);else if(e.is(ot))for(let t of e.value)t.source==o.source&&(o=t);return o}handleUserEvent(t,e,n){return"delete"!=e&&n.activateOnTyping?new et(this.source,1):this.map(t.changes)}handleChange(t){return t.changes.touchesRange(R(t.startState))?new et(this.source,0):this.map(t.changes)}map(t){return t.empty||this.explicitPos<0?this:new et(this.source,this.state,t.mapPos(this.explicitPos))}}class nt extends et{constructor(t,e,n,o,i){super(t,2,e),this.result=n,this.from=o,this.to=i}hasResult(){return!0}handleUserEvent(t,e,n){var o;let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let s=t.changes.mapPos(this.from),l=t.changes.mapPos(this.to,1),r=R(t.state);if((this.explicitPos<0?r<=s:r<this.from)||r>l||!i||"delete"==e&&R(t.startState)==this.from)return new et(this.source,"input"==e&&n.activateOnTyping?1:0);let a=this.explicitPos<0?-1:t.changes.mapPos(this.explicitPos);return function(t,e,n,o){if(!t)return!1;let i=e.sliceDoc(n,o);return"function"==typeof t?t(i,n,o,e):P(t,!0).test(i)}(i.validFor,t.state,s,l)?new nt(this.source,a,i,s,l):i.update&&(i=i.update(i,s,l,new T(t.state,r,a>=0)))?new nt(this.source,a,i,i.from,null!==(o=i.to)&&void 0!==o?o:R(t.state)):new et(this.source,1,a)}handleChange(t){return t.changes.touchesRange(this.from,this.to)?new et(this.source,0):this.map(t.changes)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new nt(this.source,this.explicitPos<0?-1:t.mapPos(this.explicitPos),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new et(this.source,0)}}const ot=a.define({map:(t,e)=>t.map((t=>t.map(e)))}),it=a.define(),st=r.define({create:()=>X.start(),update:(t,e)=>t.update(e),provide:t=>[w.from(t,(t=>t.tooltip)),g.contentAttributes.from(t,(t=>t.attrs))]});function lt(t,e){const o=e.completion.apply||e.completion.label;let i=t.state.field(st).active.find((t=>t.source==e.source));return i instanceof nt&&("string"==typeof o?t.dispatch(Object.assign(Object.assign({},function(t,e,o,i){let{main:s}=t.selection,l=o-s.from,r=i-s.from;return Object.assign(Object.assign({},t.changeByRange((a=>a!=s&&o!=i&&t.sliceDoc(a.from+l,a.from+r)!=t.sliceDoc(o,i)?{range:a}:{changes:{from:a.from+l,to:i==s.from?a.to:a.from+r,insert:e},range:n.cursor(a.from+l+e.length)}))),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,o,i.from,i.to)),{annotations:M.of(e.completion)})):o(t,e.completion,i.from,i.to),!0)}const rt=K(st,lt);function at(t,e="option"){return n=>{let o=n.state.field(st,!1);if(!o||!o.open||o.open.disabled||Date.now()-o.open.timestamp<n.state.facet(W).interactionDelay)return!1;let i,s=1;"page"==e&&(i=y(n,o.open.tooltip))&&(s=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:l}=o.open.options,r=o.open.selected>-1?o.open.selected+s*(t?1:-1):t?0:l-1;return r<0?r="page"==e?0:l-1:r>=l&&(r="page"==e?l-1:0),n.dispatch({effects:it.of(r)}),!0}}class ct{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const ht=x.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(st).active)1==e.state&&this.startQuery(e)}update(t){let e=t.state.field(st),n=t.state.facet(W);if(!t.selectionSet&&!t.docChanged&&t.startState.field(st)==e)return;let o=t.transactions.some((t=>(t.selection||t.docChanged)&&!tt(t,n)));for(let e=0;e<this.running.length;e++){let n=this.running[e];if(o||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){C(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(U)))))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>1==t.state&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),i):-1,0!=this.composing)for(let e of t.transactions)"input"==tt(e,n)?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(st);for(let t of e.active)1!=t.state||this.running.some((e=>e.active.source==t.source))||this.startQuery(t)}startQuery(t){let{state:e}=this.view,n=R(e),o=new T(e,n,t.explicitPos==n),i=new ct(t,o);this.running.push(i),Promise.resolve(t.source(o)).then((t=>{i.context.aborted||(i.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:$.of(null)}),C(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(W).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(W);for(let o=0;o<this.running.length;o++){let i=this.running[o];if(void 0===i.done)continue;if(this.running.splice(o--,1),i.done){let o=new nt(i.active.source,i.active.explicitPos,i.done,i.done.from,null!==(t=i.done.to)&&void 0!==t?t:R(i.updates.length?i.updates[0].startState:this.view.state));for(let t of i.updates)o=o.update(t,n);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(st).active.find((t=>t.source==i.active.source));if(s&&1==s.state)if(null==i.done){let t=new et(i.active.source,0);for(let e of i.updates)t=t.update(e,n);1!=t.state&&e.push(t)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:ot.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(st,!1);if(e&&e.tooltip&&this.view.state.facet(W).closeOnBlur){let n=e.open&&y(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:$.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:U.of(!1)})),20),this.composing=0}}}),pt="object"==typeof navigator&&/Win/.test(navigator.platform),ft=i.highest(g.domEventHandlers({keydown(t,e){let n=e.state.field(st,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&(!pt||!t.altKey)||t.metaKey)return!1;let o=n.open.options[n.open.selected],i=n.active.find((t=>t.source==o.source)),s=o.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&lt(e,o),!1}})),ut=g.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"},".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 dt{constructor(t,e,n,o){this.field=t,this.line=e,this.from=n,this.to=o}}class mt{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,c.TrackDel),n=t.mapPos(this.to,1,c.TrackDel);return null==e||null==n?null:new mt(this.field,e,n)}}class gt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],o=[e],i=t.doc.lineAt(e),s=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=s,l=/^\t*/.exec(i)[0].length;for(let e=0;e<l;e++)n+=t.facet(D);o.push(e+n.length-l),i=n+i.slice(l)}n.push(i),e+=i.length+1}let l=this.fieldPositions.map((t=>new mt(t.field,o[t.line]+t.from,o[t.line]+t.to)));return{text:n,ranges:l}}static parse(t){let e,n=[],o=[],i=[];for(let s of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=e[1]?+e[1]:null,l=e[2]||e[3]||"",r=-1,a=l.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<n.length;e++)(null!=t?n[e].seq==t:a&&n[e].name==a)&&(r=e);if(r<0){let e=0;for(;e<n.length&&(null==t||null!=n[e].seq&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:a}),r=e;for(let t of i)t.field>=r&&t.field++}i.push(new dt(r,o.length,e.index,e.index+a.length)),s=s.slice(0,e.index)+l+s.slice(e.index+e[0].length)}s=s.replace(/\\([{}])/g,((t,e,n)=>{for(let t of i)t.line==o.length&&t.from>n&&(t.from--,t.to--);return e})),o.push(s)}return new gt(o,i)}}let vt=I.widget({widget:new class extends O{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),bt=I.mark({class:"cm-snippetField"});class wt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?vt:bt).range(t.from,t.to))))}map(t){let e=[];for(let n of this.ranges){let o=n.map(t);if(!o)return null;e.push(o)}return new wt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const yt=a.define({map:(t,e)=>t&&t.map(e)}),xt=a.define(),Ct=r.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(yt))return n.value;if(n.is(xt)&&t)return new wt(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>g.decorations.from(t,(t=>t?t.deco:I.none))});function It(t,e){return n.create(t.filter((t=>t.field==e)).map((t=>n.range(t.from,t.to))))}function Ot(t){let e=gt.parse(t);return(t,n,o,i)=>{let{text:s,ranges:l}=e.instantiate(t.state,o),r={changes:{from:o,to:i,insert:d.of(s)},scrollIntoView:!0,annotations:n?[M.of(n),m.userEvent.of("input.complete")]:void 0};if(l.length&&(r.selection=It(l,0)),l.some((t=>t.field>0))){let e=new wt(l,0),n=r.effects=[yt.of(e)];void 0===t.state.field(Ct,!1)&&n.push(a.appendConfig.of([Ct,St,Et,ut]))}t.dispatch(t.state.update(r))}}function kt(t){return({state:e,dispatch:n})=>{let o=e.field(Ct,!1);if(!o||t<0&&0==o.active)return!1;let i=o.active+t,s=t>0&&!o.ranges.some((e=>e.field==i+t));return n(e.update({selection:It(o.ranges,i),effects:yt.of(s?null:new wt(o.ranges,i)),scrollIntoView:!0})),!0}}const Dt=[{key:"Tab",run:kt(1),shift:kt(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(Ct,!1)&&(e(t.update({effects:yt.of(null)})),!0)}],Tt=s.define({combine:t=>t.length?t[0]:Dt}),St=i.highest(v.compute([Tt],(t=>t.facet(Tt))));function At(t,e){return Object.assign(Object.assign({},e),{apply:Ot(t)})}const Et=g.domEventHandlers({mousedown(t,e){let n,o=e.state.field(Ct,!1);if(!o||null==(n=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let i=o.ranges.find((t=>t.from<=n&&t.to>=n));return!(!i||i.field==o.active)&&(e.dispatch({selection:It(o.ranges,i.field),effects:yt.of(o.ranges.some((t=>t.field>i.field))?new wt(o.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Lt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Rt=a.define({map(t,e){let n=e.mapPos(t,-1,c.TrackAfter);return null==n?void 0:n}}),Pt=new class extends h{};Pt.startSide=1,Pt.endSide=-1;const Mt=r.define({create:()=>p.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(Rt)&&(t=t.update({add:[Pt.range(n.value,n.value+1)]}));return t}});function Bt(){return[Nt,Mt]}const jt="()[]{}<>";function Ut(t){for(let e=0;e<jt.length;e+=2)if(jt.charCodeAt(e)==t)return jt.charAt(e+1);return f(t<128?t:t+1)}function $t(t,e){return t.languageDataAt("closeBrackets",e)[0]||Lt}const Ft="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Nt=g.inputHandler.of(((n,o,i,s)=>{if((Ft?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let l=n.state.selection.main;if(s.length>2||2==s.length&&1==t(e(s,0))||o!=l.from||i!=l.to)return!1;let r=function(t,n){let o=$t(t,t.selection.main.head),i=o.brackets||Lt.brackets;for(let s of i){let l=Ut(e(s,0));if(n==s)return l==s?Kt(t,s,i.indexOf(s+s+s)>-1,o):Vt(t,s,l,o.before||Lt.before);if(n==l&&qt(t,t.selection.main.from))return zt(t,s,l)}return null}(n.state,s);return!!r&&(n.dispatch(r),!0)})),Wt=[{key:"Backspace",run:({state:o,dispatch:i})=>{if(o.readOnly)return!1;let s=$t(o,o.selection.main.head).brackets||Lt.brackets,l=null,r=o.changeByRange((i=>{if(i.empty){let l=function(n,o){let i=n.sliceString(o-2,o);return t(e(i,0))==i.length?i:i.slice(1)}(o.doc,i.head);for(let t of s)if(t==l&&Ht(o.doc,i.head)==Ut(e(t,0)))return{changes:{from:i.head-t.length,to:i.head+t.length},range:n.cursor(i.head-t.length)}}return{range:l=i}}));return l||i(o.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!l}}];function qt(t,e){let n=!1;return t.field(Mt).between(0,t.doc.length,(t=>{t==e&&(n=!0)})),n}function Ht(n,o){let i=n.sliceString(o,o+2);return i.slice(0,t(e(i,0)))}function Vt(t,e,o,i){let s=null,l=t.changeByRange((l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:o,from:l.to}],effects:Rt.of(l.to+e.length),range:n.range(l.anchor+e.length,l.head+e.length)};let r=Ht(t.doc,l.head);return!r||/\s/.test(r)||i.indexOf(r)>-1?{changes:{insert:e+o,from:l.head},effects:Rt.of(l.head+e.length),range:n.cursor(l.head+e.length)}:{range:s=l}}));return s?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function zt(t,e,o){let i=null,s=t.changeByRange((e=>e.empty&&Ht(t.doc,e.head)==o?{changes:{from:e.head,to:e.head+o.length,insert:o},range:n.cursor(e.head+o.length)}:i={range:e}));return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Kt(t,e,i,s){let l=s.stringPrefixes||Lt.stringPrefixes,r=null,a=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:e,from:s.to}],effects:Rt.of(s.to+e.length),range:n.range(s.anchor+e.length,s.head+e.length)};let a,c=s.head,h=Ht(t.doc,c);if(h==e){if(Qt(t,c))return{changes:{insert:e+e,from:c},effects:Rt.of(c+e.length),range:n.cursor(c+e.length)};if(qt(t,c)){let o=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+o.length,insert:o},range:n.cursor(c+o.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(a=_t(t,c-2*e.length,l))>-1&&Qt(t,a))return{changes:{insert:e+e+e+e,from:c},effects:Rt.of(c+e.length),range:n.cursor(c+e.length)};if(t.charCategorizer(c)(h)!=o.Word&&_t(t,c,l)>-1&&!function(t,e,n,o){let i=k(t).resolveInner(e,-1),s=o.reduce(((t,e)=>Math.max(t,e.length)),0);for(let l=0;l<5;l++){let l=t.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),r=l.indexOf(n);if(!r||r>-1&&o.indexOf(l.slice(0,r))>-1){let e=i.firstChild;for(;e&&e.from==i.from&&e.to-e.from>n.length+r;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let a=i.to==e&&i.parent;if(!a)break;i=a}return!1}(t,c,e,l))return{changes:{insert:e+e,from:c},effects:Rt.of(c+e.length),range:n.cursor(c+e.length)}}return{range:r=s}}));return r?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Qt(t,e){let n=k(t).resolveInner(e+1);return n.parent&&n.from==e}function _t(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=o.Word)return e;for(let s of n){let n=e-s.length;if(t.sliceDoc(n,e)==s&&i(t.sliceDoc(n-1,n))!=o.Word)return n}return-1}function Xt(t={}){return[ft,st,W.of(t),ht,Gt,ut]}const Yt=[{key:"Ctrl-Space",run:t=>!!t.state.field(st,!1)&&(t.dispatch({effects:U.of(!0)}),!0)},{key:"Escape",run:t=>{let e=t.state.field(st,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:$.of(null)}),!0)}},{key:"ArrowDown",run:at(!0)},{key:"ArrowUp",run:at(!1)},{key:"PageDown",run:at(!0,"page")},{key:"PageUp",run:at(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(st,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(W).interactionDelay)&&lt(t,e.open.options[e.open.selected])}}],Gt=i.highest(v.computeN([W],(t=>t.facet(W).defaultKeymap?[Yt]:[])));export{Bt as a,Xt as b,A as c,Wt as d,Yt as e,E as i,At as s};
2
+ //# sourceMappingURL=index-CdWlITxy.js.map