@vite-hub/comments 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +6 -4
  2. package/dist/{client-diagnostics-D987sEK7.js → client-diagnostics-DoXqdnBd.js} +8 -0
  3. package/dist/client.d.ts +48 -3
  4. package/dist/client.js +231 -150
  5. package/dist/{database-Cguz3hZL.js → database-BuSNVwTx.js} +1 -1
  6. package/dist/database.js +1 -1
  7. package/dist/{define-C2tnAtBU.js → define-BqPcuDhf.js} +1 -1
  8. package/dist/{errors-ByCRdInk.js → errors-CBvIpwbo.js} +1 -1
  9. package/dist/hosted/hosted-comments/frame.js +1 -1
  10. package/dist/hosted/hosted-comments/tools.js +371 -0
  11. package/dist/hosted/hosted-comments.js +1 -19
  12. package/dist/index.js +4 -4
  13. package/dist/{install-D6hXZaSN.js → install-CqBWFmU7.js} +21 -15
  14. package/dist/{installed-bPUnazFf.js → installed-wUYjqk_k.js} +1 -1
  15. package/dist/{operations-8hqTi0DH.d.ts → operations-DFLer1fR.d.ts} +1 -0
  16. package/dist/{operations-BkkrI8a3.d.ts → operations-Qt8ASQqW.d.ts} +1 -1
  17. package/dist/{operations-B1ALn4VS.js → operations-kMPw-Cyb.js} +6 -7
  18. package/dist/operations.d.ts +1 -1
  19. package/dist/operations.js +2 -2
  20. package/dist/overlay/client-CrnKCZXc.js +4 -0
  21. package/dist/overlay/overlay.js +62 -35
  22. package/dist/page/loader.js +25 -23
  23. package/dist/{page-tools-shared-fvmJQCrP.js → page-tools-shared-BNw-aWEH.js} +2 -5
  24. package/dist/{plugin-l4sPt5-n.js → plugin-ChOHe7vq.js} +7 -7
  25. package/dist/realtime.d.ts +4 -1
  26. package/dist/realtime.js +1 -1
  27. package/dist/{request-origin-YPzfE2eh.js → request-origin-B-CPVAVk.js} +6 -1
  28. package/dist/{rpc-BYmbVkr8.js → rpc-kkxzQ3Qy.js} +1 -1
  29. package/dist/rpc.js +1 -1
  30. package/dist/runtime/auth.js +1 -1
  31. package/dist/runtime/console.js +1 -1
  32. package/dist/runtime/index.d.ts +1 -0
  33. package/dist/runtime/index.js +13 -13
  34. package/dist/{server-DvSehkPP.js → server-8o9u8leM.js} +1 -1
  35. package/dist/server.d.ts +1 -1
  36. package/dist/server.js +6 -6
  37. package/dist/{service-BIGe1Hpo.js → service-XT2A8YEF.js} +2 -2
  38. package/dist/{session-CCRLR9bf.js → session-DGdFKWDB.js} +7 -6
  39. package/dist/testing.js +1 -1
  40. package/dist/vite.d.ts +1 -1
  41. package/dist/vite.js +8 -4
  42. package/package.json +9 -8
  43. package/dist/hosted/hosted-comments/client-Czl2zu9P.js +0 -4
  44. package/dist/hosted/hosted-comments/dist-DyVmH21U.js +0 -14
  45. package/dist/hosted/hosted-comments/overlay-DpS0P-nd.js +0 -186
  46. package/dist/hosted/hosted-comments/protocol-DuB0Zhs-.js +0 -1
  47. package/dist/hosted/hosted-comments/rest-transport-CKZG_jZ4.js +0 -1
  48. package/dist/hosted/hosted-comments/tools-D8xg-kDW.js +0 -126
  49. package/dist/overlay/client-C7ftI-CB.js +0 -4
@@ -1 +0,0 @@
1
- function e(e,...t){return typeof e==`function`?e(...t):e}var t=Error.captureStackTrace,n=class e extends Error{get why(){return this.message}constructor(n,r=e){super(n.why,{cause:n.cause}),this.code=this.name=n.code,this.docs=n.docs,this.fix=n.fix,this.sources=n.sources,this.data=n.data,t?.(this,r)}toJSON(){return{name:this.name,why:this.why,fix:this.fix,docs:this.docs,sources:this.sources,cause:this.cause,data:this.data,stack:this.stack}}};function r(e,t){return typeof e==`string`?`${e}/${t.toLowerCase()}`:e?.(t)}var i=e=>t=>t instanceof n&&e in t;function a(t){let a=t.reporters??[],o=Symbol(),s=Object.defineProperty({},"is",{value:i(o)}),{docsBase:c}=t;for(let i of Object.keys(t.codes)){let l=t.codes[i],u=l.docs===!1?void 0:l.docs||r(c,i),d=(t={},r={})=>{let s=new n({code:i,why:e(l.why,t),fix:e(l.fix,t),docs:u,cause:t.cause,sources:t.sources,data:e(l.data,t)},d);s[o]=1;for(let e of a)e(s,r);return s};d.is=e=>s.is(e)&&e.code===i,s[i]=d}return s}var o=a({docsBase:`https://vitehub.dev/docs/comments/diagnostics`,codes:{COMMENTS_OUTBOX_ACCOUNT_CHANGED:{why:`The current author is not the author of this queued comment.`,fix:`Sign in as the original author and retry the outbox.`},COMMENTS_OUTBOX_RESOLVE_BLOCKED:{why:`Queued delivery must resume before the thread can close.`,fix:`Go online, then retry or dismiss any blocked comments and resolve the thread again.`},COMMENTS_OUTBOX_SENDING:{why:`The server may already have this comment, so the draft cannot change.`,fix:`Wait for delivery to finish, then edit or delete the server copy.`},COMMENTS_R0001:{why:({target:e})=>`createAnchor() found nothing to anchor to for ${e}.`,fix:`Pass an element, a non-empty selection, or a point that is over an element of the page.`},COMMENTS_R0013:{why:`The comments request did not get an answer from the server.`,fix:`Check the connection and the app URL, then try again.`},COMMENTS_R0015:{why:`The comment list kept changing while its pages were loading.`,fix:`Refresh again. The previous cache is kept until two complete scans agree.`}}});function s(e){let{code:t,details:r,fix:i,retryAfter:a,status:o,why:s}=e,c=t.startsWith(`COMMENTS_`)?`https://vitehub.dev/docs/comments/diagnostics/${t.toLowerCase()}`:void 0;return Object.assign(new n({code:t,why:s,...i?{fix:i}:{},...c?{docs:c}:{}}),{status:o,...r?{details:r}:{},...a===void 0?{}:{retryAfter:a}})}function c(e,t,n){return Object.assign(o.COMMENTS_R0013(t===void 0?{}:{cause:t}),{status:e,...n===void 0?{}:{retryAfter:n}})}var l=`vitehub-comments:connect`,u=[`session`,`list`,`get`,`create`,`reply`,`resolve`,`reopen`,`redeem`];function d(e){return`vitehub-comments:${e}`}function f(e){return`/comments/${encodeURIComponent(e)}/embed`}function p(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`id`),n=Reflect.get(e,`method`);return typeof t==`number`&&Number.isSafeInteger(t)&&u.some(e=>e===n)}export{s as a,n as c,p as i,a as l,l as n,o,f as r,c as s,d as t};
@@ -1 +0,0 @@
1
- import{a as e,s as t}from"./protocol-DuB0Zhs-.js";var n=`x-vitehub-comments-outbox-account`,r=new WeakMap;async function i(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function a(e){if(e instanceof File&&e.name)return e.name;let t=/^[a-z]+\/([a-z0-9]+)/i.exec(e.type)?.[1];return t?`file.${t}`:`file`}async function o(e,t,n,r){let o=[];for(let s of e){let e=await n({name:a(s),type:s.type||`application/octet-stream`,data:await i(s),...t?{subject:t}:{}});await r?.(e.key),o.push(e.key)}return o}async function s(e,{files:t,outbox:n},i,a){if(!t?.length)return e;try{return{...e,attachments:[...e.attachments??[],...await o(t,i,a,n?.uploaded)]}}catch(e){throw n&&r.set(n,{cause:e}),e}}function c(e,t=Date.now()){let n=e.headers.get(`retry-after`)?.trim();if(!n)return;if(/^\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);return Number.isNaN(r)?void 0:Math.max(0,r-t)}var l=/^https?:\/\//i;function u(e){return l.test(e)&&URL.canParse(e)?new URL(e).pathname:e}var d=`comments`,f=`comments-notices`,p=`/_vitehub/comments`;function m(e){let t=new URL(e).pathname,n=t.lastIndexOf(`${p}/assets/`);return n===-1?p:`${t.slice(0,n)}${p}`}function h(e){let t=u(e).split(/[?#]/,1)[0]??``;return t.startsWith(`/`)||(t=`/${t}`),t=t.replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),t||`/`}function g(e){let t=2166136261,n=1523705862;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2671213388)>>>0}return`pages/${t.toString(16).padStart(8,`0`)}${n.toString(16).padStart(8,`0`)}`}function _(e){return`subjects/${encodeURIComponent(JSON.stringify([e.kind,e.id]))}`}function v(e){return Object(e)===e&&!Array.isArray(e)}function y(e,t=``){return`${t.replace(/\/+$/,``)}${p}/attachments/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function b(n={}){let r=n.route??`${(n.base??``).replace(/\/+$/,``)}/_vitehub/comments`;return async(i,a={})=>{let o=n.fetch??globalThis.fetch,s=new Headers(typeof n.headers==`function`?await n.headers():n.headers);for(let[e,t]of new Headers(a.headers))s.set(e,t);a.body!==void 0&&!s.has(`content-type`)&&s.set(`content-type`,`application/json`);let l=typeof n.guest==`function`?n.guest():n.guest;l&&(s.set(`x-vitehub-comments-guest-id`,l.id),s.set(`x-vitehub-comments-guest-name`,encodeURIComponent(l.name)));let u;try{u=await o(`${r}${i}`,{...a,headers:s,credentials:n.credentials??`same-origin`,cache:`no-store`})}catch(e){throw t(0,e)}let d=await u.json().catch(()=>void 0),f=c(u);if(v(d)&&v(d.error)){let{code:n,why:r,fix:i}=d.error;throw typeof n!=`string`||typeof r!=`string`?t(u.status,void 0,f):e({code:n,why:r,...typeof i==`string`?{fix:i}:{},...f===void 0?{}:{retryAfter:f},status:u.status})}if(v(d)&&`data`in d){let e={data:d.data,people:Array.isArray(d.people)?d.people:[],...v(d.thread)?{thread:d.thread}:{}};return n.onAnswer?.(e),e}throw t(u.status,void 0,f)}}function x(e){let t=new URLSearchParams;return e.page!==void 0&&t.set(`page`,e.page),e.subject?(t.set(`subjectKind`,e.subject.kind),t.set(`subjectId`,e.subject.id)):e.subjectKind&&t.set(`subjectKind`,e.subjectKind),e.status&&t.set(`status`,e.status),e.mine!==void 0&&t.set(`mine`,String(e.mine)),e.mentions!==void 0&&t.set(`mentions`,String(e.mentions)),e.revision&&t.set(`revision`,String(e.revision.lte)),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.before&&(t.set(`beforeId`,e.before.id),t.set(`beforeUpdatedAt`,String(e.before.updatedAt))),t}var S=e=>`/threads/${encodeURIComponent(e)}`,C=(e,t)=>({method:`POST`,...e===void 0?{}:{body:JSON.stringify(e)},...t===void 0?{}:{headers:{[n]:encodeURIComponent(t)}}});function w(e={}){let n=b(e),r=(e.base??``).replace(/\/+$/,``),i=async(e,t)=>(await n(`/attachments`,C(e,t))).data;return{async list(e){return(await n(`/threads?${x(e)}`)).data},async get(e){let t=`threadId`in e?S(e.threadId):`/scopes/${encodeURIComponent(e.scope)}/threads/${e.n}`;return(await n(t)).data},async create({files:e,outbox:t,...r}){let a=await s(r,{files:e,outbox:t},r.subject,e=>i(e,t?.account));return(await n(`/threads`,C(a,t?.account))).data},async reply({threadId:e,subject:r,files:a,outbox:o,...c}){let l=await s(c,{files:a,outbox:o},r,e=>i(e,o?.account)),u=await n(`${S(e)}/comments`,C(l,o?.account));if(!u.thread)throw t(200);return u.thread},async edit({threadId:e,messageId:t,...r}){return(await n(`${S(e)}/comments/${encodeURIComponent(t)}`,{method:`PATCH`,body:JSON.stringify(r)})).data},async delete({threadId:e,messageId:t}){let r=t===void 0?S(e):`${S(e)}/comments/${encodeURIComponent(t)}`;return(await n(r,{method:`DELETE`})).data},async resolve({threadId:e}){return(await n(`${S(e)}/resolve`,C())).data},async reopen({threadId:e}){return(await n(`${S(e)}/reopen`,C())).data},async users({query:e,limit:t,threadId:r,subject:i}){let a=new URLSearchParams({q:e});return t!==void 0&&a.set(`limit`,String(t)),r===void 0?i&&(a.set(`subjectKind`,i.kind),a.set(`subjectId`,i.id)):a.set(`thread`,r),(await n(`/people?${a}`)).data},upload:e=>i(e),attachmentUrl:e=>y(e,r)}}export{m as a,p as c,g as i,h as l,w as n,f as o,_ as r,d as s,b as t,r as u};
@@ -1,126 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./overlay-DpS0P-nd.js","../hosted-comments.js","./protocol-DuB0Zhs-.js","./rest-transport-CKZG_jZ4.js"])))=>i.map(i=>d[i]);
2
- import{a as e,c as t,i as n,l as r,o as i,s as a,t as o,u as s}from"../hosted-comments.js";import{c,l,r as u,s as d}from"./protocol-DuB0Zhs-.js";import{a as f,c as p,n as m,t as h}from"./rest-transport-CKZG_jZ4.js";var g=Object.defineProperty,_=(e,t)=>{let n={};for(var r in e)g(n,r,{get:e[r],enumerable:!0});return t||g(n,Symbol.toStringTag,{value:`Module`}),n},v=new Set,y,b=!1;function x(){return y?.matches??!1}function S(){let e=x();if(e!==b){b=e;for(let t of v)t(e)}}function C(){y||typeof matchMedia!=`function`||(y=matchMedia(`(prefers-reduced-motion: reduce)`),y.addEventListener?.(`change`,S),b=x())}function w(){return C(),x()}function T(e){return C(),v.add(e),()=>v.delete(e)}var E={snappy:{stiffness:520,damping:34},soft:{stiffness:380,damping:20}},D=new Map,O=new Set,ee=0,te=!1,k=0,ne=0,re=1;function ie(){return re}function ae(e){let t=Math.min(.032,ne?(e-ne)/1e3:.016)/re;ne=e;let n=Array.from(D),r=Array.from(O);for(let[e,r]of n)if(D.get(e)===r){if(e.tween){let n=e.tween;n.elapsed+=t;let r=Math.min(1,n.elapsed/n.duration),i=1-(1-r)**3,a=n.from+(e.target-n.from)*i;e.velocity=(a-e.value)/(t||1),e.value=a,r>=1&&oe(e)}else{let{stiffness:n,damping:r}=e.preset,i=t/6;for(let t=0;t<6;t++){let t=-n*(e.value-e.target)-r*e.velocity;e.velocity+=t*i,e.value+=e.velocity*i}Math.abs(e.velocity)<.002&&Math.abs(e.value-e.target)<5e-4&&oe(e)}e.frame(e.value,e.velocity)}for(let e of r)O.has(e)&&e(t)===!1&&O.delete(e);D.size||O.size?k=requestAnimationFrame(ae):(k=0,ne=0)}function oe(e){e.value=e.target,e.velocity=0,e.tween=void 0,D.delete(e)}function se(e){D.set(e,++ee),k||=requestAnimationFrame(ae)}function ce(e){let t=t=>e(t);return O.add(t),k||=requestAnimationFrame(ae),()=>{O.delete(t)}}function le(e){if(!e)return;let t=Array.from(D);for(let[e,n]of t)D.get(e)!==n||e.tween||(oe(e),e.frame(e.value,0))}function A(e,t,n=E.snappy){let r={value:e,velocity:0,target:e,preset:n,tween:void 0,frame:t},i={get value(){return r.value},get velocity(){return r.velocity},get target(){return r.target},get active(){return D.has(r)},to(e,t={}){if(t.preset&&(r.preset=t.preset),t.tween===void 0&&w())return i.set(e);t.tween===void 0&&!te&&(te=!0,T(le)),r.target=e,t.velocity!==void 0&&(r.velocity+=t.velocity),r.tween=t.tween===void 0?void 0:{from:r.value,elapsed:0,duration:t.tween},se(r)},set(e){r.value=r.target=e,r.velocity=0,r.tween=void 0,D.delete(r),t(e,0)},stop(){r.velocity=0,r.tween=void 0,D.delete(r)}};return i}var ue=`data-resize-handle-active`;function j(e){let t=e;for(;t;){if(t.closest(`[data-motion="none"]`))return!0;let e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}return!1}var de=[`aria-checked`,`aria-selected`,`aria-pressed`,`aria-expanded`,`aria-valuenow`,`aria-valuetext`,`data-state`,`data-checked`,`data-open`,`open`,`data-leaving`],M=new Map,fe=new Set,pe=Symbol.for(`vite-hub.motion.layer`),me;function he(){let e=Reflect.get(globalThis,pe);if(e&&e!==me&&typeof e==`object`&&`define`in e&&`install`in e)return e}function ge(e){me=e,Reflect.get(globalThis,pe)||Reflect.set(globalThis,pe,e)}function _e(e){let t=[...M.values()];M.clear();for(let n of t)n.removeFromShared=e.define(n.effect,n.isReduced)}function ve(e,t=w){let n={effect:e,isReduced:t};M.set(e.name,n);for(let e of fe)e();return()=>{if(n.removeFromShared)return n.removeFromShared();if(M.get(e.name)===n){M.delete(e.name);for(let e of fe)e()}}}function N(){return[...M.values()].map(e=>e.effect)}function ye(){return[...M.values()]}function be(e){return fe.add(e),()=>fe.delete(e)}function P(e,t){for(let[n,r]of Object.entries(t))r?e.style.setProperty(n,r):e.style.removeProperty(n)}var F=new Map,I,L=new Map,R,xe=[],Se=Symbol.for(`vite-hub.motion.effect-presses`),Ce=e=>{let t=Reflect.get(e,Se);if(t)return t;let n=new Map;return Reflect.set(e,Se,n),n},we=new Set;function Te(e,t){if(we.has(t))return!1;try{return e.matches(t)}catch{return we.add(t),!1}}function Ee(e){let t=e;for(;;){for(let e of F.keys())if(e instanceof Element&&e.contains(t))return!0;let e=t.getRootNode();if((e instanceof Document||e instanceof ShadowRoot)&&F.has(e))return!0;if(!(e instanceof ShadowRoot))return!1;t=e.host}}function De(e,t){let n=-1;e.forEach((e,t)=>{e instanceof Element&&e.matches(`[data-motion="none"]`)&&(n=t)});let r=e.findIndex(e=>e instanceof HTMLElement&&Te(e,t));return r===-1||r<=n||!Ee(e[r])?void 0:e[r]}function Oe(e,t,n){z(e,!0);let r=Ce(t),i=[];for(let{effect:a,isReduced:o}of ye()){if(!a.press||o())continue;let s=De(n,a.selector);if(!s||e===`key`&&s!==n[0])continue;let c=r.get(s);if(c?.has(a.name))continue;let l=a.press(s,t);if(!l)continue;c?c.add(a.name):r.set(s,new Set([a.name]));let u={element:s,press:l};e!==`key`&&!l.move&&(u.leave=()=>ke(e,u,!0),s.addEventListener(`pointerleave`,u.leave,{once:!0})),i.push(u)}i.length&&(L.set(e,i),i.some(e=>e.press.move)&&document.addEventListener(`pointermove`,Ne,{capture:!0,passive:!0}))}function z(e,t=!1){let n=L.get(e);if(n){L.delete(e);for(let{element:e,press:r,leave:i}of n)i&&e.removeEventListener(`pointerleave`,i),t&&r.cancel?r.cancel():r.release();Ae()}}function ke(e,t,n=!1){let r=L.get(e),i=r?.indexOf(t)??-1;r&&i!==-1&&(t.leave&&t.element.removeEventListener(`pointerleave`,t.leave),r.splice(i,1),r.length||L.delete(e),n&&t.press.cancel?t.press.cancel():t.press.release(),Ae())}function Ae(){[...L.values()].some(e=>e.some(e=>e.press.move))||document.removeEventListener(`pointermove`,Ne,{capture:!0})}function je(e){if(e.button!==0)return;let t=e.composedPath();e.isPrimary&&(R={event:e,path:t}),Oe(e.pointerId,e,t)}function Me(e){R?.event.pointerId===e.pointerId&&(R=void 0),z(e.pointerId,e.type===`pointercancel`)}function Ne(e){for(let{press:t}of L.get(e.pointerId)??[])t.move?.(e)}function Pe(e){if(e.repeat||e.key!==` `&&e.key!==`Enter`)return;let t=e.composedPath();e.key===` `&&t[0]instanceof Element&&t[0].matches(`a[href], [role=link]`)||Oe(`key`,e,t)}function Fe(e){(e.key===` `||e.key===`Enter`)&&z(`key`)}function Ie(e,t){let n=t.filter(e=>e.content);if(!n.length)return;let r=new Map;for(let t of e){if(t.type===`attributes`)continue;let e=t.type===`characterData`?t.target.parentElement:t.target;if(!(e instanceof HTMLElement||e instanceof SVGElement))continue;let n=r.get(e);n||(n={added:[],removed:[],oldText:void 0,texts:new Map},r.set(e,n)),t.type===`characterData`?n.texts.has(t.target)||n.texts.set(t.target,t.oldValue):(n.added.push(...t.addedNodes),n.removed.push(...t.removedNodes))}for(let[e,t]of r){if(!e.isConnected)continue;let r=t.added.filter(e=>!t.removed.includes(e)),i=t.removed.filter(e=>!t.added.includes(e)),a=t.texts,o,s=[...e.childNodes];i.length&&s.every(e=>r.includes(e))?o=i.map(e=>e.textContent??``).join(``):a.size===1&&s.length===1&&a.has(s[0])&&(o=a.get(s[0])??``);for(let t of n)Te(e,t.selector)&&!j(e)&&t.content(e,{added:r,removed:i,oldText:o})}}function Le(e){if(!R||!e.matches(`[role=separator][data-panel-resize-handle-id]`))return;let t=ye().find(({effect:e})=>e.name===`divider`);if(!t||t.isReduced())return;let{event:n,path:r}=R,i=L.get(n.pointerId)??[],a=i.find(t=>t.splitter&&t.element===e);if(e.getAttribute(`data-resize-handle-active`)!==`pointer`){a&&ke(n.pointerId,a);return}if(a||!r.includes(e.getRootNode())||!Ee(e)||j(e))return;let o=t.effect.press?.(e,n);o&&(i.push({element:e,press:o,splitter:!0}),L.set(n.pointerId,i),document.addEventListener(`pointermove`,Ne,{capture:!0,passive:!0}))}function Re(e){let t=[...new Set(e)],n=N(),r=new Map;Ie(t,n);for(let e of t)if(e.type!==`characterData`){if(e.type===`attributes`){let t=e.target;if(!(t instanceof HTMLElement))continue;if(e.attributeName===`data-resize-handle-active`){Le(t);continue}let i=e.attributeName,a=t.getAttribute(i);if(a===e.oldValue)continue;let o=r.get(t);o||r.set(t,o=new Map);let s=o.get(i);if(s||o.set(i,s=new Set),s.has(e.oldValue))continue;s.add(e.oldValue);for(let r of n)r.state&&Te(t,r.selector)&&!j(t)&&r.state(t,{attribute:i,oldValue:e.oldValue,value:a})}else for(let t of e.addedNodes)if(t instanceof HTMLElement&&t.isConnected)for(let e of n){if(!e.enter)continue;let n=Te(t,e.selector);if(we.has(e.selector))continue;let r=[...n?[t]:[],...t.querySelectorAll(e.selector)];for(let t of r)j(t)||e.enter(t)}}}function ze(e,t){let n=N().some(e=>e.content);t.observe(e,{attributes:!0,attributeFilter:[...de,...N().some(e=>e.name===`divider`)?[ue]:[]],attributeOldValue:!0,childList:n||N().some(e=>e.enter),characterData:n,characterDataOldValue:n,subtree:!0})}function Be(e,t){let n=N();for(let[e,r]of t)n.includes(e)||(r(),t.delete(e));for(let r of n)r.watch&&!t.has(r)&&t.set(r,r.watch(e))}function Ve(){let e={capture:!0,passive:!0};document.addEventListener(`pointerdown`,je,e),document.addEventListener(`pointerup`,Me,e),document.addEventListener(`pointercancel`,Me,e),document.addEventListener(`keydown`,Pe,e),document.addEventListener(`keyup`,Fe,e),xe=[()=>{document.removeEventListener(`pointerdown`,je,e),document.removeEventListener(`pointerup`,Me,e),document.removeEventListener(`pointercancel`,Me,e),document.removeEventListener(`keydown`,Pe,e),document.removeEventListener(`keyup`,Fe,e),R=void 0;for(let e of L.keys())z(e,!0)},T(e=>{if(e){R=void 0;for(let e of L.keys())z(e,!0)}})]}function B(e,t){if(typeof document>`u`)return()=>{};let n=he();return n?(_e(n),n.install(e,t.effects,w)):(ge(He),Ue(e,t.effects))}var He={define:ve,install:Ue};function Ue(e,t,n=w){let r=new Set(N().map(e=>e.name));for(let e of t)r.has(e.name)||ve(e,n);if(!I){Ve();let e=new MutationObserver((e,t)=>Re(e.concat(t.takeRecords())));I=e,xe.push(be(()=>{for(let[t,{watchers:n}]of F)ze(t,e),Be(t,n)}))}let i=F.get(e);if(i)i.installs++;else{let t=new Map;ze(e,I),F.set(e,{installs:1,watchers:t}),Be(e,t)}let a=!1;return()=>{if(a)return;a=!0;let t=F.get(e);if(!t||--t.installs>0)return;F.delete(e);let n=I,r=n.takeRecords();n.disconnect();for(let e of t.watchers.values())e();if(F.size){for(let e of F.keys())ze(e,n);r.length&&queueMicrotask(()=>{if(I!==n)return;let e=[...F.keys()];Re(r.filter(t=>e.some(e=>e.contains(t.target))))})}else{I=void 0;for(let e of xe)e();xe=[]}}}function We(e,t,n,r){let i=(e,t,n)=>3*t*e*(1-e)**2+3*n*e**2*(1-e)+e**3;return a=>{if(a<=0||a>=1)return a<=0?0:1;let o=0,s=1,c=a;for(let t=0;t<24;t++)i(c,e,n)<a?o=c:s=c,c=(o+s)/2;return i(c,t,r)}}var Ge=e=>e;function Ke(e,t,n,r,i){let a=(n.delay??0)/1e3,o=n.duration/1e3,s=n.ease??Ge,c=w(),l=0;return{stop:ce(n=>{l+=n;let u=!c&&w()||l>=a+o?1:o>0?Math.max(0,(l-a)/o):0;return r(e+(t-e)*s(u)),u<1||(i?.(),!1)})}}function qe(e,t,n=Ge,r=0){let i=()=>{},a=new Promise(e=>i=e),o=Ke(0,1,{duration:e*1e3,delay:r*1e3,ease:n},t,()=>i(!0));return{done:a,stop:()=>{o.stop(),i(!1)}}}var Je={stiffness:900,damping:40},Ye={stiffness:380,damping:14},Xe=`:is(button, a[href], summary, input:is([type=button], [type=submit], [type=reset], [type=checkbox], [type=radio]), ${[`button`,`link`,`tab`,`radio`,`menuitem`,`menuitemradio`,`menuitemcheckbox`,`option`,`checkbox`].map(e=>`[role=${e}]`).join(`, `)}):not(:disabled, [aria-disabled="true"], [role=switch])`,Ze=`svg, img, .iconify, [data-slot=icon], [data-slot$=Icon], [data-slot=swap-icon]`,Qe=new WeakMap,$e=e=>e>=40?.03:e>=32?.04:.05;function et(e){let t=e.dataset.motionPressTarget?e.closest(e.dataset.motionPressTarget):null;if(t instanceof HTMLElement)return{target:t,amount:$e(t.offsetHeight)};let n=e.firstElementChild;return e.childElementCount===1&&!e.textContent?.trim()&&(n instanceof HTMLElement||n instanceof SVGElement)&&n.matches(Ze)?{target:n,amount:.15}:{target:e,amount:$e(e.offsetHeight)}}function tt(e){let t=e.transitionDuration.split(`,`);return e.transitionProperty.split(`,`).some((e,n)=>/^\s*(?:scale|all)\s*$/.test(e)&&Number.parseFloat(t[n%t.length])>0)}function nt(e,t,n){let{left:r,right:i,top:a,bottom:o,width:s,height:c}=e;return Math.min(t.clientX-r,i-t.clientX)<=s*n||Math.min(t.clientY-a,o-t.clientY)<=c*n}var rt={name:`press`,selector:Xe,press(e,t){let{target:n,amount:r}=et(e),i=getComputedStyle(n);if(tt(i)||i.display===`contents`||i.display===`inline`&&n===e&&!(e instanceof HTMLInputElement))return;let a;if(n===e&&`pointerId`in t&&(a=e.getBoundingClientRect(),nt(a,t,r)))return;let o=Qe.get(n);if(!o){let e={amount:r,spring:A(0,t=>{P(n,{scale:t?String(1-e.amount*t):null})},Je)};o=e,Qe.set(n,o)}o.amount=r;let{spring:s}=o;s.to(1,{preset:Je});let c=!1,l=()=>{c||(c=!0,s.set(0))};return{move:a?e=>{nt(a,e,r)&&l()}:void 0,release:()=>{c||s.to(0,{preset:Ye})},cancel:l}}};function it(e){let t=e.cloneNode(!0);t.inert=!0,t.setAttribute(`aria-hidden`,`true`);for(let e of[t,...t.querySelectorAll(`[id], [name], [form], input, button, select, textarea, fieldset`)])e.removeAttribute(`id`),e.removeAttribute(`name`),e.removeAttribute(`form`),e.matches(`input, button, select, textarea, fieldset`)&&e.setAttribute(`disabled`,``);return t}var at={stiffness:380,damping:26},ot={stiffness:260,damping:28},st=.9,ct=.32,lt=We(.5,0,.75,0),ut=`data-motion-ghost`,V=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function dt(e){return e.bottom>0&&e.right>0&&e.top<innerHeight&&e.left<innerWidth&&e.width+e.height>0}function ft(e){return[...e.children].filter(e=>e instanceof HTMLElement&&!e.hasAttribute(ut))}function pt(e,t={}){let n=t.items??ft,r=new Map,i=new Set,a=new Map,o=!1;function s(e){if(!e)return{x:0,y:0};let t=1-e.grow.value;return{x:e.x.value+e.from.x*t,y:e.y.value+e.from.y*t}}function c(e,t){let{x:n,y:i,grow:a,from:c}=t;if(!n.active&&!i.active&&!a.active&&n.value===0&&i.value===0&&a.value===1){P(e,{translate:null,scale:null,opacity:null}),o||r.delete(e);return}let{x:l,y:u}=s(t),d=c.scale+(1-c.scale)*a.value;P(e,{translate:l||u?`${l.toFixed(2)}px ${u.toFixed(2)}px`:null,scale:d===1?null:d.toFixed(4),opacity:a.value>=1?null:Math.max(0,Math.min(1,a.value)).toFixed(3)})}function l(e){let t=r.get(e);if(t)return t;let n=()=>t&&c(e,t);return t={x:A(0,n,E.snappy),y:A(0,n,E.snappy),grow:A(1,n,at),from:{x:0,y:0,scale:1}},r.set(e,t),t}function u(e){let t=r.get(e);t&&(r.delete(e),t.x.stop(),t.y.stop(),t.grow.stop(),P(e,{translate:null,scale:null,opacity:null}))}function d(e,t){let n=e.velocity;e.set(t),e.to(0,{preset:E.snappy,velocity:n})}function f(t,n,r){if(!dt(n))return;let a=e.getBoundingClientRect();getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let o=it(t);o.setAttribute(ut,``),Object.assign(o.style,{boxSizing:`border-box`,height:`${n.height}px`,left:`${n.left-a.left-e.clientLeft+e.scrollLeft}px`,margin:`0`,pointerEvents:`none`,position:`absolute`,top:`${n.top-a.top-e.clientTop+e.scrollTop}px`,width:`${n.width}px`}),P(o,{translate:null,scale:null,opacity:null,filter:null}),e.append(o);let s={element:o,stop:()=>{}},c=()=>{s.stop(),o.remove(),i.delete(s)};if(i.add(s),w()){let e=qe(.15,e=>P(o,{opacity:(1-e).toFixed(3)}));s.stop=e.stop,e.done.then(c);return}if(r){let e=V(r.getBoundingClientRect()),t=V(n),i=qe(ct,n=>{P(o,{translate:`${((e.x-t.x)*n).toFixed(2)}px ${((e.y-t.y)*n).toFixed(2)}px`,scale:(1-.8*n).toFixed(4),opacity:(1-n).toFixed(3),filter:n>0?`blur(${(3*n).toFixed(2)}px)`:null})},lt);s.stop=i.stop,i.done.then(c);return}let l=A(1,e=>{P(o,{scale:(st+.09999999999999998*e).toFixed(4),opacity:Math.max(0,e).toFixed(3)}),e<.02&&c()},ot);s.stop=()=>l.stop(),l.to(0)}return{measure(){a=new Map;for(let t of n(e)){let e=t.getBoundingClientRect();if(!e.width&&!e.height)continue;let n=V(e),i=s(r.get(t));a.set(t,{x:n.x-i.x,y:n.y-i.y,rect:e})}},play(i={}){let c=a;a=new Map;let p=j(e),m=n(e),h=new Set(m),g=m.map(e=>{let t=e.getBoundingClientRect(),n=s(r.get(e)),i=V(t);return{element:e,rect:t,layout:{x:i.x-n.x,y:i.y-n.y}}}),_=g.map(({element:e})=>{if(!c.has(e)&&i.origin)return(typeof i.origin==`function`?i.origin(e):i.origin)?.getBoundingClientRect()});for(let[e,{rect:n}]of c)h.has(e)||(u(e),p||t.movesOnly||e.hasAttribute(`data-motion-leaving`)||f(e,n,i.target));o=!0,g.forEach(({element:e,rect:n,layout:r},i)=>{if(p)return u(e);let a=c.get(e);if(a){let t=a.x-r.x,i=a.y-r.y;if(Math.abs(t)<.5&&Math.abs(i)<.5)return;if(!dt(a.rect)&&!dt(n))return u(e);let o=l(e);d(o.x,o.x.value+t),d(o.y,o.y.value+i);return}if(!dt(n)||t.movesOnly)return;let o=l(e),s=_[i];if(w())o.from={x:0,y:0,scale:1};else if(s){let e=V(s),t=Math.min(1,Math.max(.2,Math.min(s.width/(n.width||1),s.height/(n.height||1))));o.from={x:e.x-r.x,y:e.y-r.y,scale:t}}else o.from={x:0,y:0,scale:st};o.grow.set(0),o.grow.to(1,w()?{tween:.15}:{preset:at})}),o=!1},destroy(){for(let e of r.keys())u(e);for(let e of i)e.stop(),e.element.remove();i.clear(),a=new Map}}}var H={effects:[rt]},mt=[[`0px`,`6px`],[`6px`,`0px`],[`calc(100% - 6px)`,`0px`],[`100%`,`6px`],[`100%`,`50%`],[`100%`,`50%`],[`100%`,`calc(100% - 6px)`],[`calc(100% - 6px)`,`100%`],[`6px`,`100%`],[`0px`,`calc(100% - 6px)`],[`0px`,`50%`],[`0px`,`50%`]],ht=e=>e.map(([e,t])=>[`calc(50% + var(--vitehub-hex-w) * ${e})`,`calc(50% + var(--vitehub-hex-h) * ${t})`]),gt=ht([[-.28,-.453],[-.208,-.5],[.208,-.5],[.28,-.453],[.488,-.047],[.488,.047],[.28,.453],[.208,.5],[-.208,.5],[-.28,.453],[-.488,.047],[-.488,-.047]]),_t=ht([[-.5,-.5],[-.5,-.5],[.5,-.5],[.5,-.5],[.5,0],[.5,0],[.5,.5],[.5,.5],[-.5,.5],[-.5,.5],[-.5,0],[-.5,0]]),vt=e=>`polygon(${e.map(([e,t])=>`${e} ${t}`).join(`,`)})`;function yt(e,t,n){let r=(1-n).toFixed(4),i=n.toFixed(4);return vt(e.map(([e,n],a)=>[`calc(${e} * ${r} + ${t[a][0]} * ${i})`,`calc(${n} * ${r} + ${t[a][1]} * ${i})`]))}var bt=vt(mt),xt=vt(gt),St=vt(_t),Ct=e=>`calc(var(--start) + ${e} / 2 + (100% - var(--start) - var(--end) - ${e}) * var(--at) / 100)`,wt=`:host{all:initial;position:fixed;z-index:2147483001;pointer-events:none;filter:drop-shadow(0 8px 24px rgb(0 0 0/25%));color-scheme:dark;font:500 12px/1 ui-sans-serif,system-ui,sans-serif;color:#d4d4d4;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--vitehub-pill-text:#d4d4d4;--vitehub-pill-strong:#fafafa;--vitehub-pill-muted:#a3a3a3;--vitehub-pill-hover:rgb(255 255 255/8%);--vitehub-pill-on:#fafafa;--vitehub-pill-on-text:#0a0a0a;--vitehub-pill-line:rgb(255 255 255/12%);--vitehub-pill-surface:#111;--vitehub-pill-flow:row;--vitehub-hex-h:24px;--vitehub-hex-w:calc(var(--vitehub-hex-h) * 10 / 9);--vitehub-pill-fade:opacity 160ms ease-out 80ms,visibility 0s;--vitehub-pill-fade-end:opacity 160ms ease-out 120ms,visibility 0s;--at:50;--margin:16px;--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px)}
3
- :host([collapsed]){--margin:2px;--vitehub-pill-fade:opacity 80ms ease-out,visibility 0s 80ms;--vitehub-pill-fade-end:opacity 40ms ease-out,visibility 0s 40ms}
4
- :host(:is([edge=top],[edge=bottom])){left:${Ct(`0px`)};--start:max(var(--margin),var(--safe-left));--end:max(var(--margin),var(--safe-right));--x:calc(var(--at) * -1%)}
5
- :host(:is([edge=left],[edge=right])){top:${Ct(`0px`)};--start:max(var(--margin),var(--safe-top));--end:max(var(--margin),var(--safe-bottom));--y:calc(var(--at) * -1%);--vitehub-pill-flow:column;--vitehub-pill-justify:flex-start}
6
- :host([edge=bottom]){bottom:max(16px,var(--safe-bottom))}
7
- :host([edge=top]){top:max(16px,var(--safe-top))}
8
- :host([edge=right]){right:max(16px,var(--safe-right))}
9
- :host([edge=left]){left:max(16px,var(--safe-left))}
10
- :host([collapsed]:is([edge=top],[edge=bottom])){left:${Ct(`var(--vitehub-hex-w)`)};--x:-50%}
11
- :host([collapsed]:is([edge=left],[edge=right])){top:${Ct(`var(--vitehub-hex-h)`)};--y:-50%}
12
- :host([collapsed][edge=bottom]){bottom:calc(max(2px,var(--safe-bottom)) + var(--vitehub-hex-h) / 2);--y:50%}
13
- :host([collapsed][edge=top]){top:calc(max(2px,var(--safe-top)) + var(--vitehub-hex-h) / 2);--y:-50%}
14
- :host([collapsed][edge=right]){right:calc(max(2px,var(--safe-right)) + var(--vitehub-hex-w) / 2);--x:50%}
15
- :host([collapsed][edge=left]){left:calc(max(2px,var(--safe-left)) + var(--vitehub-hex-w) / 2);--x:-50%}
16
- :host{transform:translate(var(--x,0),var(--y,0))}
17
- :host([dragging]){transition:none;cursor:grabbing;user-select:none;-webkit-user-select:none}
18
- div{position:relative;box-sizing:border-box;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;scrollbar-width:none;display:flex;flex-direction:var(--vitehub-pill-flow);align-items:center;gap:8px;padding:4px;border:1px solid var(--vitehub-pill-line);border-radius:12px;background:rgb(17 17 17/92%);pointer-events:auto;clip-path:${bt};transition:background-color 150ms ease-out}
19
- :host(:is([edge=left],[edge=right])) div{display:grid;grid-template-columns:auto 1fr;align-items:stretch;gap:8px 2px}
20
- :host([collapsed]) div{clip-path:${xt}}
21
- @media(hover:hover){:host([collapsed]) div:hover{background:rgb(38 38 38/94%)}}
22
- :host([dragging]) div{transition:none}
23
- ::slotted(*){flex-shrink:0;display:flex;flex-direction:var(--vitehub-pill-flow);align-items:center;gap:2px;transition:var(--vitehub-pill-fade)}
24
- :host(:is([edge=left],[edge=right])) ::slotted(*){grid-column:1/-1;align-items:stretch}
25
- ::slotted([hidden]){display:none!important}
26
- :host([collapsed]) ::slotted(*),:host([collapsed]) .exit{opacity:0;visibility:hidden}
27
- .tabs{position:absolute;display:flex;width:max-content;height:max-content;max-width:calc(100vw - max(16px,var(--safe-left)) - max(16px,var(--safe-right)));max-height:calc(100dvh - max(16px,var(--safe-top)) - max(16px,var(--safe-bottom)));gap:4px;overflow:auto;pointer-events:auto}
28
- :host([collapsed]) .tabs{visibility:hidden}
29
- :host(:is([edge=top],[edge=bottom])) .tabs{left:calc(var(--at) * 1%);translate:calc(var(--at) * -1%) 0;max-height:calc(100dvh - max(16px,var(--safe-top)) - max(16px,var(--safe-bottom)) - 100%)}
30
- :host(:is([edge=left],[edge=right])) .tabs{top:calc(var(--at) * 1%);translate:0 calc(var(--at) * -1%);max-width:calc(100vw - max(16px,var(--safe-left)) - max(16px,var(--safe-right)) - 100%);flex-direction:column}
31
- :host([edge=bottom]) .tabs{bottom:100%;align-items:safe flex-end}
32
- :host([edge=top]) .tabs{top:100%;align-items:flex-start}
33
- :host([edge=left]) .tabs{left:100%;align-items:flex-start}
34
- :host([edge=right]) .tabs{right:100%;align-items:safe flex-end}
35
- ::slotted([slot=tab]){padding:3px;border:1px solid var(--vitehub-pill-line);background:rgb(17 17 17/92%);pointer-events:auto}
36
- :host([edge=bottom]) ::slotted([slot=tab]){border-bottom:0;border-radius:10px 10px 0 0}
37
- :host([edge=top]) ::slotted([slot=tab]){border-top:0;border-radius:0 0 10px 10px}
38
- :host([edge=left]) ::slotted([slot=tab]){border-left:0;border-radius:0 10px 10px 0}
39
- :host([edge=right]) ::slotted([slot=tab]){border-right:0;border-radius:10px 0 0 10px}
40
- ${s}
41
- button{flex-shrink:0;padding:0;justify-content:center}
42
- .exit{position:sticky;right:0;bottom:0;transition:background-color 150ms,color 150ms,var(--vitehub-pill-fade-end)}
43
- :host(:is([edge=left],[edge=right])) .mark{justify-self:start}
44
- :host(:is([edge=left],[edge=right])) .exit{grid-area:1/2;justify-self:end;top:0;bottom:auto}
45
- .mark{position:sticky;left:0;top:0;z-index:1;cursor:grab}
46
- :host([dragging]) .mark{cursor:grabbing}
47
- .mark,.mark[aria-expanded=true]{background:none;color:var(--vitehub-pill-strong)}
48
- @media(hover:hover){.mark:hover{background:var(--vitehub-pill-hover)}}
49
- .mark svg{width:16px;height:16px;transition:opacity 160ms ease-out 120ms}
50
- :host([collapsed]) .mark svg{opacity:0;transform:scale(.6);transition-duration:40ms;transition-delay:0s}
51
- :host([collapsed]) .mark:is(:hover,:active){background:none}
52
- :host([collapsed]) .mark{transform:translate(var(--vitehub-mark-x,0),var(--vitehub-mark-y,0))}
53
- :host([collapsed]) .mark::before{content:"";position:absolute;inset:-8px}
54
- :host([fold=mark]){transition:filter 240ms ease-out}
55
- :host([fold=mark][collapsed]){filter:drop-shadow(0 1px 2px rgb(0 0 0/25%))}
56
- :host([fold=mark]:not([dragging])) div{transition:background-color 120ms ease-out,border-color 120ms ease-out}
57
- :host([fold=mark][collapsed]) div,:host([fold=mark][collapsed]) div:hover{clip-path:${St};background-color:transparent;border-color:transparent}
58
- :host([fold=mark]) .mark{transition:background-color 150ms ease-out,color 150ms ease-out}
59
- :host([fold=mark]) .mark svg{transition:none}
60
- :host([fold=mark][collapsed]) .mark svg{opacity:1;transform:scale(1.5)}
61
- @media(any-pointer:coarse){:host{--vitehub-hex-h:40px}:host([fold=mark][collapsed]) .mark svg{transform:scale(2.5)}}
62
- @media(prefers-reduced-motion:reduce){:host,div,::slotted(*),.exit,.mark svg,:host([fold=mark]) :is(div,.mark){transition:none}}`;function Tt(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(let[t,i]of Object.entries({viewBox:e,"aria-hidden":`true`,...n}))r.setAttribute(t,i);let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return i.setAttribute(`d`,t),r.append(i),r}var Et=[`top`,`right`,`bottom`,`left`];function Dt(e){return Et.some(t=>t===e)}function Ot(e){let t=typeof e==`object`&&e?Reflect.get(e,`edge`):void 0,n=typeof e==`object`&&e?Reflect.get(e,`at`):void 0;return Dt(t)&&typeof n==`number`&&n>=0&&n<=100?{edge:t,at:n}:void 0}function kt(e){try{return Ot(JSON.parse(localStorage.getItem(e)??`null`))}catch{return}}function At(e,t,n,r){let i=Math.min(70,r/4),a=Math.atan2(t-r/2,e-n/2),o=Math.atan2(i-r/2,-n/2),s=Math.atan2(i-r/2,n/2),c=Math.atan2(r/2-i,n/2),l=Math.atan2(r/2-i,-n/2);return a>=o&&a<=s?`top`:a>s&&a<c?`right`:a>=c&&a<=l?`bottom`:`left`}function jt(e,t,n,r,i){let a=i-n-r-t,o=a>0?Math.min(100,Math.max(0,(e-n-t/2)/a*100)):50;return o<2?0:o>98?100:Math.abs(o-50)<3?50:Math.round(o*10)/10}var Mt=new WeakMap;function Nt(e){let t=e?getComputedStyle(e).transform:`none`,n=/^matrix\(([^,]+)/.exec(t)?.[1];return n&&Number.parseFloat(n)||1}function Pt(e,t,n,r,i){let a=()=>e.getAttribute(`fold`)===`mark`?_t:gt,o=()=>n.querySelector(`svg`),s={x:0,y:0},c=1,l=!1,u,d=[],f=()=>{if(!l&&!p.active&&!m.active&&!h.active){P(t,{"clip-path":null}),P(e,{translate:null}),P(n,{translate:null});let r=o();r&&P(r,{scale:null});for(let e of d)e();d=[],i();return}let r=e.hasAttribute(`collapsed`),u=p.value;P(t,{"clip-path":yt(mt,a(),u)}),P(e,{translate:`${m.value.toFixed(2)}px ${h.value.toFixed(2)}px`});let f=r?s:{x:0,y:0};P(n,{translate:`${(s.x*u-f.x).toFixed(2)}px ${(s.y*u-f.y).toFixed(2)}px`});let g=o();g&&P(g,{scale:((1+(c-1)*u)/(r?c:1)).toFixed(4)})},p=A(0,f,E.snappy),m=A(0,f,E.snappy),h=A(0,f,E.snappy),g=()=>{let e=t.getBoundingClientRect();return{x:e.left+e.width/2-m.value,y:e.top+e.height/2-h.value}},_=()=>{s={x:Number.parseFloat(n.style.getPropertyValue(`--vitehub-mark-x`))||0,y:Number.parseFloat(n.style.getPropertyValue(`--vitehub-mark-y`))||0},e.hasAttribute(`collapsed`)&&(c=Nt(o()))};return{get moving(){return l||p.active||m.active||h.active},move(t,n=0){r();let i=new Promise(e=>d.push(e)),a=g(),o=e.hasAttribute(`collapsed`);_(),t(),_();let s=g(),c=e.hasAttribute(`collapsed`);clearTimeout(u),l=!0;for(let[e,t]of[[m,a.x-s.x+m.value],[h,a.y-s.y+h.value]]){let n=e.velocity;e.set(t),n&&e.to(t,{velocity:n})}p.active||p.set(+!!o);let f=()=>{l=!1,m.to(0,{preset:E.snappy}),h.to(0,{preset:E.snappy}),p.to(+!!c,{preset:E.snappy})};return n>0&&!w()?u=setTimeout(f,n*ie()):f(),i}}}function Ft(e){let{signal:t}=e,n=document.createElement(e.name);n.style.viewTransitionName=e.name,e.fold===`mark`&&n.setAttribute(`fold`,`mark`);let r=n.attachShadow({mode:`open`}),i=document.createElement(`style`);i.textContent=wt;let a=document.createElement(`div`);a.setAttribute(`role`,`toolbar`),a.setAttribute(`aria-label`,e.label);let o=document.createElement(`button`);o.className=`mark`,o.append(e.mark);let s=e.initial?.collapsed===!0,c=t=>{t&&a.scrollTo(0,0),n.toggleAttribute(`collapsed`,t),t&&e.fold!==`mark`?o.dataset.motionPressTarget=`[role=toolbar]`:delete o.dataset.motionPressTarget,o.setAttribute(`aria-expanded`,String(!t)),o.setAttribute(`aria-label`,`${t?`Show`:`Hide`} ${e.label}`),o.title=`${o.getAttribute(`aria-label`)}. Drag to move.`},l=()=>e.markOnly?.active()===!0,u=e.markOnly?.opened===!0,d=()=>l()?!u:Rt(e.storage.collapsed)??s;c(d()),o.addEventListener(`click`,()=>{if(y())return;let t=!n.hasAttribute(`collapsed`);if(w.move(()=>{c(t),v(h)},t?40:0),l())u=!t;else try{t===s?localStorage.removeItem(e.storage.collapsed):localStorage.setItem(e.storage.collapsed,t?`1`:`0`)}catch{}});let f=e.exit,p;f&&(p=document.createElement(`button`),p.className=`exit`,p.setAttribute(`aria-label`,f.label),p.title=f.label,p.append(Tt(`0 0 24 24`,`M18 6 6 18M6 6l12 12`,{width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})),f.menu||p.addEventListener(`click`,e=>f.press(e.detail===0))),a.append(o,...p?[p]:[]);let m=document.createElement(`slot`);m.name=`tab`,m.className=`tabs`,r.append(i,m,a),p&&f?.menu&&r.append(...f.menu(p));for(let t of e.slots){let e=document.createElement(`slot`);e.name=t,a.insertBefore(e,p??null)}let h=kt(e.storage.dock)??e.initial?.dock??{edge:`bottom`,at:50},g=h,_=()=>h.edge===`left`||h.edge===`right`,v=t=>{h=t,g=l()&&!n.hasAttribute(`dragging`)&&t.edge===`bottom`?{edge:`bottom`,at:t.at<50?0:100}:t,n.setAttribute(`edge`,g.edge),n.style.setProperty(`--at`,String(g.at));let r=n.hasAttribute(`collapsed`),i=r?_()?U(n).width:U(n).height:_()?a.offsetWidth:a.offsetHeight;e.onPlace?.({...g,collapsed:r,thickness:i}),o.style.setProperty(`--vitehub-mark-x`,`${a.clientWidth/2-o.offsetLeft-o.offsetWidth/2}px`),o.style.setProperty(`--vitehub-mark-y`,`${a.clientHeight/2-o.offsetTop-o.offsetHeight/2}px`)},y=Lt({host:n,handle:o,dock:()=>h,shape:e=>{let t=n.hasAttribute(`collapsed`),r=t?e?n.offsetHeight:n.offsetWidth:e?a.offsetHeight:a.offsetWidth;return{size:r,lead:t?r/2:e?o.offsetTop+o.offsetHeight/2:o.offsetLeft+o.offsetWidth/2,part:t?e?U(n).height:U(n).width:r,margin:t?2:16}},place:v,drop:()=>{w.move(()=>v(h));try{localStorage.setItem(e.storage.dock,JSON.stringify({edge:h.edge,at:h.at}))}catch{}},signal:t}),b=pt(a,{items:()=>[o,...[...n.children].filter(e=>e instanceof HTMLElement&&e.slot!==`tab`),...p?[p]:[]],movesOnly:!0}),x={width:0,height:0},S={top:0,right:0,bottom:0,left:0},C=A(0,(e,t)=>{P(a,{"clip-path":t===0&&e===0?null:`inset(${[S.top,S.right,S.bottom,S.left].map(t=>`${(t*e).toFixed(2)}px`).join(` `)} round 12px)`})},E.snappy),w=Pt(n,a,o,()=>C.stop(),()=>b.measure());Mt.set(n,w);let T=[B(n,H),B(r,H)];if(t.aborted){for(let e of T)e();return n}let D=new ResizeObserver(()=>{let e=x;if(x={width:a.offsetWidth,height:a.offsetHeight},v(h),n.hasAttribute(`collapsed`)||n.hasAttribute(`dragging`)||w.moving)return;if(!e.width)return b.measure();b.play(),b.measure();let t={x:x.width-e.width,y:x.height-e.height},r={x:_()?g.edge===`right`?t.x:0:t.x*g.at/100,y:_()?t.y*g.at/100:g.edge===`bottom`?t.y:0};S={top:Math.max(0,r.y),right:Math.max(0,t.x-r.x),bottom:Math.max(0,t.y-r.y),left:Math.max(0,r.x)},(S.top||S.right||S.bottom||S.left)&&(C.set(1),C.to(0,{preset:E.snappy}))});return t.addEventListener(`abort`,()=>{n.remove(),D.disconnect(),C.stop(),b.destroy();for(let e of T)e()},{once:!0}),(e.parent??document.documentElement).append(n),v(h),t.aborted||(D.observe(a),e.markOnly?.watch(()=>{u=!1;let e=n.contains(document.activeElement),t=d();w.move(()=>{c(t),v(h)},t&&!n.hasAttribute(`collapsed`)?40:0),e&&n.hasAttribute(`collapsed`)&&o.focus({preventScroll:!0})},t)),n}async function It(e){if(e.inert=!0,e.hasAttribute(`collapsed`)||matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.shadowRoot?.querySelector(`div`),n=Mt.get(e);if(!t?.offsetWidth||!n){e.setAttribute(`collapsed`,``);return}Object.assign(t.style,{width:`${t.offsetWidth}px`,height:`${t.offsetHeight}px`});let r=n.move(()=>e.setAttribute(`collapsed`,``),40);await Promise.race([r,new Promise(e=>setTimeout(e,600*ie()))])}function Lt(e){let{host:t,handle:n}=e,r,i=!1;return n.style.touchAction=`none`,n.addEventListener(`pointerdown`,a=>{if(a.button!==0||r!==void 0)return;r=a.pointerId,i=!1;let o=n.getBoundingClientRect(),s={x:a.clientX-o.left-o.width/2,y:a.clientY-o.top-o.height/2};n.setPointerCapture(a.pointerId);let c=n=>{if(n.pointerId!==a.pointerId||!i&&Math.hypot(n.clientX-a.clientX,n.clientY-a.clientY)<4)return;i=!0,t.setAttribute(`dragging`,``);let r=document.documentElement.clientWidth,o=document.documentElement.clientHeight,c=n.clientX-s.x,l=n.clientY-s.y,u=At(c,l,r,o);u!==e.dock().edge&&e.place({edge:u,at:e.dock().at});let d=u===`left`||u===`right`,{size:f,lead:p,part:m,margin:h}=e.shape(d),g=(d?l:c)-p+f/2,_=getComputedStyle(t),v=Math.max(h,Number.parseFloat(_.getPropertyValue(d?`--safe-top`:`--safe-left`))||0),y=Math.max(h,Number.parseFloat(_.getPropertyValue(d?`--safe-bottom`:`--safe-right`))||0);e.place({edge:u,at:jt(g,m,v,y,d?o:r)})};n.addEventListener(`pointermove`,c);let l=o=>{o.pointerId===a.pointerId&&(n.removeEventListener(`pointermove`,c),n.removeEventListener(`lostpointercapture`,l),r=void 0,i&&(t.removeAttribute(`dragging`),e.drop(),setTimeout(()=>{i=!1})))};n.addEventListener(`lostpointercapture`,l)},{signal:e.signal}),()=>i}function U(e){let t=Number.parseFloat(getComputedStyle(e).getPropertyValue(`--vitehub-hex-h`))||24;return{width:t*10/9,height:t}}function Rt(e){try{let t=localStorage.getItem(e);return t===`1`||t!==`0`&&void 0}catch{return}}var zt=`[role=menu]{position:fixed;inset:auto;box-sizing:border-box;width:max-content;min-width:220px;max-width:min(300px,calc(100vw - 16px));margin:0;padding:6px;overflow:visible;border:1px solid var(--vitehub-pill-line);border-radius:12px;background:#171717;color:var(--vitehub-pill-text);font:500 13px/1.3 ui-sans-serif,system-ui,sans-serif;box-shadow:0 16px 40px rgb(0 0 0/30%);color-scheme:dark;pointer-events:auto}
63
- [role=menuitem]{display:flex;width:100%;height:32px;justify-content:flex-start;gap:8px;font-size:13px}
64
- [role=menuitem] svg{width:15px;height:15px;color:var(--vitehub-pill-muted)}
65
- [role=menuitem][hidden]{display:none}
66
- [role=menuitem][aria-disabled=true]{cursor:progress}
67
- @media(any-pointer:coarse){[role=menuitem]{height:44px}}`,Bt=`${s}
68
- ${zt}
69
- .who{align-self:flex-start;padding:0 3px}
70
- .avatar{box-sizing:border-box;display:grid;place-items:center;width:22px;height:22px;flex:none;overflow:hidden;border-radius:50%;background:#404040;color:var(--vitehub-pill-strong);font-size:10px;font-weight:600;line-height:1}
71
- .avatar img{display:block;width:100%;height:100%;object-fit:cover}
72
- .me{display:flex;align-items:center;gap:10px;margin-bottom:4px;padding:8px 8px 10px;border-bottom:1px solid var(--vitehub-pill-line)}
73
- .me .avatar{width:32px;height:32px;font-size:12px}
74
- .me div{min-width:0}
75
- .me b,.me small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
76
- .me b{color:var(--vitehub-pill-strong);font-weight:500}
77
- .me small{margin-top:2px;color:var(--vitehub-pill-muted);font-size:12px}
78
- .via{display:flex;align-items:center;gap:6px;padding:6px 8px;color:var(--vitehub-pill-muted);font-size:12px}
79
- .via svg{width:11px;height:10px;flex:none;fill:var(--vitehub-pill-text)}
80
- `,Vt=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 7h10v10M7 17 17 7"/></svg>`,Ht=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49M14.084 14.158a3 3 0 0 1-4.242-4.242M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143M2 2l20 20"/></svg>`,Ut=`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 17 5-5-5-5M21 12H9M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/></svg>`;function Wt(e){return e.trim().split(/\s+/).slice(0,2).map(e=>[...e][0]??``).join(``).toLocaleUpperCase()}function Gt(e){let t=document.createElement(`span`);if(t.className=`avatar`,t.setAttribute(`aria-hidden`,`true`),t.textContent=Wt(e.name),e.image){let n=document.createElement(`img`);n.alt=``,n.referrerPolicy=`no-referrer`,n.src=e.image,n.addEventListener(`load`,()=>t.replaceChildren(n),{once:!0})}return t}function Kt(e,t){let n=document.createElement(`button`);n.type=`button`,n.setAttribute(`role`,`menuitem`),n.tabIndex=-1,n.insertAdjacentHTML(`beforeend`,e);let r=document.createElement(`span`);return r.textContent=t,n.append(r),{item:n,label:r}}function qt(){let e=new URL(location.href);for(let t of[a,...i])e.searchParams.delete(t);return e}function Jt(e){let{account:t,bar:n,signal:r}=e,i=n.parentElement,a=n.attachShadow({mode:`open`});r.addEventListener(`abort`,B(a,H),{once:!0});let o=document.createElement(`style`);o.textContent=Bt;let s=document.createElement(`div`);s.id=`account-menu`,s.setAttribute(`popover`,`auto`),s.setAttribute(`role`,`menu`),s.setAttribute(`aria-label`,t.name);let c=document.createElement(`button`);c.type=`button`,c.className=`who`,c.title=t.email?`${t.name} (${t.email})`:t.name,c.setAttribute(`aria-label`,`Account: ${t.name}`),c.setAttribute(`aria-haspopup`,`menu`),c.setAttribute(`aria-expanded`,`false`),c.setAttribute(`aria-controls`,s.id),c.setAttribute(`popovertarget`,s.id),c.append(Gt(t));let l=document.createElement(`div`);l.className=`me`,l.setAttribute(`role`,`none`);let u=document.createElement(`div`),d=document.createElement(`b`);if(d.textContent=t.name,u.append(d),t.email){let e=document.createElement(`small`);e.textContent=t.email,u.append(e)}if(l.append(Gt(t),u),s.append(l),t.via===`console`){let t=document.createElement(`div`);t.className=`via`,t.setAttribute(`role`,`none`),t.append(Tt(`0 0 20 18`,e.mark,{}),`Signed in with ViteHub Console`),s.append(t)}let f=Kt(Vt,`Open in the Console`),p=Kt(Ut,`Sign out of ${location.host}`);s.append(f.item,p.item),a.append(o,c,s);let m;Xt({menu:s,button:c,pill:i,beforeOpen:()=>{m=e.openConsole?.(),f.item.hidden=!m},signal:r}),f.item.addEventListener(`click`,()=>{s.hidePopover(),m?.()},{signal:r}),Zt(t,p,r)}function Yt(e){let{account:t,button:n,turnOff:r,canExit:i,signal:a}=e,o=document.createElement(`style`);o.textContent=zt;let s=document.createElement(`vitehub-menu`);s.id=`exit-menu`,s.setAttribute(`popover`,`auto`),s.setAttribute(`role`,`menu`),s.setAttribute(`aria-label`,`Turn off tools or sign out`);let c=Kt(Ht,r.label),l=Kt(Ut,`Sign out of ${location.host}`);s.append(c.item,l.item);let u=`Turn off tools or sign out`;n.setAttribute(`aria-label`,u),n.title=u,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,s.id),n.setAttribute(`popovertarget`,s.id);let d=n.getRootNode();return Xt({menu:s,button:n,pill:d instanceof ShadowRoot&&d.host instanceof HTMLElement?d.host:null,signal:a}),c.item.addEventListener(`click`,e=>{s.hidePopover(),r.press(e.detail===0)},{signal:a}),Zt(t,l,a,i),[o,s]}function Xt(e){let{menu:t,button:n,pill:r,signal:i}=e,a=()=>{let e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement:null},o=()=>[...t.querySelectorAll(`[role=menuitem]`)].filter(e=>!e.hidden),s=e=>{let i=document.documentElement.clientWidth,a=document.documentElement.clientHeight,o=(r??n).getBoundingClientRect(),s=n.getBoundingClientRect(),c={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};e===`bottom`||e===`top`?(c.right=`${Math.max(8,i-s.right)}px`,e===`bottom`?c.bottom=`${a-o.top+8}px`:c.top=`${o.bottom+8}px`):(s.top<a/2?c.top=`${Math.max(8,s.top)}px`:c.bottom=`${Math.max(8,a-s.bottom)}px`,e===`left`?c.left=`${o.right+8}px`:c.right=`${i-o.left+8}px`),Object.assign(t.style,c)},c=e=>{if(e!==`bottom`&&e!==`top`)return;let r=document.documentElement.clientWidth,i=n.getBoundingClientRect(),a=t.getBoundingClientRect().width;t.style.right=`auto`,t.style.left=`${Math.max(8,Math.min(i.right-a,r-a-8))}px`};if(t.addEventListener(`beforetoggle`,i=>{if(i.newState===`closed`){t.contains(a())&&n.focus({preventScroll:!0});return}e.beforeOpen?.();let o=r?.getAttribute(`edge`)??`bottom`;s(o),requestAnimationFrame(()=>c(o))},{signal:i}),t.addEventListener(`toggle`,e=>{let t=e.newState===`open`;n.setAttribute(`aria-expanded`,String(t)),t&&o()[0]?.focus({preventScroll:!0})},{signal:i}),t.addEventListener(`keydown`,e=>{let n=o(),r=n.findIndex(e=>e===a()),i=e.key===`ArrowDown`?r+1:e.key===`ArrowUp`?r-1:e.key===`Home`?0:e.key===`End`?n.length-1:void 0;i===void 0?e.key===`Escape`?e.stopPropagation():e.key===`Tab`&&t.hidePopover():(e.preventDefault(),n[(i+n.length)%n.length]?.focus())},{signal:i}),r){let e=new MutationObserver(e=>{e.some(e=>e.oldValue!==r.getAttribute(e.attributeName??``))&&t.hidePopover()});e.observe(r,{attributes:!0,attributeOldValue:!0,attributeFilter:[`collapsed`,`dragging`,`edge`]}),i.addEventListener(`abort`,()=>e.disconnect(),{once:!0})}i.addEventListener(`abort`,()=>t.hidePopover(),{once:!0})}function Zt(e,t,n,r){t.item.addEventListener(`click`,async()=>{if(t.item.getAttribute(`aria-disabled`)===`true`||r?.()===!1)return;t.item.setAttribute(`aria-disabled`,`true`),t.label.textContent=`Signing out…`;let n=await fetch(e.signOut,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:`{}`}).catch(e=>e);if(!(n instanceof Response)||!n.ok){console.error(`[vitehub] The sign-out failed. The session stays.`,n instanceof Response?`The sign-out answered ${n.status}.`:n),t.item.removeAttribute(`aria-disabled`),t.label.textContent=`Could not sign out. Try again`;return}let i=qt();i.href===location.href?location.reload():location.replace(i)},{signal:n})}var Qt=l({docsBase:`https://vitehub.dev/docs/development/diagnostics`,codes:{INTERNAL_INVARIANT_FAILED:{why:({what:e})=>`ViteHub reached a state that it does not expect: ${e}`,fix:`This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace.`}}});function $t(e){return Qt.INTERNAL_INVARIANT_FAILED({what:e})}function en(e,t){if(!e)throw $t(t)}function tn(e,t,n){let r=e.cloneNode(!0);for(let e of[r,...r.querySelectorAll(`*`)])for(let t of[`id`,`role`,`tabindex`,`hidden`,`inert`,`popover`,`data-ending-style`,`data-starting-style`,`aria-live`])e.removeAttribute(t);return r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`data-motion`,`none`),r instanceof HTMLElement&&(r.inert=!0),r.style.pointerEvents=`none`,t.insertBefore(r,n?.parentNode===t?n:null),r}function nn(e,t){Object.assign(e.style,{position:`fixed`,inset:`auto`,left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,margin:`0`,boxSizing:`border-box`,transform:`none`,translate:`none`,zIndex:`2147483647`});let n=e.getBoundingClientRect();Math.abs(n.left-t.left)>.5&&(e.style.left=`${2*t.left-n.left}px`),Math.abs(n.top-t.top)>.5&&(e.style.top=`${2*t.top-n.top}px`)}function rn(e,t){return window.setTimeout(t,e*ie())}var W={stiffness:480,damping:36},an={stiffness:380,damping:26},G={stiffness:440,damping:32},on=30,sn=120,cn=70,ln=40,un=90,dn=520,fn=.24,pn=.15,mn=.14,hn=.15,K=new WeakMap,gn=new Set,_n=new Set,q;function vn(e){let t=getComputedStyle(e);return t.clipPath===`inset(50%)`||t.clip===`rect(0px, 0px, 0px, 0px)`}function yn(e){return e.matches(`[role=tooltip]`)?e:e.querySelector(`:scope > [role=tooltip]`)}var bn=`[data-motion-appear]`;function xn(e){if(e.matches(bn))return e;if(e.matches(`[role=tooltip]`))return vn(e)?e.parentElement:e;let t=e.querySelector(`:scope > [role=tooltip]`);return t&&vn(t)?e:null}function Sn(e){let t=e.getAttribute(`data-state`);return t===null?!e.hidden&&!e.hasAttribute(`data-closed`):t!==`closed`}function Cn(e){let t=e.getAttribute(`data-motion-appear`);if(t!==null){let n=e.parentElement;return!t||!n?null:n.closest(t)??[...n.children].find(n=>n!==e&&n.matches(t))??null}let n=yn(e)?.id;return n?e.getRootNode().querySelector(`[aria-describedby~="${CSS.escape(n)}"]`)??document.querySelector(`[aria-describedby~="${CSS.escape(n)}"]`):null}function wn(e){let t=[`translate`,`scale`,`clip-path`,`opacity`].map(t=>[t,e.style.getPropertyValue(t)]);P(e,{translate:null,scale:null,"clip-path":null});let n=e.getBoundingClientRect();for(let[n,r]of t)r&&e.style.setProperty(n,r);return n}function Tn(e,t,n){let r=e.getAttribute(`data-side`);if(r===`top`||r===`bottom`||r===`left`||r===`right`)return r;if(!n)return`top`;let[i,a]=[[`top`,n.top-t.bottom],[`bottom`,t.top-n.bottom],[`left`,n.left-t.right],[`right`,t.left-n.right]].reduce((e,t)=>t[1]>e[1]?t:e);if(a>=0)return i;let o=n.left+n.width/2-(t.left+t.width/2),s=n.top+n.height/2-(t.top+t.height/2);return Math.abs(s)>=Math.abs(o)?s>0?`top`:`bottom`:o>0?`left`:`right`}function En(e,t,n){return e===`top`?n?.top??t.bottom+8:e===`bottom`?n?.bottom??t.top-8:e===`left`?n?.left??t.right+8:n?.right??t.left-8}var Dn=e=>e===`top`||e===`bottom`;function On(e){let{rest:t,side:n,edge:r}=e;return n===`top`?r+t.height/2:n===`bottom`?r-t.height/2:n===`left`?r+t.width/2:r-t.width/2}function kn(e){return[...e.element.children].filter(t=>t instanceof HTMLElement&&t!==e.old?.element&&!t.matches(`[role=tooltip]`)&&!vn(t))}function An(e){return[...e.element.childNodes].filter(t=>t.nodeType===Node.TEXT_NODE||t instanceof Element&&t!==e.old?.element&&!t.matches(`[role=tooltip]`)&&!vn(t)).map(e=>e.textContent??``).join(``)}function jn(e){return[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())}var J=e=>`${Math.round(e*100)/100}px`;function Y(e){let{element:t,rest:n,side:r,edge:i,origin:a}=e,o=Math.max(1,e.width.value),s=e.mode===`clip`&&o<n.width,c=s?1:o/n.width,l=e.x.value-o/2,u=s?e.x.value-(n.left+n.width/2):l-n.left-a*(1-c),d=e.y.value-(n.top+n.height/2),f=[-40,-40,-40,-40];r===`top`&&(f[2]=e.y.value+n.height/2-i),r===`bottom`&&(f[0]=i-(e.y.value-n.height/2)),r===`left`&&(f[1]=(e.x.value+o/2-i)/c),r===`right`&&(f[3]=(i-(e.x.value-o/2))/c);let p=f.some(e=>e>0),m=null;if(s){let t=(n.width-o)/2;m=`inset(${[Math.max(0,f[0]),t+Math.max(0,f[1]),Math.max(0,f[2]),t+Math.max(0,f[3])].map(J).join(` `)} round ${e.radius})`}else p&&(m=`inset(${f.map(J).join(` `)})`);P(t,{translate:Math.abs(u)>.01||Math.abs(d)>.01||e.old?`${J(u)} ${J(d)}`:null,scale:Math.abs(c-1)>.001?`${c} 1`:null,"clip-path":m,opacity:e.fade.active||e.fade.value<1?String(e.fade.value):null});let h=Math.abs(c-1)>.001?`${1/c} 1`:null,g=e.label.value;for(let t of kn(e))P(t,{scale:h,opacity:g<1?String(g):null,filter:g<1?`blur(${J((1-g)*6)})`:null});if(e.old){let t=e.old.spring.value;P(e.old.element,{scale:h,opacity:String(t),filter:`blur(${J((1-t)*5)})`})}}function Mn(e){if(!(e.holding||e.timers.size||[e.x,e.y,e.width,e.label,e.fade,e.old?.spring].some(e=>e?.active))){e.old?.element.remove(),e.old=void 0,P(e.element,{translate:null,scale:null,"clip-path":null,opacity:null});for(let t of kn(e))P(t,{scale:null,opacity:null,filter:null});e.done?.()}}function Nn(e,t,n){let r=getComputedStyle(e),i=Tn(e,t,n),a={element:e,rest:t,origin:Number.parseFloat(r.transformOrigin)||t.width/2,side:i,edge:En(i,t,n),trigger:n,mode:jn(e)||e.matches(bn)?`clip`:`scale`,handoff:!e.matches(bn),radius:r.borderRadius||`0px`,timers:new Set,holding:!0},o=()=>{Y(a),Mn(a)};return a.x=A(t.left+t.width/2,o,W),a.y=A(t.top+t.height/2,o,W),a.width=A(t.width,o,G),a.label=A(1,o),a.fade=A(1,o),a}function X(e,t,n){let r=rn(t,()=>{e.timers.delete(r),n(),Mn(e)});e.timers.add(r)}function Pn(e){for(let t of e.timers)clearTimeout(t);e.timers.clear();for(let t of[e.x,e.y,e.width,e.label,e.fade,e.old?.spring])t?.stop()}function Fn(e){Pn(e),_n.delete(e),q===e&&(q=void 0),e.element.closest(`[data-motion=none]`)?.remove()}function In(e){if(e){for(let e of _n)Fn(e);for(let e of gn){let t=K.get(e)?.box;t&&(Pn(t),t.holding=!0,t.x.set(t.rest.left+t.rest.width/2),t.y.set(t.rest.top+t.rest.height/2),t.width.set(t.rest.width),t.label.set(1),t.fade.set(1),t.holding=!1,Mn(t))}}}function Ln(e,t){let n=e.trigger,r=t.trigger;return!n||!r||e.side!==t.side?!1:Dn(t.side)?n.top<r.bottom&&r.top<n.bottom:n.left<r.right&&r.left<n.right}function Rn(e){return Dn(e.side)?e.y:e.x}function zn(e,t,n){if(!t.length)return;let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),Object.assign(r.style,{position:`absolute`,inset:`0`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`inherit`,pointerEvents:`none`,whiteSpace:`nowrap`}),r.append(...t),e.element.append(r);let i=A(n,()=>{Y(e),Mn(e)});e.old={element:r,spring:i},i.to(0,{tween:pn})}function Bn(e){return e.mode===`clip`?[...e.element.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.cloneNode()):kn(e).map(e=>{let t=e.cloneNode(!0);return t.style.removeProperty(`scale`),t.style.removeProperty(`opacity`),t.style.removeProperty(`filter`),t})}function Vn(e,t){let n=t.trigger?.getBoundingClientRect(),r=wn(e),i=Nn(e,r,n);t.box=i,t.text=An(i),t.label=Bn(i),P(e,{opacity:null});let a=i.handoff&&q&&Ln(q,i)?q:void 0;if(a&&(q=void 0),w())a&&Hn(a,!0),i.fade.set(0),i.holding=!1,i.fade.to(1,{tween:hn});else if(a){let e=Bn(a),t={x:[a.x.value,a.x.velocity],y:[a.y.value,a.y.velocity],width:[a.width.value,a.width.velocity]},n=a.old?0:a.label.value;Fn(a),i.x.set(t.x[0]),i.y.set(t.y[0]),i.width.set(t.width[0]),i.label.set(0),zn(i,e,n),i.x.to(r.left+r.width/2,{preset:W,velocity:t.x[1]}),i.y.to(r.top+r.height/2,{preset:W,velocity:t.y[1]}),i.width.to(r.width,{preset:G,velocity:t.width[1]}),X(i,ln,()=>i.label.to(1,{tween:fn})),i.holding=!1,Y(i)}else Rn(i).set(On(i)),i.width.set(Math.min(on,r.width)),i.label.set(0),Y(i),Rn(i).to(Dn(i.side)?r.top+r.height/2:r.left+r.width/2,{preset:an}),X(i,sn,()=>{i.width.to(r.width,{preset:G}),X(i,cn,()=>i.label.to(1,{tween:fn}))}),i.holding=!1}function Hn(e,t){_n.add(e),e.holding=!1,t?(e.done=()=>Fn(e),e.fade.to(0,{tween:hn})):(e.handoff&&(q=e),e.old&&e.old.spring.to(0,{tween:mn}),e.label.to(0,{tween:mn}),e.width.to(Math.min(on,e.rest.width),{preset:G}),X(e,un,()=>{q===e&&(q=void 0),Rn(e).to(On(e),{preset:an})}),X(e,dn,()=>Fn(e)))}function Un(e,t){if(!t.open)return;t.open=!1,gn.delete(e),t.stopWatch?.(),t.stopWatch=void 0,gn.size||er();let n=t.box;if(t.box=void 0,P(e,{opacity:null}),!n)return;let r=t.root.parentNode??t.parent,i=r?.isConnected?tn(t.root,r,t.root.isConnected?t.root.nextSibling:t.next):void 0,a={x:n.x,y:n.y,width:n.width,label:n.label,fade:n.fade},o=Object.fromEntries(Object.entries(a).map(([e,t])=>[e,[t.value,t.velocity]])),s=n.old?.spring.value;Pn(n),n.old?.element.remove(),P(e,{translate:null,scale:null,"clip-path":null,opacity:null});for(let e of kn(n))P(e,{scale:null,opacity:null,filter:null});if(!i)return;let c=Wn(t.root,e).reduce((e,t)=>e?.children[t],i);if(!(c instanceof HTMLElement)){i.remove();return}e.hasAttribute(`popover`)&&(P(c,{scale:null}),nn(c,n.rest));let l=Nn(c,n.rest,void 0);Object.assign(l,{side:n.side,edge:n.edge,trigger:n.trigger,mode:n.mode,origin:n.origin,radius:n.radius,handoff:n.handoff});let u=c.querySelector(`:scope > [aria-hidden=true][style*=absolute]`);s!==void 0&&u&&(l.old={element:u,spring:A(s,()=>Y(l))});for(let e of[`x`,`y`,`width`,`label`,`fade`])l[e].set(o[e][0]);Y(l);for(let e of[`x`,`y`,`width`])o[e][1]&&l[e].to(o[e][0],{velocity:o[e][1]});Hn(l,w())}function Wn(e,t){let n=[];for(let r=t;r!==e&&r.parentElement;r=r.parentElement)n.unshift([...r.parentElement.children].indexOf(r));return n}function Gn(e,t,n,r=20){requestAnimationFrame(()=>{if(!t.open||!e.isConnected)return;let i=e.closest(`[data-reka-popper-content-wrapper]`);if(r>0&&i?.style.transform.includes(`-200%`))return Gn(e,t,n,r-1);n()})}function Kn(e,t){let n=()=>{r.disconnect();let t=e;for(;t;){let e=t.parentNode;e&&r.observe(e,{childList:!0}),t=e??(t instanceof ShadowRoot?t.host:null)}},r=new MutationObserver(()=>{e.isConnected?(t.parent=t.root.parentNode,t.next=t.root.nextSibling,n()):Un(e,t)});return n(),()=>r.disconnect()}function qn(e){let t=K.get(e);if(t?.open)return;let n=Cn(e);if(n&&j(n))return;let r=e.closest(`[data-reka-popper-content-wrapper]`)??e;t={open:!0,root:r,parent:r.parentNode,next:r.nextSibling,text:``,label:[],trigger:n},K.set(e,t),gn.add(e),$n(),P(e,{opacity:`0`}),t.stopWatch=Kn(e,t);let i=t;Gn(e,t,()=>Vn(e,i))}var Jn=0;function Yn(){Jn=0;for(let e of gn){let t=K.get(e),n=t?.box;if(!t||!n)continue;let r=wn(e),i=An(n);if(!(Math.abs(r.left-n.rest.left)>1||Math.abs(r.top-n.rest.top)>1||Math.abs(r.width-n.rest.width)>1)&&i===t.text)continue;let a=i===t.text?[]:t.label;t.trigger=Cn(e)??t.trigger;let o=t.trigger?.getBoundingClientRect();t.text=i,t.label=Bn(n),n.rest=r,n.side=Tn(e,r,o),n.edge=En(n.side,r,o),w()?(n.x.set(r.left+r.width/2),n.y.set(r.top+r.height/2),n.width.set(r.width)):(n.x.to(r.left+r.width/2,{preset:W}),n.y.to(r.top+r.height/2,{preset:W}),n.width.to(r.width,{preset:G}),a.length&&(n.old?.spring.stop(),n.old?.element.remove(),zn(n,a,n.label.value),n.label.set(0),X(n,ln,()=>n.label.to(1,{tween:fn}))))}}function Xn(){Jn||=requestAnimationFrame(Yn)}var Zn=!1,Qn;function $n(){Qn??=T(In),Zn||(Zn=!0,document.addEventListener(`pointerover`,Xn,{capture:!0,passive:!0}),document.addEventListener(`focusin`,Xn,{capture:!0,passive:!0}))}function er(){Zn=!1,cancelAnimationFrame(Jn),Jn=0,document.removeEventListener(`pointerover`,Xn,{capture:!0}),document.removeEventListener(`focusin`,Xn,{capture:!0})}var tr={enter(e){xn(e)===e&&Sn(e)&&qn(e)},state(e){if(xn(e)!==e)return;let t=K.get(e);Sn(e)?qn(e):t&&Un(e,t)}};({...tr});var nr={name:`appear`,selector:bn,...tr},rr=`
81
- :host{all:initial;--surface:light-dark(#fff,#0a0a0a);--text:light-dark(#18181b,#fafafa);--muted:light-dark(#71717a,#a1a1aa);--line:light-dark(rgb(0 0 0/8%),rgb(255 255 255/9%));--hover:light-dark(rgb(0 0 0/5%),rgb(255 255 255/7%));--focus:light-dark(#18181b,#fafafa);--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--at:50;--margin:16px;--start:max(var(--margin),var(--safe-left));--end:max(var(--margin),var(--safe-right));--far:max(16px,var(--safe-top));--along:calc(var(--start) + (100% - var(--start) - var(--end)) * var(--at) / 100);--shift:calc(var(--at) * -1%);--dock:calc(max(var(--margin),var(--safe-bottom)) + var(--thickness,38px) + 8px);--width:calc(100vw - var(--start) - var(--end));--height:calc(100dvh - var(--dock) - var(--far));position:fixed;inset:0;z-index:2147483000;pointer-events:none;color:var(--text);font:400 .875rem/1.5 system-ui,sans-serif;color-scheme:light dark}
82
- :host([collapsed]){--margin:2px}
83
- :host([edge=top]){--dock:calc(max(var(--margin),var(--safe-top)) + var(--thickness,38px) + 8px);--far:max(16px,var(--safe-bottom))}
84
- :host(:is([edge=left],[edge=right])){--start:max(var(--margin),var(--safe-top));--end:max(var(--margin),var(--safe-bottom));--width:calc(100vw - var(--dock) - var(--far));--height:calc(100dvh - var(--start) - var(--end))}
85
- :host([edge=right]){--dock:calc(max(var(--margin),var(--safe-right)) + var(--thickness,38px) + 8px);--far:max(16px,var(--safe-left))}
86
- :host([edge=left]){--dock:calc(max(var(--margin),var(--safe-left)) + var(--thickness,38px) + 8px);--far:max(16px,var(--safe-right))}
87
- :host([hidden]){display:none}
88
- .window{position:absolute;width:min(600px,var(--width));height:min(640px,var(--height));min-width:min(300px,var(--width));min-height:min(240px,var(--height));max-width:var(--width);max-height:var(--height);display:flex;flex-direction:column;pointer-events:auto;background:var(--surface);border-radius:12px;box-shadow:0 0 0 1px light-dark(rgb(0 0 0/8%),rgb(255 255 255/10%)),0 2px 4px light-dark(rgb(0 0 0/4%),rgb(0 0 0/24%)),0 16px 40px -8px light-dark(rgb(0 0 0/18%),rgb(0 0 0/56%));outline:none}
89
- :host([edge=bottom]) .window{bottom:var(--dock);left:var(--along);translate:var(--shift) 0}
90
- :host([edge=top]) .window{top:var(--dock);left:var(--along);translate:var(--shift) 0}
91
- :host([edge=right]) .window{right:var(--dock);top:var(--along);translate:0 var(--shift)}
92
- :host([edge=left]) .window{left:var(--dock);top:var(--along);translate:0 var(--shift)}
93
- :host([edge]) .window.expanded{inset:max(12px,var(--safe-top)) max(12px,var(--safe-right)) max(12px,var(--safe-bottom)) max(12px,var(--safe-left));translate:none;width:auto!important;height:auto!important;max-width:none;max-height:none}
94
- :host([edge=bottom]) .window.expanded{bottom:var(--dock)}:host([edge=top]) .window.expanded{top:var(--dock)}:host([edge=right]) .window.expanded{right:var(--dock)}:host([edge=left]) .window.expanded{left:var(--dock)}
95
- .frame{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;border-radius:inherit}
96
- .grip{position:absolute;z-index:1;touch-action:none}
97
- .grip.top,.grip.bottom{left:12px;right:12px;height:8px;cursor:ns-resize}
98
- .grip.top{top:-4px}.grip.bottom{bottom:-4px}
99
- .grip.left,.grip.right{top:12px;bottom:12px;width:8px;cursor:ew-resize}
100
- .grip.left{left:-4px}.grip.right{right:-4px}
101
- :host([edge=bottom]) .grip.bottom,:host([edge=top]) .grip.top,:host([edge=right]) .grip.right,:host([edge=left]) .grip.left,.expanded .grip{display:none}
102
- header{display:flex;align-items:center;gap:2px;min-height:44px;padding:0 6px 0 8px;border-bottom:1px solid var(--line);flex:none}
103
- h2{font:600 .875rem/1.5 system-ui,sans-serif;margin:0;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 8px}
104
- header :is(button,a){display:grid;place-items:center;width:32px;height:32px;border:0;border-radius:8px;background:transparent;color:var(--muted);cursor:pointer;font:inherit;touch-action:manipulation;transition:background-color 150ms ease-out,color 150ms ease-out}
105
- header a[hidden]{display:none}
106
- @media(hover:hover){header :is(button,a):hover{background:var(--hover);color:var(--text)}}
107
- header :is(button,a):focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
108
- @media(any-pointer:coarse){:host{--thickness:54px}.grip{display:none}header :is(button,a){width:44px;height:44px}}
109
- .body{flex:1;min-height:0;overflow:auto;position:relative}iframe{display:block;border:0;width:100%;height:100%;background:var(--surface)}
110
- @media(max-width:640px){:host([edge]) .window,:host([edge]) .window.expanded{inset:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);translate:none;width:auto!important;height:auto!important;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:0}:host([edge=bottom]) :is(.window,.window.expanded){bottom:var(--dock)}:host([edge=top]) :is(.window,.window.expanded){top:var(--dock)}:host([edge=right]) :is(.window,.window.expanded){right:var(--dock)}:host([edge=left]) :is(.window,.window.expanded){left:var(--dock)}:host(:is([edge=top],[edge=bottom])) .window:not(.expanded){left:var(--start);right:var(--end)}:host(:is([edge=left],[edge=right])) .window:not(.expanded){top:var(--start);bottom:var(--end)}.grip{display:none}header :is(button,a){width:44px;height:44px}.expand{display:none}}
111
- @media(forced-colors:active){.window{border:1px solid CanvasText}header :is(button,a):focus-visible{outline-color:Highlight}}
112
- `,Z={edge:`bottom`,at:50},ir=new Set,ar=0;function or(e){e.setAttribute(`edge`,Z.edge),e.toggleAttribute(`collapsed`,!!Z.collapsed),e.style.setProperty(`--at`,String(Z.at)),Z.thickness?e.style.setProperty(`--thickness`,`${Z.thickness}px`):e.style.removeProperty(`--thickness`);for(let t of[`top`,`right`,`bottom`,`left`])e.shadowRoot.querySelector(`.grip.${t}`).hidden=sr(t)===0}function sr(e){return(e===`top`||e===`bottom`)==(Z.edge===`top`||Z.edge===`bottom`)?1:e===`top`||e===`left`?Z.at/100:1-Z.at/100}function cr(e){Z=e;for(let e of ir)or(e)}function lr(e){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(let[e,n]of Object.entries({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))t.setAttribute(e,n);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttribute(`d`,e),t.append(n),t}function ur(e){let t=document.createElement(`vitehub-window`);t.hidden=!0;let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=rr;let i=document.createElement(`section`);i.className=`window`,i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-labelledby`,`title`),i.tabIndex=-1;let a=document.createElement(`header`),o=document.createElement(`h2`);o.id=`title`,o.textContent=e.title;let s=document.createElement(`div`);s.className=`body`;let c=(e,t,n)=>{let r=document.createElement(`button`);return r.className=e,r.type=`button`,r.setAttribute(`aria-label`,t),r.title=t,r.append(lr(n)),r},l=c(`expand`,`Expand window`,`M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5`),u=c(`hide`,`Minimize window`,`M5 12h14`),d=document.createElement(`a`);d.className=`tab`,d.target=`_blank`,d.rel=`noopener`,d.setAttribute(`aria-label`,`Open in new tab`),d.title=`Open in new tab`,d.append(lr(`M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`));let f=()=>{let t=e.href?.();d.hidden=!t,t?d.href=t:d.removeAttribute(`href`)};for(let e of[`pointerenter`,`pointerdown`,`focus`,`click`,`contextmenu`])d.addEventListener(e,f);f(),a.append(o,...e.href?[d]:[],l,u);let p=document.createElement(`div`);p.className=`frame`,p.append(a,s);let m=[`top`,`right`,`bottom`,`left`].map(e=>{let t=document.createElement(`div`);return t.className=`grip ${e}`,t.addEventListener(`pointerdown`,n=>{if(n.button!==0)return;let r=sr(e);if(r===0)return;n.preventDefault(),t.setPointerCapture(n.pointerId);let a=e===`top`||e===`bottom`,o=a?i.offsetHeight:i.offsetWidth,s=t=>{let s=a?t.clientY-n.clientY:t.clientX-n.clientX,c=o+(e===`top`||e===`left`?-s:s)/r;a?i.style.height=`${Math.max(240,c)}px`:i.style.width=`${Math.max(300,c)}px`};t.addEventListener(`pointermove`,s),t.addEventListener(`lostpointercapture`,()=>t.removeEventListener(`pointermove`,s),{once:!0})}),t});i.append(p,...m),n.append(r,i);let h=`vitehub-window:${e.id}`;try{let e=JSON.parse(localStorage.getItem(h)??`null`);e&&typeof e==`object`&&`width`in e&&`height`in e&&typeof e.width==`number`&&typeof e.height==`number`&&(Number.isFinite(e.width)&&(i.style.width=`${Math.max(300,e.width)}px`),Number.isFinite(e.height)&&(i.style.height=`${Math.max(240,e.height)}px`))}catch{}let g=new ResizeObserver(()=>{if(t.hidden||i.classList.contains(`expanded`)||innerWidth<=640)return;let e=i.offsetWidth,n=i.offsetHeight;try{localStorage.setItem(h,JSON.stringify({width:e,height:n}))}catch{}});g.observe(i);let _=()=>{t.hidden=!0,e.trigger.setAttribute(`aria-expanded`,`false`),e.trigger.focus({preventScroll:!0}),e.onHide?.()};l.addEventListener(`click`,()=>{let e=i.classList.toggle(`expanded`);l.setAttribute(`aria-label`,e?`Restore window size`:`Expand window`),l.title=e?`Restore window size`:`Expand window`,l.setAttribute(`aria-pressed`,String(e))}),u.addEventListener(`click`,_),e.colorScheme&&addEventListener(`storage`,()=>{t.style.colorScheme=e.colorScheme?.()??``},{signal:e.signal}),n.addEventListener(`keydown`,e=>{e instanceof KeyboardEvent&&e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),e.stopPropagation(),_())}),t.style.viewTransitionName=`vitehub-window-${++ar}`,or(t);let v=B(n,H),y=()=>{ir.delete(t),g.disconnect(),t.remove(),v()};return e.signal.aborted?y():(e.signal.addEventListener(`abort`,y,{once:!0}),ir.add(t),document.documentElement.append(t)),{body:s,show(){e.signal.aborted||(t.style.colorScheme=e.colorScheme?.()??``,f(),t.hidden=!1,e.trigger.setAttribute(`aria-expanded`,`true`),i.focus({preventScroll:!0}))},hide:_,destroy:y}}function dr(e){let t=typeof e==`object`&&e?Reflect.get(e,`default`):void 0;return t instanceof Function?t:void 0}var fr=`:host([off]){--vitehub-hex-h:14px;filter:drop-shadow(0 1px 2px rgb(0 0 0/25%))}
113
- :host([off]) button{position:relative;display:block;width:var(--vitehub-hex-w);min-width:0;height:var(--vitehub-hex-h);padding:0;border-radius:4px;pointer-events:auto;cursor:grab;opacity:.55;transition:opacity 150ms ease-out}
114
- :host([off][edge=bottom]) button{transform-origin:calc(var(--at) * 1%) 100%}
115
- :host([off][edge=top]) button{transform-origin:calc(var(--at) * 1%) 0}
116
- :host([off][edge=left]) button{transform-origin:0 calc(var(--at) * 1%)}
117
- :host([off][edge=right]) button{transform-origin:100% calc(var(--at) * 1%)}
118
- :host([off][closing]) button{opacity:1}
119
- :host([off][dragging]) button{opacity:1;cursor:grabbing}
120
- :host([off]) button::before{content:"";position:absolute;inset:-6px}
121
- svg{display:block;width:100%;height:100%;overflow:visible;fill:rgb(17 17 17/92%);stroke:rgb(255 255 255/18%);stroke-width:1px;vector-effect:non-scaling-stroke;transition:fill 150ms ease-out}
122
- :host([off]) button:focus-visible{opacity:1}
123
- :host([off][dragging]) svg{scale:none}
124
- @media(hover:hover){:host([off]) button:hover{opacity:1;background:none}button:hover svg{fill:rgb(38 38 38/94%)}}
125
- @media(any-pointer:coarse){:host([off]){--vitehub-hex-h:20px}:host([off]) button{min-width:0;height:var(--vitehub-hex-h)}:host([off]) button::before{inset:-10px}}
126
- @media(prefers-reduced-motion:reduce){:host([off]) button,svg{transition:none}}`,pr=`vitehub-tools-off`,mr=`vitehub-tools-collapsed`,hr=`vitehub-tools-dock`,gr=`vitehub-account`,_r=`M19.734 8.156 15.576.844A1.66 1.66 0 0 0 14.135 0H5.819C5.226 0 4.677.32 4.38.844L.222 8.156a1.71 1.71 0 0 0 0 1.688l4.158 7.312c.297.523.846.844 1.439.844h8.316c.593 0 1.142-.32 1.438-.844l4.158-7.312c.3-.523.3-1.165.003-1.688Z`;function vr(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}function yr(e,t){try{t?localStorage.setItem(e,`1`):localStorage.removeItem(e)}catch{}}function br(){return document.documentElement.getAttribute(`data-vitehub-pill`)===`mark`||xr}var xr=!1,Sr=!1;function Cr(){try{return localStorage.getItem(hr)}catch{return null}}function wr(){if(Sr||typeof document.elementsFromPoint!=`function`)return!1;let e=e=>{let t=e.getBoundingClientRect();return t.width*t.height<innerWidth*innerHeight/2},t=Array.from({length:36},(e,t)=>[Math.min(innerWidth-1,Math.max(0,innerWidth/2-140+t%18*16+8)),innerHeight-(t<18?24:44)]),n=new Set;for(let[r,i]of t)for(let t of document.elementsFromPoint(r,i))if(!n.has(t)){n.add(t);for(let n=t;n&&n!==document.body&&n!==document.documentElement&&!n.localName.startsWith(`vitehub-`);n=n.parentElement){let r=getComputedStyle(n);if(r.position===`fixed`||r.position===`sticky`&&r.bottom!==`auto`){if(e(n)||n!==t&&e(t))return!0;break}if(/auto|scroll/.test(r.overflowY)&&n.scrollHeight>n.clientHeight)break}}return!1}function Tr(e){return e.edge===`bottom`?{edge:`bottom`,at:e.at<50?0:100}:e}function Er(e,t){let n=br(),i=Cr(),a=()=>{Sr||=Cr()!==i;let t=xr;if(xr=wr(),t&&!xr&&Sr&&document.querySelector(`vitehub-pill`)?.hasAttribute(`collapsed`))try{localStorage.setItem(mr,`1`)}catch{}br()!==n&&(n=!n,e())},o=new MutationObserver(a);o.observe(document.documentElement,{attributes:!0,attributeFilter:[r]});let s,c=()=>{s??=setTimeout(()=>{s=void 0,a()},200)},l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.localName.startsWith(`vitehub-`)))&&c()});l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`class`,`style`]}),addEventListener(`scroll`,c,{capture:!0,passive:!0,signal:t}),addEventListener(`resize`,c,{signal:t}),addEventListener(`storage`,e=>{(e.key===null||e.key===hr)&&(i=Cr()),c()},{signal:t}),document.addEventListener(`pointerup`,c,{signal:t}),t.addEventListener(`abort`,()=>{o.disconnect(),l.disconnect(),clearTimeout(s)},{once:!0})}var Q={name:`vitehub-pill`,label:`ViteHub tools`,off:pr,collapsed:mr,dock:hr};function Dr(e,t,n,r,i){if(t.aborted)return;let a=document.createElement(e.off);a.setAttribute(`off`,``),a.setAttribute(`collapsed`,``),i&&a.setAttribute(`closing`,``),a.style.viewTransitionName=e.name;let o=kt(e.dock)??e.initialDock??{edge:`bottom`,at:50},s=()=>{let t=e===Q&&br()&&!a.hasAttribute(`dragging`)?Tr(o):o;a.setAttribute(`edge`,t.edge),a.style.setProperty(`--at`,String(t.at))};s();let c=new AbortController;t.addEventListener(`abort`,()=>{c.abort(),a.remove()},{once:!0,signal:c.signal}),e===Q&&Er(s,c.signal);let l=a.attachShadow({mode:`open`}),u=B(l,H);c.signal.addEventListener(`abort`,u,{once:!0});let d=document.createElement(`style`);d.textContent=`${wt}\n${fr}`;let f=document.createElement(`button`);if(f.type=`button`,f.title=`Turn on ${e.label}`,f.setAttribute(`aria-label`,f.title),f.append(Tt(`0 0 20 18`,_r,{})),l.append(d,f),document.documentElement.append(a),i){let e=i/U(a).height,t=A(e,(e,t)=>{let n=t===0&&e===1;P(f,{scale:n?null:e.toFixed(4)}),n&&a.removeAttribute(`closing`)},E.snappy);t.set(e),t.to(1,{preset:E.snappy})}let p=Lt({host:a,handle:f,dock:()=>o,shape:e=>{let t=e?a.offsetHeight:a.offsetWidth,n=U(a);return{size:t,lead:t/2,part:e?n.height:n.width,margin:2}},place:e=>{o=e,s()},drop:()=>{s();try{localStorage.setItem(e.dock,JSON.stringify(o))}catch{}},signal:c.signal});f.addEventListener(`click`,()=>{p()||(c.abort(),a.remove(),n())}),r&&f.focus({preventScroll:!0})}async function Or(e={}){return await jr(e,!1)}var kr=new AbortController;function Ar(){kr.abort(),kr=new AbortController}async function jr(r,i){let o=new URLSearchParams(location.search),c=typeof r.session==`function`?r.session:void 0,l=typeof r.session==`string`?r.session:e(import.meta.url);if(!c&&!t(location.search,document.cookie))return[];let{signal:u}=kr,d=r.pill??Q;d===Q&&(Sr=kt(hr)!==void 0,xr=wr());let f=r.load??(e=>import(e)),p;try{if(c)p=await c();else{let e=new URL(l,location.href);e.searchParams.set(`page`,location.pathname);let t=await fetch(e.origin===location.origin?`${e.pathname}${e.search}`:e.href,{credentials:`same-origin`,headers:{accept:`application/json`}});if(!t.ok)return[];p=n(await t.json())}}catch{return[]}if(u.aborted||p.tools.length===0||document.querySelector(`${d.name}, ${d.off}`))return[];let m=p.tools.find(e=>e.param&&o.has(e.param));if(o.has(`vitehub`)||m||r.open)yr(d.off,!1);else if(vr(d.off))return Dr(d,u,()=>{yr(d.off,!1),jr(r,!0)},!1),[];let h=r.open||o.get(`vitehub`)||m?.id,g=p.tools.some(e=>e.id===h),_=new AbortController,v=p.tools.map(()=>new AbortController);u.addEventListener(`abort`,()=>{for(let e of v)e.abort();_.abort()},{once:!0,signal:_.signal});let y=new Set,b=!1,x=()=>!b&&[...y].every(e=>e()),S=(e=!1)=>{if(!x())return;b=!0;let t=p.tools.filter(e=>O(e.id));for(let e of p.tools)D(e.id,!1);yr(d.off,!0);let n=new URL(location.href);(d===Q||p.tools.some(e=>e.id===n.searchParams.get(`vitehub`)))&&n.searchParams.delete(a);for(let e of p.tools)e.param&&n.searchParams.delete(e.param);n.href!==location.href&&history.replaceState(history.state,``,n);let i=U(w).height,o=It(w);for(let e of v)e.abort();o.then(()=>{_.abort(),Dr(d,u,()=>{yr(d.off,!1);for(let e of t)D(e.id,!0);jr(r,!0)},e,i&&!matchMedia(`(prefers-reduced-motion: reduce)`).matches?i:void 0)})},C=p.account,w=Ft({name:d.name,label:d.label,mark:Tt(`0 0 20 18`,_r,{fill:`currentColor`}),slots:[...p.tools.map(e=>e.id),...p.account?[gr]:[]],storage:{collapsed:d.collapsed,dock:d.dock},...d.initialDock?{initial:{dock:d.initialDock}}:{},exit:{label:`Turn off ${d.label}`,press:S,...C&&!C.guest?{menu:e=>Yt({account:C,button:e,turnOff:{label:`Turn off ${d.label}`,press:S},canExit:x,signal:_.signal})}:{}},onPlace:cr,...d===Q?{markOnly:{active:br,watch:Er,opened:i}}:{},signal:_.signal});if(_.signal.addEventListener(`abort`,B(w,{effects:[rt,nr]}),{once:!0}),p.account){let e=document.createElement(`vitehub-account`);e.slot=gr,w.append(e),Jt({account:p.account,bar:e,mark:_r,openConsole:()=>{let e=w.querySelector(`vitehub-tool[slot="console"]`);return e&&!e.hidden?()=>void te(`console`):void 0},signal:_.signal})}let T=new Map,E=e=>`vitehub-open:${r.pill?.name??l}:${e}`,D=(e,t)=>{try{sessionStorage.setItem(E(e),String(t))}catch{}},O=e=>{try{return sessionStorage.getItem(E(e))===`true`}catch{return!1}},ee=new Map,te=async(e,t)=>await ee.get(e)?.(t)??!1,k=(await Promise.all(p.tools.map(async(e,t)=>{let{signal:n}=v[t],r=document.createElement(`vitehub-tool`);r.slot=e.id,w.append(r);let i,a,o,c=()=>(o||(o=f(e.script),o.catch(()=>{o=void 0})),o),l=!1,u=()=>{let t=document.createElement(`vitehub-tool`);t.slot=e.id,r.replaceWith(t),r=t},d=()=>{let e=r.attachShadow({mode:`open`}),t=B(e,H);n.addEventListener(`abort`,t,{once:!0});let i=document.createElement(`style`);i.textContent=s,e.append(i,m)},p=(t,o=!0)=>n.aborted?Promise.resolve(!1):l?(i?.(t),Promise.resolve(!0)):a?a.then(e=>(e&&i?.(t),e)):(a=(async()=>{let s=new AbortController,f=()=>s.abort();n.addEventListener(`abort`,f,{once:!0});try{r.setAttribute(`aria-busy`,`true`);let a=dr(await c());if(en(a,`the script of a page tool default-exports a function (${e.script})`),n.aborted)return!1;m.remove(),r.shadowRoot?u():r.replaceChildren();let d=a({beforeExit:e=>{let t=()=>e();y.add(t),s.signal.addEventListener(`abort`,()=>y.delete(t),{once:!0})},tool:e,bar:r,signal:s.signal,open:o&&(e.lazy===!0||e.id===h||O(e.id)),exit:()=>S(),createWindow:t=>{let n=ur({...t,signal:s.signal,onHide:()=>{D(e.id,!1),w.hasAttribute(`collapsed`)&&w.shadowRoot.querySelector(`button.mark`).focus({preventScroll:!0}),t.onHide?.()}}),r={...n,show(){if(!s.signal.aborted){for(let[t,n]of T)t!==e.id&&n.hide();D(e.id,!0),n.show()}},destroy(){T.get(e.id)===r&&(T.delete(e.id),D(e.id,!1)),n.destroy()}};return T.set(e.id,r),r},openTool:te,createTab:()=>{let e=document.createElement(`vitehub-tab`);return e.slot=`tab`,e.setAttribute(`data-motion-appear`,`vitehub-pill`),w.append(e),s.signal.addEventListener(`abort`,()=>e.remove(),{once:!0}),e},onOpen:e=>{i=e}});return l=!0,t&&i?.(t),!r.shadowRoot&&!r.hasChildNodes()&&(r.hidden=!0),d instanceof Function&&(n.aborted?d():s.signal.addEventListener(`abort`,()=>d(),{once:!0})),!n.aborted}catch(t){return s.abort(),n.removeEventListener(`abort`,f),T.delete(e.id)&&D(e.id,!1),i=void 0,l=!1,console.error(`[vitehub] The page tool "${e.id}" did not start.`,t),u(),m.textContent=`Retry ${e.label}`,m.title=`The tool could not load. Try again.`,r.hidden=!1,d(),!1}finally{r.removeAttribute(`aria-busy`),a=void 0}})(),a),m=document.createElement(`button`);m.type=`button`,m.textContent=e.label,m.addEventListener(`click`,()=>void p());for(let e of[`pointerenter`,`pointerdown`,`focus`])m.addEventListener(e,()=>void c());return ee.set(e.id,p),e.lazy&&e.id!==h&&!O(e.id)?(d(),e):(await p(void 0,!g||e.id===h),n.aborted?void 0:e)}))).filter(e=>!!e);return k.length===0&&_.abort(),k}function Mr(e={}){let t=h(e),n=()=>encodeURIComponent(typeof e.page==`function`?e.page():e.page??location.pathname),r=e=>({method:`POST`,...e===void 0?{}:{body:JSON.stringify(e)}}),i=e=>encodeURIComponent(e),a=new Map;return{status:async()=>(await t(`/send/status?page=${n()}`)).data,startPairing:async()=>{let e=n(),i=(await t(`/send/start?page=${e}`,r())).data;return a.set(i.code,e),i},pollPairing:async e=>(await t(`/send/pair/${i(e)}`)).data,allow:async(e,i)=>{let o=a.get(e)??n(),s=(await t(`/send/allow?page=${o}`,r({code:e,selection:i}))).data;return s.status!==`changed`&&a.delete(e),s},cancel:async e=>{a.delete(e),await t(`/send/pair/${i(e)}`,{method:`DELETE`})},send:async()=>(await t(`/send?page=${n()}`,r())).data}}var Nr=`vitehub-comments-guest`,Pr=f(import.meta.url);function Fr(){return $?$.namespace:new URL(Pr,location.href).href}function Ir(){try{let e=JSON.parse(localStorage.getItem(Nr)??`null`);if(e&&typeof e==`object`&&`id`in e&&`name`in e&&typeof e.id==`string`&&typeof e.name==`string`)return{id:e.id,name:e.name}}catch{}}function Lr(e){let t={id:Ir()?.id??crypto.randomUUID(),name:e};return localStorage.setItem(Nr,JSON.stringify(t)),t}var Rr=h({route:Pr,guest:Ir});function zr(e){if(e instanceof c)return{code:e.code,why:e.message,...e.fix?{fix:e.fix}:{}};throw e}async function Br(e,t={}){try{return[void 0,(await Rr(e,t)).data]}catch(e){return[zr(e),void 0]}}var $;function Vr(e){$=e}var Hr=e=>({method:`POST`,body:JSON.stringify(e)}),Ur={session:e=>$?$.session(e):Br(`/session?page=${encodeURIComponent(e)}`),field:(e,t)=>Br(`/fields?page=${encodeURIComponent(t)}&field=${encodeURIComponent(e)}`),saveField:(e,t)=>Br(`/fields?page=${encodeURIComponent(t)}`,Hr(e))};function Wr(e){let t=t=>t.people.length&&e.onPeople(t.people),n=$?$.transport(t):m({base:Pr.slice(0,-p.length),guest:Ir,onAnswer:t}),r=t=>async(...n)=>{let r=await t(...n);return e.onChange(),r};return{...n,create:r(n.create),reply:r(n.reply),edit:r(n.edit),delete:r(n.delete),resolve:r(n.resolve),reopen:r(n.reopen)}}function Gr(e){return Mr({base:Pr.slice(0,-p.length),page:e})}var Kr=_({mountHostedComments:()=>Xr}),qr={tools:[{id:`comments`,label:`Comments`,icon:`i-lucide-message-square-text`,script:`comments`,param:`comment`}]};function Jr(){return Promise.reject(d(405))}function Yr(e,t){return{namespace:new URL(u(t.id),t.console).href,async session(n){try{let r=(await(await e).call(`session`,n)).value;return[void 0,t.repository?{...r,repository:t.repository}:r]}catch(e){return[zr(e),void 0]}},transport(t){let n=async(n,r)=>{let i=await(await e).call(n,r);return t({data:i.value,people:i.people}),i.value};return{list:e=>n(`list`,e),get:e=>n(`get`,e),create:({files:e,outbox:t,...r})=>n(`create`,r),reply:({files:e,outbox:t,...r})=>n(`reply`,r),resolve:e=>n(`resolve`,{threadId:e.threadId}),reopen:e=>n(`reopen`,{threadId:e.threadId}),edit:Jr,delete:Jr,users:async()=>[],upload:Jr,attachmentUrl:()=>``}}}}async function Xr(e,t){Ar(),Vr(Yr(e,t)),await Or({pill:{name:`vitehub-hosted-comments-pill`,label:`ViteHub Comments`,off:`vitehub-hosted-comments-off`,collapsed:`vitehub-hosted-comments-collapsed`,dock:`vitehub-hosted-comments-dock`,initialDock:{edge:`right`,at:85}},session:async()=>qr,load:()=>o(()=>import(`./overlay-DpS0P-nd.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)})}export{Fr as a,_ as c,Wr as i,Xr as mountHostedComments,Ur as n,Ir as o,Gr as r,Lr as s,Kr as t};
@@ -1,4 +0,0 @@
1
- import{n as e,t}from"./dist-yIZmvSaU.js";var n={why:({message:e})=>e===void 0?``:String(e)},r={RUNTIME_R0001:{...n,fix:"Pass `maxDepth` to `normalizeRuntimeDiagnosticError()` as an integer of 0 or more, or remove it to use the default."},RUNTIME_R0002:{...n,fix:"Pass `maxErrors` to `normalizeRuntimeDiagnosticError()` as an integer of 1 or more, or remove it to use the default."},RUNTIME_R0003:{...n,fix:"Pass `maxStringLength` to `normalizeRuntimeDiagnosticError()` as an integer of 64 or more, or remove it to use the default."},RUNTIME_R0004:{...n,fix:"Read the logs of the process that `vitehub drain` waited for to find why its drain failed, then fix that failure and run `vitehub drain` again."},RUNTIME_R0005:{...n,fix:"Read the logs of the process that the message names to find why it stopped, then start it again before you run `vitehub drain`."},RUNTIME_R0006:{...n,fix:"Pass `new ViteHubError()` a nonempty `code` and `message` string within the length limits, and plain JSON `details`."},RUNTIME_R0007:{...n,fix:"Give the execution authority a valid value for each of `credentials`, `environment`, `filesystem.access`, `filesystem.scope`, `isolation`, `network`, and `processes`."},RUNTIME_R0009:{...n,fix:"Set `intervalMs` of the process reconciler to a number of milliseconds from 1 to 2147483647."},RUNTIME_R0010:{...n,fix:"Give the process reconciler a `signal` other than `SIGKILL` or `SIGSTOP`, or set `signal: false`."},RUNTIME_R0011:{...n,fix:"Call `drain()` of the process reconciler after its callback returns, not from inside the callback."},RUNTIME_R0015:{...n,fix:"Pass the `Request` of a Fetchable handler, or the event of an H3 or Nitro route, to `getStandardContext()`."},RUNTIME_R0016:{...n,fix:"Return the body or a `Response` from the handler, in place of setting `~standard.res.body`."},RUNTIME_R0017:n,RUNTIME_R0018:n,RUNTIME_CONSOLE_PATH_INVALID:{why:({value:e})=>`${e} is not a Console path. Use a path that starts with one /, such as /agents/<agent>.`,fix:"Pass `hostedConsoleUrl()` a Console path that starts with one `/`, such as `/kv` or `/agents/<agent>/invocations/<id>`."},RUNTIME_CONSOLE_PROJECT_URL_INVALID:{why:({value:e})=>`${e} is not a project URL. Use the https:// origin of the app, with its base path if it has one.`,fix:"Pass `hostedConsoleUrl()` the `https://` origin of the app, or `http://localhost` in development, with its base path and without a user name or password."},RUNTIME_DURATION_INVALID:{why:({option:e,value:t})=>`${e?`\`${e}\``:`The value`} is ${t}, which is not a duration. A duration is a string with a number of 0 or more and a unit, such as "30s", "5m", or "1 day".`,fix:({suggestion:e,unit:t=`milliseconds`,value:n})=>e?`Write the time as a string with a unit: ${n} ${t} is ${e}.`:'Write a number of 0 or more and one unit: `ms`, `s`, `m`, `h`, `d`, or `w`, or a long name such as `minutes` or `days`. For example `"30s"`, `"5m"`, or `"1 day"`.'},RUNTIME_EXECUTION_BUDGET_AMOUNT_INVALID:{why:({counter:e})=>`[vitehub] Execution budget ${e} amount must be a finite non-negative number.`,fix:"Pass `consume()` and the `record*()` methods of the execution budget a finite number of 0 or more."},RUNTIME_EXECUTION_BUDGET_EXCEEDED:{why:({counter:e})=>`[vitehub] Execution budget exhausted for ${e}.`,fix:"Raise the `executionBudget` limit that `error.counter` names, such as `maxToolCalls`, `maxRetries`, `maxInputBytes`, or `maxOutputBytes`, or give the run less work."},RUNTIME_EXECUTION_BUDGET_LIMIT_INVALID:{why:()=>`[vitehub] Execution budget limits must be finite non-negative numbers.`,fix:"Set each limit of `executionBudget`, such as `maxToolCalls` or `maxOutputBytes`, to a finite number of 0 or more, or remove it."},RUNTIME_HIDDEN_ERROR:{why:()=>`The server failed. The error is not a ViteHub error, so its message and stack stay on the server.`,fix:"Read the server logs for the error. To send a code, a why, and a fix to the client, return a `ResultError` from `defineErrors()` and pass it to `toResponse()`."},RUNTIME_SERIALIZED_RESPONSE_INVALID:{why:()=>`Invalid serialized Response`,fix:"Pass `deserializeResponse()` the record that `serializeResponse()` returned, unchanged. Check it first with `isSerializedResponse()`."}},i=e({docsBase:`https://vitehub.dev/docs/runtime/diagnostics`,codes:r});function a(e){return e!==null&&Object(e)===e}var o=8,s=128,c=128,l=1024,u=16384,d=128,f=16384,ee=256,te=new WeakMap;function p(){throw i.RUNTIME_R0006({message:`[vitehub] ViteHubError requires a valid public error contract.`})}function ne(e){try{return Array.isArray(e)}catch{p()}}function m(e,t,n=!1){try{let r=Object.getOwnPropertyDescriptor(e,t);return r===void 0?void 0:((!(`value`in r)||n&&!r.enumerable)&&p(),r.value)}catch{p()}}function h(e,t,n,r){if(t.nodes+=1,t.nodes>l&&p(),e===void 0&&r)return;if(e===null||typeof e==`boolean`||typeof e==`string`&&e.length<=u||typeof e==`number`&&Number.isFinite(e))return e;(typeof e!=`object`||n>o||t.ancestors.has(e))&&p();let i,a;try{i=Object.getPrototypeOf(e),a=Reflect.ownKeys(e)}catch{p()}t.ancestors.add(e);try{if(ne(e)){let r=m(e,`length`);(!Number.isSafeInteger(r)||r<0||r>s||a.length!==r+1||!a.includes(`length`))&&p();let i=[];for(let o=0;o<r;o+=1){let r=String(o);a.includes(r)||p(),i.push(h(m(e,r,!0),t,n+1,!1))}return Object.freeze(i)}i!==Object.prototype&&i!==null&&p(),(a.length>s||a.some(e=>typeof e!=`string`))&&p();let r={};for(let i of a)(i.length===0||i.length>c)&&p(),Object.defineProperty(r,i,{enumerable:!0,value:h(m(e,i,!0),t,n+1,!0),writable:!0});return Object.freeze(r)}finally{t.ancestors.delete(e)}}function re(e){if(e!==void 0)return(typeof e!=`object`||!e||ne(e))&&p(),h(e,{ancestors:new Set,nodes:0},0,!1)}function ie(e,t,n){(typeof e!=`string`||e.length===0||e.length>d)&&p(),(typeof t!=`string`||t.length===0||t.length>f)&&p(),(typeof n!=`object`||!n||ne(n))&&p();let r=m(n,`cause`),i=re(m(n,`details`)),a=m(n,`requestId`);return a!==void 0&&(typeof a!=`string`||a.length===0||a.length>ee)&&p(),{cause:r,code:e,details:i,message:t,name:`ViteHubError`,requestId:a,shape:Object.freeze({code:e,...i===void 0?{}:{details:i},message:t,name:`ViteHubError`,...a===void 0?{}:{requestId:a}})}}var ae=class extends Error{code;details;requestId;constructor(e,t,n={}){let r=ie(e,t,n);super(r.message,r.cause===void 0?void 0:{cause:r.cause}),this.name=`ViteHubError`,this.code=r.code,this.details=r.details,this.requestId=r.requestId;let i=this.toJSON.bind(this);Object.defineProperties(this,{code:{configurable:!0,enumerable:!0,value:r.code,writable:!1},details:{configurable:!0,enumerable:!0,value:r.details,writable:!1},message:{configurable:!0,enumerable:!1,value:r.message,writable:!1},name:{configurable:!1,enumerable:!1,value:r.name,writable:!1},requestId:{configurable:!0,enumerable:!0,value:r.requestId,writable:!1},toJSON:{configurable:!1,enumerable:!1,value:i,writable:!1}}),te.set(this,r.shape)}toJSON(){let e=te.get(this);if(e)return e;let t=ie(m(this,`code`),m(this,`message`),{details:m(this,`details`),requestId:m(this,`requestId`)});return te.set(this,t.shape),t.shape}};function oe(e){if(!a(e))return!1;try{let t=Reflect.get(Error,`isError`);return typeof t==`function`?t(e)===!0:e instanceof Error||!(Symbol.toStringTag in e)&&Object.prototype.toString.call(e)===`[object Error]`}catch{return!1}}function se(e){if(!oe(e))return!1;try{let t=Reflect.get(e,`message`),n=Reflect.get(e,`code`),r=Reflect.get(e,`name`),i=Reflect.get(e,`why`),a=Reflect.get(e,`fix`),o=Reflect.get(e,`docs`),s=Reflect.get(e,`sources`);return typeof n==`string`&&n.length>0&&typeof r==`string`&&typeof t==`string`&&i===t&&(a===void 0||typeof a==`string`)&&(o===void 0||typeof o==`string`)&&(s===void 0||Array.isArray(s)&&s.every(e=>typeof e==`string`))&&typeof Reflect.get(e,`toJSON`)==`function`}catch{return!1}}var ce=Symbol.for(`vitehub.runtime.resultError`);function le(e){let n=t=>{let n=Object.getOwnPropertyDescriptor(e,t);return n?n.configurable===!0:Object.isExtensible(e)},r=n(`name`)&&n(`toJSON`)&&(Object.hasOwn(e,ce)||Object.isExtensible(e))?e:new t({code:e.code,why:e.why,fix:e.fix,docs:e.docs,cause:e.cause,data:e.data,sources:e.sources});if(r!==e){r.stack=e.stack;let t=Reflect.get(e,`status`);typeof t==`number`&&Object.defineProperty(r,"status",{configurable:!0,value:t})}return Object.defineProperty(r,"name",{configurable:!0,value:r.code,writable:!0}),Object.defineProperty(r,ce,{value:!0}),Object.defineProperty(r,"toJSON",{configurable:!0,value:()=>({code:r.code,docs:r.docs,fix:r.fix,name:r.name,why:r.why})}),r}function ue(t){let n=e({codes:t.codes,docsBase:t.docs}),r=new Set(Object.keys(t.codes)),i=Object.defineProperty({},"is",{value:e=>se(e)&&r.has(e.code)});for(let e of r){let r=n[e],a=t.codes[e]?.status;i[e]=Object.assign(e=>{let t=le(r(e));return a!==void 0&&Object.defineProperty(t,"status",{configurable:!0,enumerable:!1,value:a}),t},{is:t=>se(t)&&t.code===e})}return i}var de=ue({docs:`https://vitehub.dev/docs/realtime/diagnostics`,codes:{REALTIME_DISABLED:{why:({action:e})=>`Realtime is disabled, so \`${e}()\` cannot run.`,fix:"Set `enabled` to `true` on `useRealtimeTiptap()` before you call the method."},REALTIME_DISCONNECTED:{why:({action:e})=>`The realtime document disconnected or changed during \`${e}()\`.`,fix:"Call the method again after the new document connects. Read `synced` to know when it is ready."},REALTIME_INVALID_DOCUMENT:{why:({action:e})=>`The room body does not fit the editor schema, so \`${e}()\` did not write it. Writing it would lose content.`,fix:`Keep editing until the document fits the editor extensions of the Realtime Definition, then call the method again. The room keeps the edits.`},REALTIME_INVALID_RESPONSE:{why:({action:e})=>`The realtime server answered \`${e}()\` with a response that the client cannot use.`,fix:"Use the same `@vite-hub/realtime` version on the client and the server, and build again."},REALTIME_MISSING_DOCUMENT:{why:({action:e})=>`\`${e}()\` needs a document, and \`documentId\` is empty.`,fix:"Pass a document path to `useRealtimeTiptap(definition, documentId)` before you call the method."},REALTIME_READ_ONLY:{why:({action:e})=>`The room is read-only, so \`${e}()\` cannot write the document.`,fix:"Read `readOnlyReason` of `useRealtimeTiptap()` for the reason. Do not offer save or publish while it is set."},REALTIME_REQUEST_FAILED:{why:({action:e,message:t,status:n})=>`The realtime \`${e}()\` request failed${n===void 0?``:` with HTTP ${n}`}${t?`: ${t}`:`.`}`,fix:"Read `error.why` for the server message, `error.data.status` for the HTTP status, and `error.cause` for a network error. Retry when the server is available again.",data:({status:e})=>({status:e})},REALTIME_SOURCE_CHANGED:{why:({action:e})=>`The server refused \`${e}()\` because the stored document changed outside the room.`,fix:"Tell the person that the stored document changed. Use `onReset()` to detect a room reset and read unsaved edits from the event's `previous` document."},REALTIME_SYNC_PENDING:{why:({action:e})=>`The room did not receive every edit of this client in time, so \`${e}()\` did not run. The composable tried 20 times.`,fix:"Call the method again when `synced` is true. When it keeps failing, check that the WebSocket stays connected."},REALTIME_ROOM_ABORTED:{why:`The request to the room stopped because its signal aborted.`,fix:`Nothing to fix when the caller stopped on purpose, such as a cancelled Agent run. Call again to ask once more.`},REALTIME_ROOM_CROWDED:{why:({count:e})=>`${e} browsers are in the room, and a request goes to one browser only.`,fix:`Give each browser its own room, such as a random id for each tab, so that one browser answers.`},REALTIME_ROOM_ELSEWHERE:{why:`No browser in this instance is in the room. With Redis or Postgres, the browser can be connected to another instance, and requests reach only the browsers of the same instance.`,fix:`Route the browser and the caller to the same instance, such as with sticky sessions, or run one Node instance.`},REALTIME_ROOM_EMPTY:{why:`No browser is in the room. The page is closed, or it has not joined yet.`,fix:`Open the page again. The request waits a few seconds for a browser to join before it gives up.`},REALTIME_ROOM_REFUSED:{why:({reason:e})=>`The browser could not answer: ${e}`,fix:"Read the reason. Add `room.onRequest(handler)` on the page, and keep each answer under 1 MiB."},REALTIME_ROOM_REQUESTS_OFF:{why:({definition:e})=>`The Realtime Definition "${e}" does not take requests.`,fix:'Define it with `defineRealtime({ access: "public", document: false, requests: true })`.'},REALTIME_ROOM_TIMEOUT:{why:({timeout:e})=>`The browser did not answer in ${e/1e3} seconds.`,fix:"Make the page answer sooner, or pass a longer `timeout` to `requestRealtimeRoom()`."},REALTIME_AWARENESS_OWNERSHIP_CONFLICT:{why:`A realtime awareness client id belongs to another peer.`,fix:`Let each editor tab use its own Yjs awareness client. Do not reuse a client id on two connections.`},REALTIME_AWARENESS_TOO_LARGE:{why:`Realtime awareness state exceeds the 8 MiB room quota.`,fix:`Keep less data in awareness state. Store large values in the document or in Workspace.`},REALTIME_DOCUMENT_TOO_LARGE:{why:`The realtime document exceeds the 8 MiB room quota.`,fix:`Split the document into smaller documents, or keep large assets in Workspace or Blob.`},REALTIME_INVALID_AWARENESS:{why:`A realtime awareness update has a state that is not a plain object.`,fix:"Set awareness state to a plain object, for example `awareness.setLocalStateField('user', { name })`."},REALTIME_TOO_MANY_AWARENESS_CLIENTS:{why:`One realtime peer sent more than 1,024 awareness clients.`,fix:`Use one awareness client for each editor tab.`},REALTIME_ROOM_WRITE_CONFLICT:{why:`Realtime room record compare-and-set failed.`,fix:`Connect again. Another Realtime instance changed the room at the same time. If it keeps failing, check that every instance uses the same Realtime bus.`},REALTIME_WRITE_REJECTED:{why:({problem:e,readOnly:t})=>e===`missing-state`?`Realtime update depends on state this room does not have.`:e===`status`?`Realtime document status is written by the server.`:t??`This realtime connection is read-only.`,fix:"Write only through a writable connection, and do not change the `status` map, which the server writes. A client that misses room state connects again to sync it."},REALTIME_DOCUMENT_CONFLICT:{why:({problem:e})=>e??`The stored document changed since the realtime room loaded it.`,fix:"Realtime re-seeds the room from the stored document. Listen to `onReset()` to recover text that the room did not save."},REALTIME_BLOB_ETAG_MISSING:{why:({pathname:e})=>`The Blob store returned no \`httpEtag\` for ${e}, so \`blobDocument()\` cannot save the file only if it is unchanged.`,fix:"Pass a ViteHub Blob store, such as `blob` from `vite-hub/blob`, whose `head()` returns `httpEtag` on every driver. A store of your own must return `httpEtag` from `head()` and accept `ifMatch` in `put()`."},REALTIME_INVALID_PERSISTENCE:{why:({name:e,reason:t})=>t===`below-debounce`?"Realtime `persistence.maxWait` must be at least `persistence.debounce`.":`Realtime \`persistence.${e}\` must be a non-negative number of milliseconds.`,fix:"Set `persistence: { debounce: 2_000, maxWait: 10_000 }`, or remove the option to use these defaults."},REALTIME_MISSING_ACCESS:{why:`The Realtime definition sets no access rule, so it does not say who can read and write its rooms.`,fix:'Set `authorize: true` to require a signed-in user, set `authorize()` to decide each request, or set `access: "public"` to let anyone read and write.'},REALTIME_INVALID_ACCESS:{why:({reason:e})=>e===`auth`?"The Realtime definition sets `auth`. Realtime replaced it with `authorize: true`, and an `authorize()` callback now also runs for signed-out callers.":e===`public-with-rule`?'The Realtime definition sets `access: "public"` together with `authorize`, so its access rule is not clear.':e===`not-public`?'The Realtime definition sets `access` to a value other than "public".':e===`not-authorize`?"The Realtime definition sets `authorize` to a value that is not `true` or a function.":"The Realtime definition sets `origins()` with `authorize: true` and no `identify()`. Only the Auth trusted-origin policy can allow a different origin to use the ViteHub Auth session.",fix:({reason:e})=>e===`auth`?"Replace `auth: true` with `authorize: true`. With an `authorize()` callback, remove `auth` and return `false` from the callback when `user` is `null`.":e===`origins-without-identify`?"Remove `origins()`, or add `identify()` that reads a credential the page sends on purpose, such as a ticket in `params`.":e===`not-authorize`?"Set `authorize: true` to require a signed-in user, or set `authorize()` to a function that returns `true` to allow.":'Use `access: "public"` alone for open rooms. To limit access, remove `access` and set `authorize`.'},REALTIME_CHECKPOINT_UNSUPPORTED:{why:"The Realtime definition sets `history.checkpoint`, but its document adapter has no `checkpoint()` method, so `history.checkpoint()` could never run.",fix:"Add `checkpoint(context, { digest, message, user })` to the document adapter, use `document: { workspace }`, or remove `history`."},REALTIME_INVALID_USER:{why:"The realtime identity needs a user `id` that is a non-empty string of at most 256 characters.",fix:"Return a user with an `id` from the Auth session or from `authorize()`."},REALTIME_MISSING_DIGEST:{why:({operation:e})=>e===`save`?`Realtime saves need Workspace file digests, and the Workspace Store did not return one.`:`Realtime checkpoints need a stored document, and the save returned no digest.`,fix:"Use a Workspace Store that returns file digests, or return `digest` from the document adapter `save()`."},REALTIME_INVALID_POSTGRES_URL:{why:"REALTIME_POSTGRES_URL is set, and it is not a `postgres://` or `postgresql://` URL.",fix:`Set REALTIME_POSTGRES_URL to a Postgres URL, or remove it so that Realtime uses the connection of the Default Database.`},REALTIME_MISSING_BUS_CONNECTION:{why:({driver:e})=>e===`redis`?`Realtime driver "redis" shares rooms through Redis, and REDIS_URL is not set.`:`Realtime driver "postgres" shares rooms through Postgres, and the app has no Postgres Default Database and no REALTIME_POSTGRES_URL.`,fix:'Set REDIS_URL for Redis. For Postgres, define the Default Database with `dialect: "postgresql"`, or set REALTIME_POSTGRES_URL. Or set `realtime.driver` to "auto".'},REALTIME_ROOM_LOCK_TIMEOUT:{why:`Realtime waited 30 seconds for the save lock of a room, and another instance still holds it.`,fix:"Make the document adapter `save()` finish in less than 30 seconds. Realtime tries the save again."},REALTIME_DRIVER_CONFLICT:{why:({driver:e,host:t})=>e===`memory`?`Realtime driver "memory" is single-process only, and the ${t} host runs more than one process.`:e===`cloudflare`?`Realtime driver "cloudflare" does not work with the ${t} host.`:`Realtime driver "${e}" needs a Node.js server, and the ${t} host does not run one.`,fix:'Set `realtime.driver` to "cloudflare" with a Cloudflare host. With the Node host, use "auto", "postgres", "redis", or "memory".'},REALTIME_MISSING_DRIVER:{why:`Realtime production builds need one room driver, and ViteHub cannot select one for this deployment.`,fix:`Deploy with a Cloudflare host to use Durable Objects, or with the Node host to share rooms through Postgres or Redis.`},REALTIME_RENAMED_AUTHORITY_KEY:{why:({value:e})=>`\`realtime.authority\` is ${e}. ViteHub renamed this key to \`driver\`, and it does not read \`authority\`, so Realtime would not use the driver you chose.`,fix:({value:e})=>`Set \`realtime: { driver: ${e} }\`, or run \`npx @vite-hub/codemods driver-key\` to rename it in every config file.`}}}),g=Math.floor,fe=Math.abs,pe=(e,t)=>e<t?e:t,me=(e,t)=>e>t?e:t;Number.isNaN;var he=Math.pow,ge=e=>e===0?1/e<0:e<0,_e=2**53-1,ve=-(2**53-1),ye=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&g(e)===e);Number.isNaN,Number.parseInt;var be=()=>new Set,xe=e=>e[e.length-1],Se=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},_=Array.from,Ce=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},we=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Te=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ee=Array.isArray,De=String.fromCharCode;String.fromCodePoint,De(65535);var Oe=e=>e.toLowerCase(),ke=/^\s*/g,Ae=e=>e.replace(ke,``),je=/([A-Z])/g,Me=(e,t)=>Ae(e.replace(je,e=>`${t}${Oe(e)}`)),Ne=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},Pe=typeof TextEncoder<`u`?new TextEncoder:null,Fe=Pe?e=>Pe.encode(e):Ne,Ie=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Ie&&Ie.decode(new Uint8Array).length===1&&(Ie=null);var Le=(e,t)=>Te(t,()=>e).join(``),v=e=>Error(e),y=()=>{throw v(`Method unimplemented`)},b=()=>{throw v(`Unexpected case`)},Re=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},x=()=>new Re,ze=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},S=e=>{let t=new Uint8Array(ze(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},Be=(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(me(n,t)*2),e.cpos=0)},C=(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},Ve=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=g(t/128);C(e,127&t)},He=(e,t)=>{let n=ge(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=g(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=g(t/128)},Ue=new Uint8Array(3e4),We=Ue.length/3,T=Pe&&Pe.encodeInto?(e,t)=>{if(t.length<We){let n=Pe.encodeInto(t,Ue).written||0;w(e,n);for(let t=0;t<n;t++)C(e,Ue[t])}else E(e,Fe(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;w(e,r);for(let t=0;t<r;t++)C(e,n.codePointAt(t))},Ge=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=pe(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(me(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},E=(e,t)=>{w(e,t.byteLength),Ge(e,t)},Ke=(e,t)=>{Be(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},qe=(e,t)=>Ke(e,4).setFloat32(0,t,!1),Je=(e,t)=>Ke(e,8).setFloat64(0,t,!1),Ye=(e,t)=>Ke(e,8).setBigInt64(0,t,!1),Xe=new DataView(new ArrayBuffer(4)),Ze=e=>(Xe.setFloat32(0,e),Xe.getFloat32(0)===e),Qe=(e,t)=>{switch(typeof t){case`string`:C(e,119),T(e,t);break;case`number`:ye(t)&&fe(t)<=2147483647?(C(e,125),He(e,t)):Ze(t)?(C(e,124),qe(e,t)):(C(e,123),Je(e,t));break;case`bigint`:C(e,122),Ye(e,t);break;case`object`:if(t===null)C(e,126);else if(Ee(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)Qe(e,t[n])}else if(t instanceof Uint8Array)C(e,116),E(e,t);else{C(e,118);let n=Object.keys(t);w(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];T(e,i),Qe(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},$e=class extends Re{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},et=e=>{e.count>0&&(He(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},tt=class{constructor(){this.encoder=new Re,this.s=0,this.count=0}write(e){this.s===e?this.count++:(et(this),this.count=1,this.s=e)}toUint8Array(){return et(this),S(this.encoder)}},nt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);He(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},rt=class{constructor(){this.encoder=new Re,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(nt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return nt(this),S(this.encoder)}},it=class{constructor(){this.sarr=[],this.s=``,this.lensE=new tt}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 Re;return this.sarr.push(this.s),this.s=``,T(e,this.sarr.join(``)),Ge(e,this.lensE.toUint8Array()),S(e)}},at=v(`Unexpected end of array`),ot=v(`Integer out of Range`),st=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw at;return new Uint8Array(e.buffer,e.byteOffset+t,n)},ct=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw at;return new DataView(e.buffer,e.byteOffset+t,n)},lt=class{constructor(e){this.arr=e,this.pos=0}},D=e=>new lt(e),ut=e=>e.pos!==e.arr.length,dt=(e,t)=>{let n=st(e.arr,e.pos,t);return e.pos+=t,n},O=e=>dt(e,k(e)),ft=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>_e)throw ot}throw at},pt=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>_e)throw ot}throw at},A=Ie?e=>Ie.decode(O(e)):e=>{let t=k(e);if(t===0)return``;{let n=String.fromCodePoint(ft(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(ft(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))}},mt=(e,t)=>{let n=ct(e.arr,e.pos,t);return e.pos+=t,n},ht=[e=>void 0,e=>null,pt,e=>mt(e,4).getFloat32(0,!1),e=>mt(e,8).getFloat64(0,!1),e=>mt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,A,e=>{let t=k(e),n={};for(let r=0;r<t;r++){let t=A(e);n[t]=gt(e)}return n},e=>{let t=k(e),n=[];for(let r=0;r<t;r++)n.push(gt(e));return n},O],gt=e=>ht[127-ft(e)](e),_t=class extends lt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=ut(this)?k(this)+1:-1),this.count--,this.s}},vt=class extends lt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=pt(this);let e=ge(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}},yt=class extends lt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=pt(this),t=e&1;this.diff=g(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}},bt=class{constructor(e){this.decoder=new vt(e),this.str=A(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}};function xt(e){let t=e.slice(0,4096);return new ae(`WORKSPACE_PATH_INVALID`,`[vitehub] Workspace path escapes the workspace root: ${JSON.stringify(t)}.`,{details:{path:t}})}function St(e){let t=e.toLowerCase().split(`:`,1)[0];return{normalized:t.replace(/[ .]+$/,``),isTraversal:/^(?:\.(?: +[. ]*)?|\.\.(?: +[. ]*)?)$/.test(t)}}function Ct(e=``,t={}){let n=e.replace(/\\/g,`/`),r=n.replace(/^\/+/,``).replace(/\/+$/,``),i=r.split(`/`).filter(Boolean);if(!t.allowEmpty&&!r||n.startsWith(`/`)||/^[a-z]:/i.test(n)||n.includes(`\0`)||i.some((e,n)=>{let r=e.toLowerCase(),i=St(e),a=i.normalized===`.git`||/^git~\d+$/.test(i.normalized)||n===0&&i.normalized===`.vitehub`||n===0&&/^vitehu~\d+$/.test(i.normalized),o=(i.normalized===`.git`||n===0&&i.normalized===`.vitehub`)&&r===i.normalized;return i.isTraversal||a&&(!t.allowReserved||!o)}))throw xt(e);return r}var wt=`@workspace`,Tt=`ping`;function Et(e){try{let t=JSON.parse(A(e));if(!t||typeof t!=`object`||!(`epoch`in t)||!(`type`in t)||typeof t.epoch!=`string`||!t.epoch)return;if(t.type===`session`&&`access`in t&&(t.access===`read`||t.access===`write`))return t.access===`read`&&`reason`in t&&(t.reason===`access`||t.reason===`document`||t.reason===`version`)?{type:`session`,access:t.access,epoch:t.epoch,reason:t.reason}:{type:`session`,access:t.access,epoch:t.epoch};if(t.type===`reset`&&`reason`in t&&(t.reason===`source-changed`||t.reason===`stale`))return{type:`reset`,epoch:t.epoch,reason:t.reason}}catch{}}function Dt(e){if(typeof e!=`string`||e.length===0||e.length>4096||e.includes(`\0`)||e.startsWith(`/`)||e.endsWith(`/`)||e.includes(`\\`)||e.includes(`//`)||/^[a-z]:/i.test(e))return!1;try{return Ct(e)===e}catch{return!1}}function Ot(e){try{let t=JSON.parse(A(e));if((t.operation===`create`||t.operation===`delete`||t.operation===`update`)&&Dt(t.path))return{operation:t.operation,path:t.path};if(t.operation===`move`&&Dt(t.from)&&Dt(t.to))return{operation:t.operation,from:t.from,to:t.to}}catch{}}function kt(e){let t=x();return w(t,4),T(t,JSON.stringify(e)),S(t)}function At(e){let t=x();return w(t,6),T(t,JSON.stringify(e)),S(t)}function jt(e){try{let t=JSON.parse(A(e));if(t&&typeof t==`object`&&`kind`in t&&t.kind===`notice`)return{kind:`notice`,body:`body`in t?t.body:void 0};if(!t||typeof t!=`object`||!(`id`in t)||typeof t.id!=`string`||!t.id||t.id.length>128||!(`kind`in t))return;if(t.kind===`request`)return{kind:`request`,id:t.id,body:`body`in t?t.body:void 0};if(t.kind!==`answer`||!(`ok`in t))return;if(t.ok===!0)return{kind:`answer`,id:t.id,ok:!0,body:`body`in t?t.body:void 0};if(t.ok===!1&&`why`in t&&typeof t.why==`string`)return{kind:`answer`,id:t.id,ok:!1,why:t.why}}catch{}}function Mt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var j=Date.now;function Nt(e,t=typeof __VITEHUB_APP_BASE_URL__>`u`?`/`:__VITEHUB_APP_BASE_URL__){return t===`/`?e:`${t.replace(/\/+$/,``)}${e}`}var Pt=15e3;function Ft(e){let t;e.on(`status`,({status:n})=>{clearInterval(t),t=void 0;let r=e.ws;if(n!==`connected`||!r)return;let i=r.onmessage;r.onmessage=function(t){if(t.data!==`pong`)return i?.call(this,t);e.ws===r&&(e.wsLastMessageReceived=j())},t=setInterval(()=>{e.ws===r&&r.readyState===r.OPEN&&r.send(Tt)},Pt)})}var It=Object.freeze({body:`body`,fields:`fields`,status:`status`});function Lt(e){return typeof e==`string`?e:null}function Rt(e){let t=e.getMap(It.status),n=t.get(`issues`),r=t.get(`savedBy`),i={issues:Array.isArray(n)?n:[],savedBy:r&&!Array.isArray(r)&&r instanceof Object?r:null};return{digest:Lt(t.get(`digest`)),error:Lt(t.get(`error`)),issues:i.issues,savedAt:Lt(t.get(`savedAt`)),savedBy:i.savedBy}}var zt=[`#E11D48`,`#D97706`,`#059669`,`#0891B2`,`#2563EB`,`#7C3AED`,`#C026D3`];function Bt(e){try{return String(e)===e}catch{return!1}}function Vt(e){if(!Bt(e.id)||!e.id||e.id.length>256)throw de.REALTIME_INVALID_USER();let t=0;for(let n=0;n<e.id.length;n++)t=Math.imul(31,t)+e.id.charCodeAt(n)|0;let n=(Bt(e.name)&&e.name||Bt(e.email)&&e.email||`Anonymous`).slice(0,256),r={color:zt[Math.abs(t)%zt.length],id:e.id,name:n};return Bt(e.image)&&e.image&&e.image.length<=2048&&(r.image=e.image),r}function Ht(e){return Mt(e)?Bt(e.id)&&e.id.length>0&&e.id.length<=256&&Bt(e.name)&&e.name.length>0&&e.name.length<=256&&Bt(e.color)&&/^#[\da-f]{6}$/i.test(e.color)&&(e.image===void 0||Bt(e.image)&&e.image.length<=2048):!1}function Ut(e){let t=[];for(let[n,r]of e)if(Ht(r.user)){let{color:e,id:i,image:a,name:o}=r.user,s={color:e,id:i,name:o,clientId:n};a!==void 0&&(s.image=a),t.push(s)}return t}var M=()=>new Map,Wt=e=>{let t=M();return e.forEach((e,n)=>{t.set(n,e)}),t},N=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Gt=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Kt=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},qt=class{constructor(){this._observers=M()}on(e,t){return N(this._observers,e,be).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()}},Jt=class{constructor(){this._observers=M()}on(e,t){N(this._observers,e,be).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()}},Yt=Symbol(`Equality`),Xt=(e,t)=>e===t||!!e?.[Yt]?.(t)||!1,Zt=e=>typeof e==`object`,Qt=Object.assign,$t=Object.keys,en=(e,t)=>{for(let n in e)t(e[n],n)},tn=(e,t)=>{let n=[];for(let r in e)n.push(t(e[r],r));return n},nn=e=>$t(e).length,rn=e=>{for(let t in e)return!1;return!0},an=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},on=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),sn=(e,t)=>e===t||nn(e)===nn(t)&&an(e,(e,n)=>(e!==void 0||on(t,n))&&Xt(t[n],e)),cn=Object.freeze,ln=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&ln(e[t])}return cn(e)},un=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&un(e,t,n+1)}},dn=e=>e,fn=(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[Yt]!=null)return e[Yt](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)||!fn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(nn(e)!==nn(t))return!1;for(let n in e)if(!on(e,n)||!fn(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(!fn(e[n],t[n]))return!1;break;default:return!1}return!0},pn=(e,t)=>t.includes(e);crypto.subtle;var mn=crypto.getRandomValues.bind(crypto),hn=()=>mn(new Uint32Array(1))[0],gn=`10000000-1000-4000-8000-100000000000`,_n=()=>gn.replace(/[018]/g,e=>(e^hn()&15>>e/4).toString(16)),vn=e=>new Promise(e);Promise.all.bind(Promise);var yn=e=>e===void 0?null:e,bn=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},xn=!0;try{typeof window<`u`&&typeof localStorage<`u`&&localStorage&&(bn=localStorage,xn=!1)}catch{}var Sn=bn,Cn=e=>xn||addEventListener(`storage`,e),wn=e=>xn||removeEventListener(`storage`,e),P=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Tn=typeof window<`u`&&typeof document<`u`&&!P;typeof navigator<`u`&&/Mac/.test(navigator.platform);var F,En=[],Dn=()=>{if(F===void 0){if(P){F=M();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&F.set(t,``),t=r):t===null?En.push(r):(F.set(t,r),t=null)}t!==null&&F.set(t,``)}else typeof location==`object`?(F=M(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);F.set(`--${Me(t,`-`)}`,n),F.set(`-${Me(t,`-`)}`,n)}})):F=M()}return F},On=e=>Dn().has(e),kn=e=>yn(P?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Sn.getItem(e)),An=e=>On(`--`+e)||kn(e)!==null,jn=An(`production`),Mn=P&&pn({}.FORCE_COLOR,[`true`,`1`,`2`])||!On(`--no-colors`)&&!An(`no-color`)&&(!P||process.stdout.isTTY)&&(!P||On(`--color`)||kn(`COLORTERM`)!==null||(kn(`TERM`)||``).includes(`color`)),Nn=e=>new Uint8Array(e),Pn=e=>new Uint8Array(e),Fn=e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=De(e[n]);return btoa(t)},In=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Ln=e=>{let t=atob(e),n=Nn(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},Rn=e=>new Uint8Array(Buffer.from(e,`base64`)),zn=Tn?Fn:In,Bn=Tn?Ln:Rn,Vn=e=>{let t=Nn(e.byteLength);return t.set(e),t},Hn=class{constructor(e,t){this.left=e,this.right=t}},I=(e,t)=>new Hn(e,t),Un=e=>e.next()>=.5,Wn=(e,t,n)=>g(e.next()*(n+1-t)+t),Gn=(e,t,n)=>g(e.next()*(n+1-t)+t),Kn=(e,t,n)=>Gn(e,t,n),qn=e=>De(Kn(e,97,122)),Jn=(e,t=0,n=20)=>{let r=Kn(e,t,n),i=``;for(let t=0;t<r;t++)i+=qn(e);return i},Yn=(e,t)=>t[Kn(e,0,t.length-1)],Xn=Symbol(`0schema`),Zn=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(Le(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
2
- `)}},Qn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Yt]?Xt(e,t):Ee(e)?Ce(e,e=>we(t,t=>Qn(e,t))):Zt(e)?an(e,(e,n)=>Qn(e,t[n])):!1,L=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Qn(t,n)}equals(e){return this.constructor===e.constructor&&fn(this.shape,e.shape)}[Xn](){return!0}[Yt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){y()}get nullable(){return kr(this,Wr)}get optional(){return new sr(this)}cast(e){return Jr(e,this),e}expect(e){return Jr(e,this),e}},$n=class extends L{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}},R=(e,t=null)=>new $n(e,t);R($n);var er=class extends L{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}},z=e=>new er(e);R(er);var tr=class extends L{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}},nr=(...e)=>new tr(e),rr=R(tr),ir=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),ar=e=>{if(zr.check(e))return[ir(e)];if(rr.check(e))return e.shape.map(e=>e+``);if(Rr.check(e))return[`[+-]?\\d+.?\\d*`];if(Br.check(e))return[`.*`];if(Ar.check(e))return e.shape.map(ar).flat(1);b()};R(class extends L{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(ar).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 or=Symbol(`optional`),sr=class extends L{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[or](){return!0}},cr=R(sr),lr=class extends L{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new lr,R(lr);var ur=class e extends L{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):an(this.shape,(n,r)=>{let i=this._isPartial&&!on(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},dr=e=>new ur(e),fr=R(ur),pr=z(e=>e!=null&&(e.constructor===Object||e.constructor==null)),mr=class extends L{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&an(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)})}},hr=(e,t)=>new mr(e,t),gr=R(mr),_r=class extends L{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&an(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},vr=(...e)=>new _r(e);R(_r);var yr=class extends L{constructor(e){super(),this.shape=e.length===1?e[0]:new Or(e)}check(e,t){let n=Ee(e)&&Ce(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},br=(...e)=>new yr(e),xr=R(yr),Sr=z(e=>Ee(e)),Cr=class extends L{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}},wr=(e,t=null)=>new Cr(e,t);R(Cr);var Tr=wr(L),Er=R(class extends L{constructor(e){super(),this.len=e.length-1,this.args=vr(...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}}),Dr=z(e=>typeof e==`function`);R(class extends L{constructor(e){super(),this.shape=e}check(e,t){let n=Ce(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Or=class extends L{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=we(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},kr=(...e)=>e.findIndex(e=>Ar.check(e))>=0?kr(...e.map(e=>qr(e)).map(e=>Ar.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Or(e),Ar=R(Or),jr=()=>!0,Mr=z(jr),Nr=R(er,e=>e.shape===jr),Pr=z(e=>typeof e==`bigint`),Fr=z(e=>e===Pr),Ir=z(e=>typeof e==`symbol`);z(e=>e===Ir);var Lr=z(e=>typeof e==`number`),Rr=z(e=>e===Lr),zr=z(e=>typeof e==`string`),Br=z(e=>e===zr),Vr=z(e=>typeof e==`boolean`),Hr=z(e=>e===Vr),Ur=nr(void 0);R(tr,e=>e.shape.length===1&&e.shape[0]===void 0),nr(void 0);var Wr=nr(null),Gr=R(tr,e=>e.shape.length===1&&e.shape[0]===null);R(Uint8Array),R($n,e=>e.shape===Uint8Array);var Kr=kr(Lr,zr,Wr,Ur,Pr,Vr,Ir);(()=>{let e=br(Mr),t=hr(zr,Mr),n=kr(Lr,zr,Wr,Vr,e,t);return e.shape=n,t.shape.values=n,n})();var qr=e=>{if(Tr.check(e))return e;if(pr.check(e)){let t={};for(let n in e)t[n]=qr(e[n]);return dr(t)}if(Sr.check(e))return kr(...e.map(qr));if(Kr.check(e))return nr(e);if(Dr.check(e))return R(e);b()},Jr=jn?()=>{}:(e,t)=>{let n=new Zn;if(!t.check(e,n))throw v(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Yr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:qr(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 v(`Unhandled pattern`)}}},Xr=(e=>new Yr(e))(Mr).if(Rr,(e,t)=>Wn(t,ve,_e)).if(Br,(e,t)=>Jn(t)).if(Hr,(e,t)=>Un(t)).if(Fr,(e,t)=>BigInt(Wn(t,ve,_e))).if(Ar,(e,t)=>Zr(t,Yn(t,e.shape))).if(fr,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(cr.check(i)){if(Un(t))continue;i=i.shape}n[r]=Xr(i,t)}return n}).if(xr,(e,t)=>{let n=[],r=Gn(t,0,42);for(let i=0;i<r;i++)n.push(Zr(t,e.shape));return n}).if(rr,(e,t)=>Yn(t,e.shape)).if(Gr,(e,t)=>null).if(Er,(e,t)=>{let n=Zr(t,e.res);return()=>n}).if(Nr,(e,t)=>Zr(t,Yn(t,[Lr,zr,Wr,Ur,Pr,Vr,br(Lr),hr(kr(`a`,`b`,`c`),Lr)]))).if(gr,(e,t)=>{let n={},r=Wn(t,0,3);for(let i=0;i<r;i++){let r=Zr(t,e.shape.keys);n[r]=Zr(t,e.shape.values)}return n}).done(),Zr=(e,t)=>Xr(qr(t),e),Qr=typeof document<`u`?document:{};z(e=>e.nodeType===ri),typeof DOMParser<`u`&&new DOMParser,z(e=>e.nodeType===ei),z(e=>e.nodeType===ti);var $r=e=>Gt(e,(e,t)=>`${t}:${e};`).join(``),ei=Qr.ELEMENT_NODE,ti=Qr.TEXT_NODE;Qr.CDATA_SECTION_NODE,Qr.COMMENT_NODE;var ni=Qr.DOCUMENT_NODE;Qr.DOCUMENT_TYPE_NODE;var ri=Qr.DOCUMENT_FRAGMENT_NODE;z(e=>e.nodeType===ni);var B=Symbol,ii=B(),ai=B(),oi=B(),si=B(),ci=B(),li=B(),ui=B(),di=B(),fi=B(),pi=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};j();var mi={[ii]:I(`font-weight`,`bold`),[ai]:I(`font-weight`,`normal`),[oi]:I(`color`,`blue`),[ci]:I(`color`,`green`),[si]:I(`color`,`grey`),[li]:I(`color`,`red`),[ui]:I(`color`,`purple`),[di]:I(`color`,`orange`),[fi]:I(`color`,`black`)},hi=Mn?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=mi[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=$r(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}:pi,gi=(...e)=>{console.log(...hi(e)),vi.forEach(t=>t.print(e))},_i=(...e)=>{console.warn(...hi(e)),e.unshift(di),vi.forEach(t=>t.print(e))},vi=be(),yi=e=>({[Symbol.iterator](){return this},next:e}),bi=(e,t)=>yi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),xi=(e,t)=>yi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Si=class{constructor(e,t){this.clock=e,this.len=t}},Ci=class{constructor(){this.clients=new Map}},wi=(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])Ea(e,i,o.clock,o.len,n)}}),Ti=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=g((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},Ei=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Ti(n,t.clock)!==null},Di=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 Si(r.clock,me(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Oi=e=>{let t=new Ci;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++)Se(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Di(t),t},ki=(e,t,n,r)=>{N(e.clients,t,()=>[]).push(new Si(n,r))},Ai=()=>new Ci,ji=e=>{let t=Ai();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 Si(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Mi=(e,t)=>{w(e.restEncoder,t.clients.size),_(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),w(e.restEncoder,t);let r=n.length;w(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ni=e=>{let t=new Ci,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=N(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Si(e.readDsClock(),e.readDsLen()))}}return t},Pi=(e,t,n)=>{let r=new Ci,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=H(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&ki(r,i,s,a-s);let e=U(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,As(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,As(t,c,a-c.id.clock)),c.delete(t))}else ki(r,i,n,a-n)}}if(r.clients.size>0){let e=new Wi;return w(e.restEncoder,0),Mi(e,r),e.toUint8Array()}return null},Fi=hn,Ii=class e extends qt{constructor({guid:e=_n(),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=Fi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new ya,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=vn(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>vn(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&&G(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 G(this,e,t)}get(e,t=J){let n=N(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==J&&r!==t){if(r===J){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}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,Co)}getText(e=``){return this.get(e,Uo)}getMap(e=``){return this.get(e,Eo)}getXmlElement(e=``){return this.get(e,Jo)}getXmlFragment(e=``){return this.get(e,Ko)}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,G(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()}},Li=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}},Ri=class extends Li{readLeftID(){return V(k(this.restDecoder),k(this.restDecoder))}readRightID(){return V(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return ft(this.restDecoder)}readString(){return A(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return gt(this.restDecoder)}readBuf(){return Vn(O(this.restDecoder))}readJSON(){return JSON.parse(A(this.restDecoder))}readKey(){return A(this.restDecoder)}},zi=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}},Bi=class extends zi{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new yt(O(e)),this.clientDecoder=new vt(O(e)),this.leftClockDecoder=new yt(O(e)),this.rightClockDecoder=new yt(O(e)),this.infoDecoder=new _t(O(e),ft),this.stringDecoder=new bt(O(e)),this.parentInfoDecoder=new _t(O(e),ft),this.typeRefDecoder=new vt(O(e)),this.lenDecoder=new vt(O(e))}readLeftID(){return new pa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pa(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 gt(this.restDecoder)}readBuf(){return O(this.restDecoder)}readJSON(){return gt(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}}},Vi=class{constructor(){this.restEncoder=x()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}},Hi=class extends Vi{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){Ve(this.restEncoder,e)}writeString(e){T(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,+!!e)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){Qe(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){T(this.restEncoder,JSON.stringify(e))}writeKey(e){T(this.restEncoder,e)}},Ui=class{constructor(){this.restEncoder=x(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){e===0&&b(),w(this.restEncoder,e-1),this.dsCurrVal+=e}},Wi=class extends Ui{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new rt,this.clientEncoder=new tt,this.leftClockEncoder=new rt,this.rightClockEncoder=new rt,this.infoEncoder=new $e(Ve),this.stringEncoder=new it,this.parentInfoEncoder=new $e(Ve),this.typeRefEncoder=new tt,this.lenEncoder=new tt}toUint8Array(){let e=x();return w(e,0),E(e,this.keyClockEncoder.toUint8Array()),E(e,this.clientEncoder.toUint8Array()),E(e,this.leftClockEncoder.toUint8Array()),E(e,this.rightClockEncoder.toUint8Array()),E(e,S(this.infoEncoder)),E(e,this.stringEncoder.toUint8Array()),E(e,S(this.parentInfoEncoder)),E(e,this.typeRefEncoder.toUint8Array()),E(e,this.lenEncoder.toUint8Array()),Ge(e,S(this.restEncoder)),S(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){Qe(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){Qe(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)}},Gi=(e,t,n,r)=>{r=me(r,t[0].id.clock);let i=U(t,r);w(e.restEncoder,t.length-i),e.writeClient(n),w(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)},Ki=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{H(t,n)>e&&r.set(n,e)}),ba(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),w(e.restEncoder,r.size),_(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Gi(e,t.clients.get(n),n,r)})},qi=(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 X(V(a,o),t),o+=t;break}case 10:{let t=k(e.restDecoder);i[n]=new $(V(a,o),t),o+=t;break}default:{let s=!(r&192),c=new Q(V(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,js(e,r));i[n]=c,o+=c.length}}}}return n},Ji=(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 ya,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!==$){let i=N(d,u.id.client,()=>H(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,H(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 Wi;return Ki(e,s,new Map),w(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Yi=(e,t)=>Ki(e,t.doc.store,t.beforeState),Xi=(e,t,n,r=new Bi(e))=>G(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Ji(e,i,qi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<H(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=za([o.update,a.update])}}else i.pendingStructs=a;let s=Pi(r,e,i);if(i.pendingDs){let t=new Bi(D(i.pendingDs));k(t.restDecoder);let n=Pi(t,e,i);i.pendingDs=s&&n?za([s,n]):s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Zi(e.doc,t)}},n,!1),Zi=(e,t,n,r=Bi)=>{let i=D(t);Xi(i,e,n,new r(i))},Qi=(e,t,n)=>Zi(e,t,n,Ri),$i=(e,t,n=new Map)=>{Ki(e,t.store,n),Mi(e,ji(t.store))},ea=(e,t=new Uint8Array([0]),n=new Wi)=>{$i(n,e,ra(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Ba(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Hi)return La(r.map((e,t)=>t===0?e:Wa(e)));if(n.constructor===Wi)return za(r)}return r[0]},ta=(e,t)=>ea(e,t,new Hi),na=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},ra=e=>na(new Li(D(e))),ia=(e,t)=>(w(e.restEncoder,t.size),_(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{w(e.restEncoder,t),w(e.restEncoder,n)}),e),aa=(e,t)=>ia(e,ba(t.store)),oa=(e,t=new Ui)=>(e instanceof Map?ia(t,e):aa(t,e),t.toUint8Array()),sa=e=>oa(e,new Vi),ca=class{constructor(){this.l=[]}},la=()=>new ca,ua=(e,t)=>e.l.push(t),da=(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.`)},fa=(e,t,n)=>un(e.l,[t,n]),pa=class{constructor(e,t){this.client=e,this.clock=t}},ma=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,V=(e,t)=>new pa(e,t),ha=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw b()},ga=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new ga(e,t))(Ai(),new Map);var _a=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Ei(t.ds,e.id),va=(e,t)=>{let n=N(e.meta,va,be),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<H(r,n)&&W(e,V(n,t))}),wi(e,t.ds,e=>{}),n.add(t))},ya=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},ba=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},H=(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},xa=(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 b()}n.push(t)},U=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=g(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=g((n+r)/2)}throw b()},Sa=(e,t)=>{let n=e.clients.get(t.client);return n[U(n,t.clock)]},Ca=(e,t,n)=>{let r=U(t,n),i=t[r];return i.id.clock<n&&i instanceof Q?(t.splice(r+1,0,As(e,i,n-i.id.clock)),r+1):r},W=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Ca(e,n,t.clock)]},wa=(e,t,n)=>{let r=t.clients.get(n.client),i=U(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==X&&r.splice(i+1,0,As(e,a,n.clock-a.id.clock+1)),a},Ta=(e,t,n)=>{let r=e.clients.get(t.id.client);r[U(r,t.id.clock)]=n},Ea=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Ca(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Ca(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Da=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Ci,this.beforeState=ba(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}},Oa=(e,t)=>t.deleteSet.clients.size===0&&!Kt(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Di(t.deleteSet),Yi(e,t),Mi(e,t.deleteSet),!0),ka=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&N(e.changed,t,be).add(n)},Aa=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0&&r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n);n=r,r=e[--i-1])n instanceof Q&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);let a=t-i;return a&&e.splice(t+1-a,a),a},ja=(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=U(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 Q&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ma=(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=pe(r.length-1,1+U(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+Aa(r,e)}})},Na=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Di(a),n.afterState=ba(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)&&e.push(()=>{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),fa(r._dEH,t,n)})}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Bo(n)})}),un(e,[])}finally{r.gc&&ja(a,i,r.gcFilter),Ma(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=me(U(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Aa(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=U(r,n);a+1<r.length&&Aa(r,a+1)>1||a>0&&Aa(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(gi(di,ii,`[yjs] `,ai,li,`Changed the client-id because another client seems to be using it.`),r.clientID=Fi()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Hi;Oa(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Wi;Oa(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])):Na(e,t+1)}}},G=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Da(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&&Na(i,0)}}return o};function*Pa(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 $(V(n,r),t),r+=t}else if(31&t){let i=!(t&192),a=new Q(V(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,js(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new X(V(n,r),t),r+=t}}}}var Fa=class{constructor(e,t){this.gen=Pa(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===$);return this.curr}},Ia=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},La=e=>za(e,Ri,Hi),Ra=(e,t)=>{if(e.constructor===X){let{client:n,clock:r}=e.id;return new X(V(n,r+t),e.length-t)}if(e.constructor===$){let{client:n,clock:r}=e.id;return new $(V(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Q(V(r,i+t),null,V(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},za=(e,t=Bi,n=Wi)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(D(e))),i=r.map(e=>new Fa(e,!0)),a=null,o=new n,s=new Ia(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===$?1:-1:n}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)K(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===$)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{K(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new $(V(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===$?a.struct.length-=t:n=Ra(n,t)),a.struct.mergeWith(n)||(K(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!==$;n=e.next())K(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(K(s,a.struct,a.offset),a=null),Ha(s),Mi(o,Oi(r.map(e=>Ni(e)))),o.toUint8Array()},Ba=(e,t,n=Bi,r=Wi)=>{let i=ra(t),a=new r,o=new Ia(a),s=new n(D(e)),c=new Fa(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===$)c.next();else if(e.id.clock+e.length>n)for(K(o,e,me(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)K(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 Ha(o),Mi(a,Ni(s)),a.toUint8Array()},Va=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:S(e.encoder.restEncoder)}),e.encoder.restEncoder=x(),e.written=0)},K=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Va(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Ha=e=>{Va(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];w(t,r.written),Ge(t,r.restEncoder)}},Ua=(e,t,n,r)=>{let i=new n(D(e)),a=new Fa(i,!1),o=new r,s=new Ia(o);for(let e=a.curr;e!==null;e=a.next())K(s,t(e),0);return Ha(s),Mi(o,Ni(i)),o.toUint8Array()},Wa=e=>Ua(e,dn,Bi,Hi),Ga=`You must not compute changes after the event-handler fired.`,Ka=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||=qa(this.currentTarget,this.target)}deletes(e){return Ei(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw v(Ga);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=xe(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=xe(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=xe(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 v(Ga);let t=this.target,n=be(),r=be(),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}},qa=(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},q=()=>{_i(`Invalid access: Add Yjs type to a document before reading data.`)},Ja=80,Ya=0,Xa=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Ya++}},Za=e=>{e.timestamp=Ya++},Qa=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Ya++},$a=(e,t,n)=>{if(e.length>=Ja){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Qa(r,t,n),r}{let r=new Xa(t,n);return e.push(r),r}},eo=(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)=>fe(t-e.index)<fe(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Za(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&&fe(n.index-i)<r.parent.length/Ja?(Qa(n,r,i),n):$a(e._searchMarker,r,i)},to=(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=me(t,i.index+n))}},no=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;N(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;fa(r._eH,n,t)},J=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=la(),this._dEH=la(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw y()}clone(){throw y()}_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){ua(this._eH,e)}observeDeep(e){ua(this._dEH,e)}unobserve(e){da(this._eH,e)}unobserveDeep(e){da(this._dEH,e)}toJSON(){}},ro=(e,t,n)=>{e.doc??q(),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},io=e=>{e.doc??q();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},ao=(e,t)=>{let n=0,r=e._start;for(e.doc??q();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}},oo=(e,t)=>{let n=[];return ao(e,(r,i)=>{n.push(t(r,i,e))}),n},so=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}}}},co=(e,t)=>{e.doc??q();let n=eo(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}},lo=(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 Q(V(o,H(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new gs(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 Q(V(o,H(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new rs(new Uint8Array(n))),i.integrate(e,0);break;case Ii:i=new Q(V(o,H(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new cs(n)),i.integrate(e,0);break;default:if(n instanceof J)i=new Q(V(o,H(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Os(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},uo=()=>v(`Length exceeded!`),fo=(e,t,n,r)=>{if(n>t._length)throw uo();if(n===0)return t._searchMarker&&to(t._searchMarker,n,r.length),lo(e,t,null,r);let i=n,a=eo(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&&W(e,V(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&to(t._searchMarker,i,r.length),lo(e,t,o,r)},po=(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 lo(e,t,r,n)},mo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=eo(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&&W(e,V(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&W(e,V(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw uo();t._searchMarker&&to(t._searchMarker,i,-a+r)},ho=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},go=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new gs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new gs([r]);break;case Uint8Array:s=new rs(r);break;case Ii:s=new cs(r);break;default:if(r instanceof J)s=new Os(r);else throw Error(`Unexpected content type`)}new Q(V(o,H(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},_o=(e,t)=>{e.doc??q();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},vo=e=>{let t={};return e.doc??q(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},yo=(e,t)=>{e.doc??q();let n=e._map.get(t);return n!==void 0&&!n.deleted},bo=(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&&_a(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},xo=e=>(e.doc??q(),bi(e._map.entries(),e=>!e[1].deleted)),So=class extends Ka{},Co=class e extends J{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 J?e.clone():e)),t}get length(){return this.doc??q(),this._length}_callObserver(e,t){super._callObserver(e,t),no(this,e,new So(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):G(this.doc,n=>{fo(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):G(this.doc,t=>{po(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):G(this.doc,n=>{mo(n,this,e,t)})}get(e){return co(this,e)}toArray(){return io(this)}slice(e=0,t=this.length){return ro(this,e,t)}toJSON(){return this.map(e=>e instanceof J?e.toJSON():e)}map(e){return oo(this,e)}forEach(e){ao(this,e)}[Symbol.iterator](){return so(this)}_write(e){e.writeTypeRef(xs)}},wo=e=>new Co,To=class extends Ka{constructor(e,t,n){super(e,t),this.keysChanged=n}},Eo=class e extends J{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?new Map: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 J?e.clone():e)}),t}_callObserver(e,t){no(this,e,new To(this,e,t))}toJSON(){this.doc??q();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof J?r.toJSON():r}}),e}get size(){return[...xo(this)].length}keys(){return xi(xo(this),e=>e[0])}values(){return xi(xo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return xi(xo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??q(),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):G(this.doc,t=>{ho(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):G(this.doc,n=>{go(n,this,e,t)}),t}get(e){return _o(this,e)}has(e){return yo(this,e)}clear(){this.doc===null?this._prelimContent.clear():G(this.doc,e=>{this.forEach(function(t,n,r){ho(e,r,n)})})}_write(e){e.writeTypeRef(Ss)}},Do=e=>new Eo,Y=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&sn(e,t),Oo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&b(),this.right.content.constructor){case Z:this.right.deleted||Mo(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}},ko=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case Z:t.right.deleted||Mo(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&W(e,V(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length)}t.left=t.right,t.right=t.right.right}return t},Ao=(e,t,n,r)=>{let i=new Map,a=r?eo(t,n):null;return a?ko(e,new Oo(a.p.left,a.p,a.index,i),n-a.index):ko(e,new Oo(null,t._start,0,i),n)},jo=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Z&&Y(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 Q(V(a,H(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new Z(o,r));l.integrate(e,0),n.right=l,n.forward()})},Mo=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},No=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===Z&&Y(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Po=(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(!Y(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Q(V(a,H(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new Z(s,c)),n.right.integrate(e,0),n.forward()}}return o},Fo=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;No(n,i);let s=Po(e,t,n,i),c=r.constructor===String?new vs(r):r instanceof J?new Os(r):new us(r),{left:l,right:u,index:d}=n;t._searchMarker&&to(t._searchMarker,n.index,c.getLength()),u=new Q(V(o,H(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(),jo(e,t,n,s)},Io=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;No(n,i);let s=Po(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===Z));){if(!n.right.deleted)switch(n.right.content.constructor){case Z:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Y(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&&W(e,V(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
3
- `;n.right=new Q(V(o,H(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new vs(i)),n.right.integrate(e,0),n.forward()}jo(e,t,n,s)},Lo=(e,t,n,r,i)=>{let a=t,o=M();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Z){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 Z:{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&&Mo(i,n);break}}}t=t.right}return s},Ro=(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===Z){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},zo=e=>{let t=0;return G(e.doc,n=>{let r=e._start,i=e._start,a=M(),o=Wt(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Z:Mo(o,i.content);break;default:t+=Lo(n,r,i,a,o),a=Wt(o),r=i}i=i.right}}),t},Bo=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&&Ea(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Z&&e.constructor!==X&&t.add(e.parent)})}G(n,n=>{wi(e,e.deleteSet,e=>{if(e instanceof X||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Z?t.add(r):Ro(n,e)});for(let e of t)zo(e)})},Vo=(e,t,n)=>{let r=n,i=Wt(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Os:case us:case vs:n<t.right.length&&W(e,V(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Lo(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&to(o._searchMarker,t.index,-r+n),t},Ho=class extends Ka{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(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];G(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},rn(o)||(e.attributes=Qt({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Os:case us: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 vs: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 Z:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Y(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Y(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;Y(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Y(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Mo(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}},Uo=class e extends J{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??q(),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 Ho(this,e,t);no(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??q();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===vs&&(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)):G(this.doc,n=>{let r=new Oo(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
- `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Fo(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Vo(n,r,a.delete):Io(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??q();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(_a(s,e)||t!==void 0&&_a(s,t))switch(s.content.constructor){case vs:{let r=i.get(`ychange`);e!==void 0&&!_a(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&&!_a(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 Os:case us:{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 Z:_a(s,e)&&(c(),Mo(i,s.content))}s=s.right}c()};return e||t?G(a,n=>{e&&va(n,e),t&&va(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)):G(r,r=>{let i=Ao(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Fo(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):G(r,r=>{let i=Ao(r,this,e,!n);Fo(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)):G(n,n=>{Vo(n,Ao(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)):G(r,r=>{let i=Ao(r,this,e,!1);i.right!==null&&Io(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):G(this.doc,t=>{ho(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):G(this.doc,n=>{go(n,this,e,t)})}getAttribute(e){return _o(this,e)}getAttributes(){return vo(this)}_write(e){e.writeTypeRef(Cs)}},Wo=e=>new Uo,Go=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??q()}[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===Jo||t.constructor===Ko)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}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})}},Ko=class e extends J{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 J?e.clone():e)),t}get length(){return this.doc??q(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Go(this,e)}querySelector(e){e=e.toUpperCase();let t=new Go(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),_(new Go(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){no(this,e,new Xo(this,t,e))}toString(){return oo(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),ao(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):G(this.doc,n=>{fo(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)G(this.doc,n=>{let r=e&&e instanceof J?e._item:e;lo(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 v(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):G(this.doc,n=>{mo(n,this,e,t)})}toArray(){return io(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return co(this,e)}slice(e=0,t=this.length){return ro(this,e,t)}forEach(e){ao(this,e)}_write(e){e.writeTypeRef(Ts)}},qo=e=>new Ko,Jo=class e extends Ko{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 en(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof J?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):G(this.doc,t=>{ho(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):G(this.doc,n=>{go(n,this,e,t)})}getAttribute(e){return _o(this,e)}hasAttribute(e){return yo(this,e)}getAttributes(e){return e?bo(this,e):vo(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 ao(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(ws),e.writeKey(this.nodeName)}},Yo=e=>new Jo(e.readKey()),Xo=class extends Ka{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)})}},Zo=class e extends Eo{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(Es),e.writeKey(this.hookName)}},Qo=e=>new Zo(e.readKey()),$o=class e extends Uo{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(Ds)}},es=e=>new $o,ts=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw y()}mergeWith(e){return!1}write(e,t,n){throw y()}integrate(e,t){throw y()}},ns=0,X=class extends ts{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),xa(e.doc.store,this)}write(e,t){e.writeInfo(ns),e.writeLen(this.length-t)}getMissing(e,t){return null}},rs=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 y()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},is=e=>new rs(e.readBuf()),as=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){ki(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}},os=e=>new as(e.readLen()),ss=(e,t)=>new Ii({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),cs=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(ss(this.doc.guid,this.opts))}splice(e){throw y()}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}},ls=e=>new cs(ss(e.readString(),e.readAny())),us=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 y()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},ds=e=>new us(e.readJSON()),Z=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 y()}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}},fs=e=>new Z(e.readKey(),e.readJSON()),ps=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}},ms=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 ps(n)},hs=kn(`node_env`)===`development`,gs=class e{constructor(e){this.arr=e,hs&&ln(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}},_s=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new gs(n)},vs=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}},ys=e=>new vs(e.readString()),bs=[wo,Do,Wo,Yo,qo,Qo,es],xs=0,Ss=1,Cs=2,ws=3,Ts=4,Es=5,Ds=6,Os=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 y()}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}},ks=e=>new Os(bs[e.readTypeRef()](e)),As=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Q(V(r,i+n),t,V(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=V(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},Q=class e extends ts{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>=H(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=H(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pa&&this.id.client!==this.parent.client&&this.parent.clock>=H(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=wa(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=W(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===X||this.right&&this.right.constructor===X)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===pa){let e=Sa(n,this.parent);this.parent=e.constructor===X?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wa(e,e.doc.store,V(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),ma(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ma(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Sa(e.doc.store,n.origin)))r.has(Sa(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,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),xa(e.doc.store,this),this.content.integrate(e,this),ka(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new X(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:V(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ma(e.origin,this.lastId)&&this.right===e&&ma(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(),ki(e.deleteSet,this.id.client,this.id.clock,this.length),ka(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw b();this.content.gc(e),t?Ta(e,this,new X(this.id,this.length)):this.content=new as(this.length)}write(e,t){let n=t>0?V(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=ha(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===pa?(e.writeParentInfo(!1),e.writeLeftID(t)):b();i!==null&&e.writeString(i)}this.content.write(e,t)}},js=(e,t)=>Ms[t&31](e),Ms=[()=>{b()},os,ms,is,ys,ds,fs,ks,_s,ls,()=>{b()}],Ns=10,$=class extends ts{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){b()}write(e,t){e.writeInfo(Ns),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Ps=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Fs=`__ $YJS$ __`;Ps[Fs]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Ps[Fs]=!0;var Is=3e4,Ls=class extends Jt{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=j();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Rs(this,t,`timeout`)},g(Is/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:j()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),fn(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}},Rs=(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:j()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},zs=(e,t,n=e.states)=>{let r=t.length,i=x();w(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;w(i,r),w(i,s),T(i,JSON.stringify(o))}return S(i)},Bs=(e,t,n)=>{let r=D(t),i=j(),a=[],o=[],s=[],c=[],l=k(r);for(let t=0;t<l;t++){let t=k(r),n=k(r),l=JSON.parse(A(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&&(fn(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])},Vs=new Map,Hs=class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:Bn(t.newValue||``)}),Cn(this._onChange)}postMessage(e){Sn.setItem(this.room,zn(Pn(e)))}close(){wn(this._onChange)}},Us=typeof BroadcastChannel>`u`?Hs:BroadcastChannel,Ws=e=>N(Vs,e,()=>{let t=be(),n=new Us(e);return n.onmessage=e=>t.forEach(t=>t(e.data,`broadcastchannel`)),{bc:n,subs:t}}),Gs=(e,t)=>(Ws(e).subs.add(t),t),Ks=(e,t)=>{let n=Ws(e),r=n.subs.delete(t);return r&&n.subs.size===0&&(n.bc.close(),Vs.delete(e)),r},qs=(e,t,n=null)=>{let r=Ws(e);r.bc.postMessage(t),r.subs.forEach(e=>e(t,n))},Js=(e,t)=>{w(e,0),E(e,sa(t))},Ys=(e,t,n)=>{w(e,1),E(e,ta(t,n))},Xs=(e,t,n)=>Ys(t,n,O(e)),Zs=(e,t,n,r)=>{try{Qi(t,O(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Qs=(e,t)=>{w(e,2),E(e,t)},$s=Zs,ec=(e,t,n,r,i)=>{let a=k(e);switch(a){case 0:Xs(e,t,n);break;case 1:Zs(e,n,r,i);break;case 2:$s(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},tc=(e,t,n)=>{k(e)===0&&n(t,A(e))},nc=e=>tn(e,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join(`&`),rc=[];rc[0]=(e,t,n,r,i)=>{w(e,0);let a=ec(t,e,n.doc,n);r&&a===1&&!n.synced&&(n.synced=!0)},rc[3]=(e,t,n,r,i)=>{w(e,1),E(e,zs(n.awareness,Array.from(n.awareness.getStates().keys())))},rc[1]=(e,t,n,r,i)=>{Bs(n.awareness,O(t),n)},rc[2]=(e,t,n,r,i)=>{tc(t,n.doc,(e,t)=>ac(n,t))};var ic=3e4,ac=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),oc=(e,t,n)=>{let r=D(t),i=x(),a=k(r),o=e.messageHandlers[a];return o?o(i,r,e,n,a):console.error(`Unable to compute message`),i},sc=e=>!(e.code>=4400&&e.code<4500),cc=(e,t,n)=>{if(t!==null&&t===e.ws){e.emit(`connection-close`,[n,e]),e.ws=null,t.onmessage=null,t.onopen=null,t.onclose=null,t.onerror=()=>{},t.close(),e.wsconnecting=!1,e.wsconnected&&(e.wsconnected=!1,e.synced=!1,Rs(e.awareness,Array.from(e.awareness.getStates().keys()).filter(t=>t!==e.doc.clientID),e),e.emit(`status`,[{status:`disconnected`}])),e.wsUnsuccessfulReconnects++;let r=null;n!=null&&!e.shouldReconnect(n,e)&&(e.shouldConnect=!1,r={code:n.code,reason:n.reason}),setTimeout(lc,pe(he(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e),r!==null&&e.emit(`closed`,[r,e])}},lc=e=>{if(e.shouldConnect&&e.ws===null){let t=new e._WS(e.url,e.protocols);t.binaryType=`arraybuffer`,e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{if(e.ws!==t)return;e.wsLastMessageReceived=j();let r=oc(e,new Uint8Array(n.data),!0);ze(r)>1&&t.send(S(r))},t.onerror=n=>{e.ws===t&&e.emit(`connection-error`,[n,e])},t.onclose=n=>{cc(e,t,n)},t.onopen=()=>{if(e.ws!==t)return;e.wsLastMessageReceived=j(),e.wsconnecting=!1,e.wsconnected=!0,e.emit(`status`,[{status:`connected`}]);let n=x();if(w(n,0),Js(n,e.doc),t.send(S(n)),e.awareness.getLocalState()!==null){let n=x();w(n,1),E(n,zs(e.awareness,[e.doc.clientID])),t.send(S(n))}},e.emit(`status`,[{status:`connecting`}])}},uc=(e,t)=>{let n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&qs(e.bcChannel,t,e)},dc=class extends qt{constructor(e,t,n,{connect:r=!0,awareness:i=new Ls(n),params:a={},protocols:o=[],WebSocketPolyfill:s=WebSocket,resyncInterval:c=-1,maxBackoffTime:l=2500,disableBc:u=!1,shouldReconnect:d=sc}={}){for(super();e[e.length-1]===`/`;)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+`/`+t,this.maxBackoffTime=l,this.shouldReconnect=d,this.params=a,this.protocols=o,this.roomname=t,this.doc=n,this._WS=s,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=rc.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let e=x();w(e,0),Js(e,n),this.ws.send(S(e))}},c)),this._bcSubscriber=(e,t)=>{if(t!==this){let t=oc(this,new Uint8Array(e),!1);ze(t)>1&&qs(this.bcChannel,S(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){let t=x();w(t,0),Qs(t,e),uc(this,S(t))}},this.doc.on(`update`,this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{let a=e.concat(t).concat(n),o=x();w(o,1),E(o,zs(i,a)),uc(this,S(o))},this._exitHandler=()=>{Rs(this.awareness,[n.clientID],`app closed`)},P&&typeof process<`u`&&process.on(`exit`,this._exitHandler),i.on(`update`,this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&ic<j()-this.wsLastMessageReceived&&cc(this,this.ws,null)},ic/10),r&&this.connect()}get url(){let e=nc(this.params);return this.serverUrl+`/`+this.roomname+(e.length===0?``:`?`+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,e&&(this.wsUnsuccessfulReconnects=0),this.emit(`synced`,[e]),this.emit(`sync`,[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),P&&typeof process<`u`&&process.off(`exit`,this._exitHandler),this.awareness.off(`update`,this._awarenessUpdateHandler),this.doc.off(`update`,this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||=(Gs(this.bcChannel,this._bcSubscriber),!0);let e=x();w(e,0),Js(e,this.doc),qs(this.bcChannel,S(e),this);let t=x();w(t,0),Ys(t,this.doc),qs(this.bcChannel,S(t),this);let n=x();w(n,3),qs(this.bcChannel,S(n),this);let r=x();w(r,1),E(r,zs(this.awareness,[this.doc.clientID])),qs(this.bcChannel,S(r),this)}disconnectBc(){let e=x();w(e,1),E(e,zs(this.awareness,[this.doc.clientID],new Map)),uc(this,S(e)),this.bcconnected&&=(Ks(this.bcChannel,this._bcSubscriber),!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&cc(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(lc(this),this.connectBc())}},fc=1047552;function pc(e,t,n={}){let r=new Set,i=new Set,a=new Set,o=[],s,c=`connecting`,l=!1,u=!1,d,f,ee=()=>{for(let e of r)e()},te=()=>{let t=n.origin?new URL(n.origin):window.location;return`${t.protocol===`https:`?`wss:`:`ws:`}//${t.host}${Nt(`/_vitehub/realtime/${encodeURIComponent(e)}`,n.baseURL)}`},p=t.split(`/`).map(encodeURIComponent).join(`/`),ne={};function m(){l=!1,d=new Ii,f=new dc(te(),p,d,{disableBc:!0,params:{...n.params,clientId:String(d.clientID)}});let e=f;Ft(e),e.messageHandlers[5]=(t,n)=>{let r=Et(n);r&&(r.type===`session`?e.params.epoch=r.epoch:(e.destroy(),d.destroy(),u||(m(),ee())))},e.messageHandlers[6]=(t,n)=>{let r=jt(n);if(r?.kind===`request`&&re(e,r.id,r.body),r?.kind===`notice`)for(let e of a)e(r.body)},e.awareness.off(`update`,e._awarenessUpdateHandler),e.awareness.on(`update`,({added:t,removed:n,updated:r})=>{let i=[...t,...r,...n].filter(t=>t===e.doc.clientID),a=e.ws;if(!i.length||!e.wsconnected||!a||a.readyState!==a.OPEN)return;let o=x();w(o,1),E(o,zs(e.awareness,i)),a.send(S(o))});let t=n.identity??{id:`guest:${d.clientID}`};e.awareness.setLocalState({...ne,user:Vt({...t,id:t.id||`guest:${d.clientID}`})}),e.awareness.on(`change`,ee),d.getMap(It.status).observe(ee),e.on(`sync`,t=>{f===e&&(l=t,ee())}),e.on(`status`,e=>{c=e.status,ee()})}m();let h;n.changes&&(h=new dc(te(),encodeURIComponent(wt),new Ii,{disableBc:!0,params:{...n.params,workspace:`events`}}),h.awareness.setLocalState(null),Ft(h),h.messageHandlers[4]=(e,t)=>{let n=Ot(t);if(n)for(let e of i)e(n)},h.on(`status`,e=>{e.status===`connected`&&ie()}));async function re(e,t,n){let r=e=>At({kind:`answer`,id:t,ok:!1,why:e}),i;try{i=s?At({kind:`answer`,id:t,ok:!0,body:await s(n)}):r(`This page does not answer requests.`),i.byteLength>fc&&(i=r(`The answer has ${i.byteLength} bytes, over the 1 MiB limit.`))}catch(e){i=r(e instanceof Error?e.message:String(e))}let a=e.ws;e.wsconnected&&a&&a.readyState===a.OPEN&&a.send(Uint8Array.from(i))}function ie(){let e=h?.ws;if(h?.wsconnected&&e&&e.readyState===e.OPEN)for(;o.length;)e.send(Uint8Array.from(kt(o.shift())))}return{get awareness(){return f.awareness},get clientId(){return d.clientID},people:()=>Ut(f.awareness.getStates()),states:()=>{let e=new Map(f.awareness.getStates());return e.delete(d.clientID),e},status:()=>c,saveStatus:()=>l?Rt(d):void 0,setLocal(e,t){if(t!==null){ne[e]=t,f.awareness.setLocalStateField(e,t);return}delete ne[e];let n=f.awareness.getLocalState();if(!n||!Object.hasOwn(n,e))return;let{[e]:r,...i}=n;f.awareness.setLocalState(i)},notify(e){h&&(o.push(e),ie())},onUpdate(e){return r.add(e),()=>r.delete(e)},onChange(e){return i.add(e),()=>i.delete(e)},onRequest(e){return s=e,()=>{s===e&&(s=void 0)}},onNotice(e){return a.add(e),()=>a.delete(e)},destroy(){u=!0,f.destroy(),d.destroy(),h?.destroy(),h?.doc.destroy(),r.clear(),i.clear(),a.clear(),s=void 0}}}export{pc as connectRealtimeRoom};