diff --git a/assets/index-DL7BUxqm.js b/assets/index-BNfzFvSl.js similarity index 99% rename from assets/index-DL7BUxqm.js rename to assets/index-BNfzFvSl.js index 5f5f9312..7d691ddb 100644 --- a/assets/index-DL7BUxqm.js +++ b/assets/index-BNfzFvSl.js @@ -4472,7 +4472,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) outputColor = vec4(shade, inputColor.a); } } -`;class qre extends cw{constructor({splat:e,viewheight:n}={}){super("CRTShapeEffect",$re,{blendFunction:Qt.NORMAL,attributes:Ea.CONVOLUTION,defines:new Map([["TEXEL","texel"],["TEXTURE_PRECISION_HIGH","1"]]),uniforms:new Map([["splat",new Mn(e)],["viewheight",new Mn(n??128)]])})}get splat(){var e;return(e=this.uniforms.get("splat"))==null?void 0:e.value}set splat(e){const{splat:n,uniforms:r,defines:i}=this,s=r.get("splat"),o=r.get("uvTransform");n!==e&&s&&o&&(s.value=e,o.value=e.matrix,i.delete("TEXTURE_PRECISION_HIGH"),e!==null&&(e.matrixAutoUpdate?(i.set("UV_TRANSFORM","1"),this.setVertexShader(jre)):(i.delete("UV_TRANSFORM"),this.setVertexShader(null)),e.type!==bi&&i.set("TEXTURE_PRECISION_HIGH","1"),(n===null||(n==null?void 0:n.type)!==e.type)&&this.setChanged()))}getTexture(){return this.splat}setTexture(e){this.splat=e}get aspectCorrection(){return this.defines.has("ASPECT_CORRECTION")}set aspectCorrection(e){this.aspectCorrection!==e&&(e?this.defines.set("ASPECT_CORRECTION","1"):this.defines.delete("ASPECT_CORRECTION"),this.setChanged())}get uvTransform(){const e=this.splat;return!!(e!=null&&e.matrixAutoUpdate)}set uvTransform(e){const n=this.splat;Z(n)&&(n.matrixAutoUpdate=e)}setTextureSwizzleRGBA(e,n=e,r=e,i=e){const s="rgba";let o="";(e!==b0.RED||n!==b0.GREEN||r!==b0.BLUE||i!==b0.ALPHA)&&(o=[".",s[e],s[n],s[r],s[i]].join("")),this.defines.set("TEXEL","texel"+o),this.setChanged()}update(){var e;(e=this.splat)!=null&&e.matrixAutoUpdate&&this.splat.updateMatrix()}}const Xre=Rre(qre),Kre="/assets/scratches-BBiC0fzb.gif",aS=t=>t===Object(t)&&!Array.isArray(t)&&typeof t!="function";function YT(t,e){const n=va(s=>s.gl),r=tm(Mb,aS(t)?Object.values(t):t);return Ne.useLayoutEffect(()=>{e==null||e(r)},[e,r]),Ne.useEffect(()=>{if("initTexture"in n){let s=[];Array.isArray(r)?s=r:r instanceof or?s=[r]:aS(r)&&(s=Object.values(r)),s.forEach(o=>{o instanceof or&&n.initTexture(o)})}},[n,r]),Ne.useMemo(()=>{if(aS(t)){const s={};let o=0;for(const a in t)s[a]=r[o++];return s}else return r},[t,r])}YT.preload=t=>tm.preload(Mb,t);YT.clear=t=>tm.clear(Mb,t);function Yre(t){const e=new Set;function n(r){e.has(r.id)||(e.add(r.id),Yt.invoke(r))}return ah("forward",["all"],r=>{e.has(r.id)||(e.add(r.id),t(r))}),n}function Zre(t){return new Worker("/assets/instance-D7v0ZPjX.js",{name:t==null?void 0:t.name})}const Jre=ah("gadgetclient",[],t=>{const{desync:e,gadget:n}=os.getState();switch(t.target){case"reset":t.player===n.player&&os.setState({desync:!1,gadget:t.data});break;case"patch":t.player===n.player&&!e&&os.setState(r=>{try{const{newDocument:i}=Gv(r.gadget,t.data,!0,!1);return{...r,gadget:i}}catch(i){i instanceof kb&&(os.setState({desync:!0}),Jre.reply(t,"desync",void 0,t.player))}return r});break}});function Pp(){return Pp=Object.assign||function(t){for(var e=1;e0}function uw(t){p_++;try{return t()}finally{p_--,p_===0&&rie()}}var hw=!1;function CD(){return hw}function RD(t){hw=!0;try{t()}finally{hw=!1}}function nie(t){return function(){return RD(t)}}var fw=[];function rie(){var t=[].concat(fw);fw=[],ND(t)}function ND(t){var e=new Set;t.forEach(function(n){var r;(n.type==="add"||n.type==="delete")&&n.observable[Br].connections.iterate.forEach(function(i){e.add(i)}),(r=n.observable[Br].connections.byKey.get(n.key))==null||r.forEach(function(i){e.add(i)})}),e.forEach(function(n){n.trigger()})}function T0(t){if(MD()){fw.push(t);return}ND([t])}function IN(t,e){if(t.type==="iterate")t.observable[Br].connections.iterate.add(e);else{var n=t.observable[Br].connections.byKey.get(t.key);n||(n=new Set,t.observable[Br].connections.byKey.set(t.key,n)),n.add(e)}}function A0(t,e){if(!CD()){var n=AD();n&&(IN(t,n),n.registerConnection(t)),e&&(IN(t,e),e.registerConnection(t))}}var JT=Symbol("$skipreactive"),Br=Symbol("$reactive"),ho=Symbol("$reactiveproxy");function Tm(t,e){return!!(t&&t[ho]&&t[ho].implicitObserver===e)}function QT(t){return t[JT]=!0,t}function kD(t){return!!(t&&!Tm(t)&&t[Br])}function dw(t,e,n){if(n===void 0&&(n=!1),t[JT]||Tm(t,e))return t;var r=iie(t,n);if(!e)return r;var i=r[Br].proxiesWithImplicitObserver.get(e);if(!i){var s={implicitObserver:e};Object.setPrototypeOf(s,ID),i=new Proxy(r[Br].raw,s),r[Br].proxiesWithImplicitObserver.set(e,i)}return i}var Yf=dw;function iie(t,e){if(e===void 0&&(e=!1),Tm(t))return t;if(kD(t))return t[Br].proxy;if(t[Br]||t[ho])throw new Error("unexpected");var n={connections:{iterate:new Set,byKey:new Map},proxy:{},raw:t,proxiesWithImplicitObserver:new Map,shallow:e};Object.defineProperty(t,Br,{enumerable:!1,writable:!0,configurable:!0,value:n});var r=new Proxy(t,ID);return n.proxy=r,r}var ID={has:function(e,n){var r=Reflect.has(e,n);return typeof n=="symbol"||A0({observable:e,key:n,type:"has"},this.implicitObserver),r},get:function(e,n,r){if(n===ho)return{implicitObserver:this.implicitObserver};var i=Reflect.get(e,n,r);if(typeof n=="symbol")return n.toString()==="Symbol($reactiveproxy)"&&console.error("warning, Symbol($reactiveproxy) passed, but does not match $reactiveproxy. Multiple Reactive libraries loaded?"),i;if(n==="length"&&Array.isArray(e)?A0({observable:e,type:"iterate"},this.implicitObserver):A0({observable:e,key:n,type:"get"},this.implicitObserver),kD(i))return dw(i,this.implicitObserver);if(e[Br].shallow)return i;if(typeof i=="object"&&i!==null&&!Tm(i,this.implicitObserver)&&!Object.isFrozen(i)){var s=Reflect.getOwnPropertyDescriptor(e,n);if((!s||!(s.writable===!1&&s.configurable===!1))&&(TD()||this.implicitObserver))return dw(i,this.implicitObserver)}return i},ownKeys:function(e){return A0({observable:e,type:"iterate"},this.implicitObserver),Reflect.ownKeys(e)},set:function(e,n,r,i){return uw(function(){if(typeof n=="symbol")return Reflect.set(e,n,r,i);var s=Object.hasOwnProperty.call(e,n),o=Reflect.get(e,n,i),a=Reflect.set(e,n,r,i);if(!s)T0({observable:e,key:n,value:r,type:"add"});else if(r!==o)if(n==="length"&&Array.isArray(e)){if(!(onew Map,pw=t=>{const e=ko();return t.forEach((n,r)=>{e.set(r,n)}),e},Kl=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},lie=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},uie=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Zf=()=>new Set,cS=t=>t[t.length-1],hie=(t,e)=>{for(let n=0;n{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Ul((this._observers.get(e)||ko()).values()).forEach(r=>r(...n))}destroy(){this._observers=ko()}}const Fl=Math.floor,m_=Math.abs,LD=(t,e)=>tt>e?t:e,PD=t=>t!==0?t<0:1/t<0,ON=1,LN=2,lS=4,uS=8,Dp=32,bc=64,Ds=128,Cy=31,mw=63,Vu=127,pie=2147483647,DD=Number.MAX_SAFE_INTEGER,mie=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Fl(t)===t),gie=t=>t.toLowerCase(),_ie=/^\s*/g,vie=t=>t.replace(_ie,""),yie=/([A-Z])/g,PN=(t,e)=>vie(t.replace(yie,n=>`${e}${gie(n)}`)),xie=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;iUp.encode(t),Eie=Up?Sie:xie;let vp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});vp&&vp.decode(new Uint8Array).length===1&&(vp=null);class Am{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Cl=()=>new Am,wie=t=>{let e=t.cpos;for(let n=0;n{const e=new Uint8Array(wie(t));let n=0;for(let r=0;r{const n=t.cbuf.length;n-t.cpos{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},gw=ei,Ht=(t,e)=>{for(;e>Vu;)ei(t,Ds|Vu&e),e=Fl(e/128);ei(t,Vu&e)},eA=(t,e)=>{const n=PD(e);for(n&&(e=-e),ei(t,(e>mw?Ds:0)|(n?bc:0)|mw&e),e=Fl(e/64);e>0;)ei(t,(e>Vu?Ds:0)|Vu&e),e=Fl(e/128)},_w=new Uint8Array(3e4),Tie=_w.length/3,Aie=(t,e)=>{if(e.length{const n=unescape(encodeURIComponent(e)),r=n.length;Ht(t,r);for(let i=0;i{const n=t.cbuf.length,r=t.cpos,i=LD(n-r,e.length),s=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(mh(n*2,s)),t.cbuf.set(e.subarray(i)),t.cpos=s)},xi=(t,e)=>{Ht(t,e.byteLength),Ry(t,e)},tA=(t,e)=>{bie(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Cie=(t,e)=>tA(t,4).setFloat32(0,e,!1),Rie=(t,e)=>tA(t,8).setFloat64(0,e,!1),Nie=(t,e)=>tA(t,8).setBigInt64(0,e,!1),DN=new DataView(new ArrayBuffer(4)),kie=t=>(DN.setFloat32(0,t),DN.getFloat32(0)===t),Fp=(t,e)=>{switch(typeof e){case"string":ei(t,119),Cf(t,e);break;case"number":mie(e)&&m_(e)<=pie?(ei(t,125),eA(t,e)):kie(e)?(ei(t,124),Cie(t,e)):(ei(t,123),Rie(t,e));break;case"bigint":ei(t,122),Nie(t,e);break;case"object":if(e===null)ei(t,126);else if(fie(e)){ei(t,117),Ht(t,e.length);for(let n=0;n0&&Ht(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const FN=t=>{t.count>0&&(eA(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ht(t.encoder,t.count-2))};class g_{constructor(){this.encoder=new Am,this.s=0,this.count=0}write(e){this.s===e?this.count++:(FN(this),this.count=1,this.s=e)}toUint8Array(){return FN(this),Mo(this.encoder)}}const BN=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);eA(t.encoder,e),t.count>1&&Ht(t.encoder,t.count-2)}};class hS{constructor(){this.encoder=new Am,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(BN(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return BN(this),Mo(this.encoder)}}class Iie{constructor(){this.sarr=[],this.s="",this.lensE=new g_}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Am;return this.sarr.push(this.s),this.s="",Cf(e,this.sarr.join("")),Ry(e,this.lensE.toUint8Array()),Mo(e)}}const Bl=t=>new Error(t),wa=()=>{throw Bl("Method unimplemented")},Na=()=>{throw Bl("Unexpected case")},UD=Bl("Unexpected end of array"),FD=Bl("Integer out of Range");class Ny{constructor(e){this.arr=e,this.pos=0}}const gh=t=>new Ny(t),Oie=t=>t.pos!==t.arr.length,Lie=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Oi=t=>Lie(t,Gt(t)),Jf=t=>t.arr[t.pos++],Gt=t=>{let e=0,n=1;const r=t.arr.length;for(;t.posDD)throw FD}throw UD},nA=t=>{let e=t.arr[t.pos++],n=e&mw,r=64;const i=(e&bc)>0?-1:1;if(!(e&Ds))return i*n;const s=t.arr.length;for(;t.posDD)throw FD}throw UD},Pie=t=>{let e=Gt(t);if(e===0)return"";{let n=String.fromCodePoint(Jf(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Jf(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Die=t=>vp.decode(Oi(t)),Rf=vp?Die:Pie,rA=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Uie=t=>rA(t,4).getFloat32(0,!1),Fie=t=>rA(t,8).getFloat64(0,!1),Bie=t=>rA(t,8).getBigInt64(0,!1),zie=[t=>{},t=>null,nA,Uie,Fie,Bie,t=>!1,t=>!0,Rf,t=>{const e=Gt(t),n={};for(let r=0;r{const e=Gt(t),n=[];for(let r=0;rzie[127-Jf(t)](t);class zN extends Ny{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Oie(this)?this.count=Gt(this)+1:this.count=-1),this.count--,this.s}}class __ extends Ny{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=nA(this);const e=PD(this.s);this.count=1,e&&(this.s=-this.s,this.count=Gt(this)+2)}return this.count--,this.s}}class fS extends Ny{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=nA(this),n=e&1;this.diff=Fl(e/2),this.count=1,n&&(this.count=Gt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Vie{constructor(e){this.decoder=new __(e),this.str=Rf(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const Hie=crypto.getRandomValues.bind(crypto),BD=()=>Hie(new Uint32Array(1))[0],Gie="10000000-1000-4000-8000"+-1e11,Wie=()=>Gie.replace(/[018]/g,t=>(t^BD()&15>>t/4).toString(16)),VN=t=>new Promise(t);Promise.all.bind(Promise);const HN=t=>t===void 0?null:t;class jie{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let zD=new jie,$ie=!0;try{typeof localStorage<"u"&&localStorage&&(zD=localStorage,$ie=!1)}catch{}const qie=zD,Xie=Object.assign,Kie=Object.keys,Yie=(t,e)=>{for(const n in t)e(t[n],n)},GN=t=>Kie(t).length,Zie=t=>{for(const e in t)return!1;return!0},Jie=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Qie=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ese=(t,e)=>t===e||GN(t)===GN(e)&&Jie(t,(n,r)=>(n!==void 0||Qie(e,r))&&e[r]===n),tse=Object.freeze,VD=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&VD(t[e])}return tse(t)},iA=(t,e,n=0)=>{try{for(;nt,rse=(t,e)=>e.includes(t);var HD={};const zp=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";let ia;const ise=()=>{if(ia===void 0)if(zp){ia=ko();const t=process.argv;let e=null;for(let n=0;n{if(t.length!==0){const[e,n]=t.split("=");ia.set(`--${PN(e,"-")}`,n),ia.set(`-${PN(e,"-")}`,n)}})):ia=ko();return ia},vw=t=>ise().has(t),sv=t=>HN(zp?HD[t.toUpperCase().replaceAll("-","_")]:qie.getItem(t)),GD=t=>vw("--"+t)||sv(t)!==null;GD("production");const sse=zp&&rse(HD.FORCE_COLOR,["true","1","2"]),ose=sse||!vw("--no-colors")&&!GD("no-color")&&(!zp||process.stdout.isTTY)&&(!zp||vw("--color")||sv("COLORTERM")!==null||(sv("TERM")||"").includes("color")),ase=t=>new Uint8Array(t),cse=t=>{const e=ase(t.byteLength);return e.set(t),e};class lse{constructor(e,n){this.left=e,this.right=n}}const ac=(t,e)=>new lse(t,e);typeof DOMParser<"u"&&new DOMParser;const use=t=>lie(t,(e,n)=>`${n}:${e};`).join(""),Kc=Symbol,WD=Kc(),jD=Kc(),hse=Kc(),fse=Kc(),dse=Kc(),$D=Kc(),pse=Kc(),sA=Kc(),mse=Kc(),gse=t=>{var i;t.length===1&&((i=t[0])==null?void 0:i.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r0&&n.push(e.join(""));r{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=ko();let i=[],s=0;for(;s0||l.length>0?(e.push("%c"+a),n.push(l)):e.push(a)}else break}}for(s>0&&(i=n,i.unshift(e.join("")));s{console.log(...qD(t)),XD.forEach(e=>e.print(t))},xse=(...t)=>{console.warn(...qD(t)),t.unshift(sA),XD.forEach(e=>e.print(t))},XD=Zf(),KD=t=>({[Symbol.iterator](){return this},next:t}),Sse=(t,e)=>KD(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),dS=(t,e)=>KD(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class oA{constructor(e,n){this.clock=e,this.len=n}}class Mm{constructor(){this.clients=new Map}}const YD=(t,e,n)=>e.clients.forEach((r,i)=>{const s=t.doc.store.clients.get(i);for(let o=0;o{let n=0,r=t.length-1;for(;n<=r;){const i=Fl((n+r)/2),s=t[i],o=s.clock;if(o<=e){if(e{const n=t.clients.get(e.client);return n!==void 0&&Ese(n,e.clock)!==null},aA=t=>{t.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let n,r;for(n=1,r=1;n=s.clock?i.len=mh(i.len,s.clock+s.len-i.clock):(r{const e=new Mm;for(let n=0;n{if(!e.clients.has(i)){const s=r.slice();for(let o=n+1;o{Kl(t.clients,e,()=>[]).push(new oA(n,r))},bse=()=>new Mm,Tse=t=>{const e=bse();return t.clients.forEach((n,r)=>{const i=[];for(let s=0;s0&&e.clients.set(r,i)}),e},_d=(t,e)=>{Ht(t.restEncoder,e.clients.size),Ul(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Ht(t.restEncoder,n);const i=r.length;Ht(t.restEncoder,i);for(let s=0;s{const e=new Mm,n=Gt(t.restDecoder);for(let r=0;r0){const o=Kl(e.clients,i,()=>[]);for(let a=0;a{const r=new Mm,i=Gt(t.restDecoder);for(let s=0;s0){const s=new Qu;return Ht(s.restEncoder,0),_d(s,r),s.toUint8Array()}return null},JD=BD;class Yc extends die{constructor({guid:e=Wie(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=JD(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new aU,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=VN(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const c=()=>VN(l=>{const u=h=>{(h===void 0||h===!0)&&(this.off("sync",u),l())};this.on("sync",u)});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=l===void 0||l===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Dn(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ul(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Dn(this,e,n)}get(e,n=cr){const r=Kl(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),i=r.constructor;if(n!==cr&&i!==n)if(i===cr){const s=new n;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ba)}getText(e=""){return this.get(e,Fo)}getMap(e=""){return this.get(e,ka)}getXmlElement(e=""){return this.get(e,Pc)}getXmlFragment(e=""){return this.get(e,Ia)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ul(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Yc({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Dn(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class QD{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Gt(this.restDecoder)}readDsLen(){return Gt(this.restDecoder)}}class eU extends QD{readLeftID(){return an(Gt(this.restDecoder),Gt(this.restDecoder))}readRightID(){return an(Gt(this.restDecoder),Gt(this.restDecoder))}readClient(){return Gt(this.restDecoder)}readInfo(){return Jf(this.restDecoder)}readString(){return Rf(this.restDecoder)}readParentInfo(){return Gt(this.restDecoder)===1}readTypeRef(){return Gt(this.restDecoder)}readLen(){return Gt(this.restDecoder)}readAny(){return Bp(this.restDecoder)}readBuf(){return cse(Oi(this.restDecoder))}readJSON(){return JSON.parse(Rf(this.restDecoder))}readKey(){return Rf(this.restDecoder)}}class Ase{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Gt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Gt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Qf extends Ase{constructor(e){super(e),this.keys=[],Gt(e),this.keyClockDecoder=new fS(Oi(e)),this.clientDecoder=new __(Oi(e)),this.leftClockDecoder=new fS(Oi(e)),this.rightClockDecoder=new fS(Oi(e)),this.infoDecoder=new zN(Oi(e),Jf),this.stringDecoder=new Vie(Oi(e)),this.parentInfoDecoder=new zN(Oi(e),Jf),this.typeRefDecoder=new __(Oi(e)),this.lenDecoder=new __(Oi(e))}readLeftID(){return new Nf(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Nf(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Bp(this.restDecoder)}readBuf(){return Oi(this.restDecoder)}readJSON(){return Bp(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e{r=mh(r,e[0].id.clock);const i=Uo(e,r);Ht(t.restEncoder,e.length-i),t.writeClient(n),Ht(t.restEncoder,r);const s=e[i];s.write(t,r-s.id.clock);for(let o=i+1;o{const r=new Map;n.forEach((i,s)=>{ii(e,s)>i&&r.set(s,i)}),ky(e).forEach((i,s)=>{n.has(s)||r.set(s,0)}),Ht(t.restEncoder,r.size),Ul(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{Mse(t,e.clients.get(i),i,s)})},Cse=(t,e)=>{const n=ko(),r=Gt(t.restDecoder);for(let i=0;i{const r=[];let i=Ul(n.keys()).sort((m,g)=>m-g);if(i.length===0)return null;const s=()=>{if(i.length===0)return null;let m=n.get(i[i.length-1]);for(;m.refs.length===m.i;)if(i.pop(),i.length>0)m=n.get(i[i.length-1]);else return null;return m};let o=s();if(o===null)return null;const a=new aU,c=new Map,l=(m,g)=>{const v=c.get(m);(v==null||v>g)&&c.set(m,g)};let u=o.refs[o.i++];const h=new Map,p=()=>{for(const m of r){const g=m.id.client,v=n.get(g);v?(v.i--,a.clients.set(g,v.refs.slice(v.i)),n.delete(g),v.i=0,v.refs=[]):a.clients.set(g,[m]),i=i.filter(y=>y!==g)}r.length=0};for(;;){if(u.constructor!==Qs){const g=Kl(h,u.id.client,()=>ii(e,u.id.client))-u.id.clock;if(g<0)r.push(u),l(u.id.client,u.id.clock-1),p();else{const v=u.getMissing(t,e);if(v!==null){r.push(u);const y=n.get(v)||{refs:[],i:0};if(y.refs.length===y.i)l(v,ii(e,v)),p();else{u=y.refs[y.i++];continue}}else(g===0||g0)u=r.pop();else if(o!==null&&o.i0){const m=new Qu;return lA(m,a,new Map),Ht(m.restEncoder,0),{missing:c,update:m.toUint8Array()}}return null},Nse=(t,e)=>lA(t,e.doc.store,e.beforeState),kse=(t,e,n,r=new Qf(t))=>Dn(e,i=>{i.local=!1;let s=!1;const o=i.doc,a=o.store,c=Cse(r,o),l=Rse(i,a,c),u=a.pendingStructs;if(u){for(const[p,m]of u.missing)if(mm)&&u.missing.set(p,m)}u.update=av([u.update,l.update])}}else a.pendingStructs=l;const h=WN(r,i,a);if(a.pendingDs){const p=new Qf(gh(a.pendingDs));Gt(p.restDecoder);const m=WN(p,i,a);h&&m?a.pendingDs=av([h,m]):a.pendingDs=h||m}else a.pendingDs=h;if(s){const p=a.pendingStructs.update;a.pendingStructs=null,rU(i.doc,p)}},n,!1),rU=(t,e,n,r=Qf)=>{const i=gh(e);kse(i,t,n,new r(i))},Ise=(t,e,n)=>rU(t,e,n,eU),Ose=(t,e,n=new Map)=>{lA(t,e.store,n),_d(t,Tse(e.store))},Lse=(t,e=new Uint8Array([0]),n=new Qu)=>{const r=iU(e);Ose(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(Yse(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===Cm)return Xse(i.map((s,o)=>o===0?s:Jse(s)));if(n.constructor===Qu)return av(i)}return i[0]},Pse=(t,e)=>Lse(t,e,new Cm),Dse=t=>{const e=new Map,n=Gt(t.restDecoder);for(let r=0;rDse(new QD(gh(t))),sU=(t,e)=>(Ht(t.restEncoder,e.size),Ul(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Ht(t.restEncoder,n),Ht(t.restEncoder,r)}),t),Use=(t,e)=>sU(t,ky(e.store)),Fse=(t,e=new nU)=>(t instanceof Map?sU(e,t):Use(e,t),e.toUint8Array()),Bse=t=>Fse(t,new tU);class zse{constructor(){this.l=[]}}const jN=()=>new zse,$N=(t,e)=>t.l.push(e),qN=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},oU=(t,e,n)=>iA(t.l,[e,n]);class Nf{constructor(e,n){this.client=e,this.clock=n}}const M0=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,an=(t,e)=>new Nf(t,e),Vse=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Na()},cf=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ZD(e.ds,t.id),yw=(t,e)=>{const n=Kl(t.meta,yw,Zf),r=t.doc.store;n.has(e)||(e.sv.forEach((i,s)=>{i{}),n.add(e))};class aU{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ky=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},ii=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},cU=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Na()}n.push(e)},Uo=(t,e)=>{let n=0,r=t.length-1,i=t[r],s=i.id.clock;if(s===e)return r;let o=Fl(e/(s+i.length-1)*r);for(;n<=r;){if(i=t[o],s=i.id.clock,s<=e){if(e{const n=t.clients.get(e.client);return n[Uo(n,e.clock)]},pS=Hse,xw=(t,e,n)=>{const r=Uo(e,n),i=e[r];return i.id.clock{const n=t.doc.store.clients.get(e.client);return n[xw(t,n,e.clock)]},XN=(t,e,n)=>{const r=e.clients.get(n.client),i=Uo(r,n.clock),s=r[i];return n.clock!==s.id.clock+s.length-1&&s.constructor!==ks&&r.splice(i+1,0,hv(t,s,n.clock-s.id.clock+1)),s},Gse=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Uo(r,e.id.clock)]=n},lU=(t,e,n,r,i)=>{if(r===0)return;const s=n+r;let o=xw(t,e,n),a;do a=e[o++],se.deleteSet.clients.size===0&&!uie(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(aA(e.deleteSet),Nse(t,e),_d(t,e.deleteSet),!0),YN=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Kl(t.changed,e,Zf).add(n)},v_=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Fr&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const s=e-i;return s&&t.splice(e+1-s,s),s},jse=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){const a=i[o],c=a.clock+a.len;for(let l=Uo(s,a.clock),u=s[l];l{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let s=n.length-1;s>=0;s--){const o=n[s],a=LD(i.length-1,1+Uo(i,o.clock+o.len-1));for(let c=a,l=i[c];c>0&&l.id.clock>=o.clock;l=i[c])c-=1+v_(i,c)}})},uU=(t,e)=>{if(ea.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(n,c)})),a.push(()=>{n.changedParentTypes.forEach((c,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(c=c.filter(u=>u.target._item===null||!u.target._item.deleted),c.forEach(u=>{u.currentTarget=l,u._path=null}),c.sort((u,h)=>u.path.length-h.path.length),oU(l._dEH,c,n))})}),a.push(()=>r.emit("afterTransaction",[n,r])),iA(a,[]),n._needFormattingCleanup&&foe(n)}finally{r.gc&&jse(s,i,r.gcFilter),$se(s,i),n.afterState.forEach((u,h)=>{const p=n.beforeState.get(h)||0;if(p!==u){const m=i.clients.get(h),g=mh(Uo(m,p),1);for(let v=m.length-1;v>=g;)v-=1+v_(m,v)}});for(let u=o.length-1;u>=0;u--){const{client:h,clock:p}=o[u].id,m=i.clients.get(h),g=Uo(m,p);g+11||g>0&&v_(m,g)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(yse(sA,WD,"[yjs] ",jD,$D,"Changed the client-id because another client seems to be using it."),r.clientID=JD()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new Cm;KN(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new Qu;KN(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:c,subdocsRemoved:l}=n;(a.size>0||l.size>0||c.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),l.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:c,added:a,removed:l},r,n]),l.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):uU(t,e+1)}}},Dn=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let s=!1,o=null;t._transaction===null&&(s=!0,t._transaction=new Wse(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const a=t._transaction===i[0];t._transaction=null,a&&uU(i,0)}}return o};function*qse(t){const e=Gt(t.restDecoder);for(let n=0;nav(t,eU,Cm),Kse=(t,e)=>{if(t.constructor===ks){const{client:n,clock:r}=t.id;return new ks(an(n,r+e),t.length-e)}else if(t.constructor===Qs){const{client:n,clock:r}=t.id;return new Qs(an(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new Fr(an(r,i+e),null,an(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},av=(t,e=Qf,n=Qu)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(gh(u)));let i=r.map(u=>new uA(u,!0)),s=null;const o=new n,a=new hA(o);for(;i=i.filter(p=>p.curr!==null),i.sort((p,m)=>{if(p.curr.id.client===m.curr.id.client){const g=p.curr.id.clock-m.curr.id.clock;return g===0?p.curr.constructor===m.curr.constructor?0:p.curr.constructor===Qs?1:-1:g}else return m.curr.id.client-p.curr.id.client}),i.length!==0;){const u=i[0],h=u.curr.id.client;if(s!==null){let p=u.curr,m=!1;for(;p!==null&&p.id.clock+p.length<=s.struct.id.clock+s.struct.length&&p.id.client>=s.struct.id.client;)p=u.next(),m=!0;if(p===null||p.id.client!==h||m&&p.id.clock>s.struct.id.clock+s.struct.length)continue;if(h!==s.struct.id.client)Sl(a,s.struct,s.offset),s={struct:p,offset:0},u.next();else if(s.struct.id.clock+s.struct.length0&&(s.struct.constructor===Qs?s.struct.length-=g:p=Kse(p,g)),s.struct.mergeWith(p)||(Sl(a,s.struct,s.offset),s={struct:p,offset:0},u.next())}}else s={struct:u.curr,offset:0},u.next();for(let p=u.curr;p!==null&&p.id.client===h&&p.id.clock===s.struct.id.clock+s.struct.length&&p.constructor!==Qs;p=u.next())Sl(a,s.struct,s.offset),s={struct:p,offset:0}}s!==null&&(Sl(a,s.struct,s.offset),s=null),fA(a);const c=r.map(u=>cA(u)),l=wse(c);return _d(o,l),o.toUint8Array()},Yse=(t,e,n=Qf,r=Qu)=>{const i=iU(e),s=new r,o=new hA(s),a=new n(gh(t)),c=new uA(a,!1);for(;c.curr;){const u=c.curr,h=u.id.client,p=i.get(h)||0;if(c.curr.constructor===Qs){c.next();continue}if(u.id.clock+u.length>p)for(Sl(o,u,mh(p-u.id.clock,0)),c.next();c.curr&&c.curr.id.client===h;)Sl(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===h&&c.curr.id.clock+c.curr.length<=p;)c.next()}fA(o);const l=cA(a);return _d(s,l),s.toUint8Array()},hU=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Mo(t.encoder.restEncoder)}),t.encoder.restEncoder=Cl(),t.written=0)},Sl=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&hU(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ht(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},fA=t=>{hU(t);const e=t.encoder.restEncoder;Ht(e,t.clientStructs.length);for(let n=0;n{const i=new n(gh(t)),s=new uA(i,!1),o=new r,a=new hA(o);for(let l=s.curr;l!==null;l=s.next())Sl(a,e(l),0);fA(a);const c=cA(i);return _d(o,c),o.toUint8Array()},Jse=t=>Zse(t,nse,Qf,Cm),ZN="You must not compute changes after the event-handler fired.";class Iy{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Qse(this.currentTarget,this.target))}deletes(e){return ZD(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Bl(ZN);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const s=n._map.get(i);let o,a;if(this.adds(s)){let c=s.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",a=cS(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",a=cS(c.content.getContent())):(o="add",a=void 0)}else if(this.deletes(s))o="delete",a=cS(s.content.getContent());else return;e.set(i,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Bl(ZN);const n=this.target,r=Zf(),i=Zf(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const c=()=>{a&&s.push(a)};for(let l=n._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((a===null||a.delete===void 0)&&(c(),a={delete:0}),a.delete+=l.length,i.add(l)):this.adds(l)?((a===null||a.insert===void 0)&&(c(),a={insert:[]}),a.insert=a.insert.concat(l.content.getContent()),r.add(l)):((a===null||a.retain===void 0)&&(c(),a={retain:0}),a.retain+=l.length);a!==null&&a.retain===void 0&&c()}this._changes=e}return e}}const Qse=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}e=e._item.parent}return n},wi=()=>{xse("Invalid access: Add Yjs type to a document before reading data.")},fU=80;let dA=0;class eoe{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=dA++}}const toe=t=>{t.timestamp=dA++},dU=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=dA++},noe=(t,e,n)=>{if(t.length>=fU){const r=t.reduce((i,s)=>i.timestamp{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,o)=>m_(e-s.index)e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&m_(n.index-i){for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){t.splice(r,1);continue}i.p=s,s.marker=!0}(e0&&e===i.index)&&(i.index=mh(e,i.index+n))}},Ly=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Kl(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;oU(r._eH,n,e)};class cr{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=jN(),this._dEH=jN(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw wa()}clone(){throw wa()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){$N(this._eH,e)}observeDeep(e){$N(this._dEH,e)}unobserve(e){qN(this._eH,e)}unobserveDeep(e){qN(this._dEH,e)}toJSON(){}}const pU=(t,e,n)=>{t.doc??wi(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let s=t._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a0;a++)i.push(o[a]),r--;e=0}}s=s.right}return i},mU=t=>{t.doc??wi();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i{let n=0,r=t._start;for(t.doc??wi();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let s=0;s{const n=[];return Hp(t,(r,i)=>{n.push(e(r,i,t))}),n},roe=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},_U=(t,e)=>{t.doc??wi();const n=Oy(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e{let i=n;const s=t.doc,o=s.clientID,a=s.store,c=n===null?e._start:n.right;let l=[];const u=()=>{l.length>0&&(i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new th(l)),i.integrate(t,0),l=[])};r.forEach(h=>{if(h===null)l.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(h);break;default:switch(u(),h.constructor){case Uint8Array:case ArrayBuffer:i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Rm(new Uint8Array(h))),i.integrate(t,0);break;case Yc:i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Nm(h)),i.integrate(t,0);break;default:if(h instanceof cr)i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Zc(h)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},vU=()=>Bl("Length exceeded!"),yU=(t,e,n,r)=>{if(n>e._length)throw vU();if(n===0)return e._searchMarker&&Vp(e._searchMarker,n,r.length),cv(t,e,null,r);const i=n,s=Oy(e,n);let o=e._start;for(s!==null&&(o=s.p,n-=s.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return cv(t,e,i,n)},xU=(t,e,n,r)=>{if(r===0)return;const i=n,s=r,o=Oy(e,n);let a=e._start;for(o!==null&&(a=o.p,n-=o.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n0&&a!==null;)a.deleted||(r0)throw vU();e._searchMarker&&Vp(e._searchMarker,i,-s+r)},lv=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},pA=(t,e,n,r)=>{const i=e._map.get(n)||null,s=t.doc,o=s.clientID;let a;if(r==null)a=new th([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new th([r]);break;case Uint8Array:a=new Rm(r);break;case Yc:a=new Nm(r);break;default:if(r instanceof cr)a=new Zc(r);else throw new Error("Unexpected content type")}new Fr(an(o,ii(s.store,o)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},mA=(t,e)=>{t.doc??wi();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},SU=t=>{const e={};return t.doc??wi(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},EU=(t,e)=>{t.doc??wi();const n=t._map.get(e);return n!==void 0&&!n.deleted},soe=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&cf(s,e)&&(n[i]=s.content.getContent()[s.length-1])}),n},C0=t=>(t.doc??wi(),Sse(t._map.entries(),e=>!e[1].deleted));class ooe extends Iy{}class ba extends cr{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ba;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ba}clone(){const e=new ba;return e.insert(0,this.toArray().map(n=>n instanceof cr?n.clone():n)),e}get length(){return this.doc??wi(),this._length}_callObserver(e,n){super._callObserver(e,n),Ly(this,e,new ooe(this,e))}insert(e,n){this.doc!==null?Dn(this.doc,r=>{yU(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Dn(this.doc,n=>{ioe(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Dn(this.doc,r=>{xU(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return _U(this,e)}toArray(){return mU(this)}slice(e=0,n=this.length){return pU(this,e,n)}toJSON(){return this.map(e=>e instanceof cr?e.toJSON():e)}map(e){return gU(this,e)}forEach(e){Hp(this,e)}[Symbol.iterator](){return roe(this)}_write(e){e.writeTypeRef(koe)}}const aoe=t=>new ba;class coe extends Iy{constructor(e,n,r){super(e,n),this.keysChanged=r}}class ka extends cr{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new ka}clone(){const e=new ka;return this.forEach((n,r)=>{e.set(r,n instanceof cr?n.clone():n)}),e}_callObserver(e,n){Ly(this,e,new coe(this,e,n))}toJSON(){this.doc??wi();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof cr?i.toJSON():i}}),e}get size(){return[...C0(this)].length}keys(){return dS(C0(this),e=>e[0])}values(){return dS(C0(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return dS(C0(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??wi(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Dn(this.doc,n=>{lv(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Dn(this.doc,r=>{pA(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return mA(this,e)}has(e){return EU(this,e)}clear(){this.doc!==null?Dn(this.doc,e=>{this.forEach(function(n,r,i){lv(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Ioe)}}const loe=t=>new ka,wl=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&ese(t,e);class Sw{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&Na(),this.right.content.constructor){case Wr:this.right.deleted||vd(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const JN=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Wr:e.right.deleted||vd(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n{const i=new Map,s=r?Oy(e,n):null;if(s){const o=new Sw(s.p.left,s.p,s.index,i);return JN(t,o,n-s.index)}else{const o=new Sw(null,e._start,0,i);return JN(t,o,n)}},wU=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Wr&&wl(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,s=i.clientID;r.forEach((o,a)=>{const c=n.left,l=n.right,u=new Fr(an(s,ii(i.store,s)),c,c&&c.lastId,l,l&&l.id,e,null,new Wr(a,o));u.integrate(t,0),n.right=u,n.forward()})},vd=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},bU=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Wr&&wl(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},TU=(t,e,n,r)=>{const i=t.doc,s=i.clientID,o=new Map;for(const a in r){const c=r[a],l=n.currentAttributes.get(a)??null;if(!wl(l,c)){o.set(a,l);const{left:u,right:h}=n;n.right=new Fr(an(s,ii(i.store,s)),u,u&&u.lastId,h,h&&h.id,e,null,new Wr(a,c)),n.right.integrate(t,0),n.forward()}}return o},mS=(t,e,n,r,i)=>{n.currentAttributes.forEach((p,m)=>{i[m]===void 0&&(i[m]=null)});const s=t.doc,o=s.clientID;bU(n,i);const a=TU(t,e,n,i),c=r.constructor===String?new Oa(r):r instanceof cr?new Zc(r):new _h(r);let{left:l,right:u,index:h}=n;e._searchMarker&&Vp(e._searchMarker,n.index,c.getLength()),u=new Fr(an(o,ii(s.store,o)),l,l&&l.lastId,u,u&&u.id,e,null,c),u.integrate(t,0),n.right=u,n.index=h,n.forward(),wU(t,e,n,a)},QN=(t,e,n,r,i)=>{const s=t.doc,o=s.clientID;bU(n,i);const a=TU(t,e,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Wr));){if(!n.right.deleted)switch(n.right.content.constructor){case Wr:{const{key:c,value:l}=n.right.content,u=i[c];if(u!==void 0){if(wl(u,l))a.delete(c);else{if(r===0)break e;a.set(c,l)}n.right.delete(t)}else n.currentAttributes.set(c,l);break}default:r0){let c="";for(;r>0;r--)c+=` +`;class qre extends cw{constructor({splat:e,viewheight:n}={}){super("CRTShapeEffect",$re,{blendFunction:Qt.NORMAL,attributes:Ea.CONVOLUTION,defines:new Map([["TEXEL","texel"],["TEXTURE_PRECISION_HIGH","1"]]),uniforms:new Map([["splat",new Mn(e)],["viewheight",new Mn(n??128)]])})}get splat(){var e;return(e=this.uniforms.get("splat"))==null?void 0:e.value}set splat(e){const{splat:n,uniforms:r,defines:i}=this,s=r.get("splat"),o=r.get("uvTransform");n!==e&&s&&o&&(s.value=e,o.value=e.matrix,i.delete("TEXTURE_PRECISION_HIGH"),e!==null&&(e.matrixAutoUpdate?(i.set("UV_TRANSFORM","1"),this.setVertexShader(jre)):(i.delete("UV_TRANSFORM"),this.setVertexShader(null)),e.type!==bi&&i.set("TEXTURE_PRECISION_HIGH","1"),(n===null||(n==null?void 0:n.type)!==e.type)&&this.setChanged()))}getTexture(){return this.splat}setTexture(e){this.splat=e}get aspectCorrection(){return this.defines.has("ASPECT_CORRECTION")}set aspectCorrection(e){this.aspectCorrection!==e&&(e?this.defines.set("ASPECT_CORRECTION","1"):this.defines.delete("ASPECT_CORRECTION"),this.setChanged())}get uvTransform(){const e=this.splat;return!!(e!=null&&e.matrixAutoUpdate)}set uvTransform(e){const n=this.splat;Z(n)&&(n.matrixAutoUpdate=e)}setTextureSwizzleRGBA(e,n=e,r=e,i=e){const s="rgba";let o="";(e!==b0.RED||n!==b0.GREEN||r!==b0.BLUE||i!==b0.ALPHA)&&(o=[".",s[e],s[n],s[r],s[i]].join("")),this.defines.set("TEXEL","texel"+o),this.setChanged()}update(){var e;(e=this.splat)!=null&&e.matrixAutoUpdate&&this.splat.updateMatrix()}}const Xre=Rre(qre),Kre="/assets/scratches-BBiC0fzb.gif",aS=t=>t===Object(t)&&!Array.isArray(t)&&typeof t!="function";function YT(t,e){const n=va(s=>s.gl),r=tm(Mb,aS(t)?Object.values(t):t);return Ne.useLayoutEffect(()=>{e==null||e(r)},[e,r]),Ne.useEffect(()=>{if("initTexture"in n){let s=[];Array.isArray(r)?s=r:r instanceof or?s=[r]:aS(r)&&(s=Object.values(r)),s.forEach(o=>{o instanceof or&&n.initTexture(o)})}},[n,r]),Ne.useMemo(()=>{if(aS(t)){const s={};let o=0;for(const a in t)s[a]=r[o++];return s}else return r},[t,r])}YT.preload=t=>tm.preload(Mb,t);YT.clear=t=>tm.clear(Mb,t);function Yre(t){const e=new Set;function n(r){e.has(r.id)||(e.add(r.id),Yt.invoke(r))}return ah("forward",["all"],r=>{e.has(r.id)||(e.add(r.id),t(r))}),n}function Zre(t){return new Worker("/assets/instance-tXT3nSNg.js",{name:t==null?void 0:t.name})}const Jre=ah("gadgetclient",[],t=>{const{desync:e,gadget:n}=os.getState();switch(t.target){case"reset":t.player===n.player&&os.setState({desync:!1,gadget:t.data});break;case"patch":t.player===n.player&&!e&&os.setState(r=>{try{const{newDocument:i}=Gv(r.gadget,t.data,!0,!1);return{...r,gadget:i}}catch(i){i instanceof kb&&(os.setState({desync:!0}),Jre.reply(t,"desync",void 0,t.player))}return r});break}});function Pp(){return Pp=Object.assign||function(t){for(var e=1;e0}function uw(t){p_++;try{return t()}finally{p_--,p_===0&&rie()}}var hw=!1;function CD(){return hw}function RD(t){hw=!0;try{t()}finally{hw=!1}}function nie(t){return function(){return RD(t)}}var fw=[];function rie(){var t=[].concat(fw);fw=[],ND(t)}function ND(t){var e=new Set;t.forEach(function(n){var r;(n.type==="add"||n.type==="delete")&&n.observable[Br].connections.iterate.forEach(function(i){e.add(i)}),(r=n.observable[Br].connections.byKey.get(n.key))==null||r.forEach(function(i){e.add(i)})}),e.forEach(function(n){n.trigger()})}function T0(t){if(MD()){fw.push(t);return}ND([t])}function IN(t,e){if(t.type==="iterate")t.observable[Br].connections.iterate.add(e);else{var n=t.observable[Br].connections.byKey.get(t.key);n||(n=new Set,t.observable[Br].connections.byKey.set(t.key,n)),n.add(e)}}function A0(t,e){if(!CD()){var n=AD();n&&(IN(t,n),n.registerConnection(t)),e&&(IN(t,e),e.registerConnection(t))}}var JT=Symbol("$skipreactive"),Br=Symbol("$reactive"),ho=Symbol("$reactiveproxy");function Tm(t,e){return!!(t&&t[ho]&&t[ho].implicitObserver===e)}function QT(t){return t[JT]=!0,t}function kD(t){return!!(t&&!Tm(t)&&t[Br])}function dw(t,e,n){if(n===void 0&&(n=!1),t[JT]||Tm(t,e))return t;var r=iie(t,n);if(!e)return r;var i=r[Br].proxiesWithImplicitObserver.get(e);if(!i){var s={implicitObserver:e};Object.setPrototypeOf(s,ID),i=new Proxy(r[Br].raw,s),r[Br].proxiesWithImplicitObserver.set(e,i)}return i}var Yf=dw;function iie(t,e){if(e===void 0&&(e=!1),Tm(t))return t;if(kD(t))return t[Br].proxy;if(t[Br]||t[ho])throw new Error("unexpected");var n={connections:{iterate:new Set,byKey:new Map},proxy:{},raw:t,proxiesWithImplicitObserver:new Map,shallow:e};Object.defineProperty(t,Br,{enumerable:!1,writable:!0,configurable:!0,value:n});var r=new Proxy(t,ID);return n.proxy=r,r}var ID={has:function(e,n){var r=Reflect.has(e,n);return typeof n=="symbol"||A0({observable:e,key:n,type:"has"},this.implicitObserver),r},get:function(e,n,r){if(n===ho)return{implicitObserver:this.implicitObserver};var i=Reflect.get(e,n,r);if(typeof n=="symbol")return n.toString()==="Symbol($reactiveproxy)"&&console.error("warning, Symbol($reactiveproxy) passed, but does not match $reactiveproxy. Multiple Reactive libraries loaded?"),i;if(n==="length"&&Array.isArray(e)?A0({observable:e,type:"iterate"},this.implicitObserver):A0({observable:e,key:n,type:"get"},this.implicitObserver),kD(i))return dw(i,this.implicitObserver);if(e[Br].shallow)return i;if(typeof i=="object"&&i!==null&&!Tm(i,this.implicitObserver)&&!Object.isFrozen(i)){var s=Reflect.getOwnPropertyDescriptor(e,n);if((!s||!(s.writable===!1&&s.configurable===!1))&&(TD()||this.implicitObserver))return dw(i,this.implicitObserver)}return i},ownKeys:function(e){return A0({observable:e,type:"iterate"},this.implicitObserver),Reflect.ownKeys(e)},set:function(e,n,r,i){return uw(function(){if(typeof n=="symbol")return Reflect.set(e,n,r,i);var s=Object.hasOwnProperty.call(e,n),o=Reflect.get(e,n,i),a=Reflect.set(e,n,r,i);if(!s)T0({observable:e,key:n,value:r,type:"add"});else if(r!==o)if(n==="length"&&Array.isArray(e)){if(!(onew Map,pw=t=>{const e=ko();return t.forEach((n,r)=>{e.set(r,n)}),e},Kl=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},lie=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},uie=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Zf=()=>new Set,cS=t=>t[t.length-1],hie=(t,e)=>{for(let n=0;n{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Ul((this._observers.get(e)||ko()).values()).forEach(r=>r(...n))}destroy(){this._observers=ko()}}const Fl=Math.floor,m_=Math.abs,LD=(t,e)=>tt>e?t:e,PD=t=>t!==0?t<0:1/t<0,ON=1,LN=2,lS=4,uS=8,Dp=32,bc=64,Ds=128,Cy=31,mw=63,Vu=127,pie=2147483647,DD=Number.MAX_SAFE_INTEGER,mie=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Fl(t)===t),gie=t=>t.toLowerCase(),_ie=/^\s*/g,vie=t=>t.replace(_ie,""),yie=/([A-Z])/g,PN=(t,e)=>vie(t.replace(yie,n=>`${e}${gie(n)}`)),xie=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;iUp.encode(t),Eie=Up?Sie:xie;let vp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});vp&&vp.decode(new Uint8Array).length===1&&(vp=null);class Am{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Cl=()=>new Am,wie=t=>{let e=t.cpos;for(let n=0;n{const e=new Uint8Array(wie(t));let n=0;for(let r=0;r{const n=t.cbuf.length;n-t.cpos{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},gw=ei,Ht=(t,e)=>{for(;e>Vu;)ei(t,Ds|Vu&e),e=Fl(e/128);ei(t,Vu&e)},eA=(t,e)=>{const n=PD(e);for(n&&(e=-e),ei(t,(e>mw?Ds:0)|(n?bc:0)|mw&e),e=Fl(e/64);e>0;)ei(t,(e>Vu?Ds:0)|Vu&e),e=Fl(e/128)},_w=new Uint8Array(3e4),Tie=_w.length/3,Aie=(t,e)=>{if(e.length{const n=unescape(encodeURIComponent(e)),r=n.length;Ht(t,r);for(let i=0;i{const n=t.cbuf.length,r=t.cpos,i=LD(n-r,e.length),s=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(mh(n*2,s)),t.cbuf.set(e.subarray(i)),t.cpos=s)},xi=(t,e)=>{Ht(t,e.byteLength),Ry(t,e)},tA=(t,e)=>{bie(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Cie=(t,e)=>tA(t,4).setFloat32(0,e,!1),Rie=(t,e)=>tA(t,8).setFloat64(0,e,!1),Nie=(t,e)=>tA(t,8).setBigInt64(0,e,!1),DN=new DataView(new ArrayBuffer(4)),kie=t=>(DN.setFloat32(0,t),DN.getFloat32(0)===t),Fp=(t,e)=>{switch(typeof e){case"string":ei(t,119),Cf(t,e);break;case"number":mie(e)&&m_(e)<=pie?(ei(t,125),eA(t,e)):kie(e)?(ei(t,124),Cie(t,e)):(ei(t,123),Rie(t,e));break;case"bigint":ei(t,122),Nie(t,e);break;case"object":if(e===null)ei(t,126);else if(fie(e)){ei(t,117),Ht(t,e.length);for(let n=0;n0&&Ht(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const FN=t=>{t.count>0&&(eA(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ht(t.encoder,t.count-2))};class g_{constructor(){this.encoder=new Am,this.s=0,this.count=0}write(e){this.s===e?this.count++:(FN(this),this.count=1,this.s=e)}toUint8Array(){return FN(this),Mo(this.encoder)}}const BN=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);eA(t.encoder,e),t.count>1&&Ht(t.encoder,t.count-2)}};class hS{constructor(){this.encoder=new Am,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(BN(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return BN(this),Mo(this.encoder)}}class Iie{constructor(){this.sarr=[],this.s="",this.lensE=new g_}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Am;return this.sarr.push(this.s),this.s="",Cf(e,this.sarr.join("")),Ry(e,this.lensE.toUint8Array()),Mo(e)}}const Bl=t=>new Error(t),wa=()=>{throw Bl("Method unimplemented")},Na=()=>{throw Bl("Unexpected case")},UD=Bl("Unexpected end of array"),FD=Bl("Integer out of Range");class Ny{constructor(e){this.arr=e,this.pos=0}}const gh=t=>new Ny(t),Oie=t=>t.pos!==t.arr.length,Lie=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Oi=t=>Lie(t,Gt(t)),Jf=t=>t.arr[t.pos++],Gt=t=>{let e=0,n=1;const r=t.arr.length;for(;t.posDD)throw FD}throw UD},nA=t=>{let e=t.arr[t.pos++],n=e&mw,r=64;const i=(e&bc)>0?-1:1;if(!(e&Ds))return i*n;const s=t.arr.length;for(;t.posDD)throw FD}throw UD},Pie=t=>{let e=Gt(t);if(e===0)return"";{let n=String.fromCodePoint(Jf(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Jf(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Die=t=>vp.decode(Oi(t)),Rf=vp?Die:Pie,rA=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Uie=t=>rA(t,4).getFloat32(0,!1),Fie=t=>rA(t,8).getFloat64(0,!1),Bie=t=>rA(t,8).getBigInt64(0,!1),zie=[t=>{},t=>null,nA,Uie,Fie,Bie,t=>!1,t=>!0,Rf,t=>{const e=Gt(t),n={};for(let r=0;r{const e=Gt(t),n=[];for(let r=0;rzie[127-Jf(t)](t);class zN extends Ny{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Oie(this)?this.count=Gt(this)+1:this.count=-1),this.count--,this.s}}class __ extends Ny{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=nA(this);const e=PD(this.s);this.count=1,e&&(this.s=-this.s,this.count=Gt(this)+2)}return this.count--,this.s}}class fS extends Ny{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=nA(this),n=e&1;this.diff=Fl(e/2),this.count=1,n&&(this.count=Gt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Vie{constructor(e){this.decoder=new __(e),this.str=Rf(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const Hie=crypto.getRandomValues.bind(crypto),BD=()=>Hie(new Uint32Array(1))[0],Gie="10000000-1000-4000-8000"+-1e11,Wie=()=>Gie.replace(/[018]/g,t=>(t^BD()&15>>t/4).toString(16)),VN=t=>new Promise(t);Promise.all.bind(Promise);const HN=t=>t===void 0?null:t;class jie{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let zD=new jie,$ie=!0;try{typeof localStorage<"u"&&localStorage&&(zD=localStorage,$ie=!1)}catch{}const qie=zD,Xie=Object.assign,Kie=Object.keys,Yie=(t,e)=>{for(const n in t)e(t[n],n)},GN=t=>Kie(t).length,Zie=t=>{for(const e in t)return!1;return!0},Jie=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Qie=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ese=(t,e)=>t===e||GN(t)===GN(e)&&Jie(t,(n,r)=>(n!==void 0||Qie(e,r))&&e[r]===n),tse=Object.freeze,VD=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&VD(t[e])}return tse(t)},iA=(t,e,n=0)=>{try{for(;nt,rse=(t,e)=>e.includes(t);var HD={};const zp=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";let ia;const ise=()=>{if(ia===void 0)if(zp){ia=ko();const t=process.argv;let e=null;for(let n=0;n{if(t.length!==0){const[e,n]=t.split("=");ia.set(`--${PN(e,"-")}`,n),ia.set(`-${PN(e,"-")}`,n)}})):ia=ko();return ia},vw=t=>ise().has(t),sv=t=>HN(zp?HD[t.toUpperCase().replaceAll("-","_")]:qie.getItem(t)),GD=t=>vw("--"+t)||sv(t)!==null;GD("production");const sse=zp&&rse(HD.FORCE_COLOR,["true","1","2"]),ose=sse||!vw("--no-colors")&&!GD("no-color")&&(!zp||process.stdout.isTTY)&&(!zp||vw("--color")||sv("COLORTERM")!==null||(sv("TERM")||"").includes("color")),ase=t=>new Uint8Array(t),cse=t=>{const e=ase(t.byteLength);return e.set(t),e};class lse{constructor(e,n){this.left=e,this.right=n}}const ac=(t,e)=>new lse(t,e);typeof DOMParser<"u"&&new DOMParser;const use=t=>lie(t,(e,n)=>`${n}:${e};`).join(""),Kc=Symbol,WD=Kc(),jD=Kc(),hse=Kc(),fse=Kc(),dse=Kc(),$D=Kc(),pse=Kc(),sA=Kc(),mse=Kc(),gse=t=>{var i;t.length===1&&((i=t[0])==null?void 0:i.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r0&&n.push(e.join(""));r{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=ko();let i=[],s=0;for(;s0||l.length>0?(e.push("%c"+a),n.push(l)):e.push(a)}else break}}for(s>0&&(i=n,i.unshift(e.join("")));s{console.log(...qD(t)),XD.forEach(e=>e.print(t))},xse=(...t)=>{console.warn(...qD(t)),t.unshift(sA),XD.forEach(e=>e.print(t))},XD=Zf(),KD=t=>({[Symbol.iterator](){return this},next:t}),Sse=(t,e)=>KD(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),dS=(t,e)=>KD(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class oA{constructor(e,n){this.clock=e,this.len=n}}class Mm{constructor(){this.clients=new Map}}const YD=(t,e,n)=>e.clients.forEach((r,i)=>{const s=t.doc.store.clients.get(i);for(let o=0;o{let n=0,r=t.length-1;for(;n<=r;){const i=Fl((n+r)/2),s=t[i],o=s.clock;if(o<=e){if(e{const n=t.clients.get(e.client);return n!==void 0&&Ese(n,e.clock)!==null},aA=t=>{t.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let n,r;for(n=1,r=1;n=s.clock?i.len=mh(i.len,s.clock+s.len-i.clock):(r{const e=new Mm;for(let n=0;n{if(!e.clients.has(i)){const s=r.slice();for(let o=n+1;o{Kl(t.clients,e,()=>[]).push(new oA(n,r))},bse=()=>new Mm,Tse=t=>{const e=bse();return t.clients.forEach((n,r)=>{const i=[];for(let s=0;s0&&e.clients.set(r,i)}),e},_d=(t,e)=>{Ht(t.restEncoder,e.clients.size),Ul(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Ht(t.restEncoder,n);const i=r.length;Ht(t.restEncoder,i);for(let s=0;s{const e=new Mm,n=Gt(t.restDecoder);for(let r=0;r0){const o=Kl(e.clients,i,()=>[]);for(let a=0;a{const r=new Mm,i=Gt(t.restDecoder);for(let s=0;s0){const s=new Qu;return Ht(s.restEncoder,0),_d(s,r),s.toUint8Array()}return null},JD=BD;class Yc extends die{constructor({guid:e=Wie(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=JD(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new aU,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=VN(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const c=()=>VN(l=>{const u=h=>{(h===void 0||h===!0)&&(this.off("sync",u),l())};this.on("sync",u)});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=l===void 0||l===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Dn(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ul(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Dn(this,e,n)}get(e,n=cr){const r=Kl(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),i=r.constructor;if(n!==cr&&i!==n)if(i===cr){const s=new n;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ba)}getText(e=""){return this.get(e,Fo)}getMap(e=""){return this.get(e,ka)}getXmlElement(e=""){return this.get(e,Pc)}getXmlFragment(e=""){return this.get(e,Ia)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ul(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Yc({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Dn(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class QD{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Gt(this.restDecoder)}readDsLen(){return Gt(this.restDecoder)}}class eU extends QD{readLeftID(){return an(Gt(this.restDecoder),Gt(this.restDecoder))}readRightID(){return an(Gt(this.restDecoder),Gt(this.restDecoder))}readClient(){return Gt(this.restDecoder)}readInfo(){return Jf(this.restDecoder)}readString(){return Rf(this.restDecoder)}readParentInfo(){return Gt(this.restDecoder)===1}readTypeRef(){return Gt(this.restDecoder)}readLen(){return Gt(this.restDecoder)}readAny(){return Bp(this.restDecoder)}readBuf(){return cse(Oi(this.restDecoder))}readJSON(){return JSON.parse(Rf(this.restDecoder))}readKey(){return Rf(this.restDecoder)}}class Ase{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Gt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Gt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Qf extends Ase{constructor(e){super(e),this.keys=[],Gt(e),this.keyClockDecoder=new fS(Oi(e)),this.clientDecoder=new __(Oi(e)),this.leftClockDecoder=new fS(Oi(e)),this.rightClockDecoder=new fS(Oi(e)),this.infoDecoder=new zN(Oi(e),Jf),this.stringDecoder=new Vie(Oi(e)),this.parentInfoDecoder=new zN(Oi(e),Jf),this.typeRefDecoder=new __(Oi(e)),this.lenDecoder=new __(Oi(e))}readLeftID(){return new Nf(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Nf(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Bp(this.restDecoder)}readBuf(){return Oi(this.restDecoder)}readJSON(){return Bp(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e{r=mh(r,e[0].id.clock);const i=Uo(e,r);Ht(t.restEncoder,e.length-i),t.writeClient(n),Ht(t.restEncoder,r);const s=e[i];s.write(t,r-s.id.clock);for(let o=i+1;o{const r=new Map;n.forEach((i,s)=>{ii(e,s)>i&&r.set(s,i)}),ky(e).forEach((i,s)=>{n.has(s)||r.set(s,0)}),Ht(t.restEncoder,r.size),Ul(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{Mse(t,e.clients.get(i),i,s)})},Cse=(t,e)=>{const n=ko(),r=Gt(t.restDecoder);for(let i=0;i{const r=[];let i=Ul(n.keys()).sort((m,g)=>m-g);if(i.length===0)return null;const s=()=>{if(i.length===0)return null;let m=n.get(i[i.length-1]);for(;m.refs.length===m.i;)if(i.pop(),i.length>0)m=n.get(i[i.length-1]);else return null;return m};let o=s();if(o===null)return null;const a=new aU,c=new Map,l=(m,g)=>{const v=c.get(m);(v==null||v>g)&&c.set(m,g)};let u=o.refs[o.i++];const h=new Map,p=()=>{for(const m of r){const g=m.id.client,v=n.get(g);v?(v.i--,a.clients.set(g,v.refs.slice(v.i)),n.delete(g),v.i=0,v.refs=[]):a.clients.set(g,[m]),i=i.filter(y=>y!==g)}r.length=0};for(;;){if(u.constructor!==Qs){const g=Kl(h,u.id.client,()=>ii(e,u.id.client))-u.id.clock;if(g<0)r.push(u),l(u.id.client,u.id.clock-1),p();else{const v=u.getMissing(t,e);if(v!==null){r.push(u);const y=n.get(v)||{refs:[],i:0};if(y.refs.length===y.i)l(v,ii(e,v)),p();else{u=y.refs[y.i++];continue}}else(g===0||g0)u=r.pop();else if(o!==null&&o.i0){const m=new Qu;return lA(m,a,new Map),Ht(m.restEncoder,0),{missing:c,update:m.toUint8Array()}}return null},Nse=(t,e)=>lA(t,e.doc.store,e.beforeState),kse=(t,e,n,r=new Qf(t))=>Dn(e,i=>{i.local=!1;let s=!1;const o=i.doc,a=o.store,c=Cse(r,o),l=Rse(i,a,c),u=a.pendingStructs;if(u){for(const[p,m]of u.missing)if(mm)&&u.missing.set(p,m)}u.update=av([u.update,l.update])}}else a.pendingStructs=l;const h=WN(r,i,a);if(a.pendingDs){const p=new Qf(gh(a.pendingDs));Gt(p.restDecoder);const m=WN(p,i,a);h&&m?a.pendingDs=av([h,m]):a.pendingDs=h||m}else a.pendingDs=h;if(s){const p=a.pendingStructs.update;a.pendingStructs=null,rU(i.doc,p)}},n,!1),rU=(t,e,n,r=Qf)=>{const i=gh(e);kse(i,t,n,new r(i))},Ise=(t,e,n)=>rU(t,e,n,eU),Ose=(t,e,n=new Map)=>{lA(t,e.store,n),_d(t,Tse(e.store))},Lse=(t,e=new Uint8Array([0]),n=new Qu)=>{const r=iU(e);Ose(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(Yse(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===Cm)return Xse(i.map((s,o)=>o===0?s:Jse(s)));if(n.constructor===Qu)return av(i)}return i[0]},Pse=(t,e)=>Lse(t,e,new Cm),Dse=t=>{const e=new Map,n=Gt(t.restDecoder);for(let r=0;rDse(new QD(gh(t))),sU=(t,e)=>(Ht(t.restEncoder,e.size),Ul(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Ht(t.restEncoder,n),Ht(t.restEncoder,r)}),t),Use=(t,e)=>sU(t,ky(e.store)),Fse=(t,e=new nU)=>(t instanceof Map?sU(e,t):Use(e,t),e.toUint8Array()),Bse=t=>Fse(t,new tU);class zse{constructor(){this.l=[]}}const jN=()=>new zse,$N=(t,e)=>t.l.push(e),qN=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},oU=(t,e,n)=>iA(t.l,[e,n]);class Nf{constructor(e,n){this.client=e,this.clock=n}}const M0=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,an=(t,e)=>new Nf(t,e),Vse=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Na()},cf=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ZD(e.ds,t.id),yw=(t,e)=>{const n=Kl(t.meta,yw,Zf),r=t.doc.store;n.has(e)||(e.sv.forEach((i,s)=>{i{}),n.add(e))};class aU{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ky=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},ii=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},cU=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Na()}n.push(e)},Uo=(t,e)=>{let n=0,r=t.length-1,i=t[r],s=i.id.clock;if(s===e)return r;let o=Fl(e/(s+i.length-1)*r);for(;n<=r;){if(i=t[o],s=i.id.clock,s<=e){if(e{const n=t.clients.get(e.client);return n[Uo(n,e.clock)]},pS=Hse,xw=(t,e,n)=>{const r=Uo(e,n),i=e[r];return i.id.clock{const n=t.doc.store.clients.get(e.client);return n[xw(t,n,e.clock)]},XN=(t,e,n)=>{const r=e.clients.get(n.client),i=Uo(r,n.clock),s=r[i];return n.clock!==s.id.clock+s.length-1&&s.constructor!==ks&&r.splice(i+1,0,hv(t,s,n.clock-s.id.clock+1)),s},Gse=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Uo(r,e.id.clock)]=n},lU=(t,e,n,r,i)=>{if(r===0)return;const s=n+r;let o=xw(t,e,n),a;do a=e[o++],se.deleteSet.clients.size===0&&!uie(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(aA(e.deleteSet),Nse(t,e),_d(t,e.deleteSet),!0),YN=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Kl(t.changed,e,Zf).add(n)},v_=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Fr&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const s=e-i;return s&&t.splice(e+1-s,s),s},jse=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){const a=i[o],c=a.clock+a.len;for(let l=Uo(s,a.clock),u=s[l];l{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let s=n.length-1;s>=0;s--){const o=n[s],a=LD(i.length-1,1+Uo(i,o.clock+o.len-1));for(let c=a,l=i[c];c>0&&l.id.clock>=o.clock;l=i[c])c-=1+v_(i,c)}})},uU=(t,e)=>{if(ea.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(n,c)})),a.push(()=>{n.changedParentTypes.forEach((c,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(c=c.filter(u=>u.target._item===null||!u.target._item.deleted),c.forEach(u=>{u.currentTarget=l,u._path=null}),c.sort((u,h)=>u.path.length-h.path.length),oU(l._dEH,c,n))})}),a.push(()=>r.emit("afterTransaction",[n,r])),iA(a,[]),n._needFormattingCleanup&&foe(n)}finally{r.gc&&jse(s,i,r.gcFilter),$se(s,i),n.afterState.forEach((u,h)=>{const p=n.beforeState.get(h)||0;if(p!==u){const m=i.clients.get(h),g=mh(Uo(m,p),1);for(let v=m.length-1;v>=g;)v-=1+v_(m,v)}});for(let u=o.length-1;u>=0;u--){const{client:h,clock:p}=o[u].id,m=i.clients.get(h),g=Uo(m,p);g+11||g>0&&v_(m,g)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(yse(sA,WD,"[yjs] ",jD,$D,"Changed the client-id because another client seems to be using it."),r.clientID=JD()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new Cm;KN(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new Qu;KN(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:c,subdocsRemoved:l}=n;(a.size>0||l.size>0||c.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),l.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:c,added:a,removed:l},r,n]),l.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):uU(t,e+1)}}},Dn=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let s=!1,o=null;t._transaction===null&&(s=!0,t._transaction=new Wse(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const a=t._transaction===i[0];t._transaction=null,a&&uU(i,0)}}return o};function*qse(t){const e=Gt(t.restDecoder);for(let n=0;nav(t,eU,Cm),Kse=(t,e)=>{if(t.constructor===ks){const{client:n,clock:r}=t.id;return new ks(an(n,r+e),t.length-e)}else if(t.constructor===Qs){const{client:n,clock:r}=t.id;return new Qs(an(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new Fr(an(r,i+e),null,an(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},av=(t,e=Qf,n=Qu)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(gh(u)));let i=r.map(u=>new uA(u,!0)),s=null;const o=new n,a=new hA(o);for(;i=i.filter(p=>p.curr!==null),i.sort((p,m)=>{if(p.curr.id.client===m.curr.id.client){const g=p.curr.id.clock-m.curr.id.clock;return g===0?p.curr.constructor===m.curr.constructor?0:p.curr.constructor===Qs?1:-1:g}else return m.curr.id.client-p.curr.id.client}),i.length!==0;){const u=i[0],h=u.curr.id.client;if(s!==null){let p=u.curr,m=!1;for(;p!==null&&p.id.clock+p.length<=s.struct.id.clock+s.struct.length&&p.id.client>=s.struct.id.client;)p=u.next(),m=!0;if(p===null||p.id.client!==h||m&&p.id.clock>s.struct.id.clock+s.struct.length)continue;if(h!==s.struct.id.client)Sl(a,s.struct,s.offset),s={struct:p,offset:0},u.next();else if(s.struct.id.clock+s.struct.length0&&(s.struct.constructor===Qs?s.struct.length-=g:p=Kse(p,g)),s.struct.mergeWith(p)||(Sl(a,s.struct,s.offset),s={struct:p,offset:0},u.next())}}else s={struct:u.curr,offset:0},u.next();for(let p=u.curr;p!==null&&p.id.client===h&&p.id.clock===s.struct.id.clock+s.struct.length&&p.constructor!==Qs;p=u.next())Sl(a,s.struct,s.offset),s={struct:p,offset:0}}s!==null&&(Sl(a,s.struct,s.offset),s=null),fA(a);const c=r.map(u=>cA(u)),l=wse(c);return _d(o,l),o.toUint8Array()},Yse=(t,e,n=Qf,r=Qu)=>{const i=iU(e),s=new r,o=new hA(s),a=new n(gh(t)),c=new uA(a,!1);for(;c.curr;){const u=c.curr,h=u.id.client,p=i.get(h)||0;if(c.curr.constructor===Qs){c.next();continue}if(u.id.clock+u.length>p)for(Sl(o,u,mh(p-u.id.clock,0)),c.next();c.curr&&c.curr.id.client===h;)Sl(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===h&&c.curr.id.clock+c.curr.length<=p;)c.next()}fA(o);const l=cA(a);return _d(s,l),s.toUint8Array()},hU=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Mo(t.encoder.restEncoder)}),t.encoder.restEncoder=Cl(),t.written=0)},Sl=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&hU(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ht(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},fA=t=>{hU(t);const e=t.encoder.restEncoder;Ht(e,t.clientStructs.length);for(let n=0;n{const i=new n(gh(t)),s=new uA(i,!1),o=new r,a=new hA(o);for(let l=s.curr;l!==null;l=s.next())Sl(a,e(l),0);fA(a);const c=cA(i);return _d(o,c),o.toUint8Array()},Jse=t=>Zse(t,nse,Qf,Cm),ZN="You must not compute changes after the event-handler fired.";class Iy{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Qse(this.currentTarget,this.target))}deletes(e){return ZD(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Bl(ZN);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const s=n._map.get(i);let o,a;if(this.adds(s)){let c=s.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))o="delete",a=cS(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",a=cS(c.content.getContent())):(o="add",a=void 0)}else if(this.deletes(s))o="delete",a=cS(s.content.getContent());else return;e.set(i,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Bl(ZN);const n=this.target,r=Zf(),i=Zf(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const c=()=>{a&&s.push(a)};for(let l=n._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((a===null||a.delete===void 0)&&(c(),a={delete:0}),a.delete+=l.length,i.add(l)):this.adds(l)?((a===null||a.insert===void 0)&&(c(),a={insert:[]}),a.insert=a.insert.concat(l.content.getContent()),r.add(l)):((a===null||a.retain===void 0)&&(c(),a={retain:0}),a.retain+=l.length);a!==null&&a.retain===void 0&&c()}this._changes=e}return e}}const Qse=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}e=e._item.parent}return n},wi=()=>{xse("Invalid access: Add Yjs type to a document before reading data.")},fU=80;let dA=0;class eoe{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=dA++}}const toe=t=>{t.timestamp=dA++},dU=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=dA++},noe=(t,e,n)=>{if(t.length>=fU){const r=t.reduce((i,s)=>i.timestamp{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,o)=>m_(e-s.index)e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&m_(n.index-i){for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){t.splice(r,1);continue}i.p=s,s.marker=!0}(e0&&e===i.index)&&(i.index=mh(e,i.index+n))}},Ly=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Kl(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;oU(r._eH,n,e)};class cr{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=jN(),this._dEH=jN(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw wa()}clone(){throw wa()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){$N(this._eH,e)}observeDeep(e){$N(this._dEH,e)}unobserve(e){qN(this._eH,e)}unobserveDeep(e){qN(this._dEH,e)}toJSON(){}}const pU=(t,e,n)=>{t.doc??wi(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let s=t._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a0;a++)i.push(o[a]),r--;e=0}}s=s.right}return i},mU=t=>{t.doc??wi();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i{let n=0,r=t._start;for(t.doc??wi();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let s=0;s{const n=[];return Hp(t,(r,i)=>{n.push(e(r,i,t))}),n},roe=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},_U=(t,e)=>{t.doc??wi();const n=Oy(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e{let i=n;const s=t.doc,o=s.clientID,a=s.store,c=n===null?e._start:n.right;let l=[];const u=()=>{l.length>0&&(i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new th(l)),i.integrate(t,0),l=[])};r.forEach(h=>{if(h===null)l.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(h);break;default:switch(u(),h.constructor){case Uint8Array:case ArrayBuffer:i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Rm(new Uint8Array(h))),i.integrate(t,0);break;case Yc:i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Nm(h)),i.integrate(t,0);break;default:if(h instanceof cr)i=new Fr(an(o,ii(a,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Zc(h)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},vU=()=>Bl("Length exceeded!"),yU=(t,e,n,r)=>{if(n>e._length)throw vU();if(n===0)return e._searchMarker&&Vp(e._searchMarker,n,r.length),cv(t,e,null,r);const i=n,s=Oy(e,n);let o=e._start;for(s!==null&&(o=s.p,n-=s.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return cv(t,e,i,n)},xU=(t,e,n,r)=>{if(r===0)return;const i=n,s=r,o=Oy(e,n);let a=e._start;for(o!==null&&(a=o.p,n-=o.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n0&&a!==null;)a.deleted||(r0)throw vU();e._searchMarker&&Vp(e._searchMarker,i,-s+r)},lv=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},pA=(t,e,n,r)=>{const i=e._map.get(n)||null,s=t.doc,o=s.clientID;let a;if(r==null)a=new th([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new th([r]);break;case Uint8Array:a=new Rm(r);break;case Yc:a=new Nm(r);break;default:if(r instanceof cr)a=new Zc(r);else throw new Error("Unexpected content type")}new Fr(an(o,ii(s.store,o)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},mA=(t,e)=>{t.doc??wi();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},SU=t=>{const e={};return t.doc??wi(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},EU=(t,e)=>{t.doc??wi();const n=t._map.get(e);return n!==void 0&&!n.deleted},soe=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&cf(s,e)&&(n[i]=s.content.getContent()[s.length-1])}),n},C0=t=>(t.doc??wi(),Sse(t._map.entries(),e=>!e[1].deleted));class ooe extends Iy{}class ba extends cr{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ba;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ba}clone(){const e=new ba;return e.insert(0,this.toArray().map(n=>n instanceof cr?n.clone():n)),e}get length(){return this.doc??wi(),this._length}_callObserver(e,n){super._callObserver(e,n),Ly(this,e,new ooe(this,e))}insert(e,n){this.doc!==null?Dn(this.doc,r=>{yU(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Dn(this.doc,n=>{ioe(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Dn(this.doc,r=>{xU(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return _U(this,e)}toArray(){return mU(this)}slice(e=0,n=this.length){return pU(this,e,n)}toJSON(){return this.map(e=>e instanceof cr?e.toJSON():e)}map(e){return gU(this,e)}forEach(e){Hp(this,e)}[Symbol.iterator](){return roe(this)}_write(e){e.writeTypeRef(koe)}}const aoe=t=>new ba;class coe extends Iy{constructor(e,n,r){super(e,n),this.keysChanged=r}}class ka extends cr{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new ka}clone(){const e=new ka;return this.forEach((n,r)=>{e.set(r,n instanceof cr?n.clone():n)}),e}_callObserver(e,n){Ly(this,e,new coe(this,e,n))}toJSON(){this.doc??wi();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof cr?i.toJSON():i}}),e}get size(){return[...C0(this)].length}keys(){return dS(C0(this),e=>e[0])}values(){return dS(C0(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return dS(C0(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??wi(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Dn(this.doc,n=>{lv(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Dn(this.doc,r=>{pA(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return mA(this,e)}has(e){return EU(this,e)}clear(){this.doc!==null?Dn(this.doc,e=>{this.forEach(function(n,r,i){lv(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Ioe)}}const loe=t=>new ka,wl=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&ese(t,e);class Sw{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&Na(),this.right.content.constructor){case Wr:this.right.deleted||vd(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const JN=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Wr:e.right.deleted||vd(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n{const i=new Map,s=r?Oy(e,n):null;if(s){const o=new Sw(s.p.left,s.p,s.index,i);return JN(t,o,n-s.index)}else{const o=new Sw(null,e._start,0,i);return JN(t,o,n)}},wU=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Wr&&wl(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,s=i.clientID;r.forEach((o,a)=>{const c=n.left,l=n.right,u=new Fr(an(s,ii(i.store,s)),c,c&&c.lastId,l,l&&l.id,e,null,new Wr(a,o));u.integrate(t,0),n.right=u,n.forward()})},vd=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},bU=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Wr&&wl(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},TU=(t,e,n,r)=>{const i=t.doc,s=i.clientID,o=new Map;for(const a in r){const c=r[a],l=n.currentAttributes.get(a)??null;if(!wl(l,c)){o.set(a,l);const{left:u,right:h}=n;n.right=new Fr(an(s,ii(i.store,s)),u,u&&u.lastId,h,h&&h.id,e,null,new Wr(a,c)),n.right.integrate(t,0),n.forward()}}return o},mS=(t,e,n,r,i)=>{n.currentAttributes.forEach((p,m)=>{i[m]===void 0&&(i[m]=null)});const s=t.doc,o=s.clientID;bU(n,i);const a=TU(t,e,n,i),c=r.constructor===String?new Oa(r):r instanceof cr?new Zc(r):new _h(r);let{left:l,right:u,index:h}=n;e._searchMarker&&Vp(e._searchMarker,n.index,c.getLength()),u=new Fr(an(o,ii(s.store,o)),l,l&&l.lastId,u,u&&u.id,e,null,c),u.integrate(t,0),n.right=u,n.index=h,n.forward(),wU(t,e,n,a)},QN=(t,e,n,r,i)=>{const s=t.doc,o=s.clientID;bU(n,i);const a=TU(t,e,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Wr));){if(!n.right.deleted)switch(n.right.content.constructor){case Wr:{const{key:c,value:l}=n.right.content,u=i[c];if(u!==void 0){if(wl(u,l))a.delete(c);else{if(r===0)break e;a.set(c,l)}n.right.delete(t)}else n.currentAttributes.set(c,l);break}default:r0){let c="";for(;r>0;r--)c+=` `;n.right=new Fr(an(o,ii(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Oa(c)),n.right.integrate(t,0),n.forward()}wU(t,e,n,a)},AU=(t,e,n,r,i)=>{let s=e;const o=ko();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Wr){const l=s.content;o.set(l.key,l)}s=s.right}let a=0,c=!1;for(;e!==s;){if(n===e&&(c=!0),!e.deleted){const l=e.content;switch(l.constructor){case Wr:{const{key:u,value:h}=l,p=r.get(u)??null;(o.get(u)!==l||p===h)&&(e.delete(t),a++,!c&&(i.get(u)??null)===h&&p!==h&&(p===null?i.delete(u):i.set(u,p))),!c&&!e.deleted&&vd(i,l);break}}}e=e.right}return a},uoe=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Wr){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},hoe=t=>{let e=0;return Dn(t.doc,n=>{let r=t._start,i=t._start,s=ko();const o=pw(s);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Wr:vd(o,i.content);break;default:e+=AU(n,r,i,s,o),s=pw(o),r=i;break}i=i.right}}),e},foe=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const s=t.beforeState.get(r)||0;i!==s&&lU(t,n.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===Wr&&o.constructor!==ks&&e.add(o.parent)})}Dn(n,r=>{YD(t,t.deleteSet,i=>{if(i instanceof ks||!i.parent._hasFormatting||e.has(i.parent))return;const s=i.parent;i.content.constructor===Wr?e.add(s):uoe(r,i)});for(const i of e)hoe(i)})},ek=(t,e,n)=>{const r=n,i=pw(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Zc:case _h:case Oa:n{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Dn(e,r=>{const i=new Map,s=new Map;let o=this.target._start,a=null;const c={};let l="",u=0,h=0;const p=()=>{if(a!==null){let m=null;switch(a){case"delete":h>0&&(m={delete:h}),h=0;break;case"insert":(typeof l=="object"||l.length>0)&&(m={insert:l},i.size>0&&(m.attributes={},i.forEach((g,v)=>{g!==null&&(m.attributes[v]=g)}))),l="";break;case"retain":u>0&&(m={retain:u},Zie(c)||(m.attributes=Xie({},c))),u=0;break}m&&n.push(m),a=null}};for(;o!==null;){switch(o.content.constructor){case Zc:case _h:this.adds(o)?this.deletes(o)||(p(),a="insert",l=o.content.getContent()[0],p()):this.deletes(o)?(a!=="delete"&&(p(),a="delete"),h+=1):o.deleted||(a!=="retain"&&(p(),a="retain"),u+=1);break;case Oa:this.adds(o)?this.deletes(o)||(a!=="insert"&&(p(),a="insert"),l+=o.content.str):this.deletes(o)?(a!=="delete"&&(p(),a="delete"),h+=o.length):o.deleted||(a!=="retain"&&(p(),a="retain"),u+=o.length);break;case Wr:{const{key:m,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const v=i.get(m)??null;wl(v,g)?g!==null&&o.delete(r):(a==="retain"&&p(),wl(g,s.get(m)??null)?delete c[m]:c[m]=g)}}else if(this.deletes(o)){s.set(m,g);const v=i.get(m)??null;wl(v,g)||(a==="retain"&&p(),c[m]=v)}else if(!o.deleted){s.set(m,g);const v=c[m];v!==void 0&&(wl(v,g)?v!==null&&o.delete(r):(a==="retain"&&p(),g===null?delete c[m]:c[m]=g))}o.deleted||(a==="insert"&&p(),vd(i,o.content));break}}o=o.right}for(p();n.length>0;){const m=n[n.length-1];if(m.retain!==void 0&&m.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Fo extends cr{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??wi(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new Fo}clone(){const e=new Fo;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new doe(this,e,n);Ly(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??wi();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Oa&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Dn(this.doc,r=>{const i=new Sw(null,this._start,0,new Map);for(let s=0;s0)&&mS(r,this,i,a,o.attributes||{})}else o.retain!==void 0?QN(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&ek(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??wi();const i=[],s=new Map,o=this.doc;let a="",c=this._start;function l(){if(a.length>0){const h={};let p=!1;s.forEach((g,v)=>{p=!0,h[v]=g});const m={insert:a};p&&(m.attributes=h),i.push(m),a=""}}const u=()=>{for(;c!==null;){if(cf(c,e)||n!==void 0&&cf(c,n))switch(c.content.constructor){case Oa:{const h=s.get("ychange");e!==void 0&&!cf(c,e)?(h===void 0||h.user!==c.id.client||h.type!=="removed")&&(l(),s.set("ychange",r?r("removed",c.id):{type:"removed"})):n!==void 0&&!cf(c,n)?(h===void 0||h.user!==c.id.client||h.type!=="added")&&(l(),s.set("ychange",r?r("added",c.id):{type:"added"})):h!==void 0&&(l(),s.delete("ychange")),a+=c.content.str;break}case Zc:case _h:{l();const h={insert:c.content.getContent()[0]};if(s.size>0){const p={};h.attributes=p,s.forEach((m,g)=>{p[g]=m})}i.push(h);break}case Wr:cf(c,e)&&(l(),vd(s,c.content));break}c=c.right}l()};return e||n?Dn(o,h=>{e&&yw(h,e),n&&yw(h,n),u()},"cleanup"):u(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?Dn(i,s=>{const o=R0(s,this,e,!r);r||(r={},o.currentAttributes.forEach((a,c)=>{r[c]=a})),mS(s,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?Dn(i,s=>{const o=R0(s,this,e,!r);mS(s,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Dn(r,i=>{ek(i,R0(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?Dn(i,s=>{const o=R0(s,this,e,!1);o.right!==null&&QN(s,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Dn(this.doc,n=>{lv(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Dn(this.doc,r=>{pA(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return mA(this,e)}getAttributes(){return SU(this)}_write(e){e.writeTypeRef(Ooe)}}const poe=t=>new Fo;class gS{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??wi()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===Pc||n.constructor===Ia)&&n._start!==null)e=n._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Ia extends cr{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ia}clone(){const e=new Ia;return e.insert(0,this.toArray().map(n=>n instanceof cr?n.clone():n)),e}get length(){return this.doc??wi(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new gS(this,e)}querySelector(e){e=e.toUpperCase();const r=new gS(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Ul(new gS(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Ly(this,e,new _oe(this,n,e))}toString(){return gU(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Hp(this,s=>{i.insertBefore(s.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?Dn(this.doc,r=>{yU(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Dn(this.doc,r=>{const i=e&&e instanceof cr?e._item:e;cv(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw Bl("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?Dn(this.doc,r=>{xU(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return mU(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return _U(this,e)}slice(e=0,n=this.length){return pU(this,e,n)}forEach(e){Hp(this,e)}_write(e){e.writeTypeRef(Poe)}}const moe=t=>new Ia;class Pc extends Ia{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new Pc(this.nodeName)}clone(){const e=new Pc(this.nodeName),n=this.getAttributes();return Yie(n,(r,i)=>{typeof r=="string"&&e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof cr?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const a in e)r.push(a);r.sort();const i=r.length;for(let a=0;a0?" "+n.join(" "):"";return`<${s}${o}>${super.toString()}`}removeAttribute(e){this.doc!==null?Dn(this.doc,n=>{lv(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Dn(this.doc,r=>{pA(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return mA(this,e)}hasAttribute(e){return EU(this,e)}getAttributes(e){return e?soe(this,e):SU(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const a=s[o];typeof a=="string"&&i.setAttribute(o,a)}return Hp(this,o=>{i.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(Loe),e.writeKey(this.nodeName)}}const goe=t=>new Pc(t.readKey());class _oe extends Iy{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class ed extends ka{constructor(e){super(),this.hookName=e}_copy(){return new ed(this.hookName)}clone(){const e=new ed(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let s;return i!==void 0?s=i.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(Doe),e.writeKey(this.hookName)}}const voe=t=>new ed(t.readKey());class eh extends Fo{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new eh}clone(){const e=new eh;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const s=[];for(const o in e.attributes[i])s.push({key:o,value:e.attributes[i][o]});s.sort((o,a)=>o.keyi.nodeName=0;i--)r+=``;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Uoe)}}const yoe=t=>new eh;class gA{constructor(e,n){this.id=e,this.length=n}get deleted(){throw wa()}mergeWith(e){return!1}write(e,n,r){throw wa()}integrate(e,n){throw wa()}}const xoe=0;class ks extends gA{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),cU(e.doc.store,this)}write(e,n){e.writeInfo(xoe),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Rm{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Rm(this.content)}splice(e){throw wa()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const Soe=t=>new Rm(t.readBuf());class Gp{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Gp(this.len)}splice(e){const n=new Gp(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){ov(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const Eoe=t=>new Gp(t.readLen()),MU=(t,e)=>new Yc({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Nm{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Nm(MU(this.doc.guid,this.opts))}splice(e){throw wa()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const woe=t=>new Nm(MU(t.readString(),t.readAny()));class _h{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new _h(this.embed)}splice(e){throw wa()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const boe=t=>new _h(t.readJSON());class Wr{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Wr(this.key,this.value)}splice(e){throw wa()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const Toe=t=>new Wr(t.readKey(),t.readJSON());class uv{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new uv(this.arr)}splice(e){const n=new uv(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i{const e=t.readLen(),n=[];for(let r=0;r{const e=t.readLen(),n=[];for(let r=0;r=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Roe=t=>new Oa(t.readString()),Noe=[aoe,loe,poe,goe,moe,voe,yoe],koe=0,Ioe=1,Ooe=2,Loe=3,Poe=4,Doe=5,Uoe=6;class Zc{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Zc(this.type._copy())}splice(e){throw wa()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const Foe=t=>new Zc(Noe[t.readTypeRef()](t)),hv=(t,e,n)=>{const{client:r,clock:i}=e.id,s=new Fr(an(r,i+n),e,an(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=an(e.redone.client,e.redone.clock+n)),e.right=s,s.right!==null&&(s.right.left=s),t._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=n,s};class Fr extends gA{constructor(e,n,r,i,s,o,a,c){super(e,c.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=a,this.redone=null,this.content=c,this.info=this.content.isCountable()?LN:0}set marker(e){(this.info&uS)>0!==e&&(this.info^=uS)}get marker(){return(this.info&uS)>0}get keep(){return(this.info&ON)>0}set keep(e){this.keep!==e&&(this.info^=ON)}get countable(){return(this.info&LN)>0}get deleted(){return(this.info&lS)>0}set deleted(e){this.deleted!==e&&(this.info^=lS)}markDeleted(){this.info|=lS}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ii(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ii(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Nf&&this.id.client!==this.parent.client&&this.parent.clock>=ii(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=XN(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=zl(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===ks||this.right&&this.right.constructor===ks)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Fr&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Fr&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Nf){const r=pS(n,this.parent);r.constructor===ks?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=XN(e,e.doc.store,an(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),M0(this.origin,i.origin)){if(i.id.client{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ov(e.deleteSet,this.id.client,this.id.clock,this.length),YN(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Na();this.content.gc(e),n?Gse(e,this,new ks(this.id,this.length)):this.content=new Gp(this.length)}write(e,n){const r=n>0?an(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Cy|(r===null?0:Ds)|(i===null?0:bc)|(s===null?0:Dp);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const c=a._item;if(c===null){const l=Vse(a);e.writeParentInfo(!0),e.writeString(l)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===Nf?(e.writeParentInfo(!1),e.writeLeftID(a)):Na();s!==null&&e.writeString(s)}this.content.write(e,n)}}const CU=(t,e)=>Boe[e&Cy](t),Boe=[()=>{Na()},Eoe,Aoe,Soe,Roe,boe,Toe,Foe,Coe,woe,()=>{Na()}],zoe=10;class Qs extends gA{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Na()}write(e,n){e.writeInfo(zoe),Ht(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const RU=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},NU="__ $YJS$ __";RU[NU]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");RU[NU]=!0;let Ew,ww,Voe=t=>t();function Hoe(t,e){if(ww)return ww(t,e);Voe(t)}function nh(t,e,n){if(Ew)return Ew.apply(null,arguments);throw new Error("observable implementation not provided. Call enableReactiveBindings, enableVueBindings or enableMobxBindings.")}function Goe(t){Ew=function(e,n,r){const i=t.createAtom(e);return n&&n(),i},ww=(e,n)=>t.reaction(e,n,{fireImmediately:!1})}const tk=new WeakSet;function Woe(t){if(tk.has(t))return t;tk.add(t);let e;const n=new Map;function r(){if(!e){const h=p=>{(p.changes.added.size||p.changes.deleted.size||p.changes.keys.size||p.changes.delta.length)&&e.reportChanged()};e=nh("map",()=>{t.observe(h)},()=>{t.unobserve(h)})}e.reportObserved(t._implicitObserver)}function i(h){let p=n.get(h);if(!p){const m=g=>{p.reportChanged()};p=nh(h+"",()=>{t.observe(m)},()=>{t.unobserve(m)}),n.set(h,p)}p.reportObserved(t._implicitObserver)}const s=t.get;t.get=function(h){if(typeof h!="number")throw new Error("unexpected");return i(h),Reflect.apply(s,this,arguments)};function o(h){const p=t[h];t[h]=function(){return r(),Reflect.apply(p,this,arguments)}}function a(h){let p=t,m=Object.getOwnPropertyDescriptor(p,h);if(m||(p=Object.getPrototypeOf(p),m=Object.getOwnPropertyDescriptor(p,h)),m||(p=Object.getPrototypeOf(p),m=Object.getOwnPropertyDescriptor(p,h)),!m)throw new Error("property not found");const g=m.get;m.get=function(){return this._disableTracking||r(),Reflect.apply(g,this,arguments)},Object.defineProperty(t,h,m)}function c(h,p){let m=t,g=Object.getOwnPropertyDescriptor(m,h);if(g||(m=Object.getPrototypeOf(m),g=Object.getOwnPropertyDescriptor(m,h)),g||(m=Object.getPrototypeOf(m),g=Object.getOwnPropertyDescriptor(m,h)),!g)throw new Error("property not found");Object.defineProperty(t,p,g)}o("forEach"),o("toJSON"),o("toArray"),o("slice"),o("map"),c("length","lengthUntracked"),a("length");const l=t.push;t.push=function(h){this._disableTracking=!0;const p=l.call(this,h);return this._disableTracking=!1,p};const u=t.slice;return t.slice=function(h,p){this._disableTracking=!0;const m=u.call(this,h,p);return this._disableTracking=!1,m},t}const nk=new WeakSet;function joe(t){if(nk.has(t))return t;nk.add(t);let e;function n(){if(!e){let s=Array.from(t.share.keys());const o=a=>{const c=Array.from(t.share.keys());JSON.stringify(s)!==JSON.stringify(c)&&(s=c,e.reportChanged())};e=nh("map",()=>{t.on("beforeObserverCalls",o)},()=>{t.off("beforeObserverCalls",o)})}e.reportObserved(t._implicitObserver)}const r=t.get;t.get=function(s){if(typeof s!="string")throw new Error("unexpected");const o=Reflect.apply(r,this,arguments);return Py(o),o};function i(s){const o=t[s];let a;t[s]=function(){let c,l=arguments;return n(),a&&a.removeObservers(),a=Hoe(()=>(c=Reflect.apply(o,t,l),c),()=>e.reportChanged()),c}}return i("toJSON"),Object.defineProperty(t,"keys",{get:()=>(n(),Object.keys(t.share))}),t}const rk=new WeakSet;function $oe(t){if(rk.has(t))return t;rk.add(t);let e;const n=new Map;function r(){if(!e){const a=c=>{(c.changes.added.size||c.changes.deleted.size||c.changes.keys.size||c.changes.delta.length)&&e.reportChanged()};e=nh("map",()=>{t.observe(a)},()=>{t.unobserve(a)})}e.reportObserved(t._implicitObserver)}function i(a){let c=n.get(a);if(!c){const l=u=>{u.keysChanged.has(a)&&(u.changes.added.size||u.changes.deleted.size||u.changes.keys.size||u.changes.delta.length)&&c.reportChanged()};c=nh(a,()=>{t.observe(l)},()=>{t.unobserve(l)}),n.set(a,c)}c.reportObserved(t._implicitObserver)}const s=t.get;t.get=function(a){if(typeof a!="string")throw new Error("unexpected");return i(a),Reflect.apply(s,this,arguments)};function o(a){const c=t[a];t[a]=function(){return r(),Reflect.apply(c,this,arguments)}}return o("values"),o("entries"),o("keys"),o("forEach"),o("toJSON"),t}const ik=new WeakSet;function sk(t){if(ik.has(t))return t;ik.add(t);let e;const n=i=>{e.reportChanged()};e=nh("text",()=>{t.observe(n)},()=>{t.unobserve(n)});function r(i){const s=t[i];t[i]=function(){return e.reportObserved(this._implicitObserver),Reflect.apply(s,this,arguments)}}return r("toString"),r("toJSON"),t}const ok=new WeakSet;function ak(t){if(ok.has(t))return t;ok.add(t);let e;const n=s=>{(s.changes.added.size||s.changes.deleted.size||s.changes.keys.size||s.changes.delta.length)&&e.reportChanged()};e=nh("xml",()=>{t.observe(n)},()=>{t.unobserve(n)});function r(s){const o=t[s];t[s]=function(){return e.reportObserved(this._implicitObserver),Reflect.apply(o,this,arguments)}}function i(s){let o=t,a=Object.getOwnPropertyDescriptor(o,s);if(a||(o=Object.getPrototypeOf(o),a=Object.getOwnPropertyDescriptor(o,s)),a||(o=Object.getPrototypeOf(o),a=Object.getOwnPropertyDescriptor(o,s)),!a)throw new Error("property not found");const c=a.get;a.get=function(){return e.reportObserved(this._implicitObserver),Reflect.apply(c,this,arguments)},Object.defineProperty(t,s,a)}return r("toString"),r("toDOM"),r("toArray"),r("getAttribute"),i("firstChild"),t}function Py(t){return t instanceof eh||t instanceof Fo?sk(t):t instanceof ba?Woe(t):t instanceof ka?$oe(t):t instanceof Yc||Object.prototype.hasOwnProperty.call(t,"autoLoad")?joe(t):t instanceof Ia||t instanceof Pc?ak(t):t}function ck(t){t.share.forEach(e=>{e.constructor!==cr&&Py(e)})}function lk(t,e){for(let r=t.length-1;r>=e;r--){let i=t[r];if(!i.deleted){var n;if(i instanceof ks)continue;(n=i.content)==null||n.getContent().forEach(s=>{s instanceof cr&&Py(s)})}}}const uk=new WeakSet;function qoe(t){uk.has(t)||(uk.add(t),Py(t),t.store.clients.forEach(e=>{e&&lk(e,0)}),ck(t),t.on("beforeObserverCalls",e=>{ck(t),e.afterState.forEach((n,r)=>{const i=e.beforeState.get(r)||0;if(i!==n){const s=e.doc.store.clients.get(r);if(!s)return;const o=Uo(s,i);lk(s,o)}})}))}class Wp{constructor(e){this.value=void 0,this.value=e}}function Xoe(t){return ArrayBuffer.isView(t)?new Wp(t):new Wp(Object.freeze(t))}function Koe(t){const e=function(){var a;let c=(a=this[ho])==null?void 0:a.implicitObserver;return t._implicitObserver=c,t.slice.bind(t).apply(t,arguments).map(u=>{const h=Dy(u,c);return c&&typeof h=="object"?Yf(h,c):h})},n=function(a){return a.map(c=>{const l=_A(c);let u=Vl(l)||l;if(u instanceof Wp&&(u=u.value),u instanceof cr&&u.parent)throw new Error("Not supported: reassigning object that already occurs in the tree.");return u})},r=function(){return[].findIndex.apply(e.apply(this),arguments)},i={slice:e,unshift:(...o)=>(t.unshift(n(o)),t.lengthUntracked),push:(...o)=>(t.push(n(o)),t.lengthUntracked),insert:t.insert.bind(t),toJSON:t.toJSON.bind(t),forEach:function(){return[].forEach.apply(e.apply(this),arguments)},every:function(){return[].every.apply(e.apply(this),arguments)},filter:function(){return[].filter.apply(e.apply(this),arguments)},find:function(){return[].find.apply(e.apply(this),arguments)},findIndex:r,some:function(){return[].some.apply(e.apply(this),arguments)},includes:function(){return[].includes.apply(e.apply(this),arguments)},map:function(){return[].map.apply(e.apply(this),arguments)},indexOf:function(){const o=arguments[0];return r.call(this,a=>eae(a,o))},splice:function(){let o=arguments[0]<0?t.length-Math.abs(arguments[0]):arguments[0],a=arguments[1],c=Array.from(Array.from(arguments).slice(2)),l=e.apply(this,[o,Number.isInteger(a)?o+a:void 0]);return t.doc?t.doc.transact(()=>{t.delete(o,a),t.insert(o,n(c))}):(t.delete(o,a),t.insert(o,n(c))),l}},s=[];for(let o in i)s[o]=i[o];return s}function Xd(t){if(typeof t=="string"&&t.trim().length){const e=Number(t);if(Number.isInteger(e))return e}return t}function hk(t,e=new ba){if(e[Br])throw new Error("unexpected");const n=Koe(e),r=new Proxy(n,{set:(i,s,o)=>{throw typeof Xd(s)!="number"?new Error:new Error("array assignment is not implemented / supported")},get:(i,s,o)=>{const a=Xd(s);if(a===Uy)return e;if(typeof a=="number"){let u;if(o&&o[ho]){var c;u=(c=o[ho])==null?void 0:c.implicitObserver,e._implicitObserver=u}let h=e.get(a);return h=Dy(h,u),h}if(a===Symbol.toStringTag)return"Array";if(a===Symbol.iterator){const u=e.slice();return Reflect.get(u,a)}return a==="length"?e.length:Reflect.get(i,a,o)},deleteProperty:(i,s)=>{const o=Xd(s);if(typeof o!="number")throw new Error;return o=0?(e.delete(o),!0):!1},has:(i,s)=>{const o=Xd(s);return typeof o!="number"?Reflect.has(i,o):o=0},getOwnPropertyDescriptor(i,s){const o=Xd(s);if(o==="length")return{enumerable:!1,configurable:!1,writable:!0};if(typeof o=="number"&&o>=0&&o{const s=[];for(let o=0;o{if(typeof i!="string")throw new Error;const o=_A(s);let a=Vl(o)||o;if(a instanceof Wp&&(a=a.value),a instanceof cr&&a.parent)throw new Error("Not supported: reassigning object that already occurs in the tree.");return e.set(i,a),!0},get:(r,i,s)=>{if(i===Uy)return e;if(typeof i!="string")return Reflect.get(r,i);let o;if(s&&s[ho]){var a;o=(a=s[ho])==null?void 0:a.implicitObserver,e._implicitObserver=o}let c=e.get(i);return c=Dy(c,o),c},deleteProperty:(r,i)=>{if(typeof i!="string")throw new Error;return e.has(i)?(e.delete(i),!0):!1},has:(r,i)=>!!(typeof i=="string"&&e.has(i)),getOwnPropertyDescriptor(r,i){if(typeof i=="string"&&e.has(i))return{enumerable:!0,configurable:!0}},ownKeys:r=>Array.from(e.keys())});yp.set(e,n);for(let r in t)n[r]=t[r];return n}function Yoe(t){return t instanceof cr}const yp=new WeakMap;function Dy(t,e){if(Yoe(t)){if(t._implicitObserver=e,t instanceof ba||t instanceof ka){if(!yp.has(t)){const n=_A(t);yp.set(t,n)}t=yp.get(t)}else if(t instanceof Pc||t instanceof Ia||t instanceof eh||t instanceof ed||t instanceof Fo)QT(t),t.__v_skip=!0;else throw new Error("unknown YType");return t}else{if(t===null)return null;if(typeof t=="object")return Xoe(t)}return t}function _A(t){if(t==null)return t;if(t=Vl(t)||t,t instanceof ba)return hk([],t);if(t instanceof ka)return fk({},t);if(typeof t=="string")return t;if(Array.isArray(t))return hk(t);if(t instanceof Pc||t instanceof Ia||t instanceof eh||t instanceof ed)return t;if(t instanceof Fo)return t;if(typeof t=="object")return t instanceof Wp?t:fk(t);if(typeof t=="number"||typeof t=="boolean")return t;throw new Error("invalid")}function Zoe(t){for(let[e,n]of Object.entries(t))if(Array.isArray(n)){if(n.length!==0)throw new Error("Root Array initializer must always be empty array")}else if(n&&typeof n=="object"){if(Object.keys(n).length!==0||Object.getPrototypeOf(n)!==Object.prototype)throw new Error("Root Object initializer must always be {}")}else if(n!=="xml"&&n!=="text")throw new Error("unknown Root initializer")}function dk(t,e,n){let r=e[n];if(!r){n!=="__v_raw"&&n!=="__v_isRef"&&n!=="__v_isReadonly"&&console.warn("property not found on root doc",n);return}return r==="xml"?t.getXmlFragment(n):r==="text"?t.getText(n):Array.isArray(r)?t.getArray(n):t.getMap(n)}function Joe(t,e){if(t[Br])throw new Error("unexpected");Zoe(e);const n=new Proxy({},{set:(r,i,s)=>{throw typeof i!="string"?new Error:new Error("cannot set new elements on root doc")},get:(r,i,s)=>{if(i===Uy)return t;if(typeof i!="string")return Reflect.get(r,i);let o;if(s&&s[ho]){var a;o=(a=s[ho])==null?void 0:a.implicitObserver,t._implicitObserver=o}if(i==="toJSON"){for(let u of Object.keys(e))dk(t,e,u);return Reflect.get(t,i)}let c=dk(t,e,i);return c=Dy(c,o),c},deleteProperty:(r,i)=>{throw new Error("deleteProperty not available for doc")},has:(r,i)=>!!(typeof i=="string"&&t.share.has(i)),getOwnPropertyDescriptor(r,i){if(typeof i=="string"&&t.share.has(i)||i==="toJSON")return{enumerable:!0,configurable:!0}},ownKeys:r=>Array.from(t.share.keys())});return yp.set(t,n),n}Goe(cie);const Uy=Symbol("INTERNAL_SYMBOL");function pk(t,e){const n=Vl(t)||t;if(!n)throw new Error("not a valid synced object");return n instanceof Yc?(n.on("update",e),()=>{n.off("update",e)}):(n.observeDeep(e),()=>{n.unobserveDeep(e)})}function Qoe(t){const e=Vl(t);if(!(e instanceof Yc))throw new Error("store is not a valid syncedStore that maps to a Y.Doc");return e}function Vl(t){if(typeof t!="object"||t===null)return;const e=t[Uy];return e&&(QT(e),e.__v_skip=!0),e}function eae(t,e){if(t===e)return!0;if(typeof t=="object"&&typeof e=="object"){const n=Vl(t),r=Vl(e);return!n||!r?!1:n===r}return!1}function tae(t,e=new Yc){return qoe(e),Joe(e,t)}function nae(t,e){var n=Ne.useReducer(function(a){return a+1},0),r=n[1],i=Ne.useRef(),s=Ne.useRef(!1);i.current||(i.current=new ZT(function(){s.current&&r()}));var o=Ne.useMemo(function(){var a;return(a=i.current)==null||a.removeObservers(),Yf(t,i.current)},[]);return Ne.useEffect(function(){return s.current=!0,i.current||r(),function(){var a;s.current=!1,(a=i.current)==null||a.removeObservers(),i.current=null}},[]),o}function rae(t,e){if(!Vl(t))throw new Error("syncedObject passed to useSyncedStore is not a SyncedStore Store or internal data type.");return nae(t)}const vA=0,kU=1,IU=2,iae=(t,e)=>{Ht(t,vA);const n=Bse(e);xi(t,n)},OU=(t,e,n)=>{Ht(t,kU),xi(t,Pse(e,n))},sae=(t,e,n)=>OU(e,n,Oi(t)),LU=(t,e,n)=>{try{Ise(e,Oi(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},oae=(t,e)=>{Ht(t,IU),xi(t,e)},aae=LU,cae=(t,e,n,r)=>{const i=Gt(t);switch(i){case vA:sae(t,e,n);break;case kU:LU(t,n,r);break;case IU:aae(t,n,r);break;default:throw new Error("Unknown message type")}return i},La=tae({shared:[]});function km(t,e,n){return t.find(r=>r.key===e&&r.type===n)}function lae(){return rae(La)}function PU(t,e){const n=lae(),r=km(n.shared,t,e);return Z(r)?r:void 0}function yA(t){return PU(t,0)}function DU(t){return PU(t,1)}function UU(t,e,n){const r=km(La.shared,t,e);Z(r)||La.shared.push({key:t,type:e,value:n})}function uae(t,e){UU(t,0,e)}function FU(t,e){const n=new Fo(e);UU(t,1,n)}function Rl(t,e){const n=km(La.shared,t,0);if(Z(n)){n.value=e;return}La.shared.push({key:t,type:0,value:e})}function hae(t,e){const n=new Fo(e),r=km(La.shared,t,1);if(Z(r)){r.value=n;return}La.shared.push({key:t,type:1,value:n})}function BU(t,e,n){let r;function i(){const o=km(La.shared,t,e);Z(o)&&(s(),r=pk(o,()=>n(o.value)))}const s=pk(La.shared,i);return i(),()=>r==null?void 0:r()}function fae(t,e){return BU(t,0,e)}function dae(t,e){return BU(t,1,n=>e(n.toJSON()))}function y_(t){return Mo(t)}let mk=!1;const bl=Qoe(La),fc=ah("modem",["second"],t=>{switch(t.target){case"second":!mk&&t.data%2===0&&fc.emit("modem:join");break;case"join":if(t.sender!==fc.id()){fc.reply(t,"joinack");const e=Cl();iae(e,bl),fc.reply(t,"sync",y_(e));const n=Cl();OU(n,bl),fc.reply(t,"sync",y_(n))}break;case"joinack":mk=!0;break;case"sync":{if(Z(t.data)&&t.sender!==fc.id()){const e=gh(t.data),n=Cl();cae(e,n,bl,fc)===vA&&fc.emit("modem:sync",y_(n))}break}}});function zU(t){const e=Cl();oae(e,t),fc.emit("modem:sync",y_(e))}bl.on("update",zU);bl.on("destroy",()=>{bl==null||bl.off("update",zU)});const bw=66.666,fv=Math.round(1e3/bw),pae=3;function Zh(t){return new Promise(e=>setTimeout(e,t))}var Ru=(t=>(t[t.Border=-1]="Border",t[t.Data=0]="Data",t[t.Function=1]="Function",t[t.Position=2]="Position",t[t.Timing=3]="Timing",t[t.Alignment=4]="Alignment",t))(Ru||{}),mae=Object.defineProperty,gae=(t,e,n)=>e in t?mae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,N0=(t,e,n)=>(gae(t,typeof e!="symbol"?e+"":e,n),n);const _ae=[0,1],VU=[1,0],HU=[2,3],GU=[3,2],vae={L:_ae,M:VU,Q:HU,H:GU},yae=/^[0-9]*$/,xae=/^[A-Z0-9 $%*+.\/:-]*$/,_S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",xA=1,SA=40,gk=3,Sae=3,k0=40,Eae=10,WU=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],jU=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class wae{constructor(e,n,r,i){if(this.version=e,this.ecc=n,N0(this,"size"),N0(this,"mask"),N0(this,"modules",[]),N0(this,"types",[]),eSA)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=e*4+17;const s=Array.from({length:this.size},()=>!1);for(let a=0;a0));this.drawFunctionPatterns();const o=this.addEccAndInterleave(r);if(this.drawCodewords(o),i===-1){let a=1e9;for(let c=0;c<8;c++){this.applyMask(c),this.drawFormatBits(c);const l=this.getPenaltyScore();l=0&&e=0&&n>>9)*1335;const i=(n<<10|r)^21522;for(let s=0;s<=5;s++)this.setFunctionModule(8,s,cc(i,s));this.setFunctionModule(8,7,cc(i,6)),this.setFunctionModule(8,8,cc(i,7)),this.setFunctionModule(7,8,cc(i,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,cc(i,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,cc(i,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,cc(i,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^(e>>>11)*7973;const n=this.version<<12|e;for(let r=0;r<18;r++){const i=cc(n,r),s=this.size-11+r%3,o=Math.floor(r/3);this.setFunctionModule(s,o,i),this.setFunctionModule(o,s,i)}}drawFinderPattern(e,n){for(let r=-4;r<=4;r++)for(let i=-4;i<=4;i++){const s=Math.max(Math.abs(i),Math.abs(r)),o=e+i,a=n+r;o>=0&&o=0&&a{(p!==c-s||g>=a)&&h.push(m[p])});return h}drawCodewords(e){if(e.length!==Math.floor(Tw(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let r=this.size-1;r>=1;r-=2){r===6&&(r=5);for(let i=0;i>>3],7-(n&7)),n++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(a,c),o||(e+=this.finderPenaltyCountPatterns(c)*k0),o=this.modules[s][l],a=1);e+=this.finderPenaltyTerminateAndCount(o,a,c)*k0}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(a,c),o||(e+=this.finderPenaltyCountPatterns(c)*k0),o=this.modules[l][s],a=1);e+=this.finderPenaltyTerminateAndCount(o,a,c)*k0}for(let s=0;so+(a?1:0),n);const r=this.size*this.size,i=Math.ceil(Math.abs(n*20-r*10)/r)-1;return e+=i*Eae,e}getAlignmentPatternPositions(){if(this.version===1)return[];{const e=Math.floor(this.version/7)+2,n=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,r=[6];for(let i=this.size-7;r.length0&&e[2]===n&&e[3]===n*3&&e[4]===n&&e[5]===n;return(r&&e[0]>=n*4&&e[6]>=n?1:0)+(r&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,r){return e&&(this.finderPenaltyAddHistory(n,r),n=0),n+=this.size,this.finderPenaltyAddHistory(n,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,n){n[0]===0&&(e+=this.size),n.pop(),n.unshift(e)}}function mc(t,e,n){if(e<0||e>31||t>>>e)throw new RangeError("Value out of range");for(let r=e-1;r>=0;r--)n.push(t>>>r&1)}function cc(t,e){return(t>>>e&1)!==0}class EA{constructor(e,n,r){if(this.mode=e,this.numChars=n,this.bitData=r,n<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}getData(){return this.bitData.slice()}}const bae=[1,10,12,14],Tae=[2,9,11,13],Aae=[4,8,16,16];function $U(t,e){return t[Math.floor((e+7)/17)+1]}function qU(t){const e=[];for(const n of t)mc(n,8,e);return new EA(Aae,t.length,e)}function Mae(t){if(!XU(t))throw new RangeError("String contains non-numeric characters");const e=[];for(let n=0;n=1<SA)throw new RangeError("Version number out of range");let e=(16*t+128)*t+64;if(t>=2){const n=Math.floor(t/7)+2;e-=(25*n-10)*n-55,t>=7&&(e-=36)}return e}function x_(t,e){return Math.floor(Tw(t)/8)-WU[e[0]][t]*jU[e[0]][t]}function Iae(t){if(t<1||t>255)throw new RangeError("Degree out of range");const e=[];for(let r=0;r0);for(const r of t){const i=r^n.shift();n.push(0),e.forEach((s,o)=>n[o]^=Aw(s,i))}return n}function Aw(t,e){if(t>>>8||e>>>8)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(e>>>r&1)*t;return n}function Lae(t,e,n=1,r=40,i=-1,s=!0){if(!(xA<=n&&n<=r&&r<=SA)||i<-1||i>7)throw new RangeError("Invalid value");let o,a;for(o=n;;o++){const h=x_(o,e)*8,p=Nae(t,o);if(p<=h){a=p;break}if(o>=r)throw new RangeError("Data too long")}for(const h of[VU,HU,GU])s&&a<=x_(o,h)*8&&(e=h);const c=[];for(const h of t){mc(h.mode[0],4,c),mc(h.numChars,$U(h.mode,o),c);for(const p of h.getData())c.push(p)}const l=x_(o,e)*8;mc(0,Math.min(4,l-c.length),c),mc(0,(8-c.length%8)%8,c);for(let h=236;c.length0);return c.forEach((h,p)=>u[p>>>3]|=h<<7-(p&7)),new wae(o,e,u,i)}function Pae(t,e){var h;const{ecc:n="L",boostEcc:r=!1,minVersion:i=1,maxVersion:s=40,maskPattern:o=-1,border:a=1}=e||{},c=typeof t=="string"?Rae(t):Array.isArray(t)?[qU(t)]:void 0;if(!c)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof t}`);const l=Lae(c,vae[n],i,s,o,r),u=Dae({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},a);return e!=null&&e.invert&&(u.data=u.data.map(p=>p.map(m=>!m))),(h=e==null?void 0:e.onEncoded)==null||h.call(e,u),u}function Dae(t,e=1){if(!e)return t;const{size:n}=t,r=n+e*2;t.size=r,t.data.forEach(s=>{for(let o=0;o!1)),t.data.push(Array.from({length:r},o=>!1));const i=Ru.Border;t.types.forEach(s=>{for(let o=0;oi)),t.types.push(Array.from({length:r},o=>i));return t}function Uae(t,e,n,r=!1){return e<0||n<0||e>=t.length||n>=t.length?r:t[n][e]}function Fae(t,e={}){const n={WHITE_ALL:"█",WHITE_BLACK:"▀",BLACK_WHITE:"▄",BLACK_ALL:" "},r=Pae(t,e),i=!1,s=!0,o=(l,u)=>Uae(r.data,l,u,!0),a=[];let c="";for(let l=0;ln.add(xn(r))),n}case Ke.WHILE:{const n=hc(t.loop),r=hc(t.done),i=sn(t,"");return hp(t.lines,Ke.IF_CHECK,t.done),t.lines.forEach(s=>{switch(s.type){case Ke.BREAK:s.goto=r;break;case Ke.CONTINUE:s.goto=n;break}i.add(xn(s))}),i}case Ke.REPEAT:{const n=hc(t.loop),r=hc(t.done),i=sn(t,"");return hp(t.lines,Ke.IF_CHECK,t.done),t.lines.forEach(s=>{switch(s.type){case Ke.BREAK:s.goto=r;break;case Ke.CONTINUE:s.goto=n;break}i.add(xn(s))}),i}case Ke.WAITFOR:{const n=sn(t,"");return n.add([" if (!",Cr(t,"if",xu(t.words)),`) { api.i(${t.lineindex-1}); } `]),n}case Ke.FOREACH:{const n=hc(t.loop),r=hc(t.done),i=sn(t,"");return hp(t.lines,Ke.IF_CHECK,t.done),t.lines.forEach(s=>{switch(s.type){case Ke.BREAK:s.goto=r;break;case Ke.CONTINUE:s.goto=n;break}i.add(xn(s))}),i}case Ke.BREAK:return sn(t,[" ",q0(t,t.goto),` `]);case Ke.CONTINUE:return sn(t,[" ",q0(t,t.goto),` -`]);case Ke.OR:return Cr(t,"or",t.items.map(xn));case Ke.AND:return Cr(t,"and",t.items.map(xn));case Ke.NOT:return Cr(t,"not",t.items.map(xn));case Ke.COMPARE:return Yde(t);case Ke.OPERATOR:return Jde(t);case Ke.EXPR:return Cr(t,"expr",t.words.map(xn));default:return console.error("",t.type,t),PI(t)}}function aa(t){if(Z(t))switch(t.type===Ke.LINE&&++rs.lineindex,t.lineindex=rs.lineindex,t.type){case Ke.PROGRAM:t.lines.forEach(aa);break;case Ke.LINE:t.stmts.forEach(aa);break;case Ke.MARK:ab(t.id,t.lineindex);break;case Ke.IF:aa(t.check),aa(t.block);break;case Ke.IF_BLOCK:t.lines.forEach(aa),t.altlines.forEach(aa);break;case Ke.ELSE_IF:t.lines.forEach(aa);break;case Ke.ELSE:case Ke.WHILE:case Ke.REPEAT:case Ke.FOREACH:t.lines.forEach(aa);break;case Ke.MOVE:case Ke.COMMAND:case Ke.WAITFOR:case Ke.IF_CHECK:t.words.forEach(aa);break}}function Qde(t){return rs.labels={},rs.internal=1,rs.lineindex=0,rs.isfirststat=!0,aa(t),{...xn(t).toStringWithSourceMap({file:`${Qy}.map`}),...rs}}const epe={HALT_AT_COUNT:256};function tpe(t){return cn(t)?t.length>0?1:0:t??0}function ni(t){return`${t??""}`}function npe(t){return`${t}_chip`}function rpe(t,e,n){var c,l;const r=npe(t),i=Xp(r);let s;cn(i.lb)||(i.lb=Lb(Object.entries(n.labels??{})),i.lk="",i.mg=void 0,i.ec=1,i.lc=0,i.ys=0,i.ps=0,i.es=(((c=n.errors)==null?void 0:c.length)??0)!==0?1:0);function o(u,h){se.words=h,se.get=a.get;const p=mde(e,u);return Z(p)?p(a,h):u!=="send"?o("send",[u,...h]):0}const a={halt(){hpe(r)},id(){return t},senderid(u=t){return`vm:${u??t}`},set(u,h){const[p,m]=_de(e,a,u,h);if(p)return m},get(u){const[h,p]=gde(e,a,u);if(h)return p},bucket(u){const h=a.get("bucket");cn(h)?h.push(u):a.set("bucket",[u])},tick(u){const h=mt(i.ps)?i.ps:0,p=h%u===0;if(i.ps=h+1,p===!1)return!1;if(a.shouldtick()===!1)return NI(e,a),!1;i.lc=0,i.ys=0,vde(e,a);try{const m=s==null?void 0:s.next();m!=null&&m.done&&(Pn("chip","crash","generator logic unexpectedly exited"),i.es=1)}catch(m){Pn("chip","crash",m.message),i.es=1}return NI(e,a),!0},isended(){return i.es===1},shouldtick(){return i.es===0||a.hm()!==0},shouldhalt(){return mt(i.lc)?++i.lc>epe.HALT_AT_COUNT:!0},hm(){if(cn(i.mg)&&cn(i.lb)){const[,u]=i.mg;if(Z(u))for(let h=0;hmt(g)&&g>0)??0}}return 0},yield(){i.ys=1},jump(u){i.ec=u},sy(){return!!i.ys||a.shouldhalt()},emit(u,h,p){Yt.emit(u,a.senderid(),h,p)},send(u,h,p,m){Yt.emit(`${a.senderid(u)}:${h}`,t,p,m)},lock(u){i.lk=u},unlock(){i.lk=""},message(u){i.lk&&u.sender!==i.lk||(i.mg=[u.id,u.target,u.data,u.sender,u.player])},zap(u){if(cn(i.lb))for(let h=0;hv>0);g>=0&&(m[g]*=-1)}}},restore(u){if(cn(i.lb))for(let h=0;hm.fileName===Qy);return{line:(p==null?void 0:p.lineNumber)??0,column:(p==null?void 0:p.columnNumber)??0}},text(u){return o("text",[u])},stat(...u){return o("stat",u)},hyperlink(...u){return o("hyperlink",u)},command(...u){if(u.length===0)return 0;const[h,...p]=u;return o(ni(h),p)},if(...u){const[h,p]=He(u,0,[Ie.ANY]),m=tpe(h);return m&&p0,v=i[p];return g&&cn(v)&&a.command(...v),g?1:0},foreachstart(u,...h){const[p,m,g,v]=He(h,0,[Ie.STRING,Ie.NUMBER,Ie.NUMBER,Ie.MAYBE_NUMBER]);let y=Math.min(m,g),_=Math.max(m,g);const S=(v??0)||1;if(S<0){const E=y;y=_,_=E}return a.set(p,y-S),0},foreach(u,...h){const[p,m,g,v,y]=He(h,0,[Ie.STRING,Ie.NUMBER,Ie.NUMBER,Ie.MAYBE_NUMBER]);let _=Math.min(m,g),S=Math.max(m,g);const E=(v??0)||1;if(E<0){const R=_;_=S,S=R}let b=a.get(p);!mt(b)||b<_||b>S?b=_:b+=E;const N=b<=S?1:0;return N&&(a.set(p,b),ym?1:0},isLessThanOrEq(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p<=m?1:0},isGreaterThanOrEq(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p>=m?1:0},opPlus(u,h){const[p]=He([u],0,[Ie.ANY]),[m]=He([h],0,[Ie.ANY]);return p+m},opMinus(u,h){const[p]=He([u],0,[Ie.ANY]),[m]=He([h],0,[Ie.ANY]);return p-m},opPower(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return Math.pow(p,m)},opMultiply(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p*m},opDivide(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p/m},opModDivide(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p%m},opFloorDivide(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return Math.floor(p/m)},opUniPlus(u){const[h]=He([u],0,[Ie.NUMBER]);return+h},opUniMinus(u){const[h]=He([u],0,[Ie.NUMBER]);return-h}};return s=(l=n.code)==null?void 0:l.call(n,a),a}function X0(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ipe={exports:{}};/*! +`]);case Ke.OR:return Cr(t,"or",t.items.map(xn));case Ke.AND:return Cr(t,"and",t.items.map(xn));case Ke.NOT:return Cr(t,"not",t.items.map(xn));case Ke.COMPARE:return Yde(t);case Ke.OPERATOR:return Jde(t);case Ke.EXPR:return Cr(t,"expr",t.words.map(xn));default:return console.error("",t.type,t),PI(t)}}function aa(t){if(Z(t))switch(t.type===Ke.LINE&&++rs.lineindex,t.lineindex=rs.lineindex,t.type){case Ke.PROGRAM:t.lines.forEach(aa);break;case Ke.LINE:t.stmts.forEach(aa);break;case Ke.MARK:ab(t.id,t.lineindex);break;case Ke.IF:aa(t.check),aa(t.block);break;case Ke.IF_BLOCK:t.lines.forEach(aa),t.altlines.forEach(aa);break;case Ke.ELSE_IF:t.lines.forEach(aa);break;case Ke.ELSE:case Ke.WHILE:case Ke.REPEAT:case Ke.FOREACH:t.lines.forEach(aa);break;case Ke.MOVE:case Ke.COMMAND:case Ke.WAITFOR:case Ke.IF_CHECK:t.words.forEach(aa);break}}function Qde(t){return rs.labels={},rs.internal=1,rs.lineindex=0,rs.isfirststat=!0,aa(t),{...xn(t).toStringWithSourceMap({file:`${Qy}.map`}),...rs}}const epe={HALT_AT_COUNT:256};function tpe(t){return cn(t)?t.length>0?1:0:t??0}function ni(t){return`${t??""}`}function npe(t){return`${t}_chip`}function rpe(t,e,n){var c,l;const r=npe(t),i=Xp(r);let s;cn(i.lb)||(i.lb=Lb(Object.entries(n.labels??{})),i.lk="",i.mg=void 0,i.ec=1,i.lc=0,i.ys=0,i.ps=0,i.es=(((c=n.errors)==null?void 0:c.length)??0)!==0?1:0);function o(u,h){se.words=h;const p=mde(e,u);return Z(p)?p(a,h):u!=="send"?o("send",[u,...h]):0}const a={halt(){hpe(r)},id(){return t},senderid(u=t){return`vm:${u??t}`},set(u,h){const[p,m]=_de(e,a,u,h);if(p)return m},get(u){const[h,p]=gde(e,a,u);if(h)return p},bucket(u){const h=a.get("bucket");cn(h)?h.push(u):a.set("bucket",[u])},tick(u){const h=mt(i.ps)?i.ps:0,p=h%u===0;if(i.ps=h+1,p===!1)return!1;if(a.shouldtick()===!1)return NI(e,a),!1;i.lc=0,i.ys=0,se.get=a.get,vde(e,a);try{const m=s==null?void 0:s.next();m!=null&&m.done&&(Pn("chip","crash","generator logic unexpectedly exited"),i.es=1)}catch(m){Pn("chip","crash",m.message),i.es=1}return NI(e,a),!0},isended(){return i.es===1},shouldtick(){return i.es===0||a.hm()!==0},shouldhalt(){return mt(i.lc)?++i.lc>epe.HALT_AT_COUNT:!0},hm(){if(cn(i.mg)&&cn(i.lb)){const[,u]=i.mg;if(Z(u))for(let h=0;hmt(g)&&g>0)??0}}return 0},yield(){i.ys=1},jump(u){i.ec=u},sy(){return!!i.ys||a.shouldhalt()},emit(u,h,p){Yt.emit(u,a.senderid(),h,p)},send(u,h,p,m){Yt.emit(`${a.senderid(u)}:${h}`,t,p,m)},lock(u){i.lk=u},unlock(){i.lk=""},message(u){i.lk&&u.sender!==i.lk||(i.mg=[u.id,u.target,u.data,u.sender,u.player])},zap(u){if(cn(i.lb))for(let h=0;hv>0);g>=0&&(m[g]*=-1)}}},restore(u){if(cn(i.lb))for(let h=0;hm.fileName===Qy);return{line:(p==null?void 0:p.lineNumber)??0,column:(p==null?void 0:p.columnNumber)??0}},text(u){return o("text",[u])},stat(...u){return o("stat",u)},hyperlink(...u){return o("hyperlink",u)},command(...u){if(u.length===0)return 0;const[h,...p]=u;return o(ni(h),p)},if(...u){const[h,p]=He(u,0,[Ie.ANY]),m=tpe(h);return m&&p0,v=i[p];return g&&cn(v)&&a.command(...v),g?1:0},foreachstart(u,...h){const[p,m,g,v]=He(h,0,[Ie.STRING,Ie.NUMBER,Ie.NUMBER,Ie.MAYBE_NUMBER]);let y=Math.min(m,g),_=Math.max(m,g);const S=(v??0)||1;if(S<0){const E=y;y=_,_=E}return a.set(p,y-S),0},foreach(u,...h){const[p,m,g,v,y]=He(h,0,[Ie.STRING,Ie.NUMBER,Ie.NUMBER,Ie.MAYBE_NUMBER]);let _=Math.min(m,g),S=Math.max(m,g);const E=(v??0)||1;if(E<0){const R=_;_=S,S=R}let b=a.get(p);!mt(b)||b<_||b>S?b=_:b+=E;const N=b<=S?1:0;return N&&(a.set(p,b),ym?1:0},isLessThanOrEq(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p<=m?1:0},isGreaterThanOrEq(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p>=m?1:0},opPlus(u,h){const[p]=He([u],0,[Ie.ANY]),[m]=He([h],0,[Ie.ANY]);return p+m},opMinus(u,h){const[p]=He([u],0,[Ie.ANY]),[m]=He([h],0,[Ie.ANY]);return p-m},opPower(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return Math.pow(p,m)},opMultiply(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p*m},opDivide(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p/m},opModDivide(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return p%m},opFloorDivide(u,h){const[p]=He([u],0,[Ie.NUMBER]),[m]=He([h],0,[Ie.NUMBER]);return Math.floor(p/m)},opUniPlus(u){const[h]=He([u],0,[Ie.NUMBER]);return+h},opUniMinus(u){const[h]=He([u],0,[Ie.NUMBER]);return-h}};return s=(l=n.code)==null?void 0:l.call(n,a),a}function X0(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ipe={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -4899,6 +4899,6 @@ https://github.com/nodeca/pako/blob/main/LICENSE `,i,!1);const b=Ne.useCallback(R=>{const M=R.alt?10:1;Rl(p,Math.min(h,g+M))},[h,g,p]),N=Ne.useCallback(R=>{const M=R.alt?10:1;Rl(p,Math.max(u,g-M))},[u,g,p]);return ve.jsx(ve.Fragment,{children:e&&ve.jsx(gs,{MOVE_LEFT:N,MOVE_RIGHT:b})})}function Upe({chip:t,active:e,label:n,args:r,context:i}){const[s,...o]=[ao(r[0],""),...r.slice(1)],a=0,c=o.length-1,l=yd(t,s),u=yA(l),h=(u==null?void 0:u.value)??0,p=$a(),m=`${o[h]}`,g=n.trim(),v=Jl(e);Hn(` $dkred ? ${v}${g} `,i,!1);const y=e?p?"$26":"$27":"/";Hn(`${h+1}$green${y}${v}${c+1}`,i,!1),i.writefullwidth=32,Hn(` $green${m}`,i,!1),i.writefullwidth=void 0,Hn(` `,i,!1);const _=Ne.useCallback(E=>{const b=E.alt?10:1;Rl(l,Math.min(c,h+b))},[c,h,l]),S=Ne.useCallback(E=>{const b=E.alt?10:1;Rl(l,Math.max(a,h-b))},[a,h,l]);return ve.jsx(ve.Fragment,{children:e&&ve.jsx(gs,{MOVE_LEFT:S,MOVE_RIGHT:_})})}function Fpe({chip:t,active:e,label:n,args:r,context:i}){const s=ao(r[0],""),o=yd(t,s),a=DU(o),c=a==null?void 0:a.value,l=(c==null?void 0:c.toJSON())??"",u=$a(),[h,p]=Ne.useState(0),[m,g]=Ne.useState(!1),[v,y]=Ne.useState(void 0),_=`${l} `,S=n.trim(),E=Jl(e);Hn(`$green $20 ${E}${S} $green`,i,!1);const b=i.x,R=i.y*i.width;i.writefullwidth=32,Hn(`${_}`,i,!1),i.writefullwidth=void 0,Hn(` `,i,!1);const M=Z(v),O=i.width-b-2,C=M?Math.min(v,h):h;let I=M?Math.max(v,h):h;M&&(I!==C&&I===h&&--I,ix(b+C+R,b+I+R,15,8,i)),m&&u&&rx(b+h+R,"Û",i);function U(){Z(c)&&(p(C),y(void 0),c.delete(C,I-C+1))}return ve.jsxs(ve.Fragment,{children:[e&&ve.jsx(gs,{OK_BUTTON:()=>{c&&(g(!0),p(c.length),y(void 0))}}),m&&ve.jsx(Im,{blockhotkeys:!0,children:ve.jsx(gs,{MOVE_LEFT:L=>{L.shift?Z(v)||y(Cn(h-1,0,l.length)):y(void 0),p(P=>Cn(P-1,0,l.length))},MOVE_RIGHT:L=>{L.shift?Z(v)||y(h):y(void 0),p(P=>Cn(P+1,0,l.length))},CANCEL_BUTTON:()=>{g(!1),p(l.length),y(void 0)},OK_BUTTON:()=>g(!1),keydown:L=>{if(!c)return;const{key:P}=L,T=$t(P),H={alt:L.altKey,ctrl:td?L.metaKey:L.ctrlKey,shift:L.shiftKey},V=c.toJSON();switch(T){case"delete":M?U():V.length>0&&c.delete(h,1);break;case"backspace":M?U():h>0&&(c.delete(h-1,1),p(B=>Math.max(0,B-1)));break;default:if(H.ctrl)switch(T){case"a":y(0),p(V.length);break;case"c":Z(navigator.clipboard)&&navigator.clipboard.writeText(c.toJSON()).catch(B=>console.error(B));break;case"v":Z(navigator.clipboard)&&navigator.clipboard.readText().then(B=>{M&&U(),c.insert(h,B),p(h+B.length)}).catch(B=>console.error(B));break;case"x":Z(navigator.clipboard)&&navigator.clipboard.writeText(c.toJSON()).then(()=>U()).catch(B=>console.error(B));break}else H.alt||P.length===1&&V.lengthB+1));break}}})})]})}function Bpe({item:t,active:e}){const n=KT(),r=ja();if(r.iseven=r.y%2===0,typeof t=="string")return ve.jsx(Ipe,{player:n,item:t,context:r});if(cn(t)){const[i,s,o,...a]=t;if(typeof i!="string"||typeof s!="string"||typeof o!="string")return null;const c={player:n,chip:i,active:e,label:s,args:a,context:r};switch($t(o)){case"hk":case"hotkey":return ve.jsx(Ope,{...c});case"hyperlink":return ve.jsx(Lpe,{...c});case"rn":case"range":return ve.jsx(Dpe,{...c});case"sl":case"select":return ve.jsx(Upe,{...c});case"nm":case"number":return ve.jsx(Ppe,{...c});case"tx":case"text":return ve.jsx(Fpe,{...c})}nx(r)}return null}function uM({store:t,children:e}){return ve.jsx(cM.Provider,{value:t,children:e})}function hM({width:t,height:e}){const n=Ne.useContext(cM),[r,i,s]=XT(n,Yl(o=>[o.char,o.color,o.bg,o.render]));return t>0&&e>0&&ve.jsx(u3,{char:r.slice(),color:i.slice(),bg:s.slice(),width:t,height:e})}function QF({margin:t=1,selected:e=-1,width:n,height:r,color:i,bg:s,text:o}){const a=lM(n,r,0,i,s),c=a.getState(),l={...jm(n,r,i,s,0,t,n-t,r),...a.getState(),x:t};return Npe(c,0,i,s),c.changed(),ve.jsxs(uM,{store:a,children:[ve.jsx(Nu.Provider,{value:l,children:o.map((u,h)=>ve.jsx(Bpe,{item:u,active:h===e},h))}),ve.jsx(hM,{width:n,height:r})]})}var zpe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.01,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1/(2*Math.PI);return r/Math.atan(1/n)*Math.atan(Math.sin(2*Math.PI*e*i)/n)},Vpe=function(e){return 1/(1+e+.48*e*e+.235*e*e*e)};function Hpe(t,e,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:.25,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:.01,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:1/0,o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Vpe,a=arguments.length>7&&arguments[7]!==void 0?arguments[7]:.001,c="velocity_"+e;if(t.__damp===void 0&&(t.__damp={}),t.__damp[c]===void 0&&(t.__damp[c]=0),Math.abs(t[e]-n)<=a)return t[e]=n,!1;r=Math.max(1e-4,r);var l=2/r,u=o(l*i),h=t[e]-n,p=n,m=s*r;h=Math.min(Math.max(h,-m),m),n=t[e]-h;var g=(t.__damp[c]+l*h)*i;t.__damp[c]=(t.__damp[c]-l*g)*u;var v=n+(h+g)*u;return p-t[e]>0==v>p&&(v=p,t.__damp[c]=(v-p)/i),t[e]=v,!0}const Gpe=2,Wpe=14,eB=Wpe*Gpe;function jpe(t){return CW(t,eB*.5)}function $pe(t,e,n,r,i=1.235){function s(a){return zpe(a,r)}Hpe(t.userData,e,n,i,r,eB*12,s),t.position[e]=jpe(t.userData[e]);const o=n-t.position.y;return Math.abs(o)<.1}function VI({x:t,y:e,color:n,on:r=232,off:i=7,alt:s}){const o=$a(),a=kpe(),c=Ne.useRef(0),l=Z(s)?c.current%2===0?r:s:r;return Pr(a,a.width,a.height,t,e,{char:o?l:i,color:n}),a.changed(),o&&++c.current,null}function qpe({store:t,children:e}){return ve.jsx(YF.Provider,{value:t,children:e})}function Xpe({width:t,height:e}){const n=Ne.useContext(YF),[r]=XT(n,Yl(i=>[i.dither,i.render]));return t>0&&e>0&&ve.jsx(Vy,{alphas:r.slice(),width:t,height:e})}function Kpe({name:t,width:e,height:n,color:r,bg:i,text:s,shouldclose:o}){const{viewport:a}=va(),c=e-3,l=n-3,u=lM(e,n,0,r,i),h=Rpe(c,l,0),p=Ne.useContext(sx),m=u.getState();for(let T=1;T2&&T{o&&p.didclose()},[o,p]);Ne.useEffect(()=>{if(I.current&&!o){const T=a.height;I.current.position.y=T,I.current.userData.y=T,I.current.userData.vy=0}},[o]),Hv(Ne.useCallback((T,H)=>{if(Z(I.current)){const V=o?n*2*-Hi:0;$pe(I.current,"y",V,H)&&U()}},[o,U,n]));const L=Ne.useCallback(T=>{const H=T.alt?10:1;E(V=>Math.max(0,V-H))},[E]),P=Ne.useCallback(T=>{const H=T.alt?10:1;E(V=>Math.min(s.length,V+H))},[E,s.length]);return ve.jsx(uM,{store:u,children:ve.jsx(qpe,{store:h,children:ve.jsx("group",{ref:I,"position-y":1e6,children:ve.jsxs(Im,{children:[ve.jsx(gs,{MOVE_UP:L,MOVE_DOWN:P,CANCEL_BUTTON:p.sendclose}),ve.jsx(hM,{width:e,height:n}),ve.jsxs("group",{position:[2*as,2*Hi,0],children:[ve.jsx(Xpe,{width:c,height:l}),ve.jsx(QF,{name:t,width:c,height:l,margin:0,color:r,bg:wn.ONCLEAR,text:N,selected:R}),ve.jsx(VI,{x:1,y:1}),ve.jsx(VI,{x:1,y:2+R,on:26,alt:27,off:45,color:12})]})]})})})})}function HI({rect:t,shouldclose:e=!1}){switch(t.type){case 0:return ve.jsx(QF,{name:t.name,width:t.width,height:t.height,color:14,bg:1,text:t.text});case 1:return ve.jsx(Kpe,{name:t.name,width:t.width,height:t.height,color:14,bg:1,text:t.text,shouldclose:e});case 2:return ve.jsx(tle,{width:t.width,height:t.height})}return null}function Ype(){const t=va(g=>g.viewport),{width:e,height:n}=t.getCurrentViewport(),r=Math.floor(e/as),i=Math.floor(n/Hi),s=e-r*as,o=n-i*Hi,[a,c]=Ne.useState(),[l,u]=os(wne(g=>[g.gadget.player,g.gadget.panels]));if(r<1||i<1)return null;const h={name:"main",type:2,x:0,y:0,width:r,height:i,text:[]},p=[];let m=!0;return u.forEach(g=>{let v;switch(g.edge){case Si.LEFT:v={name:g.name,type:0,x:h.x,y:h.y,width:g.size,height:h.height,text:g.text},h.x+=g.size,h.width-=g.size,p.push(v);break;default:case Si.RIGHT:v={name:g.name,type:0,x:h.x+h.width-g.size,y:h.y,width:g.size,height:h.height,text:g.text},h.width-=g.size,p.push(v);break;case Si.TOP:v={name:g.name,type:0,x:h.x,y:h.y,width:h.width,height:g.size,text:g.text},h.y+=g.size,h.height-=g.size,p.push(v);break;case Si.BOTTOM:v={name:g.name,type:0,x:h.x,y:h.y+h.height-g.size,width:h.width,height:g.size,text:g.text},h.height-=g.size,p.push(v);break;case Si.SCROLL:v={name:g.name,type:1,x:0,y:0,width:Cn(g.size||50,24,h.width-2),height:Cn(18,8,h.height-8),text:g.text},v.x=h.x+Math.floor((h.width-v.width)*.5),v.y=h.y+Math.floor((h.height-v.height)*.5),m=!1,Bf(a,v)||c(Bi(v))}}),p.unshift(h),ve.jsx(sx.Provider,{value:{sendmessage(g,v){Yt.emit(g,"gadget",v,l)},sendclose(){g9("gadget",l)},didclose(){c(void 0)}},children:ve.jsxs("group",{position:[s*.5,o*.5,-512],children:[p.map(g=>ve.jsx("group",{position:[g.x*as,g.y*Hi,0],children:ve.jsx(HI,{rect:g})},g.name)),a&&ve.jsxs(Co.Fragment,{children:[ve.jsx("group",{position:[0,0,800],children:ve.jsx(Ace,{width:r,height:i,alpha:.14})}),ve.jsx("group",{position:[a.x*as,a.y*Hi,900],children:ve.jsx(HI,{rect:a,shouldclose:m})})]},a.name)]})})}const Zpe=250,Jpe=249,Kp=wn.BLUE,Qpe=wn.WHITE,Wl=wn.DKBLUE,eme=wn.DKGRAY,tB=wn.BLACK,kv=1,VS=as*kv,HS=Hi*kv,nB=Ne.createContext({sendmessage(){}});function Of(t,e,n,r,i){const s=qo(i);i.iseven=i.y%2===0,i.active.bg=e&&!t?tB:Wl,i.active.leftedge=s.left,i.active.rightedge=s.right,i.active.topedge=s.top,i.active.bottomedge=s.bottom,i.x=i.active.leftedge+n,i.y=i.active.topedge+r}function yf(t,e,n,r,i,s,o,a){const c=qo(i);i.iseven=i.y%2===0,i.active.bg=Wl,i.active.leftedge=c.left+s,i.active.rightedge=c.right-s,i.active.topedge=c.top+o,i.active.bottomedge=c.bottom-a,i.x=i.active.leftedge+n,i.y=i.active.topedge+r}function tme(t){let e=0;return t.split(/\r?\n/).map(r=>{const i=e,s=`${r} -`;return e+=s.length,{start:i,code:s,end:i+r.length}})}function nme(t){return t.reduce((e,n)=>{const r=n.code.length;return r>e?r:e},0)}function rme(t,e){for(let n=0;n{const e="nativeEvent"in t?t.nativeEvent:t;return{deltaX:e.deltaX||0,deltaY:e.deltaY||0,deltaZ:e.deltaZ||0,timeStamp:e.timeStamp}},ame=t=>[t.deltaX,t.deltaY,t.deltaZ],K0=t=>{const e=ame(t).map(Math.abs);return Math.max(...e)};var xl;(function(t){t.ALL_OTHER_CHECKS_FAILED="ALL_OTHER_CHECKS_FAILED",t.NO_PREVIOUS_EVENT_TO_COMPARE="NO_PREVIOUS_EVENT_TO_COMPARE",t.PAST_TIMESTAMP_EVENT="PAST_TIMESTAMP_EVENT",t.ENOUGH_TIME_PASSED="ENOUGH_TIME_PASSED",t.NON_DECREASING_DELTAS_OF_KNOWN_HUMAN="NON_DECREASING_DELTAS_OF_KNOWN_HUMAN",t.DELTA_MODULE_HAS_BEEN_INCREASING="DELTA_MODULE_HAS_BEEN_INCREASING"})(xl||(xl={}));class cme{constructor({sensitivity:e=2,delay:n=100,increasingDeltasThreshold:r=3}={}){vt(this,"sensitivity");vt(this,"delay");vt(this,"increasingDeltasThreshold");vt(this,"previousEvents");this.sensitivity=Math.max(1,e),this.delay=Math.max(1,n),this.increasingDeltasThreshold=Math.max(2,r),this.previousEvents=[]}check(e){var s;if(!(("nativeEvent"in e?e.nativeEvent:e)instanceof Event))throw new Error(`"${e}" is not a valid event`);const r=ome(e);if(K0(r)(((s=this.previousEvents.at(-1))==null?void 0:s.timeStamp)||0)&&this.previousEvents.push(r),i}isHuman(e){const n=this.previousEvents.at(-1);if(!n)return{isHuman:!0,reason:xl.NO_PREVIOUS_EVENT_TO_COMPARE};if(e.timeStampn.timeStamp+this.delay)return{isHuman:!0,reason:xl.ENOUGH_TIME_PASSED};const s=K0(e),o=K0(n);if(s>=o){if(this.previousEvents.length===1)return{isHuman:!0,reason:xl.NON_DECREASING_DELTAS_OF_KNOWN_HUMAN};if(this.increasingDeltasThreshold<=2||this.previousEvents.length>=this.increasingDeltasThreshold&&this.previousEvents.slice(-this.increasingDeltasThreshold).map(K0).every((u,h,p)=>h===0||u>p[h-1]))return{isHuman:!0,reason:xl.DELTA_MODULE_HAS_BEEN_INCREASING}}return{isHuman:!1,reason:xl.ALL_OTHER_CHECKS_FAILED}}}function GI(){}const lme=Co.forwardRef(function({args:e,children:n,...r},i){const s=Co.useRef(null);return Co.useImperativeHandle(i,()=>s.current),ve.jsxs("mesh",{ref:s,...r,children:[ve.jsx("planeGeometry",{attach:"geometry",args:e}),n]})}),ume=Co.forwardRef(function({blocking:e=!1,cursor:n="default",x:r=0,y:i=0,width:s=1,height:o=1,opacity:a=1,visible:c=!0,...l},u){const h=s*.5,p=o*.5,m=[(r+h)*as,(i+p)*Hi,0],g=Fy();return ve.jsx(lme,{ref:u,args:[s*as,o*Hi],userData:{blocking:e,cursor:n,clippingPlanes:g},onClick:e?GI:void 0,onPointerMove:e?GI:void 0,position:m,...l,children:ve.jsx("meshBasicMaterial",{color:"white",opacity:a,visible:c,transparent:a!==1,clippingPlanes:g})})}),hme=new cme({sensitivity:td?7:2}),WI=4,fme=.75;function dme(t){const e=Cn(t,-WI,WI);return Math.round(e*fme)}function iB({debug:t=!1,disabled:e=!1,blocking:n=!0,cursor:r="pointer",x:i=0,y:s=0,width:o=30,height:a=10,children:c,onScroll:l,...u}){return ve.jsxs("group",{...u,children:[ve.jsx(ume,{blocking:n,cursor:r,visible:t,x:i,y:s,width:o,height:a,onWheel:h=>{e||!hme.check(h)||l==null||l(dme(h.deltaY))}}),c]})}function pme({tapeycursor:t,logrowtotalheight:e}){const n=$a(),r=ja(),i=br(),s=KT(),o=qo(r),a=i.buffer[i.bufferindex];let c=i.xcursor,l=i.xcursor,u=!1;Z(i.xselect)&&Z(i.yselect)&&(u=!0,c=Math.min(i.xcursor,i.xselect),l=Math.max(i.xcursor,i.xselect),i.xcursor!==i.xselect&&--l);const h=l-c+1,p=i.ycursor===0,m=u?a.substring(c,l+1):a;function g(O,C,I){i.bufferindex>0&&br.setState({bufferindex:0}),i.buffer[0]=ime(a,O,C,I),br.setState({buffer:i.buffer,xselect:void 0,xcursor:O+(I??"").length})}function v(O){const C=i.buffer.length-1,I=Cn(O,0,C);br.setState({bufferindex:I,xcursor:i.buffer[I].length,ycursor:0,xselect:void 0,yselect:void 0})}function y(O){O?Z(i.xselect)||br.setState({xselect:i.xcursor,yselect:i.ycursor}):br.setState({xselect:void 0,yselect:void 0})}function _(){Z(i.xselect)&&(br.setState({xcursor:c,xselect:void 0,yselect:void 0}),g(c,h))}function S(){br.setState({xcursor:a.length,ycursor:0,xselect:void 0,yselect:void 0})}Of(!1,!1,0,0,r);const E="main:0.20.31 - if lost try #help";r.x=o.right-E.length,Hn(`$dkcyan${E}`,r,!0);const b="$196",R="$205".repeat(o.width-6);Of(!1,!1,0,o.height-2,r),Hn(` ${b}${R}${b} `,r,!0);const M=a.padEnd(o.width," ");if(Of(!1,!1,0,o.height-1,r),qF(M,r,!0),Z(i.xselect)&&Z(i.yselect)&&i.xcursor!==i.xselect){const O=Math.min(i.xcursor,i.xselect),C=Math.min(i.ycursor,i.yselect),I=Math.max(i.xcursor,i.xselect)-1,U=Math.max(i.ycursor,i.yselect);for(let L=C;L<=U;++L){const P=O+(o.bottom-L)*o.width,T=I+(o.bottom-L)*o.width;ix(P,T,15,8,r)}}if(n){const O=o.left+i.xcursor,C=o.top+t;rx(O+C*r.width,"Ý",r)}return Ne.useEffect(()=>{let O=i.scroll;t<4&&O++,t>o.bottom-4&&O--,br.setState({scroll:Math.round(Cn(O,0,e))})},[i.scroll,t,e,o.bottom]),r.changed(),ve.jsxs(ve.Fragment,{children:[ve.jsx(iB,{blocking:!0,x:o.left,y:o.top,width:o.width,height:o.height,onScroll:O=>{y(!1),br.setState({ycursor:Cn(Math.round(i.ycursor-O),0,e)})}}),ve.jsx(gs,{keydown:O=>{const{key:C}=O,I=$t(C),U=Gy(O);switch(I){case"arrowleft":y(U.shift),U.ctrl?br.setState({xcursor:0}):br.setState({xcursor:Cn(i.xcursor-(U.alt?10:1),0,o.right)});break;case"arrowright":y(U.shift),U.ctrl?br.setState({xcursor:p?a.length:o.right}):br.setState({xcursor:Cn(i.xcursor+(U.alt?10:1),0,o.right)});break;case"arrowup":U.ctrl?v(i.bufferindex+1):(y(U.shift),br.setState({ycursor:Cn(Math.round(i.ycursor+(U.alt?10:1)),0,e)}));break;case"arrowdown":U.ctrl?v(i.bufferindex-1):(y(U.shift),br.setState({ycursor:Cn(Math.round(i.ycursor-(U.alt?10:1)),0,e)}));break;case"enter":{const L=u?m:a;L.length&&(p?(br.setState({xcursor:0,bufferindex:0,xselect:void 0,yselect:void 0,buffer:["",L,...i.buffer.slice(1).filter(P=>P!==L)]}),Wv("tape",L,s)):S());break}case"esc":case"escape":Pb("tape");break;case"tab":pL("tape",!U.shift);break;case"delete":p?u?_():a.length>0&&g(i.xcursor,1):S();break;case"backspace":p?u?_():i.xcursor>0&&g(i.xcursor-1,1):S();break;default:if(U.ctrl)switch(I){case"a":br.setState({xselect:0,yselect:0,xcursor:a.length,ycursor:0});break;case"c":p&&Z(navigator.clipboard)?navigator.clipboard.writeText(m).catch(L=>console.error(L)):S();break;case"v":p&&Z(navigator.clipboard)?navigator.clipboard.readText().then(L=>{const P=L.replaceAll("\r","");u?g(c,h,P):g(i.xcursor,0,P)}).catch(L=>console.error(L)):S();break;case"x":p&&Z(navigator.clipboard)?navigator.clipboard.writeText(m).then(()=>_()).catch(L=>console.error(L)):S();break}else U.alt||C.length===1&&(p&&i.xcursor<=a.length?u?(g(c,h,C),br.setState({xselect:void 0})):g(i.xcursor,0,C):S());break}}})]})}function mme({blink:t,active:e,prefix:n,label:r,words:i,y:s}){const o=ja(),a=Ne.useCallback(()=>{if(Z(navigator.clipboard)){const[,...l]=i,u=l.join(" ");navigator.clipboard.writeText(u).then(()=>hn("copyit","copied!")).catch(h=>console.error(h))}},[i]),c=Jl(!!e);return Of(!!t,!!e,0,s,o),Hn(`${n} $purple$16 $yellowCOPYIT ${c}${r}`,o,!0),o.changed(),e&&ve.jsx(gs,{OK_BUTTON:a})}function gme({blink:t,active:e,prefix:n,label:r,words:i,y:s}){const o=ja(),a=Ne.useContext(nB),c=Ne.useCallback(()=>{const[u,h]=i;a.sendmessage(u,h)},[i,a]),l=Jl(!!e);return Of(!!t,!!e,0,s,o),Hn(`${n} $purple$16 ${l}${r}`,o,!0),o.changed(),e&&ve.jsx(gs,{OK_BUTTON:c})}function sB({blink:t,active:e,text:n,y:r}){const i=ja(),s=qo(i),o=n.startsWith("!");if(Of(!!t,!!e,0,r,i),i.active.bottomedge=s.bottom,Hn(o?"":n,i,!0),o){const[a,...c]=n.slice(1).split("!"),l=`${c.join("!")}`;let u="PRESS ME";const h=[];tx(l,!0).tokens.forEach(y=>{switch(y.tokenType){case sM:u=y.image.slice(1);break;default:h.push(y.image);break}});const[m,...g]=h,v={blink:t,active:e,prefix:a,label:u,words:g,y:r};switch($t(m)){case"hk":case"hotkey":return null;case"rn":case"range":return null;case"sl":case"select":return null;case"nm":case"number":return null;case"tx":case"text":return null;case"copyit":return ve.jsx(mme,{...v,words:h});default:case"hyperlink":return ve.jsx(gme,{...v,words:h})}}return null}function _me(t){const e=$a();return ve.jsx(sB,{active:!0,blink:e,...t})}function GS(){const t=KT(),[e,n]=ts(Yl(p=>[p.terminal.logs,p.editor.open])),r=ja(),i=br(),s=qo(r),o=e.map(p=>{const[,m,g,...v]=p;let y="$white";switch(m){case"debug":y="$yellow";break;case"error":y="$red";break}const _=v.map(b=>`${b}`).join(" "),S=_.startsWith("!"),E=`$blue[${y}${g}$blue]`;return`${S?"!":""}${E} ${_}`}),a=o.map(p=>{if(p.startsWith("!"))return 1;const m=aM(p,s.width,s.height);return(m==null?void 0:m.y)??1});let c=0,l=s.bottom-1;const u=a.map(p=>(l-=p,c+=p,l));++c;const h=s.bottom-i.ycursor+i.scroll;return ve.jsxs(ve.Fragment,{children:[ve.jsx(fM,{context:r}),ve.jsxs(nB.Provider,{value:{sendmessage(p,m){const[g,v]=sme(p);if(g==="self"){const y=`#${v} ${m??""}`;Wv("tape",y,t)}else Yt.emit(`${g}:${v}`,"gadget",m,t)}},children:[o.map((p,m)=>{const g=u[m]+i.scroll,v=a[m],y=g+v;return y<0||g>s.bottom-1?null:!n&&h>=g&&h[m.editor.type,m.editor.title])),o=$a(),a="$205".repeat(e.width-4);yf(!1,!1,0,1,t,0,0,0),Hn(`$179$${o?"7":"232"}$200${a}$181`,t,!0);const l=` ${`[${i}] `}${s} `,u=aM(l,e.width,e.height),h=(u==null?void 0:u.measuredwidth)??1,p=Math.round(e.width*.5)-Math.round(h*.5);return yf(!1,!1,p,0,t,0,0,0),Hn(l,t,!0),t.changed(),null}function yme({xcursor:t,ycursor:e,xoffset:n,yoffset:r,rows:i,codepage:s}){var P,T;const o=$a(),a=ja(),c=Ne.useRef(),l=hr(),u=qo(a),h=ts(H=>H.editor.player),p=rB(s),m=Z(p)?p.toJSON():"",g=i.length-1,v=t+1-n,y=e+2-r;if(Z(s)){const H=((P=c.current)==null?void 0:P.x)!==v||((T=c.current)==null?void 0:T.y)!==y;if(o||H){const V=u.left+v,B=u.top+y;B>u.top+1&&Bu.left&&V0&&(p==null||p.delete(H,V)),Z(B)&&(p==null||p.insert(H,B)),hr.setState({cursor:H+(B??"").length,select:void 0})}function I(){Z(l.select)&&(hr.setState({cursor:E}),C(E,R))}function U(){hr.setState({cursor:_,select:void 0})}const L=Ne.useCallback(function(V){const B=Math.round(e+V);if(B<0)hr.setState({cursor:0});else if(B>g)hr.setState({cursor:_});else{const z=i[B];hr.setState({cursor:z.start+Math.min(t,z.code.length-1)})}},[_,i,g,t,e]);return a.changed(),ve.jsxs(ve.Fragment,{children:[ve.jsx(iB,{blocking:!0,x:u.left,y:u.top,width:u.width,height:u.height,onScroll:H=>L(H*.75)}),ve.jsx(gs,{keydown:H=>{if(!Z(p))return;const{key:V}=H,B=$t(V),z=Gy(H);switch(B){case"arrowleft":if(O(z.shift),z.ctrl)hr.setState({cursor:S.start});else{const W=l.cursor-(z.alt?10:1);hr.setState({cursor:Cn(W,0,_)})}break;case"arrowright":if(O(z.shift),z.ctrl)hr.setState({cursor:S.end});else{const W=l.cursor+(z.alt?10:1);hr.setState({cursor:Cn(W,0,_)})}break;case"arrowup":O(z.shift),z.ctrl?hr.setState({cursor:0}):L(z.alt?-10:-1);break;case"arrowdown":O(z.shift),z.ctrl?hr.setState({cursor:_}):L(z.alt?10:1);break;case"enter":Z(p)&&(p.insert(l.cursor,` +`;return e+=s.length,{start:i,code:s,end:i+r.length}})}function nme(t){return t.reduce((e,n)=>{const r=n.code.length;return r>e?r:e},0)}function rme(t,e){for(let n=0;n{const e="nativeEvent"in t?t.nativeEvent:t;return{deltaX:e.deltaX||0,deltaY:e.deltaY||0,deltaZ:e.deltaZ||0,timeStamp:e.timeStamp}},ame=t=>[t.deltaX,t.deltaY,t.deltaZ],K0=t=>{const e=ame(t).map(Math.abs);return Math.max(...e)};var xl;(function(t){t.ALL_OTHER_CHECKS_FAILED="ALL_OTHER_CHECKS_FAILED",t.NO_PREVIOUS_EVENT_TO_COMPARE="NO_PREVIOUS_EVENT_TO_COMPARE",t.PAST_TIMESTAMP_EVENT="PAST_TIMESTAMP_EVENT",t.ENOUGH_TIME_PASSED="ENOUGH_TIME_PASSED",t.NON_DECREASING_DELTAS_OF_KNOWN_HUMAN="NON_DECREASING_DELTAS_OF_KNOWN_HUMAN",t.DELTA_MODULE_HAS_BEEN_INCREASING="DELTA_MODULE_HAS_BEEN_INCREASING"})(xl||(xl={}));class cme{constructor({sensitivity:e=2,delay:n=100,increasingDeltasThreshold:r=3}={}){vt(this,"sensitivity");vt(this,"delay");vt(this,"increasingDeltasThreshold");vt(this,"previousEvents");this.sensitivity=Math.max(1,e),this.delay=Math.max(1,n),this.increasingDeltasThreshold=Math.max(2,r),this.previousEvents=[]}check(e){var s;if(!(("nativeEvent"in e?e.nativeEvent:e)instanceof Event))throw new Error(`"${e}" is not a valid event`);const r=ome(e);if(K0(r)(((s=this.previousEvents.at(-1))==null?void 0:s.timeStamp)||0)&&this.previousEvents.push(r),i}isHuman(e){const n=this.previousEvents.at(-1);if(!n)return{isHuman:!0,reason:xl.NO_PREVIOUS_EVENT_TO_COMPARE};if(e.timeStampn.timeStamp+this.delay)return{isHuman:!0,reason:xl.ENOUGH_TIME_PASSED};const s=K0(e),o=K0(n);if(s>=o){if(this.previousEvents.length===1)return{isHuman:!0,reason:xl.NON_DECREASING_DELTAS_OF_KNOWN_HUMAN};if(this.increasingDeltasThreshold<=2||this.previousEvents.length>=this.increasingDeltasThreshold&&this.previousEvents.slice(-this.increasingDeltasThreshold).map(K0).every((u,h,p)=>h===0||u>p[h-1]))return{isHuman:!0,reason:xl.DELTA_MODULE_HAS_BEEN_INCREASING}}return{isHuman:!1,reason:xl.ALL_OTHER_CHECKS_FAILED}}}function GI(){}const lme=Co.forwardRef(function({args:e,children:n,...r},i){const s=Co.useRef(null);return Co.useImperativeHandle(i,()=>s.current),ve.jsxs("mesh",{ref:s,...r,children:[ve.jsx("planeGeometry",{attach:"geometry",args:e}),n]})}),ume=Co.forwardRef(function({blocking:e=!1,cursor:n="default",x:r=0,y:i=0,width:s=1,height:o=1,opacity:a=1,visible:c=!0,...l},u){const h=s*.5,p=o*.5,m=[(r+h)*as,(i+p)*Hi,0],g=Fy();return ve.jsx(lme,{ref:u,args:[s*as,o*Hi],userData:{blocking:e,cursor:n,clippingPlanes:g},onClick:e?GI:void 0,onPointerMove:e?GI:void 0,position:m,...l,children:ve.jsx("meshBasicMaterial",{color:"white",opacity:a,visible:c,transparent:a!==1,clippingPlanes:g})})}),hme=new cme({sensitivity:td?7:2}),WI=4,fme=.75;function dme(t){const e=Cn(t,-WI,WI);return Math.round(e*fme)}function iB({debug:t=!1,disabled:e=!1,blocking:n=!0,cursor:r="pointer",x:i=0,y:s=0,width:o=30,height:a=10,children:c,onScroll:l,...u}){return ve.jsxs("group",{...u,children:[ve.jsx(ume,{blocking:n,cursor:r,visible:t,x:i,y:s,width:o,height:a,onWheel:h=>{e||!hme.check(h)||l==null||l(dme(h.deltaY))}}),c]})}function pme({tapeycursor:t,logrowtotalheight:e}){const n=$a(),r=ja(),i=br(),s=KT(),o=qo(r),a=i.buffer[i.bufferindex];let c=i.xcursor,l=i.xcursor,u=!1;Z(i.xselect)&&Z(i.yselect)&&(u=!0,c=Math.min(i.xcursor,i.xselect),l=Math.max(i.xcursor,i.xselect),i.xcursor!==i.xselect&&--l);const h=l-c+1,p=i.ycursor===0,m=u?a.substring(c,l+1):a;function g(O,C,I){i.bufferindex>0&&br.setState({bufferindex:0}),i.buffer[0]=ime(a,O,C,I),br.setState({buffer:i.buffer,xselect:void 0,xcursor:O+(I??"").length})}function v(O){const C=i.buffer.length-1,I=Cn(O,0,C);br.setState({bufferindex:I,xcursor:i.buffer[I].length,ycursor:0,xselect:void 0,yselect:void 0})}function y(O){O?Z(i.xselect)||br.setState({xselect:i.xcursor,yselect:i.ycursor}):br.setState({xselect:void 0,yselect:void 0})}function _(){Z(i.xselect)&&(br.setState({xcursor:c,xselect:void 0,yselect:void 0}),g(c,h))}function S(){br.setState({xcursor:a.length,ycursor:0,xselect:void 0,yselect:void 0})}Of(!1,!1,0,0,r);const E="main:0.20.32 - if lost try #help";r.x=o.right-E.length,Hn(`$dkcyan${E}`,r,!0);const b="$196",R="$205".repeat(o.width-6);Of(!1,!1,0,o.height-2,r),Hn(` ${b}${R}${b} `,r,!0);const M=a.padEnd(o.width," ");if(Of(!1,!1,0,o.height-1,r),qF(M,r,!0),Z(i.xselect)&&Z(i.yselect)&&i.xcursor!==i.xselect){const O=Math.min(i.xcursor,i.xselect),C=Math.min(i.ycursor,i.yselect),I=Math.max(i.xcursor,i.xselect)-1,U=Math.max(i.ycursor,i.yselect);for(let L=C;L<=U;++L){const P=O+(o.bottom-L)*o.width,T=I+(o.bottom-L)*o.width;ix(P,T,15,8,r)}}if(n){const O=o.left+i.xcursor,C=o.top+t;rx(O+C*r.width,"Ý",r)}return Ne.useEffect(()=>{let O=i.scroll;t<4&&O++,t>o.bottom-4&&O--,br.setState({scroll:Math.round(Cn(O,0,e))})},[i.scroll,t,e,o.bottom]),r.changed(),ve.jsxs(ve.Fragment,{children:[ve.jsx(iB,{blocking:!0,x:o.left,y:o.top,width:o.width,height:o.height,onScroll:O=>{y(!1),br.setState({ycursor:Cn(Math.round(i.ycursor-O),0,e)})}}),ve.jsx(gs,{keydown:O=>{const{key:C}=O,I=$t(C),U=Gy(O);switch(I){case"arrowleft":y(U.shift),U.ctrl?br.setState({xcursor:0}):br.setState({xcursor:Cn(i.xcursor-(U.alt?10:1),0,o.right)});break;case"arrowright":y(U.shift),U.ctrl?br.setState({xcursor:p?a.length:o.right}):br.setState({xcursor:Cn(i.xcursor+(U.alt?10:1),0,o.right)});break;case"arrowup":U.ctrl?v(i.bufferindex+1):(y(U.shift),br.setState({ycursor:Cn(Math.round(i.ycursor+(U.alt?10:1)),0,e)}));break;case"arrowdown":U.ctrl?v(i.bufferindex-1):(y(U.shift),br.setState({ycursor:Cn(Math.round(i.ycursor-(U.alt?10:1)),0,e)}));break;case"enter":{const L=u?m:a;L.length&&(p?(br.setState({xcursor:0,bufferindex:0,xselect:void 0,yselect:void 0,buffer:["",L,...i.buffer.slice(1).filter(P=>P!==L)]}),Wv("tape",L,s)):S());break}case"esc":case"escape":Pb("tape");break;case"tab":pL("tape",!U.shift);break;case"delete":p?u?_():a.length>0&&g(i.xcursor,1):S();break;case"backspace":p?u?_():i.xcursor>0&&g(i.xcursor-1,1):S();break;default:if(U.ctrl)switch(I){case"a":br.setState({xselect:0,yselect:0,xcursor:a.length,ycursor:0});break;case"c":p&&Z(navigator.clipboard)?navigator.clipboard.writeText(m).catch(L=>console.error(L)):S();break;case"v":p&&Z(navigator.clipboard)?navigator.clipboard.readText().then(L=>{const P=L.replaceAll("\r","");u?g(c,h,P):g(i.xcursor,0,P)}).catch(L=>console.error(L)):S();break;case"x":p&&Z(navigator.clipboard)?navigator.clipboard.writeText(m).then(()=>_()).catch(L=>console.error(L)):S();break}else U.alt||C.length===1&&(p&&i.xcursor<=a.length?u?(g(c,h,C),br.setState({xselect:void 0})):g(i.xcursor,0,C):S());break}}})]})}function mme({blink:t,active:e,prefix:n,label:r,words:i,y:s}){const o=ja(),a=Ne.useCallback(()=>{if(Z(navigator.clipboard)){const[,...l]=i,u=l.join(" ");navigator.clipboard.writeText(u).then(()=>hn("copyit","copied!")).catch(h=>console.error(h))}},[i]),c=Jl(!!e);return Of(!!t,!!e,0,s,o),Hn(`${n} $purple$16 $yellowCOPYIT ${c}${r}`,o,!0),o.changed(),e&&ve.jsx(gs,{OK_BUTTON:a})}function gme({blink:t,active:e,prefix:n,label:r,words:i,y:s}){const o=ja(),a=Ne.useContext(nB),c=Ne.useCallback(()=>{const[u,h]=i;a.sendmessage(u,h)},[i,a]),l=Jl(!!e);return Of(!!t,!!e,0,s,o),Hn(`${n} $purple$16 ${l}${r}`,o,!0),o.changed(),e&&ve.jsx(gs,{OK_BUTTON:c})}function sB({blink:t,active:e,text:n,y:r}){const i=ja(),s=qo(i),o=n.startsWith("!");if(Of(!!t,!!e,0,r,i),i.active.bottomedge=s.bottom,Hn(o?"":n,i,!0),o){const[a,...c]=n.slice(1).split("!"),l=`${c.join("!")}`;let u="PRESS ME";const h=[];tx(l,!0).tokens.forEach(y=>{switch(y.tokenType){case sM:u=y.image.slice(1);break;default:h.push(y.image);break}});const[m,...g]=h,v={blink:t,active:e,prefix:a,label:u,words:g,y:r};switch($t(m)){case"hk":case"hotkey":return null;case"rn":case"range":return null;case"sl":case"select":return null;case"nm":case"number":return null;case"tx":case"text":return null;case"copyit":return ve.jsx(mme,{...v,words:h});default:case"hyperlink":return ve.jsx(gme,{...v,words:h})}}return null}function _me(t){const e=$a();return ve.jsx(sB,{active:!0,blink:e,...t})}function GS(){const t=KT(),[e,n]=ts(Yl(p=>[p.terminal.logs,p.editor.open])),r=ja(),i=br(),s=qo(r),o=e.map(p=>{const[,m,g,...v]=p;let y="$white";switch(m){case"debug":y="$yellow";break;case"error":y="$red";break}const _=v.map(b=>`${b}`).join(" "),S=_.startsWith("!"),E=`$blue[${y}${g}$blue]`;return`${S?"!":""}${E} ${_}`}),a=o.map(p=>{if(p.startsWith("!"))return 1;const m=aM(p,s.width,s.height);return(m==null?void 0:m.y)??1});let c=0,l=s.bottom-1;const u=a.map(p=>(l-=p,c+=p,l));++c;const h=s.bottom-i.ycursor+i.scroll;return ve.jsxs(ve.Fragment,{children:[ve.jsx(fM,{context:r}),ve.jsxs(nB.Provider,{value:{sendmessage(p,m){const[g,v]=sme(p);if(g==="self"){const y=`#${v} ${m??""}`;Wv("tape",y,t)}else Yt.emit(`${g}:${v}`,"gadget",m,t)}},children:[o.map((p,m)=>{const g=u[m]+i.scroll,v=a[m],y=g+v;return y<0||g>s.bottom-1?null:!n&&h>=g&&h[m.editor.type,m.editor.title])),o=$a(),a="$205".repeat(e.width-4);yf(!1,!1,0,1,t,0,0,0),Hn(`$179$${o?"7":"232"}$200${a}$181`,t,!0);const l=` ${`[${i}] `}${s} `,u=aM(l,e.width,e.height),h=(u==null?void 0:u.measuredwidth)??1,p=Math.round(e.width*.5)-Math.round(h*.5);return yf(!1,!1,p,0,t,0,0,0),Hn(l,t,!0),t.changed(),null}function yme({xcursor:t,ycursor:e,xoffset:n,yoffset:r,rows:i,codepage:s}){var P,T;const o=$a(),a=ja(),c=Ne.useRef(),l=hr(),u=qo(a),h=ts(H=>H.editor.player),p=rB(s),m=Z(p)?p.toJSON():"",g=i.length-1,v=t+1-n,y=e+2-r;if(Z(s)){const H=((P=c.current)==null?void 0:P.x)!==v||((T=c.current)==null?void 0:T.y)!==y;if(o||H){const V=u.left+v,B=u.top+y;B>u.top+1&&Bu.left&&V0&&(p==null||p.delete(H,V)),Z(B)&&(p==null||p.insert(H,B)),hr.setState({cursor:H+(B??"").length,select:void 0})}function I(){Z(l.select)&&(hr.setState({cursor:E}),C(E,R))}function U(){hr.setState({cursor:_,select:void 0})}const L=Ne.useCallback(function(V){const B=Math.round(e+V);if(B<0)hr.setState({cursor:0});else if(B>g)hr.setState({cursor:_});else{const z=i[B];hr.setState({cursor:z.start+Math.min(t,z.code.length-1)})}},[_,i,g,t,e]);return a.changed(),ve.jsxs(ve.Fragment,{children:[ve.jsx(iB,{blocking:!0,x:u.left,y:u.top,width:u.width,height:u.height,onScroll:H=>L(H*.75)}),ve.jsx(gs,{keydown:H=>{if(!Z(p))return;const{key:V}=H,B=$t(V),z=Gy(H);switch(B){case"arrowleft":if(O(z.shift),z.ctrl)hr.setState({cursor:S.start});else{const W=l.cursor-(z.alt?10:1);hr.setState({cursor:Cn(W,0,_)})}break;case"arrowright":if(O(z.shift),z.ctrl)hr.setState({cursor:S.end});else{const W=l.cursor+(z.alt?10:1);hr.setState({cursor:Cn(W,0,_)})}break;case"arrowup":O(z.shift),z.ctrl?hr.setState({cursor:0}):L(z.alt?-10:-1);break;case"arrowdown":O(z.shift),z.ctrl?hr.setState({cursor:_}):L(z.alt?10:1);break;case"enter":Z(p)&&(p.insert(l.cursor,` `),hr.setState({cursor:l.cursor+1}));break;case"esc":case"escape":z.shift||z.alt||z.ctrl?Pb("tape"):M9("editor");break;case"tab":pL("editor",!z.shift);break;case"delete":N?I():C(l.cursor,1);break;case"backspace":N?I():m.length>0&&C(Math.max(l.cursor-1,0),1);break;default:if(z.ctrl)switch(B){case"a":hr.setState({cursor:_,select:0});break;case"c":Z(navigator.clipboard)?navigator.clipboard.writeText(M).catch(W=>Pn("tape","clipboard",W)):U();break;case"v":Z(navigator.clipboard)?navigator.clipboard.readText().then(W=>{const K=W.replaceAll("\r","");N?C(E,R,K):C(l.cursor,0,K)}).catch(W=>Pn("tape","clipboard",W)):U();break;case"x":Z(navigator.clipboard)?navigator.clipboard.writeText(M).then(()=>I()).catch(W=>Pn("tape","clipboard",W)):U();break;case"p":Wv("editor",M,h),hn("editor",`running: ${M}`);break}else if(!z.alt){if(V.length===1)if(N)C(E,R,V);else{const W=l.cursor+V.length;p.insert(l.cursor,V),hr.setState({cursor:W})}}break}}})]})}function xme({ycursor:t,xoffset:e,yoffset:n,rows:r,codepage:i}){const s=$a(),o=ja(),a=hr(),c=qo(o);if(!Z(i)){const m=(s?"|":"-").repeat(3);return yf(!1,!1,0,0,o,1,2,1),Hn(` ${m} LOADING ${m}`,o,!0),null}let l=a.cursor,u=a.cursor,h=!1;Z(a.select)&&(h=!0,l=Math.min(a.cursor,a.select),u=Math.max(a.cursor,a.select),a.cursor!==a.select&&--u);const p=c.left+1;yf(!1,!1,-e,-n,o,1,2,1);for(let m=0;m=l){const _=Math.max(g.start,l)-g.start-e,S=Math.min(g.end,u)-g.start-e,E=c.width-3,b=1+o.y*o.width,N=Math.max(0,_),R=Math.min(E,S);N<=E&&R>=p&&ix(b+N,b+R,Qpe,eme,o)}if(++o.y,o.y>=c.bottom)break}return o.disablewrap=!1,null}function WS(){const[t]=ts(Yl(v=>[v.editor])),e=ja(),n=hr(),r=DU(mL(t.book,t.page)),i=qo(e);Ne.useEffect(()=>(L9("editor",t.book,t.page,t.player),()=>{P9("editor",t.book,t.page,t.player)}),[t.book,t.page,t.player]);const s=rB(r),o=Z(s)?s.toJSON():"",a=tme(o),c=rme(n.cursor,a),l=n.cursor-a[c].start,u=nme(a),h={rows:a,xcursor:l,ycursor:c,codepage:r,xoffset:n.xscroll,yoffset:n.yscroll},p=32,m=(Math.round(u/p)+1)*p,g=a.length;return Ne.useEffect(()=>{let v=n.xscroll;const y=l-v,_=i.width-3;let S=Math.round(Cn(Math.abs(y)*.5,1,p));S<8&&(S=1),y>_-8&&(v+=S),y<8&&(v-=S);let E=n.yscroll;const b=c-E,N=i.height-4,R=Math.round(N*.5);let M=Math.round(Cn(Math.abs(b)*.25,1,R));M<8&&(M=1),b>N-4&&(E+=M),b<4&&(E-=M),setTimeout(()=>hr.setState({xscroll:Math.round(Cn(v,0,m)),yscroll:Math.round(Cn(E,0,g))}),16)},[l,m,n.xscroll,c,g,n.yscroll,i.width,i.height]),ve.jsxs(ve.Fragment,{children:[ve.jsx(fM,{context:e}),ve.jsx(vme,{}),ve.jsx(xme,{...h}),ve.jsx(yme,{...h})]})}function jI(t,e,n,r,i){return{...i,x:t,y:e,reset:{...i.reset,topedge:e,leftedge:t,rightedge:n,bottomedge:r},active:{...i.reset,topedge:e,leftedge:t,rightedge:n,bottomedge:r}}}function Sme({context:t}){const[e,n]=ts(Yl(l=>[l.layout,l.editor.open])),r=t.width-1,i=t.height-1,s=qo(t),o=Math.floor(s.height*.5),a=Ne.useMemo(()=>jI(0,0,r,o-1,t),[o,r,t]),c=Ne.useMemo(()=>jI(0,o,r,i,t),[o,r,i,t]);if(n){let l,u;switch(e){case Pi.SPLIT_Y:case Pi.SPLIT_Y_ALT:l=a,u=c;break}if(Z(l)&&Z(u))switch(e){case Pi.SPLIT_Y:return ve.jsxs(ve.Fragment,{children:[ve.jsx(Nu.Provider,{value:l,children:ve.jsx(GS,{})}),ve.jsx(Nu.Provider,{value:u,children:ve.jsx(WS,{})})]});case Pi.SPLIT_Y_ALT:return ve.jsxs(ve.Fragment,{children:[ve.jsx(Nu.Provider,{value:l,children:ve.jsx(WS,{})}),ve.jsx(Nu.Provider,{value:u,children:ve.jsx(GS,{})})]})}}return ve.jsx(ve.Fragment,{children:ve.jsx(Nu.Provider,{value:t,children:n?ve.jsx(WS,{}):ve.jsx(GS,{})})})}function Eme(){const t=va(_=>_.viewport),{width:e,height:n}=t.getCurrentViewport(),r=Math.floor(e/as),i=Math.floor(n/Hi),s=Math.floor(e/VS),o=Math.floor(n/HS),a=e-s*VS,c=n-o*HS;let l=0;const u=0,h=s;let p=o;const[m,g]=ts(Yl(_=>[_.layout,_.terminal.open]));switch(m){case Pi.TOP:p=Math.round(o*.5);break;case Pi.BOTTOM:p=Math.round(o*.5),l=o-p;break;default:case Pi.FULL:break}const v=lM(h,p,0,Kp,Wl),y={...jm(h,p,Kp,Wl),...v.getState()};return h<1||p<1?null:ve.jsx(uM,{store:v,children:ve.jsxs("group",{position:[0,0,900],children:[g&&ve.jsx(Mce,{width:r,height:i,top:l,left:u,right:u+h-1,bottom:l+p-1}),ve.jsx("group",{position:[a*.5+u*VS,c+l*HS,1],scale:[kv,kv,1],children:g?ve.jsxs(Im,{blockhotkeys:!0,children:[ve.jsx(fM,{context:y}),ve.jsx(Sme,{context:y}),ve.jsx(hM,{width:h,height:p})]}):ve.jsx(xp,{hotkey:"Shift+?",children:()=>T9("tape")})})]})})}Rb({OrthographicCamera:Bv});Xae();function wme(){const t=va(p=>p.viewport),e=Ne.useRef(null),{width:n,height:r}=t.getCurrentViewport(),i=YT(Kre);i.minFilter=vr,i.magFilter=vr;const[s]=Ne.useState(()=>new Dre);Ne.useEffect(()=>{if(!Fre)return;document.body.appendChild(s.dom),s.showPanel(0),s.dom.style.cssText="position:fixed;bottom:0;left:0;";const p=dW(()=>s.begin()),m=pW(()=>s.end());return()=>{document.body.removeChild(s.dom),p(),m()}},[s]);const[o,a]=Ne.useState();Ne.useEffect(()=>{Lre({benchmarksURL:"/benchmarks-min"}).then(a).catch(p=>Pn("gpu","detect",p))},[]);const c=!zre&&o&&o.tier>2&&!o.isMobile,l=va(({set:p})=>p),u=va(({size:p})=>p),h=va(({camera:p})=>p);return Ne.useLayoutEffect(()=>{var p;(p=e.current)==null||p.updateProjectionMatrix()}),Ne.useLayoutEffect(()=>{const p=h;return l(()=>({camera:e.current})),()=>l(()=>({camera:p}))},[l,h,e]),ve.jsxs(ve.Fragment,{children:[ve.jsx("orthographicCamera",{ref:e,left:u.width/-2,right:u.width/2,top:u.height/2,bottom:u.height/-2,near:1,far:2e3,position:[0,0,1e3]}),ve.jsx("group",{"scale-x":-1,"rotation-z":Math.PI,children:ve.jsx("group",{position:[n*-.5,r*-.5,0],children:ve.jsxs(Im,{children:[ve.jsx(Ype,{}),ve.jsx(Eme,{})]})})}),c&&ve.jsx(Mre,{children:ve.jsx(Xre,{splat:i,viewheight:r})})]})}Rb({BufferGeometry:Bo,Group:rp,Mesh:Ao,MeshBasicMaterial:wb,OrthographicCamera:Bv,PlaneGeometry:em,Points:PG});document.addEventListener("keydown",()=>{gd()});window.addEventListener("touchstart",()=>{gd()});window.addEventListener("click",()=>{gd()});window.addEventListener("dragover",t=>{t.preventDefault()});window.addEventListener("contextmenu",t=>{gd(),t.preventDefault()});window.addEventListener("paste",t=>{var n;if(!((n=t.clipboardData)!=null&&n.files.length))return;gd(),t.preventDefault(),[...t.clipboardData.files].forEach(r=>HE("loadfile",r,iv()))});window.addEventListener("drop",t=>{var e,n;gd(),t.preventDefault(),(e=t.dataTransfer)!=null&&e.items?[...t.dataTransfer.items].forEach(i=>{if(i.kind==="file"){const s=i.getAsFile();Z(s)&&HE("loadfile",s,iv())}}):[...((n=t.dataTransfer)==null?void 0:n.files)??[]].forEach(i=>HE("loadfile",i,iv()))});function bme(){return ve.jsx(wme,{})}const $I=new xe,qI=new xe,XI=t=>({...EW(t),filter:e=>{const n=e.filter(o=>!(!o.object.visible||(o.object.userData.clippingPlanes??[]).some(c=>(c.projectPoint(o.point,$I),qI.subVectors(o.point,$I).normalize().round(),c.normal.equals(qI)===!1)))),r=n.findIndex(o=>o.object.userData.blocking),i=r===-1?n:n.slice(0,r+1);let s="default";return i.some(o=>o.object.userData.cursor?(s=o.object.userData.cursor,!0):!1),document.querySelectorAll("html, body").forEach(o=>{o.style.cursor=s}),i}}),KI=document.querySelector("canvas");if(Z(KI)){const t=yW(KI),e={dpr:1,flat:!0,linear:!0,shadows:!1,gl:{alpha:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!0}};t.configure({...e,events:XI,onCreated({gl:r}){r.localClippingEnabled=!0}});const n=bW((r,i)=>{t.configure({...e,events:XI,size:{width:r,height:i,top:0,left:0},onCreated({gl:s}){s.localClippingEnabled=!0}})},256);window.addEventListener("resize",()=>{n(c2(window.innerWidth),c2(window.innerHeight))}),t.render(ve.jsx(bme,{}))}});export default Tme(); diff --git a/assets/instance-D7v0ZPjX.js b/assets/instance-tXT3nSNg.js similarity index 99% rename from assets/instance-D7v0ZPjX.js rename to assets/instance-tXT3nSNg.js index d66597f5..ce41aca7 100644 --- a/assets/instance-D7v0ZPjX.js +++ b/assets/instance-tXT3nSNg.js @@ -188,7 +188,7 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis `])}case se.ELSE_IF:case se.ELSE:{const n=Ne(e,"");return e.lines.forEach(r=>n.add(Fe(r))),n}case se.WHILE:{const n=Lr(e.loop),r=Lr(e.done),i=Ne(e,"");return Oo(e.lines,se.IF_CHECK,e.done),e.lines.forEach(s=>{switch(s.type){case se.BREAK:s.goto=r;break;case se.CONTINUE:s.goto=n;break}i.add(Fe(s))}),i}case se.REPEAT:{const n=Lr(e.loop),r=Lr(e.done),i=Ne(e,"");return Oo(e.lines,se.IF_CHECK,e.done),e.lines.forEach(s=>{switch(s.type){case se.BREAK:s.goto=r;break;case se.CONTINUE:s.goto=n;break}i.add(Fe(s))}),i}case se.WAITFOR:{const n=Ne(e,"");return n.add([" if (!",mt(e,"if",Ni(e.words)),`) { api.i(${e.lineindex-1}); } `]),n}case se.FOREACH:{const n=Lr(e.loop),r=Lr(e.done),i=Ne(e,"");return Oo(e.lines,se.IF_CHECK,e.done),e.lines.forEach(s=>{switch(s.type){case se.BREAK:s.goto=r;break;case se.CONTINUE:s.goto=n;break}i.add(Fe(s))}),i}case se.BREAK:return Ne(e,[" ",Mc(e,e.goto),` `]);case se.CONTINUE:return Ne(e,[" ",Mc(e,e.goto),` -`]);case se.OR:return mt(e,"or",e.items.map(Fe));case se.AND:return mt(e,"and",e.items.map(Fe));case se.NOT:return mt(e,"not",e.items.map(Fe));case se.COMPARE:return lM(e);case se.OPERATOR:return fM(e);case se.EXPR:return mt(e,"expr",e.words.map(Fe));default:return console.error("",e.type,e),L_(e)}}function or(e){if(E(e))switch(e.type===se.LINE&&++nn.lineindex,e.lineindex=nn.lineindex,e.type){case se.PROGRAM:e.lines.forEach(or);break;case se.LINE:e.stmts.forEach(or);break;case se.MARK:Yf(e.id,e.lineindex);break;case se.IF:or(e.check),or(e.block);break;case se.IF_BLOCK:e.lines.forEach(or),e.altlines.forEach(or);break;case se.ELSE_IF:e.lines.forEach(or);break;case se.ELSE:case se.WHILE:case se.REPEAT:case se.FOREACH:e.lines.forEach(or);break;case se.MOVE:case se.COMMAND:case se.WAITFOR:case se.IF_CHECK:e.words.forEach(or);break}}function hM(e){return nn.labels={},nn.internal=1,nn.lineindex=0,nn.isfirststat=!0,or(e),{...Fe(e).toStringWithSourceMap({file:`${Cc}.map`}),...nn}}const Uc={HALT_AT_COUNT:256};function dM(e){return He(e)?e.length>0?1:0:e??0}function Nt(e){return`${e??""}`}function P_(e){return`${e}_chip`}function pM(e,t,n){var c,l;const r=P_(e),i=ms(r);let s;He(i.lb)||(i.lb=_s(Object.entries(n.labels??{})),i.lk="",i.mg=void 0,i.ec=1,i.lc=0,i.ys=0,i.ps=0,i.es=(((c=n.errors)==null?void 0:c.length)??0)!==0?1:0);function o(u,f){C.words=f,C.get=a.get;const d=_L(t,u);return E(d)?d(a,f):u!=="send"?o("send",[u,...f]):0}const a={halt(){IM(r)},id(){return e},senderid(u=e){return`vm:${u??e}`},set(u,f){const[d,h]=wL(t,a,u,f);if(d)return h},get(u){const[f,d]=bL(t,a,u);if(f)return d},bucket(u){const f=a.get("bucket");He(f)?f.push(u):a.set("bucket",[u])},tick(u){const f=ke(i.ps)?i.ps:0,d=f%u===0;if(i.ps=f+1,d===!1)return!1;if(a.shouldtick()===!1)return f_(t,a),!1;i.lc=0,i.ys=0,vL(t,a);try{const h=s==null?void 0:s.next();h!=null&&h.done&&(et("chip","crash","generator logic unexpectedly exited"),i.es=1)}catch(h){et("chip","crash",h.message),i.es=1}return f_(t,a),!0},isended(){return i.es===1},shouldtick(){return i.es===0||a.hm()!==0},shouldhalt(){return ke(i.lc)?++i.lc>Uc.HALT_AT_COUNT:!0},hm(){if(He(i.mg)&&He(i.lb)){const[,u]=i.mg;if(E(u))for(let f=0;fke(p)&&p>0)??0}}return 0},yield(){i.ys=1},jump(u){i.ec=u},sy(){return!!i.ys||a.shouldhalt()},emit(u,f,d){Ce.emit(u,a.senderid(),f,d)},send(u,f,d,h){Ce.emit(`${a.senderid(u)}:${f}`,e,d,h)},lock(u){i.lk=u},unlock(){i.lk=""},message(u){i.lk&&u.sender!==i.lk||(i.mg=[u.id,u.target,u.data,u.sender,u.player])},zap(u){if(He(i.lb))for(let f=0;fm>0);p>=0&&(h[p]*=-1)}}},restore(u){if(He(i.lb))for(let f=0;fh.fileName===Cc);return{line:(d==null?void 0:d.lineNumber)??0,column:(d==null?void 0:d.columnNumber)??0}},text(u){return o("text",[u])},stat(...u){return o("stat",u)},hyperlink(...u){return o("hyperlink",u)},command(...u){if(u.length===0)return 0;const[f,...d]=u;return o(Nt(f),d)},if(...u){const[f,d]=ne(u,0,[q.ANY]),h=dM(f);return h&&d0,m=i[d];return p&&He(m)&&a.command(...m),p?1:0},foreachstart(u,...f){const[d,h,p,m]=ne(f,0,[q.STRING,q.NUMBER,q.NUMBER,q.MAYBE_NUMBER]);let b=Math.min(h,p),_=Math.max(h,p);const w=(m??0)||1;if(w<0){const v=b;b=_,_=v}return a.set(d,b-w),0},foreach(u,...f){const[d,h,p,m,b]=ne(f,0,[q.STRING,q.NUMBER,q.NUMBER,q.MAYBE_NUMBER]);let _=Math.min(h,p),w=Math.max(h,p);const v=(m??0)||1;if(v<0){const I=_;_=w,w=I}let S=a.get(d);!ke(S)||S<_||S>w?S=_:S+=v;const L=S<=w?1:0;return L&&(a.set(d,S),bh?1:0},isLessThanOrEq(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d<=h?1:0},isGreaterThanOrEq(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d>=h?1:0},opPlus(u,f){const[d]=ne([u],0,[q.ANY]),[h]=ne([f],0,[q.ANY]);return d+h},opMinus(u,f){const[d]=ne([u],0,[q.ANY]),[h]=ne([f],0,[q.ANY]);return d-h},opPower(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return Math.pow(d,h)},opMultiply(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d*h},opDivide(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d/h},opModDivide(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d%h},opFloorDivide(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return Math.floor(d/h)},opUniPlus(u){const[f]=ne([u],0,[q.NUMBER]);return+f},opUniMinus(u){const[f]=ne([u],0,[q.NUMBER]);return-f}};return s=(l=n.code)==null?void 0:l.call(n,a),a}function Pc(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var D_={exports:{}};/*! +`]);case se.OR:return mt(e,"or",e.items.map(Fe));case se.AND:return mt(e,"and",e.items.map(Fe));case se.NOT:return mt(e,"not",e.items.map(Fe));case se.COMPARE:return lM(e);case se.OPERATOR:return fM(e);case se.EXPR:return mt(e,"expr",e.words.map(Fe));default:return console.error("",e.type,e),L_(e)}}function or(e){if(E(e))switch(e.type===se.LINE&&++nn.lineindex,e.lineindex=nn.lineindex,e.type){case se.PROGRAM:e.lines.forEach(or);break;case se.LINE:e.stmts.forEach(or);break;case se.MARK:Yf(e.id,e.lineindex);break;case se.IF:or(e.check),or(e.block);break;case se.IF_BLOCK:e.lines.forEach(or),e.altlines.forEach(or);break;case se.ELSE_IF:e.lines.forEach(or);break;case se.ELSE:case se.WHILE:case se.REPEAT:case se.FOREACH:e.lines.forEach(or);break;case se.MOVE:case se.COMMAND:case se.WAITFOR:case se.IF_CHECK:e.words.forEach(or);break}}function hM(e){return nn.labels={},nn.internal=1,nn.lineindex=0,nn.isfirststat=!0,or(e),{...Fe(e).toStringWithSourceMap({file:`${Cc}.map`}),...nn}}const Uc={HALT_AT_COUNT:256};function dM(e){return He(e)?e.length>0?1:0:e??0}function Nt(e){return`${e??""}`}function P_(e){return`${e}_chip`}function pM(e,t,n){var c,l;const r=P_(e),i=ms(r);let s;He(i.lb)||(i.lb=_s(Object.entries(n.labels??{})),i.lk="",i.mg=void 0,i.ec=1,i.lc=0,i.ys=0,i.ps=0,i.es=(((c=n.errors)==null?void 0:c.length)??0)!==0?1:0);function o(u,f){C.words=f;const d=_L(t,u);return E(d)?d(a,f):u!=="send"?o("send",[u,...f]):0}const a={halt(){IM(r)},id(){return e},senderid(u=e){return`vm:${u??e}`},set(u,f){const[d,h]=wL(t,a,u,f);if(d)return h},get(u){const[f,d]=bL(t,a,u);if(f)return d},bucket(u){const f=a.get("bucket");He(f)?f.push(u):a.set("bucket",[u])},tick(u){const f=ke(i.ps)?i.ps:0,d=f%u===0;if(i.ps=f+1,d===!1)return!1;if(a.shouldtick()===!1)return f_(t,a),!1;i.lc=0,i.ys=0,C.get=a.get,vL(t,a);try{const h=s==null?void 0:s.next();h!=null&&h.done&&(et("chip","crash","generator logic unexpectedly exited"),i.es=1)}catch(h){et("chip","crash",h.message),i.es=1}return f_(t,a),!0},isended(){return i.es===1},shouldtick(){return i.es===0||a.hm()!==0},shouldhalt(){return ke(i.lc)?++i.lc>Uc.HALT_AT_COUNT:!0},hm(){if(He(i.mg)&&He(i.lb)){const[,u]=i.mg;if(E(u))for(let f=0;fke(p)&&p>0)??0}}return 0},yield(){i.ys=1},jump(u){i.ec=u},sy(){return!!i.ys||a.shouldhalt()},emit(u,f,d){Ce.emit(u,a.senderid(),f,d)},send(u,f,d,h){Ce.emit(`${a.senderid(u)}:${f}`,e,d,h)},lock(u){i.lk=u},unlock(){i.lk=""},message(u){i.lk&&u.sender!==i.lk||(i.mg=[u.id,u.target,u.data,u.sender,u.player])},zap(u){if(He(i.lb))for(let f=0;fm>0);p>=0&&(h[p]*=-1)}}},restore(u){if(He(i.lb))for(let f=0;fh.fileName===Cc);return{line:(d==null?void 0:d.lineNumber)??0,column:(d==null?void 0:d.columnNumber)??0}},text(u){return o("text",[u])},stat(...u){return o("stat",u)},hyperlink(...u){return o("hyperlink",u)},command(...u){if(u.length===0)return 0;const[f,...d]=u;return o(Nt(f),d)},if(...u){const[f,d]=ne(u,0,[q.ANY]),h=dM(f);return h&&d0,m=i[d];return p&&He(m)&&a.command(...m),p?1:0},foreachstart(u,...f){const[d,h,p,m]=ne(f,0,[q.STRING,q.NUMBER,q.NUMBER,q.MAYBE_NUMBER]);let b=Math.min(h,p),_=Math.max(h,p);const w=(m??0)||1;if(w<0){const v=b;b=_,_=v}return a.set(d,b-w),0},foreach(u,...f){const[d,h,p,m,b]=ne(f,0,[q.STRING,q.NUMBER,q.NUMBER,q.MAYBE_NUMBER]);let _=Math.min(h,p),w=Math.max(h,p);const v=(m??0)||1;if(v<0){const I=_;_=w,w=I}let S=a.get(d);!ke(S)||S<_||S>w?S=_:S+=v;const L=S<=w?1:0;return L&&(a.set(d,S),bh?1:0},isLessThanOrEq(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d<=h?1:0},isGreaterThanOrEq(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d>=h?1:0},opPlus(u,f){const[d]=ne([u],0,[q.ANY]),[h]=ne([f],0,[q.ANY]);return d+h},opMinus(u,f){const[d]=ne([u],0,[q.ANY]),[h]=ne([f],0,[q.ANY]);return d-h},opPower(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return Math.pow(d,h)},opMultiply(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d*h},opDivide(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d/h},opModDivide(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return d%h},opFloorDivide(u,f){const[d]=ne([u],0,[q.NUMBER]),[h]=ne([f],0,[q.NUMBER]);return Math.floor(d/h)},opUniPlus(u){const[f]=ne([u],0,[q.NUMBER]);return+f},opUniMinus(u){const[f]=ne([u],0,[q.NUMBER]);return-f}};return s=(l=n.code)==null?void 0:l.call(n,a),a}function Pc(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var D_={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files diff --git a/index.html b/index.html index 827c7450..32ee690b 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - ZSS - main:0.20.31:d1dce6a3d88ed996956ba007d9f55b4b36fe9d05 + ZSS - main:0.20.32:a2a5194f4f0662a3a228e8b1ff3234d119559d62 @@ -36,7 +36,7 @@ }(window.location)) - +