@zeniai/web-app-ui 5.1.99-qa → 5.2.0-qa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AddressRoutes-DGCDOoKb.js +1 -0
- package/dist/assets/{AddressScreen-CBnElFxM.js → AddressScreen-Dzf83tSk.js} +2 -2
- package/dist/assets/AiCfoScreen-TZ---AU4.js +22 -0
- package/dist/assets/{BillPayApprovalRoutes-CB55AV0C.js → BillPayApprovalRoutes-iPPwT0JG.js} +1 -1
- package/dist/assets/{BillPayRoutes-UVA-u63A.js → BillPayRoutes-U0Aszwdv.js} +17 -17
- package/dist/assets/{BusinessVerificationPageScreen-DsowR4fB.js → BusinessVerificationPageScreen-B4os1LkS.js} +2 -2
- package/dist/assets/{CardsAiCfoScreen-BaEolMVN.js → CardsAiCfoScreen-Db20Cfsg.js} +3 -3
- package/dist/assets/{ChargeCardRoutes-D3n7KJn0.js → ChargeCardRoutes-rxetskAF.js} +10 -10
- package/dist/assets/{CompanyPassportScreen-wSnqdrZm.js → CompanyPassportScreen-COm4H_kf.js} +1 -1
- package/dist/assets/ConnectionAuthScreen-C5LpJddx.js +11 -0
- package/dist/assets/CustomerOnboardingAuthScreen-BIc9nbPF.js +1 -0
- package/dist/assets/{CustomerOnboardingRoutes-DT_Ih6lH.js → CustomerOnboardingRoutes-Id7ixv-a.js} +5 -5
- package/dist/assets/{DashboardRoutes-B4SpN_q5.js → DashboardRoutes-D_SbIh49.js} +4 -4
- package/dist/assets/{DefaultTenantHome-C-Q9oQmt.js → DefaultTenantHome-BsKeybH6.js} +1 -1
- package/dist/assets/DomesticWireDetailScreen-BKpkRMty.js +18 -0
- package/dist/assets/DrawerScreen-BPgZ_1JF.js +1 -0
- package/dist/assets/EntityDetailRoutes-BZ9Mr897.js +1 -0
- package/dist/assets/{ExpenseAutomationRoutes-nIGBHuEd.js → ExpenseAutomationRoutes-CN3ihdCO.js} +3 -3
- package/dist/assets/FeaturePreviewScreen-Di3PuVRR.js +1 -0
- package/dist/assets/HubSpotOAuthCallbackScreen-CW56Ncxa.js +1 -0
- package/dist/assets/{MagicLinkRoutes-BTau9CfB.js → MagicLinkRoutes-DJ7vyce1.js} +5 -5
- package/dist/assets/MagicLinkSignInScreen-BZfit8o3.js +12 -0
- package/dist/assets/MobileAppDrawer-NdU6zrS3.js +1 -0
- package/dist/assets/NotFoundScreen-wlhddpbg.js +1 -0
- package/dist/assets/{NotificationRoutes-CkKMsCoc.js → NotificationRoutes-DbRksc78.js} +1 -1
- package/dist/assets/OAuthConsentScreen-sL3GodJ_.js +1 -0
- package/dist/assets/PandLWithForecastRoutes-BoM4q2mR.js +1 -0
- package/dist/assets/PeopleRoutes-0fm-JoER.js +22 -0
- package/dist/assets/PerformanceRoutes-Cq8pT07f.js +1 -0
- package/dist/assets/{Preview-Dh_7Y2V1.js → Preview-CuOg-A8H.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-BOAmyhRI.js → QBOConnectionScreen-D9vGR9Iz.js} +1 -1
- package/dist/assets/ReimbursementApprovalRoutes-DfMng3xh.js +1 -0
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-B0OjRx8o.js → ReimbursementApprovalRuleDetailScreen-w7TPHMbb.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-CnfaWQKq.js → ReimbursementRoutes-uHKvr9EG.js} +8 -8
- package/dist/assets/{ReportsRoutes-ZKjtrrXu.js → ReportsRoutes-BosLV3TS.js} +1 -1
- package/dist/assets/RewardsRoutes-BPVfq5Np.js +1 -0
- package/dist/assets/ScreenRoutes-Drpg91zT.js +2 -0
- package/dist/assets/{SettingsRoutes-0RQL-spt.js → SettingsRoutes-BmbweE5j.js} +8 -8
- package/dist/assets/{SetupPagesScreen-lXVOcLJ8.js → SetupPagesScreen-HhCCJlo-.js} +5 -5
- package/dist/assets/SignInScreen-B8UhmfC2.js +1 -0
- package/dist/assets/SignOutScreen-CxWWZOhK.js +9 -0
- package/dist/assets/TaskListScreen-B7M-Cqce.js +9 -0
- package/dist/assets/TaskRoutes-CyLfJ8Tw.js +9 -0
- package/dist/assets/{TransactionDetailRoutes-DFhCPCQa.js → TransactionDetailRoutes-Ct4erWuE.js} +1 -1
- package/dist/assets/TransactionDetailScreen-DRzSksYw.js +5 -0
- package/dist/assets/{TransactionListRoutes-kn0wMJaj.js → TransactionListRoutes-B191v9kk.js} +1 -1
- package/dist/assets/{TreasuryRoutes-h3ROpRx5.js → TreasuryRoutes-DZNZaxYZ.js} +6 -6
- package/dist/assets/{VendorsRoutes-x1VmRs4J.js → VendorsRoutes-CvrHlc-r.js} +1 -1
- package/dist/assets/WiseConfirmationScreen-B9yx7qcI.js +12 -0
- package/dist/assets/{ZeniAccountRoutes-BOVvauFK.js → ZeniAccountRoutes-YPhOuFwx.js} +12 -12
- package/dist/assets/ZeniAccountStatementScreen-DJU3198J.js +9 -0
- package/dist/assets/{accountMappingHelper-DNCKLg7K.js → accountMappingHelper-SWFIL59M.js} +1 -1
- package/dist/assets/{analytics-1WMvk5Rb.js → analytics-DhULAPA0.js} +1 -1
- package/dist/assets/{analyticsHelper-C8vUB4gm.js → analyticsHelper-CbsMOq15.js} +1 -1
- package/dist/assets/{core-0WK0Zss8.js → core-CnGMK-sC.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-DYdex7Fp.js → decodeURIComponentSafe-uWfgYCNH.js} +1 -1
- package/dist/assets/{dnd-Dwsdp5ty.js → dnd-BqCGp7Ed.js} +1 -1
- package/dist/assets/{empty-o2YkWI97.js → empty-AGnm4bIq.js} +1 -1
- package/dist/assets/{empty-B_vMxB0z.js → empty-CZCaQm4J.js} +1 -1
- package/dist/assets/{emptyVideoElement-Cmrnn243.js → emptyVideoElement-Cqm9YLjS.js} +1 -1
- package/dist/assets/epic-CTjjWhpg.js +2 -0
- package/dist/assets/getLocaleForTenant-BuGWeb9s.js +1 -0
- package/dist/assets/{index-DptRs9ko.js → index-BuTuhkuP.js} +2 -2
- package/dist/assets/{index-CmH-4r8j.js → index-CUaM5Y1I.js} +1 -1
- package/dist/assets/{index-Dy73EgcO.js → index-D7tfVykC.js} +14303 -14311
- package/dist/assets/{index-C3zdsXK_.js → index-D88Jaev3.js} +1 -1
- package/dist/assets/{index-B4Kzctdg.js → index-S4IFBgph.js} +1 -1
- package/dist/assets/{index-CcesBH_n.js → index-XkyLBJ61.js} +1 -1
- package/dist/assets/{index-CqKRE3AP.js → index-b64yysEr.js} +1 -1
- package/dist/assets/{index-CFATCouK.js → index-uYv86E98.js} +1 -1
- package/dist/assets/{lexical-B9WqgH9H.js → lexical-DlqthnSG.js} +1 -1
- package/dist/assets/{liveblocks-tpE-grBU.js → liveblocks-s55OcG-D.js} +1 -1
- package/dist/assets/{lottie-dQMhiLBj.js → lottie-DMKCl4ti.js} +1 -1
- package/dist/assets/{mui-NHWzIwJg.js → mui-CggbPNN2.js} +2 -2
- package/dist/assets/{pathToGoBack-BmJj5cme.js → pathToGoBack-DpxbYxCk.js} +1 -1
- package/dist/assets/{pdf-C4fX1mA3.js → pdf-BD0zxvar.js} +3 -3
- package/dist/assets/{pdf-lib-CxgB1_73.js → pdf-lib-BzRjr6sI.js} +1 -1
- package/dist/assets/{plaid-59NT4aqa.js → plaid-d_bwfWrk.js} +1 -1
- package/dist/assets/{pusher-CY-7JGv2.js → pusher-Cfk4rd_d.js} +1 -1
- package/dist/assets/{react-D8u5JcH6.js → react-BKWnIOym.js} +1 -1
- package/dist/assets/{react-C2Lbn6h8.js → react-BdjYstH9.js} +1 -1
- package/dist/assets/{react-DhqMtE92.js → react-C8X5xuWi.js} +1 -1
- package/dist/assets/{react-SLQy3m4e.js → react-CSLZes-L.js} +1 -1
- package/dist/assets/{react-OZ0ubAW7.js → react-D5Ky_KQN.js} +1 -1
- package/dist/assets/{react-C3I7c7kB.js → react-onoaKP_J.js} +1 -1
- package/dist/assets/{recharts-CUzwcISX.js → recharts-CmLekiCG.js} +1 -1
- package/dist/assets/routePaths-CVAI7AUa.js +1 -0
- package/dist/assets/{sentry-D58SEIt0.js → sentry-qwy54zvC.js} +1 -1
- package/dist/assets/{url-BRZfE6CD.js → url-BKJ8Udjp.js} +1 -1
- package/dist/assets/{url-wdUk7Rbg.js → url-CF9Fx3Jk.js} +1 -1
- package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-DwtRgARG.js +1 -0
- package/dist/assets/useAskAiCfoHostNavButtonProps-Bl-nKTXG.js +1 -0
- package/dist/assets/useCashManagementBanner-SbCmMLis.js +1 -0
- package/dist/assets/{useChargeCardPusherEvents-DGhBtw5K.js → useChargeCardPusherEvents-Cg9Qn_oP.js} +1 -1
- package/dist/assets/{useDeviceId-SayLljl1.js → useDeviceId-DPOieVuC.js} +1 -1
- package/dist/assets/useEmailConnectResultRefresh-gsc6JcZn.js +1 -0
- package/dist/assets/{useInitialThreadRequest-B7WOjZ27.js → useInitialThreadRequest-CXnpfTcs.js} +1 -1
- package/dist/assets/{utils-CHGPa257.js → utils-5Fz6z6US.js} +1 -1
- package/dist/assets/{withTransactionSidePanel-BsJ58rSa.js → withTransactionSidePanel-ZQvLeKiY.js} +2 -2
- package/dist/assets/{zeni-epic-state-Bx_bp9Xr.js → zeni-epic-state-NrbJoBOX.js} +4 -4
- package/dist/index.html +1 -1
- package/package.json +3 -3
- package/dist/assets/AddressRoutes-ChIEG7ZZ.js +0 -1
- package/dist/assets/AiCfoScreen-DXLxFBnQ.js +0 -22
- package/dist/assets/ConnectionAuthScreen-RH-ZQnmS.js +0 -11
- package/dist/assets/CustomerOnboardingAuthScreen-Bro8vP9Q.js +0 -1
- package/dist/assets/DomesticWireDetailScreen-DmspT9Qv.js +0 -18
- package/dist/assets/DrawerScreen-CTBdvd2J.js +0 -1
- package/dist/assets/EntityDetailRoutes-DPOfKd1l.js +0 -1
- package/dist/assets/FeaturePreviewScreen-CS0na0Uv.js +0 -1
- package/dist/assets/HubSpotOAuthCallbackScreen-CDdCifUI.js +0 -1
- package/dist/assets/MagicLinkSignInScreen-BQxK3HJS.js +0 -12
- package/dist/assets/MobileAppDrawer-By5kqJZy.js +0 -1
- package/dist/assets/NotFoundScreen-BUpSeNgf.js +0 -1
- package/dist/assets/OAuthConsentScreen-BzkRmkhL.js +0 -1
- package/dist/assets/PandLWithForecastRoutes-DB98rpg8.js +0 -1
- package/dist/assets/PeopleRoutes-BPQhjQKR.js +0 -22
- package/dist/assets/PerformanceRoutes-Cu8GwbPn.js +0 -1
- package/dist/assets/ReferralListScreen-Bg4MIsqb.js +0 -5
- package/dist/assets/ReimbursementApprovalRoutes-CLqW8bjU.js +0 -1
- package/dist/assets/RewardsRoutes-Dmsl5Hhz.js +0 -1
- package/dist/assets/ScreenRoutes-DtVjvGeB.js +0 -2
- package/dist/assets/SignInScreen-Caakz2DY.js +0 -1
- package/dist/assets/SignOutScreen-CtzEkEl4.js +0 -9
- package/dist/assets/TaskListScreen-BtTYiD21.js +0 -9
- package/dist/assets/TaskRoutes-X8P3xHwH.js +0 -9
- package/dist/assets/TransactionDetailScreen-CRWTcneH.js +0 -5
- package/dist/assets/WiseConfirmationScreen-CIMiBhET.js +0 -12
- package/dist/assets/ZeniAccountStatementScreen-DZHjDSg5.js +0 -9
- package/dist/assets/epic-BqLIdimv.js +0 -2
- package/dist/assets/getLocaleForTenant-CqQ308VG.js +0 -1
- package/dist/assets/routePaths-YBRbNv0i.js +0 -1
- package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-B3JxpD0o.js +0 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-Dx1w_2sk.js +0 -1
- package/dist/assets/useCashManagementBanner-MgmXXc9G.js +0 -1
- package/dist/assets/useEmailConnectResultRefresh-CG-YyoOP.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as qm,a as h,c as pa,g as Km,b as ge,R as Gm}from"./sentry-
|
|
1
|
+
import{r as qm,a as h,c as pa,g as Km,b as ge,R as Gm}from"./sentry-qwy54zvC.js";import{R as md,r as fi}from"./core-CnGMK-sC.js";import{H as fu,I as hu,J as Xm,K as ns}from"./zeni-epic-state-NrbJoBOX.js";import{t as Zm,d as Ym}from"./recharts-CmLekiCG.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f736f521-cc7e-4559-b9e4-ed5fdbca474b",e._sentryDebugIdIdentifier="sentry-dbid-f736f521-cc7e-4559-b9e4-ed5fdbca474b")}catch{}})();var pu,mu,gu={exports:{}},Cr={},v=(mu||(mu=1,gu.exports=(function(){if(pu)return Cr;pu=1;var e=qm(),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,i={key:!0,ref:!0,__self:!0,__source:!0};function a(u,s,c){var l,d={},p=null,m=null;for(l in c!==void 0&&(p=""+c),s.key!==void 0&&(p=""+s.key),s.ref!==void 0&&(m=s.ref),s)r.call(s,l)&&!i.hasOwnProperty(l)&&(d[l]=s[l]);if(u&&u.defaultProps)for(l in s=u.defaultProps)d[l]===void 0&&(d[l]=s[l]);return{$$typeof:t,type:u,key:p,ref:m,props:d,_owner:o.current}}return Cr.Fragment=n,Cr.jsx=a,Cr.jsxs=a,Cr})()),gu.exports);function qD(e){const[t,n]=h.useState(!1);return h.useEffect((()=>{n(!0)}),[]),v.jsx(h.Suspense,{fallback:e.fallback,children:t?typeof e.children=="function"?e.children():e.children:e.fallback})}var Jm=Object.defineProperty,rs="2.23.0",ho=typeof globalThis<"u"?globalThis:typeof window<"u"?window:pa!==void 0?pa:{};function os(e,t,n){const r=Symbol.for(e),o=`${t} (${n})`;ho[r]?ho[r]===o||(function(i){console.error(i)})(["Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See https://liveblocks.io/docs/errors/dupes ","","Conflicts:",`- ${e} ${ho[r]} (already loaded)`,`- ${e} ${o} (trying to load this now)`].join(`
|
|
2
2
|
`)):ho[r]=o}function ma(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 en(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.comments.map((o=>ma(o)));return{...e,createdAt:t,updatedAt:n,comments:r}}function vn(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 Ri(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function _i(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}var sn={};((e,t)=>{for(var n in t)Jm(e,n,{get:t[n],enumerable:!0})})(sn,{error:()=>ro,errorWithTitle:()=>bd,warn:()=>at,warnWithTitle:()=>Qm});var gd="background:#0e0d12;border-radius:9999px;color:#fff;padding:3px 7px;font-family:sans-serif;font-weight:600;";function vd(e){return typeof window>"u"?console[e]:(t,...n)=>console[e]("%cLiveblocks",gd,t,...n)}var at=vd("warn"),ro=vd("error");function yd(e){return typeof window>"u"?console[e]:(t,n,...r)=>console[e](`%cLiveblocks%c ${t}`,gd,"font-weight:600",n,...r)}var Qm=yd("warn"),bd=yd("error");function Zt(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ga(e){return Zt(e)&&typeof e.startsWith=="string"}function Yt(e){throw new Error(e)}function va(e){return Object.entries(e)}function hi(e){try{return JSON.parse(e)}catch{return}}function Ir(e){return JSON.parse(JSON.stringify(e))}function ya(e){return e.filter((t=>t!=null))}function Hr(e){const t={...e};return Object.keys(e).forEach((n=>{const r=n;t[r]===void 0&&delete t[r]})),t}function eg(e){return new Promise((t=>setTimeout(t,e)))}async function vu(e,t,n){let r;const o=new Promise(((i,a)=>{r=setTimeout((()=>{a(new Error(n))}),t)}));return Promise.race([e,o]).finally((()=>clearTimeout(r)))}function yu(e){let t=null;return()=>(t===null&&(t=e().catch((n=>{throw setTimeout((()=>{t=null}),5e3),n}))),t)}var ir=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?hi(n):void 0;let o;Zt(r)&&(o=r);let i,a="";a||=typeof o?.message=="string"?o.message:"",a||=typeof o?.error=="string"?o.error:"",r===void 0&&(a||=n||""),a||=t.statusText;try{i=new URL(t.url).pathname}catch{}return a+=i!==void 0?` (got status ${t.status} from ${i})`:` (got status ${t.status})`,new wd(a,t,o)}get status(){return this.response.status}},tg=e=>e instanceof ir&&e.status>=400&&e.status<500;async function Fr(e,t,n,r=tg){const o=n.length>0?n[n.length-1]:0;let i=0;for(;;){i++;try{return await e()}catch(u){if(r(u))throw u;if(i>=t)throw new Error(`Failed after ${t} attempts: ${String(u)}`)}const a=n[i-1]??o;at(`Attempt ${i} was unsuccessful. Retrying in ${a} milliseconds.`),await eg(a)}}function Cd(){let e,t;return[new Promise(((n,r)=>{e=n,t=r})),e,t]}function Dd(){const[e,t,n]=Cd();return{promise:e,resolve:t,reject:n}}function ke(){const e=new Set;function t(o){return e.add(o),()=>e.delete(o)}function n(o){const i=t((a=>(i(),o(a))));return i}async function r(o){let i;return new Promise((a=>{i=t((u=>{(o===void 0||o(u))&&a(u)}))})).finally((()=>i?.()))}return{notify:function(o){let i=!1;for(const a of e)a(o),i=!0;return i},subscribe:t,subscribeOnce:n,count:function(){return e.size},waitUntil:r,[Symbol.dispose]:()=>{e.clear()},observable:{subscribe:t,subscribeOnce:n,waitUntil:r}}}var yn=Symbol("kSinks"),Xo=Symbol("kTrigger"),qn=null,Dn=null;function rt(e){if(qn===null){qn=new Set;try{e()}finally{for(const t of qn)t[Xo]();qn=null}}else e()}function is(e){qn||Yt("Expected to be in an active batch"),qn.add(e)}function Ed(e,t){let n=!1;const r={...e};return Object.keys(t).forEach((o=>{const i=o,a=t[i];r[i]!==a&&(a===void 0?delete r[i]:r[i]=a,n=!0)})),n?r:e}var as=class{equals;#e;[yn];constructor(e){this.equals=e??Object.is,this.#e=ke(),this[yn]=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[yn])if(e.hasWatchers)return!0;return!1}[Xo](){this.#e.notify();for(const e of this[yn])is(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[yn])e.markDirty()}addSink(e){this[yn].add(e)}removeSink(e){this[yn].delete(e)}asReadonly(){return this}},jt=class extends as{#e;constructor(e,t){super(t),this.#e=e}[Symbol.dispose](){super[Symbol.dispose](),this.#e="(disposed)"}get(){return Dn?.add(this),this.#e}set(e){rt((()=>{typeof e=="function"&&(e=e(this.#e)),this.equals(this.#e,e)||(this.#e=e,this.markSinksDirty(),is(this))}))}},ng=class extends jt{constructor(e){super(Hr(e))}set(){throw new Error("Don't call .set() directly, use .patch()")}patch(e){super.set((t=>Ed(t,e)))}},rg=Symbol(),Ke=class ba extends as{#e;#t;#n;#r;#i;static from(...t){const n=t.pop();if(typeof n!="function"&&Yt("Invalid .from() call, last argument expected to be a function"),typeof t[t.length-1]=="function"){const r=n,o=t.pop();return new ba(t,o,r)}return new ba(t,n)}constructor(t,n,r){super(r),this.#t=!0,this.#e=rg,this.#r=t,this.#n=new Set,this.#i=n}[Symbol.dispose](){for(const t of this.#n)t.removeSink(this);this.#e="(disposed)",this.#n="(disposed)",this.#r="(disposed)",this.#i="(disposed)"}get isDirty(){return this.#t}#o(){const t=Dn;let n;Dn=new Set;try{n=this.#i(...this.#r.map((r=>r.get())))}finally{const r=this.#n;this.#n=new Set;for(const o of Dn)this.#n.add(o),r.delete(o);for(const o of r)o.removeSink(this);for(const o of this.#n)o.addSink(this);Dn=t}return this.#t=!1,!this.equals(this.#e,n)&&(this.#e=n,!0)}markDirty(){this.#t||(this.#t=!0,this.markSinksDirty())}get(){return this.#t&&this.#o(),Dn?.add(this),this.#e}[Xo](){this.hasWatchers&&this.#o()&&super[Xo]()}},On=class extends as{#e;constructor(e){super(),this.#e=e}[Symbol.dispose](){super[Symbol.dispose](),this.#e="(disposed)"}get(){return Dn?.add(this),this.#e}mutate(e){rt((()=>{const t=!e||e(this.#e);t!==null&&typeof t=="object"&&"then"in t&&Yt("MutableSignal.mutate() does not support async callbacks"),t!==!1&&(this.markSinksDirty(),is(this))}))}};function og(e,t){return t===null||typeof t!="object"||Array.isArray(t)?t:Object.keys(t).sort().reduce(((n,r)=>(n[r]=t[r],n)),{})}function Tn(e){return JSON.stringify(e,og)}function qt(e){try{return JSON.stringify(e)}catch(t){throw console.error(`Could not stringify: ${t.message}`),console.error(e),t}}var ig=class{input;resolve;reject;promise;constructor(e){this.input=e;const{promise:t,resolve:n,reject:r}=Dd();this.promise=t,this.resolve=n,this.reject=r}},Tr=class{#e=[];#t;#n;#r;#i;error=!1;constructor(e,t){this.#t=e,this.#n=t.size??50,this.#r=t.delay}#o(){this.#i!==void 0&&(clearTimeout(this.#i),this.#i=void 0)}#s(){this.#e.length===this.#n?this.#a():this.#e.length===1&&(this.#o(),this.#i=setTimeout((()=>{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 i=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}.`)):i instanceof Error?r.reject(i):r.resolve(i):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=>Tn(r.input)===Tn(e)));if(t)return t.promise;const n=new ig(e);return this.#e.push(n),this.#s(),n.promise}clear(){this.#e=[],this.error=!1,this.#o()}};function wa(e){const t=new On(new Map);function n(o){return Tn(o)}function r(o,i){t.mutate((a=>{a.set(o,i)}))}return{subscribe:t.subscribe,enqueue:async function(o){const i=n(o);if(!t.get().has(i))try{r(i,{isLoading:!0}),r(i,{isLoading:!1,data:await e.get(o)})}catch(a){r(i,{isLoading:!1,error:a})}},getItemState:function(o){const i=n(o);return t.get().get(i)},invalidate:function(o){t.mutate((i=>{if(Array.isArray(o))for(const a of o)i.delete(n(a));else i.clear()}))},batch:e,_cacheKeys:function(){return[...t.get().keys()]}}}var mr=(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?"_":"-")),"");function ss(e){return`${e}_${mr()}`}function Ad(){return ss("th")}function Zo(){return ss("cm")}function xd(){return ss("at")}var vt=class extends Map{#e;constructor(e,t){super(t),this.#e=e}getOrCreate(e,t){if(super.has(e))return super.get(e);{const n=(t??this.#e??Yt("DefaultMap used without a factory function"))(e);return this.set(e,n),n}}},ag=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function bu(e){let t=[];const n=Object.entries(e),r=[],o=[],i=[];return n.forEach((([a,u])=>{if(!ag.test(a))throw new Error("Key must only contain letters, numbers, _");Du(u)?r.push([a,u]):Zt(u)&&(ga(u)?o.push([a,u]):i.push([a,u]))})),t=[...wu(r),...Cu(o)],i.forEach((([a,u])=>{const s=Object.entries(u),c=[],l=[];s.forEach((([d,p])=>{if(sg(d))throw new Error("Key cannot be empty");Du(p)?c.push([Eu(a,d),p]):ga(p)&&l.push([Eu(a,d),p])})),t=[...t,...wu(c),...Cu(l)]})),t.map((({key:a,operator:u,value:s})=>`${a}${u}${Od(s)}`)).join(" ")}var wu=e=>{const t=[];return e.forEach((([n,r])=>{t.push({key:n,operator:":",value:r})})),t},Cu=e=>{const t=[];return e.forEach((([n,r])=>{"startsWith"in r&&typeof r.startsWith=="string"&&t.push({key:n,operator:"^",value:r.startsWith})})),t},Du=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Eu=(e,t)=>t?`${e}[${Od(t)}]`:e,sg=e=>!e||e.toString().trim()==="";function Od(e){const t=JSON.stringify(e);return typeof e!="string"||t.includes("'")?t:`'${t.slice(1,-1).replace(/\\"/g,'"')}'`}function ug(e,t,n){const r=new URL(t,e);return n!==void 0&&(r.search=(n instanceof URLSearchParams?n:(function(o){const i=new URLSearchParams;for(const[a,u]of Object.entries(o))u!=null&&i.set(a,u.toString());return i})(n)).toString()),r.toString()}function we(e,...t){return e.reduce(((n,r,o)=>n+encodeURIComponent(t[o-1]??"")+r))}function cg({baseUrl:e,authManager:t,fetchPolyfill:n}){const r=new lg(e,n),o=new vt((s=>wa(new Tr((async c=>{const l=c.flat(),{urls:d}=await r.post(we`/v2/c/rooms/${s}/attachments/presigned-urls`,await t.getAuthValue({requestedScope:"comments:read",roomId:s}),{attachmentIds:l});return d.map((p=>p??new Error("There was an error while getting this attachment's URL")))}),{delay:50}))));function i(s){return o.getOrCreate(s)}const a=new vt((s=>new Tr((async c=>{const l=c.flat();return await r.post(we`/v2/c/rooms/${s}/inbox-notifications/read`,await t.getAuthValue({requestedScope:"comments:read",roomId:s}),{inboxNotificationIds:l}),l}),{delay:50}))),u=new Tr((async s=>{const c=s.flat();return await(async function(l){await r.post(we`/v2/c/inbox-notifications/read`,await t.getAuthValue({requestedScope:"comments:read"}),{inboxNotificationIds:l})})(c),c}),{delay:50});return{getThreads:async function(s){let c;s.query&&(c=bu(s.query));try{const l=await r.get(we`/v2/c/rooms/${s.roomId}/threads`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{cursor:s.cursor,query:c,limit:50});return{threads:l.data.map(en),inboxNotifications:l.inboxNotifications.map(vn),nextCursor:l.meta.nextCursor,requestedAt:new Date(l.meta.requestedAt),permissionHints:l.meta.permissionHints}}catch(l){if(l instanceof ir&&l.status===404)return{threads:[],inboxNotifications:[],nextCursor:null,requestedAt:new Date(Date.now()-216e5),permissionHints:{}};throw l}},getThreadsSince:async function(s){const c=await r.get(we`/v2/c/rooms/${s.roomId}/threads/delta`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{since:s.since.toISOString()},{signal:s.signal});return{threads:{updated:c.data.map(en),deleted:c.deletedThreads.map(Ri)},inboxNotifications:{updated:c.inboxNotifications.map(vn),deleted:c.deletedInboxNotifications.map(_i)},requestedAt:new Date(c.meta.requestedAt),permissionHints:c.meta.permissionHints}},createThread:async function(s){const c=s.commentId??Zo(),l=s.threadId??Ad();return en(await r.post(we`/v2/c/rooms/${s.roomId}/threads`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{id:l,comment:{id:c,body:s.body,attachmentIds:s.attachmentIds},metadata:s.metadata}))},getThread:async function(s){const c=await r.rawGet(we`/v2/c/rooms/${s.roomId}/thread-with-notification/${s.threadId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}));if(c.ok){const l=await c.json();return{thread:en(l.thread),inboxNotification:l.inboxNotification?vn(l.inboxNotification):void 0}}if(c.status===404)return{thread:void 0,inboxNotification:void 0};throw new Error(`There was an error while getting thread ${s.threadId}.`)},deleteThread:async function(s){await r.delete(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},editThreadMetadata:async function(s){return await r.post(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/metadata`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),s.metadata)},createComment:async function(s){const c=s.commentId??Zo();return ma(await r.post(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/comments`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{id:c,body:s.body,attachmentIds:s.attachmentIds}))},editComment:async function(s){return ma(await r.post(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/comments/${s.commentId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{body:s.body,attachmentIds:s.attachmentIds}))},deleteComment:async function(s){await r.delete(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/comments/${s.commentId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},addReaction:async function(s){return l=await r.post(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/comments/${s.commentId}/reactions`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{emoji:s.emoji}),{...l,createdAt:new Date(l.createdAt)};var l},removeReaction:async function(s){await r.delete(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/comments/${s.commentId}/reactions/${s.emoji}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},markThreadAsResolved:async function(s){await r.post(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/mark-as-resolved`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},markThreadAsUnresolved:async function(s){await r.post(we`/v2/c/rooms/${s.roomId}/threads/${s.threadId}/mark-as-unresolved`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},markRoomInboxNotificationAsRead:async function(s){return a.getOrCreate(s.roomId).get(s.inboxNotificationId)},getNotificationSettings:async function(s){return r.get(we`/v2/c/rooms/${s.roomId}/notification-settings`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),void 0,{signal:s.signal})},updateNotificationSettings:async function(s){return r.post(we`/v2/c/rooms/${s.roomId}/notification-settings`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),s.settings)},createTextMention:async function(s){await r.rawPost(we`/v2/c/rooms/${s.roomId}/text-mentions`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{userId:s.userId,mentionId:s.mentionId})},deleteTextMention:async function(s){await r.rawDelete(we`/v2/c/rooms/${s.roomId}/text-mentions/${s.mentionId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},getTextVersion:async function(s){return r.rawGet(we`/v2/c/rooms/${s.roomId}/y-version/${s.versionId}`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},createTextVersion:async function(s){await r.rawPost(we`/v2/c/rooms/${s.roomId}/version`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}))},reportTextEditor:async function(s){await r.rawPost(we`/v2/c/rooms/${s.roomId}/text-metadata`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{type:s.type,rootKey:s.rootKey})},listTextVersions:async function(s){const c=await r.get(we`/v2/c/rooms/${s.roomId}/versions`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}));return{versions:c.versions.map((({createdAt:l,...d})=>({createdAt:new Date(l),...d}))),requestedAt:new Date(c.meta.requestedAt)}},listTextVersionsSince:async function(s){const c=await r.get(we`/v2/c/rooms/${s.roomId}/versions/delta`,await t.getAuthValue({requestedScope:"comments:read",roomId:s.roomId}),{since:s.since.toISOString()},{signal:s.signal});return{versions:c.versions.map((({createdAt:l,...d})=>({createdAt:new Date(l),...d}))),requestedAt:new Date(c.meta.requestedAt)}},getAttachmentUrl:function(s){return i(s.roomId).batch.get(s.attachmentId)},uploadAttachment:async function(s){const c=s.roomId,l=s.signal,d=s.attachment,p=l?new DOMException(`Upload of attachment ${s.attachment.id} was aborted.`,"AbortError"):void 0;if(l?.aborted)throw p;const m=f=>{if(l?.aborted)throw p;if(f instanceof ir&&f.status===413)throw f;return!1},g=5242880,y=[2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3];if(d.size<=g)return Fr((async()=>r.putBlob(we`/v2/c/rooms/${c}/attachments/${d.id}/upload/${encodeURIComponent(d.name)}`,await t.getAuthValue({requestedScope:"comments:read",roomId:c}),d.file,{fileSize:d.size},{signal:l})),10,y,m);{let f;const b=[],C=await Fr((async()=>r.post(we`/v2/c/rooms/${c}/attachments/${d.id}/multipart/${encodeURIComponent(d.name)}`,await t.getAuthValue({requestedScope:"comments:read",roomId:c}),void 0,{signal:l},{fileSize:d.size})),10,y,m);try{f=C.uploadId;const D=(function(B){const O=[];let S=0;for(;S<B.size;){const k=Math.min(S+g,B.size);O.push({partNumber:O.length+1,part:B.slice(S,k)}),S=k}return O})(d.file);if(l?.aborted)throw p;const E=(function(B,O){const S=[];for(let k=0,T=B.length;k<T;k+=O)S.push(B.slice(k,k+O));return S})(D,5);for(const B of E){const O=[];for(const{part:S,partNumber:k}of B)O.push(Fr((async()=>r.putBlob(we`/v2/c/rooms/${c}/attachments/${d.id}/multipart/${C.uploadId}/${String(k)}`,await t.getAuthValue({requestedScope:"comments:read",roomId:c}),S,void 0,{signal:l})),10,y,m));b.push(...await Promise.all(O))}if(l?.aborted)throw p;const A=b.sort(((B,O)=>B.partNumber-O.partNumber));return r.post(we`/v2/c/rooms/${c}/attachments/${d.id}/multipart/${f}/complete`,await t.getAuthValue({requestedScope:"comments:read",roomId:c}),{parts:A},{signal:l})}catch(D){if(f&&D?.name&&(D.name==="AbortError"||D.name==="TimeoutError"))try{await r.rawDelete(we`/v2/c/rooms/${c}/attachments/${d.id}/multipart/${f}`,await t.getAuthValue({requestedScope:"comments:read",roomId:c}))}catch{}throw D}}},getOrCreateAttachmentUrlsStore:i,streamStorage:async function(s){return await(await r.rawGet(we`/v2/c/rooms/${s.roomId}/storage`,await t.getAuthValue({requestedScope:"room:read",roomId:s.roomId}))).json()},sendMessages:async function(s){return r.rawPost(we`/v2/c/rooms/${s.roomId}/send-message`,await t.getAuthValue({requestedScope:"room:read",roomId:s.roomId}),{nonce:s.nonce,messages:s.messages})},getInboxNotifications:async function(s){const c=await r.get(we`/v2/c/inbox-notifications`,await t.getAuthValue({requestedScope:"comments:read"}),{cursor:s?.cursor,limit:50});return{inboxNotifications:c.inboxNotifications.map(vn),threads:c.threads.map(en),nextCursor:c.meta.nextCursor,requestedAt:new Date(c.meta.requestedAt)}},getInboxNotificationsSince:async function(s){const c=await r.get(we`/v2/c/inbox-notifications/delta`,await t.getAuthValue({requestedScope:"comments:read"}),{since:s.since.toISOString()},{signal:s.signal});return{inboxNotifications:{updated:c.inboxNotifications.map(vn),deleted:c.deletedInboxNotifications.map(_i)},threads:{updated:c.threads.map(en),deleted:c.deletedThreads.map(Ri)},requestedAt:new Date(c.meta.requestedAt)}},getUnreadInboxNotificationsCount:async function(){const{count:s}=await r.get(we`/v2/c/inbox-notifications/count`,await t.getAuthValue({requestedScope:"comments:read"}));return s},markAllInboxNotificationsAsRead:async function(){await r.post(we`/v2/c/inbox-notifications/read`,await t.getAuthValue({requestedScope:"comments:read"}),{inboxNotificationIds:"all"})},markInboxNotificationAsRead:async function(s){await u.get(s)},deleteAllInboxNotifications:async function(){await r.delete(we`/v2/c/inbox-notifications`,await t.getAuthValue({requestedScope:"comments:read"}))},deleteInboxNotification:async function(s){await r.delete(we`/v2/c/inbox-notifications/${s}`,await t.getAuthValue({requestedScope:"comments:read"}))},getUserNotificationSettings:async function(s){return r.get(we`/v2/c/notification-settings`,await t.getAuthValue({requestedScope:"comments:read"}),void 0,{signal:s?.signal})},updateUserNotificationSettings:async function(s){return r.post(we`/v2/c/notification-settings`,await t.getAuthValue({requestedScope:"comments:read"}),s)},getUserThreads_experimental:async function(s){let c;s?.query&&(c=bu(s.query));const l=await r.get(we`/v2/c/threads`,await t.getAuthValue({requestedScope:"comments:read"}),{cursor:s?.cursor,query:c,limit:50});return{threads:l.threads.map(en),inboxNotifications:l.inboxNotifications.map(vn),nextCursor:l.meta.nextCursor,requestedAt:new Date(l.meta.requestedAt),permissionHints:l.meta.permissionHints}},getUserThreadsSince_experimental:async function(s){const c=await r.get(we`/v2/c/threads/delta`,await t.getAuthValue({requestedScope:"comments:read"}),{since:s.since.toISOString()},{signal:s.signal});return{threads:{updated:c.threads.map(en),deleted:c.deletedThreads.map(Ri)},inboxNotifications:{updated:c.inboxNotifications.map(vn),deleted:c.deletedInboxNotifications.map(_i)},requestedAt:new Date(c.meta.requestedAt),permissionHints:c.meta.permissionHints}},executeContextualPrompt:async function(s){const c=await r.post(we`/v2/c/rooms/${s.roomId}/ai/contextual-prompt`,await t.getAuthValue({requestedScope:"room:read",roomId:s.roomId}),{prompt:s.prompt,context:{beforeSelection:s.context.beforeSelection,selection:s.context.selection,afterSelection:s.context.afterSelection},previous:s.previous},{signal:s.signal});if(!c||c.content.length===0)throw new Error("No content returned from server");return c.content[0].text}}}function Bd(e){return e.type==="public"?e.publicApiKey:e.token.raw}var lg=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){e.startsWith("/v2/c/")||Yt("This client can only be used to make /v2/c/* requests");const o=ug(this.#e,e,r);return await this.#t(o,{...n,headers:{"Content-Type":"application/json; charset=utf-8",...n?.headers,Authorization:`Bearer ${Bd(t)}`,"X-LB-Client":rs}})}async#r(e,t,n,r){const o=await this.#n(e,t,n,r);if(!o.ok)throw await ir.fromResponse(o);let i;try{i=await o.json()}catch{i={}}return i}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:qt(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:qt(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 ft(e,t){throw new Error(t)}function me(e,t="Expected value to be non-nullable"){return e}var dg=class{#e;constructor(e){this.#e=e}get current(){return this.#e}allowPatching(e){const t=this;let n=!0;e({...this.#e,patch(r){if(!n)throw new Error("Can no longer patch stale context");t.#e=Object.assign({},t.#e,r);for(const o of Object.entries(r)){const[i,a]=o;i!=="patch"&&(this[i]=a)}}}),n=!1}},fg=1,kd=class{id;#e;#t;#n;#r;#i;#o;events;#s;#a;#l;get#f(){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.#f,this.#c(null),this}stop(){if(this.#e!==1)throw new Error("Cannot stop a state machine that hasn't started yet");this.#d(null),this.#e=2,this.#r=null}constructor(e){this.id=fg++,this.#e=0,this.#r=null,this.#n=new Set,this.#a=new Map,this.#s=[],this.#l=new Set,this.#i=new Map,this.#t=new dg(e),this.#o={didReceiveEvent:ke(),willTransition:ke(),didIgnoreEvent:ke(),willExitState:ke(),didEnterState:ke()},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 i=new AbortController,a=i.signal,u=o?setTimeout((()=>{const c=new Error("Timed out");this.#u({type:"ASYNC_ERROR",reason:c},r)}),o):void 0;let s=!1;return t(this.#t.current,a).then((c=>{a.aborted||(s=!0,this.#u({type:"ASYNC_OK",data:c},n))}),(c=>{a.aborted||(s=!0,this.#u({type:"ASYNC_ERROR",reason:c},r))})),()=>{clearTimeout(u),s||i.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.#i.get(n);r===void 0&&(r=new Map,this.#i.set(n,r));for(const[o,i]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=i;if(this.#l.add(o),a!==void 0){const u=typeof a=="function"?a:()=>a;r.set(o,u)}}}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.#i.get(this.currentState)?.get(e)}#d(e){this.#o.willExitState.notify(this.currentState),this.#t.allowPatching((t=>{e=e??this.#s.length;for(let n=0;n<e;n++)this.#s.pop()?.(t)}))}#c(e){const t=(function(n,r){const o=n.split(".");if(r<1||r>o.length+1)throw new Error("Invalid number of levels");const i=[];r>o.length&&i.push("*");for(let a=o.length-r+1;a<o.length;a++){const u=o.slice(0,a);u.length>0&&i.push(u.join(".")+".*")}return i.push(n),i})(this.currentState,e??this.currentState.split(".").length+1);this.#t.allowPatching((n=>{for(const r of t){const o=this.#a.get(r),i=o?.(n);typeof i=="function"?this.#s.push(i):this.#s.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,r=(typeof t=="function"?t:()=>t)(e,this.#t.current);let o,i;if(r===null)return void this.#o.didIgnoreEvent.notify(e);if(typeof r=="string"?o=r:(o=r.target,i=Array.isArray(r.effect)?r.effect:[r.effect]),!this.#n.has(o))throw new Error(`Invalid next state name: ${JSON.stringify(o)}`);this.#o.willTransition.notify({from:n,to:o});const[a,u]=(function(s,c){if(s===c)return[0,0];const l=s.split("."),d=c.split("."),p=Math.min(l.length,d.length);let m=0;for(;m<p&&l[m]===d[m];m++);return[l.length-m,d.length-m]})(this.currentState,o);if(a>0&&this.#d(a),this.#r=o,i!==void 0){const s=i;this.#t.allowPatching((c=>{for(const l of s)typeof l=="function"?l(c,e):c.patch(l)}))}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 Au(e){return e===4999||e>=4e3&&e<4100}function xu(e){return e===1013||e>=4200&&e<4300}function Sd(e){switch(e.currentState){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 ft(0,"Unknown state")}}var Id=[250,500,1e3,2e3,4e3,8e3,1e4],po=Id[0]-1,hg=[2e3,3e4,6e4,3e5],En=class extends Error{constructor(e){super(e)}};function Fd(e,t){return t.find((n=>n>e))??t[t.length-1]}function Mn(e){e.patch({backoffDelay:Fd(e.backoffDelay,Id)})}function Ou(e){e.patch({backoffDelay:Fd(e.backoffDelay,hg)})}function Bu(e){e.patch({successCount:0})}function $n(e,t){const n=e===2?ro:e===1?at:()=>{};return()=>{n(t)}}function ku(e){const t="Connection to Liveblocks websocket server";return n=>{e instanceof Error?at(`${t} could not be established. ${String(e)}`):at(Td(e)?`${t} closed prematurely (code: ${e.code}). Retrying in ${n.backoffDelay}ms.`:`${t} could not be established.`)}}function Ni(e){const t=[`code: ${e.code}`];return e.reason&&t.push(`reason: ${e.reason}`),n=>{at(`Connection to Liveblocks websocket server closed (${t.join(", ")}). Retrying in ${n.backoffDelay}ms.`)}}var pg=$n(1,"Connection to WebSocket closed permanently. Won't retry.");function Td(e){return!(e instanceof Error)&&e.type==="close"}var mo=e=>t=>t.patch(e);function mg(e,t){const n=(function(){const b=ke();let C=null;return{...b,notify:function(D){return C!==null?(C.push(D),!1):b.notify(D)},pause:function(){C=[]},unpause:function(){if(C!==null){for(const D of C)b.notify(D);C=null}},[Symbol.dispose]:()=>{b[Symbol.dispose](),C!==null&&(C.length=0)}}})();n.pause();const r=ke();function o(b,C){return()=>{r.notify({message:b,code:C})}}const i=new kd({successCount:0,authValue:null,socket:null,backoffDelay:po}).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");i.addTransitions("*",{RECONNECT:{target:"@auth.backoff",effect:[Mn,Bu]},DISCONNECT:"@idle.initial"}),i.onEnter("@idle.*",Bu).addTransitions("@idle.*",{CONNECT:(b,C)=>C.authValue!==null?"@connecting.busy":"@auth.busy"}),i.addTransitions("@auth.backoff",{NAVIGATOR_ONLINE:{target:"@auth.busy",effect:mo({backoffDelay:po})}}).addTimedTransition("@auth.backoff",(b=>b.backoffDelay),"@auth.busy").onEnterAsync("@auth.busy",(()=>vu(e.authenticate(),1e4,"Timed out during auth")),(b=>({target:"@connecting.busy",effect:mo({authValue:b.data})})),(b=>b.reason instanceof En?{target:"@idle.failed",effect:[$n(2,b.reason.message),o(b.reason.message,-1)]}:{target:"@auth.backoff",effect:[Mn,$n(2,`Authentication failed: ${b.reason instanceof Error?b.reason.message:String(b.reason)}`)]}));const a=b=>i.send({type:"EXPLICIT_SOCKET_ERROR",event:b}),u=b=>i.send({type:"EXPLICIT_SOCKET_CLOSE",event:b}),s=b=>b.data==="pong"?i.send({type:"PONG"}):n.notify(b);function c(b){b&&(b.removeEventListener("error",a),b.removeEventListener("close",u),b.removeEventListener("message",s),b.close())}i.addTransitions("@connecting.backoff",{NAVIGATOR_ONLINE:{target:"@connecting.busy",effect:mo({backoffDelay:po})}}).addTimedTransition("@connecting.backoff",(b=>b.backoffDelay),"@connecting.busy").onEnterAsync("@connecting.busy",(async(b,C)=>{let D=null,E=null;return vu(new Promise(((A,B)=>{if(b.authValue===null)throw new Error("No auth authValue");const O=e.createSocket(b.authValue);function S(R){D=R,O.removeEventListener("message",s),B(R)}E=O;const[k,T]=Cd();function F(R){hi(R.data)?.type===104&&T()}t.waitForActorId||T(),O.addEventListener("message",s),t.waitForActorId&&O.addEventListener("message",F),O.addEventListener("error",S),O.addEventListener("close",S),O.addEventListener("open",(()=>{O.addEventListener("error",a),O.addEventListener("close",u);const R=()=>{O.removeEventListener("error",S),O.removeEventListener("close",S),O.removeEventListener("message",F)};k.then((()=>{A([O,R])}))}))})),1e4,"Timed out during websocket connection").then((([A,B])=>{if(B(),C.aborted)throw new Error("Aborted");if(D)throw D;return A})).catch((A=>{throw c(E),A}))}),(b=>({target:"@ok.connected",effect:mo({socket:b.data,backoffDelay:po})})),(b=>{const C=b.reason;if(C instanceof En)return{target:"@idle.failed",effect:[$n(2,C.message),o(C.message,-1)]};if(Td(C)){if(C.code===4109)return"@auth.busy";if(xu(C.code))return{target:"@connecting.backoff",effect:[Ou,ku(C)]};if(Au(C.code))return{target:"@idle.failed",effect:[$n(2,C.reason),o(C.reason,C.code)]}}return{target:"@auth.backoff",effect:[Mn,ku(C)]}}));const l={target:"@ok.awaiting-pong",effect:b=>{b.socket?.send("ping")}},d=()=>(typeof document<"u"?document:void 0)?.visibilityState==="hidden"&&e.canZombie()?"@idle.zombie":l;if(i.addTimedTransition("@ok.connected",3e4,d).addTransitions("@ok.connected",{NAVIGATOR_OFFLINE:d,WINDOW_GOT_FOCUS:l}),i.addTransitions("@idle.zombie",{WINDOW_GOT_FOCUS:"@connecting.backoff"}),i.onEnter("@ok.*",(b=>{b.patch({successCount:b.successCount+1});const C=setTimeout(n.unpause,0);return D=>{c(D.socket),D.patch({socket:null}),clearTimeout(C),n.pause()}})).addTransitions("@ok.awaiting-pong",{PONG:"@ok.connected"}).addTimedTransition("@ok.awaiting-pong",2e3,{target:"@connecting.busy",effect:$n(1,"Received no pong from server, assume implicit connection loss.")}).addTransitions("@ok.*",{EXPLICIT_SOCKET_ERROR:(b,C)=>C.socket?.readyState===1?null:{target:"@connecting.backoff",effect:Mn},EXPLICIT_SOCKET_CLOSE:b=>{return Au(b.event.code)?{target:"@idle.failed",effect:[pg,o(b.event.reason,b.event.code)]}:(C=b.event.code)>=4100&&C<4200?b.event.code===4109?"@auth.busy":{target:"@auth.backoff",effect:[Mn,Ni(b.event)]}:xu(b.event.code)?{target:"@connecting.backoff",effect:[Ou,Ni(b.event)]}:{target:"@connecting.backoff",effect:[Mn,Ni(b.event)]};var C}}),typeof document<"u"){const b=typeof document<"u"?document:void 0,C=typeof window<"u"?window:void 0,D=C??b;i.onEnter("*",(E=>{function A(){i.send({type:"NAVIGATOR_OFFLINE"})}function B(){i.send({type:"NAVIGATOR_ONLINE"})}function O(){b?.visibilityState==="visible"&&i.send({type:"WINDOW_GOT_FOCUS"})}return C?.addEventListener("online",B),C?.addEventListener("offline",A),D?.addEventListener("visibilitychange",O),()=>{D?.removeEventListener("visibilitychange",O),C?.removeEventListener("online",B),C?.removeEventListener("offline",A),c(E.socket)}}))}const p=[],{statusDidChange:m,didConnect:g,didDisconnect:y,unsubscribe:f}=(function(b){const C=ke(),D=ke(),E=ke();let A=null;const B=b.events.didEnterState.subscribe((()=>{const O=Sd(b);O!==A&&C.notify(O),A==="connected"&&O!=="connected"?E.notify():A!=="connected"&&O==="connected"&&D.notify(),A=O}));return{statusDidChange:C.observable,didConnect:D.observable,didDisconnect:E.observable,unsubscribe:B}})(i);return p.push(f),t.enableDebugLogging&&p.push((function(b){const C=new Date().getTime();function D(...A){at(`${((new Date().getTime()-C)/1e3).toFixed(2)} [FSM #${b.id}]`,...A)}const E=[b.events.didReceiveEvent.subscribe((A=>D(`Event ${A.type}`))),b.events.willTransition.subscribe((({from:A,to:B})=>D("Transitioning",A,"→",B))),b.events.didIgnoreEvent.subscribe((A=>D("Ignored event",A.type,A,"(current state won't handle it)")))];return()=>{for(const A of E)A()}})(i)),i.start(),{machine:i,cleanups:p,events:{statusDidChange:m,didConnect:g,didDisconnect:y,onMessage:n.observable,onConnectionError:r.observable}}}var gg=class{#e;#t;events;constructor(e,t=!1,n=!0){const{machine:r,events:o,cleanups:i}=mg(e,{waitForActorId:n,enableDebugLogging:t});this.#e=r,this.events=o,this.#t=i}getStatus(){try{return Sd(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(){let e;for(this.#e.stop();e=this.#t.pop();)e()}send(e){const t=this.#e.context?.socket;t===null?at("Cannot send: not connected yet",e):t.readyState!==1?at("Cannot send: WebSocket no longer open",e):t.send(e)}_privateSendMachineEvent(e){this.#e.send(e)}},Ca=(e=>(e.Read="room:read",e.Write="room:write",e.PresenceWrite="room:presence:write",e.CommentsWrite="comments:write",e.CommentsRead="comments:read",e))(Ca||{});function Da(e){return e.includes("room:write")}function jd(e){return e.includes("comments:write")||e.includes("room:write")}function Su(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=hi((function(o){try{const i=o.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(i).split("").map((function(a){return"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)})).join(""))}catch{return atob(o)}})(t[1]));if(!n||!Zt(r=n)||r.k!=="acc"&&r.k!=="id"&&r.k!=="sec-legacy")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");var r;return{raw:e,parsed:n}}function vg(e,t){const n=(function(c){const{publicApiKey:l,authEndpoint:d}=c;if(d!==void 0&&l!==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 l=="string"){if(l.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(!l.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:l}}if(typeof d=="string")return{type:"private",url:d};if(typeof d=="function")return{type:"custom",callback:d};throw d!==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")})(e),r=new Set,o=[],i=[],a=new Map;function u(c,l){return c==="comments:read"?l.includes("comments:read")||l.includes("comments:write")||l.includes("room:read")||l.includes("room:write"):c==="room:read"&&(l.includes("room:read")||l.includes("room:write"))}async function s(c){const l=e.polyfills?.fetch??(typeof window>"u"?void 0:window.fetch);if(n.type==="private"){if(l===void 0)throw new En("To use Liveblocks client in a non-DOM environment with a url as auth endpoint, you need to provide a fetch polyfill.");const d=Su((await(async function(p,m,g){const y=await p(m,{method:"POST",headers:{"Content-Type":"application/json"},body:qt(g)});if(!y.ok){const C=`${(await y.text()).trim()||"reason not provided in auth response"} (${y.status} returned by POST ${m})`;throw y.status===401||y.status===403?new En(`Unauthorized: ${C}`):new Error(`Failed to authenticate: ${C}`)}let f;try{f=await y.json()}catch(C){throw new Error(`Expected a JSON response when doing a POST request on "${m}". ${String(C)}`)}if(!Zt(f)||typeof f.token!="string")throw new Error(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${m}", but got ${qt(f)}`);const{token:b}=f;return{token:b}})(l,n.url,{room:c.roomId})).token);if(r.has(d.raw))throw new En("The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported.");return t?.(d.parsed),d}if(n.type==="custom"){const d=await n.callback(c.roomId);if(d&&typeof d=="object"){if(typeof d.token=="string"){const p=Su(d.token);return t?.(p.parsed),p}if(typeof d.error=="string"){const p=`Authentication failed: ${"reason"in d&&typeof d.reason=="string"?d.reason:"Forbidden"}`;throw d.error==="forbidden"?new En(p):new Error(p)}}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.")}return{reset:function(){r.clear(),o.length=0,i.length=0,a.clear()},getAuthValue:async function(c){if(n.type==="public")return{type:"public",publicApiKey:n.publicApiKey};const l=(function(p){const m=Math.ceil(Date.now()/1e3);for(let g=o.length-1;g>=0;g--){const y=o[g];if(i[g]<=m)o.splice(g,1),i.splice(g,1);else{if(y.parsed.k==="id")return y;if(y.parsed.k==="acc"){if(!p.roomId&&Object.entries(y.parsed.perms).length===0)return y;for(const[f,b]of Object.entries(y.parsed.perms))if(p.roomId){if(f.includes("*")&&p.roomId.startsWith(f.replace("*",""))||p.roomId===f&&u(p.requestedScope,b))return y}else if(f.includes("*")&&u(p.requestedScope,b))return y}}}})(c);if(l!==void 0)return{type:"secret",token:l};let d;c.roomId?(d=a.get(c.roomId),d===void 0&&(d=s(c),a.set(c.roomId,d))):(d=a.get("liveblocks-user-token"),d===void 0&&(d=s(c),a.set("liveblocks-user-token",d)));try{const p=await d,m=30,g=Math.floor(Date.now()/1e3)+(p.parsed.exp-p.parsed.iat)-m;return r.add(p.raw),p.parsed.k!=="sec-legacy"&&(o.push(p),i.push(g)),{type:"secret",token:p}}finally{c.roomId?a.delete(c.roomId):a.delete("liveblocks-user-token")}}}}var Oe=Symbol();ke().observable;var jr=Symbol("user-notification-settings-plain");function Yo(e){const t=["email","slack","teams","webPush"],n={[jr]:{value:e,enumerable:!1}};for(const r of t)n[r]={enumerable:!0,get(){const o=this[jr][r];return o===void 0?(ro(`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(function(r,o){return o!==void 0?Object.create(r,o):Object.create(r)})(null,n)}function yg(e,t){const n=Yo({...e[jr]});for(const o of(r=t,Object.keys(r))){const i=t[o];if(i!==void 0){const a=Object.fromEntries(va(i).filter((([,u])=>u!==void 0)));n[jr][o]={...n[jr][o],...a}}}var r;return n}var un=32,An=126,us=cs(0),_o=cs(1),bg=us+cs(-1);function cs(e){const t=un+(e<0?95+e:e);if(t<un||t>An)throw new Error(`Invalid n value: ${e}`);return String.fromCharCode(t)}function Vt(e,t){return e!==void 0&&t!==void 0?(function(n,r){if(n<r)return Ea(n,r);if(n>r)return Ea(r,n);throw new Error("Cannot compute value between two equal positions")})(e,t):e!==void 0?(function(n){for(let r=0;r<=n.length-1;r++){const o=n.charCodeAt(r);if(!(o>=An))return n.substring(0,r)+String.fromCharCode(o+1)}return n+_o})(e):t!==void 0?(function(n){const r=n.length-1;for(let o=0;o<=r;o++){const i=n.charCodeAt(o);if(!(i<=un))return o===r?i===33?n.substring(0,o)+bg:n.substring(0,o)+String.fromCharCode(i-1):n.substring(0,o+1)}return _o})(t):_o}function Ea(e,t){let n=0;const r=e.length,o=t.length;for(;;){const i=n<r?e.charCodeAt(n):un,a=n<o?t.charCodeAt(n):An;if(i!==a){if(a-i==1){const u=n+1;let s=e.substring(0,u);return s.length<u&&(s+=us.repeat(u-s.length)),s+Ea(e.substring(u),"")}return wg(e,n)+String.fromCharCode(a+i>>1)}n++}}function wg(e,t){return t<e.length?e.substring(0,t):e+us.repeat(t-e.length)}function Wr(e){return(function(t){if(t==="")return!1;const n=t.length-1,r=t.charCodeAt(n);if(r<33||r>An)return!1;for(let o=0;o<n;o++){const i=t.charCodeAt(o);if(i<un||i>An)return!1}return!0})(e)?e:(function(t){const n=[];for(let r=0;r<t.length;r++){const o=t.charCodeAt(r);n.push(o<un?un:o>An?An:o)}for(;n.length>0&&n[n.length-1]===un;)n.length--;return n.length>0?String.fromCharCode(...n):_o})(e)}function Cg(e,t){const{getCurrentConnectionId:n,onDispatch:r,isStorageWritable:o=()=>!0}=t;let i=0,a=0;const u=new Map;return{roomId:e,nodes:u,getNode:s=>u.get(s),addNode:(s,c)=>{u.set(s,c)},deleteNode:s=>{u.delete(s)},generateId:()=>`${n()}:${i++}`,generateOpId:()=>`${n()}:${a++}`,dispatch(s,c,l){r?.(s,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 Iu(e,t,n=Wr(t)){return Object.freeze({type:"HasParent",node:e,key:t,pos:n})}var Fu=Object.freeze({type:"NoParent"}),pi=class{#e;#t;#n=Fu;_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 ft(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 ft(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 ft(this.parent,"Unknown state")}}_apply(e,t){return e.type===5&&this.parent.type==="HasParent"?this.parent.node._detachChild(this):{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");return void(this.#n=Iu(e,t));case"Orphaned":case"NoParent":return void(this.#n=Iu(e,t));default:return ft(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=(function(e,t=Wr(e)){return Object.freeze({type:"Orphaned",oldKey:e,oldPos:t})})(this.parent.key,this.parent.pos);break;case"NoParent":this.#n=Fu;break;case"Orphaned":break;default:ft(this.parent,"Unknown state")}this.#e=void 0}#r;#i;#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.#i===e||(this.#i=e,this.#o=this._toTreeNode(e)),this.#o}toImmutable(){return this.#r===void 0&&(this.#r=this._toImmutable()),this.#r}};function Dg(e){return e.type===0&&!(function(t){return t.parentId!==void 0&&t.parentKey!==void 0})(e)}var pn=class Rd extends pi{#e;constructor(t){super(),this.#e=t}get data(){return this.#e}static _deserialize([t,n],r,o){const i=new Rd(n.data);return i._attach(t,o),i}_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:me(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??mr(),key:t,payload:this.#e}}_toImmutable(){return this.#e}clone(){return Ir(this.data)}};function Eg(e,t){const n=e._parentPos,r=t._parentPos;return n===r?0:n<r?-1:1}var gr=class Aa extends pi{#e;#t;#n;constructor(t){let n;super(),this.#e=[],this.#t=new WeakSet,this.#n=new Map;for(const r of t){const o=Vt(n),i=Zn(r);i._setParentLink(this,o),this.#e.push(i),n=o}}static _deserialize([t],n,r){const o=new Aa([]);o._attach(t,r);const i=n.get(t);if(i===void 0)return o;for(const[a,u]of i){const s=Pd([a,u],n,r);s._setParentLink(o,u.parentKey),o._insertAndSort(s)}return o}_toOps(t,n,r){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const o=[],i={id:this._id,opId:r?.generateOpId(),type:2,parentId:t,parentKey:n};o.push(i);for(const a of this.#e){const u=a._getParentKeyOrThrow(),s=vo(a._toOps(this._id,u,r),void 0),c=s[0].opId;c!==void 0&&this.#n.set(u,c),o.push(...s)}return o}_insertAndSort(t){this.#e.push(t),this._sortItems()}_sortItems(){this.#e.sort(Eg),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=xr(t);o._attach(n,this._pool),o._setParentLink(this,r);const i=t.deletedId,a=this._indexOfPosition(r);if(a!==-1){const u=this.#e[a];if(u._id===i)return u._detach(),this.#e[a]=o,{modified:Ie(this,[Ln(a,o)]),reverse:[]};{this.#t.add(u),this.#e[a]=o;const s=[Ln(a,o)],c=this.#o(t.deletedId);return c&&s.push(c),{modified:Ie(this,s),reverse:[]}}}{const u=[],s=this.#o(t.deletedId);return s&&u.push(s),this._insertAndSort(o),u.push(Ot(this._indexOfPosition(r),o)),{reverse:[],modified:Ie(this,u)}}}#i(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:Ie(this,n),reverse:[]};this.#n.delete(t.parentKey)}const i=this._indexOfPosition(t.parentKey),a=this.#e.find((u=>u._id===t.id));if(a!==void 0){if(a._parentKey===t.parentKey)return{modified:n.length>0&&Ie(this,n),reverse:[]};if(i!==-1){this.#t.add(this.#e[i]);const[c]=this.#e.splice(i,1);n.push(go(i,c))}const u=this.#e.indexOf(a);a._setParentLink(this,t.parentKey),this._sortItems();const s=this.#e.indexOf(a);return s!==u&&n.push(bn(u,s,a)),{modified:n.length>0&&Ie(this,n),reverse:[]}}{const u=this._pool.getNode(t.id);if(u&&this.#t.has(u)){u._setParentLink(this,t.parentKey),this.#t.delete(u),this._insertAndSort(u);const s=this.#e.indexOf(u);return{modified:Ie(this,[i===-1?Ot(s,u):Ln(s,u),...n]),reverse:[]}}{i!==-1&&this.#e.splice(i,1);const{newItem:s,newIndex:c}=this.#c(t,t.parentKey);return{modified:Ie(this,[i===-1?Ot(c,s):Ln(c,s),...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]}#s(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=Wr(t.parentKey),r=this._indexOfPosition(n);r!==-1&&this.#u(r,n);const{newItem:o,newIndex:i}=this.#c(t,n);return{modified:Ie(this,[Ot(i,o)]),reverse:[]}}#a(t){const n=this.#e.find((i=>i._id===t.id)),r=Wr(t.parentKey),o=this._indexOfPosition(r);if(n){if(n._parentKey===r)return{modified:!1};{const i=this.#e.indexOf(n);o!==-1&&this.#u(o,r),n._setParentLink(this,r),this._sortItems();const a=this._indexOfPosition(r);return a===i?{modified:!1}:{modified:Ie(this,[bn(i,a,n)]),reverse:[]}}}{const i=me(this._pool).getNode(t.id);if(i&&this.#t.has(i))return i._setParentLink(this,r),this.#t.delete(i),this._insertAndSort(i),{modified:Ie(this,[Ot(this._indexOfPosition(r),i)]),reverse:[]};{o!==-1&&this.#u(o,r);const{newItem:a,newIndex:u}=this.#c(t,r);return{modified:Ie(this,[Ot(u,a)]),reverse:[]}}}}#l(t){const{id:n,parentKey:r}=t,o=xr(t);if(this._pool?.getNode(n)!==void 0)return{modified:!1};o._attach(n,me(this._pool)),o._setParentLink(this,r);const i=this._indexOfPosition(r);let a=r;if(i!==-1){const u=this.#e[i]?._parentPos,s=this.#e[i+1]?._parentPos;a=Vt(u,s),o._setParentLink(this,a)}return this._insertAndSort(o),{modified:Ie(this,[Ot(this._indexOfPosition(a),o)]),reverse:[{type:5,id:n}]}}#f(t){const{id:n,parentKey:r}=t,o=xr(t);if(this._pool?.getNode(n)!==void 0)return{modified:!1};this.#n.set(r,me(t.opId));const i=this._indexOfPosition(r);o._attach(n,me(this._pool)),o._setParentLink(this,r);const a=r;if(i!==-1){const u=this.#e[i];u._detach(),this.#e[i]=o;const s=vo(u._toOps(me(this._id),r,this._pool),t.id),c=[Ln(i,o)],l=this.#o(t.deletedId);return l&&c.push(l),{modified:Ie(this,c),reverse:s}}return this._insertAndSort(o),this.#o(t.deletedId),{reverse:[{type:5,id:n}],modified:Ie(this,[Ot(this._indexOfPosition(a),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 r=t.intent==="set"?n===1?this.#r(t):n===2?this.#i(t):this.#f(t):n===1?this.#s(t):n===2?this.#a(t):this.#l(t),r.modified!==!1&&this.invalidate(),r}_detachChild(t){if(t){const n=me(t._parentKey),r=t._toOps(me(this._id),n,this._pool),o=this.#e.indexOf(t);if(o===-1)return{modified:!1};const[i]=this.#e.splice(o,1);return this.invalidate(),t._detach(),{modified:Ie(this,[go(o,i)]),reverse:r}}return{modified:!1}}#h(t,n){if(this.#t.has(n))return this.#t.delete(n),n._setParentLink(this,t),this._insertAndSort(n),{modified:Ie(this,[Ot(this.#e.indexOf(n),n)]),reverse:[]};if(t===n._parentKey)return{modified:!1};const r=this._indexOfPosition(t);if(r===-1){const o=this.#e.indexOf(n);n._setParentLink(this,t),this._sortItems();const i=this.#e.indexOf(n);return i===o?{modified:!1}:{modified:Ie(this,[bn(o,i,n)]),reverse:[]}}{this.#e[r]._setParentLink(this,Vt(t,this.#e[r+1]?._parentPos));const o=this.#e.indexOf(n);n._setParentLink(this,t),this._sortItems();const i=this.#e.indexOf(n);return i===o?{modified:!1}:{modified:Ie(this,[bn(o,i,n)]),reverse:[]}}}#p(t,n){const r=me(n._parentKey);if(this.#t.has(n)){const o=this._indexOfPosition(t);return this.#t.delete(n),o!==-1&&this.#e[o]._setParentLink(this,Vt(t,this.#e[o+1]?._parentPos)),n._setParentLink(this,t),this._insertAndSort(n),{modified:!1}}{if(t===r)return{modified:!1};const o=this.#e.indexOf(n),i=this._indexOfPosition(t);i!==-1&&this.#e[i]._setParentLink(this,Vt(t,this.#e[i+1]?._parentPos)),n._setParentLink(this,t),this._sortItems();const a=this.#e.indexOf(n);return o===a?{modified:!1}:{modified:Ie(this,[bn(o,a,n)]),reverse:[]}}}#d(t,n){const r=me(n._parentKey),o=this.#e.indexOf(n),i=this._indexOfPosition(t);i!==-1&&this.#e[i]._setParentLink(this,Vt(t,this.#e[i+1]?._parentPos)),n._setParentLink(this,t),this._sortItems();const a=this.#e.indexOf(n);return o===a?{modified:!1}:{modified:Ie(this,[bn(o,a,n)]),reverse:[{type:1,id:me(n._id),parentKey:r}]}}_setChildKey(t,n,r){return r===1?this.#h(t,n):r===2?this.#p(t,n):this.#d(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:me(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=Vt(this.#e[n-1]?this.#e[n-1]._parentPos:void 0,this.#e[n]?this.#e[n]._parentPos:void 0),o=Zn(t);if(o._setParentLink(this,r),this._insertAndSort(o),this._pool&&this._id){const i=this._pool.generateId();o._attach(i,this._pool),this._pool.dispatch(o._toOps(this._id,r,this._pool),[{type:5,id:i}],new Map([[this._id,Ie(this,[Ot(n,o)])]]))}}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 i=Vt(r,o),a=this.#e[t],u=a._getParentKeyOrThrow();if(a._setParentLink(this,i),this._sortItems(),this._pool&&this._id){const s=new Map([[this._id,Ie(this,[bn(t,n,a)])]]);this._pool.dispatch([{type:1,id:me(a._id),opId:this._pool.generateOpId(),parentKey:i}],[{type:1,id:me(a._id),parentKey:u}],s)}}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 i=new Map;i.set(me(this._id),Ie(this,[go(t,r)])),this._pool.dispatch([{id:o,opId:this._pool.generateOpId(),type:5}],n._toOps(me(this._id),n._getParentKeyOrThrow()),i)}}}clear(){if(this._pool?.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const i of this.#e){i._detach();const a=i._id;a&&(t.push({type:5,id:a,opId:this._pool.generateOpId()}),n.push(...i._toOps(me(this._id),i._getParentKeyOrThrow())),r.push(go(0,i)))}this.#e=[],this.invalidate();const o=new Map;o.set(me(this._id),Ie(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(),i=r._id;r._detach();const a=Zn(n);if(a._setParentLink(this,o),this.#e[t]=a,this.invalidate(),this._pool&&this._id){const u=this._pool.generateId();a._attach(u,this._pool);const s=new Map;s.set(this._id,Ie(this,[Ln(t,a)]));const c=vo(a._toOps(this._id,o,this._pool),i);this.#n.set(o,me(c[0].opId));const l=vo(r._toOps(this._id,o,void 0),u);this._pool.dispatch(c,l,s)}}toArray(){return this.#e.map((t=>Bn(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 Bn(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(Bn(n),r)))}some(t){return this.toArray().some(t)}[Symbol.iterator](){return new Ag(this.#e)}#c(t,n){const r=xr(t);return r._attach(t.id,me(this._pool)),r._setParentLink(this,n),this._insertAndSort(r),{newItem:r,newIndex:this._indexOfPosition(n)}}#u(t,n){const r=Vt(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??mr(),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 Aa(this.#e.map((t=>t.clone())))}},Ag=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:Bn(e.value)}}};function Ie(e,t){return{node:e,type:"LiveList",updates:t}}function Ln(e,t){return{index:e,type:"set",item:t instanceof pn?t.data:t}}function go(e,t){return{type:"delete",index:e,deletedItem:t instanceof pn?t.data:t}}function Ot(e,t){return{index:e,type:"insert",item:t instanceof pn?t.data:t}}function bn(e,t,n){return{type:"move",index:t,item:n instanceof pn?n.data:n,previousIndex:e}}function vo(e,t){return e.map(((n,r)=>r===0?{...n,intent:"set",deletedId:t}:n))}var vr=class xa extends pi{#e;#t;constructor(t){if(super(),this.#t=new Map,t){const n=[];for(const[r,o]of t){const i=Zn(o);i._setParentLink(this,r),n.push([r,i])}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=[],i={id:this._id,opId:r?.generateOpId(),type:7,parentId:t,parentKey:n};o.push(i);for(const[a,u]of this.#e)o.push(...u._toOps(this._id,a,r));return o}static _deserialize([t,n],r,o){const i=new xa;i._attach(t,o);const a=r.get(t);if(a===void 0)return i;for(const[u,s]of a){const c=Pd([u,s],r,o);c._setParentLink(i,s.parentKey),i.#e.set(s.parentKey,c),i.invalidate()}return i}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)Ue(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:i}=t,a=o,u=xr(t);if(this._pool.getNode(r)!==void 0)return{modified:!1};if(n===2){const l=this.#t.get(a);if(l===i)return this.#t.delete(a),{modified:!1};if(l!==void 0)return{modified:!1}}else n===1&&this.#t.delete(a);const s=this.#e.get(a);let c;if(s){const l=me(this._id);c=s._toOps(l,a),s._detach()}else c=[{type:5,id:r}];return u._setParentLink(this,a),u._attach(r,this._pool),this.#e.set(a,u),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=me(this._id),r=me(t._parentKey),o=t._toOps(n,r,this._pool);for(const[i,a]of this.#e)a===t&&(this.#e.delete(i),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:me(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 Bn(n)}set(t,n){this._pool?.assertStorageIsWritable();const r=this.#e.get(t);r&&r._detach();const o=Zn(n);if(o._setParentLink(this,t),this.#e.set(t,o),this.invalidate(),this._pool&&this._id){const i=this._pool.generateId();o._attach(i,this._pool);const a=new Map;a.set(this._id,{node:this,type:"LiveMap",updates:{[t]:{type:"update"}}});const u=o._toOps(this._id,t,this._pool);this.#t.set(t,me(u[0].opId)),this._pool.dispatch(o._toOps(this._id,t,this._pool),r?r._toOps(this._id,t):[{type:5,id:i}],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=me(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();return n.done?{done:!0,value:void 0}:{value:[n.value[0],Bn(n.value[1])]}}}}[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:Bn(n.value)}}}}forEach(t){for(const n of this)t(n[1],n[0],this)}_toTreeNode(t){return{type:"LiveMap",id:this._id??mr(),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 t}clone(){return new xa(Array.from(this.#e).map((([t,n])=>[t,n.clone()])))}},Rn=class Ar extends pi{#e;#t;static#n(t){const n=new Map;let r=null;for(const[o,i]of t)if(Dg(i))r=[o,i];else{const a=[o,i],u=n.get(i.parentId);u!==void 0?u.push(a):n.set(i.parentId,[a])}if(r===null)throw new Error("Root can't be null");return[r,n]}static _fromItems(t,n){const[r,o]=Ar.#n(t);return Ar._deserialize(r,o,n)}constructor(t={}){super(),this.#t=new Map;const n=Hr(t);for(const r of Object.keys(n)){const o=n[r];Ue(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(),i=[],a={type:4,id:this._id,opId:o,parentId:t,parentKey:n,data:{}};i.push(a);for(const[u,s]of this.#e)Ue(s)?i.push(...s._toOps(this._id,u,r)):a.data[u]=s;return i}static _deserialize([t,n],r,o){const i=new Ar(n.data);return i._attach(t,o),this._deserializeChildren(i,r,o)}static _deserializeChildren(t,n,r){const o=n.get(me(t._id));if(o===void 0)return t;for(const[i,a]of o){const u=xg([i,a],n,r);Kn(u)&&u._setParentLink(t,a.parentKey),t.#e.set(a.parentKey,u),t.invalidate()}return t}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)Ue(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:i}=t,a=_d(t);if(this._pool.getNode(r)!==void 0)return this.#t.get(i)===o&&this.#t.delete(i),{modified:!1};if(n===0)this.#t.set(i,me(o));else if(this.#t.get(i)!==void 0)return this.#t.get(i)===o?(this.#t.delete(i),{modified:!1}):{modified:!1};const u=me(this._id),s=this.#e.get(i);let c;return Ue(s)?(c=s._toOps(u,i),s._detach()):c=s===void 0?[{type:6,id:u,key:i}]:[{type:3,id:u,data:{[i]:s}}],this.#e.set(i,a),this.invalidate(),Kn(a)&&(a._setParentLink(this,i),a._attach(r,this._pool)),{reverse:c,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}}}}}_detachChild(t){if(t){const n=me(this._id),r=me(t._parentKey),o=t._toOps(n,r,this._pool);for(const[i,a]of this.#e)a===t&&(this.#e.delete(i),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())Ue(t)&&t._detach()}_apply(t,n){return t.type===3?this.#r(t,n):t.type===6?this.#i(t,n):super._apply(t,n)}_serialize(){const t={};for(const[n,r]of this.#e)Ue(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=me(this._id),i=[],a={type:3,id:o,data:{}};for(const s in t.data){const c=this.#e.get(s);Ue(c)?(i.push(...c._toOps(o,s)),c._detach()):c!==void 0?a.data[s]=c:c===void 0&&i.push({type:6,id:o,key:s})}const u={};for(const s in t.data){const c=t.data[s];if(c===void 0)continue;if(n)this.#t.set(s,me(t.opId));else{if(this.#t.get(s)!==void 0){if(this.#t.get(s)===t.opId){this.#t.delete(s);continue}continue}r=!0}const l=this.#e.get(s);Ue(l)&&l._detach(),r=!0,u[s]={type:"update"},this.#e.set(s,c),this.invalidate()}return Object.keys(a.data).length!==0&&i.unshift(a),r?{modified:{node:this,type:"LiveObject",updates:u},reverse:i}:{modified:!1}}#i(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),i=me(this._id);let a=[];return Ue(o)?(a=o._toOps(i,t.key),o._detach()):o!==void 0&&(a=[{type:3,id:i,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)return Ue(r)&&r._detach(),this.#e.delete(n),void this.invalidate();let o;Ue(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 i=new Map;i.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,i)}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);Ue(d)&&d._detach(),Ue(l)&&l._setParentLink(this,c),this.#e.set(c,l),this.invalidate()}return}const n=[],r=[],o=this._pool.generateOpId(),i={},a={id:this._id,type:3,data:{}},u={};for(const c in t){const l=t[c];if(l===void 0)continue;const d=this.#e.get(c);if(Ue(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,Ue(l)){l._setParentLink(this,c),l._attach(this._pool.generateId(),this._pool);const p=l._toOps(this._id,c,this._pool),m=p.find((g=>g.parentId===this._id));m&&this.#t.set(c,me(m.opId)),n.push(...p)}else i[c]=l,this.#t.set(c,o);this.#e.set(c,l),this.invalidate(),u[c]={type:"update"}}Object.keys(a.data).length!==0&&r.unshift(a),Object.keys(i).length!==0&&n.unshift({opId:o,id:this._id,type:3,data:i});const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:u}),this._pool.dispatch(n,r,s)}toImmutable(){return super.toImmutable()}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??mr();return{type:"LiveObject",id:n,key:t,payload:Array.from(this.#e.entries()).map((([r,o])=>Ue(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]=Kn(r)?r.toImmutable():r;return t}clone(){return new Ar(Object.fromEntries(Array.from(this.#e).map((([t,n])=>[t,Kn(n)?n.clone():Ir(n)]))))}};function xr(e){return Zn(_d(e))}function _d(e){switch(e.type){case 8:return e.data;case 4:return new Rn(e.data);case 7:return new vr;case 2:return new gr([]);default:return ft(0,"Unknown creation Op")}}function Nd(e,t){return e===t||e.parent.type==="HasParent"&&Nd(e.parent.node,t)}function Pd([e,t],n,r){switch(t.type){case 0:return Rn._deserialize([e,t],n,r);case 1:return gr._deserialize([e,t],n,r);case 2:return vr._deserialize([e,t],n,r);case 3:return pn._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function xg([e,t],n,r){switch(t.type){case 0:return Rn._deserialize([e,t],n,r);case 1:return gr._deserialize([e,t],n,r);case 2:return vr._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function Kn(e){return Md(e)||(function(t){return t instanceof vr})(e)||(function(t){return t instanceof Rn})(e)}function Ue(e){return Kn(e)||(function(t){return t instanceof pn})(e)}function Md(e){return e instanceof gr}function Bn(e){return e instanceof pn?e.data:e instanceof gr||e instanceof vr||e instanceof Rn?e:ft(0,"Unknown AbstractCrdt")}function Zn(e){return e instanceof Rn||e instanceof vr||e instanceof gr?e:new pn(e)}function Pi(e,t){return e===void 0?t:e.type==="LiveObject"&&t.type==="LiveObject"?(function(n,r){const o=n.updates;for(const[i,a]of va(r.updates))o[i]=a;return{...r,updates:o}})(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?(function(n,r){const o=n.updates;for(const[i,a]of va(r.updates))o[i]=a;return{...r,updates:o}})(e,t):e.type==="LiveList"&&t.type==="LiveList"?(function(n,r){const o=n.updates;return{...r,updates:o.concat(r.updates)}})(e,t):t}var Mi=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&&Yt("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&&Yt("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 Tu(e){return Array.isArray(e)}var Og=class{#e;#t;signal;constructor(){this.#e=new On({connections:new Map,presences:new Map}),this.signal=Ke.from(this.#e,(e=>ya(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(function(o,i){const{connectionId:a,id:u,info:s}=o,c=Da(o.scopes);return Hr({connectionId:a,id:u,info:s,canWrite:c,canComment:jd(o.scopes),isReadOnly:!c,presence:i})})(n,r)}getUser(e){const t=this.#t.get(e);if(t)return t;const n=this.#n(e);return n?(this.#t.set(e,n),n):void 0}#r(e){this.#t.delete(e)}setConnection(e,t,n,r){this.#e.mutate((o=>(o.connections.set(e,{connectionId:e,id:t,info:n,scopes:r}),!!o.presences.has(e)&&this.#r(e))))}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,Hr(t)),!!n.connections.has(e)&&this.#r(e))))}patchOther(e,t){this.#e.mutate((n=>{const r=n.presences.get(e);if(r===void 0)return!1;const o=Ed(r,t);return r!==o&&(n.presences.set(e,o),this.#r(e))}))}},Ld=class Ud 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 Ud((function(r){switch(r.type){case"ROOM_CONNECTION_ERROR":switch(r.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 ft(0,"Unhandled case")}})(t),t,n)}},ju=1048064;function Ru(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 Bg(e,t){const n=t.roomId,r=e.initialPresence,o=e.initialStorage,i=t.roomHttpClient,[a,u]=(function(){const x=typeof document<"u"?document:void 0,L={current:null};function V(){L.current=x?.visibilityState==="hidden"?L.current??Date.now():null}return x?.addEventListener("visibilitychange",V),[L,()=>{x?.removeEventListener("visibilitychange",V)}]})(),s={...t.delegates,canZombie:()=>t.backgroundKeepAliveTimeout!==void 0&&a.current!==null&&Date.now()>a.current+t.backgroundKeepAliveTimeout&&Q()!=="synchronizing"},c=new gg(s,t.enableDebugLogging),l={buffer:{flushTimerID:void 0,lastFlushedAt:0,presenceUpdates:{type:"full",data:r},messages:[],storageOperations:[]},staticSessionInfoSig:new jt(null),dynamicSessionInfoSig:new jt(null),myPresence:new ng(r),others:new Og,initialStorage:o,idFactory:null,yjsProvider:void 0,yjsProviderDidChange:ke(),pool:Cg(n,{getCurrentConnectionId:function(){const x=l.dynamicSessionInfoSig.get();if(x)return x.actor;throw new Error("Internal. Tried to get connection id but connection was never open")},onDispatch:function(x,L,V){if(l.activeBatch){for(const Y of x)l.activeBatch.ops.push(Y);for(const[Y,ne]of V)l.activeBatch.updates.storageUpdates.set(Y,Pi(l.activeBatch.updates.storageUpdates.get(Y),ne));l.activeBatch.reverseOps.pushLeft(L)}else k(L),l.redoStack.length=0,ie(x),T({storageUpdates:V})},isStorageWritable:function(){const x=l.dynamicSessionInfoSig.get()?.scopes;return x===void 0||Da(x)}}),root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,unacknowledgedOps:new Map};let d,p,m=!1;c.events.onMessage.subscribe((function(x){if(typeof x.data!="string")return;const L=(function(Y){const ne=hi(Y);return ne===void 0?null:Tu(ne)?ya(ne.map((fe=>J(fe)))):ya([J(ne)])})(x.data);if(L===null||L.length===0)return;const V={storageUpdates:new Map,others:[]};for(const Y of L)switch(Y.type){case 101:{const ne=U(Y);ne&&V.others.push(ne);break}case 100:{const ne=P(Y);ne&&V.others.push(ne);break}case 103:{const ne=l.others.get();g.customEvent.notify({connectionId:Y.actor,user:Y.actor<0?null:ne.find((fe=>fe.connectionId===Y.actor))??null,event:Y.event});break}case 102:{const ne=H(Y);ne&&V.others.push(ne);break}case 300:g.ydoc.notify(Y);break;case 104:V.others.push(G(Y));break;case 200:pe(Y);break;case 201:{const ne=F(Y.ops,!1);for(const[fe,xe]of ne.updates.storageUpdates)V.storageUpdates.set(fe,Pi(V.storageUpdates.get(fe),xe));break}case 299:bd("Storage mutation rejection error",Y.reason);break;case 400:case 407:case 401:case 408:case 405:case 406:case 402:case 403:case 404:g.comments.notify(Y)}T(V)})),c.events.statusDidChange.subscribe((function(x){const L=c.authValue;if(L!==null){const V=Bd(L);if(V!==d)if(d=V,L.type==="secret"){const Y=L.token.parsed;l.staticSessionInfoSig.set({userId:Y.k==="sec-legacy"?Y.id:Y.uid,userInfo:Y.k==="sec-legacy"?Y.info:Y.ui})}else l.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}g.status.notify(x),A()})),c.events.statusDidChange.subscribe((function(x){x==="reconnecting"?p=setTimeout((()=>{g.lostConnection.notify("lost"),m=!0,l.others.clearOthers(),T({others:[{type:"reset"}]})}),t.lostConnectionTimeout):(clearTimeout(p),m&&(x==="disconnected"?g.lostConnection.notify("failed"):g.lostConnection.notify("restored"),m=!1))})),c.events.didConnect.subscribe((function(){l.buffer.presenceUpdates={type:"full",data:{...l.myPresence.get()}},de!==null&&I({flush:!1}),X()})),c.events.didDisconnect.subscribe((function(){clearTimeout(l.buffer.flushTimerID)})),c.events.onConnectionError.subscribe((({message:x,code:L})=>{const V=new Ld(x,{type:"ROOM_CONNECTION_ERROR",code:L,roomId:n});t.errorEventSource.notify(V)}));const g={status:ke(),lostConnection:ke(),customEvent:ke(),self:ke(),myPresence:ke(),others:ke(),storageBatch:ke(),history:ke(),storageDidLoad:ke(),storageStatus:ke(),ydoc:ke(),comments:ke(),roomWillDestroy:ke()};function*y(x){const{ops:L,...V}=x;if(L.length<2)throw new Error("Cannot split ops into smaller chunks");const Y=Math.floor(L.length/2),ne=L.slice(0,Y),fe=L.slice(Y);for(const xe of[ne,fe]){const De={ops:xe,...V},Fe=qt([De]);b(Fe)?yield*y(De):yield Fe}}function*f(x){if(x.length<2){if(x[0].type===201)return void(yield*y(x[0]));throw new Error("Cannot split into chunks smaller than the allowed message size")}const L=Math.floor(x.length/2),V=x.slice(0,L),Y=x.slice(L);for(const ne of[V,Y]){const fe=qt(ne);b(fe)?yield*f(ne):yield fe}}function b(x){return!(4*x.length<ju)&&new TextEncoder().encode(x).length>=ju}function C(x){const L=t.largeMessageStrategy??"default",V=qt(x);if(!b(V))return c.send(V);switch(L){case"default":return void ro("Message is too large for websockets, not sending. Configure largeMessageStrategy option to deal with this.");case"split":at("Message is too large for websockets, splitting into smaller chunks");for(const Y of f(x))c.send(Y);return;case"experimental-fallback-to-http":{at("Message is too large for websockets, so sending over HTTP instead");const Y=l.dynamicSessionInfoSig.get()?.nonce??Yt("Session is not authorized to send message over HTTP");return void i.sendMessages({roomId:n,nonce:Y,messages:x}).then((ne=>{ne.ok||ne.status!==403||c.reconnect()}))}}}const D=Ke.from(l.staticSessionInfoSig,l.dynamicSessionInfoSig,l.myPresence,((x,L,V)=>{if(x===null||L===null)return null;{const Y=Da(L.scopes);return{connectionId:L.actor,id:x.userId,info:x.userInfo,presence:V,canWrite:Y,canComment:jd(L.scopes)}}}));let E;function A(){const x=D.get();x!==null&&x!==E&&(g.self.notify(x),E=x)}const B=Ke.from(D,(x=>x!==null?Ru("Me",x):null));function O(x){if(x.items.length===0)throw new Error("Internal error: cannot load storage without items");l.root!==void 0?(function(ne){if(l.root===void 0)return;const fe=new Map;for(const[De,Fe]of l.pool.nodes)fe.set(De,Fe._serialize());const xe=(function(De,Fe){const $e=[];return De.forEach(((Se,Me)=>{Fe.get(Me)||$e.push({type:5,id:Me})})),Fe.forEach(((Se,Me)=>{const xt=De.get(Me);if(xt)Se.type===0&&(xt.type===0&&qt(Se.data)===qt(xt.data)||$e.push({type:3,id:Me,data:Se.data})),Se.parentKey!==xt.parentKey&&$e.push({type:1,id:Me,parentKey:me(Se.parentKey,"Parent key must not be missing")});else switch(Se.type){case 3:$e.push({type:8,id:Me,parentId:Se.parentId,parentKey:Se.parentKey,data:Se.data});break;case 1:$e.push({type:2,id:Me,parentId:Se.parentId,parentKey:Se.parentKey});break;case 0:if(Se.parentId===void 0||Se.parentKey===void 0)throw new Error("Internal error. Cannot serialize storage root into an operation");$e.push({type:4,id:Me,parentId:Se.parentId,parentKey:Se.parentKey,data:Se.data});break;case 2:$e.push({type:7,id:Me,parentId:Se.parentId,parentKey:Se.parentKey})}})),$e})(fe,new Map(ne));T(F(xe,!1).updates)})(x.items):l.root=Rn._fromItems(x.items,l.pool);const L=D.get()?.canWrite??!0,V=l.undoStack.length;for(const ne in l.initialStorage)l.root.get(ne)===void 0&&(L?l.root.set(ne,(Y=l.initialStorage[ne])===void 0?void 0:Kn(Y)?Y.clone():Ir(Y)):at(`Attempted to populate missing storage key '${ne}', but current user has no write access`));var Y;l.undoStack.length=V}function S(x){l.undoStack.length>=50&&l.undoStack.shift(),l.undoStack.push(x),W()}function k(x){l.pausedHistory!==null?l.pausedHistory.pushLeft(x):S(x)}function T(x){const L=x.storageUpdates,V=x.others;if(V!==void 0&&V.length>0){const Y=l.others.get();for(const ne of V)g.others.notify({...ne,others:Y})}if(x.presence&&(A(),g.myPresence.notify(l.myPresence.get())),L!==void 0&&L.size>0){const Y=Array.from(L.values());g.storageBatch.notify(Y)}ce()}function F(x,L){const V={reverse:new Mi,storageUpdates:new Map,presence:!1},Y=new Set,ne=x.map((fe=>fe.type==="presence"||fe.opId?fe:{...fe,opId:l.pool.generateOpId()}));for(const fe of ne)if(fe.type==="presence"){const xe={type:"presence",data:{}};for(const De in fe.data)xe.data[De]=l.myPresence.get()[De];if(l.myPresence.patch(fe.data),l.buffer.presenceUpdates===null)l.buffer.presenceUpdates={type:"partial",data:fe.data};else for(const De in fe.data)l.buffer.presenceUpdates.data[De]=fe.data[De];V.reverse.pushLeft(xe),V.presence=!0}else{let xe;if(L)xe=0;else{const Fe=me(fe.opId);xe=l.unacknowledgedOps.delete(Fe)?2:1}const De=R(fe,xe);if(De.modified){const Fe=De.modified.node._id;Fe&&Y.has(Fe)||(V.storageUpdates.set(me(De.modified.node._id),Pi(V.storageUpdates.get(me(De.modified.node._id)),De.modified)),V.reverse.pushLeft(De.reverse)),fe.type!==2&&fe.type!==7&&fe.type!==4||Y.add(me(fe.id))}}return{ops:ne,reverse:Array.from(V.reverse),updates:{storageUpdates:V.storageUpdates,presence:V.presence}}}function R(x,L){if((function(V){return V.type===5&&V.id==="ACK"})(x))return{modified:!1};switch(x.type){case 6:case 3:case 5:{const V=l.pool.nodes.get(x.id);return V===void 0?{modified:!1}:V._apply(x,L===0)}case 1:{const V=l.pool.nodes.get(x.id);return V===void 0?{modified:!1}:V.parent.type==="HasParent"&&Md(V.parent.node)?V.parent.node._setChildKey(Wr(x.parentKey),V,L):{modified:!1}}case 4:case 2:case 7:case 8:{if(x.parentId===void 0)return{modified:!1};const V=l.pool.nodes.get(x.parentId);return V===void 0?{modified:!1}:V._attachChild(x,L)}}}function P(x){if(x.targetActor!==void 0){const V=l.others.getUser(x.actor);l.others.setOther(x.actor,x.data);const Y=l.others.getUser(x.actor);if(V===void 0&&Y!==void 0)return{type:"enter",user:Y}}else l.others.patchOther(x.actor,x.data);const L=l.others.getUser(x.actor);return L?{type:"update",updates:x.data,user:L}:void 0}function H(x){const L=l.others.getUser(x.actor);return L?(l.others.removeConnection(x.actor),{type:"leave",user:L}):null}function G(x){l.dynamicSessionInfoSig.set({actor:x.actor,nonce:x.nonce,scopes:x.scopes}),l.idFactory=(function(L){let V=0;return()=>`${L}:${V++}`})(x.actor),A();for(const L of l.others.connectionIds())x.users[L]===void 0&&l.others.removeConnection(L);for(const L in x.users){const V=x.users[L],Y=Number(L);l.others.setConnection(Y,V.id,V.info,V.scopes)}return{type:"reset"}}function Z(){return l.undoStack.length>0}function $(){return l.redoStack.length>0}function W(){g.history.notify({canUndo:Z(),canRedo:$()})}function U(x){l.others.setConnection(x.actor,x.id,x.info,x.scopes),l.buffer.messages.push({type:100,data:l.myPresence.get(),targetActor:x.actor}),X();const L=l.others.getUser(x.actor);return L?{type:"enter",user:L}:void 0}function J(x){return(function(L){return!(function(V){return V===null||typeof V=="string"||typeof V=="number"||typeof V=="boolean"})(L)&&!Tu(L)})(x)?x:null}function X(){const x=l.buffer.storageOperations;if(x.length>0){for(const Y of x)l.unacknowledgedOps.set(me(Y.opId),Y);ce()}if(c.getStatus()!=="connected")return void(l.buffer.storageOperations=[]);const L=Date.now(),V=L-l.buffer.lastFlushedAt;if(V>=t.throttleDelay){const Y=(function(){const ne=[];l.buffer.presenceUpdates&&ne.push(l.buffer.presenceUpdates.type==="full"?{type:100,targetActor:-1,data:l.buffer.presenceUpdates.data}:{type:100,data:l.buffer.presenceUpdates.data});for(const fe of l.buffer.messages)ne.push(fe);return l.buffer.storageOperations.length>0&&ne.push({type:201,ops:l.buffer.storageOperations}),ne})();if(Y.length===0)return;C(Y),l.buffer={flushTimerID:void 0,lastFlushedAt:L,messages:[],storageOperations:[],presenceUpdates:null}}else clearTimeout(l.buffer.flushTimerID),l.buffer.flushTimerID=setTimeout(X,t.throttleDelay-V)}function ie(x){const{storageOperations:L}=l.buffer;for(const V of x)L.push(V);X()}let de=null,ee=null;function pe(x){const L=new Map(l.unacknowledgedOps);O(x),(function(V){if(V.size===0)return;const Y=[],ne=F(Array.from(V.values()),!0);Y.push({type:201,ops:ne.ops}),T(ne.updates),C(Y)})(L),ee?.(),ce(),g.storageDidLoad.notify()}function I(x){const L=l.buffer.messages;t.unstable_streamData?(async function(){c.authValue&&pe({items:await i.streamStorage({roomId:n})})})():L.some((V=>V.type===200))||L.push({type:200}),x.flush&&X()}function N(){return de===null&&(I({flush:!0}),de=new Promise((x=>{ee=x})),ce()),de}function _(){const x=l.root;return x!==void 0?x:(N(),null)}async function K(){return l.root!==void 0?Promise.resolve({root:l.root}):(await N(),{root:me(l.root)})}const oe=t.createSyncSource();function Q(){return l.root===void 0?de===null?"not-loaded":"loading":l.unacknowledgedOps.size===0?"synchronized":"synchronizing"}let ue=Q();function ce(){const x=Q();ue!==x&&(ue=x,g.storageStatus.notify(x)),oe.setSyncStatus(x==="synchronizing"?"synchronizing":"synchronized")}function he(){return D.get()!==null}function be(){return _()!==null}const le=Ke.from(l.others.signal,(x=>x.map(((L,V)=>Ru(`Other ${V}`,L))))),Ae={status:g.status.observable,lostConnection:g.lostConnection.observable,customEvent:g.customEvent.observable,others:g.others.observable,self:g.self.observable,myPresence:g.myPresence.observable,storage:g.storageBatch.observable,storageBatch:g.storageBatch.observable,history:g.history.observable,storageDidLoad:g.storageDidLoad.observable,storageStatus:g.storageStatus.observable,ydoc:g.ydoc.observable,comments:g.comments.observable,roomWillDestroy:g.roomWillDestroy.observable},re=t.createSyncSource();function Ce(x){return re.setSyncStatus(x==="synchronizing"?"synchronizing":"synchronized")}return Object.defineProperty({[Oe]:{get presenceBuffer(){return Ir(l.buffer.presenceUpdates?.data??null)},get undoStack(){return Ir(l.undoStack)},get nodeCount(){return l.pool.nodes.size},getYjsProvider:()=>l.yjsProvider,setYjsProvider(x){l.yjsProvider?.off("status",Ce),l.yjsProvider=x,x?.on("status",Ce),l.yjsProviderDidChange.notify()},yjsProviderDidChange:l.yjsProviderDidChange.observable,reportTextEditor:async function(x,L){await i.reportTextEditor({roomId:n,type:x,rootKey:L})},createTextMention:async function(x,L){return i.createTextMention({roomId:n,userId:x,mentionId:L})},deleteTextMention:async function(x){return i.deleteTextMention({roomId:n,mentionId:x})},listTextVersions:async function(){return i.listTextVersions({roomId:n})},listTextVersionsSince:async function(x){return i.listTextVersionsSince({roomId:n,since:x.since,signal:x.signal})},getTextVersion:async function(x){return i.getTextVersion({roomId:n,versionId:x})},createTextVersion:async function(){return i.createTextVersion({roomId:n})},executeContextualPrompt:async function(x){return i.executeContextualPrompt({roomId:n,...x})},getSelf_forDevTools:()=>B.get(),getOthers_forDevTools:()=>le.get(),simulate:{explicitClose:x=>c._privateSendMachineEvent({type:"EXPLICIT_SOCKET_CLOSE",event:x}),rawSend:x=>c.send(x)},attachmentUrlsStore:i.getOrCreateAttachmentUrlsStore(n)},id:n,subscribe:kg(n,Ae,t.errorEventSource),connect:()=>c.connect(),reconnect:()=>c.reconnect(),disconnect:()=>c.disconnect(),destroy:()=>{const{roomWillDestroy:x,...L}=g;for(const V of Object.values(L))V[Symbol.dispose]();g.roomWillDestroy.notify(),l.yjsProvider?.off("status",Ce),oe.destroy(),re.destroy(),u(),c.destroy(),x[Symbol.dispose]()},updatePresence:function(x,L){const V={};l.buffer.presenceUpdates===null&&(l.buffer.presenceUpdates={type:"partial",data:{}});for(const Y in x){const ne=x[Y];ne!==void 0&&(l.buffer.presenceUpdates.data[Y]=ne,V[Y]=l.myPresence.get()[Y])}l.myPresence.patch(x),l.activeBatch?(L?.addToHistory&&l.activeBatch.reverseOps.pushLeft({type:"presence",data:V}),l.activeBatch.updates.presence=!0):(X(),L?.addToHistory&&k([{type:"presence",data:V}]),T({presence:!0}))},updateYDoc:function(x,L,V){const Y={type:301,update:x,guid:L,v2:V};l.buffer.messages.push(Y),g.ydoc.notify(Y),X()},broadcastEvent:function(x,L={shouldQueueEventIfNotReady:!1}){(c.getStatus()==="connected"||L.shouldQueueEventIfNotReady)&&(l.buffer.messages.push({type:103,event:x}),X())},batch:function(x){if(l.activeBatch)return x();let L;l.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:new Mi};try{L=x()}finally{const V=l.activeBatch;l.activeBatch=null,V.reverseOps.length>0&&k(Array.from(V.reverseOps)),V.ops.length>0&&(l.redoStack.length=0),V.ops.length>0&&ie(V.ops),T(V.updates),X()}return L},history:{undo:function(){if(l.activeBatch)throw new Error("undo is not allowed during a batch");const x=l.undoStack.pop();if(x===void 0)return;l.pausedHistory=null;const L=F(x,!0);T(L.updates),l.redoStack.push(L.reverse),W();for(const V of L.ops)V.type!=="presence"&&l.buffer.storageOperations.push(V);X()},redo:function(){if(l.activeBatch)throw new Error("redo is not allowed during a batch");const x=l.redoStack.pop();if(x===void 0)return;l.pausedHistory=null;const L=F(x,!0);T(L.updates),l.undoStack.push(L.reverse),W();for(const V of L.ops)V.type!=="presence"&&l.buffer.storageOperations.push(V);X()},canUndo:Z,canRedo:$,clear:function(){l.undoStack.length=0,l.redoStack.length=0},pause:function(){l.pausedHistory===null&&(l.pausedHistory=new Mi)},resume:function(){const x=l.pausedHistory;l.pausedHistory=null,x!==null&&x.length>0&&S(Array.from(x))}},fetchYDoc:function(x,L,V){l.buffer.messages.find((Y=>Y.type===300&&Y.vector===x&&Y.guid===L&&Y.v2===V))||l.buffer.messages.push({type:300,vector:x,guid:L,v2:V}),X()},getStorage:K,getStorageSnapshot:_,getStorageStatus:Q,isPresenceReady:he,isStorageReady:be,waitUntilPresenceReady:yu((async function(){for(;!he();){const{promise:x,resolve:L}=Dd(),V=Ae.self.subscribeOnce(L),Y=Ae.status.subscribeOnce(L);await x,V(),Y()}})),waitUntilStorageReady:yu((async function(){for(;!be();)await K()})),events:Ae,getStatus:()=>c.getStatus(),getSelf:()=>D.get(),getPresence:()=>l.myPresence.get(),getOthers:()=>l.others.get(),getThreads:async function(x){return i.getThreads({roomId:n,query:x?.query,cursor:x?.cursor})},getThreadsSince:async function(x){return i.getThreadsSince({roomId:n,since:x.since,signal:x.signal})},getThread:async function(x){return i.getThread({roomId:n,threadId:x})},createThread:async function(x){return i.createThread({roomId:n,threadId:x.threadId,commentId:x.commentId,metadata:x.metadata,body:x.body,attachmentIds:x.attachmentIds})},deleteThread:async function(x){return i.deleteThread({roomId:n,threadId:x})},editThreadMetadata:async function({metadata:x,threadId:L}){return i.editThreadMetadata({roomId:n,threadId:L,metadata:x})},markThreadAsResolved:async function(x){return i.markThreadAsResolved({roomId:n,threadId:x})},markThreadAsUnresolved:async function(x){return i.markThreadAsUnresolved({roomId:n,threadId:x})},createComment:async function(x){return i.createComment({roomId:n,threadId:x.threadId,commentId:x.commentId,body:x.body,attachmentIds:x.attachmentIds})},editComment:async function(x){return i.editComment({roomId:n,threadId:x.threadId,commentId:x.commentId,body:x.body,attachmentIds:x.attachmentIds})},deleteComment:async function({threadId:x,commentId:L}){return i.deleteComment({roomId:n,threadId:x,commentId:L})},addReaction:async function({threadId:x,commentId:L,emoji:V}){return i.addReaction({roomId:n,threadId:x,commentId:L,emoji:V})},removeReaction:async function({threadId:x,commentId:L,emoji:V}){return await i.removeReaction({roomId:n,threadId:x,commentId:L,emoji:V})},prepareAttachment:function(x){return{type:"localAttachment",status:"idle",id:xd(),name:x.name,size:x.size,mimeType:x.type,file:x}},uploadAttachment:async function(x,L={}){return i.uploadAttachment({roomId:n,attachment:x,signal:L.signal})},getAttachmentUrl:function(x){return i.getAttachmentUrl({roomId:n,attachmentId:x})},getNotificationSettings:function(x){return i.getNotificationSettings({roomId:n,signal:x?.signal})},updateNotificationSettings:function(x){return i.updateNotificationSettings({roomId:n,settings:x})},markInboxNotificationAsRead:async function(x){await i.markRoomInboxNotificationAsRead({roomId:n,inboxNotificationId:x})}},Oe,{enumerable:!1})}function kg(e,t,n){function r(o,i){return t.storageBatch.subscribe((a=>{const u=a.filter((s=>Nd(s.node,o)));u.length>0&&i(u)}))}return function(o,i,a){if(typeof o=="string"&&((u=o)==="my-presence"||u==="others"||u==="event"||u==="error"||u==="history"||u==="status"||u==="storage-status"||u==="lost-connection"||u==="connection"||u==="comments")){if(typeof i!="function")throw new Error("Second argument must be a callback function");const s=i;switch(o){case"event":return t.customEvent.subscribe(s);case"my-presence":return t.myPresence.subscribe(s);case"others":{const c=s;return t.others.subscribe((l=>{const{others:d,...p}=l;return c(d,p)}))}case"error":return n.subscribe((c=>{if(c.roomId===e)return s(c)}));case"status":return t.status.subscribe(s);case"lost-connection":return t.lostConnection.subscribe(s);case"history":return t.history.subscribe(s);case"storage-status":return t.storageStatus.subscribe(s);case"comments":return t.comments.subscribe(s);default:return ft(0,`"${String(o)}" is not a valid event name`)}}var u;if(i===void 0||typeof o=="function"){if(typeof o=="function"){const s=o;return t.storageBatch.subscribe(s)}throw new Error("Please specify a listener callback")}if(Ue(o)){const s=o;return a?.isDeep?r(s,i):(function(c,l){return t.storageBatch.subscribe((d=>{for(const p of d)p.node._id===c._id&&l(p.node)}))})(s,i)}throw new Error(`${String(o)} is not a value that can be subscribed to.`)}}function Sg(e,t){return async()=>t.getAuthValue({requestedScope:"room:read",roomId:e})}function Ig(e,t,n){return r=>{const o=n??(typeof WebSocket>"u"?void 0:WebSocket);if(o===void 0)throw new En("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const i=new URL(t);if(i.protocol=i.protocol==="http:"?"ws":"wss",i.pathname="/v7",i.searchParams.set("roomId",e),r.type==="secret")i.searchParams.set("tok",r.token.raw);else{if(r.type!=="public")return ft(0,"Unhandled case");i.searchParams.set("pubkey",r.publicApiKey)}return i.searchParams.set("version",rs),new o(i.toString())}}function Fg(e){const t=e,n=Li("throttle",t.throttle??100,16,1e3),r=(function(k){return Li("lostConnectionTimeout",k,200,3e4,1e3)})(t.lostConnectionTimeout??5e3),o=(function(k){return k===void 0?void 0:Li("backgroundKeepAliveTimeout",k,15e3)})(t.backgroundKeepAliveTimeout),i=(function(k){return typeof k=="string"&&k.startsWith("http")?k:"https://api.liveblocks.io"})(t.baseUrl),a=new jt(void 0),u=vg(e,(k=>{const T=k.k==="sec-legacy"?k.id:k.uid;a.set((()=>T))})),s=t.polyfills?.fetch||globalThis.fetch?.bind(globalThis),c=cg({baseUrl:i,fetchPolyfill:s,authManager:u}),l=new Map;function d(k){const T=()=>{const F=T;var R;k.unsubs.delete(F)?k.unsubs.size===0&&((R=k.room).id,l.delete(R.id),R.destroy()):at("This leave function was already called. Calling it more than once has no effect.")};return k.unsubs.add(T),{room:k.room,leave:T}}const p=t.resolveUsers,m=_u((()=>!p),"Set the resolveUsers option in createClient to specify user info."),g=wa(new Tr((async k=>{const T=k.flat(),F=await p?.({userIds:T});return m(),F??T.map((()=>{}))}),{delay:50})),y=t.resolveRoomsInfo,f=_u((()=>!y),"Set the resolveRoomsInfo option in createClient to specify room info."),b=wa(new Tr((async k=>{const T=k.flat(),F=await y?.({roomIds:T});return f(),F??T.map((()=>{}))}),{delay:50})),C=new Map,D=[],E=new jt("synchronized"),A=ke();function B(){E.set(D.some((k=>k.get()==="synchronizing"))?"synchronizing":D.some((k=>k.get()==="has-local-changes"))?"has-local-changes":"synchronized")}function O(){const k=new jt("synchronized");D.push(k);const T=k.subscribe((()=>B()));return{setSyncStatus:function(F){k.set(F)},destroy:function(){T();const F=D.findIndex((R=>R===k));if(F>-1){const[R]=D.splice(F,1);R.get()!=="synchronized"&&B()}}}}{const k=F=>{t.preventUnsavedChanges&&E.get()!=="synchronized"&&F.preventDefault()};(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",k)}const S=Object.defineProperty({enterRoom:function(k,...T){const F=l.get(k);if(F!==void 0)return d(F);const R=T[0]??{},P=Bg({initialPresence:(typeof R.initialPresence=="function"?R.initialPresence(k):R.initialPresence)??{},initialStorage:(typeof R.initialStorage=="function"?R.initialStorage(k):R.initialStorage)??{}},{roomId:k,throttleDelay:n,lostConnectionTimeout:r,backgroundKeepAliveTimeout:o,polyfills:t.polyfills,delegates:t.mockedDelegates??{createSocket:Ig(k,i,t.polyfills?.WebSocket),authenticate:Sg(k,u)},enableDebugLogging:t.enableDebugLogging,baseUrl:i,errorEventSource:A,largeMessageStrategy:t.largeMessageStrategy??(t.unstable_fallbackToHTTP?"experimental-fallback-to-http":void 0),unstable_streamData:!!t.unstable_streamData,roomHttpClient:c,createSyncSource:O}),H={room:P,unsubs:new Set};if(l.set(k,H),R.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");pa.atob=t.polyfills.atob}P.connect()}return d(H)},getRoom:function(k){return l.get(k)?.room||null},logout:function(){u.reset(),a.set((()=>{}));for(const{room:T}of l.values())(k=T.getStatus())!=="initial"&&k!=="disconnected"&&T.reconnect();var k},getInboxNotifications:c.getInboxNotifications,getInboxNotificationsSince:c.getInboxNotificationsSince,getUnreadInboxNotificationsCount:c.getUnreadInboxNotificationsCount,markAllInboxNotificationsAsRead:c.markAllInboxNotificationsAsRead,markInboxNotificationAsRead:c.markInboxNotificationAsRead,deleteAllInboxNotifications:c.deleteAllInboxNotifications,deleteInboxNotification:c.deleteInboxNotification,getNotificationSettings:async function(k){return Yo(await c.getUserNotificationSettings(k))},updateNotificationSettings:async function(k){return Yo(await c.updateUserNotificationSettings(k))},resolvers:{invalidateUsers:function(k){g.invalidate(k)},invalidateRoomsInfo:function(k){b.invalidate(k)},invalidateMentionSuggestions:function(){C.clear()}},getSyncStatus:function(){const k=E.get();return k==="synchronizing"?k:"synchronized"},events:{error:A,syncStatus:E},[Oe]:{currentUserId:a,mentionSuggestionsCache:C,resolveMentionSuggestions:t.resolveMentionSuggestions,usersStore:g,roomsInfoStore:b,getRoomIds:()=>Array.from(l.keys()),httpClient:c,as:()=>S,createSyncSource:O,emitError:(k,T)=>{const F=Ld.from(k,T);A.notify(F)||ro(F.message)}}},Oe,{enumerable:!1});return S}function Li(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 _u(e,...t){return()=>{}}new RegExp(Object.keys({"&":"&","<":"<",">":">",'"':""","'":"'"}).map((e=>`\\${e}`)).join("|"),"g");new RegExp(Object.keys({_:"\\_","*":"\\*","#":"\\#","`":"\\`","~":"\\~","!":"\\!","|":"\\|","(":"\\(",")":"\\)","{":"\\{","}":"\\}","[":"\\[","]":"\\]"}).map((e=>`\\${e}`)).join("|"),"g");var Ui=[1e3,2e3,4e3,8e3,1e4];function Yn(e,t,n){const r=performance.now(),o=typeof document<"u"?document:void 0,i=typeof window<"u"?window:void 0,a=n?.maxStaleTimeMs??Number.POSITIVE_INFINITY,u={inForeground:o?.visibilityState!=="hidden",lastSuccessfulPollAt:r,count:0,backoff:0};function s(){return u.count>0&&u.inForeground}const c=new kd({}).addState("@idle").addState("@enabled").addState("@polling");function l(){s()?c.send({type:"START"}):c.send({type:"STOP"})}function d(){performance.now()-u.lastSuccessfulPollAt>a&&c.send({type:"POLL"})}function p(g){u.inForeground=g,l(),d()}function m(){p(o?.visibilityState!=="hidden")}return c.addTransitions("@idle",{START:"@enabled"}),c.addTransitions("@enabled",{STOP:"@idle",POLL:"@polling"}),c.addTimedTransition("@enabled",(()=>{const g=u.lastSuccessfulPollAt+t;return Math.max(0,g-performance.now())+u.backoff}),"@polling"),c.onEnterAsync("@polling",(async(g,y)=>{await e(y),y.aborted||(u.lastSuccessfulPollAt=performance.now())}),(()=>({target:s()?"@enabled":"@idle",effect:()=>{u.backoff=0}})),(()=>({target:s()?"@enabled":"@idle",effect:()=>{u.backoff=Ui.find((g=>g>u.backoff))??Ui[Ui.length-1]}})),3e4),o?.addEventListener("visibilitychange",m),i?.addEventListener("online",m),i?.addEventListener("focus",d),c.start(),{inc:function(){u.count++,l()},dec:function(){u.count--,u.count<0&&(u.count=0),l()},pollNowIfStale:d,setInForeground:p}}function Tt(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!(!n||!r)&&(function(o,i){if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!Object.is(o[a],i[a]))return!1;return!0})(e,t):(function(o,i){if(!Zt(o)||!Zt(i))return!1;const a=Object.keys(o);return a.length===Object.keys(i).length&&a.every((u=>Object.prototype.hasOwnProperty.call(i,u)&&Object.is(o[u],i[u])))})(e,t)}var Nu=class No{#e;#t;constructor(t,n){this.#t=n,this.#e=t}static from(t,n){const r=new No([],n);for(const o of t)r.add(o);return r}static fromAlreadySorted(t,n){return new No(t,n)}clone(){return new No(this.#e.slice(),this.#t)}add(t){const n=(function(r,o,i){let a=0,u=r.length;for(;a<u;){const s=a+(u-a>>1);i(o,r[s])?u=s:a=s+1}return a})(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)}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]()}};os("@liveblocks/core",rs,"esm");os("@liveblocks/client","2.23.0","esm");var Vd=h.createContext(null);function ls(e,t,n,r,o){const i=h.useRef(null);let a;i.current===null?(a={hasValue:!1,value:null},i.current=a):a=i.current;const[u,s]=h.useMemo((()=>{let l,d,p=!1;const m=y=>{if(!p){p=!0,l=y;const C=r(y);if(o!==void 0&&a.hasValue){const D=a.value;if(o(D,C))return d=D,D}return d=C,C}const f=d;if((function(C,D){return C===D&&(C!==0||1/C==1/D)||C!=C&&D!=D})(l,y))return f;const b=r(y);return o!==void 0&&o(f,b)?(l=y,f):(l=y,d=b,b)},g=n===void 0?null:n;return[()=>m(t()),g===null?void 0:()=>m(g())]}),[t,n,r,o]),c=h.useSyncExternalStore(e,u,s);return h.useEffect((()=>{a.hasValue=!0,a.value=c}),[c]),h.useDebugValue(c),c}var Tg=e=>e;function yr(e,t,n){return ls(e.subscribe,e.get,e.get,t??Tg,n)}var dt={NOTIFICATIONS_POLL_INTERVAL:6e4,NOTIFICATIONS_MAX_STALE_TIME:5e3,ROOM_THREADS_POLL_INTERVAL:3e5,ROOM_THREADS_MAX_STALE_TIME:5e3,USER_THREADS_POLL_INTERVAL:6e4,USER_THREADS_MAX_STALE_TIME:3e4,HISTORY_VERSIONS_POLL_INTERVAL:6e4,HISTORY_VERSIONS_MAX_STALE_TIME:5e3,NOTIFICATION_SETTINGS_POLL_INTERVAL:6e4,NOTIFICATION_SETTINGS_MAX_STALE_TIME:5e3,USER_NOTIFICATION_SETTINGS_INTERVAL:3e5,USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME:6e4},Jo=Object.freeze({isLoading:!0}),Hd=e=>Object.freeze({isLoading:!1,error:e});function Jn(e,t){return arguments.length===1?Object.freeze({isLoading:!1,data:e}):Object.freeze({isLoading:!1,[e]:t})}var jg=e=>e;function nt(e){return h.useReducer(jg,e)[0]}function yo(e){const t=nt(e);if(typeof t=="function"){const n=(function(r){const o=h.useRef(r);return h.useEffect((()=>{o.current=r}),[r]),o})(e);return h.useCallback(((...r)=>n.current(...r)),[n])}return t}function ds(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 Pu(e,t){if(!Zt(e)||!Zt(t))return Tt(e,t);const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r=>Object.prototype.hasOwnProperty.call(t,r)&&Tt(e[r],t[r])))}function Rg(e){return t=>(function(n,r){return r.resolved===void 0||n.resolved===r.resolved})(t,e)&&(function(n,r){const o=n.metadata;return r.metadata===void 0||Object.entries(r.metadata).every((([i,a])=>a===void 0||(function(u,s){return s===null?u===void 0:ga(s)?typeof u=="string"&&u.startsWith(s.startsWith):u===s})(o[i],a)))})(t,e)}var _g=class Wd{#e;#t;#n;signal;constructor(){this.#t=Nu.from([],((t,n)=>{const r=t.createdAt,o=n.createdAt;return r<o||r===o&&t.id<n.id})),this.#n=Nu.from([],((t,n)=>{const r=n.updatedAt,o=t.updatedAt;return r<o||r===o&&n.id<t.id})),this.#e=new Map,this.signal=new On(this)}clone(){const t=new Wd;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((()=>{const n=(t=(function(o){return o.deletedAt&&o.comments.length>0?{...o,comments:[]}:o.comments.some((i=>!i.deletedAt))?o:{...o,deletedAt:new Date,comments:[]}})(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){rt((()=>{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,i=[];return t!==void 0&&i.push((a=>a.roomId===t)),i.push(Rg(n)),Array.from(o.filter((a=>i.every((u=>u(a))))))}};function zd(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 Ng=Promise.resolve(),Vi=class{#e;signal;#t;#n;constructor(e){this.#e=new jt(Jo),this.#t=e,this.#n=null,this.signal=this.#e.asReadonly(),ds(this)}get(){return this.#e.get()}#r(e){const t=this.#e.get();t.data!==void 0&&this.#e.set(Jn({...t.data,...e}))}async#i(){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.#i().finally((()=>{this.#n=null}))),this.#n):Ng}#o=null;waitUntilLoaded(){if(this.#o)return this.#o;const e=zd(Fr((()=>this.#t(void 0)),5,[5e3,5e3,1e4,15e3]));return e.then((t=>{this.#e.set(Jn({cursor:t,hasFetchedAll:t===null,isFetchingMore:!1,fetchMoreError:void 0,fetchMore:this.fetchMore}))}),(t=>{this.#e.set(Hd(t)),setTimeout((()=>{this.#o=null,this.#e.set(Jo)}),5e3)})),this.#o=e,this.#o}},Hi=class{#e;signal;#t;constructor(e){this.#e=new jt(Jo),this.signal=this.#e.asReadonly(),this.#t=e,ds(this)}get(){return this.#e.get()}#n=null;waitUntilLoaded(){if(this.#n)return this.#n;const e=zd(Fr((()=>this.#t()),5,[5e3,5e3,1e4,15e3]));return e.then((()=>{this.#e.set(Jn(void 0))}),(t=>{this.#e.set(Hd(t)),setTimeout((()=>{this.#n=null,this.#e.set(Jo)}),5e3)})),this.#n=e,e}};function Pg(e){const t=new On(new Map);return{signal:Ke.from(t,e,((n,r)=>(function(o,i){const a=Object.fromEntries(o);for(const u of i)switch(u.type){case"update-notification-settings":{const s=a[u.roomId];if(s===void 0)break;a[u.roomId]={...s,...u.settings}}}return a})(n,r))),update:function(n,r){t.mutate((o=>{o.set(n,r)}))}}}function Mg(e){const t=new jt(Yo({}));return{signal:Ke.from(t,e,((n,r)=>(function(o,i){let a=o;for(const u of i)u.type==="update-user-notification-settings"&&(a=yg(a,u.settings));return a})(n,r))),update:function(n){t.set(n)}}}var Lg=class{#e;threads;notifications;roomNotificationSettings;historyVersions;permissionHints;userNotificationSettings;optimisticUpdates;outputs;#t=null;#n;#r=new Map;#i=null;#o=new Map;#s;constructor(e){this.#e=e[Oe].as(),this.optimisticUpdates=(function(l){const d=new jt([]),p=l[Oe].createSyncSource();return d.subscribe((()=>p.setSyncStatus(d.get().length>0?"synchronizing":"synchronized"))),{signal:d.asReadonly(),add:function(m){const g=mr(),y={...m,id:g};return d.set((f=>[...f,y])),g},remove:function(m){d.set((g=>g.filter((y=>y.id!==m))))}}})(this.#e),this.permissionHints=(function(){const l=new On(new vt((()=>new Set)));return{signal:l.asReadonly(),update:function(d){l.mutate((p=>{for(const[m,g]of Object.entries(d)){const y=p.getOrCreate(m);for(const f of g)y.add(f)}}))}}})(),this.#n=new Vi((async l=>{const d=await this.#e.getInboxNotifications({cursor:l});return this.updateThreadifications(d.threads,d.inboxNotifications),this.#t===null&&(this.#t=d.requestedAt),d.nextCursor})),this.userNotificationSettings=Mg(this.optimisticUpdates.signal),this.#s=new Hi((async()=>{const l=await this.#e.getNotificationSettings();this.userNotificationSettings.update(l)})),this.threads=new _g,this.notifications=(function(){const l=new On(new Map);return{signal:l.asReadonly(),markAllRead:function(d){l.mutate((p=>{for(const m of p.values())m.readAt=d}))},markRead:function(d,p){l.mutate((m=>{const g=m.get(d);return!!g&&(m.set(d,{...g,readAt:p}),!0)}))},delete:function(d){l.mutate((p=>p.delete(d)))},applyDelta:function(d,p){l.mutate((m=>{let g=!1;for(const y of d){const f=m.get(y.id);f&&Ug(f,y)===1||(m.set(y.id,y),g=!0)}for(const y of p)m.delete(y.id),g=!0;return g}))},clear:function(){l.mutate((d=>d.clear()))},updateAssociatedNotification:function(d){l.mutate((p=>{const m=(function(g,y){for(const f of g)if(y(f))return f})(p.values(),(g=>g.kind==="thread"&&g.threadId===d.threadId));return!!m&&(p.set(m.id,{...m,notifiedAt:d.createdAt,readAt:d.createdAt}),!0)}))},upsert:function(d){l.mutate((p=>{p.set(d.id,d)}))}}})(),this.roomNotificationSettings=Pg(this.optimisticUpdates.signal),this.historyVersions=(function(){const l=new On(new vt((()=>new Map)));return{signal:Ke.from(l,(d=>Object.fromEntries([...d].map((([p,m])=>[p,Object.fromEntries(m)]))))),update:function(d,p){l.mutate((m=>{const g=m.getOrCreate(d);for(const y of p)g.set(y.id,y)}))}}})();const t=Ke.from(this.threads.signal,this.notifications.signal,this.optimisticUpdates.signal,((l,d,p)=>(function(m,g,y){const f=m.clone();let b=Object.fromEntries(g);for(const C of y)switch(C.type){case"create-thread":f.upsert(C.thread);break;case"edit-thread-metadata":{const D=f.get(C.threadId);if(D===void 0||D.updatedAt>C.updatedAt)break;f.upsert({...D,updatedAt:C.updatedAt,metadata:{...D.metadata,...C.metadata}});break}case"mark-thread-as-resolved":{const D=f.get(C.threadId);if(D===void 0)break;f.upsert({...D,resolved:!0});break}case"mark-thread-as-unresolved":{const D=f.get(C.threadId);if(D===void 0)break;f.upsert({...D,resolved:!1});break}case"create-comment":{const D=f.get(C.comment.threadId);if(D===void 0)break;f.upsert(bo(D,C.comment));const E=Object.values(b).find((A=>A.kind==="thread"&&A.threadId===D.id));if(E===void 0)break;b[E.id]={...E,notifiedAt:C.comment.createdAt,readAt:C.comment.createdAt};break}case"edit-comment":{const D=f.get(C.comment.threadId);if(D===void 0)break;f.upsert(bo(D,C.comment));break}case"delete-comment":{const D=f.get(C.threadId);if(D===void 0)break;f.upsert(Mu(D,C.commentId,C.deletedAt));break}case"delete-thread":{const D=f.get(C.threadId);if(D===void 0)break;f.upsert({...D,deletedAt:C.deletedAt,updatedAt:C.deletedAt,comments:[]});break}case"add-reaction":{const D=f.get(C.threadId);if(D===void 0)break;f.upsert(Lu(D,C.commentId,C.reaction));break}case"remove-reaction":{const D=f.get(C.threadId);if(D===void 0)break;f.upsert(Uu(D,C.commentId,C.emoji,C.userId,C.removedAt));break}case"mark-inbox-notification-as-read":{const D=b[C.inboxNotificationId];if(D===void 0)break;b[C.inboxNotificationId]={...D,readAt:C.readAt};break}case"mark-all-inbox-notifications-as-read":for(const D in b){const E=b[D];if(E===void 0)break;b[D]={...E,readAt:C.readAt}}break;case"delete-inbox-notification":delete b[C.inboxNotificationId];break;case"delete-all-inbox-notifications":b={}}return{sortedNotifications:Object.values(b).filter((C=>C.kind!=="thread"||f.get(C.threadId)!==void 0)).sort(((C,D)=>D.notifiedAt.getTime()-C.notifiedAt.getTime())),notificationsById:b,threadsDB:f}})(l,d,p))),n=Ke.from(t,(l=>l.threadsDB)),r=Ke.from(t,(l=>({sortedNotifications:l.sortedNotifications,notificationsById:l.notificationsById})),Tt),o=new vt((l=>{const d=JSON.parse(l),p=new Vi((async m=>{const g=await this.#e[Oe].httpClient.getUserThreads_experimental({cursor:m,query:d});return this.updateThreadifications(g.threads,g.inboxNotifications),this.permissionHints.update(g.permissionHints),this.#i===null&&(this.#i=g.requestedAt),g.nextCursor}));return{signal:Ke.from((()=>{const m=p.get();if(m.isLoading||m.error)return m;const g=this.outputs.threads.get().findMany(void 0,d??{},"desc"),y=m.data;return{isLoading:!1,threads:g,hasFetchedAll:y.hasFetchedAll,isFetchingMore:y.isFetchingMore,fetchMoreError:y.fetchMoreError,fetchMore:y.fetchMore}}),Pu),waitUntilLoaded:p.waitUntilLoaded}})),i=new vt((l=>{const[d,p]=JSON.parse(l),m=new Vi((async g=>{const y=await this.#e[Oe].httpClient.getThreads({roomId:d,cursor:g,query:p});this.updateThreadifications(y.threads,y.inboxNotifications),this.permissionHints.update(y.permissionHints);const f=this.#r.get(d);return(f===void 0||f>y.requestedAt)&&this.#r.set(d,y.requestedAt),y.nextCursor}));return{signal:Ke.from((()=>{const g=m.get();if(g.isLoading||g.error)return g;const y=this.outputs.threads.get().findMany(d,p??{},"asc"),f=g.data;return{isLoading:!1,threads:y,hasFetchedAll:f.hasFetchedAll,isFetchingMore:f.isFetchingMore,fetchMoreError:f.fetchMoreError,fetchMore:f.fetchMore}}),Pu),waitUntilLoaded:m.waitUntilLoaded}})),a={signal:Ke.from((()=>{const l=this.#n.get();if(l.isLoading||l.error)return l;const d=l.data;return{isLoading:!1,inboxNotifications:this.outputs.notifications.get().sortedNotifications,hasFetchedAll:d.hasFetchedAll,isFetchingMore:d.isFetchingMore,fetchMoreError:d.fetchMoreError,fetchMore:d.fetchMore}})),waitUntilLoaded:this.#n.waitUntilLoaded},u=new vt((l=>{const d=new Hi((async()=>{const p=this.#e.getRoom(l);if(p===null)throw new Error(`Room '${l}' is not available on client`);const m=await p.getNotificationSettings();this.roomNotificationSettings.update(l,m)}));return{signal:Ke.from((()=>{const p=d.get();return p.isLoading||p.error?p:Jn("settings",me(this.roomNotificationSettings.signal.get()[l]))}),Tt),waitUntilLoaded:d.waitUntilLoaded}})),s=new vt((l=>{const d=new Hi((async()=>{const p=this.#e.getRoom(l);if(p===null)throw new Error(`Room '${l}' is not available on client`);const m=await p[Oe].listTextVersions();this.historyVersions.update(l,m.versions);const g=this.#o.get(l);(g===void 0||g>m.requestedAt)&&this.#o.set(l,m.requestedAt)}));return{signal:Ke.from((()=>{const p=d.get();return p.isLoading||p.error?p:Jn("versions",Object.values(this.historyVersions.signal.get()[l]??{}))}),Tt),waitUntilLoaded:d.waitUntilLoaded}})),c={signal:Ke.from((()=>{const l=this.#s.get();return l.isLoading||l.error?l:Jn("settings",me(this.userNotificationSettings.signal.get()))}),Tt),waitUntilLoaded:this.#s.waitUntilLoaded};this.outputs={threadifications:t,threads:n,loadingRoomThreads:i,loadingUserThreads:o,notifications:r,loadingNotifications:a,settingsByRoomId:u,versionsByRoomId:s,userNotificationSettings:c},ds(this)}markInboxNotificationRead(e,t,n){rt((()=>{this.optimisticUpdates.remove(n),this.notifications.markRead(e,t)}))}markAllInboxNotificationsRead(e,t){rt((()=>{this.optimisticUpdates.remove(e),this.notifications.markAllRead(t)}))}deleteInboxNotification(e,t){rt((()=>{this.optimisticUpdates.remove(t),this.notifications.delete(e)}))}deleteAllInboxNotifications(e){rt((()=>{this.optimisticUpdates.remove(e),this.notifications.clear()}))}createThread(e,t){rt((()=>{this.optimisticUpdates.remove(e),this.threads.upsert(t)}))}#a(e,t,n,r){rt((()=>{t!==null&&this.optimisticUpdates.remove(t);const o=this.threads,i=o.get(e);i&&(r&&i.updatedAt>r||o.upsert(n(i)))}))}patchThread(e,t,n,r){return this.#a(e,t,(o=>({...o,...Hr(n)})),r)}addReaction(e,t,n,r,o){this.#a(e,t,(i=>Lu(i,n,r)),o)}removeReaction(e,t,n,r,o,i){this.#a(e,t,(a=>Uu(a,n,r,o,i)),i)}deleteThread(e,t){return this.#a(e,t,(n=>({...n,updatedAt:new Date,deletedAt:new Date})))}createComment(e,t){rt((()=>{this.optimisticUpdates.remove(t);const n=this.threads.get(e.threadId);n&&(this.threads.upsert(bo(n,e)),this.notifications.updateAssociatedNotification(e))}))}editComment(e,t,n){return this.#a(e,t,(r=>bo(r,n)))}deleteComment(e,t,n,r){return this.#a(e,t,(o=>Mu(o,n,r)),r)}updateThreadifications(e,t,n=[],r=[]){rt((()=>{this.threads.applyDelta(e,n),this.notifications.applyDelta(t,r)}))}updateRoomNotificationSettings(e,t,n){rt((()=>{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.#i;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 r=me(this.#e.getRoom(e),`Room with id ${e} is not available on client`),o=await r[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 n=me(this.#e.getRoom(e),`Room with id ${e} is not available on client`),r=await n.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){rt((()=>{this.optimisticUpdates.remove(t),this.userNotificationSettings.update(e)}))}};function Ug(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 bo(e,t){if(e.deletedAt!==void 0)return e;if(t.threadId!==e.id)return sn.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((o=>o.id===t.id?t:o));return{...e,updatedAt:new Date(Math.max(e.updatedAt.getTime(),t.editedAt?.getTime()||t.createdAt.getTime())),comments:r}}return e}function Mu(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find((i=>i.id===t));if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map((i=>i.id===t?{...i,deletedAt:n,body:void 0,attachments:[]}:i));return o.every((i=>i.deletedAt!==void 0))?{...e,deletedAt:n,updatedAt:n}:{...e,updatedAt:n,comments:o}}function Lu(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find((i=>i.id===t));if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map((i=>i.id===t?{...i,reactions:Vg(i.reactions,n)}:i));return{...e,updatedAt:new Date(Math.max(n.createdAt.getTime(),e.updatedAt.getTime())),comments:o}}function Uu(e,t,n,r,o){if(e.deletedAt!==void 0)return e;const i=e.comments.find((u=>u.id===t));if(i===void 0||i.deletedAt!==void 0)return e;const a=e.comments.map((u=>u.id===t?{...u,reactions:u.reactions.map((s=>s.emoji===n?{...s,users:s.users.filter((c=>c.id!==r))}:s)).filter((s=>s.users.length>0))}:u));return{...e,updatedAt:new Date(Math.max(o.getTime(),e.updatedAt.getTime())),comments:a}}function Vg(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 $d=h.createContext(null);function Hg(e){return new Error(`resolveUsers didn't return anything for user '${e}'`)}function Wg(e){return e}var Vu=new WeakMap,Hu=new WeakMap;function qd(e){let t=Vu.get(e);return t||(t=new Lg(e),Vu.set(e,t)),t}function fs(e){let t=Hu.get(e);return t||(t=(function(n){const r=qd(n),o=Yn((async u=>{try{return await r.fetchNotificationsDeltaUpdate(u)}catch(s){throw console.warn(`Polling new inbox notifications failed: ${String(s)}`),s}}),dt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:dt.NOTIFICATIONS_MAX_STALE_TIME}),i=Yn((async u=>{try{return await r.fetchUserThreadsDeltaUpdate(u)}catch(s){throw console.warn(`Polling new user threads failed: ${String(s)}`),s}}),dt.USER_THREADS_POLL_INTERVAL,{maxStaleTimeMs:dt.USER_THREADS_MAX_STALE_TIME}),a=Yn((async u=>{try{return await r.refreshUserNotificationSettings(u)}catch(s){throw console.warn(`Polling new user notification settings failed: ${String(s)}`),s}}),dt.USER_NOTIFICATION_SETTINGS_INTERVAL,{maxStaleTimeMs:dt.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME});return{store:r,notificationsPoller:o,userThreadsPoller:i,userNotificationSettingsPoller:a}})(e),Hu.set(e,t)),t}function zg(e,t){const n=e[Oe].usersStore,r=h.useCallback((()=>n.getItemState(t)),[n,t]),o=h.useCallback((a=>(function(u,s){return u===void 0||u?.isLoading?u??{isLoading:!0}:u.error?u:u.data?{isLoading:!1,user:u.data}:{isLoading:!1,error:Hg(s)}})(a,t)),[t]),i=ls(n.subscribe,r,r,o,Tt);return h.useEffect((()=>{n.enqueue(t)})),i}function hs(){return h.useContext($d)}function je(){return hs()??Yt("LiveblocksProvider is missing from the React tree.")}function $g(e){return(function(t){const n=hs();if(!t?.allowNesting&&n!==null)throw new Error("You cannot nest multiple LiveblocksProvider instances in the same React tree.")})(e),v.jsx($d.Provider,{value:e.client,children:e.children})}function KD(e){const{children:t,...n}=e,r={publicApiKey:nt(n.publicApiKey),throttle:nt(n.throttle),lostConnectionTimeout:nt(n.lostConnectionTimeout),backgroundKeepAliveTimeout:nt(n.backgroundKeepAliveTimeout),polyfills:nt(n.polyfills),largeMessageStrategy:nt(n.largeMessageStrategy),unstable_fallbackToHTTP:nt(n.unstable_fallbackToHTTP),unstable_streamData:nt(n.unstable_streamData),preventUnsavedChanges:nt(n.preventUnsavedChanges),authEndpoint:yo(n.authEndpoint),resolveMentionSuggestions:yo(n.resolveMentionSuggestions),resolveUsers:yo(n.resolveUsers),resolveRoomsInfo:yo(n.resolveRoomsInfo),baseUrl:nt(n.baseUrl),enableDebugLogging:nt(n.enableDebugLogging)},o=h.useMemo((()=>Fg(r)),[]);return v.jsx($g,{client:o,children:t})}function GD(){return(function(e,t,n){const{store:r,notificationsPoller:o}=fs(e);return h.useEffect((()=>{r.outputs.loadingNotifications.waitUntilLoaded()})),h.useEffect((()=>(o.inc(),o.pollNowIfStale(),()=>{o.dec()})),[o]),yr(r.outputs.loadingNotifications.signal,t,n)})(je(),Wg,Tt)}function XD(){return e=je(),h.useCallback((t=>{const{store:n}=fs(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)}),(i=>{n.optimisticUpdates.remove(o),e[Oe].emitError({type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",inboxNotificationId:t},i)}))}),[e]);var e}var Kd=function(e){return zg(je(),e)},ZD=function(e={}){const t=je(),{store:n,userThreadsPoller:r}=fs(t),o=Tn(e.query??{});return h.useEffect((()=>{n.outputs.loadingUserThreads.getOrCreate(o).waitUntilLoaded()})),h.useEffect((()=>(r.inc(),r.pollNowIfStale(),()=>{r.dec()})),[r]),yr(n.outputs.loadingUserThreads.getOrCreate(o).signal)};function qg(e,t){h.useEffect((()=>{(function(n,r){if(n===!1||!r.threads||typeof window>"u")return;const o=window.location.hash.slice(1);if(!o.startsWith("cm_"))return;const i=document.getElementById(o);i!==null&&r.threads.flatMap((a=>a.comments)).some((a=>a.id===o))&&i.scrollIntoView()})(e,t)}),[t.isLoading])}function mi(e){const t=e[Oe].currentUserId.get();return t===void 0?"anonymous":t}var Wu=new WeakMap;function st(e){let t=Wu.get(e);return t||(t=(function(n){const r=qd(n);function o(s,c,l){if(r.optimisticUpdates.remove(s),!(l instanceof ir))throw l;if(l.status===403){const d=[l.message,l.details?.suggestion,l.details?.docs].filter(Boolean).join(`
|
|
3
3
|
`);sn.error(d)}n[Oe].emitError(c,l)}const i=new vt((s=>Yn((async c=>{try{return await r.fetchRoomThreadsDeltaUpdate(s,c)}catch(l){throw sn.warn(`Polling new threads for '${s}' failed: ${String(l)}`),l}}),dt.ROOM_THREADS_POLL_INTERVAL,{maxStaleTimeMs:dt.ROOM_THREADS_MAX_STALE_TIME}))),a=new vt((s=>Yn((async c=>{try{return await r.fetchRoomVersionsDeltaUpdate(s,c)}catch(l){throw sn.warn(`Polling new history versions for '${s}' failed: ${String(l)}`),l}}),dt.HISTORY_VERSIONS_POLL_INTERVAL,{maxStaleTimeMs:dt.HISTORY_VERSIONS_MAX_STALE_TIME}))),u=new vt((s=>Yn((async c=>{try{return await r.refreshRoomNotificationSettings(s,c)}catch(l){throw sn.warn(`Polling notification settings for '${s}' failed: ${String(l)}`),l}}),dt.NOTIFICATION_SETTINGS_POLL_INTERVAL,{maxStaleTimeMs:dt.NOTIFICATION_SETTINGS_MAX_STALE_TIME})));return{store:r,onMutationFailure:o,getOrCreateThreadsPollerForRoomId:i.getOrCreate.bind(i),getOrCreateVersionsPollerForRoomId:a.getOrCreate.bind(a),getOrCreateNotificationsSettingsPollerForRoomId:u.getOrCreate.bind(u)}})(e),Wu.set(e,t)),t}function Kg(e){const t=je(),{id:n,stableEnterRoom:r}=e,o=nt({initialPresence:e.initialPresence,initialStorage:e.initialStorage,autoConnect:e.autoConnect??typeof window<"u"}),[{room:i},a]=h.useState((()=>r(n,{...o,autoConnect:!1})));return h.useEffect((()=>{const{store:u}=st(t);return i.events.comments.subscribe((s=>{(async function(c){if(c.type===zt.THREAD_DELETED)return void u.deleteThread(c.threadId,null);const l=await i.getThread(c.threadId);if(!l.thread)return void u.deleteThread(c.threadId,null);const{thread:d,inboxNotification:p}=l,m=u.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(!m)break;u.updateThreadifications([d],p?[p]:[]);break;case zt.COMMENT_CREATED:u.updateThreadifications([d],p?[p]:[])}})(s)}))}),[t,i]),h.useEffect((()=>{const u=r(n,o);a(u);const{room:s,leave:c}=u;return o.autoConnect&&s.connect(),()=>{c()}}),[n,o,r]),v.jsx(Vd.Provider,{value:i,children:e.children})}function ps(e){const t=h.useContext(Vd);if(t===null&&!e?.allowOutsideRoom)throw new Error("RoomProvider is missing from the React tree.");return t}function ms(){return je()[Oe].resolveMentionSuggestions}function Gd(e){const t=je();return h.useCallback((n=>{const r=n.body,o=n.metadata??{},i=n.attachments,a=Ad(),u=Zo(),s=new Date,c={id:u,threadId:a,roomId:e,createdAt:s,type:"comment",userId:mi(t),body:r,reactions:[],attachments:i??[]},l={id:a,type:"thread",createdAt:s,updatedAt:s,roomId:e,metadata:o,comments:[c],resolved:!1},{store:d,onMutationFailure:p}=st(t),m=d.optimisticUpdates.add({type:"create-thread",thread:l,roomId:e}),g=i?.map((y=>y.id));return t[Oe].httpClient.createThread({roomId:e,threadId:a,commentId:u,body:r,metadata:o,attachmentIds:g}).then((y=>{d.createThread(m,y)}),(y=>p(m,{type:"CREATE_THREAD_ERROR",roomId:e,threadId:a,commentId:u,body:r,metadata:o},y))),l}),[t,e])}function Xd(e){const t=je();return h.useCallback((({threadId:n,commentId:r,body:o,attachments:i})=>{const a=new Date,{store:u,onMutationFailure:s}=st(t),c=u.outputs.threads.get().getEvenIfDeleted(n);if(c===void 0)return void sn.warn(`Internal unexpected behavior. Cannot edit comment in thread "${n}" because the thread does not exist in the cache.`);const l=c.comments.find((m=>m.id===r));if(l===void 0||l.deletedAt!==void 0)return void sn.warn(`Internal unexpected behavior. Cannot edit comment "${r}" in thread "${n}" because the comment does not exist in the cache.`);const d=u.optimisticUpdates.add({type:"edit-comment",comment:{...l,editedAt:a,body:o,attachments:i??[]}}),p=i?.map((m=>m.id));t[Oe].httpClient.editComment({roomId:e,threadId:n,commentId:r,body:o,attachmentIds:p}).then((m=>{u.editComment(n,d,m)}),(m=>s(d,{type:"EDIT_COMMENT_ERROR",roomId:e,threadId:n,commentId:r,body:o},m)))}),[t,e])}function Zd(e){const t=je();return h.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=new Date,a=mi(t),{store:u,onMutationFailure:s}=st(t),c=u.optimisticUpdates.add({type:"add-reaction",threadId:n,commentId:r,reaction:{emoji:o,userId:a,createdAt:i}});t[Oe].httpClient.addReaction({roomId:e,threadId:n,commentId:r,emoji:o}).then((l=>{u.addReaction(n,c,r,l,i)}),(l=>s(c,{type:"ADD_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},l)))}),[t,e])}function Yd(e){const t=je();return h.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=mi(t),a=new Date,{store:u,onMutationFailure:s}=st(t),c=u.optimisticUpdates.add({type:"remove-reaction",threadId:n,commentId:r,emoji:o,userId:i,removedAt:a});t[Oe].httpClient.removeReaction({roomId:e,threadId:n,commentId:r,emoji:o}).then((()=>{u.removeReaction(n,c,r,o,i,a)}),(l=>s(c,{type:"REMOVE_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},l)))}),[t,e])}function Gg(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:(e.data,{isLoading:!1,url:e.data})}function gi(e,t){const n=je()[Oe].httpClient.getOrCreateAttachmentUrlsStore(t),r=h.useCallback((()=>n.getItemState(e)),[n,e]);return h.useEffect((()=>{n.enqueue(e)}),[n,e]),ls(n.subscribe,r,r,Gg,Tt)}var Xg=new Set,YD=function(e){const t=je(),[n]=h.useState((()=>new Map)),r=h.useCallback(((o,i)=>{const a=n.get(o);if(a)return a;const u=t.enterRoom(o,i),s=u.leave;return u.leave=()=>{s(),n.delete(o)},n.set(o,u),u}),[t,n]);return v.jsx(Kg,{...e,stableEnterRoom:r})},Jd=ps,JD=function(){return Gd(ps().id)},QD=function(e={}){const{scrollOnLoad:t=!0}=e,n=je(),r=ps(),{store:o,getOrCreateThreadsPollerForRoomId:i}=st(n),a=(u=r.id,s=e.query,Tn([u,s??{}]));var u,s;const c=i(r.id);h.useEffect((()=>{o.outputs.loadingRoomThreads.getOrCreate(a).waitUntilLoaded()})),h.useEffect((()=>(c.inc(),c.pollNowIfStale(),()=>c.dec())),[c]);const l=yr(o.outputs.loadingRoomThreads.getOrCreate(a).signal);return qg(t,l),l};os("@liveblocks/react","2.23.0","esm");var Nt=typeof window<"u"?h.useLayoutEffect:h.useEffect;function Zg(e,t){const[n,r]=h.useState(),o=h.useRef(),i=ms(),a=je()[Oe].mentionSuggestionsCache;return h.useEffect((()=>{if(t===void 0||!i)return;const u={text:t,roomId:e},s=Tn(u);let c,l=!1;const d=async()=>{try{o.current=performance.now();const p=await i(u);l||(r(p),a.set(s,p))}catch(p){console.error(p?.message)}};return a.has(s)?r(a.get(s)):!o.current||Math.abs(performance.now()-o.current)>500?d():c=window.setTimeout((()=>{d()}),500),()=>{l=!0,window.clearTimeout(c)}}),[t,e,i,a]),n}function Yg(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function wt(e){const t=h.useRef(e);return h.useEffect((()=>{t.current=e})),h.useMemo((()=>(...n)=>t.current?.(...n)),[])}function oo({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=(function({defaultProp:s,onChange:c}){const l=h.useState(s),[d]=l,p=h.useRef(d),m=wt(c);return h.useEffect((()=>{p.current!==d&&(m(d),p.current=d)}),[d,p,m]),l})({defaultProp:t,onChange:n}),i=e!==void 0,a=i?e:r,u=wt(n);return[a,h.useCallback((s=>{if(i){const c=typeof s=="function"?s(e):s;c!==e&&u(c)}else o(s)}),[i,e,o,u])]}function Jg(...e){return t=>e.forEach((n=>(function(r,o){typeof r=="function"?r(o):r!=null&&(r.current=o)})(n,t)))}var Qd=h.forwardRef(((e,t)=>{const{children:n,...r}=e,o=h.Children.toArray(n),i=o.find(ev);if(i){const a=i.props.children,u=o.map((s=>s===i?h.Children.count(a)>1?h.Children.only(null):h.isValidElement(a)?a.props.children:null:s));return v.jsx(Oa,{...r,ref:t,children:h.isValidElement(a)?h.cloneElement(a,void 0,u):null})}return v.jsx(Oa,{...r,ref:t,children:n})}));Qd.displayName="Slot";var Oa=h.forwardRef(((e,t)=>{const{children:n,...r}=e;if(h.isValidElement(n)){const o=(function(i){let a=Object.getOwnPropertyDescriptor(i.props,"ref")?.get,u=a&&"isReactWarning"in a&&a.isReactWarning;return u?i.ref:(a=Object.getOwnPropertyDescriptor(i,"ref")?.get,u=a&&"isReactWarning"in a&&a.isReactWarning,u?i.props.ref:i.props.ref||i.ref)})(n);return h.cloneElement(n,{...tv(r,n.props),ref:t?Jg(t,o):o})}return h.Children.count(n)>1?h.Children.only(null):null}));Oa.displayName="SlotClone";var Qg=({children:e})=>v.jsx(v.Fragment,{children:e});function ev(e){return h.isValidElement(e)&&e.type===Qg}function tv(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}var nv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,t)=>{const n=h.forwardRef(((r,o)=>{const{asChild:i,...a}=r,u=i?Qd:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...a,ref:o})}));return n.displayName=`Primitive.${t}`,{...e,[t]:n}}),{}),ef=h.forwardRef(((e,t)=>{const{pressed:n,defaultPressed:r=!1,onPressedChange:o,...i}=e,[a=!1,u]=oo({prop:n,onChange:o,defaultProp:r});return v.jsx(nv.button,{type:"button","aria-pressed":a,"data-state":a?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:Yg(e.onClick,(()=>{e.disabled||u(!a)}))})}));ef.displayName="Toggle";var gs=ef;function Be(...e){return e.filter((t=>typeof t=="string"||typeof t=="number")).join(" ")}function Ne({children:e,className:t,...n}){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",role:"presentation",className:Be("lb-icon",t),...n,children:e})}function rv(e){return v.jsx(Ne,{...e,children:v.jsx("path",{d:"M16 6L8 14L4 10"})})}function vs(e){return v.jsxs(Ne,{...e,children:[v.jsx("path",{d:"M15 5L5 15"}),v.jsx("path",{d:"M5 5L15 15"})]})}function ov(e){return v.jsx(Ne,{...e,children:v.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 iv(e){return v.jsx(Ne,{...e,children:v.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 av(e){return v.jsxs(Ne,{fill:"currentColor",...e,children:[v.jsx("circle",{cx:5,cy:10,r:.75}),v.jsx("circle",{cx:10,cy:10,r:.75}),v.jsx("circle",{cx:15,cy:10,r:.75})]})}function zu(e){return v.jsxs(Ne,{...e,children:[v.jsx("path",{d:"M11 3.07A7 7 0 1 0 16.93 9"}),v.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h0"}),v.jsx("path",{d:"M12 8h0"}),v.jsx("path",{d:"M13 5h4m-2-2v4"}),v.jsx("circle",{cx:"8",cy:"8",r:".25"}),v.jsx("circle",{cx:"12",cy:"8",r:".25"})]})}function $u(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vi(...e){return t=>{let n=!1;const r=e.map((o=>{const i=$u(o,t);return n||typeof i!="function"||(n=!0),i}));if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():$u(e[o],null)}}}}function We(...e){return h.useCallback(vi(...e),e)}var Re=h.forwardRef(((e,t)=>{const{children:n,...r}=e,o=h.Children.toArray(n),i=o.find(sv);if(i){const a=i.props.children,u=o.map((s=>s===i?h.Children.count(a)>1?h.Children.only(null):h.isValidElement(a)?a.props.children:null:s));return v.jsx(Ba,{...r,ref:t,children:h.isValidElement(a)?h.cloneElement(a,void 0,u):null})}return v.jsx(Ba,{...r,ref:t,children:n})}));Re.displayName="Slot";var Ba=h.forwardRef(((e,t)=>{const{children:n,...r}=e;if(h.isValidElement(n)){const o=(function(a){let u=Object.getOwnPropertyDescriptor(a.props,"ref")?.get,s=u&&"isReactWarning"in u&&u.isReactWarning;return s?a.ref:(u=Object.getOwnPropertyDescriptor(a,"ref")?.get,s=u&&"isReactWarning"in u&&u.isReactWarning,s?a.props.ref:a.props.ref||a.ref)})(n),i=(function(a,u){const s={...u};for(const c in u){const l=a[c],d=u[c];/^on[A-Z]/.test(c)?l&&d?s[c]=(...p)=>{d(...p),l(...p)}:l&&(s[c]=l):c==="style"?s[c]={...l,...d}:c==="className"&&(s[c]=[l,d].filter(Boolean).join(" "))}return{...a,...s}})(r,n.props);return n.type!==h.Fragment&&(i.ref=t?vi(t,o):o),h.cloneElement(n,i)}return h.Children.count(n)>1?h.Children.only(null):null}));Ba.displayName="SlotClone";var ys=({children:e})=>v.jsx(v.Fragment,{children:e});function sv(e){return h.isValidElement(e)&&e.type===ys}const uv=h.forwardRef((({emoji:e,style:t,asChild:n,...r},o)=>{const i=n?Re:"span";return v.jsx(i,{role:"img","aria-label":e,"data-emoji":e,style:{...t,fontFamily:"'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1em",whiteSpace:"nowrap"},...r,ref:o,children:e})})),bs=h.forwardRef((({className:e,...t},n)=>v.jsx(uv,{className:Be("lb-emoji",e),...t,ref:n})));function Wi(e,t,n){return e===1?t:n??`${t}s`}const cv={locale:"en",dir:"ltr",USER_SELF:"you",USER_UNKNOWN:"Anonymous",LIST_REMAINING:e=>`${e} more`,LIST_REMAINING_USERS:e=>`${e} ${Wi(e,"other")}`,LIST_REMAINING_COMMENTS:e=>`${e} more ${Wi(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 ft(0,"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)=>v.jsxs(v.Fragment,{children:[e," reacted with ",v.jsx(bs,{emoji:t})]}),COMMENT_REACTION_DESCRIPTION:(e,t)=>`${t} ${Wi(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)=>v.jsxs(v.Fragment,{children:[e," commented",t?v.jsxs(v.Fragment,{children:[" in ",t]}):v.jsx(v.Fragment,{children:" in a thread"})]}),INBOX_NOTIFICATION_THREAD_MENTION:(e,t)=>v.jsxs(v.Fragment,{children:[e," mentioned you",t?v.jsxs(v.Fragment,{children:[" in ",t]}):null]}),INBOX_NOTIFICATION_TEXT_MENTION:(e,t)=>v.jsxs(v.Fragment,{children:[e," mentioned you",t?v.jsxs(v.Fragment,{children:[" in ",t]}):null]}),HISTORY_VERSION_PREVIEW_AUTHORS_LIST:e=>v.jsxs(v.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."},lv=h.createContext(void 0);function mt(e){const t=h.useContext(lv);return h.useMemo((()=>({...cv,...t,...e})),[t,e])}function qu(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ve(e){var t,n;return qu(e)!==!1&&((t=e.constructor)===void 0||qu(n=t.prototype)!==!1&&n.hasOwnProperty("isPrototypeOf")!==!1)}var dv={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=j.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},fv={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=Ee.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},hv={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=M.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Qo=new WeakMap,ei=new WeakMap,Rr=new WeakMap,Ku=new WeakMap,Gu=new WeakMap,Xu=new WeakMap,Zu=new WeakMap,j={ancestors(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=j.levels(e,t);return r=n?r.slice(1):r.slice(0,-1)},common(e,t){for(var n=[],r=0;r<e.length&&r<t.length;r++){var o=e[r];if(o!==t[r])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),i=e[n],a=t[n];return j.equals(r,o)&&i>a},endsAt(e,t){var n=e.length,r=e.slice(0,n),o=t.slice(0,n);return j.equals(r,o)},endsBefore(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),i=e[n],a=t[n];return j.equals(r,o)&&i<a},equals:(e,t)=>e.length===t.length&&e.every(((n,r)=>n===t[r])),hasPrevious:e=>e[e.length-1]>0,isAfter:(e,t)=>j.compare(e,t)===1,isAncestor:(e,t)=>e.length<t.length&&j.compare(e,t)===0,isBefore:(e,t)=>j.compare(e,t)===-1,isChild:(e,t)=>e.length===t.length+1&&j.compare(e,t)===0,isCommon:(e,t)=>e.length<=t.length&&j.compare(e,t)===0,isDescendant:(e,t)=>e.length>t.length&&j.compare(e,t)===0,isParent:(e,t)=>e.length+1===t.length&&j.compare(e,t)===0,isPath:e=>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);return e[e.length-1]!==t[t.length-1]&&j.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(!j.isAncestor(t,e)&&!j.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:i}=t;(j.equals(i,r)||j.endsBefore(i,r)||j.isAncestor(i,r))&&(r[i.length-1]+=1);break;case"remove_node":var{path:a}=t;if(j.equals(a,r)||j.isAncestor(a,r))return null;j.endsBefore(a,r)&&(r[a.length-1]-=1);break;case"merge_node":var{path:u,position:s}=t;j.equals(u,r)||j.endsBefore(u,r)?r[u.length-1]-=1:j.isAncestor(u,r)&&(r[u.length-1]-=1,r[u.length]+=s);break;case"split_node":var{path:c,position:l}=t;if(j.equals(c,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else j.endsBefore(c,r)?r[c.length-1]+=1:j.isAncestor(c,r)&&e[c.length]>=l&&(r[c.length-1]+=1,r[c.length]-=l);break;case"move_node":var{path:d,newPath:p}=t;if(j.equals(d,p))return r;if(j.isAncestor(d,r)||j.equals(d,r)){var m=p.slice();return j.endsBefore(d,p)&&d.length<p.length&&(m[d.length-1]-=1),m.concat(r.slice(d.length))}j.isSibling(d,p)&&(j.isAncestor(p,r)||j.equals(p,r))?j.endsBefore(d,r)?r[d.length-1]-=1:r[d.length-1]+=1:j.endsBefore(p,r)||j.equals(p,r)||j.isAncestor(p,r)?(j.endsBefore(d,r)&&(r[d.length-1]-=1),r[p.length-1]+=1):j.endsBefore(d,r)&&(j.equals(p,r)&&(r[p.length-1]+=1),r[d.length-1]-=1)}return r}};function _r(e){return _r=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},_r(e)}function pv(e){var t=(function(n,r){if(_r(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(_r(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return _r(t)==="symbol"?t:String(t)}function Je(e,t,n){return(t=pv(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yu(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 Dr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Yu(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yu(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var mv={transform(e,t){e.children=fu(e.children);var n=e.selection&&fu(e.selection);try{n=((r,o,i)=>{switch(i.type){case"insert_node":var{path:a,node:u}=i,s=te.parent(r,a),c=a[a.length-1];if(c>s.children.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(a,"] because the destination is past the end of the node."));if(s.children.splice(c,0,u),o)for(var[l,d]of M.points(o))o[d]=Ee.transform(l,i);break;case"insert_text":var{path:p,offset:m,text:g}=i;if(g.length===0)break;var y=te.leaf(r,p),f=y.text.slice(0,m),b=y.text.slice(m);if(y.text=f+g+b,o)for(var[C,D]of M.points(o))o[D]=Ee.transform(C,i);break;case"merge_node":var{path:E}=i,A=te.get(r,E),B=j.previous(E),O=te.get(r,B),S=te.parent(r,E),k=E[E.length-1];if(se.isText(A)&&se.isText(O))O.text+=A.text;else{if(se.isText(A)||se.isText(O))throw new Error('Cannot apply a "merge_node" operation at path ['.concat(E,"] to nodes of different interfaces: ").concat(He.stringify(A)," ").concat(He.stringify(O)));O.children.push(...A.children)}if(S.children.splice(k,1),o)for(var[T,F]of M.points(o))o[F]=Ee.transform(T,i);break;case"move_node":var{path:R,newPath:P}=i;if(j.isAncestor(R,P))throw new Error("Cannot move a path [".concat(R,"] to new path [").concat(P,"] because the destination is inside itself."));var H=te.get(r,R),G=te.parent(r,R),Z=R[R.length-1];G.children.splice(Z,1);var $=j.transform(R,i),W=te.get(r,j.parent($)),U=$[$.length-1];if(W.children.splice(U,0,H),o)for(var[J,X]of M.points(o))o[X]=Ee.transform(J,i);break;case"remove_node":var{path:ie}=i,de=ie[ie.length-1];if(te.parent(r,ie).children.splice(de,1),o)for(var[ee,pe]of M.points(o)){var I=Ee.transform(ee,i);if(o!=null&&I!=null)o[pe]=I;else{var N=void 0,_=void 0;for(var[K,oe]of te.texts(r)){if(j.compare(oe,ie)!==-1){_=[K,oe];break}N=[K,oe]}var Q=!1;N&&_&&(Q=j.equals(_[1],ie)?!j.hasPrevious(_[1]):j.common(N[1],ie).length<j.common(_[1],ie).length),N&&!Q?(ee.path=N[1],ee.offset=N[0].text.length):_?(ee.path=_[1],ee.offset=0):o=null}}break;case"remove_text":var{path:ue,offset:ce,text:he}=i;if(he.length===0)break;var be=te.leaf(r,ue),le=be.text.slice(0,ce),Ae=be.text.slice(ce+he.length);if(be.text=le+Ae,o)for(var[re,Ce]of M.points(o))o[Ce]=Ee.transform(re,i);break;case"set_node":var{path:x,properties:L,newProperties:V}=i;if(x.length===0)throw new Error("Cannot set properties on the root node!");var Y=te.get(r,x);for(var ne in V){if(ne==="children"||ne==="text")throw new Error('Cannot set the "'.concat(ne,'" property of nodes!'));var fe=V[ne];fe==null?delete Y[ne]:Y[ne]=fe}for(var xe in L)V.hasOwnProperty(xe)||delete Y[xe];break;case"set_selection":var{newProperties:De}=i;if(De==null)o=De;else{if(o==null){if(!M.isRange(De))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat(He.stringify(De)," when there is no current selection."));o=Dr({},De)}for(var Fe in De){var $e=De[Fe];if($e==null){if(Fe==="anchor"||Fe==="focus")throw new Error('Cannot remove the "'.concat(Fe,'" selection property'));delete o[Fe]}else o[Fe]=$e}}break;case"split_node":var{path:Se,position:Me,properties:xt}=i;if(Se.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(Se,"] because the root node cannot be split."));var ji,gn=te.get(r,Se),Mm=te.parent(r,Se),Lm=Se[Se.length-1];if(se.isText(gn)){var Um=gn.text.slice(0,Me),Vm=gn.text.slice(Me);gn.text=Um,ji=Dr(Dr({},xt),{},{text:Vm})}else{var Hm=gn.children.slice(0,Me),Wm=gn.children.slice(Me);gn.children=Hm,ji=Dr(Dr({},xt),{},{children:Wm})}if(Mm.children.splice(Lm+1,0,ji),o)for(var[zm,$m]of M.points(o))o[$m]=Ee.transform(zm,i)}return o})(e,n,t)}finally{e.children=hu(e.children),e.selection=n?Xm(n)?hu(n):n:null}}},gv={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)}},vv={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)}},tf=(e,t)=>{for(var n in e){var r=e[n],o=t[n];if(Ve(r)&&Ve(o)){if(!tf(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++)if(r[i]!==o[i])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 Kt(e,t){if(e==null)return{};var n,r,o=(function(a,u){if(a==null)return{};var s,c,l={},d=Object.keys(a);for(c=0;c<d.length;c++)s=d[c],u.indexOf(s)>=0||(l[s]=a[s]);return l})(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var yv=["anchor","focus"];function Ju(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}var M={edges(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,{anchor:r,focus:o}=e;return M.isBackward(e)===n?[r,o]:[o,r]},end(e){var[,t]=M.edges(e);return t},equals:(e,t)=>Ee.equals(e.anchor,t.anchor)&&Ee.equals(e.focus,t.focus),surrounds(e,t){var n=M.intersection(e,t);return!!n&&M.equals(n,t)},includes(e,t){if(M.isRange(t)){if(M.includes(e,t.anchor)||M.includes(e,t.focus))return!0;var[n,r]=M.edges(e),[o,i]=M.edges(t);return Ee.isBefore(n,o)&&Ee.isAfter(r,i)}var[a,u]=M.edges(e),s=!1,c=!1;return Ee.isPoint(t)?(s=Ee.compare(t,a)>=0,c=Ee.compare(t,u)<=0):(s=j.compare(t,a.path)>=0,c=j.compare(t,u.path)<=0),s&&c},intersection(e,t){var n=Kt(e,yv),[r,o]=M.edges(e),[i,a]=M.edges(t),u=Ee.isBefore(r,i)?i:r,s=Ee.isBefore(o,a)?o:a;return Ee.isBefore(s,u)?null:(function(c){for(var l=1;l<arguments.length;l++){var d=arguments[l]!=null?arguments[l]:{};l%2?Ju(Object(d),!0).forEach((function(p){Je(c,p,d[p])})):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(d)):Ju(Object(d)).forEach((function(p){Object.defineProperty(c,p,Object.getOwnPropertyDescriptor(d,p))}))}return c})({anchor:u,focus:s},n)},isBackward(e){var{anchor:t,focus:n}=e;return Ee.isAfter(t,n)},isCollapsed(e){var{anchor:t,focus:n}=e;return Ee.equals(t,n)},isExpanded:e=>!M.isCollapsed(e),isForward:e=>!M.isBackward(e),isRange:e=>Ve(e)&&Ee.isPoint(e.anchor)&&Ee.isPoint(e.focus),*points(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]},start(e){var[t]=M.edges(e);return t},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return ns(e,(r=>{if(r===null)return null;var o,i,{affinity:a="inward"}=n;if(a==="inward"){var u=M.isCollapsed(r);M.isForward(r)?(o="forward",i=u?o:"backward"):(o="backward",i=u?o:"forward")}else a==="outward"?M.isForward(r)?(o="backward",i="forward"):(o="forward",i="backward"):(o=a,i=a);var s=Ee.transform(r.anchor,t,{affinity:o}),c=Ee.transform(r.focus,t,{affinity:i});if(!s||!c)return null;r.anchor=s,r.focus=c}))}},Qu=e=>Ve(e)&&te.isNodeList(e.children)&&!w.isEditor(e),ae={isAncestor:e=>Ve(e)&&te.isNodeList(e.children),isElement:Qu,isElementList:e=>Array.isArray(e)&&e.every((t=>ae.isElement(t))),isElementProps:e=>e.children!==void 0,isElementType:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"type";return Qu(e)&&e[n]===t},matches(e,t){for(var n in t)if(n!=="children"&&e[n]!==t[n])return!1;return!0}},bv=["children"],wv=["text"],ec=new WeakMap,te={ancestor(e,t){var n=te.get(e,t);if(se.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(t,"] because it refers to a text node instead: ").concat(He.stringify(n)));return n},ancestors(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of j.ancestors(t,n)){var o=[te.ancestor(e,r),r];yield o}})()},child(e,t){if(se.isText(e))throw new Error("Cannot get the child of a text node: ".concat(He.stringify(e)));var n=e.children[t];if(n==null)throw new Error("Cannot get child at index `".concat(t,"` in node: ").concat(He.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=te.ancestor(e,t),{children:i}=o,a=r?i.length-1:0;r?a>=0:a<i.length;){var u=te.child(o,a),s=t.concat(a);yield[u,s],a=r?a-1:a+1}})()},common(e,t,n){var r=j.common(t,n);return[te.get(e,r),r]},descendant(e,t){var n=te.get(e,t);if(w.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(t,"] because it refers to the root editor node instead: ").concat(He.stringify(n)));return n},descendants(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of te.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 te.nodes(e,t))ae.isElement(n)&&(yield[n,r])})()},extractProps:e=>ae.isAncestor(e)?Kt(e,bv):Kt(e,wv),first(e,t){for(var n=t.slice(),r=te.get(e,n);r&&!se.isText(r)&&r.children.length!==0;)r=r.children[0],n.push(0);return[r,n]},fragment(e,t){if(se.isText(e))throw new Error("Cannot get a fragment starting from a root text node: ".concat(He.stringify(e)));var n=ns({children:e.children},(r=>{var[o,i]=M.edges(t),a=te.nodes(r,{reverse:!0,pass:p=>{var[,m]=p;return!M.includes(t,m)}});for(var[,u]of a){if(!M.includes(t,u)){var s=te.parent(r,u),c=u[u.length-1];s.children.splice(c,1)}if(j.equals(u,i.path)){var l=te.leaf(r,u);l.text=l.text.slice(0,i.offset)}if(j.equals(u,o.path)){var d=te.leaf(r,u);d.text=d.text.slice(o.offset)}}w.isEditor(r)&&(r.selection=null)}));return n.children},get(e,t){var n=te.getIf(e,t);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(t,"] in node: ").concat(He.stringify(e)));return n},getIf(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(se.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(se.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode:e=>se.isText(e)||ae.isElement(e)||w.isEditor(e),isNodeList(e){if(!Array.isArray(e))return!1;var t=ec.get(e);if(t!==void 0)return t;var n=e.every((r=>te.isNode(r)));return ec.set(e,n),n},last(e,t){for(var n=t.slice(),r=te.get(e,n);r&&!se.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=te.get(e,t);if(!se.isText(n))throw new Error("Cannot get the leaf node at path [".concat(t,"] because it refers to a non-leaf node: ").concat(He.stringify(n)));return n},levels(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of j.levels(t,n)){var o=te.get(e,r);yield[o,r]}})()},matches:(e,t)=>ae.isElement(e)&&ae.isElementProps(t)&&ae.matches(e,t)||se.isText(e)&&se.isTextProps(t)&&se.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:i}=t,a=new Set,u=[],s=e;!i||!(r?j.isBefore(u,i):j.isAfter(u,i));)if(a.has(s)||(yield[s,u]),a.has(s)||se.isText(s)||s.children.length===0||n!=null&&n([s,u])!==!1){if(u.length===0)break;if(!r){var c=j.next(u);if(te.has(e,c)){u=c,s=te.get(e,u);continue}}r&&u[u.length-1]!==0?(u=j.previous(u),s=te.get(e,u)):(u=j.parent(u),s=te.get(e,u),a.add(s))}else{a.add(s);var l=r?s.children.length-1:0;j.isAncestor(u,o)&&(l=o[u.length]),u=u.concat(l),s=te.get(e,u)}})()},parent(e,t){var n=j.parent(t),r=te.get(e,n);if(se.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=>se.isText(e)?e.text:e.children.map(te.string).join(""),texts(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of te.nodes(e,t))se.isText(n)&&(yield[n,r])})()}};function tc(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 Pe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?tc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var cn={isNodeOperation:e=>cn.isOperation(e)&&e.type.endsWith("_node"),isOperation(e){if(!Ve(e))return!1;switch(e.type){case"insert_node":case"remove_node":return j.isPath(e.path)&&te.isNode(e.node);case"insert_text":case"remove_text":return typeof e.offset=="number"&&typeof e.text=="string"&&j.isPath(e.path);case"merge_node":return typeof e.position=="number"&&j.isPath(e.path)&&Ve(e.properties);case"move_node":return j.isPath(e.path)&&j.isPath(e.newPath);case"set_node":return j.isPath(e.path)&&Ve(e.properties)&&Ve(e.newProperties);case"set_selection":return e.properties===null&&M.isRange(e.newProperties)||e.newProperties===null&&M.isRange(e.properties)||Ve(e.properties)&&Ve(e.newProperties);case"split_node":return j.isPath(e.path)&&typeof e.position=="number"&&Ve(e.properties);default:return!1}},isOperationList:e=>Array.isArray(e)&&e.every((t=>cn.isOperation(t))),isSelectionOperation:e=>cn.isOperation(e)&&e.type.endsWith("_selection"),isTextOperation:e=>cn.isOperation(e)&&e.type.endsWith("_text"),inverse(e){switch(e.type){case"insert_node":return Pe(Pe({},e),{},{type:"remove_node"});case"insert_text":return Pe(Pe({},e),{},{type:"remove_text"});case"merge_node":return Pe(Pe({},e),{},{type:"split_node",path:j.previous(e.path)});case"move_node":var{newPath:t,path:n}=e;if(j.equals(t,n))return e;if(j.isSibling(n,t))return Pe(Pe({},e),{},{path:t,newPath:n});var r=j.transform(n,e),o=j.transform(j.next(n),e);return Pe(Pe({},e),{},{path:r,newPath:o});case"remove_node":return Pe(Pe({},e),{},{type:"insert_node"});case"remove_text":return Pe(Pe({},e),{},{type:"insert_text"});case"set_node":var{properties:i,newProperties:a}=e;return Pe(Pe({},e),{},{properties:a,newProperties:i});case"set_selection":var{properties:u,newProperties:s}=e;return Pe(Pe({},e),{},u==null?{properties:s,newProperties:null}:s==null?{properties:null,newProperties:u}:{properties:s,newProperties:u});case"split_node":return Pe(Pe({},e),{},{type:"merge_node",path:j.next(e.path)})}}},nc=new WeakMap,w={above:(e,t)=>e.above(t),addMark(e,t,n){e.addMark(t,n)},after:(e,t,n)=>e.after(t,n),before:(e,t,n)=>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)=>e.edges(t),elementReadOnly(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.elementReadOnly(t)},end:(e,t)=>e.end(t),first:(e,t)=>e.first(t),fragment:(e,t)=>e.fragment(t),hasBlocks:(e,t)=>e.hasBlocks(t),hasInlines:(e,t)=>e.hasInlines(t),hasPath:(e,t)=>e.hasPath(t),hasTexts:(e,t)=>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)=>e.isBlock(t),isEdge:(e,t,n)=>e.isEdge(t,n),isEditor:e=>(t=>{var n=nc.get(t);if(n!==void 0)return n;if(!Ve(t))return!1;var r=typeof t.addMark=="function"&&typeof t.apply=="function"&&typeof t.deleteFragment=="function"&&typeof t.insertBreak=="function"&&typeof t.insertSoftBreak=="function"&&typeof t.insertFragment=="function"&&typeof t.insertNode=="function"&&typeof t.insertText=="function"&&typeof t.isElementReadOnly=="function"&&typeof t.isInline=="function"&&typeof t.isSelectable=="function"&&typeof t.isVoid=="function"&&typeof t.normalizeNode=="function"&&typeof t.onChange=="function"&&typeof t.removeMark=="function"&&typeof t.getDirtyPaths=="function"&&(t.marks===null||Ve(t.marks))&&(t.selection===null||M.isRange(t.selection))&&te.isNodeList(t.children)&&cn.isOperationList(t.operations);return nc.set(t,r),r})(e),isElementReadOnly:(e,t)=>e.isElementReadOnly(t),isEmpty:(e,t)=>e.isEmpty(t),isEnd:(e,t,n)=>e.isEnd(t,n),isInline:(e,t)=>e.isInline(t),isNormalizing:e=>e.isNormalizing(),isSelectable:(e,t)=>e.isSelectable(t),isStart:(e,t,n)=>e.isStart(t,n),isVoid:(e,t)=>e.isVoid(t),last:(e,t)=>e.last(t),leaf:(e,t,n)=>e.leaf(t,n),levels:(e,t)=>e.levels(t),marks:e=>e.getMarks(),next:(e,t)=>e.next(t),node:(e,t,n)=>e.node(t,n),nodes:(e,t)=>e.nodes(t),normalize(e,t){e.normalize(t)},parent:(e,t,n)=>e.parent(t,n),path:(e,t,n)=>e.path(t,n),pathRef:(e,t,n)=>e.pathRef(t,n),pathRefs:e=>e.pathRefs(),point:(e,t,n)=>e.point(t,n),pointRef:(e,t,n)=>e.pointRef(t,n),pointRefs:e=>e.pointRefs(),positions:(e,t)=>e.positions(t),previous:(e,t)=>e.previous(t),range:(e,t,n)=>e.range(t,n),rangeRef:(e,t,n)=>e.rangeRef(t,n),rangeRefs:e=>e.rangeRefs(),removeMark(e,t){e.removeMark(t)},setNormalizing(e,t){e.setNormalizing(t)},start:(e,t)=>e.start(t),string:(e,t,n)=>e.string(t,n),unhangRange:(e,t,n)=>e.unhangRange(t,n),void:(e,t)=>e.void(t),withoutNormalizing(e,t){e.withoutNormalizing(t)},shouldMergeNodesRemovePrevNode:(e,t,n)=>e.shouldMergeNodesRemovePrevNode(t,n)},Cv={isSpan:e=>Array.isArray(e)&&e.length===2&&e.every(j.isPath)};function rc(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 oc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?rc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Ee={compare(e,t){var n=j.compare(e.path,t.path);return n===0?e.offset<t.offset?-1:e.offset>t.offset?1:0:n},isAfter:(e,t)=>Ee.compare(e,t)===1,isBefore:(e,t)=>Ee.compare(e,t)===-1,equals:(e,t)=>e.offset===t.offset&&j.equals(e.path,t.path),isPoint:e=>Ve(e)&&typeof e.offset=="number"&&j.isPath(e.path),transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return ns(e,(r=>{if(r===null)return null;var{affinity:o="forward"}=n,{path:i,offset:a}=r;switch(t.type){case"insert_node":case"move_node":r.path=j.transform(i,t,n);break;case"insert_text":j.equals(t.path,i)&&(t.offset<a||t.offset===a&&o==="forward")&&(r.offset+=t.text.length);break;case"merge_node":j.equals(t.path,i)&&(r.offset+=t.position),r.path=j.transform(i,t,n);break;case"remove_text":j.equals(t.path,i)&&t.offset<=a&&(r.offset-=Math.min(a-t.offset,t.text.length));break;case"remove_node":if(j.equals(t.path,i)||j.isAncestor(t.path,i))return null;r.path=j.transform(i,t,n);break;case"split_node":if(j.equals(t.path,i)){if(t.position===a&&o==null)return null;(t.position<a||t.position===a&&o==="forward")&&(r.offset-=t.position,r.path=j.transform(i,t,oc(oc({},n),{},{affinity:"forward"})))}else r.path=j.transform(i,t,n)}}))}},ic=void 0,He={setScrubber(e){ic=e},stringify:e=>JSON.stringify(e,ic)},Dv=["text"],Ev=["anchor","focus"];function ac(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 Ht(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ac(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ac(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ve,se={equals(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(i){return Kt(i,Dv)}return tf(r?o(e):e,r?o(t):t)},isText:e=>Ve(e)&&typeof e.text=="string",isTextList:e=>Array.isArray(e)&&e.every((t=>se.isText(t))),isTextProps:e=>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=[Ht({},e)];for(var r of t){var o=Kt(r,Ev),[i,a]=M.edges(r),u=[],s=0,c=i.offset,l=a.offset;for(var d of n){var{length:p}=d.text,m=s;if(s+=p,c<=m&&s<=l)Object.assign(d,o),u.push(d);else if(c!==l&&(c===s||l===m)||c>s||l<m||l===m&&m!==0)u.push(d);else{var g=d,y=void 0,f=void 0;if(l<s){var b=l-m;f=Ht(Ht({},g),{},{text:g.text.slice(b)}),g=Ht(Ht({},g),{},{text:g.text.slice(0,b)})}if(c>m){var C=c-m;y=Ht(Ht({},g),{},{text:g.text.slice(0,C)}),g=Ht(Ht({},g),{},{text:g.text.slice(C)})}Object.assign(g,o),y&&u.push(y),u.push(g),f&&u.push(f)}}n=u}return n}},ws=e=>e.selection?e.selection:e.children.length>0?w.end(e,[]):[0],Un=(e,t)=>{var[n]=w.node(e,t);return r=>r===n},ka=function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=!t,r=t?kv(e):e,o=ve.None,i=ve.None,a=0,u=null;for(var s of r){var c=s.codePointAt(0);if(!c)break;var l=Uv(s,c);if([o,i]=n?[i,l]:[l,o],Gn(o,ve.ZWJ)&&Gn(i,ve.ExtPict)&&!zv(n?e.substring(0,a):e.substring(0,e.length-a))||Gn(o,ve.RI)&&Gn(i,ve.RI)&&!(u=u!==null?!u:!!n||qv(e.substring(0,e.length-a)))||o!==ve.None&&i!==ve.None&&Hv(o,i))break;a+=s.length}return a||1},Av=/\s/,xv=/[\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]/,Ov=/['\u2018\u2019]/,Sa=(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)]},Bv=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(Av.test(t))return!1;if(Ov.test(t)){var o=ka(n,r),[i,a]=Sa(n,o,r);if(e(i,a,r))return!0}return!xv.test(t)},kv=function*(e){for(var t=e.length-1,n=0;n<e.length;n++){var r=e.charAt(t-n);if(Iv(r.charCodeAt(0))){var o=e.charAt(t-n-1);if(Sv(o.charCodeAt(0))){yield o+r,n++;continue}}yield r}},Sv=e=>e>=55296&&e<=56319,Iv=e=>e>=56320&&e<=57343;(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"})(ve||(ve={}));var Fv=/^(?:[\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])$/,Tv=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,jv=/^(?:[\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])$/,Rv=/^[\u1100-\u115F\uA960-\uA97C]$/,_v=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,Nv=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,Pv=/^[\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]$/,Mv=/^[\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]$/,Lv=/^(?:[\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])$/,Uv=(e,t)=>{var n=ve.Any;return e.search(Fv)!==-1&&(n|=ve.Extend),t===8205&&(n|=ve.ZWJ),t>=127462&&t<=127487&&(n|=ve.RI),e.search(Tv)!==-1&&(n|=ve.Prepend),e.search(jv)!==-1&&(n|=ve.SpacingMark),e.search(Rv)!==-1&&(n|=ve.L),e.search(_v)!==-1&&(n|=ve.V),e.search(Nv)!==-1&&(n|=ve.T),e.search(Pv)!==-1&&(n|=ve.LV),e.search(Mv)!==-1&&(n|=ve.LVT),e.search(Lv)!==-1&&(n|=ve.ExtPict),n};function Gn(e,t){return!!(e&t)}var Vv=[[ve.L,ve.L|ve.V|ve.LV|ve.LVT],[ve.LV|ve.V,ve.V|ve.T],[ve.LVT|ve.T,ve.T],[ve.Any,ve.Extend|ve.ZWJ],[ve.Any,ve.SpacingMark],[ve.Prepend,ve.Any],[ve.ZWJ,ve.ExtPict],[ve.RI,ve.RI]];function Hv(e,t){return Vv.findIndex((n=>Gn(e,n[0])&&Gn(t,n[1])))===-1}var Wv=/(?:[\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$/,zv=e=>e.search(Wv)!==-1,$v=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,qv=e=>{var t=e.match($v);return t!==null&&t[0].length/2%2==1},Kv={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]:{};w.withoutNormalizing(e,(()=>{var{voids:r=!1}=n,{at:o=ws(e)}=n;if(j.isPath(o)&&(o=w.range(e,o)),M.isRange(o))if(M.isCollapsed(o))o=o.anchor;else{var i=M.end(o);if(!r&&w.void(e,{at:i}))return;var a=M.start(o),u=w.pointRef(e,a),s=w.pointRef(e,i);z.delete(e,{at:o,voids:r});var c=u.unref(),l=s.unref();o=c||l,z.setSelection(e,{anchor:o,focus:o})}if(!(!r&&w.void(e,{at:o})||w.elementReadOnly(e,{at:o}))){var{path:d,offset:p}=o;t.length>0&&e.apply({type:"insert_text",path:d,offset:p,text:t})}}))}};function sc(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 wo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?sc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var z=wo(wo(wo(wo({},mv),gv),vv),Kv),Po=new WeakMap;function nf(e,t,n){var r,o,i=Qo.get(e)||[],a=ei.get(e)||new Set,u=l=>{if(l){var d=l.join(",");o.has(d)||(o.add(d),r.push(l))}};if(n)for(var s of(r=[],o=new Set,i))u(n(s));else r=i,o=a;for(var c of t)u(c);Qo.set(e,r),ei.set(e,o)}var Gv=(e,t)=>{for(var n of w.pathRefs(e))dv.transform(n,t);for(var r of w.pointRefs(e))fv.transform(r,t);for(var o of w.rangeRefs(e))hv.transform(o,t);if(!(a=>Po.get(a)||!1)(e)){var i=j.operationCanTransformPath(t)?a=>j.transform(a,t):void 0;nf(e,e.getDirtyPaths(t),i)}z.transform(e,t),e.operations.push(t),w.normalize(e,{operation:t}),t.type==="set_selection"&&(e.marks=null),Rr.get(e)||(Rr.set(e,!0),Promise.resolve().then((()=>{Rr.set(e,!1),e.onChange({operation:t}),e.operations=[]})))};function uc(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 cc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?uc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function lc(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 dc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function fc(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 hc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?fc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function pc(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 mc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function gc(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 vc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function yc(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}var rf=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:r,marks:o}=e;if(r){if(o){var i=(function(a){for(var u=1;u<arguments.length;u++){var s=arguments[u]!=null?arguments[u]:{};u%2?yc(Object(s),!0).forEach((function(c){Je(a,c,s[c])})):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):yc(Object(s)).forEach((function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(s,c))}))}return a})({text:t},o);z.insertNodes(e,i,{at:n.at,voids:n.voids})}else z.insertText(e,t,n);e.marks=null}},Xv=["text"],Zv=["text"],Yv=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:n=!1,operation:r}=t,o=s=>Qo.get(s)||[],i=s=>{var c=o(s).pop(),l=c.join(",");return(d=>ei.get(d)||new Set)(s).delete(l),c};if(w.isNormalizing(e)){if(n){var a=Array.from(te.nodes(e),(s=>{var[,c]=s;return c})),u=new Set(a.map((s=>s.join(","))));Qo.set(e,a),ei.set(e,u)}o(e).length!==0&&w.withoutNormalizing(e,(()=>{for(var s of o(e))if(te.has(e,s)){var c=w.node(e,s),[l,d]=c;ae.isElement(l)&&l.children.length===0&&e.normalizeNode(c,{operation:r})}for(var p=o(e),m=p.length,g=0;p.length!==0;){if(!e.shouldNormalize({dirtyPaths:p,iteration:g,initialDirtyPathsLength:m,operation:r}))return;var y=i(e);if(te.has(e,y)){var f=w.node(e,y);e.normalizeNode(f,{operation:r})}g++,p=o(e)}}))}};function Jv(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:i=!1,ignoreNonSelectable:a=!1}=t;if(n){var u=w.range(e,n),[s,c]=M.edges(u),l=o?c:s,d=!1,p="",m=0,g=0,y=0;for(var[f,b]of w.nodes(e,{at:n,reverse:o,voids:i,ignoreNonSelectable:a})){if(ae.isElement(f)){if(!i&&(e.isVoid(f)||e.isElementReadOnly(f))){yield w.start(e,b);continue}if(e.isInline(f))continue;if(w.hasInlines(e,f)){var C=j.isAncestor(b,c.path)?c:w.end(e,b),D=j.isAncestor(b,s.path)?s:w.start(e,b);p=w.string(e,{anchor:D,focus:C},{voids:i}),d=!0}}if(se.isText(f)){var E=j.equals(b,l.path);for(E?(g=o?l.offset:f.text.length-l.offset,y=l.offset):(g=f.text.length,y=o?g:0),(E||d||r==="offset")&&(yield{path:b,offset:y},d=!1);;){if(m===0){if(p==="")break;m=A(p,r,o),p=Sa(p,m,o)[1]}if(y=o?y-m:y+m,(g-=m)<0){m=-g;break}m=0,yield{path:b,offset:y}}}}}function A(B,O,S){return O==="character"?ka(B,S):O==="word"?(function(k){for(var T=arguments.length>1&&arguments[1]!==void 0&&arguments[1],F=0,R=!1;k.length>0;){var P=ka(k,T),[H,G]=Sa(k,P,T);if(Bv(H,G,T))R=!0,F+=P;else{if(R)break;F+=P}k=G}return F})(B,S):O==="line"||O==="block"?B.length:1}})()}function bc(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}var Qv=(e,t)=>{var{selection:n}=e;if(n){var r=(l,d)=>{if(!se.isText(l))return!1;var[p,m]=w.parent(e,d);return!e.isVoid(p)||e.markableVoid(p)},o=M.isExpanded(n),i=!1;if(!o){var[a,u]=w.node(e,n);if(a&&r(a,u)){var[s]=w.parent(e,u);i=s&&e.markableVoid(s)}}if(o||i)z.unsetNodes(e,t,{match:r,split:!0,voids:!0});else{var c=(function(l){for(var d=1;d<arguments.length;d++){var p=arguments[d]!=null?arguments[d]:{};d%2?bc(Object(p),!0).forEach((function(m){Je(l,m,p[m])})):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(p)):bc(Object(p)).forEach((function(m){Object.defineProperty(l,m,Object.getOwnPropertyDescriptor(p,m))}))}return l})({},w.marks(e)||{});delete c[t],e.marks=c,Rr.get(e)||e.onChange()}}};function wc(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 Cc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?wc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var e0=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};w.withoutNormalizing(e,(()=>{var{hanging:r=!1,voids:o=!1,mode:i="lowest",batchDirty:a=!0}=n,{at:u,match:s,select:c}=n;if(te.isNode(t)&&(t=[t]),t.length!==0){var[l]=t;if(u||(u=ws(e),c!==!1&&(c=!0)),c==null&&(c=!1),M.isRange(u))if(r||(u=w.unhangRange(e,u,{voids:o})),M.isCollapsed(u))u=u.anchor;else{var[,d]=M.edges(u),p=w.pointRef(e,d);z.delete(e,{at:u}),u=p.unref()}if(Ee.isPoint(u)){s==null&&(s=se.isText(l)?k=>se.isText(k):e.isInline(l)?k=>se.isText(k)||w.isInline(e,k):k=>ae.isElement(k)&&w.isBlock(e,k));var[m]=w.nodes(e,{at:u.path,match:s,mode:i,voids:o});if(!m)return;var[,g]=m,y=w.pathRef(e,g),f=w.isEnd(e,u,g);z.splitNodes(e,{at:u,match:s,mode:i,voids:o});var b=y.unref();u=f?j.next(b):b}var C=j.parent(u),D=u[u.length-1];if(o||!w.void(e,{at:C})){if(a){var E=[],A=j.levels(C);((k,T,F)=>{var R=Po.get(k)||!1;Po.set(k,!0);try{T(),F()}finally{Po.set(k,R)}})(e,(()=>{var k=function(){var F=C.concat(D);D++;var R={type:"insert_node",path:F,node:T};e.apply(R),u=j.next(u),E.push(R),se.isText?A.push(...Array.from(te.nodes(T),(P=>{var[,H]=P;return F.concat(H)}))):A.push(F)};for(var T of t)k()}),(()=>{nf(e,A,(k=>{var T=k;for(var F of E)if(j.operationCanTransformPath(F)&&!(T=j.transform(T,F)))return null;return T}))}))}else for(var B of t){var O=C.concat(D);D++,e.apply({type:"insert_node",path:O,node:B}),u=j.next(u)}if(u=j.previous(u),c){var S=w.end(e,u);S&&z.select(e,S)}}}}))},t0=["text"],n0=["children"],of=(e,t)=>{if(ae.isElement(t)){var n=t;return!!w.isVoid(e,t)||n.children.length===1&&of(e,n.children[0])}return!w.isEditor(t)},r0=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w.withoutNormalizing(e,(()=>{var{mode:n="lowest",voids:r=!1}=t,{match:o,at:i=e.selection,height:a=0,always:u=!1}=t;if(o==null&&(o=G=>ae.isElement(G)&&w.isBlock(e,G)),M.isRange(i)&&(i=((G,Z)=>{if(M.isCollapsed(Z))return Z.anchor;var[,$]=M.edges(Z),W=w.pointRef(G,$);return z.delete(G,{at:Z}),W.unref()})(e,i)),j.isPath(i)){var s=i,c=w.point(e,s),[l]=w.parent(e,s);o=G=>G===l,a=c.path.length-s.length+1,i=c,u=!0}if(i){var d,p=w.pointRef(e,i,{affinity:"backward"});try{var[m]=w.nodes(e,{at:i,match:o,mode:n,voids:r});if(!m)return;var g=w.void(e,{at:i,mode:"highest"});if(!r&&g){var[y,f]=g;if(ae.isElement(y)&&e.isInline(y)){var b=w.after(e,f);if(!b){var C=j.next(f);z.insertNodes(e,{text:""},{at:C,voids:r}),b=w.point(e,C)}i=b,u=!0}a=i.path.length-f.length+1,u=!0}d=w.pointRef(e,i);var D=i.path.length-a,[,E]=m,A=i.path.slice(0,D),B=a===0?i.offset:i.path[D]+0;for(var[O,S]of w.levels(e,{at:A,reverse:!0,voids:r})){var k=!1;if(S.length<E.length||S.length===0||!r&&ae.isElement(O)&&w.isVoid(e,O))break;var T=p.current,F=w.isEnd(e,T,S);if(u||!p||!w.isEdge(e,T,S)){k=!0;var R=te.extractProps(O);e.apply({type:"split_node",path:S,position:B,properties:R})}B=S[S.length-1]+(k||F?1:0)}if(t.at==null){var P=d.current||w.end(e,[]);z.select(e,P)}}finally{var H;p.unref(),(H=d)===null||H===void 0||H.unref()}}}))};function Dc(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 Ec(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dc(Object(n),!0).forEach((function(r){Je(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dc(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var af=()=>{var e={children:[],operations:[],selection:null,marks:null,isElementReadOnly:()=>!1,isInline:()=>!1,isSelectable:()=>!0,isVoid:()=>!1,markableVoid:()=>!1,onChange:()=>{},apply:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Gv(e,...n)},addMark:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,a)=>{var{selection:u}=o;if(u){var s=(y,f)=>{if(!se.isText(y))return!1;var[b,C]=w.parent(o,f);return!o.isVoid(b)||o.markableVoid(b)},c=M.isExpanded(u),l=!1;if(!c){var[d,p]=w.node(o,u);if(d&&s(d,p)){var[m]=w.parent(o,p);l=m&&o.markableVoid(m)}}if(c||l)z.setNodes(o,{[i]:a},{match:s,split:!0,voids:!0});else{var g=cc(cc({},w.marks(o)||{}),{},{[i]:a});o.marks=g,Rr.get(o)||o.onChange()}}})(e,...n)},deleteBackward:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:a}=o;a&&M.isCollapsed(a)&&z.delete(o,{unit:i,reverse:!0})})(e,...n)},deleteForward:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:a}=o;a&&M.isCollapsed(a)&&z.delete(o,{unit:i})})(e,...n)},deleteFragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var{direction:i="forward"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:a}=o;a&&M.isExpanded(a)&&z.delete(o,{reverse:i==="backward"})})(e,...n)},getFragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var{selection:i}=o;return i?te.fragment(o,i):[]})(e,...n)},insertBreak:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{z.splitNodes(o,{always:!0})})(e,...n)},insertSoftBreak:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{z.splitNodes(o,{always:!0})})(e,...n)},insertFragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};w.withoutNormalizing(o,(()=>{var{hanging:u=!1,voids:s=!1}=a,{at:c=ws(o),batchDirty:l=!0}=a;if(i.length){if(M.isRange(c))if(u||(c=w.unhangRange(o,c,{voids:s})),M.isCollapsed(c))c=c.anchor;else{var[,d]=M.edges(c);if(!s&&w.void(o,{at:d}))return;var p=w.pointRef(o,d);z.delete(o,{at:c}),c=p.unref()}else j.isPath(c)&&(c=w.start(o,c));if(s||!w.void(o,{at:c})){var m=w.above(o,{at:c,match:I=>ae.isElement(I)&&w.isInline(o,I),mode:"highest",voids:s});if(m){var[,g]=m;w.isEnd(o,c,g)?c=w.after(o,g):w.isStart(o,c,g)&&(c=w.before(o,g))}var y=w.above(o,{match:I=>ae.isElement(I)&&w.isBlock(o,I),at:c,voids:s}),[,f]=y,b=w.isStart(o,c,f),C=w.isEnd(o,c,f),D=b&&C,E=!b||b&&C,A=!C,[,B]=te.first({children:i},[]),[,O]=te.last({children:i},[]),S=[],k=I=>{var[N,_]=I;return!(_.length===0||!D&&(E&&j.isAncestor(_,B)&&ae.isElement(N)&&!o.isVoid(N)&&!o.isInline(N)||A&&j.isAncestor(_,O)&&ae.isElement(N)&&!o.isVoid(N)&&!o.isInline(N)))};for(var T of te.nodes({children:i},{pass:k}))k(T)&&S.push(T);var F=[],R=[],P=[],H=!0,G=!1;for(var[Z]of S)ae.isElement(Z)&&!o.isInline(Z)?(H=!1,G=!0,R.push(Z)):H?F.push(Z):P.push(Z);var[$]=w.nodes(o,{at:c,match:I=>se.isText(I)||w.isInline(o,I),mode:"highest",voids:s}),[,W]=$,U=w.isStart(o,c,W),J=w.isEnd(o,c,W),X=w.pathRef(o,C&&!P.length?j.next(f):f),ie=w.pathRef(o,J?j.next(W):W);z.splitNodes(o,{at:c,match:I=>G?ae.isElement(I)&&w.isBlock(o,I):se.isText(I)||w.isInline(o,I),mode:G?"lowest":"highest",always:G&&(!b||F.length>0)&&(!C||P.length>0),voids:s});var de,ee=w.pathRef(o,!U||U&&J?j.next(W):W);if(z.insertNodes(o,F,{at:ee.current,match:I=>se.isText(I)||w.isInline(o,I),mode:"highest",voids:s,batchDirty:l}),D&&!F.length&&R.length&&!P.length&&z.delete(o,{at:f,voids:s}),z.insertNodes(o,R,{at:X.current,match:I=>ae.isElement(I)&&w.isBlock(o,I),mode:"lowest",voids:s,batchDirty:l}),z.insertNodes(o,P,{at:ie.current,match:I=>se.isText(I)||w.isInline(o,I),mode:"highest",voids:s,batchDirty:l}),!a.at&&(P.length>0&&ie.current?de=j.previous(ie.current):R.length>0&&X.current?de=j.previous(X.current):ee.current&&(de=j.previous(ee.current)),de)){var pe=w.end(o,de);z.select(o,pe)}ee.unref(),X.unref(),ie.unref()}}}))})(e,...n)},insertNode:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,a)=>{z.insertNodes(o,i,a)})(e,...n)},insertText:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return rf(e,...n)},normalizeNode:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var[a,u]=i;if(!se.isText(a))if(ae.isElement(a)&&a.children.length===0)z.insertNodes(o,{text:""},{at:u.concat(0),voids:!0});else for(var s=!w.isEditor(a)&&ae.isElement(a)&&(o.isInline(a)||a.children.length===0||se.isText(a.children[0])||o.isInline(a.children[0])),c=0,l=0;l<a.children.length;l++,c++){var d=te.get(o,u);if(!se.isText(d)){var p=d.children[c],m=d.children[c-1],g=l===a.children.length-1;(se.isText(p)||ae.isElement(p)&&o.isInline(p))!==s?(z.removeNodes(o,{at:u.concat(c),voids:!0}),c--):ae.isElement(p)?o.isInline(p)&&(m!=null&&se.isText(m)?g&&(z.insertNodes(o,{text:""},{at:u.concat(c+1),voids:!0}),c++):(z.insertNodes(o,{text:""},{at:u.concat(c),voids:!0}),c++)):(se.isText(p)||"children"in p||(p.children=[]),m!=null&&se.isText(m)&&(se.equals(p,m,{loose:!0})?(z.mergeNodes(o,{at:u.concat(c),voids:!0}),c--):m.text===""?(z.removeNodes(o,{at:u.concat(c-1),voids:!0}),c--):p.text===""&&(z.removeNodes(o,{at:u.concat(c),voids:!0}),c--)))}}})(e,...n)},removeMark:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Qv(e,...n)},getDirtyPaths:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{switch(i.type){case"insert_text":case"remove_text":case"set_node":var{path:a}=i;return j.levels(a);case"insert_node":var{node:u,path:s}=i,c=j.levels(s),l=se.isText(u)?[]:Array.from(te.nodes(u),(k=>{var[,T]=k;return s.concat(T)}));return[...c,...l];case"merge_node":var{path:d}=i;return[...j.ancestors(d),j.previous(d)];case"move_node":var{path:p,newPath:m}=i;if(j.equals(p,m))return[];var g=[],y=[];for(var f of j.ancestors(p)){var b=j.transform(f,i);g.push(b)}for(var C of j.ancestors(m)){var D=j.transform(C,i);y.push(D)}var E=y[y.length-1],A=m[m.length-1],B=E.concat(A);return[...g,...y,B];case"remove_node":var{path:O}=i;return[...j.ancestors(O)];case"split_node":var{path:S}=i;return[...j.levels(S),j.next(S)];default:return[]}})(e,...n)},shouldNormalize:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{iteration:a,initialDirtyPathsLength:u}=i,s=42*u;if(a>s)throw new Error("Could not completely normalize the editor after ".concat(s," iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));return!0})(e,...n)},above:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{voids:a=!1,mode:u="lowest",at:s=o.selection,match:c}=i;if(s){var l=w.path(o,s),d=u==="lowest";for(var[p,m]of w.levels(o,{at:l,voids:a,match:c,reverse:d}))if(!se.isText(p)){if(M.isRange(s)){if(j.isAncestor(m,s.anchor.path)&&j.isAncestor(m,s.focus.path))return[p,m]}else if(!j.equals(l,m))return[p,m]}}})(e,...n)},after:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s={anchor:w.point(o,i,{edge:"end"}),focus:w.end(o,[])},{distance:c=1}=u,l=0;for(var d of w.positions(o,dc(dc({},u),{},{at:s}))){if(l>c)break;l!==0&&(a=d),l++}return a})(e,...n)},before:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s={anchor:w.start(o,[]),focus:w.point(o,i,{edge:"start"})},{distance:c=1}=u,l=0;for(var d of w.positions(o,hc(hc({},u),{},{at:s,reverse:!0}))){if(l>c)break;l!==0&&(a=d),l++}return a})(e,...n)},collapse:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{edge:a="anchor"}=i,{selection:u}=o;if(u){if(a==="anchor")z.select(o,u.anchor);else if(a==="focus")z.select(o,u.focus);else if(a==="start"){var[s]=M.edges(u);z.select(o,s)}else if(a==="end"){var[,c]=M.edges(u);z.select(o,c)}}})(e,...n)},delete:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w.withoutNormalizing(o,(()=>{var a,u,{reverse:s=!1,unit:c="character",distance:l=1,voids:d=!1}=i,{at:p=o.selection,hanging:m=!1}=i;if(p){var g=!1;if(M.isRange(p)&&M.isCollapsed(p)&&(g=!0,p=p.anchor),Ee.isPoint(p)){var y=w.void(o,{at:p,mode:"highest"});if(!d&&y){var[,f]=y;p=f}else{var b={unit:c,distance:l};p={anchor:p,focus:s?w.before(o,p,b)||w.start(o,[]):w.after(o,p,b)||w.end(o,[])},m=!0}}if(j.isPath(p))z.removeNodes(o,{at:p,voids:d});else if(!M.isCollapsed(p)){if(!m){var[,C]=M.edges(p),D=w.end(o,[]);Ee.equals(C,D)||(p=w.unhangRange(o,p,{voids:d}))}var[E,A]=M.edges(p),B=w.above(o,{match:le=>ae.isElement(le)&&w.isBlock(o,le),at:E,voids:d}),O=w.above(o,{match:le=>ae.isElement(le)&&w.isBlock(o,le),at:A,voids:d}),S=B&&O&&!j.equals(B[1],O[1]),k=j.equals(E.path,A.path),T=d?null:(a=w.void(o,{at:E,mode:"highest"}))!==null&&a!==void 0?a:w.elementReadOnly(o,{at:E,mode:"highest"}),F=d?null:(u=w.void(o,{at:A,mode:"highest"}))!==null&&u!==void 0?u:w.elementReadOnly(o,{at:A,mode:"highest"});if(T){var R=w.before(o,E);R&&B&&j.isAncestor(B[1],R.path)&&(E=R)}if(F){var P=w.after(o,A);P&&O&&j.isAncestor(O[1],P.path)&&(A=P)}var H,G=[];for(var Z of w.nodes(o,{at:p,voids:d})){var[$,W]=Z;H&&j.compare(W,H)===0||(!d&&ae.isElement($)&&(w.isVoid(o,$)||w.isElementReadOnly(o,$))||!j.isCommon(W,E.path)&&!j.isCommon(W,A.path))&&(G.push(Z),H=W)}var U=Array.from(G,(le=>{var[,Ae]=le;return w.pathRef(o,Ae)})),J=w.pointRef(o,E),X=w.pointRef(o,A),ie="";if(!k&&!T){var de=J.current,[ee]=w.leaf(o,de),{path:pe}=de,{offset:I}=E,N=ee.text.slice(I);N.length>0&&(o.apply({type:"remove_text",path:pe,offset:I,text:N}),ie=N)}if(U.reverse().map((le=>le.unref())).filter((le=>le!==null)).forEach((le=>z.removeNodes(o,{at:le,voids:d}))),!F){var _=X.current,[K]=w.leaf(o,_),{path:oe}=_,Q=k?E.offset:0,ue=K.text.slice(Q,A.offset);ue.length>0&&(o.apply({type:"remove_text",path:oe,offset:Q,text:ue}),ie=ue)}!k&&S&&X.current&&J.current&&z.mergeNodes(o,{at:X.current,hanging:!0,voids:d}),g&&s&&c==="character"&&ie.length>1&&ie.match(/[\u0E00-\u0E7F]+/)&&z.insertText(o,ie.slice(0,ie.length-l));var ce=J.unref(),he=X.unref(),be=s?ce||he:he||ce;i.at==null&&be&&z.select(o,be)}}}))})(e,...n)},deselect:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var{selection:i}=o;i&&o.apply({type:"set_selection",properties:i,newProperties:null})})(e,...n)},edges:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>[w.start(o,i),w.end(o,i)])(e,...n)},elementReadOnly:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return w.above(o,mc(mc({},i),{},{match:a=>ae.isElement(a)&&w.isElementReadOnly(o,a)}))})(e,...n)},end:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>w.point(o,i,{edge:"end"}))(e,...n)},first:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var a=w.path(o,i,{edge:"start"});return w.node(o,a)})(e,...n)},fragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var a=w.range(o,i);return te.fragment(o,a)})(e,...n)},getMarks:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var{marks:i,selection:a}=o;if(!a)return null;var{anchor:u,focus:s}=a;if(i)return i;if(M.isExpanded(a)){if(M.isBackward(a)&&([s,u]=[u,s]),w.isEnd(o,u,u.path)){var c=w.after(o,u);c&&(u=c)}var[l]=w.nodes(o,{match:se.isText,at:{anchor:u,focus:s}});if(l){var[d]=l;return Kt(d,Xv)}return{}}var{path:p}=u,[m]=w.leaf(o,p);if(u.offset===0){var g=w.previous(o,{at:p,match:se.isText}),y=w.above(o,{match:E=>ae.isElement(E)&&w.isVoid(o,E)&&o.markableVoid(E)});if(!y){var f=w.above(o,{match:E=>ae.isElement(E)&&w.isBlock(o,E)});if(g&&f){var[b,C]=g,[,D]=f;j.isAncestor(D,C)&&(m=b)}}}return Kt(m,Zv)})(e,...n)},hasBlocks:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>i.children.some((a=>ae.isElement(a)&&w.isBlock(o,a))))(e,...n)},hasInlines:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>i.children.some((a=>se.isText(a)||w.isInline(o,a))))(e,...n)},hasPath:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>te.has(o,i))(e,...n)},hasTexts:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>i.children.every((a=>se.isText(a))))(e,...n)},insertNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e0(e,...n)},isBlock:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>!o.isInline(i))(e,...n)},isEdge:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,a)=>w.isStart(o,i,a)||w.isEnd(o,i,a))(e,...n)},isEmpty:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{children:a}=i,[u]=a;return a.length===0||a.length===1&&se.isText(u)&&u.text===""&&!o.isVoid(i)})(e,...n)},isEnd:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,a)=>{var u=w.end(o,a);return Ee.equals(i,u)})(e,...n)},isNormalizing:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Ku.get(o);return i===void 0||i})(e,...n)},isStart:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,a)=>{if(i.offset!==0)return!1;var u=w.start(o,a);return Ee.equals(i,u)})(e,...n)},last:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var a=w.path(o,i,{edge:"end"});return w.node(o,a)})(e,...n)},leaf:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=w.path(o,i,a);return[te.leaf(o,u),u]})(e,...n)},levels:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:a=o.selection,reverse:u=!1,voids:s=!1}=i,{match:c}=i;if(c==null&&(c=()=>!0),a){var l=[],d=w.path(o,a);for(var[p,m]of te.levels(o,d))if(c(p,m)&&(l.push([p,m]),!s&&ae.isElement(p)&&w.isVoid(o,p)))break;u&&l.reverse(),yield*l}})()})(e,...n)},liftNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w.withoutNormalizing(o,(()=>{var{at:a=o.selection,mode:u="lowest",voids:s=!1}=i,{match:c}=i;if(c==null&&(c=j.isPath(a)?Un(o,a):O=>ae.isElement(O)&&w.isBlock(o,O)),a){var l=w.nodes(o,{at:a,match:c,mode:u,voids:s}),d=Array.from(l,(O=>{var[,S]=O;return w.pathRef(o,S)}));for(var p of d){var m=p.unref();if(m.length<2)throw new Error("Cannot lift node at a path [".concat(m,"] because it has a depth of less than `2`."));var g=w.node(o,j.parent(m)),[y,f]=g,b=m[m.length-1],{length:C}=y.children;if(C===1){var D=j.next(f);z.moveNodes(o,{at:m,to:D,voids:s}),z.removeNodes(o,{at:f,voids:s})}else if(b===0)z.moveNodes(o,{at:m,to:f,voids:s});else if(b===C-1){var E=j.next(f);z.moveNodes(o,{at:m,to:E,voids:s})}else{var A=j.next(m),B=j.next(f);z.splitNodes(o,{at:A,voids:s}),z.moveNodes(o,{at:m,to:B,voids:s})}}}}))})(e,...n)},mergeNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w.withoutNormalizing(o,(()=>{var{match:a,at:u=o.selection}=i,{hanging:s=!1,voids:c=!1,mode:l="lowest"}=i;if(u){if(a==null)if(j.isPath(u)){var[d]=w.parent(o,u);a=P=>d.children.includes(P)}else a=P=>ae.isElement(P)&&w.isBlock(o,P);if(!s&&M.isRange(u)&&(u=w.unhangRange(o,u,{voids:c})),M.isRange(u))if(M.isCollapsed(u))u=u.anchor;else{var[,p]=M.edges(u),m=w.pointRef(o,p);z.delete(o,{at:u}),u=m.unref(),i.at==null&&z.select(o,u)}var[g]=w.nodes(o,{at:u,match:a,voids:c,mode:l}),y=w.previous(o,{at:u,match:a,voids:c,mode:l});if(g&&y){var[f,b]=g,[C,D]=y;if(b.length!==0&&D.length!==0){var E,A,B=j.next(D),O=j.common(b,D),S=j.isSibling(b,D),k=Array.from(w.levels(o,{at:b}),(P=>{var[H]=P;return H})).slice(O.length).slice(0,-1),T=w.above(o,{at:b,mode:"highest",match:P=>k.includes(P)&&of(o,P)}),F=T&&w.pathRef(o,T[1]);if(se.isText(f)&&se.isText(C)){var R=Kt(f,t0);A=C.text.length,E=R}else{if(!ae.isElement(f)||!ae.isElement(C))throw new Error("Cannot merge the node at path [".concat(b,"] with the previous sibling because it is not the same kind: ").concat(He.stringify(f)," ").concat(He.stringify(C)));R=Kt(f,n0),A=C.children.length,E=R}S||z.moveNodes(o,{at:b,to:B,voids:c}),F&&z.removeNodes(o,{at:F.current,voids:c}),w.shouldMergeNodesRemovePrevNode(o,y,g)?z.removeNodes(o,{at:D,voids:c}):o.apply({type:"merge_node",path:B,position:A,properties:E}),F&&F.unref()}}}}))})(e,...n)},move:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:a}=o,{distance:u=1,unit:s="character",reverse:c=!1}=i,{edge:l=null}=i;if(a){l==="start"&&(l=M.isBackward(a)?"focus":"anchor"),l==="end"&&(l=M.isBackward(a)?"anchor":"focus");var{anchor:d,focus:p}=a,m={distance:u,unit:s,ignoreNonSelectable:!0},g={};if(l==null||l==="anchor"){var y=c?w.before(o,d,m):w.after(o,d,m);y&&(g.anchor=y)}if(l==null||l==="focus"){var f=c?w.before(o,p,m):w.after(o,p,m);f&&(g.focus=f)}z.setSelection(o,g)}})(e,...n)},moveNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{w.withoutNormalizing(o,(()=>{var{to:a,at:u=o.selection,mode:s="lowest",voids:c=!1}=i,{match:l}=i;if(u){l==null&&(l=j.isPath(u)?Un(o,u):b=>ae.isElement(b)&&w.isBlock(o,b));var d=w.pathRef(o,a),p=w.nodes(o,{at:u,match:l,mode:s,voids:c}),m=Array.from(p,(b=>{var[,C]=b;return w.pathRef(o,C)}));for(var g of m){var y=g.unref(),f=d.current;y.length!==0&&o.apply({type:"move_node",path:y,newPath:f}),d.current&&j.isSibling(f,y)&&j.isAfter(f,y)&&(d.current=j.next(d.current))}d.unref()}}))})(e,...n)},next:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:a="lowest",voids:u=!1}=i,{match:s,at:c=o.selection}=i;if(c){var l=w.after(o,c,{voids:u});if(l){var[,d]=w.last(o,[]),p=[l.path,d];if(j.isPath(c)&&c.length===0)throw new Error("Cannot get the next node from the root node!");if(s==null)if(j.isPath(c)){var[m]=w.parent(o,c);s=y=>m.children.includes(y)}else s=()=>!0;var[g]=w.nodes(o,{at:p,match:s,mode:a,voids:u});return g}}})(e,...n)},node:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=w.path(o,i,a),s=te.get(o,u);return[s,u]})(e,...n)},nodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:a=o.selection,mode:u="all",universal:s=!1,reverse:c=!1,voids:l=!1,ignoreNonSelectable:d=!1}=i,{match:p}=i;if(p||(p=()=>!0),a){var m,g;if(Cv.isSpan(a))m=a[0],g=a[1];else{var y=w.path(o,a,{edge:"start"}),f=w.path(o,a,{edge:"end"});m=c?f:y,g=c?y:f}var b,C=te.nodes(o,{reverse:c,from:m,to:g,pass:S=>{var[k]=S;return!(!ae.isElement(k)||(l||!w.isVoid(o,k)&&!w.isElementReadOnly(o,k))&&(!d||w.isSelectable(o,k)))}}),D=[];for(var[E,A]of C)if(!d||!ae.isElement(E)||w.isSelectable(o,E)){var B=b&&j.compare(A,b[1])===0;if(u!=="highest"||!B){if(p(E,A))if(u==="lowest"&&B)b=[E,A];else{var O=u==="lowest"?b:[E,A];O&&(s?D.push(O):yield O),b=[E,A]}else if(s&&!B&&se.isText(E))return}}u==="lowest"&&b&&(s?D.push(b):yield b),s&&(yield*D)}})()})(e,...n)},normalize:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Yv(e,...n)},parent:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=w.path(o,i,a),s=j.parent(u);return w.node(o,s)})(e,...n)},path:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:u,edge:s}=a;if(j.isPath(i)){if(s==="start"){var[,c]=te.first(o,i);i=c}else if(s==="end"){var[,l]=te.last(o,i);i=l}}return M.isRange(i)&&(i=s==="start"?M.start(i):s==="end"?M.end(i):j.common(i.anchor.path,i.focus.path)),Ee.isPoint(i)&&(i=i.path),u!=null&&(i=i.slice(0,u)),i})(e,...n)},pathRef:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:u="forward"}=a,s={current:i,affinity:u,unref(){var{current:c}=s;return w.pathRefs(o).delete(s),s.current=null,c}};return w.pathRefs(o).add(s),s})(e,...n)},pathRefs:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Gu.get(o);return i||(i=new Set,Gu.set(o,i)),i})(e,...n)},point:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:u="start"}=a;if(j.isPath(i)){var s;if(u==="end"){var[,c]=te.last(o,i);s=c}else{var[,l]=te.first(o,i);s=l}var d=te.get(o,s);if(!se.isText(d))throw new Error("Cannot get the ".concat(u," point in the node at path [").concat(i,"] because it has no ").concat(u," text node."));return{path:s,offset:u==="end"?d.text.length:0}}if(M.isRange(i)){var[p,m]=M.edges(i);return u==="start"?p:m}return i})(e,...n)},pointRef:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:u="forward"}=a,s={current:i,affinity:u,unref(){var{current:c}=s;return w.pointRefs(o).delete(s),s.current=null,c}};return w.pointRefs(o).add(s),s})(e,...n)},pointRefs:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Xu.get(o);return i||(i=new Set,Xu.set(o,i)),i})(e,...n)},positions:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Jv(e,...n)},previous:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:a="lowest",voids:u=!1}=i,{match:s,at:c=o.selection}=i;if(c){var l=w.before(o,c,{voids:u});if(l){var[,d]=w.first(o,[]),p=[l.path,d];if(j.isPath(c)&&c.length===0)throw new Error("Cannot get the previous node from the root node!");if(s==null)if(j.isPath(c)){var[m]=w.parent(o,c);s=y=>m.children.includes(y)}else s=()=>!0;var[g]=w.nodes(o,{reverse:!0,at:p,match:s,mode:a,voids:u});return g}}})(e,...n)},range:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,a)=>M.isRange(i)&&!a?i:{anchor:w.start(o,i),focus:w.end(o,a||i)})(e,...n)},rangeRef:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:u="forward"}=a,s={current:i,affinity:u,unref(){var{current:c}=s;return w.rangeRefs(o).delete(s),s.current=null,c}};return w.rangeRefs(o).add(s),s})(e,...n)},rangeRefs:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Zu.get(o);return i||(i=new Set,Zu.set(o,i)),i})(e,...n)},removeNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w.withoutNormalizing(o,(()=>{var{hanging:a=!1,voids:u=!1,mode:s="lowest"}=i,{at:c=o.selection,match:l}=i;if(c){l==null&&(l=j.isPath(c)?Un(o,c):f=>ae.isElement(f)&&w.isBlock(o,f)),!a&&M.isRange(c)&&(c=w.unhangRange(o,c,{voids:u}));var d=w.nodes(o,{at:c,match:l,mode:s,voids:u}),p=Array.from(d,(f=>{var[,b]=f;return w.pathRef(o,b)}));for(var m of p){var g=m.unref();if(g){var[y]=w.node(o,g);o.apply({type:"remove_node",path:g,node:y})}}}}))})(e,...n)},select:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:a}=o;if(i=w.range(o,i),a)z.setSelection(o,i);else{if(!M.isRange(i))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(He.stringify(i)));o.apply({type:"set_selection",properties:a,newProperties:i})}})(e,...n)},setNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};w.withoutNormalizing(o,(()=>{var{match:u,at:s=o.selection,compare:c,merge:l}=a,{hanging:d=!1,mode:p="lowest",split:m=!1,voids:g=!1}=a;if(s){if(u==null&&(u=j.isPath(s)?Un(o,s):F=>ae.isElement(F)&&w.isBlock(o,F)),!d&&M.isRange(s)&&(s=w.unhangRange(o,s,{voids:g})),m&&M.isRange(s)){if(M.isCollapsed(s)&&w.leaf(o,s.anchor)[0].text.length>0)return;var y=w.rangeRef(o,s,{affinity:"inward"}),[f,b]=M.edges(s),C=p==="lowest"?"lowest":"highest",D=w.isEnd(o,b,b.path);z.splitNodes(o,{at:b,match:u,mode:C,voids:g,always:!D});var E=w.isStart(o,f,f.path);z.splitNodes(o,{at:f,match:u,mode:C,voids:g,always:!E}),s=y.unref(),a.at==null&&z.select(o,s)}for(var[A,B]of(c||(c=(F,R)=>F!==R),w.nodes(o,{at:s,match:u,mode:p,voids:g}))){var O={},S={};if(B.length!==0){var k=!1;for(var T in i)T!=="children"&&T!=="text"&&c(i[T],A[T])&&(k=!0,A.hasOwnProperty(T)&&(O[T]=A[T]),l?i[T]!=null&&(S[T]=l(A[T],i[T])):i[T]!=null&&(S[T]=i[T]));k&&o.apply({type:"set_node",path:B,properties:O,newProperties:S})}}}}))})(e,...n)},setNormalizing:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{Ku.set(o,i)})(e,...n)},setPoint:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:u}=o,{edge:s="both"}=a;if(u){s==="start"&&(s=M.isBackward(u)?"focus":"anchor"),s==="end"&&(s=M.isBackward(u)?"anchor":"focus");var{anchor:c,focus:l}=u,d=s==="anchor"?c:l;z.setSelection(o,{[s==="anchor"?"anchor":"focus"]:Cc(Cc({},d),i)})}})(e,...n)},setSelection:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:a}=o,u={},s={};if(a){for(var c in i)(c==="anchor"&&i.anchor!=null&&!Ee.equals(i.anchor,a.anchor)||c==="focus"&&i.focus!=null&&!Ee.equals(i.focus,a.focus)||c!=="anchor"&&c!=="focus"&&i[c]!==a[c])&&(u[c]=a[c],s[c]=i[c]);Object.keys(u).length>0&&o.apply({type:"set_selection",properties:u,newProperties:s})}})(e,...n)},splitNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return r0(e,...n)},start:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>w.point(o,i,{edge:"start"}))(e,...n)},string:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:u=!1}=a,s=w.range(o,i),[c,l]=M.edges(s),d="";for(var[p,m]of w.nodes(o,{at:s,match:se.isText,voids:u})){var g=p.text;j.equals(m,l.path)&&(g=g.slice(0,l.offset)),j.equals(m,c.path)&&(g=g.slice(c.offset)),d+=g}return d})(e,...n)},unhangRange:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:u=!1}=a,[s,c]=M.edges(i);if(s.offset!==0||c.offset!==0||M.isCollapsed(i)||j.hasPrevious(c.path))return i;var l=w.above(o,{at:c,match:f=>ae.isElement(f)&&w.isBlock(o,f),voids:u}),d=l?l[1]:[],p={anchor:w.start(o,s),focus:c},m=!0;for(var[g,y]of w.nodes(o,{at:p,match:se.isText,reverse:!0,voids:u}))if(m)m=!1;else if(g.text!==""||j.isBefore(y,d)){c={path:y,offset:g.text.length};break}return{anchor:s,focus:c}})(e,...n)},unsetNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(i)||(i=[i]);var u={};for(var s of i)u[s]=null;z.setNodes(o,u,a)})(e,...n)},unwrapNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};w.withoutNormalizing(o,(()=>{var{mode:a="lowest",split:u=!1,voids:s=!1}=i,{at:c=o.selection,match:l}=i;if(c){l==null&&(l=j.isPath(c)?Un(o,c):f=>ae.isElement(f)&&w.isBlock(o,f)),j.isPath(c)&&(c=w.range(o,c));var d=M.isRange(c)?w.rangeRef(o,c):null,p=w.nodes(o,{at:c,match:l,mode:a,voids:s}),m=Array.from(p,(f=>{var[,b]=f;return w.pathRef(o,b)})).reverse(),g=function(){var f=y.unref(),[b]=w.node(o,f),C=w.range(o,f);u&&d&&(C=M.intersection(d.current,C)),z.liftNodes(o,{at:C,match:D=>ae.isAncestor(b)&&b.children.includes(D),voids:s})};for(var y of m)g();d&&d.unref()}}))})(e,...n)},void:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return w.above(o,vc(vc({},i),{},{match:a=>ae.isElement(a)&&w.isVoid(o,a)}))})(e,...n)},withoutNormalizing:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var a=w.isNormalizing(o);w.setNormalizing(o,!1);try{i()}finally{w.setNormalizing(o,a)}w.normalize(o)})(e,...n)},wrapNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};w.withoutNormalizing(o,(()=>{var{mode:u="lowest",split:s=!1,voids:c=!1}=a,{match:l,at:d=o.selection}=a;if(d){if(l==null&&(l=j.isPath(d)?Un(o,d):o.isInline(i)?C=>ae.isElement(C)&&w.isInline(o,C)||se.isText(C):C=>ae.isElement(C)&&w.isBlock(o,C)),s&&M.isRange(d)){var[p,m]=M.edges(d),g=w.rangeRef(o,d,{affinity:"inward"});z.splitNodes(o,{at:m,match:l,voids:c}),z.splitNodes(o,{at:p,match:l,voids:c}),d=g.unref(),a.at==null&&z.select(o,d)}var y=Array.from(w.nodes(o,{at:d,match:o.isInline(i)?C=>ae.isElement(C)&&w.isBlock(o,C):C=>w.isEditor(C),mode:"lowest",voids:c})),f=function(){var C=M.isRange(d)?M.intersection(d,w.range(o,b)):d;if(!C)return 0;var D=Array.from(w.nodes(o,{at:C,match:l,mode:u,voids:c}));if(D.length>0){var[E]=D,A=D[D.length-1],[,B]=E,[,O]=A;if(B.length===0&&O.length===0)return 0;var S=j.equals(B,O)?j.parent(B):j.common(B,O),k=w.range(o,B,O),T=w.node(o,S),[F]=T,R=S.length+1,P=j.next(O.slice(0,R)),H=Ec(Ec({},i),{},{children:[]});z.insertNodes(o,H,{at:P,voids:c}),z.moveNodes(o,{at:k,match:G=>ae.isAncestor(F)&&F.children.includes(G),to:P.concat(0),voids:c})}};for(var[,b]of y)f()}}))})(e,...n)},shouldMergeNodesRemovePrevNode:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var[a,u]=i;return ae.isElement(a)&&w.isEmpty(o,a)||se.isText(a)&&a.text===""&&u[u.length-1]!==0})(e,...n)}};return e};function zr(e,t,n={}){const{filterVoids:r}=n,o=w.before(e,t,{unit:"character",voids:r});if(o){const i=w.range(e,o,M.isRange(t)?M.start(t):t),a=w.string(e,i);return{range:i,text:a,void:a.length===0}}}function Cs(e,t,n={}){const{filterVoids:r}=n,o=w.after(e,t,{unit:"character",voids:r});if(o){const i=w.range(e,o,M.isRange(t)?M.end(t):t),a=w.string(e,i);return{range:i,text:a,void:a.length===0}}}const o0=/\s/;function ti(e){return!!e&&o0.test(e)}const Ac={direction:"before",allowConsecutiveWhitespace:!0};function sf(e,t,n=[" "],r=Ac){const{include:o,direction:i,ignoreTerminator:a,allowConsecutiveWhitespace:u}={...Ac,...r};let[s,c]=M.edges(t),l=s,d=!1;function p(m){const g=m==="after"?w.after(e,l,{unit:"character"}):w.before(e,l,{unit:"character"});if(!g||j.compare(g.path,l.path)!==0)return!1;const y=g&&w.string(e,m==="after"?{anchor:l,focus:g}:{anchor:g,focus:l}),f=y&&y[m==="after"?0:y.length-1];return!(!u&&d&&ti(f))&&!(!g||!f||n.includes(f)&&!a?.(f,g,m))&&(d=ti(f),l=g,l.offset!==0)}if(i!=="before"){for(l=c;p("after"););c=l}if(i!=="after"){for(l=s;p("before"););s=l}return o?{anchor:i==="before"||i==="both"?w.before(e,s,{unit:"offset"})??s:s,focus:i==="after"||i==="both"?w.after(e,c,{unit:"offset"})??c:c}:{anchor:s,focus:c}}function ar(e){return!e.trim()}const fn="@";function Or(e){return ae.isElement(e)&&e.type==="mention"}function uf(e){return"type"in e&&e.type==="mention"}function cf(e){return"type"in e&&e.type==="link"}function lf(e){return e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("www.")?"https://"+e:void 0}const df=h.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?Re:"span";return v.jsx(o,{...n,ref:r,children:e})})),ff=h.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?Re:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),i0={Mention:({userId:e})=>v.jsxs(df,{children:[fn,e]}),Link:({href:e,children:t})=>v.jsx(ff,{href:e,children:t})},a0=h.forwardRef((({body:e,components:t,style:n,asChild:r,...o},i)=>{const a=r?Re:"div",{Mention:u,Link:s}=h.useMemo((()=>({...i0,...t})),[t]);return e&&e?.content?v.jsx(a,{...o,style:{whiteSpace:"break-spaces",...n},ref:i,children:e.content.map(((c,l)=>c.type==="paragraph"?v.jsx("p",{style:{minHeight:"1lh"},children:c.children.map(((d,p)=>{if(uf(d))return d.id?v.jsx(u,{userId:d.id},p):null;if(cf(d)){const g=lf(d.url)??d.url;return v.jsx(s,{href:g,children:d.text??d.url},p)}let m=d.text;return d.bold&&(m=v.jsx("strong",{children:m},p)),d.italic&&(m=v.jsx("em",{children:m},p)),d.strikethrough&&(m=v.jsx("s",{children:m},p)),d.code&&(m=v.jsx("code",{children:m},p)),v.jsx("span",{children:m},p)}))},l):null))}):null}));var zi,xc,s0={isHistory:e=>Ve(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||cn.isOperationList(e.redos[0].operations))&&(e.undos.length===0||cn.isOperationList(e.undos[0].operations))},$i=new WeakMap,wn=new WeakMap,Co=new WeakMap,St={isHistoryEditor:e=>s0.isHistory(e.history)&&w.isEditor(e),isMerging:e=>wn.get(e),isSplittingOnce:e=>Co.get(e),setSplittingOnce(e,t){Co.set(e,t)},isSaving:e=>$i.get(e),redo(e){e.redo()},undo(e){e.undo()},withMerging(e,t){var n=St.isMerging(e);wn.set(e,!0),t(),wn.set(e,n)},withNewBatch(e,t){var n=St.isMerging(e);wn.set(e,!0),Co.set(e,!0),t(),wn.set(e,n),Co.delete(e)},withoutMerging(e,t){var n=St.isMerging(e);wn.set(e,!1),t(),wn.set(e,n)},withoutSaving(e,t){var n=St.isSaving(e);$i.set(e,!1),t(),$i.set(e,n)}},u0=(e,t)=>!(!t||e.type!=="insert_text"||t.type!=="insert_text"||e.offset!==t.offset+t.text.length||!j.equals(e.path,t.path))||!(!t||e.type!=="remove_text"||t.type!=="remove_text"||e.offset+e.text.length!==t.offset||!j.equals(e.path,t.path)),c0=(e,t)=>e.type!=="set_selection";const hf=Km((function(){if(xc)return zi;xc=1,zi=function(o){return o=String(o||""),n.test(o)?"rtl":r.test(o)?"ltr":"neutral"};var e="֑-߿יִ-﷽ﹰ-ﻼ",t="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",n=new RegExp("^[^"+t+"]*["+e+"]"),r=new RegExp("^[^"+e+"]*["+t+"]");return zi})()),Oc=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Bc=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",qi=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Bc(n.overflowY,t)||Bc(n.overflowX,t)||(r=>{const o=(i=>{if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(e)}return!1},Do=(e,t,n,r,o,i,a,u)=>i<e&&a>t||i>e&&a<t?0:i<=e&&u<=n||a>=t&&u>=n?i-e-r:a>t&&u<n||i<e&&u>n?a-t+o:0,l0=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},kc=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:a,block:u,inline:s,boundary:c,skipOverflowHiddenElements:l}=t,d=typeof c=="function"?c:Z=>Z!==c;if(!Oc(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,m=[];let g=e;for(;Oc(g)&&d(g);){if(g=l0(g),g===p){m.push(g);break}g!=null&&g===document.body&&qi(g)&&!qi(document.documentElement)||g!=null&&qi(g,l)&&m.push(g)}const y=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,f=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:b,scrollY:C}=window,{height:D,width:E,top:A,right:B,bottom:O,left:S}=e.getBoundingClientRect(),{top:k,right:T,bottom:F,left:R}=(Z=>{const $=window.getComputedStyle(Z);return{top:parseFloat($.scrollMarginTop)||0,right:parseFloat($.scrollMarginRight)||0,bottom:parseFloat($.scrollMarginBottom)||0,left:parseFloat($.scrollMarginLeft)||0}})(e);let P=u==="start"||u==="nearest"?A-k:u==="end"?O+F:A+D/2-k+F,H=s==="center"?S+E/2-R+T:s==="end"?B+T:S-R;const G=[];for(let Z=0;Z<m.length;Z++){const $=m[Z],{height:W,width:U,top:J,right:X,bottom:ie,left:de}=$.getBoundingClientRect();if(a==="if-needed"&&A>=0&&S>=0&&O<=f&&B<=y&&A>=J&&O<=ie&&S>=de&&B<=X)return G;const ee=getComputedStyle($),pe=parseInt(ee.borderLeftWidth,10),I=parseInt(ee.borderTopWidth,10),N=parseInt(ee.borderRightWidth,10),_=parseInt(ee.borderBottomWidth,10);let K=0,oe=0;const Q="offsetWidth"in $?$.offsetWidth-$.clientWidth-pe-N:0,ue="offsetHeight"in $?$.offsetHeight-$.clientHeight-I-_:0,ce="offsetWidth"in $?$.offsetWidth===0?0:U/$.offsetWidth:0,he="offsetHeight"in $?$.offsetHeight===0?0:W/$.offsetHeight:0;if(p===$)K=u==="start"?P:u==="end"?P-f:u==="nearest"?Do(C,C+f,f,I,_,C+P,C+P+D,D):P-f/2,oe=s==="start"?H:s==="center"?H-y/2:s==="end"?H-y:Do(b,b+y,y,pe,N,b+H,b+H+E,E),K=Math.max(0,K+C),oe=Math.max(0,oe+b);else{K=u==="start"?P-J-I:u==="end"?P-ie+_+ue:u==="nearest"?Do(J,ie,W,I,_+ue,P,P+D,D):P-(J+W/2)+ue/2,oe=s==="start"?H-de-pe:s==="center"?H-(de+U/2)+Q/2:s==="end"?H-X+N+Q:Do(de,X,U,pe,N+Q,H,H+E,E);const{scrollLeft:be,scrollTop:le}=$;K=he===0?0:Math.max(0,Math.min(le+K/he,$.scrollHeight-W/he+ue)),oe=ce===0?0:Math.max(0,Math.min(be+oe/ce,$.scrollWidth-U/ce+Q)),P+=le-K,H+=be-oe}G.push({el:$,top:K,left:oe})}return G};function d0(e,t){if(!e.isConnected||!(o=>{let i=o;for(;i&&i.parentNode;){if(i.parentNode===document)return!0;i=i.parentNode instanceof ShadowRoot?i.parentNode.host:i.parentNode}return!1})(e))return;const n=(o=>{const i=window.getComputedStyle(o);return{top:parseFloat(i.scrollMarginTop)||0,right:parseFloat(i.scrollMarginRight)||0,bottom:parseFloat(i.scrollMarginBottom)||0,left:parseFloat(i.scrollMarginLeft)||0}})(e);if((o=>typeof o=="object"&&typeof o.behavior=="function")(t))return t.behavior(kc(e,t));const r=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:o,top:i,left:a}of kc(e,(u=>u===!1?{block:"end",inline:"nearest"}:(s=>s===Object(s)&&Object.keys(s).length!==0)(u)?u:{block:"start",inline:"nearest"})(t))){const u=i-n.top+n.bottom,s=a-n.left+n.right;o.scroll({top:u,left:s,behavior:r})}}var $r,kn=[],Sc="ResizeObserver loop completed with undelivered notifications.";(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})($r||($r={}));var Ki,Ic,Sn=function(e){return Object.freeze(e)},f0=function(e,t){this.inlineSize=e,this.blockSize=t,Sn(this)},pf=(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,Sn(this)}return e.prototype.toJSON=function(){var t=this;return{x:t.x,y:t.y,top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e})(),Ds=function(e){return e instanceof SVGElement&&"getBBox"in e},mf=function(e){if(Ds(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,i=o.offsetWidth,a=o.offsetHeight;return!(i||a||e.getClientRects().length)},Fc=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)},Nr=typeof window<"u"?window:{},Eo=new WeakMap,Tc=/auto|scroll/,h0=/^tb|vertical/,p0=/msie|trident/i.test(Nr.navigator&&Nr.navigator.userAgent),Bt=function(e){return parseFloat(e||"0")},Qn=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new f0((n?t:e)||0,(n?e:t)||0)},jc=Sn({devicePixelContentBoxSize:Qn(),borderBoxSize:Qn(),contentBoxSize:Qn(),contentRect:new pf(0,0,0,0)}),gf=function(e,t){if(t===void 0&&(t=!1),Eo.has(e)&&!t)return Eo.get(e);if(mf(e))return Eo.set(e,jc),jc;var n=getComputedStyle(e),r=Ds(e)&&e.ownerSVGElement&&e.getBBox(),o=!p0&&n.boxSizing==="border-box",i=h0.test(n.writingMode||""),a=!r&&Tc.test(n.overflowY||""),u=!r&&Tc.test(n.overflowX||""),s=r?0:Bt(n.paddingTop),c=r?0:Bt(n.paddingRight),l=r?0:Bt(n.paddingBottom),d=r?0:Bt(n.paddingLeft),p=r?0:Bt(n.borderTopWidth),m=r?0:Bt(n.borderRightWidth),g=r?0:Bt(n.borderBottomWidth),y=d+c,f=s+l,b=(r?0:Bt(n.borderLeftWidth))+m,C=p+g,D=u?e.offsetHeight-C-e.clientHeight:0,E=a?e.offsetWidth-b-e.clientWidth:0,A=o?y+b:0,B=o?f+C:0,O=r?r.width:Bt(n.width)-A-E,S=r?r.height:Bt(n.height)-B-D,k=O+y+E+b,T=S+f+D+C,F=Sn({devicePixelContentBoxSize:Qn(Math.round(O*devicePixelRatio),Math.round(S*devicePixelRatio),i),borderBoxSize:Qn(k,T,i),contentBoxSize:Qn(O,S,i),contentRect:new pf(d,s,O,S)});return Eo.set(e,F),F},vf=function(e,t,n){var r=gf(e,n),o=r.borderBoxSize,i=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(t){case $r.DEVICE_PIXEL_CONTENT_BOX:return a;case $r.BORDER_BOX:return o;default:return i}},m0=function(e){var t=gf(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Sn([t.borderBoxSize]),this.contentBoxSize=Sn([t.contentBoxSize]),this.devicePixelContentBoxSize=Sn([t.devicePixelContentBoxSize])},yf=function(e){if(mf(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},g0=function(){var e=1/0,t=[];kn.forEach((function(o){if(o.activeTargets.length!==0){var i=[];o.activeTargets.forEach((function(a){var u=new m0(a.target),s=yf(a.target);i.push(u),a.lastReportedSize=vf(a.target,a.observedBox),s<e&&(e=s)})),t.push((function(){o.callback.call(o.observer,i,o.observer)})),o.activeTargets.splice(0,o.activeTargets.length)}}));for(var n=0,r=t;n<r.length;n++)(0,r[n])();return e},Rc=function(e){kn.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(n){n.isActive()&&(yf(n.target)>e?t.activeTargets.push(n):t.skippedTargets.push(n))}))}))},v0=function(){var e,t=0;for(Rc(t);kn.some((function(n){return n.activeTargets.length>0}));)t=g0(),Rc(t);return kn.some((function(n){return n.skippedTargets.length>0}))&&(typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:Sc}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=Sc),window.dispatchEvent(e)),t>0},_c=[],y0=function(e){if(!Ki){var t=0,n=document.createTextNode("");new MutationObserver((function(){return _c.splice(0).forEach((function(r){return r()}))})).observe(n,{characterData:!0}),Ki=function(){n.textContent="".concat(t?t--:t++)}}_c.push(e),Ki()},Ia=0,b0={attributes:!0,characterData:!0,childList:!0,subtree:!0},Nc=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Pc=function(e){return e===void 0&&(e=0),Date.now()+e},Gi=!1,Fa=new((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=250),!Gi){Gi=!0;var r,o=Pc(t);r=function(){var i=!1;try{i=v0()}finally{if(Gi=!1,t=o-Pc(),!Ia)return;i?n.run(1e3):t>0?n.run(t):n.start()}},y0((function(){requestAnimationFrame(r)}))}},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,b0)};document.body?n():Nr.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Nc.forEach((function(n){return Nr.addEventListener(n,t.listener,!0)})))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),Nc.forEach((function(n){return Nr.removeEventListener(n,t.listener,!0)})),this.stopped=!0)},e})()),Mc=function(e){!Ia&&e>0&&Fa.start(),!(Ia+=e)&&Fa.stop()},w0=(function(){function e(t,n){this.target=t,this.observedBox=n||$r.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t,n=vf(this.target,this.observedBox,!0);return t=this.target,Ds(t)||(function(r){switch(r.tagName){case"INPUT":if(r.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1})(t)||getComputedStyle(t).display!=="inline"||(this.lastReportedSize=n),this.lastReportedSize.inlineSize!==n.inlineSize||this.lastReportedSize.blockSize!==n.blockSize},e})(),C0=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},Ao=new WeakMap,Lc=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},xo=(function(){function e(){}return e.connect=function(t,n){var r=new C0(t,n);Ao.set(t,r)},e.observe=function(t,n,r){var o=Ao.get(t),i=o.observationTargets.length===0;Lc(o.observationTargets,n)<0&&(i&&kn.push(o),o.observationTargets.push(new w0(n,r&&r.box)),Mc(1),Fa.schedule())},e.unobserve=function(t,n){var r=Ao.get(t),o=Lc(r.observationTargets,n),i=r.observationTargets.length===1;o>=0&&(i&&kn.splice(kn.indexOf(r),1),r.observationTargets.splice(o,1),Mc(-1))},e.disconnect=function(t){var n=this,r=Ao.get(t);r.observationTargets.slice().forEach((function(o){return n.unobserve(t,o.target)})),r.activeTargets.splice(0,r.activeTargets.length)},e})(),D0=(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.");xo.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(!Fc(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");xo.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(!Fc(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");xo.unobserve(this,t)},e.prototype.disconnect=function(){xo.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e})(),gt={},Xi=(function(){if(Ic)return gt;Ic=1,Object.defineProperty(gt,"__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 i(l,d,p){d&&!("byKey"in d)&&(p=d,d=null),Array.isArray(l)||(l=[l]);var m=l.map((function(y){return a(y,d)})),g=function(y){return m.some((function(f){return u(f,y)}))};return p==null?g:g(p)}function a(l,d){var p=d&&d.byKey,m={},g=(l=l.replace("++","+add")).split("+"),y=g.length;for(var f in t)m[t[f]]=!1;var b=!0,C=!1,D=void 0;try{for(var E,A=g[Symbol.iterator]();!(b=(E=A.next()).done);b=!0){var B=E.value,O=B.endsWith("?")&&B.length>1;O&&(B=B.slice(0,-1));var S=c(B),k=t[S];if(B.length>1&&!k&&!n[B]&&!r[S])throw new TypeError('Unknown modifier: "'+B+'"');y!==1&&k||(p?m.key=S:m.which=s(B)),k&&(m[k]=!O||null)}}catch(T){C=!0,D=T}finally{try{!b&&A.return&&A.return()}finally{if(C)throw D}}return m}function u(l,d){for(var p in l){var m=l[p],g=void 0;if(m!=null&&((g=p==="key"&&d.key!=null?d.key.toLowerCase():p==="which"?m===91&&d.which===93?91:d.which:d[p])!=null||m!==!1)&&g!==m)return!1}return!0}function s(l){return l=c(l),r[l]||l.toUpperCase().charCodeAt(0)}function c(l){return l=l.toLowerCase(),l=n[l]||l}return gt.default=i,gt.isHotkey=i,gt.isCodeHotkey=function(l,d){return i(l,d)},gt.isKeyHotkey=function(l,d){return i(l,{byKey:!0},d)},gt.parseHotkey=a,gt.compareHotkey=u,gt.toKeyCode=s,gt.toKeyName=c,gt})();function sr(e,t){if(e==null)return{};var n,r,o=(function(a,u){if(a==null)return{};var s,c,l={},d=Object.keys(a);for(c=0;c<d.length;c++)s=d[c],u.indexOf(s)>=0||(l[s]=a[s]);return l})(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Pr(e){return Pr=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},Pr(e)}function E0(e){var t=(function(n,r){if(Pr(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(Pr(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return Pr(t)==="symbol"?t:String(t)}function ht(e,t,n){return(t=E0(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Zi,Yi,Es=h.createContext(null),Ut=()=>{var e=h.useContext(Es);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},bf=parseInt(ge.version.split(".")[0],10),wf=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Uc=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),Ye=typeof navigator<"u"&&/Android/.test(navigator.userAgent),Xn=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Cn=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),A0=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),Cf=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),x0=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),O0=Ye&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),B0=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),k0=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),S0=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent),Mo=!(typeof window>"u"||window.document===void 0||window.document.createElement===void 0);typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&(Zi=navigator.userAgent.match(/Version\/(\d+)/))!==null&&Zi!==void 0&&Zi[1]&&parseInt((Yi=navigator.userAgent.match(/Version\/(\d+)/))===null||Yi===void 0?void 0:Yi[1],10);var tn=(!x0||!O0)&&!A0&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function",er=new WeakMap,As=new WeakMap,xs=new WeakMap,Df=new WeakMap,Lo=new WeakMap,Ta=new WeakMap,qr=new WeakMap,In=new WeakMap,ni=new WeakMap,yi=new WeakMap,ja=new WeakMap,ln=new WeakMap,xn=new WeakMap,Mr=new WeakMap,Ra=new WeakMap,Os=new WeakMap,bt=new WeakMap,Gt=new WeakMap,et=new WeakMap,on=new WeakMap,an=new WeakMap,Ef=new WeakMap,ur=Symbol("placeholder"),Af=Symbol("mark-placeholder"),xf=globalThis.Node,I0=globalThis.Text,Bs=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,lt=e=>hn(e)&&e.nodeType===1,hn=e=>{var t=Bs(e);return!!t&&e instanceof t.Node},_a=e=>{var t=e&&e.anchorNode&&Bs(e.anchorNode);return!!t&&e instanceof t.Selection},Of=e=>hn(e)&&e.nodeType===3,Bf=(e,t,n)=>{for(var r,{childNodes:o}=e,i=o[t],a=t,u=!1,s=!1;(hn(r=i)&&r.nodeType===8||lt(i)&&i.childNodes.length===0||lt(i)&&i.getAttribute("contenteditable")==="false")&&(!u||!s);)a>=o.length?(u=!0,a=t-1,n="backward"):a<0?(s=!0,a=t+1,n="forward"):(i=o[a],t=a,a+=n==="forward"?1:-1);return[i,t]},F0=(e,t,n)=>{var[r]=Bf(e,t,n);return r},kf=e=>{var t="";if(Of(e)&&e.nodeValue)return e.nodeValue;if(lt(e)){for(var n of Array.from(e.childNodes))t+=kf(n);var r=getComputedStyle(e).getPropertyValue("display");r!=="block"&&r!=="list"&&e.tagName!=="BR"||(t+=`
|
|
4
4
|
`)}return t},T0=/data-slate-fragment="(.+?)"/m,Lr=e=>e.getSelection!=null?e.getSelection():document.getSelection(),ks=(e,t,n)=>{var{target:r}=t;if(lt(r)&&r.matches('[contentEditable="false"]'))return!1;var{document:o}=q.getWindow(e);if(o.contains(r))return q.hasDOMNode(e,r,{editable:!0});var i=n.find((a=>{var{addedNodes:u,removedNodes:s}=a;for(var c of u)if(c===r||c.contains(r))return!0;for(var l of s)if(l===r||l.contains(r))return!0}));return!(!i||i===t)&&ks(e,i,n)},Vc=(e,t)=>!!(e.compareDocumentPosition(t)&xf.DOCUMENT_POSITION_PRECEDING),j0=0;class R0{constructor(){ht(this,"id",void 0),this.id="".concat(j0++)}}var q={androidPendingDiffs:e=>et.get(e),androidScheduleFlush:e=>{var t;(t=Os.get(e))===null||t===void 0||t()},blur:e=>{var t=q.toDOMNode(e,e),n=q.findDocumentOrShadowRoot(e);ln.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{var{selection:t}=e,n=q.findDocumentOrShadowRoot(e),r=Lr(n);r&&r.rangeCount>0&&r.removeAllRanges(),t&&z.deselect(e)},findDocumentOrShadowRoot:e=>{var t=q.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 i,a=q.toSlateNode(e,t.target),u=q.findPath(e,a);if(ae.isElement(a)&&w.isVoid(e,a)){var s=o.getBoundingClientRect(),c=e.isInline(a)?n-s.left<s.left+s.width-n:r-s.top<s.top+s.height-r,l=w.point(e,u,{edge:c?"start":"end"}),d=c?w.before(e,l):w.after(e,l);if(d)return w.range(e,d)}var{document:p}=q.getWindow(e);if(p.caretRangeFromPoint)i=p.caretRangeFromPoint(n,r);else{var m=p.caretPositionFromPoint(n,r);m&&((i=p.createRange()).setStart(m.offsetNode,m.offset),i.setEnd(m.offsetNode,m.offset))}if(!i)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));return q.toSlateRange(e,i,{exactMatch:!1,suppressThrow:!1})},findKey:(e,t)=>{var n=ni.get(t);return n||(n=new R0,ni.set(t,n)),n},findPath:(e,t)=>{for(var n=[],r=t;;){var o=xs.get(r);if(o==null){if(w.isEditor(r))return n;break}var i=As.get(r);if(i==null)break;n.unshift(i),r=o}throw new Error("Unable to find the path for Slate node: ".concat(He.stringify(t)))},focus:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{retries:5};if(!ln.get(e)){if(t.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(e.operations.length>0)setTimeout((()=>{q.focus(e,{retries:t.retries-1})}),10);else{var n=q.toDOMNode(e,e),r=q.findDocumentOrShadowRoot(e);if(r.activeElement!==n){if(e.selection&&r instanceof Document){var o=Lr(r),i=q.toDOMRange(e,e.selection);o?.removeAllRanges(),o?.addRange(i)}e.selection||z.select(e,w.start(e,[])),ln.set(e,!0),n.focus({preventScroll:!0})}}}},getWindow:e=>{var t=Df.get(e);if(!t)throw new Error("Unable to find a host window element for this editor");return t},hasDOMNode:function(e,t){var n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{editable:o=!1}=r,i=q.toDOMNode(e,e);try{n=lt(t)?t:t.parentElement}catch(a){if(a instanceof Error&&!a.message.includes('Permission denied to access property "nodeType"'))throw a}return!!n&&!(n.closest("[data-slate-editor]")!==i||o&&!n.isContentEditable&&(typeof n.isContentEditable!="boolean"||n.closest('[contenteditable="false"]')!==i)&&!n.getAttribute("data-slate-zero-width"))},hasEditableTarget:(e,t)=>hn(t)&&q.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{var{anchor:n,focus:r}=t;return w.hasPath(e,n.path)&&w.hasPath(e,r.path)},hasSelectableTarget:(e,t)=>q.hasEditableTarget(e,t)||q.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>hn(t)&&q.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!xn.get(e),isFocused:e=>!!ln.get(e),isReadOnly:e=>!!ja.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(ja.get(e))return!1;var n=q.hasTarget(e,t)&&q.toSlateNode(e,t);return ae.isElement(n)&&w.isVoid(e,n)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{var n=yi.get(e),r=w.isEditor(t)?Lo.get(e):n?.get(q.findKey(e,t));if(!r)throw new Error("Cannot resolve a DOM node from Slate node: ".concat(He.stringify(t)));return r},toDOMPoint:(e,t)=>{var n,[r]=w.node(e,t.path),o=q.toDOMNode(e,r);w.void(e,{at:t})&&(t={path:t.path,offset:0});for(var i=Array.from(o.querySelectorAll("[data-slate-string], [data-slate-zero-width]")),a=0,u=0;u<i.length;u++){var s=i[u],c=s.childNodes[0];if(c!=null&&c.textContent!=null){var{length:l}=c.textContent,d=s.getAttribute("data-slate-length"),p=a+(d==null?l:parseInt(d,10)),m=i[u+1];if(t.offset===p&&m!=null&&m.hasAttribute("data-slate-mark-placeholder")){var g,y=m.childNodes[0];n=[y instanceof I0?y:m,(g=m.textContent)!==null&&g!==void 0&&g.startsWith("\uFEFF")?1:0];break}if(t.offset<=p){n=[c,Math.min(l,Math.max(0,t.offset-a))];break}a=p}}if(!n)throw new Error("Cannot resolve a DOM point from Slate point: ".concat(He.stringify(t)));return n},toDOMRange:(e,t)=>{var{anchor:n,focus:r}=t,o=M.isBackward(t),i=q.toDOMPoint(e,n),a=M.isCollapsed(t)?i:q.toDOMPoint(e,r),u=q.getWindow(e).document.createRange(),[s,c]=o?a:i,[l,d]=o?i:a,p=!!(lt(s)?s:s.parentElement).getAttribute("data-slate-zero-width"),m=!!(lt(l)?l:l.parentElement).getAttribute("data-slate-zero-width");return u.setStart(s,p?1:c),u.setEnd(l,m?1:d),u},toSlateNode:(e,t)=>{var n=lt(t)?t:t.parentElement;n&&!n.hasAttribute("data-slate-node")&&(n=n.closest("[data-slate-node]"));var r=n?qr.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:i="backward"}=n,[a,u]=r?t:(W=>{var[U,J]=W;if(lt(U)&&U.childNodes.length){var X=J===U.childNodes.length,ie=X?J-1:J;for([U,ie]=Bf(U,ie,X?"backward":"forward"),X=ie<J;lt(U)&&U.childNodes.length;){var de=X?U.childNodes.length-1:0;U=F0(U,de,X?"backward":"forward")}J=X&&U.textContent!=null?U.textContent.length:0}return[U,J]})(t),s=a.parentNode,c=null,l=0;if(s){var d,p,m=q.toDOMNode(e,e),g=s.closest('[data-slate-void="true"]'),y=g&&m.contains(g)?g:null,f=s.closest('[contenteditable="false"]'),b=f&&m.contains(f)?f:null,C=s.closest("[data-slate-leaf]"),D=null;if(C){if(c=C.closest('[data-slate-node="text"]')){var E=q.getWindow(e).document.createRange();E.setStart(c,0),E.setEnd(a,u);var A=E.cloneContents();[...Array.prototype.slice.call(A.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(A.querySelectorAll("[contenteditable=false]"))].forEach((W=>{Ye&&!r&&W.hasAttribute("data-slate-zero-width")&&W.textContent.length>0&&W.textContext!=="\uFEFF"?W.textContent.startsWith("\uFEFF")&&(W.textContent=W.textContent.slice(1)):W.parentNode.removeChild(W)})),l=A.textContent.length,D=c}}else if(y){for(var B=y.querySelectorAll("[data-slate-leaf]"),O=0;O<B.length;O++){var S=B[O];if(q.hasDOMNode(e,S)){C=S;break}}C?(c=C.closest('[data-slate-node="text"]'),l=(D=C).textContent.length,D.querySelectorAll("[data-slate-zero-width]").forEach((W=>{l-=W.textContent.length}))):l=1}else if(b){var k,T,F=W=>W?W.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],R=b.closest('[data-slate-node="element"]');i==="forward"?C=(k=[...F(R),...F(R?.nextElementSibling)].find((W=>((U,J)=>!!(U.compareDocumentPosition(J)&xf.DOCUMENT_POSITION_FOLLOWING))(b,W))))!==null&&k!==void 0?k:null:C=(T=[...F(R?.previousElementSibling),...F(R)].findLast((W=>Vc(b,W))))!==null&&T!==void 0?T:null,C&&(c=C.closest('[data-slate-node="text"]'),D=C,i==="forward"?l=0:(l=D.textContent.length,D.querySelectorAll("[data-slate-zero-width]").forEach((W=>{l-=W.textContent.length}))))}D&&l===D.textContent.length&&Ye&&D.getAttribute("data-slate-zero-width")==="z"&&(d=D.textContent)!==null&&d!==void 0&&d.startsWith("\uFEFF")&&(s.hasAttribute("data-slate-zero-width")||Xn&&(p=D.textContent)!==null&&p!==void 0&&p.endsWith(`
|