sage-agent-internal 0.1.33__py3-none-any.whl → 0.1.35__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.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/package.json +4 -3
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/schemas/sage-agent-internal/package.json.orig +3 -2
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/353.2c285601a208c3735929.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/439.3cb9ac7022c8a6074647.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/540.3d4b5aa9edd073afbaf7.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/573.efca05eb516500b41d7d.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/635.8c395c854aa2b140b668.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/747.b8e9485ebcbb3066eb4b.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/821.b58f29814f5900f1f6f8.js +1 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/973.38ee5148a3908e41c2dd.js +2 -0
- sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/remoteEntry.e5d4b01866c76d9e2e92.js +1 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/third-party-licenses.json +35 -5
- {sage_agent_internal-0.1.33.dist-info → sage_agent_internal-0.1.35.dist-info}/METADATA +1 -1
- sage_agent_internal-0.1.35.dist-info/RECORD +33 -0
- sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/379.b3bf2f8d00bdb186e6f8.js +0 -1
- sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/424.58d3508585951cee4f35.js +0 -1
- sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/439.61293ec148172a793000.js +0 -1
- sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/540.283f7cceb475717261ed.js +0 -1
- sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/982.e8f28fa7892d44e0d1bb.js +0 -2
- sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/remoteEntry.a07e15ae626b9209fccd.js +0 -1
- sage_agent_internal-0.1.33.dist-info/RECORD +0 -30
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/install.json +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/schemas/sage-agent-internal/plugin.json +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/122.3c2c200586e65203b674.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/220.d384edfd5bbcfda33a2a.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/262.3fc4ad88e6f8c273d4ad.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/364.c2fb82c6f484097228c6.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/481.96b91d018df31d54d173.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/553.b7906877d98a62265533.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/553.b7906877d98a62265533.js.LICENSE.txt +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/713.103cb5ae248be385b08a.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/742.b204789055ded4e07883.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/845.cc2bc80fbfea6d20a396.js +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/888.09382cc93a2ad3932b31.js +0 -0
- /sage_agent_internal-0.1.33.data/data/share/jupyter/labextensions/sage-agent-internal/static/982.e8f28fa7892d44e0d1bb.js.LICENSE.txt → /sage_agent_internal-0.1.35.data/data/share/jupyter/labextensions/sage-agent-internal/static/973.38ee5148a3908e41c2dd.js.LICENSE.txt +0 -0
- {sage_agent_internal-0.1.33.data → sage_agent_internal-0.1.35.data}/data/share/jupyter/labextensions/sage-agent-internal/static/style.js +0 -0
- {sage_agent_internal-0.1.33.dist-info → sage_agent_internal-0.1.35.dist-info}/WHEEL +0 -0
- {sage_agent_internal-0.1.33.dist-info → sage_agent_internal-0.1.35.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunksage_agent_internal=self.webpackChunksage_agent_internal||[]).push([[635],{7635:(e,t,n)=>{n.r(t),n.d(t,{Change:()=>m,Chunk:()=>X,MergeView:()=>Oe,acceptChunk:()=>Ye,applyGeneratedCode:()=>He,diff:()=>U,generateCodeEffect:()=>Pe,getChunks:()=>$,getOriginalDoc:()=>Ie,goToNextChunk:()=>K,goToPreviousChunk:()=>Q,originalDocChangeEffect:()=>_e,presentableDiff:()=>W,rejectChunk:()=>Ze,uncollapseUnchanged:()=>Ce,unifiedMergeView:()=>Ne,updateOriginalDoc:()=>Ge});var r=n(5024),o=n(195);const i="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class a{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function o(e,t,i,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return i.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))o(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,i);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");o(r(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(l.length||c)&&i.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let t in e)o(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=l[i]||1;return l[i]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[s],o=n&&n.nonce;r?o&&r.setNonce(o):r=new f(e,o),r.mount(Array.isArray(t)?t:[t],e)}}let c=new Map;class f{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=c.get(n);if(t)return e[s]=t;this.sheet=new r.CSSStyleSheet,c.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[s]=this}mount(e,t){let n=this.sheet,r=0,o=0;for(let t=0;t<e.length;t++){let i=e[t],s=this.modules.indexOf(i);if(s<o&&s>-1&&(this.modules.splice(s,1),o--,s=-1),-1==s){if(this.modules.splice(o++,0,i),n)for(let e=0;e<i.rules.length;e++)n.insertRule(i.rules[e],r++)}else{for(;o<s;)r+=this.modules[o++].rules.length;r+=i.rules.length,o++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var h=n(4353),d=n(2084),u=n(1839);class m{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(e,t=e){return new m(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function g(e,t,n,r,o,i){if(e==r)return[];let s=x(e,t,n,r,o,i),l=M(e,t+s,n,r,o+s,i),a=(n-=l)-(t+=s),c=(i-=l)-(o+=s);if(!a||!c)return[new m(t,n,o,i)];if(a>c){let s=e.slice(t,n).indexOf(r.slice(o,i));if(s>-1)return[new m(t,t+s,o,o),new m(t+s+c,n,i,i)]}else if(c>a){let s=r.slice(o,i).indexOf(e.slice(t,n));if(s>-1)return[new m(t,t,o,o+s),new m(n,n,o+s+a,i)]}if(1==a||1==c)return[new m(t,n,o,i)];let f=S(e,t,n,r,o,i);if(f){let[s,l,a]=f;return g(e,t,s,r,o,l).concat(g(e,s+a,n,r,l+a,i))}return function(e,t,n,r,o,i){let s=n-t,l=i-o;if(p<1e9&&Math.min(s,l)>16*p||A>0&&Date.now()>A)return Math.min(s,l)>64*p?[new m(t,n,o,i)]:E(e,t,n,r,o,i);let a=Math.ceil((s+l)/2);b.reset(a),w.reset(a);let c=(n,i)=>e.charCodeAt(t+n)==r.charCodeAt(o+i),f=(t,o)=>e.charCodeAt(n-t-1)==r.charCodeAt(i-o-1),h=(s-l)%2!=0?w:null,d=h?null:b;for(let u=0;u<a;u++){if(u>p||A>0&&!(63&u)&&Date.now()>A)return E(e,t,n,r,o,i);let m=b.advance(u,s,l,a,h,!1,c)||w.advance(u,s,l,a,d,!0,f);if(m)return C(e,t,n,t+m[0],r,o,i,o+m[1])}return[new m(t,n,o,i)]}(e,t,n,r,o,i)}let p=1e9,A=0,B=!1;class v{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,o,i,s){for(let l=-e+this.start;l<=e-this.end;l+=2){let a=r+l,c=l==-e||l!=e&&this.vec[a-1]<this.vec[a+1]?this.vec[a+1]:this.vec[a-1]+1,f=c-l;for(;c<t&&f<n&&s(c,f);)c++,f++;if(this.vec[a]=c,c>t)this.end+=2;else if(f>n)this.start+=2;else if(o){let e=r+(t-n)-l;if(e>=0&&e<this.len&&-1!=o.vec[e])if(i){let n=o.vec[e];if(n>=t-c)return[n,r+n-e]}else if(c>=t-o.vec[e])return[c,f]}}return null}}const b=new v,w=new v;function C(e,t,n,r,o,i,s,l){let a=!1;return H(e,r)||++r!=n||(a=!0),H(o,l)||++l!=s||(a=!0),a?[new m(t,n,i,s)]:g(e,t,r,o,i,l).concat(g(e,r,n,o,l,s))}function k(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function x(e,t,n,r,o,i){if(t==n||t==i||e.charCodeAt(t)!=r.charCodeAt(o))return 0;let s=k(n-t,i-o);for(let l=t,a=o;;){let o=l+s,c=a+s;if(o>n||c>i||e.slice(l,o)!=r.slice(a,c)){if(1==s)return l-t-(H(e,l)?0:1);s>>=1}else{if(o==n||c==i)return o-t;l=o,a=c}}}function M(e,t,n,r,o,i){if(t==n||o==i||e.charCodeAt(n-1)!=r.charCodeAt(i-1))return 0;let s=k(n-t,i-o);for(let l=n,a=i;;){let i=l-s,c=a-s;if(i<t||c<o||e.slice(i,l)!=r.slice(c,a)){if(1==s)return n-l-(H(e,l)?0:1);s>>=1}else{if(i==t||c==o)return n-i;l=i,a=c}}}function D(e,t,n,r,o,i,s,l){let a=r.slice(o,i),c=null;for(;;){if(c||s<l)return c;for(let l=t+s;;){H(e,l)||l++;let f=l+s;if(H(e,f)||(f+=f==l+1?1:-1),f>=n)break;let h=e.slice(l,f),d=-1;for(;-1!=(d=a.indexOf(h,d+1));){let s=x(e,f,n,r,o+d+h.length,i),a=M(e,t,l,r,o,o+d),u=h.length+s+a;(!c||c[2]<u)&&(c=[l-a,o+d-a,u])}l=f}if(l<0)return c;s>>=1}}function S(e,t,n,r,o,i){let s=n-t,l=i-o;if(s<l){let s=S(r,o,i,e,t,n);return s&&[s[1],s[0],s[2]]}return s<4||2*l<s?null:D(e,t,n,r,o,i,Math.floor(s/4),-1)}function E(e,t,n,r,o,i){B=!0;let s,l=n-t,a=i-o;if(l<a){let a=D(r,o,i,e,t,n,Math.floor(l/6),50);s=a&&[a[1],a[0],a[2]]}else s=D(e,t,n,r,o,i,Math.floor(a/6),50);if(!s)return[new m(t,n,o,i)];let[c,f,h]=s;return g(e,t,c,r,o,f).concat(g(e,c+h,n,r,f+h,i))}function y(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];r.toA>o.fromA-t&&r.toB>o.fromB-t&&(e[n-1]=new m(r.fromA,o.toA,r.fromB,o.toB),e.splice(n--,1))}}let T;try{T=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(e){}function O(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function L(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?O(n)?1:0:T?P(n)&&t!=e.length-1?T.test(e.slice(t,t+2))?2:0:T.test(String.fromCharCode(n))?1:0:0}function R(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?O(n)?1:0:T?_(n)&&1!=t?T.test(e.slice(t-2,t))?2:0:T.test(String.fromCharCode(n))?1:0:0}const V=8;function N(e,t,n){if(t==e.length||!R(e,t))return t;for(let r=t,o=t+n,i=0;i<V;i++){let t=L(e,r);if(!t||r+t>o)return r;r+=t}return t}function G(e,t,n){if(!t||!L(e,t))return t;for(let r=t,o=t-n,i=0;i<V;i++){let t=R(e,r);if(!t||r-t<o)return r;r-=t}return t}function F(e,t,n){for(;t!=n;t--)if(10==e.charCodeAt(t-1))return t;return-1}function j(e,t,n){for(;t!=n;t++)if(10==e.charCodeAt(t))return t;return-1}const P=e=>e>=55296&&e<=56319,_=e=>e>=56320&&e<=57343;function H(e,t){return!t||t==e.length||!P(e.charCodeAt(t-1))||!_(e.charCodeAt(t))}function U(e,t,n){var r;return p=(null!==(r=null==n?void 0:n.scanLimit)&&void 0!==r?r:1e9)>>1,A=(null==n?void 0:n.timeout)?Date.now()+n.timeout:0,B=!1,function(e,t,n){for(;;){y(n,1);let r=!1;for(let o=0;o<n.length;o++){let i,s,l=n[o];(i=x(e,l.fromA,l.toA,t,l.fromB,l.toB))&&(l=n[o]=new m(l.fromA+i,l.toA,l.fromB+i,l.toB)),(s=M(e,l.fromA,l.toA,t,l.fromB,l.toB))&&(l=n[o]=new m(l.fromA,l.toA-s,l.fromB,l.toB-s));let a=l.toA-l.fromA,c=l.toB-l.fromB;if(a&&c)continue;let f=l.fromA-(o?n[o-1].toA:0),h=(o<n.length-1?n[o+1].fromA:e.length)-l.toA;if(!f||!h)continue;let d=a?e.slice(l.fromA,l.toA):t.slice(l.fromB,l.toB);f<=d.length&&e.slice(l.fromA-f,l.fromA)==d.slice(d.length-f)?(n[o]=new m(l.fromA-f,l.toA-f,l.fromB-f,l.toB-f),r=!0):h<=d.length&&e.slice(l.toA,l.toA+h)==d.slice(0,h)&&(n[o]=new m(l.fromA+h,l.toA+h,l.fromB+h,l.toB+h),r=!0)}if(!r)break}return n}(e,t,g(e,0,e.length,t,0,t.length))}function I(){return!B}function W(e,t,n){return function(e,t,n){for(let r=0,o=0;o<e.length;o++){let i=e[o],s=i.toA-i.fromA,l=i.toB-i.fromB;if(s&&l||s>3||l>3){let a=o==e.length-1?t.length:e[o+1].fromA,c=i.fromA-r,f=a-i.toA,h=G(t,i.fromA,c),d=N(t,i.toA,f),u=i.fromA-h,g=d-i.toA;if((!s||!l)&&u&&g){let c=Math.max(s,l),[f,p,A]=s?[t,i.fromA,i.toA]:[n,i.fromB,i.toB];c>u&&t.slice(h,i.fromA)==f.slice(A-u,A)?(i=e[o]=new m(h,h+s,i.fromB-u,i.toB-u),h=i.fromA,d=N(t,i.toA,a-i.toA)):c>g&&t.slice(i.toA,d)==f.slice(p,p+g)&&(i=e[o]=new m(d-s,d,i.fromB+g,i.toB+g),d=i.toA,h=G(t,i.fromA,i.fromA-r)),u=i.fromA-h,g=d-i.toA}if(u||g)i=e[o]=new m(i.fromA-u,i.toA+g,i.fromB-u,i.toB+g);else if(s){if(!l){let n,r=j(t,i.fromA,i.toA),s=r<0?-1:F(t,i.toA,i.fromA);r>-1&&(n=r-i.fromA)<=f&&t.slice(i.fromA,r)==t.slice(i.toA,i.toA+n)?i=e[o]=i.offset(n):s>-1&&(n=i.toA-s)<=c&&t.slice(i.fromA-n,i.fromA)==t.slice(s,i.toA)&&(i=e[o]=i.offset(-n))}}else{let t,r=j(n,i.fromB,i.toB),s=r<0?-1:F(n,i.toB,i.fromB);r>-1&&(t=r-i.fromB)<=f&&n.slice(i.fromB,r)==n.slice(i.toB,i.toB+t)?i=e[o]=i.offset(t):s>-1&&(t=i.toB-s)<=c&&n.slice(i.fromB-t,i.fromB)==n.slice(s,i.toB)&&(i=e[o]=i.offset(-t))}}r=i.toA}return y(e,3),e}(U(e,t,n),e,t)}const q=o.Facet.define({combine:e=>e[0]}),z=o.StateEffect.define(),Y=o.Facet.define(),Z=o.StateField.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(z)&&(e=n.value);for(let n of t.state.facet(Y))e=n(e,t);return e}});function $(e){let t=e.field(Z,!1);if(!t)return null;let n=e.facet(q);return{chunks:t,side:n?n.side:null}}let J=e=>({state:t,dispatch:n})=>{let i=t.field(Z,!1),s=t.facet(q);if(!i||!i.length||!s)return!1;let{head:l}=t.selection.main,a=0;for(let t=i.length-1;t>=0;t--){let n=i[t],[r,o]="b"==s.side?[n.fromB,n.toB]:[n.fromA,n.toA];if(o<l){a=t+1;break}if(r<=l){if(1==i.length)return!1;a=t+(e<0?0:1);break}}let c=i[(a+(e<0?i.length-1:0))%i.length],[f,h]="b"==s.side?[c.fromB,c.toB]:[c.fromA,c.toA];return n(t.update({selection:{anchor:f},userEvent:"select.byChunk",effects:r.EditorView.scrollIntoView(o.EditorSelection.range(h,f))})),!0};const K=J(1),Q=J(-1);class X{constructor(e,t,n,r,o,i=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=o,this.precise=i}offset(e,t){return e||t?new X(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return ne(W(e.toString(),t.toString(),n),e,t,0,0,I())}static updateA(e,t,n,r,o){return se(ie(e,r,!0,n.length),e,t,n,o)}static updateB(e,t,n,r,o){return se(ie(e,r,!1,t.length),e,t,n,o)}}function ee(e,t,n,r){let o=n.lineAt(e),i=r.lineAt(t);return o.to==e&&i.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[o.from,i.from]}function te(e,t,n,r){let o=n.lineAt(e),i=r.lineAt(t);return o.from==e&&i.from==t?[e,t]:[o.to+1,i.to+1]}function ne(e,t,n,r,o,i){let s=[];for(let l=0;l<e.length;l++){let a=e[l],[c,f]=ee(a.fromA+r,a.fromB+o,t,n),[h,d]=te(a.toA+r,a.toB+o,t,n),u=[a.offset(-c+r,-f+o)];for(;l<e.length-1;){let i=e[l+1],[s,a]=ee(i.fromA+r,i.fromB+o,t,n);if(s>h+1&&a>d+1)break;u.push(i.offset(-c+r,-f+o)),[h,d]=te(i.toA+r,i.toB+o,t,n),l++}s.push(new X(u,c,Math.max(c,h),f,Math.max(f,d),i))}return s}const re=1e3;function oe(e,t,n,r){let o=0,i=e.length;for(;;){if(o==i){let r=0,i=0;o&&({toA:r,toB:i}=e[o-1]);let s=t-(n?r:i);return[r+s,i+s]}let s=o+i>>1,l=e[s],[a,c]=n?[l.fromA,l.toA]:[l.fromB,l.toB];if(a>t)i=s;else{if(!(c<=t))return r?[l.fromA,l.fromB]:[l.toA,l.toB];o=s+1}}}function ie(e,t,n,r){let o=[];return t.iterChangedRanges((i,s,l,a)=>{let c=0,f=n?t.length:r,h=0,d=n?r:t.length;i>re&&([c,h]=oe(e,i-re,n,!0)),s<t.length-re&&([f,d]=oe(e,s+re,n,!1));let u,m=a-l-(s-i),[g,p]=n?[m,0]:[0,m];o.length&&(u=o[o.length-1]).toA>=c?o[o.length-1]={fromA:u.fromA,fromB:u.fromB,toA:f,toB:d,diffA:u.diffA+g,diffB:u.diffB+p}:o.push({fromA:c,toA:f,fromB:h,toB:d,diffA:g,diffB:p})}),o}function se(e,t,n,r,o){if(!e.length)return t;let i=[];for(let s=0,l=0,a=0,c=0;;s++){let f=s==e.length?null:e[s],h=f?f.fromA+l:n.length,d=f?f.fromB+a:r.length;for(;c<t.length;){let e=t[c];if(e.toA+l>h||e.toB+a>d)break;i.push(e.offset(l,a)),c++}if(!f)break;let u=f.toA+l+f.diffA,m=f.toB+a+f.diffB,g=W(n.sliceString(h,u),r.sliceString(d,m),o);for(let e of ne(g,n,r,h,d,I()))i.push(e);for(l+=f.diffA,a+=f.diffB;c<t.length;){let e=t[c];if(e.fromA+l>u&&e.fromB+a>m)break;c++}}return i}const le={scanLimit:500},ae=r.ViewPlugin.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=pe(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(Z,!1)!=n.field(Z,!1))||function(e,t){return e.facet(q)!=t.facet(q)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=pe(e.view))}},{decorations:e=>e.deco}),ce=o.Prec.low((0,r.gutter)({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(ae))||void 0===t?void 0:t.gutter)||o.RangeSet.empty}})),fe=r.Decoration.line({class:"cm-changedLine"}),he=r.Decoration.mark({class:"cm-changedText"}),de=r.Decoration.mark({tagName:"ins",class:"cm-insertedLine"}),ue=r.Decoration.mark({tagName:"del",class:"cm-deletedLine"}),me=new class extends r.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function ge(e,t,n,r,o,i){let s=n?e.fromA:e.fromB,l=n?e.toA:e.toB,a=0;if(s!=l){o.add(s,s,fe),o.add(s,l,n?ue:de),i&&i.add(s,s,me);for(let c=t.iterRange(s,l-1),f=s;!c.next().done;){if(c.lineBreak){f++,o.add(f,f,fe),i&&i.add(f,f,me);continue}let t=f+c.value.length;if(r)for(;a<e.changes.length;){let r=e.changes[a],i=s+(n?r.fromA:r.fromB),l=s+(n?r.toA:r.toB),c=Math.max(f,i),h=Math.min(t,l);if(c<h&&o.add(c,h,he),!(l<t))break;a++}f=t}}}function pe(e){let t=e.state.field(Z),{side:n,highlightChanges:r,markGutter:i,overrideChunk:s}=e.state.facet(q),l="a"==n,a=new o.RangeSetBuilder,c=i?new o.RangeSetBuilder:null,{from:f,to:h}=e.viewport;for(let n of t){if((l?n.fromA:n.fromB)>=h)break;(l?n.toA:n.toB)>f&&(s&&s(e.state,n,a,c)||ge(n,e.state.doc,l,r,a,c))}return{deco:a.finish(),gutter:c&&c.finish()}}class Ae extends r.WidgetType{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const Be=o.StateEffect.define({map:(e,t)=>e.map(t)}),ve=o.StateField.define({create:()=>r.Decoration.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Be))return e.value;return e.map(t.changes)},provide:e=>r.EditorView.decorations.from(e)}),be=.01;function we(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}const Ce=o.StateEffect.define({map:(e,t)=>t.mapPos(e)});class ke extends r.WidgetType{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent=e.state.phrase("$ unchanged lines",this.lines),t.addEventListener("click",t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Ce.of(n)});let{side:r,sibling:o}=e.state.facet(q);o&&o().dispatch({effects:Ce.of(xe(n,e.state.field(Z),"a"==r))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function xe(e,t,n){let r=0,o=0;for(let i=0;;i++){let s=i<t.length?t[i]:null;if(!s||(n?s.fromA:s.fromB)>=e)return o+(e-r);[r,o]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const Me=o.StateField.define({create:e=>r.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ce)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>r.EditorView.decorations.from(e)});function De({margin:e=3,minSize:t=4}){return Me.init(n=>function(e,t,n){let i=new o.RangeSetBuilder,s="a"==e.facet(q).side,l=e.field(Z),a=1;for(let o=0;;o++){let c=o<l.length?l[o]:null,f=o?a+t:1,h=c?e.doc.lineAt(s?c.fromA:c.fromB).number-1-t:e.doc.lines,d=h-f+1;if(d>=n&&i.add(e.doc.line(f).from,e.doc.line(h).to,r.Decoration.replace({widget:new ke(d),block:!0})),!c)break;a=e.doc.lineAt(Math.min(e.doc.length,s?c.toA:c.toB)).number}return i.finish()}(n,e,t))}const Se=r.EditorView.styleModule.of(new a({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Ee=r.EditorView.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),ye=new o.Compartment,Te=new o.Compartment;class Oe{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||le;let t=[o.Prec.low(ae),Ee,Se,ve,r.EditorView.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Be)))&&this.measure()})],n=[q.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(ce);let i=o.EditorState.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],r.EditorView.editorAttributes.of({class:"cm-merge-a"}),Te.of(n),t]}),s=[q.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&s.push(ce);let l=o.EditorState.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],r.EditorView.editorAttributes.of({class:"cm-merge-b"}),Te.of(s),t]});this.chunks=X.build(i.doc,l.doc,this.diffConf);let a=[Z.init(()=>this.chunks),ye.of(e.collapseUnchanged?De(e.collapseUnchanged):[])];i=i.update({effects:o.StateEffect.appendConfig.of(a)}).state,l=l.update({effects:o.StateEffect.appendConfig.of(a)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let c=e.orientation||"a-b",f=document.createElement("div");f.className="cm-mergeViewEditor";let h=document.createElement("div");h.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==c?f:h),this.editorDOM.appendChild("a-b"==c?h:f),this.a=new r.EditorView({state:i,parent:f,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new r.EditorView({state:l,parent:h,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),o.ChangeSet.empty(e[0].startState.doc.length));this.chunks=t==this.a?X.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):X.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:z.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:z.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t="highlightChanges"in e,n="gutter"in e,r="collapseUnchanged"in e;if(t||n||r){let o=[],i=[];if(t||n){let r=this.a.state.facet(q),s=n?!1!==e.gutter:r.markGutter,l=t?!1!==e.highlightChanges:r.highlightChanges;o.push(Te.reconfigure([q.of({side:"a",sibling:()=>this.b,highlightChanges:l,markGutter:s}),s?ce:[]])),i.push(Te.reconfigure([q.of({side:"b",sibling:()=>this.a,highlightChanges:l,markGutter:s}),s?ce:[]]))}if(r){let t=ye.reconfigure(e.collapseUnchanged?De(e.collapseUnchanged):[]);o.push(t),i.push(t)}this.a.dispatch({effects:o}),this.b.dispatch({effects:i})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",e=>this.revertClicked(e)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){!function(e,t,n){let i=new o.RangeSetBuilder,s=new o.RangeSetBuilder,l=e.state.field(ve).iter(),a=t.state.field(ve).iter(),c=0,f=0,h=0,d=0,u=e.viewport,m=t.viewport;for(let o=0;;o++){let g=o<n.length?n[o]:null,p=g?g.fromA:e.state.doc.length,A=g?g.fromB:t.state.doc.length;if(c<p){let n=e.lineBlockAt(c).top+h-(t.lineBlockAt(f).top+d);n<-.01?(h-=n,i.add(c,c,r.Decoration.widget({widget:new Ae(-n),block:!0,side:-1}))):n>be&&(d+=n,s.add(f,f,r.Decoration.widget({widget:new Ae(n),block:!0,side:-1})))}if(p>c+1e3&&c<u.from&&p>u.from&&f<m.from&&A>m.from){let e=Math.min(u.from-c,m.from-f);c+=e,f+=e,o--}else{if(!g)break;c=g.toA,f=g.toB}for(;l.value&&l.from<c;)h-=l.value.spec.widget.height,l.next();for(;a.value&&a.from<f;)d-=a.value.spec.widget.height,a.next()}for(;l.value;)h-=l.value.spec.widget.height,l.next();for(;a.value;)d-=a.value.spec.widget.height,a.next();let g=e.contentHeight+h-(t.contentHeight+d);g<be?i.add(e.state.doc.length,e.state.doc.length,r.Decoration.widget({widget:new Ae(-g),block:!0,side:1})):g>be&&s.add(t.state.doc.length,t.state.doc.length,r.Decoration.widget({widget:new Ae(g),block:!0,side:1}));let p=i.finish(),A=s.finish();we(p,e.state.field(ve))||e.dispatch({effects:Be.of(p)}),we(A,t.state.field(ve))||t.dispatch({effects:Be.of(A)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let o=0;o<this.chunks.length;o++){let i=this.chunks[o];if(i.fromA>n.to||i.fromB>r.to)break;if(i.fromA<n.from||i.fromB<r.from)continue;let s=this.a.lineBlockAt(i.fromA).top+"px";for(;t&&+t.dataset.chunk<o;)t=Le(t);t&&t.dataset.chunk==String(o)?(t.style.top!=s&&(t.style.top=s),t=t.nextSibling):e.insertBefore(this.renderRevertButton(s,o),t)}for(;t;)t=Le(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,r,o,i,s,l]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],a=n.state.sliceDoc(o,Math.max(o,i-1));o!=i&&l<=r.state.doc.length&&(a+=n.state.lineBreak),r.dispatch({changes:{from:s,to:Math.min(r.state.doc.length,l),insert:a},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Le(e){let t=e.nextSibling;return e.remove(),t}const Re=new class extends r.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Ve=o.Prec.low((0,r.gutter)({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(ae))||void 0===t?void 0:t.gutter)||o.RangeSet.empty},widgetMarker:(e,t)=>t instanceof qe?Re:null}));function Ne(e){var t;let n="string"==typeof e.original?o.Text.of(e.original.split(/\r?\n/)):e.original,i=e.diffConfig||le;const s=(e.invertedEffects||h.g_).of(e=>{let t=[];for(let n of e.effects)n.is(Fe)?t.push(Ge.of({doc:n.value.originalDoc,changes:n.value.changes.invert(e.startState.field(Ue))})):n.is(je)&&t.push(je.of({chunkFromA:n.value.chunkFromA,chunkToA:n.value.chunkToA,chunkFromB:n.value.chunkFromB,chunkToB:n.value.chunkToB,originalContent:n.value.currentContent,currentContent:n.value.originalContent,changes:n.value.changes.invert(e.startState.doc)}));return t});return[o.Prec.low(ae),Je,Ee,s,r.EditorView.editorAttributes.of({class:"cm-merge-b"}),Y.of((e,t)=>{let n=t.effects.find(e=>e.is(Ge)),r=t.effects.find(e=>e.is(Fe)),o=t.effects.find(e=>e.is(je)),s=t.effects.find(e=>e.is(Pe));return n&&(e=X.updateA(e,n.value.doc,t.startState.doc,n.value.changes,i)),r&&(e=X.updateA(e,r.value.changes.apply(t.startState.field(Ue)),t.startState.doc,r.value.changes,i)),s&&(e=X.build(t.state.field(Ue),t.newDoc,i)),(o||e.length&&t.docChanged)&&(e=X.updateB(e,t.state.field(Ue),t.newDoc,t.changes,i)),e}),q.of({highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter,syntaxHighlightDeletions:!1!==e.syntaxHighlightDeletions,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:null===(t=e.mergeControls)||void 0===t||t,overrideChunk:e.allowInlineDiffs?nt:void 0,side:"b"}),Ue.init(()=>n),!1!==e.gutter?Ve:[],e.collapseUnchanged?De(e.collapseUnchanged):[],Z.init(e=>X.build(n,e.doc,i))]}const Ge=o.StateEffect.define(),Fe=o.StateEffect.define({map:(e,t)=>{let n=t.mapPos(e.chunkFromB),r=t.mapPos(e.chunkToB);return n<r?Object.assign(Object.assign({},e),{chunkFromB:n,chunkToB:r}):void 0}}),je=o.StateEffect.define({map:(e,t)=>{let n=t.mapPos(e.chunkFromB),r=t.mapPos(e.chunkToB);return n<r?Object.assign(Object.assign({},e),{chunkFromB:n,chunkToB:r}):void 0}}),Pe=o.StateEffect.define();function _e(e,t){return Ge.of({doc:t.apply(Ie(e)),changes:t})}function He(e,t,n={}){const{replaceAll:r=!0,insertAt:o}=n;let i;if(r)i={from:0,to:e.state.doc.length,insert:t};else if(void 0!==o)i={from:o,to:o,insert:t};else{const n=e.state.selection.main.head;i={from:n,to:n,insert:t}}e.dispatch({changes:i,effects:Pe.of({generatedCode:t,replaceAll:r,insertAt:o}),userEvent:"generate.code"})}const Ue=o.StateField.define({create:()=>o.Text.empty,update(e,t){for(let n of t.effects)n.is(Ge)?e=n.value.doc:n.is(Fe)?e=n.value.changes.apply(e):n.is(je);return e}});function Ie(e){return e.field(Ue)}const We=new WeakMap;class qe extends r.WidgetType{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function ze(e,t,n){let o=We.get(t.changes);if(o)return o;let i=r.Decoration.widget({block:!0,side:-1,widget:new qe(r=>{let{highlightChanges:o,syntaxHighlightDeletions:i,syntaxHighlightDeletionsMaxLength:s,mergeControls:l}=e.facet(q),a=document.createElement("div");if(a.className="cm-deletedChunk",l){let t=a.appendChild(document.createElement("div"));t.className="cm-chunkButtons";let n=e=>{e.preventDefault(),Ye(r,r.posAtDOM(a))},o=e=>{e.preventDefault(),Ze(r,r.posAtDOM(a))};if("function"==typeof l)t.appendChild(l("accept",n)),t.appendChild(l("reject",o));else{let r=t.appendChild(document.createElement("button"));r.name="accept",r.textContent=e.phrase("Accept"),r.onmousedown=n;let i=t.appendChild(document.createElement("button"));i.name="reject",i.textContent=e.phrase("Reject"),i.onmousedown=o}}if(n||t.fromA>=t.toA)return a;let c=r.state.field(Ue).sliceString(t.fromA,t.endA),f=i&&e.facet(d.language),h=A(),m=t.changes,g=0,p=!1;function A(){let e=a.appendChild(document.createElement("div"));return e.className="cm-deletedLine",e.appendChild(document.createElement("del"))}function B(e,t,n){for(let r=e;r<t;){if("\n"==c.charAt(r)){h.firstChild||h.appendChild(document.createElement("br")),h=A(),r++;continue}let e=t,i=n+(p?" cm-deletedText":""),s=!1,l=c.indexOf("\n",r);if(l>-1&&l<t&&(e=l),o&&g<m.length){let t=Math.max(0,p?m[g].toA:m[g].fromA);t<=e&&(e=t,p&&g++,s=!0)}if(e>r){let t=document.createTextNode(c.slice(r,e));if(i){let e=h.appendChild(document.createElement("span"));e.className=i,e.appendChild(t)}else h.appendChild(t);r=e}s&&(p=!p)}}if(f&&t.toA-t.fromA<=s){let t=f.parser.parse(c),n=0;(0,u.highlightTree)(t,{style:t=>(0,d.highlightingFor)(e,t)},(e,t,r)=>{e>n&&B(n,e,""),B(e,t,r),n=t}),B(n,c.length,"")}else B(0,c.length,"");return h.firstChild||h.appendChild(document.createElement("br")),a})});return We.set(t.changes,i),i}function Ye(e,t){let{state:n}=e,r=null!=t?t:n.selection.main.head,i=e.state.field(Z).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let s=e.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),l=e.state.field(Ue);i.fromB!=i.toB&&i.toA<=l.length&&(s+=e.state.lineBreak);let a=o.ChangeSet.of({from:i.fromA,to:Math.min(l.length,i.toA),insert:s},l.length);return e.dispatch({effects:Fe.of({chunkFromA:i.fromA,chunkToA:i.toA,chunkFromB:i.fromB,chunkToB:i.toB,originalDoc:l,currentContent:s,changes:a}),userEvent:"accept"}),!0}function Ze(e,t){let{state:n}=e,r=null!=t?t:n.selection.main.head,i=n.field(Z).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let s=n.field(Ue).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));i.fromA!=i.toA&&i.toB<=n.doc.length&&(s+=n.lineBreak);let l=n.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),a=o.ChangeSet.of({from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:s},n.doc.length);return e.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:s},effects:je.of({chunkFromA:i.fromA,chunkToA:i.toA,chunkFromB:i.fromB,chunkToB:i.toB,originalContent:s,currentContent:l,changes:a}),userEvent:"revert"}),!0}function $e(e){let t=new o.RangeSetBuilder;for(let n of e.field(Z)){let r=e.facet(q).overrideChunk&&Qe(e,n);t.add(n.fromB,n.fromB,ze(e,n,!!r))}return t.finish()}const Je=o.StateField.define({create:e=>$e(e),update:(e,t)=>t.state.field(Z,!1)!=t.startState.field(Z,!1)?$e(t.state):e,provide:e=>r.EditorView.decorations.from(e)}),Ke=new WeakMap;function Qe(e,t){let n=Ke.get(t);if(void 0!==n)return n;n=null;let o=e.field(Ue),i=e.doc,s=o.lineAt(t.endA).number-o.lineAt(t.fromA).number+1;e:if(s==i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1&&s<10){let e=[],i=0,l=t.fromA,a=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=o.sliceString(l+n.fromA,l+n.toA);if(/\n/.test(t))break e;e.push(r.Decoration.widget({widget:new Xe(t),side:-1}).range(a+n.fromB))}n.fromB<n.toB&&e.push(he.range(a+n.fromB,a+n.toB))}i<t.endA-t.fromA-2*s&&(n=e)}return Ke.set(t,n),n}class Xe extends r.WidgetType{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement("del");return t.className="cm-deletedText",t.textContent=this.text,t}}const et=new class extends r.GutterMarker{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},tt=r.Decoration.line({class:"cm-inlineChangedLine"});function nt(e,t,n,r){let o=Qe(e,t),i=0;if(!o)return!1;for(let s=e.doc.lineAt(t.fromB);;){for(r&&r.add(s.from,s.from,et),n.add(s.from,s.from,tt);i<o.length&&o[i].to<=s.to;){let e=o[i++];n.add(e.from,e.to,e.value)}if(s.to>=t.endB)break;s=e.doc.lineAt(s.to+1)}return!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])])()}}]);
|