@inkeep/open-knowledge 0.29.0-beta.0 → 0.29.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/constants-DzwzGnge.mjs +2 -0
- package/dist/{dist-YCnI0BBU.mjs → dist-D1WPeGDD.mjs} +1 -1
- package/dist/{dist-CzszUkVL.mjs → dist-enzS4QJb.mjs} +4 -4
- package/dist/{gh-detect-V88Du2MF.mjs → gh-detect-CkD5P0-7.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-BwZjunnX.mjs +1 -0
- package/dist/{init-T4iNBuZr.mjs → init-CD7gPvxY.mjs} +4 -4
- package/dist/loader-B2tdFV2u.mjs +1 -0
- package/dist/{loader-DrYPDE4W.mjs → loader-BNccmd7o.mjs} +2 -2
- package/dist/{open-browser-ngpLclet.mjs → open-browser-DamMPOar.mjs} +2 -2
- package/dist/{preview-DCgISA37.mjs → preview-CJTJyhRe.mjs} +2 -2
- package/dist/preview-CloAm65l.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-9CRsXwpX.js → ActivityModeContent-CxxS8nFq.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DTQhS7of.js → CodeMirrorPropInput-CI_BdrFO.js} +1 -1
- package/dist/public/assets/{DocumentContext-fCycsmXU.js → DocumentContext-H8ueoY2i.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-Di9PpxcJ.js → EnableSyncConfirmDialog-Bfx-F020.js} +1 -1
- package/dist/public/assets/{GraphPanel-RxqTHyYU.js → GraphPanel-Bq38mdVO.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-OmaGINfG.js → ManagedArtifactProperties-BSPBOnr-.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-ikl9jWLz.js → McpConsentDialogBody-iiKQkaSO.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DmgH_l9s.js → MermaidDocEditor-DeLvY3mL.js} +1 -1
- package/dist/public/assets/{PropertyPanel-DW-wXPL8.js → PropertyPanel-M1FqAxBu.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-DLKGYz4m.js → SettingsDialogBody-CI2EJgcM.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-BO-B5Z58.js → ShareBranchSwitchDialog-DCB8oBto.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-C2putkgB.js → ShareReceiveDialog-Dd0J6bu0.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-WUihVM0X.js → ShareReceiveMissDialog-CXxQa4KW.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-DBG6FPch.js → SkillEditorActions-CYONKTh4.js} +1 -1
- package/dist/public/assets/{SourceEditor-Dli-GA4u.js → SourceEditor-9SpbjiWH.js} +1 -1
- package/dist/public/assets/{TerminalPanel-B5-ikSnl.js → TerminalPanel-Cc0voOqd.js} +1 -1
- package/dist/public/assets/{agent-presence-EPReOnD1.js → agent-presence-BH_OoZBC.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CwFOes4V.js → auth-state-cache-Chy1TIhv.js} +1 -1
- package/dist/public/assets/{config-provider-idYtRijR.js → config-provider-C8aBdDar.js} +1 -1
- package/dist/public/assets/{dist-wGNuEzOi.js → dist-AuN-WRQ2.js} +1 -1
- package/dist/public/assets/{dist-vGnNU_kt.js → dist-D5fPTJjV.js} +2 -2
- package/dist/public/assets/{doc-hash-DZPPDZDP.js → doc-hash-I00EhzUZ.js} +1 -1
- package/dist/public/assets/{documents-events-C387FFj2.js → documents-events-BvkJvzEE.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-DohgQL5I.js → file-tree-adapter-DvAE1kkw.js} +1 -1
- package/dist/public/assets/{index-BESZ1LvY.js → index-CWW9ADpk.js} +7 -7
- package/dist/public/assets/{keyboard-shortcuts-CKBtlgh1.js → keyboard-shortcuts-BuZN2bTe.js} +1 -1
- package/dist/public/assets/{navigation-targets-v47kYNlN.js → navigation-targets-u2AFSpqT.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BylvD5LD.js → open-managed-artifact-tab-BX3OwOLJ.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-NlnPJ3yz.js → pending-receive-nav-store-DD8Ei1lo.js} +1 -1
- package/dist/public/assets/{prop-types-DDCTJMGl.js → prop-types-B0pfL-iG.js} +1 -1
- package/dist/public/assets/{receive-store-S3luT2x-.js → receive-store-Dt6o4uQU.js} +1 -1
- package/dist/public/assets/{selection-context-BeAbIsTm.js → selection-context-BVfXsapt.js} +1 -1
- package/dist/public/assets/skill-actions-D6y739v8.js +1 -0
- package/dist/public/assets/{skills-api-CDt3rqi3.js → skills-api-C4PwgAoY.js} +1 -1
- package/dist/public/assets/{src-ePqEpSu0.js → src-ibmWGcks.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-9hvgFXB8.js → target-navigation-intent-P7IapNEj.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CEJxVkAD.js → typing-burst-detector-DXjPfO7_.js} +1 -1
- package/dist/public/assets/{workspace-paths-Dhhbnhbw.js → workspace-paths-BTMolBhv.js} +1 -1
- package/dist/public/index.html +25 -25
- package/dist/{repair-launch-json-BQQaFuKa.mjs → repair-launch-json-B0B568xb.mjs} +2 -2
- package/dist/{repair-mcp-configs-COKWe8pq.mjs → repair-mcp-configs-Cz7vaVvt.mjs} +2 -2
- package/dist/repair-skills-DRT6PpNy.mjs +1 -0
- package/dist/{repair-skills-q1ij3mTL.mjs → repair-skills-DoroYY8I.mjs} +2 -2
- package/dist/server-lock-GuuouVft-C8t6Ffyt.mjs +1 -0
- package/dist/{server-lock-iLcBw_q0-CU5aT1xR.mjs → server-lock-iLcBw_q0-rwg8rOgA.mjs} +2 -2
- package/dist/{src-D0bM1z_b.mjs → src-BGLE9r6j.mjs} +2 -2
- package/dist/start-CSu4I80l.mjs +1 -0
- package/dist/{start-Sq4c1D8L.mjs → start-D8BbQM4c.mjs} +2 -2
- package/dist/{write-project-skill-IMZdJi1p.mjs → write-project-skill-8alJi7YJ.mjs} +3 -3
- package/package.json +1 -1
- package/dist/constants-Dddf4Zbt.mjs +0 -2
- package/dist/init-CGWSpnxf.mjs +0 -1
- package/dist/loader-u8jcWe4s.mjs +0 -1
- package/dist/preview-CzKjLznn.mjs +0 -1
- package/dist/public/assets/skill-actions-CCgKV1BP.js +0 -1
- package/dist/repair-skills-DAdqIWrM.mjs +0 -1
- package/dist/server-lock-GuuouVft-Bm1fDFIJ.mjs +0 -1
- package/dist/start-rgO6nXNS.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{n as i}from"./dist-BVOt51sU.js";import{Ft as a,Jt as o,Lt as s,Yt as c,_ as l,g as u,h as d,m as f,nr as ee}from"./dist-vGnNU_kt.js";import{t as te}from"./config-context-CE3SCVYc.js";var ne=r(),p=e(t(),1),re=null,ie=new Set;function ae(){return re}function oe(e){let t=e!==null&&e.length>0?e:null;if(t!==re){re=t;for(let e of ie)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function se(e){return ie.add(e),()=>{ie.delete(e)}}function ce(){return(0,p.useSyncExternalStore)(se,ae,ae)}var m=()=>new Map,le=e=>{let t=m();return e.forEach((e,n)=>{t.set(n,e)}),t},h=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ue=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},de=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},g=()=>new Set,fe=e=>e[e.length-1],pe=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},_=Array.from,me=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},he=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ge=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},v=Array.isArray,_e=class{constructor(){this._observers=m()}on(e,t){return h(this._observers,e,g).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},ve=class{constructor(){this._observers=m()}on(e,t){h(this._observers,e,g).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},y=Math.floor,b=Math.abs,ye=(e,t)=>e<t?e:t,be=(e,t)=>e>t?e:t;Number.isNaN;var xe=e=>e===0?1/e<0:e<0,Se=1<<17,Ce=1<<18,we=1<<19,Te=1<<20,Ee=1<<21,De=1<<22,Oe=1<<23,ke=1<<24,Ae=1<<25,je=1<<26,Me=1<<27,Ne=1<<28,Pe=1<<29;Se-1,Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1;var Fe=2**53-1,Ie=-(2**53-1),Le=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&y(e)===e);Number.isNaN,Number.parseInt;var Re=String.fromCharCode;String.fromCodePoint,Re(65535);var ze=e=>e.toLowerCase(),Be=/^\s*/g,Ve=e=>e.replace(Be,``),He=/([A-Z])/g,Ue=(e,t)=>Ve(e.replace(He,e=>`${t}${ze(e)}`)),We=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ge=typeof TextEncoder<`u`?new TextEncoder:null,Ke=Ge?e=>Ge.encode(e):We,qe=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});qe&&qe.decode(new Uint8Array).length===1&&(qe=null);var Je=(e,t)=>ge(t,()=>e).join(``),Ye=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Xe=()=>new Ye,Ze=e=>{let t=Xe();return e(t),x(t)},Qe=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},x=e=>{let t=new Uint8Array(Qe(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},$e=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(be(n,t)*2),e.cpos=0)},S=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},et=S,C=(e,t)=>{for(;t>127;)S(e,128|127&t),t=y(t/128);S(e,127&t)},tt=(e,t)=>{let n=xe(t);for(n&&(t=-t),S(e,(t>63?128:0)|(n?64:0)|63&t),t=y(t/64);t>0;)S(e,(t>127?128:0)|127&t),t=y(t/128)},nt=new Uint8Array(3e4),rt=nt.length/3,it=Ge&&Ge.encodeInto?(e,t)=>{if(t.length<rt){let n=Ge.encodeInto(t,nt).written||0;C(e,n);for(let t=0;t<n;t++)S(e,nt[t])}else w(e,Ke(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;C(e,r);for(let t=0;t<r;t++)S(e,n.codePointAt(t))},at=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ye(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(be(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},w=(e,t)=>{C(e,t.byteLength),at(e,t)},ot=(e,t)=>{$e(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},st=(e,t)=>ot(e,4).setFloat32(0,t,!1),ct=(e,t)=>ot(e,8).setFloat64(0,t,!1),lt=(e,t)=>ot(e,8).setBigInt64(0,t,!1),ut=new DataView(new ArrayBuffer(4)),dt=e=>(ut.setFloat32(0,e),ut.getFloat32(0)===e),ft=(e,t)=>{switch(typeof t){case`string`:S(e,119),it(e,t);break;case`number`:Le(t)&&b(t)<=2147483647?(S(e,125),tt(e,t)):dt(t)?(S(e,124),st(e,t)):(S(e,123),ct(e,t));break;case`bigint`:S(e,122),lt(e,t);break;case`object`:if(t===null)S(e,126);else if(v(t)){S(e,117),C(e,t.length);for(let n=0;n<t.length;n++)ft(e,t[n])}else if(t instanceof Uint8Array)S(e,116),w(e,t);else{S(e,118);let n=Object.keys(t);C(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];it(e,i),ft(e,t[i])}}break;case`boolean`:S(e,t?120:121);break;default:S(e,127)}},pt=class extends Ye{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&C(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},mt=e=>{e.count>0&&(tt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&C(e.encoder,e.count-2))},ht=class{constructor(){this.encoder=new Ye,this.s=0,this.count=0}write(e){this.s===e?this.count++:(mt(this),this.count=1,this.s=e)}toUint8Array(){return mt(this),x(this.encoder)}},gt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);tt(e.encoder,t),e.count>1&&C(e.encoder,e.count-2)}},_t=class{constructor(){this.encoder=new Ye,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(gt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return gt(this),x(this.encoder)}},vt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new ht}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Ye;return this.sarr.push(this.s),this.s=``,it(e,this.sarr.join(``)),at(e,this.lensE.toUint8Array()),x(e)}},T=e=>Error(e),E=()=>{throw T(`Method unimplemented`)},D=()=>{throw T(`Unexpected case`)},yt=T(`Unexpected end of array`),bt=T(`Integer out of Range`),xt=class{constructor(e){this.arr=e,this.pos=0}},St=e=>new xt(e),Ct=e=>e.pos!==e.arr.length,wt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},O=e=>wt(e,k(e)),Tt=e=>e.arr[e.pos++],k=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Fe)throw bt}throw yt},Et=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Fe)throw bt}throw yt},Dt=qe?e=>qe.decode(O(e)):e=>{let t=k(e);if(t===0)return``;{let n=String.fromCodePoint(Tt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Tt(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ot=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},kt=[e=>void 0,e=>null,Et,e=>Ot(e,4).getFloat32(0,!1),e=>Ot(e,8).getFloat64(0,!1),e=>Ot(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Dt,e=>{let t=k(e),n={};for(let r=0;r<t;r++){let t=Dt(e);n[t]=At(e)}return n},e=>{let t=k(e),n=[];for(let r=0;r<t;r++)n.push(At(e));return n},O],At=e=>kt[127-Tt(e)](e),jt=class extends xt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ct(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}},Mt=class extends xt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Et(this);let e=xe(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}},Nt=class extends xt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Et(this),t=e&1;this.diff=y(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}},Pt=class{constructor(e){this.decoder=new Mt(e),this.str=Dt(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Ft=crypto.getRandomValues.bind(crypto),It=Math.random,Lt=()=>Ft(new Uint32Array(1))[0],Rt=e=>e[y(It()*e.length)],zt=`10000000-1000-4000-8000-100000000000`,Bt=()=>zt.replace(/[018]/g,e=>(e^Lt()&15>>e/4).toString(16)),Vt=Date.now,Ht=e=>new Promise(e);Promise.all.bind(Promise);var Ut=e=>e===void 0?null:e,Wt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Wt=localStorage)}catch{}var Gt=Wt,Kt=Symbol(`Equality`),qt=(e,t)=>e===t||!!e?.[Kt]?.(t)||!1,Jt=e=>typeof e==`object`,Yt=Object.assign,Xt=Object.keys,Zt=(e,t)=>{for(let n in e)t(e[n],n)},Qt=e=>Xt(e).length,$t=e=>{for(let t in e)return!1;return!0},en=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},tn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),nn=(e,t)=>e===t||Qt(e)===Qt(t)&&en(e,(e,n)=>(e!==void 0||tn(t,n))&&qt(t[n],e)),rn=Object.freeze,an=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&an(e[t])}return rn(e)},on=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&on(e,t,n+1)}},sn=e=>e,cn=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Kt]!=null)return e[Kt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!cn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Qt(e)!==Qt(t))return!1;for(let n in e)if(!tn(e,n)||!cn(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!cn(e[n],t[n]))return!1;break;default:return!1}return!0},ln=(e,t)=>t.includes(e),un=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,dn=typeof window<`u`&&typeof document<`u`&&!un;typeof navigator<`u`&&/Mac/.test(navigator.platform);var A,fn=[],pn=()=>{if(A===void 0)if(un){A=m();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&A.set(t,``),t=r):t===null?fn.push(r):(A.set(t,r),t=null)}t!==null&&A.set(t,``)}else typeof location==`object`?(A=m(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);A.set(`--${Ue(t,`-`)}`,n),A.set(`-${Ue(t,`-`)}`,n)}})):A=m();return A},mn=e=>pn().has(e),hn=e=>Ut(un?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Gt.getItem(e)),gn=e=>mn(`--`+e)||hn(e)!==null,_n=gn(`production`),vn=un&&ln({}.FORCE_COLOR,[`true`,`1`,`2`])||!mn(`--no-colors`)&&!gn(`no-color`)&&(!un||process.stdout.isTTY)&&(!un||mn(`--color`)||hn(`COLORTERM`)!==null||(hn(`TERM`)||``).includes(`color`)),yn=e=>new Uint8Array(e),bn=dn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Re(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),xn=e=>{let t=yn(e.byteLength);return t.set(e),t},Sn=e=>Ze(t=>ft(t,e)),Cn=class{constructor(e,t){this.left=e,this.right=t}},j=(e,t)=>new Cn(e,t),wn=(e,t)=>e.forEach(e=>t(e.left,e.right)),Tn=e=>e.next()>=.5,En=(e,t,n)=>y(e.next()*(n+1-t)+t),Dn=(e,t,n)=>y(e.next()*(n+1-t)+t),On=(e,t,n)=>Dn(e,t,n),kn=e=>Re(On(e,97,122)),An=(e,t=0,n=20)=>{let r=On(e,t,n),i=``;for(let t=0;t<r;t++)i+=kn(e);return i},jn=(e,t)=>t[On(e,0,t.length-1)],Mn=Symbol(`0schema`),Nn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Je(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{n as i}from"./dist-BVOt51sU.js";import{Ft as a,Jt as o,Lt as s,Yt as c,_ as l,g as u,h as d,m as f,nr as ee}from"./dist-D5fPTJjV.js";import{t as te}from"./config-context-CE3SCVYc.js";var ne=r(),p=e(t(),1),re=null,ie=new Set;function ae(){return re}function oe(e){let t=e!==null&&e.length>0?e:null;if(t!==re){re=t;for(let e of ie)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function se(e){return ie.add(e),()=>{ie.delete(e)}}function ce(){return(0,p.useSyncExternalStore)(se,ae,ae)}var m=()=>new Map,le=e=>{let t=m();return e.forEach((e,n)=>{t.set(n,e)}),t},h=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ue=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},de=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},g=()=>new Set,fe=e=>e[e.length-1],pe=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},_=Array.from,me=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},he=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ge=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},v=Array.isArray,_e=class{constructor(){this._observers=m()}on(e,t){return h(this._observers,e,g).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},ve=class{constructor(){this._observers=m()}on(e,t){h(this._observers,e,g).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},y=Math.floor,b=Math.abs,ye=(e,t)=>e<t?e:t,be=(e,t)=>e>t?e:t;Number.isNaN;var xe=e=>e===0?1/e<0:e<0,Se=1<<17,Ce=1<<18,we=1<<19,Te=1<<20,Ee=1<<21,De=1<<22,Oe=1<<23,ke=1<<24,Ae=1<<25,je=1<<26,Me=1<<27,Ne=1<<28,Pe=1<<29;Se-1,Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1;var Fe=2**53-1,Ie=-(2**53-1),Le=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&y(e)===e);Number.isNaN,Number.parseInt;var Re=String.fromCharCode;String.fromCodePoint,Re(65535);var ze=e=>e.toLowerCase(),Be=/^\s*/g,Ve=e=>e.replace(Be,``),He=/([A-Z])/g,Ue=(e,t)=>Ve(e.replace(He,e=>`${t}${ze(e)}`)),We=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ge=typeof TextEncoder<`u`?new TextEncoder:null,Ke=Ge?e=>Ge.encode(e):We,qe=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});qe&&qe.decode(new Uint8Array).length===1&&(qe=null);var Je=(e,t)=>ge(t,()=>e).join(``),Ye=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Xe=()=>new Ye,Ze=e=>{let t=Xe();return e(t),x(t)},Qe=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},x=e=>{let t=new Uint8Array(Qe(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},$e=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(be(n,t)*2),e.cpos=0)},S=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},et=S,C=(e,t)=>{for(;t>127;)S(e,128|127&t),t=y(t/128);S(e,127&t)},tt=(e,t)=>{let n=xe(t);for(n&&(t=-t),S(e,(t>63?128:0)|(n?64:0)|63&t),t=y(t/64);t>0;)S(e,(t>127?128:0)|127&t),t=y(t/128)},nt=new Uint8Array(3e4),rt=nt.length/3,it=Ge&&Ge.encodeInto?(e,t)=>{if(t.length<rt){let n=Ge.encodeInto(t,nt).written||0;C(e,n);for(let t=0;t<n;t++)S(e,nt[t])}else w(e,Ke(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;C(e,r);for(let t=0;t<r;t++)S(e,n.codePointAt(t))},at=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ye(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(be(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},w=(e,t)=>{C(e,t.byteLength),at(e,t)},ot=(e,t)=>{$e(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},st=(e,t)=>ot(e,4).setFloat32(0,t,!1),ct=(e,t)=>ot(e,8).setFloat64(0,t,!1),lt=(e,t)=>ot(e,8).setBigInt64(0,t,!1),ut=new DataView(new ArrayBuffer(4)),dt=e=>(ut.setFloat32(0,e),ut.getFloat32(0)===e),ft=(e,t)=>{switch(typeof t){case`string`:S(e,119),it(e,t);break;case`number`:Le(t)&&b(t)<=2147483647?(S(e,125),tt(e,t)):dt(t)?(S(e,124),st(e,t)):(S(e,123),ct(e,t));break;case`bigint`:S(e,122),lt(e,t);break;case`object`:if(t===null)S(e,126);else if(v(t)){S(e,117),C(e,t.length);for(let n=0;n<t.length;n++)ft(e,t[n])}else if(t instanceof Uint8Array)S(e,116),w(e,t);else{S(e,118);let n=Object.keys(t);C(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];it(e,i),ft(e,t[i])}}break;case`boolean`:S(e,t?120:121);break;default:S(e,127)}},pt=class extends Ye{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&C(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},mt=e=>{e.count>0&&(tt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&C(e.encoder,e.count-2))},ht=class{constructor(){this.encoder=new Ye,this.s=0,this.count=0}write(e){this.s===e?this.count++:(mt(this),this.count=1,this.s=e)}toUint8Array(){return mt(this),x(this.encoder)}},gt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);tt(e.encoder,t),e.count>1&&C(e.encoder,e.count-2)}},_t=class{constructor(){this.encoder=new Ye,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(gt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return gt(this),x(this.encoder)}},vt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new ht}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Ye;return this.sarr.push(this.s),this.s=``,it(e,this.sarr.join(``)),at(e,this.lensE.toUint8Array()),x(e)}},T=e=>Error(e),E=()=>{throw T(`Method unimplemented`)},D=()=>{throw T(`Unexpected case`)},yt=T(`Unexpected end of array`),bt=T(`Integer out of Range`),xt=class{constructor(e){this.arr=e,this.pos=0}},St=e=>new xt(e),Ct=e=>e.pos!==e.arr.length,wt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},O=e=>wt(e,k(e)),Tt=e=>e.arr[e.pos++],k=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Fe)throw bt}throw yt},Et=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Fe)throw bt}throw yt},Dt=qe?e=>qe.decode(O(e)):e=>{let t=k(e);if(t===0)return``;{let n=String.fromCodePoint(Tt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Tt(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ot=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},kt=[e=>void 0,e=>null,Et,e=>Ot(e,4).getFloat32(0,!1),e=>Ot(e,8).getFloat64(0,!1),e=>Ot(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Dt,e=>{let t=k(e),n={};for(let r=0;r<t;r++){let t=Dt(e);n[t]=At(e)}return n},e=>{let t=k(e),n=[];for(let r=0;r<t;r++)n.push(At(e));return n},O],At=e=>kt[127-Tt(e)](e),jt=class extends xt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ct(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}},Mt=class extends xt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Et(this);let e=xe(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}},Nt=class extends xt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Et(this),t=e&1;this.diff=y(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}},Pt=class{constructor(e){this.decoder=new Mt(e),this.str=Dt(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Ft=crypto.getRandomValues.bind(crypto),It=Math.random,Lt=()=>Ft(new Uint32Array(1))[0],Rt=e=>e[y(It()*e.length)],zt=`10000000-1000-4000-8000-100000000000`,Bt=()=>zt.replace(/[018]/g,e=>(e^Lt()&15>>e/4).toString(16)),Vt=Date.now,Ht=e=>new Promise(e);Promise.all.bind(Promise);var Ut=e=>e===void 0?null:e,Wt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Wt=localStorage)}catch{}var Gt=Wt,Kt=Symbol(`Equality`),qt=(e,t)=>e===t||!!e?.[Kt]?.(t)||!1,Jt=e=>typeof e==`object`,Yt=Object.assign,Xt=Object.keys,Zt=(e,t)=>{for(let n in e)t(e[n],n)},Qt=e=>Xt(e).length,$t=e=>{for(let t in e)return!1;return!0},en=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},tn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),nn=(e,t)=>e===t||Qt(e)===Qt(t)&&en(e,(e,n)=>(e!==void 0||tn(t,n))&&qt(t[n],e)),rn=Object.freeze,an=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&an(e[t])}return rn(e)},on=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&on(e,t,n+1)}},sn=e=>e,cn=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Kt]!=null)return e[Kt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!cn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Qt(e)!==Qt(t))return!1;for(let n in e)if(!tn(e,n)||!cn(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!cn(e[n],t[n]))return!1;break;default:return!1}return!0},ln=(e,t)=>t.includes(e),un=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,dn=typeof window<`u`&&typeof document<`u`&&!un;typeof navigator<`u`&&/Mac/.test(navigator.platform);var A,fn=[],pn=()=>{if(A===void 0)if(un){A=m();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&A.set(t,``),t=r):t===null?fn.push(r):(A.set(t,r),t=null)}t!==null&&A.set(t,``)}else typeof location==`object`?(A=m(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);A.set(`--${Ue(t,`-`)}`,n),A.set(`-${Ue(t,`-`)}`,n)}})):A=m();return A},mn=e=>pn().has(e),hn=e=>Ut(un?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Gt.getItem(e)),gn=e=>mn(`--`+e)||hn(e)!==null,_n=gn(`production`),vn=un&&ln({}.FORCE_COLOR,[`true`,`1`,`2`])||!mn(`--no-colors`)&&!gn(`no-color`)&&(!un||process.stdout.isTTY)&&(!un||mn(`--color`)||hn(`COLORTERM`)!==null||(hn(`TERM`)||``).includes(`color`)),yn=e=>new Uint8Array(e),bn=dn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Re(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),xn=e=>{let t=yn(e.byteLength);return t.set(e),t},Sn=e=>Ze(t=>ft(t,e)),Cn=class{constructor(e,t){this.left=e,this.right=t}},j=(e,t)=>new Cn(e,t),wn=(e,t)=>e.forEach(e=>t(e.left,e.right)),Tn=e=>e.next()>=.5,En=(e,t,n)=>y(e.next()*(n+1-t)+t),Dn=(e,t,n)=>y(e.next()*(n+1-t)+t),On=(e,t,n)=>Dn(e,t,n),kn=e=>Re(On(e,97,122)),An=(e,t=0,n=20)=>{let r=On(e,t,n),i=``;for(let t=0;t<r;t++)i+=kn(e);return i},jn=(e,t)=>t[On(e,0,t.length-1)],Mn=Symbol(`0schema`),Nn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Je(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
2
|
`)}},Pn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Kt]?qt(e,t):v(e)?me(e,e=>he(t,t=>Pn(e,t))):Jt(e)?en(e,(e,n)=>Pn(e,t[n])):!1,M=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Pn(t,n)}equals(e){return this.constructor===e.constructor&&cn(this.shape,e.shape)}[Mn](){return!0}[Kt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){E()}get nullable(){return dr(this,Er)}get optional(){return new Un(this)}cast(e){return Ar(e,this),e}expect(e){return Ar(e,this),e}},Fn=class extends M{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},N=(e,t=null)=>new Fn(e,t);N(Fn);var In=class extends M{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},P=e=>new In(e);N(In);var Ln=class extends M{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Rn=(...e)=>new Ln(e),zn=N(Ln),Bn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Vn=e=>{if(xr.check(e))return[Bn(e)];if(zn.check(e))return e.shape.map(e=>e+``);if(br.check(e))return[`[+-]?\\d+.?\\d*`];if(Sr.check(e))return[`.*`];if(fr.check(e))return e.shape.map(Vn).flat(1);D()};N(class extends M{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Vn).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Hn=Symbol(`optional`),Un=class extends M{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Hn](){return!0}},Wn=N(Un),Gn=class extends M{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Gn,N(Gn);var Kn=class e extends M{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):en(this.shape,(n,r)=>{let i=this._isPartial&&!tn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},qn=e=>new Kn(e),Jn=N(Kn),Yn=P(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Xn=class extends M{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&en(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Zn=(e,t)=>new Xn(e,t),Qn=N(Xn),$n=class extends M{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&en(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},er=(...e)=>new $n(e);N($n);var tr=class extends M{constructor(e){super(),this.shape=e.length===1?e[0]:new ur(e)}check(e,t){let n=v(e)&&me(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},nr=(...e)=>new tr(e),rr=N(tr),ir=P(e=>v(e)),ar=class extends M{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},or=(e,t=null)=>new ar(e,t);N(ar);var sr=or(M),cr=N(class extends M{constructor(e){super(),this.len=e.length-1,this.args=er(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),lr=P(e=>typeof e==`function`);N(class extends M{constructor(e){super(),this.shape=e}check(e,t){let n=me(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var ur=class extends M{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=he(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},dr=(...e)=>e.findIndex(e=>fr.check(e))>=0?dr(...e.map(e=>kr(e)).map(e=>fr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new ur(e),fr=N(ur),pr=()=>!0,mr=P(pr),hr=N(In,e=>e.shape===pr),gr=P(e=>typeof e==`bigint`),_r=P(e=>e===gr),vr=P(e=>typeof e==`symbol`);P(e=>e===vr);var yr=P(e=>typeof e==`number`),br=P(e=>e===yr),xr=P(e=>typeof e==`string`),Sr=P(e=>e===xr),Cr=P(e=>typeof e==`boolean`),wr=P(e=>e===Cr),Tr=Rn(void 0);N(Ln,e=>e.shape.length===1&&e.shape[0]===void 0),Rn(void 0);var Er=Rn(null),Dr=N(Ln,e=>e.shape.length===1&&e.shape[0]===null);N(Uint8Array),N(Fn,e=>e.shape===Uint8Array);var Or=dr(yr,xr,Er,Tr,gr,Cr,vr);(()=>{let e=nr(mr),t=Zn(xr,mr),n=dr(yr,xr,Er,Cr,e,t);return e.shape=n,t.shape.values=n,n})();var kr=e=>{if(sr.check(e))return e;if(Yn.check(e)){let t={};for(let n in e)t[n]=kr(e[n]);return qn(t)}else if(ir.check(e))return dr(...e.map(kr));else if(Or.check(e))return Rn(e);else if(lr.check(e))return N(e);D()},Ar=_n?()=>{}:(e,t)=>{let n=new Nn;if(!t.check(e,n))throw T(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},jr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:kr(e),h:t}),this}else(e){return this.if(mr,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw T(`Unhandled pattern`)}}},Mr=(e=>new jr(e))(mr).if(br,(e,t)=>En(t,Ie,Fe)).if(Sr,(e,t)=>An(t)).if(wr,(e,t)=>Tn(t)).if(_r,(e,t)=>BigInt(En(t,Ie,Fe))).if(fr,(e,t)=>Nr(t,jn(t,e.shape))).if(Jn,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Wn.check(i)){if(Tn(t))continue;i=i.shape}n[r]=Mr(i,t)}return n}).if(rr,(e,t)=>{let n=[],r=Dn(t,0,42);for(let i=0;i<r;i++)n.push(Nr(t,e.shape));return n}).if(zn,(e,t)=>jn(t,e.shape)).if(Dr,(e,t)=>null).if(cr,(e,t)=>{let n=Nr(t,e.res);return()=>n}).if(hr,(e,t)=>Nr(t,jn(t,[yr,xr,Er,Tr,gr,Cr,nr(yr),Zn(dr(`a`,`b`,`c`),yr)]))).if(Qn,(e,t)=>{let n={},r=En(t,0,3);for(let i=0;i<r;i++){let r=Nr(t,e.shape.keys);n[r]=Nr(t,e.shape.values)}return n}).done(),Nr=(e,t)=>Mr(kr(t),e),F=typeof document<`u`?document:{},Pr=e=>F.createElement(e),Fr=()=>F.createDocumentFragment();P(e=>e.nodeType===qr);var Ir=e=>F.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Lr=(e,t)=>(wn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Rr=e=>{let t=Fr();for(let n=0;n<e.length;n++)Ur(t,e[n]);return t},zr=(e,t)=>(Ur(e,Rr(t)),e),Br=(e,t=[],n=[])=>zr(Lr(Pr(e),t),n);P(e=>e.nodeType===Wr);var Vr=Ir;P(e=>e.nodeType===Gr);var Hr=e=>ue(e,(e,t)=>`${t}:${e};`).join(``),Ur=(e,t)=>e.appendChild(t),Wr=F.ELEMENT_NODE,Gr=F.TEXT_NODE;F.CDATA_SECTION_NODE,F.COMMENT_NODE;var Kr=F.DOCUMENT_NODE;F.DOCUMENT_TYPE_NODE;var qr=F.DOCUMENT_FRAGMENT_NODE;P(e=>e.nodeType===Kr);var Jr=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Yr=(e,t)=>new Jr(setTimeout(t,e)),I=Symbol,Xr=I(),Zr=I(),Qr=I(),$r=I(),ei=I(),ti=I(),ni=I(),ri=I(),ii=I(),ai=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Vt();var oi={[Xr]:j(`font-weight`,`bold`),[Zr]:j(`font-weight`,`normal`),[Qr]:j(`color`,`blue`),[ei]:j(`color`,`green`),[$r]:j(`color`,`grey`),[ti]:j(`color`,`red`),[ni]:j(`color`,`purple`),[ri]:j(`color`,`orange`),[ii]:j(`color`,`black`)},si=vn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=m(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=oi[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Hr(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:ai,ci=(...e)=>{console.log(...si(e)),ui.forEach(t=>t.print(e))},li=(...e)=>{console.warn(...si(e)),e.unshift(ri),ui.forEach(t=>t.print(e))},ui=g(),di=e=>({[Symbol.iterator](){return this},next:e}),fi=(e,t)=>di(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),pi=(e,t)=>di(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),mi=class{constructor(e,t){this.clock=e,this.len=t}},hi=class{constructor(){this.clients=new Map}},gi=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])ja(e,i,o.clock,o.len,n)}}),_i=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=y((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},vi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&_i(n,t.clock)!==null},yi=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new mi(r.clock,be(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},bi=e=>{let t=new hi;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)pe(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return yi(t),t},xi=(e,t,n,r)=>{h(e.clients,t,()=>[]).push(new mi(n,r))},Si=()=>new hi,Ci=e=>{let t=Si();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new mi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},wi=(e,t)=>{C(e.restEncoder,t.clients.size),_(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),C(e.restEncoder,t);let r=n.length;C(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ti=e=>{let t=new hi,n=k(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=k(e.restDecoder),r=k(e.restDecoder);if(r>0){let i=h(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new mi(e.readDsClock(),e.readDsLen()))}}return t},Ei=(e,t,n)=>{let r=new hi,i=k(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=k(e.restDecoder),a=k(e.restDecoder),o=n.clients.get(i)||[],s=R(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&xi(r,i,s,a-s);let e=z(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Hs(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Hs(t,c,a-c.id.clock)),c.delete(t))}else xi(r,i,n,a-n)}}if(r.clients.size>0){let e=new Ii;return C(e.restEncoder,0),wi(e,r),e.toUint8Array()}return null},Di=Lt,Oi=class e extends _e{constructor({guid:e=Bt(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Di(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new wa,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ht(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Ht(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&V(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(_(this.subdocs).map(e=>e.guid))}transact(e,t=null){return V(this,e,t)}get(e,t=W){let n=h(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==W&&r!==t)if(r===W){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,No)}getText(e=``){return this.get(e,es)}getMap(e=``){return this.get(e,Io)}getXmlElement(e=``){return this.get(e,as)}getXmlFragment(e=``){return this.get(e,rs)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,_(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,V(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},ki=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}},Ai=class extends ki{readLeftID(){return L(k(this.restDecoder),k(this.restDecoder))}readRightID(){return L(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return Tt(this.restDecoder)}readString(){return Dt(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return At(this.restDecoder)}readBuf(){return xn(O(this.restDecoder))}readJSON(){return JSON.parse(Dt(this.restDecoder))}readKey(){return Dt(this.restDecoder)}},ji=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){let e=k(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Mi=class extends ji{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Nt(O(e)),this.clientDecoder=new Mt(O(e)),this.leftClockDecoder=new Nt(O(e)),this.rightClockDecoder=new Nt(O(e)),this.infoDecoder=new jt(O(e),Tt),this.stringDecoder=new Pt(O(e)),this.parentInfoDecoder=new jt(O(e),Tt),this.typeRefDecoder=new Mt(O(e)),this.lenDecoder=new Mt(O(e))}readLeftID(){return new aa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new aa(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 At(this.restDecoder)}readBuf(){return O(this.restDecoder)}readJSON(){return At(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Ni=class{constructor(){this.restEncoder=Xe()}toUint8Array(){return x(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){C(this.restEncoder,e)}writeDsLen(e){C(this.restEncoder,e)}},Pi=class extends Ni{writeLeftID(e){C(this.restEncoder,e.client),C(this.restEncoder,e.clock)}writeRightID(e){C(this.restEncoder,e.client),C(this.restEncoder,e.clock)}writeClient(e){C(this.restEncoder,e)}writeInfo(e){et(this.restEncoder,e)}writeString(e){it(this.restEncoder,e)}writeParentInfo(e){C(this.restEncoder,+!!e)}writeTypeRef(e){C(this.restEncoder,e)}writeLen(e){C(this.restEncoder,e)}writeAny(e){ft(this.restEncoder,e)}writeBuf(e){w(this.restEncoder,e)}writeJSON(e){it(this.restEncoder,JSON.stringify(e))}writeKey(e){it(this.restEncoder,e)}},Fi=class{constructor(){this.restEncoder=Xe(),this.dsCurrVal=0}toUint8Array(){return x(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,C(this.restEncoder,t)}writeDsLen(e){e===0&&D(),C(this.restEncoder,e-1),this.dsCurrVal+=e}},Ii=class extends Fi{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new _t,this.clientEncoder=new ht,this.leftClockEncoder=new _t,this.rightClockEncoder=new _t,this.infoEncoder=new pt(et),this.stringEncoder=new vt,this.parentInfoEncoder=new pt(et),this.typeRefEncoder=new ht,this.lenEncoder=new ht}toUint8Array(){let e=Xe();return C(e,0),w(e,this.keyClockEncoder.toUint8Array()),w(e,this.clientEncoder.toUint8Array()),w(e,this.leftClockEncoder.toUint8Array()),w(e,this.rightClockEncoder.toUint8Array()),w(e,x(this.infoEncoder)),w(e,this.stringEncoder.toUint8Array()),w(e,x(this.parentInfoEncoder)),w(e,this.typeRefEncoder.toUint8Array()),w(e,this.lenEncoder.toUint8Array()),at(e,x(this.restEncoder)),x(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){ft(this.restEncoder,e)}writeBuf(e){w(this.restEncoder,e)}writeJSON(e){ft(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Li=(e,t,n,r)=>{r=be(r,t[0].id.clock);let i=z(t,r);C(e.restEncoder,t.length-i),e.writeClient(n),C(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},Ri=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{R(t,n)>e&&r.set(n,e)}),Ta(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),C(e.restEncoder,r.size),_(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Li(e,t.clients.get(n),n,r)})},zi=(e,t)=>{let n=m(),r=k(e.restDecoder);for(let i=0;i<r;i++){let r=k(e.restDecoder),i=Array(r),a=e.readClient(),o=k(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new G(L(a,o),t),o+=t;break}case 10:{let t=k(e.restDecoder);i[n]=new Y(L(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(L(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Gs(e,r));i[n]=c,o+=c.length}}}}return n},Bi=(e,t,n)=>{let r=[],i=_(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new wa,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Y){let i=h(d,u.id.client,()=>R(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,R(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Ii;return Ri(e,s,new Map),C(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Vi=(e,t)=>Ri(e,t.doc.store,t.beforeState),Hi=(e,t,n,r=new Mi(e))=>V(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Bi(e,i,zi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<R(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Ja([o.update,a.update])}}else i.pendingStructs=a;let s=Ei(r,e,i);if(i.pendingDs){let t=new Mi(St(i.pendingDs));k(t.restDecoder);let n=Ei(t,e,i);s&&n?i.pendingDs=Ja([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Ui(e.doc,t)}},n,!1),Ui=(e,t,n,r=Mi)=>{let i=St(t);Hi(i,e,n,new r(i))},Wi=(e,t,n)=>Ui(e,t,n,Ai),Gi=(e,t,n=new Map)=>{Ri(e,t.store,n),wi(e,Ci(t.store))},Ki=(e,t=new Uint8Array([0]),n=new Ii)=>{Gi(n,e,Yi(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Ya(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Pi)return Ka(r.map((e,t)=>t===0?e:$a(e)));if(n.constructor===Ii)return Ja(r)}return r[0]},qi=(e,t)=>Ki(e,t,new Pi),Ji=e=>{let t=new Map,n=k(e.restDecoder);for(let r=0;r<n;r++){let n=k(e.restDecoder),r=k(e.restDecoder);t.set(n,r)}return t},Yi=e=>Ji(new ki(St(e))),Xi=(e,t)=>(C(e.restEncoder,t.size),_(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{C(e.restEncoder,t),C(e.restEncoder,n)}),e),Zi=(e,t)=>Xi(e,Ta(t.store)),Qi=(e,t=new Fi)=>(e instanceof Map?Xi(t,e):Zi(t,e),t.toUint8Array()),$i=e=>Qi(e,new Ni),ea=class{constructor(){this.l=[]}},ta=()=>new ea,na=(e,t)=>e.l.push(t),ra=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},ia=(e,t,n)=>on(e.l,[t,n]),aa=class{constructor(e,t){this.client=e,this.clock=t}},oa=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,L=(e,t)=>new aa(e,t),sa=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw D()},ca=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},la=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ua=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},da=e=>new la(e.type==null?null:L(e.type.client,e.type.clock),e.tname??null,e.item==null?null:L(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),fa=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},pa=(e,t,n=0)=>new fa(e,t,n),ma=(e,t,n)=>{let r=null,i=null;return e._item===null?i=sa(e):r=L(e._item.id.client,e._item.id.clock),new la(r,i,t,n)},ha=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ma(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ma(e,L(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ma(e,r.lastId,n);r=r.right}return ma(e,null,n)},ga=(e,t)=>{let n=Da(e,t);return{item:n,diff:t.clock-n.id.clock}},_a=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(R(r,i.client)<=i.clock)return null;let e=n?Bs(r,i):ga(r,i),t=e.item;if(!(t instanceof J))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(R(r,a.client)<=a.clock)return null;let{item:e}=n?Bs(r,a):{item:Da(r,a)};if(e instanceof J&&e.content instanceof q)c=e.content.type;else return null}else throw D();l=s>=0?c._length:0}return pa(c,l,e.assoc)},va=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&oa(e.item,t.item)&&oa(e.type,t.type)&&e.assoc===t.assoc,ya=class{constructor(e,t){this.ds=e,this.sv=t}},ba=(e,t)=>new ya(e,t);ba(Si(),new Map);var xa=e=>ba(Ci(e.store),Ta(e.store)),Sa=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!vi(t.ds,e.id),Ca=(e,t)=>{let n=h(e.meta,Ca,g),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<R(r,n)&&B(e,L(n,t))}),gi(e,t.ds,e=>{}),n.add(t))},wa=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ta=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},R=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Ea=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw D()}n.push(t)},z=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=y(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=y((n+r)/2)}throw D()},Da=(e,t)=>{let n=e.clients.get(t.client);return n[z(n,t.clock)]},Oa=(e,t,n)=>{let r=z(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,Hs(e,i,n-i.id.clock)),r+1):r},B=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Oa(e,n,t.clock)]},ka=(e,t,n)=>{let r=t.clients.get(n.client),i=z(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==G&&r.splice(i+1,0,Hs(e,a,n.clock-a.id.clock+1)),a},Aa=(e,t,n)=>{let r=e.clients.get(t.id.client);r[z(r,t.id.clock)]=n},ja=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Oa(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Oa(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Ma=class{constructor(e,t,n){this.doc=e,this.deleteSet=new hi,this.beforeState=Ta(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Na=(e,t)=>t.deleteSet.clients.size===0&&!de(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(yi(t.deleteSet),Vi(e,t),wi(e,t.deleteSet),!0),Pa=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&h(e.changed,t,g).add(n)},Fa=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof J&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Ia=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=z(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof J&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},La=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=ye(r.length-1,1+z(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Fa(r,e)}})},Ra=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{yi(a),n.afterState=Ta(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{ia(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Zo(n)})}),on(e,[])}finally{r.gc&&Ia(a,i,r.gcFilter),La(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=be(z(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Fa(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=z(r,n);a+1<r.length&&Fa(r,a+1)>1||a>0&&Fa(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(ci(ri,Xr,`[yjs] `,Zr,ti,`Changed the client-id because another client seems to be using it.`),r.clientID=Di()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Pi;Na(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Ii;Na(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Ra(e,t+1)}}},V=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Ma(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Ra(i,0)}}return o},za=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Ba=(e,t,n)=>{gi(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||ca(t,n))&&Vs(n,!1)})},Va=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;V(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;gi(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=Bs(r,e.id);i>0&&(t=B(n,L(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ca(t,e))&&c.push(e)}}),gi(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||ca(t,e))&&!vi(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Ws(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Ha=class extends _e{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=v(e)?e[0].doc:e instanceof Oi?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new hi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&xi(i,n,r,a)});let a=Vt(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=bi([t.deletions,e.deleteSet]),t.insertions=bi([t.insertions,i])}else r.push(new za(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),gi(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||ca(n,t))&&Vs(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=v(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof W?e.doc!==this.doc:e!==this.doc)&&li(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ba(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ba(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Va(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Va(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*Ua(e){let t=k(e.restDecoder);for(let n=0;n<t;n++){let t=k(e.restDecoder),n=e.readClient(),r=k(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=k(e.restDecoder);yield new Y(L(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(L(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Gs(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new G(L(n,r),t),r+=t}}}}var Wa=class{constructor(e,t){this.gen=Ua(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Y);return this.curr}},Ga=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Ka=e=>Ja(e,Ai,Pi),qa=(e,t)=>{if(e.constructor===G){let{client:n,clock:r}=e.id;return new G(L(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(L(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(L(r,i+t),null,L(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ja=(e,t=Mi,n=Ii)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(St(e))),i=r.map(e=>new Wa(e,!0)),a=null,o=new n,s=new Ga(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Y?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)H(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Y)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{H(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(L(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Y?a.struct.length-=t:n=qa(n,t)),a.struct.mergeWith(n)||(H(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Y;n=e.next())H(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(H(s,a.struct,a.offset),a=null),Za(s),wi(o,bi(r.map(e=>Ti(e)))),o.toUint8Array()},Ya=(e,t,n=Mi,r=Ii)=>{let i=Yi(t),a=new r,o=new Ga(a),s=new n(St(e)),c=new Wa(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Y){c.next();continue}if(e.id.clock+e.length>n)for(H(o,e,be(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)H(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Za(o),wi(a,Ti(s)),a.toUint8Array()},Xa=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:x(e.encoder.restEncoder)}),e.encoder.restEncoder=Xe(),e.written=0)},H=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Xa(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),C(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Za=e=>{Xa(e);let t=e.encoder.restEncoder;C(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];C(t,r.written),at(t,r.restEncoder)}},Qa=(e,t,n,r)=>{let i=new n(St(e)),a=new Wa(i,!1),o=new r,s=new Ga(o);for(let e=a.curr;e!==null;e=a.next())H(s,t(e),0);return Za(s),wi(o,Ti(i)),o.toUint8Array()},$a=e=>Qa(e,sn,Mi,Pi),eo=`You must not compute changes after the event-handler fired.`,to=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=no(this.currentTarget,this.target)}deletes(e){return vi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw T(eo);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=fe(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=fe(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=fe(r.content.getContent());else return;e.set(n,{action:i,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 T(eo);let t=this.target,n=g(),r=g(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},no=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},U=()=>{li(`Invalid access: Add Yjs type to a document before reading data.`)},ro=80,io=0,ao=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=io++}},oo=e=>{e.timestamp=io++},so=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=io++},co=(e,t,n)=>{if(e.length>=ro){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return so(r,t,n),r}else{let r=new ao(t,n);return e.push(r),r}},lo=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>b(t-e.index)<b(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,oo(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)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&&b(n.index-i)<r.parent.length/ro?(so(n,r,i),n):co(e._searchMarker,r,i)},uo=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=be(t,i.index+n))}},fo=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;h(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ia(r._eH,n,t)},W=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ta(),this._dEH=ta(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw E()}clone(){throw E()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){na(this._eH,e)}observeDeep(e){na(this._dEH,e)}unobserve(e){ra(this._eH,e)}unobserveDeep(e){ra(this._dEH,e)}toJSON(){}},po=(e,t,n)=>{e.doc??U(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},mo=e=>{e.doc??U();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},ho=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Sa(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},go=(e,t)=>{let n=0,r=e._start;for(e.doc??U();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},_o=(e,t)=>{let n=[];return go(e,(r,i)=>{n.push(t(r,i,e))}),n},vo=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},yo=(e,t)=>{e.doc??U();let n=lo(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},bo=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ds(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ms(new Uint8Array(n))),i.integrate(e,0);break;case Oi:i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ys(n)),i.integrate(e,0);break;default:if(n instanceof W)i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new q(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},xo=()=>T(`Length exceeded!`),So=(e,t,n,r)=>{if(n>t._length)throw xo();if(n===0)return t._searchMarker&&uo(t._searchMarker,n,r.length),bo(e,t,null,r);let i=n,a=lo(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.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<o.length&&B(e,L(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&uo(t._searchMarker,i,r.length),bo(e,t,o,r)},Co=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return bo(e,t,r,n)},wo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=lo(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&B(e,L(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&B(e,L(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw xo();t._searchMarker&&uo(t._searchMarker,i,-a+r)},To=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Eo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Ds([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Ds([r]);break;case Uint8Array:s=new ms(r);break;case Oi:s=new ys(r);break;default:if(r instanceof W)s=new q(r);else throw Error(`Unexpected content type`)}new J(L(o,R(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Do=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Oo=e=>{let t={};return e.doc??U(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},ko=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted},Ao=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Sa(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},jo=e=>(e.doc??U(),fi(e._map.entries(),e=>!e[1].deleted)),Mo=class extends to{},No=class e extends W{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}get length(){return this.doc??U(),this._length}_callObserver(e,t){super._callObserver(e,t),fo(this,e,new Mo(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):V(this.doc,n=>{So(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):V(this.doc,t=>{Co(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):V(this.doc,n=>{wo(n,this,e,t)})}get(e){return yo(this,e)}toArray(){return mo(this)}slice(e=0,t=this.length){return po(this,e,t)}toJSON(){return this.map(e=>e instanceof W?e.toJSON():e)}map(e){return _o(this,e)}forEach(e){go(this,e)}[Symbol.iterator](){return vo(this)}_write(e){e.writeTypeRef(Ms)}},Po=e=>new No,Fo=class extends to{constructor(e,t,n){super(e,t),this.keysChanged=n}},Io=class e extends W{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof W?e.clone():e)}),t}_callObserver(e,t){fo(this,e,new Fo(this,e,t))}toJSON(){this.doc??U();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof W?r.toJSON():r}}),e}get size(){return[...jo(this)].length}keys(){return pi(jo(this),e=>e[0])}values(){return pi(jo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return pi(jo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??U(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):V(this.doc,t=>{To(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):V(this.doc,n=>{Eo(n,this,e,t)}),t}get(e){return Do(this,e)}has(e){return ko(this,e)}clear(){this.doc===null?this._prelimContent.clear():V(this.doc,e=>{this.forEach(function(t,n,r){To(e,r,n)})})}_write(e){e.writeTypeRef(Ns)}},Lo=e=>new Io,Ro=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&nn(e,t),zo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&D(),this.right.content.constructor){case K:this.right.deleted||Uo(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}},Bo=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case K:t.right.deleted||Uo(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&B(e,L(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Vo=(e,t,n,r)=>{let i=new Map,a=r?lo(t,n):null;return a?Bo(e,new zo(a.p.left,a.p,a.index,i),n-a.index):Bo(e,new zo(null,t._start,0,i),n)},Ho=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===K&&Ro(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new J(L(a,R(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new K(o,r));l.integrate(e,0),n.right=l,n.forward()})},Uo=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Wo=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===K&&Ro(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Go=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Ro(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(L(a,R(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new K(s,c)),n.right.integrate(e,0),n.forward()}}return o},Ko=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Wo(n,i);let s=Go(e,t,n,i),c=r.constructor===String?new ks(r):r instanceof W?new q(r):new xs(r),{left:l,right:u,index:d}=n;t._searchMarker&&uo(t._searchMarker,n.index,c.getLength()),u=new J(L(o,R(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Ho(e,t,n,s)},qo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Wo(n,i);let s=Go(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===K));){if(!n.right.deleted)switch(n.right.content.constructor){case K:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Ro(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&B(e,L(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
3
3
|
`;n.right=new J(L(o,R(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new ks(i)),n.right.integrate(e,0),n.forward()}Ho(e,t,n,s)},Jo=(e,t,n,r,i)=>{let a=t,o=m();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===K){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case K:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Uo(i,n);break}}}t=t.right}return s},Yo=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===K){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Xo=e=>{let t=0;return V(e.doc,n=>{let r=e._start,i=e._start,a=m(),o=le(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case K:Uo(o,i.content);break;default:t+=Jo(n,r,i,a,o),a=le(o),r=i;break}i=i.right}}),t},Zo=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&ja(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===K&&e.constructor!==G&&t.add(e.parent)})}V(n,n=>{gi(e,e.deleteSet,e=>{if(e instanceof G||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===K?t.add(r):Yo(n,e)});for(let e of t)Xo(e)})},Qo=(e,t,n)=>{let r=n,i=le(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case q:case xs:case ks:n<t.right.length&&B(e,L(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Jo(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&uo(o._searchMarker,t.index,-r+n),t},$o=class extends to{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];V(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},$t(o)||(e.attributes=Yt({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case q:case xs:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case ks:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case K:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Ro(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Ro(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Ro(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Ro(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Uo(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},es=class e extends W{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??U(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new $o(this,e,t);fo(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??U();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===ks&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):V(this.doc,n=>{let r=new zo(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
4
4
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Ko(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Qo(n,r,a.delete):qo(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??U();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Sa(s,e)||t!==void 0&&Sa(s,t))switch(s.content.constructor){case ks:{let r=i.get(`ychange`);e!==void 0&&!Sa(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Sa(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case q:case xs:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case K:Sa(s,e)&&(c(),Uo(i,s.content));break}s=s.right}c()};return e||t?V(a,n=>{e&&Ca(n,e),t&&Ca(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):V(r,r=>{let i=Vo(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Ko(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):V(r,r=>{let i=Vo(r,this,e,!n);Ko(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):V(n,n=>{Qo(n,Vo(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):V(r,r=>{let i=Vo(r,this,e,!1);i.right!==null&&qo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):V(this.doc,t=>{To(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):V(this.doc,n=>{Eo(n,this,e,t)})}getAttribute(e){return Do(this,e)}getAttributes(){return Oo(this)}_write(e){e.writeTypeRef(Ps)}},ts=e=>new es,ns=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??U()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===as||t.constructor===rs)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null: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})}},rs=class e extends W{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}get length(){return this.doc??U(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ns(this,e)}querySelector(e){e=e.toUpperCase();let t=new ns(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),_(new ns(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){fo(this,e,new ss(this,t,e))}toString(){return _o(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),go(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):V(this.doc,n=>{So(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)V(this.doc,n=>{let r=e&&e instanceof W?e._item:e;bo(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw T(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):V(this.doc,n=>{wo(n,this,e,t)})}toArray(){return mo(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return yo(this,e)}slice(e=0,t=this.length){return po(this,e,t)}forEach(e){go(this,e)}_write(e){e.writeTypeRef(Is)}},is=e=>new rs,as=class e extends rs{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Zt(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):V(this.doc,t=>{To(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):V(this.doc,n=>{Eo(n,this,e,t)})}getAttribute(e){return Do(this,e)}hasAttribute(e){return ko(this,e)}getAttributes(e){return e?Ao(this,e):Oo(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return go(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Fs),e.writeKey(this.nodeName)}},os=e=>new as(e.readKey()),ss=class extends to{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},cs=class e extends Io{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Ls),e.writeKey(this.hookName)}},ls=e=>new cs(e.readKey()),us=class e extends es{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Rs)}},ds=e=>new us,fs=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw E()}mergeWith(e){return!1}write(e,t,n){throw E()}integrate(e,t){throw E()}},ps=0,G=class extends fs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Ea(e.doc.store,this)}write(e,t){e.writeInfo(ps),e.writeLen(this.length-t)}getMissing(e,t){return null}},ms=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw E()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},hs=e=>new ms(e.readBuf()),gs=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){xi(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},_s=e=>new gs(e.readLen()),vs=(e,t)=>new Oi({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),ys=class e{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;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(vs(this.doc.guid,this.opts))}splice(e){throw E()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,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,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},bs=e=>new ys(vs(e.readString(),e.readAny())),xs=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw E()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Ss=e=>new xs(e.readJSON()),K=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw E()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Cs=e=>new K(e.readKey(),e.readJSON()),ws=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Ts=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new ws(n)},Es=hn(`node_env`)===`development`,Ds=class e{constructor(e){this.arr=e,Es&&an(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Os=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Ds(n)},ks=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},As=e=>new ks(e.readString()),js=[Po,Lo,ts,os,is,ls,ds],Ms=0,Ns=1,Ps=2,Fs=3,Is=4,Ls=5,Rs=6,q=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw E()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},zs=e=>new q(js[e.readTypeRef()](e)),Bs=(e,t)=>{let n=t,r=0,i;do r>0&&(n=L(n.client,n.clock+r)),i=Da(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},Vs=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Hs=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(L(r,i+n),t,L(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=L(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Us=(e,t)=>he(e,e=>vi(e.deletions,t)),Ws=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return B(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ws(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=B(e,u.redone)}let ee=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:B(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:B(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||vi(r,d.right.id)||Us(a.undoStack,d.right.id)||Us(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=B(e,d.redone);if(d&&d.right!==null)return null}else d=ee._map.get(t.parentSub)||null;let te=L(c,R(s,c)),ne=new J(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,Vs(ne,!0),ne.integrate(e,0),ne},J=class e extends fs{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=R(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=R(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===aa&&this.id.client!==this.parent.client&&this.parent.clock>=R(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=ka(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=B(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===G||this.right&&this.right.constructor===G)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===aa){let e=Da(n,this.parent);e.constructor===G?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=ka(e,e.doc.store,L(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),oa(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(oa(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Da(e.doc.store,n.origin)))r.has(Da(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Ea(e.doc.store,this),this.content.integrate(e,this),Pa(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new G(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:L(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&oa(e.origin,this.lastId)&&this.right===e&&oa(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.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){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),xi(e.deleteSet,this.id.client,this.id.clock,this.length),Pa(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw D();this.content.gc(e),t?Aa(e,this,new G(this.id,this.length)):this.content=new gs(this.length)}write(e,t){let n=t>0?L(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=sa(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===aa?(e.writeParentInfo(!1),e.writeLeftID(t)):D();i!==null&&e.writeString(i)}this.content.write(e,t)}},Gs=(e,t)=>Ks[t&31](e),Ks=[()=>{D()},_s,Ts,hs,As,Ss,Cs,zs,Os,bs,()=>{D()}],qs=10,Y=class extends fs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){D()}write(e,t){e.writeInfo(qs),C(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Js=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Ys=`__ $YJS$ __`;Js[Ys]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Js[Ys]=!0;var Xs=Math.floor,Zs=(e,t)=>e<t?e:t,Qs=(e,t)=>e>t?e:t;Number.isNaN;var $s=128,ec=1<<17,tc=1<<18,nc=1<<19,rc=1<<20,ic=1<<21,ac=1<<22,oc=1<<23,sc=1<<24,cc=1<<25,lc=1<<26,uc=1<<27,dc=1<<28,fc=1<<29,pc=1<<30,mc=127;ec-1,tc-1,nc-1,rc-1,ic-1,ac-1,oc-1,sc-1,cc-1,lc-1,uc-1,dc-1,fc-1,pc-1;var hc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var gc=String.fromCharCode;String.fromCodePoint,gc(65535);var _c=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},vc=typeof TextEncoder<`u`?new TextEncoder:null,yc=vc?e=>vc.encode(e):_c,bc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});bc&&bc.decode(new Uint8Array).length===1&&(bc=null);var xc=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Sc=(e,t)=>{for(;t>mc;)xc(e,$s|mc&t),t=Xs(t/128);xc(e,mc&t)},Cc=new Uint8Array(3e4),wc=Cc.length/3,Tc=vc&&vc.encodeInto?(e,t)=>{if(t.length<wc){let n=vc.encodeInto(t,Cc).written||0;Sc(e,n);for(let t=0;t<n;t++)xc(e,Cc[t])}else Dc(e,yc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Sc(e,r);for(let t=0;t<r;t++)xc(e,n.codePointAt(t))},Ec=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Zs(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Qs(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Dc=(e,t)=>{Sc(e,t.byteLength),Ec(e,t)},Oc=e=>Error(e),kc=Oc(`Unexpected end of array`),Ac=Oc(`Integer out of Range`),jc=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Mc=e=>jc(e,Pc(e)),Nc=e=>e.arr[e.pos++],Pc=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&mc)*n,n*=128,r<$s)return t;if(t>hc)throw Ac}throw kc},Fc=bc?e=>bc.decode(Mc(e)):e=>{let t=Pc(e);if(t===0)return``;{let n=String.fromCodePoint(Nc(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Nc(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ic=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),Lc=(e,t)=>{Sc(e,Ic.Token),Tc(e,t)},Rc=(e,t,n,r)=>{switch(Pc(e)){case Ic.Token:t();break;case Ic.PermissionDenied:n(Fc(e));break;case Ic.Authenticated:r(Fc(e));break;default:}},zc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Bc=`\0`;function Vc(e,t){return e+Bc+t}function Hc(e){let t=e.indexOf(Bc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Uc=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Wc(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function Gc(e){return new Promise(t=>setTimeout(t,e))}function Kc(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function qc(e,t){let n=Wc(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Kc;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await Gc(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await Gc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await Gc(e)}return a()}var Jc=Math.floor,Yc=(e,t)=>e<t?e:t,Xc=(e,t)=>e>t?e:t;Number.isNaN;var Zc=64,Qc=128,$c=1<<17,el=1<<18,tl=1<<19,nl=1<<20,rl=1<<21,il=1<<22,al=1<<23,ol=1<<24,sl=1<<25,cl=1<<26,ll=1<<27,ul=1<<28,dl=1<<29,fl=1<<30,pl=63,ml=127;$c-1,el-1,tl-1,nl-1,rl-1,il-1,al-1,ol-1,sl-1,cl-1,ll-1,ul-1,dl-1,fl-1;var hl=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var gl=()=>new Set,_l=Array.from;Array.isArray;var vl=String.fromCharCode;String.fromCodePoint,vl(65535);var yl=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},bl=typeof TextEncoder<`u`?new TextEncoder:null,xl=bl?e=>bl.encode(e):yl,Sl=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Sl&&Sl.decode(new Uint8Array).length===1&&(Sl=null);var Cl=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},wl=()=>new Cl,Tl=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},El=e=>{let t=new Uint8Array(Tl(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Dl=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},X=(e,t)=>{for(;t>ml;)Dl(e,Qc|ml&t),t=Jc(t/128);Dl(e,ml&t)},Ol=new Uint8Array(3e4),kl=Ol.length/3,Z=bl&&bl.encodeInto?(e,t)=>{if(t.length<kl){let n=bl.encodeInto(t,Ol).written||0;X(e,n);for(let t=0;t<n;t++)Dl(e,Ol[t])}else jl(e,xl(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)Dl(e,n.codePointAt(t))},Al=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Yc(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Xc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},jl=(e,t)=>{X(e,t.byteLength),Al(e,t)},Ml=e=>Error(e),Nl=Ml(`Unexpected end of array`),Pl=Ml(`Integer out of Range`),Fl=class{constructor(e){this.arr=e,this.pos=0}},Il=e=>new Fl(e),Ll=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Rl=e=>Ll(e,Bl(e)),zl=e=>e.arr[e.pos++],Bl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&ml)*n,n*=128,r<Qc)return t;if(t>hl)throw Pl}throw Nl},Vl=e=>{let t=e.arr[e.pos++],n=t&pl,r=64,i=(t&Zc)>0?-1:1;if((t&Qc)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&ml)*r,r*=128,t<Qc)return i*n;if(n>hl)throw Pl}throw Nl},Hl=Sl?e=>Sl.decode(Rl(e)):e=>{let t=Bl(e);if(t===0)return``;{let n=String.fromCodePoint(zl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(zl(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ul=e=>{let t=e.pos,n=Hl(e);return e.pos=t,n},Wl=Date.now,Gl=()=>new Map,Kl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ql=class{constructor(){this._observers=Gl()}on(e,t){Kl(this._observers,e,gl).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _l((this._observers.get(e)||Gl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Gl()}},Jl=Symbol(`Equality`),Yl=Object.keys,Xl=e=>Yl(e).length,Zl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ql=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Jl]!=null)return e[Jl](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Ql(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Xl(e)!==Xl(t))return!1;for(let n in e)if(!Zl(e,n)||!Ql(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ql(e[n],t[n]))return!1;break;default:return!1}return!0},$l=3e4,eu=class extends ql{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Wl();this.getLocalState()!==null&&$l/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&$l<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&tu(this,t,`timeout`)},Jc($l/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Wl()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Ql(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},tu=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:Wl()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},nu=(e,t,n=e.states)=>{let r=t.length,i=wl();X(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;X(i,r),X(i,s),Z(i,JSON.stringify(o))}return El(i)},ru=(e,t,n)=>{let r=Il(t),i=Wl(),a=[],o=[],s=[],c=[],l=Bl(r);for(let t=0;t<l;t++){let t=Bl(r),n=Bl(r),l=JSON.parse(Hl(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(Ql(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},iu=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},au=class{constructor(e){this.data=e,this.encoder=wl(),this.decoder=Il(new Uint8Array(this.data))}peekVarString(){return Ul(this.decoder)}readVarUint(){return Bl(this.decoder)}readVarString(){return Hl(this.decoder)}readVarUint8Array(){return Rl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return jl(this.encoder,e)}length(){return Tl(this.encoder)}},Q=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),$=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),ou=class{constructor(){this.encoder=wl()}get(e){return e.encoder}toUint8Array(){return El(this.encoder)}},su=class extends ou{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),this.encoder}},cu=class e extends iu{static{this.DEDUPLICATABLE_TYPES=new Set([Q.Awareness,Q.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=$.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===$.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===$.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(su,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===$.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:qc(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=$.Connecting,this.emit(`status`,{status:$.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Wl();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new au(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=wl();X(e,Q.Pong),this.send(El(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===$.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Wl()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=Il(e);return{documentName:Hl(t),messageType:Bl(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Uc.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=$.Disconnected,this.emit(`status`,{status:$.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},lu=0,uu=1,du=2,fu=(e,t)=>{X(e,lu),jl(e,$i(t))},pu=(e,t,n)=>{X(e,uu),jl(e,qi(t,n))},mu=(e,t,n)=>pu(t,n,Rl(e)),hu=(e,t,n,r)=>{try{Wi(t,Rl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},gu=(e,t)=>{X(e,du),jl(e,t)},_u=hu,vu=(e,t,n,r,i)=>{let a=Bl(e);switch(a){case lu:mu(e,t,n);break;case uu:hu(e,n,r,i);break;case du:_u(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},yu=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Q.Sync:this.applySyncMessage(e,t);break;case Q.Awareness:this.applyAwarenessMessage(e);break;case Q.Auth:this.applyAuthMessage(e);break;case Q.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Q.Stateless:e.receiveStateless(Hl(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,Vl(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:Hl(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(ou,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=vu(n.decoder,n.encoder,e.document,e);t&&r===uu&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;ru(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Rc(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(Q.Awareness),t.writeVarUint8Array(nu(e.awareness,Array.from(e.awareness.getStates().keys())))}},bu=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return El(this.encoder)}send(e){e?.send(this.create())}},xu=`4.0.0-rc.1`,Su=class extends ou{constructor(...e){super(...e),this.type=Q.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return Z(this.encoder,e.documentName),X(this.encoder,this.type),Lc(this.encoder,e.token),Z(this.encoder,xu),this.encoder}},Cu=class extends ou{constructor(...e){super(...e),this.type=Q.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);Z(this.encoder,e.documentName),X(this.encoder,this.type);let t;return t=e.states===void 0?nu(e.awareness,e.clients):nu(e.awareness,e.clients,e.states),jl(this.encoder,t),this.encoder}},wu=class extends ou{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Z(this.encoder,e.payload??``),this.encoder}},Tu=class extends ou{constructor(...e){super(...e),this.type=Q.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return Z(this.encoder,e.documentName),X(this.encoder,this.type),fu(this.encoder,e.document),this.encoder}},Eu=class extends ou{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),gu(this.encoder,e.update),this.encoder}},Du=class extends Error{constructor(...e){super(...e),this.code=1001}},Ou=class extends iu{get effectiveName(){return this.configuration.sessionAwareness?Vc(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Oi,this.configuration.awareness=e.awareness===void 0?new eu(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:zc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:zc(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new cu(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(Tu,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&tu(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(wu,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(Su,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Eu,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Cu,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(Tu,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Cu,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new bu(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new au(e.data),{documentName:n}=Hc(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new au(e.data)}),new yu(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&tu(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(tu(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new Du(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},ku={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.28.2`}?.VITE_APP_VERSION??`0.0.0-unknown`;function Au(){return o({kind:`web`,runtimeVersion:ku})}function ju(){return c({kind:`web`,runtimeVersion:ku})}function Mu(e,t,n=null,r=null){let i={...ju()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}function Nu(e,t){let n=(0,ne.c)(7),r,i;n[0]!==e||n[1]!==t?(r=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1;return e.setThemeSource(t).catch(e=>{console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))}).finally(()=>{if(n)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;e.signalThemeApplied({reducedTransparency:t})}),()=>{n=!0}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,p.useEffect)(r,i);let a,o;n[4]===e?(a=n[5],o=n[6]):(a=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},o=[e],n[4]=e,n[5]=a,n[6]=o),(0,p.useEffect)(a,o)}function Pu(e){let t=(0,ne.c)(5),{setTheme:n}=i(),r;t[0]!==n||t[1]!==e?(r=()=>{(e===`light`||e===`dark`||e===`system`)&&n(e)},t[0]=n,t[1]=e,t[2]=r):r=t[2];let a;t[3]===e?a=t[4]:(a=[e],t[3]=e,t[4]=a),(0,p.useEffect)(r,a)}var Fu=n();function Iu(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function Lu(e,t,n,r){let i=new Oi,o=new Ou({url:e,name:t,document:i,token:Mu(null,r,null),onDisconnect:({event:e})=>Iu(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>Iu(`config-provider`,t,`close`,e)}),s=a(o,n);return{binding:s,config:s.current(),cleanup:()=>{s.dispose(),o.destroy(),i.destroy()}}}function Ru(e,t){let n=new Oi,r=new Ou({url:e,name:f,document:n,token:Mu(null,t,null),onDisconnect:({event:e})=>Iu(`okignore-provider`,f,`disconnect`,e),onClose:({event:e})=>Iu(`okignore-provider`,f,`close`,e)}),i=s(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function zu(e){let t=(0,ne.c)(24),{collabUrl:n,children:r}=e,i=ce(),[a,o]=(0,p.useState)(null),[s,c]=(0,p.useState)(null),[f,re]=(0,p.useState)(null),[ie,ae]=(0,p.useState)(null),oe,se;t[0]!==n||t[1]!==i?(oe=()=>{if(n===null)return;let e=Lu(n,l,`user`,i),t=Lu(n,d,`project`,i),r=Lu(n,u,`project-local`,i),a=Ru(n,i);o({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),c({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),re({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),ae({binding:a.binding,synced:!1});let s=e.binding.subscribe(t=>{o(n=>n?.binding===e.binding?{...n,config:t}:n)}),f=e.binding.subscribeSynced(()=>{o(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),ee=t.binding.subscribe(e=>{c(n=>n?.binding===t.binding?{...n,config:e}:n)}),te=t.binding.subscribeSynced(()=>{c(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),ne=r.binding.subscribe(e=>{re(t=>t?.binding===r.binding?{...t,config:e}:t)}),p=r.binding.subscribeSynced(()=>{re(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),ie=()=>{ae(e=>e?.binding===a.binding?{...e,synced:!0}:e)};return a.provider.on(`synced`,ie),()=>{s(),f(),ee(),te(),ne(),p(),a.provider.off(`synced`,ie);for(let n of[e,t,r,a])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}o(t=>t?.binding===e.binding?null:t),c(e=>e?.binding===t.binding?null:e),re(e=>e?.binding===r.binding?null:e),ae(e=>e?.binding===a.binding?null:e)}},se=[n,i],t[0]=n,t[1]=i,t[2]=oe,t[3]=se):(oe=t[2],se=t[3]),(0,p.useEffect)(oe,se);let m;t[4]!==f?.config||t[5]!==s||t[6]!==a?(m=a&&s?ee(a.config,s.config,f?.config):null,t[4]=f?.config,t[5]=s,t[6]=a,t[7]=m):m=t[7];let le=m,h=le?.appearance?.theme;Pu(h),Nu(typeof window<`u`?window.okDesktop:void 0,h??`system`);let ue=a?.binding??null,de=a?.synced??!1,g=s?.binding??null,fe=f?.binding??null,pe=ie?.binding??null,_=ie?.synced??!1,me=a?.config??null,he=s?.config??null,ge=s?.synced??!1,v=f?.config??null,_e=f?.synced??!1,ve;t[8]!==le||t[9]!==me||t[10]!==he||t[11]!==ge||t[12]!==v||t[13]!==_e||t[14]!==ue||t[15]!==de||t[16]!==g||t[17]!==fe||t[18]!==pe||t[19]!==_?(ve={userBinding:ue,userSynced:de,projectBinding:g,projectLocalBinding:fe,okignoreBinding:pe,okignoreSynced:_,userConfig:me,projectConfig:he,projectSynced:ge,projectLocalConfig:v,projectLocalSynced:_e,merged:le},t[8]=le,t[9]=me,t[10]=he,t[11]=ge,t[12]=v,t[13]=_e,t[14]=ue,t[15]=de,t[16]=g,t[17]=fe,t[18]=pe,t[19]=_,t[20]=ve):ve=t[20];let y=ve,b;return t[21]!==r||t[22]!==y?(b=(0,Fu.jsx)(te,{value:y,children:r}),t[21]=r,t[22]=y,t[23]=b):b=t[23],b}export{Pe as $,sa as A,Br as B,da as C,qi as D,Yi as E,xa as F,dn as G,j as H,V as I,Ht as J,en as K,ho as L,ca as M,gi as N,$i as O,ua as P,D as Q,Yr as R,L as S,ba as T,Sn as U,Vr as V,bn as W,T as X,Rt as Y,E as Z,Wi as _,Ou as a,h as at,_a as b,q as c,la as d,be as et,ya as f,us as g,as as h,Au as i,m as it,vi as j,z as k,Oi as l,es as m,Nu as n,ve as nt,K as o,oe as ot,Ha as p,Xt as q,Mu as r,g as rt,ks as s,zu as t,ye as tt,J as u,Ui as v,ha as w,Si as x,va as y,F as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{M as e,N as t,j as n}from"./CodeMirrorPropInput-
|
|
1
|
+
import{M as e,N as t,j as n}from"./CodeMirrorPropInput-CI_BdrFO.js";import{$ as r,At as i,Bt as a,Dt as o,E as s,Et as c,Ft as l,Ht as u,J as d,Mt as f,N as p,Ot as m,Pt as h,Q as ee,Rt as te,Ut as ne,X as g,_ as re,_t as _,ct as ie,dt as ae,et as oe,f as se,gt as ce,ht as le,l as ue,lt as de,mt as fe,nt as pe,ot as me,rt as v,st as he,tt as ge,ut as _e,wt as y,y as ve,yt as b,zt as ye}from"./dist-Dot7Y1W_.js";import{i as be,n as xe,o as Se,r as Ce}from"./dist-BzxczcQx.js";var we=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,x=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(we(e)):we,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return te(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=ne(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ye(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(x.prototype[Symbol.iterator]=function(){return this});var Te={from:-1,to:-1,match:/.*/.exec(``)},S=`gm`+(/x/.unicode==null?``:`u`),Ee=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Te,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new De(e,t,n,r,i);this.re=new RegExp(t,S+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=T(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=T(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},C=new WeakMap,w=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=C.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return C.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),C.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},De=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Te,this.matchPos=T(e,r),this.re=new RegExp(t,S+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=w.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=T(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=w.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ee.prototype[Symbol.iterator]=De.prototype[Symbol.iterator]=function(){return this});function Oe(e){try{return new RegExp(e,S),!0}catch{return!1}}function T(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var ke=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=ce(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,l,u]=i,d=l?+l.slice(1):0,f=s?+s:a.number;if(s&&u){let e=f/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),f=Math.round(t.doc.lines*e)}else s&&o&&(f=f*(o==`-`?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),m=c.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[r,g.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},Ae={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},E=m.define({combine(e){return a(e,Ae,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function je(e){let t=[Le,Ie];return e&&t.push(E.of(e)),t}var Me=d.mark({class:`cm-selectionMatch`}),Ne=d.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Pe(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=y.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=y.Word)}function Fe(e,t,n,r){return e(t.sliceDoc(n,n+1))==y.Word&&e(t.sliceDoc(r-1,r))==y.Word}var Ie=ee.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(E),{state:n}=e,r=n.selection;if(r.ranges.length>1)return d.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return d.none;let e=n.wordAt(i.head);if(!e)return d.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return d.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Pe(o,n,i.from,i.to)&&Fe(o,n,i.from,i.to)))return d.none}else if(a=n.sliceDoc(i.from,i.to),!a)return d.none}let s=[];for(let r of e.visibleRanges){let e=new x(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Pe(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Ne.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Me.range(r,a)),s.length>t.maxMatches))return d.none}}return d.set(s)}},{decorations:e=>e.decorations}),Le=g.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Re=({state:e,dispatch:t})=>{let{selection:n}=e,r=c.create(n.ranges.map(t=>e.wordAt(t.head)||c.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function ze(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new x(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new x(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Be=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Re({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ze(e,r);return i?(t(e.update({selection:e.selection.addRange(c.range(i.from,i.to),!1),effects:g.scrollIntoView(i.to)})),!0):!1},D=m.define({combine(e){return a(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ct(e),scrollToMatch:e=>g.scrollIntoView(e)})}});function Ve(e){return e?[D.of(e),G]:G}var He=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Oe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
2
2
|
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ye(this):new Ke(this)}getCursor(e,t=0,n){let r=e.doc?e:o.create({doc:e});return n??=r.doc.length,this.regexp?k(this,r,t,n):O(this,r,t,n)}},Ue=class{constructor(e){this.spec=e}};function We(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function O(e,t,n,r){let i;return e.wholeWord&&(i=Ge(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=We(e.test,t,i)),new x(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Ge(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(A(i,n-a))!=y.Word||t(j(i,n-a))!=y.Word)&&(t(j(i,r-a))!=y.Word||t(A(i,r-a))!=y.Word))}var Ke=class extends Ue{constructor(e){super(e)}nextMatch(e,t,n){let r=O(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=O(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=O(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=O(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=O(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function qe(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function k(e,t,n,r){let i;return e.wholeWord&&(i=Je(t.charCategorizer(t.selection.main.head))),e.test&&(i=qe(e.test,t,i)),new Ee(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function A(e,t){return e.slice(u(e,t,!1),t)}function j(e,t){return e.slice(t,u(e,t))}function Je(e){return(t,n,r)=>!r[0].length||(e(A(r.input,r.index))!=y.Word||e(j(r.input,r.index))!=y.Word)&&(e(j(r.input,r.index+r[0].length))!=y.Word||e(A(r.input,r.index+r[0].length))!=y.Word)}var Ye=class extends Ue{nextMatch(e,t,n){let r=k(this.spec,e,n,e.doc.length).next();return r.done&&(r=k(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=k(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=k(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=k(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},M=h.define(),N=h.define(),P=l.define({create(e){return new F(B(e).create(),null)},update(e,t){for(let n of t.effects)n.is(M)?e=new F(n.value.create(),e.panel):n.is(N)&&(e=new F(e.query,n.value?z:null));return e},provide:e=>_.from(e,e=>e.panel)}),F=class{constructor(e,t){this.query=e,this.panel=t}},Xe=d.mark({class:`cm-searchMatch`}),Ze=d.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Qe=ee.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(P))}update(e){let t=e.state.field(P);(t!=e.startState.field(P)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return d.none;let{view:n}=this,r=new f;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Ze:Xe)})}return r.finish()}},{decorations:e=>e.decorations});function I(e){return t=>{let n=t.state.field(P,!1);return n&&n.query.spec.valid?e(t,n):at(t)}}var L=I((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=c.single(r.from,r.to),a=e.state.facet(D);return e.dispatch({selection:i,effects:[W(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),it(e),!0}),R=I((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=c.single(i.from,i.to),o=e.state.facet(D);return e.dispatch({selection:a,effects:[W(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),it(e),!0}),$e=I((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:c.create(n.map(e=>c.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),et=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new x(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(c.range(t.value.from,t.value.to))}return t(e.update({selection:c.create(a,o),userEvent:`select.search.matches`})),!0},tt=I((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],l,u,d=[];o.from==r&&o.to==i&&(u=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:u}),o=t.nextMatch(n,o.from,o.to),d.push(g.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let f=e.state.changes(s);return o&&(l=c.single(o.from,o.to).map(f),d.push(W(e,o)),d.push(n.facet(D).scrollToMatch(l.main,e))),e.dispatch({changes:f,selection:l,effects:d,userEvent:`input.replace`}),!0}),nt=I((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:g.announce.of(r),userEvent:`input.replace.all`}),!0});function z(e){return e.state.facet(D).createPanel(e)}function B(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(D);return new He({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function rt(e){let t=v(e,z);return t&&t.dom.querySelector(`[main-field]`)}function it(e){let t=rt(e);t&&t==e.root.activeElement&&t.select()}var at=e=>{let t=e.state.field(P,!1);if(t&&t.panel){let n=rt(e);if(n&&n!=e.root.activeElement){let r=B(e.state,t.query.spec);r.valid&&e.dispatch({effects:M.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[N.of(!0),t?M.of(B(e.state,t.query.spec)):h.appendConfig.of(G)]});return!0},ot=e=>{let t=e.state.field(P,!1);if(!t||!t.panel)return!1;let n=v(e,z);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:N.of(!1)}),!0},st=[{key:`Mod-f`,run:at,scope:`editor search-panel`},{key:`F3`,run:L,shift:R,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:L,shift:R,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ot,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:et},{key:`Mod-Alt-g`,run:ke},{key:`Mod-d`,run:Be,preventDefault:!0}],ct=class{constructor(e){this.view=e;let t=this.query=e.state.field(P).query.spec;this.commit=this.commit.bind(this),this.searchField=b(`input`,{value:t.search,placeholder:V(e,`Find`),"aria-label":V(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=b(`input`,{value:t.replace,placeholder:V(e,`Replace`),"aria-label":V(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=b(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=b(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=b(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return b(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=b(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>L(e),[V(e,`next`)]),n(`prev`,()=>R(e),[V(e,`previous`)]),n(`select`,()=>$e(e),[V(e,`all`)]),b(`label`,null,[this.caseField,V(e,`match case`)]),b(`label`,null,[this.reField,V(e,`regexp`)]),b(`label`,null,[this.wordField,V(e,`by word`)]),...e.state.readOnly?[]:[b(`br`),this.replaceField,n(`replace`,()=>tt(e),[V(e,`replace`)]),n(`replaceAll`,()=>nt(e),[V(e,`replace all`)])],b(`button`,{name:`close`,onclick:()=>ot(e),"aria-label":V(e,`close`),type:`button`},[`×`])])}commit(){let e=new He({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:M.of(e)}))}keydown(e){le(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?R:L)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),tt(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(M)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(D).top}};function V(e,t){return e.state.phrase(t)}var H=30,U=/[\s\.,:;?!]/;function W(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-H),o=Math.min(i,n+H),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<H;e++)if(!U.test(s[e+1])&&U.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-H;e--)if(!U.test(s[e-1])&&U.test(s[e])){s=s.slice(0,e);break}}return g.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var lt=g.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),G=[P,i.low(Qe),lt],ut=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},K=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Z).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new f,s=[],c=0,l=r.doc.iter(),u=0,p=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>p)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,p);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==p))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Ot(s);if(i)o.add(n,n,d.widget({widget:new Ct(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,d.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==p)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let m=o.finish();return new e(m,n,q(m))}};function q(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new ut(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new ut(r.from,n,r.diagnostic)}),r}function dt(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Z).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(J))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function ft(e,t){return e.field(X,!1)?t:t.concat(h.appendConfig.of(kt))}var J=h.define(),Y=h.define(),pt=h.define(),X=l.define({create(){return new K(d.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=q(n,e.selected.diagnostic,i)||q(n,null,i)}!n.size&&i&&t.state.facet(Z).autoPanel&&(i=null),e=new K(n,i,r)}for(let n of t.effects)if(n.is(J)){let r=t.state.facet(Z).autoPanel?n.value.length?Q.open:null:e.panel;e=K.init(n.value,r,t.state)}else n.is(Y)?e=new K(e.diagnostics,n.value?Q.open:null,e.selected):n.is(pt)&&(e=new K(e.diagnostics,e.panel,n.value));return e},provide:e=>[_.from(e,e=>e.panel),g.decorations.from(e,e=>e.diagnostics)]}),mt=d.mark({class:`cm-lintRange cm-lintRange-active`});function ht(e,t,n){let{diagnostics:r}=e.state.field(X),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Z).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:gt(e,i)}}}:null}function gt(e,t){return b(`ul`,{class:`cm-tooltip-lint`},t.map(t=>St(e,t,!1)))}var _t=e=>{let t=e.state.field(X,!1);(!t||!t.panel)&&e.dispatch({effects:ft(e.state,[Y.of(!0)])});let n=v(e,Q.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},vt=e=>{let t=e.state.field(X,!1);return!t||!t.panel?!1:(e.dispatch({effects:Y.of(!1)}),!0)},yt=[{key:`Mod-Shift-m`,run:_t,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(X,!1);if(!t)return!1;let n=e.state.selection.main,r=q(t.diagnostics,null,n.to+1);return!r&&(r=q(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Z=m.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...a(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:bt,tooltipFilter:bt,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function bt(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function xt(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function St(e,t,n){let r=n?xt(t.actions):[];return b(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},b(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=q(e.state.field(X).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),b(`u`,s.slice(c,c+1)),s.slice(c+1)];return b(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&b(`div`,{class:`cm-diagnosticSource`},t.source))}var Ct=class extends r{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return b(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},wt=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=St(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Q=class e{constructor(e){this.view=e,this.items=[],this.list=b(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)vt(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=xt(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=q(this.view.state.field(X).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=b(`div`,{class:`cm-panel-lint`},this.list,b(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>vt(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(X).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(X),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new wt(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new wt(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=q(this.view.state.field(X).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:pt.of(t)})}static open(t){return new e(t)}};function Tt(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function $(e){return Tt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Et=g.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:$(`#d11`)},".cm-lintRange-warning":{backgroundImage:$(`orange`)},".cm-lintRange-info":{backgroundImage:$(`#999`)},".cm-lintRange-hint":{backgroundImage:$(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Dt(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Ot(e){let t=`hint`,n=1;for(let r of e){let e=Dt(r.severity);e>n&&(n=e,t=r.severity)}return t}var kt=[X,g.decorations.compute([X],e=>{let{selected:t,panel:n}=e.field(X);return!t||!n||t.from==t.to?d.none:d.set([mt.range(t.from,t.to)])}),de(ht,{hideOn:dt}),Et],At=[ae(),he(),ie(),e(),re(),ge(),pe(),o.allowMultipleSelections.of(!0),s(),p(se,{fallback:!0}),ue(),Ce(),xe(),fe(),oe(),me(),je(),_e.of([...be,...n,...st,...t,...ve,...Se,...yt])];ie(),e(),ge(),p(se,{fallback:!0}),_e.of([...n,...t]);export{Ve as n,At as t};
|