vzcode 0.69.0 → 0.70.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.
- package/dist/assets/{index-czCP4WYS.js → index-Bfl2hCW9.js} +1 -1
- package/dist/assets/{worker-FhZpMMPl.js → worker-D0nKlL79.js} +36 -36
- package/dist/assets/{worker-_NbuAnR0.js → worker-DoodSOTA.js} +183 -183
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/client/useTypeScript/worker.ts +6 -3
|
@@ -65,7 +65,7 @@ Source:
|
|
|
65
65
|
`))):rt=Y.stylize("[Circular]","special")),T(qe)){if(je&&Ae.match(/^\d+$/))return rt;qe=JSON.stringify(""+Ae),qe.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(qe=qe.slice(1,-1),qe=Y.stylize(qe,"name")):(qe=qe.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),qe=Y.stylize(qe,"string"))}return qe+": "+rt}function S(Y,z,ee){var ve=Y.reduce(function(Ae,je){return je.indexOf(`
|
|
66
66
|
`)>=0,Ae+je.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ve>60?ee[0]+(z===""?"":z+`
|
|
67
67
|
`)+" "+Y.join(`,
|
|
68
|
-
`)+" "+ee[1]:ee[0]+z+" "+Y.join(", ")+" "+ee[1]}i.types=r("./support/types");function P(Y){return Array.isArray(Y)}i.isArray=P;function _(Y){return typeof Y=="boolean"}i.isBoolean=_;function Q(Y){return Y===null}i.isNull=Q;function b(Y){return Y==null}i.isNullOrUndefined=b;function k(Y){return typeof Y=="number"}i.isNumber=k;function x(Y){return typeof Y=="string"}i.isString=x;function $(Y){return typeof Y=="symbol"}i.isSymbol=$;function T(Y){return Y===void 0}i.isUndefined=T;function D(Y){return I(Y)&&V(Y)==="[object RegExp]"}i.isRegExp=D,i.types.isRegExp=D;function I(Y){return typeof Y=="object"&&Y!==null}i.isObject=I;function K(Y){return I(Y)&&V(Y)==="[object Date]"}i.isDate=K,i.types.isDate=K;function M(Y){return I(Y)&&(V(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function N(Y){return typeof Y=="function"}i.isFunction=N;function q(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=q,i.isBuffer=r("./support/isBuffer");function V(Y){return Object.prototype.toString.call(Y)}function F(Y){return Y<10?"0"+Y.toString(10):Y.toString(10)}var le=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function he(){var Y=new Date,z=[F(Y.getHours()),F(Y.getMinutes()),F(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],z].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,z){if(!z||!I(z))return Y;for(var ee=Object.keys(z),ve=ee.length;ve--;)Y[ee[ve]]=z[ee[ve]];return Y};function X(Y,z){return Object.prototype.hasOwnProperty.call(Y,z)}var G=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(z){if(typeof z!="function")throw new TypeError('The "original" argument must be of type Function');if(G&&z[G]){var ee=z[G];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,G,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var ve,Ae,je=new Promise(function(st,Et){ve=st,Ae=Et}),qe=[],rt=0;rt<arguments.length;rt++)qe.push(arguments[rt]);qe.push(function(st,Et){st?Ae(st):ve(Et)});try{z.apply(this,qe)}catch(st){Ae(st)}return je}return Object.setPrototypeOf(ee,Object.getPrototypeOf(z)),G&&Object.defineProperty(ee,G,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,s(z))},i.promisify.custom=G;function se(Y,z){if(!Y){var ee=new Error("Promise was rejected with a falsy value");ee.reason=Y,Y=ee}return z(Y)}function Me(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function z(){for(var ee=[],ve=0;ve<arguments.length;ve++)ee.push(arguments[ve]);var Ae=ee.pop();if(typeof Ae!="function")throw new TypeError("The last argument must be of type Function");var je=this,qe=function(){return Ae.apply(je,arguments)};Y.apply(this,ee).then(function(rt){o.nextTick(qe.bind(null,null,rt))},function(rt){o.nextTick(se.bind(null,rt,qe))})}return Object.setPrototypeOf(z,Object.getPrototypeOf(Y)),Object.defineProperties(z,s(Y)),z}i.callbackify=Me}).call(this)}).call(this,r("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(r,n,i){(function(o){(function(){var s=r("for-each"),a=r("available-typed-arrays"),l=r("call-bind/callBound"),u=r("gopd"),c=l("Object.prototype.toString"),f=r("has-tostringtag/shams")(),h=typeof globalThis>"u"?o:globalThis,d=a(),p=l("String.prototype.slice"),O={},m=Object.getPrototypeOf;f&&u&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=u(P,Symbol.toStringTag);if(!_){var Q=m(P);_=u(Q,Symbol.toStringTag)}O[v]=_.get}}});var y=function(S){var P=!1;return s(O,function(_,Q){if(!P)try{var b=_.call(S);b===Q&&(P=b)}catch{}}),P},g=r("is-typed-array");n.exports=function(S){return g(S)?!f||!(Symbol.toStringTag in S)?p(c(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof Xn<"u"?Xn: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(r,n,i){const o=r("ot-json1-presence"),s=r("ot-text-unicode");n.exports={json1Presence:o,textUnicode:s}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(NQ);var oj=NQ.exports;const sj=vi(oj),{json1Presence:v0,textUnicode:WQ}=sj;function aj(t){return new Worker("/assets/worker-_NbuAnR0.js",{name:t==null?void 0:t.name})}function lj(t){return new Worker("/assets/worker-FhZpMMPl.js",{name:t==null?void 0:t.name})}const uj=!0,Gw=800,IQ="vzCodeSidebarWidth",BQ="vzCodeCodeEditorWidth",LQ=220;let pO=LQ;const VQ=800;let OO=VQ,Jm=!1;if(typeof window<"u"&&uj){const t=window.localStorage.getItem(IQ),e=window.localStorage.getItem(BQ);t!==null&&(pO=+t,Jm=!0),e!==null&&(OO=+e,Jm=!0)}const cj={codeEditorWidth:OO,sidebarWidth:pO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},gO=W.createContext(cj),fj={sidebarWidth:LQ,codeEditorWidth:VQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},hj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:pO,codeEditorWidth:OO,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}},dj=({children:t})=>{const[e,r]=W.useReducer(hj,fj),n=W.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=W.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:u}=e;typeof window<"u"&&W.useLayoutEffect(()=>{Jm&&!u&&r({type:"initialize"})},[u]),W.useEffect(()=>{o!==pO&&setTimeout(()=>{window.localStorage.setItem(IQ,""+o)},Gw),s!==OO&&setTimeout(()=>{window.localStorage.setItem(BQ,""+s)},Gw)},[s,o]);const c={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return U.jsx(gO.Provider,{value:c,children:t})},pj=t=>{const r=/Mac|iMac|MacBook/i.test(navigator.userAgent)?t.metaKey:t.ctrlKey;return r&&t.key==="s"?!0:!!(t.key==="F5"||r&&t.key==="Enter"||t.shiftKey&&t.key==="Enter"||t.altKey&&t.key==="Enter"||r&&t.shiftKey&&(t.key==="B"||t.key==="b")||r&&t.shiftKey&&t.key==="F10"||t.key==="F8"||t.key==="F9")},XQ=1200,Oj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},gj=({shareDBDoc:t,submitOperation:e,prettierWorker:r,enableManualPretter:n})=>{const i=W.useRef(new Set),[o,s]=W.useState(null),a=W.useRef(!1),l=W.useRef(null);return W.useEffect(()=>{if(!t)return;const u=p=>{const{fileId:O,error:m,fileTextPrettified:y}=p.data;if(m){s(m);return}else s(null);a.current=!0,e(g=>({...g,files:{...g.files,[O]:{...g.files[O],text:y}}})),a.current=!1};r.addEventListener("message",u);const c=async()=>{const O=t.data.files,m=i.current,y=Array.from(m);m.clear();for(const g of y){const v=O[g],S={fileText:v.text,fileExtension:Oj(v.name),fileId:g};r.postMessage(S)}};l.current=c;let f,h,d;return n?(d=p=>{pj(p)&&(p.preventDefault(),c())},document.addEventListener("keydown",d)):(f=()=>{clearTimeout(h),h=setTimeout(c,XQ)},window.addEventListener("mousemove",f),window.addEventListener("keydown",f)),t.on("op batch",(p,O)=>{if(!a.current&&p&&p.length===4&&p[0]==="files"&&typeof p[1]=="string"&&p[2]==="text"){const m=p[1];i.current.add(m),n||f()}}),()=>{r.removeEventListener("message",u),n?document.removeEventListener("keydown",d):(window.removeEventListener("keydown",f),window.removeEventListener("mousemove",f),clearTimeout(h))}},[t]),{prettierError:o,runPrettierRef:l}},mj=500,yj=XQ+mj,vj=({content:t,typeScriptWorker:e})=>{const r=W.useRef(null),n=W.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},yj))},[e]);W.useEffect(()=>{n(t)},[t])},wj=(t,e)=>{if(e.type!=="close_tabs")return t;const r=t.tabList.filter(o=>!e.fileIdsToClose.includes(o.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:r};const n=t.tabList.findIndex(o=>o.fileId===t.activeFileId);let i=null;for(let o=n-1;o>=0;o--)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}if(!i){for(let o=n+1;o<t.tabList.length;o++)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}}return{...t,tabList:r,activeFileId:i}},Sj=(t,e)=>{if(e.type!=="open_tab")return t;const r=t.tabList.findIndex(l=>l.fileId===e.fileId),n=r!==-1,i=n&&t.tabList[r].isTransient,o=t.tabList.findIndex(l=>l.isTransient&&l.fileId!==e.fileId),s={fileId:e.fileId,isTransient:e.isTransient};let a;return n?i?a=t.tabList.map(l=>l.fileId===e.fileId?s:l):a=[...t.tabList]:o!==-1?(a=[...t.tabList],a[o]=s):a=[...t.tabList,s],{...t,activeFileId:e.fileId,tabList:a,editorWantsFocus:!e.isTransient}},bj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Pj=(t,e)=>{if(e.type!=="set_active_file_left")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r-=1,r<0&&(r=t.tabList.length-1),{...t,activeFileId:t.tabList[r].fileId}},kj=(t,e)=>{if(e.type!=="set_active_file_right")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r+=1,r>t.tabList.length-1&&(r=0),{...t,activeFileId:t.tabList[r].fileId}},xj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,_j=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,$j=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Qj=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,Ej=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),Tj=[bj,Pj,kj,Sj,wj,_j,xj,$j,Qj],Cj=(t,e)=>Tj.reduce((r,n)=>n(r,e),t);class It{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,r,n){[e,r]=Wl(this,e,r);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(r,this.length,i,1),io.from(i,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=Wl(this,e,r);let n=[];return this.decompose(e,r,n,0),io.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new uc(this),o=new uc(e);for(let s=r,a=r;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new uc(this,e)}iterRange(e,r=this.length){return new YQ(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new UQ(n)}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]?It.empty:e.length<=32?new Er(e):io.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Rj(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((r?n:a)>=e)return new Aj(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(Hw(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Qd(o.text,s.text.slice(),0,o.length);if(a.length<=32)n.push(new Er(a,s.length+o.length));else{let l=a.length>>1;n.push(new Er(a.slice(0,l)),new Er(a.slice(l)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof Er))return super.replace(e,r,n);[e,r]=Wl(this,e,r);let i=Qd(this.text,Qd(n.text,Hw(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):io.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
|
|
68
|
+
`)+" "+ee[1]:ee[0]+z+" "+Y.join(", ")+" "+ee[1]}i.types=r("./support/types");function P(Y){return Array.isArray(Y)}i.isArray=P;function _(Y){return typeof Y=="boolean"}i.isBoolean=_;function Q(Y){return Y===null}i.isNull=Q;function b(Y){return Y==null}i.isNullOrUndefined=b;function k(Y){return typeof Y=="number"}i.isNumber=k;function x(Y){return typeof Y=="string"}i.isString=x;function $(Y){return typeof Y=="symbol"}i.isSymbol=$;function T(Y){return Y===void 0}i.isUndefined=T;function D(Y){return I(Y)&&V(Y)==="[object RegExp]"}i.isRegExp=D,i.types.isRegExp=D;function I(Y){return typeof Y=="object"&&Y!==null}i.isObject=I;function K(Y){return I(Y)&&V(Y)==="[object Date]"}i.isDate=K,i.types.isDate=K;function M(Y){return I(Y)&&(V(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function N(Y){return typeof Y=="function"}i.isFunction=N;function q(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=q,i.isBuffer=r("./support/isBuffer");function V(Y){return Object.prototype.toString.call(Y)}function F(Y){return Y<10?"0"+Y.toString(10):Y.toString(10)}var le=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function he(){var Y=new Date,z=[F(Y.getHours()),F(Y.getMinutes()),F(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],z].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,z){if(!z||!I(z))return Y;for(var ee=Object.keys(z),ve=ee.length;ve--;)Y[ee[ve]]=z[ee[ve]];return Y};function X(Y,z){return Object.prototype.hasOwnProperty.call(Y,z)}var G=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(z){if(typeof z!="function")throw new TypeError('The "original" argument must be of type Function');if(G&&z[G]){var ee=z[G];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,G,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var ve,Ae,je=new Promise(function(st,Et){ve=st,Ae=Et}),qe=[],rt=0;rt<arguments.length;rt++)qe.push(arguments[rt]);qe.push(function(st,Et){st?Ae(st):ve(Et)});try{z.apply(this,qe)}catch(st){Ae(st)}return je}return Object.setPrototypeOf(ee,Object.getPrototypeOf(z)),G&&Object.defineProperty(ee,G,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,s(z))},i.promisify.custom=G;function se(Y,z){if(!Y){var ee=new Error("Promise was rejected with a falsy value");ee.reason=Y,Y=ee}return z(Y)}function Me(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function z(){for(var ee=[],ve=0;ve<arguments.length;ve++)ee.push(arguments[ve]);var Ae=ee.pop();if(typeof Ae!="function")throw new TypeError("The last argument must be of type Function");var je=this,qe=function(){return Ae.apply(je,arguments)};Y.apply(this,ee).then(function(rt){o.nextTick(qe.bind(null,null,rt))},function(rt){o.nextTick(se.bind(null,rt,qe))})}return Object.setPrototypeOf(z,Object.getPrototypeOf(Y)),Object.defineProperties(z,s(Y)),z}i.callbackify=Me}).call(this)}).call(this,r("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(r,n,i){(function(o){(function(){var s=r("for-each"),a=r("available-typed-arrays"),l=r("call-bind/callBound"),u=r("gopd"),c=l("Object.prototype.toString"),f=r("has-tostringtag/shams")(),h=typeof globalThis>"u"?o:globalThis,d=a(),p=l("String.prototype.slice"),O={},m=Object.getPrototypeOf;f&&u&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=u(P,Symbol.toStringTag);if(!_){var Q=m(P);_=u(Q,Symbol.toStringTag)}O[v]=_.get}}});var y=function(S){var P=!1;return s(O,function(_,Q){if(!P)try{var b=_.call(S);b===Q&&(P=b)}catch{}}),P},g=r("is-typed-array");n.exports=function(S){return g(S)?!f||!(Symbol.toStringTag in S)?p(c(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof Xn<"u"?Xn: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(r,n,i){const o=r("ot-json1-presence"),s=r("ot-text-unicode");n.exports={json1Presence:o,textUnicode:s}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(NQ);var oj=NQ.exports;const sj=vi(oj),{json1Presence:v0,textUnicode:WQ}=sj;function aj(t){return new Worker("/assets/worker-DoodSOTA.js",{name:t==null?void 0:t.name})}function lj(t){return new Worker("/assets/worker-D0nKlL79.js",{name:t==null?void 0:t.name})}const uj=!0,Gw=800,IQ="vzCodeSidebarWidth",BQ="vzCodeCodeEditorWidth",LQ=220;let pO=LQ;const VQ=800;let OO=VQ,Jm=!1;if(typeof window<"u"&&uj){const t=window.localStorage.getItem(IQ),e=window.localStorage.getItem(BQ);t!==null&&(pO=+t,Jm=!0),e!==null&&(OO=+e,Jm=!0)}const cj={codeEditorWidth:OO,sidebarWidth:pO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},gO=W.createContext(cj),fj={sidebarWidth:LQ,codeEditorWidth:VQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},hj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:pO,codeEditorWidth:OO,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}},dj=({children:t})=>{const[e,r]=W.useReducer(hj,fj),n=W.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=W.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:u}=e;typeof window<"u"&&W.useLayoutEffect(()=>{Jm&&!u&&r({type:"initialize"})},[u]),W.useEffect(()=>{o!==pO&&setTimeout(()=>{window.localStorage.setItem(IQ,""+o)},Gw),s!==OO&&setTimeout(()=>{window.localStorage.setItem(BQ,""+s)},Gw)},[s,o]);const c={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return U.jsx(gO.Provider,{value:c,children:t})},pj=t=>{const r=/Mac|iMac|MacBook/i.test(navigator.userAgent)?t.metaKey:t.ctrlKey;return r&&t.key==="s"?!0:!!(t.key==="F5"||r&&t.key==="Enter"||t.shiftKey&&t.key==="Enter"||t.altKey&&t.key==="Enter"||r&&t.shiftKey&&(t.key==="B"||t.key==="b")||r&&t.shiftKey&&t.key==="F10"||t.key==="F8"||t.key==="F9")},XQ=1200,Oj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},gj=({shareDBDoc:t,submitOperation:e,prettierWorker:r,enableManualPretter:n})=>{const i=W.useRef(new Set),[o,s]=W.useState(null),a=W.useRef(!1),l=W.useRef(null);return W.useEffect(()=>{if(!t)return;const u=p=>{const{fileId:O,error:m,fileTextPrettified:y}=p.data;if(m){s(m);return}else s(null);a.current=!0,e(g=>({...g,files:{...g.files,[O]:{...g.files[O],text:y}}})),a.current=!1};r.addEventListener("message",u);const c=async()=>{const O=t.data.files,m=i.current,y=Array.from(m);m.clear();for(const g of y){const v=O[g],S={fileText:v.text,fileExtension:Oj(v.name),fileId:g};r.postMessage(S)}};l.current=c;let f,h,d;return n?(d=p=>{pj(p)&&(p.preventDefault(),c())},document.addEventListener("keydown",d)):(f=()=>{clearTimeout(h),h=setTimeout(c,XQ)},window.addEventListener("mousemove",f),window.addEventListener("keydown",f)),t.on("op batch",(p,O)=>{if(!a.current&&p&&p.length===4&&p[0]==="files"&&typeof p[1]=="string"&&p[2]==="text"){const m=p[1];i.current.add(m),n||f()}}),()=>{r.removeEventListener("message",u),n?document.removeEventListener("keydown",d):(window.removeEventListener("keydown",f),window.removeEventListener("mousemove",f),clearTimeout(h))}},[t]),{prettierError:o,runPrettierRef:l}},mj=500,yj=XQ+mj,vj=({content:t,typeScriptWorker:e})=>{const r=W.useRef(null),n=W.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},yj))},[e]);W.useEffect(()=>{n(t)},[t])},wj=(t,e)=>{if(e.type!=="close_tabs")return t;const r=t.tabList.filter(o=>!e.fileIdsToClose.includes(o.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:r};const n=t.tabList.findIndex(o=>o.fileId===t.activeFileId);let i=null;for(let o=n-1;o>=0;o--)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}if(!i){for(let o=n+1;o<t.tabList.length;o++)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}}return{...t,tabList:r,activeFileId:i}},Sj=(t,e)=>{if(e.type!=="open_tab")return t;const r=t.tabList.findIndex(l=>l.fileId===e.fileId),n=r!==-1,i=n&&t.tabList[r].isTransient,o=t.tabList.findIndex(l=>l.isTransient&&l.fileId!==e.fileId),s={fileId:e.fileId,isTransient:e.isTransient};let a;return n?i?a=t.tabList.map(l=>l.fileId===e.fileId?s:l):a=[...t.tabList]:o!==-1?(a=[...t.tabList],a[o]=s):a=[...t.tabList,s],{...t,activeFileId:e.fileId,tabList:a,editorWantsFocus:!e.isTransient}},bj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Pj=(t,e)=>{if(e.type!=="set_active_file_left")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r-=1,r<0&&(r=t.tabList.length-1),{...t,activeFileId:t.tabList[r].fileId}},kj=(t,e)=>{if(e.type!=="set_active_file_right")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r+=1,r>t.tabList.length-1&&(r=0),{...t,activeFileId:t.tabList[r].fileId}},xj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,_j=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,$j=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Qj=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,Ej=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),Tj=[bj,Pj,kj,Sj,wj,_j,xj,$j,Qj],Cj=(t,e)=>Tj.reduce((r,n)=>n(r,e),t);class It{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,r,n){[e,r]=Wl(this,e,r);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(r,this.length,i,1),io.from(i,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=Wl(this,e,r);let n=[];return this.decompose(e,r,n,0),io.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new uc(this),o=new uc(e);for(let s=r,a=r;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new uc(this,e)}iterRange(e,r=this.length){return new YQ(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new UQ(n)}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]?It.empty:e.length<=32?new Er(e):io.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Rj(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((r?n:a)>=e)return new Aj(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(Hw(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Qd(o.text,s.text.slice(),0,o.length);if(a.length<=32)n.push(new Er(a,s.length+o.length));else{let l=a.length>>1;n.push(new Er(a.slice(0,l)),new Er(a.slice(l)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof Er))return super.replace(e,r,n);[e,r]=Wl(this,e,r);let i=Qd(this.text,Qd(n.text,Hw(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):io.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
|
|
69
69
|
`){[e,r]=Wl(this,e,r);let i="";for(let o=0,s=0;o<=r&&s<this.text.length;s++){let a=this.text[s],l=o+a.length;o>e&&s&&(i+=n),e<l&&r>o&&(i+=a.slice(Math.max(0,e-o),r-o)),o=l+1}return i}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],i=-1;for(let o of e)n.push(o),i+=o.length+1,n.length==32&&(r.push(new Er(n,i)),n=[],i=-1);return i>-1&&r.push(new Er(n,i)),r}}class io extends It{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.children[o],a=i+s.length,l=n+s.lines-1;if((r?l:a)>=e)return s.lineInner(e,r,n,i);i=a+1,n=l+1}}decompose(e,r,n,i){for(let o=0,s=0;s<=r&&o<this.children.length;o++){let a=this.children[o],l=s+a.length;if(e<=l&&r>=s){let u=i&((s<=e?1:0)|(l>=r?2:0));s>=e&&l<=r&&!u?n.push(a):a.decompose(e-s,r-s,n,u)}s=l+1}}replace(e,r,n){if([e,r]=Wl(this,e,r),n.lines<this.lines)for(let i=0,o=0;i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e>=o&&r<=a){let l=s.replace(e-o,r-o,n),u=this.lines-s.lines+l.lines;if(l.lines<u>>4&&l.lines>u>>6){let c=this.children.slice();return c[i]=l,new io(c,this.length-(r-e)+n.length)}return super.replace(o,a,l)}o=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=`
|
|
70
70
|
`){[e,r]=Wl(this,e,r);let i="";for(let o=0,s=0;o<this.children.length&&s<=r;o++){let a=this.children[o],l=s+a.length;s>e&&o&&(i+=n),e<l&&r>s&&(i+=a.sliceString(e-s,r-s,n)),s=l+1}return i}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof io))return 0;let n=0,[i,o,s,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=r,o+=r){if(i==s||o==a)return n;let l=this.children[i],u=e.children[o];if(l!=u)return n+l.scanIdentical(u,r);n+=l.length+1}}static from(e,r=e.reduce((n,i)=>n+i.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new Er(d,r)}let i=Math.max(32,n>>5),o=i<<1,s=i>>1,a=[],l=0,u=-1,c=[];function f(d){let p;if(d.lines>o&&d instanceof io)for(let O of d.children)f(O);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof Er&&l&&(p=c[c.length-1])instanceof Er&&d.lines+p.lines<=32?(l+=d.lines,u+=d.length+1,c[c.length-1]=new Er(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&h(),l+=d.lines,u+=d.length+1,c.push(d))}function h(){l!=0&&(a.push(c.length==1?c[0]:io.from(c,u)),u=-1,l=c.length=0)}for(let d of e)f(d);return h(),a.length==1?a[0]:new io(a,r)}}It.empty=new Er([""],0);function Rj(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Qd(t,e,r=0,n=1e9){for(let i=0,o=0,s=!0;o<t.length&&i<=n;o++){let a=t[o],l=i+a.length;l>=r&&(l>n&&(a=a.slice(0,n-i)),i<r&&(a=a.slice(r-i)),s?(e[e.length-1]+=a,s=!1):e.push(a)),i=l+1}return e}function Hw(t,e,r){return Qd(t,[""],e,r)}class uc{constructor(e,r=1){this.dir=r,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[r>0?1:(e instanceof Er?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],o=this.offsets[n],s=o>>1,a=i instanceof Er?i.text.length:i.children.length;if(s==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=`
|
|
71
71
|
`,this;e--}else if(i instanceof Er){let l=i.text[s+(r<0?-1:0)];if(this.offsets[n]+=r,l.length>Math.max(0,e))return this.value=e==0?l:r>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[s+(r<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(r>0?1:(l instanceof Er?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class YQ{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new uc(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*r,this.value=i.length<=n?i:r<0?i.slice(i.length-n):i.slice(0,n),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 UQ{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:i}=this.inner.next(e);return r&&this.afterBreak?(this.value="",this.afterBreak=!1):r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(It.prototype[Symbol.iterator]=function(){return this.iter()},uc.prototype[Symbol.iterator]=YQ.prototype[Symbol.iterator]=UQ.prototype[Symbol.iterator]=function(){return this});let Aj=class{constructor(e,r,n,i){this.from=e,this.to=r,this.number=n,this.text=i}get length(){return this.to-this.from}};function Wl(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}let Pl="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<Pl.length;t++)Pl[t]+=Pl[t-1];function Mj(t){for(let e=1;e<Pl.length;e+=2)if(Pl[e]>t)return Pl[e-1]<=t;return!1}function Kw(t){return t>=127462&&t<=127487}const Jw=8205;function an(t,e,r=!0,n=!0){return(r?FQ:jj)(t,e,n)}function FQ(t,e,r){if(e==t.length)return e;e&&zQ(t.charCodeAt(e))&&GQ(t.charCodeAt(e-1))&&e--;let n=nn(t,e);for(e+=ci(n);e<t.length;){let i=nn(t,e);if(n==Jw||i==Jw||r&&Mj(i))e+=ci(i),n=i;else if(Kw(i)){let o=0,s=e-2;for(;s>=0&&Kw(nn(t,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function jj(t,e,r){for(;e>0;){let n=FQ(t,e-2,r);if(n<e)return n;e--}return 0}function zQ(t){return t>=56320&&t<57344}function GQ(t){return t>=55296&&t<56320}function nn(t,e){let r=t.charCodeAt(e);if(!GQ(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return zQ(n)?(r-55296<<10)+(n-56320)+65536:r}function w0(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function ci(t){return t<65536?1:2}const ey=/\r\n?|\n/;var Vr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Vr||(Vr={}));class co{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;r<this.sections.length;r+=2)e+=this.sections[r];return e}get newLength(){let e=0;for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r+1];e+=n<0?this.sections[r]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let r=0,n=0,i=0;r<this.sections.length;){let o=this.sections[r++],s=this.sections[r++];s<0?(e(n,i,o),i+=o):i+=s,n+=o}}iterChangedRanges(e,r=!1){ty(this,e,r)}get invertedDesc(){let e=[];for(let r=0;r<this.sections.length;){let n=this.sections[r++],i=this.sections[r++];i<0?e.push(n,i):e.push(i,n)}return new co(e)}composeDesc(e){return this.empty?e:e.empty?this:HQ(this,e)}mapDesc(e,r=!1){return e.empty?this:ry(this,e,r)}mapPos(e,r=-1,n=Vr.Simple){let i=0,o=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],u=i+a;if(l<0){if(u>e)return o+(e-i);o+=a}else{if(n!=Vr.Simple&&u>=e&&(n==Vr.TrackDel&&i<e&&u>e||n==Vr.TrackBefore&&i<e||n==Vr.TrackAfter&&u>e))return null;if(u>e||u==e&&r<0&&!a)return e==i||r<0?o:o+l;o+=l}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return o}touchesRange(e,r=e){for(let n=0,i=0;n<this.sections.length&&i<=r;){let o=this.sections[n++],s=this.sections[n++],a=i+o;if(s>=0&&i<=r&&a>=e)return i<e&&a>r?"cover":!0;i=a}return!1}toString(){let e="";for(let r=0;r<this.sections.length;){let n=this.sections[r++],i=this.sections[r++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new co(e)}static create(e){return new co(e)}}class Lr extends co{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ty(this,(r,n,i,o,s)=>e=e.replace(i,i+(n-r),s),!1),e}mapDesc(e,r=!1){return ry(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let i=0,o=0;i<r.length;i+=2){let s=r[i],a=r[i+1];if(a>=0){r[i]=a,r[i+1]=s;let l=i>>1;for(;n.length<l;)n.push(It.empty);n.push(s?e.slice(o,o+s):It.empty)}o+=s}return new Lr(r,n)}compose(e){return this.empty?e:e.empty?this:HQ(this,e,!0)}map(e,r=!1){return e.empty?this:ry(this,e,r,!0)}iterChanges(e,r=!1){ty(this,e,r)}get desc(){return co.create(this.sections)}filter(e){let r=[],n=[],i=[],o=new Mc(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&o.len==0;){if(o.done)break e;let c=Math.min(o.len,l-a);pn(i,c,-1);let f=o.ins==-1?-1:o.off==0?o.ins:0;pn(r,c,f),f>0&&es(n,r,o.text),o.forward(c),a+=c}let u=e[s++];for(;a<u;){if(o.done)break e;let c=Math.min(o.len,u-a);pn(r,c,-1),pn(i,c,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(c),a+=c}}return{changes:new Lr(r,n),filtered:co.create(i)}}toJSON(){let e=[];for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r],i=this.sections[r+1];i<0?e.push(n):i==0?e.push([n]):e.push([n].concat(this.inserted[r>>1].toJSON()))}return e}static of(e,r,n){let i=[],o=[],s=0,a=null;function l(c=!1){if(!c&&!i.length)return;s<r&&pn(i,r-s,-1);let f=new Lr(i,o);a=a?a.compose(f.map(a)):f,i=[],o=[],s=0}function u(c){if(Array.isArray(c))for(let f of c)u(f);else if(c instanceof Lr){if(c.length!=r)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${r})`);l(),a=a?a.compose(c.map(a)):c}else{let{from:f,to:h=f,insert:d}=c;if(f>h||f<0||h>r)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${r})`);let p=d?typeof d=="string"?It.of(d.split(n||ey)):d:It.empty,O=p.length;if(f==h&&O==0)return;f<s&&l(),f>s&&pn(i,f-s,-1),pn(i,h-f,O),es(o,i,p),s=h}}return u(e),l(!a),a}static empty(e){return new Lr(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let i=0;i<e.length;i++){let o=e[i];if(typeof o=="number")r.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)r.push(o[0],0);else{for(;n.length<i;)n.push(It.empty);n[i]=It.of(o.slice(1)),r.push(o[0],n[i].length)}}}return new Lr(r,n)}static createSet(e,r){return new Lr(e,r)}}function pn(t,e,r,n=!1){if(e==0&&r<=0)return;let i=t.length-2;i>=0&&r<=0&&r==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=r:n?(t[i]+=e,t[i+1]+=r):t.push(e,r)}function es(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(r);else{for(;t.length<n;)t.push(It.empty);t.push(r)}}function ty(t,e,r){let n=t.inserted;for(let i=0,o=0,s=0;s<t.sections.length;){let a=t.sections[s++],l=t.sections[s++];if(l<0)i+=a,o+=a;else{let u=i,c=o,f=It.empty;for(;u+=a,c+=l,l&&n&&(f=f.append(n[s-2>>1])),!(r||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(i,u,o,c,f),i=u,o=c}}}function ry(t,e,r,n=!1){let i=[],o=n?[]:null,s=new Mc(t),a=new Mc(e);for(let l=-1;;)if(s.ins==-1&&a.ins==-1){let u=Math.min(s.len,a.len);pn(i,u,-1),s.forward(u),a.forward(u)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!r))){let u=a.len;for(pn(i,a.ins,-1);u;){let c=Math.min(s.len,u);s.ins>=0&&l<s.i&&s.len<=c&&(pn(i,0,s.ins),o&&es(o,i,s.text),l=s.i),s.forward(c),u-=c}a.next()}else if(s.ins>=0){let u=0,c=s.len;for(;c;)if(a.ins==-1){let f=Math.min(c,a.len);u+=f,c-=f,a.forward(f)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;pn(i,u,l<s.i?s.ins:0),o&&l<s.i&&es(o,i,s.text),l=s.i,s.forward(s.len-c)}else{if(s.done&&a.done)return o?Lr.createSet(i,o):co.create(i);throw new Error("Mismatched change set lengths")}}function HQ(t,e,r=!1){let n=[],i=r?[]:null,o=new Mc(t),s=new Mc(e);for(let a=!1;;){if(o.done&&s.done)return i?Lr.createSet(n,i):co.create(n);if(o.ins==0)pn(n,o.len,0,a),o.next();else if(s.len==0&&!s.done)pn(n,0,s.ins,a),i&&es(i,n,s.text),s.next();else{if(o.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(o.len2,s.len),u=n.length;if(o.ins==-1){let c=s.ins==-1?-1:s.off?0:s.ins;pn(n,l,c,a),i&&c&&es(i,n,s.text)}else s.ins==-1?(pn(n,o.off?0:o.len,l,a),i&&es(i,n,o.textBit(l))):(pn(n,o.off?0:o.len,s.off?0:s.ins,a),i&&!s.off&&es(i,n,s.text));a=(o.ins>l||s.ins>=0&&s.len>l)&&(a||n.length>u),o.forward2(l),s.forward(l)}}}}class Mc{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,r=this.i-2>>1;return r>=e.length?It.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?It.empty:r[n].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 oa{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}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,r=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new oa(n,i,this.flags)}extend(e,r=e){if(e<=this.anchor&&r>=this.anchor)return oe.range(e,r);let n=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return oe.range(this.anchor,n)}eq(e,r=!1){return this.anchor==e.anchor&&this.head==e.head&&(!r||!this.empty||this.assoc==e.assoc)}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 oe.range(e.anchor,e.head)}static create(e,r,n){return new oa(e,r,n)}}class oe{constructor(e,r){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:oe.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e,r=!1){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],r))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new oe([this.main],0)}addRange(e,r=!0){return oe.create([e].concat(this.ranges),r?0:this.mainIndex+1)}replaceRange(e,r=this.mainIndex){let n=this.ranges.slice();return n[r]=e,oe.create(n,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 oe(e.ranges.map(r=>oa.fromJSON(r)),e.main)}static single(e,r=e){return new oe([oe.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let o=e[i];if(o.empty?o.from<=n:o.from<n)return oe.normalized(e.slice(),r);n=o.to}return new oe(e,r)}static cursor(e,r=0,n,i){return oa.create(e,e,(r==0?0:r<0?8:16)|(n==null?7:Math.min(6,n))|(i??16777215)<<6)}static range(e,r,n,i){let o=(n??16777215)<<6|(i==null?7:Math.min(6,i));return r<e?oa.create(r,e,48|o):oa.create(e,r,(r>e?8:0)|o)}static normalized(e,r=0){let n=e[r];e.sort((i,o)=>i.from-o.from),r=e.indexOf(n);for(let i=1;i<e.length;i++){let o=e[i],s=e[i-1];if(o.empty?o.from<=s.to:o.from<s.to){let a=s.from,l=Math.max(o.to,s.to);i<=r&&r--,e.splice(--i,2,o.anchor>o.head?oe.range(l,a):oe.range(a,l))}}return new oe(e,r)}}function KQ(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}let S0=0;class Ze{constructor(e,r,n,i,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=i,this.id=S0++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ze(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:b0),!!e.static,e.enables)}of(e){return new Ed([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ed(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ed(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}}function b0(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}class Ed{constructor(e,r,n,i){this.dependencies=e,this.facet=r,this.type=n,this.value=i,this.id=S0++}dynamicSlot(e){var r;let n=this.value,i=this.facet.compareInput,o=this.id,s=e[o]>>1,a=this.type==2,l=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?u=!0:((r=e[f.id])!==null&&r!==void 0?r:1)&1||c.push(e[f.id]);return{create(f){return f.values[s]=n(f),1},update(f,h){if(l&&h.docChanged||u&&(h.docChanged||h.selection)||ny(f,c)){let d=n(f);if(a?!eS(d,f.values[s],i):!i(d,f.values[s]))return f.values[s]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[o];if(p!=null){let O=mp(h,p);if(this.dependencies.every(m=>m instanceof Ze?h.facet(m)===f.facet(m):m instanceof Ur?h.field(m,!1)==f.field(m,!1):!0)||(a?eS(d=n(f),O,i):i(d=n(f),O)))return f.values[s]=O,0}else d=n(f);return f.values[s]=d,1}}}}function eS(t,e,r){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!r(t[n],e[n]))return!1;return!0}function ny(t,e){let r=!1;for(let n of e)cc(t,n)&1&&(r=!0);return r}function qj(t,e,r){let n=r.map(l=>t[l.id]),i=r.map(l=>l.type),o=n.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let u=[];for(let c=0;c<n.length;c++){let f=mp(l,n[c]);if(i[c]==2)for(let h of f)u.push(h);else u.push(f)}return e.combine(u)}return{create(l){for(let u of n)cc(l,u);return l.values[s]=a(l),1},update(l,u){if(!ny(l,o))return 0;let c=a(l);return e.compare(c,l.values[s])?0:(l.values[s]=c,1)},reconfigure(l,u){let c=ny(l,n),f=u.config.facets[e.id],h=u.facet(e);if(f&&!c&&b0(r,f))return l.values[s]=h,0;let d=a(l);return e.compare(d,h)?(l.values[s]=h,0):(l.values[s]=d,1)}}}const tS=Ze.define({static:!0});class Ur{constructor(e,r,n,i,o){this.id=e,this.createF=r,this.updateF=n,this.compareF=i,this.spec=o,this.provides=void 0}static define(e){let r=new Ur(S0++,e.create,e.update,e.compare||((n,i)=>n===i),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(tS).find(n=>n.field==this);return((r==null?void 0:r.create)||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,i)=>{let o=n.values[r],s=this.updateF(o,i);return this.compareF(o,s)?0:(n.values[r]=s,1)},reconfigure:(n,i)=>i.config.address[this.id]!=null?(n.values[r]=i.field(this),0):(n.values[r]=this.create(n),1)}}init(e){return[this,tS.of({field:this,create:e})]}get extension(){return this}}const Ks={lowest:4,low:3,default:2,high:1,highest:0};function bu(t){return e=>new JQ(e,t)}const Es={highest:bu(Ks.highest),high:bu(Ks.high),default:bu(Ks.default),low:bu(Ks.low),lowest:bu(Ks.lowest)};class JQ{constructor(e,r){this.inner=e,this.prec=r}}class Il{of(e){return new iy(this,e)}reconfigure(e){return Il.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class iy{constructor(e,r){this.compartment=e,this.inner=r}}class gp{constructor(e,r,n,i,o,s){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=i,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let r=this.address[e.id];return r==null?e.default:this.staticValues[r>>1]}static resolve(e,r,n){let i=[],o=Object.create(null),s=new Map;for(let h of Dj(e,r,s))h instanceof Ur?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],u=[];for(let h of i)a[h.id]=u.length<<1,u.push(d=>h.slot(d));let c=n==null?void 0:n.config.facets;for(let h in o){let d=o[h],p=d[0].facet,O=c&&c[h]||[];if(d.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,b0(O,d))l.push(n.facet(p));else{let m=p.combine(d.map(y=>y.value));l.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of d)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=u.length<<1,u.push(y=>m.dynamicSlot(y)));a[p.id]=u.length<<1,u.push(m=>qj(m,p,d))}}let f=u.map(h=>h(a));return new gp(e,s,f,a,l,o)}}function Dj(t,e,r){let n=[[],[],[],[],[]],i=new Map;function o(s,a){let l=i.get(s);if(l!=null){if(l<=a)return;let u=n[l].indexOf(s);u>-1&&n[l].splice(u,1),s instanceof iy&&r.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let u of s)o(u,a);else if(s instanceof iy){if(r.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(s.compartment)||s.inner;r.set(s.compartment,u),o(u,a)}else if(s instanceof JQ)o(s.inner,s.prec);else if(s instanceof Ur)n[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Ed)n[a].push(s),s.facet.extensions&&o(s.facet.extensions,Ks.default);else{let u=s.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(u,a)}}return o(t,Ks.default),n.reduce((s,a)=>s.concat(a))}function cc(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let i=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|i}function mp(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const eE=Ze.define(),oy=Ze.define({combine:t=>t.some(e=>e),static:!0}),tE=Ze.define({combine:t=>t.length?t[0]:void 0,static:!0}),rE=Ze.define(),nE=Ze.define(),iE=Ze.define(),oE=Ze.define({combine:t=>t.length?t[0]:!1});class ho{constructor(e,r){this.type=e,this.value=r}static define(){return new Zj}}class Zj{of(e){return new ho(this,e)}}class Nj{constructor(e){this.map=e}of(e){return new mt(this,e)}}class mt{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new mt(this.type,r)}is(e){return this.type==e}static define(e={}){return new Nj(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let i of e){let o=i.map(r);o&&n.push(o)}return n}}mt.reconfigure=mt.define();mt.appendConfig=mt.define();class jr{constructor(e,r,n,i,o,s){this.startState=e,this.changes=r,this.selection=n,this.effects=i,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,n&&KQ(n,r.newLength),o.some(a=>a.type==jr.time)||(this.annotations=o.concat(jr.time.of(Date.now())))}static create(e,r,n,i,o,s){return new jr(e,r,n,i,o,s)}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 r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(jr.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}}jr.time=ho.define();jr.userEvent=ho.define();jr.addToHistory=ho.define();jr.remote=ho.define();function Wj(t,e){let r=[];for(let n=0,i=0;;){let o,s;if(n<t.length&&(i==e.length||e[i]>=t[n]))o=t[n++],s=t[n++];else if(i<e.length)o=e[i++],s=e[i++];else return r;!r.length||r[r.length-1]<o?r.push(o,s):r[r.length-1]<s&&(r[r.length-1]=s)}}function sE(t,e,r){var n;let i,o,s;return r?(i=e.changes,o=Lr.empty(e.changes.length),s=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(i)),{changes:s,selection:e.selection?e.selection.map(o):(n=t.selection)===null||n===void 0?void 0:n.map(i),effects:mt.mapEffects(t.effects,i).concat(mt.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function sy(t,e,r){let n=e.selection,i=kl(e.annotations);return e.userEvent&&(i=i.concat(jr.userEvent.of(e.userEvent))),{changes:e.changes instanceof Lr?e.changes:Lr.of(e.changes||[],r,t.facet(tE)),selection:n&&(n instanceof oe?n:oe.single(n.anchor,n.head)),effects:kl(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function aE(t,e,r){let n=sy(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(r=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(r=!1);let s=!!e[o].sequential;n=sE(n,sy(t,e[o],s?n.changes.newLength:t.doc.length),s)}let i=jr.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Bj(r?Ij(i):i)}function Ij(t){let e=t.startState,r=!0;for(let i of e.facet(rE)){let o=i(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:Wj(r,o))}if(r!==!0){let i,o;if(r===!1)o=t.changes.invertedDesc,i=Lr.empty(e.doc.length);else{let s=t.changes.filter(r);i=s.changes,o=s.filtered.mapDesc(s.changes).invertedDesc}t=jr.create(e,i,t.selection&&t.selection.map(o),mt.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(nE);for(let i=n.length-1;i>=0;i--){let o=n[i](t);o instanceof jr?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof jr?t=o[0]:t=aE(e,kl(o),!1)}return t}function Bj(t){let e=t.startState,r=e.facet(iE),n=t;for(let i=r.length-1;i>=0;i--){let o=r[i](t);o&&Object.keys(o).length&&(n=sE(n,sy(e,o,t.changes.newLength),!0))}return n==t?t:jr.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}const Lj=[];function kl(t){return t==null?Lj:Array.isArray(t)?t:[t]}var gr=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(gr||(gr={}));const Vj=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ay;try{ay=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Xj(t){if(ay)return ay.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>""&&(r.toUpperCase()!=r.toLowerCase()||Vj.test(r)))return!0}return!1}function Yj(t){return e=>{if(!/\S/.test(e))return gr.Space;if(Xj(e))return gr.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return gr.Word;return gr.Other}}class jt{constructor(e,r,n,i,o,s){this.config=e,this.doc=r,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)cc(this,a<<1);this.computeSlot=null}field(e,r=!0){let n=this.config.address[e.id];if(n==null){if(r)throw new RangeError("Field is not present in this state");return}return cc(this,n),mp(this,n)}update(...e){return aE(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:i}=r;for(let a of e.effects)a.is(Il.reconfigure)?(r&&(i=new Map,r.compartments.forEach((l,u)=>i.set(u,l)),r=null),i.set(a.value.compartment,a.value.extension)):a.is(mt.reconfigure)?(r=null,n=a.value):a.is(mt.appendConfig)&&(r=null,n=kl(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=gp.resolve(n,i,this),o=new jt(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(l,u)=>u.reconfigure(l,this),null).values);let s=e.startState.facet(oy)?e.newSelection:e.newSelection.asSingle();new jt(r,e.newDoc,s,o,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:oe.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),i=this.changes(n.changes),o=[n.range],s=kl(n.effects);for(let a=1;a<r.ranges.length;a++){let l=e(r.ranges[a]),u=this.changes(l.changes),c=u.map(i);for(let h=0;h<a;h++)o[h]=o[h].map(c);let f=i.mapDesc(u,!0);o.push(l.range.map(f)),i=i.compose(c),s=mt.mapEffects(s,c).concat(mt.mapEffects(kl(l.effects),f))}return{changes:i,selection:oe.create(o,r.mainIndex),effects:s}}changes(e=[]){return e instanceof Lr?e:Lr.of(e,this.doc.length,this.facet(jt.lineSeparator))}toText(e){return It.of(e.split(this.facet(jt.lineSeparator)||ey))}sliceDoc(e=0,r=this.doc.length){return this.doc.sliceString(e,r,this.lineBreak)}facet(e){let r=this.config.address[e.id];return r==null?e.default:(cc(this,r),mp(this,r))}toJSON(e){let r={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof Ur&&this.config.address[i.id]!=null&&(r[n]=i.spec.toJSON(this.field(e[n]),this))}return r}static fromJSON(e,r={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let o in n)if(Object.prototype.hasOwnProperty.call(e,o)){let s=n[o],a=e[o];i.push(s.init(l=>s.spec.fromJSON(a,l)))}}return jt.create({doc:e.doc,selection:oe.fromJSON(e.selection),extensions:r.extensions?i.concat([r.extensions]):i})}static create(e={}){let r=gp.resolve(e.extensions||[],new Map),n=e.doc instanceof It?e.doc:It.of((e.doc||"").split(r.staticFacet(jt.lineSeparator)||ey)),i=e.selection?e.selection instanceof oe?e.selection:oe.single(e.selection.anchor,e.selection.head):oe.single(0);return KQ(i,n.length),r.staticFacet(oy)||(i=i.asSingle()),new jt(r,n,i,r.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(jt.tabSize)}get lineBreak(){return this.facet(jt.lineSeparator)||`
|