sage-agent-internal 0.1.31__py3-none-any.whl → 0.1.31rc0__py3-none-any.whl
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.
- sage_agent_internal/_version.py +1 -1
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/package.json +4 -3
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/schemas/sage-agent-internal/package.json.orig +3 -2
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/schemas/sage-agent-internal/plugin.json +5 -5
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/353.2c285601a208c3735929.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/363.d6c25400a011b62fbae6.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/439.3cb9ac7022c8a6074647.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/635.8c395c854aa2b140b668.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/747.b8e9485ebcbb3066eb4b.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/821.b58f29814f5900f1f6f8.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/833.1509794f6b586558f96c.js +1 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/973.38ee5148a3908e41c2dd.js +2 -0
- sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/remoteEntry.b4d298844205dc8d9771.js +1 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/third-party-licenses.json +35 -5
- {sage_agent_internal-0.1.31.dist-info → sage_agent_internal-0.1.31rc0.dist-info}/METADATA +1 -1
- sage_agent_internal-0.1.31rc0.dist-info/RECORD +33 -0
- sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/379.b3bf2f8d00bdb186e6f8.js +0 -1
- sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/424.58d3508585951cee4f35.js +0 -1
- sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/439.61293ec148172a793000.js +0 -1
- sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/540.283f7cceb475717261ed.js +0 -1
- sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/982.e8f28fa7892d44e0d1bb.js +0 -2
- sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/remoteEntry.28bb17beaf868e051da1.js +0 -1
- sage_agent_internal-0.1.31.dist-info/RECORD +0 -30
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/install.json +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/122.3c2c200586e65203b674.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/220.d384edfd5bbcfda33a2a.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/262.3fc4ad88e6f8c273d4ad.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/364.c2fb82c6f484097228c6.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/481.96b91d018df31d54d173.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/553.b7906877d98a62265533.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/553.b7906877d98a62265533.js.LICENSE.txt +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/713.103cb5ae248be385b08a.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/742.b204789055ded4e07883.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/845.cc2bc80fbfea6d20a396.js +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/888.09382cc93a2ad3932b31.js +0 -0
- /sage_agent_internal-0.1.31.data/data/share/jupyter/labextensions/sage-agent-internal/static/982.e8f28fa7892d44e0d1bb.js.LICENSE.txt → /sage_agent_internal-0.1.31rc0.data/data/share/jupyter/labextensions/sage-agent-internal/static/973.38ee5148a3908e41c2dd.js.LICENSE.txt +0 -0
- {sage_agent_internal-0.1.31.data → sage_agent_internal-0.1.31rc0.data}/data/share/jupyter/labextensions/sage-agent-internal/static/style.js +0 -0
- {sage_agent_internal-0.1.31.dist-info → sage_agent_internal-0.1.31rc0.dist-info}/WHEEL +0 -0
- {sage_agent_internal-0.1.31.dist-info → sage_agent_internal-0.1.31rc0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[747],{2747:(t,e,i)=>{i.d(e,{Ar:()=>c,Bc:()=>xt,Gw:()=>ct,OO:()=>Tt,et:()=>a,wm:()=>mt,yU:()=>Dt});var o=i(195),n=i(5024),s=i(2084);class l{constructor(t,e,i,o){this.state=t,this.pos=e,this.explicit=i,this.view=o,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=(0,s.syntaxTree)(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),i=Math.max(e.from,this.pos-250),o=e.text.slice(i-e.from,this.pos-e.from),n=o.search(d(t,!1));return n<0?null:{from:i+n,to:this.pos,text:o.slice(n)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function r(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function a(t){let e=t.map(t=>"string"==typeof t?{label:t}:t),[i,o]=e.every(t=>/^\w+$/.test(t.label))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:o}of t){e[o[0]]=!0;for(let t=1;t<o.length;t++)i[o[t]]=!0}let o=r(e)+r(i)+"*$";return[new RegExp("^"+o),new RegExp(o)]}(e);return t=>{let n=t.matchBefore(o);return n||t.explicit?{from:n?n.from:t.pos,options:e,validFor:i}:null}}function c(t,e){return i=>{for(let e=(0,s.syntaxTree)(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class h{constructor(t,e,i,o){this.completion=t,this.source=e,this.match=i,this.score=o}}function p(t){return t.selection.main.from}function d(t,e){var i;let{source:o}=t,n=e&&"^"!=o[0],s="$"!=o[o.length-1];return n||s?new RegExp(`${n?"^":""}(?:${o})${s?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const f=o.Annotation.define(),u=new WeakMap;function m(t){if(!Array.isArray(t))return t;let e=u.get(t);return e||u.set(t,e=a(t)),e}const g=o.StateEffect.define(),v=o.StateEffect.define();class b{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=(0,o.codePointAt)(t,e),n=(0,o.codePointSize)(i);this.chars.push(i);let s=t.slice(e,e+n),l=s.toUpperCase();this.folded.push((0,o.codePointAt)(l==s?s.toLowerCase():l,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:s,byWord:l}=this;if(1==e.length){let n=(0,o.codePointAt)(t,0),s=(0,o.codePointSize)(n),l=s==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;l+=-200}return this.ret(l,[0,s])}let r=t.indexOf(this.pattern);if(0==r)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,c=0;if(r<0){for(let s=0,l=Math.min(t.length,200);s<l&&c<a;){let l=(0,o.codePointAt)(t,s);l!=e[c]&&l!=i[c]||(n[c++]=s),s+=(0,o.codePointSize)(l)}if(c<a)return null}let h=0,p=0,d=!1,f=0,u=-1,m=-1,g=/[a-z]/.test(t),v=!0;for(let n=0,c=Math.min(t.length,200),b=0;n<c&&p<a;){let c=(0,o.codePointAt)(t,n);r<0&&(h<a&&c==e[h]&&(s[h++]=n),f<a&&(c==e[f]||c==i[f]?(0==f&&(u=n),m=n+1,f++):f=0));let w,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:c>=65&&c<=90?1:0:(w=(0,o.fromCodePoint)(c))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!n||1==y&&g||0==b&&0!=y)&&(e[p]==c||i[p]==c&&(d=!0)?l[p++]=n:l.length&&(v=!1)),b=y,n+=(0,o.codePointSize)(c)}return p==a&&0==l[0]&&v?this.result((d?-200:0)-100,l,t):f==a&&0==u?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):r>-1?this.ret(-700-t.length,[r,r+this.pattern.length]):f==a?this.ret(-900-t.length,[u,m]):p==a?this.result((d?-200:0)-100-700+(v?0:-1100),l,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],s=0;for(let t of e){let e=t+(this.astral?(0,o.codePointSize)((0,o.codePointAt)(i,t)):1);s&&n[s-1]==t?n[s-1]=e:(n[s++]=t,n[s++]=e)}return this.ret(t-i.length,n)}}class w{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),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const y=o.Facet.define({combine:t=>(0,o.combineConfig)(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:C,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)=>i=>x(t(i),e(i)),optionClass:(t,e)=>i=>x(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function x(t,e){return t?e?t+" "+e:t:e}function C(t,e,i,o,s,l){let r,a,c=t.textDirection==n.Direction.RTL,h=c,p=!1,d="top",f=e.left-s.left,u=s.right-e.right,m=o.right-o.left,g=o.bottom-o.top;if(h&&f<Math.min(m,u)?h=!1:!h&&u<Math.min(m,f)&&(h=!0),m<=(h?f:u))r=Math.max(s.top,Math.min(i.top,s.bottom-g))-e.top,a=Math.min(400,h?f:u);else{p=!0,a=Math.min(400,(c?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=g||t>e.top?r=i.bottom-e.top:(d="bottom",r=e.bottom-i.top)}return{style:`${d}: ${r/((e.bottom-e.top)/l.offsetHeight)}px; max-width: ${a/((e.right-e.left)/l.offsetWidth)}px`,class:"cm-completionInfo-"+(p?c?"left-narrow":"right-narrow":h?"left":"right")}}function S(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let o=Math.floor((t-e)/i);return{from:t-(o+1)*i,to:t-o*i}}class E{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,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:n,selected:s}=o.open,l=t.state.facet(y);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,i,o){let n=document.createElement("span");n.className="cm-completionLabel";let s=t.displayLabel||t.label,l=0;for(let t=0;t<o.length;){let e=o[t++],i=o[t++];e>l&&n.appendChild(document.createTextNode(s.slice(l,e)));let r=n.appendChild(document.createElement("span"));r.appendChild(document.createTextNode(s.slice(e,i))),r.className="cm-completionMatchedText",l=i}return l<s.length&&n.appendChild(document.createTextNode(s.slice(l))),n},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=S(n.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",i=>{let{options:o}=t.state.field(e).open;for(let e,n=i.target;n&&n!=this.dom;n=n.parentNode)if("LI"==n.nodeName&&(e=/-(\d+)$/.exec(n.id))&&+e[1]<o.length)return this.applyCompletion(t,o[+e[1]]),void i.preventDefault()}),this.dom.addEventListener("focusout",e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(y).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:v.of(null)})}),this.showOptions(n,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 i=t.state.field(this.stateField),o=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=o){let{options:n,selected:s,disabled:l}=i.open;o.open&&o.open.options==n||(this.range=S(n.length,s,t.state.facet(y).maxRenderedOptions),this.showOptions(n,i.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=S(e.options.length,e.selected,this.view.state.facet(y).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:i}=e.options[e.selected],{info:o}=i;if(!o)return;let s="string"==typeof o?document.createTextNode(o):o(i);if(!s)return;"then"in s?s.then(e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)}).catch(t=>(0,n.logException)(this.view.state,t,"completion info")):this.addInfoPane(s,i)}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:o}=t;i.appendChild(e),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,o=this.range.from;i;i=i.nextSibling,o++)"LI"==i.nodeName&&i.id?o==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):o--;return e&&function(t,e){let i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),n=i.height/t.offsetHeight;o.top<i.top?t.scrollTop-=(i.top-o.top)/n:o.bottom>i.bottom&&(t.scrollTop+=(o.bottom-i.bottom)/n)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),o=t.getBoundingClientRect(),n=this.space;if(!n){let t=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return o.top>Math.min(n.bottom,e.bottom)-10||o.bottom<Math.max(n.top,e.top)+10?null:this.view.state.facet(y).positionInfo(this.view,e,o,i,n,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,i){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")),o.addEventListener("mousedown",t=>{t.target==o&&t.preventDefault()});let n=null;for(let s=i.from;s<i.to;s++){let{completion:l,match:r}=t[s],{section:a}=l;if(a){let t="string"==typeof a?a:a.name;t!=n&&(s>i.from||0==i.from)&&(n=t,"string"!=typeof a&&a.header?o.appendChild(a.header(a)):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 i.from&&o.classList.add("cm-completionListIncompleteTop"),i.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 I(t,e){return i=>new E(i,t,e)}function O(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class P{constructor(t,e,i,o,n,s){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=o,this.selected=n,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new P(this.options,A(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,o,n,s){if(o&&!s&&t.some(t=>t.isPending))return o.setDisabled();let l=function(t,e){let i=[],o=null,n=t=>{i.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(y);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)n(new h(e,o.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(o.from,o.to),r=s.filterStrict?new w(l):new b(l);for(let e of o.result.options)if(i=r.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched;n(new h(e,o.source,s,i.score+(e.boost||0)))}}}if(o){let t=Object.create(null),e=0,n=(t,e)=>{var i,o;return(null!==(i=t.rank)&&void 0!==i?i:1e9)-(null!==(o=e.rank)&&void 0!==o?o:1e9)||(t.name<e.name?-1:1)};for(let i of o.sort(n))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],r=null,a=s.compareCompletions;for(let t of i.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):O(t.completion)>O(r)&&(l[l.length-1]=t),r=t.completion}return l}(t,e);if(!l.length)return o&&t.some(t=>t.isPending)?o.setDisabled():null;let r=e.facet(y).selectOnOpen?0:-1;if(o&&o.selected!=r&&-1!=o.selected){let t=o.options[o.selected].completion;for(let e=0;e<l.length;e++)if(l[e].completion==t){r=e;break}}return new P(l,A(i,r),{pos:t.reduce((t,e)=>e.hasResult()?Math.min(t,e.from):t,1e8),create:V,above:n.aboveCursor},o?o.timestamp:Date.now(),r,!1)}map(t){return new P(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new P(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class k{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new k(R,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(y),o=(i.override||e.languageDataAt("autocomplete",p(e)).map(m)).map(e=>(this.active.find(t=>t.source==e)||new M(e,this.active.some(t=>0!=t.state)?1:0)).update(t,i));o.length==this.active.length&&o.every((t,e)=>t==this.active[e])&&(o=this.active);let n=this.open,s=t.effects.some(t=>t.is(F));n&&t.docChanged&&(n=n.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 i=0,o=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;o<e.length&&!e[o].hasResult();)o++;let n=i==t.length,s=o==e.length;if(n||s)return n==s;if(t[i++].result!=e[o++].result)return!1}}(o,this.active)||s?n=P.build(o,e,this.id,n,i,s):n&&n.disabled&&!o.some(t=>t.isPending)&&(n=null),!n&&o.every(t=>!t.isPending)&&o.some(t=>t.hasResult())&&(o=o.map(t=>t.hasResult()?new M(t.source,0):t));for(let e of t.effects)e.is(U)&&(n=n&&n.setSelected(e.value,this.id));return o==this.active&&n==this.open?this:new k(o,this.id,n)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?D:T}}const D={"aria-autocomplete":"list"},T={};function A(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const R=[];function L(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(f);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class M{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=L(t,e),o=this;(8&i||16&i&&this.touches(t))&&(o=new M(o.source,0)),4&i&&0==o.state&&(o=new M(this.source,1)),o=o.updateFor(t,i);for(let e of t.effects)if(e.is(g))o=new M(o.source,1,e.value);else if(e.is(v))o=new M(o.source,0);else if(e.is(F))for(let t of e.value)t.source==o.source&&(o=t);return o}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(p(t.state))}}class B extends M{constructor(t,e,i,o,n,s){super(t,3,e),this.limit=i,this.result=o,this.from=n,this.to=s}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let o=this.result;o.map&&!t.changes.empty&&(o=o.map(o,t.changes));let n=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),r=p(t.state);if(r>s||!o||2&e&&(p(t.startState)==this.from||r<this.limit))return new M(this.source,4&e?1:0);let a=t.changes.mapPos(this.limit);return function(t,e,i,o){if(!t)return!1;let n=e.sliceDoc(i,o);return"function"==typeof t?t(n,i,o,e):d(t,!0).test(n)}(o.validFor,t.state,n,s)?new B(this.source,this.explicit,a,o,n,s):o.update&&(o=o.update(o,n,s,new l(t.state,r,!1)))?new B(this.source,this.explicit,a,o,o.from,null!==(i=o.to)&&void 0!==i?i:p(t.state)):new M(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new B(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new M(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const F=o.StateEffect.define({map:(t,e)=>t.map(t=>t.map(e))}),U=o.StateEffect.define(),$=o.StateField.define({create:()=>k.start(),update:(t,e)=>t.update(e),provide:t=>[n.showTooltip.from(t,t=>t.tooltip),n.EditorView.contentAttributes.from(t,t=>t.attrs)]});function N(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field($).active.find(t=>t.source==e.source);return n instanceof B&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},function(t,e,i,n){let{main:s}=t.selection,l=i-s.from,r=n-s.from;return Object.assign(Object.assign({},t.changeByRange(a=>{if(a!=s&&i!=n&&t.sliceDoc(a.from+l,a.from+r)!=t.sliceDoc(i,n))return{range:a};let c=t.toText(e);return{changes:{from:a.from+l,to:n==s.from?a.to:a.from+r,insert:c},range:o.EditorSelection.cursor(a.from+l+c.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,i,n.from,n.to)),{annotations:f.of(e.completion)})):i(t,e.completion,n.from,n.to),!0)}const V=I($,N);function j(t,e="option"){return i=>{let o=i.state.field($,!1);if(!o||!o.open||o.open.disabled||Date.now()-o.open.timestamp<i.state.facet(y).interactionDelay)return!1;let s,l=1;"page"==e&&(s=(0,n.getTooltip)(i,o.open.tooltip))&&(l=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:r}=o.open.options,a=o.open.selected>-1?o.open.selected+l*(t?1:-1):t?0:r-1;return a<0?a="page"==e?0:r-1:a>=r&&(a="page"==e?r-1:0),i.dispatch({effects:U.of(a)}),!0}}const z=t=>!!t.state.field($,!1)&&(t.dispatch({effects:g.of(!0)}),!0);class W{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const q=n.ViewPlugin.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($).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field($),i=t.state.facet(y);if(!t.selectionSet&&!t.docChanged&&t.startState.field($)==e)return;let o=t.transactions.some(t=>{let e=L(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)});for(let e=0;e<this.running.length;e++){let i=this.running[e];if(o||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){(0,n.logException)(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(t=>t.effects.some(t=>t.is(g)))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(t=>t.isPending&&!this.running.some(e=>e.active.source==t.source))?setTimeout(()=>this.startUpdate(),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field($);for(let t of e.active)t.isPending&&!this.running.some(e=>e.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(y).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=p(e),o=new l(e,i,t.explicit,this.view),s=new W(t,o);this.running.push(s),Promise.resolve(t.source(o)).then(t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())},t=>{this.view.dispatch({effects:v.of(null)}),(0,n.logException)(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(y).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(y),o=this.view.state.field($);for(let n=0;n<this.running.length;n++){let s=this.running[n];if(void 0===s.done)continue;if(this.running.splice(n--,1),s.done){let o=p(s.updates.length?s.updates[0].startState:this.view.state),n=Math.min(o,s.done.from+(s.active.explicit?0:1)),l=new B(s.active.source,s.active.explicit,n,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:o);for(let t of s.updates)l=l.update(t,i);if(l.hasResult()){e.push(l);continue}}let l=o.active.find(t=>t.source==s.active.source);if(l&&l.isPending)if(null==s.done){let t=new M(s.active.source,0);for(let e of s.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(l)}(e.length||o.open&&o.open.disabled)&&this.view.dispatch({effects:F.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field($,!1);if(e&&e.tooltip&&this.view.state.facet(y).closeOnBlur){let i=e.open&&(0,n.getTooltip)(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:v.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:g.of(!1)}),20),this.composing=0}}}),H="object"==typeof navigator&&/Win/.test(navigator.platform),K=o.Prec.highest(n.EditorView.domEventHandlers({keydown(t,e){let i=e.state.field($,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!H||!t.altKey)||t.metaKey)return!1;let o=i.open.options[i.open.selected],n=i.active.find(t=>t.source==o.source),s=o.completion.commitCharacters||n.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&N(e,o),!1}})),_=n.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Q{constructor(t,e,i,o){this.field=t,this.line=e,this.from=i,this.to=o}}class X{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,o.MapMode.TrackDel),i=t.mapPos(this.to,1,o.MapMode.TrackDel);return null==e||null==i?null:new X(this.field,e,i)}}class G{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],o=[e],n=t.doc.lineAt(e),l=/^\s*/.exec(n.text)[0];for(let n of this.lines){if(i.length){let i=l,r=/^\t*/.exec(n)[0].length;for(let e=0;e<r;e++)i+=t.facet(s.indentUnit);o.push(e+i.length-r),n=i+n.slice(r)}i.push(n),e+=n.length+1}let r=this.fieldPositions.map(t=>new X(t.field,o[t.line]+t.from,o[t.line]+t.to));return{text:i,ranges:r}}static parse(t){let e,i=[],o=[],n=[];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<i.length;e++)(null!=t?i[e].seq==t:a&&i[e].name==a)&&(r=e);if(r<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:a}),r=e;for(let t of n)t.field>=r&&t.field++}n.push(new Q(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,i)=>{for(let t of n)t.line==o.length&&t.from>i&&(t.from--,t.to--);return e}),o.push(s)}return new G(o,n)}}let Y=n.Decoration.widget({widget:new class extends n.WidgetType{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),J=n.Decoration.mark({class:"cm-snippetField"});class Z{constructor(t,e){this.ranges=t,this.active=e,this.deco=n.Decoration.set(t.map(t=>(t.from==t.to?Y:J).range(t.from,t.to)))}map(t){let e=[];for(let i of this.ranges){let o=i.map(t);if(!o)return null;e.push(o)}return new Z(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 tt=o.StateEffect.define({map:(t,e)=>t&&t.map(e)}),et=o.StateEffect.define(),it=o.StateField.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(tt))return i.value;if(i.is(et)&&t)return new Z(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>n.EditorView.decorations.from(t,t=>t?t.deco:n.Decoration.none)});function ot(t,e){return o.EditorSelection.create(t.filter(t=>t.field==e).map(t=>o.EditorSelection.range(t.from,t.to)))}function nt(t){let e=G.parse(t);return(t,i,n,s)=>{let{text:l,ranges:r}=e.instantiate(t.state,n),{main:a}=t.state.selection,c={changes:{from:n,to:s==a.from?a.to:s,insert:o.Text.of(l)},scrollIntoView:!0,annotations:i?[f.of(i),o.Transaction.userEvent.of("input.complete")]:void 0};if(r.length&&(c.selection=ot(r,0)),r.some(t=>t.field>0)){let e=new Z(r,0),i=c.effects=[tt.of(e)];void 0===t.state.field(it,!1)&&i.push(o.StateEffect.appendConfig.of([it,at,ht,_]))}t.dispatch(t.state.update(c))}}function st(t){return({state:e,dispatch:i})=>{let o=e.field(it,!1);if(!o||t<0&&0==o.active)return!1;let n=o.active+t,s=t>0&&!o.ranges.some(e=>e.field==n+t);return i(e.update({selection:ot(o.ranges,n),effects:tt.of(s?null:new Z(o.ranges,n)),scrollIntoView:!0})),!0}}const lt=[{key:"Tab",run:st(1),shift:st(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(it,!1)&&(e(t.update({effects:tt.of(null)})),!0)}],rt=o.Facet.define({combine:t=>t.length?t[0]:lt}),at=o.Prec.highest(n.keymap.compute([rt],t=>t.facet(rt)));function ct(t,e){return Object.assign(Object.assign({},e),{apply:nt(t)})}const ht=n.EditorView.domEventHandlers({mousedown(t,e){let i,o=e.state.field(it,!1);if(!o||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let n=o.ranges.find(t=>t.from<=i&&t.to>=i);return!(!n||n.field==o.active||(e.dispatch({selection:ot(o.ranges,n.field),effects:tt.of(o.ranges.some(t=>t.field>n.field)?new Z(o.ranges,n.field):null),scrollIntoView:!0}),0))}}),pt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},dt=o.StateEffect.define({map(t,e){let i=e.mapPos(t,-1,o.MapMode.TrackAfter);return null==i?void 0:i}}),ft=new class extends o.RangeValue{};ft.startSide=1,ft.endSide=-1;const ut=o.StateField.define({create:()=>o.RangeSet.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(dt)&&(t=t.update({add:[ft.range(i.value,i.value+1)]}));return t}});function mt(){return[yt,ut]}const gt="()[]{}<>«»»«[]{}";function vt(t){for(let e=0;e<16;e+=2)if(gt.charCodeAt(e)==t)return gt.charAt(e+1);return(0,o.fromCodePoint)(t<128?t:t+1)}function bt(t,e){return t.languageDataAt("closeBrackets",e)[0]||pt}const wt="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),yt=n.EditorView.inputHandler.of((t,e,i,n)=>{if((wt?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let s=t.state.selection.main;if(n.length>2||2==n.length&&1==(0,o.codePointSize)((0,o.codePointAt)(n,0))||e!=s.from||i!=s.to)return!1;let l=function(t,e){let i=bt(t,t.selection.main.head),n=i.brackets||pt.brackets;for(let s of n){let l=vt((0,o.codePointAt)(s,0));if(e==s)return l==s?Ot(t,s,n.indexOf(s+s+s)>-1,i):Et(t,s,l,i.before||pt.before);if(e==l&&Ct(t,t.selection.main.from))return It(t,0,l)}return null}(t.state,n);return!!l&&(t.dispatch(l),!0)}),xt=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=bt(t,t.selection.main.head).brackets||pt.brackets,n=null,s=t.changeByRange(e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return(0,o.codePointSize)((0,o.codePointAt)(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let s of i)if(s==n&&St(t.doc,e.head)==vt((0,o.codePointAt)(s,0)))return{changes:{from:e.head-s.length,to:e.head+s.length},range:o.EditorSelection.cursor(e.head-s.length)}}return{range:n=e}});return n||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!n}}];function Ct(t,e){let i=!1;return t.field(ut).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function St(t,e){let i=t.sliceString(e,e+2);return i.slice(0,(0,o.codePointSize)((0,o.codePointAt)(i,0)))}function Et(t,e,i,n){let s=null,l=t.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:i,from:l.to}],effects:dt.of(l.to+e.length),range:o.EditorSelection.range(l.anchor+e.length,l.head+e.length)};let r=St(t.doc,l.head);return!r||/\s/.test(r)||n.indexOf(r)>-1?{changes:{insert:e+i,from:l.head},effects:dt.of(l.head+e.length),range:o.EditorSelection.cursor(l.head+e.length)}:{range:s=l}});return s?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function It(t,e,i){let n=null,s=t.changeByRange(e=>e.empty&&St(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:o.EditorSelection.cursor(e.head+i.length)}:n={range:e});return n?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Ot(t,e,i,n){let l=n.stringPrefixes||pt.stringPrefixes,r=null,a=t.changeByRange(n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:dt.of(n.to+e.length),range:o.EditorSelection.range(n.anchor+e.length,n.head+e.length)};let a,c=n.head,h=St(t.doc,c);if(h==e){if(Pt(t,c))return{changes:{insert:e+e,from:c},effects:dt.of(c+e.length),range:o.EditorSelection.cursor(c+e.length)};if(Ct(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:o.EditorSelection.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(a=kt(t,c-2*e.length,l))>-1&&Pt(t,a))return{changes:{insert:e+e+e+e,from:c},effects:dt.of(c+e.length),range:o.EditorSelection.cursor(c+e.length)};if(t.charCategorizer(c)(h)!=o.CharCategory.Word&&kt(t,c,l)>-1&&!function(t,e,i,o){let n=(0,s.syntaxTree)(t).resolveInner(e,-1),l=o.reduce((t,e)=>Math.max(t,e.length),0);for(let s=0;s<5;s++){let s=t.sliceDoc(n.from,Math.min(n.to,n.from+i.length+l)),r=s.indexOf(i);if(!r||r>-1&&o.indexOf(s.slice(0,r))>-1){let e=n.firstChild;for(;e&&e.from==n.from&&e.to-e.from>i.length+r;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let a=n.to==e&&n.parent;if(!a)break;n=a}return!1}(t,c,e,l))return{changes:{insert:e+e,from:c},effects:dt.of(c+e.length),range:o.EditorSelection.cursor(c+e.length)}}return{range:r=n}});return r?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Pt(t,e){let i=(0,s.syntaxTree)(t).resolveInner(e+1);return i.parent&&i.from==e}function kt(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=o.CharCategory.Word)return e;for(let s of i){let i=e-s.length;if(t.sliceDoc(i,e)==s&&n(t.sliceDoc(i-1,i))!=o.CharCategory.Word)return i}return-1}function Dt(t={}){return[K,$,y.of(t),q,At,_]}const Tt=[{key:"Ctrl-Space",run:z},{mac:"Alt-`",run:z},{key:"Escape",run:t=>{let e=t.state.field($,!1);return!(!e||!e.active.some(t=>0!=t.state)||(t.dispatch({effects:v.of(null)}),0))}},{key:"ArrowDown",run:j(!0)},{key:"ArrowUp",run:j(!1)},{key:"PageDown",run:j(!0,"page")},{key:"PageUp",run:j(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field($,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(y).interactionDelay)&&N(t,e.open.options[e.open.selected])}}],At=o.Prec.highest(n.keymap.computeN([y],t=>t.facet(y).defaultKeymap?[Tt]:[]))}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[821],{8821:(e,t,i)=>{i.r(t),i.d(t,{EditorView:()=>n.EditorView,basicSetup:()=>Oe,minimalSetup:()=>Ve});var n=i(5024),o=i(195),r=i(2084),s=i(4353);function l(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var o=i[n];"string"==typeof o?e.setAttribute(n,o):null!=o&&(e[n]=o)}t++}for(;t<arguments.length;t++)a(e,arguments[t]);return e}function a(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var i=0;i<t.length;i++)a(e,t[i])}}const c="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class h{constructor(e,t,i=0,n=e.length,o,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=o?e=>o(c(e)):c,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(0,o.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,o.fromCodePoint)(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=(0,o.codePointSize)(e);let n=this.normalize(t);if(n.length)for(let e=0,o=i;;e++){let r=n.charCodeAt(e),s=this.match(r,o,this.bufferPos+this.bufferStart);if(e==n.length-1){if(s)return this.value=s,this;break}o==i&&e<t.length&&t.charCodeAt(e)==r&&o++}}}match(e,t,i){let n=null;for(let t=0;t<this.matches.length;t+=2){let o=this.matches[t],r=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?n={from:this.matches[t+1],to:i}:(this.matches[t]++,r=!0)),r||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:i}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(h.prototype[Symbol.iterator]=function(){return this});const d={from:-1,to:-1,match:/.*/.exec("")},u="gm"+(null==/x/.unicode?"":"u");class f{constructor(e,t,i,n=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=d,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new p(e,t,i,n,o);this.re=new RegExp(t,u+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let r=e.lineAt(n);this.curLineStart=r.from,this.matchPos=v(e,n),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 i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=v(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const m=new WeakMap;class g{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=m.get(e);if(!n||n.from>=i||n.to<=t){let n=new g(t,e.sliceString(t,i));return m.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:o,from:r}=n;return r>t&&(o=e.sliceString(t,r)+o,r=t),n.to<i&&(o+=e.sliceString(n.to,i)),m.set(e,new g(r,o)),new g(t,o.slice(t-r,i-r))}}class p{constructor(e,t,i,n,o){this.text=e,this.to=o,this.done=!1,this.value=d,this.matchPos=v(e,n),this.re=new RegExp(t,u+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=g.get(e,n,this.chunkEnd(n+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,i=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,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=v(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=g.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function v(e,t){if(t>=e.length)return t;let i,n=e.lineAt(t);for(;t<n.to&&(i=n.text.charCodeAt(t-n.from))>=56320&&i<57344;)t++;return t}function b(e){let t=l("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!i)return;let{state:r}=e,s=r.doc.lineAt(r.selection.main.head),[,l,a,c,h]=i,d=c?+c.slice(1):0,u=a?+a:s.number;if(a&&h){let e=u/100;l&&(e=e*("-"==l?-1:1)+s.number/r.doc.lines),u=Math.round(r.doc.lines*e)}else a&&l&&(u=u*("-"==l?-1:1)+s.number);let f=r.doc.line(Math.max(1,Math.min(r.doc.lines,u))),m=o.EditorSelection.cursor(f.from+Math.max(0,Math.min(d,f.length)));e.dispatch({effects:[x.of(!1),n.EditorView.scrollIntoView(m.from,{y:"center"})],selection:m}),e.focus()}return{dom:l("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:x.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:e=>{e.preventDefault(),i()}},l("label",e.state.phrase("Go to line"),": ",t)," ",l("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),l("button",{name:"close",onclick:()=>{e.dispatch({effects:x.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(f.prototype[Symbol.iterator]=p.prototype[Symbol.iterator]=function(){return this});const x=o.StateEffect.define(),w=o.StateField.define({create:()=>!0,update(e,t){for(let i of t.effects)i.is(x)&&(e=i.value);return e},provide:e=>n.showPanel.from(e,e=>e?b:null)}),y=n.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),k={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},S=o.Facet.define({combine:e=>(0,o.combineConfig)(e,k,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function C(e){let t=[L,A];return e&&t.push(S.of(e)),t}const M=n.Decoration.mark({class:"cm-selectionMatch"}),E=n.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function D(e,t,i,n){return!(0!=i&&e(t.sliceDoc(i-1,i))==o.CharCategory.Word||n!=t.doc.length&&e(t.sliceDoc(n,n+1))==o.CharCategory.Word)}const A=n.ViewPlugin.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 t=e.state.facet(S),{state:i}=e,r=i.selection;if(r.ranges.length>1)return n.Decoration.none;let s,l=r.main,a=null;if(l.empty){if(!t.highlightWordAroundCursor)return n.Decoration.none;let e=i.wordAt(l.head);if(!e)return n.Decoration.none;a=i.charCategorizer(l.head),s=i.sliceDoc(e.from,e.to)}else{let e=l.to-l.from;if(e<t.minSelectionLength||e>200)return n.Decoration.none;if(t.wholeWords){if(s=i.sliceDoc(l.from,l.to),a=i.charCategorizer(l.head),!D(a,i,l.from,l.to)||!function(e,t,i,n){return e(t.sliceDoc(i,i+1))==o.CharCategory.Word&&e(t.sliceDoc(n-1,n))==o.CharCategory.Word}(a,i,l.from,l.to))return n.Decoration.none}else if(s=i.sliceDoc(l.from,l.to),!s)return n.Decoration.none}let c=[];for(let o of e.visibleRanges){let e=new h(i.doc,s,o.from,o.to);for(;!e.next().done;){let{from:o,to:r}=e.value;if((!a||D(a,i,o,r))&&(l.empty&&o<=l.from&&r>=l.to?c.push(E.range(o,r)):(o>=l.to||r<=l.from)&&c.push(M.range(o,r)),c.length>t.maxMatches))return n.Decoration.none}}return n.Decoration.set(c)}},{decorations:e=>e.decorations}),L=n.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),q=o.Facet.define({combine:e=>(0,o.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new re(e),scrollToMatch:e=>n.EditorView.scrollIntoView(e)})});class P{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,u),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new T(this):new W(this)}getCursor(e,t=0,i){let n=e.doc?e:o.EditorState.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?I(this,n,t,i):F(this,n,t,i)}}class R{constructor(e){this.spec=e}}function F(e,t,i,n){return new h(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,i,n)=>((n>e||n+i.length<t)&&(n=Math.max(0,e-2),i=r.sliceString(n,Math.min(r.length,t+2))),!(s(O(i,e-n))==o.CharCategory.Word&&s(V(i,e-n))==o.CharCategory.Word||s(V(i,t-n))==o.CharCategory.Word&&s(O(i,t-n))==o.CharCategory.Word))):void 0);var r,s}class W extends R{constructor(e){super(e)}nextMatch(e,t,i){let n=F(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);n=F(this.spec,e,0,i).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let i=Math.max(t,n-1e4-this.spec.unquoted.length),o=F(this.spec,e,i,n),r=null;for(;!o.nextOverlapping().done;)r=o.value;if(r)return r;if(i==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),!n||n.from==t&&n.to==i?null:n}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=F(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let o=F(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}}function I(e,t,i,n){return new f(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,i)=>!i[0].length||(r(O(i.input,i.index))!=o.CharCategory.Word||r(V(i.input,i.index))!=o.CharCategory.Word)&&(r(V(i.input,i.index+i[0].length))!=o.CharCategory.Word||r(O(i.input,i.index+i[0].length))!=o.CharCategory.Word)):void 0},i,n);var r}function O(e,t){return e.slice((0,o.findClusterBreak)(e,t,!1),t)}function V(e,t){return e.slice(t,(0,o.findClusterBreak)(e,t))}class T extends R{nextMatch(e,t,i){let n=I(this.spec,e,i,e.doc.length).next();return n.done&&(n=I(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let o=Math.max(t,i-1e4*n),r=I(this.spec,e,o,i),s=null;for(;!r.next().done;)s=r.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let n=+i.slice(0,t);if(n>0&&n<e.match.length)return e.match[n]+i.slice(t)}return t})}matchAll(e,t){let i=I(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let o=I(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)n(o.value.from,o.value.to)}}const $=o.StateEffect.define(),z=o.StateEffect.define(),B=o.StateField.define({create:e=>new H(X(e).create(),null),update(e,t){for(let i of t.effects)i.is($)?e=new H(i.value.create(),e.panel):i.is(z)&&(e=new H(e.query,i.value?J:null));return e},provide:e=>n.showPanel.from(e,e=>e.panel)});class H{constructor(e,t){this.query=e,this.panel=t}}const _=n.Decoration.mark({class:"cm-searchMatch"}),N=n.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),G=n.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(B))}update(e){let t=e.state.field(B);(t!=e.startState.field(B)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return n.Decoration.none;let{view:i}=this,r=new o.RangeSetBuilder;for(let t=0,n=i.visibleRanges,o=n.length;t<o;t++){let{from:s,to:l}=n[t];for(;t<o-1&&l>n[t+1].from-500;)l=n[++t].to;e.highlight(i.state,s,l,(e,t)=>{let n=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);r.add(e,t,n?N:_)})}return r.finish()}},{decorations:e=>e.decorations});function U(e){return t=>{let i=t.state.field(B,!1);return i&&i.query.spec.valid?e(t,i):ie(t)}}const j=U((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let r=o.EditorSelection.single(n.from,n.to),s=e.state.facet(q);return e.dispatch({selection:r,effects:[ce(e,n),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),te(e),!0}),K=U((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,r=t.prevMatch(i,n,n);if(!r)return!1;let s=o.EditorSelection.single(r.from,r.to),l=e.state.facet(q);return e.dispatch({selection:s,effects:[ce(e,r),l.scrollToMatch(s.main,e)],userEvent:"select.search"}),te(e),!0}),Q=U((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!(!i||!i.length||(e.dispatch({selection:o.EditorSelection.create(i.map(e=>o.EditorSelection.range(e.from,e.to))),userEvent:"select.search.matches"}),0))}),Y=U((e,{query:t})=>{let{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let l=t.nextMatch(i,r,r);if(!l)return!1;let a,c,h=l,d=[],u=[];h.from==r&&h.to==s&&(c=i.toText(t.getReplacement(h)),d.push({from:h.from,to:h.to,insert:c}),h=t.nextMatch(i,h.from,h.to),u.push(n.EditorView.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+".")));let f=e.state.changes(d);return h&&(a=o.EditorSelection.single(h.from,h.to).map(f),u.push(ce(e,h)),u.push(i.facet(q).scrollToMatch(a.main,e))),e.dispatch({changes:f,selection:a,effects:u,userEvent:"input.replace"}),!0}),Z=U((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:i,to:n}=e;return{from:i,to:n,insert:t.getReplacement(e)}});if(!i.length)return!1;let o=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:n.EditorView.announce.of(o),userEvent:"input.replace.all"}),!0});function J(e){return e.state.facet(q).createPanel(e)}function X(e,t){var i,n,o,r,s;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(q);return new P({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:c.caseSensitive,literal:null!==(o=null==t?void 0:t.literal)&&void 0!==o?o:c.literal,regexp:null!==(r=null==t?void 0:t.regexp)&&void 0!==r?r:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function ee(e){let t=(0,n.getPanel)(e,J);return t&&t.dom.querySelector("[main-field]")}function te(e){let t=ee(e);t&&t==e.root.activeElement&&t.select()}const ie=e=>{let t=e.state.field(B,!1);if(t&&t.panel){let i=ee(e);if(i&&i!=e.root.activeElement){let n=X(e.state,t.query.spec);n.valid&&e.dispatch({effects:$.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[z.of(!0),t?$.of(X(e.state,t.query.spec)):o.StateEffect.appendConfig.of(de)]});return!0},ne=e=>{let t=e.state.field(B,!1);if(!t||!t.panel)return!1;let i=(0,n.getPanel)(e,J);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:z.of(!1)}),!0},oe=[{key:"Mod-f",run:ie,scope:"editor search-panel"},{key:"F3",run:j,shift:K,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:j,shift:K,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ne,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],l=0;for(let t=new h(e.doc,e.sliceDoc(n,r));!t.next().done;){if(s.length>1e3)return!1;t.value.from==n&&(l=s.length),s.push(o.EditorSelection.range(t.value.from,t.value.to))}return t(e.update({selection:o.EditorSelection.create(s,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=(0,n.getPanel)(e,b);if(!t){let i=[x.of(!0)];null==e.state.field(w,!1)&&i.push(o.StateEffect.appendConfig.of([w,y])),e.dispatch({effects:i}),t=(0,n.getPanel)(e,b)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:i}=e,n=o.EditorSelection.create(i.ranges.map(t=>e.wordAt(t.head)||o.EditorSelection.cursor(t.head)),i.mainIndex);return!n.eq(i)&&(t(e.update({selection:n})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let s=function(e,t){let{main:i,ranges:n}=e.selection,o=e.wordAt(i.head),r=o&&o.from==i.from&&o.to==i.to;for(let i=!1,o=new h(e.doc,t,n[n.length-1].to);;){if(o.next(),!o.done){if(i&&n.some(e=>e.from==o.value.from))continue;if(r){let t=e.wordAt(o.value.from);if(!t||t.from!=o.value.from||t.to!=o.value.to)continue}return o.value}if(i)return null;o=new h(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(e,r);return!!s&&(t(e.update({selection:e.selection.addRange(o.EditorSelection.range(s.from,s.to),!1),effects:n.EditorView.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class re{constructor(e){this.view=e;let t=this.query=e.state.field(B).query.spec;function i(e,t,i){return l("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=l("input",{value:t.search,placeholder:se(e,"Find"),"aria-label":se(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=l("input",{value:t.replace,placeholder:se(e,"Replace"),"aria-label":se(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=l("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=l("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=l("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=l("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>j(e),[se(e,"next")]),i("prev",()=>K(e),[se(e,"previous")]),i("select",()=>Q(e),[se(e,"all")]),l("label",null,[this.caseField,se(e,"match case")]),l("label",null,[this.reField,se(e,"regexp")]),l("label",null,[this.wordField,se(e,"by word")]),...e.state.readOnly?[]:[l("br"),this.replaceField,i("replace",()=>Y(e),[se(e,"replace")]),i("replaceAll",()=>Z(e),[se(e,"replace all")])],l("button",{name:"close",onclick:()=>ne(e),"aria-label":se(e,"close"),type:"button"},["×"])])}commit(){let e=new P({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:$.of(e)}))}keydown(e){(0,n.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?K:j)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Y(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is($)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(q).top}}function se(e,t){return e.state.phrase(t)}const le=30,ae=/[\s\.,:;?!]/;function ce(e,{from:t,to:i}){let o=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,s=Math.max(o.from,t-le),l=Math.min(r,i+le),a=e.state.sliceDoc(s,l);if(s!=o.from)for(let e=0;e<le;e++)if(!ae.test(a[e+1])&&ae.test(a[e])){a=a.slice(e);break}if(l!=r)for(let e=a.length-1;e>a.length-le;e--)if(!ae.test(a[e-1])&&ae.test(a[e])){a=a.slice(0,e);break}return n.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${o.number}.`)}const he=n.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),de=[B,o.Prec.low(G),he];var ue=i(2747);class fe{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class me{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(Me).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),l=new o.RangeSetBuilder,a=[],c=0;for(let e=0;;){let t,o,r=e==s.length?null:s[e];if(!r&&!a.length)break;for(a.length?(t=c,o=a.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8)):(t=r.from,o=r.to,a.push(r),e++);e<s.length;){let i=s[e];if(i.from!=t||!(i.to>i.from||i.to==t)){o=Math.min(i.from,o);break}a.push(i),e++,o=Math.min(i.to,o)}let h=We(a);if(a.some(e=>e.from==e.to||e.from==e.to-1&&i.doc.lineAt(e.from).to==e.from))l.add(t,t,n.Decoration.widget({widget:new Ae(h),diagnostics:a.slice()}));else{let e=a.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");l.add(t,o,n.Decoration.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:a.slice(),inclusiveEnd:a.some(e=>e.to>o)}))}c=o;for(let e=0;e<a.length;e++)a[e].to<=c&&a.splice(e--,1)}let h=l.finish();return new me(h,t,ge(h))}}function ge(e,t=null,i=0){let n=null;return e.between(i,1e9,(e,i,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(n){if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new fe(n.from,i,n.diagnostic)}else n=new fe(e,i,t||o.diagnostics[0])}),n}const pe=o.StateEffect.define(),ve=o.StateEffect.define(),be=o.StateEffect.define(),xe=o.StateField.define({create:()=>new me(n.Decoration.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),n=null,o=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);n=ge(i,e.selected.diagnostic,o)||ge(i,null,o)}!i.size&&o&&t.state.facet(Me).autoPanel&&(o=null),e=new me(i,o,n)}for(let i of t.effects)if(i.is(pe)){let n=t.state.facet(Me).autoPanel?i.value.length?qe.open:null:e.panel;e=me.init(i.value,n,t.state)}else i.is(ve)?e=new me(e.diagnostics,i.value?qe.open:null,e.selected):i.is(be)&&(e=new me(e.diagnostics,e.panel,i.value));return e},provide:e=>[n.showPanel.from(e,e=>e.panel),n.EditorView.decorations.from(e,e=>e.diagnostics)]}),we=n.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function ye(e,t,i){let n,{diagnostics:o}=e.state.field(xe),r=-1,s=-1;o.between(t-(i<0?1:0),t+(i>0?1:0),(e,o,{spec:l})=>{if(t>=e&&t<=o&&(e==o||(t>e||i>0)&&(t<o||i<0)))return n=l.diagnostics,r=e,s=o,!1});let l=e.state.facet(Me).tooltipFilter;return n&&l&&(n=l(n,e.state)),n?{pos:r,end:s,above:e.state.doc.lineAt(r).to<s,create:()=>({dom:ke(e,n)})}:null}function ke(e,t){return l("ul",{class:"cm-tooltip-lint"},t.map(t=>De(e,t,!1)))}const Se=e=>{let t=e.state.field(xe,!1);return!(!t||!t.panel||(e.dispatch({effects:ve.of(!1)}),0))},Ce=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(xe,!1);var i,r;t&&t.panel||e.dispatch({effects:(i=e.state,r=[ve.of(!0)],i.field(xe,!1)?r:r.concat(o.StateEffect.appendConfig.of(Ie)))});let s=(0,n.getPanel)(e,qe.open);return s&&s.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(xe,!1);if(!t)return!1;let i=e.state.selection.main,n=t.diagnostics.iter(i.to+1);return!(!n.value&&(n=t.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to)||(e.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),0))}}],Me=o.Facet.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},(0,o.combineConfig)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))});function Ee(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let n=i[e];if(/[a-zA-Z]/.test(n)&&!t.some(e=>e.toLowerCase()==n.toLowerCase())){t.push(n);continue e}}t.push("")}return t}function De(e,t,i){var n;let o=i?Ee(t.actions):[];return l("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},l("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(n=t.actions)||void 0===n?void 0:n.map((i,n)=>{let r=!1,s=n=>{if(n.preventDefault(),r)return;r=!0;let o=ge(e.state.field(xe).diagnostics,t);o&&i.apply(e,o.from,o.to)},{name:a}=i,c=o[n]?a.indexOf(o[n]):-1,h=c<0?a:[a.slice(0,c),l("u",a.slice(c,c+1)),a.slice(c+1)];return l("button",{type:"button",class:"cm-diagnosticAction",onclick:s,onmousedown:s,"aria-label":` Action: ${a}${c<0?"":` (access key "${o[n]})"`}.`},h)}),t.source&&l("div",{class:"cm-diagnosticSource"},t.source))}class Ae extends n.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return l("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Le{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=De(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qe{constructor(e){this.view=e,this.items=[],this.list=l("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)Se(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=Ee(i.actions);for(let o=0;o<n.length;o++)if(n[o].toUpperCase().charCodeAt(0)==t.keyCode){let t=ge(this.view.state.field(xe).diagnostics,i);t&&i.actions[o].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=l("div",{class:"cm-panel-lint"},this.list,l("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Se(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(xe).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(xe),i=0,n=!1,o=null,r=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:l})=>{for(let e of l.diagnostics){if(r.has(e))continue;r.add(e);let s,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){l=t;break}l<0?(s=new Le(this.view,e),this.items.splice(i,0,s),n=!0):(s=this.items[l],l>i&&(this.items.splice(i,l-i),n=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),o=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();0==this.items.length&&(this.items.push(new Le(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=ge(this.view.state.field(xe).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:be.of(t)})}static open(e){return new qe(e)}}function Pe(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Re=n.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Pe("#d11")},".cm-lintRange-warning":{backgroundImage:Pe("orange")},".cm-lintRange-info":{backgroundImage:Pe("#999")},".cm-lintRange-hint":{backgroundImage:Pe("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Fe(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function We(e){let t="hint",i=1;for(let n of e){let e=Fe(n.severity);e>i&&(i=e,t=n.severity)}return t}n.GutterMarker;const Ie=[xe,n.EditorView.decorations.compute([xe],e=>{let{selected:t,panel:i}=e.field(xe);return t&&i&&t.from!=t.to?n.Decoration.set([we.range(t.from,t.to)]):n.Decoration.none}),(0,n.hoverTooltip)(ye,{hideOn:function(e,t){let i=t.pos,n=t.end||i,o=e.state.facet(Me).hideOn(e,i,n);if(null!=o)return o;let r=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(pe))&&!e.changes.touchesRange(r.from,Math.max(r.to,n)))}}),Re],Oe=(()=>[(0,n.lineNumbers)(),(0,n.highlightActiveLineGutter)(),(0,n.highlightSpecialChars)(),(0,s.b6)(),(0,r.foldGutter)(),(0,n.drawSelection)(),(0,n.dropCursor)(),o.EditorState.allowMultipleSelections.of(!0),(0,r.indentOnInput)(),(0,r.syntaxHighlighting)(r.defaultHighlightStyle,{fallback:!0}),(0,r.bracketMatching)(),(0,ue.wm)(),(0,ue.yU)(),(0,n.rectangularSelection)(),(0,n.crosshairCursor)(),(0,n.highlightActiveLine)(),C(),n.keymap.of([...ue.Bc,...s.pw,...oe,...s.cL,...r.foldKeymap,...ue.OO,...Ce])])(),Ve=(()=>[(0,n.highlightSpecialChars)(),(0,s.b6)(),(0,n.drawSelection)(),(0,r.syntaxHighlighting)(r.defaultHighlightStyle,{fallback:!0}),n.keymap.of([...s.pw,...s.cL])])()}}]);
|