@pi-outpost/embed 0.46.0 → 0.48.0

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 (25) hide show
  1. package/README.md +4 -0
  2. package/dist/CodeEditor-CIWnYOMo.cjs +9 -0
  3. package/dist/{CodeEditor-CNBsvq8Z.js → CodeEditor-Dei7wUOV.js} +834 -750
  4. package/dist/{conversationExport-C-PQsHzJ.js → conversationExport-BZ08h6Er.js} +1 -1
  5. package/dist/{conversationExport-750vH7SP.cjs → conversationExport-CXmq8l0b.cjs} +1 -1
  6. package/dist/{conversationHistory-Dh1AOfU9.js → conversationHistory-D4iAdrF9.js} +91 -91
  7. package/dist/{conversationHistory-CKYAWF0H.cjs → conversationHistory-iHvZAmNN.cjs} +1 -1
  8. package/dist/{dist-CEPd6ecF.cjs → dist-0gxsdPHi.cjs} +1 -1
  9. package/dist/{dist-CELe3Rxj.cjs → dist-BAXGE-5E.cjs} +1 -1
  10. package/dist/{dist-BF9tfVH8.cjs → dist-BB8DIy0-.cjs} +1 -1
  11. package/dist/{dist-CPxwFKs7.cjs → dist-BXKM-sMu.cjs} +1 -1
  12. package/dist/{dist-BjQ1Exnz.js → dist-BhRuhsmx.js} +1 -1
  13. package/dist/{dist-iZeihidk.js → dist-Bt2YslBF.js} +2 -2
  14. package/dist/{dist-C2UMsquH.js → dist-CDuDYc3h.js} +1 -1
  15. package/dist/{dist-Ca51SM3i.js → dist-CUml8Wzk.js} +1 -1
  16. package/dist/{dist-BZ1m84Kh.js → dist-CV2qXUTt.js} +1 -1
  17. package/dist/{dist-BnXHuZGz.js → dist-Ccs3Mpvk.js} +1 -1
  18. package/dist/{dist-W-WjEDJm.cjs → dist-CqvTKR3J.cjs} +1 -1
  19. package/dist/{dist-SqwJhRs0.js → dist-CuX47mx0.js} +1 -1
  20. package/dist/{dist-CGPxOMk5.cjs → dist-DNzYo4it.cjs} +1 -1
  21. package/dist/{dist-BLS46S7g.cjs → dist-DU0BjKn0.cjs} +1 -1
  22. package/dist/pi-outpost-embed.cjs +625 -29
  23. package/dist/pi-outpost-embed.js +4215 -3961
  24. package/package.json +1 -1
  25. package/dist/CodeEditor-84sk1WGW.cjs +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-outpost/embed",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "type": "module",
5
5
  "description": "Mount pi-outpost as a Shadow-DOM-isolated widget inside another web app.",
6
6
  "license": "MIT",
@@ -1,9 +0,0 @@
1
- const e=require("./rolldown-runtime-DbbDpzbe.cjs"),t=require("./dist-BlUoR-U1.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=t.k(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(d(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}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 a(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function o(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=a(t)+a(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function s(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:o(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function c(e,n){return r=>{for(let n=t.k(r.state).resolveInner(r.pos,-1);n;n=n.parent){if(e.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return n(r)}}var l=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function u(e){return e.selection.main.from}function d(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var f=t.Y.define();function p(e,n,r,i){let{main:a}=e.selection,o=r-a.from,s=i-a.from;return{...e.changeByRange(c=>{if(c!=a&&r!=i&&e.sliceDoc(c.from+o,c.from+s)!=e.sliceDoc(r,i))return{range:c};let l=e.toText(n);return{changes:{from:c.from+o,to:i==a.from?c.to:c.from+s,insert:l},range:t.et.cursor(c.from+o+l.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var m=new WeakMap;function h(e){if(!Array.isArray(e))return e;let t=m.get(e);return t||m.set(e,t=s(e)),t}var g=t.st.define(),_=t.st.define(),v=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=t.dt(e,n),i=t.ft(r);this.chars.push(r);let a=e.slice(n,n+i),o=a.toUpperCase();this.folded.push(t.dt(o==a?a.toLowerCase():o,0)),n+=i}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:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let i=t.dt(e,0),a=t.ft(i),o=a==e.length?0:-100;if(i!=n[0]){if(i==r[0])o+=-200;else return null}return this.ret(o,[0,a])}let s=e.indexOf(this.pattern);if(s==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=n.length,l=0;if(s<0){for(let a=0,o=Math.min(e.length,200);a<o&&l<c;){let o=t.dt(e,a);(o==n[l]||o==r[l])&&(i[l++]=a),a+=t.ft(o)}if(l<c)return null}let u=0,d=0,f=!1,p=0,m=-1,h=-1,g=/[a-z]/.test(e),_=!0;for(let i=0,l=Math.min(e.length,200),v=0;i<l&&d<c;){let l=t.dt(e,i);s<0&&(u<c&&l==n[u]&&(a[u++]=i),p<c&&(l==n[p]||l==r[p]?(p==0&&(m=i),h=i+1,p++):p=0));let y,b=l<255?l>=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(y=t.gt(l))==y.toLowerCase()?y==y.toUpperCase()?0:2:1;(!i||b==1&&g||v==0&&b!=0)&&(n[d]==l||r[d]==l&&(f=!0)?o[d++]=i:o.length&&(_=!1)),v=b,i+=t.ft(l)}return d==c&&o[0]==0&&_?this.result(-100+(f?-200:0),o,e):p==c&&m==0?this.ret(-200-e.length+(h==e.length?0:-100),[0,h]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):p==c?this.ret(-900-e.length,[m,h]):d==c?this.result(-100+(f?-200:0)+-700+(_?0:-1100),o,e):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,n,r){let i=[],a=0;for(let e of n){let n=e+(this.astral?t.ft(t.dt(r,e)):1);a&&i[a-1]==e?i[a-1]=n:(i[a++]=e,i[a++]=n)}return this.ret(e-r.length,i)}},y=class{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)}},b=t.nt.define({combine(e){return t.pt(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:te,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=>ee(e(n),t(n)),optionClass:(e,t)=>n=>ee(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function ee(e,t){return e?t?e+` `+t:e:t}function te(e,n,r,i,a,o){let s=e.textDirection==t.j.RTL,c=s,l=!1,u=`top`,d,f,p=n.left-a.left,m=a.right-n.right,h=i.right-i.left,g=i.bottom-i.top;if(c&&p<Math.min(h,m)?c=!1:!c&&m<Math.min(h,p)&&(c=!0),h<=(c?p:m))d=Math.max(a.top,Math.min(r.top,a.bottom-g))-n.top,f=Math.min(400,c?p:m);else{l=!0,f=Math.min(400,(s?n.right:a.right-n.left)-30);let e=a.bottom-n.bottom;e>=g||e>n.top?d=r.bottom-n.top:(u=`bottom`,d=n.bottom-r.top)}let _=(n.bottom-n.top)/o.offsetHeight,v=(n.right-n.left)/o.offsetWidth;return{style:`${u}: ${d/_}px; max-width: ${f/v}px`,class:`cm-completionInfo-`+(l?s?`left-narrow`:`right-narrow`:c?`left`:`right`)}}var ne=t.st.define();function re(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function ie(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var ae=class{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:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(b);this.optionContent=re(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=ie(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:ne.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(b).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:_.of(null)})}),this.showOptions(i,r.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){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=ie(r.length,i,e.state.facet(b).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=ie(n.options.length,n.selected,this.view.state.facet(b).maxRenderedOptions),this.showOptions(n.options,e.id));let r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();let{completion:i}=n.options[n.selected],{info:a}=i;if(!a)return;let o=typeof a==`string`?document.createTextNode(a):a(i);if(!o)return;`then`in o?o.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,i)}).catch(e=>t.K(this.view.state,e,`completion info`)):(this.addInfoPane(o,i),r.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:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==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&&se(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(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(b).positionInfo(this.view,t,r,n,i,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){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function oe(e,t){return n=>new ae(n,e,t)}function se(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function ce(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function le(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(b);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new l(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new y(n):new v(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new l(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,u=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||u(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):ce(e.completion)>ce(c)&&(s[s.length-1]=e),c=e.completion}return s}var ue=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,he(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=le(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(b).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,he(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Se,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},de=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(ge,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(b),i=(r.override||n.languageDataAt(`autocomplete`,u(n)).map(h)).map(e=>(this.active.find(t=>t.source==e)||new x(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(be));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!fe(i,this.active)||o?a=ue.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new x(e.source,0):e));for(let e of t.effects)e.is(ne)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?pe:me}};function fe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var pe={"aria-autocomplete":`list`},me={};function he(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var ge=[];function _e(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(f);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var x=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=_e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(g))i=new e(i.source,1,n.value);else if(n.is(_))i=new e(i.source,0);else if(n.is(be))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(u(e.state))}},ve=class e extends x{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=u(t.state);if(s>o||!r||n&2&&(u(t.startState)==this.from||s<this.limit))return new x(this.source,n&4?1:0);let c=t.changes.mapPos(this.limit);return ye(r.validFor,t.state,a,o)?new e(this.source,this.explicit,c,r,a,o):r.update&&(r=r.update(r,a,o,new i(t.state,s,!1)))?new e(this.source,this.explicit,c,r,r.from,r.to??u(t.state)):new x(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new x(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function ye(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):d(e,!0).test(i)}var be=t.st.define({map(e,t){return e.map(e=>e.map(t))}}),S=t.ct.define({create(){return de.start()},update(e,t){return e.update(t)},provide:e=>[t.J.from(e,e=>e.tooltip),t.M.contentAttributes.from(e,e=>e.attrs)]});function xe(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(S).active.find(e=>e.source==t.source);return r instanceof ve&&(typeof n==`string`?e.dispatch({...p(e.state,n,r.from,r.to),annotations:f.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var Se=oe(S,xe);function C(e,n=`option`){return r=>{let i=r.state.field(S,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<r.state.facet(b).interactionDelay)return!1;let a=1,o;n==`page`&&(o=t.z(r,i.open.tooltip))&&(a=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector(`li`).offsetHeight)-1));let{length:s}=i.open.options,c=i.open.selected>-1?i.open.selected+a*(e?1:-1):e?0:s-1;return c<0?c=n==`page`?0:s-1:c>=s&&(c=n==`page`?s-1:0),r.dispatch({effects:ne.of(c)}),!0}}var Ce=e=>{let t=e.state.field(S,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(b).interactionDelay?!1:xe(e,t.open.options[t.open.selected])},we=e=>e.state.field(S,!1)?(e.dispatch({effects:g.of(!0)}),!0):!1,Te=e=>{let t=e.state.field(S,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:_.of(null)}),!0)},Ee=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},De=50,Oe=1e3,ke=t.P.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(S).active)t.isPending&&this.startQuery(t)}update(e){let n=e.state.field(S),r=e.state.facet(b);if(!e.selectionSet&&!e.docChanged&&e.startState.field(S)==n)return;let i=e.transactions.some(e=>{let t=_e(e,r);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let n=0;n<this.running.length;n++){let r=this.running[n];if(i||r.context.abortOnDocChange&&e.docChanged||r.updates.length+e.transactions.length>De&&Date.now()-r.time>Oe){for(let e of r.context.abortListeners)try{e()}catch(e){t.K(this.view.state,e)}r.context.abortListeners=null,this.running.splice(n--,1)}else r.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(g)))&&(this.pendingStart=!0);let a=this.pendingStart?50:r.activateOnTypingDelay;if(this.debounceUpdate=n.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),a):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(S);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(b).updateSyncTime))}startQuery(e){let{state:n}=this.view,r=new i(n,u(n),e.explicit,this.view),a=new Ee(e,r);this.running.push(a),Promise.resolve(e.source(r)).then(e=>{a.context.aborted||(a.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:_.of(null)}),t.K(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(b).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(b),n=this.view.state.field(S);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=u(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new ve(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new x(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:be.of(e)})}},{eventHandlers:{blur(e){let n=this.view.state.field(S,!1);if(n&&n.tooltip&&this.view.state.facet(b).closeOnBlur){let r=n.open&&t.z(this.view,n.open.tooltip);(!r||!r.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:_.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:g.of(!1)}),20),this.composing=0}}}),Ae=typeof navigator==`object`&&/Win/.test(navigator.platform),je=t.it.highest(t.M.domEventHandlers({keydown(e,t){let n=t.state.field(S,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Ae&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&xe(t,r),!1}})),Me=t.M.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Ne=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Pe=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(n){let r=n.mapPos(this.from,-1,t.rt.TrackDel),i=n.mapPos(this.to,1,t.rt.TrackDel);return r==null||i==null?null:new e(this.field,r,i)}},Fe=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,n){let r=[],i=[n],a=e.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let a of this.lines){if(r.length){let r=o,s=/^\t*/.exec(a)[0].length;for(let n=0;n<s;n++)r+=e.facet(t.w);i.push(n+r.length-s),a=r+a.slice(s)}r.push(a),n+=a.length+1}return{text:r,ranges:this.fieldPositions.map(e=>new Pe(e.field,i[e.line]+e.from,i[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Ne(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},Ie=t.A.widget({widget:new class extends t.F{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Le=t.A.mark({class:`cm-snippetField`}),Re=class e{constructor(e,n){this.ranges=e,this.active=n,this.deco=t.A.set(e.map(e=>(e.from==e.to?Ie:Le).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},w=t.st.define({map(e,t){return e&&e.map(t)}}),ze=t.st.define(),T=t.ct.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(w))return n.value;if(n.is(ze)&&e)return new Re(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>t.M.decorations.from(e,e=>e?e.deco:t.A.none)});function Be(e,n){return t.et.create(e.filter(e=>e.field==n).map(e=>t.et.range(e.from,e.to)))}function Ve(e){let n=Fe.parse(e);return(e,r,i,a)=>{let{text:o,ranges:s}=n.instantiate(e.state,i),{main:c}=e.state.selection,l={changes:{from:i,to:a==c.from?c.to:a,insert:t.lt.of(o)},scrollIntoView:!0,annotations:r?[f.of(r),t.ut.userEvent.of(`input.complete`)]:void 0};if(s.length&&(l.selection=Be(s,0)),s.some(e=>e.field>0)){let n=new Re(s,0),r=l.effects=[w.of(n)];e.state.field(T,!1)===void 0&&r.push(t.st.appendConfig.of([T,Ge,qe,Me]))}e.dispatch(e.state.update(l))}}function He(e){return({state:t,dispatch:n})=>{let r=t.field(T,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:Be(r.ranges,i),effects:w.of(a?null:new Re(r.ranges,i)),scrollIntoView:!0})),!0}}var Ue=[{key:`Tab`,run:He(1),shift:He(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(T,!1)?(t(e.update({effects:w.of(null)})),!0):!1}],We=t.nt.define({combine(e){return e.length?e[0]:Ue}}),Ge=t.it.highest(t.W.compute([We],e=>e.facet(We)));function Ke(e,t){return{...t,apply:Ve(e)}}var qe=t.M.domEventHandlers({mousedown(e,t){let n=t.state.field(T,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:Be(n.ranges,i.field),effects:w.of(n.ranges.some(e=>e.field>i.field)?new Re(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),E={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},D=t.st.define({map(e,n){return n.mapPos(e,-1,t.rt.TrackAfter)??void 0}}),Je=new class extends t.ot{};Je.startSide=1,Je.endSide=-1;var Ye=t.ct.define({create(){return t.at.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(D)&&(e=e.update({add:[Je.range(n.value,n.value+1)]}));return e}});function Xe(){return[tt,Ye]}var Ze=`()[]{}<>«»»«[]{}`;function Qe(e){for(let t=0;t<16;t+=2)if(Ze.charCodeAt(t)==e)return Ze.charAt(t+1);return t.gt(e<128?e:e+1)}function $e(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||E}var et=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),tt=t.M.inputHandler.of((e,n,r,i)=>{if((et?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let a=e.state.selection.main;if(i.length>2||i.length==2&&t.ft(t.dt(i,0))==1||n!=a.from||r!=a.to)return!1;let o=rt(e.state,i);return o?(e.dispatch(o),!0):!1}),nt=[{key:`Backspace`,run:({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=$e(e,e.selection.main.head).brackets||E.brackets,i=null,a=e.changeByRange(n=>{if(n.empty){let i=at(e.doc,n.head);for(let a of r)if(a==i&&O(e.doc,n.head)==Qe(t.dt(a,0)))return{changes:{from:n.head-a.length,to:n.head+a.length},range:t.et.cursor(n.head-a.length)}}return{range:i=n}});return i||n(e.update(a,{scrollIntoView:!0,userEvent:`delete.backward`})),!i}}];function rt(e,n){let r=$e(e,e.selection.main.head),i=r.brackets||E.brackets;for(let a of i){let o=Qe(t.dt(a,0));if(n==a)return o==a?ct(e,a,i.indexOf(a+a+a)>-1,r):ot(e,a,o,r.before||E.before);if(n==o&&it(e,e.selection.main.from))return st(e,a,o)}return null}function it(e,t){let n=!1;return e.field(Ye).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function O(e,n){let r=e.sliceString(n,n+2);return r.slice(0,t.ft(t.dt(r,0)))}function at(e,n){let r=e.sliceString(n-2,n);return t.ft(t.dt(r,0))==r.length?r:r.slice(1)}function ot(e,n,r,i){let a=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:n,from:o.from},{insert:r,from:o.to}],effects:D.of(o.to+n.length),range:t.et.range(o.anchor+n.length,o.head+n.length)};let s=O(e.doc,o.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:n+r,from:o.head},effects:D.of(o.head+n.length),range:t.et.cursor(o.head+n.length)}:{range:a=o}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function st(e,n,r){let i=null,a=e.changeByRange(n=>n.empty&&O(e.doc,n.head)==r?{changes:{from:n.head,to:n.head+r.length,insert:r},range:t.et.cursor(n.head+r.length)}:i={range:n});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function ct(e,n,r,i){let a=i.stringPrefixes||E.stringPrefixes,o=null,s=e.changeByRange(i=>{if(!i.empty)return{changes:[{insert:n,from:i.from},{insert:n,from:i.to}],effects:D.of(i.to+n.length),range:t.et.range(i.anchor+n.length,i.head+n.length)};let s=i.head,c=O(e.doc,s),l;if(c==n){if(lt(e,s))return{changes:{insert:n+n,from:s},effects:D.of(s+n.length),range:t.et.cursor(s+n.length)};if(it(e,s)){let i=r&&e.sliceDoc(s,s+n.length*3)==n+n+n?n+n+n:n;return{changes:{from:s,to:s+i.length,insert:i},range:t.et.cursor(s+i.length)}}}else if(r&&e.sliceDoc(s-2*n.length,s)==n+n&&(l=dt(e,s-2*n.length,a))>-1&&lt(e,l))return{changes:{insert:n+n+n+n,from:s},effects:D.of(s+n.length),range:t.et.cursor(s+n.length)};else if(e.charCategorizer(s)(c)!=t.Q.Word&&dt(e,s,a)>-1&&!ut(e,s,n,a))return{changes:{insert:n+n,from:s},effects:D.of(s+n.length),range:t.et.cursor(s+n.length)};return{range:o=i}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:`input.type`})}function lt(e,n){let r=t.k(e).resolveInner(n+1);return r.parent&&r.from==n}function ut(e,n,r,i){let a=t.k(e).resolveInner(n,-1),o=i.reduce((e,t)=>Math.max(e,t.length),0);for(let t=0;t<5;t++){let t=e.sliceDoc(a.from,Math.min(a.to,a.from+r.length+o)),s=t.indexOf(r);if(!s||s>-1&&i.indexOf(t.slice(0,s))>-1){let t=a.firstChild;for(;t&&t.from==a.from&&t.to-t.from>r.length+s;){if(e.sliceDoc(t.to-r.length,t.to)==r)return!1;t=t.firstChild}return!0}let c=a.to==n&&a.parent;if(!c)break;a=c}return!1}function dt(e,n,r){let i=e.charCategorizer(n);if(i(e.sliceDoc(n-1,n))!=t.Q.Word)return n;for(let a of r){let r=n-a.length;if(e.sliceDoc(r,n)==a&&i(e.sliceDoc(r-1,r))!=t.Q.Word)return r}return-1}function ft(e={}){return[je,S,b.of(e),ke,mt,Me]}var pt=[{key:`Ctrl-Space`,run:we},{mac:"Alt-`",run:we},{mac:`Alt-i`,run:we},{key:`Escape`,run:Te},{key:`ArrowDown`,run:C(!0)},{key:`ArrowUp`,run:C(!1)},{key:`PageDown`,run:C(!0,`page`)},{key:`PageUp`,run:C(!1,`page`)},{key:`Enter`,run:Ce}],mt=t.it.highest(t.W.computeN([b],e=>e.facet(b).defaultKeymap?[pt]:[])),ht=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=bt(e.state,n.from);return r.line?_t(e):r.block?yt(e):!1};function gt(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var _t=gt(wt,0),vt=gt(Ct,0),yt=gt((e,t)=>Ct(e,t,St(t)),0);function bt(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var k=50;function xt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-k,r),o=e.sliceDoc(i,i+k),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+k),d=e.sliceDoc(i-k,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function St(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ct(e,t,n=t.selection.ranges){let r=n.map(e=>bt(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function wt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=bt(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Tt=t.Y.define(),Et=t.Y.define(),Dt=t.nt.define(),Ot=t.nt.define({combine(e){return t.pt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),kt=t.ct.define({create(){return P.empty},update(e,n){let r=n.state.facet(Ot),i=n.annotation(Tt);if(i){let t=j.fromTransaction(n,i.selection),a=i.side,o=a==0?e.undone:e.done;return o=t?M(o,o.length,r.minDepth,t):zt(o,n.startState.selection),new P(a==0?i.rest:o,a==0?o:i.rest)}let a=n.annotation(Et);if((a==`full`||a==`before`)&&(e=e.isolate()),n.annotation(t.ut.addToHistory)===!1)return n.changes.empty?e:e.addMapping(n.changes.desc);let o=j.fromTransaction(n),s=n.annotation(t.ut.time),c=n.annotation(t.ut.userEvent);return o?e=e.addChanges(o,s,c,r,n):n.selection&&(e=e.addSelection(n.startState.selection,s,c,r.newGroupDelay)),(a==`full`||a==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new P(e.done.map(j.fromJSON),e.undone.map(j.fromJSON))}});function At(e={}){return[kt,Ot.of(e),t.M.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?jt:e.inputType==`historyRedo`?Mt:null;return n?(e.preventDefault(),n(t)):!1}})]}function A(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(kt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var jt=A(0,!1),Mt=A(1,!1),Nt=A(0,!0),Pt=A(1,!0),j=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(n){return new e(n.changes&&t.Z.fromJSON(n.changes),[],n.mapped&&t.X.fromJSON(n.mapped),n.startSelection&&t.et.fromJSON(n.startSelection),n.selectionsAfter.map(t.et.fromJSON))}static fromTransaction(t,n){let r=N;for(let e of t.startState.facet(Dt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,N)}static selection(t){return new e(void 0,N,void 0,void 0,t)}};function M(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Ft(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function It(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Lt(e,t){return e.length?t.length?e.concat(t):e:t}var N=[],Rt=200;function zt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Rt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),M(e,e.length-1,1e9,n.setSelAfter(r)))}return[j.selection([t])]}function Bt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Vt(e,t){if(!e.length)return e;let n=e.length,r=N;for(;n;){let i=Ht(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[j.selection(r)]:N}function Ht(e,n,r){let i=Lt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(n)):N,r);if(!e.changes)return j.selection(i);let a=e.changes.map(n),o=n.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new j(a,t.st.mapEffects(e.effects,n),s,e.startSelection.map(o),i)}var Ut=/^(input\.type|delete)($|\.)/,P=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(n,r,i,a,o){let s=this.done,c=s[s.length-1];return s=c&&c.changes&&!c.changes.empty&&n.changes&&(!i||Ut.test(i))&&(!c.selectionsAfter.length&&r-this.prevTime<a.newGroupDelay&&a.joinToEvent(o,Ft(c.changes,n.changes))||i==`input.type.compose`)?M(s,s.length-1,a.minDepth,new j(n.changes.compose(c.changes),Lt(t.st.mapEffects(n.effects,c.changes),c.effects),c.mapped,c.startSelection,N)):M(s,s.length,a.minDepth,n),new e(s,N,r,i)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:N;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&It(a[a.length-1],t)?this:new e(zt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Vt(this.done,t),Vt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Tt.of({side:e,rest:Bt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?N:r.slice(0,r.length-1);return i.mapped&&(n=Vt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Tt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};P.empty=new P(N,N);var Wt=[{key:`Mod-z`,run:jt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Mt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Mt,preventDefault:!0},{key:`Mod-u`,run:Nt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Pt,preventDefault:!0}];function F(e,n){return t.et.create(e.ranges.map(n),e.mainIndex)}function I(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function L({state:e,dispatch:t},n){let r=F(e.selection,n);return!r.eq(e.selection,!0)&&(t(I(e,r)),!0)}function R(e,n){return t.et.cursor(n?e.to:e.from)}function Gt(e,t){return L(e,n=>n.empty?e.moveByChar(n,t):R(n,t))}function z(e){return e.textDirectionAt(e.state.selection.main.head)==t.j.LTR}var Kt=e=>Gt(e,!z(e)),qt=e=>Gt(e,z(e));function Jt(e,t){return L(e,n=>n.empty?e.moveByGroup(n,t):R(n,t))}var Yt=e=>Jt(e,!z(e)),Xt=e=>Jt(e,z(e));typeof Intl<`u`&&Intl.Segmenter;function Zt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function B(e,n,r){let i=t.k(e).resolveInner(n.head),a=r?t.Ct.closedBy:t.Ct.openedBy;for(let t=n.head;;){let n=r?i.childAfter(t):i.childBefore(t);if(!n)break;Zt(e,n,a)?i=n:t=r?n.to:n.from}let o=i.type.prop(a),s,c;return c=o&&(s=r?t.E(e,i.from,1):t.E(e,i.to,-1))&&s.matched?r?s.end.to:s.end.from:r?i.to:i.from,t.et.cursor(c,r?-1:1)}var Qt=e=>L(e,t=>B(e.state,t,!z(e))),$t=e=>L(e,t=>B(e.state,t,z(e)));function en(e,t){return L(e,n=>{if(!n.empty)return R(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var tn=e=>en(e,!1),nn=e=>en(e,!0);function rn(e){let n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0,a;if(n){for(let n of e.state.facet(t.M.scrollMargins)){let t=n(e);t?.top&&(r=Math.max(t?.top,r)),t?.bottom&&(i=Math.max(t?.bottom,i))}a=e.scrollDOM.clientHeight-r-i}else a=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,a-5)}}function an(e,n){let r=rn(e),{state:i}=e,a=F(i.selection,t=>t.empty?e.moveVertically(t,n,r.height):R(t,n));if(a.eq(i.selection))return!1;let o;if(r.selfScroll){let n=e.coordsAtPos(i.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),c=s.top+r.marginTop,l=s.bottom-r.marginBottom;n&&n.top>c&&n.bottom<l&&(o=t.M.scrollIntoView(a.main.head,{y:`start`,yMargin:n.top-c}))}return e.dispatch(I(i,a),{effects:o}),!0}var on=e=>an(e,!1),sn=e=>an(e,!0);function V(e,n,r){let i=e.lineBlockAt(n.head),a=e.moveToLineBoundary(n,r);if(a.head==n.head&&a.head!=(r?i.to:i.from)&&(a=e.moveToLineBoundary(n,r,!1)),!r&&a.head==i.from&&i.length){let r=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&n.head!=i.from+r&&(a=t.et.cursor(i.from+r))}return a}var cn=e=>L(e,t=>V(e,t,!0)),ln=e=>L(e,t=>V(e,t,!1)),un=e=>L(e,t=>V(e,t,!z(e))),dn=e=>L(e,t=>V(e,t,z(e))),fn=e=>L(e,t=>e.moveToLineBoundary(t,!1,!1)),pn=e=>L(e,t=>e.moveToLineBoundary(t,!0,!1));function mn(e,n,r){let i=!1,a=F(e.selection,n=>{let a=t.E(e,n.head,-1)||t.E(e,n.head,1)||n.head>0&&t.E(e,n.head-1,1)||n.head<e.doc.length&&t.E(e,n.head+1,-1);if(!a||!a.end)return n;i=!0;let o=a.start.from==n.head?a.end.to:a.end.from;return r?t.et.range(n.anchor,o):t.et.cursor(o)});return i?(n(I(e,a)),!0):!1}var hn=({state:e,dispatch:t})=>mn(e,t,!1);function H(e,n,r){let i=F(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=n&&(e=t.et.range(e.head,e.anchor));let i=r(e);return t.et.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return!i.eq(e.state.selection)&&(e.dispatch(I(e.state,i)),!0)}function gn(e,t){return H(e,t,n=>e.moveByChar(n,t))}var _n=e=>gn(e,!z(e)),vn=e=>gn(e,z(e));function yn(e,t){return H(e,t,n=>e.moveByGroup(n,t))}var bn=e=>yn(e,!z(e)),xn=e=>yn(e,z(e)),Sn=e=>{let t=!z(e);return H(e,t,n=>B(e.state,n,t))},Cn=e=>{let t=z(e);return H(e,t,n=>B(e.state,n,t))};function wn(e,t){return H(e,t,n=>e.moveVertically(n,t))}var Tn=e=>wn(e,!1),En=e=>wn(e,!0);function Dn(e,t){return H(e,t,n=>e.moveVertically(n,t,rn(e).height))}var On=e=>Dn(e,!1),kn=e=>Dn(e,!0),An=e=>H(e,!0,t=>V(e,t,!0)),jn=e=>H(e,!1,t=>V(e,t,!1)),Mn=e=>{let t=!z(e);return H(e,t,n=>V(e,n,t))},Nn=e=>{let t=z(e);return H(e,t,n=>V(e,n,t))},Pn=e=>H(e,!1,n=>t.et.cursor(e.lineBlockAt(n.head).from)),Fn=e=>H(e,!0,n=>t.et.cursor(e.lineBlockAt(n.head).to)),In=({state:e,dispatch:t})=>(t(I(e,{anchor:0})),!0),Ln=({state:e,dispatch:t})=>(t(I(e,{anchor:e.doc.length})),!0),Rn=({state:e,dispatch:t})=>(t(I(e,{anchor:e.selection.main.anchor,head:0})),!0),zn=({state:e,dispatch:t})=>(t(I(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Bn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Vn=({state:e,dispatch:n})=>{let r=ar(e).map(({from:n,to:r})=>t.et.undirectionalRange(n,Math.min(r+1,e.doc.length)));return n(e.update({selection:t.et.create(r),userEvent:`select`})),!0},Hn=({state:e,dispatch:n})=>{let r=F(e.selection,n=>{let r=t.k(e),i=r.resolveStack(n.from,1);if(n.empty){let e=r.resolveStack(n.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:r}=e;if((r.from<n.from&&r.to>=n.to||r.to>n.to&&r.from<=n.from)&&e.next)return t.et.undirectionalRange(r.from,r.to)}return n});return!r.eq(e.selection)&&(n(I(e,r)),!0)};function Un(e,n){let{state:r}=e,i=r.selection,a=r.selection.ranges.slice();for(let t of r.selection.ranges){let i=r.doc.lineAt(t.head);if(n?i.to<e.state.doc.length:i.from>0)for(let r=t;;){let t=e.moveVertically(r,n);if(t.head<i.from||t.head>i.to){a.some(e=>e.head==t.head)||a.push(t);break}if(t.head==r.head)break;r=t}}return a.length!=i.ranges.length&&(e.dispatch(I(r,t.et.create(a,a.length-1))),!0)}var Wn=e=>Un(e,!1),Gn=e=>Un(e,!0),Kn=({state:e,dispatch:n})=>{let r=e.selection,i=null;return r.ranges.length>1?i=t.et.create([r.main]):r.main.empty||(i=t.et.create([t.et.cursor(r.main.head)])),i?(n(I(e,i)),!0):!1};function U(e,n){if(e.state.readOnly)return!1;let r=`delete.selection`,{state:i}=e,a=i.changeByRange(i=>{let{from:a,to:o}=i;if(a==o){let t=n(i);t<a?(r=`delete.backward`,t=qn(e,t,!1)):t>a&&(r=`delete.forward`,t=qn(e,t,!0)),a=Math.min(a,t),o=Math.max(o,t)}else a=qn(e,a,!1),o=qn(e,o,!0);return a==o?{range:i}:{changes:{from:a,to:o},range:t.et.cursor(a,a<i.head?-1:1)}});return!a.changes.empty&&(e.dispatch(i.update(a,{scrollIntoView:!0,userEvent:r,effects:r==`delete.selection`?t.M.announce.of(i.phrase(`Selection deleted`)):void 0})),!0)}function qn(e,n,r){if(e instanceof t.M)for(let i of e.state.facet(t.M.atomicRanges).map(t=>t(e)))i.between(n,n,(e,t)=>{e<n&&t>n&&(n=r?t:e)});return n}var Jn=(e,n,r)=>U(e,i=>{let a=i.from,{state:o}=e,s=o.doc.lineAt(a),c,l;if(r&&!n&&a>s.from&&a<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,a-s.from))){if(c[c.length-1]==` `)return a-1;let e=t.mt(c,o.tabSize)%t.y(o)||t.y(o);for(let t=0;t<e&&c[c.length-1-t]==` `;t++)a--;l=a}else l=t.ht(s.text,a-s.from,n,n)+s.from,l==a&&s.number!=(n?o.doc.lines:1)?l+=n?1:-1:!n&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,a-s.from))&&(l=t.ht(s.text,l-s.from,!1,!1)+s.from);return l}),Yn=e=>Jn(e,!1,!0),Xn=e=>Jn(e,!0,!1),Zn=(e,n)=>U(e,r=>{let i=r.head,{state:a}=e,o=a.doc.lineAt(i),s=a.charCategorizer(i);for(let e=null;;){if(i==(n?o.to:o.from)){i==r.head&&o.number!=(n?a.doc.lines:1)&&(i+=n?1:-1);break}let c=t.ht(o.text,i-o.from,n)+o.from,l=o.text.slice(Math.min(i,c)-o.from,Math.max(i,c)-o.from),u=s(l);if(e!=null&&u!=e)break;(l!=` `||i!=r.head)&&(e=u),i=c}return i}),Qn=e=>Zn(e,!1),$n=e=>Zn(e,!0),er=e=>U(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),tr=e=>U(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),nr=e=>U(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),rr=({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t.lt.of([``,``])},range:t.et.cursor(e.from)}));return n(e.update(r,{scrollIntoView:!0,userEvent:`input`})),!0},ir=({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let r=n.from,i=e.doc.lineAt(r),a=r==i.from?r-1:t.ht(i.text,r-i.from,!1)+i.from,o=r==i.to?r+1:t.ht(i.text,r-i.from,!0)+i.from;return{changes:{from:a,to:o,insert:e.doc.slice(r,o).append(e.doc.slice(a,r))},range:t.et.cursor(o)}});return!r.changes.empty&&(n(e.update(r,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function ar(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function or(e,n,r){if(e.readOnly)return!1;let i=[],a=[];for(let n of ar(e)){if(r?n.to==e.doc.length:n.from==0)continue;let o=e.doc.lineAt(r?n.to+1:n.from-1),s=o.length+1;if(r){i.push({from:n.to,to:o.to},{from:n.from,insert:o.text+e.lineBreak});for(let r of n.ranges)a.push(t.et.range(Math.min(e.doc.length,r.anchor+s),Math.min(e.doc.length,r.head+s)))}else{i.push({from:o.from,to:n.from},{from:n.to,insert:e.lineBreak+o.text});for(let e of n.ranges)a.push(t.et.range(e.anchor-s,e.head-s))}}return i.length?(n(e.update({changes:i,scrollIntoView:!0,selection:t.et.create(a,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var sr=({state:e,dispatch:t})=>or(e,t,!1),cr=({state:e,dispatch:t})=>or(e,t,!0);function lr(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of ar(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var ur=({state:e,dispatch:t})=>lr(e,t,!1),dr=({state:e,dispatch:t})=>lr(e,t,!0),fr=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ar(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=F(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function pr(e,n){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(n-1,n+1)))return{from:n,to:n};let r=t.k(e).resolveInner(n),i=r.childBefore(n),a=r.childAfter(n),o;return i&&a&&i.to<=n&&a.from>=n&&(o=i.type.prop(t.Ct.closedBy))&&o.indexOf(a.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(a.from).from&&!/\S/.test(e.sliceDoc(i.to,a.from))?{from:i.to,to:a.from}:null}var mr=gr(!1),hr=gr(!0);function gr(e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=n.changeByRange(r=>{let{from:i,to:a}=r,o=n.doc.lineAt(i),s=!e&&i==a&&pr(n,i);e&&(i=a=(a<=o.to?o:n.doc.lineAt(a)).to);let c=new t.t(n,{simulateBreak:i,simulateDoubleBreak:!!s}),l=t.b(c,i);for(l??=t.mt(/^\s*/.exec(n.doc.lineAt(i).text)[0],n.tabSize);a<o.to&&/\s/.test(o.text[a-o.from]);)a++;s?{from:i,to:a}=s:i>o.from&&i<o.from+100&&!/\S/.test(o.text.slice(0,i))&&(i=o.from);let u=[``,t.C(n,l)];return s&&u.push(t.C(n,c.lineIndent(o.from,-1))),{changes:{from:i,to:a,insert:t.lt.of(u)},range:t.et.cursor(i+1+u[1].length)}});return r(n.update(i,{scrollIntoView:!0,userEvent:`input`})),!0}}function _r(e,n){let r=-1;return e.changeByRange(i=>{let a=[];for(let t=i.from;t<=i.to;){let o=e.doc.lineAt(t);o.number>r&&(i.empty||i.to>o.from)&&(n(o,a,i),r=o.number),t=o.to+1}let o=e.changes(a);return{changes:a,range:t.et.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var vr=({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=Object.create(null),i=new t.t(e,{overrideIndentation:e=>r[e]??-1}),a=_r(e,(n,a,o)=>{let s=t.b(i,n.from);if(s==null)return;/\S/.test(n.text)||(s=0);let c=/^\s*/.exec(n.text)[0],l=t.C(e,s);(c!=l||o.from<n.from+c.length)&&(r[n.from]=s,a.push({from:n.from,to:n.from+c.length,insert:l}))});return a.changes.empty||n(e.update(a,{userEvent:`indent`})),!0},yr=({state:e,dispatch:n})=>!e.readOnly&&(n(e.update(_r(e,(n,r)=>{r.push({from:n.from,insert:e.facet(t.w)})}),{userEvent:`input.indent`})),!0),br=({state:e,dispatch:n})=>!e.readOnly&&(n(e.update(_r(e,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let a=t.mt(i,e.tabSize),o=0,s=t.C(e,Math.max(0,a-t.y(e)));for(;o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+i.length,insert:s.slice(o)})}),{userEvent:`delete.dedent`})),!0),xr=e=>(e.setTabFocusMode(),!0),Sr=[{key:`Ctrl-b`,run:Kt,shift:_n,preventDefault:!0},{key:`Ctrl-f`,run:qt,shift:vn},{key:`Ctrl-p`,run:tn,shift:Tn},{key:`Ctrl-n`,run:nn,shift:En},{key:`Ctrl-a`,run:fn,shift:Pn},{key:`Ctrl-e`,run:pn,shift:Fn},{key:`Ctrl-d`,run:Xn},{key:`Ctrl-h`,run:Yn},{key:`Ctrl-k`,run:er},{key:`Ctrl-Alt-h`,run:Qn},{key:`Ctrl-o`,run:rr},{key:`Ctrl-t`,run:ir},{key:`Ctrl-v`,run:sn}],Cr=[{key:`ArrowLeft`,run:Kt,shift:_n,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Yt,shift:bn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:un,shift:Mn,preventDefault:!0},{key:`ArrowRight`,run:qt,shift:vn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Xt,shift:xn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:dn,shift:Nn,preventDefault:!0},{key:`ArrowUp`,run:tn,shift:Tn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:In,shift:Rn},{mac:`Ctrl-ArrowUp`,run:on,shift:On},{key:`ArrowDown`,run:nn,shift:En,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Ln,shift:zn},{mac:`Ctrl-ArrowDown`,run:sn,shift:kn},{key:`PageUp`,run:on,shift:On},{key:`PageDown`,run:sn,shift:kn},{key:`Home`,run:ln,shift:jn,preventDefault:!0},{key:`Mod-Home`,run:In,shift:Rn},{key:`End`,run:cn,shift:An,preventDefault:!0},{key:`Mod-End`,run:Ln,shift:zn},{key:`Enter`,run:mr,shift:mr},{key:`Mod-a`,run:Bn},{key:`Backspace`,run:Yn,shift:Yn,preventDefault:!0},{key:`Delete`,run:Xn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Qn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:$n,preventDefault:!0},{mac:`Mod-Backspace`,run:tr,preventDefault:!0},{mac:`Mod-Delete`,run:nr,preventDefault:!0}].concat(Sr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),wr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Qt,shift:Sn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:$t,shift:Cn},{key:`Alt-ArrowUp`,run:sr},{key:`Shift-Alt-ArrowUp`,run:ur},{key:`Alt-ArrowDown`,run:cr},{key:`Shift-Alt-ArrowDown`,run:dr},{key:`Mod-Alt-ArrowUp`,run:Wn},{key:`Mod-Alt-ArrowDown`,run:Gn},{key:`Escape`,run:Kn},{key:`Mod-Enter`,run:hr},{key:`Alt-l`,mac:`Ctrl-l`,run:Vn},{key:`Mod-i`,run:Hn,preventDefault:!0},{key:`Mod-[`,run:br},{key:`Mod-]`,run:yr},{key:`Mod-Alt-\\`,run:vr},{key:`Shift-Mod-k`,run:fr},{key:`Shift-Mod-\\`,run:hn},{key:`Mod-/`,run:ht},{key:`Alt-A`,mac:`Ctrl-A`,run:vt},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:xr}].concat(Cr),Tr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,Er=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Tr(e)):Tr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return t.dt(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 n=t.gt(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=t.ft(e);let i=this.normalize(n);if(i.length)for(let e=0,t=r,a=!0;;e++){let r=i.charCodeAt(e),o=this.match(r,t,a,this.bufferPos+this.bufferStart,e==i.length-1);if(o)return this.value=o,this;if(e==i.length-1)break;a&&e<n.length&&n.charCodeAt(e)==r?t++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(Er.prototype[Symbol.iterator]=function(){return this});var Dr={from:-1,to:-1,match:/.*/.exec(``),precise:!0},Or=`gm`+(/x/.unicode==null?``:`u`),kr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Dr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Mr(e,t,n,r,i);this.re=new RegExp(t,Or+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=Nr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Nr(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Ar=new WeakMap,jr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Ar.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Ar.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Ar.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Mr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Dr,this.matchPos=Nr(e,r),this.re=new RegExp(t,Or+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=jr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=Nr(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=jr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(kr.prototype[Symbol.iterator]=Mr.prototype[Symbol.iterator]=function(){return this});function Nr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Pr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Fr=t.nt.define({combine(e){return t.pt(e,Pr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Ir(e){let t=[Hr,Vr];return e&&t.push(Fr.of(e)),t}var Lr=t.A.mark({class:`cm-selectionMatch`}),Rr=t.A.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function zr(e,n,r,i){return(r==0||e(n.sliceDoc(r-1,r))!=t.Q.Word)&&(i==n.doc.length||e(n.sliceDoc(i,i+1))!=t.Q.Word)}function Br(e,n,r,i){return e(n.sliceDoc(r,r+1))==t.Q.Word&&e(n.sliceDoc(i-1,i))==t.Q.Word}var Vr=t.P.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let n=e.state.facet(Fr),{state:r}=e,i=r.selection;if(i.ranges.length>1)return t.A.none;let a=i.main,o,s=null;if(a.empty){if(!n.highlightWordAroundCursor)return t.A.none;let e=r.wordAt(a.head);if(!e)return t.A.none;s=r.charCategorizer(a.head),o=r.sliceDoc(e.from,e.to)}else{let e=a.to-a.from;if(e<n.minSelectionLength||e>200)return t.A.none;if(n.wholeWords){if(o=r.sliceDoc(a.from,a.to),s=r.charCategorizer(a.head),!(zr(s,r,a.from,a.to)&&Br(s,r,a.from,a.to)))return t.A.none}else if(o=r.sliceDoc(a.from,a.to),!o)return t.A.none}let c=[];for(let i of e.visibleRanges){let e=new Er(r.doc,o,i.from,i.to);for(;!e.next().done;){let{from:i,to:o}=e.value;if((!s||zr(s,r,i,o))&&(a.empty&&i<=a.from&&o>=a.to?c.push(Rr.range(i,o)):(i>=a.to||o<=a.from)&&c.push(Lr.range(i,o)),c.length>n.maxMatches))return t.A.none}}return t.A.set(c)}},{decorations:e=>e.decorations}),Hr=t.M.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Ur=({state:e,dispatch:n})=>{let{selection:r}=e,i=t.et.create(r.ranges.map(n=>e.wordAt(n.head)||t.et.cursor(n.head)),r.mainIndex);return!i.eq(r)&&(n(e.update({selection:i})),!0)};function Wr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new Er(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new Er(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Gr=({state:e,dispatch:n})=>{let{ranges:r}=e.selection;if(r.some(e=>e.from===e.to))return Ur({state:e,dispatch:n});let i=e.sliceDoc(r[0].from,r[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=i))return!1;let a=Wr(e,i);return a?(n(e.update({selection:e.selection.addRange(t.et.range(a.from,a.to),!1),effects:t.M.scrollIntoView(a.to)})),!0):!1};async function W(e){return t.s.define(await e())}var Kr=async()=>(await Promise.resolve().then(()=>require("./dist-BLS46S7g.cjs")).then(e=>e.t)).javascript({typescript:!0}),qr=async()=>(await Promise.resolve().then(()=>require("./dist-BLS46S7g.cjs")).then(e=>e.t)).javascript({typescript:!0,jsx:!0}),Jr=async()=>(await Promise.resolve().then(()=>require("./dist-BLS46S7g.cjs")).then(e=>e.t)).javascript({jsx:!0}),Yr=async()=>(await Promise.resolve().then(()=>require("./dist-vBlUeRrZ.cjs"))).json(),Xr=async()=>(await Promise.resolve().then(()=>require("./dist-CpsCEkIr.cjs")).then(e=>e.r)).css(),Zr=async()=>(await Promise.resolve().then(()=>require("./dist-BF9tfVH8.cjs"))).html(),Qr=async()=>(await Promise.resolve().then(()=>require("./dist-B9TXDASo.cjs"))).xml(),$r=async()=>(await Promise.resolve().then(()=>require("./dist-CPxwFKs7.cjs"))).markdown(),ei=async()=>(await Promise.resolve().then(()=>require("./dist-W-WjEDJm.cjs"))).python(),ti=async()=>(await Promise.resolve().then(()=>require("./dist-CGPxOMk5.cjs"))).go(),ni=async()=>(await Promise.resolve().then(()=>require("./dist-Lxxq5IH0.cjs"))).rust(),ri=async()=>(await Promise.resolve().then(()=>require("./dist-c-DRw6Dh.cjs"))).java(),G=async()=>(await Promise.resolve().then(()=>require("./dist-CkDnvyBs.cjs"))).cpp(),ii=async()=>(await Promise.resolve().then(()=>require("./dist-CEPd6ecF.cjs"))).php(),ai=async()=>(await Promise.resolve().then(()=>require("./dist-CELe3Rxj.cjs"))).sql(),oi=async()=>(await Promise.resolve().then(()=>require("./dist-sM-IE5EO.cjs"))).yaml(),si=()=>W(async()=>(await Promise.resolve().then(()=>require("./shell-CD1ADQh5.cjs"))).shell),ci=()=>W(async()=>(await Promise.resolve().then(()=>require("./dockerfile-C67wRfne.cjs"))).dockerFile),li=()=>W(async()=>(await Promise.resolve().then(()=>require("./toml-OuUxin0A.cjs"))).toml),K=()=>W(async()=>(await Promise.resolve().then(()=>require("./properties-XjDvZYDm.cjs"))).properties),ui={ts:Kr,mts:Kr,cts:Kr,tsx:qr,js:Jr,jsx:Jr,mjs:Jr,cjs:Jr,json:Yr,jsonc:Yr,css:Xr,scss:Xr,less:Xr,html:Zr,htm:Zr,xml:Qr,svg:Qr,md:$r,markdown:$r,py:ei,go:ti,rs:ni,java:ri,c:G,h:G,cpp:G,cc:G,cxx:G,hpp:G,php:ii,sql:ai,yaml:oi,yml:oi,sh:si,bash:si,zsh:si,toml:li,ini:K,cfg:K,properties:K,env:K,rb:()=>W(async()=>(await Promise.resolve().then(()=>require("./ruby-Bx72aP7E.cjs"))).ruby),cs:()=>W(async()=>(await Promise.resolve().then(()=>require("./clike-I-fVVl3d.cjs"))).csharp)};function di(e){let t=e.split(`/`).pop()??e;if(/^dockerfile$/i.test(t))return ci();if(/^\.env(\..+)?$/.test(t))return K();let n=t.lastIndexOf(`.`),r=n<0?void 0:ui[t.slice(n+1).toLowerCase()];return r===void 0?Promise.resolve(null):r()}var q=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function J(e,t,n,r,i,a){if(e==r)return[];let o=vi(e,t,n,r,i,a),s=yi(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new q(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new q(t,t+o,i,i),new q(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new q(t,t,i,i+o),new q(n,n,i+o+c,a)]}if(c==1||l==1)return[new q(t,n,i,a)];let u=xi(e,t,n,r,i,a);if(u){let[o,s,c]=u;return J(e,t,o,r,i,s).concat(J(e,o+c,n,r,s+c,a))}return fi(e,t,n,r,i,a)}var Y=1e9,X=0;function fi(e,t,n,r,i,a){let o=n-t,s=a-i;if(Y<1e9&&Math.min(o,s)>Y*16||X>0&&Date.now()>X)return Math.min(o,s)>Y*64?[new q(t,n,i,a)]:Si(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);mi.reset(c),hi.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:hi,f=d?null:mi;for(let p=0;p<c;p++){if(p>Y||X>0&&!(p&63)&&Date.now()>X)return Si(e,t,n,r,i,a);let m=mi.advance(p,o,s,c,d,!1,l)||hi.advance(p,o,s,c,f,!0,u);if(m)return gi(e,t,n,t+m[0],r,i,a,i+m[1])}return[new q(t,n,i,a)]}var pi=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1){if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}}return null}},mi=new pi,hi=new pi;function gi(e,t,n,r,i,a,o,s){let c=!1;return!Z(e,r)&&++r==n&&(c=!0),!Z(i,s)&&++s==o&&(c=!0),c?[new q(t,n,a,o)]:J(e,t,r,i,a,s).concat(J(e,r,n,i,s,o))}function _i(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function vi(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=_i(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-+!Z(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function yi(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=_i(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-+!Z(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function bi(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){Z(e,s)||s++;let u=s+o;if(Z(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=vi(e,u,n,r,i+f+d.length,a),c=yi(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function xi(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=xi(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:bi(e,t,n,r,i,a,Math.floor(o/4),-1)}function Si(e,t,n,r,i,a){let o=n-t,s=a-i,c;if(o<s){let s=bi(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=bi(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new q(t,n,i,a)];let[l,u,d]=c;return J(e,t,l,r,i,u).concat(J(e,l+d,n,r,u+d,a))}function Ci(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new q(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function wi(e,t,n){for(;;){Ci(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=vi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new q(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=yi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new q(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new q(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new q(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}var Ti=e=>e>=55296&&e<=56319,Ei=e=>e>=56320&&e<=57343;function Z(e,t){return!t||t==e.length||!Ti(e.charCodeAt(t-1))||!Ei(e.charCodeAt(t))}function Di(e,t,n){let r=n?.override;return r?r(e,t):(Y=(n?.scanLimit??1e9)>>1,X=n?.timeout?Date.now()+n.timeout:0,wi(e,t,J(e,0,e.length,t,0,t.length)))}function Oi(e){return e.fromA===e.toA?`added`:e.fromB===e.toB?`deleted`:`modified`}function ki(e){return e.split(/\r?\n/)}var Ai=256,ji=2048,Mi=63232;function Ni(e){let t=Ai+e;return String.fromCharCode(t>=55296?t+ji:t)}function Pi(e,t){let n=new Map,r=e=>{let t=``;for(let r of e){let e=n.get(r);if(e===void 0){if(n.size>=Mi)return null;e=Ni(n.size),n.set(r,e)}t+=e}return t},i=r(e),a=r(t);return i===null||a===null?null:Di(i,a).map(({fromA:e,toA:t,fromB:n,toB:r})=>({fromA:e,toA:t,fromB:n,toB:r}))}function Fi(e,n,r){let i=n.slice(r.fromA,r.toA);if(r.fromB===r.toB){if(r.fromB<e.lines){let n=e.line(r.fromB+1).from;return{from:n,to:n,insert:t.lt.of([...i,``])}}return{from:e.length,to:e.length,insert:t.lt.of([``,...i])}}let a=e.line(r.fromB+1).from,o=e.line(r.toB).to;return i.length===0?(r.toB<e.lines?o=e.line(r.toB+1).from:r.fromB>0&&(a=e.line(r.fromB).to),{from:a,to:o,insert:t.lt.empty}):{from:a,to:o,insert:t.lt.of(i)}}var Ii=t.st.define(),Li=t.st.define();function Ri(e){let t=[];for(let n=e.iterLines();!n.next().done;)t.push(n.value);return t}function zi(e,t){return e===null?[]:Pi(e,Ri(t))??[]}function Bi(e,t){let n=t.findIndex(t=>t.fromA===e.fromA&&t.toA===e.toA);return n===-1?null:n}var Q=t.ct.define({create:()=>({baseline:null,hunks:[],open:null}),update(e,t){let{baseline:n,hunks:r,open:i}=e,a=!1;for(let e of t.effects)e.is(Ii)&&(n=e.value===null?null:ki(e.value),i=null,a=!0);if(a||t.docChanged&&n!==null){let e=i===null?void 0:r[i];r=zi(n,t.state.doc),i=e===void 0?null:Bi(e,r)}for(let e of t.effects)e.is(Li)&&(i=i===e.value?null:e.value);return n===e.baseline&&r===e.hunks&&i===e.open?e:{baseline:n,hunks:r,open:i}}}),Vi=class extends t.N{kind;index;atEnd;constructor(e,t,n=!1){super(),this.kind=e,this.index=t,this.atEnd=n}eq(e){return e.kind===this.kind&&e.index===this.index&&e.atEnd===this.atEnd}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-git-mark cm-git-${this.kind}${this.atEnd?` cm-git-at-end`:``}`,t.dataset.gitChange=this.kind,t.title={added:`Added since HEAD: click to see the change`,modified:`Changed since HEAD: click to see what was there`,deleted:`Lines removed since HEAD: click to see them`}[this.kind],t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({effects:Li.of(this.index)})}),t}};function Hi(e){let{hunks:n}=e.field(Q),r=e.doc,i=[];for(let[e,t]of n.entries()){let n=Oi(t);if(n===`deleted`){let a=t.fromB>=r.lines;i.push(new Vi(n,e,a).range(r.line(a?r.lines:t.fromB+1).from))}else for(let a=t.fromB;a<t.toB;a++)i.push(new Vi(n,e).range(r.line(a+1).from))}return t.at.of(i,!0)}var Ui=class extends t.F{index;kind;old;editable;constructor(e,t,n,r){super(),this.index=e,this.kind=t,this.old=n,this.editable=r}eq(e){return e.index===this.index&&e.editable===this.editable&&e.old.join(`
2
- `)===this.old.join(`
3
- `)}toDOM(e){let t=document.createElement(`div`);t.className=`cm-git-peek`,t.setAttribute(`role`,`region`),t.setAttribute(`aria-label`,`HEAD version of this change`);let n=document.createElement(`div`);n.className=`cm-git-peek-bar`;let r=document.createElement(`span`);if(r.textContent=this.kind===`added`?`Not in HEAD`:`In HEAD`,n.append(r),this.editable){let t=document.createElement(`button`);t.type=`button`,t.textContent=`Revert this change`,t.addEventListener(`click`,()=>{let{baseline:t,hunks:n}=e.state.field(Q),r=n[this.index];t!==null&&r!==void 0&&(e.dispatch({changes:Fi(e.state.doc,t,r),userEvent:`input.revert`}),e.focus())}),n.append(t)}let i=document.createElement(`button`);if(i.type=`button`,i.textContent=`Close`,i.addEventListener(`click`,()=>e.dispatch({effects:Li.of(this.index)})),n.append(i),t.append(n),this.old.length>0){let e=document.createElement(`pre`);e.className=`cm-git-peek-old`,e.textContent=this.old.join(`
4
- `),t.append(e)}return t}ignoreEvent(){return!0}};function Wi(e){let n=e.field(Q);if(n.open===null||n.baseline===null)return t.A.none;let r=n.hunks[n.open];if(r===void 0)return t.A.none;let i=e.doc,a=Oi(r),o=n.baseline.slice(r.fromA,r.toA),s=new Ui(n.open,a,o,!e.readOnly),c=a!==`deleted`,l=c?i.line(r.toB):r.fromB<i.lines?i.line(r.fromB+1):i.line(i.lines),u=c||r.fromB>=i.lines;return t.A.set(t.A.widget({widget:s,block:!0,side:u?1:-1}).range(u?l.to:l.from))}function Gi(){return[Q,t.M.decorations.compute([Q],Wi),t.B({class:`cm-git-gutter`,markers:e=>Hi(e.state),lineMarkerChange:e=>e.startState.field(Q)!==e.state.field(Q)})]}var Ki=e.n({CodeEditor:()=>Qi,detectIndentUnit:()=>Yi,documentPosition:()=>$}),qi=t.st.define(),Ji=t.ct.define({create:()=>t.A.none,update(e,n){for(let e of n.effects)if(e.is(qi))return t.A.set(e.value.map(({from:e,to:n,current:r})=>t.A.mark({class:r?`find-match-current`:`find-match`}).range(e,n)),!0);return e.map(n.changes)},provide:e=>t.M.decorations.from(e)});function Yi(e){if(/^\t/m.test(e))return` `;let t=[...e.matchAll(/^( +)\S/gm)].map(e=>e[1].length).filter(e=>e>=2&&e<=8);return` `.repeat(t.length===0?2:Math.min(...t))}function $(e,t){let n=0;for(let r=e.indexOf(`\r
5
- `);r!==-1&&r<t-1;r=e.indexOf(`\r
6
- `,r+2))n++;return t-n}var Xi=({state:e,dispatch:n})=>e.selection.ranges.some(e=>!e.empty)?yr({state:e,dispatch:n}):(n(e.update(e.replaceSelection(e.facet(t.w)),{scrollIntoView:!0,userEvent:`input`})),!0);function Zi(e){return[t.H(),At(),t.R(),t.tt.allowMultipleSelections.of(!0),t.S(),Xe(),ft({activateOnTyping:!1}),t.q(),t.I(),t.V(),t.W.of([...[`Ctrl-s`,`Meta-s`].map(t=>({key:t,preventDefault:!0,run:()=>(e.current.onSave?.(),!0)})),{key:`Mod-d`,run:Gr,preventDefault:!0},...nt,...wr,...Wt,...t.g,...pt,{key:`Tab`,run:Xi,shift:br,preventDefault:!0}]),t.M.updateListener.of(t=>{t.docChanged&&e.current.onChange?.(t.state.sliceDoc())})]}function Qi({value:e,path:i,onChange:a,onSave:o,handle:s,readOnly:c=!1,baseline:l=null,label:u=c?`File source`:`File editor`}){let d=(0,n.useRef)(null),f=(0,n.useRef)(null),p=(0,n.useRef)({onChange:a,onSave:o});p.current={onChange:a,onSave:o},(0,n.useImperativeHandle)(s,()=>({focus:()=>f.current?.focus(),select(e,n){let r=f.current;if(r===null)return;let i=r.state.sliceDoc(),a=r.state.doc.length,o=Math.min($(i,e),a),s=Math.min($(i,n),a);r.dispatch({selection:t.et.single(o,s),effects:t.M.scrollIntoView(o,{y:`center`})})},markMatches(e,t){let n=f.current;if(n===null)return;let r=n.state.sliceDoc(),i=n.state.doc.length,a=e.map(({start:e,end:n},a)=>({from:Math.min($(r,e),i),to:Math.min($(r,n),i),current:a===t})).filter(({from:e,to:t})=>e<t);n.dispatch({effects:qi.of(a)})}})),(0,n.useEffect)(()=>{let n=new t.$,r=new t.M({parent:d.current,state:t.tt.create({doc:e,extensions:[t.tt.lineSeparator.of(e.includes(`\r
7
- `)?`\r
8
- `:`
9
- `),t.w.of(Yi(e)),t.G(),Gi(),t.U(),t.m(),t.L(),t.O(t.vt),t.c(),Ir(),Ji,t.M.lineWrapping,t.M.contentAttributes.of({"aria-label":u,spellcheck:`false`}),...c?[t.tt.readOnly.of(!0),t.M.editable.of(!1),t.W.of(t.g)]:Zi(p),n.of([])]})});f.current=r,l!==null&&r.dispatch({effects:Ii.of(l)}),c||r.focus();let a=!0;return di(i).then(e=>{a&&e!==null&&r.dispatch({effects:n.reconfigure(e)})},()=>{}),()=>{a=!1,r.destroy(),f.current=null}},[]),(0,n.useEffect)(()=>{let t=f.current;t!==null&&t.state.sliceDoc()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e]);let m=(0,n.useRef)(l);return(0,n.useEffect)(()=>{let e=f.current;e!==null&&m.current!==l&&(m.current=l,e.dispatch({effects:Ii.of(l)}))},[l]),(0,r.jsx)(`div`,{ref:d,className:`code-editor h-full w-full`,"data-testid":c?`file-source`:`file-editor`})}exports.CodeEditor=Qi,exports.a=Ke,exports.detectIndentUnit=Yi,exports.documentPosition=$,exports.i=c,exports.n=i,exports.r=s,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ki}});