vzcode 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,7 +65,7 @@ Source:
|
|
|
65
65
|
`))):qe=W.stylize("[Circular]","special")),A(ze)){if(De&&Ee.match(/^\d+$/))return qe;ze=JSON.stringify(""+Ee),ze.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(ze=ze.slice(1,-1),ze=W.stylize(ze,"name")):(ze=ze.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),ze=W.stylize(ze,"string"))}return ze+": "+qe}function w(W,j,V){var Oe=W.reduce(function(Ee,De){return De.indexOf(`
|
|
66
66
|
`)>=0,Ee+De.replace(/\u001b\[\d\d?m/g,"").length+1},0);return Oe>60?V[0]+(j===""?"":j+`
|
|
67
67
|
`)+" "+W.join(`,
|
|
68
|
-
`)+" "+V[1]:V[0]+j+" "+W.join(", ")+" "+V[1]}i.types=n("./support/types");function x(W){return Array.isArray(W)}i.isArray=x;function _(W){return typeof W=="boolean"}i.isBoolean=_;function T(W){return W===null}i.isNull=T;function b(W){return W==null}i.isNullOrUndefined=b;function k(W){return typeof W=="number"}i.isNumber=k;function P(W){return typeof W=="string"}i.isString=P;function C(W){return typeof W=="symbol"}i.isSymbol=C;function A(W){return W===void 0}i.isUndefined=A;function N(W){return X(W)&&L(W)==="[object RegExp]"}i.isRegExp=N,i.types.isRegExp=N;function X(W){return typeof W=="object"&&W!==null}i.isObject=X;function te(W){return X(W)&&L(W)==="[object Date]"}i.isDate=te,i.types.isDate=te;function M(W){return X(W)&&(L(W)==="[object Error]"||W instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(W){return typeof W=="function"}i.isFunction=I;function D(W){return W===null||typeof W=="boolean"||typeof W=="number"||typeof W=="string"||typeof W=="symbol"||typeof W>"u"}i.isPrimitive=D,i.isBuffer=n("./support/isBuffer");function L(W){return Object.prototype.toString.call(W)}function F(W){return W<10?"0"+W.toString(10):W.toString(10)}var he=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ve(){var W=new Date,j=[F(W.getHours()),F(W.getMinutes()),F(W.getSeconds())].join(":");return[W.getDate(),he[W.getMonth()],j].join(" ")}i.log=function(){console.log("%s - %s",ve(),i.format.apply(i,arguments))},i.inherits=n("inherits"),i._extend=function(W,j){if(!j||!X(j))return W;for(var V=Object.keys(j),Oe=V.length;Oe--;)W[V[Oe]]=j[V[Oe]];return W};function B(W,j){return Object.prototype.hasOwnProperty.call(W,j)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&j[K]){var V=j[K];if(typeof V!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),V}function V(){for(var Oe,Ee,De=new Promise(function(Ve,gt){Oe=Ve,Ee=gt}),ze=[],qe=0;qe<arguments.length;qe++)ze.push(arguments[qe]);ze.push(function(Ve,gt){Ve?Ee(Ve):Oe(gt)});try{j.apply(this,ze)}catch(Ve){Ee(Ve)}return De}return Object.setPrototypeOf(V,Object.getPrototypeOf(j)),K&&Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(V,o(j))},i.promisify.custom=K;function oe(W,j){if(!W){var V=new Error("Promise was rejected with a falsy value");V.reason=W,W=V}return j(W)}function Be(W){if(typeof W!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var V=[],Oe=0;Oe<arguments.length;Oe++)V.push(arguments[Oe]);var Ee=V.pop();if(typeof Ee!="function")throw new TypeError("The last argument must be of type Function");var De=this,ze=function(){return Ee.apply(De,arguments)};W.apply(this,V).then(function(qe){s.nextTick(ze.bind(null,null,qe))},function(qe){s.nextTick(oe.bind(null,qe,ze))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(W)),Object.defineProperties(j,o(W)),j}i.callbackify=Be}).call(this)}).call(this,n("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(n,r,i){(function(s){(function(){var o=n("for-each"),l=n("available-typed-arrays"),a=n("call-bind/callBound"),u=n("gopd"),c=a("Object.prototype.toString"),h=n("has-tostringtag/shams")(),f=typeof globalThis>"u"?s:globalThis,d=l(),p=a("String.prototype.slice"),g={},O=Object.getPrototypeOf;h&&u&&O&&o(d,function(v){if(typeof f[v]=="function"){var w=new f[v];if(Symbol.toStringTag in w){var x=O(w),_=u(x,Symbol.toStringTag);if(!_){var T=O(x);_=u(T,Symbol.toStringTag)}g[v]=_.get}}});var y=function(w){var x=!1;return o(g,function(_,T){if(!x)try{var b=_.call(w);b===T&&(x=b)}catch{}}),x},m=n("is-typed-array");r.exports=function(w){return m(w)?!h||!(Symbol.toStringTag in w)?p(c(w),8,-1):y(w):!1}}).call(this)}).call(this,typeof yr<"u"?yr:typeof self<"u"?self:typeof window<"u"?window:{})},{"available-typed-arrays":5,"call-bind/callBound":6,"for-each":8,gopd:12,"has-tostringtag/shams":15,"is-typed-array":21}],39:[function(n,r,i){const s=n("ot-json1-presence"),o=n("ot-text-unicode");r.exports={json1Presence:s,textUnicode:o}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(f_);var y2=f_.exports;const v2=us(y2),{json1Presence:ep,textUnicode:h_}=v2;function S2(t){return new Worker("/assets/worker-hNl6wfTa.js",{name:t==null?void 0:t.name})}function w2(t){return new Worker("/assets/worker-yC2XHXrj.js",{name:t==null?void 0:t.name})}const b2=!0,_1=800,d_="vzCodeSidebarWidth",p_="vzCodeCodeEditorWidth",g_=220;let tp=g_;const m_=800;let np=m_,Im=!1;if(typeof window<"u"&&b2){const t=window.localStorage.getItem(d_),e=window.localStorage.getItem(p_);t!==null&&(tp=+t,Im=!0),e!==null&&(np=+e,Im=!0)}const k2={codeEditorWidth:np,sidebarWidth:tp,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},rp=Y.createContext(k2),x2={sidebarWidth:g_,codeEditorWidth:m_,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},P2=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:tp,codeEditorWidth:np,isInitialized:!0};case"move":return e.side==="left"?{...t,sidebarWidth:t.sidebarWidth+e.movementX}:{...t,codeEditorWidth:t.codeEditorWidth+e.movementX};case"setIsDragging":return e.side==="left"?{...t,isDraggingLeft:e.isDragging}:{...t,isDraggingRight:e.isDragging};default:return t}},_2=({children:t})=>{const[e,n]=Y.useReducer(P2,x2),r=Y.useCallback((h,f)=>{n({type:"setIsDragging",isDragging:h,side:f})},[n]),i=Y.useCallback((h,f)=>{n({type:"move",movementX:h,side:f})},[n]),{sidebarWidth:s,codeEditorWidth:o,isDraggingLeft:l,isDraggingRight:a,isInitialized:u}=e;typeof window<"u"&&Y.useLayoutEffect(()=>{Im&&!u&&n({type:"initialize"})},[u]),Y.useEffect(()=>{s!==tp&&setTimeout(()=>{window.localStorage.setItem(d_,""+s)},_1),o!==np&&setTimeout(()=>{window.localStorage.setItem(p_,""+o)},_1)},[o,s]);const c={codeEditorWidth:o,sidebarWidth:s,moveSplitPane:i,isDraggingLeft:l,isDraggingRight:a,setIsDragging:r};return G.jsx(rp.Provider,{value:c,children:t})},O_=1200,C2=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},E2=(t,e,n)=>{const r=new Set,[i,s]=Y.useState(null),o=Y.useRef(!1);return Y.useEffect(()=>{if(!t)return;const l=h=>{const{fileId:f,error:d,fileTextPrettified:p}=h.data;if(d){s(d);return}else s(null);o.current=!0,e(g=>({...g,files:{...g.files,[f]:{...g.files[f],text:p}}})),o.current=!1};n.addEventListener("message",l);const a=async()=>{const f=t.data.files,d=Array.from(r);r.clear();for(const p of d){const g=f[p],O={fileText:g.text,fileExtension:C2(g.name),fileId:p};n.postMessage(O)}};let u;function c(){clearTimeout(u),u=setTimeout(a,O_)}return window.addEventListener("mousemove",c),window.addEventListener("keydown",c),t.on("op batch",(h,f)=>{if(f){if(o.current)return;if(h&&h.length===4&&h[0]==="files"&&typeof h[1]=="string"&&h[2]==="text"){const d=h[1];r.add(d),c()}}}),()=>{n.removeEventListener("message",l),window.removeEventListener("keydown",c),window.removeEventListener("mousemove",c),clearTimeout(u)}},[t]),{prettierError:i}},T2=500,$2=O_+T2,Q2=({content:t,typeScriptWorker:e})=>{const n=Y.useRef(null),r=Y.useCallback(i=>{clearTimeout(n.current),n.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},$2)},[e]);Y.useEffect(()=>{r(t)},[t])},R2=(t,e)=>{if(e.type!=="close_tabs")return t;const n=t.tabList.filter(s=>!e.fileIdsToClose.includes(s.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:n};const r=t.tabList.findIndex(s=>s.fileId===t.activeFileId);let i=null;for(let s=r-1;s>=0;s--)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}if(!i){for(let s=r+1;s<t.tabList.length;s++)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}}return{...t,tabList:n,activeFileId:i}},A2=(t,e)=>{if(e.type!=="open_tab")return t;const n=t.tabList.findIndex(a=>a.fileId===e.fileId),r=n!==-1,i=r&&t.tabList[n].isTransient,s=t.tabList.findIndex(a=>a.isTransient&&a.fileId!==e.fileId),o={fileId:e.fileId,isTransient:e.isTransient};let l;return r?i?l=t.tabList.map(a=>a.fileId===e.fileId?o:a):l=[...t.tabList]:s!==-1?(l=[...t.tabList],l[s]=o):l=[...t.tabList,o],{...t,activeFileId:e.fileId,tabList:l,editorWantsFocus:!e.isTransient}},M2=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,D2=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,N2=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,I2=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Z2=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,L2=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),W2=[M2,A2,R2,N2,D2,I2,Z2],B2=(t,e)=>W2.reduce((n,r)=>r(n,e),t);class St{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Ri.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){let r=[];return this.decompose(e,n,r,0),Ri.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new uu(this),s=new uu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new uu(this,e)}iterRange(e,n=this.length){return new y_(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new v_(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?St.empty:e.length<=32?new rn(e):Ri.from(rn.split(e,[]))}}class rn extends St{constructor(e,n=X2(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new Y2(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new rn(C1(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Oh(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new rn(l,o.length+s.length));else{let a=l.length>>1;r.push(new rn(l.slice(0,a)),new rn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof rn))return super.replace(e,n,r);let i=Oh(this.text,Oh(r.text,C1(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new rn(i,s):Ri.from(rn.split(i,[]),s)}sliceString(e,n=this.length,r=`
|
|
68
|
+
`)+" "+V[1]:V[0]+j+" "+W.join(", ")+" "+V[1]}i.types=n("./support/types");function x(W){return Array.isArray(W)}i.isArray=x;function _(W){return typeof W=="boolean"}i.isBoolean=_;function T(W){return W===null}i.isNull=T;function b(W){return W==null}i.isNullOrUndefined=b;function k(W){return typeof W=="number"}i.isNumber=k;function P(W){return typeof W=="string"}i.isString=P;function C(W){return typeof W=="symbol"}i.isSymbol=C;function A(W){return W===void 0}i.isUndefined=A;function N(W){return X(W)&&L(W)==="[object RegExp]"}i.isRegExp=N,i.types.isRegExp=N;function X(W){return typeof W=="object"&&W!==null}i.isObject=X;function te(W){return X(W)&&L(W)==="[object Date]"}i.isDate=te,i.types.isDate=te;function M(W){return X(W)&&(L(W)==="[object Error]"||W instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(W){return typeof W=="function"}i.isFunction=I;function D(W){return W===null||typeof W=="boolean"||typeof W=="number"||typeof W=="string"||typeof W=="symbol"||typeof W>"u"}i.isPrimitive=D,i.isBuffer=n("./support/isBuffer");function L(W){return Object.prototype.toString.call(W)}function F(W){return W<10?"0"+W.toString(10):W.toString(10)}var he=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ve(){var W=new Date,j=[F(W.getHours()),F(W.getMinutes()),F(W.getSeconds())].join(":");return[W.getDate(),he[W.getMonth()],j].join(" ")}i.log=function(){console.log("%s - %s",ve(),i.format.apply(i,arguments))},i.inherits=n("inherits"),i._extend=function(W,j){if(!j||!X(j))return W;for(var V=Object.keys(j),Oe=V.length;Oe--;)W[V[Oe]]=j[V[Oe]];return W};function B(W,j){return Object.prototype.hasOwnProperty.call(W,j)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&j[K]){var V=j[K];if(typeof V!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),V}function V(){for(var Oe,Ee,De=new Promise(function(Ve,gt){Oe=Ve,Ee=gt}),ze=[],qe=0;qe<arguments.length;qe++)ze.push(arguments[qe]);ze.push(function(Ve,gt){Ve?Ee(Ve):Oe(gt)});try{j.apply(this,ze)}catch(Ve){Ee(Ve)}return De}return Object.setPrototypeOf(V,Object.getPrototypeOf(j)),K&&Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(V,o(j))},i.promisify.custom=K;function oe(W,j){if(!W){var V=new Error("Promise was rejected with a falsy value");V.reason=W,W=V}return j(W)}function Be(W){if(typeof W!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var V=[],Oe=0;Oe<arguments.length;Oe++)V.push(arguments[Oe]);var Ee=V.pop();if(typeof Ee!="function")throw new TypeError("The last argument must be of type Function");var De=this,ze=function(){return Ee.apply(De,arguments)};W.apply(this,V).then(function(qe){s.nextTick(ze.bind(null,null,qe))},function(qe){s.nextTick(oe.bind(null,qe,ze))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(W)),Object.defineProperties(j,o(W)),j}i.callbackify=Be}).call(this)}).call(this,n("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(n,r,i){(function(s){(function(){var o=n("for-each"),l=n("available-typed-arrays"),a=n("call-bind/callBound"),u=n("gopd"),c=a("Object.prototype.toString"),h=n("has-tostringtag/shams")(),f=typeof globalThis>"u"?s:globalThis,d=l(),p=a("String.prototype.slice"),g={},O=Object.getPrototypeOf;h&&u&&O&&o(d,function(v){if(typeof f[v]=="function"){var w=new f[v];if(Symbol.toStringTag in w){var x=O(w),_=u(x,Symbol.toStringTag);if(!_){var T=O(x);_=u(T,Symbol.toStringTag)}g[v]=_.get}}});var y=function(w){var x=!1;return o(g,function(_,T){if(!x)try{var b=_.call(w);b===T&&(x=b)}catch{}}),x},m=n("is-typed-array");r.exports=function(w){return m(w)?!h||!(Symbol.toStringTag in w)?p(c(w),8,-1):y(w):!1}}).call(this)}).call(this,typeof yr<"u"?yr:typeof self<"u"?self:typeof window<"u"?window:{})},{"available-typed-arrays":5,"call-bind/callBound":6,"for-each":8,gopd:12,"has-tostringtag/shams":15,"is-typed-array":21}],39:[function(n,r,i){const s=n("ot-json1-presence"),o=n("ot-text-unicode");r.exports={json1Presence:s,textUnicode:o}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(f_);var y2=f_.exports;const v2=us(y2),{json1Presence:ep,textUnicode:h_}=v2;function S2(t){return new Worker("/assets/worker-hNl6wfTa.js",{name:t==null?void 0:t.name})}function w2(t){return new Worker("/assets/worker-pw8iYY3X.js",{name:t==null?void 0:t.name})}const b2=!0,_1=800,d_="vzCodeSidebarWidth",p_="vzCodeCodeEditorWidth",g_=220;let tp=g_;const m_=800;let np=m_,Im=!1;if(typeof window<"u"&&b2){const t=window.localStorage.getItem(d_),e=window.localStorage.getItem(p_);t!==null&&(tp=+t,Im=!0),e!==null&&(np=+e,Im=!0)}const k2={codeEditorWidth:np,sidebarWidth:tp,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},rp=Y.createContext(k2),x2={sidebarWidth:g_,codeEditorWidth:m_,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},P2=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:tp,codeEditorWidth:np,isInitialized:!0};case"move":return e.side==="left"?{...t,sidebarWidth:t.sidebarWidth+e.movementX}:{...t,codeEditorWidth:t.codeEditorWidth+e.movementX};case"setIsDragging":return e.side==="left"?{...t,isDraggingLeft:e.isDragging}:{...t,isDraggingRight:e.isDragging};default:return t}},_2=({children:t})=>{const[e,n]=Y.useReducer(P2,x2),r=Y.useCallback((h,f)=>{n({type:"setIsDragging",isDragging:h,side:f})},[n]),i=Y.useCallback((h,f)=>{n({type:"move",movementX:h,side:f})},[n]),{sidebarWidth:s,codeEditorWidth:o,isDraggingLeft:l,isDraggingRight:a,isInitialized:u}=e;typeof window<"u"&&Y.useLayoutEffect(()=>{Im&&!u&&n({type:"initialize"})},[u]),Y.useEffect(()=>{s!==tp&&setTimeout(()=>{window.localStorage.setItem(d_,""+s)},_1),o!==np&&setTimeout(()=>{window.localStorage.setItem(p_,""+o)},_1)},[o,s]);const c={codeEditorWidth:o,sidebarWidth:s,moveSplitPane:i,isDraggingLeft:l,isDraggingRight:a,setIsDragging:r};return G.jsx(rp.Provider,{value:c,children:t})},O_=1200,C2=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},E2=(t,e,n)=>{const r=new Set,[i,s]=Y.useState(null),o=Y.useRef(!1);return Y.useEffect(()=>{if(!t)return;const l=h=>{const{fileId:f,error:d,fileTextPrettified:p}=h.data;if(d){s(d);return}else s(null);o.current=!0,e(g=>({...g,files:{...g.files,[f]:{...g.files[f],text:p}}})),o.current=!1};n.addEventListener("message",l);const a=async()=>{const f=t.data.files,d=Array.from(r);r.clear();for(const p of d){const g=f[p],O={fileText:g.text,fileExtension:C2(g.name),fileId:p};n.postMessage(O)}};let u;function c(){clearTimeout(u),u=setTimeout(a,O_)}return window.addEventListener("mousemove",c),window.addEventListener("keydown",c),t.on("op batch",(h,f)=>{if(f){if(o.current)return;if(h&&h.length===4&&h[0]==="files"&&typeof h[1]=="string"&&h[2]==="text"){const d=h[1];r.add(d),c()}}}),()=>{n.removeEventListener("message",l),window.removeEventListener("keydown",c),window.removeEventListener("mousemove",c),clearTimeout(u)}},[t]),{prettierError:i}},T2=500,$2=O_+T2,Q2=({content:t,typeScriptWorker:e})=>{const n=Y.useRef(null),r=Y.useCallback(i=>{clearTimeout(n.current),n.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},$2)},[e]);Y.useEffect(()=>{r(t)},[t])},R2=(t,e)=>{if(e.type!=="close_tabs")return t;const n=t.tabList.filter(s=>!e.fileIdsToClose.includes(s.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:n};const r=t.tabList.findIndex(s=>s.fileId===t.activeFileId);let i=null;for(let s=r-1;s>=0;s--)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}if(!i){for(let s=r+1;s<t.tabList.length;s++)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}}return{...t,tabList:n,activeFileId:i}},A2=(t,e)=>{if(e.type!=="open_tab")return t;const n=t.tabList.findIndex(a=>a.fileId===e.fileId),r=n!==-1,i=r&&t.tabList[n].isTransient,s=t.tabList.findIndex(a=>a.isTransient&&a.fileId!==e.fileId),o={fileId:e.fileId,isTransient:e.isTransient};let l;return r?i?l=t.tabList.map(a=>a.fileId===e.fileId?o:a):l=[...t.tabList]:s!==-1?(l=[...t.tabList],l[s]=o):l=[...t.tabList,o],{...t,activeFileId:e.fileId,tabList:l,editorWantsFocus:!e.isTransient}},M2=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,D2=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,N2=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,I2=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Z2=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,L2=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),W2=[M2,A2,R2,N2,D2,I2,Z2],B2=(t,e)=>W2.reduce((n,r)=>r(n,e),t);class St{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Ri.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){let r=[];return this.decompose(e,n,r,0),Ri.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new uu(this),s=new uu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new uu(this,e)}iterRange(e,n=this.length){return new y_(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new v_(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?St.empty:e.length<=32?new rn(e):Ri.from(rn.split(e,[]))}}class rn extends St{constructor(e,n=X2(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new Y2(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new rn(C1(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Oh(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new rn(l,o.length+s.length));else{let a=l.length>>1;r.push(new rn(l.slice(0,a)),new rn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof rn))return super.replace(e,n,r);let i=Oh(this.text,Oh(r.text,C1(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new rn(i,s):Ri.from(rn.split(i,[]),s)}sliceString(e,n=this.length,r=`
|
|
69
69
|
`){let i="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(i+=r),e<a&&n>s&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new rn(r,i)),r=[],i=-1);return i>-1&&n.push(new rn(r,i)),n}}class Ri extends St{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&n>=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if(r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.length;if(e>=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines<u>>5-1&&a.lines>u>>5+1){let c=this.children.slice();return c[i]=a,new Ri(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
|
|
70
70
|
`){let i="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(i+=r),e<a&&n>o&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Ri))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new rn(d,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function h(d){let p;if(d.lines>s&&d instanceof Ri)for(let g of d.children)h(g);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof rn&&a&&(p=c[c.length-1])instanceof rn&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new rn(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>i&&f(),a+=d.lines,u+=d.length+1,c.push(d))}function f(){a!=0&&(l.push(c.length==1?c[0]:Ri.from(c,u)),u=-1,a=c.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new Ri(l,n)}}St.empty=new rn([""],0);function X2(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Oh(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=r;s++){let l=t[s],a=i+l.length;a>=n&&(a>r&&(l=l.slice(0,r-i)),i<n&&(l=l.slice(n-i)),o?(e[e.length-1]+=l,o=!1):e.push(l)),i=a+1}return e}function C1(t,e,n){return Oh(t,[""],e,n)}class uu{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof rn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof rn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
71
71
|
`,this;e--}else if(i instanceof rn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof rn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class y_{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new uu(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class v_{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(St.prototype[Symbol.iterator]=function(){return this.iter()},uu.prototype[Symbol.iterator]=y_.prototype[Symbol.iterator]=v_.prototype[Symbol.iterator]=function(){return this});let Y2=class{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}},Ql="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;t<Ql.length;t++)Ql[t]+=Ql[t-1];function j2(t){for(let e=1;e<Ql.length;e+=2)if(Ql[e]>t)return Ql[e-1]<=t;return!1}function E1(t){return t>=127462&&t<=127487}const T1=8205;function Bn(t,e,n=!0,r=!0){return(n?S_:U2)(t,e,r)}function S_(t,e,n){if(e==t.length)return e;e&&w_(t.charCodeAt(e))&&b_(t.charCodeAt(e-1))&&e--;let r=En(t,e);for(e+=Ir(r);e<t.length;){let i=En(t,e);if(r==T1||i==T1||n&&j2(i))e+=Ir(i),r=i;else if(E1(i)){let s=0,o=e-2;for(;o>=0&&E1(En(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function U2(t,e,n){for(;e>0;){let r=S_(t,e-2,n);if(r<e)return r;e--}return 0}function w_(t){return t>=56320&&t<57344}function b_(t){return t>=55296&&t<56320}function En(t,e){let n=t.charCodeAt(e);if(!b_(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return w_(r)?(n-55296<<10)+(r-56320)+65536:n}function qy(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Ir(t){return t<65536?1:2}const Zm=/\r\n?|\n/;var cn=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(cn||(cn={}));class Li{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(e,n=!1){Lm(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new Li(e)}composeDesc(e){return this.empty?e:e.empty?this:k_(this,e)}mapDesc(e,n=!1){return e.empty?this:Wm(this,e,n)}mapPos(e,n=-1,r=cn.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],u=i+l;if(a<0){if(u>e)return s+(e-i);s+=l}else{if(r!=cn.Simple&&u>=e&&(r==cn.TrackDel&&i<e&&u>e||r==cn.TrackBefore&&i<e||r==cn.TrackAfter&&u>e))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],l=i+s;if(o>=0&&i<=n&&l>=e)return i<e&&l>n?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Li(e)}static create(e){return new Li(e)}}class un extends Li{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Lm(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return Wm(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],l=n[i+1];if(l>=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length<a;)r.push(St.empty);r.push(o?e.slice(s,s+o):St.empty)}s+=o}return new un(n,r)}compose(e){return this.empty?e:e.empty?this:k_(this,e,!0)}map(e,n=!1){return e.empty?this:Wm(this,e,n,!0)}iterChanges(e,n=!1){Lm(this,e,n)}get desc(){return Li.create(this.sections)}filter(e){let n=[],r=[],i=[],s=new Mu(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);In(i,c,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;In(n,c,h),h>0&&Ts(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l<u;){if(s.done)break e;let c=Math.min(s.len,u-l);In(n,c,-1),In(i,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new un(n,r),filtered:Li.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;o<n&&In(i,n-o,-1);let h=new un(i,s);l=l?l.compose(h.map(l)):h,i=[],s=[],o=0}function u(c){if(Array.isArray(c))for(let h of c)u(h);else if(c instanceof un){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:h,to:f=h,insert:d}=c;if(h>f||h<0||f>n)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${n})`);let p=d?typeof d=="string"?St.of(d.split(r||Zm)):d:St.empty,g=p.length;if(h==f&&g==0)return;h<o&&a(),h>o&&In(i,h-o,-1),In(i,f-h,g),Ts(s,i,p),o=f}}return u(e),a(!l),l}static empty(e){return new un(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(St.empty);r[i]=St.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new un(n,r)}static createSet(e,n){return new un(e,n)}}function In(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function Ts(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(St.empty);t.push(n)}}function Lm(t,e,n){let r=t.inserted;for(let i=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)i+=l,s+=l;else{let u=i,c=s,h=St.empty;for(;u+=l,c+=a,a&&r&&(h=h.append(r[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,h),i=u,s=c}}}function Wm(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Mu(t),l=new Mu(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);In(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!n))){let u=l.len;for(In(i,l.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&a<o.i&&o.len<=c&&(In(i,0,o.ins),s&&Ts(s,i,o.text),a=o.i),o.forward(c),u-=c}l.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let h=Math.min(c,l.len);u+=h,c-=h,l.forward(h)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;In(i,u,a<o.i?o.ins:0),s&&a<o.i&&Ts(s,i,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?un.createSet(i,s):Li.create(i);throw new Error("Mismatched change set lengths")}}function k_(t,e,n=!1){let r=[],i=n?[]:null,s=new Mu(t),o=new Mu(e);for(let l=!1;;){if(s.done&&o.done)return i?un.createSet(r,i):Li.create(r);if(s.ins==0)In(r,s.len,0,l),s.next();else if(o.len==0&&!o.done)In(r,0,o.ins,l),i&&Ts(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),u=r.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;In(r,a,c,l),i&&c&&Ts(i,r,o.text)}else o.ins==-1?(In(r,s.off?0:s.len,a,l),i&&Ts(i,r,s.textBit(a))):(In(r,s.off?0:s.len,o.off?0:o.ins,l),i&&!o.off&&Ts(i,r,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Mu{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?St.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?St.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class bo{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new bo(r,i,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return J.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return J.range(this.anchor,r)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return J.range(e.anchor,e.head)}static create(e,n,r){return new bo(e,n,r)}}class J{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:J.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new J([this.main],0)}addRange(e,n=!0){return J.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,J.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new J(e.ranges.map(n=>bo.fromJSON(n)),e.main)}static single(e,n=e){return new J([J.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=r:s.from<r)return J.normalized(e.slice(),n);r=s.to}return new J(e,n)}static cursor(e,n=0,r,i){return bo.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<e?bo.create(n,e,48|s):bo.create(e,n,(n>e?8:0)|s)}static normalized(e,n=0){let r=e[n];e.sort((i,s)=>i.from-s.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);i<=n&&n--,e.splice(--i,2,s.anchor>s.head?J.range(a,l):J.range(l,a))}}return new J(e,n)}}function x_(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Vy=0;class Pe{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Vy++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Pe(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Gy),!!e.static,e.enables)}of(e){return new yh([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new yh(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new yh(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Gy(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class yh{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Vy++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?u=!0:((n=e[h.id])!==null&&n!==void 0?n:1)&1||c.push(e[h.id]);return{create(h){return h.values[o]=r(h),1},update(h,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||Bm(h,c)){let d=r(h);if(l?!$1(d,h.values[o],i):!i(d,h.values[o]))return h.values[o]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[s];if(p!=null){let g=rd(f,p);if(this.dependencies.every(O=>O instanceof Pe?f.facet(O)===h.facet(O):O instanceof pn?f.field(O,!1)==h.field(O,!1):!0)||(l?$1(d=r(h),g,i):i(d=r(h),g)))return h.values[o]=g,0}else d=r(h);return h.values[o]=d,1}}}}function $1(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function Bm(t,e){let n=!1;for(let r of e)cu(t,r)&1&&(n=!0);return n}function F2(t,e,n){let r=n.map(a=>t[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;c<r.length;c++){let h=rd(a,r[c]);if(i[c]==2)for(let f of h)u.push(f);else u.push(h)}return e.combine(u)}return{create(a){for(let u of r)cu(a,u);return a.values[o]=l(a),1},update(a,u){if(!Bm(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,u){let c=Bm(a,r),h=u.config.facets[e.id],f=u.facet(e);if(h&&!c&&Gy(n,h))return a.values[o]=f,0;let d=l(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const Q1=Pe.define({static:!0});class pn{constructor(e,n,r,i,s){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let n=new pn(Vy++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Q1).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}init(e){return[this,Q1.of({field:this,create:e})]}get extension(){return this}}const go={lowest:4,low:3,default:2,high:1,highest:0};function _a(t){return e=>new P_(e,t)}const Js={highest:_a(go.highest),high:_a(go.high),default:_a(go.default),low:_a(go.low),lowest:_a(go.lowest)};class P_{constructor(e,n){this.inner=e,this.prec=n}}class zl{of(e){return new Xm(this,e)}reconfigure(e){return zl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Xm{constructor(e,n){this.compartment=e,this.inner=n}}class nd{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let f of z2(e,n,o))f instanceof pn?i.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],u=[];for(let f of i)l[f.id]=u.length<<1,u.push(d=>f.slot(d));let c=r==null?void 0:r.config.facets;for(let f in s){let d=s[f],p=d[0].facet,g=c&&c[f]||[];if(d.every(O=>O.type==0))if(l[p.id]=a.length<<1|1,Gy(g,d))a.push(r.facet(p));else{let O=p.combine(d.map(y=>y.value));a.push(r&&p.compare(O,r.facet(p))?r.facet(p):O)}else{for(let O of d)O.type==0?(l[O.id]=a.length<<1|1,a.push(O.value)):(l[O.id]=u.length<<1,u.push(y=>O.dynamicSlot(y)));l[p.id]=u.length<<1,u.push(O=>F2(O,p,d))}}let h=u.map(f=>f(l));return new nd(e,o,h,l,a,s)}}function z2(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof Xm&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Xm){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof P_)s(o.inner,o.prec);else if(o instanceof pn)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof yh)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,go.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,go.default),r.reduce((o,l)=>o.concat(l))}function cu(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function rd(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const __=Pe.define(),C_=Pe.define({combine:t=>t.some(e=>e),static:!0}),E_=Pe.define({combine:t=>t.length?t[0]:void 0,static:!0}),T_=Pe.define(),$_=Pe.define(),Q_=Pe.define(),R_=Pe.define({combine:t=>t.length?t[0]:!1});class hi{constructor(e,n){this.type=e,this.value=n}static define(){return new q2}}class q2{of(e){return new hi(this,e)}}class V2{constructor(e){this.map=e}of(e){return new tt(this,e)}}class tt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new tt(this.type,n)}is(e){return this.type==e}static define(e={}){return new V2(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}tt.reconfigure=tt.define();tt.appendConfig=tt.define();class hn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&x_(r,n.newLength),s.some(l=>l.type==hn.time)||(this.annotations=s.concat(hn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new hn(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(hn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}hn.time=hi.define();hn.userEvent=hi.define();hn.addToHistory=hi.define();hn.remote=hi.define();function G2(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r<t.length&&(i==e.length||e[i]>=t[r]))s=t[r++],o=t[r++];else if(i<e.length)s=e[i++],o=e[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function A_(t,e,n){var r;let i,s,o;return n?(i=e.changes,s=un.empty(e.changes.length),o=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:tt.mapEffects(t.effects,i).concat(tt.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Ym(t,e,n){let r=e.selection,i=Rl(e.annotations);return e.userEvent&&(i=i.concat(hn.userEvent.of(e.userEvent))),{changes:e.changes instanceof un?e.changes:un.of(e.changes||[],n,t.facet(E_)),selection:r&&(r instanceof J?r:J.single(r.anchor,r.head)),effects:Rl(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function M_(t,e,n){let r=Ym(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;r=A_(r,Ym(t,e[s],o?r.changes.newLength:t.doc.length),o)}let i=hn.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return K2(n?H2(i):i)}function H2(t){let e=t.startState,n=!0;for(let i of e.facet(T_)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:G2(n,s))}if(n!==!0){let i,s;if(n===!1)s=t.changes.invertedDesc,i=un.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=hn.create(e,i,t.selection&&t.selection.map(s),tt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet($_);for(let i=r.length-1;i>=0;i--){let s=r[i](t);s instanceof hn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof hn?t=s[0]:t=M_(e,Rl(s),!1)}return t}function K2(t){let e=t.startState,n=e.facet(Q_),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=A_(r,Ym(e,s,t.changes.newLength),!0))}return r==t?t:hn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const J2=[];function Rl(t){return t==null?J2:Array.isArray(t)?t:[t]}var Ft=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ft||(Ft={}));const eM=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let jm;try{jm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function tM(t){if(jm)return jm.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||eM.test(n)))return!0}return!1}function nM(t){return e=>{if(!/\S/.test(e))return Ft.Space;if(tM(e))return Ft.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Ft.Word;return Ft.Other}}class pt{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)cu(this,l<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return cu(this,r),rd(this,r)}update(...e){return M_(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let o of e.effects)o.is(zl.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,a)=>i.set(a,l)),n=null),i.set(o.value.compartment,o.value.extension)):o.is(tt.reconfigure)?(n=null,r=o.value):o.is(tt.appendConfig)&&(n=null,r=Rl(r).concat(o.value));let s;n?s=e.startState.values.slice():(n=nd.resolve(r,i,this),s=new pt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new pt(n,e.newDoc,e.newSelection,s,(o,l)=>l.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:J.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Rl(r.effects);for(let l=1;l<n.ranges.length;l++){let a=e(n.ranges[l]),u=this.changes(a.changes),c=u.map(i);for(let f=0;f<l;f++)s[f]=s[f].map(c);let h=i.mapDesc(u,!0);s.push(a.range.map(h)),i=i.compose(c),o=tt.mapEffects(o,c).concat(tt.mapEffects(Rl(a.effects),h))}return{changes:i,selection:J.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof un?e:un.of(e,this.doc.length,this.facet(pt.lineSeparator))}toText(e){return St.of(e.split(this.facet(pt.lineSeparator)||Zm))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(cu(this,n),rd(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof pn&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],l=e[s];i.push(o.init(a=>o.spec.fromJSON(l,a)))}}return pt.create({doc:e.doc,selection:J.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=nd.resolve(e.extensions||[],new Map),r=e.doc instanceof St?e.doc:St.of((e.doc||"").split(n.staticFacet(pt.lineSeparator)||Zm)),i=e.selection?e.selection instanceof J?e.selection:J.single(e.selection.anchor,e.selection.head):J.single(0);return x_(i,r.length),n.staticFacet(C_)||(i=i.asSingle()),new pt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||`
|