@zeniai/web-cockpit-ui 2.0.51-qa → 2.0.52-dev

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 (39) hide show
  1. package/dist/assets/{CreditAgentRoutes-Db6vjOXz.js → CreditAgentRoutes-CJeSEseA.js} +2 -2
  2. package/dist/assets/{Preview-MGVapU49.js → Preview-DdcA0Ffz.js} +1 -1
  3. package/dist/assets/{ScreenRoutes-BI8P5v1e.js → ScreenRoutes-D6wRFlV1.js} +3 -3
  4. package/dist/assets/SignInScreen-Dq8Dd1Gn.js +1 -0
  5. package/dist/assets/{analytics-Cy7O-pb_.js → analytics-DK4CSFmD.js} +1 -1
  6. package/dist/assets/{analyticsHelper-DfCbp4nE.js → analyticsHelper-BEREkRP-.js} +1 -1
  7. package/dist/assets/{core-W20WZYZ3.js → core-B5i2n7MF.js} +1 -1
  8. package/dist/assets/{dash.all.min-DDiDN_ew.js → dash.all.min-D2ueDDFi.js} +1 -1
  9. package/dist/assets/{empty-B4DT6yr2.js → empty-Db8SxLZy.js} +1 -1
  10. package/dist/assets/{empty-DCazWr_c.js → empty-R4KN4j1U.js} +1 -1
  11. package/dist/assets/{epic-CoqQH5yd.js → epic-Uw-Jl09V.js} +1 -1
  12. package/dist/assets/{index-BuBDZJTm.js → index-0tDtUqG0.js} +1 -1
  13. package/dist/assets/{index-C0BRdomq.js → index-C1ze42AS.js} +1 -1
  14. package/dist/assets/{index-DlZg3Jn2.js → index-CuYwVGwB.js} +1 -1
  15. package/dist/assets/{index-WIt8ZOyH.js → index-D4fVVbXY.js} +2 -2
  16. package/dist/assets/{index-C-8bRTtA.js → index-DjHKywCm.js} +6 -7
  17. package/dist/assets/{index-CbjBmx6V.js → index-Dw-M7CjK.js} +1 -1
  18. package/dist/assets/{index-CHLFpUKA.js → index-uiQm1GFe.js} +1 -1
  19. package/dist/assets/{lexical-DETwg-VK.js → lexical-CckmyaNY.js} +1 -1
  20. package/dist/assets/{liveblocks-DmmuZ0B6.js → liveblocks-DLTKco2q.js} +1 -1
  21. package/dist/assets/{lottie-5dcPRa0p.js → lottie-DDJKQtHL.js} +1 -1
  22. package/dist/assets/{mui-UT5zfWy3.js → mui-wyeu8Y40.js} +1 -1
  23. package/dist/assets/{react-i5QMBJhO.js → react-C0v44AWY.js} +1 -1
  24. package/dist/assets/{react-Br93EnuA.js → react-CAkdg2Z5.js} +1 -1
  25. package/dist/assets/{react-BYESoFDJ.js → react-CSwTITfT.js} +1 -1
  26. package/dist/assets/{react-Bo24Z6X7.js → react-Co90Z0nb.js} +1 -1
  27. package/dist/assets/{react-DQcgpeBm.js → react-DdZ8eg95.js} +1 -1
  28. package/dist/assets/{react-D3-6YSe3.js → react-Dx9RphQG.js} +1 -1
  29. package/dist/assets/{react-C8uO9Trs.js → react-PFuazbPx.js} +2 -2
  30. package/dist/assets/{react-CN3YA_96.js → react-cgjZcd5H.js} +1 -1
  31. package/dist/assets/{recharts-CKJ5Joxz.js → recharts-BSWlrs8I.js} +1 -1
  32. package/dist/assets/{sentry-D_VUUmSk.js → sentry-BMszMB7z.js} +1 -1
  33. package/dist/assets/{url-C3MMxB7N.js → url-83xns7qz.js} +1 -1
  34. package/dist/assets/{url-DYOvztbn.js → url-jSz-Fw7m.js} +1 -1
  35. package/dist/assets/{utils-Cg6yJIaV.js → utils-tJn-c0vI.js} +1 -1
  36. package/dist/assets/{zeni-epic-state-B8HUJfOC.js → zeni-epic-state-DcfBYZaW.js} +3 -3
  37. package/dist/index.html +1 -1
  38. package/package.json +2 -2
  39. package/dist/assets/SignInScreen-DNjpF0nK.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as $g,a as f,c as ai,g as Ug,b as me,R as Hg}from"./sentry-D_VUUmSk.js";import{r as Ls,R as Cd}from"./core-W20WZYZ3.js";import{t as Wg,d as zg}from"./recharts-CKJ5Joxz.js";(function(){try{var e=typeof window<"u"?window:typeof Wn<"u"?Wn:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f36bf39f-077f-4ded-90a7-83b1b0805469",e._sentryDebugIdIdentifier="sentry-dbid-f36bf39f-077f-4ded-90a7-83b1b0805469")}catch{}})();var Aa={exports:{}},Hr={};var bc;function Vg(){if(bc)return Hr;bc=1;var e=$g(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(i,u,c){var l,d={},m=null,g=null;c!==void 0&&(m=""+c),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(g=u.ref);for(l in u)r.call(u,l)&&!s.hasOwnProperty(l)&&(d[l]=u[l]);if(i&&i.defaultProps)for(l in u=i.defaultProps,u)d[l]===void 0&&(d[l]=u[l]);return{$$typeof:t,type:i,key:m,ref:g,props:d,_owner:o.current}}return Hr.Fragment=n,Hr.jsx=a,Hr.jsxs=a,Hr}var Ec;function Kg(){return Ec||(Ec=1,Aa.exports=Vg()),Aa.exports}var h=Kg(),qg="@liveblocks/react",Gg="2.23.0",Yg="esm";function OF(e){const[t,n]=f.useState(!1);return f.useEffect(()=>{n(!0)},[]),h.jsx(f.Suspense,{fallback:e.fallback,children:t?typeof e.children=="function"?e.children():e.children:e.fallback})}var Xg=Object.defineProperty,Zg=(e,t)=>{for(var n in t)Xg(e,n,{get:t[n],enumerable:!0})},Jg="@liveblocks/core",Yi="2.23.0",Qg="esm",$o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ai<"u"?ai:{},e0="https://liveblocks.io/docs/errors/dupes",t0=" ";function n0(e){console.error(e)}function Xi(e,t,n){const r=Symbol.for(e),o=`${t} (${n})`;if(!$o[r])$o[r]=o;else if($o[r]!==o){const s=[`Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See ${e0+t0}`,"","Conflicts:",`- ${e} ${$o[r]} (already loaded)`,`- ${e} ${o} (trying to load this now)`].join(`
1
+ import{r as $g,a as f,c as ai,g as Ug,b as me,R as Hg}from"./sentry-BMszMB7z.js";import{r as Ls,R as Cd}from"./core-B5i2n7MF.js";import{t as Wg,d as zg}from"./recharts-BSWlrs8I.js";(function(){try{var e=typeof window<"u"?window:typeof Wn<"u"?Wn:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f36bf39f-077f-4ded-90a7-83b1b0805469",e._sentryDebugIdIdentifier="sentry-dbid-f36bf39f-077f-4ded-90a7-83b1b0805469")}catch{}})();var Aa={exports:{}},Hr={};var bc;function Vg(){if(bc)return Hr;bc=1;var e=$g(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(i,u,c){var l,d={},m=null,g=null;c!==void 0&&(m=""+c),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(g=u.ref);for(l in u)r.call(u,l)&&!s.hasOwnProperty(l)&&(d[l]=u[l]);if(i&&i.defaultProps)for(l in u=i.defaultProps,u)d[l]===void 0&&(d[l]=u[l]);return{$$typeof:t,type:i,key:m,ref:g,props:d,_owner:o.current}}return Hr.Fragment=n,Hr.jsx=a,Hr.jsxs=a,Hr}var Ec;function Kg(){return Ec||(Ec=1,Aa.exports=Vg()),Aa.exports}var h=Kg(),qg="@liveblocks/react",Gg="2.23.0",Yg="esm";function OF(e){const[t,n]=f.useState(!1);return f.useEffect(()=>{n(!0)},[]),h.jsx(f.Suspense,{fallback:e.fallback,children:t?typeof e.children=="function"?e.children():e.children:e.fallback})}var Xg=Object.defineProperty,Zg=(e,t)=>{for(var n in t)Xg(e,n,{get:t[n],enumerable:!0})},Jg="@liveblocks/core",Yi="2.23.0",Qg="esm",$o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ai<"u"?ai:{},e0="https://liveblocks.io/docs/errors/dupes",t0=" ";function n0(e){console.error(e)}function Xi(e,t,n){const r=Symbol.for(e),o=`${t} (${n})`;if(!$o[r])$o[r]=o;else if($o[r]!==o){const s=[`Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See ${e0+t0}`,"","Conflicts:",`- ${e} ${$o[r]} (already loaded)`,`- ${e} ${o} (trying to load this now)`].join(`
2
2
  `);n0(s)}}function ii(e){const t=e.editedAt?new Date(e.editedAt):void 0,n=new Date(e.createdAt),r=e.reactions.map(o=>({...o,createdAt:new Date(o.createdAt)}));if(e.body)return{...e,reactions:r,createdAt:n,editedAt:t};{const o=new Date(e.deletedAt);return{...e,reactions:r,createdAt:n,editedAt:t,deletedAt:o}}}function fn(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.comments.map(o=>ii(o));return{...e,createdAt:t,updatedAt:n,comments:r}}function r0(e){return{...e,createdAt:new Date(e.createdAt)}}function In(e){const t=new Date(e.notifiedAt),n=e.readAt?new Date(e.readAt):null;if("activities"in e){const r=e.activities.map(o=>({...o,createdAt:new Date(o.createdAt)}));return{...e,notifiedAt:t,readAt:n,activities:r}}return{...e,notifiedAt:t,readAt:n}}function xa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function Oa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}var Cn={};Zg(Cn,{error:()=>Ao,errorWithTitle:()=>Dd,warn:()=>ft,warnWithTitle:()=>s0});var yd="background:#0e0d12;border-radius:9999px;color:#fff;padding:3px 7px;font-family:sans-serif;font-weight:600;",o0="font-weight:600";function bd(e){return typeof window>"u"?console[e]:(t,...n)=>console[e]("%cLiveblocks",yd,t,...n)}var ft=bd("warn"),Ao=bd("error");function Ed(e){return typeof window>"u"?console[e]:(t,n,...r)=>console[e](`%cLiveblocks%c ${t}`,yd,o0,n,...r)}var s0=Ed("warn"),Dd=Ed("error");function nn(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ui(e){return nn(e)&&typeof e.startsWith=="string"}function wt(e){throw new Error(e)}function Zi(e){return Object.entries(e)}function a0(e){return Object.keys(e)}function i0(e,t){return typeof t<"u"?Object.create(e,t):Object.create(e)}function $s(e){try{return JSON.parse(e)}catch{return}}function oo(e){return JSON.parse(JSON.stringify(e))}function u0(e){try{const t=e.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))}catch{return atob(e)}}function ci(e){return e.filter(t=>t!=null)}function xo(e){const t={...e};return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function c0(e){return new Promise(t=>setTimeout(t,e))}async function Dc(e,t,n){let r;const o=new Promise((s,a)=>{r=setTimeout(()=>{a(new Error(n))},t)});return Promise.race([e,o]).finally(()=>clearTimeout(r))}function wc(e){let t=null;return()=>(t===null&&(t=e().catch(n=>{throw setTimeout(()=>{t=null},5e3),n})),t)}var xr=class wd extends Error{response;details;constructor(t,n,r){super(t),this.name="HttpError",this.response=n,this.details=r}static async fromResponse(t){let n;try{n=await t.text()}catch{}const r=n?$s(n):void 0;let o;nn(r)&&(o=r);let s="";s||=typeof o?.message=="string"?o.message:"",s||=typeof o?.error=="string"?o.error:"",r===void 0&&(s||=n||""),s||=t.statusText;let a;try{a=new URL(t.url).pathname}catch{}s+=a!==void 0?` (got status ${t.status} from ${a})`:` (got status ${t.status})`;const i=o;return new wd(s,t,i)}get status(){return this.response.status}},l0=e=>e instanceof xr&&e.status>=400&&e.status<500;async function Zr(e,t,n,r=l0){const o=n.length>0?n[n.length-1]:0;let s=0;for(;;){s++;try{return await e()}catch(i){if(r(i))throw i;if(s>=t)throw new Error(`Failed after ${t} attempts: ${String(i)}`)}const a=n[s-1]??o;ft(`Attempt ${s} was unsuccessful. Retrying in ${a} milliseconds.`),await c0(a)}}function Ad(){let e,t;return[new Promise((r,o)=>{e=r,t=o}),e,t]}function xd(){const[e,t,n]=Ad();return{promise:e,resolve:t,reject:n}}function Ie(){const e=new Set;function t(a){return e.add(a),()=>e.delete(a)}function n(a){const i=t(u=>(i(),a(u)));return i}async function r(a){let i;return new Promise(u=>{i=t(c=>{(a===void 0||a(c))&&u(c)})}).finally(()=>i?.())}function o(a){let i=!1;for(const u of e)u(a),i=!0;return i}function s(){return e.size}return{notify:o,subscribe:t,subscribeOnce:n,count:s,waitUntil:r,[Symbol.dispose]:()=>{e.clear()},observable:{subscribe:t,subscribeOnce:n,waitUntil:r}}}function f0(){const e=Ie();let t=null;function n(){t=[]}function r(){if(t!==null){for(const s of t)e.notify(s);t=null}}function o(s){return t!==null?(t.push(s),!1):e.notify(s)}return{...e,notify:o,pause:n,unpause:r,[Symbol.dispose]:()=>{e[Symbol.dispose](),t!==null&&(t.length=0)}}}var En=e=>e,Bn=Symbol("kSinks"),gs=Symbol("kTrigger"),dr=null,_n=null;function ct(e){if(dr!==null){e();return}dr=new Set;try{e()}finally{for(const t of dr)t[gs]();dr=null}}function Ji(e){dr||wt("Expected to be in an active batch"),dr.add(e)}function Od(e,t){let n=!1;const r={...e};return Object.keys(t).forEach(o=>{const s=o,a=t[s];r[s]!==a&&(a===void 0?delete r[s]:r[s]=a,n=!0)}),n?r:e}var Qi=class{equals;#e;[Bn];constructor(e){this.equals=e??Object.is,this.#e=Ie(),this[Bn]=new Set,this.get=this.get.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeOnce=this.subscribeOnce.bind(this)}[Symbol.dispose](){this.#e[Symbol.dispose](),this.#e="(disposed)",this.equals="(disposed)"}get hasWatchers(){if(this.#e.count()>0)return!0;for(const e of this[Bn])if(e.hasWatchers)return!0;return!1}[gs](){this.#e.notify();for(const e of this[Bn])Ji(e)}subscribe(e){return this.#e.count()===0&&this.get(),this.#e.subscribe(e)}subscribeOnce(e){const t=this.subscribe(()=>(t(),e()));return t}waitUntil(){throw new Error("waitUntil not supported on Signals")}markSinksDirty(){for(const e of this[Bn])e.markDirty()}addSink(e){this[Bn].add(e)}removeSink(e){this[Bn].delete(e)}asReadonly(){return this}},zt=class extends Qi{#e;constructor(e,t){super(t),this.#e=En(e)}[Symbol.dispose](){super[Symbol.dispose](),this.#e="(disposed)"}get(){return _n?.add(this),this.#e}set(e){ct(()=>{typeof e=="function"&&(e=e(this.#e)),this.equals(this.#e,e)||(this.#e=En(e),this.markSinksDirty(),Ji(this))})}},d0=class extends zt{constructor(e){super(En(xo(e)))}set(){throw new Error("Don't call .set() directly, use .patch()")}patch(e){super.set(t=>Od(t,e))}},h0=Symbol(),Xe=class li extends Qi{#e;#t;#n;#r;#s;static from(...t){const n=t.pop();if(typeof n!="function"&&wt("Invalid .from() call, last argument expected to be a function"),typeof t[t.length-1]=="function"){const r=n,o=t.pop();return new li(t,o,r)}else{const r=n;return new li(t,r)}}constructor(t,n,r){super(r),this.#t=!0,this.#e=h0,this.#r=t,this.#n=new Set,this.#s=n}[Symbol.dispose](){for(const t of this.#n)t.removeSink(this);this.#e="(disposed)",this.#n="(disposed)",this.#r="(disposed)",this.#s="(disposed)"}get isDirty(){return this.#t}#o(){const t=_n;let n;_n=new Set;try{n=this.#s(...this.#r.map(r=>r.get()))}finally{const r=this.#n;this.#n=new Set;for(const o of _n)this.#n.add(o),r.delete(o);for(const o of r)o.removeSink(this);for(const o of this.#n)o.addSink(this);_n=t}return this.#t=!1,this.equals(this.#e,n)?!1:(this.#e=n,!0)}markDirty(){this.#t||(this.#t=!0,this.markSinksDirty())}get(){return this.#t&&this.#o(),_n?.add(this),this.#e}[gs](){if(!this.hasWatchers)return;this.#o()&&super[gs]()}},Zn=class extends Qi{#e;constructor(e){super(),this.#e=e}[Symbol.dispose](){super[Symbol.dispose](),this.#e="(disposed)"}get(){return _n?.add(this),this.#e}mutate(e){ct(()=>{const t=e?e(this.#e):!0;t!==null&&typeof t=="object"&&"then"in t&&wt("MutableSignal.mutate() does not support async callbacks"),t!==!1&&(this.markSinksDirty(),Ji(this))})}};function p0(e,t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).sort().reduce((n,r)=>(n[r]=t[r],n),{}):t}function Vn(e){return JSON.stringify(e,p0)}function tn(e){try{return JSON.stringify(e)}catch(t){throw console.error(`Could not stringify: ${t.message}`),console.error(e),t}}var m0=50,v0=class{input;resolve;reject;promise;constructor(e){this.input=e;const{promise:t,resolve:n,reject:r}=xd();this.promise=t,this.resolve=n,this.reject=r}},Jr=class{#e=[];#t;#n;#r;#s;error=!1;constructor(e,t){this.#t=e,this.#n=t.size??m0,this.#r=t.delay}#o(){this.#s!==void 0&&(clearTimeout(this.#s),this.#s=void 0)}#i(){this.#e.length===this.#n?this.#a():this.#e.length===1&&(this.#o(),this.#s=setTimeout(()=>void this.#a(),this.#r))}async#a(){if(this.#e.length===0)return;const e=this.#e.splice(0),t=e.map(n=>n.input);try{const n=await this.#t(t);this.error=!1,e.forEach((r,o)=>{const s=n?.[o];Array.isArray(n)?e.length!==n.length?r.reject(new Error(`Callback must return an array of the same length as the number of provided items. Expected ${e.length}, but got ${n.length}.`)):s instanceof Error?r.reject(s):r.resolve(s):r.reject(new Error("Callback must return an array."))})}catch(n){this.error=!0,e.forEach(r=>{r.reject(n)})}}get(e){const t=this.#e.find(r=>Vn(r.input)===Vn(e));if(t)return t.promise;const n=new v0(e);return this.#e.push(n),this.#i(),n.promise}clear(){this.#e=[],this.error=!1,this.#o()}};function fi(e){const t=new Zn(new Map);function n(u){return Vn(u)}function r(u,c){t.mutate(l=>{l.set(u,c)})}function o(u){t.mutate(c=>{if(Array.isArray(u))for(const l of u)c.delete(n(l));else c.clear()})}async function s(u){const c=n(u);if(!t.get().has(c))try{r(c,{isLoading:!0});const d=await e.get(u);r(c,{isLoading:!1,data:d})}catch(d){r(c,{isLoading:!1,error:d})}}function a(u){const c=n(u);return t.get().get(c)}function i(){return[...t.get().keys()]}return{subscribe:t.subscribe,enqueue:s,getItemState:a,invalidate:o,batch:e,_cacheKeys:i}}function g0(e,t){const n=[];for(let r=0,o=e.length;r<o;r+=t)n.push(e.slice(r,r+t));return n}var Nr=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>t+=(n&=63)<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-",""),C0="th",y0="cm",b0="at";function eu(e){return`${e}_${Nr()}`}function Sd(){return eu(C0)}function Cs(){return eu(y0)}function Td(){return eu(b0)}var It=class extends Map{#e;constructor(e,t){super(t),this.#e=e}getOrCreate(e,t){if(super.has(e))return super.get(e);{const r=(t??this.#e??wt("DefaultMap used without a factory function"))(e);return this.set(e,r),r}}},E0=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function Ac(e){let t=[];const n=Object.entries(e),r=[],o=[],s=[];return n.forEach(([a,i])=>{if(!E0.test(a))throw new Error("Key must only contain letters, numbers, _");Sc(i)?r.push([a,i]):nn(i)&&(ui(i)?o.push([a,i]):s.push([a,i]))}),t=[...xc(r),...Oc(o)],s.forEach(([a,i])=>{const u=Object.entries(i),c=[],l=[];u.forEach(([d,m])=>{if(D0(d))throw new Error("Key cannot be empty");Sc(m)?c.push([Tc(a,d),m]):ui(m)&&l.push([Tc(a,d),m])}),t=[...t,...xc(c),...Oc(l)]}),t.map(({key:a,operator:i,value:u})=>`${a}${i}${Rd(u)}`).join(" ")}var xc=e=>{const t=[];return e.forEach(([n,r])=>{t.push({key:n,operator:":",value:r})}),t},Oc=e=>{const t=[];return e.forEach(([n,r])=>{"startsWith"in r&&typeof r.startsWith=="string"&&t.push({key:n,operator:"^",value:r.startsWith})}),t},Sc=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Tc=(e,t)=>t?`${e}[${Rd(t)}]`:e,D0=e=>!e||e.toString().trim()==="";function Rd(e){const t=JSON.stringify(e);return typeof e!="string"||t.includes("'")?t:`'${t.slice(1,-1).replace(/\\"/g,'"')}'`}function w0(e){const t=new URLSearchParams;for(const[n,r]of Object.entries(e))r!=null&&t.set(n,r.toString());return t}function A0(e,t,n){const r=new URL(t,e);return n!==void 0&&(r.search=(n instanceof URLSearchParams?n:w0(n)).toString()),r.toString()}function be(e,...t){return e.reduce((n,r,o)=>n+encodeURIComponent(t[o-1]??"")+r)}function x0({baseUrl:e,authManager:t,fetchPolyfill:n}){const r=new O0(e,n);async function o(T){const q=await r.get(be`/v2/c/rooms/${T.roomId}/threads/delta`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{since:T.since.toISOString()},{signal:T.signal});return{threads:{updated:q.data.map(fn),deleted:q.deletedThreads.map(xa)},inboxNotifications:{updated:q.inboxNotifications.map(In),deleted:q.deletedInboxNotifications.map(Oa)},requestedAt:new Date(q.meta.requestedAt),permissionHints:q.meta.permissionHints}}async function s(T){let q;T.query&&(q=Ac(T.query));const ne=50;try{const ie=await r.get(be`/v2/c/rooms/${T.roomId}/threads`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{cursor:T.cursor,query:q,limit:ne});return{threads:ie.data.map(fn),inboxNotifications:ie.inboxNotifications.map(In),nextCursor:ie.meta.nextCursor,requestedAt:new Date(ie.meta.requestedAt),permissionHints:ie.meta.permissionHints}}catch(ie){if(ie instanceof xr&&ie.status===404)return{threads:[],inboxNotifications:[],nextCursor:null,requestedAt:new Date(Date.now()-6*60*60*1e3),permissionHints:{}};throw ie}}async function a(T){const q=T.commentId??Cs(),ne=T.threadId??Sd(),ie=await r.post(be`/v2/c/rooms/${T.roomId}/threads`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{id:ne,comment:{id:q,body:T.body,attachmentIds:T.attachmentIds},metadata:T.metadata});return fn(ie)}async function i(T){await r.delete(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function u(T){const q=await r.rawGet(be`/v2/c/rooms/${T.roomId}/thread-with-notification/${T.threadId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}));if(q.ok){const ne=await q.json();return{thread:fn(ne.thread),inboxNotification:ne.inboxNotification?In(ne.inboxNotification):void 0}}else{if(q.status===404)return{thread:void 0,inboxNotification:void 0};throw new Error(`There was an error while getting thread ${T.threadId}.`)}}async function c(T){return await r.post(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/metadata`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),T.metadata)}async function l(T){const q=T.commentId??Cs(),ne=await r.post(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/comments`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{id:q,body:T.body,attachmentIds:T.attachmentIds});return ii(ne)}async function d(T){const q=await r.post(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/comments/${T.commentId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{body:T.body,attachmentIds:T.attachmentIds});return ii(q)}async function m(T){await r.delete(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/comments/${T.commentId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function g(T){const q=await r.post(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/comments/${T.commentId}/reactions`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{emoji:T.emoji});return r0(q)}async function C(T){await r.delete(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/comments/${T.commentId}/reactions/${T.emoji}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function v(T){await r.post(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/mark-as-resolved`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function p(T){await r.post(be`/v2/c/rooms/${T.roomId}/threads/${T.threadId}/mark-as-unresolved`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function E(T){const q=T.roomId,ne=T.signal,ie=T.attachment,we=ne?new DOMException(`Upload of attachment ${T.attachment.id} was aborted.`,"AbortError"):void 0;if(ne?.aborted)throw we;const xe=Ce=>{if(ne?.aborted)throw we;if(Ce instanceof xr&&Ce.status===413)throw Ce;return!1},ae=5*1024*1024,Te=10,je=[2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3];function he(Ce){const ke=[];let Pe=0;for(;Pe<Ce.size;){const ye=Math.min(Pe+ae,Ce.size);ke.push({partNumber:ke.length+1,part:Ce.slice(Pe,ye)}),Pe=ye}return ke}if(ie.size<=ae)return Zr(async()=>r.putBlob(be`/v2/c/rooms/${q}/attachments/${ie.id}/upload/${encodeURIComponent(ie.name)}`,await t.getAuthValue({requestedScope:"comments:read",roomId:q}),ie.file,{fileSize:ie.size},{signal:ne}),Te,je,xe);{let Ce;const ke=[],Pe=await Zr(async()=>r.post(be`/v2/c/rooms/${q}/attachments/${ie.id}/multipart/${encodeURIComponent(ie.name)}`,await t.getAuthValue({requestedScope:"comments:read",roomId:q}),void 0,{signal:ne},{fileSize:ie.size}),Te,je,xe);try{Ce=Pe.uploadId;const ye=he(ie.file);if(ne?.aborted)throw we;const Ee=g0(ye,5);for(const $e of Ee){const qe=[];for(const{part:yt,partNumber:Je}of $e)qe.push(Zr(async()=>r.putBlob(be`/v2/c/rooms/${q}/attachments/${ie.id}/multipart/${Pe.uploadId}/${String(Je)}`,await t.getAuthValue({requestedScope:"comments:read",roomId:q}),yt,void 0,{signal:ne}),Te,je,xe));ke.push(...await Promise.all(qe))}if(ne?.aborted)throw we;const Ct=ke.sort(($e,qe)=>$e.partNumber-qe.partNumber);return r.post(be`/v2/c/rooms/${q}/attachments/${ie.id}/multipart/${Ce}/complete`,await t.getAuthValue({requestedScope:"comments:read",roomId:q}),{parts:Ct},{signal:ne})}catch(ye){if(Ce&&ye?.name&&(ye.name==="AbortError"||ye.name==="TimeoutError"))try{await r.rawDelete(be`/v2/c/rooms/${q}/attachments/${ie.id}/multipart/${Ce}`,await t.getAuthValue({requestedScope:"comments:read",roomId:q}))}catch{}throw ye}}}const b=new It(T=>{const q=new Jr(async ne=>{const ie=ne.flat(),{urls:we}=await r.post(be`/v2/c/rooms/${T}/attachments/presigned-urls`,await t.getAuthValue({requestedScope:"comments:read",roomId:T}),{attachmentIds:ie});return we.map(xe=>xe??new Error("There was an error while getting this attachment's URL"))},{delay:50});return fi(q)});function w(T){return b.getOrCreate(T)}function D(T){return w(T.roomId).batch.get(T.attachmentId)}async function x(T){return r.get(be`/v2/c/rooms/${T.roomId}/notification-settings`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),void 0,{signal:T.signal})}async function I(T){return r.post(be`/v2/c/rooms/${T.roomId}/notification-settings`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),T.settings)}const S=new It(T=>new Jr(async q=>{const ne=q.flat();return await r.post(be`/v2/c/rooms/${T}/inbox-notifications/read`,await t.getAuthValue({requestedScope:"comments:read",roomId:T}),{inboxNotificationIds:ne}),ne},{delay:50}));async function k(T){return S.getOrCreate(T.roomId).get(T.inboxNotificationId)}async function H(T){await r.rawPost(be`/v2/c/rooms/${T.roomId}/text-mentions`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{userId:T.userId,mentionId:T.mentionId})}async function P(T){await r.rawDelete(be`/v2/c/rooms/${T.roomId}/text-mentions/${T.mentionId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function j(T){return r.rawGet(be`/v2/c/rooms/${T.roomId}/y-version/${T.versionId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function B(T){await r.rawPost(be`/v2/c/rooms/${T.roomId}/version`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}))}async function N(T){await r.rawPost(be`/v2/c/rooms/${T.roomId}/text-metadata`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{type:T.type,rootKey:T.rootKey})}async function M(T){const q=await r.post(be`/v2/c/rooms/${T.roomId}/ai/contextual-prompt`,await t.getAuthValue({requestedScope:"room:read",roomId:T.roomId}),{prompt:T.prompt,context:{beforeSelection:T.context.beforeSelection,selection:T.context.selection,afterSelection:T.context.afterSelection},previous:T.previous},{signal:T.signal});if(!q||q.content.length===0)throw new Error("No content returned from server");return q.content[0].text}async function W(T){const q=await r.get(be`/v2/c/rooms/${T.roomId}/versions`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}));return{versions:q.versions.map(({createdAt:ne,...ie})=>({createdAt:new Date(ne),...ie})),requestedAt:new Date(q.meta.requestedAt)}}async function re(T){const q=await r.get(be`/v2/c/rooms/${T.roomId}/versions/delta`,await t.getAuthValue({requestedScope:"comments:read",roomId:T.roomId}),{since:T.since.toISOString()},{signal:T.signal});return{versions:q.versions.map(({createdAt:ne,...ie})=>({createdAt:new Date(ne),...ie})),requestedAt:new Date(q.meta.requestedAt)}}async function Y(T){return await(await r.rawGet(be`/v2/c/rooms/${T.roomId}/storage`,await t.getAuthValue({requestedScope:"room:read",roomId:T.roomId}))).json()}async function ee(T){return r.rawPost(be`/v2/c/rooms/${T.roomId}/send-message`,await t.getAuthValue({requestedScope:"room:read",roomId:T.roomId}),{nonce:T.nonce,messages:T.messages})}async function L(T){const ne=await r.get(be`/v2/c/inbox-notifications`,await t.getAuthValue({requestedScope:"comments:read"}),{cursor:T?.cursor,limit:50});return{inboxNotifications:ne.inboxNotifications.map(In),threads:ne.threads.map(fn),nextCursor:ne.meta.nextCursor,requestedAt:new Date(ne.meta.requestedAt)}}async function Q(T){const q=await r.get(be`/v2/c/inbox-notifications/delta`,await t.getAuthValue({requestedScope:"comments:read"}),{since:T.since.toISOString()},{signal:T.signal});return{inboxNotifications:{updated:q.inboxNotifications.map(In),deleted:q.deletedInboxNotifications.map(Oa)},threads:{updated:q.threads.map(fn),deleted:q.deletedThreads.map(xa)},requestedAt:new Date(q.meta.requestedAt)}}async function V(){const{count:T}=await r.get(be`/v2/c/inbox-notifications/count`,await t.getAuthValue({requestedScope:"comments:read"}));return T}async function te(){await r.post(be`/v2/c/inbox-notifications/read`,await t.getAuthValue({requestedScope:"comments:read"}),{inboxNotificationIds:"all"})}async function se(T){await r.post(be`/v2/c/inbox-notifications/read`,await t.getAuthValue({requestedScope:"comments:read"}),{inboxNotificationIds:T})}const de=new Jr(async T=>{const q=T.flat();return await se(q),q},{delay:50});async function G(T){await de.get(T)}async function R(){await r.delete(be`/v2/c/inbox-notifications`,await t.getAuthValue({requestedScope:"comments:read"}))}async function _(T){await r.delete(be`/v2/c/inbox-notifications/${T}`,await t.getAuthValue({requestedScope:"comments:read"}))}async function U(T){return r.get(be`/v2/c/notification-settings`,await t.getAuthValue({requestedScope:"comments:read"}),void 0,{signal:T?.signal})}async function X(T){return r.post(be`/v2/c/notification-settings`,await t.getAuthValue({requestedScope:"comments:read"}),T)}async function fe(T){let q;T?.query&&(q=Ac(T.query));const ie=await r.get(be`/v2/c/threads`,await t.getAuthValue({requestedScope:"comments:read"}),{cursor:T?.cursor,query:q,limit:50});return{threads:ie.threads.map(fn),inboxNotifications:ie.inboxNotifications.map(In),nextCursor:ie.meta.nextCursor,requestedAt:new Date(ie.meta.requestedAt),permissionHints:ie.meta.permissionHints}}async function le(T){const q=await r.get(be`/v2/c/threads/delta`,await t.getAuthValue({requestedScope:"comments:read"}),{since:T.since.toISOString()},{signal:T.signal});return{threads:{updated:q.threads.map(fn),deleted:q.deletedThreads.map(xa)},inboxNotifications:{updated:q.inboxNotifications.map(In),deleted:q.deletedInboxNotifications.map(Oa)},requestedAt:new Date(q.meta.requestedAt),permissionHints:q.meta.permissionHints}}return{getThreads:s,getThreadsSince:o,createThread:a,getThread:u,deleteThread:i,editThreadMetadata:c,createComment:l,editComment:d,deleteComment:m,addReaction:g,removeReaction:C,markThreadAsResolved:v,markThreadAsUnresolved:p,markRoomInboxNotificationAsRead:k,getNotificationSettings:x,updateNotificationSettings:I,createTextMention:H,deleteTextMention:P,getTextVersion:j,createTextVersion:B,reportTextEditor:N,listTextVersions:W,listTextVersionsSince:re,getAttachmentUrl:D,uploadAttachment:E,getOrCreateAttachmentUrlsStore:w,streamStorage:Y,sendMessages:ee,getInboxNotifications:L,getInboxNotificationsSince:Q,getUnreadInboxNotificationsCount:V,markAllInboxNotificationsAsRead:te,markInboxNotificationAsRead:G,deleteAllInboxNotifications:R,deleteInboxNotification:_,getUserNotificationSettings:U,updateUserNotificationSettings:X,getUserThreads_experimental:fe,getUserThreadsSince_experimental:le,executeContextualPrompt:M}}function Id(e){return e.type==="public"?e.publicApiKey:e.token.raw}var O0=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){e.startsWith("/v2/c/")||wt("This client can only be used to make /v2/c/* requests");const o=A0(this.#e,e,r);return await this.#t(o,{...n,headers:{"Content-Type":"application/json; charset=utf-8",...n?.headers,Authorization:`Bearer ${Id(t)}`,"X-LB-Client":Yi}})}async#r(e,t,n,r){const o=await this.#n(e,t,n,r);if(!o.ok)throw await xr.fromResponse(o);let s;try{s=await o.json()}catch{s={}}return s}async rawGet(e,t,n,r){return await this.#n(e,t,r,n)}async rawPost(e,t,n){return await this.#n(e,t,{method:"POST",body:tn(n)})}async rawDelete(e,t){return await this.#n(e,t,{method:"DELETE"})}async get(e,t,n,r){return await this.#r(e,t,r,n)}async post(e,t,n,r,o){return await this.#r(e,t,{...r,method:"POST",body:tn(n)},o)}async delete(e,t){return await this.#r(e,t,{method:"DELETE"})}async putBlob(e,t,n,r,o){return await this.#r(e,t,{...o,method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:n},r)}};function lt(e,t){throw new Error(t)}function pe(e,t="Expected value to be non-nullable"){return e}function S0(e,t){if(e===t)return[0,0];const n=e.split("."),r=t.split("."),o=Math.min(n.length,r.length);let s=0;for(;s<o&&n[s]===r[s];s++);const a=n.length-s,i=r.length-s;return[a,i]}function T0(e,t){const n=e.split(".");if(t<1||t>n.length+1)throw new Error("Invalid number of levels");const r=[];t>n.length&&r.push("*");for(let o=n.length-t+1;o<n.length;o++){const s=n.slice(0,o);s.length>0&&r.push(s.join(".")+".*")}return r.push(e),r}var R0=class{#e;constructor(e){this.#e=e}get current(){return this.#e}allowPatching(e){const t=this;let n=!0;const r={...this.#e,patch(o){if(n){t.#e=Object.assign({},t.#e,o);for(const s of Object.entries(o)){const[a,i]=s;a!=="patch"&&(this[a]=i)}}else throw new Error("Can no longer patch stale context")}};e(r),n=!1}},I0=1,Bd=class{id;#e;#t;#n;#r;#s;#o;events;#i;#a;#l;get#d(){const e=this.#n.values()[Symbol.iterator]().next();if(e.done)throw new Error("No states defined yet");return e.value}get currentState(){if(this.#r===null)throw this.#e===0?new Error("Not started yet"):new Error("Already stopped");return this.#r}start(){if(this.#e!==0)throw new Error("State machine has already started");return this.#e=1,this.#r=this.#d,this.#c(null),this}stop(){if(this.#e!==1)throw new Error("Cannot stop a state machine that hasn't started yet");this.#f(null),this.#e=2,this.#r=null}constructor(e){this.id=I0++,this.#e=0,this.#r=null,this.#n=new Set,this.#a=new Map,this.#i=[],this.#l=new Set,this.#s=new Map,this.#t=new R0(e),this.#o={didReceiveEvent:Ie(),willTransition:Ie(),didIgnoreEvent:Ie(),willExitState:Ie(),didEnterState:Ie()},this.events={didReceiveEvent:this.#o.didReceiveEvent.observable,willTransition:this.#o.willTransition.observable,didIgnoreEvent:this.#o.didIgnoreEvent.observable,willExitState:this.#o.willExitState.observable,didEnterState:this.#o.didEnterState.observable}}get context(){return this.#t.current}addState(e){if(this.#e!==0)throw new Error("Already started");return this.#n.add(e),this}onEnter(e,t){if(this.#e!==0)throw new Error("Already started");if(this.#a.has(e))throw new Error(`enter/exit function for ${e} already exists`);return this.#a.set(e,t),this}onEnterAsync(e,t,n,r,o){return this.onEnter(e,()=>{const s=new AbortController,a=s.signal,i=o?setTimeout(()=>{const c=new Error("Timed out");this.#u({type:"ASYNC_ERROR",reason:c},r)},o):void 0;let u=!1;return t(this.#t.current,a).then(c=>{a.aborted||(u=!0,this.#u({type:"ASYNC_OK",data:c},n))},c=>{a.aborted||(u=!0,this.#u({type:"ASYNC_ERROR",reason:c},r))}),()=>{clearTimeout(i),u||s.abort()}})}#h(e){const t=[];if(e==="*")for(const n of this.#n)t.push(n);else if(e.endsWith(".*")){const n=e.slice(0,-1);for(const r of this.#n)r.startsWith(n)&&t.push(r)}else{const n=e;this.#n.has(n)&&t.push(n)}if(t.length===0)throw new Error(`No states match ${JSON.stringify(e)}`);return t}addTransitions(e,t){if(this.#e!==0)throw new Error("Already started");for(const n of this.#h(e)){let r=this.#s.get(n);r===void 0&&(r=new Map,this.#s.set(n,r));for(const[o,s]of Object.entries(t)){if(r.has(o))throw new Error(`Trying to set transition "${o}" on "${n}" (via "${e}"), but a transition already exists there.`);const a=s;if(this.#l.add(o),a!==void 0){const i=typeof a=="function"?a:()=>a;r.set(o,i)}}}return this}addTimedTransition(e,t,n){return this.onEnter(e,()=>{const r=typeof t=="function"?t(this.#t.current):t,o=setTimeout(()=>{this.#u({type:"TIMER"},n)},r);return()=>{clearTimeout(o)}})}#p(e){return this.#s.get(this.currentState)?.get(e)}#f(e){this.#o.willExitState.notify(this.currentState),this.#t.allowPatching(t=>{e=e??this.#i.length;for(let n=0;n<e;n++)this.#i.pop()?.(t)})}#c(e){const t=T0(this.currentState,e??this.currentState.split(".").length+1);this.#t.allowPatching(n=>{for(const r of t){const s=this.#a.get(r)?.(n);typeof s=="function"?this.#i.push(s):this.#i.push(null)}}),this.#o.didEnterState.notify(this.currentState)}send(e){if(!this.#l.has(e.type))throw new Error(`Invalid event ${JSON.stringify(e.type)}`);if(this.#e===2)return;const t=this.#p(e.type);if(t!==void 0)return this.#u(e,t);this.#o.didIgnoreEvent.notify(e)}#u(e,t){this.#o.didReceiveEvent.notify(e);const n=this.currentState,o=(typeof t=="function"?t:()=>t)(e,this.#t.current);let s,a;if(o===null){this.#o.didIgnoreEvent.notify(e);return}if(typeof o=="string"?s=o:(s=o.target,a=Array.isArray(o.effect)?o.effect:[o.effect]),!this.#n.has(s))throw new Error(`Invalid next state name: ${JSON.stringify(s)}`);this.#o.willTransition.notify({from:n,to:s});const[i,u]=S0(this.currentState,s);if(i>0&&this.#f(i),this.#r=s,a!==void 0){const c=a;this.#t.allowPatching(l=>{for(const d of c)typeof d=="function"?d(l,e):l.patch(d)})}u>0&&this.#c(u)}},Zt=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.USER_JOINED=101]="USER_JOINED",e[e.USER_LEFT=102]="USER_LEFT",e[e.BROADCASTED_EVENT=103]="BROADCASTED_EVENT",e[e.ROOM_STATE=104]="ROOM_STATE",e[e.INITIAL_STORAGE_STATE=200]="INITIAL_STORAGE_STATE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e[e.REJECT_STORAGE_OP=299]="REJECT_STORAGE_OP",e[e.UPDATE_YDOC=300]="UPDATE_YDOC",e[e.THREAD_CREATED=400]="THREAD_CREATED",e[e.THREAD_DELETED=407]="THREAD_DELETED",e[e.THREAD_METADATA_UPDATED=401]="THREAD_METADATA_UPDATED",e[e.THREAD_UPDATED=408]="THREAD_UPDATED",e[e.COMMENT_CREATED=402]="COMMENT_CREATED",e[e.COMMENT_EDITED=403]="COMMENT_EDITED",e[e.COMMENT_DELETED=404]="COMMENT_DELETED",e[e.COMMENT_REACTION_ADDED=405]="COMMENT_REACTION_ADDED",e[e.COMMENT_REACTION_REMOVED=406]="COMMENT_REACTION_REMOVED",e))(Zt||{});function Rc(e){return e===4999||e>=4e3&&e<4100}function B0(e){return e>=4100&&e<4200}function Ic(e){return e===1013||e>=4200&&e<4300}function F0(e){return e==="initial"||e==="disconnected"}function Fd(e){const t=e.currentState;switch(t){case"@ok.connected":case"@ok.awaiting-pong":return"connected";case"@idle.initial":return"initial";case"@auth.busy":case"@auth.backoff":case"@connecting.busy":case"@connecting.backoff":case"@idle.zombie":return e.context.successCount>0?"reconnecting":"connecting";case"@idle.failed":return"disconnected";default:return lt(t,"Unknown state")}}var Pd=[250,500,1e3,2e3,4e3,8e3,1e4],Uo=Pd[0]-1,P0=[2e3,3e4,6e4,3e5],N0=3e4,k0=2e3,M0=1e4,_0=1e4,Ln=class extends Error{constructor(e){super(e)}};function Nd(e,t){return t.find(n=>n>e)??t[t.length-1]}function or(e){e.patch({backoffDelay:Nd(e.backoffDelay,Pd)})}function Bc(e){e.patch({backoffDelay:Nd(e.backoffDelay,P0)})}function Fc(e){e.patch({successCount:0})}function lr(e,t){const n=e===2?Ao:e===1?ft:()=>{};return()=>{n(t)}}function Pc(e){const t="Connection to Liveblocks websocket server";return n=>{e instanceof Error?ft(`${t} could not be established. ${String(e)}`):ft(kd(e)?`${t} closed prematurely (code: ${e.code}). Retrying in ${n.backoffDelay}ms.`:`${t} could not be established.`)}}function Sa(e){const t=[`code: ${e.code}`];return e.reason&&t.push(`reason: ${e.reason}`),n=>{ft(`Connection to Liveblocks websocket server closed (${t.join(", ")}). Retrying in ${n.backoffDelay}ms.`)}}var j0=lr(1,"Connection to WebSocket closed permanently. Won't retry.");function kd(e){return!(e instanceof Error)&&e.type==="close"}function L0(e){const t=new Date().getTime();function n(...o){ft(`${((new Date().getTime()-t)/1e3).toFixed(2)} [FSM #${e.id}]`,...o)}const r=[e.events.didReceiveEvent.subscribe(o=>n(`Event ${o.type}`)),e.events.willTransition.subscribe(({from:o,to:s})=>n("Transitioning",o,"→",s)),e.events.didIgnoreEvent.subscribe(o=>n("Ignored event",o.type,o,"(current state won't handle it)"))];return()=>{for(const o of r)o()}}function $0(e){const t=Ie(),n=Ie(),r=Ie();let o=null;const s=e.events.didEnterState.subscribe(()=>{const a=Fd(e);a!==o&&t.notify(a),o==="connected"&&a!=="connected"?r.notify():o!=="connected"&&a==="connected"&&n.notify(),o=a});return{statusDidChange:t.observable,didConnect:n.observable,didDisconnect:r.observable,unsubscribe:s}}var Ho=e=>t=>t.patch(e);function U0(e,t){const n=f0();n.pause();const r=Ie();function o(b,w){return()=>{r.notify({message:b,code:w})}}const s={successCount:0,authValue:null,socket:null,backoffDelay:Uo},a=new Bd(s).addState("@idle.initial").addState("@idle.failed").addState("@idle.zombie").addState("@auth.busy").addState("@auth.backoff").addState("@connecting.busy").addState("@connecting.backoff").addState("@ok.connected").addState("@ok.awaiting-pong");a.addTransitions("*",{RECONNECT:{target:"@auth.backoff",effect:[or,Fc]},DISCONNECT:"@idle.initial"}),a.onEnter("@idle.*",Fc).addTransitions("@idle.*",{CONNECT:(b,w)=>w.authValue!==null?"@connecting.busy":"@auth.busy"}),a.addTransitions("@auth.backoff",{NAVIGATOR_ONLINE:{target:"@auth.busy",effect:Ho({backoffDelay:Uo})}}).addTimedTransition("@auth.backoff",b=>b.backoffDelay,"@auth.busy").onEnterAsync("@auth.busy",()=>Dc(e.authenticate(),M0,"Timed out during auth"),b=>({target:"@connecting.busy",effect:Ho({authValue:b.data})}),b=>b.reason instanceof Ln?{target:"@idle.failed",effect:[lr(2,b.reason.message),o(b.reason.message,-1)]}:{target:"@auth.backoff",effect:[or,lr(2,`Authentication failed: ${b.reason instanceof Error?b.reason.message:String(b.reason)}`)]});const i=b=>a.send({type:"EXPLICIT_SOCKET_ERROR",event:b}),u=b=>a.send({type:"EXPLICIT_SOCKET_CLOSE",event:b}),c=b=>b.data==="pong"?a.send({type:"PONG"}):n.notify(b);function l(b){b&&(b.removeEventListener("error",i),b.removeEventListener("close",u),b.removeEventListener("message",c),b.close())}a.addTransitions("@connecting.backoff",{NAVIGATOR_ONLINE:{target:"@connecting.busy",effect:Ho({backoffDelay:Uo})}}).addTimedTransition("@connecting.backoff",b=>b.backoffDelay,"@connecting.busy").onEnterAsync("@connecting.busy",async(b,w)=>{let D=null,x=null;const I=new Promise((S,k)=>{if(b.authValue===null)throw new Error("No auth authValue");const H=e.createSocket(b.authValue);x=H;function P(M){D=M,H.removeEventListener("message",c),k(M)}const[j,B]=Ad();t.waitForActorId||B();function N(M){$s(M.data)?.type===104&&B()}H.addEventListener("message",c),t.waitForActorId&&H.addEventListener("message",N),H.addEventListener("error",P),H.addEventListener("close",P),H.addEventListener("open",()=>{H.addEventListener("error",i),H.addEventListener("close",u);const M=()=>{H.removeEventListener("error",P),H.removeEventListener("close",P),H.removeEventListener("message",N)};j.then(()=>{S([H,M])})})});return Dc(I,_0,"Timed out during websocket connection").then(([S,k])=>{if(k(),w.aborted)throw new Error("Aborted");if(D)throw D;return S}).catch(S=>{throw l(x),S})},b=>({target:"@ok.connected",effect:Ho({socket:b.data,backoffDelay:Uo})}),b=>{const w=b.reason;if(w instanceof Ln)return{target:"@idle.failed",effect:[lr(2,w.message),o(w.message,-1)]};if(kd(w)){if(w.code===4109)return"@auth.busy";if(Ic(w.code))return{target:"@connecting.backoff",effect:[Bc,Pc(w)]};if(Rc(w.code))return{target:"@idle.failed",effect:[lr(2,w.reason),o(w.reason,w.code)]}}return{target:"@auth.backoff",effect:[or,Pc(w)]}});const d={target:"@ok.awaiting-pong",effect:b=>{b.socket?.send("ping")}},m=()=>(typeof document<"u"?document:void 0)?.visibilityState==="hidden"&&e.canZombie()?"@idle.zombie":d;if(a.addTimedTransition("@ok.connected",N0,m).addTransitions("@ok.connected",{NAVIGATOR_OFFLINE:m,WINDOW_GOT_FOCUS:d}),a.addTransitions("@idle.zombie",{WINDOW_GOT_FOCUS:"@connecting.backoff"}),a.onEnter("@ok.*",b=>{b.patch({successCount:b.successCount+1});const w=setTimeout(n.unpause,0);return D=>{l(D.socket),D.patch({socket:null}),clearTimeout(w),n.pause()}}).addTransitions("@ok.awaiting-pong",{PONG:"@ok.connected"}).addTimedTransition("@ok.awaiting-pong",k0,{target:"@connecting.busy",effect:lr(1,"Received no pong from server, assume implicit connection loss.")}).addTransitions("@ok.*",{EXPLICIT_SOCKET_ERROR:(b,w)=>w.socket?.readyState===1?null:{target:"@connecting.backoff",effect:or},EXPLICIT_SOCKET_CLOSE:b=>Rc(b.event.code)?{target:"@idle.failed",effect:[j0,o(b.event.reason,b.event.code)]}:B0(b.event.code)?b.event.code===4109?"@auth.busy":{target:"@auth.backoff",effect:[or,Sa(b.event)]}:Ic(b.event.code)?{target:"@connecting.backoff",effect:[Bc,Sa(b.event)]}:{target:"@connecting.backoff",effect:[or,Sa(b.event)]}}),typeof document<"u"){const b=typeof document<"u"?document:void 0,w=typeof window<"u"?window:void 0,D=w??b;a.onEnter("*",x=>{function I(){a.send({type:"NAVIGATOR_OFFLINE"})}function S(){a.send({type:"NAVIGATOR_ONLINE"})}function k(){b?.visibilityState==="visible"&&a.send({type:"WINDOW_GOT_FOCUS"})}return w?.addEventListener("online",S),w?.addEventListener("offline",I),D?.addEventListener("visibilitychange",k),()=>{D?.removeEventListener("visibilitychange",k),w?.removeEventListener("online",S),w?.removeEventListener("offline",I),l(x.socket)}})}const g=[],{statusDidChange:C,didConnect:v,didDisconnect:p,unsubscribe:E}=$0(a);return g.push(E),t.enableDebugLogging&&g.push(L0(a)),a.start(),{machine:a,cleanups:g,events:{statusDidChange:C,didConnect:v,didDisconnect:p,onMessage:n.observable,onConnectionError:r.observable}}}var H0=class{#e;#t;events;constructor(e,t=!1,n=!0){const{machine:r,events:o,cleanups:s}=U0(e,{waitForActorId:n,enableDebugLogging:t});this.#e=r,this.events=o,this.#t=s}getStatus(){try{return Fd(this.#e)}catch{return"initial"}}get authValue(){return this.#e.context.authValue}connect(){this.#e.send({type:"CONNECT"})}reconnect(){this.#e.send({type:"RECONNECT"})}disconnect(){this.#e.send({type:"DISCONNECT"})}destroy(){this.#e.stop();let e;for(;e=this.#t.pop();)e()}send(e){const t=this.#e.context?.socket;t===null?ft("Cannot send: not connected yet",e):t.readyState!==1?ft("Cannot send: WebSocket no longer open",e):t.send(e)}_privateSendMachineEvent(e){this.#e.send(e)}},di=(e=>(e.Read="room:read",e.Write="room:write",e.PresenceWrite="room:presence:write",e.CommentsWrite="comments:write",e.CommentsRead="comments:read",e))(di||{});function hi(e){return e.includes("room:write")}function Md(e){return e.includes("comments:write")||e.includes("room:write")}function W0(e){return nn(e)&&(e.k==="acc"||e.k==="id"||e.k==="sec-legacy")}function Nc(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=$s(u0(t[1]));if(!(n&&W0(n)))throw new Error("Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback");return{raw:e,parsed:n}}function z0(e,t){const n=V0(e),r=new Set,o=[],s=[],a=new Map;function i(){r.clear(),o.length=0,s.length=0,a.clear()}function u(m,g){return m==="comments:read"?g.includes("comments:read")||g.includes("comments:write")||g.includes("room:read")||g.includes("room:write"):m==="room:read"?g.includes("room:read")||g.includes("room:write"):!1}function c(m){const g=Math.ceil(Date.now()/1e3);for(let C=o.length-1;C>=0;C--){const v=o[C];if(s[C]<=g){o.splice(C,1),s.splice(C,1);continue}if(v.parsed.k==="id")return v;if(v.parsed.k==="acc"){if(!m.roomId&&Object.entries(v.parsed.perms).length===0)return v;for(const[E,b]of Object.entries(v.parsed.perms))if(m.roomId){if(E.includes("*")&&m.roomId.startsWith(E.replace("*",""))||m.roomId===E&&u(m.requestedScope,b))return v}else if(E.includes("*")&&u(m.requestedScope,b))return v}}}async function l(m){const g=e.polyfills?.fetch??(typeof window>"u"?void 0:window.fetch);if(n.type==="private"){if(g===void 0)throw new Ln("To use Liveblocks client in a non-DOM environment with a url as auth endpoint, you need to provide a fetch polyfill.");const C=await K0(g,n.url,{room:m.roomId}),v=Nc(C.token);if(r.has(v.raw))throw new Ln("The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported.");return t?.(v.parsed),v}if(n.type==="custom"){const C=await n.callback(m.roomId);if(C&&typeof C=="object"){if(typeof C.token=="string"){const v=Nc(C.token);return t?.(v.parsed),v}else if(typeof C.error=="string"){const v=`Authentication failed: ${"reason"in C&&typeof C.reason=="string"?C.reason:"Forbidden"}`;throw C.error==="forbidden"?new Ln(v):new Error(v)}}throw new Error('Your authentication callback function should return a token, but it did not. Hint: the return value should look like: { token: "..." }')}throw new Error("Unexpected authentication type. Must be private or custom.")}async function d(m){if(n.type==="public")return{type:"public",publicApiKey:n.publicApiKey};const g=c(m);if(g!==void 0)return{type:"secret",token:g};let C;m.roomId?(C=a.get(m.roomId),C===void 0&&(C=l(m),a.set(m.roomId,C))):(C=a.get("liveblocks-user-token"),C===void 0&&(C=l(m),a.set("liveblocks-user-token",C)));try{const v=await C,E=Math.floor(Date.now()/1e3)+(v.parsed.exp-v.parsed.iat)-30;return r.add(v.raw),v.parsed.k!=="sec-legacy"&&(o.push(v),s.push(E)),{type:"secret",token:v}}finally{m.roomId?a.delete(m.roomId):a.delete("liveblocks-user-token")}}return{reset:i,getAuthValue:d}}function V0(e){const{publicApiKey:t,authEndpoint:n}=e;if(n!==void 0&&t!==void 0)throw new Error("You cannot simultaneously use `publicApiKey` and `authEndpoint` options. Please pick one and leave the other option unspecified. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient");if(typeof t=="string"){if(t.startsWith("sk_"))throw new Error("Invalid `publicApiKey` option. The value you passed is a secret key, which should not be used from the client. Please only ever pass a public key here. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");if(!t.startsWith("pk_"))throw new Error("Invalid key. Please use the public key format: pk_<public key>. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:t}}if(typeof n=="string")return{type:"private",url:n};if(typeof n=="function")return{type:"custom",callback:n};throw n!==void 0?new Error("The `authEndpoint` option must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"):new Error("Invalid Liveblocks client options. Please provide either a `publicApiKey` or `authEndpoint` option. They cannot both be empty. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient")}async function K0(e,t,n){const r=await e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:tn(n)});if(!r.ok){const a=`${(await r.text()).trim()||"reason not provided in auth response"} (${r.status} returned by POST ${t})`;throw r.status===401||r.status===403?new Ln(`Unauthorized: ${a}`):new Error(`Failed to authenticate: ${a}`)}let o;try{o=await r.json()}catch(a){throw new Error(`Expected a JSON response when doing a POST request on "${t}". ${String(a)}`)}if(!nn(o)||typeof o.token!="string")throw new Error(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${tn(o)}`);const{token:s}=o;return{token:s}}var q0="https://api.liveblocks.io",Oe=Symbol(),G0=Ie();G0.observable;var Qr=Symbol("user-notification-settings-plain");function ys(e){const t=["email","slack","teams","webPush"],n={[Qr]:{value:e,enumerable:!1}};for(const r of t)n[r]={enumerable:!0,get(){const o=this[Qr][r];return typeof o>"u"?(Ao(`In order to use the '${r}' channel, please set up your project first. For more information: https://liveblocks.io/docs/errors/enable-a-notification-channel`),null):o}};return i0(null,n)}function Y0(e,t){const n=ys({...e[Qr]});for(const r of a0(t)){const o=t[r];if(o!==void 0){const s=Object.fromEntries(Zi(o).filter(([,a])=>a!==void 0));n[Qr][r]={...n[Qr][r],...s}}}return n}var Pt=32,Dn=126,X0=Dn-Pt+1,tu=nu(0),Us=nu(1),Z0=tu+nu(-1);function nu(e){const t=Pt+(e<0?X0+e:e);if(t<Pt||t>Dn)throw new Error(`Invalid n value: ${e}`);return String.fromCharCode(t)}function Yt(e,t){return e!==void 0&&t!==void 0?eC(e,t):e!==void 0?Q0(e):t!==void 0?J0(t):Us}function J0(e){const t=e.length-1;for(let n=0;n<=t;n++){const r=e.charCodeAt(n);if(!(r<=Pt))return n===t?r===Pt+1?e.substring(0,n)+Z0:e.substring(0,n)+String.fromCharCode(r-1):e.substring(0,n+1)}return Us}function Q0(e){for(let t=0;t<=e.length-1;t++){const n=e.charCodeAt(t);if(!(n>=Dn))return e.substring(0,t)+String.fromCharCode(n+1)}return e+Us}function eC(e,t){if(e<t)return pi(e,t);if(e>t)return pi(t,e);throw new Error("Cannot compute value between two equal positions")}function pi(e,t){let n=0;const r=e.length,o=t.length;for(;;){const s=n<r?e.charCodeAt(n):Pt,a=n<o?t.charCodeAt(n):Dn;if(s===a){n++;continue}if(a-s===1){const i=n+1;let u=e.substring(0,i);u.length<i&&(u+=tu.repeat(i-u.length));const c=e.substring(i);return u+pi(c,"")}else return tC(e,n)+String.fromCharCode(a+s>>1)}}function tC(e,t){return t<e.length?e.substring(0,t):e+tu.repeat(t-e.length)}var nC=Pt+1;function rC(e){if(e==="")return!1;const t=e.length-1,n=e.charCodeAt(t);if(n<nC||n>Dn)return!1;for(let r=0;r<t;r++){const o=e.charCodeAt(r);if(o<Pt||o>Dn)return!1}return!0}function oC(e){const t=[];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t.push(r<Pt?Pt:r>Dn?Dn:r)}for(;t.length>0&&t[t.length-1]===Pt;)t.length--;return t.length>0?String.fromCharCode(...t):Us}function so(e){return rC(e)?e:oC(e)}function sC(e){return e.type===5&&e.id==="ACK"}function aC(e,t){const{getCurrentConnectionId:n,onDispatch:r,isStorageWritable:o=()=>!0}=t;let s=0,a=0;const i=new Map;return{roomId:e,nodes:i,getNode:u=>i.get(u),addNode:(u,c)=>void i.set(u,c),deleteNode:u=>void i.delete(u),generateId:()=>`${n()}:${s++}`,generateOpId:()=>`${n()}:${a++}`,dispatch(u,c,l){r?.(u,c,l)},assertStorageIsWritable:()=>{if(!o())throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")}}}function kc(e,t,n=so(t)){return Object.freeze({type:"HasParent",node:e,key:t,pos:n})}var Mc=Object.freeze({type:"NoParent"});function iC(e,t=so(e)){return Object.freeze({type:"Orphaned",oldKey:e,oldPos:t})}var Hs=class{#e;#t;#n=Mc;_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return lt(this.parent,"Unknown state")}}get _parentPos(){switch(this.parent.type){case"HasParent":return this.parent.pos;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldPos;default:return lt(this.parent,"Unknown state")}}get _pool(){return this.#e}get roomId(){return this.#e?this.#e.roomId:null}get _id(){return this.#t}get parent(){return this.#n}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return lt(this.parent,"Unknown state")}}_apply(e,t){switch(e.type){case 5:return this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}}return{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this.#n=kc(e,t);return;case"Orphaned":case"NoParent":{this.#n=kc(e,t);return}default:return lt(this.parent,"Unknown state")}}_attach(e,t){if(this.#t||this.#e)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.#t=e,this.#e=t}_detach(){switch(this.#e&&this.#t&&this.#e.deleteNode(this.#t),this.parent.type){case"HasParent":{this.#n=iC(this.parent.key,this.parent.pos);break}case"NoParent":{this.#n=Mc;break}case"Orphaned":break;default:lt(this.parent,"Unknown state")}this.#e=void 0}#r;#s;#o;invalidate(){(this.#r!==void 0||this.#o!==void 0)&&(this.#r=void 0,this.#o=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toTreeNode(e){return(this.#o===void 0||this.#s!==e)&&(this.#s=e,this.#o=this._toTreeNode(e)),this.#o}toImmutable(){return this.#r===void 0&&(this.#r=this._toImmutable()),this.#r}};function uC(e){return e.type===0&&!cC(e)}function cC(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Sn=class _d extends Hs{#e;constructor(t){super(),this.#e=t}get data(){return this.#e}static _deserialize([t,n],r,o){const s=new _d(n.data);return s._attach(t,o),s}_toOps(t,n,r){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:8,opId:r?.generateOpId(),id:this._id,parentId:t,parentKey:n,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:3,parentId:pe(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(t){throw new Error("Method not implemented.")}_detachChild(t){throw new Error("Method not implemented.")}_apply(t,n){return super._apply(t,n)}_toTreeNode(t){return{type:"Json",id:this._id??Nr(),key:t,payload:this.#e}}_toImmutable(){return this.#e}clone(){return oo(this.data)}};function lC(e,t){const n=e._parentPos,r=t._parentPos;return n===r?0:n<r?-1:1}var kr=class mi extends Hs{#e;#t;#n;constructor(t){super(),this.#e=[],this.#t=new WeakSet,this.#n=new Map;let n;for(const r of t){const o=Yt(n),s=vr(r);s._setParentLink(this,o),this.#e.push(s),n=o}}static _deserialize([t],n,r){const o=new mi([]);o._attach(t,r);const s=n.get(t);if(s===void 0)return o;for(const[a,i]of s){const u=$d([a,i],n,r);u._setParentLink(o,i.parentKey),o._insertAndSort(u)}return o}_toOps(t,n,r){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const o=[],s={id:this._id,opId:r?.generateOpId(),type:2,parentId:t,parentKey:n};o.push(s);for(const a of this.#e){const i=a._getParentKeyOrThrow(),u=zo(a._toOps(this._id,i,r),void 0),c=u[0].opId;c!==void 0&&this.#n.set(i,c),o.push(...u)}return o}_insertAndSort(t){this.#e.push(t),this._sortItems()}_sortItems(){this.#e.sort(lC),this.invalidate()}_indexOfPosition(t){return this.#e.findIndex(n=>n._getParentKeyOrThrow()===t)}_attach(t,n){super._attach(t,n);for(const r of this.#e)r._attach(n.generateId(),n)}_detach(){super._detach();for(const t of this.#e)t._detach()}#r(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r}=t,o=Kr(t);o._attach(n,this._pool),o._setParentLink(this,r);const s=t.deletedId,a=this._indexOfPosition(r);if(a!==-1){const i=this.#e[a];if(i._id===s)return i._detach(),this.#e[a]=o,{modified:Fe(this,[sr(a,o)]),reverse:[]};{this.#t.add(i),this.#e[a]=o;const u=[sr(a,o)],c=this.#o(t.deletedId);return c&&u.push(c),{modified:Fe(this,u),reverse:[]}}}else{const i=[],u=this.#o(t.deletedId);return u&&i.push(u),this._insertAndSort(o),i.push(_t(this._indexOfPosition(r),o)),{reverse:[],modified:Fe(this,i)}}}#s(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=[],r=this.#o(t.deletedId);r&&n.push(r);const o=this.#n.get(t.parentKey);if(o!==void 0){if(o!==t.opId)return n.length===0?{modified:!1}:{modified:Fe(this,n),reverse:[]};this.#n.delete(t.parentKey)}const s=this._indexOfPosition(t.parentKey),a=this.#e.find(i=>i._id===t.id);if(a!==void 0){if(a._parentKey===t.parentKey)return{modified:n.length>0?Fe(this,n):!1,reverse:[]};if(s!==-1){this.#t.add(this.#e[s]);const[c]=this.#e.splice(s,1);n.push(Wo(s,c))}const i=this.#e.indexOf(a);a._setParentLink(this,t.parentKey),this._sortItems();const u=this.#e.indexOf(a);return u!==i&&n.push(Fn(i,u,a)),{modified:n.length>0?Fe(this,n):!1,reverse:[]}}else{const i=this._pool.getNode(t.id);if(i&&this.#t.has(i)){i._setParentLink(this,t.parentKey),this.#t.delete(i),this._insertAndSort(i);const u=this.#e.indexOf(i);return{modified:Fe(this,[s===-1?_t(u,i):sr(u,i),...n]),reverse:[]}}else{s!==-1&&this.#e.splice(s,1);const{newItem:u,newIndex:c}=this.#c(t,t.parentKey);return{modified:Fe(this,[s===-1?_t(c,u):sr(c,u),...n]),reverse:[]}}}}#o(t){if(t===void 0||this._pool===void 0)return null;const n=this._pool.getNode(t);if(n===void 0)return null;const r=this._detachChild(n);return r.modified===!1?null:r.modified.updates[0]}#i(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=so(t.parentKey),r=this._indexOfPosition(n);r!==-1&&this.#u(r,n);const{newItem:o,newIndex:s}=this.#c(t,n);return{modified:Fe(this,[_t(s,o)]),reverse:[]}}#a(t){const n=this.#e.find(s=>s._id===t.id),r=so(t.parentKey),o=this._indexOfPosition(r);if(n){if(n._parentKey===r)return{modified:!1};{const s=this.#e.indexOf(n);o!==-1&&this.#u(o,r),n._setParentLink(this,r),this._sortItems();const a=this._indexOfPosition(r);return a===s?{modified:!1}:{modified:Fe(this,[Fn(s,a,n)]),reverse:[]}}}else{const s=pe(this._pool).getNode(t.id);if(s&&this.#t.has(s)){s._setParentLink(this,r),this.#t.delete(s),this._insertAndSort(s);const a=this._indexOfPosition(r);return{modified:Fe(this,[_t(a,s)]),reverse:[]}}else{o!==-1&&this.#u(o,r);const{newItem:a,newIndex:i}=this.#c(t,r);return{modified:Fe(this,[_t(i,a)]),reverse:[]}}}}#l(t){const{id:n,parentKey:r}=t,o=Kr(t);if(this._pool?.getNode(n)!==void 0)return{modified:!1};o._attach(n,pe(this._pool)),o._setParentLink(this,r);const s=this._indexOfPosition(r);let a=r;if(s!==-1){const u=this.#e[s]?._parentPos,c=this.#e[s+1]?._parentPos;a=Yt(u,c),o._setParentLink(this,a)}this._insertAndSort(o);const i=this._indexOfPosition(a);return{modified:Fe(this,[_t(i,o)]),reverse:[{type:5,id:n}]}}#d(t){const{id:n,parentKey:r}=t,o=Kr(t);if(this._pool?.getNode(n)!==void 0)return{modified:!1};this.#n.set(r,pe(t.opId));const s=this._indexOfPosition(r);o._attach(n,pe(this._pool)),o._setParentLink(this,r);const a=r;if(s!==-1){const i=this.#e[s];i._detach(),this.#e[s]=o;const u=zo(i._toOps(pe(this._id),r,this._pool),t.id),c=[sr(s,o)],l=this.#o(t.deletedId);return l&&c.push(l),{modified:Fe(this,c),reverse:u}}else{this._insertAndSort(o),this.#o(t.deletedId);const i=this._indexOfPosition(a);return{reverse:[{type:5,id:n}],modified:Fe(this,[_t(i,o)])}}}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let r;return t.intent==="set"?n===1?r=this.#r(t):n===2?r=this.#s(t):r=this.#d(t):n===1?r=this.#i(t):n===2?r=this.#a(t):r=this.#l(t),r.modified!==!1&&this.invalidate(),r}_detachChild(t){if(t){const n=pe(t._parentKey),r=t._toOps(pe(this._id),n,this._pool),o=this.#e.indexOf(t);if(o===-1)return{modified:!1};const[s]=this.#e.splice(o,1);return this.invalidate(),t._detach(),{modified:Fe(this,[Wo(o,s)]),reverse:r}}return{modified:!1}}#h(t,n){if(this.#t.has(n)){this.#t.delete(n),n._setParentLink(this,t),this._insertAndSort(n);const s=this.#e.indexOf(n);return{modified:Fe(this,[_t(s,n)]),reverse:[]}}const r=n._parentKey;if(t===r)return{modified:!1};const o=this._indexOfPosition(t);if(o===-1){const s=this.#e.indexOf(n);n._setParentLink(this,t),this._sortItems();const a=this.#e.indexOf(n);return a===s?{modified:!1}:{modified:Fe(this,[Fn(s,a,n)]),reverse:[]}}else{this.#e[o]._setParentLink(this,Yt(t,this.#e[o+1]?._parentPos));const s=this.#e.indexOf(n);n._setParentLink(this,t),this._sortItems();const a=this.#e.indexOf(n);return a===s?{modified:!1}:{modified:Fe(this,[Fn(s,a,n)]),reverse:[]}}}#p(t,n){const r=pe(n._parentKey);if(this.#t.has(n)){const o=this._indexOfPosition(t);return this.#t.delete(n),o!==-1&&this.#e[o]._setParentLink(this,Yt(t,this.#e[o+1]?._parentPos)),n._setParentLink(this,t),this._insertAndSort(n),{modified:!1}}else{if(t===r)return{modified:!1};const o=this.#e.indexOf(n),s=this._indexOfPosition(t);s!==-1&&this.#e[s]._setParentLink(this,Yt(t,this.#e[s+1]?._parentPos)),n._setParentLink(this,t),this._sortItems();const a=this.#e.indexOf(n);return o===a?{modified:!1}:{modified:Fe(this,[Fn(o,a,n)]),reverse:[]}}}#f(t,n){const r=pe(n._parentKey),o=this.#e.indexOf(n),s=this._indexOfPosition(t);s!==-1&&this.#e[s]._setParentLink(this,Yt(t,this.#e[s+1]?._parentPos)),n._setParentLink(this,t),this._sortItems();const a=this.#e.indexOf(n);return o===a?{modified:!1}:{modified:Fe(this,[Fn(o,a,n)]),reverse:[{type:1,id:pe(n._id),parentKey:r}]}}_setChildKey(t,n,r){return r===1?this.#h(t,n):r===2?this.#p(t,n):this.#f(t,n)}_apply(t,n){return super._apply(t,n)}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveList if parent is missing");return{type:1,parentId:pe(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this.#e.length}push(t){return this._pool?.assertStorageIsWritable(),this.insert(t,this.length)}insert(t,n){if(this._pool?.assertStorageIsWritable(),n<0||n>this.#e.length)throw new Error(`Cannot insert list item at index "${n}". index should be between 0 and ${this.#e.length}`);const r=this.#e[n-1]?this.#e[n-1]._parentPos:void 0,o=this.#e[n]?this.#e[n]._parentPos:void 0,s=Yt(r,o),a=vr(t);if(a._setParentLink(this,s),this._insertAndSort(a),this._pool&&this._id){const i=this._pool.generateId();a._attach(i,this._pool),this._pool.dispatch(a._toOps(this._id,s,this._pool),[{type:5,id:i}],new Map([[this._id,Fe(this,[_t(n,a)])]]))}}move(t,n){if(this._pool?.assertStorageIsWritable(),n<0)throw new Error("targetIndex cannot be less than 0");if(n>=this.#e.length)throw new Error("targetIndex cannot be greater or equal than the list length");if(t<0)throw new Error("index cannot be less than 0");if(t>=this.#e.length)throw new Error("index cannot be greater or equal than the list length");let r=null,o=null;t<n?(o=n===this.#e.length-1?void 0:this.#e[n+1]._parentPos,r=this.#e[n]._parentPos):(o=this.#e[n]._parentPos,r=n===0?void 0:this.#e[n-1]._parentPos);const s=Yt(r,o),a=this.#e[t],i=a._getParentKeyOrThrow();if(a._setParentLink(this,s),this._sortItems(),this._pool&&this._id){const u=new Map([[this._id,Fe(this,[Fn(t,n,a)])]]);this._pool.dispatch([{type:1,id:pe(a._id),opId:this._pool.generateOpId(),parentKey:s}],[{type:1,id:pe(a._id),parentKey:i}],u)}}delete(t){if(this._pool?.assertStorageIsWritable(),t<0||t>=this.#e.length)throw new Error(`Cannot delete list item at index "${t}". index should be between 0 and ${this.#e.length-1}`);const n=this.#e[t];n._detach();const[r]=this.#e.splice(t,1);if(this.invalidate(),this._pool){const o=n._id;if(o){const s=new Map;s.set(pe(this._id),Fe(this,[Wo(t,r)])),this._pool.dispatch([{id:o,opId:this._pool.generateOpId(),type:5}],n._toOps(pe(this._id),n._getParentKeyOrThrow()),s)}}}clear(){if(this._pool?.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const s of this.#e){s._detach();const a=s._id;a&&(t.push({type:5,id:a,opId:this._pool.generateOpId()}),n.push(...s._toOps(pe(this._id),s._getParentKeyOrThrow())),r.push(Wo(0,s)))}this.#e=[],this.invalidate();const o=new Map;o.set(pe(this._id),Fe(this,r)),this._pool.dispatch(t,n,o)}else{for(const t of this.#e)t._detach();this.#e=[],this.invalidate()}}set(t,n){if(this._pool?.assertStorageIsWritable(),t<0||t>=this.#e.length)throw new Error(`Cannot set list item at index "${t}". index should be between 0 and ${this.#e.length-1}`);const r=this.#e[t],o=r._getParentKeyOrThrow(),s=r._id;r._detach();const a=vr(n);if(a._setParentLink(this,o),this.#e[t]=a,this.invalidate(),this._pool&&this._id){const i=this._pool.generateId();a._attach(i,this._pool);const u=new Map;u.set(this._id,Fe(this,[sr(t,a)]));const c=zo(a._toOps(this._id,o,this._pool),s);this.#n.set(o,pe(c[0].opId));const l=zo(r._toOps(this._id,o,void 0),i);this._pool.dispatch(c,l,u)}}toArray(){return this.#e.map(t=>$n(t))}every(t){return this.toArray().every(t)}filter(t){return this.toArray().filter(t)}find(t){return this.toArray().find(t)}findIndex(t){return this.toArray().findIndex(t)}forEach(t){return this.toArray().forEach(t)}get(t){if(!(t<0||t>=this.#e.length))return $n(this.#e[t])}indexOf(t,n){return this.toArray().indexOf(t,n)}lastIndexOf(t,n){return this.toArray().lastIndexOf(t,n)}map(t){return this.#e.map((n,r)=>t($n(n),r))}some(t){return this.toArray().some(t)}[Symbol.iterator](){return new fC(this.#e)}#c(t,n){const r=Kr(t);r._attach(t.id,pe(this._pool)),r._setParentLink(this,n),this._insertAndSort(r);const o=this._indexOfPosition(n);return{newItem:r,newIndex:o}}#u(t,n){const r=Yt(n,this.#e.length>t+1?this.#e[t+1]?._parentPos:void 0);this.#e[t]._setParentLink(this,r)}_toTreeNode(t){return{type:"LiveList",id:this._id??Nr(),key:t,payload:this.#e.map((n,r)=>n.toTreeNode(r.toString()))}}toImmutable(){return super.toImmutable()}_toImmutable(){return this.#e.map(n=>n.toImmutable())}clone(){return new mi(this.#e.map(t=>t.clone()))}},fC=class{#e;constructor(e){this.#e=e[Symbol.iterator]()}[Symbol.iterator](){return this}next(){const e=this.#e.next();return e.done?{done:!0,value:void 0}:{value:$n(e.value)}}};function Fe(e,t){return{node:e,type:"LiveList",updates:t}}function sr(e,t){return{index:e,type:"set",item:t instanceof Sn?t.data:t}}function Wo(e,t){return{type:"delete",index:e,deletedItem:t instanceof Sn?t.data:t}}function _t(e,t){return{index:e,type:"insert",item:t instanceof Sn?t.data:t}}function Fn(e,t,n){return{type:"move",index:t,item:n instanceof Sn?n.data:n,previousIndex:e}}function zo(e,t){return e.map((n,r)=>r===0?{...n,intent:"set",deletedId:t}:n)}var Mr=class vi extends Hs{#e;#t;constructor(t){if(super(),this.#t=new Map,t){const n=[];for(const[r,o]of t){const s=vr(o);s._setParentLink(this,r),n.push([r,s])}this.#e=new Map(n)}else this.#e=new Map}_toOps(t,n,r){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const o=[],s={id:this._id,opId:r?.generateOpId(),type:7,parentId:t,parentKey:n};o.push(s);for(const[a,i]of this.#e)o.push(...i._toOps(this._id,a,r));return o}static _deserialize([t,n],r,o){const s=new vi;s._attach(t,o);const a=r.get(t);if(a===void 0)return s;for(const[i,u]of a){const c=$d([i,u],r,o);c._setParentLink(s,u.parentKey),s.#e.set(u.parentKey,c),s.invalidate()}return s}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)We(o)&&o._attach(n.generateId(),n)}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:r,parentKey:o,opId:s}=t,a=o,i=Kr(t);if(this._pool.getNode(r)!==void 0)return{modified:!1};if(n===2){const l=this.#t.get(a);if(l===s)return this.#t.delete(a),{modified:!1};if(l!==void 0)return{modified:!1}}else n===1&&this.#t.delete(a);const u=this.#e.get(a);let c;if(u){const l=pe(this._id);c=u._toOps(l,a),u._detach()}else c=[{type:5,id:r}];return i._setParentLink(this,a),i._attach(r,this._pool),this.#e.set(a,i),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[a]:{type:"update"}}},reverse:c}}_detach(){super._detach();for(const t of this.#e.values())t._detach()}_detachChild(t){const n=pe(this._id),r=pe(t._parentKey),o=t._toOps(n,r,this._pool);for(const[a,i]of this.#e)i===t&&(this.#e.delete(a),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveMap",updates:{[r]:{type:"delete"}}},reverse:o}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:2,parentId:pe(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(t){const n=this.#e.get(t);if(n!==void 0)return $n(n)}set(t,n){this._pool?.assertStorageIsWritable();const r=this.#e.get(t);r&&r._detach();const o=vr(n);if(o._setParentLink(this,t),this.#e.set(t,o),this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();o._attach(s,this._pool);const a=new Map;a.set(this._id,{node:this,type:"LiveMap",updates:{[t]:{type:"update"}}});const i=o._toOps(this._id,t,this._pool);this.#t.set(t,pe(i[0].opId)),this._pool.dispatch(o._toOps(this._id,t,this._pool),r?r._toOps(this._id,t):[{type:5,id:s}],a)}}get size(){return this.#e.size}has(t){return this.#e.has(t)}delete(t){this._pool?.assertStorageIsWritable();const n=this.#e.get(t);if(n===void 0)return!1;if(n._detach(),this.#e.delete(t),this.invalidate(),this._pool&&n._id){const r=pe(this._id),o=new Map;o.set(r,{node:this,type:"LiveMap",updates:{[t]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:n._id,opId:this._pool.generateOpId()}],n._toOps(r,t),o)}return!0}entries(){const t=this.#e.entries();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return{done:!0,value:void 0};const o=n.value[0],s=$n(n.value[1]);return{value:[o,s]}}}}[Symbol.iterator](){return this.entries()}keys(){return this.#e.keys()}values(){const t=this.#e.values();return{[Symbol.iterator](){return this},next(){const n=t.next();return n.done?{done:!0,value:void 0}:{value:$n(n.value)}}}}forEach(t){for(const n of this)t(n[1],n[0],this)}_toTreeNode(t){return{type:"LiveMap",id:this._id??Nr(),key:t,payload:Array.from(this.#e.entries()).map(([n,r])=>r.toTreeNode(n))}}toImmutable(){return super.toImmutable()}_toImmutable(){const t=new Map;for(const[n,r]of this.#e)t.set(n,r.toImmutable());return En(t)}clone(){return new vi(Array.from(this.#e).map(([t,n])=>[t,n.clone()]))}},Jn=class Vr extends Hs{#e;#t;static#n(t){const n=new Map;let r=null;for(const[o,s]of t)if(uC(s))r=[o,s];else{const a=[o,s],i=n.get(s.parentId);i!==void 0?i.push(a):n.set(s.parentId,[a])}if(r===null)throw new Error("Root can't be null");return[r,n]}static _fromItems(t,n){const[r,o]=Vr.#n(t);return Vr._deserialize(r,o,n)}constructor(t={}){super(),this.#t=new Map;const n=xo(t);for(const r of Object.keys(n)){const o=n[r];We(o)&&o._setParentLink(this,r)}this.#e=new Map(Object.entries(n))}_toOps(t,n,r){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const o=r?.generateOpId(),s=[],a={type:4,id:this._id,opId:o,parentId:t,parentKey:n,data:{}};s.push(a);for(const[i,u]of this.#e)We(u)?s.push(...u._toOps(this._id,i,r)):a.data[i]=u;return s}static _deserialize([t,n],r,o){const s=new Vr(n.data);return s._attach(t,o),this._deserializeChildren(s,r,o)}static _deserializeChildren(t,n,r){const o=n.get(pe(t._id));if(o===void 0)return t;for(const[s,a]of o){const i=dC([s,a],n,r);hr(i)&&i._setParentLink(t,a.parentKey),t.#e.set(a.parentKey,i),t.invalidate()}return t}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)We(o)&&o._attach(n.generateId(),n)}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:r,opId:o,parentKey:s}=t,a=jd(t);if(this._pool.getNode(r)!==void 0)return this.#t.get(s)===o&&this.#t.delete(s),{modified:!1};if(n===0)this.#t.set(s,pe(o));else if(this.#t.get(s)!==void 0)return this.#t.get(s)===o?(this.#t.delete(s),{modified:!1}):{modified:!1};const i=pe(this._id),u=this.#e.get(s);let c;return We(u)?(c=u._toOps(i,s),u._detach()):u===void 0?c=[{type:6,id:i,key:s}]:c=[{type:3,id:i,data:{[s]:u}}],this.#e.set(s,a),this.invalidate(),hr(a)&&(a._setParentLink(this,s),a._attach(r,this._pool)),{reverse:c,modified:{node:this,type:"LiveObject",updates:{[s]:{type:"update"}}}}}_detachChild(t){if(t){const n=pe(this._id),r=pe(t._parentKey),o=t._toOps(n,r,this._pool);for(const[a,i]of this.#e)i===t&&(this.#e.delete(a),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveObject",updates:{[r]:{type:"delete"}}},reverse:o}}return{modified:!1}}_detach(){super._detach();for(const t of this.#e.values())We(t)&&t._detach()}_apply(t,n){return t.type===3?this.#r(t,n):t.type===6?this.#s(t,n):super._apply(t,n)}_serialize(){const t={};for(const[n,r]of this.#e)We(r)||(t[n]=r);return this.parent.type==="HasParent"&&this.parent.node._id?{type:0,parentId:this.parent.node._id,parentKey:this.parent.key,data:t}:{type:0,data:t}}#r(t,n){let r=!1;const o=pe(this._id),s=[],a={type:3,id:o,data:{}};for(const u in t.data){const c=this.#e.get(u);We(c)?(s.push(...c._toOps(o,u)),c._detach()):c!==void 0?a.data[u]=c:c===void 0&&s.push({type:6,id:o,key:u})}const i={};for(const u in t.data){const c=t.data[u];if(c===void 0)continue;if(n)this.#t.set(u,pe(t.opId));else if(this.#t.get(u)===void 0)r=!0;else if(this.#t.get(u)===t.opId){this.#t.delete(u);continue}else continue;const l=this.#e.get(u);We(l)&&l._detach(),r=!0,i[u]={type:"update"},this.#e.set(u,c),this.invalidate()}return Object.keys(a.data).length!==0&&s.unshift(a),r?{modified:{node:this,type:"LiveObject",updates:i},reverse:s}:{modified:!1}}#s(t,n){const r=t.key;if(this.#e.has(r)===!1)return{modified:!1};if(!n&&this.#t.get(r)!==void 0)return{modified:!1};const o=this.#e.get(r),s=pe(this._id);let a=[];return We(o)?(a=o._toOps(s,t.key),o._detach()):o!==void 0&&(a=[{type:3,id:s,data:{[r]:o}}]),this.#e.delete(r),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[t.key]:{type:"delete"}}},reverse:a}}toObject(){return Object.fromEntries(this.#e)}set(t,n){this._pool?.assertStorageIsWritable(),this.update({[t]:n})}get(t){return this.#e.get(t)}delete(t){this._pool?.assertStorageIsWritable();const n=t,r=this.#e.get(n);if(r===void 0)return;if(this._pool===void 0||this._id===void 0){We(r)&&r._detach(),this.#e.delete(n),this.invalidate();return}let o;We(r)?(r._detach(),o=r._toOps(this._id,n)):o=[{type:3,data:{[n]:r},id:this._id}],this.#e.delete(n),this.invalidate();const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:{[t]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:n,id:this._id,opId:this._pool.generateOpId()}],o,s)}update(t){if(this._pool?.assertStorageIsWritable(),this._pool===void 0||this._id===void 0){for(const c in t){const l=t[c];if(l===void 0)continue;const d=this.#e.get(c);We(d)&&d._detach(),We(l)&&l._setParentLink(this,c),this.#e.set(c,l),this.invalidate()}return}const n=[],r=[],o=this._pool.generateOpId(),s={},a={id:this._id,type:3,data:{}},i={};for(const c in t){const l=t[c];if(l===void 0)continue;const d=this.#e.get(c);if(We(d)?(r.push(...d._toOps(this._id,c)),d._detach()):d===void 0?r.push({type:6,id:this._id,key:c}):a.data[c]=d,We(l)){l._setParentLink(this,c),l._attach(this._pool.generateId(),this._pool);const m=l._toOps(this._id,c,this._pool),g=m.find(C=>C.parentId===this._id);g&&this.#t.set(c,pe(g.opId)),n.push(...m)}else s[c]=l,this.#t.set(c,o);this.#e.set(c,l),this.invalidate(),i[c]={type:"update"}}Object.keys(a.data).length!==0&&r.unshift(a),Object.keys(s).length!==0&&n.unshift({opId:o,id:this._id,type:3,data:s});const u=new Map;u.set(this._id,{node:this,type:"LiveObject",updates:i}),this._pool.dispatch(n,r,u)}toImmutable(){return super.toImmutable()}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??Nr();return{type:"LiveObject",id:n,key:t,payload:Array.from(this.#e.entries()).map(([r,o])=>We(o)?o.toTreeNode(r):{type:"Json",id:`${n}:${r}`,key:r,payload:o})}}_toImmutable(){const t={};for(const[n,r]of this.#e)t[n]=hr(r)?r.toImmutable():r;return t}clone(){return new Vr(Object.fromEntries(Array.from(this.#e).map(([t,n])=>[t,hr(n)?n.clone():oo(n)])))}};function Kr(e){return vr(jd(e))}function jd(e){switch(e.type){case 8:return e.data;case 4:return new Jn(e.data);case 7:return new Mr;case 2:return new kr([]);default:return lt(e,"Unknown creation Op")}}function Ld(e,t){return e===t?!0:e.parent.type==="HasParent"?Ld(e.parent.node,t):!1}function $d([e,t],n,r){switch(t.type){case 0:return Jn._deserialize([e,t],n,r);case 1:return kr._deserialize([e,t],n,r);case 2:return Mr._deserialize([e,t],n,r);case 3:return Sn._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function dC([e,t],n,r){switch(t.type){case 0:return Jn._deserialize([e,t],n,r);case 1:return kr._deserialize([e,t],n,r);case 2:return Mr._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function hr(e){return Ud(e)||hC(e)||pC(e)}function We(e){return hr(e)||mC(e)}function Ud(e){return e instanceof kr}function hC(e){return e instanceof Mr}function pC(e){return e instanceof Jn}function mC(e){return e instanceof Sn}function vC(e){return e===void 0?void 0:hr(e)?e.clone():oo(e)}function $n(e){return e instanceof Sn?e.data:e instanceof kr||e instanceof Mr||e instanceof Jn?e:lt(e,"Unknown AbstractCrdt")}function vr(e){return e instanceof Jn||e instanceof Mr||e instanceof kr?e:new Sn(e)}function gC(e,t){const n=[];return e.forEach((r,o)=>{t.get(o)||n.push({type:5,id:o})}),t.forEach((r,o)=>{const s=e.get(o);if(s)r.type===0&&(s.type!==0||tn(r.data)!==tn(s.data))&&n.push({type:3,id:o,data:r.data}),r.parentKey!==s.parentKey&&n.push({type:1,id:o,parentKey:pe(r.parentKey,"Parent key must not be missing")});else switch(r.type){case 3:n.push({type:8,id:o,parentId:r.parentId,parentKey:r.parentKey,data:r.data});break;case 1:n.push({type:2,id:o,parentId:r.parentId,parentKey:r.parentKey});break;case 0:if(r.parentId===void 0||r.parentKey===void 0)throw new Error("Internal error. Cannot serialize storage root into an operation");n.push({type:4,id:o,parentId:r.parentId,parentKey:r.parentKey,data:r.data});break;case 2:n.push({type:7,id:o,parentId:r.parentId,parentKey:r.parentKey});break}}),n}function CC(e,t){const n=e.updates;for(const[r,o]of Zi(t.updates))n[r]=o;return{...t,updates:n}}function yC(e,t){const n=e.updates;for(const[r,o]of Zi(t.updates))n[r]=o;return{...t,updates:n}}function bC(e,t){const n=e.updates;return{...t,updates:n.concat(t.updates)}}function Ta(e,t){return e===void 0?t:e.type==="LiveObject"&&t.type==="LiveObject"?CC(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?yC(e,t):e.type==="LiveList"&&t.type==="LiveList"?bC(e,t):t}var Ra=class{#e;#t;#n;#r;constructor(){this.#e={},this.#t=0,this.#n=1,this.#r=0}get length(){return this.#r}*[Symbol.iterator](){const e=this.#r,t=this.#t;for(let n=0;n<e;n++)yield this.#e[t+n]}push(e){const t=Array.isArray(e)?e:[e];this.#n>Number.MAX_SAFE_INTEGER-t.length-1&&wt("Deque full");for(const n of t)this.#e[this.#n++-1]=n;this.#r+=t.length}pop(){if(this.#r<1)return;this.#n--;const e=this.#e[this.#n-1];return delete this.#e[this.#n-1],this.#r--,e}pushLeft(e){const t=Array.isArray(e)?e:[e];this.#t<Number.MIN_SAFE_INTEGER+t.length&&wt("Deque full");for(let n=t.length-1;n>=0;n--)this.#e[--this.#t]=t[n];this.#r+=t.length}popLeft(){if(this.#r<1)return;const e=this.#e[this.#t];return delete this.#e[this.#t],this.#t++,this.#r--,e}};function EC(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Hd(e){return Array.isArray(e)}function DC(e){return!EC(e)&&!Hd(e)}function wC(e,t){const{connectionId:n,id:r,info:o}=e,s=hi(e.scopes);return En(xo({connectionId:n,id:r,info:o,canWrite:s,canComment:Md(e.scopes),isReadOnly:!s,presence:t}))}var AC=class{#e;#t;signal;constructor(){this.#e=new Zn({connections:new Map,presences:new Map}),this.signal=Xe.from(this.#e,e=>ci(Array.from(this.#e.get().presences.keys()).map(t=>this.getUser(Number(t))))),this.#t=new Map}get(){return this.signal.get()}connectionIds(){return this.#e.get().connections.keys()}clearOthers(){this.#e.mutate(e=>{e.connections.clear(),e.presences.clear(),this.#t.clear()})}#n(e){const t=this.#e.get(),n=t.connections.get(e),r=t.presences.get(e);if(n!==void 0&&r!==void 0)return wC(n,r)}getUser(e){const t=this.#t.get(e);if(t)return t;const n=this.#n(e);if(n)return this.#t.set(e,n),n}#r(e){this.#t.delete(e)}setConnection(e,t,n,r){this.#e.mutate(o=>(o.connections.set(e,En({connectionId:e,id:t,info:n,scopes:r})),o.presences.has(e)?this.#r(e):!1))}removeConnection(e){this.#e.mutate(t=>{t.connections.delete(e),t.presences.delete(e),this.#r(e)})}setOther(e,t){this.#e.mutate(n=>(n.presences.set(e,En(xo(t))),n.connections.has(e)?this.#r(e):!1))}patchOther(e,t){this.#e.mutate(n=>{const r=n.presences.get(e);if(r===void 0)return!1;const o=Od(r,t);return r===o?!1:(n.presences.set(e,En(o)),this.#r(e))})}},Wd=class zd extends Error{context;constructor(t,n,r){super(t,{cause:r}),this.context=n,this.name="LiveblocksError"}get roomId(){return this.context.roomId}get code(){return this.context.code}static from(t,n){return new zd(xC(t),t,n)}};function xC(e){switch(e.type){case"ROOM_CONNECTION_ERROR":switch(e.code){case 4001:return"Not allowed to connect to the room";case 4005:return"Room is already full";case 4006:return"Kicked out of the room, because the room ID changed";default:return"Could not connect to the room"}case"CREATE_THREAD_ERROR":return"Could not create new thread";case"DELETE_THREAD_ERROR":return"Could not delete thread";case"EDIT_THREAD_METADATA_ERROR":return"Could not edit thread metadata";case"MARK_THREAD_AS_RESOLVED_ERROR":return"Could not mark thread as resolved";case"MARK_THREAD_AS_UNRESOLVED_ERROR":return"Could not mark thread as unresolved";case"CREATE_COMMENT_ERROR":return"Could not create new comment";case"EDIT_COMMENT_ERROR":return"Could not edit comment";case"DELETE_COMMENT_ERROR":return"Could not delete comment";case"ADD_REACTION_ERROR":return"Could not add reaction";case"REMOVE_REACTION_ERROR":return"Could not remove reaction";case"MARK_INBOX_NOTIFICATION_AS_READ_ERROR":return"Could not mark inbox notification as read";case"DELETE_INBOX_NOTIFICATION_ERROR":return"Could not delete inbox notification";case"MARK_ALL_INBOX_NOTIFICATIONS_AS_READ_ERROR":return"Could not mark all inbox notifications as read";case"DELETE_ALL_INBOX_NOTIFICATIONS_ERROR":return"Could not delete all inbox notifications";case"UPDATE_NOTIFICATION_SETTINGS_ERROR":return"Could not update notification settings";case"UPDATE_USER_NOTIFICATION_SETTINGS_ERROR":return"Could not update user notification settings";default:return lt(e,"Unhandled case")}}var _c=1024*1024-512;function OC(e){let t=0;return()=>`${e}:${t++}`}function jc(e,t){return{type:"User",id:`${t.connectionId}`,key:e,payload:{connectionId:t.connectionId,id:t.id,info:t.info,presence:t.presence,isReadOnly:!t.canWrite}}}function SC(){const e=typeof document<"u"?document:void 0,t={current:null};function n(){e?.visibilityState==="hidden"?t.current=t.current??Date.now():t.current=null}return e?.addEventListener("visibilitychange",n),[t,()=>{e?.removeEventListener("visibilitychange",n)}]}function TC(e,t){const n=t.roomId,r=e.initialPresence,o=e.initialStorage,s=t.roomHttpClient,[a,i]=SC(),u={...t.delegates,canZombie(){return t.backgroundKeepAliveTimeout!==void 0&&a.current!==null&&Date.now()>a.current+t.backgroundKeepAliveTimeout&&_o()!=="synchronizing"}},c=new H0(u,t.enableDebugLogging),l={buffer:{flushTimerID:void 0,lastFlushedAt:0,presenceUpdates:{type:"full",data:r},messages:[],storageOperations:[]},staticSessionInfoSig:new zt(null),dynamicSessionInfoSig:new zt(null),myPresence:new d0(r),others:new AC,initialStorage:o,idFactory:null,yjsProvider:void 0,yjsProviderDidChange:Ie(),pool:aC(n,{getCurrentConnectionId:R,onDispatch:b,isStorageWritable:w}),root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,unacknowledgedOps:new Map};let d;function m(A){const K=c.authValue;if(K!==null){const Z=Id(K);if(Z!==d)if(d=Z,K.type==="secret"){const oe=K.token.parsed;l.staticSessionInfoSig.set({userId:oe.k==="sec-legacy"?oe.id:oe.uid,userInfo:oe.k==="sec-legacy"?oe.info:oe.ui})}else l.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}D.status.notify(A),L()}let g,C=!1;function v(A){A==="reconnecting"?g=setTimeout(()=>{D.lostConnection.notify("lost"),C=!0,l.others.clearOthers(),G({others:[{type:"reset"}]})},t.lostConnectionTimeout):(clearTimeout(g),C&&(A==="disconnected"?D.lostConnection.notify("failed"):D.lostConnection.notify("restored"),C=!1))}function p(){l.buffer.presenceUpdates={type:"full",data:{...l.myPresence.get()}},Ee!==null&&yt({flush:!1}),he()}function E(){clearTimeout(l.buffer.flushTimerID)}c.events.onMessage.subscribe(je),c.events.statusDidChange.subscribe(m),c.events.statusDidChange.subscribe(v),c.events.didConnect.subscribe(p),c.events.didDisconnect.subscribe(E),c.events.onConnectionError.subscribe(({message:A,code:K})=>{const Z="ROOM_CONNECTION_ERROR",oe=new Wd(A,{type:Z,code:K,roomId:n});t.errorEventSource.notify(oe)});function b(A,K,Z){if(l.activeBatch){for(const oe of A)l.activeBatch.ops.push(oe);for(const[oe,Se]of Z)l.activeBatch.updates.storageUpdates.set(oe,Ta(l.activeBatch.updates.storageUpdates.get(oe),Se));l.activeBatch.reverseOps.pushLeft(K)}else de(K),l.redoStack.length=0,ye(A),G({storageUpdates:Z})}function w(){const A=l.dynamicSessionInfoSig.get()?.scopes;return A!==void 0?hi(A):!0}const D={status:Ie(),lostConnection:Ie(),customEvent:Ie(),self:Ie(),myPresence:Ie(),others:Ie(),storageBatch:Ie(),history:Ie(),storageDidLoad:Ie(),storageStatus:Ie(),ydoc:Ie(),comments:Ie(),roomWillDestroy:Ie()};async function x(A,K){return s.createTextMention({roomId:n,userId:A,mentionId:K})}async function I(A){return s.deleteTextMention({roomId:n,mentionId:A})}async function S(A,K){await s.reportTextEditor({roomId:n,type:A,rootKey:K})}async function k(){return s.listTextVersions({roomId:n})}async function H(A){return s.listTextVersionsSince({roomId:n,since:A.since,signal:A.signal})}async function P(A){return s.getTextVersion({roomId:n,versionId:A})}async function j(){return s.createTextVersion({roomId:n})}async function B(A){return s.executeContextualPrompt({roomId:n,...A})}function*N(A){const{ops:K,...Z}=A;if(K.length<2)throw new Error("Cannot split ops into smaller chunks");const oe=Math.floor(K.length/2),Se=K.slice(0,oe),Re=K.slice(oe);for(const Mt of[Se,Re]){const Qe={ops:Mt,...Z},Rn=tn([Qe]);W(Rn)?yield*N(Qe):yield Rn}}function*M(A){if(A.length<2)if(A[0].type===201){yield*N(A[0]);return}else throw new Error("Cannot split into chunks smaller than the allowed message size");const K=Math.floor(A.length/2),Z=A.slice(0,K),oe=A.slice(K);for(const Se of[Z,oe]){const Re=tn(Se);W(Re)?yield*M(Se):yield Re}}function W(A){return A.length*4<_c?!1:new TextEncoder().encode(A).length>=_c}function re(A){const K=t.largeMessageStrategy??"default",Z=tn(A);if(!W(Z))return c.send(Z);switch(K){case"default":{Ao("Message is too large for websockets, not sending. Configure largeMessageStrategy option to deal with this.");return}case"split":{ft("Message is too large for websockets, splitting into smaller chunks");for(const oe of M(A))c.send(oe);return}case"experimental-fallback-to-http":{ft("Message is too large for websockets, so sending over HTTP instead");const oe=l.dynamicSessionInfoSig.get()?.nonce??wt("Session is not authorized to send message over HTTP");s.sendMessages({roomId:n,nonce:oe,messages:A}).then(Se=>{!Se.ok&&Se.status===403&&c.reconnect()});return}}}const Y=Xe.from(l.staticSessionInfoSig,l.dynamicSessionInfoSig,l.myPresence,(A,K,Z)=>{if(A===null||K===null)return null;{const oe=hi(K.scopes);return{connectionId:K.actor,id:A.userId,info:A.userInfo,presence:Z,canWrite:oe,canComment:Md(K.scopes)}}});let ee;function L(){const A=Y.get();A!==null&&A!==ee&&(D.self.notify(A),ee=A)}const Q=Xe.from(Y,A=>A!==null?jc("Me",A):null);function V(A){if(A.items.length===0)throw new Error("Internal error: cannot load storage without items");l.root!==void 0?te(A.items):l.root=Jn._fromItems(A.items,l.pool);const K=Y.get()?.canWrite??!0,Z=l.undoStack.length;for(const oe in l.initialStorage)l.root.get(oe)===void 0&&(K?l.root.set(oe,vC(l.initialStorage[oe])):ft(`Attempted to populate missing storage key '${oe}', but current user has no write access`));l.undoStack.length=Z}function te(A){if(l.root===void 0)return;const K=new Map;for(const[Se,Re]of l.pool.nodes)K.set(Se,Re._serialize());const Z=gC(K,new Map(A)),oe=_(Z,!1);G(oe.updates)}function se(A){l.undoStack.length>=50&&l.undoStack.shift(),l.undoStack.push(A),ie()}function de(A){l.pausedHistory!==null?l.pausedHistory.pushLeft(A):se(A)}function G(A){const K=A.storageUpdates,Z=A.others;if(Z!==void 0&&Z.length>0){const oe=l.others.get();for(const Se of Z)D.others.notify({...Se,others:oe})}if((A.presence??!1)&&(L(),D.myPresence.notify(l.myPresence.get())),K!==void 0&&K.size>0){const oe=Array.from(K.values());D.storageBatch.notify(oe)}jo()}function R(){const A=l.dynamicSessionInfoSig.get();if(A)return A.actor;throw new Error("Internal. Tried to get connection id but connection was never open")}function _(A,K){const Z={reverse:new Ra,storageUpdates:new Map,presence:!1},oe=new Set,Se=A.map(Re=>Re.type!=="presence"&&!Re.opId?{...Re,opId:l.pool.generateOpId()}:Re);for(const Re of Se)if(Re.type==="presence"){const Mt={type:"presence",data:{}};for(const Qe in Re.data)Mt.data[Qe]=l.myPresence.get()[Qe];if(l.myPresence.patch(Re.data),l.buffer.presenceUpdates===null)l.buffer.presenceUpdates={type:"partial",data:Re.data};else for(const Qe in Re.data)l.buffer.presenceUpdates.data[Qe]=Re.data[Qe];Z.reverse.pushLeft(Mt),Z.presence=!0}else{let Mt;if(K)Mt=0;else{const Rn=pe(Re.opId);Mt=l.unacknowledgedOps.delete(Rn)?2:1}const Qe=U(Re,Mt);if(Qe.modified){const Rn=Qe.modified.node._id;Rn&&oe.has(Rn)||(Z.storageUpdates.set(pe(Qe.modified.node._id),Ta(Z.storageUpdates.get(pe(Qe.modified.node._id)),Qe.modified)),Z.reverse.pushLeft(Qe.reverse)),(Re.type===2||Re.type===7||Re.type===4)&&oe.add(pe(Re.id))}}return{ops:Se,reverse:Array.from(Z.reverse),updates:{storageUpdates:Z.storageUpdates,presence:Z.presence}}}function U(A,K){if(sC(A))return{modified:!1};switch(A.type){case 6:case 3:case 5:{const Z=l.pool.nodes.get(A.id);return Z===void 0?{modified:!1}:Z._apply(A,K===0)}case 1:{const Z=l.pool.nodes.get(A.id);return Z===void 0?{modified:!1}:Z.parent.type==="HasParent"&&Ud(Z.parent.node)?Z.parent.node._setChildKey(so(A.parentKey),Z,K):{modified:!1}}case 4:case 2:case 7:case 8:{if(A.parentId===void 0)return{modified:!1};const Z=l.pool.nodes.get(A.parentId);return Z===void 0?{modified:!1}:Z._attachChild(A,K)}}}function X(A,K){const Z={};l.buffer.presenceUpdates===null&&(l.buffer.presenceUpdates={type:"partial",data:{}});for(const oe in A){const Se=A[oe];Se!==void 0&&(l.buffer.presenceUpdates.data[oe]=Se,Z[oe]=l.myPresence.get()[oe])}l.myPresence.patch(A),l.activeBatch?(K?.addToHistory&&l.activeBatch.reverseOps.pushLeft({type:"presence",data:Z}),l.activeBatch.updates.presence=!0):(he(),K?.addToHistory&&de([{type:"presence",data:Z}]),G({presence:!0}))}function fe(A){if(A.targetActor!==void 0){const Z=l.others.getUser(A.actor);l.others.setOther(A.actor,A.data);const oe=l.others.getUser(A.actor);if(Z===void 0&&oe!==void 0)return{type:"enter",user:oe}}else l.others.patchOther(A.actor,A.data);const K=l.others.getUser(A.actor);if(K)return{type:"update",updates:A.data,user:K}}function le(A){const K=l.others.getUser(A.actor);return K?(l.others.removeConnection(A.actor),{type:"leave",user:K}):null}function T(A){l.dynamicSessionInfoSig.set({actor:A.actor,nonce:A.nonce,scopes:A.scopes}),l.idFactory=OC(A.actor),L();for(const K of l.others.connectionIds())A.users[K]===void 0&&l.others.removeConnection(K);for(const K in A.users){const Z=A.users[K],oe=Number(K);l.others.setConnection(oe,Z.id,Z.info,Z.scopes)}return{type:"reset"}}function q(){return l.undoStack.length>0}function ne(){return l.redoStack.length>0}function ie(){D.history.notify({canUndo:q(),canRedo:ne()})}function we(A){l.others.setConnection(A.actor,A.id,A.info,A.scopes),l.buffer.messages.push({type:100,data:l.myPresence.get(),targetActor:A.actor}),he();const K=l.others.getUser(A.actor);return K?{type:"enter",user:K}:void 0}function xe(A){return DC(A)?A:null}function ae(A){const K=$s(A);return K===void 0?null:Hd(K)?ci(K.map(Z=>xe(Z))):ci([xe(K)])}function Te(A){if(A.size===0)return;const K=[],Z=Array.from(A.values()),oe=_(Z,!0);K.push({type:201,ops:oe.ops}),G(oe.updates),re(K)}function je(A){if(typeof A.data!="string")return;const K=ae(A.data);if(K===null||K.length===0)return;const Z={storageUpdates:new Map,others:[]};for(const oe of K)switch(oe.type){case 101:{const Se=we(oe);Se&&Z.others.push(Se);break}case 100:{const Se=fe(oe);Se&&Z.others.push(Se);break}case 103:{const Se=l.others.get();D.customEvent.notify({connectionId:oe.actor,user:oe.actor<0?null:Se.find(Re=>Re.connectionId===oe.actor)??null,event:oe.event});break}case 102:{const Se=le(oe);Se&&Z.others.push(Se);break}case 300:{D.ydoc.notify(oe);break}case 104:{Z.others.push(T(oe));break}case 200:{$e(oe);break}case 201:{const Se=_(oe.ops,!1);for(const[Re,Mt]of Se.updates.storageUpdates)Z.storageUpdates.set(Re,Ta(Z.storageUpdates.get(Re),Mt));break}case 299:{Dd("Storage mutation rejection error",oe.reason);break}case 400:case 407:case 401:case 408:case 405:case 406:case 402:case 403:case 404:{D.comments.notify(oe);break}}G(Z)}function he(){const A=l.buffer.storageOperations;if(A.length>0){for(const oe of A)l.unacknowledgedOps.set(pe(oe.opId),oe);jo()}if(c.getStatus()!=="connected"){l.buffer.storageOperations=[];return}const K=Date.now(),Z=K-l.buffer.lastFlushedAt;if(Z>=t.throttleDelay){const oe=Ce();if(oe.length===0)return;re(oe),l.buffer={flushTimerID:void 0,lastFlushedAt:K,messages:[],storageOperations:[],presenceUpdates:null}}else clearTimeout(l.buffer.flushTimerID),l.buffer.flushTimerID=setTimeout(he,t.throttleDelay-Z)}function Ce(){const A=[];l.buffer.presenceUpdates&&A.push(l.buffer.presenceUpdates.type==="full"?{type:100,targetActor:-1,data:l.buffer.presenceUpdates.data}:{type:100,data:l.buffer.presenceUpdates.data});for(const K of l.buffer.messages)A.push(K);return l.buffer.storageOperations.length>0&&A.push({type:201,ops:l.buffer.storageOperations}),A}function ke(A,K,Z){const oe={type:301,update:A,guid:K,v2:Z};l.buffer.messages.push(oe),D.ydoc.notify(oe),he()}function Pe(A,K={shouldQueueEventIfNotReady:!1}){c.getStatus()!=="connected"&&!K.shouldQueueEventIfNotReady||(l.buffer.messages.push({type:103,event:A}),he())}function ye(A){const{storageOperations:K}=l.buffer;for(const Z of A)K.push(Z);he()}let Ee=null,Ct=null;function $e(A){const K=new Map(l.unacknowledgedOps);V(A),Te(K),Ct?.(),jo(),D.storageDidLoad.notify()}async function qe(){if(!c.authValue)return;const A=await s.streamStorage({roomId:n});$e({items:A})}function yt(A){const K=l.buffer.messages;t.unstable_streamData?qe():K.some(Z=>Z.type===200)||K.push({type:200}),A.flush&&he()}function Je(){return Ee===null&&(yt({flush:!0}),Ee=new Promise(A=>{Ct=A}),jo()),Ee}function rr(){const A=l.root;return A!==void 0?A:(Je(),null)}async function cn(){return l.root!==void 0?Promise.resolve({root:l.root}):(await Je(),{root:pe(l.root)})}function ln(A,K,Z){l.buffer.messages.find(oe=>oe.type===300&&oe.vector===A&&oe.guid===K&&oe.v2===Z)||l.buffer.messages.push({type:300,vector:A,guid:K,v2:Z}),he()}function ga(){if(l.activeBatch)throw new Error("undo is not allowed during a batch");const A=l.undoStack.pop();if(A===void 0)return;l.pausedHistory=null;const K=_(A,!0);G(K.updates),l.redoStack.push(K.reverse),ie();for(const Z of K.ops)Z.type!=="presence"&&l.buffer.storageOperations.push(Z);he()}function Ca(){if(l.activeBatch)throw new Error("redo is not allowed during a batch");const A=l.redoStack.pop();if(A===void 0)return;l.pausedHistory=null;const K=_(A,!0);G(K.updates),l.undoStack.push(K.reverse),ie();for(const Z of K.ops)Z.type!=="presence"&&l.buffer.storageOperations.push(Z);he()}function ya(){l.undoStack.length=0,l.redoStack.length=0}function ba(A){if(l.activeBatch)return A();let K;l.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:new Ra};try{K=A()}finally{const Z=l.activeBatch;l.activeBatch=null,Z.reverseOps.length>0&&de(Array.from(Z.reverseOps)),Z.ops.length>0&&(l.redoStack.length=0),Z.ops.length>0&&ye(Z.ops),G(Z.updates),he()}return K}function Ea(){l.pausedHistory===null&&(l.pausedHistory=new Ra)}function Da(){const A=l.pausedHistory;l.pausedHistory=null,A!==null&&A.length>0&&se(Array.from(A))}const mc=t.createSyncSource();function _o(){return l.root===void 0?Ee===null?"not-loaded":"loading":l.unacknowledgedOps.size===0?"synchronized":"synchronizing"}let vc=_o();function jo(){const A=_o();vc!==A&&(vc=A,D.storageStatus.notify(A)),mc.setSyncStatus(A==="synchronizing"?"synchronizing":"synchronized")}function gc(){return Y.get()!==null}async function Cg(){for(;!gc();){const{promise:A,resolve:K}=xd(),Z=Lo.self.subscribeOnce(K),oe=Lo.status.subscribeOnce(K);await A,Z(),oe()}}function Cc(){return rr()!==null}async function yg(){for(;!Cc();)await cn()}const bg=Xe.from(l.others.signal,A=>A.map((K,Z)=>jc(`Other ${Z}`,K))),Lo={status:D.status.observable,lostConnection:D.lostConnection.observable,customEvent:D.customEvent.observable,others:D.others.observable,self:D.self.observable,myPresence:D.myPresence.observable,storage:D.storageBatch.observable,storageBatch:D.storageBatch.observable,history:D.history.observable,storageDidLoad:D.storageDidLoad.observable,storageStatus:D.storageStatus.observable,ydoc:D.ydoc.observable,comments:D.comments.observable,roomWillDestroy:D.roomWillDestroy.observable};async function Eg(A){return s.getThreadsSince({roomId:n,since:A.since,signal:A.signal})}async function Dg(A){return s.getThreads({roomId:n,query:A?.query,cursor:A?.cursor})}async function wg(A){return s.getThread({roomId:n,threadId:A})}async function Ag(A){return s.createThread({roomId:n,threadId:A.threadId,commentId:A.commentId,metadata:A.metadata,body:A.body,attachmentIds:A.attachmentIds})}async function xg(A){return s.deleteThread({roomId:n,threadId:A})}async function Og({metadata:A,threadId:K}){return s.editThreadMetadata({roomId:n,threadId:K,metadata:A})}async function Sg(A){return s.markThreadAsResolved({roomId:n,threadId:A})}async function Tg(A){return s.markThreadAsUnresolved({roomId:n,threadId:A})}async function Rg(A){return s.createComment({roomId:n,threadId:A.threadId,commentId:A.commentId,body:A.body,attachmentIds:A.attachmentIds})}async function Ig(A){return s.editComment({roomId:n,threadId:A.threadId,commentId:A.commentId,body:A.body,attachmentIds:A.attachmentIds})}async function Bg({threadId:A,commentId:K}){return s.deleteComment({roomId:n,threadId:A,commentId:K})}async function Fg({threadId:A,commentId:K,emoji:Z}){return s.addReaction({roomId:n,threadId:A,commentId:K,emoji:Z})}async function Pg({threadId:A,commentId:K,emoji:Z}){return await s.removeReaction({roomId:n,threadId:A,commentId:K,emoji:Z})}function Ng(A){return{type:"localAttachment",status:"idle",id:Td(),name:A.name,size:A.size,mimeType:A.type,file:A}}async function kg(A,K={}){return s.uploadAttachment({roomId:n,attachment:A,signal:K.signal})}function Mg(A){return s.getAttachmentUrl({roomId:n,attachmentId:A})}function _g(A){return s.getNotificationSettings({roomId:n,signal:A?.signal})}function jg(A){return s.updateNotificationSettings({roomId:n,settings:A})}async function Lg(A){await s.markRoomInboxNotificationAsRead({roomId:n,inboxNotificationId:A})}const yc=t.createSyncSource();function wa(A){return yc.setSyncStatus(A==="synchronizing"?"synchronizing":"synchronized")}return Object.defineProperty({[Oe]:{get presenceBuffer(){return oo(l.buffer.presenceUpdates?.data??null)},get undoStack(){return oo(l.undoStack)},get nodeCount(){return l.pool.nodes.size},getYjsProvider(){return l.yjsProvider},setYjsProvider(A){l.yjsProvider?.off("status",wa),l.yjsProvider=A,A?.on("status",wa),l.yjsProviderDidChange.notify()},yjsProviderDidChange:l.yjsProviderDidChange.observable,reportTextEditor:S,createTextMention:x,deleteTextMention:I,listTextVersions:k,listTextVersionsSince:H,getTextVersion:P,createTextVersion:j,executeContextualPrompt:B,getSelf_forDevTools:()=>Q.get(),getOthers_forDevTools:()=>bg.get(),simulate:{explicitClose:A=>c._privateSendMachineEvent({type:"EXPLICIT_SOCKET_CLOSE",event:A}),rawSend:A=>c.send(A)},attachmentUrlsStore:s.getOrCreateAttachmentUrlsStore(n)},id:n,subscribe:RC(n,Lo,t.errorEventSource),connect:()=>c.connect(),reconnect:()=>c.reconnect(),disconnect:()=>c.disconnect(),destroy:()=>{const{roomWillDestroy:A,...K}=D;for(const Z of Object.values(K))Z[Symbol.dispose]();D.roomWillDestroy.notify(),l.yjsProvider?.off("status",wa),mc.destroy(),yc.destroy(),i(),c.destroy(),A[Symbol.dispose]()},updatePresence:X,updateYDoc:ke,broadcastEvent:Pe,batch:ba,history:{undo:ga,redo:Ca,canUndo:q,canRedo:ne,clear:ya,pause:Ea,resume:Da},fetchYDoc:ln,getStorage:cn,getStorageSnapshot:rr,getStorageStatus:_o,isPresenceReady:gc,isStorageReady:Cc,waitUntilPresenceReady:wc(Cg),waitUntilStorageReady:wc(yg),events:Lo,getStatus:()=>c.getStatus(),getSelf:()=>Y.get(),getPresence:()=>l.myPresence.get(),getOthers:()=>l.others.get(),getThreads:Dg,getThreadsSince:Eg,getThread:wg,createThread:Ag,deleteThread:xg,editThreadMetadata:Og,markThreadAsResolved:Sg,markThreadAsUnresolved:Tg,createComment:Rg,editComment:Ig,deleteComment:Bg,addReaction:Fg,removeReaction:Pg,prepareAttachment:Ng,uploadAttachment:kg,getAttachmentUrl:Mg,getNotificationSettings:_g,updateNotificationSettings:jg,markInboxNotificationAsRead:Lg},Oe,{enumerable:!1})}function RC(e,t,n){function r(a,i){return t.storageBatch.subscribe(u=>{const c=u.filter(l=>Ld(l.node,a));c.length>0&&i(c)})}function o(a,i){return t.storageBatch.subscribe(u=>{for(const c of u)c.node._id===a._id&&i(c.node)})}function s(a,i,u){if(typeof a=="string"&&IC(a)){if(typeof i!="function")throw new Error("Second argument must be a callback function");const c=i;switch(a){case"event":return t.customEvent.subscribe(c);case"my-presence":return t.myPresence.subscribe(c);case"others":{const l=c;return t.others.subscribe(d=>{const{others:m,...g}=d;return l(m,g)})}case"error":return n.subscribe(l=>{if(l.roomId===e)return c(l)});case"status":return t.status.subscribe(c);case"lost-connection":return t.lostConnection.subscribe(c);case"history":return t.history.subscribe(c);case"storage-status":return t.storageStatus.subscribe(c);case"comments":return t.comments.subscribe(c);default:return lt(a,`"${String(a)}" is not a valid event name`)}}if(i===void 0||typeof a=="function")if(typeof a=="function"){const c=a;return t.storageBatch.subscribe(c)}else throw new Error("Please specify a listener callback");if(We(a)){const c=a;return u?.isDeep?r(c,i):o(c,i)}throw new Error(`${String(a)} is not a value that can be subscribed to.`)}return s}function IC(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="history"||e==="status"||e==="storage-status"||e==="lost-connection"||e==="connection"||e==="comments"}function BC(e,t){return async()=>t.getAuthValue({requestedScope:"room:read",roomId:e})}function FC(e,t,n){return r=>{const o=n??(typeof WebSocket>"u"?void 0:WebSocket);if(o===void 0)throw new Ln("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const s=new URL(t);if(s.protocol=s.protocol==="http:"?"ws":"wss",s.pathname="/v7",s.searchParams.set("roomId",e),r.type==="secret")s.searchParams.set("tok",r.token.raw);else if(r.type==="public")s.searchParams.set("pubkey",r.publicApiKey);else return lt(r,"Unhandled case");return s.searchParams.set("version",Yi),new o(s.toString())}}var PC=16,NC=1e3,kC=100,MC=15e3,_C=200,jC=1e3,LC=3e4,$C=5e3,UC=50,HC=50;function WC(e){return typeof e=="string"&&e.startsWith("http")?e:q0}function zC(e){const t=e,n=KC(t.throttle??kC),r=qC(t.lostConnectionTimeout??$C),o=VC(t.backgroundKeepAliveTimeout),s=WC(t.baseUrl),a=new zt(void 0),i=z0(e,V=>{const te=V.k==="sec-legacy"?V.id:V.uid;a.set(()=>te)}),u=t.polyfills?.fetch||globalThis.fetch?.bind(globalThis),c=x0({baseUrl:s,fetchPolyfill:u,authManager:i}),l=new Map;function d(V){V.id,l.delete(V.id),V.destroy()}function m(V){const te=()=>{const se=te;V.unsubs.delete(se)?V.unsubs.size===0&&d(V.room):ft("This leave function was already called. Calling it more than once has no effect.")};return V.unsubs.add(te),{room:V.room,leave:te}}function g(V,...te){const se=l.get(V);if(se!==void 0)return m(se);const de=te[0]??{},G=(typeof de.initialPresence=="function"?de.initialPresence(V):de.initialPresence)??{},R=(typeof de.initialStorage=="function"?de.initialStorage(V):de.initialStorage)??{},_=TC({initialPresence:G,initialStorage:R},{roomId:V,throttleDelay:n,lostConnectionTimeout:r,backgroundKeepAliveTimeout:o,polyfills:t.polyfills,delegates:t.mockedDelegates??{createSocket:FC(V,s,t.polyfills?.WebSocket),authenticate:BC(V,i)},enableDebugLogging:t.enableDebugLogging,baseUrl:s,errorEventSource:M,largeMessageStrategy:t.largeMessageStrategy??(t.unstable_fallbackToHTTP?"experimental-fallback-to-http":void 0),unstable_streamData:!!t.unstable_streamData,roomHttpClient:c,createSyncSource:Y}),U={room:_,unsubs:new Set};if(l.set(V,U),de.autoConnect??!0){if(typeof atob>"u"){if(t.polyfills?.atob===void 0)throw new Error("You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill");ai.atob=t.polyfills.atob}_.connect()}return m(U)}function C(V){const te=l.get(V)?.room;return te||null}function v(){i.reset(),a.set(()=>{});for(const{room:V}of l.values())F0(V.getStatus())||V.reconnect()}const p=t.resolveUsers,E=Lc(()=>!p,"Set the resolveUsers option in createClient to specify user info."),b=new Jr(async V=>{const te=V.flat(),se=await p?.({userIds:te});return E(),se??te.map(()=>{})},{delay:UC}),w=fi(b);function D(V){w.invalidate(V)}const x=t.resolveRoomsInfo,I=Lc(()=>!x,"Set the resolveRoomsInfo option in createClient to specify room info."),S=new Jr(async V=>{const te=V.flat(),se=await x?.({roomIds:te});return I(),se??te.map(()=>{})},{delay:HC}),k=fi(S);function H(V){k.invalidate(V)}const P=new Map;function j(){P.clear()}const B=[],N=new zt("synchronized"),M=Ie();function W(){const V=N.get();return V==="synchronizing"?V:"synchronized"}function re(){N.set(B.some(V=>V.get()==="synchronizing")?"synchronizing":B.some(V=>V.get()==="has-local-changes")?"has-local-changes":"synchronized")}function Y(){const V=new zt("synchronized");B.push(V);const te=V.subscribe(()=>re());function se(G){V.set(G)}function de(){te();const G=B.findIndex(R=>R===V);if(G>-1){const[R]=B.splice(G,1);R.get()!=="synchronized"&&re()}}return{setSyncStatus:se,destroy:de}}{const V=se=>{t.preventUnsavedChanges&&N.get()!=="synchronized"&&se.preventDefault()};(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",V)}async function ee(V){const te=await c.getUserNotificationSettings(V);return ys(te)}async function L(V){const te=await c.updateUserNotificationSettings(V);return ys(te)}const Q=Object.defineProperty({enterRoom:g,getRoom:C,logout:v,getInboxNotifications:c.getInboxNotifications,getInboxNotificationsSince:c.getInboxNotificationsSince,getUnreadInboxNotificationsCount:c.getUnreadInboxNotificationsCount,markAllInboxNotificationsAsRead:c.markAllInboxNotificationsAsRead,markInboxNotificationAsRead:c.markInboxNotificationAsRead,deleteAllInboxNotifications:c.deleteAllInboxNotifications,deleteInboxNotification:c.deleteInboxNotification,getNotificationSettings:ee,updateNotificationSettings:L,resolvers:{invalidateUsers:D,invalidateRoomsInfo:H,invalidateMentionSuggestions:j},getSyncStatus:W,events:{error:M,syncStatus:N},[Oe]:{currentUserId:a,mentionSuggestionsCache:P,resolveMentionSuggestions:t.resolveMentionSuggestions,usersStore:w,roomsInfoStore:k,getRoomIds(){return Array.from(l.keys())},httpClient:c,as:()=>Q,createSyncSource:Y,emitError:(V,te)=>{const se=Wd.from(V,te);M.notify(se)||Ao(se.message)}}},Oe,{enumerable:!1});return Q}function ru(e,t,n,r,o){if(typeof t!="number"||t<n||r!==void 0&&t>r)throw new Error(r!==void 0?`${e} should be between ${o??n} and ${r}.`:`${e} should be at least ${o??n}.`);return t}function VC(e){if(e!==void 0)return ru("backgroundKeepAliveTimeout",e,MC)}function KC(e){return ru("throttle",e,PC,NC)}function qC(e){return ru("lostConnectionTimeout",e,_C,LC,jC)}function Lc(e,...t){return()=>{}}function GC(e){return"type"in e&&e.type==="paragraph"}function YC(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function XC(e){return"type"in e&&e.type==="mention"}function ZC(e){return"type"in e&&e.type==="link"}var JC={paragraph:GC,text:YC,link:ZC,mention:XC};function QC(e,t,n){if(!e||!e?.content)return;const o=JC[t],s=n;for(const a of e.content)for(const i of a.children)o(i)&&s?.(i)}function ey(e){const t=new Set;return QC(e,"mention",n=>t.add(n.id)),Array.from(t)}var ty={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};new RegExp(Object.keys(ty).map(e=>`\\${e}`).join("|"),"g");var ny={_:"\\_","*":"\\*","#":"\\#","`":"\\`","~":"\\~","!":"\\!","|":"\\|","(":"\\(",")":"\\)","{":"\\{","}":"\\}","[":"\\[","]":"\\]"};new RegExp(Object.keys(ny).map(e=>`\\${e}`).join("|"),"g");var Ia=[1e3,2e3,4e3,8e3,1e4];function gr(e,t,n){const r=performance.now(),o=typeof document<"u"?document:void 0,s=typeof window<"u"?window:void 0,a=n?.maxStaleTimeMs??Number.POSITIVE_INFINITY,i={inForeground:o?.visibilityState!=="hidden",lastSuccessfulPollAt:r,count:0,backoff:0};function u(){return i.count>0&&i.inForeground}const c=new Bd({}).addState("@idle").addState("@enabled").addState("@polling");c.addTransitions("@idle",{START:"@enabled"}),c.addTransitions("@enabled",{STOP:"@idle",POLL:"@polling"}),c.addTimedTransition("@enabled",()=>{const E=i.lastSuccessfulPollAt+t;return Math.max(0,E-performance.now())+i.backoff},"@polling"),c.onEnterAsync("@polling",async(p,E)=>{await e(E),E.aborted||(i.lastSuccessfulPollAt=performance.now())},()=>({target:u()?"@enabled":"@idle",effect:()=>{i.backoff=0}}),()=>({target:u()?"@enabled":"@idle",effect:()=>{i.backoff=Ia.find(p=>p>i.backoff)??Ia[Ia.length-1]}}),3e4);function l(){u()?c.send({type:"START"}):c.send({type:"STOP"})}function d(){i.count++,l()}function m(){i.count--,i.count<0&&(i.count=0),l()}function g(){performance.now()-i.lastSuccessfulPollAt>a&&c.send({type:"POLL"})}function C(p){i.inForeground=p,l(),g()}function v(){C(o?.visibilityState!=="hidden")}return o?.addEventListener("visibilitychange",v),s?.addEventListener("online",v),s?.addEventListener("focus",g),c.start(),{inc:d,dec:m,pollNowIfStale:g,setInForeground:C}}function ry(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function oy(e,t){if(!nn(e)||!nn(t))return!1;const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function Bt(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:ry(e,t):oy(e,t)}function sy(e,t,n){let r=0,o=e.length;for(;r<o;){const s=r+(o-r>>1);n(t,e[s])?o=s:r=s+1}return r}var $c=class as{#e;#t;constructor(t,n){this.#t=n,this.#e=t}static from(t,n){const r=new as([],n);for(const o of t)r.add(o);return r}static fromAlreadySorted(t,n){return new as(t,n)}clone(){return new as(this.#e.slice(),this.#t)}add(t){const n=sy(this.#e,t,this.#t);this.#e.splice(n,0,t)}remove(t){const n=this.#e.indexOf(t);return n>=0?(this.#e.splice(n,1),!0):!1}get length(){return this.#e.length}*filter(t){for(const n of this.#e)t(n)&&(yield n)}[Symbol.iterator](){return this.#e[Symbol.iterator]()}};Xi(Jg,Yi,Qg);var ay="@liveblocks/client",iy="2.23.0",uy="esm";Xi(ay,iy,uy);var Vd=f.createContext(null);function cy(){return f.useContext(Vd)}function ly(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}function Ws(e,t,n,r,o){const s=f.useRef(null);let a;s.current===null?(a={hasValue:!1,value:null},s.current=a):a=s.current;const[i,u]=f.useMemo(()=>{let l=!1,d,m;const g=E=>{if(!l){l=!0,d=E;const x=r(E);if(o!==void 0&&a.hasValue){const I=a.value;if(o(I,x))return m=I,I}return m=x,x}const b=d,w=m;if(ly(b,E))return w;const D=r(E);return o!==void 0&&o(w,D)?(d=E,w):(d=E,m=D,D)},C=n===void 0?null:n;return[()=>g(t()),C===null?void 0:()=>g(C())]},[t,n,r,o]),c=f.useSyncExternalStore(e,i,u);return f.useEffect(()=>{a.hasValue=!0,a.value=c},[c]),f.useDebugValue(c),c}var fy=e=>e;function Qn(e,t,n){return Ws(e.subscribe,e.get,e.get,t??fy,n)}var fr=1e3,Pn=60*fr,bt={NOTIFICATIONS_POLL_INTERVAL:1*Pn,NOTIFICATIONS_MAX_STALE_TIME:5*fr,ROOM_THREADS_POLL_INTERVAL:5*Pn,ROOM_THREADS_MAX_STALE_TIME:5*fr,USER_THREADS_POLL_INTERVAL:1*Pn,USER_THREADS_MAX_STALE_TIME:30*fr,HISTORY_VERSIONS_POLL_INTERVAL:1*Pn,HISTORY_VERSIONS_MAX_STALE_TIME:5*fr,NOTIFICATION_SETTINGS_POLL_INTERVAL:1*Pn,NOTIFICATION_SETTINGS_MAX_STALE_TIME:5*fr,USER_NOTIFICATION_SETTINGS_INTERVAL:5*Pn,USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME:1*Pn},bs=Object.freeze({isLoading:!0}),Kd=e=>Object.freeze({isLoading:!1,error:e});function Cr(e,t){return arguments.length===1?Object.freeze({isLoading:!1,data:e}):Object.freeze({isLoading:!1,[e]:t})}function dy(e,t){for(const n of e)if(t(n))return n}function hy(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e},[e]),t}var py=e=>e;function ut(e){return f.useReducer(py,e)[0]}function Vo(e){const t=ut(e);if(typeof t=="function"){const n=hy(e);return f.useCallback((...r)=>n.current(...r),[n])}else return t}function ou(e){const t=new Set;t.add("constructor");let n=e.constructor.prototype;do for(const r of Reflect.ownKeys(n)){if(t.has(r))continue;typeof Reflect.getOwnPropertyDescriptor(n,r)?.value=="function"&&(t.add(r),e[r]=e[r].bind(e))}while((n=Reflect.getPrototypeOf(n))&&n!==Object.prototype)}function Uc(e,t){if(!nn(e)||!nn(t))return Bt(e,t);const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Bt(e[r],t[r]))}function my(e){return t=>vy(t,e)&&gy(t,e)}function vy(e,t){return t.resolved===void 0||e.resolved===t.resolved}function gy(e,t){const n=e.metadata;return t.metadata===void 0||Object.entries(t.metadata).every(([r,o])=>o===void 0||Cy(n[r],o))}function Cy(e,t){return t===null?e===void 0:ui(t)?typeof e=="string"&&e.startsWith(t.startsWith):e===t}function yy(e){return e.deletedAt&&e.comments.length>0?{...e,comments:[]}:e.comments.some(n=>!n.deletedAt)?e:{...e,deletedAt:new Date,comments:[]}}var by=class qd{#e;#t;#n;signal;constructor(){this.#t=$c.from([],(t,n)=>{const r=t.createdAt,o=n.createdAt;return r<o?!0:r===o?t.id<n.id:!1}),this.#n=$c.from([],(t,n)=>{const r=n.updatedAt,o=t.updatedAt;return r<o?!0:r===o?n.id<t.id:!1}),this.#e=new Map,this.signal=new Zn(this)}clone(){const t=new qd;return t.#e=new Map(this.#e),t.#t=this.#t.clone(),t.#n=this.#n.clone(),t}get(t){const n=this.getEvenIfDeleted(t);return n?.deletedAt?void 0:n}getEvenIfDeleted(t){return this.#e.get(t)}upsert(t){this.signal.mutate(()=>{t=yy(t);const n=t.id,r=this.#e.get(n);if(r){if(r.deletedAt)return!1;this.#t.remove(r),this.#n.remove(r)}return t.deletedAt||(this.#t.add(t),this.#n.add(t)),this.#e.set(n,t),!0})}upsertIfNewer(t){const n=this.get(t.id);(!n||t.updatedAt>=n.updatedAt)&&this.upsert(t)}applyDelta(t,n){ct(()=>{for(const r of t)this.upsertIfNewer(r);for(const{id:r,deletedAt:o}of n)this.getEvenIfDeleted(r)&&this.delete(r,o)})}delete(t,n){const r=this.#e.get(t);r&&!r.deletedAt&&this.upsert({...r,deletedAt:n,updatedAt:n})}findMany(t,n,r){const o=r==="desc"?this.#n:this.#t,s=[];return t!==void 0&&s.push(a=>a.roomId===t),s.push(my(n)),Array.from(o.filter(a=>s.every(i=>i(a))))}};function Ey(e,t){return Vn([e,t??{}])}function Dy(e){return Vn(e??{})}function Gd(e){if("status"in e)return e;const t=e;return t.status="pending",t.then(n=>{t.status="fulfilled",t.value=n},n=>{t.status="rejected",t.reason=n}),t}var wy=Promise.resolve(),Ba=class{#e;signal;#t;#n;constructor(e){this.#e=new zt(bs),this.#t=e,this.#n=null,this.signal=this.#e.asReadonly(),ou(this)}get(){return this.#e.get()}#r(e){const t=this.#e.get();t.data!==void 0&&this.#e.set(Cr({...t.data,...e}))}async#s(){const e=this.#e.get();if(!(!e.data?.cursor||e.data.isFetchingMore)){this.#r({isFetchingMore:!0});try{const t=await this.#t(e.data.cursor);this.#r({cursor:t,hasFetchedAll:t===null,fetchMoreError:void 0,isFetchingMore:!1})}catch(t){this.#r({isFetchingMore:!1,fetchMoreError:t})}}}fetchMore(){return this.#e.get().data?.cursor?(this.#n||(this.#n=this.#s().finally(()=>{this.#n=null})),this.#n):wy}#o=null;waitUntilLoaded(){if(this.#o)return this.#o;const e=Zr(()=>this.#t(void 0),5,[5e3,5e3,1e4,15e3]),t=Gd(e);return t.then(n=>{this.#e.set(Cr({cursor:n,hasFetchedAll:n===null,isFetchingMore:!1,fetchMoreError:void 0,fetchMore:this.fetchMore}))},n=>{this.#e.set(Kd(n)),setTimeout(()=>{this.#o=null,this.#e.set(bs)},5e3)}),this.#o=t,this.#o}},Fa=class{#e;signal;#t;constructor(e){this.#e=new zt(bs),this.signal=this.#e.asReadonly(),this.#t=e,ou(this)}get(){return this.#e.get()}#n=null;waitUntilLoaded(){if(this.#n)return this.#n;const e=Zr(()=>this.#t(),5,[5e3,5e3,1e4,15e3]),t=Gd(e);return t.then(()=>{this.#e.set(Cr(void 0))},n=>{this.#e.set(Kd(n)),setTimeout(()=>{this.#n=null,this.#e.set(bs)},5e3)}),this.#n=t,t}};function Ay(){const e=new Zn(new Map);function t(u,c){e.mutate(l=>{const d=l.get(u);return d?(l.set(u,{...d,readAt:c}),!0):!1})}function n(u){e.mutate(c=>{for(const l of c.values())l.readAt=u})}function r(u){e.mutate(c=>c.delete(u))}function o(){e.mutate(u=>u.clear())}function s(u,c){e.mutate(l=>{let d=!1;for(const m of u){const g=l.get(m.id);g&&Ny(g,m)===1||(l.set(m.id,m),d=!0)}for(const m of c)l.delete(m.id),d=!0;return d})}function a(u){e.mutate(c=>{const l=dy(c.values(),d=>d.kind==="thread"&&d.threadId===u.threadId);return l?(c.set(l.id,{...l,notifiedAt:u.createdAt,readAt:u.createdAt}),!0):!1})}function i(u){e.mutate(c=>{c.set(u.id,u)})}return{signal:e.asReadonly(),markAllRead:n,markRead:t,delete:r,applyDelta:s,clear:o,updateAssociatedNotification:a,upsert:i}}function xy(e){const t=new Zn(new Map);function n(r,o){t.mutate(s=>{s.set(r,o)})}return{signal:Xe.from(t,e,(r,o)=>Fy(r,o)),update:n}}function Oy(){const e=new Zn(new It(()=>new Map));function t(n,r){e.mutate(o=>{const s=o.getOrCreate(n);for(const a of r)s.set(a.id,a)})}return{signal:Xe.from(e,n=>Object.fromEntries([...n].map(([r,o])=>[r,Object.fromEntries(o)]))),update:t}}function Sy(){const e=new Zn(new It(()=>new Set));function t(n){e.mutate(r=>{for(const[o,s]of Object.entries(n)){const a=r.getOrCreate(o);for(const i of s)a.add(i)}})}return{signal:e.asReadonly(),update:t}}function Ty(e){const t=new zt(ys({}));function n(r){t.set(r)}return{signal:Xe.from(t,e,(r,o)=>Py(r,o)),update:n}}function Ry(e){const t=new zt([]),n=e[Oe].createSyncSource();t.subscribe(()=>n.setSyncStatus(t.get().length>0?"synchronizing":"synchronized"));function r(s){const a=Nr(),i={...s,id:a};return t.set(u=>[...u,i]),a}function o(s){t.set(a=>a.filter(i=>i.id!==s))}return{signal:t.asReadonly(),add:r,remove:o}}var Iy=class{#e;threads;notifications;roomNotificationSettings;historyVersions;permissionHints;userNotificationSettings;optimisticUpdates;outputs;#t=null;#n;#r=new Map;#s=null;#o=new Map;#i;constructor(e){this.#e=e[Oe].as(),this.optimisticUpdates=Ry(this.#e),this.permissionHints=Sy(),this.#n=new Ba(async d=>{const m=await this.#e.getInboxNotifications({cursor:d});return this.updateThreadifications(m.threads,m.inboxNotifications),this.#t===null&&(this.#t=m.requestedAt),m.nextCursor});const t=async()=>{const d=await this.#e.getNotificationSettings();this.userNotificationSettings.update(d)};this.userNotificationSettings=Ty(this.optimisticUpdates.signal),this.#i=new Fa(t),this.threads=new by,this.notifications=Ay(),this.roomNotificationSettings=xy(this.optimisticUpdates.signal),this.historyVersions=Oy();const n=Xe.from(this.threads.signal,this.notifications.signal,this.optimisticUpdates.signal,(d,m,g)=>By(d,m,g)),r=Xe.from(n,d=>d.threadsDB),o=Xe.from(n,d=>({sortedNotifications:d.sortedNotifications,notificationsById:d.notificationsById}),Bt),s=new It(d=>{const m=JSON.parse(d),g=new Ba(async v=>{const p=await this.#e[Oe].httpClient.getUserThreads_experimental({cursor:v,query:m});return this.updateThreadifications(p.threads,p.inboxNotifications),this.permissionHints.update(p.permissionHints),this.#s===null&&(this.#s=p.requestedAt),p.nextCursor});return{signal:Xe.from(()=>{const v=g.get();if(v.isLoading||v.error)return v;const p=this.outputs.threads.get().findMany(void 0,m??{},"desc"),E=v.data;return{isLoading:!1,threads:p,hasFetchedAll:E.hasFetchedAll,isFetchingMore:E.isFetchingMore,fetchMoreError:E.fetchMoreError,fetchMore:E.fetchMore}},Uc),waitUntilLoaded:g.waitUntilLoaded}}),a=new It(d=>{const[m,g]=JSON.parse(d),C=new Ba(async p=>{const E=await this.#e[Oe].httpClient.getThreads({roomId:m,cursor:p,query:g});this.updateThreadifications(E.threads,E.inboxNotifications),this.permissionHints.update(E.permissionHints);const b=this.#r.get(m);return(b===void 0||b>E.requestedAt)&&this.#r.set(m,E.requestedAt),E.nextCursor});return{signal:Xe.from(()=>{const p=C.get();if(p.isLoading||p.error)return p;const E=this.outputs.threads.get().findMany(m,g??{},"asc"),b=p.data;return{isLoading:!1,threads:E,hasFetchedAll:b.hasFetchedAll,isFetchingMore:b.isFetchingMore,fetchMoreError:b.fetchMoreError,fetchMore:b.fetchMore}},Uc),waitUntilLoaded:C.waitUntilLoaded}}),i={signal:Xe.from(()=>{const m=this.#n.get();if(m.isLoading||m.error)return m;const g=m.data;return{isLoading:!1,inboxNotifications:this.outputs.notifications.get().sortedNotifications,hasFetchedAll:g.hasFetchedAll,isFetchingMore:g.isFetchingMore,fetchMoreError:g.fetchMoreError,fetchMore:g.fetchMore}}),waitUntilLoaded:this.#n.waitUntilLoaded},u=new It(d=>{const m=new Fa(async()=>{const C=this.#e.getRoom(d);if(C===null)throw new Error(`Room '${d}' is not available on client`);const v=await C.getNotificationSettings();this.roomNotificationSettings.update(d,v)});return{signal:Xe.from(()=>{const C=m.get();return C.isLoading||C.error?C:Cr("settings",pe(this.roomNotificationSettings.signal.get()[d]))},Bt),waitUntilLoaded:m.waitUntilLoaded}}),c=new It(d=>{const m=new Fa(async()=>{const C=this.#e.getRoom(d);if(C===null)throw new Error(`Room '${d}' is not available on client`);const v=await C[Oe].listTextVersions();this.historyVersions.update(d,v.versions);const p=this.#o.get(d);(p===void 0||p>v.requestedAt)&&this.#o.set(d,v.requestedAt)});return{signal:Xe.from(()=>{const C=m.get();return C.isLoading||C.error?C:Cr("versions",Object.values(this.historyVersions.signal.get()[d]??{}))},Bt),waitUntilLoaded:m.waitUntilLoaded}}),l={signal:Xe.from(()=>{const d=this.#i.get();return d.isLoading||d.error?d:Cr("settings",pe(this.userNotificationSettings.signal.get()))},Bt),waitUntilLoaded:this.#i.waitUntilLoaded};this.outputs={threadifications:n,threads:r,loadingRoomThreads:a,loadingUserThreads:s,notifications:o,loadingNotifications:i,settingsByRoomId:u,versionsByRoomId:c,userNotificationSettings:l},ou(this)}markInboxNotificationRead(e,t,n){ct(()=>{this.optimisticUpdates.remove(n),this.notifications.markRead(e,t)})}markAllInboxNotificationsRead(e,t){ct(()=>{this.optimisticUpdates.remove(e),this.notifications.markAllRead(t)})}deleteInboxNotification(e,t){ct(()=>{this.optimisticUpdates.remove(t),this.notifications.delete(e)})}deleteAllInboxNotifications(e){ct(()=>{this.optimisticUpdates.remove(e),this.notifications.clear()})}createThread(e,t){ct(()=>{this.optimisticUpdates.remove(e),this.threads.upsert(t)})}#a(e,t,n,r){ct(()=>{t!==null&&this.optimisticUpdates.remove(t);const o=this.threads,s=o.get(e);s&&(r&&s.updatedAt>r||o.upsert(n(s)))})}patchThread(e,t,n,r){return this.#a(e,t,o=>({...o,...xo(n)}),r)}addReaction(e,t,n,r,o){this.#a(e,t,s=>Xd(s,n,r),o)}removeReaction(e,t,n,r,o,s){this.#a(e,t,a=>Zd(a,n,r,o,s),s)}deleteThread(e,t){return this.#a(e,t,n=>({...n,updatedAt:new Date,deletedAt:new Date}))}createComment(e,t){ct(()=>{this.optimisticUpdates.remove(t);const n=this.threads.get(e.threadId);n&&(this.threads.upsert(Es(n,e)),this.notifications.updateAssociatedNotification(e))})}editComment(e,t,n){return this.#a(e,t,r=>Es(r,n))}deleteComment(e,t,n,r){return this.#a(e,t,o=>Yd(o,n,r),r)}updateThreadifications(e,t,n=[],r=[]){ct(()=>{this.threads.applyDelta(e,n),this.notifications.applyDelta(t,r)})}updateRoomNotificationSettings(e,t,n){ct(()=>{this.optimisticUpdates.remove(t),this.roomNotificationSettings.update(e,n)})}async fetchNotificationsDeltaUpdate(e){const t=this.#t;if(t===null)return;const n=await this.#e.getInboxNotificationsSince({since:t,signal:e});t<n.requestedAt&&(this.#t=n.requestedAt),this.updateThreadifications(n.threads.updated,n.inboxNotifications.updated,n.threads.deleted,n.inboxNotifications.deleted)}async fetchRoomThreadsDeltaUpdate(e,t){const n=this.#r.get(e);if(n===void 0)return;const r=await this.#e[Oe].httpClient.getThreadsSince({roomId:e,since:n,signal:t});this.updateThreadifications(r.threads.updated,r.inboxNotifications.updated,r.threads.deleted,r.inboxNotifications.deleted),this.permissionHints.update(r.permissionHints),n<r.requestedAt&&this.#r.set(e,r.requestedAt)}async fetchUserThreadsDeltaUpdate(e){const t=this.#s;if(t===null)return;const n=await this.#e[Oe].httpClient.getUserThreadsSince_experimental({since:t,signal:e});t<n.requestedAt&&(this.#t=n.requestedAt),this.updateThreadifications(n.threads.updated,n.inboxNotifications.updated,n.threads.deleted,n.inboxNotifications.deleted),this.permissionHints.update(n.permissionHints)}async fetchRoomVersionsDeltaUpdate(e,t){const n=this.#o.get(e);if(n===void 0)return;const o=await pe(this.#e.getRoom(e),`Room with id ${e} is not available on client`)[Oe].listTextVersionsSince({since:n,signal:t});this.historyVersions.update(e,o.versions),n<o.requestedAt&&this.#o.set(e,o.requestedAt)}async refreshRoomNotificationSettings(e,t){const r=await pe(this.#e.getRoom(e),`Room with id ${e} is not available on client`).getNotificationSettings({signal:t});this.roomNotificationSettings.update(e,r)}async refreshUserNotificationSettings(e){const t=await this.#e.getNotificationSettings({signal:e});this.userNotificationSettings.update(t)}updateUserNotificationSettings_confirmOptimisticUpdate(e,t){ct(()=>{this.optimisticUpdates.remove(t),this.userNotificationSettings.update(e)})}};function By(e,t,n){const r=e.clone();let o=Object.fromEntries(t);for(const a of n)switch(a.type){case"create-thread":{r.upsert(a.thread);break}case"edit-thread-metadata":{const i=r.get(a.threadId);if(i===void 0||i.updatedAt>a.updatedAt)break;r.upsert({...i,updatedAt:a.updatedAt,metadata:{...i.metadata,...a.metadata}});break}case"mark-thread-as-resolved":{const i=r.get(a.threadId);if(i===void 0)break;r.upsert({...i,resolved:!0});break}case"mark-thread-as-unresolved":{const i=r.get(a.threadId);if(i===void 0)break;r.upsert({...i,resolved:!1});break}case"create-comment":{const i=r.get(a.comment.threadId);if(i===void 0)break;r.upsert(Es(i,a.comment));const u=Object.values(o).find(c=>c.kind==="thread"&&c.threadId===i.id);if(u===void 0)break;o[u.id]={...u,notifiedAt:a.comment.createdAt,readAt:a.comment.createdAt};break}case"edit-comment":{const i=r.get(a.comment.threadId);if(i===void 0)break;r.upsert(Es(i,a.comment));break}case"delete-comment":{const i=r.get(a.threadId);if(i===void 0)break;r.upsert(Yd(i,a.commentId,a.deletedAt));break}case"delete-thread":{const i=r.get(a.threadId);if(i===void 0)break;r.upsert({...i,deletedAt:a.deletedAt,updatedAt:a.deletedAt,comments:[]});break}case"add-reaction":{const i=r.get(a.threadId);if(i===void 0)break;r.upsert(Xd(i,a.commentId,a.reaction));break}case"remove-reaction":{const i=r.get(a.threadId);if(i===void 0)break;r.upsert(Zd(i,a.commentId,a.emoji,a.userId,a.removedAt));break}case"mark-inbox-notification-as-read":{const i=o[a.inboxNotificationId];if(i===void 0)break;o[a.inboxNotificationId]={...i,readAt:a.readAt};break}case"mark-all-inbox-notifications-as-read":{for(const i in o){const u=o[i];if(u===void 0)break;o[i]={...u,readAt:a.readAt}}break}case"delete-inbox-notification":{delete o[a.inboxNotificationId];break}case"delete-all-inbox-notifications":{o={};break}}return{sortedNotifications:Object.values(o).filter(a=>a.kind==="thread"?r.get(a.threadId)!==void 0:!0).sort((a,i)=>i.notifiedAt.getTime()-a.notifiedAt.getTime()),notificationsById:o,threadsDB:r}}function Fy(e,t){const n=Object.fromEntries(e);for(const r of t)switch(r.type){case"update-notification-settings":{const o=n[r.roomId];if(o===void 0)break;n[r.roomId]={...o,...r.settings}}}return n}function Py(e,t){let n=e;for(const r of t)r.type==="update-user-notification-settings"&&(n=Y0(n,r.settings));return n}function Ny(e,t){return e.notifiedAt>t.notifiedAt?1:e.notifiedAt<t.notifiedAt?-1:e.readAt&&t.readAt?e.readAt>t.readAt?1:e.readAt<t.readAt?-1:0:e.readAt||t.readAt?e.readAt?1:-1:0}function Es(e,t){if(e.deletedAt!==void 0)return e;if(t.threadId!==e.id)return Cn.warn(`Comment ${t.id} does not belong to thread ${e.id}`),e;const n=e.comments.find(r=>r.id===t.id);if(n===void 0){const r=new Date(Math.max(e.updatedAt.getTime(),t.createdAt.getTime()));return{...e,updatedAt:r,comments:[...e.comments,t]}}if(n.deletedAt!==void 0)return e;if(n.editedAt===void 0||t.editedAt===void 0||n.editedAt<=t.editedAt){const r=e.comments.map(s=>s.id===t.id?t:s);return{...e,updatedAt:new Date(Math.max(e.updatedAt.getTime(),t.editedAt?.getTime()||t.createdAt.getTime())),comments:r}}return e}function Yd(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find(s=>s.id===t);if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map(s=>s.id===t?{...s,deletedAt:n,body:void 0,attachments:[]}:s);return o.every(s=>s.deletedAt!==void 0)?{...e,deletedAt:n,updatedAt:n}:{...e,updatedAt:n,comments:o}}function Xd(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find(s=>s.id===t);if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map(s=>s.id===t?{...s,reactions:ky(s.reactions,n)}:s);return{...e,updatedAt:new Date(Math.max(n.createdAt.getTime(),e.updatedAt.getTime())),comments:o}}function Zd(e,t,n,r,o){if(e.deletedAt!==void 0)return e;const s=e.comments.find(i=>i.id===t);if(s===void 0||s.deletedAt!==void 0)return e;const a=e.comments.map(i=>i.id===t?{...i,reactions:i.reactions.map(u=>u.emoji===n?{...u,users:u.users.filter(c=>c.id!==r)}:u).filter(u=>u.users.length>0)}:i);return{...e,updatedAt:new Date(Math.max(o.getTime(),e.updatedAt.getTime())),comments:a}}function ky(e,t){const n=e.find(r=>r.emoji===t.emoji);return n===void 0?[...e,{emoji:t.emoji,createdAt:t.createdAt,users:[{id:t.userId}]}]:n.users.some(r=>r.id===t.userId)===!1?e.map(r=>r.emoji===t.emoji?{...r,users:[...r.users,{id:t.userId}]}:r):e}var Jd=f.createContext(null);function Qd(e){return new Error(`resolveUsers didn't return anything for user '${e}'`)}function My(e){return new Error(`resolveRoomsInfo didn't return anything for room '${e}'`)}function _y(e){return e}var Hc=new WeakMap,Wc=new WeakMap;function jy(e,t){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:e.data?{isLoading:!1,user:e.data}:{isLoading:!1,error:Qd(t)}}function Ly(e,t){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:e.data?{isLoading:!1,info:e.data}:{isLoading:!1,error:My(t)}}function eh(e){let t=Hc.get(e);return t||(t=new Iy(e),Hc.set(e,t)),t}function Oo(e){let t=Wc.get(e);return t||(t=$y(e),Wc.set(e,t)),t}function $y(e){const t=eh(e),n=gr(async s=>{try{return await t.fetchNotificationsDeltaUpdate(s)}catch(a){throw console.warn(`Polling new inbox notifications failed: ${String(a)}`),a}},bt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:bt.NOTIFICATIONS_MAX_STALE_TIME}),r=gr(async s=>{try{return await t.fetchUserThreadsDeltaUpdate(s)}catch(a){throw console.warn(`Polling new user threads failed: ${String(a)}`),a}},bt.USER_THREADS_POLL_INTERVAL,{maxStaleTimeMs:bt.USER_THREADS_MAX_STALE_TIME}),o=gr(async s=>{try{return await t.refreshUserNotificationSettings(s)}catch(a){throw console.warn(`Polling new user notification settings failed: ${String(a)}`),a}},bt.USER_NOTIFICATION_SETTINGS_INTERVAL,{maxStaleTimeMs:bt.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME});return{store:t,notificationsPoller:n,userThreadsPoller:r,userNotificationSettingsPoller:o}}function Uy(e,t,n){const{store:r,notificationsPoller:o}=Oo(e);return f.useEffect(()=>void r.outputs.loadingNotifications.waitUntilLoaded()),f.useEffect(()=>(o.inc(),o.pollNowIfStale(),()=>{o.dec()}),[o]),Qn(r.outputs.loadingNotifications.signal,t,n)}function Hy(e){return f.useCallback(t=>{const{store:n}=Oo(e),r=new Date,o=n.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:t,readAt:r});e.markInboxNotificationAsRead(t).then(()=>{n.markInboxNotificationRead(t,r,o)},s=>{n.optimisticUpdates.remove(o),e[Oe].emitError({type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",inboxNotificationId:t},s)})},[e])}function Wy(e){return f.useCallback(t=>{const{store:n}=Oo(e),r=new Date,o=n.optimisticUpdates.add({type:"delete-inbox-notification",inboxNotificationId:t,deletedAt:r});e.deleteInboxNotification(t).then(()=>{n.deleteInboxNotification(t,o)},s=>{n.optimisticUpdates.remove(o),e[Oe].emitError({type:"DELETE_INBOX_NOTIFICATION_ERROR",inboxNotificationId:t},s)})},[e])}function zy(e,t){const{store:n}=Oo(e);return Qn(n.outputs.threadifications,f.useCallback(r=>{const o=r.notificationsById[t]??wt(`Inbox notification with ID "${t}" not found`);return o.kind!=="thread"&&wt(`Inbox notification with ID "${t}" is not of kind "thread"`),r.threadsDB.get(o.threadId)??wt(`Thread with ID "${o.threadId}" not found, this inbox notification might not be of kind "thread"`)},[t]))}function Vy(e,t){const n=e[Oe].usersStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=f.useCallback(a=>jy(a,t),[t]),s=Ws(n.subscribe,r,r,o,Bt);return f.useEffect(()=>void n.enqueue(t)),s}function Ky(e,t){const n=e[Oe].usersStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=r();if(!o||o.isLoading)throw n.enqueue(t);if(o.error)throw o.error;if(!o.data)throw Qd(t);const s=f.useSyncExternalStore(n.subscribe,r,r);return s.isLoading,s.error,{isLoading:!1,user:s.data,error:void 0}}function qy(e,t){const n=e[Oe].roomsInfoStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=f.useCallback(a=>Ly(a,t),[t]),s=Ws(n.subscribe,r,r,o,Bt);return f.useEffect(()=>void n.enqueue(t)),s}function Gy(e){const t=su();if(!e?.allowNesting&&t!==null)throw new Error("You cannot nest multiple LiveblocksProvider instances in the same React tree.")}function su(){return f.useContext(Jd)}function Be(){return su()??wt("LiveblocksProvider is missing from the React tree.")}function Yy(e){return Gy(e),h.jsx(Jd.Provider,{value:e.client,children:e.children})}function SF(e){const{children:t,...n}=e,r={publicApiKey:ut(n.publicApiKey),throttle:ut(n.throttle),lostConnectionTimeout:ut(n.lostConnectionTimeout),backgroundKeepAliveTimeout:ut(n.backgroundKeepAliveTimeout),polyfills:ut(n.polyfills),largeMessageStrategy:ut(n.largeMessageStrategy),unstable_fallbackToHTTP:ut(n.unstable_fallbackToHTTP),unstable_streamData:ut(n.unstable_streamData),preventUnsavedChanges:ut(n.preventUnsavedChanges),authEndpoint:Vo(n.authEndpoint),resolveMentionSuggestions:Vo(n.resolveMentionSuggestions),resolveUsers:Vo(n.resolveUsers),resolveRoomsInfo:Vo(n.resolveRoomsInfo),baseUrl:ut(n.baseUrl),enableDebugLogging:ut(n.enableDebugLogging)},o=f.useMemo(()=>zC(r),[]);return h.jsx(Yy,{client:o,children:t})}function Xy(e={}){const t=Be(),{store:n,userThreadsPoller:r}=Oo(t),o=Dy(e.query);return f.useEffect(()=>void n.outputs.loadingUserThreads.getOrCreate(o).waitUntilLoaded()),f.useEffect(()=>(r.inc(),r.pollNowIfStale(),()=>{r.dec()}),[r]),Qn(n.outputs.loadingUserThreads.getOrCreate(o).signal)}function TF(){return Uy(Be(),_y,Bt)}function Zy(e){return zy(Be(),e)}function Jy(){return Hy(Be())}function Qy(){return Wy(Be())}function eb(e){const t=Be();return Vy(t,e)}function tb(e){const t=Be();return Ky(t,e)}function au(e){return qy(Be(),e)}var nb=Zy,th=eb,RF=tb,IF=Xy;function rb(e,t){if(e===!1||!t.threads||!(typeof window<"u"))return;const o=window.location.hash.slice(1);if(!o.startsWith("cm_"))return;const s=document.getElementById(o);s===null||!t.threads.flatMap(u=>u.comments).some(u=>u.id===o)||s.scrollIntoView()}function ob(e,t){f.useEffect(()=>{rb(e,t)},[t.isLoading])}function zs(e){const t=e[Oe].currentUserId.get();return t===void 0?"anonymous":t}var zc=new WeakMap;function vt(e){let t=zc.get(e);return t||(t=sb(e),zc.set(e,t)),t}function sb(e){const t=eh(e);function n(a,i,u){if(t.optimisticUpdates.remove(a),u instanceof xr){if(u.status===403){const c=[u.message,u.details?.suggestion,u.details?.docs].filter(Boolean).join(`
3
3
  `);Cn.error(c)}e[Oe].emitError(i,u)}else throw u}const r=new It(a=>gr(async i=>{try{return await t.fetchRoomThreadsDeltaUpdate(a,i)}catch(u){throw Cn.warn(`Polling new threads for '${a}' failed: ${String(u)}`),u}},bt.ROOM_THREADS_POLL_INTERVAL,{maxStaleTimeMs:bt.ROOM_THREADS_MAX_STALE_TIME})),o=new It(a=>gr(async i=>{try{return await t.fetchRoomVersionsDeltaUpdate(a,i)}catch(u){throw Cn.warn(`Polling new history versions for '${a}' failed: ${String(u)}`),u}},bt.HISTORY_VERSIONS_POLL_INTERVAL,{maxStaleTimeMs:bt.HISTORY_VERSIONS_MAX_STALE_TIME})),s=new It(a=>gr(async i=>{try{return await t.refreshRoomNotificationSettings(a,i)}catch(u){throw Cn.warn(`Polling notification settings for '${a}' failed: ${String(u)}`),u}},bt.NOTIFICATION_SETTINGS_POLL_INTERVAL,{maxStaleTimeMs:bt.NOTIFICATION_SETTINGS_MAX_STALE_TIME}));return{store:t,onMutationFailure:n,getOrCreateThreadsPollerForRoomId:r.getOrCreate.bind(r),getOrCreateVersionsPollerForRoomId:o.getOrCreate.bind(o),getOrCreateNotificationsSettingsPollerForRoomId:s.getOrCreate.bind(s)}}function ab(e){const t=Be(),[n]=f.useState(()=>new Map),r=f.useCallback((o,s)=>{const a=n.get(o);if(a)return a;const i=t.enterRoom(o,s),u=i.leave;return i.leave=()=>{u(),n.delete(o)},n.set(o,i),i},[t,n]);return h.jsx(ib,{...e,stableEnterRoom:r})}function ib(e){const t=Be(),{id:n,stableEnterRoom:r}=e,o=ut({initialPresence:e.initialPresence,initialStorage:e.initialStorage,autoConnect:e.autoConnect??typeof window<"u"}),[{room:s},a]=f.useState(()=>r(n,{...o,autoConnect:!1}));return f.useEffect(()=>{const{store:i}=vt(t);async function u(c){if(c.type===Zt.THREAD_DELETED){i.deleteThread(c.threadId,null);return}const l=await s.getThread(c.threadId);if(!l.thread){i.deleteThread(c.threadId,null);return}const{thread:d,inboxNotification:m}=l,g=i.outputs.threads.get().getEvenIfDeleted(c.threadId);switch(c.type){case Zt.COMMENT_EDITED:case Zt.THREAD_METADATA_UPDATED:case Zt.THREAD_UPDATED:case Zt.COMMENT_REACTION_ADDED:case Zt.COMMENT_REACTION_REMOVED:case Zt.COMMENT_DELETED:if(!g)break;i.updateThreadifications([d],m?[m]:[]);break;case Zt.COMMENT_CREATED:i.updateThreadifications([d],m?[m]:[]);break}}return s.events.comments.subscribe(c=>void u(c))},[t,s]),f.useEffect(()=>{const i=r(n,o);a(i);const{room:u,leave:c}=i;return o.autoConnect&&u.connect(),()=>{c()}},[n,o,r]),h.jsx(Vd.Provider,{value:s,children:e.children})}function iu(e){const t=cy();if(t===null&&!e?.allowOutsideRoom)throw new Error("RoomProvider is missing from the React tree.");return t}function uu(){return Be()[Oe].resolveMentionSuggestions}function ub(){return Be()[Oe].mentionSuggestionsCache}function cb(e={}){const{scrollOnLoad:t=!0}=e,n=Be(),r=iu(),{store:o,getOrCreateThreadsPollerForRoomId:s}=vt(n),a=Ey(r.id,e.query),i=s(r.id);f.useEffect(()=>void o.outputs.loadingRoomThreads.getOrCreate(a).waitUntilLoaded()),f.useEffect(()=>(i.inc(),i.pollNowIfStale(),()=>i.dec()),[i]);const u=Qn(o.outputs.loadingRoomThreads.getOrCreate(a).signal);return ob(t,u),u}function lb(){return nh(iu().id)}function nh(e){const t=Be();return f.useCallback(n=>{const r=n.body,o=n.metadata??{},s=n.attachments,a=Sd(),i=Cs(),u=new Date,c={id:i,threadId:a,roomId:e,createdAt:u,type:"comment",userId:zs(t),body:r,reactions:[],attachments:s??[]},l={id:a,type:"thread",createdAt:u,updatedAt:u,roomId:e,metadata:o,comments:[c],resolved:!1},{store:d,onMutationFailure:m}=vt(t),g=d.optimisticUpdates.add({type:"create-thread",thread:l,roomId:e}),C=s?.map(v=>v.id);return t[Oe].httpClient.createThread({roomId:e,threadId:a,commentId:i,body:r,metadata:o,attachmentIds:C}).then(v=>{d.createThread(g,v)},v=>m(g,{type:"CREATE_THREAD_ERROR",roomId:e,threadId:a,commentId:i,body:r,metadata:o},v)),l},[t,e])}function fb(e){const t=Be();return f.useCallback(({threadId:n,body:r,attachments:o})=>{const s=Cs(),i={id:s,threadId:n,roomId:e,type:"comment",createdAt:new Date,userId:zs(t),body:r,reactions:[],attachments:o??[]},{store:u,onMutationFailure:c}=vt(t),l=u.optimisticUpdates.add({type:"create-comment",comment:i}),d=o?.map(m=>m.id);return t[Oe].httpClient.createComment({roomId:e,threadId:n,commentId:s,body:r,attachmentIds:d}).then(m=>{u.createComment(m,l)},m=>c(l,{type:"CREATE_COMMENT_ERROR",roomId:e,threadId:n,commentId:s,body:r},m)),i},[t,e])}function rh(e){const t=Be();return f.useCallback(({threadId:n,commentId:r,body:o,attachments:s})=>{const a=new Date,{store:i,onMutationFailure:u}=vt(t),c=i.outputs.threads.get().getEvenIfDeleted(n);if(c===void 0){Cn.warn(`Internal unexpected behavior. Cannot edit comment in thread "${n}" because the thread does not exist in the cache.`);return}const l=c.comments.find(g=>g.id===r);if(l===void 0||l.deletedAt!==void 0){Cn.warn(`Internal unexpected behavior. Cannot edit comment "${r}" in thread "${n}" because the comment does not exist in the cache.`);return}const d=i.optimisticUpdates.add({type:"edit-comment",comment:{...l,editedAt:a,body:o,attachments:s??[]}}),m=s?.map(g=>g.id);t[Oe].httpClient.editComment({roomId:e,threadId:n,commentId:r,body:o,attachmentIds:m}).then(g=>{i.editComment(n,d,g)},g=>u(d,{type:"EDIT_COMMENT_ERROR",roomId:e,threadId:n,commentId:r,body:o},g))},[t,e])}function db(e){const t=Be();return f.useCallback(({threadId:n,commentId:r})=>{const o=new Date,{store:s,onMutationFailure:a}=vt(t),i=s.optimisticUpdates.add({type:"delete-comment",threadId:n,commentId:r,deletedAt:o,roomId:e});t[Oe].httpClient.deleteComment({roomId:e,threadId:n,commentId:r}).then(()=>{s.deleteComment(n,i,r,o)},u=>a(i,{type:"DELETE_COMMENT_ERROR",roomId:e,threadId:n,commentId:r},u))},[t,e])}function oh(e){const t=Be();return f.useCallback(({threadId:n,commentId:r,emoji:o})=>{const s=new Date,a=zs(t),{store:i,onMutationFailure:u}=vt(t),c=i.optimisticUpdates.add({type:"add-reaction",threadId:n,commentId:r,reaction:{emoji:o,userId:a,createdAt:s}});t[Oe].httpClient.addReaction({roomId:e,threadId:n,commentId:r,emoji:o}).then(l=>{i.addReaction(n,c,r,l,s)},l=>u(c,{type:"ADD_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},l))},[t,e])}function sh(e){const t=Be();return f.useCallback(({threadId:n,commentId:r,emoji:o})=>{const s=zs(t),a=new Date,{store:i,onMutationFailure:u}=vt(t),c=i.optimisticUpdates.add({type:"remove-reaction",threadId:n,commentId:r,emoji:o,userId:s,removedAt:a});t[Oe].httpClient.removeReaction({roomId:e,threadId:n,commentId:r,emoji:o}).then(()=>{i.removeReaction(n,c,r,o,s,a)},l=>u(c,{type:"REMOVE_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},l))},[t,e])}function hb(e){const t=Be();return f.useCallback(n=>{const{store:r,onMutationFailure:o}=vt(t),s=Object.values(r.outputs.notifications.get().notificationsById).find(u=>u.kind==="thread"&&u.threadId===n);if(!s)return;const a=new Date,i=r.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:s.id,readAt:a});t[Oe].httpClient.markRoomInboxNotificationAsRead({roomId:e,inboxNotificationId:s.id}).then(()=>{r.markInboxNotificationRead(s.id,a,i)},u=>{o(i,{type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",roomId:e,inboxNotificationId:s.id},u)})},[t,e])}function pb(e){const t=Be();return f.useCallback(n=>{const r=new Date,{store:o,onMutationFailure:s}=vt(t),a=o.optimisticUpdates.add({type:"mark-thread-as-resolved",threadId:n,updatedAt:r});t[Oe].httpClient.markThreadAsResolved({roomId:e,threadId:n}).then(()=>{o.patchThread(n,a,{resolved:!0},r)},i=>s(a,{type:"MARK_THREAD_AS_RESOLVED_ERROR",roomId:e,threadId:n},i))},[t,e])}function mb(e){const t=Be();return f.useCallback(n=>{const r=new Date,{store:o,onMutationFailure:s}=vt(t),a=o.optimisticUpdates.add({type:"mark-thread-as-unresolved",threadId:n,updatedAt:r});t[Oe].httpClient.markThreadAsUnresolved({roomId:e,threadId:n}).then(()=>{o.patchThread(n,a,{resolved:!1},r)},i=>s(a,{type:"MARK_THREAD_AS_UNRESOLVED_ERROR",roomId:e,threadId:n},i))},[t,e])}function vb(e){const t=Be(),{store:n}=vt(t),r=n.outputs.threadifications,o=f.useCallback(s=>{const a=s.sortedNotifications.find(u=>u.kind==="thread"&&u.threadId===e),i=s.threadsDB.get(e);return a===void 0||i===void 0?{status:"not-subscribed"}:{status:"subscribed",unreadSince:a.readAt}},[e]);return Qn(r,o,Bt)}function gb(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:(e.data,{isLoading:!1,url:e.data})}function Vs(e,t){const r=Be()[Oe].httpClient.getOrCreateAttachmentUrlsStore(t),o=f.useCallback(()=>r.getItemState(e),[r,e]);return f.useEffect(()=>{r.enqueue(e)},[r,e]),Ws(r.subscribe,o,o,gb,Bt)}var Cb=new Set;function yb(e){const t=Be(),n=vt(t).store;return Qn(n.permissionHints.signal,r=>r.get(e)??Cb)}var BF=ab,ah=iu,FF=lb,PF=cb;Xi(qg,Gg,Yg);var Vt=typeof window<"u"?f.useLayoutEffect:f.useEffect,Vc=500;function bb(e,t){const[n,r]=f.useState(),o=f.useRef(),s=uu(),a=ub();return f.useEffect(()=>{if(t===void 0||!s)return;const i={text:t,roomId:e},u=Vn(i);let c,l=!1;const d=async()=>{try{o.current=performance.now();const m=await s(i);l||(r(m),a.set(u,m))}catch(m){console.error(m?.message)}};return a.has(u)?r(a.get(u)):!o.current||Math.abs(performance.now()-o.current)>Vc?d():c=window.setTimeout(()=>{d()},Vc),()=>{l=!0,window.clearTimeout(c)}},[t,e,s,a]),n}function Eb(){const t=Be()[Oe].createSyncSource,[n,r]=f.useState();return f.useEffect(()=>{const o=t();return r(o),()=>o.destroy()},[t]),n}function ve(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function kt(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>t.current?.(...n),[])}function So({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=Db({defaultProp:t,onChange:n}),s=e!==void 0,a=s?e:r,i=kt(n),u=f.useCallback(c=>{if(s){const d=typeof c=="function"?c(e):c;d!==e&&i(d)}else o(c)},[s,e,o,i]);return[a,u]}function Db({defaultProp:e,onChange:t}){const n=f.useState(e),[r]=n,o=f.useRef(r),s=kt(t);return f.useEffect(()=>{o.current!==r&&(s(r),o.current=r)},[r,o,s]),n}function wb(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Ks(...e){return t=>e.forEach(n=>wb(n,t))}function Ke(...e){return f.useCallback(Ks(...e),e)}var Ne=f.forwardRef((e,t)=>{const{children:n,...r}=e,o=f.Children.toArray(n),s=o.find(Ab);if(s){const a=s.props.children,i=o.map(u=>u===s?f.Children.count(a)>1?f.Children.only(null):f.isValidElement(a)?a.props.children:null:u);return h.jsx(gi,{...r,ref:t,children:f.isValidElement(a)?f.cloneElement(a,void 0,i):null})}return h.jsx(gi,{...r,ref:t,children:n})});Ne.displayName="Slot";var gi=f.forwardRef((e,t)=>{const{children:n,...r}=e;if(f.isValidElement(n)){const o=Ob(n);return f.cloneElement(n,{...xb(r,n.props),ref:t?Ks(t,o):o})}return f.Children.count(n)>1?f.Children.only(null):null});gi.displayName="SlotClone";var cu=({children:e})=>h.jsx(h.Fragment,{children:e});function Ab(e){return f.isValidElement(e)&&e.type===cu}function xb(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{s(...i),o(...i)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Ob(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Sb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],He=Sb.reduce((e,t)=>{const n=f.forwardRef((r,o)=>{const{asChild:s,...a}=r,i=s?Ne:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(i,{...a,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function ih(e,t){e&&Ls.flushSync(()=>e.dispatchEvent(t))}var Tb="Toggle",uh=f.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r=!1,onPressedChange:o,...s}=e,[a=!1,i]=So({prop:n,onChange:o,defaultProp:r});return h.jsx(He.button,{type:"button","aria-pressed":a,"data-state":a?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:ve(e.onClick,()=>{e.disabled||i(!a)})})});uh.displayName=Tb;var lu=uh;function Ae(...e){return e.filter(t=>typeof t=="string"||typeof t=="number").join(" ")}const Kc=20,qc=20;function Ue({children:e,className:t,...n}){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:Kc,height:qc,viewBox:`0 0 ${Kc} ${qc}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",role:"presentation",className:Ae("lb-icon",t),...n,children:e})}function ch(e){return h.jsx(Ue,{...e,children:h.jsx("path",{d:"M16 6L8 14L4 10"})})}function fu(e){return h.jsxs(Ue,{...e,children:[h.jsx("path",{d:"M15 5L5 15"}),h.jsx("path",{d:"M5 5L15 15"})]})}function lh(e){return h.jsx(Ue,{...e,children:h.jsx("path",{d:"M4.5 6.5h11M14 6.5V14a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 6 14V6.5M7.5 6.5V5a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1.5"})})}function Rb(e){return h.jsx(Ue,{...e,children:h.jsx("path",{d:"m11.784 5.797-6.13 6.138a4 4 0 0 0-1.03 1.775L4 16l2.285-.624a4 4 0 0 0 1.776-1.032l6.145-6.152m-2.422-2.395 1.244-1.246c.608-.608 1.826-.81 2.53-.104.7.7.499 1.893-.122 2.515l-1.23 1.23m-2.422-2.395 2.422 2.395"})})}function fh(e){return h.jsxs(Ue,{fill:"currentColor",...e,children:[h.jsx("circle",{cx:5,cy:10,r:.75}),h.jsx("circle",{cx:10,cy:10,r:.75}),h.jsx("circle",{cx:15,cy:10,r:.75})]})}function Gc(e){return h.jsxs(Ue,{...e,children:[h.jsx("path",{d:"M11 3.07A7 7 0 1 0 16.93 9"}),h.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h0"}),h.jsx("path",{d:"M12 8h0"}),h.jsx("path",{d:"M13 5h4m-2-2v4"}),h.jsx("circle",{cx:"8",cy:"8",r:".25"}),h.jsx("circle",{cx:"12",cy:"8",r:".25"})]})}const To=6,qs=10,Ib="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",Bb=f.forwardRef(({emoji:e,style:t,asChild:n,...r},o)=>{const s=n?Ne:"span";return h.jsx(s,{role:"img","aria-label":e,"data-emoji":e,style:{...t,fontFamily:Ib,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1em",whiteSpace:"nowrap"},...r,ref:o,children:e})}),du=f.forwardRef(({className:e,...t},n)=>h.jsx(Bb,{className:Ae("lb-emoji",e),...t,ref:n}));function Pa(e,t,n){return e===1?t:n??`${t}s`}const Fb={locale:"en",dir:"ltr",USER_SELF:"you",USER_UNKNOWN:"Anonymous",LIST_REMAINING:e=>`${e} more`,LIST_REMAINING_USERS:e=>`${e} ${Pa(e,"other")}`,LIST_REMAINING_COMMENTS:e=>`${e} more ${Pa(e,"comment")}`,EMOJI_PICKER_SEARCH_PLACEHOLDER:"Search…",EMOJI_PICKER_EMPTY:"No emoji found.",EMOJI_PICKER_ERROR:()=>"There was an error while getting the list of emoji.",EMOJI_PICKER_CHANGE_SKIN_TONE:"Change skin tone",ATTACHMENT_TOO_LARGE:e=>e?`The file is larger than ${e}`:"The file is too large",ATTACHMENT_ERROR:()=>"The file couldn’t be uploaded.",COMPOSER_INSERT_MENTION:"Mention someone",COMPOSER_INSERT_EMOJI:"Add emoji",COMPOSER_ATTACH_FILES:"Attach files",COMPOSER_REMOVE_ATTACHMENT:"Remove attachment",COMPOSER_PLACEHOLDER:"Write a comment…",COMPOSER_SEND:"Send",COMPOSER_TOGGLE_MARK:e=>{switch(e){case"bold":return"Bold";case"italic":return"Italic";case"strikethrough":return"Strikethrough";case"code":return"Inline code";default:return lt(e,"Unexpected mark")}},COMMENT_EDITED:"(edited)",COMMENT_DELETED:"This comment has been deleted.",COMMENT_MORE:"More",COMMENT_EDIT:"Edit comment",COMMENT_EDIT_COMPOSER_PLACEHOLDER:"Edit comment…",COMMENT_EDIT_COMPOSER_CANCEL:"Cancel",COMMENT_EDIT_COMPOSER_SAVE:"Save",COMMENT_DELETE:"Delete comment",COMMENT_DELETE_ATTACHMENT:"Delete attachment",COMMENT_ADD_REACTION:"Add reaction",COMMENT_REACTION_LIST:(e,t)=>h.jsxs(h.Fragment,{children:[e," reacted with ",h.jsx(du,{emoji:t})]}),COMMENT_REACTION_DESCRIPTION:(e,t)=>`${t} ${Pa(t,"reaction")}, react with ${e}`,THREAD_RESOLVE:"Resolve thread",THREAD_UNRESOLVE:"Re-open thread",THREAD_NEW_INDICATOR:"New",THREAD_NEW_INDICATOR_DESCRIPTION:"New comments",THREAD_COMPOSER_PLACEHOLDER:"Reply to thread…",THREAD_COMPOSER_SEND:"Reply",INBOX_NOTIFICATION_MORE:"More",INBOX_NOTIFICATION_MARK_AS_READ:"Mark as read",INBOX_NOTIFICATION_DELETE:"Delete notification",INBOX_NOTIFICATION_THREAD_COMMENTS_LIST:(e,t)=>h.jsxs(h.Fragment,{children:[e," commented",t?h.jsxs(h.Fragment,{children:[" in ",t]}):h.jsx(h.Fragment,{children:" in a thread"})]}),INBOX_NOTIFICATION_THREAD_MENTION:(e,t)=>h.jsxs(h.Fragment,{children:[e," mentioned you",t?h.jsxs(h.Fragment,{children:[" in ",t]}):null]}),INBOX_NOTIFICATION_TEXT_MENTION:(e,t)=>h.jsxs(h.Fragment,{children:[e," mentioned you",t?h.jsxs(h.Fragment,{children:[" in ",t]}):null]}),HISTORY_VERSION_PREVIEW_AUTHORS_LIST:e=>h.jsxs(h.Fragment,{children:["Edits from ",e]}),HISTORY_VERSION_PREVIEW_RESTORE:"Restore",HISTORY_VERSION_PREVIEW_EMPTY:"No content.",HISTORY_VERSION_PREVIEW_ERROR:()=>"There was an error while getting this version."},Pb=f.createContext(void 0);function Ze(e){const t=f.useContext(Pb);return f.useMemo(()=>({...Fb,...t,...e}),[t,e])}function Yc(e){return Object.prototype.toString.call(e)==="[object Object]"}function ze(e){var t,n;return Yc(e)===!1?!1:(t=e.constructor,t===void 0?!0:(n=t.prototype,!(Yc(n)===!1||n.hasOwnProperty("isPrototypeOf")===!1)))}var dh=Symbol.for("immer-nothing"),Xc=Symbol.for("immer-draftable"),ht=Symbol.for("immer-state");function Rt(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Or=Object.getPrototypeOf;function Kn(e){return!!e&&!!e[ht]}function qn(e){return e?hh(e)||Array.isArray(e)||!!e[Xc]||!!e.constructor?.[Xc]||Ys(e)||Xs(e):!1}var Nb=Object.prototype.constructor.toString();function hh(e){if(!e||typeof e!="object")return!1;const t=Or(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Nb}function Ds(e,t){Gs(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Gs(e){const t=e[ht];return t?t.type_:Array.isArray(e)?1:Ys(e)?2:Xs(e)?3:0}function Ci(e,t){return Gs(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ph(e,t,n){const r=Gs(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function kb(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ys(e){return e instanceof Map}function Xs(e){return e instanceof Set}function kn(e){return e.copy_||e.base_}function yi(e,t){if(Ys(e))return new Map(e);if(Xs(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&hh(e))return Or(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[ht];let r=Reflect.ownKeys(n);for(let o=0;o<r.length;o++){const s=r[o],a=n[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(n[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create(Or(e),n)}function hu(e,t=!1){return Zs(e)||Kn(e)||!qn(e)||(Gs(e)>1&&(e.set=e.add=e.clear=e.delete=Mb),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>hu(r,!0))),e}function Mb(){Rt(2)}function Zs(e){return Object.isFrozen(e)}var _b={};function Gn(e){const t=_b[e];return t||Rt(0,e),t}var ao;function mh(){return ao}function jb(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Zc(e,t){t&&(Gn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function bi(e){Ei(e),e.drafts_.forEach(Lb),e.drafts_=null}function Ei(e){e===ao&&(ao=e.parent_)}function Jc(e){return ao=jb(ao,e)}function Lb(e){const t=e[ht];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Qc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ht].modified_&&(bi(t),Rt(4)),qn(e)&&(e=ws(t,e),t.parent_||As(t,e)),t.patches_&&Gn("Patches").generateReplacementPatches_(n[ht].base_,e,t.patches_,t.inversePatches_)):e=ws(t,n,[]),bi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==dh?e:void 0}function ws(e,t,n){if(Zs(t))return t;const r=t[ht];if(!r)return Ds(t,(o,s)=>el(e,r,t,o,s,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return As(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let s=o,a=!1;r.type_===3&&(s=new Set(o),o.clear(),a=!0),Ds(s,(i,u)=>el(e,r,o,i,u,n,a)),As(e,o,!1),n&&e.patches_&&Gn("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function el(e,t,n,r,o,s,a){if(Kn(o)){const i=s&&t&&t.type_!==3&&!Ci(t.assigned_,r)?s.concat(r):void 0,u=ws(e,o,i);if(ph(n,r,u),Kn(u))e.canAutoFreeze_=!1;else return}else a&&n.add(o);if(qn(o)&&!Zs(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ws(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&As(e,o)}}function As(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&hu(t,n)}function $b(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:mh(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,s=pu;n&&(o=[r],s=io);const{revoke:a,proxy:i}=Proxy.revocable(o,s);return r.draft_=i,r.revoke_=a,i}var pu={get(e,t){if(t===ht)return e;const n=kn(e);if(!Ci(n,t))return Ub(e,n,t);const r=n[t];return e.finalized_||!qn(r)?r:r===Na(e.base_,t)?(ka(e),e.copy_[t]=wi(r,e)):r},has(e,t){return t in kn(e)},ownKeys(e){return Reflect.ownKeys(kn(e))},set(e,t,n){const r=vh(kn(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Na(kn(e),t),s=o?.[ht];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(kb(n,o)&&(n!==void 0||Ci(e.base_,t)))return!0;ka(e),Di(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Na(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ka(e),Di(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=kn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Rt(11)},getPrototypeOf(e){return Or(e.base_)},setPrototypeOf(){Rt(12)}},io={};Ds(pu,(e,t)=>{io[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});io.deleteProperty=function(e,t){return io.set.call(this,e,t,void 0)};io.set=function(e,t,n){return pu.set.call(this,e[0],t,n,e[0])};function Na(e,t){const n=e[ht];return(n?kn(n):e)[t]}function Ub(e,t,n){const r=vh(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function vh(e,t){if(!(t in e))return;let n=Or(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Or(n)}}function Di(e){e.modified_||(e.modified_=!0,e.parent_&&Di(e.parent_))}function ka(e){e.copy_||(e.copy_=yi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Hb=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const s=n;n=t;const a=this;return function(u=s,...c){return a.produce(u,l=>n.call(this,l,...c))}}typeof n!="function"&&Rt(6),r!==void 0&&typeof r!="function"&&Rt(7);let o;if(qn(t)){const s=Jc(this),a=wi(t,void 0);let i=!0;try{o=n(a),i=!1}finally{i?bi(s):Ei(s)}return Zc(s,r),Qc(o,s)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===dh&&(o=void 0),this.autoFreeze_&&hu(o,!0),r){const s=[],a=[];Gn("Patches").generateReplacementPatches_(t,o,s,a),r(s,a)}return o}else Rt(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(a,...i)=>this.produceWithPatches(a,u=>t(u,...i));let r,o;return[this.produce(t,n,(a,i)=>{r=a,o=i}),r,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){qn(e)||Rt(8),Kn(e)&&(e=Wb(e));const t=Jc(this),n=wi(e,void 0);return n[ht].isManual_=!0,Ei(t),n}finishDraft(e,t){const n=e&&e[ht];(!n||!n.isManual_)&&Rt(9);const{scope_:r}=n;return Zc(r,t),Qc(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=Gn("Patches").applyPatches_;return Kn(e)?r(e,t):this.produce(e,o=>r(o,t))}};function wi(e,t){const n=Ys(e)?Gn("MapSet").proxyMap_(e,t):Xs(e)?Gn("MapSet").proxySet_(e,t):$b(e,t);return(t?t.scope_:mh()).drafts_.push(n),n}function Wb(e){return Kn(e)||Rt(10,e),gh(e)}function gh(e){if(!qn(e)||Zs(e))return e;const t=e[ht];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=yi(e,t.scope_.immer_.useStrictShallowCopy_)}else n=yi(e,!0);return Ds(n,(r,o)=>{ph(n,r,gh(o))}),t&&(t.finalized_=!1),n}var pt=new Hb,mu=pt.produce;pt.produceWithPatches.bind(pt);pt.setAutoFreeze.bind(pt);pt.setUseStrictShallowCopy.bind(pt);pt.applyPatches.bind(pt);var tl=pt.createDraft.bind(pt),nl=pt.finishDraft.bind(pt),zb={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=O.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Vb={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=De.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Kb={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=F.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},xs=new WeakMap,Os=new WeakMap,eo=new WeakMap,Ch=new WeakMap,rl=new WeakMap,ol=new WeakMap,sl=new WeakMap,O={ancestors(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=O.levels(e,t);return n?r=r.slice(1):r=r.slice(0,-1),r},common(e,t){for(var n=[],r=0;r<e.length&&r<t.length;r++){var o=e[r],s=t[r];if(o!==s)break;n.push(o)}return n},compare(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return 0},endsAfter(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),s=e[n],a=t[n];return O.equals(r,o)&&s>a},endsAt(e,t){var n=e.length,r=e.slice(0,n),o=t.slice(0,n);return O.equals(r,o)},endsBefore(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),s=e[n],a=t[n];return O.equals(r,o)&&s<a},equals(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])},hasPrevious(e){return e[e.length-1]>0},isAfter(e,t){return O.compare(e,t)===1},isAncestor(e,t){return e.length<t.length&&O.compare(e,t)===0},isBefore(e,t){return O.compare(e,t)===-1},isChild(e,t){return e.length===t.length+1&&O.compare(e,t)===0},isCommon(e,t){return e.length<=t.length&&O.compare(e,t)===0},isDescendant(e,t){return e.length>t.length&&O.compare(e,t)===0},isParent(e,t){return e.length+1===t.length&&O.compare(e,t)===0},isPath(e){return Array.isArray(e)&&(e.length===0||typeof e[0]=="number")},isSibling(e,t){if(e.length!==t.length)return!1;var n=e.slice(0,-1),r=t.slice(0,-1),o=e[e.length-1],s=t[t.length-1];return o!==s&&O.equals(n,r)},levels(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=[],o=0;o<=e.length;o++)r.push(e.slice(0,o));return n&&r.reverse(),r},next(e){if(e.length===0)throw new Error("Cannot get the next path of a root path [".concat(e,"], because it has no next index."));var t=e[e.length-1];return e.slice(0,-1).concat(t+1)},operationCanTransformPath(e){switch(e.type){case"insert_node":case"remove_node":case"merge_node":case"split_node":case"move_node":return!0;default:return!1}},parent(e){if(e.length===0)throw new Error("Cannot get the parent path of the root path [".concat(e,"]."));return e.slice(0,-1)},previous(e){if(e.length===0)throw new Error("Cannot get the previous path of a root path [".concat(e,"], because it has no previous index."));var t=e[e.length-1];if(t<=0)throw new Error("Cannot get the previous path of a first child path [".concat(e,"] because it would result in a negative index."));return e.slice(0,-1).concat(t-1)},relative(e,t){if(!O.isAncestor(t,e)&&!O.equals(e,t))throw new Error("Cannot get the relative path of [".concat(e,"] inside ancestor [").concat(t,"], because it is not above or equal to the path."));return e.slice(t.length)},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e)return null;var r=[...e],{affinity:o="forward"}=n;if(e.length===0)return r;switch(t.type){case"insert_node":{var{path:s}=t;(O.equals(s,r)||O.endsBefore(s,r)||O.isAncestor(s,r))&&(r[s.length-1]+=1);break}case"remove_node":{var{path:a}=t;if(O.equals(a,r)||O.isAncestor(a,r))return null;O.endsBefore(a,r)&&(r[a.length-1]-=1);break}case"merge_node":{var{path:i,position:u}=t;O.equals(i,r)||O.endsBefore(i,r)?r[i.length-1]-=1:O.isAncestor(i,r)&&(r[i.length-1]-=1,r[i.length]+=u);break}case"split_node":{var{path:c,position:l}=t;if(O.equals(c,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else O.endsBefore(c,r)?r[c.length-1]+=1:O.isAncestor(c,r)&&e[c.length]>=l&&(r[c.length-1]+=1,r[c.length]-=l);break}case"move_node":{var{path:d,newPath:m}=t;if(O.equals(d,m))return r;if(O.isAncestor(d,r)||O.equals(d,r)){var g=m.slice();return O.endsBefore(d,m)&&d.length<m.length&&(g[d.length-1]-=1),g.concat(r.slice(d.length))}else O.isSibling(d,m)&&(O.isAncestor(m,r)||O.equals(m,r))?O.endsBefore(d,r)?r[d.length-1]-=1:r[d.length-1]+=1:O.endsBefore(m,r)||O.equals(m,r)||O.isAncestor(m,r)?(O.endsBefore(d,r)&&(r[d.length-1]-=1),r[m.length-1]+=1):O.endsBefore(d,r)&&(O.equals(m,r)&&(r[m.length-1]+=1),r[d.length-1]-=1);break}}return r}};function uo(e){"@babel/helpers - typeof";return uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},uo(e)}function qb(e,t){if(uo(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(uo(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Gb(e){var t=qb(e,"string");return uo(t)==="symbol"?t:String(t)}function rt(e,t,n){return t=Gb(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function al(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Wr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?al(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):al(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Yb=(e,t,n)=>{switch(n.type){case"insert_node":{var{path:r,node:o}=n,s=J.parent(e,r),a=r[r.length-1];if(a>s.children.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(r,"] because the destination is past the end of the node."));if(s.children.splice(a,0,o),t)for(var[i,u]of F.points(t))t[u]=De.transform(i,n);break}case"insert_text":{var{path:c,offset:l,text:d}=n;if(d.length===0)break;var m=J.leaf(e,c),g=m.text.slice(0,l),C=m.text.slice(l);if(m.text=g+d+C,t)for(var[v,p]of F.points(t))t[p]=De.transform(v,n);break}case"merge_node":{var{path:E}=n,b=J.get(e,E),w=O.previous(E),D=J.get(e,w),x=J.parent(e,E),I=E[E.length-1];if(ce.isText(b)&&ce.isText(D))D.text+=b.text;else if(!ce.isText(b)&&!ce.isText(D))D.children.push(...b.children);else throw new Error('Cannot apply a "merge_node" operation at path ['.concat(E,"] to nodes of different interfaces: ").concat(Ve.stringify(b)," ").concat(Ve.stringify(D)));if(x.children.splice(I,1),t)for(var[S,k]of F.points(t))t[k]=De.transform(S,n);break}case"move_node":{var{path:H,newPath:P}=n;if(O.isAncestor(H,P))throw new Error("Cannot move a path [".concat(H,"] to new path [").concat(P,"] because the destination is inside itself."));var j=J.get(e,H),B=J.parent(e,H),N=H[H.length-1];B.children.splice(N,1);var M=O.transform(H,n),W=J.get(e,O.parent(M)),re=M[M.length-1];if(W.children.splice(re,0,j),t)for(var[Y,ee]of F.points(t))t[ee]=De.transform(Y,n);break}case"remove_node":{var{path:L}=n,Q=L[L.length-1],V=J.parent(e,L);if(V.children.splice(Q,1),t)for(var[te,se]of F.points(t)){var de=De.transform(te,n);if(t!=null&&de!=null)t[se]=de;else{var G=void 0,R=void 0;for(var[_,U]of J.texts(e))if(O.compare(U,L)===-1)G=[_,U];else{R=[_,U];break}var X=!1;G&&R&&(O.equals(R[1],L)?X=!O.hasPrevious(R[1]):X=O.common(G[1],L).length<O.common(R[1],L).length),G&&!X?(te.path=G[1],te.offset=G[0].text.length):R?(te.path=R[1],te.offset=0):t=null}}break}case"remove_text":{var{path:fe,offset:le,text:T}=n;if(T.length===0)break;var q=J.leaf(e,fe),ne=q.text.slice(0,le),ie=q.text.slice(le+T.length);if(q.text=ne+ie,t)for(var[we,xe]of F.points(t))t[xe]=De.transform(we,n);break}case"set_node":{var{path:ae,properties:Te,newProperties:je}=n;if(ae.length===0)throw new Error("Cannot set properties on the root node!");var he=J.get(e,ae);for(var Ce in je){if(Ce==="children"||Ce==="text")throw new Error('Cannot set the "'.concat(Ce,'" property of nodes!'));var ke=je[Ce];ke==null?delete he[Ce]:he[Ce]=ke}for(var Pe in Te)je.hasOwnProperty(Pe)||delete he[Pe];break}case"set_selection":{var{newProperties:ye}=n;if(ye==null)t=ye;else{if(t==null){if(!F.isRange(ye))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat(Ve.stringify(ye)," when there is no current selection."));t=Wr({},ye)}for(var Ee in ye){var Ct=ye[Ee];if(Ct==null){if(Ee==="anchor"||Ee==="focus")throw new Error('Cannot remove the "'.concat(Ee,'" selection property'));delete t[Ee]}else t[Ee]=Ct}}break}case"split_node":{var{path:$e,position:qe,properties:yt}=n;if($e.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat($e,"] because the root node cannot be split."));var Je=J.get(e,$e),rr=J.parent(e,$e),cn=$e[$e.length-1],ln;if(ce.isText(Je)){var ga=Je.text.slice(0,qe),Ca=Je.text.slice(qe);Je.text=ga,ln=Wr(Wr({},yt),{},{text:Ca})}else{var ya=Je.children.slice(0,qe),ba=Je.children.slice(qe);Je.children=ya,ln=Wr(Wr({},yt),{},{children:ba})}if(rr.children.splice(cn+1,0,ln),t)for(var[Ea,Da]of F.points(t))t[Da]=De.transform(Ea,n);break}}return t},Xb={transform(e,t){e.children=tl(e.children);var n=e.selection&&tl(e.selection);try{n=Yb(e,n,t)}finally{e.children=nl(e.children),n?e.selection=Kn(n)?nl(n):n:e.selection=null}}},Zb={insertNodes(e,t,n){e.insertNodes(t,n)},liftNodes(e,t){e.liftNodes(t)},mergeNodes(e,t){e.mergeNodes(t)},moveNodes(e,t){e.moveNodes(t)},removeNodes(e,t){e.removeNodes(t)},setNodes(e,t,n){e.setNodes(t,n)},splitNodes(e,t){e.splitNodes(t)},unsetNodes(e,t,n){e.unsetNodes(t,n)},unwrapNodes(e,t){e.unwrapNodes(t)},wrapNodes(e,t,n){e.wrapNodes(t,n)}},Jb={collapse(e,t){e.collapse(t)},deselect(e){e.deselect()},move(e,t){e.move(t)},select(e,t){e.select(t)},setPoint(e,t,n){e.setPoint(t,n)},setSelection(e,t){e.setSelection(t)}},yh=(e,t)=>{for(var n in e){var r=e[n],o=t[n];if(ze(r)&&ze(o)){if(!yh(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var s=0;s<r.length;s++)if(r[s]!==o[s])return!1}else if(r!==o)return!1}for(var a in t)if(e[a]===void 0&&t[a]!==void 0)return!1;return!0};function Qb(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function rn(e,t){if(e==null)return{};var n=Qb(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var eE=["anchor","focus"];function il(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function tE(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?il(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):il(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var F={edges(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,{anchor:r,focus:o}=e;return F.isBackward(e)===n?[r,o]:[o,r]},end(e){var[,t]=F.edges(e);return t},equals(e,t){return De.equals(e.anchor,t.anchor)&&De.equals(e.focus,t.focus)},surrounds(e,t){var n=F.intersection(e,t);return n?F.equals(n,t):!1},includes(e,t){if(F.isRange(t)){if(F.includes(e,t.anchor)||F.includes(e,t.focus))return!0;var[n,r]=F.edges(e),[o,s]=F.edges(t);return De.isBefore(n,o)&&De.isAfter(r,s)}var[a,i]=F.edges(e),u=!1,c=!1;return De.isPoint(t)?(u=De.compare(t,a)>=0,c=De.compare(t,i)<=0):(u=O.compare(t,a.path)>=0,c=O.compare(t,i.path)<=0),u&&c},intersection(e,t){var n=rn(e,eE),[r,o]=F.edges(e),[s,a]=F.edges(t),i=De.isBefore(r,s)?s:r,u=De.isBefore(o,a)?o:a;return De.isBefore(u,i)?null:tE({anchor:i,focus:u},n)},isBackward(e){var{anchor:t,focus:n}=e;return De.isAfter(t,n)},isCollapsed(e){var{anchor:t,focus:n}=e;return De.equals(t,n)},isExpanded(e){return!F.isCollapsed(e)},isForward(e){return!F.isBackward(e)},isRange(e){return ze(e)&&De.isPoint(e.anchor)&&De.isPoint(e.focus)},*points(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]},start(e){var[t]=F.edges(e);return t},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return mu(e,r=>{if(r===null)return null;var{affinity:o="inward"}=n,s,a;if(o==="inward"){var i=F.isCollapsed(r);F.isForward(r)?(s="forward",a=i?s:"backward"):(s="backward",a=i?s:"forward")}else o==="outward"?F.isForward(r)?(s="backward",a="forward"):(s="forward",a="backward"):(s=o,a=o);var u=De.transform(r.anchor,t,{affinity:s}),c=De.transform(r.focus,t,{affinity:a});if(!u||!c)return null;r.anchor=u,r.focus=c})}},ul=e=>ze(e)&&J.isNodeList(e.children)&&!y.isEditor(e),ue={isAncestor(e){return ze(e)&&J.isNodeList(e.children)},isElement:ul,isElementList(e){return Array.isArray(e)&&e.every(t=>ue.isElement(t))},isElementProps(e){return e.children!==void 0},isElementType:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"type";return ul(t)&&t[r]===n},matches(e,t){for(var n in t)if(n!=="children"&&e[n]!==t[n])return!1;return!0}},nE=["children"],rE=["text"],cl=new WeakMap,J={ancestor(e,t){var n=J.get(e,t);if(ce.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(t,"] because it refers to a text node instead: ").concat(Ve.stringify(n)));return n},ancestors(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){for(var r of O.ancestors(t,n)){var o=J.ancestor(e,r),s=[o,r];yield s}}()},child(e,t){if(ce.isText(e))throw new Error("Cannot get the child of a text node: ".concat(Ve.stringify(e)));var n=e.children[t];if(n==null)throw new Error("Cannot get child at index `".concat(t,"` in node: ").concat(Ve.stringify(e)));return n},children(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){for(var{reverse:r=!1}=n,o=J.ancestor(e,t),{children:s}=o,a=r?s.length-1:0;r?a>=0:a<s.length;){var i=J.child(o,a),u=t.concat(a);yield[i,u],a=r?a-1:a+1}}()},common(e,t,n){var r=O.common(t,n),o=J.get(e,r);return[o,r]},descendant(e,t){var n=J.get(e,t);if(y.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(t,"] because it refers to the root editor node instead: ").concat(Ve.stringify(n)));return n},descendants(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){for(var[n,r]of J.nodes(e,t))r.length!==0&&(yield[n,r])}()},elements(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){for(var[n,r]of J.nodes(e,t))ue.isElement(n)&&(yield[n,r])}()},extractProps(e){if(ue.isAncestor(e)){var t=rn(e,nE);return t}else{var t=rn(e,rE);return t}},first(e,t){for(var n=t.slice(),r=J.get(e,n);r&&!(ce.isText(r)||r.children.length===0);)r=r.children[0],n.push(0);return[r,n]},fragment(e,t){if(ce.isText(e))throw new Error("Cannot get a fragment starting from a root text node: ".concat(Ve.stringify(e)));var n=mu({children:e.children},r=>{var[o,s]=F.edges(t),a=J.nodes(r,{reverse:!0,pass:m=>{var[,g]=m;return!F.includes(t,g)}});for(var[,i]of a){if(!F.includes(t,i)){var u=J.parent(r,i),c=i[i.length-1];u.children.splice(c,1)}if(O.equals(i,s.path)){var l=J.leaf(r,i);l.text=l.text.slice(0,s.offset)}if(O.equals(i,o.path)){var d=J.leaf(r,i);d.text=d.text.slice(o.offset)}}y.isEditor(r)&&(r.selection=null)});return n.children},get(e,t){var n=J.getIf(e,t);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(t,"] in node: ").concat(Ve.stringify(e)));return n},getIf(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(ce.isText(n)||!n.children[o])return;n=n.children[o]}return n},has(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(ce.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode(e){return ce.isText(e)||ue.isElement(e)||y.isEditor(e)},isNodeList(e){if(!Array.isArray(e))return!1;var t=cl.get(e);if(t!==void 0)return t;var n=e.every(r=>J.isNode(r));return cl.set(e,n),n},last(e,t){for(var n=t.slice(),r=J.get(e,n);r&&!(ce.isText(r)||r.children.length===0);){var o=r.children.length-1;r=r.children[o],n.push(o)}return[r,n]},leaf(e,t){var n=J.get(e,t);if(!ce.isText(n))throw new Error("Cannot get the leaf node at path [".concat(t,"] because it refers to a non-leaf node: ").concat(Ve.stringify(n)));return n},levels(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){for(var r of O.levels(t,n)){var o=J.get(e,r);yield[o,r]}}()},matches(e,t){return ue.isElement(e)&&ue.isElementProps(t)&&ue.matches(e,t)||ce.isText(e)&&ce.isTextProps(t)&&ce.matches(e,t)},nodes(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){for(var{pass:n,reverse:r=!1}=t,{from:o=[],to:s}=t,a=new Set,i=[],u=e;!(s&&(r?O.isBefore(i,s):O.isAfter(i,s)));){if(a.has(u)||(yield[u,i]),!a.has(u)&&!ce.isText(u)&&u.children.length!==0&&(n==null||n([u,i])===!1)){a.add(u);var c=r?u.children.length-1:0;O.isAncestor(i,o)&&(c=o[i.length]),i=i.concat(c),u=J.get(e,i);continue}if(i.length===0)break;if(!r){var l=O.next(i);if(J.has(e,l)){i=l,u=J.get(e,i);continue}}if(r&&i[i.length-1]!==0){var d=O.previous(i);i=d,u=J.get(e,i);continue}i=O.parent(i),u=J.get(e,i),a.add(u)}}()},parent(e,t){var n=O.parent(t),r=J.get(e,n);if(ce.isText(r))throw new Error("Cannot get the parent of path [".concat(t,"] because it does not exist in the root."));return r},string(e){return ce.isText(e)?e.text:e.children.map(J.string).join("")},texts(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){for(var[n,r]of J.nodes(e,t))ce.isText(n)&&(yield[n,r])}()}};function ll(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Me(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ll(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ll(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var yn={isNodeOperation(e){return yn.isOperation(e)&&e.type.endsWith("_node")},isOperation(e){if(!ze(e))return!1;switch(e.type){case"insert_node":return O.isPath(e.path)&&J.isNode(e.node);case"insert_text":return typeof e.offset=="number"&&typeof e.text=="string"&&O.isPath(e.path);case"merge_node":return typeof e.position=="number"&&O.isPath(e.path)&&ze(e.properties);case"move_node":return O.isPath(e.path)&&O.isPath(e.newPath);case"remove_node":return O.isPath(e.path)&&J.isNode(e.node);case"remove_text":return typeof e.offset=="number"&&typeof e.text=="string"&&O.isPath(e.path);case"set_node":return O.isPath(e.path)&&ze(e.properties)&&ze(e.newProperties);case"set_selection":return e.properties===null&&F.isRange(e.newProperties)||e.newProperties===null&&F.isRange(e.properties)||ze(e.properties)&&ze(e.newProperties);case"split_node":return O.isPath(e.path)&&typeof e.position=="number"&&ze(e.properties);default:return!1}},isOperationList(e){return Array.isArray(e)&&e.every(t=>yn.isOperation(t))},isSelectionOperation(e){return yn.isOperation(e)&&e.type.endsWith("_selection")},isTextOperation(e){return yn.isOperation(e)&&e.type.endsWith("_text")},inverse(e){switch(e.type){case"insert_node":return Me(Me({},e),{},{type:"remove_node"});case"insert_text":return Me(Me({},e),{},{type:"remove_text"});case"merge_node":return Me(Me({},e),{},{type:"split_node",path:O.previous(e.path)});case"move_node":{var{newPath:t,path:n}=e;if(O.equals(t,n))return e;if(O.isSibling(n,t))return Me(Me({},e),{},{path:t,newPath:n});var r=O.transform(n,e),o=O.transform(O.next(n),e);return Me(Me({},e),{},{path:r,newPath:o})}case"remove_node":return Me(Me({},e),{},{type:"insert_node"});case"remove_text":return Me(Me({},e),{},{type:"insert_text"});case"set_node":{var{properties:s,newProperties:a}=e;return Me(Me({},e),{},{properties:a,newProperties:s})}case"set_selection":{var{properties:i,newProperties:u}=e;return i==null?Me(Me({},e),{},{properties:u,newProperties:null}):u==null?Me(Me({},e),{},{properties:null,newProperties:i}):Me(Me({},e),{},{properties:u,newProperties:i})}case"split_node":return Me(Me({},e),{},{type:"merge_node",path:O.next(e.path)})}}},fl=new WeakMap,oE=e=>{var t=fl.get(e);if(t!==void 0)return t;if(!ze(e))return!1;var n=typeof e.addMark=="function"&&typeof e.apply=="function"&&typeof e.deleteFragment=="function"&&typeof e.insertBreak=="function"&&typeof e.insertSoftBreak=="function"&&typeof e.insertFragment=="function"&&typeof e.insertNode=="function"&&typeof e.insertText=="function"&&typeof e.isElementReadOnly=="function"&&typeof e.isInline=="function"&&typeof e.isSelectable=="function"&&typeof e.isVoid=="function"&&typeof e.normalizeNode=="function"&&typeof e.onChange=="function"&&typeof e.removeMark=="function"&&typeof e.getDirtyPaths=="function"&&(e.marks===null||ze(e.marks))&&(e.selection===null||F.isRange(e.selection))&&J.isNodeList(e.children)&&yn.isOperationList(e.operations);return fl.set(e,n),n},y={above(e,t){return e.above(t)},addMark(e,t,n){e.addMark(t,n)},after(e,t,n){return e.after(t,n)},before(e,t,n){return e.before(t,n)},deleteBackward(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=t;e.deleteBackward(n)},deleteForward(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=t;e.deleteForward(n)},deleteFragment(e,t){e.deleteFragment(t)},edges(e,t){return e.edges(t)},elementReadOnly(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.elementReadOnly(t)},end(e,t){return e.end(t)},first(e,t){return e.first(t)},fragment(e,t){return e.fragment(t)},hasBlocks(e,t){return e.hasBlocks(t)},hasInlines(e,t){return e.hasInlines(t)},hasPath(e,t){return e.hasPath(t)},hasTexts(e,t){return e.hasTexts(t)},insertBreak(e){e.insertBreak()},insertFragment(e,t,n){e.insertFragment(t,n)},insertNode(e,t){e.insertNode(t)},insertSoftBreak(e){e.insertSoftBreak()},insertText(e,t){e.insertText(t)},isBlock(e,t){return e.isBlock(t)},isEdge(e,t,n){return e.isEdge(t,n)},isEditor(e){return oE(e)},isElementReadOnly(e,t){return e.isElementReadOnly(t)},isEmpty(e,t){return e.isEmpty(t)},isEnd(e,t,n){return e.isEnd(t,n)},isInline(e,t){return e.isInline(t)},isNormalizing(e){return e.isNormalizing()},isSelectable(e,t){return e.isSelectable(t)},isStart(e,t,n){return e.isStart(t,n)},isVoid(e,t){return e.isVoid(t)},last(e,t){return e.last(t)},leaf(e,t,n){return e.leaf(t,n)},levels(e,t){return e.levels(t)},marks(e){return e.getMarks()},next(e,t){return e.next(t)},node(e,t,n){return e.node(t,n)},nodes(e,t){return e.nodes(t)},normalize(e,t){e.normalize(t)},parent(e,t,n){return e.parent(t,n)},path(e,t,n){return e.path(t,n)},pathRef(e,t,n){return e.pathRef(t,n)},pathRefs(e){return e.pathRefs()},point(e,t,n){return e.point(t,n)},pointRef(e,t,n){return e.pointRef(t,n)},pointRefs(e){return e.pointRefs()},positions(e,t){return e.positions(t)},previous(e,t){return e.previous(t)},range(e,t,n){return e.range(t,n)},rangeRef(e,t,n){return e.rangeRef(t,n)},rangeRefs(e){return e.rangeRefs()},removeMark(e,t){e.removeMark(t)},setNormalizing(e,t){e.setNormalizing(t)},start(e,t){return e.start(t)},string(e,t,n){return e.string(t,n)},unhangRange(e,t,n){return e.unhangRange(t,n)},void(e,t){return e.void(t)},withoutNormalizing(e,t){e.withoutNormalizing(t)},shouldMergeNodesRemovePrevNode:(e,t,n)=>e.shouldMergeNodesRemovePrevNode(t,n)},sE={isSpan(e){return Array.isArray(e)&&e.length===2&&e.every(O.isPath)}};function dl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function hl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var De={compare(e,t){var n=O.compare(e.path,t.path);return n===0?e.offset<t.offset?-1:e.offset>t.offset?1:0:n},isAfter(e,t){return De.compare(e,t)===1},isBefore(e,t){return De.compare(e,t)===-1},equals(e,t){return e.offset===t.offset&&O.equals(e.path,t.path)},isPoint(e){return ze(e)&&typeof e.offset=="number"&&O.isPath(e.path)},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return mu(e,r=>{if(r===null)return null;var{affinity:o="forward"}=n,{path:s,offset:a}=r;switch(t.type){case"insert_node":case"move_node":{r.path=O.transform(s,t,n);break}case"insert_text":{O.equals(t.path,s)&&(t.offset<a||t.offset===a&&o==="forward")&&(r.offset+=t.text.length);break}case"merge_node":{O.equals(t.path,s)&&(r.offset+=t.position),r.path=O.transform(s,t,n);break}case"remove_text":{O.equals(t.path,s)&&t.offset<=a&&(r.offset-=Math.min(a-t.offset,t.text.length));break}case"remove_node":{if(O.equals(t.path,s)||O.isAncestor(t.path,s))return null;r.path=O.transform(s,t,n);break}case"split_node":{if(O.equals(t.path,s)){if(t.position===a&&o==null)return null;(t.position<a||t.position===a&&o==="forward")&&(r.offset-=t.position,r.path=O.transform(s,t,hl(hl({},n),{},{affinity:"forward"})))}else r.path=O.transform(s,t,n);break}}})}},pl=void 0,Ve={setScrubber(e){pl=e},stringify(e){return JSON.stringify(e,pl)}},aE=["text"],iE=["anchor","focus"];function ml(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Xt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ml(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ml(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var ce={equals(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(s){var a=rn(s,aE);return a}return yh(r?o(e):e,r?o(t):t)},isText(e){return ze(e)&&typeof e.text=="string"},isTextList(e){return Array.isArray(e)&&e.every(t=>ce.isText(t))},isTextProps(e){return e.text!==void 0},matches(e,t){for(var n in t)if(n!=="text"&&(!e.hasOwnProperty(n)||e[n]!==t[n]))return!1;return!0},decorations(e,t){var n=[Xt({},e)];for(var r of t){var o=rn(r,iE),[s,a]=F.edges(r),i=[],u=0,c=s.offset,l=a.offset;for(var d of n){var{length:m}=d.text,g=u;if(u+=m,c<=g&&u<=l){Object.assign(d,o),i.push(d);continue}if(c!==l&&(c===u||l===g)||c>u||l<g||l===g&&g!==0){i.push(d);continue}var C=d,v=void 0,p=void 0;if(l<u){var E=l-g;p=Xt(Xt({},C),{},{text:C.text.slice(E)}),C=Xt(Xt({},C),{},{text:C.text.slice(0,E)})}if(c>g){var b=c-g;v=Xt(Xt({},C),{},{text:C.text.slice(0,b)}),C=Xt(Xt({},C),{},{text:C.text.slice(b)})}Object.assign(C,o),v&&i.push(v),i.push(C),p&&i.push(p)}n=i}return n}},vu=e=>e.selection?e.selection:e.children.length>0?y.end(e,[]):[0],_r=(e,t)=>{var[n]=y.node(e,t);return r=>r===n},gu=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=!n,o=n?hE(t):t,s=ge.None,a=ge.None,i=0,u=null,c=null;for(var l of o){var d=l.codePointAt(0);if(!d)break;var m=xE(l,d);if([s,a]=r?[a,m]:[m,s],pr(s,ge.ZWJ)&&pr(a,ge.ExtPict)&&(r?u=vl(t.substring(0,i)):u=vl(t.substring(0,t.length-i)),!u)||pr(s,ge.RI)&&pr(a,ge.RI)&&(c!==null?c=!c:r?c=!0:c=IE(t.substring(0,t.length-i)),!c)||s!==ge.None&&a!==ge.None&&SE(s,a))break;i+=l.length}return i||1},uE=/\s/,cE=/[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,lE=/['\u2018\u2019]/,fE=function(t){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=0,o=!1;t.length>0;){var s=gu(t,n),[a,i]=Cu(t,s,n);if(dE(a,i,n))o=!0,r+=s;else if(!o)r+=s;else break;t=i}return r},Cu=(e,t,n)=>{if(n){var r=e.length-t;return[e.slice(r,e.length),e.slice(0,r)]}return[e.slice(0,t),e.slice(t)]},dE=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(uE.test(t))return!1;if(lE.test(t)){var o=gu(n,r),[s,a]=Cu(n,o,r);if(e(s,a,r))return!0}return!cE.test(t)},hE=function*(t){for(var n=t.length-1,r=0;r<t.length;r++){var o=t.charAt(n-r);if(mE(o.charCodeAt(0))){var s=t.charAt(n-r-1);if(pE(s.charCodeAt(0))){yield s+o,r++;continue}}yield o}},pE=e=>e>=55296&&e<=56319,mE=e=>e>=56320&&e<=57343,ge;(function(e){e[e.None=0]="None",e[e.Extend=1]="Extend",e[e.ZWJ=2]="ZWJ",e[e.RI=4]="RI",e[e.Prepend=8]="Prepend",e[e.SpacingMark=16]="SpacingMark",e[e.L=32]="L",e[e.V=64]="V",e[e.T=128]="T",e[e.LV=256]="LV",e[e.LVT=512]="LVT",e[e.ExtPict=1024]="ExtPict",e[e.Any=2048]="Any"})(ge||(ge={}));var vE=/^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/,gE=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,CE=/^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/,yE=/^[\u1100-\u115F\uA960-\uA97C]$/,bE=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,EE=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,DE=/^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/,wE=/^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/,AE=/^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/,xE=(e,t)=>{var n=ge.Any;return e.search(vE)!==-1&&(n|=ge.Extend),t===8205&&(n|=ge.ZWJ),t>=127462&&t<=127487&&(n|=ge.RI),e.search(gE)!==-1&&(n|=ge.Prepend),e.search(CE)!==-1&&(n|=ge.SpacingMark),e.search(yE)!==-1&&(n|=ge.L),e.search(bE)!==-1&&(n|=ge.V),e.search(EE)!==-1&&(n|=ge.T),e.search(DE)!==-1&&(n|=ge.LV),e.search(wE)!==-1&&(n|=ge.LVT),e.search(AE)!==-1&&(n|=ge.ExtPict),n};function pr(e,t){return(e&t)!==0}var OE=[[ge.L,ge.L|ge.V|ge.LV|ge.LVT],[ge.LV|ge.V,ge.V|ge.T],[ge.LVT|ge.T,ge.T],[ge.Any,ge.Extend|ge.ZWJ],[ge.Any,ge.SpacingMark],[ge.Prepend,ge.Any],[ge.ZWJ,ge.ExtPict],[ge.RI,ge.RI]];function SE(e,t){return OE.findIndex(n=>pr(e,n[0])&&pr(t,n[1]))===-1}var TE=/(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/,vl=e=>e.search(TE)!==-1,RE=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,IE=e=>{var t=e.match(RE);if(t===null)return!1;var n=t[0].length/2;return n%2===1},BE={delete(e,t){e.delete(t)},insertFragment(e,t,n){e.insertFragment(t,n)},insertText(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};y.withoutNormalizing(e,()=>{var{voids:r=!1}=n,{at:o=vu(e)}=n;if(O.isPath(o)&&(o=y.range(e,o)),F.isRange(o))if(F.isCollapsed(o))o=o.anchor;else{var s=F.end(o);if(!r&&y.void(e,{at:s}))return;var a=F.start(o),i=y.pointRef(e,a),u=y.pointRef(e,s);$.delete(e,{at:o,voids:r});var c=i.unref(),l=u.unref();o=c||l,$.setSelection(e,{anchor:o,focus:o})}if(!(!r&&y.void(e,{at:o})||y.elementReadOnly(e,{at:o}))){var{path:d,offset:m}=o;t.length>0&&e.apply({type:"insert_text",path:d,offset:m,text:t})}})}};function gl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Ko(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var $=Ko(Ko(Ko(Ko({},Xb),Zb),Jb),BE),is=new WeakMap,FE=e=>is.get(e)||!1,PE=(e,t,n)=>{var r=is.get(e)||!1;is.set(e,!0);try{t(),n()}finally{is.set(e,r)}};function bh(e,t,n){var r=xs.get(e)||[],o=Os.get(e)||new Set,s,a,i=d=>{if(d){var m=d.join(",");a.has(m)||(a.add(m),s.push(d))}};if(n){s=[],a=new Set;for(var u of r){var c=n(u);i(c)}}else s=r,a=o;for(var l of t)i(l);xs.set(e,s),Os.set(e,a)}var NE=(e,t)=>{for(var n of y.pathRefs(e))zb.transform(n,t);for(var r of y.pointRefs(e))Vb.transform(r,t);for(var o of y.rangeRefs(e))Kb.transform(o,t);if(!FE(e)){var s=O.operationCanTransformPath(t)?a=>O.transform(a,t):void 0;bh(e,e.getDirtyPaths(t),s)}$.transform(e,t),e.operations.push(t),y.normalize(e,{operation:t}),t.type==="set_selection"&&(e.marks=null),eo.get(e)||(eo.set(e,!0),Promise.resolve().then(()=>{eo.set(e,!1),e.onChange({operation:t}),e.operations=[]}))},kE=(e,t)=>{switch(t.type){case"insert_text":case"remove_text":case"set_node":{var{path:n}=t;return O.levels(n)}case"insert_node":{var{node:r,path:o}=t,s=O.levels(o),a=ce.isText(r)?[]:Array.from(J.nodes(r),P=>{var[,j]=P;return o.concat(j)});return[...s,...a]}case"merge_node":{var{path:i}=t,u=O.ancestors(i),c=O.previous(i);return[...u,c]}case"move_node":{var{path:l,newPath:d}=t;if(O.equals(l,d))return[];var m=[],g=[];for(var C of O.ancestors(l)){var v=O.transform(C,t);m.push(v)}for(var p of O.ancestors(d)){var E=O.transform(p,t);g.push(E)}var b=g[g.length-1],w=d[d.length-1],D=b.concat(w);return[...m,...g,D]}case"remove_node":{var{path:x}=t,I=O.ancestors(x);return[...I]}case"split_node":{var{path:S}=t,k=O.levels(S),H=O.next(S);return[...k,H]}default:return[]}},ME=e=>{var{selection:t}=e;return t?J.fragment(e,t):[]},_E=(e,t)=>{var[n,r]=t;if(!ce.isText(n)){if(ue.isElement(n)&&n.children.length===0){var o={text:""};$.insertNodes(e,o,{at:r.concat(0),voids:!0});return}for(var s=y.isEditor(n)?!1:ue.isElement(n)&&(e.isInline(n)||n.children.length===0||ce.isText(n.children[0])||e.isInline(n.children[0])),a=0,i=0;i<n.children.length;i++,a++){var u=J.get(e,r);if(!ce.isText(u)){var c=u.children[a],l=u.children[a-1],d=i===n.children.length-1,m=ce.isText(c)||ue.isElement(c)&&e.isInline(c);if(m!==s)$.removeNodes(e,{at:r.concat(a),voids:!0}),a--;else if(ue.isElement(c)){if(e.isInline(c)){if(l==null||!ce.isText(l)){var g={text:""};$.insertNodes(e,g,{at:r.concat(a),voids:!0}),a++}else if(d){var C={text:""};$.insertNodes(e,C,{at:r.concat(a+1),voids:!0}),a++}}}else{if(!ce.isText(c)&&!("children"in c)){var v=c;v.children=[]}l!=null&&ce.isText(l)&&(ce.equals(c,l,{loose:!0})?($.mergeNodes(e,{at:r.concat(a),voids:!0}),a--):l.text===""?($.removeNodes(e,{at:r.concat(a-1),voids:!0}),a--):c.text===""&&($.removeNodes(e,{at:r.concat(a),voids:!0}),a--))}}}}},jE=(e,t)=>{var{iteration:n,initialDirtyPathsLength:r}=t,o=r*42;if(n>o)throw new Error("Could not completely normalize the editor after ".concat(o," iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));return!0},LE=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{voids:r=!1,mode:o="lowest",at:s=t.selection,match:a}=n;if(s){var i=y.path(t,s),u=o==="lowest";for(var[c,l]of y.levels(t,{at:i,voids:r,match:a,reverse:u}))if(!ce.isText(c)){if(F.isRange(s)){if(O.isAncestor(l,s.anchor.path)&&O.isAncestor(l,s.focus.path))return[c,l]}else if(!O.equals(i,l))return[c,l]}}};function Cl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function yl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Cl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var $E=(e,t,n)=>{var{selection:r}=e;if(r){var o=(d,m)=>{if(!ce.isText(d))return!1;var[g,C]=y.parent(e,m);return!e.isVoid(g)||e.markableVoid(g)},s=F.isExpanded(r),a=!1;if(!s){var[i,u]=y.node(e,r);if(i&&o(i,u)){var[c]=y.parent(e,u);a=c&&e.markableVoid(c)}}if(s||a)$.setNodes(e,{[t]:n},{match:o,split:!0,voids:!0});else{var l=yl(yl({},y.marks(e)||{}),{},{[t]:n});e.marks=l,eo.get(e)||e.onChange()}}};function bl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function El(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?bl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var UE=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=y.point(t,n,{edge:"end"}),s=y.end(t,[]),a={anchor:o,focus:s},{distance:i=1}=r,u=0,c;for(var l of y.positions(t,El(El({},r),{},{at:a}))){if(u>i)break;u!==0&&(c=l),u++}return c};function Dl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function wl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var HE=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=y.start(t,[]),s=y.point(t,n,{edge:"start"}),a={anchor:o,focus:s},{distance:i=1}=r,u=0,c;for(var l of y.positions(t,wl(wl({},r),{},{at:a,reverse:!0}))){if(u>i)break;u!==0&&(c=l),u++}return c},WE=(e,t)=>{var{selection:n}=e;n&&F.isCollapsed(n)&&$.delete(e,{unit:t,reverse:!0})},zE=(e,t)=>{var{selection:n}=e;n&&F.isCollapsed(n)&&$.delete(e,{unit:t})},VE=function(t){var{direction:n="forward"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=t;r&&F.isExpanded(r)&&$.delete(t,{reverse:n==="backward"})},KE=(e,t)=>[y.start(e,t),y.end(e,t)];function Al(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function xl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Al(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Al(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var qE=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return y.above(t,xl(xl({},n),{},{match:r=>ue.isElement(r)&&y.isElementReadOnly(t,r)}))},GE=(e,t)=>y.point(e,t,{edge:"end"}),YE=(e,t)=>{var n=y.path(e,t,{edge:"start"});return y.node(e,n)},XE=(e,t)=>{var n=y.range(e,t);return J.fragment(e,n)};function Ol(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Sl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ol(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ol(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var ZE=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return y.above(t,Sl(Sl({},n),{},{match:r=>ue.isElement(r)&&y.isVoid(t,r)}))},JE=(e,t)=>t.children.some(n=>ue.isElement(n)&&y.isBlock(e,n)),QE=(e,t)=>t.children.some(n=>ce.isText(n)||y.isInline(e,n)),eD=(e,t)=>J.has(e,t),tD=(e,t)=>t.children.every(n=>ce.isText(n)),nD=e=>{$.splitNodes(e,{always:!0})},rD=(e,t,n)=>{$.insertNodes(e,t,n)},oD=e=>{$.splitNodes(e,{always:!0})};function Tl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function sD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Tl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Eh=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o,marks:s}=t;if(o){if(s){var a=sD({text:n},s);$.insertNodes(t,a,{at:r.at,voids:r.voids})}else $.insertText(t,n,r);t.marks=null}},aD=(e,t)=>!e.isInline(t),iD=(e,t,n)=>y.isStart(e,t,n)||y.isEnd(e,t,n),uD=(e,t)=>{var{children:n}=t,[r]=n;return n.length===0||n.length===1&&ce.isText(r)&&r.text===""&&!e.isVoid(t)},cD=(e,t,n)=>{var r=y.end(e,n);return De.equals(t,r)},lD=e=>{var t=Ch.get(e);return t===void 0?!0:t},fD=(e,t,n)=>{if(t.offset!==0)return!1;var r=y.start(e,n);return De.equals(t,r)},dD=(e,t)=>{var n=y.path(e,t,{edge:"end"});return y.node(e,n)},hD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=y.path(t,n,r),s=J.leaf(t,o);return[s,o]};function pD(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){var{at:n=e.selection,reverse:r=!1,voids:o=!1}=t,{match:s}=t;if(s==null&&(s=()=>!0),!!n){var a=[],i=y.path(e,n);for(var[u,c]of J.levels(e,i))if(s(u,c)&&(a.push([u,c]),!o&&ue.isElement(u)&&y.isVoid(e,u)))break;r&&a.reverse(),yield*a}}()}var mD=["text"],vD=["text"],gD=function(t){var{marks:n,selection:r}=t;if(!r)return null;var{anchor:o,focus:s}=r;if(n)return n;if(F.isExpanded(r)){var a=F.isBackward(r);a&&([s,o]=[o,s]);var i=y.isEnd(t,o,o.path);if(i){var u=y.after(t,o);u&&(o=u)}var[c]=y.nodes(t,{match:ce.isText,at:{anchor:o,focus:s}});if(c){var[l]=c,d=rn(l,mD);return d}else return{}}var{path:m}=o,[g]=y.leaf(t,m);if(o.offset===0){var C=y.previous(t,{at:m,match:ce.isText}),v=y.above(t,{match:x=>ue.isElement(x)&&y.isVoid(t,x)&&t.markableVoid(x)});if(!v){var p=y.above(t,{match:x=>ue.isElement(x)&&y.isBlock(t,x)});if(C&&p){var[E,b]=C,[,w]=p;O.isAncestor(w,b)&&(g=E)}}}var D=rn(g,vD);return D},CD=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:s,at:a=t.selection}=n;if(a){var i=y.after(t,a,{voids:o});if(i){var[,u]=y.last(t,[]),c=[i.path,u];if(O.isPath(a)&&a.length===0)throw new Error("Cannot get the next node from the root node!");if(s==null)if(O.isPath(a)){var[l]=y.parent(t,a);s=m=>l.children.includes(m)}else s=()=>!0;var[d]=y.nodes(t,{at:c,match:s,mode:r,voids:o});return d}}},yD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=y.path(t,n,r),s=J.get(t,o);return[s,o]};function bD(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){var{at:n=e.selection,mode:r="all",universal:o=!1,reverse:s=!1,voids:a=!1,ignoreNonSelectable:i=!1}=t,{match:u}=t;if(u||(u=()=>!0),!!n){var c,l;if(sE.isSpan(n))c=n[0],l=n[1];else{var d=y.path(e,n,{edge:"start"}),m=y.path(e,n,{edge:"end"});c=s?m:d,l=s?d:m}var g=J.nodes(e,{reverse:s,from:c,to:l,pass:D=>{var[x]=D;return ue.isElement(x)?!!(!a&&(y.isVoid(e,x)||y.isElementReadOnly(e,x))||i&&!y.isSelectable(e,x)):!1}}),C=[],v;for(var[p,E]of g)if(!(i&&ue.isElement(p)&&!y.isSelectable(e,p))){var b=v&&O.compare(E,v[1])===0;if(!(r==="highest"&&b)){if(!u(p,E)){if(o&&!b&&ce.isText(p))return;continue}if(r==="lowest"&&b){v=[p,E];continue}var w=r==="lowest"?v:[p,E];w&&(o?C.push(w):yield w),v=[p,E]}}r==="lowest"&&v&&(o?C.push(v):yield v),o&&(yield*C)}}()}var ED=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:r=!1,operation:o}=n,s=l=>xs.get(l)||[],a=l=>Os.get(l)||new Set,i=l=>{var d=s(l).pop(),m=d.join(",");return a(l).delete(m),d};if(y.isNormalizing(t)){if(r){var u=Array.from(J.nodes(t),l=>{var[,d]=l;return d}),c=new Set(u.map(l=>l.join(",")));xs.set(t,u),Os.set(t,c)}s(t).length!==0&&y.withoutNormalizing(t,()=>{for(var l of s(t))if(J.has(t,l)){var d=y.node(t,l),[m,g]=d;ue.isElement(m)&&m.children.length===0&&t.normalizeNode(d,{operation:o})}for(var C=s(t),v=C.length,p=0;C.length!==0;){if(!t.shouldNormalize({dirtyPaths:C,iteration:p,initialDirtyPathsLength:v,operation:o}))return;var E=i(t);if(J.has(t,E)){var b=y.node(t,E);t.normalizeNode(b,{operation:o})}p++,C=s(t)}})}},DD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=y.path(t,n,r),s=O.parent(o),a=y.node(t,s);return a},wD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,s={current:n,affinity:o,unref(){var{current:i}=s,u=y.pathRefs(t);return u.delete(s),s.current=null,i}},a=y.pathRefs(t);return a.add(s),s},AD=e=>{var t=rl.get(e);return t||(t=new Set,rl.set(e,t)),t},xD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:o,edge:s}=r;if(O.isPath(n)){if(s==="start"){var[,a]=J.first(t,n);n=a}else if(s==="end"){var[,i]=J.last(t,n);n=i}}return F.isRange(n)&&(s==="start"?n=F.start(n):s==="end"?n=F.end(n):n=O.common(n.anchor.path,n.focus.path)),De.isPoint(n)&&(n=n.path),o!=null&&(n=n.slice(0,o)),n},OD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,s={current:n,affinity:o,unref(){var{current:i}=s,u=y.pointRefs(t);return u.delete(s),s.current=null,i}},a=y.pointRefs(t);return a.add(s),s},SD=e=>{var t=ol.get(e);return t||(t=new Set,ol.set(e,t)),t},TD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:o="start"}=r;if(O.isPath(n)){var s;if(o==="end"){var[,a]=J.last(t,n);s=a}else{var[,i]=J.first(t,n);s=i}var u=J.get(t,s);if(!ce.isText(u))throw new Error("Cannot get the ".concat(o," point in the node at path [").concat(n,"] because it has no ").concat(o," text node."));return{path:s,offset:o==="end"?u.text.length:0}}if(F.isRange(n)){var[c,l]=F.edges(n);return o==="start"?c:l}return n};function RD(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){var{at:n=e.selection,unit:r="offset",reverse:o=!1,voids:s=!1,ignoreNonSelectable:a=!1}=t;if(!n)return;var i=y.range(e,n),[u,c]=F.edges(i),l=o?c:u,d=!1,m="",g=0,C=0,v=0;for(var[p,E]of y.nodes(e,{at:n,reverse:o,voids:s,ignoreNonSelectable:a})){if(ue.isElement(p)){if(!s&&(e.isVoid(p)||e.isElementReadOnly(p))){yield y.start(e,E);continue}if(e.isInline(p))continue;if(y.hasInlines(e,p)){var b=O.isAncestor(E,c.path)?c:y.end(e,E),w=O.isAncestor(E,u.path)?u:y.start(e,E);m=y.string(e,{anchor:w,focus:b},{voids:s}),d=!0}}if(ce.isText(p)){var D=O.equals(E,l.path);for(D?(C=o?l.offset:p.text.length-l.offset,v=l.offset):(C=p.text.length,v=o?C:0),(D||d||r==="offset")&&(yield{path:E,offset:v},d=!1);;){if(g===0){if(m==="")break;g=x(m,r,o),m=Cu(m,g,o)[1]}if(v=o?v-g:v+g,C=C-g,C<0){g=-C;break}g=0,yield{path:E,offset:v}}}}function x(I,S,k){return S==="character"?gu(I,k):S==="word"?fE(I,k):S==="line"||S==="block"?I.length:1}}()}var ID=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:s,at:a=t.selection}=n;if(a){var i=y.before(t,a,{voids:o});if(i){var[,u]=y.first(t,[]),c=[i.path,u];if(O.isPath(a)&&a.length===0)throw new Error("Cannot get the previous node from the root node!");if(s==null)if(O.isPath(a)){var[l]=y.parent(t,a);s=m=>l.children.includes(m)}else s=()=>!0;var[d]=y.nodes(t,{reverse:!0,at:c,match:s,mode:r,voids:o});return d}}},BD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,s={current:n,affinity:o,unref(){var{current:i}=s,u=y.rangeRefs(t);return u.delete(s),s.current=null,i}},a=y.rangeRefs(t);return a.add(s),s},FD=e=>{var t=sl.get(e);return t||(t=new Set,sl.set(e,t)),t},PD=(e,t,n)=>{if(F.isRange(t)&&!n)return t;var r=y.start(e,t),o=y.end(e,n||t);return{anchor:r,focus:o}};function Rl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ND(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Rl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var kD=(e,t)=>{var{selection:n}=e;if(n){var r=(l,d)=>{if(!ce.isText(l))return!1;var[m,g]=y.parent(e,d);return!e.isVoid(m)||e.markableVoid(m)},o=F.isExpanded(n),s=!1;if(!o){var[a,i]=y.node(e,n);if(a&&r(a,i)){var[u]=y.parent(e,i);s=u&&e.markableVoid(u)}}if(o||s)$.unsetNodes(e,t,{match:r,split:!0,voids:!0});else{var c=ND({},y.marks(e)||{});delete c[t],e.marks=c,eo.get(e)||e.onChange()}}},MD=(e,t)=>{Ch.set(e,t)},_D=(e,t)=>y.point(e,t,{edge:"start"}),jD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,s=y.range(t,n),[a,i]=F.edges(s),u="";for(var[c,l]of y.nodes(t,{at:s,match:ce.isText,voids:o})){var d=c.text;O.equals(l,i.path)&&(d=d.slice(0,i.offset)),O.equals(l,a.path)&&(d=d.slice(a.offset)),u+=d}return u},LD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,[s,a]=F.edges(n);if(s.offset!==0||a.offset!==0||F.isCollapsed(n)||O.hasPrevious(a.path))return n;var i=y.above(t,{at:a,match:C=>ue.isElement(C)&&y.isBlock(t,C),voids:o}),u=i?i[1]:[],c=y.start(t,s),l={anchor:c,focus:a},d=!0;for(var[m,g]of y.nodes(t,{at:l,match:ce.isText,reverse:!0,voids:o})){if(d){d=!1;continue}if(m.text!==""||O.isBefore(g,u)){a={path:g,offset:m.text.length};break}}return{anchor:s,focus:a}},$D=(e,t)=>{var n=y.isNormalizing(e);y.setNormalizing(e,!1);try{t()}finally{y.setNormalizing(e,n)}y.normalize(e)},UD=(e,t,n)=>{var[r,o]=t;return ue.isElement(r)&&y.isEmpty(e,r)||ce.isText(r)&&r.text===""&&o[o.length-1]!==0},HD=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};y.withoutNormalizing(t,()=>{var r,o,{reverse:s=!1,unit:a="character",distance:i=1,voids:u=!1}=n,{at:c=t.selection,hanging:l=!1}=n;if(c){var d=!1;if(F.isRange(c)&&F.isCollapsed(c)&&(d=!0,c=c.anchor),De.isPoint(c)){var m=y.void(t,{at:c,mode:"highest"});if(!u&&m){var[,g]=m;c=g}else{var C={unit:a,distance:i},v=s?y.before(t,c,C)||y.start(t,[]):y.after(t,c,C)||y.end(t,[]);c={anchor:c,focus:v},l=!0}}if(O.isPath(c)){$.removeNodes(t,{at:c,voids:u});return}if(!F.isCollapsed(c)){if(!l){var[,p]=F.edges(c),E=y.end(t,[]);De.equals(p,E)||(c=y.unhangRange(t,c,{voids:u}))}var[b,w]=F.edges(c),D=y.above(t,{match:ne=>ue.isElement(ne)&&y.isBlock(t,ne),at:b,voids:u}),x=y.above(t,{match:ne=>ue.isElement(ne)&&y.isBlock(t,ne),at:w,voids:u}),I=D&&x&&!O.equals(D[1],x[1]),S=O.equals(b.path,w.path),k=u?null:(r=y.void(t,{at:b,mode:"highest"}))!==null&&r!==void 0?r:y.elementReadOnly(t,{at:b,mode:"highest"}),H=u?null:(o=y.void(t,{at:w,mode:"highest"}))!==null&&o!==void 0?o:y.elementReadOnly(t,{at:w,mode:"highest"});if(k){var P=y.before(t,b);P&&D&&O.isAncestor(D[1],P.path)&&(b=P)}if(H){var j=y.after(t,w);j&&x&&O.isAncestor(x[1],j.path)&&(w=j)}var B=[],N;for(var M of y.nodes(t,{at:c,voids:u})){var[W,re]=M;N&&O.compare(re,N)===0||(!u&&ue.isElement(W)&&(y.isVoid(t,W)||y.isElementReadOnly(t,W))||!O.isCommon(re,b.path)&&!O.isCommon(re,w.path))&&(B.push(M),N=re)}var Y=Array.from(B,ne=>{var[,ie]=ne;return y.pathRef(t,ie)}),ee=y.pointRef(t,b),L=y.pointRef(t,w),Q="";if(!S&&!k){var V=ee.current,[te]=y.leaf(t,V),{path:se}=V,{offset:de}=b,G=te.text.slice(de);G.length>0&&(t.apply({type:"remove_text",path:se,offset:de,text:G}),Q=G)}if(Y.reverse().map(ne=>ne.unref()).filter(ne=>ne!==null).forEach(ne=>$.removeNodes(t,{at:ne,voids:u})),!H){var R=L.current,[_]=y.leaf(t,R),{path:U}=R,X=S?b.offset:0,fe=_.text.slice(X,w.offset);fe.length>0&&(t.apply({type:"remove_text",path:U,offset:X,text:fe}),Q=fe)}!S&&I&&L.current&&ee.current&&$.mergeNodes(t,{at:L.current,hanging:!0,voids:u}),d&&s&&a==="character"&&Q.length>1&&Q.match(/[\u0E00-\u0E7F]+/)&&$.insertText(t,Q.slice(0,Q.length-i));var le=ee.unref(),T=L.unref(),q=s?le||T:T||le;n.at==null&&q&&$.select(t,q)}}})},WD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};y.withoutNormalizing(t,()=>{var{hanging:o=!1,voids:s=!1}=r,{at:a=vu(t),batchDirty:i=!0}=r;if(n.length){if(F.isRange(a))if(o||(a=y.unhangRange(t,a,{voids:s})),F.isCollapsed(a))a=a.anchor;else{var[,u]=F.edges(a);if(!s&&y.void(t,{at:u}))return;var c=y.pointRef(t,u);$.delete(t,{at:a}),a=c.unref()}else O.isPath(a)&&(a=y.start(t,a));if(!(!s&&y.void(t,{at:a}))){var l=y.above(t,{at:a,match:G=>ue.isElement(G)&&y.isInline(t,G),mode:"highest",voids:s});if(l){var[,d]=l;if(y.isEnd(t,a,d)){var m=y.after(t,d);a=m}else if(y.isStart(t,a,d)){var g=y.before(t,d);a=g}}var C=y.above(t,{match:G=>ue.isElement(G)&&y.isBlock(t,G),at:a,voids:s}),[,v]=C,p=y.isStart(t,a,v),E=y.isEnd(t,a,v),b=p&&E,w=!p||p&&E,D=!E,[,x]=J.first({children:n},[]),[,I]=J.last({children:n},[]),S=[],k=G=>{var[R,_]=G,U=_.length===0;return U?!1:b?!0:!(w&&O.isAncestor(_,x)&&ue.isElement(R)&&!t.isVoid(R)&&!t.isInline(R)||D&&O.isAncestor(_,I)&&ue.isElement(R)&&!t.isVoid(R)&&!t.isInline(R))};for(var H of J.nodes({children:n},{pass:k}))k(H)&&S.push(H);var P=[],j=[],B=[],N=!0,M=!1;for(var[W]of S)ue.isElement(W)&&!t.isInline(W)?(N=!1,M=!0,j.push(W)):N?P.push(W):B.push(W);var[re]=y.nodes(t,{at:a,match:G=>ce.isText(G)||y.isInline(t,G),mode:"highest",voids:s}),[,Y]=re,ee=y.isStart(t,a,Y),L=y.isEnd(t,a,Y),Q=y.pathRef(t,E&&!B.length?O.next(v):v),V=y.pathRef(t,L?O.next(Y):Y);$.splitNodes(t,{at:a,match:G=>M?ue.isElement(G)&&y.isBlock(t,G):ce.isText(G)||y.isInline(t,G),mode:M?"lowest":"highest",always:M&&(!p||P.length>0)&&(!E||B.length>0),voids:s});var te=y.pathRef(t,!ee||ee&&L?O.next(Y):Y);if($.insertNodes(t,P,{at:te.current,match:G=>ce.isText(G)||y.isInline(t,G),mode:"highest",voids:s,batchDirty:i}),b&&!P.length&&j.length&&!B.length&&$.delete(t,{at:v,voids:s}),$.insertNodes(t,j,{at:Q.current,match:G=>ue.isElement(G)&&y.isBlock(t,G),mode:"lowest",voids:s,batchDirty:i}),$.insertNodes(t,B,{at:V.current,match:G=>ce.isText(G)||y.isInline(t,G),mode:"highest",voids:s,batchDirty:i}),!r.at){var se;if(B.length>0&&V.current?se=O.previous(V.current):j.length>0&&Q.current?se=O.previous(Q.current):te.current&&(se=O.previous(te.current)),se){var de=y.end(t,se);$.select(t,de)}}te.unref(),Q.unref(),V.unref()}}})},zD=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{edge:r="anchor"}=n,{selection:o}=t;if(o){if(r==="anchor")$.select(t,o.anchor);else if(r==="focus")$.select(t,o.focus);else if(r==="start"){var[s]=F.edges(o);$.select(t,s)}else if(r==="end"){var[,a]=F.edges(o);$.select(t,a)}}else return},VD=e=>{var{selection:t}=e;t&&e.apply({type:"set_selection",properties:t,newProperties:null})},KD=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=t,{distance:o=1,unit:s="character",reverse:a=!1}=n,{edge:i=null}=n;if(r){i==="start"&&(i=F.isBackward(r)?"focus":"anchor"),i==="end"&&(i=F.isBackward(r)?"anchor":"focus");var{anchor:u,focus:c}=r,l={distance:o,unit:s,ignoreNonSelectable:!0},d={};if(i==null||i==="anchor"){var m=a?y.before(t,u,l):y.after(t,u,l);m&&(d.anchor=m)}if(i==null||i==="focus"){var g=a?y.before(t,c,l):y.after(t,c,l);g&&(d.focus=g)}$.setSelection(t,d)}},qD=(e,t)=>{var{selection:n}=e;if(t=y.range(e,t),n){$.setSelection(e,t);return}if(!F.isRange(t))throw new Error("When setting the selection and the current selection is `null` you must provide at least an `anchor` and `focus`, but you passed: ".concat(Ve.stringify(t)));e.apply({type:"set_selection",properties:n,newProperties:t})};function Il(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Bl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Il(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Il(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var GD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o}=t,{edge:s="both"}=r;if(o){s==="start"&&(s=F.isBackward(o)?"focus":"anchor"),s==="end"&&(s=F.isBackward(o)?"anchor":"focus");var{anchor:a,focus:i}=o,u=s==="anchor"?a:i;$.setSelection(t,{[s==="anchor"?"anchor":"focus"]:Bl(Bl({},u),n)})}},YD=(e,t)=>{var{selection:n}=e,r={},o={};if(n){for(var s in t)(s==="anchor"&&t.anchor!=null&&!De.equals(t.anchor,n.anchor)||s==="focus"&&t.focus!=null&&!De.equals(t.focus,n.focus)||s!=="anchor"&&s!=="focus"&&t[s]!==n[s])&&(r[s]=n[s],o[s]=t[s]);Object.keys(r).length>0&&e.apply({type:"set_selection",properties:r,newProperties:o})}},XD=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};y.withoutNormalizing(t,()=>{var{hanging:o=!1,voids:s=!1,mode:a="lowest",batchDirty:i=!0}=r,{at:u,match:c,select:l}=r;if(J.isNode(n)&&(n=[n]),n.length!==0){var[d]=n;if(u||(u=vu(t),l!==!1&&(l=!0)),l==null&&(l=!1),F.isRange(u))if(o||(u=y.unhangRange(t,u,{voids:s})),F.isCollapsed(u))u=u.anchor;else{var[,m]=F.edges(u),g=y.pointRef(t,m);$.delete(t,{at:u}),u=g.unref()}if(De.isPoint(u)){c==null&&(ce.isText(d)?c=P=>ce.isText(P):t.isInline(d)?c=P=>ce.isText(P)||y.isInline(t,P):c=P=>ue.isElement(P)&&y.isBlock(t,P));var[C]=y.nodes(t,{at:u.path,match:c,mode:a,voids:s});if(C){var[,v]=C,p=y.pathRef(t,v),E=y.isEnd(t,u,v);$.splitNodes(t,{at:u,match:c,mode:a,voids:s});var b=p.unref();u=E?O.next(b):b}else return}var w=O.parent(u),D=u[u.length-1];if(!(!s&&y.void(t,{at:w}))){if(i){var x=[],I=O.levels(w);PE(t,()=>{var P=function(){var N=w.concat(D);D++;var M={type:"insert_node",path:N,node:j};t.apply(M),u=O.next(u),x.push(M),ce.isText?I.push(...Array.from(J.nodes(j),W=>{var[,re]=W;return N.concat(re)})):I.push(N)};for(var j of n)P()},()=>{bh(t,I,P=>{var j=P;for(var B of x)if(O.operationCanTransformPath(B)&&(j=O.transform(j,B),!j))return null;return j})})}else for(var S of n){var k=w.concat(D);D++,t.apply({type:"insert_node",path:k,node:S}),u=O.next(u)}if(u=O.previous(u),l){var H=y.end(t,u);H&&$.select(t,H)}}}})},ZD=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};y.withoutNormalizing(t,()=>{var{at:r=t.selection,mode:o="lowest",voids:s=!1}=n,{match:a}=n;if(a==null&&(a=O.isPath(r)?_r(t,r):D=>ue.isElement(D)&&y.isBlock(t,D)),!!r){var i=y.nodes(t,{at:r,match:a,mode:o,voids:s}),u=Array.from(i,D=>{var[,x]=D;return y.pathRef(t,x)});for(var c of u){var l=c.unref();if(l.length<2)throw new Error("Cannot lift node at a path [".concat(l,"] because it has a depth of less than `2`."));var d=y.node(t,O.parent(l)),[m,g]=d,C=l[l.length-1],{length:v}=m.children;if(v===1){var p=O.next(g);$.moveNodes(t,{at:l,to:p,voids:s}),$.removeNodes(t,{at:g,voids:s})}else if(C===0)$.moveNodes(t,{at:l,to:g,voids:s});else if(C===v-1){var E=O.next(g);$.moveNodes(t,{at:l,to:E,voids:s})}else{var b=O.next(l),w=O.next(g);$.splitNodes(t,{at:b,voids:s}),$.moveNodes(t,{at:l,to:w,voids:s})}}}})},JD=["text"],QD=["children"],Dh=(e,t)=>{if(ue.isElement(t)){var n=t;return y.isVoid(e,t)?!0:n.children.length===1?Dh(e,n.children[0]):!1}else return!y.isEditor(t)},ew=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};y.withoutNormalizing(t,()=>{var{match:r,at:o=t.selection}=n,{hanging:s=!1,voids:a=!1,mode:i="lowest"}=n;if(o){if(r==null)if(O.isPath(o)){var[u]=y.parent(t,o);r=P=>u.children.includes(P)}else r=P=>ue.isElement(P)&&y.isBlock(t,P);if(!s&&F.isRange(o)&&(o=y.unhangRange(t,o,{voids:a})),F.isRange(o))if(F.isCollapsed(o))o=o.anchor;else{var[,c]=F.edges(o),l=y.pointRef(t,c);$.delete(t,{at:o}),o=l.unref(),n.at==null&&$.select(t,o)}var[d]=y.nodes(t,{at:o,match:r,voids:a,mode:i}),m=y.previous(t,{at:o,match:r,voids:a,mode:i});if(!(!d||!m)){var[g,C]=d,[v,p]=m;if(!(C.length===0||p.length===0)){var E=O.next(p),b=O.common(C,p),w=O.isSibling(C,p),D=Array.from(y.levels(t,{at:C}),P=>{var[j]=P;return j}).slice(b.length).slice(0,-1),x=y.above(t,{at:C,mode:"highest",match:P=>D.includes(P)&&Dh(t,P)}),I=x&&y.pathRef(t,x[1]),S,k;if(ce.isText(g)&&ce.isText(v)){var H=rn(g,JD);k=v.text.length,S=H}else if(ue.isElement(g)&&ue.isElement(v)){var H=rn(g,QD);k=v.children.length,S=H}else throw new Error("Cannot merge the node at path [".concat(C,"] with the previous sibling because it is not the same kind: ").concat(Ve.stringify(g)," ").concat(Ve.stringify(v)));w||$.moveNodes(t,{at:C,to:E,voids:a}),I&&$.removeNodes(t,{at:I.current,voids:a}),y.shouldMergeNodesRemovePrevNode(t,m,d)?$.removeNodes(t,{at:p,voids:a}):t.apply({type:"merge_node",path:E,position:k,properties:S}),I&&I.unref()}}}})},tw=(e,t)=>{y.withoutNormalizing(e,()=>{var{to:n,at:r=e.selection,mode:o="lowest",voids:s=!1}=t,{match:a}=t;if(r){a==null&&(a=O.isPath(r)?_r(e,r):g=>ue.isElement(g)&&y.isBlock(e,g));var i=y.pathRef(e,n),u=y.nodes(e,{at:r,match:a,mode:o,voids:s}),c=Array.from(u,g=>{var[,C]=g;return y.pathRef(e,C)});for(var l of c){var d=l.unref(),m=i.current;d.length!==0&&e.apply({type:"move_node",path:d,newPath:m}),i.current&&O.isSibling(m,d)&&O.isAfter(m,d)&&(i.current=O.next(i.current))}i.unref()}})},nw=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};y.withoutNormalizing(t,()=>{var{hanging:r=!1,voids:o=!1,mode:s="lowest"}=n,{at:a=t.selection,match:i}=n;if(a){i==null&&(i=O.isPath(a)?_r(t,a):g=>ue.isElement(g)&&y.isBlock(t,g)),!r&&F.isRange(a)&&(a=y.unhangRange(t,a,{voids:o}));var u=y.nodes(t,{at:a,match:i,mode:s,voids:o}),c=Array.from(u,g=>{var[,C]=g;return y.pathRef(t,C)});for(var l of c){var d=l.unref();if(d){var[m]=y.node(t,d);t.apply({type:"remove_node",path:d,node:m})}}}})},rw=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};y.withoutNormalizing(t,()=>{var{match:o,at:s=t.selection,compare:a,merge:i}=r,{hanging:u=!1,mode:c="lowest",split:l=!1,voids:d=!1}=r;if(s){if(o==null&&(o=O.isPath(s)?_r(t,s):k=>ue.isElement(k)&&y.isBlock(t,k)),!u&&F.isRange(s)&&(s=y.unhangRange(t,s,{voids:d})),l&&F.isRange(s)){if(F.isCollapsed(s)&&y.leaf(t,s.anchor)[0].text.length>0)return;var m=y.rangeRef(t,s,{affinity:"inward"}),[g,C]=F.edges(s),v=c==="lowest"?"lowest":"highest",p=y.isEnd(t,C,C.path);$.splitNodes(t,{at:C,match:o,mode:v,voids:d,always:!p});var E=y.isStart(t,g,g.path);$.splitNodes(t,{at:g,match:o,mode:v,voids:d,always:!E}),s=m.unref(),r.at==null&&$.select(t,s)}a||(a=(k,H)=>k!==H);for(var[b,w]of y.nodes(t,{at:s,match:o,mode:c,voids:d})){var D={},x={};if(w.length!==0){var I=!1;for(var S in n)S==="children"||S==="text"||a(n[S],b[S])&&(I=!0,b.hasOwnProperty(S)&&(D[S]=b[S]),i?n[S]!=null&&(x[S]=i(b[S],n[S])):n[S]!=null&&(x[S]=n[S]));I&&t.apply({type:"set_node",path:w,properties:D,newProperties:x})}}}})},ow=(e,t)=>{if(F.isCollapsed(t))return t.anchor;var[,n]=F.edges(t),r=y.pointRef(e,n);return $.delete(e,{at:t}),r.unref()},sw=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};y.withoutNormalizing(t,()=>{var{mode:r="lowest",voids:o=!1}=n,{match:s,at:a=t.selection,height:i=0,always:u=!1}=n;if(s==null&&(s=L=>ue.isElement(L)&&y.isBlock(t,L)),F.isRange(a)&&(a=ow(t,a)),O.isPath(a)){var c=a,l=y.point(t,c),[d]=y.parent(t,c);s=L=>L===d,i=l.path.length-c.length+1,a=l,u=!0}if(a){var m=y.pointRef(t,a,{affinity:"backward"}),g;try{var[C]=y.nodes(t,{at:a,match:s,mode:r,voids:o});if(!C)return;var v=y.void(t,{at:a,mode:"highest"}),p=0;if(!o&&v){var[E,b]=v;if(ue.isElement(E)&&t.isInline(E)){var w=y.after(t,b);if(!w){var D={text:""},x=O.next(b);$.insertNodes(t,D,{at:x,voids:o}),w=y.point(t,x)}a=w,u=!0}var I=a.path.length-b.length;i=I+1,u=!0}g=y.pointRef(t,a);var S=a.path.length-i,[,k]=C,H=a.path.slice(0,S),P=i===0?a.offset:a.path[S]+p;for(var[j,B]of y.levels(t,{at:H,reverse:!0,voids:o})){var N=!1;if(B.length<k.length||B.length===0||!o&&ue.isElement(j)&&y.isVoid(t,j))break;var M=m.current,W=y.isEnd(t,M,B);if(u||!m||!y.isEdge(t,M,B)){N=!0;var re=J.extractProps(j);t.apply({type:"split_node",path:B,position:P,properties:re})}P=B[B.length-1]+(N||W?1:0)}if(n.at==null){var Y=g.current||y.end(t,[]);$.select(t,Y)}}finally{var ee;m.unref(),(ee=g)===null||ee===void 0||ee.unref()}}})},aw=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(n)||(n=[n]);var o={};for(var s of n)o[s]=null;$.setNodes(t,o,r)},iw=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};y.withoutNormalizing(t,()=>{var{mode:r="lowest",split:o=!1,voids:s=!1}=n,{at:a=t.selection,match:i}=n;if(a){i==null&&(i=O.isPath(a)?_r(t,a):g=>ue.isElement(g)&&y.isBlock(t,g)),O.isPath(a)&&(a=y.range(t,a));var u=F.isRange(a)?y.rangeRef(t,a):null,c=y.nodes(t,{at:a,match:i,mode:r,voids:s}),l=Array.from(c,g=>{var[,C]=g;return y.pathRef(t,C)}).reverse(),d=function(){var C=m.unref(),[v]=y.node(t,C),p=y.range(t,C);o&&u&&(p=F.intersection(u.current,p)),$.liftNodes(t,{at:p,match:E=>ue.isAncestor(v)&&v.children.includes(E),voids:s})};for(var m of l)d();u&&u.unref()}})};function Fl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Pl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Fl(Object(n),!0).forEach(function(r){rt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var uw=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};y.withoutNormalizing(t,()=>{var{mode:o="lowest",split:s=!1,voids:a=!1}=r,{match:i,at:u=t.selection}=r;if(u){if(i==null&&(O.isPath(u)?i=_r(t,u):t.isInline(n)?i=p=>ue.isElement(p)&&y.isInline(t,p)||ce.isText(p):i=p=>ue.isElement(p)&&y.isBlock(t,p)),s&&F.isRange(u)){var[c,l]=F.edges(u),d=y.rangeRef(t,u,{affinity:"inward"});$.splitNodes(t,{at:l,match:i,voids:a}),$.splitNodes(t,{at:c,match:i,voids:a}),u=d.unref(),r.at==null&&$.select(t,u)}var m=Array.from(y.nodes(t,{at:u,match:t.isInline(n)?p=>ue.isElement(p)&&y.isBlock(t,p):p=>y.isEditor(p),mode:"lowest",voids:a})),g=function(){var E=F.isRange(u)?F.intersection(u,y.range(t,v)):u;if(!E)return 0;var b=Array.from(y.nodes(t,{at:E,match:i,mode:o,voids:a}));if(b.length>0){var[w]=b,D=b[b.length-1],[,x]=w,[,I]=D;if(x.length===0&&I.length===0)return 0;var S=O.equals(x,I)?O.parent(x):O.common(x,I),k=y.range(t,x,I),H=y.node(t,S),[P]=H,j=S.length+1,B=O.next(I.slice(0,j)),N=Pl(Pl({},n),{},{children:[]});$.insertNodes(t,N,{at:B,voids:a}),$.moveNodes(t,{at:k,match:M=>ue.isAncestor(P)&&P.children.includes(M),to:B.concat(0),voids:a})}},C;for(var[,v]of m)C=g()}})},wh=()=>{var e={children:[],operations:[],selection:null,marks:null,isElementReadOnly:()=>!1,isInline:()=>!1,isSelectable:()=>!0,isVoid:()=>!1,markableVoid:()=>!1,onChange:()=>{},apply:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return NE(e,...r)},addMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $E(e,...r)},deleteBackward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WE(e,...r)},deleteForward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return zE(e,...r)},deleteFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VE(e,...r)},getFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ME(e,...r)},insertBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return nD(e,...r)},insertSoftBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return oD(e,...r)},insertFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WD(e,...r)},insertNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return rD(e,...r)},insertText:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return Eh(e,...r)},normalizeNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _E(e,...r)},removeMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return kD(e,...r)},getDirtyPaths:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return kE(e,...r)},shouldNormalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return jE(e,...r)},above:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LE(e,...r)},after:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UE(e,...r)},before:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HE(e,...r)},collapse:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return zD(e,...r)},delete:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HD(e,...r)},deselect:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VD(e,...r)},edges:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KE(e,...r)},elementReadOnly:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qE(e,...r)},end:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return GE(e,...r)},first:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YE(e,...r)},fragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XE(e,...r)},getMarks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return gD(e,...r)},hasBlocks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return JE(e,...r)},hasInlines:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return QE(e,...r)},hasPath:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return eD(e,...r)},hasTexts:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return tD(e,...r)},insertNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XD(e,...r)},isBlock:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return aD(e,...r)},isEdge:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return iD(e,...r)},isEmpty:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return uD(e,...r)},isEnd:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return cD(e,...r)},isNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return lD(e,...r)},isStart:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return fD(e,...r)},last:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return dD(e,...r)},leaf:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return hD(e,...r)},levels:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return pD(e,...r)},liftNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ZD(e,...r)},mergeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ew(e,...r)},move:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KD(e,...r)},moveNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return tw(e,...r)},next:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CD(e,...r)},node:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return yD(e,...r)},nodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return bD(e,...r)},normalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ED(e,...r)},parent:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DD(e,...r)},path:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return xD(e,...r)},pathRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return wD(e,...r)},pathRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AD(e,...r)},point:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TD(e,...r)},pointRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OD(e,...r)},pointRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return SD(e,...r)},positions:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return RD(e,...r)},previous:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ID(e,...r)},range:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return PD(e,...r)},rangeRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return BD(e,...r)},rangeRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return FD(e,...r)},removeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return nw(e,...r)},select:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qD(e,...r)},setNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return rw(e,...r)},setNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return MD(e,...r)},setPoint:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return GD(e,...r)},setSelection:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YD(e,...r)},splitNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return sw(e,...r)},start:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _D(e,...r)},string:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return jD(e,...r)},unhangRange:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LD(e,...r)},unsetNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return aw(e,...r)},unwrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return iw(e,...r)},void:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ZE(e,...r)},withoutNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $D(e,...r)},wrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return uw(e,...r)},shouldMergeNodesRemovePrevNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UD(e,...r)}};return e};function co(e,t,n={}){const{filterVoids:r}=n,o=y.before(e,t,{unit:"character",voids:r});if(o){const s=y.range(e,o,F.isRange(t)?F.start(t):t),a=y.string(e,s);return{range:s,text:a,void:a.length===0}}}function yu(e,t,n={}){const{filterVoids:r}=n,o=y.after(e,t,{unit:"character",voids:r});if(o){const s=y.range(e,o,F.isRange(t)?F.end(t):t),a=y.string(e,s);return{range:s,text:a,void:a.length===0}}}const cw=/\s/;function Ss(e){return e?cw.test(e):!1}const Nl={direction:"before",allowConsecutiveWhitespace:!0};function Ah(e,t,n=[" "],r=Nl){const{include:o,direction:s,ignoreTerminator:a,allowConsecutiveWhitespace:i}={...Nl,...r};let[u,c]=F.edges(t),l=u,d=!1;function m(g){const C=g==="after"?y.after(e,l,{unit:"character"}):y.before(e,l,{unit:"character"});if(!C||O.compare(C.path,l.path)!==0)return!1;const v=C&&y.string(e,g==="after"?{anchor:l,focus:C}:{anchor:C,focus:l}),p=v&&v[g==="after"?0:v.length-1];if(!i&&d&&Ss(p))return!1;if(C&&p&&(!n.includes(p)||a?.(p,C,g))){if(d=Ss(p),l=C,l.offset===0)return!1}else return!1;return!0}if(s!=="before"){for(l=c;m("after"););c=l}if(s!=="after"){for(l=u;m("before"););u=l}return o?{anchor:s==="before"||s==="both"?y.before(e,u,{unit:"offset"})??u:u,focus:s==="after"||s==="both"?y.after(e,c,{unit:"offset"})??c:c}:{anchor:u,focus:c}}function Sr(e){return!e.trim()}const wn="@";function lw(e){const{selection:t}=e;if(!t||!F.isCollapsed(t))return;const n=Ah(e,t,["@"],{include:!0,allowConsecutiveWhitespace:!1,ignoreTerminator:(o,s)=>{const a=co(e,s);return!!(a&&!Ss(a.text))}});if(!n)return;const r=y.string(e,n);if(!(!r.startsWith(wn)||r.length>1&&Ss(r[1])))return{range:n,text:r.substring(1)}}function qr(e){return ue.isElement(e)&&e.type==="mention"}function fw(e,t){const n={type:"mention",id:t,children:[{text:""}]};$.insertNodes(e,n),$.move(e);const r=e.selection?yu(e,e.selection):void 0;!r||r.void?$.insertText(e," "):Sr(r.text)&&$.move(e)}function dw(e){if(!e.selection)return;const t=co(e,e.selection,{filterVoids:!0}),n=yu(e,e.selection,{filterVoids:!0}),r=t&&!Sr(t.text),o=n&&!Sr(n.text);if(F.isCollapsed(e.selection)){const s=(r?" ":"")+wn;e.insertText(s,{at:F.start(e.selection)}),o&&e.insertText(" ",{at:F.end(e.selection)}),$.collapse(e,{edge:"end"})}else{const s=(r?" ":"")+wn+(o?" ":"");e.insertText(s),o&&$.move(e,{distance:1,unit:"character",reverse:!0})}}function hw(e){const{isInline:t,isVoid:n,markableVoid:r,deleteBackward:o}=e;return e.isInline=s=>qr(s)||t(s),e.isVoid=s=>qr(s)||n(s),e.markableVoid=s=>qr(s)||r(s),e.deleteBackward=s=>{const{selection:a}=e;if(a&&F.isCollapsed(a)){const[i]=y.nodes(e,{at:s==="character"?y.before(e,a,{unit:"character"}):a,match:qr});o(s),i&&$.insertText(e,wn)}else o(s)},e}function pw(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function xh(e){return"type"in e&&e.type==="mention"}function Oh(e){return"type"in e&&e.type==="link"}function Sh(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("www."))return"https://"+e}const Th=f.forwardRef(({children:e,asChild:t,...n},r)=>{const o=t?Ne:"span";return h.jsx(o,{...n,ref:r,children:e})}),Rh=f.forwardRef(({children:e,asChild:t,...n},r)=>{const o=t?Ne:"a";return h.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})}),mw={Mention:({userId:e})=>h.jsxs(Th,{children:[wn,e]}),Link:({href:e,children:t})=>h.jsx(Rh,{href:e,children:t})},Ih=f.forwardRef(({body:e,components:t,style:n,asChild:r,...o},s)=>{const a=r?Ne:"div",{Mention:i,Link:u}=f.useMemo(()=>({...mw,...t}),[t]);return!e||!e?.content?null:h.jsx(a,{...o,style:{whiteSpace:"break-spaces",...n},ref:s,children:e.content.map((c,l)=>{switch(c.type){case"paragraph":return h.jsx("p",{style:{minHeight:"1lh"},children:c.children.map((d,m)=>{if(xh(d))return d.id?h.jsx(i,{userId:d.id},m):null;if(Oh(d)){const C=Sh(d.url)??d.url;return h.jsx(u,{href:C,children:d.text??d.url},m)}let g=d.text;return d.bold&&(g=h.jsx("strong",{children:g},m)),d.italic&&(g=h.jsx("em",{children:g},m)),d.strikethrough&&(g=h.jsx("s",{children:g},m)),d.code&&(g=h.jsx("code",{children:g},m)),h.jsx("span",{children:g},m)})},l);default:return null}})})});var vw={isHistory(e){return ze(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||yn.isOperationList(e.redos[0].operations))&&(e.undos.length===0||yn.isOperationList(e.undos[0].operations))}},Ma=new WeakMap,Nn=new WeakMap,qo=new WeakMap,Ut={isHistoryEditor(e){return vw.isHistory(e.history)&&y.isEditor(e)},isMerging(e){return Nn.get(e)},isSplittingOnce(e){return qo.get(e)},setSplittingOnce(e,t){qo.set(e,t)},isSaving(e){return Ma.get(e)},redo(e){e.redo()},undo(e){e.undo()},withMerging(e,t){var n=Ut.isMerging(e);Nn.set(e,!0),t(),Nn.set(e,n)},withNewBatch(e,t){var n=Ut.isMerging(e);Nn.set(e,!0),qo.set(e,!0),t(),Nn.set(e,n),qo.delete(e)},withoutMerging(e,t){var n=Ut.isMerging(e);Nn.set(e,!1),t(),Nn.set(e,n)},withoutSaving(e,t){var n=Ut.isSaving(e);Ma.set(e,!1),t(),Ma.set(e,n)}},gw=e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:r}=t,{redos:o}=r;if(o.length>0){var s=o[o.length-1];s.selectionBefore&&$.setSelection(t,s.selectionBefore),Ut.withoutSaving(t,()=>{y.withoutNormalizing(t,()=>{for(var a of s.operations)t.apply(a)})}),r.redos.pop(),t.writeHistory("undos",s)}},t.undo=()=>{var{history:r}=t,{undos:o}=r;if(o.length>0){var s=o[o.length-1];Ut.withoutSaving(t,()=>{y.withoutNormalizing(t,()=>{var a=s.operations.map(yn.inverse).reverse();for(var i of a)t.apply(i);s.selectionBefore&&$.setSelection(t,s.selectionBefore)})}),t.writeHistory("redos",s),r.undos.pop()}},t.apply=r=>{var{operations:o,history:s}=t,{undos:a}=s,i=a[a.length-1],u=i&&i.operations[i.operations.length-1],c=Ut.isSaving(t),l=Ut.isMerging(t);if(c==null&&(c=yw(r)),c){if(l==null&&(i==null?l=!1:o.length!==0?l=!0:l=Cw(r,u)),Ut.isSplittingOnce(t)&&(l=!1,Ut.setSplittingOnce(t,void 0)),i&&l)i.operations.push(r);else{var d={operations:[r],selectionBefore:t.selection};t.writeHistory("undos",d)}for(;a.length>100;)a.shift();s.redos=[]}n(r)},t.writeHistory=(r,o)=>{t.history[r].push(o)},t},Cw=(e,t)=>!!(t&&e.type==="insert_text"&&t.type==="insert_text"&&e.offset===t.offset+t.text.length&&O.equals(e.path,t.path)||t&&e.type==="remove_text"&&t.type==="remove_text"&&e.offset+e.text.length===t.offset&&O.equals(e.path,t.path)),yw=(e,t)=>e.type!=="set_selection",_a,kl;function bw(){if(kl)return _a;kl=1,_a=o;var e="֑-߿יִ-﷽ﹰ-ﻼ",t="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",n=new RegExp("^[^"+t+"]*["+e+"]"),r=new RegExp("^[^"+e+"]*["+t+"]");function o(s){return s=String(s||""),n.test(s)?"rtl":r.test(s)?"ltr":"neutral"}return _a}var Ew=bw();const Bh=Ug(Ew),Ml=e=>typeof e=="object"&&e!=null&&e.nodeType===1,_l=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",ja=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return _l(n.overflowY,t)||_l(n.overflowX,t)||(r=>{const o=(s=>{if(!s.ownerDocument||!s.ownerDocument.defaultView)return null;try{return s.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(e)}return!1},Go=(e,t,n,r,o,s,a,i)=>s<e&&a>t||s>e&&a<t?0:s<=e&&i<=n||a>=t&&i>=n?s-e-r:a>t&&i<n||s<e&&i>n?a-t+o:0,Dw=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},jl=(e,t)=>{var n,r,o,s;if(typeof document>"u")return[];const{scrollMode:a,block:i,inline:u,boundary:c,skipOverflowHiddenElements:l}=t,d=typeof c=="function"?c:re=>re!==c;if(!Ml(e))throw new TypeError("Invalid target");const m=document.scrollingElement||document.documentElement,g=[];let C=e;for(;Ml(C)&&d(C);){if(C=Dw(C),C===m){g.push(C);break}C!=null&&C===document.body&&ja(C)&&!ja(document.documentElement)||C!=null&&ja(C,l)&&g.push(C)}const v=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,p=(s=(o=window.visualViewport)==null?void 0:o.height)!=null?s:innerHeight,{scrollX:E,scrollY:b}=window,{height:w,width:D,top:x,right:I,bottom:S,left:k}=e.getBoundingClientRect(),{top:H,right:P,bottom:j,left:B}=(re=>{const Y=window.getComputedStyle(re);return{top:parseFloat(Y.scrollMarginTop)||0,right:parseFloat(Y.scrollMarginRight)||0,bottom:parseFloat(Y.scrollMarginBottom)||0,left:parseFloat(Y.scrollMarginLeft)||0}})(e);let N=i==="start"||i==="nearest"?x-H:i==="end"?S+j:x+w/2-H+j,M=u==="center"?k+D/2-B+P:u==="end"?I+P:k-B;const W=[];for(let re=0;re<g.length;re++){const Y=g[re],{height:ee,width:L,top:Q,right:V,bottom:te,left:se}=Y.getBoundingClientRect();if(a==="if-needed"&&x>=0&&k>=0&&S<=p&&I<=v&&x>=Q&&S<=te&&k>=se&&I<=V)return W;const de=getComputedStyle(Y),G=parseInt(de.borderLeftWidth,10),R=parseInt(de.borderTopWidth,10),_=parseInt(de.borderRightWidth,10),U=parseInt(de.borderBottomWidth,10);let X=0,fe=0;const le="offsetWidth"in Y?Y.offsetWidth-Y.clientWidth-G-_:0,T="offsetHeight"in Y?Y.offsetHeight-Y.clientHeight-R-U:0,q="offsetWidth"in Y?Y.offsetWidth===0?0:L/Y.offsetWidth:0,ne="offsetHeight"in Y?Y.offsetHeight===0?0:ee/Y.offsetHeight:0;if(m===Y)X=i==="start"?N:i==="end"?N-p:i==="nearest"?Go(b,b+p,p,R,U,b+N,b+N+w,w):N-p/2,fe=u==="start"?M:u==="center"?M-v/2:u==="end"?M-v:Go(E,E+v,v,G,_,E+M,E+M+D,D),X=Math.max(0,X+b),fe=Math.max(0,fe+E);else{X=i==="start"?N-Q-R:i==="end"?N-te+U+T:i==="nearest"?Go(Q,te,ee,R,U+T,N,N+w,w):N-(Q+ee/2)+T/2,fe=u==="start"?M-se-G:u==="center"?M-(se+L/2)+le/2:u==="end"?M-V+_+le:Go(se,V,L,G,_+le,M,M+D,D);const{scrollLeft:ie,scrollTop:we}=Y;X=ne===0?0:Math.max(0,Math.min(we+X/ne,Y.scrollHeight-ee/ne+T)),fe=q===0?0:Math.max(0,Math.min(ie+fe/q,Y.scrollWidth-L/q+le)),N+=we-X,M+=ie-fe}W.push({el:Y,top:X,left:fe})}return W},ww=e=>e===!1?{block:"end",inline:"nearest"}:(t=>t===Object(t)&&Object.keys(t).length!==0)(e)?e:{block:"start",inline:"nearest"};function Aw(e,t){if(!e.isConnected||!(o=>{let s=o;for(;s&&s.parentNode;){if(s.parentNode===document)return!0;s=s.parentNode instanceof ShadowRoot?s.parentNode.host:s.parentNode}return!1})(e))return;const n=(o=>{const s=window.getComputedStyle(o);return{top:parseFloat(s.scrollMarginTop)||0,right:parseFloat(s.scrollMarginRight)||0,bottom:parseFloat(s.scrollMarginBottom)||0,left:parseFloat(s.scrollMarginLeft)||0}})(e);if((o=>typeof o=="object"&&typeof o.behavior=="function")(t))return t.behavior(jl(e,t));const r=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:o,top:s,left:a}of jl(e,ww(t))){const i=s-n.top+n.bottom,u=a-n.left+n.right;o.scroll({top:i,left:u,behavior:r})}}var Un=[],xw=function(){return Un.some(function(e){return e.activeTargets.length>0})},Ow=function(){return Un.some(function(e){return e.skippedTargets.length>0})},Ll="ResizeObserver loop completed with undelivered notifications.",Sw=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:Ll}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=Ll),window.dispatchEvent(e)},lo;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(lo||(lo={}));var Hn=function(e){return Object.freeze(e)},Tw=function(){function e(t,n){this.inlineSize=t,this.blockSize=n,Hn(this)}return e}(),Fh=function(){function e(t,n,r,o){return this.x=t,this.y=n,this.width=r,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Hn(this)}return e.prototype.toJSON=function(){var t=this,n=t.x,r=t.y,o=t.top,s=t.right,a=t.bottom,i=t.left,u=t.width,c=t.height;return{x:n,y:r,top:o,right:s,bottom:a,left:i,width:u,height:c}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),bu=function(e){return e instanceof SVGElement&&"getBBox"in e},Ph=function(e){if(bu(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,s=o.offsetWidth,a=o.offsetHeight;return!(s||a||e.getClientRects().length)},$l=function(e){var t;if(e instanceof Element)return!0;var n=(t=e?.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},Rw=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},Wn=typeof window<"u"?window:{},Yo=new WeakMap,Ul=/auto|scroll/,Iw=/^tb|vertical/,Bw=/msie|trident/i.test(Wn.navigator&&Wn.navigator.userAgent),jt=function(e){return parseFloat(e||"0")},yr=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new Tw((n?t:e)||0,(n?e:t)||0)},Hl=Hn({devicePixelContentBoxSize:yr(),borderBoxSize:yr(),contentBoxSize:yr(),contentRect:new Fh(0,0,0,0)}),Nh=function(e,t){if(t===void 0&&(t=!1),Yo.has(e)&&!t)return Yo.get(e);if(Ph(e))return Yo.set(e,Hl),Hl;var n=getComputedStyle(e),r=bu(e)&&e.ownerSVGElement&&e.getBBox(),o=!Bw&&n.boxSizing==="border-box",s=Iw.test(n.writingMode||""),a=!r&&Ul.test(n.overflowY||""),i=!r&&Ul.test(n.overflowX||""),u=r?0:jt(n.paddingTop),c=r?0:jt(n.paddingRight),l=r?0:jt(n.paddingBottom),d=r?0:jt(n.paddingLeft),m=r?0:jt(n.borderTopWidth),g=r?0:jt(n.borderRightWidth),C=r?0:jt(n.borderBottomWidth),v=r?0:jt(n.borderLeftWidth),p=d+c,E=u+l,b=v+g,w=m+C,D=i?e.offsetHeight-w-e.clientHeight:0,x=a?e.offsetWidth-b-e.clientWidth:0,I=o?p+b:0,S=o?E+w:0,k=r?r.width:jt(n.width)-I-x,H=r?r.height:jt(n.height)-S-D,P=k+p+x+b,j=H+E+D+w,B=Hn({devicePixelContentBoxSize:yr(Math.round(k*devicePixelRatio),Math.round(H*devicePixelRatio),s),borderBoxSize:yr(P,j,s),contentBoxSize:yr(k,H,s),contentRect:new Fh(d,u,k,H)});return Yo.set(e,B),B},kh=function(e,t,n){var r=Nh(e,n),o=r.borderBoxSize,s=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(t){case lo.DEVICE_PIXEL_CONTENT_BOX:return a;case lo.BORDER_BOX:return o;default:return s}},Fw=function(){function e(t){var n=Nh(t);this.target=t,this.contentRect=n.contentRect,this.borderBoxSize=Hn([n.borderBoxSize]),this.contentBoxSize=Hn([n.contentBoxSize]),this.devicePixelContentBoxSize=Hn([n.devicePixelContentBoxSize])}return e}(),Mh=function(e){if(Ph(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},Pw=function(){var e=1/0,t=[];Un.forEach(function(a){if(a.activeTargets.length!==0){var i=[];a.activeTargets.forEach(function(c){var l=new Fw(c.target),d=Mh(c.target);i.push(l),c.lastReportedSize=kh(c.target,c.observedBox),d<e&&(e=d)}),t.push(function(){a.callback.call(a.observer,i,a.observer)}),a.activeTargets.splice(0,a.activeTargets.length)}});for(var n=0,r=t;n<r.length;n++){var o=r[n];o()}return e},Wl=function(e){Un.forEach(function(n){n.activeTargets.splice(0,n.activeTargets.length),n.skippedTargets.splice(0,n.skippedTargets.length),n.observationTargets.forEach(function(o){o.isActive()&&(Mh(o.target)>e?n.activeTargets.push(o):n.skippedTargets.push(o))})})},Nw=function(){var e=0;for(Wl(e);xw();)e=Pw(),Wl(e);return Ow()&&Sw(),e>0},La,_h=[],kw=function(){return _h.splice(0).forEach(function(e){return e()})},Mw=function(e){if(!La){var t=0,n=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return kw()}).observe(n,r),La=function(){n.textContent="".concat(t?t--:t++)}}_h.push(e),La()},_w=function(e){Mw(function(){requestAnimationFrame(e)})},us=0,jw=function(){return!!us},Lw=250,$w={attributes:!0,characterData:!0,childList:!0,subtree:!0},zl=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Vl=function(e){return e===void 0&&(e=0),Date.now()+e},$a=!1,Uw=function(){function e(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return e.prototype.run=function(t){var n=this;if(t===void 0&&(t=Lw),!$a){$a=!0;var r=Vl(t);_w(function(){var o=!1;try{o=Nw()}finally{if($a=!1,t=r-Vl(),!jw())return;o?n.run(1e3):t>0?n.run(t):n.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,n=function(){return t.observer&&t.observer.observe(document.body,$w)};document.body?n():Wn.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),zl.forEach(function(n){return Wn.addEventListener(n,t.listener,!0)}))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),zl.forEach(function(n){return Wn.removeEventListener(n,t.listener,!0)}),this.stopped=!0)},e}(),Ai=new Uw,Kl=function(e){!us&&e>0&&Ai.start(),us+=e,!us&&Ai.stop()},Hw=function(e){return!bu(e)&&!Rw(e)&&getComputedStyle(e).display==="inline"},Ww=function(){function e(t,n){this.target=t,this.observedBox=n||lo.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=kh(this.target,this.observedBox,!0);return Hw(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),zw=function(){function e(t,n){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=n}return e}(),Xo=new WeakMap,ql=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},Zo=function(){function e(){}return e.connect=function(t,n){var r=new zw(t,n);Xo.set(t,r)},e.observe=function(t,n,r){var o=Xo.get(t),s=o.observationTargets.length===0;ql(o.observationTargets,n)<0&&(s&&Un.push(o),o.observationTargets.push(new Ww(n,r&&r.box)),Kl(1),Ai.schedule())},e.unobserve=function(t,n){var r=Xo.get(t),o=ql(r.observationTargets,n),s=r.observationTargets.length===1;o>=0&&(s&&Un.splice(Un.indexOf(r),1),r.observationTargets.splice(o,1),Kl(-1))},e.disconnect=function(t){var n=this,r=Xo.get(t);r.observationTargets.slice().forEach(function(o){return n.unobserve(t,o.target)}),r.activeTargets.splice(0,r.activeTargets.length)},e}(),Vw=function(){function e(t){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof t!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");Zo.connect(this,t)}return e.prototype.observe=function(t,n){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!$l(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Zo.observe(this,t,n)},e.prototype.unobserve=function(t){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!$l(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Zo.unobserve(this,t)},e.prototype.disconnect=function(){Zo.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}(),St={},Gl;function Kw(){if(Gl)return St;Gl=1,Object.defineProperty(St,"__esModule",{value:!0});for(var e=typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),t={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},n={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:e?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},r={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=1;o<20;o++)r["f"+o]=111+o;function s(m,g,C){g&&!("byKey"in g)&&(C=g,g=null),Array.isArray(m)||(m=[m]);var v=m.map(function(b){return u(b,g)}),p=function(w){return v.some(function(D){return c(D,w)})},E=C==null?p:p(C);return E}function a(m,g){return s(m,g)}function i(m,g){return s(m,{byKey:!0},g)}function u(m,g){var C=g&&g.byKey,v={};m=m.replace("++","+add");var p=m.split("+"),E=p.length;for(var b in t)v[t[b]]=!1;var w=!0,D=!1,x=void 0;try{for(var I=p[Symbol.iterator](),S;!(w=(S=I.next()).done);w=!0){var k=S.value,H=k.endsWith("?")&&k.length>1;H&&(k=k.slice(0,-1));var P=d(k),j=t[P];if(k.length>1&&!j&&!n[k]&&!r[P])throw new TypeError('Unknown modifier: "'+k+'"');(E===1||!j)&&(C?v.key=P:v.which=l(k)),j&&(v[j]=H?null:!0)}}catch(B){D=!0,x=B}finally{try{!w&&I.return&&I.return()}finally{if(D)throw x}}return v}function c(m,g){for(var C in m){var v=m[C],p=void 0;if(v!=null&&(C==="key"&&g.key!=null?p=g.key.toLowerCase():C==="which"?p=v===91&&g.which===93?91:g.which:p=g[C],!(p==null&&v===!1)&&p!==v))return!1}return!0}function l(m){m=d(m);var g=r[m]||m.toUpperCase().charCodeAt(0);return g}function d(m){return m=m.toLowerCase(),m=n[m]||m,m}return St.default=s,St.isHotkey=s,St.isCodeHotkey=a,St.isKeyHotkey=i,St.parseHotkey=u,St.compareHotkey=c,St.toKeyCode=l,St.toKeyName=d,St}var Ua=Kw();function qw(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function Tr(e,t){if(e==null)return{};var n=qw(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function fo(e){"@babel/helpers - typeof";return fo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fo(e)}function Gw(e,t){if(fo(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(fo(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Yw(e){var t=Gw(e,"string");return fo(t)==="symbol"?t:String(t)}function At(e,t,n){return t=Yw(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Eu=f.createContext(null),Gt=()=>{var e=f.useContext(Eu);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},Ha,Wa,jh=parseInt(me.version.split(".")[0],10),Lh=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Yl=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),nt=typeof navigator<"u"&&/Android/.test(navigator.userAgent),mr=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Mn=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),Xw=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),$h=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),Zw=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),Jw=nt&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),Qw=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),eA=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),tA=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent),cs=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&((Ha=navigator.userAgent.match(/Version\/(\d+)/))!==null&&Ha!==void 0&&Ha[1]&&parseInt((Wa=navigator.userAgent.match(/Version\/(\d+)/))===null||Wa===void 0?void 0:Wa[1],10)<17);var dn=(!Zw||!Jw)&&!Xw&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function",br=new WeakMap,Du=new WeakMap,wu=new WeakMap,Uh=new WeakMap,ls=new WeakMap,xi=new WeakMap,ho=new WeakMap,zn=new WeakMap,Ts=new WeakMap,Js=new WeakMap,Oi=new WeakMap,bn=new WeakMap,jn=new WeakMap,to=new WeakMap,Si=new WeakMap,Au=new WeakMap,Ft=new WeakMap,Qt=new WeakMap,st=new WeakMap,mn=new WeakMap,vn=new WeakMap,Hh=new WeakMap,Rr=Symbol("placeholder"),Wh=Symbol("mark-placeholder"),zh=globalThis.Node,nA=globalThis.Text,xu=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,rA=e=>An(e)&&e.nodeType===8,Et=e=>An(e)&&e.nodeType===1,An=e=>{var t=xu(e);return!!t&&e instanceof t.Node},Ti=e=>{var t=e&&e.anchorNode&&xu(e.anchorNode);return!!t&&e instanceof t.Selection},Vh=e=>An(e)&&e.nodeType===3,oA=e=>e.clipboardData&&e.clipboardData.getData("text/plain")!==""&&e.clipboardData.types.length===1,sA=e=>{var[t,n]=e;if(Et(t)&&t.childNodes.length){var r=n===t.childNodes.length,o=r?n-1:n;for([t,o]=Kh(t,o,r?"backward":"forward"),r=o<n;Et(t)&&t.childNodes.length;){var s=r?t.childNodes.length-1:0;t=iA(t,s,r?"backward":"forward")}n=r&&t.textContent!=null?t.textContent.length:0}return[t,n]},aA=e=>{for(var t=e&&e.parentNode;t;){if(t.toString()==="[object ShadowRoot]")return!0;t=t.parentNode}return!1},Kh=(e,t,n)=>{for(var{childNodes:r}=e,o=r[t],s=t,a=!1,i=!1;(rA(o)||Et(o)&&o.childNodes.length===0||Et(o)&&o.getAttribute("contenteditable")==="false")&&!(a&&i);){if(s>=r.length){a=!0,s=t-1,n="backward";continue}if(s<0){i=!0,s=t+1,n="forward";continue}o=r[s],t=s,s+=n==="forward"?1:-1}return[o,t]},iA=(e,t,n)=>{var[r]=Kh(e,t,n);return r},qh=e=>{var t="";if(Vh(e)&&e.nodeValue)return e.nodeValue;if(Et(e)){for(var n of Array.from(e.childNodes))t+=qh(n);var r=getComputedStyle(e).getPropertyValue("display");(r==="block"||r==="list"||e.tagName==="BR")&&(t+=`
4
4
  `)}return t},uA=/data-slate-fragment="(.+?)"/m,cA=e=>{var t=e.getData("text/html"),[,n]=t.match(uA)||[];return n},no=e=>e.getSelection!=null?e.getSelection():document.getSelection(),Ou=(e,t,n)=>{var{target:r}=t;if(Et(r)&&r.matches('[contentEditable="false"]'))return!1;var{document:o}=z.getWindow(e);if(o.contains(r))return z.hasDOMNode(e,r,{editable:!0});var s=n.find(a=>{var{addedNodes:i,removedNodes:u}=a;for(var c of i)if(c===r||c.contains(r))return!0;for(var l of u)if(l===r||l.contains(r))return!0});return!s||s===t?!1:Ou(e,s,n)},lA=()=>{for(var e=document.activeElement;(t=e)!==null&&t!==void 0&&t.shadowRoot&&(n=e.shadowRoot)!==null&&n!==void 0&&n.activeElement;){var t,n,r;e=(r=e)===null||r===void 0||(r=r.shadowRoot)===null||r===void 0?void 0:r.activeElement}return e},Xl=(e,t)=>!!(e.compareDocumentPosition(t)&zh.DOCUMENT_POSITION_PRECEDING),fA=(e,t)=>!!(e.compareDocumentPosition(t)&zh.DOCUMENT_POSITION_FOLLOWING),dA=0;class hA{constructor(){At(this,"id",void 0),this.id="".concat(dA++)}}var z={androidPendingDiffs:e=>st.get(e),androidScheduleFlush:e=>{var t;(t=Au.get(e))===null||t===void 0||t()},blur:e=>{var t=z.toDOMNode(e,e),n=z.findDocumentOrShadowRoot(e);bn.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{var{selection:t}=e,n=z.findDocumentOrShadowRoot(e),r=no(n);r&&r.rangeCount>0&&r.removeAllRanges(),t&&$.deselect(e)},findDocumentOrShadowRoot:e=>{var t=z.toDOMNode(e,e),n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},findEventRange:(e,t)=>{"nativeEvent"in t&&(t=t.nativeEvent);var{clientX:n,clientY:r,target:o}=t;if(n==null||r==null)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var s=z.toSlateNode(e,t.target),a=z.findPath(e,s);if(ue.isElement(s)&&y.isVoid(e,s)){var i=o.getBoundingClientRect(),u=e.isInline(s)?n-i.left<i.left+i.width-n:r-i.top<i.top+i.height-r,c=y.point(e,a,{edge:u?"start":"end"}),l=u?y.before(e,c):y.after(e,c);if(l){var d=y.range(e,l);return d}}var m,{document:g}=z.getWindow(e);if(g.caretRangeFromPoint)m=g.caretRangeFromPoint(n,r);else{var C=g.caretPositionFromPoint(n,r);C&&(m=g.createRange(),m.setStart(C.offsetNode,C.offset),m.setEnd(C.offsetNode,C.offset))}if(!m)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var v=z.toSlateRange(e,m,{exactMatch:!1,suppressThrow:!1});return v},findKey:(e,t)=>{var n=Ts.get(t);return n||(n=new hA,Ts.set(t,n)),n},findPath:(e,t)=>{for(var n=[],r=t;;){var o=wu.get(r);if(o==null){if(y.isEditor(r))return n;break}var s=Du.get(r);if(s==null)break;n.unshift(s),r=o}throw new Error("Unable to find the path for Slate node: ".concat(Ve.stringify(t)))},focus:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{retries:5};if(!bn.get(t)){if(n.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(t.operations.length>0){setTimeout(()=>{z.focus(t,{retries:n.retries-1})},10);return}var r=z.toDOMNode(t,t),o=z.findDocumentOrShadowRoot(t);if(o.activeElement!==r){if(t.selection&&o instanceof Document){var s=no(o),a=z.toDOMRange(t,t.selection);s?.removeAllRanges(),s?.addRange(a)}t.selection||$.select(t,y.start(t,[])),bn.set(t,!0),r.focus({preventScroll:!0})}}},getWindow:e=>{var t=Uh.get(e);if(!t)throw new Error("Unable to find a host window element for this editor");return t},hasDOMNode:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{editable:o=!1}=r,s=z.toDOMNode(t,t),a;try{a=Et(n)?n:n.parentElement}catch(i){if(i instanceof Error&&!i.message.includes('Permission denied to access property "nodeType"'))throw i}return a?a.closest("[data-slate-editor]")===s&&(!o||a.isContentEditable?!0:typeof a.isContentEditable=="boolean"&&a.closest('[contenteditable="false"]')===s||!!a.getAttribute("data-slate-zero-width")):!1},hasEditableTarget:(e,t)=>An(t)&&z.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{var{anchor:n,focus:r}=t;return y.hasPath(e,n.path)&&y.hasPath(e,r.path)},hasSelectableTarget:(e,t)=>z.hasEditableTarget(e,t)||z.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>An(t)&&z.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!jn.get(e),isFocused:e=>!!bn.get(e),isReadOnly:e=>!!Oi.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(Oi.get(e))return!1;var n=z.hasTarget(e,t)&&z.toSlateNode(e,t);return ue.isElement(n)&&y.isVoid(e,n)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{var n=Js.get(e),r=y.isEditor(t)?ls.get(e):n?.get(z.findKey(e,t));if(!r)throw new Error("Cannot resolve a DOM node from Slate node: ".concat(Ve.stringify(t)));return r},toDOMPoint:(e,t)=>{var[n]=y.node(e,t.path),r=z.toDOMNode(e,n),o;y.void(e,{at:t})&&(t={path:t.path,offset:0});for(var s="[data-slate-string], [data-slate-zero-width]",a=Array.from(r.querySelectorAll(s)),i=0,u=0;u<a.length;u++){var c=a[u],l=c.childNodes[0];if(!(l==null||l.textContent==null)){var{length:d}=l.textContent,m=c.getAttribute("data-slate-length"),g=m==null?d:parseInt(m,10),C=i+g,v=a[u+1];if(t.offset===C&&v!==null&&v!==void 0&&v.hasAttribute("data-slate-mark-placeholder")){var p,E=v.childNodes[0];o=[E instanceof nA?E:v,(p=v.textContent)!==null&&p!==void 0&&p.startsWith("\uFEFF")?1:0];break}if(t.offset<=C){var b=Math.min(d,Math.max(0,t.offset-i));o=[l,b];break}i=C}}if(!o)throw new Error("Cannot resolve a DOM point from Slate point: ".concat(Ve.stringify(t)));return o},toDOMRange:(e,t)=>{var{anchor:n,focus:r}=t,o=F.isBackward(t),s=z.toDOMPoint(e,n),a=F.isCollapsed(t)?s:z.toDOMPoint(e,r),i=z.getWindow(e),u=i.document.createRange(),[c,l]=o?a:s,[d,m]=o?s:a,g=Et(c)?c:c.parentElement,C=!!g.getAttribute("data-slate-zero-width"),v=Et(d)?d:d.parentElement,p=!!v.getAttribute("data-slate-zero-width");return u.setStart(c,C?1:l),u.setEnd(d,p?1:m),u},toSlateNode:(e,t)=>{var n=Et(t)?t:t.parentElement;n&&!n.hasAttribute("data-slate-node")&&(n=n.closest("[data-slate-node]"));var r=n?ho.get(n):null;if(!r)throw new Error("Cannot resolve a Slate node from DOM node: ".concat(n));return r},toSlatePoint:(e,t,n)=>{var{exactMatch:r,suppressThrow:o,searchDirection:s="backward"}=n,[a,i]=r?t:sA(t),u=a.parentNode,c=null,l=0;if(u){var d,m,g=z.toDOMNode(e,e),C=u.closest('[data-slate-void="true"]'),v=C&&g.contains(C)?C:null,p=u.closest('[contenteditable="false"]'),E=p&&g.contains(p)?p:null,b=u.closest("[data-slate-leaf]"),w=null;if(b){if(c=b.closest('[data-slate-node="text"]'),c){var D=z.getWindow(e),x=D.document.createRange();x.setStart(c,0),x.setEnd(a,i);var I=x.cloneContents(),S=[...Array.prototype.slice.call(I.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(I.querySelectorAll("[contenteditable=false]"))];S.forEach(se=>{if(nt&&!r&&se.hasAttribute("data-slate-zero-width")&&se.textContent.length>0&&se.textContext!=="\uFEFF"){se.textContent.startsWith("\uFEFF")&&(se.textContent=se.textContent.slice(1));return}se.parentNode.removeChild(se)}),l=I.textContent.length,w=c}}else if(v){for(var k=v.querySelectorAll("[data-slate-leaf]"),H=0;H<k.length;H++){var P=k[H];if(z.hasDOMNode(e,P)){b=P;break}}b?(c=b.closest('[data-slate-node="text"]'),w=b,l=w.textContent.length,w.querySelectorAll("[data-slate-zero-width]").forEach(se=>{l-=se.textContent.length})):l=1}else if(E){var j=se=>se?se.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],B=E.closest('[data-slate-node="element"]');if(s==="forward"){var N,M=[...j(B),...j(B?.nextElementSibling)];b=(N=M.find(se=>fA(E,se)))!==null&&N!==void 0?N:null}else{var W,re=[...j(B?.previousElementSibling),...j(B)];b=(W=re.findLast(se=>Xl(E,se)))!==null&&W!==void 0?W:null}b&&(c=b.closest('[data-slate-node="text"]'),w=b,s==="forward"?l=0:(l=w.textContent.length,w.querySelectorAll("[data-slate-zero-width]").forEach(se=>{l-=se.textContent.length})))}w&&l===w.textContent.length&&nt&&w.getAttribute("data-slate-zero-width")==="z"&&(d=w.textContent)!==null&&d!==void 0&&d.startsWith("\uFEFF")&&(u.hasAttribute("data-slate-zero-width")||mr&&(m=w.textContent)!==null&&m!==void 0&&m.endsWith(`