vzcode 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-an0ZIKQ3.js → index-oU3BPloT.js} +3 -3
- package/dist/assets/{worker-pw8iYY3X.js → worker-i-gsyYZ1.js} +28 -28
- package/dist/index.html +1 -1
- package/package.json +3 -3
- package/src/client/CodeEditor/json1PresenceDisplay.ts +6 -0
- package/src/client/CodeEditor/typeScriptCompletions.ts +11 -0
- package/src/client/CodeEditor/widgets.ts +4 -2
- package/src/client/useTypeScript/worker.ts +2 -2
|
@@ -65,7 +65,7 @@ Source:
|
|
|
65
65
|
`))):qe=W.stylize("[Circular]","special")),A(ze)){if(De&&Ee.match(/^\d+$/))return qe;ze=JSON.stringify(""+Ee),ze.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(ze=ze.slice(1,-1),ze=W.stylize(ze,"name")):(ze=ze.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),ze=W.stylize(ze,"string"))}return ze+": "+qe}function w(W,j,V){var Oe=W.reduce(function(Ee,De){return De.indexOf(`
|
|
66
66
|
`)>=0,Ee+De.replace(/\u001b\[\d\d?m/g,"").length+1},0);return Oe>60?V[0]+(j===""?"":j+`
|
|
67
67
|
`)+" "+W.join(`,
|
|
68
|
-
`)+" "+V[1]:V[0]+j+" "+W.join(", ")+" "+V[1]}i.types=n("./support/types");function x(W){return Array.isArray(W)}i.isArray=x;function _(W){return typeof W=="boolean"}i.isBoolean=_;function T(W){return W===null}i.isNull=T;function b(W){return W==null}i.isNullOrUndefined=b;function k(W){return typeof W=="number"}i.isNumber=k;function P(W){return typeof W=="string"}i.isString=P;function C(W){return typeof W=="symbol"}i.isSymbol=C;function A(W){return W===void 0}i.isUndefined=A;function N(W){return X(W)&&L(W)==="[object RegExp]"}i.isRegExp=N,i.types.isRegExp=N;function X(W){return typeof W=="object"&&W!==null}i.isObject=X;function te(W){return X(W)&&L(W)==="[object Date]"}i.isDate=te,i.types.isDate=te;function M(W){return X(W)&&(L(W)==="[object Error]"||W instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(W){return typeof W=="function"}i.isFunction=I;function D(W){return W===null||typeof W=="boolean"||typeof W=="number"||typeof W=="string"||typeof W=="symbol"||typeof W>"u"}i.isPrimitive=D,i.isBuffer=n("./support/isBuffer");function L(W){return Object.prototype.toString.call(W)}function F(W){return W<10?"0"+W.toString(10):W.toString(10)}var he=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ve(){var W=new Date,j=[F(W.getHours()),F(W.getMinutes()),F(W.getSeconds())].join(":");return[W.getDate(),he[W.getMonth()],j].join(" ")}i.log=function(){console.log("%s - %s",ve(),i.format.apply(i,arguments))},i.inherits=n("inherits"),i._extend=function(W,j){if(!j||!X(j))return W;for(var V=Object.keys(j),Oe=V.length;Oe--;)W[V[Oe]]=j[V[Oe]];return W};function B(W,j){return Object.prototype.hasOwnProperty.call(W,j)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&j[K]){var V=j[K];if(typeof V!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),V}function V(){for(var Oe,Ee,De=new Promise(function(Ve,gt){Oe=Ve,Ee=gt}),ze=[],qe=0;qe<arguments.length;qe++)ze.push(arguments[qe]);ze.push(function(Ve,gt){Ve?Ee(Ve):Oe(gt)});try{j.apply(this,ze)}catch(Ve){Ee(Ve)}return De}return Object.setPrototypeOf(V,Object.getPrototypeOf(j)),K&&Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(V,o(j))},i.promisify.custom=K;function oe(W,j){if(!W){var V=new Error("Promise was rejected with a falsy value");V.reason=W,W=V}return j(W)}function Be(W){if(typeof W!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var V=[],Oe=0;Oe<arguments.length;Oe++)V.push(arguments[Oe]);var Ee=V.pop();if(typeof Ee!="function")throw new TypeError("The last argument must be of type Function");var De=this,ze=function(){return Ee.apply(De,arguments)};W.apply(this,V).then(function(qe){s.nextTick(ze.bind(null,null,qe))},function(qe){s.nextTick(oe.bind(null,qe,ze))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(W)),Object.defineProperties(j,o(W)),j}i.callbackify=Be}).call(this)}).call(this,n("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(n,r,i){(function(s){(function(){var o=n("for-each"),l=n("available-typed-arrays"),a=n("call-bind/callBound"),u=n("gopd"),c=a("Object.prototype.toString"),h=n("has-tostringtag/shams")(),f=typeof globalThis>"u"?s:globalThis,d=l(),p=a("String.prototype.slice"),g={},O=Object.getPrototypeOf;h&&u&&O&&o(d,function(v){if(typeof f[v]=="function"){var w=new f[v];if(Symbol.toStringTag in w){var x=O(w),_=u(x,Symbol.toStringTag);if(!_){var T=O(x);_=u(T,Symbol.toStringTag)}g[v]=_.get}}});var y=function(w){var x=!1;return o(g,function(_,T){if(!x)try{var b=_.call(w);b===T&&(x=b)}catch{}}),x},m=n("is-typed-array");r.exports=function(w){return m(w)?!h||!(Symbol.toStringTag in w)?p(c(w),8,-1):y(w):!1}}).call(this)}).call(this,typeof yr<"u"?yr:typeof self<"u"?self:typeof window<"u"?window:{})},{"available-typed-arrays":5,"call-bind/callBound":6,"for-each":8,gopd:12,"has-tostringtag/shams":15,"is-typed-array":21}],39:[function(n,r,i){const s=n("ot-json1-presence"),o=n("ot-text-unicode");r.exports={json1Presence:s,textUnicode:o}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(p_);var y2=p_.exports;const v2=us(y2),{json1Presence:tp,textUnicode:g_}=v2;function S2(t){return new Worker("/assets/worker-hNl6wfTa.js",{name:t==null?void 0:t.name})}function w2(t){return new Worker("/assets/worker-pw8iYY3X.js",{name:t==null?void 0:t.name})}const b2=!0,$1=800,m_="vzCodeSidebarWidth",O_="vzCodeCodeEditorWidth",y_=220;let np=y_;const v_=800;let rp=v_,Lm=!1;if(typeof window<"u"&&b2){const t=window.localStorage.getItem(m_),e=window.localStorage.getItem(O_);t!==null&&(np=+t,Lm=!0),e!==null&&(rp=+e,Lm=!0)}const k2={codeEditorWidth:rp,sidebarWidth:np,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},ip=Y.createContext(k2),x2={sidebarWidth:y_,codeEditorWidth:v_,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},P2=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:np,codeEditorWidth:rp,isInitialized:!0};case"move":return e.side==="left"?{...t,sidebarWidth:t.sidebarWidth+e.movementX}:{...t,codeEditorWidth:t.codeEditorWidth+e.movementX};case"setIsDragging":return e.side==="left"?{...t,isDraggingLeft:e.isDragging}:{...t,isDraggingRight:e.isDragging};default:return t}},_2=({children:t})=>{const[e,n]=Y.useReducer(P2,x2),r=Y.useCallback((h,f)=>{n({type:"setIsDragging",isDragging:h,side:f})},[n]),i=Y.useCallback((h,f)=>{n({type:"move",movementX:h,side:f})},[n]),{sidebarWidth:s,codeEditorWidth:o,isDraggingLeft:l,isDraggingRight:a,isInitialized:u}=e;typeof window<"u"&&Y.useLayoutEffect(()=>{Lm&&!u&&n({type:"initialize"})},[u]),Y.useEffect(()=>{s!==np&&setTimeout(()=>{window.localStorage.setItem(m_,""+s)},$1),o!==rp&&setTimeout(()=>{window.localStorage.setItem(O_,""+o)},$1)},[o,s]);const c={codeEditorWidth:o,sidebarWidth:s,moveSplitPane:i,isDraggingLeft:l,isDraggingRight:a,setIsDragging:r};return G.jsx(ip.Provider,{value:c,children:t})},S_=1200,C2=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},E2=(t,e,n)=>{const r=new Set,[i,s]=Y.useState(null),o=Y.useRef(!1);return Y.useEffect(()=>{if(!t)return;const l=h=>{const{fileId:f,error:d,fileTextPrettified:p}=h.data;if(d){s(d);return}else s(null);o.current=!0,e(g=>({...g,files:{...g.files,[f]:{...g.files[f],text:p}}})),o.current=!1};n.addEventListener("message",l);const a=async()=>{const f=t.data.files,d=Array.from(r);r.clear();for(const p of d){const g=f[p],O={fileText:g.text,fileExtension:C2(g.name),fileId:p};n.postMessage(O)}};let u;function c(){clearTimeout(u),u=setTimeout(a,S_)}return window.addEventListener("mousemove",c),window.addEventListener("keydown",c),t.on("op batch",(h,f)=>{if(f){if(o.current)return;if(h&&h.length===4&&h[0]==="files"&&typeof h[1]=="string"&&h[2]==="text"){const d=h[1];r.add(d),c()}}}),()=>{n.removeEventListener("message",l),window.removeEventListener("keydown",c),window.removeEventListener("mousemove",c),clearTimeout(u)}},[t]),{prettierError:i}},T2=500,$2=S_+T2,Q2=({content:t,typeScriptWorker:e})=>{const n=Y.useRef(null),r=Y.useCallback(i=>{clearTimeout(n.current),n.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},$2)},[e]);Y.useEffect(()=>{r(t)},[t])},R2=(t,e)=>{if(e.type!=="close_tabs")return t;const n=t.tabList.filter(s=>!e.fileIdsToClose.includes(s.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:n};const r=t.tabList.findIndex(s=>s.fileId===t.activeFileId);let i=null;for(let s=r-1;s>=0;s--)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}if(!i){for(let s=r+1;s<t.tabList.length;s++)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}}return{...t,tabList:n,activeFileId:i}},A2=(t,e)=>{if(e.type!=="open_tab")return t;const n=t.tabList.findIndex(a=>a.fileId===e.fileId),r=n!==-1,i=r&&t.tabList[n].isTransient,s=t.tabList.findIndex(a=>a.isTransient&&a.fileId!==e.fileId),o={fileId:e.fileId,isTransient:e.isTransient};let l;return r?i?l=t.tabList.map(a=>a.fileId===e.fileId?o:a):l=[...t.tabList]:s!==-1?(l=[...t.tabList],l[s]=o):l=[...t.tabList,o],{...t,activeFileId:e.fileId,tabList:l,editorWantsFocus:!e.isTransient}},M2=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,D2=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,N2=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,I2=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Z2=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,L2=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),W2=[M2,A2,R2,N2,D2,I2,Z2],B2=(t,e)=>W2.reduce((n,r)=>r(n,e),t);class St{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Ri.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){let r=[];return this.decompose(e,n,r,0),Ri.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new uu(this),s=new uu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new uu(this,e)}iterRange(e,n=this.length){return new w_(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new b_(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?St.empty:e.length<=32?new rn(e):Ri.from(rn.split(e,[]))}}class rn extends St{constructor(e,n=X2(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new Y2(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new rn(Q1(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=yh(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new rn(l,o.length+s.length));else{let a=l.length>>1;r.push(new rn(l.slice(0,a)),new rn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof rn))return super.replace(e,n,r);let i=yh(this.text,yh(r.text,Q1(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new rn(i,s):Ri.from(rn.split(i,[]),s)}sliceString(e,n=this.length,r=`
|
|
68
|
+
`)+" "+V[1]:V[0]+j+" "+W.join(", ")+" "+V[1]}i.types=n("./support/types");function x(W){return Array.isArray(W)}i.isArray=x;function _(W){return typeof W=="boolean"}i.isBoolean=_;function T(W){return W===null}i.isNull=T;function b(W){return W==null}i.isNullOrUndefined=b;function k(W){return typeof W=="number"}i.isNumber=k;function P(W){return typeof W=="string"}i.isString=P;function C(W){return typeof W=="symbol"}i.isSymbol=C;function A(W){return W===void 0}i.isUndefined=A;function N(W){return X(W)&&L(W)==="[object RegExp]"}i.isRegExp=N,i.types.isRegExp=N;function X(W){return typeof W=="object"&&W!==null}i.isObject=X;function te(W){return X(W)&&L(W)==="[object Date]"}i.isDate=te,i.types.isDate=te;function M(W){return X(W)&&(L(W)==="[object Error]"||W instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(W){return typeof W=="function"}i.isFunction=I;function D(W){return W===null||typeof W=="boolean"||typeof W=="number"||typeof W=="string"||typeof W=="symbol"||typeof W>"u"}i.isPrimitive=D,i.isBuffer=n("./support/isBuffer");function L(W){return Object.prototype.toString.call(W)}function F(W){return W<10?"0"+W.toString(10):W.toString(10)}var he=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ve(){var W=new Date,j=[F(W.getHours()),F(W.getMinutes()),F(W.getSeconds())].join(":");return[W.getDate(),he[W.getMonth()],j].join(" ")}i.log=function(){console.log("%s - %s",ve(),i.format.apply(i,arguments))},i.inherits=n("inherits"),i._extend=function(W,j){if(!j||!X(j))return W;for(var V=Object.keys(j),Oe=V.length;Oe--;)W[V[Oe]]=j[V[Oe]];return W};function B(W,j){return Object.prototype.hasOwnProperty.call(W,j)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(j){if(typeof j!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&j[K]){var V=j[K];if(typeof V!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),V}function V(){for(var Oe,Ee,De=new Promise(function(Ve,gt){Oe=Ve,Ee=gt}),ze=[],qe=0;qe<arguments.length;qe++)ze.push(arguments[qe]);ze.push(function(Ve,gt){Ve?Ee(Ve):Oe(gt)});try{j.apply(this,ze)}catch(Ve){Ee(Ve)}return De}return Object.setPrototypeOf(V,Object.getPrototypeOf(j)),K&&Object.defineProperty(V,K,{value:V,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(V,o(j))},i.promisify.custom=K;function oe(W,j){if(!W){var V=new Error("Promise was rejected with a falsy value");V.reason=W,W=V}return j(W)}function Be(W){if(typeof W!="function")throw new TypeError('The "original" argument must be of type Function');function j(){for(var V=[],Oe=0;Oe<arguments.length;Oe++)V.push(arguments[Oe]);var Ee=V.pop();if(typeof Ee!="function")throw new TypeError("The last argument must be of type Function");var De=this,ze=function(){return Ee.apply(De,arguments)};W.apply(this,V).then(function(qe){s.nextTick(ze.bind(null,null,qe))},function(qe){s.nextTick(oe.bind(null,qe,ze))})}return Object.setPrototypeOf(j,Object.getPrototypeOf(W)),Object.defineProperties(j,o(W)),j}i.callbackify=Be}).call(this)}).call(this,n("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(n,r,i){(function(s){(function(){var o=n("for-each"),l=n("available-typed-arrays"),a=n("call-bind/callBound"),u=n("gopd"),c=a("Object.prototype.toString"),h=n("has-tostringtag/shams")(),f=typeof globalThis>"u"?s:globalThis,d=l(),p=a("String.prototype.slice"),g={},O=Object.getPrototypeOf;h&&u&&O&&o(d,function(v){if(typeof f[v]=="function"){var w=new f[v];if(Symbol.toStringTag in w){var x=O(w),_=u(x,Symbol.toStringTag);if(!_){var T=O(x);_=u(T,Symbol.toStringTag)}g[v]=_.get}}});var y=function(w){var x=!1;return o(g,function(_,T){if(!x)try{var b=_.call(w);b===T&&(x=b)}catch{}}),x},m=n("is-typed-array");r.exports=function(w){return m(w)?!h||!(Symbol.toStringTag in w)?p(c(w),8,-1):y(w):!1}}).call(this)}).call(this,typeof yr<"u"?yr:typeof self<"u"?self:typeof window<"u"?window:{})},{"available-typed-arrays":5,"call-bind/callBound":6,"for-each":8,gopd:12,"has-tostringtag/shams":15,"is-typed-array":21}],39:[function(n,r,i){const s=n("ot-json1-presence"),o=n("ot-text-unicode");r.exports={json1Presence:s,textUnicode:o}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(p_);var y2=p_.exports;const v2=us(y2),{json1Presence:tp,textUnicode:g_}=v2;function S2(t){return new Worker("/assets/worker-hNl6wfTa.js",{name:t==null?void 0:t.name})}function w2(t){return new Worker("/assets/worker-i-gsyYZ1.js",{name:t==null?void 0:t.name})}const b2=!0,$1=800,m_="vzCodeSidebarWidth",O_="vzCodeCodeEditorWidth",y_=220;let np=y_;const v_=800;let rp=v_,Lm=!1;if(typeof window<"u"&&b2){const t=window.localStorage.getItem(m_),e=window.localStorage.getItem(O_);t!==null&&(np=+t,Lm=!0),e!==null&&(rp=+e,Lm=!0)}const k2={codeEditorWidth:rp,sidebarWidth:np,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},ip=Y.createContext(k2),x2={sidebarWidth:y_,codeEditorWidth:v_,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},P2=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:np,codeEditorWidth:rp,isInitialized:!0};case"move":return e.side==="left"?{...t,sidebarWidth:t.sidebarWidth+e.movementX}:{...t,codeEditorWidth:t.codeEditorWidth+e.movementX};case"setIsDragging":return e.side==="left"?{...t,isDraggingLeft:e.isDragging}:{...t,isDraggingRight:e.isDragging};default:return t}},_2=({children:t})=>{const[e,n]=Y.useReducer(P2,x2),r=Y.useCallback((h,f)=>{n({type:"setIsDragging",isDragging:h,side:f})},[n]),i=Y.useCallback((h,f)=>{n({type:"move",movementX:h,side:f})},[n]),{sidebarWidth:s,codeEditorWidth:o,isDraggingLeft:l,isDraggingRight:a,isInitialized:u}=e;typeof window<"u"&&Y.useLayoutEffect(()=>{Lm&&!u&&n({type:"initialize"})},[u]),Y.useEffect(()=>{s!==np&&setTimeout(()=>{window.localStorage.setItem(m_,""+s)},$1),o!==rp&&setTimeout(()=>{window.localStorage.setItem(O_,""+o)},$1)},[o,s]);const c={codeEditorWidth:o,sidebarWidth:s,moveSplitPane:i,isDraggingLeft:l,isDraggingRight:a,setIsDragging:r};return G.jsx(ip.Provider,{value:c,children:t})},S_=1200,C2=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},E2=(t,e,n)=>{const r=new Set,[i,s]=Y.useState(null),o=Y.useRef(!1);return Y.useEffect(()=>{if(!t)return;const l=h=>{const{fileId:f,error:d,fileTextPrettified:p}=h.data;if(d){s(d);return}else s(null);o.current=!0,e(g=>({...g,files:{...g.files,[f]:{...g.files[f],text:p}}})),o.current=!1};n.addEventListener("message",l);const a=async()=>{const f=t.data.files,d=Array.from(r);r.clear();for(const p of d){const g=f[p],O={fileText:g.text,fileExtension:C2(g.name),fileId:p};n.postMessage(O)}};let u;function c(){clearTimeout(u),u=setTimeout(a,S_)}return window.addEventListener("mousemove",c),window.addEventListener("keydown",c),t.on("op batch",(h,f)=>{if(f){if(o.current)return;if(h&&h.length===4&&h[0]==="files"&&typeof h[1]=="string"&&h[2]==="text"){const d=h[1];r.add(d),c()}}}),()=>{n.removeEventListener("message",l),window.removeEventListener("keydown",c),window.removeEventListener("mousemove",c),clearTimeout(u)}},[t]),{prettierError:i}},T2=500,$2=S_+T2,Q2=({content:t,typeScriptWorker:e})=>{const n=Y.useRef(null),r=Y.useCallback(i=>{clearTimeout(n.current),n.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},$2)},[e]);Y.useEffect(()=>{r(t)},[t])},R2=(t,e)=>{if(e.type!=="close_tabs")return t;const n=t.tabList.filter(s=>!e.fileIdsToClose.includes(s.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:n};const r=t.tabList.findIndex(s=>s.fileId===t.activeFileId);let i=null;for(let s=r-1;s>=0;s--)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}if(!i){for(let s=r+1;s<t.tabList.length;s++)if(!e.fileIdsToClose.includes(t.tabList[s].fileId)){i=t.tabList[s].fileId;break}}return{...t,tabList:n,activeFileId:i}},A2=(t,e)=>{if(e.type!=="open_tab")return t;const n=t.tabList.findIndex(a=>a.fileId===e.fileId),r=n!==-1,i=r&&t.tabList[n].isTransient,s=t.tabList.findIndex(a=>a.isTransient&&a.fileId!==e.fileId),o={fileId:e.fileId,isTransient:e.isTransient};let l;return r?i?l=t.tabList.map(a=>a.fileId===e.fileId?o:a):l=[...t.tabList]:s!==-1?(l=[...t.tabList],l[s]=o):l=[...t.tabList,o],{...t,activeFileId:e.fileId,tabList:l,editorWantsFocus:!e.isTransient}},M2=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,D2=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,N2=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,I2=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Z2=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,L2=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),W2=[M2,A2,R2,N2,D2,I2,Z2],B2=(t,e)=>W2.reduce((n,r)=>r(n,e),t);class St{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Ri.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){let r=[];return this.decompose(e,n,r,0),Ri.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new uu(this),s=new uu(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new uu(this,e)}iterRange(e,n=this.length){return new w_(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new b_(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?St.empty:e.length<=32?new rn(e):Ri.from(rn.split(e,[]))}}class rn extends St{constructor(e,n=X2(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new Y2(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new rn(Q1(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=yh(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new rn(l,o.length+s.length));else{let a=l.length>>1;r.push(new rn(l.slice(0,a)),new rn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof rn))return super.replace(e,n,r);let i=yh(this.text,yh(r.text,Q1(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new rn(i,s):Ri.from(rn.split(i,[]),s)}sliceString(e,n=this.length,r=`
|
|
69
69
|
`){let i="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(i+=r),e<a&&n>s&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new rn(r,i)),r=[],i=-1);return i>-1&&n.push(new rn(r,i)),n}}class Ri extends St{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&n>=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if(r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],l=s+o.length;if(e>=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines<u>>5-1&&a.lines>u>>5+1){let c=this.children.slice();return c[i]=a,new Ri(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
|
|
70
70
|
`){let i="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(i+=r),e<a&&n>o&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Ri))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new rn(d,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function h(d){let p;if(d.lines>s&&d instanceof Ri)for(let g of d.children)h(g);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof rn&&a&&(p=c[c.length-1])instanceof rn&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new rn(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>i&&f(),a+=d.lines,u+=d.length+1,c.push(d))}function f(){a!=0&&(l.push(c.length==1?c[0]:Ri.from(c,u)),u=-1,a=c.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new Ri(l,n)}}St.empty=new rn([""],0);function X2(t){let e=-1;for(let n of t)e+=n.length+1;return e}function yh(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=r;s++){let l=t[s],a=i+l.length;a>=n&&(a>r&&(l=l.slice(0,r-i)),i<n&&(l=l.slice(n-i)),o?(e[e.length-1]+=l,o=!1):e.push(l)),i=a+1}return e}function Q1(t,e,n){return yh(t,[""],e,n)}class uu{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof rn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof rn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
71
71
|
`,this;e--}else if(i instanceof rn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof rn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class w_{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new uu(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class b_{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(St.prototype[Symbol.iterator]=function(){return this.iter()},uu.prototype[Symbol.iterator]=w_.prototype[Symbol.iterator]=b_.prototype[Symbol.iterator]=function(){return this});let Y2=class{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}},Rl="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<Rl.length;t++)Rl[t]+=Rl[t-1];function j2(t){for(let e=1;e<Rl.length;e+=2)if(Rl[e]>t)return Rl[e-1]<=t;return!1}function R1(t){return t>=127462&&t<=127487}const A1=8205;function Bn(t,e,n=!0,r=!0){return(n?k_:U2)(t,e,r)}function k_(t,e,n){if(e==t.length)return e;e&&x_(t.charCodeAt(e))&&P_(t.charCodeAt(e-1))&&e--;let r=En(t,e);for(e+=Ir(r);e<t.length;){let i=En(t,e);if(r==A1||i==A1||n&&j2(i))e+=Ir(i),r=i;else if(R1(i)){let s=0,o=e-2;for(;o>=0&&R1(En(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function U2(t,e,n){for(;e>0;){let r=k_(t,e-2,n);if(r<e)return r;e--}return 0}function x_(t){return t>=56320&&t<57344}function P_(t){return t>=55296&&t<56320}function En(t,e){let n=t.charCodeAt(e);if(!P_(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return x_(r)?(n-55296<<10)+(r-56320)+65536:n}function Ky(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Ir(t){return t<65536?1:2}const Wm=/\r\n?|\n/;var cn=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(cn||(cn={}));class Li{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(e,n=!1){Bm(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new Li(e)}composeDesc(e){return this.empty?e:e.empty?this:__(this,e)}mapDesc(e,n=!1){return e.empty?this:Xm(this,e,n)}mapPos(e,n=-1,r=cn.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],u=i+l;if(a<0){if(u>e)return s+(e-i);s+=l}else{if(r!=cn.Simple&&u>=e&&(r==cn.TrackDel&&i<e&&u>e||r==cn.TrackBefore&&i<e||r==cn.TrackAfter&&u>e))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],l=i+s;if(o>=0&&i<=n&&l>=e)return i<e&&l>n?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Li(e)}static create(e){return new Li(e)}}class un extends Li{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Bm(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return Xm(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],l=n[i+1];if(l>=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length<a;)r.push(St.empty);r.push(o?e.slice(s,s+o):St.empty)}s+=o}return new un(n,r)}compose(e){return this.empty?e:e.empty?this:__(this,e,!0)}map(e,n=!1){return e.empty?this:Xm(this,e,n,!0)}iterChanges(e,n=!1){Bm(this,e,n)}get desc(){return Li.create(this.sections)}filter(e){let n=[],r=[],i=[],s=new Mu(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);In(i,c,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;In(n,c,h),h>0&&Ts(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l<u;){if(s.done)break e;let c=Math.min(s.len,u-l);In(n,c,-1),In(i,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new un(n,r),filtered:Li.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;o<n&&In(i,n-o,-1);let h=new un(i,s);l=l?l.compose(h.map(l)):h,i=[],s=[],o=0}function u(c){if(Array.isArray(c))for(let h of c)u(h);else if(c instanceof un){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:h,to:f=h,insert:d}=c;if(h>f||h<0||f>n)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${n})`);let p=d?typeof d=="string"?St.of(d.split(r||Wm)):d:St.empty,g=p.length;if(h==f&&g==0)return;h<o&&a(),h>o&&In(i,h-o,-1),In(i,f-h,g),Ts(s,i,p),o=f}}return u(e),a(!l),l}static empty(e){return new un(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(St.empty);r[i]=St.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new un(n,r)}static createSet(e,n){return new un(e,n)}}function In(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function Ts(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(St.empty);t.push(n)}}function Bm(t,e,n){let r=t.inserted;for(let i=0,s=0,o=0;o<t.sections.length;){let l=t.sections[o++],a=t.sections[o++];if(a<0)i+=l,s+=l;else{let u=i,c=s,h=St.empty;for(;u+=l,c+=a,a&&r&&(h=h.append(r[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,h),i=u,s=c}}}function Xm(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Mu(t),l=new Mu(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);In(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!n))){let u=l.len;for(In(i,l.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&a<o.i&&o.len<=c&&(In(i,0,o.ins),s&&Ts(s,i,o.text),a=o.i),o.forward(c),u-=c}l.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let h=Math.min(c,l.len);u+=h,c-=h,l.forward(h)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;In(i,u,a<o.i?o.ins:0),s&&a<o.i&&Ts(s,i,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?un.createSet(i,s):Li.create(i);throw new Error("Mismatched change set lengths")}}function __(t,e,n=!1){let r=[],i=n?[]:null,s=new Mu(t),o=new Mu(e);for(let l=!1;;){if(s.done&&o.done)return i?un.createSet(r,i):Li.create(r);if(s.ins==0)In(r,s.len,0,l),s.next();else if(o.len==0&&!o.done)In(r,0,o.ins,l),i&&Ts(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),u=r.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;In(r,a,c,l),i&&c&&Ts(i,r,o.text)}else o.ins==-1?(In(r,s.off?0:s.len,a,l),i&&Ts(i,r,s.textBit(a))):(In(r,s.off?0:s.len,o.off?0:o.ins,l),i&&!o.off&&Ts(i,r,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Mu{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?St.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?St.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class bo{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new bo(r,i,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return J.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return J.range(this.anchor,r)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return J.range(e.anchor,e.head)}static create(e,n,r){return new bo(e,n,r)}}class J{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:J.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new J([this.main],0)}addRange(e,n=!0){return J.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,J.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new J(e.ranges.map(n=>bo.fromJSON(n)),e.main)}static single(e,n=e){return new J([J.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=r:s.from<r)return J.normalized(e.slice(),n);r=s.to}return new J(e,n)}static cursor(e,n=0,r,i){return bo.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<e?bo.create(n,e,48|s):bo.create(e,n,(n>e?8:0)|s)}static normalized(e,n=0){let r=e[n];e.sort((i,s)=>i.from-s.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);i<=n&&n--,e.splice(--i,2,s.anchor>s.head?J.range(a,l):J.range(l,a))}}return new J(e,n)}}function C_(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Jy=0;class Pe{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Jy++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Pe(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:ev),!!e.static,e.enables)}of(e){return new vh([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new vh(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new vh(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function ev(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class vh{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Jy++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?u=!0:((n=e[h.id])!==null&&n!==void 0?n:1)&1||c.push(e[h.id]);return{create(h){return h.values[o]=r(h),1},update(h,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||Ym(h,c)){let d=r(h);if(l?!M1(d,h.values[o],i):!i(d,h.values[o]))return h.values[o]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[s];if(p!=null){let g=id(f,p);if(this.dependencies.every(O=>O instanceof Pe?f.facet(O)===h.facet(O):O instanceof pn?f.field(O,!1)==h.field(O,!1):!0)||(l?M1(d=r(h),g,i):i(d=r(h),g)))return h.values[o]=g,0}else d=r(h);return h.values[o]=d,1}}}}function M1(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function Ym(t,e){let n=!1;for(let r of e)cu(t,r)&1&&(n=!0);return n}function F2(t,e,n){let r=n.map(a=>t[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;c<r.length;c++){let h=id(a,r[c]);if(i[c]==2)for(let f of h)u.push(f);else u.push(h)}return e.combine(u)}return{create(a){for(let u of r)cu(a,u);return a.values[o]=l(a),1},update(a,u){if(!Ym(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,u){let c=Ym(a,r),h=u.config.facets[e.id],f=u.facet(e);if(h&&!c&&ev(n,h))return a.values[o]=f,0;let d=l(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const D1=Pe.define({static:!0});class pn{constructor(e,n,r,i,s){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let n=new pn(Jy++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(D1).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}init(e){return[this,D1.of({field:this,create:e})]}get extension(){return this}}const go={lowest:4,low:3,default:2,high:1,highest:0};function _a(t){return e=>new E_(e,t)}const Js={highest:_a(go.highest),high:_a(go.high),default:_a(go.default),low:_a(go.low),lowest:_a(go.lowest)};class E_{constructor(e,n){this.inner=e,this.prec=n}}class ql{of(e){return new jm(this,e)}reconfigure(e){return ql.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jm{constructor(e,n){this.compartment=e,this.inner=n}}class rd{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let f of z2(e,n,o))f instanceof pn?i.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],u=[];for(let f of i)l[f.id]=u.length<<1,u.push(d=>f.slot(d));let c=r==null?void 0:r.config.facets;for(let f in s){let d=s[f],p=d[0].facet,g=c&&c[f]||[];if(d.every(O=>O.type==0))if(l[p.id]=a.length<<1|1,ev(g,d))a.push(r.facet(p));else{let O=p.combine(d.map(y=>y.value));a.push(r&&p.compare(O,r.facet(p))?r.facet(p):O)}else{for(let O of d)O.type==0?(l[O.id]=a.length<<1|1,a.push(O.value)):(l[O.id]=u.length<<1,u.push(y=>O.dynamicSlot(y)));l[p.id]=u.length<<1,u.push(O=>F2(O,p,d))}}let h=u.map(f=>f(l));return new rd(e,o,h,l,a,s)}}function z2(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof jm&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof jm){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof E_)s(o.inner,o.prec);else if(o instanceof pn)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof vh)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,go.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,go.default),r.reduce((o,l)=>o.concat(l))}function cu(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function id(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const T_=Pe.define(),Um=Pe.define({combine:t=>t.some(e=>e),static:!0}),$_=Pe.define({combine:t=>t.length?t[0]:void 0,static:!0}),Q_=Pe.define(),R_=Pe.define(),A_=Pe.define(),M_=Pe.define({combine:t=>t.length?t[0]:!1});class hi{constructor(e,n){this.type=e,this.value=n}static define(){return new q2}}class q2{of(e){return new hi(this,e)}}class V2{constructor(e){this.map=e}of(e){return new tt(this,e)}}class tt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new tt(this.type,n)}is(e){return this.type==e}static define(e={}){return new V2(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}tt.reconfigure=tt.define();tt.appendConfig=tt.define();class hn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&C_(r,n.newLength),s.some(l=>l.type==hn.time)||(this.annotations=s.concat(hn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new hn(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(hn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}hn.time=hi.define();hn.userEvent=hi.define();hn.addToHistory=hi.define();hn.remote=hi.define();function G2(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r<t.length&&(i==e.length||e[i]>=t[r]))s=t[r++],o=t[r++];else if(i<e.length)s=e[i++],o=e[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function D_(t,e,n){var r;let i,s,o;return n?(i=e.changes,s=un.empty(e.changes.length),o=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:tt.mapEffects(t.effects,i).concat(tt.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Fm(t,e,n){let r=e.selection,i=Al(e.annotations);return e.userEvent&&(i=i.concat(hn.userEvent.of(e.userEvent))),{changes:e.changes instanceof un?e.changes:un.of(e.changes||[],n,t.facet($_)),selection:r&&(r instanceof J?r:J.single(r.anchor,r.head)),effects:Al(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function N_(t,e,n){let r=Fm(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;r=D_(r,Fm(t,e[s],o?r.changes.newLength:t.doc.length),o)}let i=hn.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return K2(n?H2(i):i)}function H2(t){let e=t.startState,n=!0;for(let i of e.facet(Q_)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:G2(n,s))}if(n!==!0){let i,s;if(n===!1)s=t.changes.invertedDesc,i=un.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=hn.create(e,i,t.selection&&t.selection.map(s),tt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(R_);for(let i=r.length-1;i>=0;i--){let s=r[i](t);s instanceof hn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof hn?t=s[0]:t=N_(e,Al(s),!1)}return t}function K2(t){let e=t.startState,n=e.facet(A_),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=D_(r,Fm(e,s,t.changes.newLength),!0))}return r==t?t:hn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const J2=[];function Al(t){return t==null?J2:Array.isArray(t)?t:[t]}var Ft=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ft||(Ft={}));const eM=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let zm;try{zm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function tM(t){if(zm)return zm.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||eM.test(n)))return!0}return!1}function nM(t){return e=>{if(!/\S/.test(e))return Ft.Space;if(tM(e))return Ft.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Ft.Word;return Ft.Other}}class pt{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)cu(this,l<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return cu(this,r),id(this,r)}update(...e){return N_(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let l of e.effects)l.is(ql.reconfigure)?(n&&(i=new Map,n.compartments.forEach((a,u)=>i.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(tt.reconfigure)?(n=null,r=l.value):l.is(tt.appendConfig)&&(n=null,r=Al(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=rd.resolve(r,i,this),s=new pt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Um)?e.newSelection:e.newSelection.asSingle();new pt(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:J.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Al(r.effects);for(let l=1;l<n.ranges.length;l++){let a=e(n.ranges[l]),u=this.changes(a.changes),c=u.map(i);for(let f=0;f<l;f++)s[f]=s[f].map(c);let h=i.mapDesc(u,!0);s.push(a.range.map(h)),i=i.compose(c),o=tt.mapEffects(o,c).concat(tt.mapEffects(Al(a.effects),h))}return{changes:i,selection:J.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof un?e:un.of(e,this.doc.length,this.facet(pt.lineSeparator))}toText(e){return St.of(e.split(this.facet(pt.lineSeparator)||Wm))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(cu(this,n),id(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof pn&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],l=e[s];i.push(o.init(a=>o.spec.fromJSON(l,a)))}}return pt.create({doc:e.doc,selection:J.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=rd.resolve(e.extensions||[],new Map),r=e.doc instanceof St?e.doc:St.of((e.doc||"").split(n.staticFacet(pt.lineSeparator)||Wm)),i=e.selection?e.selection instanceof J?e.selection:J.single(e.selection.anchor,e.selection.head):J.single(0);return C_(i,r.length),n.staticFacet(Um)||(i=i.asSingle()),new pt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||`
|
|
@@ -106,9 +106,9 @@ Source:
|
|
|
106
106
|
`)}))}),console.log(" generated json1 op: "+JSON.stringify(zk(e,s.changes,s.startState.doc,n,r)))),t.submitOp(zk(e,s.changes,s.startState.doc,n,r)),this.lock=!1)}destroy(){t.off("op",this.handleOp)}}),kU=({path:t,localPresence:e,usernameRef:n})=>Se.updateListener.of(r=>{if(r.selectionSet){const i=r.state.selection.ranges[0],{from:s,to:o}=i,l={start:[...t,s],end:[...t,o],username:n.current};e.submit(l,a=>{if(a)throw a})}});var Je=function(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n},ke=function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},ps,ho,Jr,ul,Ja,bi,ki,xi,Pi,_i,Ci,Ei,Ti,po,cl,gs,Rh,ms;const xU=function(t){var e=131,n=137,r=0;t+="x";var i=Math.floor(9007199254740991/n);for(let s=0;s<t.length;s++)r>i&&(r=Math.floor(r/n)),r=r*e+t.charCodeAt(s);return r},Ce="0123456789abcdef".split(""),PU=[-2147483648,8388608,32768,128],Kr=[24,16,8,0],ih=[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],yn=[];class _U{constructor(e=!1,n=!1){ps.set(this,void 0),ho.set(this,void 0),Jr.set(this,void 0),ul.set(this,void 0),Ja.set(this,void 0),bi.set(this,void 0),ki.set(this,void 0),xi.set(this,void 0),Pi.set(this,void 0),_i.set(this,void 0),Ci.set(this,void 0),Ei.set(this,void 0),Ti.set(this,void 0),po.set(this,void 0),cl.set(this,void 0),gs.set(this,void 0),Rh.set(this,0),ms.set(this,void 0),this.init(e,n)}init(e,n){n?(yn[0]=yn[16]=yn[1]=yn[2]=yn[3]=yn[4]=yn[5]=yn[6]=yn[7]=yn[8]=yn[9]=yn[10]=yn[11]=yn[12]=yn[13]=yn[14]=yn[15]=0,Je(this,ho,yn)):Je(this,ho,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e?(Je(this,bi,3238371032),Je(this,ki,914150663),Je(this,xi,812702999),Je(this,Pi,4144912697),Je(this,_i,4290775857),Je(this,Ci,1750603025),Je(this,Ei,1694076839),Je(this,Ti,3204075428)):(Je(this,bi,1779033703),Je(this,ki,3144134277),Je(this,xi,1013904242),Je(this,Pi,2773480762),Je(this,_i,1359893119),Je(this,Ci,2600822924),Je(this,Ei,528734635),Je(this,Ti,1541459225)),Je(this,ps,Je(this,ms,Je(this,Jr,Je(this,cl,0)))),Je(this,ul,Je(this,po,!1)),Je(this,Ja,!0),Je(this,gs,e)}update(e){if(ke(this,ul))return this;let n;e instanceof ArrayBuffer?n=new Uint8Array(e):n=e;let r=0;const i=n.length,s=ke(this,ho);for(;r<i;){let o;if(ke(this,po)&&(Je(this,po,!1),s[0]=ke(this,ps),s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),typeof n!="string")for(o=ke(this,ms);r<i&&o<64;++r)s[o>>2]|=n[r]<<Kr[o++&3];else for(o=ke(this,ms);r<i&&o<64;++r){let l=n.charCodeAt(r);l<128?s[o>>2]|=l<<Kr[o++&3]:l<2048?(s[o>>2]|=(192|l>>6)<<Kr[o++&3],s[o>>2]|=(128|l&63)<<Kr[o++&3]):l<55296||l>=57344?(s[o>>2]|=(224|l>>12)<<Kr[o++&3],s[o>>2]|=(128|l>>6&63)<<Kr[o++&3],s[o>>2]|=(128|l&63)<<Kr[o++&3]):(l=65536+((l&1023)<<10|n.charCodeAt(++r)&1023),s[o>>2]|=(240|l>>18)<<Kr[o++&3],s[o>>2]|=(128|l>>12&63)<<Kr[o++&3],s[o>>2]|=(128|l>>6&63)<<Kr[o++&3],s[o>>2]|=(128|l&63)<<Kr[o++&3])}Je(this,Rh,o),Je(this,Jr,ke(this,Jr)+(o-ke(this,ms))),o>=64?(Je(this,ps,s[16]),Je(this,ms,o-64),this.hash(),Je(this,po,!0)):Je(this,ms,o)}return ke(this,Jr)>4294967295&&(Je(this,cl,ke(this,cl)+(ke(this,Jr)/4294967296<<0)),Je(this,Jr,ke(this,Jr)%4294967296)),this}finalize(){if(ke(this,ul))return;Je(this,ul,!0);const e=ke(this,ho),n=ke(this,Rh);e[16]=ke(this,ps),e[n>>2]|=PU[n&3],Je(this,ps,e[16]),n>=56&&(ke(this,po)||this.hash(),e[0]=ke(this,ps),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]=ke(this,cl)<<3|ke(this,Jr)>>>29,e[15]=ke(this,Jr)<<3,this.hash()}hash(){let e=ke(this,bi),n=ke(this,ki),r=ke(this,xi),i=ke(this,Pi),s=ke(this,_i),o=ke(this,Ci),l=ke(this,Ei),a=ke(this,Ti);const u=ke(this,ho);let c,h,f,d,p,g,O,y,m,v;for(let w=16;w<64;++w)d=u[w-15],c=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,d=u[w-2],h=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,u[w]=u[w-16]+c+u[w-7]+h<<0;v=n&r;for(let w=0;w<64;w+=4)ke(this,Ja)?(ke(this,gs)?(O=300032,d=u[0]-1413257819,a=d-150054599<<0,i=d+24177077<<0):(O=704751109,d=u[0]-210244248,a=d-1521486534<<0,i=d+143694565<<0),Je(this,Ja,!1)):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),h=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),O=e&n,f=O^e&r^v,g=s&o^~s&l,d=a+h+g+ih[w]+u[w],p=c+f,a=i+d<<0,i=d+p<<0),c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),h=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),y=i&e,f=y^i&n^O,g=a&s^~a&o,d=l+h+g+ih[w+1]+u[w+1],p=c+f,l=r+d<<0,r=d+p<<0,c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),h=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),m=r&i,f=m^r&e^y,g=l&a^~l&s,d=o+h+g+ih[w+2]+u[w+2],p=c+f,o=n+d<<0,n=d+p<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),h=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),v=n&r,f=v^n&i^m,g=o&l^~o&a,d=s+h+g+ih[w+3]+u[w+3],p=c+f,s=e+d<<0,e=d+p<<0;Je(this,bi,ke(this,bi)+e<<0),Je(this,ki,ke(this,ki)+n<<0),Je(this,xi,ke(this,xi)+r<<0),Je(this,Pi,ke(this,Pi)+i<<0),Je(this,_i,ke(this,_i)+s<<0),Je(this,Ci,ke(this,Ci)+o<<0),Je(this,Ei,ke(this,Ei)+l<<0),Je(this,Ti,ke(this,Ti)+a<<0)}hex(){this.finalize();const e=ke(this,bi),n=ke(this,ki),r=ke(this,xi),i=ke(this,Pi),s=ke(this,_i),o=ke(this,Ci),l=ke(this,Ei),a=ke(this,Ti);let u=Ce[e>>28&15]+Ce[e>>24&15]+Ce[e>>20&15]+Ce[e>>16&15]+Ce[e>>12&15]+Ce[e>>8&15]+Ce[e>>4&15]+Ce[e&15]+Ce[n>>28&15]+Ce[n>>24&15]+Ce[n>>20&15]+Ce[n>>16&15]+Ce[n>>12&15]+Ce[n>>8&15]+Ce[n>>4&15]+Ce[n&15]+Ce[r>>28&15]+Ce[r>>24&15]+Ce[r>>20&15]+Ce[r>>16&15]+Ce[r>>12&15]+Ce[r>>8&15]+Ce[r>>4&15]+Ce[r&15]+Ce[i>>28&15]+Ce[i>>24&15]+Ce[i>>20&15]+Ce[i>>16&15]+Ce[i>>12&15]+Ce[i>>8&15]+Ce[i>>4&15]+Ce[i&15]+Ce[s>>28&15]+Ce[s>>24&15]+Ce[s>>20&15]+Ce[s>>16&15]+Ce[s>>12&15]+Ce[s>>8&15]+Ce[s>>4&15]+Ce[s&15]+Ce[o>>28&15]+Ce[o>>24&15]+Ce[o>>20&15]+Ce[o>>16&15]+Ce[o>>12&15]+Ce[o>>8&15]+Ce[o>>4&15]+Ce[o&15]+Ce[l>>28&15]+Ce[l>>24&15]+Ce[l>>20&15]+Ce[l>>16&15]+Ce[l>>12&15]+Ce[l>>8&15]+Ce[l>>4&15]+Ce[l&15];return ke(this,gs)||(u+=Ce[a>>28&15]+Ce[a>>24&15]+Ce[a>>20&15]+Ce[a>>16&15]+Ce[a>>12&15]+Ce[a>>8&15]+Ce[a>>4&15]+Ce[a&15]),u}toString(){return this.hex()}digest(){this.finalize();const e=ke(this,bi),n=ke(this,ki),r=ke(this,xi),i=ke(this,Pi),s=ke(this,_i),o=ke(this,Ci),l=ke(this,Ei),a=ke(this,Ti),u=[e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,i>>24&255,i>>16&255,i>>8&255,i&255,s>>24&255,s>>16&255,s>>8&255,s&255,o>>24&255,o>>16&255,o>>8&255,o&255,l>>24&255,l>>16&255,l>>8&255,l&255];return ke(this,gs)||u.push(a>>24&255,a>>16&255,a>>8&255,a&255),u}array(){return this.digest()}arrayBuffer(){this.finalize();const e=new ArrayBuffer(ke(this,gs)?28:32),n=new DataView(e);return n.setUint32(0,ke(this,bi)),n.setUint32(4,ke(this,ki)),n.setUint32(8,ke(this,xi)),n.setUint32(12,ke(this,Pi)),n.setUint32(16,ke(this,_i)),n.setUint32(20,ke(this,Ci)),n.setUint32(24,ke(this,Ei)),ke(this,gs)||n.setUint32(28,ke(this,Ti)),e}}ps=new WeakMap,ho=new WeakMap,Jr=new WeakMap,ul=new WeakMap,Ja=new WeakMap,bi=new WeakMap,ki=new WeakMap,xi=new WeakMap,Pi=new WeakMap,_i=new WeakMap,Ci=new WeakMap,Ei=new WeakMap,Ti=new WeakMap,po=new WeakMap,cl=new WeakMap,gs=new WeakMap,Rh=new WeakMap,ms=new WeakMap;function CU(t){const e=new _U;return e.update(t),parseInt(e.hex().substring(0,8),16)}const EU=function(t){var e="#";return t.forEach(function(n){n<16&&(e+=0),e+=n.toString(16)}),e},TU=function(t,e,n){t/=360;var r=n<.5?n*(1+e):n+e-n*e,i=2*n-r;return[t+1/3,t,t-1/3].map(function(s){return s<0&&s++,s>1&&s--,s<1/6?s=i+(r-i)*6*s:s<.5?s=r:s<2/3?s=i+(r-i)*6*(2/3-s):s=i,Math.round(s*255)})};class $U{constructor(e={}){const[n,r]=[e.lightness,e.saturation].map(function(i){return i=i!==void 0?i:[.35,.5,.65],Array.isArray(i)?i.concat():[i]});this.L=n,this.S=r,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=CU,typeof e.hash=="function"&&(this.hash=e.hash),e.hash==="bkdr"&&(this.hash=xU)}hsl(e){var n,r,i,s=this.hash(e),o=727;if(this.hueRanges.length){const l=this.hueRanges[s%this.hueRanges.length];n=s/this.hueRanges.length%o*(l.max-l.min)/o+l.min}else n=s%359;return s=Math.ceil(s/360),r=this.S[s%this.S.length],s=Math.ceil(s/this.S.length),i=this.L[s%this.L.length],[n,r,i]}rgb(e){var n=this.hsl(e);return TU.apply(this,n)}hex(e){var n=this.rgb(e);return EU(n)}}const QU=({path:t,docPresence:e})=>[$t.fromClass(class{constructor(n){this.decorations=bt.of([]);const r={};e.on("receive",(i,s)=>{s&&AU(t,s)?r[i]=s:delete r[i],this.decorations=Te.set(Object.keys(r).map(o=>{const l=r[o],{start:a,end:u}=l,c=a[a.length-1],h=u[u.length-1],f=new $U().rgb(o),{username:d}=l;return c===h?{from:c,to:h,value:Te.widget({side:-1,block:!1,widget:new MU(o,f,d)})}:{from:c,to:h,value:Te.mark({class:"cm-json1-presence",attributes:{style:`
|
|
107
107
|
background-color: rgba(${f}, 0.75);
|
|
108
108
|
mix-blend-mode: luminosity;
|
|
109
|
-
`}})}}),!0),setTimeout(()=>{n.dispatch({annotations:[RU.of(!0)]})},0)})}},{decorations:n=>n.decorations}),DU],RU=hi.define(),AU=(t,e)=>{for(let n=0;n<t.length;n++)if(t[n]!==e.start[n])return!1;return!0};class MU extends Fr{constructor(e,n,r){super(),this.id=e,this.color=n,this.username=r}eq(e){return e.id===this.id}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-json1-presence";const n=document.createElement("div");e.appendChild(n),n.style.borderLeft=`1px solid rgba(${this.color})`;const r=document.createElement("div");return r.className="remote-cursor-username",r.style.top="-20px",r.style.height="20px",r.style.width=`${this.username.length*11}px`,r.style.backgroundColor=`rgba(${this.color})`,r.style.color="black",r.style.textAlign="center",r.appendChild(document.createTextNode(this.username)),e.appendChild(r),e}ignoreEvent(){return!1}}const DU=Se.baseTheme({".cm-json1-presence":{position:"relative"},".cm-json1-presence > div":{position:"absolute",top:"0",bottom:"0",left:"0",right:"0"}}),_Q=pn.define({create:()=>null,update:(t,e)=>{for(const n of e.effects)if(n.is(ry))return n.value;if(!t)return null;if(!e.changes.empty){const n=e.changes.mapPos(t.pos,-1,cn.TrackDel),r=e.changes.mapPos(t.pos+t.text.length,-1,cn.TrackDel);return n===null||r===null||e.newDoc.sliceString(n,r)!==t.text?null:Object.assign(Object.assign({},t),{pos:n})}return t},provide:t=>[Se.decorations.from(t,e=>{if(!e)return Te.none;const n=e.pos,r=e.pos+e.text.length,i=e.rule.className;return Te.set(NU({className:i}).range(n,r))}),Se.contentAttributes.from(t,e=>!e||!e.rule.cursor?{style:""}:{style:`cursor: ${e.rule.cursor}`})]}),ry=tt.define(),NU=t=>{var e;return Te.mark({class:`cm-interact ${(e=t==null?void 0:t.className)!==null&&e!==void 0?e:""}`})},IU=Se.theme({".cm-interact":{background:"rgba(128, 128, 255, 0.2)",borderRadius:"4px"}}),CQ=Pe.define(),EQ=Pe.define({combine:t=>t[t.length-1]}),ZU=$t.define(t=>({target:null,dragging:!1,mouseX:0,mouseY:0,getMatch(){const e=t.state.facet(CQ),n=t.posAtCoords({x:this.mouseX,y:this.mouseY});if(!n)return null;const r=t.state.doc.lineAt(n),i=n-r.from;let s=null;for(const o of e)for(const l of r.text.matchAll(o.regexp)){if(l.index===void 0)continue;const a=l[0];if(!a)continue;const u=l.index,c=l.index+a.length;i<u||i>c||(!s||a.length<s.text.length)&&(s={rule:o,pos:r.from+u,text:a})}return s},updateText(e){return n=>{t.dispatch({effects:ry.of(Object.assign(Object.assign({},e),{text:n})),changes:{from:e.pos,to:e.pos+e.text.length,insert:n}})}},setTarget(e){this.target=e,t.dispatch({effects:ry.of(e)})},isModKeyDown(e){const n=t.state.facet(EQ),r=!!window.navigator&&window.navigator.userAgent.includes("Macintosh");switch(n){case"alt":return e.altKey;case"shift":return e.shiftKey;case"ctrl":return e.ctrlKey;case"meta":return e.metaKey;case"mod":return r?e.metaKey:e.ctrlKey}throw new Error(`Invalid mod key: ${n}`)},update(e){const n=e.state.field(_Q,!1);n!==void 0&&this.target!==n&&(this.target=n,n===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,this.updateText(this.target),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))}}}),LU=(t={})=>{var e,n;return[_Q,IU,ZU,EQ.of((e=t.key)!==null&&e!==void 0?e:"alt"),((n=t.rules)!==null&&n!==void 0?n:[]).map(r=>CQ.of(r))]},WU=({onInteract:t})=>LU({rules:[{regexp:/\"\#([0-9]|[A-F]|[a-f]){6}\"/g,cursor:"pointer",onClick(e,n,r){var u;const s=(u=/\"(?<hex>\#([0-9]|[A-F]|[a-f]){6})\"/.exec(e).groups)==null?void 0:u.hex,o=document.createElement("input");o.type="color",o.value=s.toLowerCase();const l=s.toUpperCase()===s,a=c=>{const h=c.target;h.value&&n(`"${l?h.value.toUpperCase():h.value}"`)};o.addEventListener("input",a),o.click()}},{regexp:new RegExp("(?<!\\#)-?\\b\\d+\\.?\\d*\\b","g"),cursor:"ew-resize",onDrag:(e,n,r)=>{t&&t();const i=Number(e)+r.movementX;isNaN(i)||n(i.toString())}},{regexp:/true|false/g,cursor:"pointer",onClick:(e,n)=>{switch(t&&t(),e){case"true":return n("false");case"false":return n("true")}}},{regexp:/vec2\(-?\b\d+\.?\d*\b\s*(,\s*-?\b\d+\.?\d*\b)?\)/g,cursor:"move",onDrag:(e,n,r)=>{var l,a;const i=/vec2\((?<x>-?\b\d+\.?\d*\b)\s*(,\s*(?<y>-?\b\d+\.?\d*\b))?\)/.exec(e),s=Number((l=i==null?void 0:i.groups)==null?void 0:l.x);let o=Number((a=i==null?void 0:i.groups)==null?void 0:a.y);isNaN(s)||(isNaN(o)&&(o=s),n(`vec2(${s+r.movementX}, ${o-r.movementY})`))}},{regexp:/rgb\(.*\)/g,cursor:"pointer",onClick:(e,n,r)=>{var c,h,f;const i=/rgb\((?<r>\d+)\s*,\s*(?<g>\d+)\s*,\s*(?<b>\d+)\)/.exec(e),s=Number((c=i==null?void 0:i.groups)==null?void 0:c.r),o=Number((h=i==null?void 0:i.groups)==null?void 0:h.g),l=Number((f=i==null?void 0:i.groups)==null?void 0:f.b),a=document.createElement("input");a.type="color",isNaN(s+o+l)||(a.value=XU(s,o,l));const u=d=>{const p=d.target;if(p.value){const[g,O,y]=BU(p.value);n(`rgb(${g}, ${O}, ${y})`)}a.removeEventListener("change",u)};a.addEventListener("change",u),a.click()}},{regexp:/https?:\/\/[^ "]+/g,cursor:"pointer",onClick:e=>{window.open(e)}},{regexp:/rotate\(-?\d*\.?\d*\)/g,cursor:"move",onDragStart(e,n,r){yo={x:r.clientX,y:r.clientY}},onDrag(e,n,r){if(yo==null)return;const i=Math.round(Math.atan2(yo.y-r.clientY,r.clientX-yo.x)*180/Math.PI);n(`rotate(${i})`);const s=new CustomEvent("updateRotateDrag",{detail:i});document.dispatchEvent(s)},onDragEnd(e,n){yo=null}}]});let yo=null;const BU=t=>{const e=parseInt(t.substring(1),16);return[e>>16&255,e>>8&255,e&255]},XU=(t,e,n)=>"#"+t.toString(16)+e.toString(16)+n.toString(16),YU=Se.baseTheme({".color-circle-parent":{display:"inline-block"}});hi.define();const jU=[$t.fromClass(class{constructor(t){this.decorations=bt.of([]),this.view=t}},{decorations:t=>{const e=[],n=t.view.state.doc.iter();let r=n.next(),i=0;for(;!r.done;){if(r.value===`
|
|
109
|
+
`}})}}),!0),setTimeout(()=>{n.dispatch({annotations:[RU.of(!0)]})},0)})}},{decorations:n=>n.decorations}),DU],RU=hi.define(),AU=(t,e)=>{for(let n=0;n<t.length;n++)if(t[n]!==e.start[n])return!1;return!0};class MU extends Fr{constructor(e,n,r){super(),this.id=e,this.color=n,this.username=r}eq(e){return e.id===this.id}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-json1-presence";const n=document.createElement("div");e.appendChild(n),n.style.borderLeft=`1px solid rgba(${this.color})`;const r=document.createElement("div");return r.className="remote-cursor-username",r.style.top="-20px",r.style.height="20px",r.style.width=`${this.username.length*11}px`,r.style.backgroundColor=`rgba(${this.color})`,r.style.color="black",r.style.textAlign="center",r.appendChild(document.createTextNode(this.username)),e.appendChild(r),setTimeout(()=>{r.style.backgroundColor=`rgba(${this.color}, 0.2)`,r.style.color="rgba(0,0,0,0.2)"},2e3),e}ignoreEvent(){return!1}}const DU=Se.baseTheme({".cm-json1-presence":{position:"relative"},".cm-json1-presence > div":{position:"absolute",top:"0",bottom:"0",left:"0",right:"0"}}),_Q=pn.define({create:()=>null,update:(t,e)=>{for(const n of e.effects)if(n.is(ry))return n.value;if(!t)return null;if(!e.changes.empty){const n=e.changes.mapPos(t.pos,-1,cn.TrackDel),r=e.changes.mapPos(t.pos+t.text.length,-1,cn.TrackDel);return n===null||r===null||e.newDoc.sliceString(n,r)!==t.text?null:Object.assign(Object.assign({},t),{pos:n})}return t},provide:t=>[Se.decorations.from(t,e=>{if(!e)return Te.none;const n=e.pos,r=e.pos+e.text.length,i=e.rule.className;return Te.set(NU({className:i}).range(n,r))}),Se.contentAttributes.from(t,e=>!e||!e.rule.cursor?{style:""}:{style:`cursor: ${e.rule.cursor}`})]}),ry=tt.define(),NU=t=>{var e;return Te.mark({class:`cm-interact ${(e=t==null?void 0:t.className)!==null&&e!==void 0?e:""}`})},IU=Se.theme({".cm-interact":{background:"rgba(128, 128, 255, 0.2)",borderRadius:"4px"}}),CQ=Pe.define(),EQ=Pe.define({combine:t=>t[t.length-1]}),ZU=$t.define(t=>({target:null,dragging:!1,mouseX:0,mouseY:0,getMatch(){const e=t.state.facet(CQ),n=t.posAtCoords({x:this.mouseX,y:this.mouseY});if(!n)return null;const r=t.state.doc.lineAt(n),i=n-r.from;let s=null;for(const o of e)for(const l of r.text.matchAll(o.regexp)){if(l.index===void 0)continue;const a=l[0];if(!a)continue;const u=l.index,c=l.index+a.length;i<u||i>c||(!s||a.length<s.text.length)&&(s={rule:o,pos:r.from+u,text:a})}return s},updateText(e){return n=>{t.dispatch({effects:ry.of(Object.assign(Object.assign({},e),{text:n})),changes:{from:e.pos,to:e.pos+e.text.length,insert:n}})}},setTarget(e){this.target=e,t.dispatch({effects:ry.of(e)})},isModKeyDown(e){const n=t.state.facet(EQ),r=!!window.navigator&&window.navigator.userAgent.includes("Macintosh");switch(n){case"alt":return e.altKey;case"shift":return e.shiftKey;case"ctrl":return e.ctrlKey;case"meta":return e.metaKey;case"mod":return r?e.metaKey:e.ctrlKey}throw new Error(`Invalid mod key: ${n}`)},update(e){const n=e.state.field(_Q,!1);n!==void 0&&this.target!==n&&(this.target=n,n===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,this.updateText(this.target),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))}}}),LU=(t={})=>{var e,n;return[_Q,IU,ZU,EQ.of((e=t.key)!==null&&e!==void 0?e:"alt"),((n=t.rules)!==null&&n!==void 0?n:[]).map(r=>CQ.of(r))]},WU=({onInteract:t})=>LU({rules:[{regexp:/\"\#([0-9]|[A-F]|[a-f]){6}\"/g,cursor:"pointer",onClick(e,n,r){var u;const s=(u=/\"(?<hex>\#([0-9]|[A-F]|[a-f]){6})\"/.exec(e).groups)==null?void 0:u.hex,o=document.createElement("input");o.type="color",o.value=s.toLowerCase();const l=s.toUpperCase()===s,a=c=>{const h=c.target;t&&t(),h.value&&n(`"${l?h.value.toUpperCase():h.value}"`)};o.addEventListener("input",a),o.click()}},{regexp:new RegExp("(?<!\\#)-?\\b\\d+\\.?\\d*\\b","g"),cursor:"ew-resize",onDrag:(e,n,r)=>{t&&t();const i=Number(e)+r.movementX;isNaN(i)||n(i.toString())}},{regexp:/true|false/g,cursor:"pointer",onClick:(e,n)=>{switch(t&&t(),e){case"true":return n("false");case"false":return n("true")}}},{regexp:/vec2\(-?\b\d+\.?\d*\b\s*(,\s*-?\b\d+\.?\d*\b)?\)/g,cursor:"move",onDrag:(e,n,r)=>{var l,a;const i=/vec2\((?<x>-?\b\d+\.?\d*\b)\s*(,\s*(?<y>-?\b\d+\.?\d*\b))?\)/.exec(e),s=Number((l=i==null?void 0:i.groups)==null?void 0:l.x);let o=Number((a=i==null?void 0:i.groups)==null?void 0:a.y);isNaN(s)||(isNaN(o)&&(o=s),n(`vec2(${s+r.movementX}, ${o-r.movementY})`))}},{regexp:/rgb\(.*\)/g,cursor:"pointer",onClick:(e,n,r)=>{var c,h,f;const i=/rgb\((?<r>\d+)\s*,\s*(?<g>\d+)\s*,\s*(?<b>\d+)\)/.exec(e),s=Number((c=i==null?void 0:i.groups)==null?void 0:c.r),o=Number((h=i==null?void 0:i.groups)==null?void 0:h.g),l=Number((f=i==null?void 0:i.groups)==null?void 0:f.b),a=document.createElement("input");a.type="color",isNaN(s+o+l)||(a.value=XU(s,o,l));const u=d=>{const p=d.target;if(t&&t(),p.value){const[g,O,y]=BU(p.value);n(`rgb(${g}, ${O}, ${y})`)}a.removeEventListener("change",u)};a.addEventListener("change",u),a.click()}},{regexp:/https?:\/\/[^ "]+/g,cursor:"pointer",onClick:e=>{window.open(e)}},{regexp:/rotate\(-?\d*\.?\d*\)/g,cursor:"move",onDragStart(e,n,r){yo={x:r.clientX,y:r.clientY}},onDrag(e,n,r){if(yo==null)return;const i=Math.round(Math.atan2(yo.y-r.clientY,r.clientX-yo.x)*180/Math.PI);n(`rotate(${i})`);const s=new CustomEvent("updateRotateDrag",{detail:i});document.dispatchEvent(s)},onDragEnd(e,n){yo=null}}]});let yo=null;const BU=t=>{const e=parseInt(t.substring(1),16);return[e>>16&255,e>>8&255,e&255]},XU=(t,e,n)=>"#"+t.toString(16)+e.toString(16)+n.toString(16),YU=Se.baseTheme({".color-circle-parent":{display:"inline-block"}});hi.define();const jU=[$t.fromClass(class{constructor(t){this.decorations=bt.of([]),this.view=t}},{decorations:t=>{const e=[],n=t.view.state.doc.iter();let r=n.next(),i=0;for(;!r.done;){if(r.value===`
|
|
110
110
|
`){i++,r=n.next();continue}const s=r.value.matchAll(/\"\#([0-9]|[A-F]|[a-f]){6}\"/g);let o=s.next();for(;!o.done;){const l=o.value;l.index+=i,e.push(l),o=s.next()}i+=r.value.length,r=n.next()}return Te.set(e.map(s=>({from:s.index+9,to:s.index+9,value:Te.widget({side:-1,widget:new UU(s[0])})})))}}),YU];class UU extends Fr{constructor(e){super(),this.color=e}eq(e){return e.color===this.color}toDOM(e){const n=document.createElement("div");n.setAttribute("style","width:10px;height:10px"),n.className="color-circle-parent";const r=document.createElementNS("http://www.w3.org/2000/svg","svg"),i=document.createElementNS("http://www.w3.org/2000/svg","circle");return i.setAttributeNS(null,"fill",this.color.replace(/\"/g,"")),i.setAttributeNS(null,"r","5"),i.setAttributeNS(null,"cx","5"),i.setAttributeNS(null,"cy","5"),r.setAttributeNS(null,"viewBox","0 0 10 10"),r.setAttributeNS(null,"width","10"),r.setAttributeNS(null,"height","10"),r.appendChild(i),n.appendChild(r),n}ignoreEvent(){return!1}}const FU=$t.fromClass(class{constructor(t){this.showHighlight=!1,this.view=t}},{decorations:t=>{if(!t.showHighlight)return Te.none;const e=[],n=t.view.state.doc.iter();let r=n.next(),i=0;for(;!r.done;){if(r.value===`
|
|
111
|
-
`){i++,r=n.next();continue}const s=r.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 o=s.next();for(;!o.done;){const l=o.value;l.indices[0][0]+=i,l.indices[0][1]+=i,e.push(l),o=s.next()}i+=r.value.length,r=n.next()}return Te.set(e.map(s=>({from:s.indices[0][0],to:s.indices[0][1],value:Te.mark({class:"cm-interact "})})))},eventHandlers:{keydown(t,e){t.key=="Alt"&&(this.showHighlight=!0)},keyup(t,e){t.key=="Alt"&&(this.showHighlight=!1)}}}),zU=$t.fromClass(class{constructor(t){this.view=t,this.textPosition=null,this.rotation=0,document.addEventListener("updateRotateDrag",e=>{this.textPosition=this.view.posAtCoords(yo,!1),this.rotation=e.detail})}},{decorations:t=>yo===null?Te.none:Te.set([{from:t.textPosition,to:t.textPosition,value:Te.widget({side:-1,widget:new qU(t.rotation)})}])});class qU extends Fr{constructor(e){super(),this.angle=e}toDOM(e){const n=document.createElement("div");n.setAttribute("style","width:20px;height:20px"),n.className="color-circle-parent";const r=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 s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttributeNS(null,"x1","10"),s.setAttributeNS(null,"x2","5"),s.setAttributeNS(null,"y1","5"),s.setAttributeNS(null,"y2","5"),s.setAttributeNS(null,"stroke","black"),s.setAttributeNS(null,"transform",`rotate(${360-this.angle},5,5)`),r.setAttributeNS(null,"viewBox","0 0 10 10"),r.setAttributeNS(null,"width","20"),r.setAttributeNS(null,"height","20"),r.appendChild(i),r.appendChild(s),n.appendChild(r),n}ignoreEvent(){return!1}}const Hv=()=>(Math.random()+"").slice(2),VU=({typeScriptWorker:t,fileName:e})=>async r=>{const i=Hv(),s=r.state.doc.toString(),o={event:"autocomplete-request",fileName:e,fileContent:s,position:r.pos,requestId:i};t.postMessage(o);const l=await new Promise(c=>{t.onmessage=h=>{const f=h.data,{event:d,requestId:p,completions:g}=f;d==="post-completions"&&p===p&&c(g)}});if(!l)return{from:r.pos,options:[]};const a=r.matchBefore(/\w*/).from,u=r.matchBefore(/\w*/).text;return u&&(l.entries=l.entries.filter(c=>c.name.startsWith(u))),{from:r.pos,options:l.entries.map(c=>({label:c.name,apply:h=>{h.dispatch({changes:{from:a,to:r.pos,insert:c.name}})}}))}},{insertOp:Vk,replaceOp:GU}=tp,HU=({shareDBDoc:t,fileId:e,tabList:n})=>aa.of([{key:"control-m",run:r=>{var i;return t.data.aiStreams===void 0||t.data.aiStreams[ia]===null||((i=t.data.aiStreams[ia])==null?void 0:i.AIStreamStatus.serverIsRunning)!==!0?TQ(r,t,e,n):$Q(t),!0}}]);let ia=null;const TQ=async(t,e,n,r)=>{const i=await KU(r.map(s=>e.data.files[s.fileId]))+`Current File:
|
|
111
|
+
`){i++,r=n.next();continue}const s=r.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 o=s.next();for(;!o.done;){const l=o.value;l.indices[0][0]+=i,l.indices[0][1]+=i,e.push(l),o=s.next()}i+=r.value.length,r=n.next()}return Te.set(e.map(s=>({from:s.indices[0][0],to:s.indices[0][1],value:Te.mark({class:"cm-interact "})})))},eventHandlers:{keydown(t,e){t.key=="Alt"&&(this.showHighlight=!0)},keyup(t,e){t.key=="Alt"&&(this.showHighlight=!1)}}}),zU=$t.fromClass(class{constructor(t){this.view=t,this.textPosition=null,this.rotation=0,document.addEventListener("updateRotateDrag",e=>{this.textPosition=this.view.posAtCoords(yo,!1),this.rotation=e.detail})}},{decorations:t=>yo===null?Te.none:Te.set([{from:t.textPosition,to:t.textPosition,value:Te.widget({side:-1,widget:new qU(t.rotation)})}])});class qU extends Fr{constructor(e){super(),this.angle=e}toDOM(e){const n=document.createElement("div");n.setAttribute("style","width:20px;height:20px"),n.className="color-circle-parent";const r=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 s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttributeNS(null,"x1","10"),s.setAttributeNS(null,"x2","5"),s.setAttributeNS(null,"y1","5"),s.setAttributeNS(null,"y2","5"),s.setAttributeNS(null,"stroke","black"),s.setAttributeNS(null,"transform",`rotate(${360-this.angle},5,5)`),r.setAttributeNS(null,"viewBox","0 0 10 10"),r.setAttributeNS(null,"width","20"),r.setAttributeNS(null,"height","20"),r.appendChild(i),r.appendChild(s),n.appendChild(r),n}ignoreEvent(){return!1}}const Hv=()=>(Math.random()+"").slice(2),VU=({typeScriptWorker:t,fileName:e})=>async r=>{const i=Hv(),s=r.state.doc.toString(),o={event:"autocomplete-request",fileName:e,fileContent:s,position:r.pos,requestId:i};if(s[r.pos-1]==='"'||s[r.pos-1]==="'"||s[r.pos-1]===";"||s[r.pos-1]==="("||s[r.pos-1]===")")return{from:r.pos,options:[]};t.postMessage(o);const l=await new Promise(c=>{t.onmessage=h=>{const f=h.data,{event:d,requestId:p,completions:g}=f;d==="post-completions"&&p===p&&c(g)}});if(!l)return{from:r.pos,options:[]};const a=r.matchBefore(/\w*/).from,u=r.matchBefore(/\w*/).text;return u&&(l.entries=l.entries.filter(c=>c.name.startsWith(u))),{from:r.pos,options:l.entries.map(c=>({label:c.name,apply:h=>{h.dispatch({changes:{from:a,to:r.pos,insert:c.name}})}}))}},{insertOp:Vk,replaceOp:GU}=tp,HU=({shareDBDoc:t,fileId:e,tabList:n})=>aa.of([{key:"control-m",run:r=>{var i;return t.data.aiStreams===void 0||t.data.aiStreams[ia]===null||((i=t.data.aiStreams[ia])==null?void 0:i.AIStreamStatus.serverIsRunning)!==!0?TQ(r,t,e,n):$Q(t),!0}}]);let ia=null;const TQ=async(t,e,n,r)=>{const i=await KU(r.map(s=>e.data.files[s.fileId]))+`Current File:
|
|
112
112
|
`+t.state.sliceDoc(0,t.state.selection.main.to);console.log(i),ia=Hv(),e.data.aiStreams===void 0&&e.submitOp(Vk(["aiStreams"],{}),{source:"AIClient"}),e.submitOp(Vk(["aiStreams",ia],{AIStreamStatus:{clientWantsToStart:!0,serverIsRunning:!1,text:i,insertionCursor:t.state.selection.main.to,fileId:n}}),{source:"AIClient"})},$Q=t=>{const e=GU(["aiStreams",ia,"AIStreamStatus","clientWantsToStart"],!0,!1);t.submitOp(e,{source:"AIClient"})},KU=async t=>t.map(n=>{const r=n.name.trim(),i=n.text.trim();return`File \`${r}\`:
|
|
113
113
|
\`\`\`${i}\`\`\``}).join(`
|
|
114
114
|
|