vzcode 0.82.0 → 0.83.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/{worker-1ri6mpan.js → index-CI1sbUJw.js} +63 -63
- package/dist/assets/{index-BKQfM_WG.js → index-CnHJy69d.js} +3 -3
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/client/App/index.tsx +1 -1
- package/src/client/CodeEditor/widgets.ts +1 -5
- package/src/client/useTypeScript/worker/constants.ts +73 -0
- package/src/client/useTypeScript/worker/getTSFileName.ts +4 -0
- package/src/client/useTypeScript/worker/handleMessageAutocompleteRequest.ts +63 -0
- package/src/client/useTypeScript/worker/handleMessageLintRequest.ts +84 -0
- package/src/client/useTypeScript/worker/handleMessageTranspileRequest.ts +20 -0
- package/src/client/useTypeScript/worker/handleMessageUpdateContent.ts +38 -0
- package/src/client/useTypeScript/worker/index.ts +121 -0
- package/src/client/useTypeScript/worker/isTS.ts +3 -0
- package/src/client/useTypeScript/{requestTypes.ts → worker/requestTypes.ts} +0 -1
- package/src/client/CodeEditor/codemirror-interact.ts +0 -409
- package/src/client/useTypeScript/worker.ts +0 -335
|
@@ -65,7 +65,7 @@ Source:
|
|
|
65
65
|
`))):tt=Y.stylize("[Circular]","special")),C(qe)){if(De&&Re.match(/^\d+$/))return tt;qe=JSON.stringify(""+Re),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+": "+tt}function S(Y,G,ee){var ve=Y.reduce(function(Re,De){return De.indexOf(`
|
|
66
66
|
`)>=0,Re+De.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ve>60?ee[0]+(G===""?"":G+`
|
|
67
67
|
`)+" "+Y.join(`,
|
|
68
|
-
`)+" "+ee[1]:ee[0]+G+" "+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 C(Y){return Y===void 0}i.isUndefined=C;function Z(Y){return B(Y)&&X(Y)==="[object RegExp]"}i.isRegExp=Z,i.types.isRegExp=Z;function B(Y){return typeof Y=="object"&&Y!==null}i.isObject=B;function F(Y){return B(Y)&&X(Y)==="[object Date]"}i.isDate=F,i.types.isDate=F;function M(Y){return B(Y)&&(X(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(Y){return typeof Y=="function"}i.isFunction=I;function D(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=D,i.isBuffer=r("./support/isBuffer");function X(Y){return Object.prototype.toString.call(Y)}function z(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,G=[z(Y.getHours()),z(Y.getMinutes()),z(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],G].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,G){if(!G||!B(G))return Y;for(var ee=Object.keys(G),ve=ee.length;ve--;)Y[ee[ve]]=G[ee[ve]];return Y};function U(Y,G){return Object.prototype.hasOwnProperty.call(Y,G)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&G[K]){var ee=G[K];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var ve,Re,De=new Promise(function(st,Et){ve=st,Re=Et}),qe=[],tt=0;tt<arguments.length;tt++)qe.push(arguments[tt]);qe.push(function(st,Et){st?Re(st):ve(Et)});try{G.apply(this,qe)}catch(st){Re(st)}return De}return Object.setPrototypeOf(ee,Object.getPrototypeOf(G)),K&&Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,s(G))},i.promisify.custom=K;function se(Y,G){if(!Y){var ee=new Error("Promise was rejected with a falsy value");ee.reason=Y,Y=ee}return G(Y)}function Me(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function G(){for(var ee=[],ve=0;ve<arguments.length;ve++)ee.push(arguments[ve]);var Re=ee.pop();if(typeof Re!="function")throw new TypeError("The last argument must be of type Function");var De=this,qe=function(){return Re.apply(De,arguments)};Y.apply(this,ee).then(function(tt){o.nextTick(qe.bind(null,null,tt))},function(tt){o.nextTick(se.bind(null,tt,qe))})}return Object.setPrototypeOf(G,Object.getPrototypeOf(Y)),Object.defineProperties(G,s(Y)),G}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"),c=r("gopd"),u=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&&c&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=c(P,Symbol.toStringTag);if(!_){var Q=m(P);_=c(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(u(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof zn<"u"?zn: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)})})(YQ);var pj=YQ.exports;const Oj=Si(pj),{json1Presence:b0,textUnicode:UQ}=Oj;function gj(t){return new Worker("/assets/worker-DHoGVnSk.js",{name:t==null?void 0:t.name})}function mj(t){return new Worker("/assets/worker-1ri6mpan.js",{name:t==null?void 0:t.name})}const yj=!0,tS=800,FQ="vzCodeSidebarWidth",zQ="vzCodeCodeEditorWidth",GQ=220;let yO=GQ;const HQ=800;let vO=HQ,ny=!1;if(typeof window<"u"&&yj){const t=window.localStorage.getItem(FQ),e=window.localStorage.getItem(zQ);t!==null&&(yO=+t,ny=!0),e!==null&&(vO=+e,ny=!0)}const vj={codeEditorWidth:vO,sidebarWidth:yO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},wO=q.createContext(vj),wj={sidebarWidth:GQ,codeEditorWidth:HQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},Sj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:yO,codeEditorWidth:vO,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}},bj=({children:t})=>{const[e,r]=q.useReducer(Sj,wj),n=q.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=q.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:c}=e;typeof window<"u"&&q.useLayoutEffect(()=>{ny&&!c&&r({type:"initialize"})},[c]),q.useEffect(()=>{o!==yO&&setTimeout(()=>{window.localStorage.setItem(FQ,""+o)},tS),s!==vO&&setTimeout(()=>{window.localStorage.setItem(zQ,""+s)},tS)},[s,o]);const u={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return W.jsx(wO.Provider,{value:u,children:t})},Pj=1200,kj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},xj=({shareDBDoc:t,submitOperation:e,prettierWorker:r})=>{const n=q.useRef(new Set),[i,o]=q.useState(null),s=q.useRef(!1),a=q.useRef(null);return q.useEffect(()=>{if(!t)return;const l=f=>{const{fileId:h,error:d,fileTextPrettified:p}=f.data;if(d){o(d);return}else o(null);s.current=!0,e(O=>({...O,files:{...O.files,[h]:{...O.files[h],text:p}}})),s.current=!1};r.addEventListener("message",l);const c=async()=>{const h=t.data.files,d=n.current,p=Array.from(d);d.clear();for(const O of p){const m=h[O],y={fileText:m.text,fileExtension:kj(m.name),fileId:O};r.postMessage(y)}};a.current=c;const u=f=>{if(!s.current&&f&&f.length===4&&f[0]==="files"&&typeof f[1]=="string"&&f[2]==="text"){const h=f[1];n.current.add(h)}};return t.on("op batch",u),()=>{r.removeEventListener("message",l),t.removeListener("op batch",u)}},[t]),{prettierError:i,runPrettierRef:a}},_j=500,$j=Pj+_j,Qj=({content:t,typeScriptWorker:e})=>{const r=q.useRef(null),n=q.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},$j))},[e]);q.useEffect(()=>{n(t)},[t])},Ej=(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}},Cj=(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}},Tj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Rj=(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}},Aj=(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}},Mj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,jj=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,Dj=(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,Zj=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),Nj=[Tj,Rj,Aj,Cj,Ej,jj,Mj,Dj,qj],Wj=(t,e)=>Nj.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]=Il(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),oo.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]=Il(this,e,r);let n=[];return this.decompose(e,r,n,0),oo.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 dc(this),o=new dc(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 dc(this,e)}iterRange(e,r=this.length){return new KQ(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 JQ(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):oo.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Ij(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 Bj(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(rS(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Td(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]=Il(this,e,r);let i=Td(this.text,Td(n.text,rS(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):oo.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
|
|
68
|
+
`)+" "+ee[1]:ee[0]+G+" "+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 C(Y){return Y===void 0}i.isUndefined=C;function Z(Y){return B(Y)&&X(Y)==="[object RegExp]"}i.isRegExp=Z,i.types.isRegExp=Z;function B(Y){return typeof Y=="object"&&Y!==null}i.isObject=B;function F(Y){return B(Y)&&X(Y)==="[object Date]"}i.isDate=F,i.types.isDate=F;function M(Y){return B(Y)&&(X(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(Y){return typeof Y=="function"}i.isFunction=I;function D(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=D,i.isBuffer=r("./support/isBuffer");function X(Y){return Object.prototype.toString.call(Y)}function z(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,G=[z(Y.getHours()),z(Y.getMinutes()),z(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],G].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,G){if(!G||!B(G))return Y;for(var ee=Object.keys(G),ve=ee.length;ve--;)Y[ee[ve]]=G[ee[ve]];return Y};function U(Y,G){return Object.prototype.hasOwnProperty.call(Y,G)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&G[K]){var ee=G[K];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var ve,Re,De=new Promise(function(st,Et){ve=st,Re=Et}),qe=[],tt=0;tt<arguments.length;tt++)qe.push(arguments[tt]);qe.push(function(st,Et){st?Re(st):ve(Et)});try{G.apply(this,qe)}catch(st){Re(st)}return De}return Object.setPrototypeOf(ee,Object.getPrototypeOf(G)),K&&Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,s(G))},i.promisify.custom=K;function se(Y,G){if(!Y){var ee=new Error("Promise was rejected with a falsy value");ee.reason=Y,Y=ee}return G(Y)}function Me(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function G(){for(var ee=[],ve=0;ve<arguments.length;ve++)ee.push(arguments[ve]);var Re=ee.pop();if(typeof Re!="function")throw new TypeError("The last argument must be of type Function");var De=this,qe=function(){return Re.apply(De,arguments)};Y.apply(this,ee).then(function(tt){o.nextTick(qe.bind(null,null,tt))},function(tt){o.nextTick(se.bind(null,tt,qe))})}return Object.setPrototypeOf(G,Object.getPrototypeOf(Y)),Object.defineProperties(G,s(Y)),G}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"),c=r("gopd"),u=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&&c&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=c(P,Symbol.toStringTag);if(!_){var Q=m(P);_=c(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(u(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof zn<"u"?zn: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)})})(YQ);var pj=YQ.exports;const Oj=Si(pj),{json1Presence:b0,textUnicode:UQ}=Oj;function gj(t){return new Worker("/assets/worker-DHoGVnSk.js",{name:t==null?void 0:t.name})}function mj(t){return new Worker("/assets/index-CI1sbUJw.js",{name:t==null?void 0:t.name})}const yj=!0,tS=800,FQ="vzCodeSidebarWidth",zQ="vzCodeCodeEditorWidth",GQ=220;let yO=GQ;const HQ=800;let vO=HQ,ny=!1;if(typeof window<"u"&&yj){const t=window.localStorage.getItem(FQ),e=window.localStorage.getItem(zQ);t!==null&&(yO=+t,ny=!0),e!==null&&(vO=+e,ny=!0)}const vj={codeEditorWidth:vO,sidebarWidth:yO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},wO=q.createContext(vj),wj={sidebarWidth:GQ,codeEditorWidth:HQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},Sj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:yO,codeEditorWidth:vO,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}},bj=({children:t})=>{const[e,r]=q.useReducer(Sj,wj),n=q.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=q.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:c}=e;typeof window<"u"&&q.useLayoutEffect(()=>{ny&&!c&&r({type:"initialize"})},[c]),q.useEffect(()=>{o!==yO&&setTimeout(()=>{window.localStorage.setItem(FQ,""+o)},tS),s!==vO&&setTimeout(()=>{window.localStorage.setItem(zQ,""+s)},tS)},[s,o]);const u={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return W.jsx(wO.Provider,{value:u,children:t})},Pj=1200,kj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},xj=({shareDBDoc:t,submitOperation:e,prettierWorker:r})=>{const n=q.useRef(new Set),[i,o]=q.useState(null),s=q.useRef(!1),a=q.useRef(null);return q.useEffect(()=>{if(!t)return;const l=f=>{const{fileId:h,error:d,fileTextPrettified:p}=f.data;if(d){o(d);return}else o(null);s.current=!0,e(O=>({...O,files:{...O.files,[h]:{...O.files[h],text:p}}})),s.current=!1};r.addEventListener("message",l);const c=async()=>{const h=t.data.files,d=n.current,p=Array.from(d);d.clear();for(const O of p){const m=h[O],y={fileText:m.text,fileExtension:kj(m.name),fileId:O};r.postMessage(y)}};a.current=c;const u=f=>{if(!s.current&&f&&f.length===4&&f[0]==="files"&&typeof f[1]=="string"&&f[2]==="text"){const h=f[1];n.current.add(h)}};return t.on("op batch",u),()=>{r.removeEventListener("message",l),t.removeListener("op batch",u)}},[t]),{prettierError:i,runPrettierRef:a}},_j=500,$j=Pj+_j,Qj=({content:t,typeScriptWorker:e})=>{const r=q.useRef(null),n=q.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},$j))},[e]);q.useEffect(()=>{n(t)},[t])},Ej=(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}},Cj=(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}},Tj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Rj=(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}},Aj=(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}},Mj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,jj=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,Dj=(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,Zj=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),Nj=[Tj,Rj,Aj,Cj,Ej,jj,Mj,Dj,qj],Wj=(t,e)=>Nj.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]=Il(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),oo.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]=Il(this,e,r);let n=[];return this.decompose(e,r,n,0),oo.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 dc(this),o=new dc(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 dc(this,e)}iterRange(e,r=this.length){return new KQ(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 JQ(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):oo.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Ij(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 Bj(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(rS(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Td(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]=Il(this,e,r);let i=Td(this.text,Td(n.text,rS(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):oo.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
|
|
69
69
|
`){[e,r]=Il(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 oo 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 c=i&((s<=e?1:0)|(l>=r?2:0));s>=e&&l<=r&&!c?n.push(a):a.decompose(e-s,r-s,n,c)}s=l+1}}replace(e,r,n){if([e,r]=Il(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),c=this.lines-s.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new oo(u,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]=Il(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 oo))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],c=e.children[o];if(l!=c)return n+l.scanIdentical(c,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,c=-1,u=[];function f(d){let p;if(d.lines>o&&d instanceof oo)for(let O of d.children)f(O);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof Er&&l&&(p=u[u.length-1])instanceof Er&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new Er(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&h(),l+=d.lines,c+=d.length+1,u.push(d))}function h(){l!=0&&(a.push(u.length==1?u[0]:oo.from(u,c)),c=-1,l=u.length=0)}for(let d of e)f(d);return h(),a.length==1?a[0]:new oo(a,r)}}It.empty=new Er([""],0);function Ij(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Td(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 rS(t,e,r){return Td(t,[""],e,r)}class dc{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 KQ{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new dc(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 JQ{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()},dc.prototype[Symbol.iterator]=KQ.prototype[Symbol.iterator]=JQ.prototype[Symbol.iterator]=function(){return this});let Bj=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 Il(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}let kl="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<kl.length;t++)kl[t]+=kl[t-1];function Lj(t){for(let e=1;e<kl.length;e+=2)if(kl[e]>t)return kl[e-1]<=t;return!1}function nS(t){return t>=127462&&t<=127487}const iS=8205;function ln(t,e,r=!0,n=!0){return(r?eE:Vj)(t,e,n)}function eE(t,e,r){if(e==t.length)return e;e&&tE(t.charCodeAt(e))&&rE(t.charCodeAt(e-1))&&e--;let n=on(t,e);for(e+=hi(n);e<t.length;){let i=on(t,e);if(n==iS||i==iS||r&&Lj(i))e+=hi(i),n=i;else if(nS(i)){let o=0,s=e-2;for(;s>=0&&nS(on(t,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function Vj(t,e,r){for(;e>0;){let n=eE(t,e-2,r);if(n<e)return n;e--}return 0}function tE(t){return t>=56320&&t<57344}function rE(t){return t>=55296&&t<56320}function on(t,e){let r=t.charCodeAt(e);if(!rE(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return tE(n)?(r-55296<<10)+(n-56320)+65536:r}function P0(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function hi(t){return t<65536?1:2}const iy=/\r\n?|\n/;var Xr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Xr||(Xr={}));class fo{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){oy(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 fo(e)}composeDesc(e){return this.empty?e:e.empty?this:nE(this,e)}mapDesc(e,r=!1){return e.empty?this:sy(this,e,r)}mapPos(e,r=-1,n=Xr.Simple){let i=0,o=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=i+a;if(l<0){if(c>e)return o+(e-i);o+=a}else{if(n!=Xr.Simple&&c>=e&&(n==Xr.TrackDel&&i<e&&c>e||n==Xr.TrackBefore&&i<e||n==Xr.TrackAfter&&c>e))return null;if(c>e||c==e&&r<0&&!a)return e==i||r<0?o:o+l;o+=l}i=c}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 fo(e)}static create(e){return new fo(e)}}class Vr extends fo{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 oy(this,(r,n,i,o,s)=>e=e.replace(i,i+(n-r),s),!1),e}mapDesc(e,r=!1){return sy(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 Vr(r,n)}compose(e){return this.empty?e:e.empty?this:nE(this,e,!0)}map(e,r=!1){return e.empty?this:sy(this,e,r,!0)}iterChanges(e,r=!1){oy(this,e,r)}get desc(){return fo.create(this.sections)}filter(e){let r=[],n=[],i=[],o=new qc(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 u=Math.min(o.len,l-a);gn(i,u,-1);let f=o.ins==-1?-1:o.off==0?o.ins:0;gn(r,u,f),f>0&&rs(n,r,o.text),o.forward(u),a+=u}let c=e[s++];for(;a<c;){if(o.done)break e;let u=Math.min(o.len,c-a);gn(r,u,-1),gn(i,u,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(u),a+=u}}return{changes:new Vr(r,n),filtered:fo.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(u=!1){if(!u&&!i.length)return;s<r&&gn(i,r-s,-1);let f=new Vr(i,o);a=a?a.compose(f.map(a)):f,i=[],o=[],s=0}function c(u){if(Array.isArray(u))for(let f of u)c(f);else if(u instanceof Vr){if(u.length!=r)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${r})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:f,to:h=f,insert:d}=u;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||iy)):d:It.empty,O=p.length;if(f==h&&O==0)return;f<s&&l(),f>s&&gn(i,f-s,-1),gn(i,h-f,O),rs(o,i,p),s=h}}return c(e),l(!a),a}static empty(e){return new Vr(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 Vr(r,n)}static createSet(e,r){return new Vr(e,r)}}function gn(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 rs(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 oy(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 c=i,u=o,f=It.empty;for(;c+=a,u+=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,c,o,u,f),i=c,o=u}}}function sy(t,e,r,n=!1){let i=[],o=n?[]:null,s=new qc(t),a=new qc(e);for(let l=-1;;)if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);gn(i,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!r))){let c=a.len;for(gn(i,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(gn(i,0,s.ins),o&&rs(o,i,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let f=Math.min(u,a.len);c+=f,u-=f,a.forward(f)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;gn(i,c,l<s.i?s.ins:0),o&&l<s.i&&rs(o,i,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return o?Vr.createSet(i,o):fo.create(i);throw new Error("Mismatched change set lengths")}}function nE(t,e,r=!1){let n=[],i=r?[]:null,o=new qc(t),s=new qc(e);for(let a=!1;;){if(o.done&&s.done)return i?Vr.createSet(n,i):fo.create(n);if(o.ins==0)gn(n,o.len,0,a),o.next();else if(s.len==0&&!s.done)gn(n,0,s.ins,a),i&&rs(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),c=n.length;if(o.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;gn(n,l,u,a),i&&u&&rs(i,n,s.text)}else s.ins==-1?(gn(n,o.off?0:o.len,l,a),i&&rs(i,n,o.textBit(l))):(gn(n,o.off?0:o.len,s.off?0:s.ins,a),i&&!s.off&&rs(i,n,s.text));a=(o.ins>l||s.ins>=0&&s.len>l)&&(a||n.length>c),o.forward2(l),s.forward(l)}}}}class qc{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 sa{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 sa(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 sa(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=>sa.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 sa.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?sa.create(r,e,48|o):sa.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 iE(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}let k0=0;class Ze{constructor(e,r,n,i,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=i,this.id=k0++,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:x0),!!e.static,e.enables)}of(e){return new Rd([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rd(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rd(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}}function x0(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}class Rd{constructor(e,r,n,i){this.dependencies=e,this.facet=r,this.type=n,this.value=i,this.id=k0++}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,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:((r=e[f.id])!==null&&r!==void 0?r:1)&1||u.push(e[f.id]);return{create(f){return f.values[s]=n(f),1},update(f,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||ay(f,u)){let d=n(f);if(a?!oS(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=Sp(h,p);if(this.dependencies.every(m=>m instanceof Ze?h.facet(m)===f.facet(m):m instanceof Fr?h.field(m,!1)==f.field(m,!1):!0)||(a?oS(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 oS(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 ay(t,e){let r=!1;for(let n of e)pc(t,n)&1&&(r=!0);return r}function Xj(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 c=[];for(let u=0;u<n.length;u++){let f=Sp(l,n[u]);if(i[u]==2)for(let h of f)c.push(h);else c.push(f)}return e.combine(c)}return{create(l){for(let c of n)pc(l,c);return l.values[s]=a(l),1},update(l,c){if(!ay(l,o))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=ay(l,n),f=c.config.facets[e.id],h=c.facet(e);if(f&&!u&&x0(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 sS=Ze.define({static:!0});class Fr{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 Fr(k0++,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(sS).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,sS.of({field:this,create:e})]}get extension(){return this}}const Js={lowest:4,low:3,default:2,high:1,highest:0};function xu(t){return e=>new oE(e,t)}const Do={highest:xu(Js.highest),high:xu(Js.high),default:xu(Js.default),low:xu(Js.low),lowest:xu(Js.lowest)};class oE{constructor(e,r){this.inner=e,this.prec=r}}class Bl{of(e){return new ly(this,e)}reconfigure(e){return Bl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ly{constructor(e,r){this.compartment=e,this.inner=r}}class wp{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 Yj(e,r,s))h instanceof Fr?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of i)a[h.id]=c.length<<1,c.push(d=>h.slot(d));let u=n==null?void 0:n.config.facets;for(let h in o){let d=o[h],p=d[0].facet,O=u&&u[h]||[];if(d.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,x0(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]=c.length<<1,c.push(y=>m.dynamicSlot(y)));a[p.id]=c.length<<1,c.push(m=>Xj(m,p,d))}}let f=c.map(h=>h(a));return new wp(e,s,f,a,l,o)}}function Yj(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 c=n[l].indexOf(s);c>-1&&n[l].splice(c,1),s instanceof ly&&r.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof ly){if(r.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;r.set(s.compartment,c),o(c,a)}else if(s instanceof oE)o(s.inner,s.prec);else if(s instanceof Fr)n[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Rd)n[a].push(s),s.facet.extensions&&o(s.facet.extensions,Js.default);else{let c=s.extension;if(!c)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(c,a)}}return o(t,Js.default),n.reduce((s,a)=>s.concat(a))}function pc(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 Sp(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const sE=Ze.define(),uy=Ze.define({combine:t=>t.some(e=>e),static:!0}),aE=Ze.define({combine:t=>t.length?t[0]:void 0,static:!0}),lE=Ze.define(),uE=Ze.define(),cE=Ze.define(),fE=Ze.define({combine:t=>t.length?t[0]:!1});class po{constructor(e,r){this.type=e,this.value=r}static define(){return new Uj}}class Uj{of(e){return new po(this,e)}}class Fj{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 Fj(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 Dr{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&&iE(n,r.newLength),o.some(a=>a.type==Dr.time)||(this.annotations=o.concat(Dr.time.of(Date.now())))}static create(e,r,n,i,o,s){return new Dr(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(Dr.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}}Dr.time=po.define();Dr.userEvent=po.define();Dr.addToHistory=po.define();Dr.remote=po.define();function zj(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 hE(t,e,r){var n;let i,o,s;return r?(i=e.changes,o=Vr.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 cy(t,e,r){let n=e.selection,i=xl(e.annotations);return e.userEvent&&(i=i.concat(Dr.userEvent.of(e.userEvent))),{changes:e.changes instanceof Vr?e.changes:Vr.of(e.changes||[],r,t.facet(aE)),selection:n&&(n instanceof oe?n:oe.single(n.anchor,n.head)),effects:xl(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function dE(t,e,r){let n=cy(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=hE(n,cy(t,e[o],s?n.changes.newLength:t.doc.length),s)}let i=Dr.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Hj(r?Gj(i):i)}function Gj(t){let e=t.startState,r=!0;for(let i of e.facet(lE)){let o=i(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:zj(r,o))}if(r!==!0){let i,o;if(r===!1)o=t.changes.invertedDesc,i=Vr.empty(e.doc.length);else{let s=t.changes.filter(r);i=s.changes,o=s.filtered.mapDesc(s.changes).invertedDesc}t=Dr.create(e,i,t.selection&&t.selection.map(o),mt.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(uE);for(let i=n.length-1;i>=0;i--){let o=n[i](t);o instanceof Dr?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof Dr?t=o[0]:t=dE(e,xl(o),!1)}return t}function Hj(t){let e=t.startState,r=e.facet(cE),n=t;for(let i=r.length-1;i>=0;i--){let o=r[i](t);o&&Object.keys(o).length&&(n=hE(n,cy(e,o,t.changes.newLength),!0))}return n==t?t:Dr.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}const Kj=[];function xl(t){return t==null?Kj: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 Jj=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let fy;try{fy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function eD(t){if(fy)return fy.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>""&&(r.toUpperCase()!=r.toLowerCase()||Jj.test(r)))return!0}return!1}function tD(t){return e=>{if(!/\S/.test(e))return gr.Space;if(eD(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++)pc(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 pc(this,n),Sp(this,n)}update(...e){return dE(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:i}=r;for(let a of e.effects)a.is(Bl.reconfigure)?(r&&(i=new Map,r.compartments.forEach((l,c)=>i.set(c,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=xl(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=wp.resolve(n,i,this),o=new jt(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(uy)?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=xl(n.effects);for(let a=1;a<r.ranges.length;a++){let l=e(r.ranges[a]),c=this.changes(l.changes),u=c.map(i);for(let h=0;h<a;h++)o[h]=o[h].map(u);let f=i.mapDesc(c,!0);o.push(l.range.map(f)),i=i.compose(u),s=mt.mapEffects(s,u).concat(mt.mapEffects(xl(l.effects),f))}return{changes:i,selection:oe.create(o,r.mainIndex),effects:s}}changes(e=[]){return e instanceof Vr?e:Vr.of(e,this.doc.length,this.facet(jt.lineSeparator))}toText(e){return It.of(e.split(this.facet(jt.lineSeparator)||iy))}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:(pc(this,r),Sp(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 Fr&&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=wp.resolve(e.extensions||[],new Map),n=e.doc instanceof It?e.doc:It.of((e.doc||"").split(r.staticFacet(jt.lineSeparator)||iy)),i=e.selection?e.selection instanceof oe?e.selection:oe.single(e.selection.anchor,e.selection.head):oe.single(0);return iE(i,n.length),r.staticFacet(uy)||(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)||`
|
|
@@ -141,7 +141,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof t.getDerivedStat
|
|
|
141
141
|
`)}))}),console.log(" generated json1 op: "+JSON.stringify(k_(e,o.changes,o.startState.doc,r,n)))),t.submitOp(k_(e,o.changes,o.startState.doc,r,n)),this.lock=!1)}destroy(){t.off("op",this.handleOp)}});function dF(t,e=t.state){const r=new Set;for(const{from:n,to:i}of t.visibleRanges){let o=n;for(;o<=i;){const s=e.doc.lineAt(o);r.has(s)||r.add(s),o=s.to+1}}return r}function _v(t){const e=t.selection.main.head;return t.doc.lineAt(e)}function __(t,e){let r=0;e:for(let n=0;n<t.length;n++)switch(t[n]){case" ":{r+=1;continue e}case" ":{r+=e-r%e;continue e}case"\r":continue e;default:break e}return r}const tO=Ze.define({combine(t){return Bi(t,{highlightActiveBlock:!0,hideFirstIndent:!1,markerType:"fullScope",thickness:1})}});class pF{constructor(e,r,n,i){this.lines=e,this.state=r,this.map=new Map,this.unitWidth=n,this.markerType=i;for(const o of this.lines)this.add(o);this.state.facet(tO).highlightActiveBlock&&this.findAndSetActiveLines()}has(e){return this.map.has(typeof e=="number"?e:e.number)}get(e){const r=this.map.get(typeof e=="number"?e:e.number);if(!r)throw new Error("Line not found in indentation map");return r}set(e,r,n){const i=!e.text.trim().length,o={line:e,col:r,level:n,empty:i};return this.map.set(o.line.number,o),o}add(e){if(this.has(e))return this.get(e);if(!e.length||!e.text.trim().length){if(e.number===1)return this.set(e,0,0);if(e.number===this.state.doc.lines){const s=this.closestNonEmpty(e,-1);return this.set(e,0,s.level)}const i=this.closestNonEmpty(e,-1),o=this.closestNonEmpty(e,1);return i.level>=o.level&&this.markerType!=="codeOnly"?this.set(e,0,i.level):i.empty&&i.level===0&&o.level!==0?this.set(e,0,0):o.level>i.level?this.set(e,0,i.level+1):this.set(e,0,o.level)}const r=__(e.text,this.state.tabSize),n=Math.floor(r/this.unitWidth);return this.set(e,r,n)}closestNonEmpty(e,r){let n=e.number+r;for(;r===-1?n>=1:n<=this.state.doc.lines;){if(this.has(n)){const s=this.get(n);if(!s.empty)return s}const o=this.state.doc.line(n);if(o.text.trim().length){const s=__(o.text,this.state.tabSize),a=Math.floor(s/this.unitWidth);return this.set(o,s,a)}n+=r}const i=this.state.doc.line(r===-1?1:this.state.doc.lines);return this.set(i,0,0)}findAndSetActiveLines(){const e=_v(this.state);if(!this.has(e))return;let r=this.get(e);if(this.has(r.line.number+1)){const o=this.get(r.line.number+1);o.level>r.level&&(r=o)}if(this.has(r.line.number-1)){const o=this.get(r.line.number-1);o.level>r.level&&(r=o)}if(r.level===0)return;r.active=r.level;let n,i;for(n=r.line.number;n>1;n--){if(!this.has(n-1))continue;const o=this.get(n-1);if(o.level<r.level)break;o.active=r.level}for(i=r.line.number;i<this.state.doc.lines;i++){if(!this.has(i+1))continue;const o=this.get(i+1);if(o.level<r.level)break;o.active=r.level}}}function OF(t){const e={light:"#F0F1F2",dark:"#2B3245",activeLight:"#E4E5E6",activeDark:"#3C445C"};let r=e;return t&&(r=Object.assign(Object.assign({},e),t)),$e.baseTheme({"&light":{"--indent-marker-bg-color":r.light,"--indent-marker-active-bg-color":r.activeLight},"&dark":{"--indent-marker-bg-color":r.dark,"--indent-marker-active-bg-color":r.activeDark},".cm-line":{position:"relative"},".cm-indent-markers::before":{content:'""',position:"absolute",top:0,left:"2px",right:0,bottom:0,background:"var(--indent-markers)",pointerEvents:"none",zIndex:"-1"}})}function gd(t,e,r,n,i){return`${`repeating-linear-gradient(to right, var(${t}) 0 ${e}px, transparent ${e}px ${r}ch)`} ${n*r}.5ch/calc(${r*i}ch - 1px) no-repeat`}function gF(t,e,r,n){const{level:i,active:o}=t;if(r&&i===0)return[];const s=r?1:0,a=[];if(o!==void 0){const l=o-s-1;l>0&&a.push(gd("--indent-marker-bg-color",n,e,s,l)),a.push(gd("--indent-marker-active-bg-color",n,e,o-1,1)),o!==i&&a.push(gd("--indent-marker-bg-color",n,e,o,i-o))}else a.push(gd("--indent-marker-bg-color",n,e,s,i-s));return a.join(",")}class mF{constructor(e){this.view=e,this.unitWidth=Yl(e.state),this.currentLineNumber=_v(e.state).number,this.generate(e.state)}update(e){const r=Yl(e.state),n=r!==this.unitWidth;n&&(this.unitWidth=r);const i=_v(e.state).number,o=i!==this.currentLineNumber;this.currentLineNumber=i;const s=e.state.facet(tO).highlightActiveBlock&&o;(e.docChanged||e.viewportChanged||n||s)&&this.generate(e.state)}generate(e){const r=new ws,n=dF(this.view,e),{hideFirstIndent:i,markerType:o,thickness:s}=e.facet(tO),a=new pF(n,e,this.unitWidth,o);for(const l of n){const c=a.get(l.number);if(!(c!=null&&c.level))continue;const u=gF(c,this.unitWidth,i,s);r.add(l.from,l.from,Ae.line({class:"cm-indent-markers",attributes:{style:`--indent-markers: ${u}`}}))}this.decorations=r.finish()}}function yF(t={}){return[tO.of(t),OF(t.colors),Jt.fromClass(mF,{decorations:e=>e.decorations})]}const M2=t=>e=>{const r=t==="down";let n=e.state.selection;for(const i of n.ranges)n=n.addRange(e.moveVertically(i,r));return e.dispatch({selection:n}),!0},vF=M2("up"),wF=M2("down"),SF=t=>{let e=null;for(const r of t.state.selection.ranges)if(!r.empty)for(let n=r.from;n<=r.to;){const i=t.state.doc.lineAt(n),o=Math.min(i.to,r.to);e?e=e.addRange(oe.range(o,o)):e=oe.single(o),n=i.to+1}return e?(t.dispatch({selection:e}),!0):!1},bF=[{key:"Ctrl-Space",run:GR},{key:"Escape",run:HR},{key:"ArrowDown",run:ss(!0)},{key:"ArrowUp",run:ss(!1)},{key:"PageDown",run:ss(!0,"page")},{key:"PageUp",run:ss(!1,"page")},{key:"Enter",run:dv},{key:"Tab",run:dv},{key:"Mod-f",run:LR,scope:"editor search-panel"},{key:"Escape",run:VR,scope:"editor search-panel"},{key:"Alt-Enter",run:NR,scope:"editor search-panel"},{key:"Mod-Alt-Enter",run:WR,scope:"editor search-panel"},{key:"Ctrl-g",run:UV},{key:"Mod-d",run:iX,preventDefault:!0},{key:"Shift-Mod-l",run:hX},{key:"Enter",run:ix,shift:ix},{key:"ArrowLeft",run:qk,shift:Lk,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:PV,shift:EV},{key:"ArrowRight",run:Zk,shift:Vk,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:kV,shift:CV},{key:"ArrowUp",run:Nk,shift:Xk,preventDefault:!0},{key:"ArrowDown",run:Wk,shift:Yk,preventDefault:!0},{key:"Home",run:Bk,shift:Gk},{mac:"Cmd-ArrowLeft",run:Bk,shift:Gk},{key:"Mod-Home",run:Hk,shift:Jk},{mac:"Cmd-ArrowUp",run:Hk,shift:Jk},{key:"PageUp",run:Bg,shift:Uk},{mac:"Ctrl-ArrowUp",run:Bg,shift:Uk},{key:"PageDown",run:Lg,shift:Fk},{mac:"Ctrl-ArrowDown",run:Lg,shift:Fk},{key:"End",run:Ik,shift:zk},{mac:"Cmd-ArrowRight",run:Ik,shift:zk},{key:"Mod-Alt-ArrowUp",linux:"Shift-Alt-ArrowUp",run:vF,preventDefault:!0},{key:"Mod-Alt-ArrowDown",linux:"Shift-Alt-ArrowDown",run:wF,preventDefault:!0},{key:"Shift-Alt-i",run:SF},{key:"Mod-End",run:Kk,shift:ex},{mac:"Cmd-ArrowDown",run:Kk,shift:ex},{key:"Mod-a",run:AV},{key:"Backspace",run:JX},{key:"Backspace",run:Vg,shift:Vg},{key:"Delete",run:tx},{key:"Mod-Backspace",mac:"Alt-Backspace",run:rx},{key:"Mod-Delete",mac:"Alt-Delete",run:jV},{mac:"Mod-Backspace",run:DV},{mac:"Mod-Delete",run:nx},{mac:"Ctrl-b",run:qk,shift:Lk,preventDefault:!0},{mac:"Ctrl-f",run:Zk,shift:Vk},{mac:"Ctrl-p",run:Nk,shift:Xk},{mac:"Ctrl-n",run:Wk,shift:Yk},{mac:"Ctrl-a",run:xV,shift:TV},{mac:"Ctrl-e",run:_V,shift:RV},{mac:"Ctrl-d",run:tx},{mac:"Ctrl-h",run:Vg},{mac:"Ctrl-k",run:nx},{mac:"Ctrl-Alt-h",run:rx},{mac:"Ctrl-o",run:qV},{mac:"Ctrl-t",run:ZV},{mac:"Ctrl-v",run:Lg},{mac:"Alt-v",run:Bg},{key:"Shift-Mod-k",run:LV},{key:"Alt-ArrowDown",run:WV},{key:"Alt-ArrowUp",run:NV},{win:"Shift-Alt-ArrowDown",mac:"Shift-Alt-ArrowDown",run:BV},{win:"Shift-Alt-ArrowUp",mac:"Shift-Alt-ArrowUp",run:IV},{key:"Mod-l",run:MV,preventDefault:!0},{key:"Shift-Mod-\\",run:QV},{key:"Tab",run:ox,shift:sx,preventDefault:!0},{key:"Mod-[",run:sx},{key:"Mod-]",run:ox},{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gN},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:mN},{key:"Mod-k Mod-0",run:yN},{key:"Mod-k Mod-j",run:vN},{key:"Mod-k Mod-c",run:aV},{key:"Mod-k Mod-u",run:lV},{key:"Mod-/",run:oV},{key:"Shift-Alt-a",run:uV},{key:"Mod-z",run:OR,preventDefault:!0},{key:"Mod-y",run:uv,preventDefault:!0},{key:"Mod-Shift-z",run:uv,preventDefault:!0},{key:"Mod-u",run:gV,preventDefault:!0},{key:"Mod-Shift-m",run:p4},{key:"F8",run:O4}],PF=({path:t,localPresence:e,usernameRef:r})=>$e.updateListener.of(n=>{if(n.selectionSet){const i=n.state.selection.ranges[0],{from:o,to:s}=i,a={start:[...t,o],end:[...t,s],username:r.current};e.submit(a,l=>{if(l)throw l})}});var ft=function(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r},Ne=function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},Io,Hs,Qi,tl,nc,zi,Gi,Hi,Ki,Ji,eo,to,ro,Ks,rl,Bo,zd,Lo;const kF=function(t){var e=131,r=137,n=0;t+="x";var i=Math.floor(9007199254740991/r);for(let o=0;o<t.length;o++)n>i&&(n=Math.floor(n/r)),n=n*e+t.charCodeAt(o);return n},Xe="0123456789abcdef".split(""),xF=[-2147483648,8388608,32768,128],$i=[24,16,8,0],md=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Hr=[];class _F{constructor(e=!1,r=!1){Io.set(this,void 0),Hs.set(this,void 0),Qi.set(this,void 0),tl.set(this,void 0),nc.set(this,void 0),zi.set(this,void 0),Gi.set(this,void 0),Hi.set(this,void 0),Ki.set(this,void 0),Ji.set(this,void 0),eo.set(this,void 0),to.set(this,void 0),ro.set(this,void 0),Ks.set(this,void 0),rl.set(this,void 0),Bo.set(this,void 0),zd.set(this,0),Lo.set(this,void 0),this.init(e,r)}init(e,r){r?(Hr[0]=Hr[16]=Hr[1]=Hr[2]=Hr[3]=Hr[4]=Hr[5]=Hr[6]=Hr[7]=Hr[8]=Hr[9]=Hr[10]=Hr[11]=Hr[12]=Hr[13]=Hr[14]=Hr[15]=0,ft(this,Hs,Hr)):ft(this,Hs,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e?(ft(this,zi,3238371032),ft(this,Gi,914150663),ft(this,Hi,812702999),ft(this,Ki,4144912697),ft(this,Ji,4290775857),ft(this,eo,1750603025),ft(this,to,1694076839),ft(this,ro,3204075428)):(ft(this,zi,1779033703),ft(this,Gi,3144134277),ft(this,Hi,1013904242),ft(this,Ki,2773480762),ft(this,Ji,1359893119),ft(this,eo,2600822924),ft(this,to,528734635),ft(this,ro,1541459225)),ft(this,Io,ft(this,Lo,ft(this,Qi,ft(this,rl,0)))),ft(this,tl,ft(this,Ks,!1)),ft(this,nc,!0),ft(this,Bo,e)}update(e){if(Ne(this,tl))return this;let r;e instanceof ArrayBuffer?r=new Uint8Array(e):r=e;let n=0;const i=r.length,o=Ne(this,Hs);for(;n<i;){let s;if(Ne(this,Ks)&&(ft(this,Ks,!1),o[0]=Ne(this,Io),o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),typeof r!="string")for(s=Ne(this,Lo);n<i&&s<64;++n)o[s>>2]|=r[n]<<$i[s++&3];else for(s=Ne(this,Lo);n<i&&s<64;++n){let a=r.charCodeAt(n);a<128?o[s>>2]|=a<<$i[s++&3]:a<2048?(o[s>>2]|=(192|a>>6)<<$i[s++&3],o[s>>2]|=(128|a&63)<<$i[s++&3]):a<55296||a>=57344?(o[s>>2]|=(224|a>>12)<<$i[s++&3],o[s>>2]|=(128|a>>6&63)<<$i[s++&3],o[s>>2]|=(128|a&63)<<$i[s++&3]):(a=65536+((a&1023)<<10|r.charCodeAt(++n)&1023),o[s>>2]|=(240|a>>18)<<$i[s++&3],o[s>>2]|=(128|a>>12&63)<<$i[s++&3],o[s>>2]|=(128|a>>6&63)<<$i[s++&3],o[s>>2]|=(128|a&63)<<$i[s++&3])}ft(this,zd,s),ft(this,Qi,Ne(this,Qi)+(s-Ne(this,Lo))),s>=64?(ft(this,Io,o[16]),ft(this,Lo,s-64),this.hash(),ft(this,Ks,!0)):ft(this,Lo,s)}return Ne(this,Qi)>4294967295&&(ft(this,rl,Ne(this,rl)+(Ne(this,Qi)/4294967296<<0)),ft(this,Qi,Ne(this,Qi)%4294967296)),this}finalize(){if(Ne(this,tl))return;ft(this,tl,!0);const e=Ne(this,Hs),r=Ne(this,zd);e[16]=Ne(this,Io),e[r>>2]|=xF[r&3],ft(this,Io,e[16]),r>=56&&(Ne(this,Ks)||this.hash(),e[0]=Ne(this,Io),e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=Ne(this,rl)<<3|Ne(this,Qi)>>>29,e[15]=Ne(this,Qi)<<3,this.hash()}hash(){let e=Ne(this,zi),r=Ne(this,Gi),n=Ne(this,Hi),i=Ne(this,Ki),o=Ne(this,Ji),s=Ne(this,eo),a=Ne(this,to),l=Ne(this,ro);const c=Ne(this,Hs);let u,f,h,d,p,O,m,y,g,v;for(let S=16;S<64;++S)d=c[S-15],u=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,d=c[S-2],f=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,c[S]=c[S-16]+u+c[S-7]+f<<0;v=r&n;for(let S=0;S<64;S+=4)Ne(this,nc)?(Ne(this,Bo)?(m=300032,d=c[0]-1413257819,l=d-150054599<<0,i=d+24177077<<0):(m=704751109,d=c[0]-210244248,l=d-1521486534<<0,i=d+143694565<<0),ft(this,nc,!1)):(u=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),f=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),m=e&r,h=m^e&n^v,O=o&s^~o&a,d=l+f+O+md[S]+c[S],p=u+h,l=i+d<<0,i=d+p<<0),u=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),f=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),y=i&e,h=y^i&r^m,O=l&o^~l&s,d=a+f+O+md[S+1]+c[S+1],p=u+h,a=n+d<<0,n=d+p<<0,u=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),f=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),g=n&i,h=g^n&e^y,O=a&l^~a&o,d=s+f+O+md[S+2]+c[S+2],p=u+h,s=r+d<<0,r=d+p<<0,u=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),f=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),v=r&n,h=v^r&i^g,O=s&a^~s&l,d=o+f+O+md[S+3]+c[S+3],p=u+h,o=e+d<<0,e=d+p<<0;ft(this,zi,Ne(this,zi)+e<<0),ft(this,Gi,Ne(this,Gi)+r<<0),ft(this,Hi,Ne(this,Hi)+n<<0),ft(this,Ki,Ne(this,Ki)+i<<0),ft(this,Ji,Ne(this,Ji)+o<<0),ft(this,eo,Ne(this,eo)+s<<0),ft(this,to,Ne(this,to)+a<<0),ft(this,ro,Ne(this,ro)+l<<0)}hex(){this.finalize();const e=Ne(this,zi),r=Ne(this,Gi),n=Ne(this,Hi),i=Ne(this,Ki),o=Ne(this,Ji),s=Ne(this,eo),a=Ne(this,to),l=Ne(this,ro);let c=Xe[e>>28&15]+Xe[e>>24&15]+Xe[e>>20&15]+Xe[e>>16&15]+Xe[e>>12&15]+Xe[e>>8&15]+Xe[e>>4&15]+Xe[e&15]+Xe[r>>28&15]+Xe[r>>24&15]+Xe[r>>20&15]+Xe[r>>16&15]+Xe[r>>12&15]+Xe[r>>8&15]+Xe[r>>4&15]+Xe[r&15]+Xe[n>>28&15]+Xe[n>>24&15]+Xe[n>>20&15]+Xe[n>>16&15]+Xe[n>>12&15]+Xe[n>>8&15]+Xe[n>>4&15]+Xe[n&15]+Xe[i>>28&15]+Xe[i>>24&15]+Xe[i>>20&15]+Xe[i>>16&15]+Xe[i>>12&15]+Xe[i>>8&15]+Xe[i>>4&15]+Xe[i&15]+Xe[o>>28&15]+Xe[o>>24&15]+Xe[o>>20&15]+Xe[o>>16&15]+Xe[o>>12&15]+Xe[o>>8&15]+Xe[o>>4&15]+Xe[o&15]+Xe[s>>28&15]+Xe[s>>24&15]+Xe[s>>20&15]+Xe[s>>16&15]+Xe[s>>12&15]+Xe[s>>8&15]+Xe[s>>4&15]+Xe[s&15]+Xe[a>>28&15]+Xe[a>>24&15]+Xe[a>>20&15]+Xe[a>>16&15]+Xe[a>>12&15]+Xe[a>>8&15]+Xe[a>>4&15]+Xe[a&15];return Ne(this,Bo)||(c+=Xe[l>>28&15]+Xe[l>>24&15]+Xe[l>>20&15]+Xe[l>>16&15]+Xe[l>>12&15]+Xe[l>>8&15]+Xe[l>>4&15]+Xe[l&15]),c}toString(){return this.hex()}digest(){this.finalize();const e=Ne(this,zi),r=Ne(this,Gi),n=Ne(this,Hi),i=Ne(this,Ki),o=Ne(this,Ji),s=Ne(this,eo),a=Ne(this,to),l=Ne(this,ro),c=[e>>24&255,e>>16&255,e>>8&255,e&255,r>>24&255,r>>16&255,r>>8&255,r&255,n>>24&255,n>>16&255,n>>8&255,n&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255,s>>24&255,s>>16&255,s>>8&255,s&255,a>>24&255,a>>16&255,a>>8&255,a&255];return Ne(this,Bo)||c.push(l>>24&255,l>>16&255,l>>8&255,l&255),c}array(){return this.digest()}arrayBuffer(){this.finalize();const e=new ArrayBuffer(Ne(this,Bo)?28:32),r=new DataView(e);return r.setUint32(0,Ne(this,zi)),r.setUint32(4,Ne(this,Gi)),r.setUint32(8,Ne(this,Hi)),r.setUint32(12,Ne(this,Ki)),r.setUint32(16,Ne(this,Ji)),r.setUint32(20,Ne(this,eo)),r.setUint32(24,Ne(this,to)),Ne(this,Bo)||r.setUint32(28,Ne(this,ro)),e}}Io=new WeakMap,Hs=new WeakMap,Qi=new WeakMap,tl=new WeakMap,nc=new WeakMap,zi=new WeakMap,Gi=new WeakMap,Hi=new WeakMap,Ki=new WeakMap,Ji=new WeakMap,eo=new WeakMap,to=new WeakMap,ro=new WeakMap,Ks=new WeakMap,rl=new WeakMap,Bo=new WeakMap,zd=new WeakMap,Lo=new WeakMap;function $F(t){const e=new _F;return e.update(t),parseInt(e.hex().substring(0,8),16)}const QF=function(t){var e="#";return t.forEach(function(r){r<16&&(e+=0),e+=r.toString(16)}),e},EF=function(t,e,r){t/=360;var n=r<.5?r*(1+e):r+e-r*e,i=2*r-n;return[t+1/3,t,t-1/3].map(function(o){return o<0&&o++,o>1&&o--,o<1/6?o=i+(n-i)*6*o:o<.5?o=n:o<2/3?o=i+(n-i)*6*(2/3-o):o=i,Math.round(o*255)})};class CF{constructor(e={}){const[r,n]=[e.lightness,e.saturation].map(function(i){return i=i!==void 0?i:[.35,.5,.65],Array.isArray(i)?i.concat():[i]});this.L=r,this.S=n,typeof e.hue=="number"&&(e.hue={min:e.hue,max:e.hue}),typeof e.hue=="object"&&!Array.isArray(e.hue)&&(e.hue=[e.hue]),typeof e.hue>"u"&&(e.hue=[]),this.hueRanges=e.hue.map(function(i){return{min:typeof i.min>"u"?0:i.min,max:typeof i.max>"u"?360:i.max}}),this.hash=$F,typeof e.hash=="function"&&(this.hash=e.hash),e.hash==="bkdr"&&(this.hash=kF)}hsl(e){var r,n,i,o=this.hash(e),s=727;if(this.hueRanges.length){const a=this.hueRanges[o%this.hueRanges.length];r=o/this.hueRanges.length%s*(a.max-a.min)/s+a.min}else r=o%359;return o=Math.ceil(o/360),n=this.S[o%this.S.length],o=Math.ceil(o/this.S.length),i=this.L[o%this.L.length],[r,n,i]}rgb(e){var r=this.hsl(e);return EF.apply(this,r)}hex(e){var r=this.rgb(e);return QF(r)}}const TF=({path:t,docPresence:e})=>[Jt.fromClass(class{constructor(r){this.decorations=Dt.of([]);const n={};e.on("receive",(i,o)=>{o&&AF(t,o)?n[i]=o:delete n[i];const s=[];for(const a of Object.keys(n)){const l=n[a],{start:c,end:u}=l,f=c[c.length-1],h=u[u.length-1],d=new CF().rgb(a),{username:p}=l;s.push({from:f,to:f,value:Ae.widget({side:-1,block:!1,widget:new MF(""+Math.random(),d,p)})}),f!==h&&s.push({from:f,to:h,value:Ae.mark({class:"cm-json1-presence",attributes:{style:`
|
|
142
142
|
background-color: rgba(${d}, 0.75);
|
|
143
143
|
mix-blend-mode: luminosity;
|
|
144
|
-
`}})})}this.decorations=Ae.set(s,!0),setTimeout(()=>{r.dispatch({annotations:[RF.of(!0)]})},0)})}},{decorations:r=>r.decorations}),jF],RF=po.define(),AF=(t,e)=>{for(let r=0;r<t.length;r++)if(t[r]!==e.start[r])return!1;return!0};class MF extends bi{constructor(e,r,n){super(),this.id=e,this.color=r,this.username=n}eq(e){return e.id===this.id}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-json1-presence";const r=document.createElement("div");e.appendChild(r),r.style.borderLeft=`1px solid rgba(${this.color})`;const n=document.createElement("div");return n.className="remote-cursor-username",n.style.top="-20px",n.style.height="20px",n.style.width=`${this.username.length*12}px`,n.style.backgroundColor=`rgba(${this.color})`,n.style.color="black",n.appendChild(document.createTextNode(this.username)),e.appendChild(n),this.timeout=window.setTimeout(()=>{n.style.opacity="0.3"},2e3),e}ignoreEvent(){return!1}}const jF=$e.baseTheme({".cm-json1-presence":{position:"relative"},".cm-json1-presence > div":{position:"absolute",top:"0",bottom:"0",left:"0",right:"0"}}),j2=Fr.define({create:()=>null,update:(t,e)=>{for(const r of e.effects)if(r.is($v))return r.value;if(!t)return null;if(!e.changes.empty){const r=e.changes.mapPos(t.pos,-1,Xr.TrackDel),n=e.changes.mapPos(t.pos+t.text.length,-1,Xr.TrackDel);return r===null||n===null||e.newDoc.sliceString(r,n)!==t.text?null:Object.assign(Object.assign({},t),{pos:r})}return t},provide:t=>[$e.decorations.from(t,e=>{if(!e)return Ae.none;const r=e.pos,n=e.pos+e.text.length,i=e.rule.className;return Ae.set(DF({className:i}).range(r,n))}),$e.contentAttributes.from(t,e=>!e||!e.rule.cursor?{style:""}:{style:`cursor: ${e.rule.cursor}`})]}),$v=mt.define(),DF=t=>{var e;return Ae.mark({class:`cm-interact ${(e=t==null?void 0:t.className)!==null&&e!==void 0?e:""}`})},qF=$e.theme({".cm-interact":{background:"rgba(128, 128, 255, 0.2)",borderRadius:"4px"}}),D2=Ze.define(),q2=Ze.define({combine:t=>t[t.length-1]}),ZF=Jt.define(t=>({target:null,dragging:!1,mouseX:0,mouseY:0,getMatch(){const e=t.state.facet(D2),r=t.posAtCoords({x:this.mouseX,y:this.mouseY});if(!r)return null;const n=t.state.doc.lineAt(r),i=r-n.from;let o=null;for(const s of e)for(const a of n.text.matchAll(s.regexp)){if(a.index===void 0)continue;const l=a[0];if(!l)continue;const c=a.index,u=a.index+l.length;i<c||i>u||(!o||l.length<o.text.length)&&(o={rule:s,pos:n.from+c,text:l})}return o},updateText(e){return r=>{t.dispatch({effects:$v.of(Object.assign(Object.assign({},e),{text:r})),changes:{from:e.pos,to:e.pos+e.text.length,insert:r}})}},setTarget(e){this.target=e,t.dispatch({effects:$v.of(e)})},isModKeyDown(e){const r=t.state.facet(q2),n=!!window.navigator&&window.navigator.userAgent.includes("Macintosh");switch(r){case"alt":return e.altKey;case"shift":return e.shiftKey;case"ctrl":return e.ctrlKey;case"meta":return e.metaKey;case"mod":return n?e.metaKey:e.ctrlKey}throw new Error(`Invalid mod key: ${r}`)},update(e){const r=e.state.field(j2,!1);r!==void 0&&this.target!==r&&(this.target=r,r===null&&this.endDrag())},startDrag(e){this.dragging||this.target&&(this.dragging=!0,this.target.rule.onDragStart&&this.target.rule.onDragStart(this.target.text,this.updateText(this.target),e))},endDrag(){var e;this.dragging&&(this.dragging=!1,!((e=this.target)===null||e===void 0)&&e.rule.onDragEnd&&this.target.rule.onDragEnd(this.target.text,this.updateText(this.target)))}}),{eventHandlers:{mousedown(t,e){this.isModKeyDown(t)&&this.target&&(t.preventDefault(),this.target.rule.onClick&&this.target.rule.onClick(this.target.text,r=>{this.target&&this.updateText(this.target)(r)},t),this.target.rule.onDrag&&this.startDrag(t))},mousemove(t,e){if(this.mouseX=t.clientX,this.mouseY=t.clientY,!this.isModKeyDown(t)){this.target&&this.setTarget(null);return}this.target&&this.dragging?this.target.rule.onDrag&&this.target.rule.onDrag(this.target.text,this.updateText(this.target),t):this.setTarget(this.getMatch())},mouseup(t,e){this.endDrag(),this.target&&!this.isModKeyDown(t)&&this.setTarget(null),this.isModKeyDown(t)&&this.setTarget(this.getMatch())},mouseleave(t,e){this.endDrag(),this.target&&this.setTarget(null)},keydown(t,e){!this.target&&this.isModKeyDown(t)&&this.setTarget(this.getMatch())},keyup(t,e){this.target&&!this.isModKeyDown(t)&&(this.endDrag(),this.setTarget(null))}}}),NF=(t={})=>{var e,r;return[j2,qF,ZF,q2.of((e=t.key)!==null&&e!==void 0?e:"alt"),((r=t.rules)!==null&&r!==void 0?r:[]).map(n=>D2.of(n))]},Z2=/#[0-9A-Fa-f]{6}/g,WF=({onInteract:t,customInteractRules:e})=>{const r=[{regexp:Z2,cursor:"pointer",onClick(n,i){const o=n,s=document.createElement("input");s.type="color",s.value=o.toLowerCase();const a=o.toUpperCase()===o,l=c=>{const u=c.target;u.value&&i(a?u.value.toUpperCase():u.value)};s.addEventListener("input",l),s.click()}},{regexp:new RegExp("(?<!\\#)-?\\b\\d+\\.?\\d*\\b","g"),cursor:"ew-resize",onDrag:(n,i,o)=>{t&&t();const s=Number(n)+o.movementX;isNaN(s)||i(s.toString())}},{regexp:/true|false/g,cursor:"pointer",onClick:(n,i)=>{switch(t&&t(),n){case"true":return i("false");case"false":return i("true")}}},{regexp:/vec2\(-?\b\d+\.?\d*\b\s*(,\s*-?\b\d+\.?\d*\b)?\)/g,cursor:"move",onDrag:(n,i,o)=>{var c,u;const s=/vec2\((?<x>-?\b\d+\.?\d*\b)\s*(,\s*(?<y>-?\b\d+\.?\d*\b))?\)/.exec(n),a=Number((c=s==null?void 0:s.groups)==null?void 0:c.x);let l=Number((u=s==null?void 0:s.groups)==null?void 0:u.y);isNaN(a)||(isNaN(l)&&(l=a),i(`vec2(${a+o.movementX}, ${l-o.movementY})`))}},{regexp:/rgb\(.*\)/g,cursor:"pointer",onClick:(n,i,o)=>{var h,d,p;const s=/rgb\((?<r>\d+)\s*,\s*(?<g>\d+)\s*,\s*(?<b>\d+)\)/.exec(n),a=Number((h=s==null?void 0:s.groups)==null?void 0:h.r),l=Number((d=s==null?void 0:s.groups)==null?void 0:d.g),c=Number((p=s==null?void 0:s.groups)==null?void 0:p.b),u=document.createElement("input");u.type="color",isNaN(a+l+c)||(u.value=BF(a,l,c));const f=O=>{const m=O.target;if(t&&t(),m.value){const[y,g,v]=IF(m.value);i(`rgb(${y}, ${g}, ${v})`)}u.removeEventListener("change",f)};u.addEventListener("change",f),u.click()}},{regexp:/https?:\/\/[^ ")]+/g,cursor:"pointer",onClick:n=>{window.open(n)}},{regexp:/rotate\(-?\d*\.?\d*\)/g,cursor:"move",onDragStart(n,i,o){ra={x:o.clientX,y:o.clientY}},onDrag(n,i,o){if(ra==null)return;const s=Math.round(Math.atan2(ra.y-o.clientY,o.clientX-ra.x)*180/Math.PI);i(`rotate(${s})`);const a=new CustomEvent("updateRotateDrag",{detail:s});document.dispatchEvent(a)},onDragEnd(){ra=null}}];return e&&r.push(...e),NF({rules:r})};let ra=null;const IF=t=>{const e=parseInt(t.substring(1),16);return[e>>16&255,e>>8&255,e&255]},BF=(t,e,r)=>"#"+t.toString(16)+e.toString(16)+r.toString(16),LF=$e.baseTheme({".color-circle-parent":{display:"inline-block",cursor:"inherit"}}),VF=[Jt.fromClass(class{constructor(t){this.decorations=Dt.of([]),this.view=t}},{decorations:t=>{const e=[],r=t.view.state.doc.iter();let n=r.next(),i=0;for(;!n.done;){if(n.value===`
|
|
144
|
+
`}})})}this.decorations=Ae.set(s,!0),setTimeout(()=>{r.dispatch({annotations:[RF.of(!0)]})},0)})}},{decorations:r=>r.decorations}),jF],RF=po.define(),AF=(t,e)=>{for(let r=0;r<t.length;r++)if(t[r]!==e.start[r])return!1;return!0};class MF extends bi{constructor(e,r,n){super(),this.id=e,this.color=r,this.username=n}eq(e){return e.id===this.id}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-json1-presence";const r=document.createElement("div");e.appendChild(r),r.style.borderLeft=`1px solid rgba(${this.color})`;const n=document.createElement("div");return n.className="remote-cursor-username",n.style.top="-20px",n.style.height="20px",n.style.width=`${this.username.length*12}px`,n.style.backgroundColor=`rgba(${this.color})`,n.style.color="black",n.appendChild(document.createTextNode(this.username)),e.appendChild(n),this.timeout=window.setTimeout(()=>{n.style.opacity="0.3"},2e3),e}ignoreEvent(){return!1}}const jF=$e.baseTheme({".cm-json1-presence":{position:"relative"},".cm-json1-presence > div":{position:"absolute",top:"0",bottom:"0",left:"0",right:"0"}}),j2=Fr.define({create:()=>null,update:(t,e)=>{for(const r of e.effects)if(r.is($v))return r.value;if(!t)return null;if(!e.changes.empty){const r=e.changes.mapPos(t.pos,-1,Xr.TrackDel),n=e.changes.mapPos(t.pos+t.text.length,-1,Xr.TrackDel);return r===null||n===null||e.newDoc.sliceString(r,n)!==t.text?null:Object.assign(Object.assign({},t),{pos:r})}return t},provide:t=>[$e.decorations.from(t,e=>{if(!e)return Ae.none;const r=e.pos,n=e.pos+e.text.length,i=e.rule.className;return Ae.set(DF({className:i}).range(r,n))}),$e.contentAttributes.from(t,e=>!e||!e.rule.cursor?{style:""}:{style:`cursor: ${e.rule.cursor}`})]}),$v=mt.define(),DF=t=>{var e;return Ae.mark({class:`cm-interact ${(e=t==null?void 0:t.className)!==null&&e!==void 0?e:""}`})},qF=$e.theme({".cm-interact":{background:"rgba(128, 128, 255, 0.2)",borderRadius:"4px"}}),D2=Ze.define(),q2=Ze.define({combine:t=>t[t.length-1]}),ZF=Jt.define(t=>({target:null,dragging:!1,mouseX:0,mouseY:0,getMatch(){const e=t.state.facet(D2),r=t.posAtCoords({x:this.mouseX,y:this.mouseY});if(!r)return null;const n=t.state.doc.lineAt(r),i=r-n.from;let o=null;for(const s of e)for(const a of n.text.matchAll(s.regexp)){if(a.index===void 0)continue;const l=a[0];if(!l)continue;const c=a.index,u=a.index+l.length;i<c||i>u||(!o||l.length<o.text.length)&&(o={rule:s,pos:n.from+c,text:l})}return o},updateText(e){return r=>{t.dispatch({effects:$v.of(Object.assign(Object.assign({},e),{text:r})),changes:{from:e.pos,to:e.pos+e.text.length,insert:r}})}},setTarget(e){this.target=e,t.dispatch({effects:$v.of(e)})},isModKeyDown(e){const r=t.state.facet(q2),n=!!window.navigator&&window.navigator.userAgent.includes("Macintosh");switch(r){case"alt":return e.altKey;case"shift":return e.shiftKey;case"ctrl":return e.ctrlKey;case"meta":return e.metaKey;case"mod":return n?e.metaKey:e.ctrlKey}throw new Error(`Invalid mod key: ${r}`)},update(e){const r=e.state.field(j2,!1);r!==void 0&&this.target!==r&&(this.target=r,r===null&&this.endDrag())},startDrag(e){this.dragging||this.target&&(this.dragging=!0,this.target.rule.onDragStart&&this.target.rule.onDragStart(this.target.text,this.updateText(this.target),e))},endDrag(){var e;this.dragging&&(this.dragging=!1,!((e=this.target)===null||e===void 0)&&e.rule.onDragEnd&&this.target.rule.onDragEnd(this.target.text,this.updateText(this.target)))}}),{eventHandlers:{mousedown(t,e){this.isModKeyDown(t)&&this.target&&(t.preventDefault(),this.target.rule.onClick&&this.target.rule.onClick(this.target.text,r=>{this.target&&this.updateText(this.target)(r)},t),this.target.rule.onDrag&&this.startDrag(t))},mousemove(t,e){if(this.mouseX=t.clientX,this.mouseY=t.clientY,!this.isModKeyDown(t)){this.target&&this.setTarget(null);return}this.target&&this.dragging?this.target.rule.onDrag&&this.target.rule.onDrag(this.target.text,this.updateText(this.target),t):this.setTarget(this.getMatch())},mouseup(t,e){this.endDrag(),this.target&&!this.isModKeyDown(t)&&this.setTarget(null),this.isModKeyDown(t)&&this.setTarget(this.getMatch())},mouseleave(t,e){this.endDrag(),this.target&&this.setTarget(null)},keydown(t,e){!this.target&&this.isModKeyDown(t)&&this.setTarget(this.getMatch())},keyup(t,e){this.target&&!this.isModKeyDown(t)&&(this.endDrag(),this.setTarget(null))}}}),NF=(t={})=>{var e,r;return[j2,qF,ZF,q2.of((e=t.key)!==null&&e!==void 0?e:"alt"),((r=t.rules)!==null&&r!==void 0?r:[]).map(n=>D2.of(n))]},Z2=/#[0-9A-Fa-f]{6}/g,WF=({onInteract:t,customInteractRules:e})=>{const r=[{regexp:Z2,cursor:"pointer",onClick(n,i){const o=n,s=document.createElement("input");s.type="color",s.value=o.toLowerCase();const a=o.toUpperCase()===o,l=c=>{const u=c.target;t&&t(),u.value&&i(a?u.value.toUpperCase():u.value)};s.addEventListener("input",l),s.click()}},{regexp:new RegExp("(?<!\\#)-?\\b\\d+\\.?\\d*\\b","g"),cursor:"ew-resize",onDrag:(n,i,o)=>{t&&t();const s=Number(n)+o.movementX;isNaN(s)||i(s.toString())}},{regexp:/true|false/g,cursor:"pointer",onClick:(n,i)=>{switch(t&&t(),n){case"true":return i("false");case"false":return i("true")}}},{regexp:/vec2\(-?\b\d+\.?\d*\b\s*(,\s*-?\b\d+\.?\d*\b)?\)/g,cursor:"move",onDrag:(n,i,o)=>{var c,u;const s=/vec2\((?<x>-?\b\d+\.?\d*\b)\s*(,\s*(?<y>-?\b\d+\.?\d*\b))?\)/.exec(n),a=Number((c=s==null?void 0:s.groups)==null?void 0:c.x);let l=Number((u=s==null?void 0:s.groups)==null?void 0:u.y);isNaN(a)||(isNaN(l)&&(l=a),i(`vec2(${a+o.movementX}, ${l-o.movementY})`))}},{regexp:/rgb\(.*\)/g,cursor:"pointer",onClick:(n,i,o)=>{var h,d,p;const s=/rgb\((?<r>\d+)\s*,\s*(?<g>\d+)\s*,\s*(?<b>\d+)\)/.exec(n),a=Number((h=s==null?void 0:s.groups)==null?void 0:h.r),l=Number((d=s==null?void 0:s.groups)==null?void 0:d.g),c=Number((p=s==null?void 0:s.groups)==null?void 0:p.b),u=document.createElement("input");u.type="color",isNaN(a+l+c)||(u.value=BF(a,l,c));const f=O=>{const m=O.target;if(t&&t(),m.value){const[y,g,v]=IF(m.value);i(`rgb(${y}, ${g}, ${v})`)}u.removeEventListener("change",f)};u.addEventListener("change",f),u.click()}},{regexp:/https?:\/\/[^ ")]+/g,cursor:"pointer",onClick:n=>{window.open(n)}},{regexp:/rotate\(-?\d*\.?\d*\)/g,cursor:"move",onDragStart(n,i,o){ra={x:o.clientX,y:o.clientY}},onDrag(n,i,o){if(ra==null)return;const s=Math.round(Math.atan2(ra.y-o.clientY,o.clientX-ra.x)*180/Math.PI);i(`rotate(${s})`);const a=new CustomEvent("updateRotateDrag",{detail:s});document.dispatchEvent(a)},onDragEnd(){ra=null}}];return e&&r.push(...e),NF({rules:r})};let ra=null;const IF=t=>{const e=parseInt(t.substring(1),16);return[e>>16&255,e>>8&255,e&255]},BF=(t,e,r)=>"#"+t.toString(16)+e.toString(16)+r.toString(16),LF=$e.baseTheme({".color-circle-parent":{display:"inline-block",cursor:"inherit"}}),VF=[Jt.fromClass(class{constructor(t){this.decorations=Dt.of([]),this.view=t}},{decorations:t=>{const e=[],r=t.view.state.doc.iter();let n=r.next(),i=0;for(;!n.done;){if(n.value===`
|
|
145
145
|
`){i++,n=r.next();continue}const o=n.value.matchAll(Z2);let s=o.next();for(;!s.done;){const a=s.value;a.index+=i,e.push(a),s=o.next()}i+=n.value.length,n=r.next()}return Ae.set(e.map(o=>({from:o.index+7,to:o.index+7,value:Ae.widget({side:-1,widget:new XF(o[0])})})))}}),LF];class XF extends bi{constructor(e){super(),this.color=e}eq(e){return e.color===this.color}toDOM(){const e=document.createElement("div"),r=20,n=14;e.setAttribute("style",`width:${r}px;height:${r}px`),e.className="color-circle-parent";const i=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=document.createElementNS("http://www.w3.org/2000/svg","circle");return o.setAttributeNS(null,"fill",this.color.replace(/["']/g,"")),o.setAttributeNS(null,"r",""+n/2),o.setAttributeNS(null,"cx",""+r/2),o.setAttributeNS(null,"cy",""+(r/2-1)),i.setAttributeNS(null,"width",""+r),i.setAttributeNS(null,"height",""+r),i.appendChild(o),e.appendChild(i),e}ignoreEvent(){return!1}}const YF=Jt.fromClass(class{constructor(t){this.showHighlight=!1,this.view=t}},{decorations:t=>{if(!t.showHighlight)return Ae.none;const e=[],r=t.view.state.doc.iter();let n=r.next(),i=0;for(;!n.done;){if(n.value===`
|
|
146
146
|
`){i++,n=r.next();continue}const o=n.value.matchAll(new RegExp('\\"\\#([0-9]|[A-F]|[a-f]){6}\\"|rotate\\(-?\\d*\\.?\\d*\\)|https?:\\/\\/[^ "]+|vec2\\(-?\\b\\d+\\.?\\d*\\b\\s*(,\\s*-?\\b\\d+\\.?\\d*\\b)?\\)|true|false|(?<!\\#)-?\\b\\d+\\.?\\d*\\b|rgb\\(.*\\)',"dg"));let s=o.next();for(;!s.done;){const a=s.value;a.indices[0][0]+=i,a.indices[0][1]+=i,e.push(a),s=o.next()}i+=n.value.length,n=r.next()}return Ae.set(e.map(o=>({from:o.indices[0][0],to:o.indices[0][1],value:Ae.mark({class:"cm-interact "})})))},eventHandlers:{keydown(t,e){t.key=="Alt"&&(this.showHighlight=!0)},keyup(t,e){t.key=="Alt"&&(this.showHighlight=!1)}}}),UF=Jt.fromClass(class{constructor(t){this.view=t,this.textPosition=null,this.rotation=0,document.addEventListener("updateRotateDrag",e=>{this.textPosition=this.view.posAtCoords(ra,!1),this.rotation=e.detail})}},{decorations:t=>ra===null?Ae.none:Ae.set([{from:t.textPosition,to:t.textPosition,value:Ae.widget({side:-1,widget:new FF(t.rotation)})}])});class FF extends bi{constructor(e){super(),this.angle=e}toDOM(e){const r=document.createElement("div");r.setAttribute("style","width:20px;height:20px"),r.className="color-circle-parent";const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),i=document.createElementNS("http://www.w3.org/2000/svg","circle");i.setAttributeNS(null,"fill","#808080"),i.setAttributeNS(null,"r","5"),i.setAttributeNS(null,"cx","5"),i.setAttributeNS(null,"cy","5");const o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttributeNS(null,"x1","10"),o.setAttributeNS(null,"x2","5"),o.setAttributeNS(null,"y1","5"),o.setAttributeNS(null,"y2","5"),o.setAttributeNS(null,"stroke","black"),o.setAttributeNS(null,"transform",`rotate(${360-this.angle},5,5)`),n.setAttributeNS(null,"viewBox","0 0 10 10"),n.setAttributeNS(null,"width","20"),n.setAttributeNS(null,"height","20"),n.appendChild(i),n.appendChild(o),r.appendChild(n),r}ignoreEvent(){return!1}}const L1=()=>(Math.random()+"").slice(2),zF=({typeScriptWorker:t,fileName:e})=>async n=>{const i=L1(),o=n.state.doc.toString(),s={event:"autocomplete-request",fileName:e,fileContent:o,position:n.pos,requestId:i},a=o[n.pos-1];if(['"',"'",";","(",")","{",","," ","=","<",">"].includes(a))return{from:n.pos,options:[]};t.postMessage(s);const l=await new Promise(f=>{t.onmessage=h=>{const d=h.data,{event:p,requestId:O,completions:m}=d;p==="post-completions"&&O===O&&f(m)}});if(!l)return{from:n.pos,options:[]};const c=n.matchBefore(/\w*/).from,u=n.matchBefore(/\w*/).text;return u&&(l.entries=l.entries.filter(f=>f.name.startsWith(u))),{from:n.pos,options:l.entries.map(f=>({label:f.name,apply:h=>{const d=n.pos+f.name.length-u.length;h.dispatch({changes:{from:c,to:n.pos,insert:f.name},selection:{anchor:d,head:d}})}}))}},GF=({typeScriptWorker:t,fileName:e,shareDBDoc:r,fileId:n,allowGlobals:i})=>async()=>{const o=L1(),s=r.data.files[n].text,a={event:"lint-request",fileName:e,fileContent:s,requestId:o,allowGlobals:i};return t.postMessage(a),await new Promise(c=>{t.onmessage=u=>{const f=u.data,{event:h,requestId:d,tsErrors:p}=f;h==="post-error-linter"&&d===d&&c(p)}})},HF=[EZ(),RZ(),Kq(),OV(),Iq(),Yq(),jt.allowMultipleSelections.of(!0),hN(),F0(_N,{fallback:!0}),AN(),GX(),iA({defaultKeymap:!1}),cZ(),dZ(),iZ(),GV()],KF=!0,yd=()=>R1({jsx:!0,typescript:!0}),JF={json:PU,tsx:yd,js:yd,jsx:yd,ts:yd,html:YA,css:A1,md:lF,svelte:yU},$_=(t,e)=>{let r=t;for(const n of e){if(!r)return;r=r[n]}return r},e6=({fileId:t,shareDBDoc:e,content:r,filesPath:n,localPresence:i,docPresence:o,theme:s,onInteract:a,editorCache:l,usernameRef:c,typeScriptWorker:u,customInteractRules:f,allowGlobals:h})=>{if(l.has(t))return l.get(t);const d=[...n,t,"text"],p=[...n,t,"name"],O=$_(r,d),m=$_(r,p),y=m.split(".").pop();let g=new Bl;const v=[];e?(v.push(hF({shareDBDoc:e,path:d,json1:b0,textUnicode:UQ})),i&&v.push(PF({path:d,localPresence:i,usernameRef:c})),o&&v.push(TF({path:d,docPresence:o}))):v.push($e.editable.of(!1)),v.push(VF),v.push(HF),v.push(g.of(zC[s].value));const S=new Bl,_=(k=>{const x=JF[k];return x?x():void 0})(y);_?v.push(S.of(_)):v.push(S.of([])),v.push(WF({onInteract:a,customInteractRules:f})),v.push(YF),v.push(UF),v.push(iA({override:[zF({typeScriptWorker:u,fileName:m})]})),e&&KF&&v.push(m4(GF({typeScriptWorker:u,fileName:m,shareDBDoc:e,fileId:t,allowGlobals:h}))),v.push(yF({colors:{light:"#4d586b",dark:"#4d586b",activeLight:"#8e949f",activeDark:"#8e949f"}})),v.push(Of.of(bF.map(k=>(k.key==="Enter"&&delete k.shift,k))));const b={editor:new $e({state:jt.create({doc:O,extensions:v})}),themeCompartment:g};return l.set(t,b),b},Q_=["files"],t6=({customInteractRules:t,allowGlobals:e})=>{const{activeFileId:r,shareDBDoc:n,content:i,submitOperation:o,localPresence:s,docPresence:a,username:l,editorCache:c,editorWantsFocus:u,editorNoLongerWantsFocus:f,typeScriptWorker:h,theme:d}=q.useContext(fn),p=q.useRef(null),O=q.useRef(null),m=q.useCallback(()=>{O.current?clearTimeout(O.current):o(v=>({...v,isInteracting:!0})),O.current=setTimeout(()=>{O.current=null,o(({isInteracting:v,...S})=>S)},800)},[o]),y=q.useRef(l);y.current=l;const g=q.useMemo(()=>e6({fileId:r,shareDBDoc:n,content:i,filesPath:Q_,localPresence:s,docPresence:a,theme:d,onInteract:m,editorCache:c,usernameRef:y,typeScriptWorker:h,customInteractRules:t,allowGlobals:e}),[r,n,Q_,s,a,d,m,c,y,h]);return q.useLayoutEffect(()=>{if(p.current&&i)return p.current.appendChild(g.editor.dom),()=>{p.current.removeChild(g.editor.dom)}},[n,g]),q.useLayoutEffect(()=>{u&&(g.editor.focus(),f())},[u,g,f]),W.jsx("div",{className:"vz-code-editor",ref:p})},r6=({errorMessage:t,content:e})=>{const[r,n]=q.useState(!0);q.useEffect(()=>{t!==null&&n(!0)},[t]);const i=q.useCallback(()=>{n(!1)},[]);return q.useEffect(()=>{const o=s=>{s.key==="Escape"&&i()};return document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("keydown",o,!0)}},[i]),r&&t!==null?W.jsxs("div",{className:"vz-code-error-overlay",children:[W.jsx("pre",{children:t}),W.jsx("i",{className:"icon-button icon-button-dark error-dismiss-button",onClick:i,children:W.jsx(lR,{})})]}):null},E_=t=>{const[e]=t.split("-");return parseInt(e,36)},n6=(t,e)=>{const r=E_(t),n=E_(e);return r>n},i6=(t,e,r,n)=>{r.current.has(t)?r.current.set(t,e):(r.current.set(t,e),n(i=>[...i,{user:e,join:!0,presenceId:t}]))},o6=(t,e,r)=>{const n=e.current.get(t);n&&(e.current.delete(t),r(i=>[...i,{user:n,join:!1,presenceId:t}]))},s6=({docPresence:t,localPresence:e})=>{const[r,n]=q.useState([]),i=q.useRef(new Map);return q.useEffect(()=>{if(t){const o=(s,a)=>{var c;const l=a!==null;if(n6(s,e.presenceId)){if(l){const f=(c=t.remotePresences[s])==null?void 0:c.username;i6(s,f,i,n)}else o6(s,i,n);const u=setTimeout(()=>{n(f=>f.slice(1))},5e3);return()=>{clearTimeout(u)}}};return t.on("receive",o),()=>{t.off("receive",o)}}},[t,e]),r.length>0?W.jsx("div",{className:"vz-notification",children:r.map(({user:o,join:s,presenceId:a})=>W.jsx("div",{className:"vz-notification-item",children:s?`${o} has joined the session.`:`${o} has left the session.`},a))}):null},a6=100,l6=2e3,u6=(t,e=!0)=>{var i,o;const r=(i=t.name)==null?void 0:i.substring(0,a6).trim(),n=(e?(o=t.text)==null?void 0:o.substring(0,l6):t.text).trim();return["`"+r+"`:","```",n,"```"].join(`
|
|
147
|
-
`)},c6="/ai-assist",f6=async({view:t,shareDBDoc:e,fileId:r,tabList:n,aiAssistEndpoint:i=c6,aiAssistOptions:o={},aiStreamId:s})=>{const a=e.data.files[r].name,l=t.state.sliceDoc(0,t.state.selection.main.from),c=t.state.sliceDoc(t.state.selection.main.to),u=l+"<FILL_ME>"+c,f={name:a,text:u},h=t.state.selection.main.to;let d=u6(f,!1);const O=await(await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,inputText:d,fileId:r,insertionCursor:h,aiStreamId:s})})).json();O.error&&console.error("[startAIAssist] error from server:",O.error)},h6=[{x:40,y:0,r:4},{x:28.28,y:28.28,r:4.85},{x:0,y:40,r:5.71},{x:-28.29,y:28.28,r:6.57},{x:-40,y:0,r:7.42},{x:-28.29,y:-28.29,r:8.28},{x:-.01,y:-40,r:9.14},{x:28.28,y:-28.29,r:10}],d6=({height:t=40,fill:e="currentcolor",fadeIn:r=!0})=>{const[n,i]=q.useState(!1);return q.useEffect(()=>{i(!0)},[]),n&&W.jsx("div",{className:`vh-spinner${r?" fade-in":""}`,children:W.jsx("svg",{height:t,viewBox:"0 0 100 100",style:{opacity:1},children:W.jsx("g",{transform:"translate(50, 50)",fill:e,children:W.jsx("g",{className:"vh-spinner-dots",children:h6.map(({x:o,y:s,r:a},l)=>W.jsx("circle",{cx:o,cy:s,r:a},l))})})})})},p6=({aiAssistEndpoint:t,aiAssistOptions:e,aiAssistTooltipText:r="Start AI Assist",aiAssistClickOverride:n})=>{const{shareDBDoc:i,activeFileId:o,tabList:s,editorCache:a}=q.useContext(fn),[l,c]=q.useState(null),{runPrettierRef:u,runCodeRef:f}=q.useContext(fn),h=q.useCallback(async()=>{if(!(l!==null)){const O=L1();c(O),await f6({view:a.get(o).editor,shareDBDoc:i,fileId:o,tabList:s,aiStreamId:O,aiAssistEndpoint:t,aiAssistOptions:e}),await new Promise(g=>setTimeout(g,1e3));const m=u.current;m!==null&&m();const y=f.current;y!==null&&y(),c(g=>g===O?null:g)}},[o,l]),d=l===null;return W.jsx("div",{className:"vz-code-ai-assist-widget",children:l?W.jsx(d6,{}):d&&W.jsx(zl,{placement:"left",overlay:W.jsx(Fl,{id:"ai-assist-widget-tooltip",children:r}),children:W.jsx("i",{className:"icon-button icon-button-dark",onClick:n||h,children:W.jsx(I3,{})})})})},O6=({runCodeWidgetTooltipText:t=W.jsxs(W.Fragment,{children:[W.jsx("strong",{children:"Run Code"}),W.jsx("div",{children:"(Shift + Enter or Ctrl + s)"})]})})=>{const{runCodeRef:e,runPrettierRef:r}=q.useContext(fn),n=q.useCallback(()=>{const i=r.current;i!==null&&i();const o=e.current;o!==null&&o()},[]);return W.jsx("div",{className:"vz-code-run-code-widget",children:W.jsx(zl,{placement:"left",overlay:W.jsx(Fl,{id:"run-code-widget-tooltip",children:t}),children:W.jsx("i",{className:"icon-button icon-button-dark",onClick:n,children:W.jsx(U3,{})})})})},g6=({enableAIAssist:t=!0,aiAssistEndpoint:e,aiAssistOptions:r,aiAssistTooltipText:n,aiAssistClickOverride:i,customInteractRules:o,allowGlobals:s=!1})=>{const{codeEditorWidth:a}=q.useContext(wO),{content:l,localPresence:c,docPresence:u,activeFileId:f,errorMessage:h}=q.useContext(fn),[d,p]=q.useState(!1);return q.useEffect(()=>{p(!0)},[]),f!==null?W.jsxs("div",{className:"middle",style:{width:a+"px"},children:[W.jsx(iV,{}),d&&l&&f&&W.jsx(t6,{customInteractRules:o,allowGlobals:s}),d&&t&&l&&f?W.jsx(p6,{aiAssistEndpoint:e,aiAssistOptions:r,aiAssistTooltipText:n,aiAssistClickOverride:i}):null,W.jsx(O6,{}),W.jsx(r6,{errorMessage:h,content:l}),W.jsx(s6,{docPresence:u,localPresence:c})]}):null},m6=()=>W.jsx("div",{className:"right",children:null}),y6=new gj,v6=new mj;XQ.types.register(b0.type);const{Connection:w6}=XQ,S6=window.location.protocol==="https:"?"wss://":"ws://",b6=new WebSocket(S6+window.location.host+"/ws"),P6=new w6(b6),k6=()=>{const{username:t}=q.useContext(fn);return QI(t),null};function x6(){const{shareDBDoc:t,content:e,localPresence:r,docPresence:n,submitOperation:i,connected:o}=j7({connection:P6}),s=$I();return W.jsx(bj,{children:W.jsxs(bI,{content:e,shareDBDoc:t,submitOperation:i,localPresence:r,docPresence:n,prettierWorker:y6,typeScriptWorker:v6,initialUsername:s,connected:o,children:[W.jsxs("div",{className:"app",children:[W.jsx(tV,{}),W.jsx(g6,{}),W.jsx(m6,{}),W.jsx(Wb,{side:"left"}),W.jsx(Wb,{side:"right"})]}),W.jsx(k6,{})]})})}LQ(document.getElementById("root")).render(W.jsx(pI,{children:W.jsx(x6,{})}));
|
|
147
|
+
`)},c6="/ai-assist",f6=async({view:t,shareDBDoc:e,fileId:r,tabList:n,aiAssistEndpoint:i=c6,aiAssistOptions:o={},aiStreamId:s})=>{const a=e.data.files[r].name,l=t.state.sliceDoc(0,t.state.selection.main.from),c=t.state.sliceDoc(t.state.selection.main.to),u=l+"<FILL_ME>"+c,f={name:a,text:u},h=t.state.selection.main.to;let d=u6(f,!1);const O=await(await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,inputText:d,fileId:r,insertionCursor:h,aiStreamId:s})})).json();O.error&&console.error("[startAIAssist] error from server:",O.error)},h6=[{x:40,y:0,r:4},{x:28.28,y:28.28,r:4.85},{x:0,y:40,r:5.71},{x:-28.29,y:28.28,r:6.57},{x:-40,y:0,r:7.42},{x:-28.29,y:-28.29,r:8.28},{x:-.01,y:-40,r:9.14},{x:28.28,y:-28.29,r:10}],d6=({height:t=40,fill:e="currentcolor",fadeIn:r=!0})=>{const[n,i]=q.useState(!1);return q.useEffect(()=>{i(!0)},[]),n&&W.jsx("div",{className:`vh-spinner${r?" fade-in":""}`,children:W.jsx("svg",{height:t,viewBox:"0 0 100 100",style:{opacity:1},children:W.jsx("g",{transform:"translate(50, 50)",fill:e,children:W.jsx("g",{className:"vh-spinner-dots",children:h6.map(({x:o,y:s,r:a},l)=>W.jsx("circle",{cx:o,cy:s,r:a},l))})})})})},p6=({aiAssistEndpoint:t,aiAssistOptions:e,aiAssistTooltipText:r="Start AI Assist",aiAssistClickOverride:n})=>{const{shareDBDoc:i,activeFileId:o,tabList:s,editorCache:a}=q.useContext(fn),[l,c]=q.useState(null),{runPrettierRef:u,runCodeRef:f}=q.useContext(fn),h=q.useCallback(async()=>{if(!(l!==null)){const O=L1();c(O),await f6({view:a.get(o).editor,shareDBDoc:i,fileId:o,tabList:s,aiStreamId:O,aiAssistEndpoint:t,aiAssistOptions:e}),await new Promise(g=>setTimeout(g,1e3));const m=u.current;m!==null&&m();const y=f.current;y!==null&&y(),c(g=>g===O?null:g)}},[o,l]),d=l===null;return W.jsx("div",{className:"vz-code-ai-assist-widget",children:l?W.jsx(d6,{}):d&&W.jsx(zl,{placement:"left",overlay:W.jsx(Fl,{id:"ai-assist-widget-tooltip",children:r}),children:W.jsx("i",{className:"icon-button icon-button-dark",onClick:n||h,children:W.jsx(I3,{})})})})},O6=({runCodeWidgetTooltipText:t=W.jsxs(W.Fragment,{children:[W.jsx("strong",{children:"Run Code"}),W.jsx("div",{children:"(Shift + Enter or Ctrl + s)"})]})})=>{const{runCodeRef:e,runPrettierRef:r}=q.useContext(fn),n=q.useCallback(()=>{const i=r.current;i!==null&&i();const o=e.current;o!==null&&o()},[]);return W.jsx("div",{className:"vz-code-run-code-widget",children:W.jsx(zl,{placement:"left",overlay:W.jsx(Fl,{id:"run-code-widget-tooltip",children:t}),children:W.jsx("i",{className:"icon-button icon-button-dark",onClick:n,children:W.jsx(U3,{})})})})},g6=({enableAIAssist:t=!0,aiAssistEndpoint:e,aiAssistOptions:r,aiAssistTooltipText:n,aiAssistClickOverride:i,customInteractRules:o,allowGlobals:s=!1})=>{const{codeEditorWidth:a}=q.useContext(wO),{content:l,localPresence:c,docPresence:u,activeFileId:f,errorMessage:h}=q.useContext(fn),[d,p]=q.useState(!1);return q.useEffect(()=>{p(!0)},[]),f!==null?W.jsxs("div",{className:"middle",style:{width:a+"px"},children:[W.jsx(iV,{}),d&&l&&f&&W.jsx(t6,{customInteractRules:o,allowGlobals:s}),d&&t&&l&&f?W.jsx(p6,{aiAssistEndpoint:e,aiAssistOptions:r,aiAssistTooltipText:n,aiAssistClickOverride:i}):null,W.jsx(O6,{}),W.jsx(r6,{errorMessage:h,content:l}),W.jsx(s6,{docPresence:u,localPresence:c})]}):null},m6=()=>W.jsx("div",{className:"right",children:null}),y6=new gj,v6=new mj;XQ.types.register(b0.type);const{Connection:w6}=XQ,S6=window.location.protocol==="https:"?"wss://":"ws://",b6=new WebSocket(S6+window.location.host+"/ws"),P6=new w6(b6),k6=()=>{const{username:t}=q.useContext(fn);return QI(t),null};function x6(){const{shareDBDoc:t,content:e,localPresence:r,docPresence:n,submitOperation:i,connected:o}=j7({connection:P6}),s=$I();return W.jsx(bj,{children:W.jsxs(bI,{content:e,shareDBDoc:t,submitOperation:i,localPresence:r,docPresence:n,prettierWorker:y6,typeScriptWorker:v6,initialUsername:s,connected:o,children:[W.jsxs("div",{className:"app",children:[W.jsx(tV,{}),W.jsx(g6,{allowGlobals:!0}),W.jsx(m6,{}),W.jsx(Wb,{side:"left"}),W.jsx(Wb,{side:"right"})]}),W.jsx(k6,{})]})})}LQ(document.getElementById("root")).render(W.jsx(pI,{children:W.jsx(x6,{})}));
|
package/dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-CnHJy69d.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-J8-kRnnE.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/package.json
CHANGED
package/src/client/App/index.tsx
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
// TODO move back to this way of importing when this PR is merged:
|
|
2
|
-
// https://github.com/replit/codemirror-interact/pull/19/files
|
|
3
1
|
import interact, {
|
|
4
2
|
InteractRule,
|
|
5
3
|
} from '@replit/codemirror-interact';
|
|
6
|
-
// import interact, {
|
|
7
|
-
// InteractRule,
|
|
8
|
-
// } from './codemirror-interact';
|
|
9
4
|
|
|
10
5
|
import {
|
|
11
6
|
ViewPlugin,
|
|
@@ -58,6 +53,7 @@ export const widgets = ({
|
|
|
58
53
|
const updateHex = (e: Event) => {
|
|
59
54
|
const el: HTMLInputElement =
|
|
60
55
|
e.target as HTMLInputElement;
|
|
56
|
+
if (onInteract) onInteract();
|
|
61
57
|
if (el.value) {
|
|
62
58
|
setText(
|
|
63
59
|
valueIsUpper
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
|
|
3
|
+
export const compilerOptions: ts.CompilerOptions = {
|
|
4
|
+
lib: ['dom', 'esnext'],
|
|
5
|
+
|
|
6
|
+
// Disable warnings around "Any type".
|
|
7
|
+
noImplicitAny: false,
|
|
8
|
+
|
|
9
|
+
// Disable warnings around "Implicit any in parameter".
|
|
10
|
+
noImplicitThis: false,
|
|
11
|
+
|
|
12
|
+
// Allow JavaScript files to be processed
|
|
13
|
+
allowJs: true,
|
|
14
|
+
|
|
15
|
+
// Disable type checking for JavaScript files
|
|
16
|
+
// checkJs: false,
|
|
17
|
+
|
|
18
|
+
// Skip type checking of declaration files
|
|
19
|
+
skipLibCheck: true,
|
|
20
|
+
|
|
21
|
+
// Support React JSX
|
|
22
|
+
jsx: ts.JsxEmit.React,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Be less aggressive for non-TS files,
|
|
26
|
+
// e.g. files that end in .js or .jsx.
|
|
27
|
+
// if (!isTS(fileName)) {
|
|
28
|
+
// This code is for errors like:
|
|
29
|
+
// "Binding element 'data' implicitly has an 'any' type."
|
|
30
|
+
const LINT_ERROR_CODE_ANY = 7031;
|
|
31
|
+
|
|
32
|
+
// This code is for errors like:
|
|
33
|
+
// "Parameter 'selection' implicitly has an 'any' type.""
|
|
34
|
+
const LINT_ERROR_CODE_ANY_PARAM = 7006;
|
|
35
|
+
|
|
36
|
+
// This code is for errors like:
|
|
37
|
+
// "Cannot find module 'd3' or its corresponding type declarations."
|
|
38
|
+
const LINT_ERROR_CODE_IMPORT = 2307;
|
|
39
|
+
|
|
40
|
+
// This code is for errors like:
|
|
41
|
+
// "Variable 'mic' implicitly has type 'any' in some locations where its type cannot be determined."
|
|
42
|
+
const LINT_ERROR_CODE_ANY_TYPE = 7034;
|
|
43
|
+
|
|
44
|
+
// "Element implicitly has an 'any' type because expression
|
|
45
|
+
// of type '"test"' can't be used to index type '{}'."
|
|
46
|
+
const LINT_ERROR_CODE_ANY_TYPE_KEYS = 7053;
|
|
47
|
+
|
|
48
|
+
// "Property 'id' does not exist on type { ... }"
|
|
49
|
+
// Happens on objects with dynamic keys.
|
|
50
|
+
// Not valid in TypeScript, but common in JavaScript.
|
|
51
|
+
const LINT_ERROR_CODE_NON_EXISTENT_PROPERTY = 2339;
|
|
52
|
+
|
|
53
|
+
// "Type 'Set<unknown>' can only be iterated through when using the '--downlevelIteration'
|
|
54
|
+
// flag or with a '--target' of 'es2015' or higher."
|
|
55
|
+
const LINT_ERROR_CODE_ITERATED_THROUGH = 2802;
|
|
56
|
+
|
|
57
|
+
// Argument of type '{ Month: string; High: number; Temp: number; Low: number; }'
|
|
58
|
+
// is not assignable to parameter of type 'never'.
|
|
59
|
+
const LINT_ERROR_CODE_ASSIGNABLE_TO_NEVER = 2345;
|
|
60
|
+
|
|
61
|
+
// Cannot find name 'd3'.
|
|
62
|
+
export const LINT_ERROR_CODE_CANNOT_FIND_NAME = 2304;
|
|
63
|
+
|
|
64
|
+
export const excludedErrorCodes = new Set([
|
|
65
|
+
LINT_ERROR_CODE_ANY,
|
|
66
|
+
LINT_ERROR_CODE_IMPORT,
|
|
67
|
+
LINT_ERROR_CODE_ANY_PARAM,
|
|
68
|
+
LINT_ERROR_CODE_ANY_TYPE,
|
|
69
|
+
LINT_ERROR_CODE_ANY_TYPE_KEYS,
|
|
70
|
+
LINT_ERROR_CODE_NON_EXISTENT_PROPERTY,
|
|
71
|
+
LINT_ERROR_CODE_ITERATED_THROUGH,
|
|
72
|
+
LINT_ERROR_CODE_ASSIGNABLE_TO_NEVER,
|
|
73
|
+
]);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getTSFileName } from './getTSFileName';
|
|
2
|
+
import { isTS } from './isTS';
|
|
3
|
+
import {
|
|
4
|
+
AutocompleteRequest,
|
|
5
|
+
AutocompleteResponse,
|
|
6
|
+
} from './requestTypes';
|
|
7
|
+
|
|
8
|
+
// This function is called when the worker receives a message with the type
|
|
9
|
+
// 'autocomplete-request'. It gets completions at the specified position in the
|
|
10
|
+
// file and sends them back to the main thread.
|
|
11
|
+
export const handleMessageAutocompleteRequest = async ({
|
|
12
|
+
debug,
|
|
13
|
+
data,
|
|
14
|
+
env,
|
|
15
|
+
setFile,
|
|
16
|
+
}) => {
|
|
17
|
+
if (debug) {
|
|
18
|
+
console.log('autocomplete-request message received');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Should not happen.
|
|
22
|
+
if (env === null) {
|
|
23
|
+
console.log('env is null');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Example of `data`:
|
|
28
|
+
// {
|
|
29
|
+
// "event": "autocomplete-request",
|
|
30
|
+
// "pos": 8,
|
|
31
|
+
// "location": "index.js",
|
|
32
|
+
// "requestId": "0.9090605799171392"
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
const autocompleteRequest: AutocompleteRequest = data;
|
|
36
|
+
const { fileName, fileContent, position, requestId } =
|
|
37
|
+
autocompleteRequest;
|
|
38
|
+
|
|
39
|
+
const tsFileName = getTSFileName(fileName);
|
|
40
|
+
|
|
41
|
+
let completions = null;
|
|
42
|
+
if (isTS(tsFileName) && fileContent !== '') {
|
|
43
|
+
// Update the file in the file system to the
|
|
44
|
+
// absolute latest version. This is critical
|
|
45
|
+
// for correct completions.
|
|
46
|
+
setFile(tsFileName, fileContent);
|
|
47
|
+
|
|
48
|
+
completions =
|
|
49
|
+
env.languageService.getCompletionsAtPosition(
|
|
50
|
+
tsFileName,
|
|
51
|
+
position,
|
|
52
|
+
{},
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const autocompleteResponse: AutocompleteResponse = {
|
|
57
|
+
event: 'post-completions',
|
|
58
|
+
completions,
|
|
59
|
+
requestId,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
postMessage(autocompleteResponse);
|
|
63
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { Diagnostic } from '@codemirror/lint';
|
|
3
|
+
import {
|
|
4
|
+
LinterRequest,
|
|
5
|
+
LinterResponse,
|
|
6
|
+
} from './requestTypes';
|
|
7
|
+
import { getTSFileName } from './getTSFileName';
|
|
8
|
+
import { isTS } from './isTS';
|
|
9
|
+
import {
|
|
10
|
+
LINT_ERROR_CODE_CANNOT_FIND_NAME,
|
|
11
|
+
excludedErrorCodes,
|
|
12
|
+
} from './constants';
|
|
13
|
+
|
|
14
|
+
// Inspired by: https://stackblitz.com/edit/codemirror-6-typescript?file=client%2Findex.ts%3AL44-L44
|
|
15
|
+
const convertToCodeMirrorDiagnostic = (
|
|
16
|
+
tsErrors: ts.Diagnostic[],
|
|
17
|
+
): Array<Diagnostic> =>
|
|
18
|
+
tsErrors.map((tsError: ts.Diagnostic) => ({
|
|
19
|
+
from: tsError.start,
|
|
20
|
+
to: tsError.start + tsError.length,
|
|
21
|
+
severity: 'error',
|
|
22
|
+
message:
|
|
23
|
+
typeof tsError.messageText === 'string'
|
|
24
|
+
? tsError.messageText
|
|
25
|
+
: tsError.messageText.messageText,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
export const handleMessageLintRequest = async ({
|
|
29
|
+
debug,
|
|
30
|
+
data,
|
|
31
|
+
env,
|
|
32
|
+
setFile,
|
|
33
|
+
}) => {
|
|
34
|
+
if (debug) {
|
|
35
|
+
console.log('Lint Request');
|
|
36
|
+
}
|
|
37
|
+
const linterRequest: LinterRequest = data;
|
|
38
|
+
const { fileName, fileContent, requestId, allowGlobals } =
|
|
39
|
+
linterRequest;
|
|
40
|
+
|
|
41
|
+
const tsFileName = getTSFileName(fileName);
|
|
42
|
+
let tsErrors = [];
|
|
43
|
+
if (isTS(tsFileName) && fileContent !== '') {
|
|
44
|
+
// We are updating the server with the latest content
|
|
45
|
+
// when we autocomplete, so it's always up to date.
|
|
46
|
+
setFile(tsFileName, fileContent);
|
|
47
|
+
|
|
48
|
+
// Creates an array of diagnostic objects containing
|
|
49
|
+
// both semantic and syntactic diagnostics.
|
|
50
|
+
tsErrors = env.languageService
|
|
51
|
+
.getSemanticDiagnostics(tsFileName)
|
|
52
|
+
.concat(
|
|
53
|
+
env.languageService.getSyntacticDiagnostics(
|
|
54
|
+
tsFileName,
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (debug) {
|
|
59
|
+
console.log('tsErrors');
|
|
60
|
+
console.log(tsErrors);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
tsErrors = tsErrors.filter(
|
|
64
|
+
(error: { code: number }) => {
|
|
65
|
+
if (
|
|
66
|
+
allowGlobals &&
|
|
67
|
+
error.code === LINT_ERROR_CODE_CANNOT_FIND_NAME
|
|
68
|
+
) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return !excludedErrorCodes.has(error.code);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
tsErrors = convertToCodeMirrorDiagnostic(tsErrors);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const linterResponse: LinterResponse = {
|
|
79
|
+
event: 'post-error-linter',
|
|
80
|
+
tsErrors,
|
|
81
|
+
requestId,
|
|
82
|
+
};
|
|
83
|
+
postMessage(linterResponse);
|
|
84
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { compilerOptions } from './constants';
|
|
3
|
+
|
|
4
|
+
// Handle the transpile-request event, which
|
|
5
|
+
// transpiles TypeScript to JavaScript.
|
|
6
|
+
export const handleMessageTranspileRequest = async ({
|
|
7
|
+
data,
|
|
8
|
+
}) => {
|
|
9
|
+
const tsCode = data.tsCode;
|
|
10
|
+
|
|
11
|
+
const jsCode = ts.transpileModule(tsCode, {
|
|
12
|
+
compilerOptions: compilerOptions,
|
|
13
|
+
}).outputText;
|
|
14
|
+
|
|
15
|
+
postMessage({
|
|
16
|
+
event: 'transpile-response',
|
|
17
|
+
jsCode,
|
|
18
|
+
fileId: data.fileId,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { File, Files, VZCodeContent } from '../../../types';
|
|
2
|
+
import { getTSFileName } from './getTSFileName';
|
|
3
|
+
import { isTS } from './isTS';
|
|
4
|
+
|
|
5
|
+
// Handle the update-content event, which
|
|
6
|
+
// updates the files as they change.
|
|
7
|
+
// This handles the cases where:
|
|
8
|
+
// * The file system is populated for the first time.
|
|
9
|
+
// * Files are edited by remote users.
|
|
10
|
+
export const handleMessageUpdateContent = async ({
|
|
11
|
+
debug,
|
|
12
|
+
data,
|
|
13
|
+
setFile,
|
|
14
|
+
}) => {
|
|
15
|
+
if (debug) {
|
|
16
|
+
console.log('update-content message received');
|
|
17
|
+
}
|
|
18
|
+
// Unpack the files
|
|
19
|
+
const content: VZCodeContent = data.details;
|
|
20
|
+
const files: Files = content.files;
|
|
21
|
+
|
|
22
|
+
// Iterate over the files
|
|
23
|
+
for (const fileId of Object.keys(files)) {
|
|
24
|
+
const file: File = files[fileId];
|
|
25
|
+
const { name, text } = file;
|
|
26
|
+
|
|
27
|
+
const tsFileName = getTSFileName(name);
|
|
28
|
+
|
|
29
|
+
if (!isTS(tsFileName)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setFile(tsFileName, text);
|
|
34
|
+
// TODO - Handle renaming files.
|
|
35
|
+
// TODO - Handle deleting files.
|
|
36
|
+
// TODO - Handle directories.
|
|
37
|
+
}
|
|
38
|
+
};
|