@zeniai/web-app-ui 5.4.14-dev → 5.4.15-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccountMappingScreen-BZk8jrAP.js → AccountMappingScreen-BjOLn722.js} +2 -2
- package/dist/assets/ActualMatchingMatchDetailScreen-DxeGt00n.js +1 -0
- package/dist/assets/AddressRoutes-wf3jLMp6.js +1 -0
- package/dist/assets/AddressScreen-6MrKOfvb.js +9 -0
- package/dist/assets/AiCfoScreen-D2IsGTI7.js +22 -0
- package/dist/assets/{AppDrawer-BnkAekbe.js → AppDrawer-51tmFCqo.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-2Q-AgKCr.js → BillPayApprovalRoutes-CqcByft0.js} +1 -1
- package/dist/assets/BillPayRoutes-DjTR6LDc.js +119 -0
- package/dist/assets/BusinessVerificationPageScreen-C8E7IOrb.js +9 -0
- package/dist/assets/CardsAiCfoScreen-CyjNAzbg.js +14 -0
- package/dist/assets/ChargeCardRoutes-D1jDUnLE.js +71 -0
- package/dist/assets/CompanyPassportScreen-CCrHjEm4.js +1 -0
- package/dist/assets/ConnectionAuthScreen-u25O8YEL.js +11 -0
- package/dist/assets/CustomerOnboardingAuthScreen-DP56g3tx.js +1 -0
- package/dist/assets/CustomerOnboardingRoutes-CdWk604C.js +30 -0
- package/dist/assets/{DashboardRoutes-VCRBM_Lo.js → DashboardRoutes-CxVvIZyr.js} +4 -4
- package/dist/assets/{DefaultTenantHome-Bnjp4uin.js → DefaultTenantHome-B1dhRA7X.js} +1 -1
- package/dist/assets/DomesticWireDetailScreen-HGMMXsdl.js +18 -0
- package/dist/assets/DrawerScreen-DpM9V-h3.js +1 -0
- package/dist/assets/EntityDetailRoutes-CiWU9eOR.js +1 -0
- package/dist/assets/{ExpenseAutomationRoutes-C-dPVJak.js → ExpenseAutomationRoutes-BykEoKxY.js} +6 -6
- package/dist/assets/FeaturePreviewScreen-5jpbyDlq.js +1 -0
- package/dist/assets/HubSpotOAuthCallbackScreen-B-Qgi5tZ.js +1 -0
- package/dist/assets/{InboxNotificationsProvider-CPjcPE2w.js → InboxNotificationsProvider-CJ59FBLr.js} +1 -1
- package/dist/assets/InvoicingRoutes-DVzjxAr7.js +3 -0
- package/dist/assets/MagicLinkRoutes-BulcIao_.js +72 -0
- package/dist/assets/MagicLinkSignInScreen-B3s3dqD3.js +12 -0
- package/dist/assets/MobileAppDrawer-Diz4hNBc.js +1 -0
- package/dist/assets/NotFoundScreen-l_eBhBHD.js +1 -0
- package/dist/assets/NotificationRoutes-P-tvBMkz.js +1 -0
- package/dist/assets/OAuthConsentScreen-CH9Lv95g.js +1 -0
- package/dist/assets/PandLWithForecastRoutes-D7LURgK7.js +1 -0
- package/dist/assets/{PaymentLinkScreen-B77tcNGP.js → PaymentLinkScreen-BWyxCLTs.js} +5 -5
- package/dist/assets/PeopleRoutes-rbgPpJey.js +22 -0
- package/dist/assets/PerformanceRoutes-CoOModp8.js +1 -0
- package/dist/assets/{Preview-DyDyLMFa.js → Preview-0DfltTWd.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-DdhMvyre.js → QBOConnectionScreen-Det19rnQ.js} +2 -2
- package/dist/assets/ReimbursementApprovalRoutes-D5ZwAxEx.js +1 -0
- package/dist/assets/ReimbursementApprovalRuleDetailScreen-BQTsJiep.js +1 -0
- package/dist/assets/ReimbursementRoutes-B_5omRv6.js +68 -0
- package/dist/assets/ReportsRoutes-CRvQbciE.js +1 -0
- package/dist/assets/RewardsRoutes-5nWEeQ99.js +1 -0
- package/dist/assets/ScheduleDetailsPrepaidExpensesScreen-ehyhu56d.js +33 -0
- package/dist/assets/ScreenRoutes-Cg0QxFx2.js +2 -0
- package/dist/assets/SettingsRoutes-foH5ZJ3w.js +49 -0
- package/dist/assets/{SetupPagesScreen-CfUfKDWM.js → SetupPagesScreen-CAejgxls.js} +5 -5
- package/dist/assets/SignInScreen-BLMRggvG.js +1 -0
- package/dist/assets/SignOutScreen-6HU69Hwf.js +9 -0
- package/dist/assets/TaskListScreen-BuEk-5wI.js +9 -0
- package/dist/assets/TaskRoutes-C7UfLoX_.js +9 -0
- package/dist/assets/TransactionDetailRoutes-CKuWykLU.js +1 -0
- package/dist/assets/TransactionDetailScreen-D1z9X11O.js +5 -0
- package/dist/assets/TransactionListRoutes-DZvkZnS3.js +1 -0
- package/dist/assets/TreasuryRoutes-Bm4PZ59U.js +37 -0
- package/dist/assets/{VendorsRoutes-DWNg-EPe.js → VendorsRoutes-ThVY1BXz.js} +20 -20
- package/dist/assets/WiseConfirmationScreen-CnXwL3Zk.js +12 -0
- package/dist/assets/{ZeniAccountRoutes-BI00gqox.js → ZeniAccountRoutes-gVqLclSg.js} +11 -11
- package/dist/assets/ZeniAccountStatementScreen-n4s_O46n.js +9 -0
- package/dist/assets/{accountMappingHelper-DPBaxZAX.js → accountMappingHelper-C2thHMMO.js} +1 -1
- package/dist/assets/{analytics-D_VVN36A.js → analytics-WkSvCk9z.js} +4 -4
- package/dist/assets/analyticsHelper-PDBXl7Se.js +1 -0
- package/dist/assets/{core-Cc1CwF93.js → core-DtTeGJWB.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-BhSMetwg.js → decodeURIComponentSafe-Dnku9ZdA.js} +1 -1
- package/dist/assets/{dnd-AdUHoEcy.js → dnd-DR4eaoV-.js} +1 -1
- package/dist/assets/{empty-PD8ivveW.js → empty-BNegk5KG.js} +1 -1
- package/dist/assets/{empty-DhAh77JM.js → empty-DmZnYBE2.js} +1 -1
- package/dist/assets/{emptyVideoElement-BKPO_tn0.js → emptyVideoElement-CGit-XA8.js} +1 -1
- package/dist/assets/{epic-BJGEeb_3.js → epic-C0vaCxPe.js} +1 -1
- package/dist/assets/expenseAutomationHelper-CNcHl26i.js +1 -0
- package/dist/assets/getLocaleForTenant-Bqc2BhMq.js +1 -0
- package/dist/assets/{index-Bp8ijVbG.js → index-BRw-S0Do.js} +1 -1
- package/dist/assets/{index-zmOdoQIt.js → index-B_U4bcDF.js} +14753 -14753
- package/dist/assets/{index-BJg1S6MG.js → index-BoDMWS6Z.js} +2 -2
- package/dist/assets/index-CnQ2Hwrv.js +1 -0
- package/dist/assets/{index-Cxx08j41.js → index-D79Yg4Pa.js} +1 -1
- package/dist/assets/{index-cHP9lO1h.js → index-DQOY5nqW.js} +1 -1
- package/dist/assets/{index-BJ8vYoNR.js → index-X62DPOrd.js} +1 -1
- package/dist/assets/{index-zhmkax0y.js → index-gtxCOQrD.js} +1 -1
- package/dist/assets/{lexical-BRekJTpF.js → lexical-DF0K2978.js} +1 -1
- package/dist/assets/{liveblocks-CM1vcHN_.js → liveblocks-DXlRhlw7.js} +15 -15
- package/dist/assets/{lottie-BXg_FLck.js → lottie-DOEy9FLJ.js} +1 -1
- package/dist/assets/{mui-ehyt9jca.js → mui-UvvMpioS.js} +2 -2
- package/dist/assets/{pathToGoBack-jAeSfAQ9.js → pathToGoBack-CTzkpPUW.js} +1 -1
- package/dist/assets/{pdf-lib-kwPPw7gn.js → pdf-lib-C8URdnXW.js} +1 -1
- package/dist/assets/{pdf-CHwZP-Er.js → pdf-rdPHFveP.js} +4 -4
- package/dist/assets/{plaid-WRjvFkFp.js → plaid-CIpr1Lyg.js} +1 -1
- package/dist/assets/{pusher-C0WLqP6E.js → pusher-DfQYB_JN.js} +1 -1
- package/dist/assets/{react-miDI-z35.js → react-BS0hNTf7.js} +1 -1
- package/dist/assets/{react-CvCXtyEQ.js → react-BTgc9osR.js} +1 -1
- package/dist/assets/{react-CQgMB5FX.js → react-By3kCyTX.js} +1 -1
- package/dist/assets/{react-ZP71p6P6.js → react-CQQuAOkD.js} +1 -1
- package/dist/assets/{react-L2WtUuXe.js → react-DEp3ukzS.js} +1 -1
- package/dist/assets/{react-Bw2LIZU7.js → react-H6WPphNY.js} +1 -1
- package/dist/assets/{recharts-tLFME7sM.js → recharts-VBeTlX07.js} +1 -1
- package/dist/assets/{reportTimeframe-DX5pHUc_.js → reportTimeframe-CAbHy0y8.js} +1 -1
- package/dist/assets/routePaths-DsLddvmS.js +1 -0
- package/dist/assets/{sentry-Bh68thgn.js → sentry-CtZyo70D.js} +2 -2
- package/dist/assets/stripSplatSuffix-DUYOfZtR.js +1 -0
- package/dist/assets/{url-DqRIAQ9M.js → url-DDEUDnJw.js} +4 -4
- package/dist/assets/{url-BTt3PKLo.js → url-ZY4Nz4s5.js} +1 -1
- package/dist/assets/useActualMatchingMatchDetail-cU8XyJV-.js +1 -0
- package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-Du9fPfH0.js +1 -0
- package/dist/assets/useAskAiCfoHostNavButtonProps-Rl6Dxu4t.js +1 -0
- package/dist/assets/useChargeCardPusherEvents-CREE1zcc.js +1 -0
- package/dist/assets/{useDeviceId-B4dK-Ywm.js → useDeviceId-CUrjU4ja.js} +1 -1
- package/dist/assets/useEmailConnectResultRefresh-DfCz3FA3.js +1 -0
- package/dist/assets/useEnsureVendorListLoaded-CoE84-0L.js +1 -0
- package/dist/assets/useInitialThreadRequest-B9aUCLGn.js +1 -0
- package/dist/assets/useTaskManagerAccess-jB_YQM25.js +1 -0
- package/dist/assets/useTaskManagerPusherEvents-UGiOcEas.js +1 -0
- package/dist/assets/{utils-CjDqL2uk.js → utils-Bmb8VI_4.js} +2 -2
- package/dist/assets/withTransactionSidePanel-DCK_khop.js +25 -0
- package/dist/assets/{zeni-epic-state-DFhlE0W3.js → zeni-epic-state-DZFeYKWz.js} +7 -7
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/dist/assets/ActualMatchingMatchDetailScreen-DdqC6TYo.js +0 -1
- package/dist/assets/AddressRoutes-DZnn8xs0.js +0 -1
- package/dist/assets/AddressScreen-DpzckL13.js +0 -9
- package/dist/assets/AiCfoScreen-BuC0DF7-.js +0 -22
- package/dist/assets/BillPayRoutes-CV19o_tt.js +0 -119
- package/dist/assets/BusinessVerificationPageScreen-NPjj2cPM.js +0 -9
- package/dist/assets/CardsAiCfoScreen-CadRu1yE.js +0 -14
- package/dist/assets/ChargeCardRoutes-BRNnHx29.js +0 -71
- package/dist/assets/CompanyPassportScreen-d_xThxF-.js +0 -1
- package/dist/assets/ConnectionAuthScreen-B-GQ_uXR.js +0 -11
- package/dist/assets/CustomerOnboardingAuthScreen-Dv-djr6z.js +0 -1
- package/dist/assets/CustomerOnboardingRoutes-KQwdDIjg.js +0 -30
- package/dist/assets/DomesticWireDetailScreen-FhF-Oy51.js +0 -18
- package/dist/assets/DrawerScreen-DOVfIfbY.js +0 -1
- package/dist/assets/EntityDetailRoutes-BKu8bIme.js +0 -1
- package/dist/assets/FallBackRoute-BsefzYi4.js +0 -2
- package/dist/assets/FeaturePreviewScreen-CEvvSUOY.js +0 -1
- package/dist/assets/HubSpotOAuthCallbackScreen-BRLjqcM8.js +0 -1
- package/dist/assets/InvoicingRoutes-Cn0ho2Ac.js +0 -3
- package/dist/assets/MagicLinkRoutes-DETheAv8.js +0 -72
- package/dist/assets/MagicLinkSignInScreen-hwNEJu9D.js +0 -12
- package/dist/assets/MobileAppDrawer-YElMwyTk.js +0 -1
- package/dist/assets/NotFoundScreen-DD1ftXbM.js +0 -1
- package/dist/assets/NotificationRoutes-j31qfFA3.js +0 -1
- package/dist/assets/OAuthConsentScreen-CQV1J_Nj.js +0 -1
- package/dist/assets/PandLWithForecastRoutes-CUitXoy8.js +0 -1
- package/dist/assets/PeopleRoutes-BbZuMgKW.js +0 -22
- package/dist/assets/PerformanceRoutes-D6iGCdx1.js +0 -1
- package/dist/assets/ReimbursementApprovalRoutes-lGHZV1sd.js +0 -1
- package/dist/assets/ReimbursementApprovalRuleDetailScreen-CtdOG2XT.js +0 -1
- package/dist/assets/ReimbursementRoutes-DjGiFO3h.js +0 -68
- package/dist/assets/ReportsRoutes-DNhWXb3T.js +0 -1
- package/dist/assets/RewardsRoutes-C0czxWPN.js +0 -1
- package/dist/assets/ScheduleDetailsPrepaidExpensesScreen-CkM33AZC.js +0 -33
- package/dist/assets/ScreenRoutes-DYGYxgwA.js +0 -2
- package/dist/assets/SettingsRoutes-DRSU5I7g.js +0 -49
- package/dist/assets/SignInScreen-DDQ1e38Q.js +0 -1
- package/dist/assets/SignOutScreen-CmYRhks4.js +0 -9
- package/dist/assets/TaskListScreen-D8jqZbNF.js +0 -9
- package/dist/assets/TaskRoutes-Cu7kReic.js +0 -9
- package/dist/assets/TransactionDetailRoutes-B7AzD4hg.js +0 -1
- package/dist/assets/TransactionDetailScreen-CpvJY1a3.js +0 -5
- package/dist/assets/TransactionListRoutes-BejbKDzL.js +0 -1
- package/dist/assets/TreasuryRoutes-DTax48Tc.js +0 -37
- package/dist/assets/WiseConfirmationScreen-C4KbEpAc.js +0 -12
- package/dist/assets/ZeniAccountStatementScreen-BUg2sDXI.js +0 -9
- package/dist/assets/analyticsHelper-DcUdLdtd.js +0 -1
- package/dist/assets/expenseAutomationHelper-CCv2kRkH.js +0 -1
- package/dist/assets/getLocaleForTenant-CSUvt8Gt.js +0 -1
- package/dist/assets/index-foi_vl2g.js +0 -1
- package/dist/assets/routePaths-RxstHRDw.js +0 -1
- package/dist/assets/stripSplatSuffix-B0jus2nC.js +0 -1
- package/dist/assets/useActualMatchingMatchDetail-Dr6cKA7B.js +0 -1
- package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-CC8PIy8S.js +0 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-Bl76c5H-.js +0 -1
- package/dist/assets/useChargeCardPusherEvents-C6oeFa4_.js +0 -1
- package/dist/assets/useEmailConnectResultRefresh-nv6tTKw5.js +0 -1
- package/dist/assets/useEnsureVendorListLoaded-zh5PaZPv.js +0 -1
- package/dist/assets/useInitialThreadRequest-DqCJRXyQ.js +0 -1
- package/dist/assets/useTaskManagerAccess-DhT542co.js +0 -1
- package/dist/assets/useTaskManagerPusherEvents-B9F1i19u.js +0 -1
- package/dist/assets/withTransactionSidePanel-BaaDGWl5.js +0 -25
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)):Li[r]=o}function Ue(){const e=new Set;function t(o){return e.add(o),()=>e.delete(o)}function n(o){const i=t((s=>(i(),o(s))));return i}async function r(o){let i;return new Promise((s=>{i=t((a=>{(o===void 0||o(a))&&s(a)}))})).finally((()=>i?.()))}return{notify:function(o){let i=!1;for(const s of e)s(o),i=!0;return i},subscribe:t,subscribeOnce:n,count:function(){return e.size},waitUntil:r,dispose(){e.clear()},observable:{subscribe:t,subscribeOnce:n,waitUntil:r}}}function dn(e){throw new Error(e)}function ic(e){return Object.entries(e)}function Ln(e){try{return JSON.parse(e)}catch{return}}function hi(e){return JSON.parse(JSON.stringify(e))}function Ya(e){return e.filter((t=>t!=null))}function pi(e){const t={...e};return Object.keys(e).forEach((n=>{const r=n;t[r]===void 0&&delete t[r]})),t}function jv(e){return new Promise((t=>setTimeout(t,e)))}async function jl(e,t,n){let r;const o=new Promise(((i,s)=>{r=setTimeout((()=>{s(new Error(n))}),t)}));return Promise.race([e,o]).finally((()=>clearTimeout(r)))}function Ml(e){let t=null;return()=>(t===null&&(t=e().catch((n=>{throw setTimeout((()=>{t=null}),5e3),n}))),t)}function qh(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n],n,e))return n;return-1}var yr=Symbol("kSinks"),Es=Symbol("kTrigger"),so=null,Ar=null;function Xe(e){if(so===null){so=new Set;try{e()}finally{for(const t of so)t[Es]();so=null}}else e()}function sc(e){so||dn("Expected to be in an active batch"),so.add(e)}function Gh(e,t){let n=!1;const r={...e};return Object.keys(t).forEach((o=>{const i=o,s=t[i];r[i]!==s&&(s===void 0?delete r[i]:r[i]=s,n=!0)})),n?r:e}var ac=class{equals;#e;[yr];constructor(e){this.equals=e??Object.is,this.#e=Ue(),this[yr]=new Set,this.get=this.get.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeOnce=this.subscribeOnce.bind(this)}dispose(){this.#e.dispose(),this.#e="(disposed)",this.equals="(disposed)"}get hasWatchers(){if(this.#e.count()>0)return!0;for(const e of this[yr])if(e.hasWatchers)return!0;return!1}[Es](){this.#e.notify();for(const e of this[yr])sc(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[yr])e.markDirty()}addSink(e){this[yr].add(e)}removeSink(e){this[yr].delete(e)}asReadonly(){return this}},Tt=class extends ac{#e;constructor(e,t){super(t),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return Ar?.add(this),this.#e}set(e){Xe((()=>{typeof e=="function"&&(e=e(this.#e)),this.equals(this.#e,e)||(this.#e=e,this.markSinksDirty(),sc(this))}))}},Mv=class extends Tt{constructor(e){super(pi(e))}set(){throw new Error("Don't call .set() directly, use .patch()")}patch(e){super.set((t=>Gh(t,e)))}},Pv=Symbol(),$e=class Qa extends ac{#e;#t;#n;#r;#o;static from(...t){const n=t.pop();if(typeof n!="function"&&dn("Invalid .from() call, last argument expected to be a function"),typeof t[t.length-1]=="function"){const r=n,o=t.pop();return new Qa(t,o,r)}return new Qa(t,n)}constructor(t,n,r){super(r),this.#t=!0,this.#e=Pv,this.#r=t,this.#n=new Set,this.#o=n}dispose(){for(const t of this.#n)t.removeSink(this);this.#e="(disposed)",this.#n="(disposed)",this.#r="(disposed)",this.#o="(disposed)"}get isDirty(){return this.#t}#i(){const t=Ar;let n;Ar=new Set;try{n=this.#o(...this.#r.map((r=>r.get())))}finally{const r=this.#n;this.#n=new Set;for(const o of Ar)this.#n.add(o),r.delete(o);for(const o of r)o.removeSink(this);for(const o of this.#n)o.addSink(this);Ar=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.#i(),Ar?.add(this),this.#e}[Es](){this.hasWatchers&&this.#i()&&super[Es]()}},Ot=class extends ac{#e;constructor(e){super(),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return Ar?.add(this),this.#e}mutate(e){Xe((()=>{const t=!e||e(this.#e);t!==null&&typeof t=="object"&&"then"in t&&dn("MutableSignal.mutate() does not support async callbacks"),t!==!1&&(this.markSinksDirty(),sc(this))}))}};function Pl(e,t,n){let r=0,o=e.length;for(;r<o;){const i=r+(o-r>>1);n(t,e[i])?o=i:r=i+1}return r}var ir=class Xo{#e;#t;constructor(t,n){this.#t=n,this.#e=t}static with(t){return Xo.fromAlreadySorted([],t)}static from(t,n){const r=new Xo([],n);for(const o of t)r.add(o);return r}static fromAlreadySorted(t,n){return new Xo(t,n)}clone(){return new Xo(this.#e.slice(),this.#t)}add(t){const n=Pl(this.#e,t,this.#t);return this.#e.splice(n,0,t),n}clear(){const t=this.#e.length>0;return this.#e.length=0,t}removeBy(t,n=Number.POSITIVE_INFINITY){let r=0;for(let o=0;o<this.#e.length;o++)if(t(this.#e[o])){if(this.#e.splice(o,1),r++,r>=n)break;o--}return r>0}remove(t){const n=this.#e.indexOf(t);return n>=0&&(this.#e.splice(n,1),!0)}removeAt(t){if(t<0||t>=this.#e.length)return;const[n]=this.#e.splice(t,1);return n}reposition(t){const n=this.#e.indexOf(t);if(n<0)throw new Error("Cannot reposition item that is not in the list");const r=this.#e[n-1],o=this.#e[n+1],i=r===void 0||this.#t(r,t),s=o===void 0||this.#t(t,o);if(i&&s)return n;let a=n;for(;a>0&&this.#t(t,this.#e[a-1]);)this.#e[a]=this.#e[a-1],a--;if(a<n)return this.#e[a]=t,a;for(;a<this.#e.length-1&&!this.#t(t,this.#e[a+1]);)this.#e[a]=this.#e[a+1],a++;return a!==n&&(this.#e[a]=t),a}at(t){return this.#e[t]}get length(){return this.#e.length}includes(t){for(let n=Pl(this.#e,t,this.#t)-1;n>=0&&!this.#t(this.#e[n],t);n--)if(this.#e[n]===t)return!0;return!1}*filter(t){for(const n of this.#e)t(n)&&(yield n)}*findAllRight(t){for(let n=this.#e.length-1;n>=0;n--){const r=this.#e[n];t(r,n)&&(yield r)}}[Symbol.iterator](){return this.#e[Symbol.iterator]()}*iterReversed(){for(let t=this.#e.length-1;t>=0;t--)yield this.#e[t]}find(t,n){const r=this.findIndex(t,n);return r>-1?this.#e.at(r):void 0}findIndex(t,n=0){for(let r=Math.max(0,n);r<this.#e.length;r++)if(t(this.#e[r],r))return r;return-1}findRight(t,n){const r=this.findIndexRight(t,n);return r>-1?this.#e.at(r):void 0}findIndexRight(t,n=this.#e.length-1){for(let r=Math.min(n,this.#e.length-1);r>=0;r--)if(t(this.#e[r],r))return r;return-1}get rawArray(){return this.#e}},Nv=class{#e;#t;signal;constructor(){this.#e=new Map,this.#t=ir.from([],((e,t)=>{const n=t.lastMessageAt??t.createdAt,r=e.lastMessageAt??e.createdAt;return n<r||n===r&&t.id<e.id})),this.signal=new Ot(this)}getEvenIfDeleted(e){return this.signal.get(),this.#e.get(e)}markDeleted(e){const t=this.#e.get(e);t!==void 0&&t.deletedAt===void 0&&this.upsert({...t,deletedAt:new Date().toISOString()})}upsert(e){this.signal.mutate((()=>{const t=this.#e.get(e.id);if(t!==void 0){if(t.deletedAt!==void 0)return!1;this.#t.remove(t),this.#e.delete(t.id)}return e.deletedAt===void 0&&this.#t.add(e),this.#e.set(e.id,e),!0}))}findMany(e){return Array.from(this.#t.filter((t=>{if(e.metadata===void 0)return!0;for(const[n,r]of Object.entries(e.metadata))if(r===null){if(n in t.metadata)return!1}else if(typeof r=="string"){if(t.metadata[n]!==r)return!1}else{const o=t.metadata[n];if(!Array.isArray(o)||!r.every((i=>o.includes(i))))return!1}return!0})))}};function eu(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 Zn(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.comments.map((o=>eu(o)));return{...e,createdAt:t,updatedAt:n,comments:r}}function br(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 Xn(e){const t=new Date(e.createdAt);return{...e,createdAt:t}}function oa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function ia(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function sa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function Nl(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.members.map((o=>({...o,addedAt:new Date(o.addedAt)})));return{...e,createdAt:t,updatedAt:n,members:r}}function Ye(e,t){throw new Error(t)}function ye(e,t="Expected value to be non-nullable"){return e}var st=(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?"_":"-")),""),ue=Object.freeze({INIT:0,SET_PARENT_KEY:1,CREATE_LIST:2,UPDATE_OBJECT:3,CREATE_OBJECT:4,DELETE_CRDT:5,DELETE_OBJECT_KEY:6,CREATE_MAP:7,CREATE_REGISTER:8,CREATE_TEXT:9,UPDATE_TEXT:10,CREATE_FILE:11});function tu(e){return e.type===ue.CREATE_OBJECT||e.type===ue.CREATE_REGISTER||e.type===ue.CREATE_FILE||e.type===ue.CREATE_MAP||e.type===ue.CREATE_LIST||e.type===ue.CREATE_TEXT}var je=Object.freeze({OBJECT:0,LIST:1,MAP:2,REGISTER:3,TEXT:4,FILE:5});function Lv(e){return e[0]==="root"}function Jh(e){return e[1].type===je.OBJECT}function Zh(e){return e[1].type===je.LIST}function Xh(e){return e[1].type===je.MAP}function Yh(e){return e[1].type===je.REGISTER}function Qh(e){return e[1].type===je.TEXT}function ep(e){return e[1].type===je.FILE}function Uv(e){return e[0]==="root"}function*Hv(e){for(const t of e)if(Uv(t))yield[t[0],{type:je.OBJECT,data:t[1]}];else switch(t[1]){case je.OBJECT:yield[t[0],{type:je.OBJECT,parentId:t[2],parentKey:t[3],data:t[4]}];break;case je.LIST:yield[t[0],{type:je.LIST,parentId:t[2],parentKey:t[3]}];break;case je.MAP:yield[t[0],{type:je.MAP,parentId:t[2],parentKey:t[3]}];break;case je.REGISTER:yield[t[0],{type:je.REGISTER,parentId:t[2],parentKey:t[3],data:t[4]}];break;case je.TEXT:yield[t[0],{type:je.TEXT,parentId:t[2],parentKey:t[3],data:t[4],version:t[5]}];break;case je.FILE:yield[t[0],{type:je.FILE,parentId:t[2],parentKey:t[3],data:t[4]}]}}var Oe=Symbol(),Zt={};((e,t)=>{for(var n in t)_v(e,n,{get:t[n],enumerable:!0})})(Zt,{error:()=>Un,errorWithTitle:()=>op,warn:()=>mt,warnWithTitle:()=>Vv});var tp="background:#0e0d12;border-radius:9999px;color:#fff;padding:3px 7px;font-family:sans-serif;font-weight:600;";function np(e){return typeof window>"u"?console[e]:(t,...n)=>console[e]("%cLiveblocks",tp,t,...n)}var mt=np("warn"),Un=np("error");function rp(e){return typeof window>"u"?console[e]:(t,n,...r)=>console[e](`%cLiveblocks%c ${t}`,tp,"font-weight:600",n,...r)}var Vv=rp("warn"),op=rp("error"),Ut=32,Sr=126,Us=uc(0),eo=uc(1),$v=Us+uc(-1);function uc(e){const t=Ut+(e<0?95+e:e);if(t<Ut||t>Sr)throw new Error(`Invalid n value: ${e}`);return String.fromCharCode(t)}function gn(e,t){return e!==void 0&&t!==void 0?(function(n,r){if(n<r)return nu(n,r);if(n>r)return nu(r,n);throw new Error("Cannot compute value between two equal positions")})(e,t):e!==void 0?(function(n){for(let s=0;s<n.length;s++){const a=n.charCodeAt(s);if(a<Ut||a>Sr)return n+eo}for(;n.length>1&&n.charCodeAt(n.length-1)===Ut;)n=n.slice(0,-1);if(n.length===0||n===Us)return eo;let r=Ui;n.length>Ui&&(r=Ui+Math.ceil((n.length-Ui)/aa)*aa);const o=Ll(n,r);if(o!==null)return o;r+=aa;const i=Ll(n,r);return i!==null?i:n+eo})(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<=Ut))return o===r?i===33?n.substring(0,o)+$v:n.substring(0,o)+String.fromCharCode(i-1):n.substring(0,o+1)}return eo})(t):eo}var Ui=2,aa=3;function Ll(e,t){const n=[];for(let i=0;i<t;i++)i<e.length?n.push(e.charCodeAt(i)-Ut):n.push(0);let r=1;for(let i=t-1;i>=0&&r;i--){const s=n[i]+r;s>=95?(n[i]=0,r=1):(n[i]=s,r=0)}if(r)return null;let o="";for(const i of n)o+=String.fromCharCode(i+Ut);for(;o.length>1&&o.charCodeAt(o.length-1)===Ut;)o=o.slice(0,-1);return o}function nu(e,t){let n=0;const r=e.length,o=t.length;for(;;){const i=n<r?e.charCodeAt(n):Ut,s=n<o?t.charCodeAt(n):Sr;if(i!==s){if(s-i==1){const a=n+1;let u=e.substring(0,a);return u.length<a&&(u+=Us.repeat(a-u.length)),u+nu(e.substring(a),"")}return Wv(e,n)+String.fromCharCode(s+i>>1)}n++}}function Wv(e,t){return t<e.length?e.substring(0,t):e+Us.repeat(t-e.length)}function mi(e){return(function(t){if(t==="")return!1;const n=t.length-1,r=t.charCodeAt(n);if(r<33||r>Sr)return!1;for(let o=0;o<n;o++){const i=t.charCodeAt(o);if(i<Ut||i>Sr)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<Ut?Ut:o>Sr?Sr:o)}for(;n.length>0&&n[n.length-1]===Ut;)n.length--;return n.length>0?String.fromCharCode(...n):eo})(e)}var Kt={origin:"remote"},St={origin:"local",via:"edit"},zv={origin:"local",via:"undo"},Kv={origin:"local",via:"redo"};function sn(e){return e.origin==="remote"?e:{origin:"local",via:e.via}}var ip=class{#e=new Map;#t=new Map;#n=new Map;#r=new Set;#o(e,t){return`${e}
|
|
3
|
-
${t}`}get size(){return this.#e.size}get(e){return this.#e.get(e)}add(e){if(this.#e.set(e.opId,e),tu(e)){const t=this.#o(e.parentId,e.parentKey);let n=this.#t.get(t);n===void 0&&(n=new Map,this.#t.set(t,n)),n.set(e.opId,e);let r=this.#n.get(e.parentId);r===void 0&&(r=new Map,this.#n.set(e.parentId,r)),r.set(e.opId,e)}}delete(e){const t=this.#e.get(e);if(t!==void 0&&(this.#e.delete(e),this.#r.delete(e),tu(t))){const n=this.#o(t.parentId,t.parentKey),r=this.#t.get(n);r?.delete(e),r!==void 0&&r.size===0&&this.#t.delete(n);const o=this.#n.get(t.parentId);o?.delete(e),o!==void 0&&o.size===0&&this.#n.delete(t.parentId)}}getByParentIdAndKey(e,t){return this.#t.get(this.#o(e,t))?.values()??[]}getByParentId(e){return this.#n.get(e)?.values()??[]}values(){return this.#e.values()}isPossiblyStored(e){return this.#r.has(e)}markAllAsPossiblyStored(){for(const e of this.#e.keys())this.#r.add(e)}},Ul=new WeakSet;function sp(e){const{getCurrentConnectionId:t,onDispatch:n,isStorageWritable:r=()=>!0,unacknowledgedOps:o=new ip}=e;let i=0,s=0;const a=new Map;return{nodes:a,getNode:u=>a.get(u),addNode:(u,l)=>{a.set(u,l)},deleteNode:u=>{a.delete(u)},generateId:()=>`${t()}:${i++}`,generateOpId:()=>`${t()}:${s++}`,dispatch(u,l,f,c){n?.(u,l,f,c)},assertStorageIsWritable:()=>{if(!r())throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")},unacknowledgedOps:o}}function Hl(e,t,n=mi(t)){return Object.freeze({type:"HasParent",node:e,key:t,pos:n})}var Vl=Object.freeze({type:"NoParent"}),Ro=class{#e;#t;#n=Vl;constructor(){Object.defineProperty(this,Oe,{value:{getId:()=>this.#t},enumerable:!1})}_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 Ye(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 Ye(this.parent,"Unknown state")}}get _pool(){return this.#e}get _id(){return this.#t}get parent(){return this.#n}_warnIfOrphaned(){const e=this;this.parent.type!=="Orphaned"||Ul.has(e)||(Ul.add(e),mt("Cannot sync changes made to this Live structure because it is no longer part of Storage. Retrieve the current value from its parent before mutating it.",{type:e.constructor.name,formerParentKey:this.parent.oldKey}))}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return Ye(this.parent,"Unknown state")}}_apply(e,t){return e.type===ue.DELETE_CRDT&&this.parent.type==="HasParent"?this.parent.node._detachChild(this,sn(t)):{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=Hl(e,t));case"Orphaned":case"NoParent":return void(this.#n=Hl(e,t));default:return Ye(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=mi(e)){return Object.freeze({type:"Orphaned",oldKey:e,oldPos:t})})(this.parent.key,this.parent.pos);break;case"NoParent":this.#n=Vl;break;case"Orphaned":break;default:Ye(this.parent,"Unknown state")}this.#e=void 0}_toOpsWithOpId(e,t,n){return this._toOps(e,t).map((r=>({opId:n.generateOpId(),...r})))}#r;#o;#i;invalidate(){this.#r===void 0&&this.#i===void 0||(this.#r=void 0,this.#i=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toTreeNode(e){return this.#i!==void 0&&this.#o===e||(this.#o=e,this.#i=this._toTreeNode(e)),this.#i}hasCache(e){return this.#r!==void 0&&this.#r===e}toJSON(){return this.#r===void 0&&(this.#r=this._toJSON()),this.#r}};function qv(e){return typeof e=="string"?e:e.id}var mr=class ru extends Ro{#e;constructor(t){super(),this.#e=Object.freeze({...t})}get data(){return this.#e}get id(){return this.#e.id}get name(){return this.#e.name}get size(){return this.#e.size}get mimeType(){return this.#e.mimeType}static _deserialize([t,n],r,o){const i=new ru(n.data);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize LiveFile if parent is missing");return[{type:ue.CREATE_FILE,id:this._id,parentId:t,parentKey:n,data:this.#e}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveFile if parent is missing");return{type:je.FILE,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.#e}}_attachChild(t){throw new Error("A LiveFile node cannot have children")}_detachChild(t){throw new Error("A LiveFile node cannot have children")}_apply(t,n){return super._apply(t,n)}_toTreeNode(t){return{type:"LiveFile",id:this._id??st(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return new ru(this.#e)}};function Gv(e){return e!=null}function gt(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ou(e){return gt(e)&&typeof e.startsWith=="string"}function iu(e){return gt(e)&&(typeof e.lt=="number"||typeof e.gt=="number"||typeof e.lte=="number"||typeof e.gte=="number")}var _o=class ap 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?Ln(n):void 0;let o;gt(r)&&(o=r);let i,s="";s||=typeof o?.message=="string"?o.message:"",s||=typeof o?.error=="string"?o.error:"",r===void 0&&(s||=n||""),s||=t.statusText;try{i=new URL(t.url).pathname}catch{}return s+=i!==void 0?` (got status ${t.status} from ${i})`:` (got status ${t.status})`,new ap(s,t,o)}get status(){return this.response.status}},Jv=e=>e instanceof _o&&e.status>=400&&e.status<500;async function ao(e,t,n,r=Jv){const o=n.length>0?n[n.length-1]:0;let i=0;for(;;){i++;try{return await e()}catch(a){if(r(a))throw a;if(i>=t)throw new Error(`Failed after ${t} attempts: ${String(a)}`)}const s=n[i-1]??o;mt(`Attempt ${i} was unsuccessful. Retrying in ${s} milliseconds.`),await jv(s)}}function up(){let e,t;return[new Promise(((n,r)=>{e=n,t=r})),e,t]}function uo(){const[e,t,n]=up();return{promise:e,resolve:t,reject:n}}function Zv(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 Xt(e){return JSON.stringify(e,Zv)}function _r(e){try{return JSON.stringify(e)}catch(t){throw console.error(`Could not stringify: ${t.message}`),console.error(e),t}}var Xv=class{input;resolve;reject;promise;constructor(e){this.input=e;const{promise:t,resolve:n,reject:r}=uo();this.promise=t,this.resolve=n,this.reject=r}},or=class{#e=[];#t;#n;#r;#o;error=!1;constructor(e,t){this.#t=e,this.#n=t.size??50,this.#r=t.delay}#i(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#s(){this.#e.length===this.#n?this.#u():this.#e.length===1&&(this.#i(),this.#o=setTimeout((()=>{this.#u()}),this.#r))}async#u(){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=>Xt(r.input)===Xt(e)));if(t)return t.promise;const n=new Xv(e);return this.#e.push(n),this.#s(),n.promise}clear(){this.#e=[],this.error=!1,this.#i()}};function fo(e,t){const n=new Ot(new Map),r=new Map,o=new Map;function i(f){return Xt(f)}function s(f){n.mutate((c=>{if(Array.isArray(f))for(const d of f)c.set(d.key,d.state);else c.set(f.key,f.state)}))}function a(f){const c=r.get(f);c!==void 0&&(clearTimeout(c),r.delete(f))}function u(f,c){const d=i(f);if(a(d),c===void 0||!Number.isFinite(c))return;const h=setTimeout((()=>{r.delete(d),l([f])}),Math.max(0,c-Date.now()));r.set(d,h)}function l(f){if(Array.isArray(f))for(const c of f){const d=i(c);a(d),o.delete(d)}else{for(const c of r.values())clearTimeout(c);r.clear(),o.clear()}n.mutate((c=>{if(Array.isArray(f))for(const d of f)c.delete(i(d));else c.clear()}))}return{subscribe:n.subscribe,enqueue:function(f){const c=i(f),d=o.get(c);if(d!==void 0)return d.promise;if(n.get().has(c))return Promise.resolve();const h=e.get(f),g=Symbol(),y=(async function(p,w,b,C){try{const E=await b;if(o.get(w)?.id!==C)return;s({key:w,state:{isLoading:!1,data:E}}),u(p,t?.getCacheExpiry?.(E))}catch(E){if(o.get(w)?.id!==C)return;u(p,t?.getErrorCacheExpiry?.(E)),s({key:w,state:{isLoading:!1,error:E}})}finally{o.get(w)?.id===C&&o.delete(w)}})(f,c,h,g);return o.set(c,{id:g,promise:y}),s({key:c,state:{isLoading:!0}}),y},setData:function(f){s(f.map((c=>({key:i(c[0]),state:{isLoading:!1,data:c[1]}}))));for(const[c,d]of f)u(c,t?.getCacheExpiry?.(d))},getItemState:function(f){const c=i(f);return n.get().get(c)},getData:function(f){const c=i(f);return n.get().get(c)?.data},waitUntilItemCacheExpires:function(f){const c=i(f);if(!r.has(c))return;const d=n.get().get(c);return new Promise((h=>{const g=n.subscribe((()=>{n.get().get(c)!==d&&(g(),h())}))}))},invalidate:l,batch:e,_cacheKeys:function(){return[...n.get().keys()]}}}function Hs(e){return`${e}_${st()}`}function cp(){return Hs("th")}function Ds(){return Hs("cm")}function lp(){return Hs("at")}var He=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??dn("DefaultMap used without a factory function"))(e);return this.set(e,n),n}}},Yv=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function Wr(e){let t=[];const n=Object.entries(e),r=[],o=[],i=[];return n.forEach((([s,a])=>{if(!Yv.test(s))throw new Error("Key must only contain letters, numbers, _");zl(a)?r.push([s,a]):gt(a)&&(ou(a)||iu(a)?o.push([s,a]):i.push([s,a]))})),t=[...$l(r),...Wl(o)],i.forEach((([s,a])=>{const u=Object.entries(a),l=[],f=[];u.forEach((([c,d])=>{if(Qv(c))throw new Error("Key cannot be empty");zl(d)?l.push([Kl(s,c),d]):(ou(d)||iu(d))&&f.push([Kl(s,c),d])})),t=[...t,...$l(l),...Wl(f)]})),t.map((({key:s,operator:a,value:u})=>`${s}${a}${dp(u)}`)).join(" ")}var $l=e=>{const t=[];return e.forEach((([n,r])=>{t.push({key:n,operator:":",value:r})})),t},Wl=e=>{const t=[];return e.forEach((([n,r])=>{"startsWith"in r&&typeof r.startsWith=="string"&&t.push({key:n,operator:"^",value:r.startsWith}),"lt"in r&&typeof r.lt=="number"&&t.push({key:n,operator:"<",value:r.lt}),"gt"in r&&typeof r.gt=="number"&&t.push({key:n,operator:">",value:r.gt}),"gte"in r&&typeof r.gte=="number"&&t.push({key:n,operator:">=",value:r.gte}),"lte"in r&&typeof r.lte=="number"&&t.push({key:n,operator:"<=",value:r.lte})})),t},zl=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Kl=(e,t)=>t?`${e}[${dp(t)}]`:e,Qv=e=>!e||e.toString().trim()==="";function dp(e){const t=JSON.stringify(e);return typeof e!="string"||t.includes("'")?t:`'${t.slice(1,-1).replace(/\\"/g,'"')}'`}var e1=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,t1=/\/(?:(?:\?|#).*)?$/;function n1(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[s,a]of Object.entries(o))a!=null&&i.set(s,a.toString());return i})(n)).toString()),r.toString()}function De(e,...t){return e.reduce(((n,r,o)=>n+encodeURIComponent(t[o-1]??"")+r))}function fp(e){if(e.startsWith("www.")&&(e="https://"+e),e==="#")return e;try{const t=e1.test(e),n=new URL(e,t?void 0:"https://localhost:9999");if(n.protocol!=="http:"&&n.protocol!=="https:")return null;const r=t1.test(e),o=(t?n.origin:"")+(n.pathname==="/"?r?"/":"":r&&!n.pathname.endsWith("/")?n.pathname+"/":n.pathname)+n.search+n.hash;return o!==""?o:null}catch{return null}}var ql=5242880,Hi=[2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3],Gl=class extends Error{};async function Jl({file:e,signal:t,abortErrorMessage:n,retryMultipartCompletion:r,uploadSingle:o,createMultipartUpload:i,uploadMultipartPart:s,completeMultipartUpload:a,abortMultipartUpload:u}){const l=(function(b){if(typeof DOMException=="function")return new DOMException(b,"AbortError");const C=new Error(b);return C.name="AbortError",C})(n);if(t?.aborted)throw l;const f=b=>{if(t?.aborted)throw l;return b instanceof _o&&b.status>=400&&b.status<500};if(e.size<=ql)return ao(o,10,Hi,f);let c;const d=[],h=await ao(i,10,Hi,f),g=new AbortController,y=g.signal,p=b=>{g.abort(b)},w=()=>p();t?.aborted?w():t?.addEventListener("abort",w,{once:!0});try{if(c=h.uploadId,t?.aborted)throw l;const b=(function(E,A){const x=[];for(let I=0,T=E.length;I<T;I+=A)x.push(E.slice(I,I+A));return x})((function(E){const A=[];let x=0;for(;x<E.size;){const I=Math.min(x+ql,E.size);A.push({partNumber:A.length+1,part:E.slice(x,I)}),x=I}return A})(e),5);for(const E of b){const A={},x=[];for(const{part:T,partNumber:F}of E)x.push(ao((()=>s(h.uploadId,F,T,y)),10,Hi,(S=>{if(t?.aborted)throw l;return y.aborted||f(S)})).catch((S=>{throw A.value===void 0&&(A.value={error:S},p(S)),S})));const I=await Promise.allSettled(x);if(A.value!==void 0)throw A.value.error;for(const T of I)T.status==="fulfilled"&&d.push(T.value)}if(t?.aborted)throw l;const C=d.sort(((E,A)=>E.partNumber-A.partNumber));return r?ao((()=>a(h.uploadId,C)),10,Hi,f):a(c,C)}catch(b){if(c)try{await u(c)}catch{}throw b}finally{t?.removeEventListener("abort",w)}}function zt(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function r1({baseUrl:e,authManager:t,fetchPolyfill:n}){const r=new o1(e,n),o=new He((d=>fo(new or((async h=>{const g=h.flat(),{urls:y}=await r.post(De`/v2/c/rooms/${d}/attachments/presigned-urls`,await t.getAuthValue({roomId:d,resource:"comments",access:"read"}),{attachmentIds:g});return y.map((p=>p??new Error("There was an error while getting this attachment's URL")))}),{delay:50}))));function i(d){return o.getOrCreate(d)}const s=new He((d=>{const h=new Map,g=new or((async y=>{const p=y.flat(),{urls:w,expiresAt:b}=await r.post(De`/v2/c/rooms/${d}/storage/files/presigned-urls`,await t.getAuthValue({roomId:d,resource:"storage",access:"read"}),{fileIds:p}),C=Date.parse(b);return w.map(((E,A)=>{const x=p[A];return E===!1?(I=>{const T=h.get(I);T!==void 0&&clearTimeout(T.cleanupTimeoutId);const F=(T?.count??0)+1;return F>=3?(h.delete(I),!1):(h.set(I,{count:F,cleanupTimeoutId:setTimeout((()=>h.delete(I)),3e4)}),!0)})(x)?new Gl("There was an error while getting this file's URL"):new Error("There was an error while getting this file's URL"):((I=>{const T=h.get(I);T!==void 0&&(clearTimeout(T.cleanupTimeoutId),h.delete(I))})(x),E!==null?{url:E,expiresAt:C}:new Error("There was an error while getting this file's URL"))}))}),{delay:50});return fo(g,{getCacheExpiry:({expiresAt:y})=>y-3e4,getErrorCacheExpiry:y=>y instanceof Gl?Date.now()+1e3:void 0})}));function a(d){return s.getOrCreate(d)}const u=new He((d=>new or((async h=>{const g=h.flat();return await r.post(De`/v2/c/rooms/${d}/inbox-notifications/read`,await t.getAuthValue({roomId:d,resource:"comments",access:"read"}),{inboxNotificationIds:g}),g}),{delay:50}))),l=new or((async d=>{const h=d.flat();return await(async function(g){await r.post(De`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:g})})(h),h}),{delay:50}),f=new or((async d=>{const h=d.flat(),{groups:g}=await r.post(De`/v2/c/groups/find`,await t.getAuthValue({resource:"personal",access:"write"}),{groupIds:h}),y=new Map;for(const p of g)y.set(p.id,Nl(p));return h.map((p=>y.get(p)))}),{delay:50}),c=fo(f);return{getThreads:async function(d){let h;d.query&&(h=Wr(d.query));try{const g=await r.get(De`/v2/c/rooms/${d.roomId}/threads`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.query?.visibility),access:"read"}),{cursor:d.cursor,query:h,limit:50});return{threads:g.data.map(Zn),inboxNotifications:g.inboxNotifications.map(br),subscriptions:g.subscriptions.map(Xn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt),permissionHints:g.meta.permissionHints}}catch(g){if(g instanceof _o&&g.status===404)return{threads:[],inboxNotifications:[],subscriptions:[],nextCursor:null,requestedAt:new Date(Date.now()-216e5),permissionHints:{}};throw g}},getThreadsSince:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/threads/delta`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),{since:d.since.toISOString()},{signal:d.signal});return{threads:{updated:h.data.map(Zn),deleted:h.deletedThreads.map(oa)},inboxNotifications:{updated:h.inboxNotifications.map(br),deleted:h.deletedInboxNotifications.map(ia)},subscriptions:{updated:h.subscriptions.map(Xn),deleted:h.deletedSubscriptions.map(sa)},requestedAt:new Date(h.meta.requestedAt),permissionHints:h.meta.permissionHints}},searchComments:async function(d,h){return await r.get(De`/v2/c/rooms/${d.roomId}/threads/comments/search`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),{text:d.query.text,query:Wr({threadMetadata:d.query.threadMetadata,threadResolved:d.query.threadResolved,hasAttachments:d.query.hasAttachments,hasMentions:d.query.hasMentions})},{signal:h?.signal})},createThread:async function(d){const h=d.commentId??Ds(),g=d.threadId??cp();return Zn(await r.post(De`/v2/c/rooms/${d.roomId}/threads`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility??"public"),access:"write"}),{id:g,visibility:d.visibility,comment:{id:h,body:d.body,metadata:d.commentMetadata,attachmentIds:d.attachmentIds},metadata:d.metadata}))},getThread:async function(d){const h=await r.rawGet(De`/v2/c/rooms/${d.roomId}/thread-with-notification/${d.threadId}`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}));if(h.ok){const g=await h.json();return{thread:Zn(g.thread),inboxNotification:g.inboxNotification?br(g.inboxNotification):void 0,subscription:g.subscription?Xn(g.subscription):void 0}}if(h.status===404)return{thread:void 0,inboxNotification:void 0,subscription:void 0};throw new Error(`There was an error while getting thread ${d.threadId}.`)},deleteThread:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},editThreadMetadata:async function(d){return await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/metadata`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),d.metadata)},createComment:async function(d){const h=d.commentId??Ds();return eu(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),{id:h,body:d.body,metadata:d.metadata,attachmentIds:d.attachmentIds}))},editComment:async function(d){return eu(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),{body:d.body,attachmentIds:d.attachmentIds,metadata:d.metadata}))},editCommentMetadata:async function(d){return await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/metadata`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),d.metadata)},deleteComment:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},addReaction:async function(d){return g=await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/reactions`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),{emoji:d.emoji}),{...g,createdAt:new Date(g.createdAt)};var g},removeReaction:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/reactions/${d.emoji}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},markThreadAsResolved:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/mark-as-resolved`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},markThreadAsUnresolved:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/mark-as-unresolved`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},subscribeToThread:async function(d){return Xn(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/subscribe`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"})))},unsubscribeFromThread:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/unsubscribe`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}))},markRoomInboxNotificationAsRead:async function(d){return u.getOrCreate(d.roomId).get(d.inboxNotificationId)},getSubscriptionSettings:async function(d){return r.get(De`/v2/c/rooms/${d.roomId}/subscription-settings`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),void 0,{signal:d.signal})},updateSubscriptionSettings:async function(d){return r.post(De`/v2/c/rooms/${d.roomId}/subscription-settings`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),d.settings)},createTextMention:async function(d){if(d.mention.kind!=="user"&&d.mention.kind!=="group")return Ye(d.mention,"Unexpected mention kind");await r.rawPost(De`/v2/c/rooms/${d.roomId}/text-mentions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}),{userId:d.mention.kind==="user"?d.mention.id:void 0,groupId:d.mention.kind==="group"?d.mention.id:void 0,userIds:d.mention.kind==="group"?d.mention.userIds:void 0,mentionId:d.mentionId})},deleteTextMention:async function(d){await r.rawDelete(De`/v2/c/rooms/${d.roomId}/text-mentions/${d.mentionId}`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},fetchStorageHistoryVersion:async function(d){return r.rawGet(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}/storage`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))},fetchYjsHistoryVersion:async function(d){return r.rawGet(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}/yjs`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))},createVersionHistorySnapshot:async function(d){await r.rawPost(De`/v2/c/rooms/${d.roomId}/versions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},deleteHistoryVersion:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},reportTextEditor:async function(d){await r.rawPost(De`/v2/c/rooms/${d.roomId}/text-metadata`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{type:d.type,rootKey:d.rootKey})},listHistoryVersions:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/versions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}));return{versions:h.versions.map((({createdAt:g,...y})=>({createdAt:new Date(g),...y}))),requestedAt:new Date(h.meta.requestedAt)}},listHistoryVersionsSince:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/versions/delta`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{since:d.since.toISOString()},{signal:d.signal});return{versions:h.versions.map((({createdAt:g,...y})=>({createdAt:new Date(g),...y}))),requestedAt:new Date(h.meta.requestedAt)}},getAttachmentUrl:function(d){return i(d.roomId).batch.get(d.attachmentId)},uploadAttachment:async function(d){const h=d.roomId,g=d.attachment;return Jl({file:g.file,signal:d.signal,abortErrorMessage:`Upload of attachment ${g.id} was aborted.`,retryMultipartCompletion:!1,uploadSingle:async()=>r.putBlob(De`/v2/c/rooms/${h}/attachments/${g.id}/upload/${g.name}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),g.file,{fileSize:g.size},{signal:d.signal}),createMultipartUpload:async()=>r.post(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${g.name}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),void 0,{signal:d.signal},{fileSize:g.size}),uploadMultipartPart:async(y,p,w,b)=>r.putBlob(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}/${String(p)}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),w,void 0,{signal:b}),completeMultipartUpload:async(y,p)=>r.post(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}/complete`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),{parts:p},{signal:d.signal}),abortMultipartUpload:async y=>{await r.rawDelete(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}))}})},getOrCreateAttachmentUrlsStore:i,getFileUrl:async function(d){return(await a(d.roomId).batch.get(d.fileId)).url},uploadFile:async function(d){const h=d.roomId,g=d.file,y=Hs("fl"),p=await Jl({file:g,signal:d.signal,abortErrorMessage:`Upload of file ${y} was aborted.`,retryMultipartCompletion:!0,uploadSingle:async()=>r.putBlob(De`/v2/c/rooms/${h}/storage/files/${y}/upload/${g.name}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),g,{fileSize:g.size},{signal:d.signal}),createMultipartUpload:async()=>r.post(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${g.name}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),void 0,{signal:d.signal},{fileSize:g.size}),uploadMultipartPart:async(w,b,C,E)=>r.putBlob(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}/${String(b)}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),C,void 0,{signal:E}),completeMultipartUpload:async(w,b)=>r.post(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}/complete`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),{parts:b},{signal:d.signal}),abortMultipartUpload:async w=>{await r.rawDelete(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}))}});return new mr(p)},getOrCreateFileUrlsStore:a,streamStorage:async function(d){return await(await r.rawGet(De`/v2/c/rooms/${d.roomId}/storage`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))).json()},getInboxNotifications:async function(d){let h;d?.query&&(h=Wr(d.query));const g=await r.get(De`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:d?.cursor,limit:50,query:h}),y=g.groups.map(Nl);return c.setData(y.map((p=>[p.id,p]))),{inboxNotifications:g.inboxNotifications.map(br),threads:g.threads.map(Zn),subscriptions:g.subscriptions.map(Xn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt)}},getInboxNotificationsSince:async function(d){let h;d?.query&&(h=Wr(d.query));const g=await r.get(De`/v2/c/inbox-notifications/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:d.since.toISOString(),query:h},{signal:d.signal});return{inboxNotifications:{updated:g.inboxNotifications.map(br),deleted:g.deletedInboxNotifications.map(ia)},threads:{updated:g.threads.map(Zn),deleted:g.deletedThreads.map(oa)},subscriptions:{updated:g.subscriptions.map(Xn),deleted:g.deletedSubscriptions.map(sa)},requestedAt:new Date(g.meta.requestedAt)}},getUnreadInboxNotificationsCount:async function(d){let h;d?.query&&(h=Wr(d.query));const{count:g}=await r.get(De`/v2/c/inbox-notifications/count`,await t.getAuthValue({resource:"personal",access:"write"}),{query:h},{signal:d?.signal});return g},markAllInboxNotificationsAsRead:async function(){await r.post(De`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:"all"})},markInboxNotificationAsRead:async function(d){await l.get(d)},deleteAllInboxNotifications:async function(){await r.delete(De`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}))},deleteInboxNotification:async function(d){await r.delete(De`/v2/c/inbox-notifications/${d}`,await t.getAuthValue({resource:"personal",access:"write"}))},getNotificationSettings:async function(d){return r.get(De`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),void 0,{signal:d?.signal})},updateNotificationSettings:async function(d){return r.post(De`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),d)},getUserThreads_experimental:async function(d){let h;d?.query&&(h=Wr(d.query));const g=await r.get(De`/v2/c/threads`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:d?.cursor,query:h,limit:50});return{threads:g.threads.map(Zn),inboxNotifications:g.inboxNotifications.map(br),subscriptions:g.subscriptions.map(Xn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt),permissionHints:g.meta.permissionHints}},getUserThreadsSince_experimental:async function(d){const h=await r.get(De`/v2/c/threads/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:d.since.toISOString()},{signal:d.signal});return{threads:{updated:h.threads.map(Zn),deleted:h.deletedThreads.map(oa)},inboxNotifications:{updated:h.inboxNotifications.map(br),deleted:h.deletedInboxNotifications.map(ia)},subscriptions:{updated:h.subscriptions.map(Xn),deleted:h.deletedSubscriptions.map(sa)},requestedAt:new Date(h.meta.requestedAt),permissionHints:h.meta.permissionHints}},groupsStore:c,getGroup:function(d){return f.get(d)},executeContextualPrompt:async function(d){const h=await r.post(De`/v2/c/rooms/${d.roomId}/ai/contextual-prompt`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{prompt:d.prompt,context:{beforeSelection:d.context.beforeSelection,selection:d.context.selection,afterSelection:d.context.afterSelection},previous:d.previous},{signal:d.signal});if(!h||h.content.length===0)throw new Error("No content returned from server");return h.content[0].text},getUrlMetadata:async function(d){const{metadata:h}=await r.get(De`/v2/c/urls/metadata`,await t.getAuthValue({resource:"personal",access:"write"}),{url:d});return h}}}function cc(e){return e.type==="public"?e.publicApiKey:e.token.raw}var o1=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){e.startsWith("/v2/c/")||dn("This client can only be used to make /v2/c/* requests");const o=n1(this.#e,e,r),i=await this.#t(o,{...n,headers:{"Content-Type":"application/json; charset=utf-8",...n?.headers,Authorization:`Bearer ${cc(t)}`,"X-LB-Client":Ls}}),s=i.headers.get("X-LB-Warn");if(s){const a=`${s} (${n?.method?.toUpperCase()??"GET"} ${e})`;i.ok?mt(a):Un(a)}return i}async#r(e,t,n,r){const o=await this.#n(e,t,n,r);if(!o.ok)throw await _o.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:_r(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:_r(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)}},Ir=Symbol("fsm.ignore"),i1=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,s]=o;i!=="patch"&&(this[i]=s)}}}),n=!1}},s1=1,hp=class{id;#e;#t;#n;#r;#o;#i;events;#s;#u;#a;#c;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.#h(null),this}stop(){if(this.#e!==1)throw new Error("Cannot stop a state machine that hasn't started yet");this.#p(null),this.#e=2,this.#r=null}constructor(e){this.id=s1++,this.#e=0,this.#r=null,this.#n=new Set,this.#a=new Map,this.#s=[],this.#u=[],this.#c=new Set,this.#o=new Map,this.#t=new i1(e),this.#i={didReceiveEvent:Ue(),willTransition:Ue(),didIgnoreUnexpectedEvent:Ue(),willExitState:Ue(),didEnterState:Ue(),didExitState:Ue()},this.events={didReceiveEvent:this.#i.didReceiveEvent.observable,willTransition:this.#i.willTransition.observable,didIgnoreUnexpectedEvent:this.#i.didIgnoreUnexpectedEvent.observable,willExitState:this.#i.willExitState.observable,didEnterState:this.#i.didEnterState.observable,didExitState:this.#i.didExitState.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,s=i.signal,a=o?setTimeout((()=>{const l=new Error("Timed out");this.#d({type:"ASYNC_ERROR",reason:l},r)}),o):void 0;let u=!1;return t(this.#t.current,s).then((l=>{s.aborted||(u=!0,this.#d({type:"ASYNC_OK",data:l},n))}),(l=>{s.aborted||(u=!0,this.#d({type:"ASYNC_ERROR",reason:l},r))})),()=>{clearTimeout(a),u||i.abort()}}))}#m(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.#m(e)){let r=this.#o.get(n);r===void 0&&(r=new Map,this.#o.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 s=i;if(this.#c.add(o),s!==void 0)if(s===Ir)r.set(o,Ir);else{const a=typeof s=="function"?s:()=>s;r.set(o,a)}}}return this}addTimedTransition(e,t,n){return this.onEnter(e,(()=>{const r=typeof t=="function"?t(this.#t.current):t,o=setTimeout((()=>{this.#d({type:"TIMER"},n)}),r);return()=>{clearTimeout(o)}}))}#g(e){return this.#o.get(this.currentState)?.get(e)}#p(e){this.#i.willExitState.notify(this.currentState);const t=performance.now(),n=this.currentState.split(".");this.#t.allowPatching((r=>{e=e??this.#s.length;for(let o=0;o<e;o++){this.#s.pop()?.(r);const i=this.#u.pop();if(i!==void 0&&this.#i.didExitState.count()>0){const s=this.#u.length;if(s===0)continue;const a=s===n.length?this.currentState:`${n.slice(0,s).join(".")}.*`;this.#i.didExitState.notify({state:a,durationMs:t-i})}}}))}#h(e){const t=(function(r,o){const i=r.split(".");if(o<1||o>i.length+1)throw new Error("Invalid number of levels");const s=[];o>i.length&&s.push("*");for(let a=i.length-o+1;a<i.length;a++){const u=i.slice(0,a);u.length>0&&s.push(u.join(".")+".*")}return s.push(r),s})(this.currentState,e??this.currentState.split(".").length+1),n=performance.now();this.#t.allowPatching((r=>{for(const o of t){const i=this.#a.get(o),s=i?.(r);typeof s=="function"?this.#s.push(s):this.#s.push(null),this.#u.push(n)}})),this.#i.didEnterState.notify(this.currentState)}send(e){if(!this.#c.has(e.type))throw new Error(`Invalid event ${JSON.stringify(e.type)}`);if(this.#e===2)return;const t=this.#g(e.type);return t!==Ir?t!==void 0?this.#d(e,t):void this.#i.didIgnoreUnexpectedEvent.notify(e):void 0}#d(e,t){this.#i.didReceiveEvent.notify(e);const n=this.currentState,r=(typeof t=="function"?t:()=>t)(e,this.#t.current);let o,i;if(r===Ir)return;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.#i.willTransition.notify({from:n,to:o});const[s,a]=(function(u,l){if(u===l)return[0,0];const f=u.split("."),c=l.split("."),d=Math.min(f.length,c.length);let h=0;for(;h<d&&f[h]===c[h];h++);return[f.length-h,c.length-h]})(this.currentState,o);if(s>0&&this.#p(s),this.#r=o,i!==void 0){const u=i;this.#t.allowPatching((l=>{for(const f of u)typeof f=="function"?f(l,e):l.patch(f)}))}a>0&&this.#h(a)}},xe=Object.freeze({UPDATE_PRESENCE:100,USER_JOINED:101,USER_LEFT:102,BROADCASTED_EVENT:103,ROOM_STATE:104,STORAGE_STATE_V7:200,STORAGE_CHUNK:210,STORAGE_STREAM_END:211,UPDATE_STORAGE:201,UPDATE_YDOC:300,THREAD_CREATED:400,THREAD_DELETED:407,THREAD_METADATA_UPDATED:401,THREAD_UPDATED:408,COMMENT_CREATED:402,COMMENT_EDITED:403,COMMENT_DELETED:404,COMMENT_REACTION_ADDED:405,COMMENT_REACTION_REMOVED:406,COMMENT_METADATA_UPDATED:409,FEEDS_LIST:500,FEEDS_ADDED:501,FEEDS_UPDATED:502,FEED_DELETED:503,FEED_MESSAGES_LIST:504,FEED_MESSAGES_ADDED:505,FEED_MESSAGES_UPDATED:506,FEED_MESSAGES_DELETED:507,FEED_REQUEST_FAILED:508,REJECT_STORAGE_OP:299});function Zl(e){return e===4999||e>=4e3&&e<4100}function Xl(e){return e===1013||e>=4200&&e<4300}function pp(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 Ye(0,"Unknown state")}}var mp=[250,500,1e3,2e3,4e3,8e3,1e4],Vi=mp[0]-1,a1=[2e3,3e4,6e4,3e5],jn=class extends Error{constructor(e){super(e)}};function gp(e,t){return t.find((n=>n>e))??t[t.length-1]}function zr(e){e.patch({backoffDelay:gp(e.backoffDelay,mp)})}function Yl(e){e.patch({backoffDelay:gp(e.backoffDelay,a1)})}function Ql(e){e.patch({successCount:0})}function to(e,t){const n=e===2?Un:e===1?mt:()=>{};return()=>{n(t)}}function ed(e){const t="Connection to Liveblocks websocket server";return n=>{vp(e)?mt(`${t} closed prematurely (code: ${e.code}). Retrying in ${n.backoffDelay}ms.`):mt(`${t} could not be established.`,e)}}function ua(e){const t=[`code: ${e.code}`];return e.reason&&t.push(`reason: ${e.reason}`),n=>{mt(`Connection to Liveblocks websocket server closed (${t.join(", ")}). Retrying in ${n.backoffDelay}ms.`)}}var u1=to(1,"Connection to WebSocket closed permanently. Won't retry.");function vp(e){return!(e instanceof Error)&&e.type==="close"}var $i=e=>t=>t.patch(e);function c1(e,t){const n=(function(){const w=Ue();let b=null;return{...w,notify:function(C){return b!==null?(b.push(C),!1):w.notify(C)},pause:function(){b=[]},unpause:function(){if(b!==null){for(const C of b)w.notify(C);b=null}},dispose(){w.dispose(),b!==null&&(b.length=0)}}})();n.pause();const r=Ue();function o(w,b){return()=>{r.notify({message:w,code:b})}}const i=new hp({successCount:0,authValue:null,socket:null,backoffDelay:Vi}).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:[zr,Ql]},DISCONNECT:"@idle.initial"}),i.onEnter("@idle.*",Ql).addTransitions("@idle.*",{CONNECT:(w,b)=>b.authValue!==null?"@connecting.busy":"@auth.busy"}),i.addTransitions("@auth.backoff",{NAVIGATOR_ONLINE:{target:"@auth.busy",effect:$i({backoffDelay:Vi})}}).addTimedTransition("@auth.backoff",(w=>w.backoffDelay),"@auth.busy").onEnterAsync("@auth.busy",(()=>jl(e.authenticate(),1e4,"Timed out during auth")),(w=>({target:"@connecting.busy",effect:$i({authValue:w.data})})),(w=>w.reason instanceof jn?{target:"@idle.failed",effect:[to(2,w.reason.message),o(w.reason.message,-1)]}:{target:"@auth.backoff",effect:[zr,to(2,`Authentication failed: ${w.reason instanceof Error?w.reason.message:String(w.reason)}`)]}));const s=w=>i.send({type:"EXPLICIT_SOCKET_ERROR",event:w}),a=w=>i.send({type:"EXPLICIT_SOCKET_CLOSE",event:w}),u=w=>{i.send({type:"ALIVE"}),w.data!=="pong"&&n.notify(w)};function l(w){w&&(w.removeEventListener("error",s),w.removeEventListener("close",a),w.removeEventListener("message",u),w.close())}i.addTransitions("@connecting.backoff",{NAVIGATOR_ONLINE:{target:"@connecting.busy",effect:$i({backoffDelay:Vi})}}).addTimedTransition("@connecting.backoff",(w=>w.backoffDelay),"@connecting.busy").onEnterAsync("@connecting.busy",(async(w,b)=>{const C=performance.now();let E=null,A=null,x=null;return jl(new Promise(((I,T)=>{if(w.authValue===null)throw new Error("No auth authValue");const F=e.createSocket(w.authValue);function S(H){A=H,F.removeEventListener("message",u),T(H)}x=F;const[k,_]=up();function M(H){if(Ln(H.data)?.type===xe.ROOM_STATE){if(t.enableDebugLogging&&E!==null){const G=performance.now()-E;mt(`[FSM #${i.id}] Socket open → ROOM_STATE: ${G.toFixed(0)}ms`)}_()}}t.waitForActorId||_(),F.addEventListener("message",u),t.waitForActorId&&F.addEventListener("message",M),F.addEventListener("error",S),F.addEventListener("close",S),F.addEventListener("open",(()=>{if(E=performance.now(),t.enableDebugLogging){const W=E-C;mt(`[FSM #${i.id}] Socket epoch → open: ${W.toFixed(0)}ms`)}F.addEventListener("error",s),F.addEventListener("close",a);const H=()=>{F.removeEventListener("error",S),F.removeEventListener("close",S),F.removeEventListener("message",M)};k.then((()=>{I([F,H])}))}))})),2e4,"Timed out during websocket connection").then((([I,T])=>{if(T(),b.aborted)throw new Error("Aborted");if(A)throw A;return I})).catch((I=>{throw l(x),I}))}),(w=>({target:"@ok.connected",effect:$i({socket:w.data,backoffDelay:Vi})})),(w=>{const b=w.reason;if(b instanceof jn)return{target:"@idle.failed",effect:[to(2,b.message),o(b.message,-1)]};if(vp(b)){if(b.code===4109)return"@auth.busy";if(Xl(b.code))return{target:"@connecting.backoff",effect:[Yl,ed(b)]};if(Zl(b.code))return{target:"@idle.failed",effect:[to(2,b.reason),o(b.reason,b.code)]}}return{target:"@auth.backoff",effect:[zr,ed(b)]}})).addTransitions("@connecting.busy",{ALIVE:Ir});const f={target:"@ok.awaiting-pong",effect:w=>{w.socket?.send("ping")}},c=()=>(typeof document<"u"?document:void 0)?.visibilityState==="hidden"&&e.canZombie()?"@idle.zombie":f;if(i.addTimedTransition("@ok.connected",3e4,c).addTransitions("@ok.connected",{NAVIGATOR_OFFLINE:c,WINDOW_GOT_FOCUS:f,ALIVE:Ir}),i.addTransitions("@idle.zombie",{WINDOW_GOT_FOCUS:"@connecting.backoff"}),i.onEnter("@ok.*",(w=>{w.patch({successCount:w.successCount+1});const b=setTimeout(n.unpause,0);return C=>{l(C.socket),C.patch({socket:null}),clearTimeout(b),n.pause()}})).addTransitions("@ok.awaiting-pong",{ALIVE:"@ok.connected"}).addTimedTransition("@ok.awaiting-pong",2e3,{target:"@connecting.busy",effect:to(1,"Received no pong from server, assume implicit connection loss.")}).addTransitions("@ok.*",{EXPLICIT_SOCKET_ERROR:(w,b)=>b.socket?.readyState===1?Ir:{target:"@connecting.backoff",effect:zr},EXPLICIT_SOCKET_CLOSE:w=>{return Zl(w.event.code)?{target:"@idle.failed",effect:[u1,o(w.event.reason,w.event.code)]}:(b=w.event.code)>=4100&&b<4200?w.event.code===4109?"@auth.busy":{target:"@auth.backoff",effect:[zr,ua(w.event)]}:Xl(w.event.code)?{target:"@connecting.backoff",effect:[Yl,ua(w.event)]}:{target:"@connecting.backoff",effect:[zr,ua(w.event)]};var b}}),typeof document<"u"){const w=typeof document<"u"?document:void 0,b=typeof window<"u"?window:void 0,C=b??w;i.onEnter("*",(E=>{function A(){i.send({type:"NAVIGATOR_OFFLINE"})}function x(){i.send({type:"NAVIGATOR_ONLINE"})}function I(){w?.visibilityState==="visible"&&i.send({type:"WINDOW_GOT_FOCUS"})}return b?.addEventListener("online",x),b?.addEventListener("offline",A),C?.addEventListener("visibilitychange",I),()=>{C?.removeEventListener("visibilitychange",I),b?.removeEventListener("online",x),b?.removeEventListener("offline",A),l(E.socket)}}))}const d=[],{statusDidChange:h,didConnect:g,didDisconnect:y,unsubscribe:p}=(function(w){const b=Ue(),C=Ue(),E=Ue();let A=null;const x=w.events.didEnterState.subscribe((()=>{const I=pp(w);I!==A&&b.notify(I),A==="connected"&&I!=="connected"?E.notify():A!=="connected"&&I==="connected"&&C.notify(),A=I}));return{statusDidChange:b.observable,didConnect:C.observable,didDisconnect:E.observable,unsubscribe:x}})(i);return d.push(p),t.enableDebugLogging&&d.push((function(w){function b(...E){mt(`[FSM #${w.id}]`,...E)}const C=[w.events.didReceiveEvent.subscribe((E=>b(`Event ${E.type}`))),w.events.willTransition.subscribe((({from:E,to:A})=>b("Transitioning",E,"→",A))),w.events.didExitState.subscribe((({state:E,durationMs:A})=>b(`Exited ${E} after ${A.toFixed(0)}ms`))),w.events.didIgnoreUnexpectedEvent.subscribe((E=>b("Ignored unexpected event",E.type,E,"(no transition declared)")))];return()=>{for(const E of C)E()}})(i)),i.start(),{machine:i,cleanups:d,events:{statusDidChange:h,didConnect:g,didDisconnect:y,onMessage:n.observable,onConnectionError:r.observable}}}var yp=class{#e;#t;events;constructor(e,t=!1,n=!0){const{machine:r,events:o,cleanups:i}=c1(e,{waitForActorId:n,enableDebugLogging:t});this.#e=r,this.events=o,this.#t=i}getStatus(){try{return pp(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?mt("Cannot send: not connected yet",e):t.readyState!==1?mt("Cannot send: WebSocket no longer open",e):t.send(e)}_privateSendMachineEvent(e){this.#e.send(e)}},td=Object.freeze({}),l1=Array.from(new Set("null")),d1=Array.from(new Set("true")),f1=Array.from(new Set("false")),h1=Array.from(new Set("nulltruefalse"));function ca(e,t){const n=e[e.length-1];return t.includes(n)?e.slice(0,-1):e}var p1=class{#e="";#t;#n=0;#r=!1;#o=-1;#i=-1;#s=[];constructor(e=""){this.append(e)}get source(){return this.#e}get json(){return this.#t===void 0&&(this.#t=this.#f()),this.#t}get#u(){return this.#o>=0}append(e){e&&(this.#e===""&&(e=e.trimStart()),this.#e+=e,this.#t=void 0)}#a(e){if(this.#u)return"";const t=e.charAt(e.length-1);if(t==="")return"";if(t==="-")return"0";if(!h1.includes(t))return"";if(l1.includes(t)){if(e.endsWith("nul"))return"l";if(e.endsWith("nu"))return"ll";if(e.endsWith("n"))return"ull"}if(d1.includes(t)){if(e.endsWith("tru"))return"e";if(e.endsWith("tr"))return"ue";if(e.endsWith("t"))return"rue"}if(f1.includes(t)){if(e.endsWith("fals"))return"e";if(e.endsWith("fal"))return"se";if(e.endsWith("fa"))return"lse";if(e.endsWith("f"))return"alse"}return""}#c(){const e=this.#e.slice(this.#n);for(let t=0;t<e.length;t++){const n=e[t],r=this.#n+t;this.#u?this.#r?this.#r=!1:n==="\\"?this.#r=!0:n==='"'&&(this.#i=this.#o,this.#o=-1):n==='"'?this.#o=r:n==="{"?this.#s.push("}"):n==="["?this.#s.push("]"):(n==="}"&&this.#s.length>0&&this.#s[this.#s.length-1]==="}"||n==="]"&&this.#s.length>0&&this.#s[this.#s.length-1]==="]")&&this.#s.pop()}this.#n=this.#e.length}#f(){this.#c();let e=this.#e;if(e.charAt(0)!=="{")return td;if(e.endsWith("}")){const n=Ln(e);if(n)return n}this.#u&&(this.#r&&(e=e.slice(0,-1)),e+='"'),e=e.trimEnd(),e=ca(e,",."),e+=this.#a(e);const t=this.#s.reduceRight(((n,r)=>n+r),"");{const n=Ln(e+t);if(n)return n}return this.#u?e=e.slice(0,this.#o):(e=ca(e,":"),e.endsWith('"')&&(e=e.slice(0,this.#i))),e=ca(e,","),e+=t,Ln(e)??td}};function lt(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 s=0;s<o.length;s++)if(!Object.is(o[s],i[s]))return!1;return!0})(e,t):(function(o,i){if(!gt(o)||!gt(i))return!1;const s=Object.keys(o);return s.length===Object.keys(i).length&&s.every((a=>Object.prototype.hasOwnProperty.call(i,a)&&Object.is(o[a],i[a])))})(e,t)}function no(e,t){if(!gt(e)||!gt(t))return lt(e,t);const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r=>Object.prototype.hasOwnProperty.call(t,r)&<(e[r],t[r])))}var m1=class{#e;#t;#n;#r;#o;#i;constructor(e,t,n){this.#r=e,this.#o=t,this.#i=n,this.#e=new Map,this.#t=new He((()=>new Set)),this.#n=ir.with(n)}get(e){return this.#e.get(e)}getOrThrow(e){return this.get(e)??dn(`Item with id ${e} not found`)}get sorted(){return this.#n}getParentId(e){const t=this.getOrThrow(e);return this.#o(t)}getParent(e){const t=this.getParentId(e);return t?this.getOrThrow(t):null}getChildren(e){const t=this.#t.get(e);return t?Array.from(t).map((n=>this.#e.get(n))):[]}*walkUp(e,t){let n=e;do{const r=this.getOrThrow(n);t&&!t(r)||(yield r),n=this.#o(r)}while(n!==null)}*walkLeft(e,t){const n=this.getOrThrow(e),r=ir.from(this.getSiblings(e),this.#i);for(const o of r.iterReversed())this.#i(n,o)||t&&!t(o)||(yield o)}*walkRight(e,t){const n=this.getOrThrow(e),r=ir.from(this.getSiblings(e),this.#i);for(const o of r)this.#i(o,n)||t&&!t(o)||(yield o)}*walkDown(e,t){const n=ir.from(this.getChildren(e),this.#i).rawArray;for(let r=n.length-1;r>=0;r--){const o=n[r];yield*this.walkDown(this.#r(o),t),t&&!t(o)||(yield o)}}getSiblings(e){const t=this.getOrThrow(e),n=this.getParentId(e);return this.getChildren(n).filter((r=>r!==t))}[Symbol.iterator](){return this.#n[Symbol.iterator]()}upsert(e){const t=this.#r(e),n=this.#e.get(t);if(n){if(this.#o(n)!==this.#o(e))throw new Error("Cannot upsert parent ID changes that change the tree structure. Remove the entry first, and recreate it");this.#n.remove(n)}this.#e.set(t,e),this.#n.add(e);const r=this.#o(e);this.#t.getOrCreate(r).add(t)}remove(e){const t=this.#e.get(e);if(!t)return!1;if(this.#t.get(e))throw new Error(`Cannot remove item '${e}' while it still has children. Remove children first.`);const n=this.#o(t),r=this.#t.get(n);return r&&(r.delete(e),r.size===0&&this.#t.delete(n)),this.#n.remove(t),this.#t.delete(e),this.#e.delete(e),!0}clear(){return this.#e.size!==0&&(this.#t.clear(),this.#e.clear(),this.#n.clear(),!0)}},g1=class{#e;#t;#n;constructor(){this.#e=new Set,this.#t=new He((()=>new Map)),this.#n=void 0}registerLayer(e){const t=e;return this.#e.has(t)&&dn(`Layer '${t}' already exists, provide a unique layer id`),this.#e.add(t),t}deregisterLayer(e){this.#e.delete(e);let t=!1;for(const[n,r]of this.#t)r.delete(e)&&(t=!0),r.size===0&&this.#t.delete(n);t&&this.invalidate()}get(){return this.#n??=this.#r()}invalidate(){this.#n=void 0}#r(){return Array.from(this.#t.values()).flatMap((e=>Array.from(e.values()).slice(-1).filter(Gv)))}updateKnowledge(e,t,n){this.#e.has(e)||dn(`Unknown layer key: ${e}`),this.#t.getOrCreate(t).set(e,n),this.invalidate()}};function la(){return new Date().toISOString()}var ni=Symbol("*");function v1(){const e=new He((n=>new He((r=>new Tt(void 0))))),t=new He((n=>{const[r,o]=Ln(n);return $e.from((()=>(o!==void 0?e.getOrCreate(o).getOrCreate(r):void 0)?.get()??e.getOrCreate(ni).getOrCreate(r).get()))}));return{getToolDescriptions:function(n){const r=e.get(ni),o=e.get(n);return Array.from([...r?.entries()??[],...o?.entries()??[]]).flatMap((([i,s])=>{const a=s.get();return a&&(a.enabled??1)?[{name:i,description:a.description,parameters:a.parameters}]:[]}))},getToolΣ:function(n,r){const o=JSON.stringify(r!==void 0?[n,r]:[n]);return t.getOrCreate(o)},registerTool:function(n,r,o){if(!r.execute&&!r.render)throw new Error("A tool definition must have an execute() function, a render() function, or both.");const i=o??ni;return e.getOrCreate(i).getOrCreate(n).set(r),()=>(function(s,a){const u=e.get(s);if(u===void 0)return;const l=u.get(a);l!==void 0&&l.set(void 0)})(i,n)}}}function y1(e,t){const n=new Set,r=new Set,o=new He((c=>new Ot(new m1((d=>d.id),(d=>d.parentId),((d,h)=>d.createdAt<h.createdAt))))),i=new Ot(new Map);function s(c){Xe((()=>{for(const d of c)a(d)}))}function a(c){Xe((()=>{if(o.getOrCreate(c.chatId).mutate((d=>d.upsert(c))),c.role==="assistant"&&c.status==="generating"?i.mutate((d=>{d.set(c.id,structuredClone(c))})):i.mutate((d=>{d.delete(c.id)})),c.role==="assistant"&&c.status==="awaiting-tool"){if(n.has(c.id))for(const d of c.contentSoFar.filter((h=>h.type==="tool-invocation"&&h.stage==="executing"))){if(r.has(d.invocationId))continue;r.add(d.invocationId);const h=e.getToolΣ(d.name,c.chatId).get()?.execute;h&&(async()=>{const g=await h(d.args,{name:d.name,invocationId:d.invocationId});return await t(c.chatId,c.id,d.invocationId,g??{data:{}},{copilotId:c.copilotId})})().catch((g=>{Un(`Error trying to respond to tool-call: ${String(g)} (in execute())`)}))}}else c.role==="assistant"&&c.status==="generating"||n.delete(c.id)}))}function u(c){for(const d of o.values()){const h=d.get().get(c);if(h)return h}}function l(c){const d=c.next();return d.done?void 0:d.value}const f=new He((c=>new He((d=>{const h=$e.from((()=>(function(g,y){function p(E){if(!E.deletedAt)return!0;for(const A of g.walkDown(E.id,(x=>!x.deletedAt)))return!0;return!1}function w(E){const A=[];let x=null;for(const I of g.walkUp(E.id)){const T=l(g.walkLeft(I.id,p))?.id??null,F=l(g.walkRight(I.id,p))?.id??null;if(!I.deletedAt||T||F){const S={...I,navigation:{parent:null,prev:T,next:F}};x!==null&&(x.navigation.parent=S.id),x=S,A.push(S)}}return A.reverse()}function b(){const E=g.sorted.findRight((A=>!A.deletedAt));return E?w(E):[]}if(y===null)return b();const C=g.get(y);if(!C)return b();for(const E of g.walkUp(C.id)){for(const A of g.walkDown(E.id,(x=>!x.deletedAt)))return w(A);if(!E.deletedAt)return w(E)}return b()})(o.getOrCreate(c).get(),d)),no);return $e.from((()=>{const g=i.get();return h.get().map((y=>{if(y.role!=="assistant"||y.status!=="generating")return y;const p=g.get(y.id);return p===void 0?y:{...y,contentSoFar:p.contentSoFar}}))}),lt)}))));return{getMessageById:u,getChatMessagesForBranchΣ:function(c,d){return f.getOrCreate(c).getOrCreate(d||null)},getLastUsedCopilotId:function(c){return o.getOrCreate(c).get().sorted.findRight((h=>h.role==="assistant"&&!h.deletedAt))?.copilotId},createOptimistically:function(c,d,h,g){const y=`ms_${st()}`,p=la();return a(d==="user"?{id:y,chatId:c,role:d,parentId:h,createdAt:p,content:g,_optimistic:!0}:{id:y,chatId:c,role:d,parentId:h,createdAt:p,status:"generating",contentSoFar:[],copilotId:g,_optimistic:!0}),y},upsert:a,upsertMany:s,remove:function(c,d){const h=o.get(c);if(!h)return;const g=h.get().get(d);g&&!g.deletedAt&&(g.role==="assistant"&&g.status!=="completed"?a({...g,deletedAt:la(),contentSoFar:[]}):a({...g,deletedAt:la(),content:[]}))},removeByChatId:function(c){const d=o.get(c);d!==void 0&&d.mutate((h=>h.clear()))},addDelta:function(c,d){i.mutate((h=>{const g=h.get(c);return g!==void 0&&((function(y,p){if(p===null)return;const w=y.filter((A=>A.type!=="sources")),b=y.filter((A=>A.type==="sources")).flatMap((A=>A.sources)),C=new Date().toISOString(),E=w[w.length-1];switch(p.type){case"text-delta":E?.type==="text"?E.text+=p.textDelta:(su(E,C),w.push({type:"text",text:p.textDelta}));break;case"reasoning-delta":E?.type==="reasoning"?E.text+=p.textDelta:(su(E,C),w.push({type:"reasoning",text:p.textDelta,startedAt:C}));break;case"tool-stream":{const A=(function(x,I,T=""){const F=new p1(T);return{type:"tool-invocation",stage:"receiving",invocationId:x,name:I,get partialArgsText(){return F.source},get partialArgs(){return F.json},__appendDelta(S){F.append(S)}}})(p.invocationId,p.name);w.push(A);break}case"tool-delta":E?.type==="tool-invocation"&&E.stage==="receiving"&&E.__appendDelta?.(p.delta);break;case"tool-invocation":nd(w,p,(A=>A.invocationId),C);break;case"retrieval":nd(w,p,(A=>A.id),C);break;case"source":b.push(p);break;default:return Ye(0,"Unhandled case")}b.length>0&&w.push({type:"sources",sources:b}),y.length=0,y.push(...w)})(g.contentSoFar,d),h.set(c,g),!0)}))},failAllPending:function(){Xe((()=>{i.mutate((c=>{let d=!1;for(const[h,g]of c)g._optimistic||(c.delete(h),d=!0);return d})),s(Array.from((function*(){for(const c of o.values())for(const d of c.get())d.role!=="assistant"||d.status!=="generating"||d._optimistic||(yield d)})()).map((c=>({...c,status:"failed",errorReason:"Lost connection"}))))}))},markMine(c){n.add(c)},*getAutoExecutingMessageIds(){for(const c of n){const d=u(c);d?.role==="assistant"&&d.status==="awaiting-tool"&&d.contentSoFar.some((h=>h.type==="tool-invocation"&&h.stage==="executing"?typeof e.getToolΣ(h.name,d.chatId).get()?.execute=="function":!1))&&(yield d.id)}}}}function b1(e){const t=new yp(e.delegates,e.enableDebugLogging,!1),n=(function(){const w=new Nv;return{getChatById:function(b){return w.getEvenIfDeleted(b)},findMany:function(b){return w.signal.get().findMany(b)},upsert:function(b){w.upsert(b)},upsertMany:function(b){Xe((()=>{for(const C of b)w.upsert(C)}))},markDeleted:function(b){w.markDeleted(b)}}})(),r=v1(),o=(function(){const w=new He((b=>new g1));return{getKnowledgeStack:function(b){return w.getOrCreate(b??ni)},getKnowledgeForChat:function(b){return[...w.getOrCreate(ni).get(),...w.get(b)?.get()??[]]}}})(),i=y1(r,y),s={staticSessionInfoSig:new Tt(null),dynamicSessionInfoSig:new Tt(null),pendingCmds:new Map,chatsStore:n,messagesStore:i,toolsStore:r,knowledgeStore:o},a=new Tt("initial");let u,l,f=[],c=null;function d(){const w=f;f=[],c!==null&&(clearTimeout(c),c=null),Xe((()=>{for(const{id:b,delta:C}of w)s.messagesStore.addDelta(b,C)}))}function h(){t.getStatus()==="initial"&&t.connect()}async function g(w){h(),t.getStatus()!=="connected"&&await t.events.didConnect.waitUntil();const{promise:b,resolve:C,reject:E}=uo(),A=AbortSignal.timeout(4e3);A.addEventListener("abort",(()=>E(A.reason)),{once:!0});const x=st(7);return s.pendingCmds.set(x,{resolve:C,reject:E}),(function(I){t.send(JSON.stringify({...I}))})({...w,cmdId:x}),b.finally((()=>{s.pendingCmds.delete(x)})).catch((I=>{throw Un(I.message),I}))}async function y(w,b,C,E,A){const x=s.knowledgeStore.getKnowledgeForChat(w),I=s.toolsStore.getToolDescriptions(w),T=await g({cmd:"set-tool-result",chatId:w,messageId:b,invocationId:C,result:E,generationOptions:{copilotId:A?.copilotId,stream:A?.stream,timeout:A?.timeout,knowledge:x.length>0?x:void 0,tools:I.length>0?I:void 0}});T.ok&&i.markMine(T.message.id)}return t.events.onMessage.subscribe((function(w){if(typeof w.data!="string")return;const b=Ln(w.data);if(!b)return;const C="cmdId"in b?b.cmdId:b.event==="cmd-failed"?b.failedCmdId:void 0,E=s.pendingCmds.get(C);if(!C||E){if("event"in b)if(b.event==="delta"){const{id:A,delta:x}=b;(function(I,T){f.push({id:I,delta:T}),c===null&&(c=setTimeout(d,25))})(A,x)}else Xe((()=>{switch(d(),b.event){case"cmd-failed":E?.reject(new Error(b.error));break;case"settle":s.messagesStore.upsert(b.message);break;case"warning":mt(b.message);break;case"error":Un(b.error);break;case"rebooted":s.messagesStore.failAllPending();break;case"sync":for(const A of b["-messages"]??[])s.messagesStore.remove(A.chatId,A.id);for(const A of b["-chats"]??[])s.chatsStore.markDeleted(A),s.messagesStore.removeByChatId(A);for(const A of b.clear??[])s.messagesStore.removeByChatId(A);b.chats&&s.chatsStore.upsertMany(b.chats),b.messages&&s.messagesStore.upsertMany(b.messages);break;default:return Ye(0,"Unhandled case")}}));else switch(b.cmd){case"get-chats":s.chatsStore.upsertMany(b.chats);break;case"get-or-create-chat":s.chatsStore.upsert(b.chat);break;case"delete-chat":s.chatsStore.markDeleted(b.chatId),s.messagesStore.removeByChatId(b.chatId);break;case"get-message-tree":s.chatsStore.upsert(b.chat),s.messagesStore.upsertMany(b.messages);break;case"delete-message":s.messagesStore.remove(b.chatId,b.messageId);break;case"clear-chat":s.messagesStore.removeByChatId(b.chatId);break;case"ask-in-chat":b.sourceMessage&&s.messagesStore.upsert(b.sourceMessage),s.messagesStore.upsert(b.targetMessage);break;case"abort-ai":break;case"set-tool-result":b.ok&&s.messagesStore.upsert(b.message);break;default:return Ye(0,"Unhandled case")}E?.resolve(b)}else mt("Ignoring unexpected command response. Already timed out, or not for us?",b)})),t.events.statusDidChange.subscribe((function(w){const b=t.authValue;if(b!==null){const C=cc(b);if(C!==u)if(u=C,b.type==="secret"){const E=b.token.parsed;s.staticSessionInfoSig.set({userId:E.uid,userInfo:E.ui})}else s.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}a.set(w)})),t.events.statusDidChange.subscribe((function(w){w==="reconnecting"?l=setTimeout((()=>{}),e.lostConnectionTimeout):clearTimeout(l)})),t.events.didConnect.subscribe((function(){})),t.events.didDisconnect.subscribe((function(){d()})),t.events.onConnectionError.subscribe((({message:w,code:b})=>{})),(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",(function(){for(const w of s.messagesStore.getAutoExecutingMessageIds())g({cmd:"abort-ai",messageId:w}).catch((()=>{}))}),{once:!0}),Object.defineProperty({[Oe]:{context:s},connectInitially:h,disconnect:()=>t.disconnect(),getChats:function(w={}){return g({cmd:"get-chats",cursor:w.cursor,query:w.query})},getOrCreateChat:function(w,b){return g({cmd:"get-or-create-chat",id:w,options:b})},deleteChat:w=>g({cmd:"delete-chat",chatId:w}),getMessageTree:function(w){return g({cmd:"get-message-tree",chatId:w})},deleteMessage:(w,b)=>g({cmd:"delete-message",chatId:w,messageId:b}),clearChat:w=>g({cmd:"clear-chat",chatId:w}),askUserMessageInChat:async(w,b,C,E)=>{const A=[...s.knowledgeStore.getKnowledgeForChat(w),...E?.knowledge||[]],x=s.toolsStore.getToolDescriptions(w);return i.markMine(C),await g({cmd:"ask-in-chat",chatId:w,sourceMessage:b,targetMessageId:C,generationOptions:{copilotId:E?.copilotId,stream:E?.stream,timeout:E?.timeout,knowledge:A.length>0?A:void 0,tools:x.length>0?x:void 0}})},abort:w=>g({cmd:"abort-ai",messageId:w}),setToolResult:y,getStatus:()=>t.getStatus(),signals:{getChatMessagesForBranchΣ:s.messagesStore.getChatMessagesForBranchΣ,getToolΣ:s.toolsStore.getToolΣ,statusΣ:a},getChatById:s.chatsStore.getChatById,queryChats:s.chatsStore.findMany,getLastUsedCopilotId:s.messagesStore.getLastUsedCopilotId,registerKnowledgeLayer:(w,b)=>{const C=s.knowledgeStore.getKnowledgeStack(b),E=C.registerLayer(w);return{layerKey:E,deregister:()=>C.deregisterLayer(E)}},updateKnowledge:(w,b,C,E)=>{s.knowledgeStore.getKnowledgeStack(E).updateKnowledge(w,C??st(),b)},registerTool:s.toolsStore.registerTool},Oe,{enumerable:!1})}function C1(e,t){return n=>{const r=t??(typeof WebSocket>"u"?void 0:WebSocket);if(r===void 0)throw new jn("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const o=new URL(e);if(o.protocol=o.protocol==="http:"?"ws":"wss",o.pathname="/ai/v7",n.type!=="secret"){if(n.type==="public")throw new Error("Public key not supported with AI Copilots");return Ye(0,"Unhandled case")}return o.searchParams.set("tok",n.token.raw),o.searchParams.set("version",Ls),new r(o.toString())}}function nd(e,t,n,r){const o=qh(e,(i=>i.type===t.type&&n(i)===n(t)));o>-1?e[o]=t:(su(e[e.length-1],r),e.push(t))}function su(e,t){e?.type==="reasoning"&&(e.endedAt??=t)}var rt={Read:"*:read",Write:"*:write",RoomWrite:"room:write",RoomRead:"room:read",StorageRead:"storage:read",StorageWrite:"storage:write",StorageNone:"storage:none",CommentsWrite:"comments:write",CommentsRead:"comments:read",CommentsNone:"comments:none",CommentsPublicWrite:"comments:public:write",CommentsPublicRead:"comments:public:read",CommentsPublicNone:"comments:public:none",CommentsPrivateWrite:"comments:private:write",CommentsPrivateRead:"comments:private:read",CommentsPrivateNone:"comments:private:none",FeedsRead:"feeds:read",FeedsWrite:"feeds:write",FeedsNone:"feeds:none",LegacyRoomPresenceWrite:"room:presence:write"},w1=["none","read","write"],xr={none:0,read:1,write:2},E1={room:{read:[rt.Read,rt.RoomRead],write:[rt.Write,rt.RoomWrite]},storage:{write:[rt.StorageWrite],read:[rt.StorageRead],none:[rt.StorageNone]},comments:{write:[rt.CommentsWrite],read:[rt.CommentsRead],none:[rt.CommentsNone]},"comments:public":{write:[rt.CommentsPublicWrite],read:[rt.CommentsPublicRead],none:[rt.CommentsPublicNone]},"comments:private":{write:[rt.CommentsPrivateWrite],read:[rt.CommentsPrivateRead],none:[rt.CommentsPrivateNone]},feeds:{write:[rt.FeedsWrite],read:[rt.FeedsRead],none:[rt.FeedsNone]}},D1={room:"none",storage:"none",comments:"none","comments:public":"none","comments:private":"none",feeds:"none",personal:"none"},bp=["storage","comments","comments:public","comments:private","feeds"],A1=new Set(Object.values(rt));function x1(e){return A1.has(e)}function rd(e,t){const n=E1[t];let r;for(const o of w1){const i=n[o];i!==void 0&&i.some((s=>e.includes(s)))&&(r=o)}return r}function Cp(e){const t={},n=rd(e,"room");n!==void 0&&(t.room=n);for(const r of bp){const o=rd(e,r);o!==void 0&&(t[r]=o)}return t}function wp(e){const t=e.room;if(t===void 0)return{...D1};const n=e.comments??t;return{room:t,storage:e.storage??t,comments:n,"comments:public":e["comments:public"]??n,"comments:private":e["comments:private"]??n,feeds:e.feeds??t,personal:"write"}}function lc(e){return wp(Cp(e))}function lr(e,t,n){const r=xr[n];if(t==="comments")return Math.max(xr[e.comments??"none"],xr[e["comments:public"]??"none"],xr[e["comments:private"]??"none"])>=r;const o=e[t]??"none";return xr[o]>=r}function dc(e){if(!Array.isArray(e))throw new Error("Permission list must be an array");const t=[];for(const n of e){if(!x1(n))throw new Error(`Not a valid permission: ${n}`);t.push(n)}return t}function O1(e,t){return e[t]??((function(n){return n.startsWith("comments:")})(t)?e.comments:void 0)}function od(e,t){return xr[t]>xr[e]?t:e}function id(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=Ln((function(o){try{const i=o.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(i).split("").map((function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)})).join(""))}catch{return atob(o)}})(t[1]));if(!n||!gt(r=n)||r.k!=="acc"&&r.k!=="id")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}}var S1=[400,401,403,404,405,410,412,414,422,431,451];function I1(e,t){const n=(function(u){const{publicApiKey:l,authEndpoint:f}=u;if(f!==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 f=="string")return{type:"private",url:f};if(typeof f=="function")return{type:"custom",callback:f};throw f!==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=new Map;function s(u){const l=Math.ceil(Date.now()/1e3);for(let f=o.length-1;f>=0;f--){const c=o[f];if(c.expiresAt<=l)o.splice(f,1);else if(T1(c,u))return c.token}}async function a(u){const l=e.polyfills?.fetch??(typeof window>"u"?void 0:window.fetch);if(n.type==="private"){if(l===void 0)throw new jn("To use Liveblocks client in a non-DOM environment with a url as auth endpoint, you need to provide a fetch polyfill.");const f=id((await(async function(c,d,h){const g=await c(d,{method:"POST",headers:{"Content-Type":"application/json"},body:_r(h)});if(!g.ok){const w=`${(await g.text()).trim()||"reason not provided in auth response"} (${g.status} returned by POST ${d})`;throw S1.includes(g.status)?new jn(`Unauthorized: ${w}`):new Error(`Failed to authenticate: ${w}`)}let y;try{y=await g.json()}catch(w){throw new Error(`Expected a JSON response when doing a POST request on "${d}". ${String(w)}`)}if(!gt(y)||typeof y.token!="string")throw new Error(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${d}", but got ${_r(y)}`);const{token:p}=y;return{token:p}})(l,n.url,{room:u.roomId})).token);if(r.has(f.raw)){const c=s(u);if(c?.raw===f.raw)return c;throw new jn("The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported.")}return t?.(f.parsed),f}if(n.type==="custom"){const f=await n.callback(u.roomId);if(f&&typeof f=="object"){if(typeof f.token=="string"){const c=id(f.token);return t?.(c.parsed),c}if(typeof f.error=="string"){const c=`Authentication failed: ${"reason"in f&&typeof f.reason=="string"?f.reason:"Forbidden"}`;throw f.error==="forbidden"?new jn(c):new Error(c)}}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.clear()},getAuthValue:async function(u){if(n.type==="public")return{type:"public",publicApiKey:n.publicApiKey};const l=s(u);if(l!==void 0)return{type:"secret",token:l};let f;const c=(function(d){if(d.roomId!==void 0)return`${d.roomId}:${d.resource}:${d.access}`})(u);c!==void 0?(f=i.get(c),f===void 0&&(f=a(u),i.set(c,f))):(f=i.get("liveblocks-user-token"),f===void 0&&(f=a(u),i.set("liveblocks-user-token",f)));try{const d=await f,h=30,g=Math.floor(Date.now()/1e3)+(d.parsed.exp-d.parsed.iat)-h;r.add(d.raw);const y=(function(p,w){return p.parsed.k==="acc"?{token:p,expiresAt:w,permissions:Object.entries(p.parsed.perms).map((([b,C])=>({pattern:b,scopes:dc(C)})))}:{token:p,expiresAt:w}})(d,g);return o.push(y),{type:"secret",token:d}}finally{c!==void 0?i.delete(c):i.delete("liveblocks-user-token")}}}}function T1(e,t){if(e.token.parsed.k==="id"||t.resource==="personal")return!0;if(t.roomId===void 0)return!1;const n=(function(r,o){const i=r.filter((u=>(function(l,f){return l.includes("*")?f.startsWith(l.replace("*","")):l===f})(u.pattern,o)));if(i.length===0)return;const s={},a={};for(const u of i){const l=Cp(u.scopes),f=u.pattern.replace("*","").length;l.room!==void 0&&(s.room=od(s.room??"none",l.room));for(const c of bp){const d=O1(l,c);if(d===void 0)continue;const h=a[c]??-1;f>h?(s[c]=d,a[c]=f):f===h&&(s[c]=od(s[c]??"none",d))}}return wp(s)})(e.permissions??[],t.roomId);return n!==void 0&&lr(n,t.resource,t.access)}var An="@",zn=class Ep extends Ro{#e;constructor(t){super(),this.#e=t}get data(){return this.#e}static _deserialize([t,n],r,o){const i=new Ep(n.data);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:ue.CREATE_REGISTER,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:je.REGISTER,parentId:ye(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??st(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return hi(this.data)}};function k1(e,t){return e._parentPos<t._parentPos}var gr=class au extends Ro{#e;#t;constructor(t){super(),this.#t=new WeakSet;const n=[];let r;for(const o of t){const i=gn(r),s=ho(o);s._setParentLink(this,i),n.push(s),r=i}this.#e=ir.fromAlreadySorted(n,k1)}static _deserialize([t,n],r,o){const i=new au([]);i._attach(t,o);const s=r.get(t);if(s===void 0)return i;for(const a of s){const u=a[1],l=Ip(a,r,o);l._setParentLink(i,u.parentKey),i.#n(l)}return i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ue.CREATE_LIST,parentId:t,parentKey:n};r.push(o);for(const i of this.#e){const s=i._getParentKeyOrThrow(),a=zo(i._toOps(this._id,s),"set");for(const u of a)r.push(u)}return r}#n(t){const n=this.#e.add(t);return this.invalidate(),n}#r(t,n){t._setParentLink(this,n),this.#e.reposition(t),this.invalidate()}#o(t,n){const r=ye(this.#e.at(t));this.#r(r,n)}_indexOfPosition(t){return this.#e.findIndex((n=>n._getParentKeyOrThrow()===t))}#i(t){if(this._pool===void 0||this._id===void 0)return;let n;for(const r of this._pool.unacknowledgedOps.getByParentIdAndKey(this._id,t))r.intent==="set"&&(n=r.opId);return n}_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()}#s(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=Yo(t);o._attach(n,this._pool),o._setParentLink(this,r);const i=t.deletedId,s=this._indexOfPosition(r);if(s!==-1){const a=ye(this.#e.removeAt(s));if(a._id===i)return a._detach(),this.#e.add(o),{modified:ze(this,[Kr(s,o)],Kt),reverse:[]};{this.#t.add(a),this.#e.remove(a),this.#e.add(o);const u=[Kr(s,o)],l=this.#a(t.deletedId,Kt);return l&&u.push(l),{modified:ze(this,u,Kt),reverse:[]}}}{const a=[],u=this.#a(t.deletedId,Kt);return u&&a.push(u),this.#n(o),a.push(en(this._indexOfPosition(r),o)),{reverse:[],modified:ze(this,a,Kt)}}}#u(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const r=[],o=this.#a(t.deletedId,n);o&&r.push(o);const i=this.#i(t.parentKey);if(i!==void 0&&i!==t.opId)return r.length===0?{modified:!1}:{modified:ze(this,r,n),reverse:[]};const s=this._indexOfPosition(t.parentKey),a=this.#e.find((u=>u._id===t.id));if(a!==void 0){if(a._parentKey===t.parentKey)return{modified:r.length>0&&ze(this,r,n),reverse:[]};if(s!==-1){const f=ye(this.#e.removeAt(s));this.#t.add(f),r.push(Wi(s,f))}const u=this.#e.findIndex((f=>f===a));this.#r(a,t.parentKey);const l=this.#e.findIndex((f=>f===a));return l!==u&&r.push(Yn(u,l,a)),{modified:r.length>0&&ze(this,r,n),reverse:[]}}{const u=this._pool.getNode(t.id);if(u&&this.#t.has(u)){u._setParentLink(this,t.parentKey),this.#t.delete(u);const l=this.#n(u);return{modified:ze(this,[s===-1?en(l,u):Kr(l,u),...r],n),reverse:[]}}{if(s!==-1){const c=ye(this.#e.removeAt(s));this.#t.add(c)}const{newItem:l,newIndex:f}=this.#b(t,t.parentKey);return{modified:ze(this,[s===-1?en(f,l):Kr(f,l),...r],n),reverse:[]}}}}#a(t,n){if(t===void 0||this._pool===void 0)return null;const r=this._pool.getNode(t);if(r===void 0)return null;const o=this._detachChild(r,n);return o.modified===!1?null:o.modified.updates[0]}#c(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=mi(t.parentKey),r=this._indexOfPosition(n);r!==-1&&this.#C(r,n);const{newItem:o,newIndex:i}=this.#b(t,n),s=this.#m(n);return{modified:ze(this,[en(i,o),...s],Kt),reverse:[]}}*#f(){if(this._pool!==void 0&&this._id!==void 0)for(const t of this._pool.unacknowledgedOps.getByParentId(this._id)){if(t.intent!=="push"||this._pool.unacknowledgedOps.isPossiblyStored(t.opId))continue;const n=this._pool.getNode(t.id);n!==void 0&&this.#e.includes(n)&&(yield n)}}#m(t){const n=new Set(this.#f());if(n.size===0)return[];let r,o;for(const s of n){const a=s._parentPos;(r===void 0||a<r)&&(r=a)}if(t<ye(r))return[];for(const s of this.#e)n.has(s)||(o=s._parentPos);const i=[];for(const s of n){const a=this.#e.findIndex((l=>l===s));o=gn(o),this.#r(s,o);const u=this.#e.findIndex((l=>l===s));u!==a&&i.push(Yn(a,u,s))}return i}#g(t,n){const r=this.#e.find((s=>s._id===t.id)),o=mi(t.parentKey),i=this._indexOfPosition(o);if(r){if(r._parentKey===o)return{modified:!1};{const s=this.#e.findIndex((u=>u===r));i!==-1&&this.#C(i,o),this.#r(r,o);const a=this._indexOfPosition(o);return a===s?{modified:!1}:{modified:ze(this,[Yn(s,a,r)],n),reverse:[]}}}{const s=ye(this._pool).getNode(t.id);if(s&&this.#t.has(s))return s._setParentLink(this,o),this.#t.delete(s),this.#n(s),{modified:ze(this,[en(this._indexOfPosition(o),s)],n),reverse:[]};{i!==-1&&this.#C(i,o);const{newItem:a,newIndex:u}=this.#b(t,o);return{modified:ze(this,[en(u,a)],n),reverse:[]}}}}#p(t,n){const{id:r,parentKey:o}=t,i=Yo(t);if(this._pool?.getNode(r)!==void 0)return{modified:!1};i._attach(r,ye(this._pool)),i._setParentLink(this,o);const s=this._indexOfPosition(o);let a=o;if(s!==-1){const u=this.#e.at(s)?._parentPos,l=this.#e.at(s+1)?._parentPos;a=gn(u,l),i._setParentLink(this,a)}return this.#n(i),{modified:ze(this,[en(this._indexOfPosition(a),i)],n),reverse:[{type:ue.DELETE_CRDT,id:r}]}}#h(t,n){const{id:r,parentKey:o}=t,i=Yo(t);if(this._pool?.getNode(r)!==void 0)return{modified:!1};const s=this._indexOfPosition(o);i._attach(r,ye(this._pool)),i._setParentLink(this,o);const a=o;if(s!==-1){const u=this.#e.at(s);u._detach(),this.#e.remove(u),this.#e.add(i);const l=zo(u._toOps(ye(this._id),o),"set",t.id),f=[Kr(s,i)],c=this.#a(t.deletedId,n);return c&&f.push(c),{modified:ze(this,f,n),reverse:l}}{this.#n(i),this.#a(t.deletedId,n);const u=this._indexOfPosition(a);return{reverse:[{type:ue.DELETE_CRDT,id:r}],modified:ze(this,[en(u,i)],n)}}}_attachChild(t,n){const r=sn(n);if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let o;return o=t.intent==="set"?n.origin==="remote"?this.#s(t):n.optimistic?this.#h(t,r):this.#u(t,r):n.origin==="remote"?this.#c(t):n.optimistic?this.#p(t,r):this.#g(t,r),o.modified!==!1&&this.invalidate(),o}_detachChild(t,n){if(t){const r=ye(t._parentKey),o=t._toOps(ye(this._id),r),i=this.#e.findIndex((a=>a===t));if(i===-1)return{modified:!1};const s=this.#e.at(i);return this.#e.remove(t),this.invalidate(),t._detach(),{modified:ze(this,[Wi(i,s)],n),reverse:o}}return{modified:!1}}#d(t,n){if(this.#t.has(n))return this.#t.delete(n),n._setParentLink(this,t),{modified:ze(this,[en(this.#n(n),n)],Kt),reverse:[]};if(t===n._parentKey)return{modified:!1};const r=this._indexOfPosition(t);if(r===-1){const o=this.#e.findIndex((s=>s===n));this.#r(n,t);const i=this.#e.findIndex((s=>s===n));return i===o?{modified:!1}:{modified:ze(this,[Yn(o,i,n)],Kt),reverse:[]}}{this.#o(r,gn(t,this.#e.at(r+1)?._parentPos));const o=this.#e.findIndex((s=>s===n));this.#r(n,t);const i=this.#e.findIndex((s=>s===n));return i===o?{modified:!1}:{modified:ze(this,[Yn(o,i,n)],Kt),reverse:[]}}}#v(t,n,r){const o=ye(n._parentKey);if(this.#t.has(n)){const i=this._indexOfPosition(t);if(this.#t.delete(n),i!==-1){const s=this.#e.at(i);s._setParentLink(this,gn(t,this.#e.at(i+1)?._parentPos)),this.#e.reposition(s)}return n._setParentLink(this,t),{modified:ze(this,[en(this.#n(n),n)],r),reverse:[]}}{if(t===o)return{modified:!1};const i=this.#e.findIndex((u=>u===n)),s=this._indexOfPosition(t);s!==-1&&this.#o(s,gn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,t);const a=this.#e.findIndex((u=>u===n));return i===a?{modified:!1}:{modified:ze(this,[Yn(i,a,n)],r),reverse:[]}}}#y(t,n,r){const o=ye(n._parentKey),i=this.#e.findIndex((l=>l===n)),s=this._indexOfPosition(t);let a=t;s!==-1&&(a=gn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,a);const u=this.#e.findIndex((l=>l===n));return i===u?{modified:!1}:{modified:ze(this,[Yn(i,u,n)],r),reverse:[{type:ue.SET_PARENT_KEY,id:ye(n._id),parentKey:o}]}}_setChildKey(t,n,r){const o=sn(r);return r.origin==="remote"?this.#d(t,n):r.optimistic?this.#y(t,n,o):this.#v(t,n,o)}_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:je.LIST,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this.#e.length}push(t){return this.#w(t,this.length,"push")}insert(t,n){return this.#w(t,n,"insert")}#w(t,n,r){if(this._warnIfOrphaned(),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 o=this.#e.at(n-1)?._parentPos,i=this.#e.at(n)?._parentPos,s=gn(o,i),a=ho(t);if(a._setParentLink(this,s),this.#n(a),this._pool&&this._id){const u=this._pool.generateId();a._attach(u,this._pool);const l=a._toOpsWithOpId(this._id,s,this._pool);this._pool.dispatch(r==="push"?zo(l,"push"):l,[{type:ue.DELETE_CRDT,id:u}],new Map([[this._id,ze(this,[en(n,a)],St)]]))}}move(t,n){if(this._warnIfOrphaned(),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.at(n+1)?._parentPos,r=this.#e.at(n)._parentPos):(o=this.#e.at(n)._parentPos,r=n===0?void 0:this.#e.at(n-1)?._parentPos);const i=gn(r,o),s=this.#e.at(t),a=s._getParentKeyOrThrow();if(this.#o(t,i),this._pool&&this._id){const u=new Map([[this._id,ze(this,[Yn(t,n,s)],St)]]);this._pool.dispatch([{type:ue.SET_PARENT_KEY,id:ye(s._id),opId:this._pool.generateOpId(),parentKey:i}],[{type:ue.SET_PARENT_KEY,id:ye(s._id),parentKey:a}],u)}}delete(t){if(this._warnIfOrphaned(),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.at(t);if(n._detach(),this.#e.remove(n),this.invalidate(),this._pool){const r=n._id;if(r){const o=new Map;o.set(ye(this._id),ze(this,[Wi(t,n)],St)),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:ue.DELETE_CRDT}],n._toOps(ye(this._id),n._getParentKeyOrThrow()),o)}}}clear(){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const i of this.#e){i._detach();const s=i._id;s&&(t.push({type:ue.DELETE_CRDT,id:s,opId:this._pool.generateOpId()}),n.push(...i._toOps(ye(this._id),i._getParentKeyOrThrow())),r.push(Wi(0,i)))}this.#e.clear(),this.invalidate();const o=new Map;o.set(ye(this._id),ze(this,r,St)),this._pool.dispatch(t,n,o)}else{for(const t of this.#e)t._detach();this.#e.clear(),this.invalidate()}}set(t,n){if(this._warnIfOrphaned(),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.at(t),o=r._getParentKeyOrThrow(),i=r._id;r._detach();const s=ho(n);if(s._setParentLink(this,o),this.#e.remove(r),this.#e.add(s),this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();s._attach(a,this._pool);const u=new Map;u.set(this._id,ze(this,[Kr(t,s)],St));const l=zo(s._toOpsWithOpId(this._id,o,this._pool),"set",i),f=zo(r._toOps(this._id,o),"set",a);this._pool.dispatch(l,f,u)}}#l(t){return Or(t)}every(t){return this.#e.rawArray.every(((n,r)=>t(this.#l(n),r)))}filter(t){const n=[];return this.#e.rawArray.forEach(((r,o)=>{const i=this.#l(r);t(i,o)&&n.push(i)})),n}find(t){for(const[n,r]of this.#e.rawArray.entries()){const o=this.#l(r);if(t(o,n))return o}}findIndex(t){return this.#e.rawArray.findIndex(((n,r)=>t(this.#l(n),r)))}forEach(t){this.#e.rawArray.forEach(((n,r)=>t(this.#l(n),r)))}get(t){const n=this.#e.at(t);return n!==void 0?this.#l(n):void 0}indexOf(t,n){return this.#e.rawArray.findIndex(((r,o)=>o>=(n??0)&&this.#l(r)===t))}lastIndexOf(t,n){const r=this.#e.rawArray;for(let o=n??r.length-1;o>=0;o--)if(this.#l(r[o])===t)return o;return-1}map(t){return this.#e.rawArray.map(((n,r)=>t(this.#l(n),r)))}some(t){return this.#e.rawArray.some(((n,r)=>t(this.#l(n),r)))}*[Symbol.iterator](){for(const t of this.#e)yield this.#l(t)}#b(t,n){const r=Yo(t);return r._attach(t.id,ye(this._pool)),r._setParentLink(this,n),this.#n(r),{newItem:r,newIndex:this._indexOfPosition(n)}}#C(t,n){const r=gn(n,this.#e.length>t+1?this.#e.at(t+1)?._parentPos:void 0);this.#o(t,r)}_toTreeNode(t){const n=[];let r=0;for(const o of this.#e)n.push(o.toTreeNode(r.toString())),r++;return{type:"LiveList",id:this._id??st(),key:t,payload:n}}toJSON(){return super.toJSON()}_toJSON(){return Array.from(this.#e,(n=>n.toJSON()))}clone(){return new au(Array.from(this.#e,(t=>t.clone())))}};function ze(e,t,n){return{node:e,type:"LiveList",updates:t,source:n}}function Kr(e,t){return{index:e,type:"set",item:t instanceof zn?t.data:t}}function Wi(e,t){return{type:"delete",index:e,deletedItem:t instanceof zn?t.data:t}}function en(e,t){return{index:e,type:"insert",item:t instanceof zn?t.data:t}}function Yn(e,t,n){return{type:"move",index:t,item:n instanceof zn?n.data:n,previousIndex:e}}function zo(e,t,n){return e.map(((r,o)=>o===0?{...r,intent:t,deletedId:n}:r))}var Hr=class uu extends Ro{#e;#t;constructor(t){if(super(),this.#t=new Map,t){const n=[];for(const[r,o]of t){const i=ho(o);i._setParentLink(this,r),n.push([r,i])}this.#e=new Map(n)}else this.#e=new Map}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ue.CREATE_MAP,parentId:t,parentKey:n};r.push(o);for(const[i,s]of this.#e)for(const a of s._toOps(this._id,i))r.push(a);return r}static _deserialize([t,n],r,o){const i=new uu;i._attach(t,o);const s=r.get(t);if(s===void 0)return i;for(const a of s){const u=a[1],l=Ip(a,r,o);l._setParentLink(i,u.parentKey),i.#e.set(u.parentKey,l),i.invalidate()}return i}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)ot(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,s=o,a=Yo(t);if(this._pool.getNode(r)!==void 0)return{modified:!1};if(n.origin==="remote")this.#t.delete(s);else if(!n.optimistic){const f=this.#t.get(s);if(f===i)return this.#t.delete(s),{modified:!1};if(f!==void 0)return{modified:!1}}const u=this.#e.get(s);let l;if(u){const f=ye(this._id);l=u._toOps(f,s),u._detach()}else l=[{type:ue.DELETE_CRDT,id:r}];return a._setParentLink(this,s),a._attach(r,this._pool),this.#e.set(s,a),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}},source:sn(n)},reverse:l}}_detach(){super._detach();for(const t of this.#e.values())t._detach()}_detachChild(t,n){const r=ye(this._id),o=ye(t._parentKey),i=t._toOps(r,o);for(const[s,a]of this.#e)a===t&&(this.#e.delete(s),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveMap",updates:{[o]:{type:"delete",deletedItem:Or(t)}},source:n},reverse:i}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:je.MAP,parentId:ye(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 Or(n)}set(t,n){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const r=this.#e.get(t);r&&r._detach();const o=ho(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 s=new Map;s.set(this._id,{node:this,type:"LiveMap",updates:{[t]:{type:"update"}},source:St});const a=o._toOpsWithOpId(this._id,t,this._pool);this.#t.set(t,ye(a[0].opId)),this._pool.dispatch(a,r?r._toOps(this._id,t):[{type:ue.DELETE_CRDT,id:i}],s)}}get size(){return this.#e.size}has(t){return this.#e.has(t)}delete(t){this._warnIfOrphaned(),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=ye(this._id),o=new Map;o.set(r,{node:this,type:"LiveMap",updates:{[t]:{type:"delete",deletedItem:Or(n)}},source:St}),this._pool.dispatch([{type:ue.DELETE_CRDT,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],Or(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:Or(n.value)}}}}forEach(t){for(const n of this)t(n[1],n[0],this)}_toTreeNode(t){return{type:"LiveMap",id:this._id??st(),key:t,payload:Array.from(this.#e.entries()).map((([n,r])=>r.toTreeNode(n)))}}toJSON(){return super.toJSON()}_toJSON(){const t={};for(const[n,r]of this.#e)t[n]=r.toJSON();return t}clone(){return new uu(Array.from(this.#e).map((([t,n])=>[t,n.clone()])))}};function jr(e,t){if(Array.isArray(e))return new gr(e.map((n=>jr(n,t))));if(gt(e)){const n={},r={};for(const i in e){const s=e[i];if(s===void 0)continue;const a=gt(t)?t[i]:t;a===!1?r[i]=s:n[i]=a==="atomic"?s:jr(s,a)}const o=new Kn(n);for(const i in r)o.setLocal(i,r[i]);return o}return e}function Dp(e,t,n){return gc(e)&>(t)?cu(e,t,"full",n):mc(e)&&Array.isArray(t)?(function(r,o,i){const s=r.length,a=o.length;for(let u=0;u<Math.min(s,a);u++){const l=r.get(u),f=o[u];if(sr(l)){const c=Dp(l,f,i);c!==l&&r.set(u,c)}else l!==f&&r.set(u,jr(f,i))}for(let u=s;u<a;u++)r.push(jr(o[u],i));for(let u=s-1;u>=a;u--)r.delete(u);return r})(e,t,n):Tp(e)&>(t)?(function(){throw new Error("Reconciling a LiveMap is not supported yet")})():kp(e)&<(e.data,t)?e:jr(t,n)}function cu(e,t,n,r){const o=e.keys();for(const i in t){o.delete(i);const s=t[i];if(s===void 0){n==="full"&&e.delete(i);continue}const a=gt(r)?r[i]:r;if(a===!1)e.setLocal(i,s);else if(a==="atomic")e.get(i)!==s&&e.set(i,s);else{const u=e.get(i);if(u===void 0)e.set(i,jr(s,a));else if(sr(u)){const l=Dp(u,s,a);l!==u&&e.set(i,l)}else u!==s&&e.set(i,jr(s,a))}}if(n==="full")for(const i of o)e.delete(i);return e}var sd=131072,Kn=class Er extends Ro{#e;#t=new Map;#n;static detectLargeObjects=!1;static#r(t){const n=new Map;let r=null;for(const o of t)if(Lv(o))r=o[1];else{const i=o[1],s=n.get(i.parentId);s!==void 0?s.push(o):n.set(i.parentId,[o])}if(r===null)throw new Error("Root can't be null");return[r,n]}static _fromItems(t,n){const[r,o]=Er.#r(t);return Er._deserialize(["root",r],o,n)}constructor(t={}){super(),this.#n=new Map;const n=pi(t);for(const r of Object.keys(n)){const o=n[r];ot(o)&&o._setParentLink(this,r)}this.#e=new Map(Object.entries(n))}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={type:ue.CREATE_OBJECT,id:this._id,parentId:t,parentKey:n,data:{}};r.push(o);for(const[i,s]of this.#e)if(ot(s))for(const a of s._toOps(this._id,i))r.push(a);else o.data[i]=s;return r}static _deserialize([t,n],r,o){const i=new Er(n.data);return i._attach(t,o),this._deserializeChildren(i,r,o)}static _deserializeChildren(t,n,r){const o=n.get(ye(t._id));if(o===void 0)return t;for(const i of o){const s=U1(i,n,r),a=i[1];sr(s)&&s._setParentLink(t,a.parentKey),t.#e.set(a.parentKey,s),t.invalidate()}return t}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)ot(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,s=Op(t);if(this._pool.getNode(r)!==void 0)return this.#n.get(i)===o&&this.#n.delete(i),{modified:!1};if(n.origin==="local"&&n.optimistic)this.#n.set(i,ye(o));else if(this.#n.get(i)!==void 0)return this.#n.get(i)===o?(this.#n.delete(i),{modified:!1}):{modified:!1};const a=ye(this._id),u=this.#e.get(i);let l;return ot(u)?(l=u._toOps(a,i),u._detach()):l=u===void 0?[{type:ue.DELETE_OBJECT_KEY,id:a,key:i}]:[{type:ue.UPDATE_OBJECT,id:a,data:{[i]:u}}],this.#t.delete(i),this.#e.set(i,s),this.invalidate(),sr(s)&&(s._setParentLink(this,i),s._attach(r,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}},source:sn(n)}}}_detachChild(t,n){if(t){const r=ye(this._id),o=ye(t._parentKey),i=t._toOps(r,o),s=Or(t);for(const[a,u]of this.#e)u===t&&(this.#e.delete(a),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveObject",updates:{[o]:{type:"delete",deletedItem:s}},source:n},reverse:i}}return{modified:!1}}_detach(){super._detach();for(const t of this.#e.values())ot(t)&&t._detach()}_apply(t,n){return t.type===ue.UPDATE_OBJECT?this.#o(t,n):t.type===ue.DELETE_OBJECT_KEY?this.#i(t,n):super._apply(t,n)}_serialize(){const t={};for(const[n,r]of this.#e)ot(r)||(t[n]=r);return this.parent.type==="HasParent"&&this.parent.node._id?{type:je.OBJECT,parentId:this.parent.node._id,parentKey:this.parent.key,data:t}:{type:je.OBJECT,data:t}}#o(t,n){let r=!1;const o=ye(this._id),i=[],s={type:ue.UPDATE_OBJECT,id:o,data:{}};for(const u in t.data){const l=this.#e.get(u);if(ot(l)){for(const f of l._toOps(o,u))i.push(f);l._detach()}else l!==void 0?s.data[u]=l:l===void 0&&i.push({type:ue.DELETE_OBJECT_KEY,id:o,key:u})}const a={};for(const u in t.data){const l=t.data[u];if(l===void 0)continue;if(n.origin==="local"&&n.optimistic)this.#n.set(u,ye(t.opId));else{if(this.#n.get(u)!==void 0){if(this.#n.get(u)===t.opId){this.#n.delete(u);continue}continue}r=!0}const f=this.#e.get(u);ot(f)&&f._detach(),r=!0,a[u]={type:"update"},this.#t.delete(u),this.#e.set(u,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),r?{modified:{node:this,type:"LiveObject",updates:a,source:sn(n)},reverse:i}:{modified:!1}}#i(t,n){const r=t.key,o=this.#e.get(r);if(o===void 0)return{modified:!1};if((n.origin!=="local"||!n.optimistic)&&this.#n.get(r)!==void 0)return{modified:!1};const i=ye(this._id);let s=[];return ot(o)?(s=o._toOps(i,t.key),o._detach()):o!==void 0&&(s=[{type:ue.UPDATE_OBJECT,id:i,data:{[r]:o}}]),this.#t.delete(r),this.#e.delete(r),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[t.key]:{type:"delete",deletedItem:o}},source:sn(n)},reverse:s}}keys(){const t=new Set(this.#e.keys());for(const n of this.#t.keys())t.add(n);return t}set(t,n){this.update({[t]:n})}setLocal(t,n){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const r=this.#s(t);if(this.#t.set(t,n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const o=r?.[0]??[],i=r?.[1]??[],s=r?.[2]??new Map,a=s.get(this._id);s.set(this._id,{node:this,type:"LiveObject",updates:{...a?.updates,[t]:{type:"update"}},source:St}),this._pool.dispatch(o,i,s)}}get(t){return this.#t.has(t)?this.#t.get(t):this.#e.get(t)}#s(t){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=t;if(this.#t.has(n)&&!this.#e.has(n)){const a=this.#t.get(n);if(this.#t.delete(n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const u=new Map;return u.set(this._id,{node:this,type:"LiveObject",updates:{[n]:{type:"delete",deletedItem:a}},source:St}),[[],[],u]}return null}this.#t.delete(n);const r=this.#e.get(n);if(r===void 0)return null;if(this._pool===void 0||this._id===void 0)return ot(r)&&r._detach(),this.#e.delete(n),this.invalidate(),null;const o=[{type:ue.DELETE_OBJECT_KEY,key:n,id:this._id,opId:this._pool.generateOpId()}];let i;ot(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:ue.UPDATE_OBJECT,data:{[n]:r},id:this._id}],this.#e.delete(n),this.invalidate();const s=new Map;return s.set(this._id,{node:this,type:"LiveObject",updates:{[t]:{type:"delete",deletedItem:r}},source:St}),[o,i,s]}delete(t){const n=this.#s(t);if(n){const[r,o,i]=n;this._pool?.dispatch(r,o,i)}}update(t){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),Er.detectLargeObjects){const l={};for(const[c,d]of this.#e)ot(d)||(l[c]=d);for(const c of Object.keys(t)){const d=t[c];d!==void 0&&(ot(d)||(l[c]=d))}const f=JSON.stringify(l);if(4*f.length>sd){const c=new TextEncoder().encode(f).length;if(c>sd)throw new Error(`LiveObject size exceeded limit: ${c} bytes > 131072 bytes. See https://liveblocks.io/docs/pricing/limits#Other-limits`)}}if(this._pool===void 0||this._id===void 0){for(const l in t){const f=t[l];if(f===void 0)continue;const c=this.#e.get(l);ot(c)&&c._detach(),ot(f)&&f._setParentLink(this,l),this.#t.delete(l),this.#e.set(l,f),this.invalidate()}return}const n=[],r=[],o=this._pool.generateOpId(),i={},s={id:this._id,type:ue.UPDATE_OBJECT,data:{}},a={};for(const l in t){const f=t[l];if(f===void 0)continue;const c=this.#e.get(l);if(c!==f){if(ot(c)){for(const d of c._toOps(this._id,l))r.push(d);c._detach()}else c===void 0?r.push({type:ue.DELETE_OBJECT_KEY,id:this._id,key:l}):s.data[l]=c;if(ot(f)){f._setParentLink(this,l),f._attach(this._pool.generateId(),this._pool);const d=f._toOpsWithOpId(this._id,l,this._pool),h=d.find((g=>g.parentId===this._id));h&&this.#n.set(l,ye(h.opId));for(const g of d)n.push(g)}else i[l]=f,this.#n.set(l,o);this.#t.delete(l),this.#e.set(l,f),this.invalidate(),a[l]={type:"update"}}}if(Object.keys(s.data).length!==0&&r.unshift(s),Object.keys(i).length!==0&&n.unshift({opId:o,id:this._id,type:ue.UPDATE_OBJECT,data:i}),n.length===0&&r.length===0&&Object.keys(a).length===0)return;const u=new Map;u.set(this._id,{node:this,type:"LiveObject",updates:a,source:St}),this._pool.dispatch(n,r,u)}static from(t,n){if(!gt(t))throw new Error("Expected a JSON object");const r=new Er({});return r.reconcile(t,n),r}reconcile(t,n){if(!this.hasCache(t)){if(!gt(t))throw new Error("Reconciling the document root expects a plain object value");cu(this,t,"full",n)}}reconcilePartially(t,n){if(!gt(t))throw new Error("Reconciling the document root expects a plain object value");cu(this,t,"partial",n)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??st();return{type:"LiveObject",id:n,key:t,payload:Array.from(this.#e.entries()).map((([r,o])=>ot(o)?o.toTreeNode(r):{type:"Json",id:`${n}:${r}`,key:r,payload:o}))}}toJSON(){return super.toJSON()}_toJSON(){const t={};for(const[n,r]of this.#e)t[n]=sr(r)?r.toJSON():r;for(const[n,r]of this.#t)t[n]=r;return t}clone(){const t=new Er(Object.fromEntries(Array.from(this.#e).map((([n,r])=>[n,sr(r)?r.clone():hi(r)]))));for(const[n,r]of this.#t)t.#t.set(n,hi(r));return t}};function B1(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(e[o]!==t[o])return!1;return!0}function F1(e){return e===void 0?void 0:{...e}}function Co(e){const t=[];for(const n of e){if(n.text.length===0)continue;const r=t.at(-1),o=F1(n.attributes);r!==void 0&&B1(r.attributes,o)?r.text+=n.text:t.push({text:n.text,attributes:o})}return t}function ad(e){return Co(e.map((([t,n])=>({text:t,attributes:n}))))}function da(e){return e.map((t=>t.attributes===void 0?[t.text]:[t.text,{...t.attributes}]))}function ro(e){return e.reduce(((t,n)=>t+n.text.length),0)}function Hn(e,t){const n=[];let r=0;for(const o of e){const i=r+o.text.length;if(t>r&&t<i){const s=o.text.slice(0,t-r),a=o.text.slice(t-r);n.push({text:s,attributes:o.attributes}),n.push({text:a,attributes:o.attributes})}else n.push({text:o.text,attributes:o.attributes});r=i}return n}function lu(e,t,n){const r=Math.max(0,Math.min(e,n));return{index:r,length:Math.max(r,Math.min(e+t,n))-r}}function du(e,t){const n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function Ap(e,t){const n=Math.max(0,Math.min(t,e.length));return du(e,n)?n-1:n}function fa(e,t,n){const r=lu(t,n,e.length);if(r.length===0)return{index:Ap(e,r.index),length:0};const o=r.index+r.length,i=du(e,r.index)?r.index-1:r.index;return{index:i,length:(du(e,o)?o+1:o)-i}}function fc(e,t,n,r){if(n.length===0)return Co(e);const o=Hn(e,t),i=[];let s=0,a=!1;for(const u of o)a||s!==t||(i.push({text:n,attributes:r}),a=!0),i.push(u),s+=u.text.length;return a||i.push({text:n,attributes:r}),Co(i)}function xp(e,t,n){const r=Hn(Hn(e,t),t+n),o=[];let i=0;for(const s of r){const a=i+s.text.length;i>=t&&a<=t+n&&o.push({text:s.text,attributes:s.attributes}),i=a}return Co(o)}function hc(e,t,n){const r=xp(e,t,n),o=Hn(Hn(e,t),t+n),i=[];let s=0,a="";for(const u of o){const l=s+u.text.length;s>=t&&l<=t+n?a+=u.text:i.push(u),s=l}return{segments:Co(i),deletedText:a,deletedSegments:r}}function pc(e,t,n,r){const o=Hn(Hn(e,t),t+n),i=[];let s=0;for(const a of o){const u=s+a.text.length;if(s>=t&&u<=t+n){const l={...a.attributes??{}};for(const[f,c]of Object.entries(r))c===null?delete l[f]:l[f]=c;i.push({text:a.text,attributes:Object.keys(l).length===0?void 0:l})}else i.push(a);s=u}return Co(i)}function R1(e,t,n,r){const o=Hn(Hn(e,t),t+n),i=[];let s=0;for(const a of o){const u=s+a.text.length;if(s>=t&&u<=t+n){const l={},f=a.attributes??{};for(const c of Object.keys(r)){const d=Object.hasOwn(f,c)?f[c]:void 0;l[c]=d??null}i.push({type:"format",index:s,length:a.text.length,attributes:l})}s=u}return i}function _1(e,t){return t.type==="insert"?t.index<=e?e+t.text.length:e:t.type==="delete"?t.index>=e?e:Math.max(t.index,e-t.length):e}function ha(e,t){let n=e;for(const r of t)n=_1(n,r);return n}function j1(e,t){return t.type==="insert"?e<=t.index?e:Math.max(t.index,e-t.text.length):t.type==="delete"&&t.index<=e?e+t.length:e}function ud(e,t){let n=e;for(let r=t.length-1;r>=0;r--)n=j1(n,t[r]);return n}function M1(e){return e==="before"?"after":"before"}function Ko(e,t,n){return t>=e?e:Math.max(t,e-n)}function cd(e,t,n){switch(e.type){case"insert":return(function(r,o,i){return o.type==="insert"?[o.index<r.index||o.index===r.index&&i==="after"?{...r,index:r.index+o.text.length}:{...r}]:o.type==="delete"?[{...r,index:Ko(r.index,o.index,o.length)}]:[{...r}]})(e,t,n);case"delete":return(function(r,o){const i=r.index,s=r.index+r.length;if(o.type==="insert"){const a=o.index,u=o.text.length;return a<=i?[{...r,index:i+u}]:a>=s?[{...r}]:[{type:"delete",index:i,length:a-i},{type:"delete",index:i+u,length:s-a}]}if(o.type==="delete"){const a=Ko(i,o.index,o.length),u=Ko(s,o.index,o.length);return u-a>0?[{type:"delete",index:a,length:u-a}]:[]}return[{...r}]})(e,t);case"format":return(function(r,o,i){const s=r.index,a=r.index+r.length;if(o.type==="insert"){const u=o.index,l=o.text.length;return u<=s?[{...r,index:s+l}]:u>=a?[{...r}]:[{type:"format",index:s,length:u-s,attributes:r.attributes},{type:"format",index:u+l,length:a-u,attributes:r.attributes}]}if(o.type==="delete"){const u=Ko(s,o.index,o.length),l=Ko(a,o.index,o.length);return l-u>0?[{type:"format",index:u,length:l-u,attributes:r.attributes}]:[]}{if(i==="after")return[{...r}];const u=Math.max(s,o.index),l=Math.min(a,o.index+o.length);if(u>=l)return[{...r}];if(!Object.keys(r.attributes).some((d=>Object.hasOwn(o.attributes,d))))return[{...r}];const f={};for(const[d,h]of Object.entries(r.attributes))Object.hasOwn(o.attributes,d)||(f[d]=h);const c=[];return s<u&&c.push({type:"format",index:s,length:u-s,attributes:r.attributes}),Object.keys(f).length>0&&c.push({type:"format",index:u,length:l-u,attributes:f}),l<a&&c.push({type:"format",index:l,length:a-l,attributes:r.attributes}),c}})(e,t,n)}}function Tr(e,t,n){if(e.length===0||t.length===0)return[[...e],[...t]];if(e.length===1&&t.length===1)return[cd(e[0],t[0],n),cd(t[0],e[0],M1(n))];if(e.length>1){const[a,u]=Tr([e[0]],t,n),[l,f]=Tr(e.slice(1),u,n);return[[...a,...l],f]}const[r,o]=Tr(e,[t[0]],n),[i,s]=Tr(r,t.slice(1),n);return[i,[...o,...s]]}function P1(e,t,n){return Tr(e,t,n)[0]}function pa(e,t){let n=[...e];for(const r of t)if(r.type==="insert")n=fc(n,Math.max(0,Math.min(r.index,ro(n))),r.text,r.attributes);else if(r.type==="delete"){const o=lu(Math.max(0,Math.min(r.index,ro(n))),r.length,ro(n));n=hc(n,o.index,o.length).segments}else{const o=lu(Math.max(0,Math.min(r.index,ro(n))),r.length,ro(n));n=pc(n,o.index,o.length,r.attributes)}return n}function N1(e,t){let n=[...e];const r=[];for(const o of t)if(o.type==="insert")n=fc(n,o.index,o.text,o.attributes),r.unshift({type:"delete",index:o.index,length:o.text.length});else if(o.type==="delete"){const i=xp(n,o.index,o.length);n=hc(n,o.index,o.length).segments;const s=[];let a=o.index;for(const u of i)s.push({type:"insert",index:a,text:u.text,attributes:u.attributes}),a+=u.text.length;for(let u=s.length-1;u>=0;u--)r.unshift(s[u])}else{const i=R1(n,o.index,o.length,o.attributes);n=pc(n,o.index,o.length,o.attributes),r.unshift(...i.reverse())}return r}var jo=class fu extends Ro{#e;#t;#n;#r;#o=[];#i=[];#s=[];constructor(t="",n=0){super(),this.#e=typeof t=="string"?t.length===0?[]:[{text:t}]:ad(t),this.#t=[...this.#e],this.#n=n,Object.assign(this[Oe],{encodeIndex:r=>this.#u(r),decodeIndex:(r,o)=>this.#a(r,o)})}get version(){return this.#n}get length(){return ro(this.#e)}static _deserialize([t,n],r,o){const i=new fu(n.data,n.version);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize LiveText if it is not attached");return[{type:ue.CREATE_TEXT,id:this._id,parentId:t,parentKey:n,data:this.toJSON(),version:this.#n}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveText if parent is missing");return{type:je.TEXT,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.toJSON(),version:this.#n}}_attachChild(t){throw new Error("LiveText cannot contain child nodes")}_detachChild(t){throw new Error("LiveText cannot contain child nodes")}_apply(t,n){return t.type!==ue.UPDATE_TEXT?super._apply(t,n):n.origin==="local"&&n.optimistic?this.#f(t,sn(n)):t.opId!==void 0&&t.opId===this.#r?this.#m(t,sn(n)):t.opId!==void 0&&this.#s.some((r=>r.opId===t.opId))?(this.#n=Math.max(this.#n,t.version??t.baseVersion+1),{modified:!1}):this.#g(t,sn(n))}insert(t,n,r){const o=Ap(this.toString(),t);this.#c([{type:"insert",index:o,text:n,attributes:r}])}delete(t,n){const r=fa(this.toString(),t,n);r.length!==0&&this.#c([{type:"delete",index:r.index,length:r.length}])}replace(t,n,r,o){const i=fa(this.toString(),t,n),s=[];i.length>0&&s.push({type:"delete",index:i.index,length:i.length}),r.length>0&&s.push({type:"insert",index:i.index,text:r,attributes:o}),this.#c(s)}#u(t){let n=Math.max(0,Math.min(t,this.length));return n=ud(n,this.#i),n=ud(n,this.#o),n}#a(t,n){if(n>this.#n)return null;if(n<this.#n){const o=this.#s[0]?.version;if(o===void 0||o>n+1)return null}let r=t;for(const o of this.#s)if(!(o.version<=n)){if(o.version>this.#n)break;o.ops.length!==0&&(r=ha(r,o.ops))}return r=ha(r,this.#o),r=ha(r,this.#i),Math.max(0,Math.min(r,this.length))}format(t,n,r){const o=fa(this.toString(),t,n);o.length!==0&&this.#c([{type:"format",index:o.index,length:o.length,attributes:r}])}#c(t){if(t.length===0)return;this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=this._pool!==void 0&&this._id!==void 0,r=n?this.#y(t):[],o=this.#v(t);if(!n)return;const i=ye(this._pool),s=ye(this._id),a=new Map([[s,{type:"LiveText",node:this,version:this.#n,updates:o,source:St}]]);if(this.#r===void 0){const u=i.generateOpId();this.#r=u,this.#o=[...t],i.dispatch([{type:ue.UPDATE_TEXT,id:s,opId:u,baseVersion:this.#n,ops:[...t]}],r,a)}else this.#i.push(...t),i.dispatch([],r,a,{clearRedoStack:!0})}#f(t,n){const r=t;if(t.opId!==void 0&&t.opId===this.#r)return this.#o=[...this.#o,...this.#i],this.#i=[],r.baseVersion=this.#n,r.ops=[...this.#o],{modified:!1};let o=t.ops;for(const a of this.#s)a.version>t.baseVersion&&a.ops.length>0&&(o=P1(o,a.ops,"after"));const i=this.#y(o),s=this.#v(o);return this.#r===void 0&&o.length>0?(this.#r=ye(t.opId,"Local ops must have an opId"),this.#o=[...o],r.baseVersion=this.#n,r.ops=[...o]):(this.#i.push(...o),r.baseVersion=this.#n,r.ops=[]),s.length===0?{modified:!1}:{reverse:i,modified:{type:"LiveText",node:this,version:this.#n,updates:s,source:n}}}#m(t,n){const r=t.version??Math.max(this.#n,t.baseVersion+1),o=this.#o,i=this.#r;this.#t=pa(this.#t,t.ops),this.#r=void 0,this.#o=[];let s=[],a={modified:!1};if((u=t.ops)!==(l=o)&&Xt(u)!==Xt(l)){Un("LiveText: acknowledgement did not match the local prediction; resynchronizing");const f=this.#h();s=f.appliedOps,f.changes.length>0&&(a={reverse:[],modified:{type:"LiveText",node:this,version:r,updates:f.changes,source:n}})}var u,l;return this.#n=Math.max(this.#n,r),this.#d(r,s,i),this.#p(),a}#g(t,n){const r=t.version??this.#n+1;this.#t=pa(this.#t,t.ops);const[o,i]=Tr(t.ops,this.#o,"before"),[s,a]=Tr(o,this.#i,"before");if(this.#o=i,this.#i=a,this.#d(r,s,t.opId),s.length===0)return this.#n=Math.max(this.#n,r),{modified:!1};const u=this.#y(s),l=this.#v(s);return this.#n=Math.max(this.#n,r),{reverse:u,modified:{type:"LiveText",node:this,version:this.#n,updates:l,source:n}}}#p(){if(this.#i.length===0||this._pool===void 0||this._id===void 0)return;const t=this._pool.generateOpId();this.#r=t,this.#o=this.#i,this.#i=[],this._pool.dispatch([{type:ue.UPDATE_TEXT,id:this._id,opId:t,baseVersion:this.#n,ops:[...this.#o]}],[],new Map,{clearRedoStack:!1})}#h(){const t=this.#e,n=pa(this.#t,[...this.#o,...this.#i]);if(Xt(da(t))===Xt(da(n)))return this.#e=n,{appliedOps:[],changes:[]};const r=t.map((a=>a.text)).join("");this.#e=n,this.invalidate();const o=[],i=[];r.length>0&&(o.push({type:"delete",index:0,length:r.length}),i.push({type:"delete",index:0,length:r.length,deletedText:r}));let s=0;for(const a of n)o.push({type:"insert",index:s,text:a.text,attributes:a.attributes}),i.push({type:"insert",index:s,text:a.text,attributes:a.attributes}),s+=a.text.length;return{appliedOps:o,changes:i}}_resyncText(t,n,r){this.#t=ad(t),this.#n=n,this.#s=[];const o=this.#h();if(o.changes.length!==0)return{type:"LiveText",node:this,version:this.#n,updates:o.changes,source:r}}_rejectPendingOp(t){t===this.#r&&(this.#r=void 0,this.#o=[],this.#i=[])}#d(t,n,r){this.#s.some((o=>o.version===t))||(this.#s.push({version:t,opId:r,ops:[...n]}),this.#s.sort(((o,i)=>o.version-i.version)),this.#s.length>1e3&&this.#s.splice(0,this.#s.length-1e3))}#v(t){const n=[];for(const r of t)if(r.type==="insert")this.#e=fc(this.#e,r.index,r.text,r.attributes),n.push({type:"insert",index:r.index,text:r.text,attributes:r.attributes});else if(r.type==="delete"){const o=hc(this.#e,r.index,r.length);this.#e=o.segments,n.push({type:"delete",index:r.index,length:r.length,deletedText:o.deletedText})}else this.#e=pc(this.#e,r.index,r.length,r.attributes),n.push({type:"format",index:r.index,length:r.length,attributes:r.attributes});return this.invalidate(),n}#y(t){return[{type:ue.UPDATE_TEXT,id:ye(this._id),baseVersion:this.#n,ops:N1(this.#e,t)}]}toString(){return this.#e.map((t=>t.text)).join("")}toJSON(){return super.toJSON()}_toJSON(){return da(this.#e)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??st(),r=this.toJSON().map(((o,i)=>({type:"Json",id:`${n}:${i}`,key:String(i),payload:o})));return r.push({type:"Json",id:`${n}:version`,key:"version",payload:this.version}),{type:"LiveText",id:n,key:t,payload:r}}clone(){return new fu(this.toJSON(),this.#n)}};function Yo(e){return ho(Op(e))}function Op(e){switch(e.type){case ue.CREATE_FILE:return new mr(e.data);case ue.CREATE_REGISTER:return e.data;case ue.CREATE_OBJECT:return new Kn(e.data);case ue.CREATE_MAP:return new Hr;case ue.CREATE_LIST:return new gr([]);case ue.CREATE_TEXT:return new jo(e.data,e.version);default:return Ye(0,"Unknown creation Op")}}function Sp(e,t){return e===t||e.parent.type==="HasParent"&&Sp(e.parent.node,t)}function L1(e){const t=sp({getCurrentConnectionId:()=>{throw new Error("Cannot mutate a historic storage version: it is a read-only snapshot")}});return Kn._fromItems(e,t)}function Ip(e,t,n){if(Jh(e))return Kn._deserialize(e,t,n);if(Zh(e))return gr._deserialize(e,t,n);if(Xh(e))return Hr._deserialize(e,t,n);if(Yh(e))return zn._deserialize(e,t,n);if(Qh(e))return jo._deserialize(e,t,n);if(ep(e))return mr._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function U1(e,t,n){if(Jh(e))return Kn._deserialize(e,t,n);if(Zh(e))return gr._deserialize(e,t,n);if(Xh(e))return Hr._deserialize(e,t,n);if(Yh(e))return e[1].data;if(Qh(e))return jo._deserialize(e,t,n);if(ep(e))return mr._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function sr(e){return mc(e)||Tp(e)||gc(e)||hu(e)||kp(e)}function ot(e){return sr(e)||(function(t){return t instanceof zn})(e)}function mc(e){return e instanceof gr}function Tp(e){return e instanceof Hr}function gc(e){return e instanceof Kn}function hu(e){return e instanceof jo}function kp(e){return e instanceof mr}function Or(e){return e instanceof zn?e.data:e instanceof gr||e instanceof Hr||e instanceof Kn||e instanceof jo||e instanceof mr?e:Ye(0,"Unknown AbstractCrdt")}function ho(e){return e instanceof Kn||e instanceof Hr||e instanceof gr||e instanceof jo||e instanceof mr?e:new zn(e)}function As(e,t){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!As(e[r],t[r]))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!As(e[r],t[r]))return!1;return!0}function H1(e,t){const n=[],r=e.reduce(((i,[s])=>i+s.length),0);r>0&&n.push({type:"delete",index:0,length:r});let o=0;for(const[i,s]of t)i.length!==0&&(n.push({type:"insert",index:o,text:i,attributes:s}),o+=i.length);return n}function V1(e,t,n){const r=[],o=new Set;t.forEach(((u,l)=>{const f=e.get(l);f!==void 0&&(f.type===u.type&&(f.type!==je.FILE||u.type!==je.FILE||f.data.id===u.data.id&&f.data.name===u.data.name&&f.data.size===u.data.size&&f.data.mimeType===u.data.mimeType)||o.add(l))}));let i=!0;for(;i;){i=!1;for(const u of[e,t])u.forEach(((l,f)=>{!o.has(f)&&l.parentId!==void 0&&o.has(l.parentId)&&(o.add(f),i=!0)}))}e.forEach(((u,l)=>{const f=u.parentId!==void 0&&o.has(u.parentId);t.has(l)&&!o.has(l)||f||r.push({type:ue.DELETE_CRDT,id:l})}));const s=new Set;function a(u,l){if(s.has(u))return;s.add(u);const f=l.parentId;if(f!==void 0&&(!e.has(f)||o.has(f))){const c=t.get(f);c!==void 0&&a(f,c)}switch(l.type){case je.REGISTER:r.push({type:ue.CREATE_REGISTER,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data});break;case je.FILE:r.push({type:ue.CREATE_FILE,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data});break;case je.LIST:r.push({type:ue.CREATE_LIST,id:u,parentId:l.parentId,parentKey:l.parentKey});break;case je.OBJECT:if(l.parentId===void 0||l.parentKey===void 0)throw new Error("Internal error. Cannot serialize storage root into an operation");r.push({type:ue.CREATE_OBJECT,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data});break;case je.MAP:r.push({type:ue.CREATE_MAP,id:u,parentId:l.parentId,parentKey:l.parentKey});break;case je.TEXT:r.push({type:ue.CREATE_TEXT,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data,version:l.version})}}return t.forEach(((u,l)=>{const f=e.get(l);if(f&&!o.has(l)){if(u.type===je.OBJECT&&f.type===je.OBJECT){const c=new Map;for(const d of Object.keys(u.data)){const h=u.data[d];h===void 0||As(h,f.data[d])||c.set(d,h)}c.size>0&&r.push({type:ue.UPDATE_OBJECT,id:l,data:Object.fromEntries(c)});for(const d of Object.keys(f.data))d in u.data||r.push({type:ue.DELETE_OBJECT_KEY,id:l,key:d})}n?.includeLiveTextUpdates!==!0||u.type!==je.TEXT||f.type!==je.TEXT||As(u.data,f.data)||r.push({type:ue.UPDATE_TEXT,id:l,baseVersion:f.version,ops:H1(f.data,u.data)}),u.parentKey!==f.parentKey&&r.push({type:ue.SET_PARENT_KEY,id:l,parentKey:ye(u.parentKey,"Parent key must not be missing")})}else a(l,u)})),r}function $1(e,t){const n=e.updates;for(const[r,o]of ic(t.updates))n[r]=o;return{...t,updates:n}}function W1(e,t){const n=e.updates;for(const[r,o]of ic(t.updates))n[r]=o;return{...t,updates:n}}function z1(e,t){const n=e.updates;return{...t,updates:n.concat(t.updates)}}function K1(e,t){return{...t,updates:e.updates.concat(t.updates)}}function zi(e,t){if(e===void 0)return t;const n=(function(r,o){return r.origin==="remote"||o.origin==="remote"?Kt:o.via!=="edit"?o:r.via!=="edit"?r:St})(e.source,t.source);return e.type==="LiveObject"&&t.type==="LiveObject"?{...$1(e,t),source:n}:e.type==="LiveMap"&&t.type==="LiveMap"?{...W1(e,t),source:n}:e.type==="LiveList"&&t.type==="LiveList"?{...z1(e,t),source:n}:e.type==="LiveText"&&t.type==="LiveText"?{...K1(e,t),source:n}:{...t,source:n}}function ma(e,t,n=t){typeof e=="function"&&e()}Ue().observable;var ri=Symbol("notification-settings-plain");function xs(e){const t=["email","slack","teams","webPush"],n={[ri]:{value:e,enumerable:!1}};for(const r of t)n[r]={enumerable:!0,get(){const o=this[ri][r];return o===void 0?(Un(`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 q1(e,t){const n=xs({...e[ri]});for(const o of(r=t,Object.keys(r))){const i=t[o];if(i!==void 0){const s=Object.fromEntries(ic(i).filter((([,a])=>a!==void 0)));n[ri][o]={...n[ri][o],...s}}}var r;return n}var Qn="12px",ga=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&&dn("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&&dn("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 ld(e){return Array.isArray(e)}var at=Object.freeze({UPDATE_PRESENCE:100,BROADCAST_EVENT:103,FETCH_STORAGE:200,UPDATE_STORAGE:201,FETCH_YDOC:300,UPDATE_YDOC:301,FETCH_FEEDS:510,FETCH_FEED_MESSAGES:511,ADD_FEED:512,UPDATE_FEED:513,DELETE_FEED:514,ADD_FEED_MESSAGE:515,UPDATE_FEED_MESSAGE:516,DELETE_FEED_MESSAGE:517}),G1=class{#e;#t;signal;constructor(){this.#e=new Ot({connections:new Map,presences:new Map}),this.signal=$e.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:s,id:a,info:u,access:l}=o,{canWrite:f,canComment:c}=l;return pi({connectionId:s,id:a,info:u,canWrite:f,canComment:c,isReadOnly:!f,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,access: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,pi(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=Gh(r,t);return r!==o&&(n.presences.set(e,o),this.#r(e))}))}},pu=class Bp 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 Bp((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"AI_CONNECTION_ERROR":return r.code===4001?"Not allowed to connect to ai":"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"EDIT_COMMENT_METADATA_ERROR":return"Could not edit comment 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"SUBSCRIBE_TO_THREAD_ERROR":return"Could not subscribe to thread";case"UNSUBSCRIBE_FROM_THREAD_ERROR":return"Could not unsubscribe from thread";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_ROOM_SUBSCRIPTION_SETTINGS_ERROR":return"Could not update room subscription settings";case"UPDATE_NOTIFICATION_SETTINGS_ERROR":return"Could not update notification settings";case"LARGE_MESSAGE_ERROR":return"Could not send large message";case"FEED_REQUEST_ERROR":return r.reason??"Feed request failed";default:return Ye(0,"Unhandled case")}})(t),t,n)}},va=5e3;function dd(e){const t=lc(dc(e));return{canWrite:lr(t,"storage","write"),canComment:lr(t,"comments","write")}}function fd(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 J1(e,t){const n=t.roomId,r=e.initialPresence,o=e.initialStorage,i=t.roomHttpClient,[s,a]=(function(){const O=typeof document<"u"?document:void 0,P={current:null};function j(){P.current=O?.visibilityState==="hidden"?P.current??Date.now():null}return O?.addEventListener("visibilitychange",j),[P,()=>{O?.removeEventListener("visibilitychange",j)}]})(),u={...t.delegates,canZombie:()=>t.backgroundKeepAliveTimeout!==void 0&&s.current!==null&&Date.now()>s.current+t.backgroundKeepAliveTimeout&&ut.getStatus()!=="synchronizing"&&Vo.getStatus()!=="synchronizing"},l=new yp(u,t.enableDebugLogging),f=new ip,c={buffer:{flushTimerID:void 0,lastFlushedAt:0,presenceUpdates:{type:"full",data:r},messages:[],storageOperations:[]},staticSessionInfoSig:new Tt(null),dynamicSessionInfoSig:new Tt(null),myPresence:new Mv(r),others:new G1,initialStorage:o,idFactory:null,yjsProvider:void 0,yjsProviderDidChange:Ue(),pool:sp({getCurrentConnectionId:function(){const O=c.dynamicSessionInfoSig.get();if(O)return O.actor;throw new Error("Internal. Tried to get connection id but connection was never open")},onDispatch:function(O,P,j,L){if(c.activeBatch){for(const N of O)c.activeBatch.ops.push(N);for(const[N,ce]of j)c.activeBatch.updates.storageUpdates.set(N,zi(c.activeBatch.updates.storageUpdates.get(N),ce));c.activeBatch.reverseOps.pushLeft(P),L?.clearRedoStack&&(c.activeBatch.clearRedoStack=!0)}else P.length>0&&H(P),(L?.clearRedoStack??O.length>0)&&_(),O.length>0&&we(O),W({storageUpdates:j})},isStorageWritable:function(){const O=c.dynamicSessionInfoSig.get()?.permissionMatrix;return O===void 0||lr(O,"storage","write")},unacknowledgedOps:f}),root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,unacknowledgedOps:f};let d=0,h=0;const g=(function(){let O=new Map;return{append(P){for(const[j,L]of P)O.set(j,L)},take(){const P=O;return O=new Map,P}}})(),y=t.enableDebugLogging?(function(){let O,P=0,j=0;function L(N=performance.now()){O.push(N-j),j=N}return{start:function(){O=[],P=performance.now(),j=P},lap:L,stop:function(){const N=performance.now();return L(N),{total:N-P,laps:O}}}})():void 0;let p,w,b=!1;l.events.onMessage.subscribe(pe),l.events.statusDidChange.subscribe((function(O){const P=l.authValue;if(P!==null){const j=cc(P);if(j!==p)if(p=j,P.type==="secret"){const L=P.token.parsed;c.staticSessionInfoSig.set({userId:L.uid,userInfo:L.ui})}else c.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}C.status.notify(O),I()})),l.events.statusDidChange.subscribe((function(O){O==="reconnecting"?w=setTimeout((()=>{C.lostConnection.notify("lost"),b=!0,c.others.clearOthers(),W({others:[{type:"reset"}]})}),t.lostConnectionTimeout):(clearTimeout(w),b&&(O==="disconnected"?C.lostConnection.notify("failed"):C.lostConnection.notify("restored"),b=!1))})),l.events.didConnect.subscribe((function(){c.buffer.presenceUpdates={type:"full",data:{...c.myPresence.get()}},Ce!==null&&ge(),fe()})),l.events.didDisconnect.subscribe((function(){clearTimeout(c.buffer.flushTimerID),c.unacknowledgedOps.markAllAsPossiblyStored()})),l.events.onConnectionError.subscribe((({message:O,code:P})=>{const j=new pu(O,{type:"ROOM_CONNECTION_ERROR",code:P,roomId:n});t.errorEventSource.notify(j)}));const C={status:Ue(),lostConnection:Ue(),customEvent:Ue(),self:Ue(),myPresence:Ue(),others:Ue(),storageBatch:Ue(),history:Ue(),privateHistory:Ue(),storageDidLoad:Ue(),storageStatus:Ue(),ydoc:Ue(),comments:Ue(),feeds:Ue(),roomWillDestroy:Ue()};function E(O){l.send(_r(O))}const A=$e.from(c.staticSessionInfoSig,c.dynamicSessionInfoSig,c.myPresence,((O,P,j)=>{if(O===null||P===null)return null;{const L=lr(P.permissionMatrix,"storage","write");return{connectionId:P.actor,id:O.userId,info:O.userInfo,presence:j,canWrite:L,canComment:lr(P.permissionMatrix,"comments","write")}}}));let x;function I(){const O=A.get();O!==null&&O!==x&&(C.self.notify(O),x=O)}const T=$e.from(A,(O=>O!==null?fd("Me",O):null));function F(O,P){const j=new Map;for(const[L,N]of c.pool.nodes)j.set(L,N._serialize());return V1(j,O,P)}function S(O){if(O.size===0)throw new Error("Internal error: cannot load storage without items");if(c.root!==void 0){const N=V(F(O));for(const[ce,Ee]of O)if(Ee.type===je.TEXT){const Re=c.pool.nodes.get(ce);if(Re!==void 0&&hu(Re)){const be=Re._resyncText(Ee.data,Ee.version,Kt);be!==void 0&&N.updates.storageUpdates.set(ce,zi(N.updates.storageUpdates.get(ce),be))}}W(N.updates)}else c.root=Kn._fromItems(O,c.pool);const P=A.get()?.canWrite??!0,j=(function(N){const ce=new Set,Ee=N.get("root");for(const Re in Ee?.data)ce.add(Re);for(const Re of N.values())Re.parentId==="root"&&ce.add(Re.parentKey);return ce})(O),L=c.root;et((()=>{for(const ce in c.initialStorage)j.has(ce)||(P?L.set(ce,(N=c.initialStorage[ce])===void 0?void 0:sr(N)?N.clone():hi(N)):mt(`Attempted to populate missing storage key '${ce}', but current user has no write access`));var N}))}function k(O){h>0||C.privateHistory.notify(O)}function _(){if(c.redoStack.length===0)return;const O=c.redoStack.map((P=>P.id));c.redoStack.length=0,k({action:"discard",ids:O})}function M(O){if(c.undoStack.length>=50){const j=c.undoStack.shift();j!==void 0&&k({action:"discard",ids:[j.id]})}const P=d++;c.undoStack.push({id:P,frames:O}),k({action:"push",id:P}),X()}function H(O){c.pausedHistory!==null?c.pausedHistory.pushLeft(O):M(O)}function W(O){const P=O.storageUpdates,j=O.others;if(j!==void 0&&j.length>0){const L=c.others.get();for(const N of j)C.others.notify({...N,others:L})}if(O.presence&&(I(),C.myPresence.notify(c.myPresence.get())),P!==void 0&&P.size>0){const L=Array.from(P.values(),(N=>({...N,source:sn(N.source)})));C.storageBatch.notify(L)}Gn()}const G=new Map;function q(O){const P=G.get(O);return P===void 0?"edit":(G.delete(O),P)}function $(O,P=St){const[j,L]=(function(be,tt){const Bt=[],Ft=[];let qe=0;for(const mn of be)tt(mn,qe++)?Bt.push(mn):Ft.push(mn);return[Bt,Ft]})(O,(be=>be.type==="presence")),N=new Map;for(const be of L)be.type!==ue.CREATE_TEXT||be.opId!==void 0||c.pool.nodes.get(be.id)!==void 0||N.has(be.id)||N.set(be.id,c.pool.generateId());const ce=(N.size===0?L:L.map((be=>{if(be.opId!==void 0)return be;const tt=N.get(be.id);if(tu(be)){const Bt=N.get(be.parentId),Ft=be.deletedId===void 0?void 0:N.get(be.deletedId);return tt===void 0&&Bt===void 0&&Ft===void 0?be:be.type===ue.CREATE_TEXT&&tt!==void 0?{...be,id:tt,version:0,...Bt===void 0?{}:{parentId:Bt},...Ft===void 0?{}:{deletedId:Ft}}:{...be,...tt===void 0?{}:{id:tt},...Bt===void 0?{}:{parentId:Bt},...Ft===void 0?{}:{deletedId:Ft}}}return tt===void 0?be:{...be,id:tt}}))).map((be=>be.opId===void 0?{...be,opId:c.pool.generateOpId()}:be));if(P.via!=="edit")for(const be of ce)G.set(be.opId,P.via);const{reverse:Ee,updates:Re}=Q(j,ce,!0,P);return{opsToEmit:ce,reverse:Ee,updates:Re}}function V(O){return Q([],O,!1)}function Q(O,P,j,L=St){const N={reverse:new ga,storageUpdates:new Map,presence:!1};for(const Ee of O){const Re={type:"presence",data:{}};for(const be in Ee.data)Re.data[be]=c.myPresence.get()[be];if(c.myPresence.patch(Ee.data),c.buffer.presenceUpdates===null)c.buffer.presenceUpdates={type:"partial",data:Ee.data};else for(const be in Ee.data)c.buffer.presenceUpdates.data[be]=Ee.data[be];N.reverse.pushLeft(Re),N.presence=!0}const ce=new Set;for(const Ee of P){let Re;j?Re={...L,optimistic:!0}:Ee.opId!==void 0?(c.unacknowledgedOps.delete(Ee.opId),Re={origin:"local",via:q(Ee.opId),optimistic:!1}):Re=Kt;const be=ae(Ee,Re);if(be.modified){const tt=be.modified.node._id;tt&&ce.has(tt)||(N.storageUpdates.set(ye(be.modified.node._id),zi(N.storageUpdates.get(ye(be.modified.node._id)),be.modified)),N.reverse.pushLeft(be.reverse)),Ee.type!==ue.CREATE_LIST&&Ee.type!==ue.CREATE_MAP&&Ee.type!==ue.CREATE_OBJECT&&Ee.type!==ue.CREATE_TEXT&&Ee.type!==ue.CREATE_FILE||ce.add(Ee.id)}}return{reverse:Array.from(N.reverse),updates:{storageUpdates:N.storageUpdates,presence:N.presence}}}function ae(O,P){if((function(j){return j.type===ue.DELETE_CRDT&&j.id==="ACK"})(O))return{modified:!1};switch(O.type){case ue.DELETE_OBJECT_KEY:case ue.UPDATE_OBJECT:case ue.UPDATE_TEXT:case ue.DELETE_CRDT:{const j=c.pool.nodes.get(O.id);return j===void 0?{modified:!1}:j._apply(O,P)}case ue.SET_PARENT_KEY:{const j=c.pool.nodes.get(O.id);return j===void 0?{modified:!1}:j.parent.type==="HasParent"&&mc(j.parent.node)?j.parent.node._setChildKey(mi(O.parentKey),j,P):{modified:!1}}case ue.CREATE_OBJECT:case ue.CREATE_LIST:case ue.CREATE_MAP:case ue.CREATE_TEXT:case ue.CREATE_FILE:case ue.CREATE_REGISTER:{if(O.parentId===void 0)return{modified:!1};const j=c.pool.nodes.get(O.parentId);return j===void 0?{modified:!1}:j._attachChild(O,P)}default:return{modified:!1}}}function ie(O){if(O.targetActor!==void 0){const j=c.others.getUser(O.actor);c.others.setOther(O.actor,O.data);const L=c.others.getUser(O.actor);if(j===void 0&&L!==void 0)return{type:"enter",user:L}}else c.others.patchOther(O.actor,O.data);const P=c.others.getUser(O.actor);return P?{type:"update",updates:O.data,user:P}:void 0}function Se(O){const P=c.others.getUser(O.actor);return P?(c.others.removeConnection(O.actor),{type:"leave",user:P}):null}function Ie(O){c.dynamicSessionInfoSig.set({actor:O.actor,nonce:O.nonce,permissionMatrix:lc(dc(O.scopes)),meta:O.meta}),c.idFactory=(function(P){let j=0;return()=>`${P}:${j++}`})(O.actor),I(),O.meta.showBrand===!0&&((P="bottom-right")=>{if(typeof document>"u"||document.getElementById("liveblocks-badge"))return;const j=document.createElement("div");switch(j.id="liveblocks-badge",j.style.position="fixed",j.style.opacity="0",j.style.transition="opacity 300ms",j.style.zIndex="9999",P){case"top-right":j.style.top=Qn,j.style.right=Qn;break;case"bottom-right":j.style.bottom=Qn,j.style.right=Qn;break;case"bottom-left":j.style.bottom=Qn,j.style.left=Qn;break;case"top-left":j.style.top=Qn,j.style.left=Qn}j.onmouseenter=()=>{const Jn=document.getElementById("liveblocks-badge-hide-button");Jn&&(Jn.style.opacity="0.3")},j.onmouseleave=()=>{const Jn=document.getElementById("liveblocks-badge-hide-button");Jn&&(Jn.style.opacity="0")};const L=document.createElement("a");L.href="https://lblcks.io/badge",L.target="_blank",L.rel="noopener noreferrer",L.title="Liveblocks";const N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width","111"),N.setAttribute("height","38"),N.setAttribute("viewBox","0 0 111 38"),N.setAttribute("fill","none");const ce=document.createElementNS("http://www.w3.org/2000/svg","rect");ce.setAttribute("x","1"),ce.setAttribute("y","1"),ce.setAttribute("width","109"),ce.setAttribute("height","36"),ce.setAttribute("rx","8"),ce.setAttribute("fill","white"),N.appendChild(ce);const Ee=document.createElementNS("http://www.w3.org/2000/svg","rect");Ee.setAttribute("x","0.5"),Ee.setAttribute("y","0.5"),Ee.setAttribute("width","110"),Ee.setAttribute("height","37"),Ee.setAttribute("rx","8.5"),Ee.setAttribute("stroke","black"),Ee.setAttribute("stroke-opacity","0.1"),N.appendChild(Ee);const Re=document.createElementNS("http://www.w3.org/2000/svg","path");Re.setAttribute("d","M39.8256 18.0832H38L38.0005 28.9009H39.8256V18.0832ZM43.213 21.1757H41.3879V28.9009H43.213V21.1757ZM43.213 18H41.3879V19.9688H43.213V18ZM45.8916 21.1757H43.9302L46.6915 28.9009H48.7283L51.4896 21.1757H49.5581L48.4039 24.8348C48.3739 24.93 48.2657 25.3024 48.0795 25.9511L47.7099 27.1959C47.4914 26.406 47.2626 25.6189 47.0237 24.8348L45.8916 21.1757ZM58.9659 23.59C58.8147 23.0721 58.5934 22.6317 58.3014 22.2694C57.9743 21.8628 57.5598 21.5482 57.0571 21.3268C56.5589 21.1004 56.0058 20.9877 55.3973 20.9877C54.2407 20.9877 53.3152 21.3495 52.6212 22.0735C52.275 22.4476 52.0103 22.8896 51.844 23.3715C51.6731 23.8691 51.5876 24.4199 51.5876 25.0233C51.5876 26.3157 51.9322 27.3142 52.6217 28.0184C53.3203 28.7323 54.2509 29.0894 55.4125 29.0894C56.4083 29.0894 57.2151 28.8658 57.8342 28.4181C58.453 27.9704 58.8628 27.3068 59.0638 26.4266L57.2834 26.2908C57.198 26.7685 57.0016 27.1257 56.6948 27.3618C56.3879 27.5933 55.9555 27.7093 55.3973 27.7093C54.1201 27.7093 53.4663 26.9899 53.4363 25.5514H59.1844L59.1922 25.295C59.1922 24.6763 59.1165 24.108 58.9659 23.59ZM53.8434 23.0471C54.1654 22.5943 54.6834 22.3679 55.3973 22.3679C55.7443 22.3679 56.0363 22.4155 56.2725 22.5111C56.509 22.6067 56.7128 22.7601 56.8837 22.9713C57.0167 23.1352 57.1189 23.3218 57.1855 23.5221C57.2605 23.731 57.3062 23.9493 57.3213 24.1708H53.451C53.4964 23.7231 53.6271 23.3484 53.8434 23.0471ZM66.2836 21.4779C65.7656 21.1406 65.1673 20.9724 64.4885 20.9724H64.4875C63.995 20.9724 63.5449 21.0727 63.1374 21.2742C62.7364 21.4696 62.3931 21.7659 62.1412 22.1341V18.0832H60.316V28.9009H62.1416V27.8373C62.373 28.2195 62.7008 28.5342 63.0921 28.7499C63.4996 28.9763 63.9497 29.0894 64.4422 29.0894C65.1266 29.0894 65.7324 28.9259 66.2614 28.5992C66.7891 28.2726 67.1989 27.8045 67.4905 27.1959C67.7871 26.5823 67.9359 25.8634 67.9359 25.0386C67.9359 24.2337 67.7895 23.5248 67.4984 22.9113C67.2115 22.2926 66.8066 21.8148 66.2836 21.4779ZM65.5064 27.0828C65.2148 27.5254 64.7172 27.7463 64.0125 27.7463C63.3786 27.7463 62.9013 27.5175 62.5797 27.0601C62.2576 26.6026 62.0968 25.9336 62.0968 25.0534C62.0968 24.2032 62.24 23.5397 62.5265 23.0619C62.8185 22.579 63.3088 22.3378 63.9978 22.3378C64.7019 22.3378 65.2023 22.5592 65.499 23.0013C65.7961 23.4389 65.944 24.1181 65.944 25.0386C65.944 25.9585 65.7985 26.6401 65.5064 27.0828ZM70.901 18.0832H69.0754V28.9009H70.901V18.0832ZM73.8582 28.6066C74.452 28.9286 75.1558 29.0894 75.9708 29.0894C76.7554 29.0894 77.4444 28.9208 78.0377 28.5844C78.6268 28.2569 79.1068 27.7637 79.4183 27.1659C79.745 26.5523 79.9086 25.843 79.9086 25.0386C79.9086 24.2642 79.7478 23.5697 79.4257 22.9565C79.117 22.3516 78.6404 21.8487 78.0529 21.508C77.4592 21.161 76.7652 20.9872 75.9708 20.9872C75.171 20.9872 74.4719 21.161 73.8735 21.508C73.2876 21.8472 72.811 22.3471 72.5002 22.9486C72.1837 23.5572 72.0252 24.254 72.0252 25.0386C72.0252 25.8735 72.181 26.5948 72.4929 27.2033C72.7962 27.798 73.2722 28.2871 73.8582 28.6066ZM77.4869 27.0906C77.18 27.5231 76.6746 27.7393 75.9708 27.7393C75.493 27.7393 75.1082 27.6437 74.8166 27.4524C74.5246 27.2565 74.3134 26.9621 74.1826 26.5699C74.0518 26.1725 73.9867 25.6619 73.9867 25.0381C73.9867 24.1029 74.1401 23.419 74.4469 22.9866C74.7588 22.5541 75.2667 22.3378 75.9708 22.3378C76.6699 22.3378 77.1727 22.5541 77.4795 22.9866C77.7914 23.419 77.9471 24.1029 77.9471 25.0386C77.9471 25.9738 77.7937 26.6576 77.4869 27.0906ZM82.3982 28.6066C82.9869 28.9286 83.6883 29.0894 84.5033 29.0894C85.1369 29.0894 85.7029 28.9791 86.2005 28.7577C86.6989 28.5364 87.1031 28.2272 87.4152 27.8299C87.7279 27.4249 87.9329 26.9471 88.0109 26.4414L86.2534 26.2607C86.1328 26.7431 85.9316 27.1031 85.6497 27.3392C85.3683 27.5757 84.9857 27.694 84.5033 27.694C84.0103 27.694 83.6232 27.5933 83.3413 27.3918C83.0598 27.1858 82.8635 26.8919 82.7531 26.5093C82.6422 26.1221 82.5872 25.6318 82.5872 25.0386C82.5872 24.455 82.6422 23.9722 82.7531 23.59C82.8635 23.2028 83.0571 22.9062 83.3339 22.6997C83.6157 22.4884 84.0053 22.3831 84.5033 22.3831C85.0362 22.3831 85.4312 22.5314 85.6877 22.8281C85.949 23.1196 86.1354 23.5193 86.2456 24.0276L87.9735 23.718C87.8078 22.8932 87.4326 22.232 86.8491 21.7344C86.2708 21.2363 85.489 20.9877 84.5033 20.9877C83.6985 20.9877 83.0021 21.1587 82.4134 21.5006C81.8322 21.8351 81.3625 22.3337 81.0633 22.9339C80.7514 23.5424 80.5952 24.2439 80.5952 25.0386C80.5952 25.8781 80.7486 26.6026 81.0554 27.2112C81.3673 27.8197 81.8151 28.285 82.3982 28.6066ZM90.8104 26.0343L91.6627 25.2192L93.9257 28.9009H96.0308L92.8999 24.0498L95.9328 21.1757H93.5634L90.8104 23.9976V18.0832H88.9845V28.9009H90.8104V26.0343ZM97.6304 28.8103C98.1436 28.9965 98.7142 29.0894 99.3428 29.0894C100.303 29.0894 101.095 28.8981 101.719 28.5165C102.348 28.1339 102.663 27.5101 102.663 26.6451C102.663 26.0818 102.516 25.6392 102.225 25.3176C101.933 24.9905 101.586 24.7566 101.184 24.6157C100.786 24.4702 100.245 24.3219 99.562 24.1707C99.1642 24.0853 98.8502 24.0049 98.6188 23.9295C98.3873 23.8538 98.201 23.7558 98.0604 23.6352C97.925 23.5141 97.8567 23.3584 97.8567 23.1676C97.8567 22.8858 97.9824 22.6723 98.2338 22.5263C98.4853 22.3803 98.7973 22.3073 99.1694 22.3073C99.6619 22.3073 100.047 22.4255 100.324 22.6621C100.605 22.8987 100.756 23.2531 100.776 23.7258L102.466 23.4467C102.385 22.5817 102.046 21.9556 101.447 21.568C100.854 21.1812 100.095 20.9872 99.1694 20.9872C98.6258 20.9872 98.1236 21.0699 97.6607 21.2362C97.2029 21.397 96.8335 21.6511 96.5517 21.9986C96.27 22.3451 96.1294 22.7827 96.1294 23.3109C96.1294 23.7988 96.25 24.1934 96.4911 24.4951C96.7368 24.8001 97.0527 25.0408 97.4118 25.1965C97.7838 25.3578 98.2512 25.5112 98.8147 25.6567L99.2828 25.7699C99.5949 25.844 99.9044 25.9295 100.211 26.0264C100.421 26.092 100.595 26.1826 100.731 26.2981C100.867 26.4136 100.935 26.5647 100.935 26.7509C100.935 27.0776 100.799 27.3294 100.527 27.505C100.261 27.6815 99.8708 27.7693 99.3583 27.7693C98.8347 27.7693 98.4176 27.6385 98.1055 27.377C97.7941 27.1154 97.6355 26.7384 97.6304 26.2454L95.9109 26.4413C95.9302 27.0351 96.094 27.5304 96.4009 27.9278C96.7129 28.3252 97.1223 28.619 97.6304 28.8103Z"),Re.setAttribute("fill","black"),N.appendChild(Re);const be=document.createElementNS("http://www.w3.org/2000/svg","path");be.setAttribute("d","M37.6392 15V9.18182H39.7131C40.1657 9.18182 40.5407 9.2642 40.8381 9.42898C41.1354 9.59375 41.358 9.81913 41.5057 10.1051C41.6534 10.3892 41.7273 10.7093 41.7273 11.0653C41.7273 11.4233 41.6525 11.7453 41.5028 12.0312C41.3551 12.3153 41.1316 12.5407 40.8324 12.7074C40.535 12.8722 40.161 12.9545 39.7102 12.9545H38.2841V12.2102H39.6307C39.9167 12.2102 40.1487 12.161 40.3267 12.0625C40.5047 11.9621 40.6354 11.8258 40.7188 11.6534C40.8021 11.4811 40.8438 11.285 40.8438 11.0653C40.8438 10.8456 40.8021 10.6506 40.7188 10.4801C40.6354 10.3097 40.5038 10.1761 40.3239 10.0795C40.1458 9.98295 39.911 9.93466 39.6193 9.93466H38.517V15H37.6392ZM44.4716 15.0881C44.0625 15.0881 43.7055 14.9943 43.4006 14.8068C43.0956 14.6193 42.8589 14.357 42.6903 14.0199C42.5218 13.6828 42.4375 13.2888 42.4375 12.8381C42.4375 12.3854 42.5218 11.9896 42.6903 11.6506C42.8589 11.3116 43.0956 11.0483 43.4006 10.8608C43.7055 10.6733 44.0625 10.5795 44.4716 10.5795C44.8807 10.5795 45.2377 10.6733 45.5426 10.8608C45.8475 11.0483 46.0843 11.3116 46.2528 11.6506C46.4214 11.9896 46.5057 12.3854 46.5057 12.8381C46.5057 13.2888 46.4214 13.6828 46.2528 14.0199C46.0843 14.357 45.8475 14.6193 45.5426 14.8068C45.2377 14.9943 44.8807 15.0881 44.4716 15.0881ZM44.4744 14.375C44.7396 14.375 44.9593 14.3049 45.1335 14.1648C45.3078 14.0246 45.4366 13.8381 45.5199 13.6051C45.6051 13.3722 45.6477 13.1155 45.6477 12.8352C45.6477 12.5568 45.6051 12.3011 45.5199 12.0682C45.4366 11.8333 45.3078 11.6449 45.1335 11.5028C44.9593 11.3608 44.7396 11.2898 44.4744 11.2898C44.2074 11.2898 43.9858 11.3608 43.8097 11.5028C43.6354 11.6449 43.5057 11.8333 43.4205 12.0682C43.3371 12.3011 43.2955 12.5568 43.2955 12.8352C43.2955 13.1155 43.3371 13.3722 43.4205 13.6051C43.5057 13.8381 43.6354 14.0246 43.8097 14.1648C43.9858 14.3049 44.2074 14.375 44.4744 14.375ZM48.267 15L46.983 10.6364H47.8608L48.7159 13.8409H48.7585L49.6165 10.6364H50.4943L51.3466 13.8267H51.3892L52.2386 10.6364H53.1165L51.8352 15H50.9688L50.0824 11.8494H50.017L49.1307 15H48.267ZM55.6705 15.0881C55.2405 15.0881 54.8703 14.9962 54.5597 14.8125C54.2509 14.6269 54.0123 14.3665 53.8438 14.0312C53.6771 13.6941 53.5938 13.2992 53.5938 12.8466C53.5938 12.3996 53.6771 12.0057 53.8438 11.6648C54.0123 11.3239 54.2472 11.0578 54.5483 10.8665C54.8513 10.6752 55.2055 10.5795 55.6108 10.5795C55.857 10.5795 56.0956 10.6203 56.3267 10.7017C56.5578 10.7831 56.7652 10.911 56.9489 11.0852C57.1326 11.2595 57.2775 11.4858 57.3835 11.7642C57.4896 12.0407 57.5426 12.3769 57.5426 12.7727V13.0739H54.0739V12.4375H56.7102C56.7102 12.214 56.6648 12.0161 56.5739 11.8438C56.483 11.6695 56.3551 11.5322 56.1903 11.4318C56.0275 11.3314 55.8362 11.2812 55.6165 11.2812C55.3778 11.2812 55.1695 11.34 54.9915 11.4574C54.8153 11.5729 54.679 11.7244 54.5824 11.9119C54.4877 12.0975 54.4403 12.2992 54.4403 12.517V13.0142C54.4403 13.3059 54.4915 13.554 54.5938 13.7585C54.6979 13.9631 54.8428 14.1193 55.0284 14.2273C55.214 14.3333 55.4309 14.3864 55.679 14.3864C55.84 14.3864 55.9867 14.3636 56.1193 14.3182C56.2519 14.2708 56.3665 14.2008 56.4631 14.108C56.5597 14.0152 56.6335 13.9006 56.6847 13.7642L57.4886 13.9091C57.4242 14.1458 57.3087 14.3532 57.142 14.5312C56.9773 14.7074 56.7699 14.8447 56.5199 14.9432C56.2718 15.0398 55.9886 15.0881 55.6705 15.0881ZM58.4851 15V10.6364H59.3061V11.3295H59.3516C59.4311 11.0947 59.5713 10.91 59.772 10.7756C59.9747 10.6392 60.2038 10.571 60.4595 10.571C60.5125 10.571 60.575 10.5729 60.647 10.5767C60.7209 10.5805 60.7786 10.5852 60.8203 10.5909V11.4034C60.7862 11.3939 60.7256 11.3835 60.6385 11.3722C60.5514 11.3589 60.4643 11.3523 60.3771 11.3523C60.1764 11.3523 59.9974 11.3949 59.8402 11.4801C59.6849 11.5634 59.5618 11.6799 59.4709 11.8295C59.38 11.9773 59.3345 12.1458 59.3345 12.3352V15H58.4851ZM63.2798 15.0881C62.8499 15.0881 62.4796 14.9962 62.169 14.8125C61.8603 14.6269 61.6217 14.3665 61.4531 14.0312C61.2865 13.6941 61.2031 13.2992 61.2031 12.8466C61.2031 12.3996 61.2865 12.0057 61.4531 11.6648C61.6217 11.3239 61.8565 11.0578 62.1577 10.8665C62.4607 10.6752 62.8149 10.5795 63.2202 10.5795C63.4664 10.5795 63.705 10.6203 63.9361 10.7017C64.1671 10.7831 64.3745 10.911 64.5582 11.0852C64.742 11.2595 64.8868 11.4858 64.9929 11.7642C65.099 12.0407 65.152 12.3769 65.152 12.7727V13.0739H61.6832V12.4375H64.3196C64.3196 12.214 64.2741 12.0161 64.1832 11.8438C64.0923 11.6695 63.9645 11.5322 63.7997 11.4318C63.6368 11.3314 63.4455 11.2812 63.2259 11.2812C62.9872 11.2812 62.7789 11.34 62.6009 11.4574C62.4247 11.5729 62.2884 11.7244 62.1918 11.9119C62.0971 12.0975 62.0497 12.2992 62.0497 12.517V13.0142C62.0497 13.3059 62.1009 13.554 62.2031 13.7585C62.3073 13.9631 62.4522 14.1193 62.6378 14.2273C62.8234 14.3333 63.0402 14.3864 63.2884 14.3864C63.4493 14.3864 63.5961 14.3636 63.7287 14.3182C63.8613 14.2708 63.9759 14.2008 64.0724 14.108C64.169 14.0152 64.2429 13.9006 64.294 13.7642L65.098 13.9091C65.0336 14.1458 64.9181 14.3532 64.7514 14.5312C64.5866 14.7074 64.3793 14.8447 64.1293 14.9432C63.8812 15.0398 63.598 15.0881 63.2798 15.0881ZM67.728 15.0852C67.3757 15.0852 67.0613 14.9953 66.7848 14.8153C66.5102 14.6335 66.2943 14.375 66.1371 14.0398C65.9818 13.7027 65.9041 13.2983 65.9041 12.8267C65.9041 12.3551 65.9827 11.9517 66.1399 11.6165C66.299 11.2812 66.5168 11.0246 66.7933 10.8466C67.0698 10.6686 67.3833 10.5795 67.7337 10.5795C68.0045 10.5795 68.2223 10.625 68.3871 10.7159C68.5537 10.8049 68.6825 10.9091 68.7734 11.0284C68.8662 11.1477 68.9382 11.2528 68.9893 11.3438H69.0405V9.18182H69.8899V15H69.0604V14.321H68.9893C68.9382 14.4138 68.8643 14.5199 68.7678 14.6392C68.6731 14.7585 68.5424 14.8627 68.3757 14.9517C68.209 15.0407 67.9931 15.0852 67.728 15.0852ZM67.9155 14.3608C68.1598 14.3608 68.3662 14.2964 68.5348 14.1676C68.7053 14.0369 68.834 13.8561 68.9212 13.625C69.0102 13.3939 69.0547 13.125 69.0547 12.8182C69.0547 12.5152 69.0111 12.25 68.924 12.0227C68.8369 11.7955 68.709 11.6184 68.5405 11.4915C68.3719 11.3646 68.1636 11.3011 67.9155 11.3011C67.6598 11.3011 67.4467 11.3674 67.2763 11.5C67.1058 11.6326 66.977 11.8134 66.8899 12.0426C66.8047 12.2718 66.7621 12.5303 66.7621 12.8182C66.7621 13.1098 66.8056 13.3722 66.8928 13.6051C66.9799 13.8381 67.1087 14.0227 67.2791 14.1591C67.4515 14.2936 67.6636 14.3608 67.9155 14.3608ZM73.2876 15V9.18182H74.1371V11.3438H74.1882C74.2375 11.2528 74.3085 11.1477 74.4013 11.0284C74.4941 10.9091 74.6229 10.8049 74.7876 10.7159C74.9524 10.625 75.1702 10.5795 75.4411 10.5795C75.7933 10.5795 76.1077 10.6686 76.3842 10.8466C76.6607 11.0246 76.8776 11.2812 77.0348 11.6165C77.1939 11.9517 77.2734 12.3551 77.2734 12.8267C77.2734 13.2983 77.1948 13.7027 77.0376 14.0398C76.8804 14.375 76.6645 14.6335 76.3899 14.8153C76.1153 14.9953 75.8018 15.0852 75.4496 15.0852C75.1844 15.0852 74.9676 15.0407 74.799 14.9517C74.6323 14.8627 74.5017 14.7585 74.407 14.6392C74.3123 14.5199 74.2393 14.4138 74.1882 14.321H74.1172V15H73.2876ZM74.12 12.8182C74.12 13.125 74.1645 13.3939 74.2536 13.625C74.3426 13.8561 74.4714 14.0369 74.6399 14.1676C74.8085 14.2964 75.0149 14.3608 75.2592 14.3608C75.513 14.3608 75.7251 14.2936 75.8956 14.1591C76.0661 14.0227 76.1948 13.8381 76.282 13.6051C76.371 13.3722 76.4155 13.1098 76.4155 12.8182C76.4155 12.5303 76.3719 12.2718 76.2848 12.0426C76.1996 11.8134 76.0708 11.6326 75.8984 11.5C75.728 11.3674 75.5149 11.3011 75.2592 11.3011C75.013 11.3011 74.8047 11.3646 74.6342 11.4915C74.4657 11.6184 74.3378 11.7955 74.2507 12.0227C74.1636 12.25 74.12 12.5152 74.12 12.8182ZM78.6158 16.6364C78.4889 16.6364 78.3733 16.6259 78.2692 16.6051C78.165 16.5862 78.0874 16.5653 78.0362 16.5426L78.2408 15.8466C78.3961 15.8883 78.5343 15.9063 78.6555 15.9006C78.7768 15.8949 78.8838 15.8494 78.9766 15.7642C79.0713 15.679 79.1546 15.5398 79.2266 15.3466L79.3317 15.0568L77.7351 10.6364H78.6442L79.7493 14.0227H79.7947L80.8999 10.6364H81.8118L80.0135 15.5824C79.9302 15.8097 79.8241 16.0019 79.6953 16.1591C79.5665 16.3182 79.4131 16.4375 79.2351 16.517C79.0571 16.5966 78.8506 16.6364 78.6158 16.6364Z"),be.setAttribute("fill","black"),be.setAttribute("fill-opacity","0.5"),N.appendChild(be);const tt=document.createElementNS("http://www.w3.org/2000/svg","rect");tt.setAttribute("x","7"),tt.setAttribute("y","7"),tt.setAttribute("width","24"),tt.setAttribute("height","24"),tt.setAttribute("rx","3"),tt.setAttribute("fill","black"),N.appendChild(tt);const Bt=document.createElementNS("http://www.w3.org/2000/svg","path");Bt.setAttribute("fill-rule","evenodd"),Bt.setAttribute("clip-rule","evenodd"),Bt.setAttribute("d","M22.0455 15H12.2273L15.1364 17.9091V21.9091L22.0455 15Z"),Bt.setAttribute("fill","white"),N.appendChild(Bt);const Ft=document.createElementNS("http://www.w3.org/2000/svg","path");Ft.setAttribute("fill-rule","evenodd"),Ft.setAttribute("clip-rule","evenodd"),Ft.setAttribute("d","M16.9546 22.9999H26.7728L23.8637 20.0908V16.0908L16.9546 22.9999Z"),Ft.setAttribute("fill","white"),N.appendChild(Ft),L.appendChild(N),j.appendChild(L);const qe=document.createElement("button");qe.id="liveblocks-badge-hide-button",qe.style.position="absolute",qe.style.top="0",qe.style.right="0",qe.style.border="none",qe.style.padding="0",qe.style.margin="0",qe.style.background="none",qe.style.font="inherit",qe.style.cursor="pointer",qe.style.outline="none",qe.style.setProperty("-webkit-appearance","none"),qe.style.setProperty("-moz-appearance","none"),qe.style.setProperty("appearance","none"),qe.style.opacity="0",qe.onclick=()=>{const Jn=document.getElementById("liveblocks-badge");Jn&&(Jn.style.display="none")},qe.onmouseenter=()=>{qe.style.opacity="0.5"},qe.onmouseleave=()=>{qe.style.opacity="0.3"};const mn=document.createElementNS("http://www.w3.org/2000/svg","svg");mn.setAttribute("width","18"),mn.setAttribute("height","18"),mn.setAttribute("viewBox","0 0 18 18"),mn.setAttribute("fill","none");const na=document.createElementNS("http://www.w3.org/2000/svg","path");na.setAttribute("d","M6 6L9 9M12 12L9 9M9 9L12 6M9 9L6 12"),na.setAttribute("stroke","black"),mn.appendChild(na),qe.appendChild(mn),j.appendChild(qe),document.body.appendChild(j),requestAnimationFrame((()=>{requestAnimationFrame((()=>{j.style.opacity="1"}))}))})(t.badgeLocation??"bottom-right");for(const P of c.others.connectionIds())O.users[P]===void 0&&c.others.removeConnection(P);for(const P in O.users){const j=O.users[P],L=Number(P);c.others.setConnection(L,j.id,j.info,dd(j.scopes))}return{type:"reset"}}function ne(){return c.undoStack.length>0}function B(){return c.redoStack.length>0}function X(){h>0||C.history.notify({canUndo:ne(),canRedo:B()})}function K(O){c.others.setConnection(O.actor,O.id,O.info,dd(O.scopes)),c.buffer.messages.push({type:at.UPDATE_PRESENCE,data:c.myPresence.get(),targetActor:O.actor}),fe();const P=c.others.getUser(O.actor);return P?{type:"enter",user:P}:void 0}function Y(O){return(function(P){return!(function(j){return j===null||typeof j=="string"||typeof j=="number"||typeof j=="boolean"})(P)&&!ld(P)})(O)?O:null}function de(O){return O.type===xe.FEED_REQUEST_FAILED}function pe(O){if(typeof O.data!="string")return;const P=(function(L){const N=Ln(L);return N===void 0?null:ld(N)?Ya(N.map((ce=>Y(ce)))):Ya([Y(N)])})(O.data);if(P===null||P.length===0)return;const j={storageUpdates:new Map,others:[]};for(const L of P)switch(L.type){case xe.USER_JOINED:{const N=K(L);N&&j.others.push(N);break}case xe.UPDATE_PRESENCE:{const N=ie(L);N&&j.others.push(N);break}case xe.BROADCASTED_EVENT:{const N=c.others.get();C.customEvent.notify({connectionId:L.actor,user:L.actor<0?null:N.find((ce=>ce.connectionId===L.actor))??null,event:L.event});break}case xe.USER_LEFT:{const N=Se(L);N&&j.others.push(N);break}case xe.UPDATE_YDOC:C.ydoc.notify(L);break;case xe.ROOM_STATE:j.others.push(Ie(L));break;case xe.STORAGE_CHUNK:y?.lap(),g.append(Hv(L.nodes));break;case xe.STORAGE_STREAM_END:{const N=y?.stop();if(N){const ce=Re=>`${Re.toFixed(1)}ms`,Ee=N.laps.slice(1);mt(`Storage chunk arrival: ${[`total=${ce(N.total)}`,`first=${ce(N.laps[0])}`,`rest.n=${Ee.length}`,`rest.avg=${ce(Ee.reduce(((Re,be)=>Re+be),0)/Ee.length)}`,`rest.max=${ce(Ee.reduce(((Re,be)=>Math.max(Re,be)),0))}`].join(", ")}`)}oe(g.take());break}case xe.UPDATE_STORAGE:{const N=V(L.ops);for(const[ce,Ee]of N.updates.storageUpdates)j.storageUpdates.set(ce,zi(j.storageUpdates.get(ce),Ee));break}case xe.REJECT_STORAGE_OP:{op("Storage mutation rejection error",L.reason);let N=!1;for(const ce of L.opIds){const Ee=c.unacknowledgedOps.get(ce);if(c.unacknowledgedOps.delete(ce),c.buffer.storageOperations=c.buffer.storageOperations.filter((Re=>Re.opId!==ce)),G.delete(ce),Ee!==void 0&&Ee.type===ue.UPDATE_TEXT){const Re=c.pool.nodes.get(Ee.id);Re!==void 0&&hu(Re)&&(Re._rejectPendingOp(ce),N=!0)}}N&&(ge(),fe());break}case xe.THREAD_CREATED:case xe.THREAD_DELETED:case xe.THREAD_METADATA_UPDATED:case xe.THREAD_UPDATED:case xe.COMMENT_REACTION_ADDED:case xe.COMMENT_REACTION_REMOVED:case xe.COMMENT_CREATED:case xe.COMMENT_EDITED:case xe.COMMENT_DELETED:case xe.COMMENT_METADATA_UPDATED:C.comments.notify(L);break;case xe.FEEDS_LIST:{const N=L,ce=te.get(N.requestId);ce&&(ce.resolve({feeds:N.feeds,nextCursor:N.nextCursor}),te.delete(N.requestId)),C.feeds.notify(N);break}case xe.FEEDS_ADDED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEEDS_UPDATED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_DELETED:C.feeds.notify(L),J(L);break;case xe.FEED_MESSAGES_LIST:{const N=L,ce=me.get(N.requestId);ce&&(ce.resolve({messages:N.messages,nextCursor:N.nextCursor}),me.delete(N.requestId)),C.feeds.notify(N);break}case xe.FEED_MESSAGES_ADDED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_MESSAGES_UPDATED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_MESSAGES_DELETED:C.feeds.notify(L),J(L);break;case xe.FEED_REQUEST_FAILED:{if(!de(L))break;const{requestId:N,code:ce,reason:Ee}=L,Re=new pu(Ee??"Feed request failed",{type:"FEED_REQUEST_ERROR",roomId:n,requestId:N,code:ce,reason:Ee});if(Ae.has(N))Fe(N,"error",Re);else if(te.has(N)){const be=te.get(N);te.delete(N),be?.reject(Re)}else if(me.has(N)){const be=me.get(N);me.delete(N),be?.reject(Re)}C.feeds.notify(L);break}case xe.STORAGE_STATE_V7:}W(j)}function fe(){const O=c.buffer.storageOperations;if(O.length>0){for(const L of O)c.unacknowledgedOps.add(L);Gn()}if(l.getStatus()!=="connected")return void(c.buffer.storageOperations=[]);const P=Date.now(),j=P-c.buffer.lastFlushedAt;if(j>=t.throttleDelay){const L=(function(){const N=[];c.buffer.presenceUpdates&&N.push(c.buffer.presenceUpdates.type==="full"?{type:at.UPDATE_PRESENCE,targetActor:-1,data:c.buffer.presenceUpdates.data}:{type:at.UPDATE_PRESENCE,data:c.buffer.presenceUpdates.data});for(const ce of c.buffer.messages)N.push(ce);return c.buffer.storageOperations.length>0&&N.push({type:at.UPDATE_STORAGE,ops:c.buffer.storageOperations}),N})();if(L.length===0)return;E(L),c.buffer={flushTimerID:void 0,lastFlushedAt:P,messages:[],storageOperations:[],presenceUpdates:null}}else clearTimeout(c.buffer.flushTimerID),c.buffer.flushTimerID=setTimeout(fe,t.throttleDelay-j)}function we(O){const{storageOperations:P}=c.buffer;for(const j of O)P.push(j);fe()}let Ce=null,se=null;const te=new Map,me=new Map,Ae=new Map,Pe=new Map;function Fe(O,P,j){const L=Ae.get(O);if(L!==void 0){if(clearTimeout(L.timeoutId),Ae.delete(O),L.kind==="add-message"&&!L.expectedClientMessageId){const N=Pe.get(L.feedId);if(N!==void 0){const ce=N.indexOf(O);ce>=0&&N.splice(ce,1),N.length===0&&Pe.delete(L.feedId)}}P==="ok"?L.resolve():L.reject(j??new Error("Feed mutation failed"))}}function re(O,P,j,L){const{promise:N,resolve:ce,reject:Ee}=uo(),Re=setTimeout((()=>{Ae.has(O)&&Fe(O,"error",new Error("Feed mutation timeout"))}),va);if(Ae.set(O,{resolve:ce,reject:Ee,timeoutId:Re,kind:P,feedId:j,messageId:L?.messageId,expectedClientMessageId:L?.expectedClientMessageId}),P==="add-message"&&L?.expectedClientMessageId===void 0){const be=Pe.get(j)??[];be.push(O),Pe.set(j,be)}return N}function J(O){switch(O.type){case xe.FEEDS_ADDED:for(const P of O.feeds)for(const[j,L]of[...Ae])if(L.kind==="add-feed"&&L.feedId===P.feedId){Fe(j,"ok");break}break;case xe.FEEDS_UPDATED:for(const P of O.feeds)for(const[j,L]of[...Ae])L.kind==="update-feed"&&L.feedId===P.feedId&&Fe(j,"ok");break;case xe.FEED_DELETED:for(const[P,j]of[...Ae])if(j.kind==="delete-feed"&&j.feedId===O.feedId){Fe(P,"ok");break}break;case xe.FEED_MESSAGES_ADDED:for(const P of O.messages){let j=!1;for(const[L,N]of[...Ae])if(N.kind==="add-message"&&N.feedId===O.feedId&&N.expectedClientMessageId===P.id){Fe(L,"ok"),j=!0;break}if(!j){const L=Pe.get(O.feedId),N=L?.[0];if(N!==void 0){const ce=Ae.get(N);ce?.kind==="add-message"&&ce.expectedClientMessageId===void 0&&Fe(N,"ok")}}}break;case xe.FEED_MESSAGES_UPDATED:for(const P of O.messages)for(const[j,L]of[...Ae])L.kind==="update-message"&&L.feedId===O.feedId&&L.messageId===P.id&&Fe(j,"ok");break;case xe.FEED_MESSAGES_DELETED:for(const P of O.messageIds)for(const[j,L]of[...Ae])L.kind==="delete-message"&&L.feedId===O.feedId&&L.messageId===P&&Fe(j,"ok")}}function oe(O){const P=[...c.unacknowledgedOps.values()];S(O),(function(j){if(j.length===0)return;const L=[],N=$(j);L.push({type:at.UPDATE_STORAGE,ops:N.opsToEmit}),W(N.updates),E(L)})(P),se?.(),Gn(),C.storageDidLoad.notify()}function ge(){const O=c.buffer.messages;O.some((P=>P.type===at.FETCH_STORAGE))||(O.push({type:at.FETCH_STORAGE}),g.take(),y?.start())}function ve(){return Ce===null&&(ge(),fe(),Ce=new Promise((O=>{se=O})),Gn()),Ce}function Te(){const O=c.root;return O!==void 0?O:(ve(),null)}async function We(){return c.root!==void 0?Promise.resolve({root:c.root}):(await ve(),{root:ye(c.root)})}function Le(){const O=c.pausedHistory;c.pausedHistory=null,O!==null&&O.length>0&&M(Array.from(O))}function et(O){const P=c.undoStack,j=c.redoStack,L=[],N=[];c.undoStack=L,c.redoStack=N,h++;try{return O()}finally{if(h--,c.undoStack!==L||c.redoStack!==N)throw new Error("unexpected stack swap during history.disable()");c.undoStack=P,c.redoStack=j}}const ut=t.createSyncSource();function Nt(){return c.root===void 0?Ce===null?"not-loaded":"loading":c.unacknowledgedOps.size===0?"synchronized":"synchronizing"}let hn=Nt();function Gn(){const O=Nt();hn!==O&&(hn=O,C.storageStatus.notify(O)),ut.setSyncStatus(O==="synchronizing"?"synchronizing":"synchronized")}function pn(){return A.get()!==null}function Mi(){return Te()!==null}const ta=$e.from(c.others.signal,(O=>O.map(((P,j)=>fd(`Other ${j}`,P))))),Ho={status:C.status.observable,lostConnection:C.lostConnection.observable,customEvent:C.customEvent.observable,others:C.others.observable,self:C.self.observable,myPresence:C.myPresence.observable,storageBatch:C.storageBatch.observable,history:C.history.observable,storageDidLoad:C.storageDidLoad.observable,storageStatus:C.storageStatus.observable,ydoc:C.ydoc.observable,comments:C.comments.observable,feeds:C.feeds.observable,roomWillDestroy:C.roomWillDestroy.observable};function Pi(O){return i.getSubscriptionSettings({roomId:n,signal:O?.signal})}function Ni(O){return i.updateSubscriptionSettings({roomId:n,settings:O})}const Vo=t.createSyncSource();function $o(O){return Vo.setSyncStatus(O==="synchronizing"||O==="loading"?"synchronizing":"synchronized")}return Object.defineProperty({[Oe]:{get presenceBuffer(){return hi(c.buffer.presenceUpdates?.data??null)},get undoStack(){return structuredClone(c.undoStack.map((O=>({id:O.id,frames:O.frames}))))},get redoStack(){return structuredClone(c.redoStack.map((O=>({id:O.id,frames:O.frames}))))},get nodeCount(){return c.pool.nodes.size},history:C.privateHistory.observable,getYjsProvider:()=>c.yjsProvider,setYjsProvider(O){c.yjsProvider?.off("status",$o),c.yjsProvider=O,O?.on("status",$o),c.yjsProviderDidChange.notify()},yjsProviderDidChange:c.yjsProviderDidChange.observable,reportTextEditor:async function(O,P){await i.reportTextEditor({roomId:n,type:O,rootKey:P})},getPermissionMatrix:()=>c.dynamicSessionInfoSig.get()?.permissionMatrix,createTextMention:async function(O,P){return i.createTextMention({roomId:n,mentionId:O,mention:P})},deleteTextMention:async function(O){return i.deleteTextMention({roomId:n,mentionId:O})},listHistoryVersions:async function(){return i.listHistoryVersions({roomId:n})},listHistoryVersionsSince:async function(O){return i.listHistoryVersionsSince({roomId:n,since:O.since,signal:O.signal})},fetchStorageHistoryVersion:async function(O){return i.fetchStorageHistoryVersion({roomId:n,versionId:O})},fetchYjsHistoryVersion:async function(O){return i.fetchYjsHistoryVersion({roomId:n,versionId:O})},liveObjectFromNodeStream:L1,reconcileStorageWithNodes:function(O){if(c.root===void 0)throw new Error("Cannot reconcile storage before it is loaded");const P=F(new Map(O),{includeLiveTextUpdates:!0});if(P.length===0)return;const j=$(P);j.reverse.length>0&&H(j.reverse),c.redoStack.length=0;for(const L of j.opsToEmit)c.buffer.storageOperations.push(L);W(j.updates),X(),fe()},createVersionHistorySnapshot:async function(){return i.createVersionHistorySnapshot({roomId:n})},deleteHistoryVersion:async function(O){return i.deleteHistoryVersion({roomId:n,versionId:O})},executeContextualPrompt:async function(O){return i.executeContextualPrompt({roomId:n,...O})},getSelf_forDevTools:()=>T.get(),getOthers_forDevTools:()=>ta.get(),simulate:{explicitClose:O=>l._privateSendMachineEvent({type:"EXPLICIT_SOCKET_CLOSE",event:O}),rawSend:O=>l.send(O),incomingMessage:O=>pe(new MessageEvent("message",{data:O}))},attachmentUrlsStore:i.getOrCreateAttachmentUrlsStore(n),fileUrlsStore:i.getOrCreateFileUrlsStore(n)},id:n,subscribe:Z1(n,C,t.errorEventSource),connect:()=>l.connect(),reconnect:()=>l.reconnect(),disconnect:()=>l.disconnect(),_dump:()=>{const O=c.pool.nodes.size;return`Room "${n}" (${O} node${O===1?"":"s"}):
|
|
1
|
+
var Ol=e=>{throw TypeError(e)};var Sl=(e,t,n)=>t.has(e)||Ol("Cannot "+n);var bt=(e,t,n)=>(Sl(e,t,"read from private field"),n?n.call(e):t.get(e)),Il=(e,t,n)=>t.has(e)?Ol("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ra=(e,t,n,r)=>(Sl(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);import{r as Iv,a as m,b as Xa,e as Fo,g as Tv,R as Be}from"./sentry-CtZyo70D.js";import{r as Oi,R as kv}from"./core-DtTeGJWB.js";import{H as Tl,I as kl,J as Bv,K as rc}from"./zeni-epic-state-DZFeYKWz.js";import{t as Fv,d as Rv}from"./recharts-VBeTlX07.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]="991a1250-b80a-4afd-af2d-856fe452de34",e._sentryDebugIdIdentifier="sentry-dbid-991a1250-b80a-4afd-af2d-856fe452de34")}catch{}})();var Bl,Fl,Rl={exports:{}},Wo={},v=(Fl||(Fl=1,Rl.exports=(function(){if(Bl)return Wo;Bl=1;var e=Iv(),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 s(a,u,l){var f,c={},d=null,h=null;for(f in l!==void 0&&(d=""+l),u.key!==void 0&&(d=""+u.key),u.ref!==void 0&&(h=u.ref),u)r.call(u,f)&&!i.hasOwnProperty(f)&&(c[f]=u[f]);if(a&&a.defaultProps)for(f in u=a.defaultProps)c[f]===void 0&&(c[f]=u[f]);return{$$typeof:t,type:a,key:d,ref:h,props:c,_owner:o.current}}return Wo.Fragment=n,Wo.jsx=s,Wo.jsxs=s,Wo})()),Rl.exports);function Ax(e){const[t,n]=m.useState(!1);return m.useEffect((()=>{n(!0)}),[]),v.jsx(m.Suspense,{fallback:e.fallback,children:t?typeof e.children=="function"?e.children():e.children:e.fallback})}var _v=Object.defineProperty,Ls="3.24.0",Li=typeof globalThis<"u"?globalThis:typeof window<"u"?window:Xa!==void 0?Xa:{};function Kh(e,t,n){const r=Symbol.for(e),o=`${t} (${n})`;Li[r]?Li[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} ${Li[r]} (already loaded)`,`- ${e} ${o} (trying to load this now)`].join(`
|
|
2
|
+
`)):Li[r]=o}function Ue(){const e=new Set;function t(o){return e.add(o),()=>e.delete(o)}function n(o){const i=t((s=>(i(),o(s))));return i}async function r(o){let i;return new Promise((s=>{i=t((a=>{(o===void 0||o(a))&&s(a)}))})).finally((()=>i?.()))}return{notify:function(o){let i=!1;for(const s of e)s(o),i=!0;return i},subscribe:t,subscribeOnce:n,count:function(){return e.size},waitUntil:r,dispose(){e.clear()},observable:{subscribe:t,subscribeOnce:n,waitUntil:r}}}function dn(e){throw new Error(e)}function oc(e){return Object.entries(e)}function Ln(e){try{return JSON.parse(e)}catch{return}}function hi(e){return JSON.parse(JSON.stringify(e))}function Ya(e){return e.filter((t=>t!=null))}function pi(e){const t={...e};return Object.keys(e).forEach((n=>{const r=n;t[r]===void 0&&delete t[r]})),t}function jv(e){return new Promise((t=>setTimeout(t,e)))}async function _l(e,t,n){let r;const o=new Promise(((i,s)=>{r=setTimeout((()=>{s(new Error(n))}),t)}));return Promise.race([e,o]).finally((()=>clearTimeout(r)))}function jl(e){let t=null;return()=>(t===null&&(t=e().catch((n=>{throw setTimeout((()=>{t=null}),5e3),n}))),t)}function qh(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n],n,e))return n;return-1}var yr=Symbol("kSinks"),Es=Symbol("kTrigger"),so=null,Ar=null;function Xe(e){if(so===null){so=new Set;try{e()}finally{for(const t of so)t[Es]();so=null}}else e()}function ic(e){so||dn("Expected to be in an active batch"),so.add(e)}function Gh(e,t){let n=!1;const r={...e};return Object.keys(t).forEach((o=>{const i=o,s=t[i];r[i]!==s&&(s===void 0?delete r[i]:r[i]=s,n=!0)})),n?r:e}var sc=class{equals;#e;[yr];constructor(e){this.equals=e??Object.is,this.#e=Ue(),this[yr]=new Set,this.get=this.get.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeOnce=this.subscribeOnce.bind(this)}dispose(){this.#e.dispose(),this.#e="(disposed)",this.equals="(disposed)"}get hasWatchers(){if(this.#e.count()>0)return!0;for(const e of this[yr])if(e.hasWatchers)return!0;return!1}[Es](){this.#e.notify();for(const e of this[yr])ic(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[yr])e.markDirty()}addSink(e){this[yr].add(e)}removeSink(e){this[yr].delete(e)}asReadonly(){return this}},Tt=class extends sc{#e;constructor(e,t){super(t),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return Ar?.add(this),this.#e}set(e){Xe((()=>{typeof e=="function"&&(e=e(this.#e)),this.equals(this.#e,e)||(this.#e=e,this.markSinksDirty(),ic(this))}))}},Mv=class extends Tt{constructor(e){super(pi(e))}set(){throw new Error("Don't call .set() directly, use .patch()")}patch(e){super.set((t=>Gh(t,e)))}},Pv=Symbol(),$e=class Qa extends sc{#e;#t;#n;#r;#o;static from(...t){const n=t.pop();if(typeof n!="function"&&dn("Invalid .from() call, last argument expected to be a function"),typeof t[t.length-1]=="function"){const r=n,o=t.pop();return new Qa(t,o,r)}return new Qa(t,n)}constructor(t,n,r){super(r),this.#t=!0,this.#e=Pv,this.#r=t,this.#n=new Set,this.#o=n}dispose(){for(const t of this.#n)t.removeSink(this);this.#e="(disposed)",this.#n="(disposed)",this.#r="(disposed)",this.#o="(disposed)"}get isDirty(){return this.#t}#i(){const t=Ar;let n;Ar=new Set;try{n=this.#o(...this.#r.map((r=>r.get())))}finally{const r=this.#n;this.#n=new Set;for(const o of Ar)this.#n.add(o),r.delete(o);for(const o of r)o.removeSink(this);for(const o of this.#n)o.addSink(this);Ar=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.#i(),Ar?.add(this),this.#e}[Es](){this.hasWatchers&&this.#i()&&super[Es]()}},Ot=class extends sc{#e;constructor(e){super(),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return Ar?.add(this),this.#e}mutate(e){Xe((()=>{const t=!e||e(this.#e);t!==null&&typeof t=="object"&&"then"in t&&dn("MutableSignal.mutate() does not support async callbacks"),t!==!1&&(this.markSinksDirty(),ic(this))}))}};function Ml(e,t,n){let r=0,o=e.length;for(;r<o;){const i=r+(o-r>>1);n(t,e[i])?o=i:r=i+1}return r}var ir=class Xo{#e;#t;constructor(t,n){this.#t=n,this.#e=t}static with(t){return Xo.fromAlreadySorted([],t)}static from(t,n){const r=new Xo([],n);for(const o of t)r.add(o);return r}static fromAlreadySorted(t,n){return new Xo(t,n)}clone(){return new Xo(this.#e.slice(),this.#t)}add(t){const n=Ml(this.#e,t,this.#t);return this.#e.splice(n,0,t),n}clear(){const t=this.#e.length>0;return this.#e.length=0,t}removeBy(t,n=Number.POSITIVE_INFINITY){let r=0;for(let o=0;o<this.#e.length;o++)if(t(this.#e[o])){if(this.#e.splice(o,1),r++,r>=n)break;o--}return r>0}remove(t){const n=this.#e.indexOf(t);return n>=0&&(this.#e.splice(n,1),!0)}removeAt(t){if(t<0||t>=this.#e.length)return;const[n]=this.#e.splice(t,1);return n}reposition(t){const n=this.#e.indexOf(t);if(n<0)throw new Error("Cannot reposition item that is not in the list");const r=this.#e[n-1],o=this.#e[n+1],i=r===void 0||this.#t(r,t),s=o===void 0||this.#t(t,o);if(i&&s)return n;let a=n;for(;a>0&&this.#t(t,this.#e[a-1]);)this.#e[a]=this.#e[a-1],a--;if(a<n)return this.#e[a]=t,a;for(;a<this.#e.length-1&&!this.#t(t,this.#e[a+1]);)this.#e[a]=this.#e[a+1],a++;return a!==n&&(this.#e[a]=t),a}at(t){return this.#e[t]}get length(){return this.#e.length}includes(t){for(let n=Ml(this.#e,t,this.#t)-1;n>=0&&!this.#t(this.#e[n],t);n--)if(this.#e[n]===t)return!0;return!1}*filter(t){for(const n of this.#e)t(n)&&(yield n)}*findAllRight(t){for(let n=this.#e.length-1;n>=0;n--){const r=this.#e[n];t(r,n)&&(yield r)}}[Symbol.iterator](){return this.#e[Symbol.iterator]()}*iterReversed(){for(let t=this.#e.length-1;t>=0;t--)yield this.#e[t]}find(t,n){const r=this.findIndex(t,n);return r>-1?this.#e.at(r):void 0}findIndex(t,n=0){for(let r=Math.max(0,n);r<this.#e.length;r++)if(t(this.#e[r],r))return r;return-1}findRight(t,n){const r=this.findIndexRight(t,n);return r>-1?this.#e.at(r):void 0}findIndexRight(t,n=this.#e.length-1){for(let r=Math.min(n,this.#e.length-1);r>=0;r--)if(t(this.#e[r],r))return r;return-1}get rawArray(){return this.#e}},Nv=class{#e;#t;signal;constructor(){this.#e=new Map,this.#t=ir.from([],((e,t)=>{const n=t.lastMessageAt??t.createdAt,r=e.lastMessageAt??e.createdAt;return n<r||n===r&&t.id<e.id})),this.signal=new Ot(this)}getEvenIfDeleted(e){return this.signal.get(),this.#e.get(e)}markDeleted(e){const t=this.#e.get(e);t!==void 0&&t.deletedAt===void 0&&this.upsert({...t,deletedAt:new Date().toISOString()})}upsert(e){this.signal.mutate((()=>{const t=this.#e.get(e.id);if(t!==void 0){if(t.deletedAt!==void 0)return!1;this.#t.remove(t),this.#e.delete(t.id)}return e.deletedAt===void 0&&this.#t.add(e),this.#e.set(e.id,e),!0}))}findMany(e){return Array.from(this.#t.filter((t=>{if(e.metadata===void 0)return!0;for(const[n,r]of Object.entries(e.metadata))if(r===null){if(n in t.metadata)return!1}else if(typeof r=="string"){if(t.metadata[n]!==r)return!1}else{const o=t.metadata[n];if(!Array.isArray(o)||!r.every((i=>o.includes(i))))return!1}return!0})))}};function eu(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 Zn(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.comments.map((o=>eu(o)));return{...e,createdAt:t,updatedAt:n,comments:r}}function br(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 Xn(e){const t=new Date(e.createdAt);return{...e,createdAt:t}}function oa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function ia(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function sa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function Pl(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.members.map((o=>({...o,addedAt:new Date(o.addedAt)})));return{...e,createdAt:t,updatedAt:n,members:r}}function Ye(e,t){throw new Error(t)}function ye(e,t="Expected value to be non-nullable"){return e}var st=(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?"_":"-")),""),ue=Object.freeze({INIT:0,SET_PARENT_KEY:1,CREATE_LIST:2,UPDATE_OBJECT:3,CREATE_OBJECT:4,DELETE_CRDT:5,DELETE_OBJECT_KEY:6,CREATE_MAP:7,CREATE_REGISTER:8,CREATE_TEXT:9,UPDATE_TEXT:10,CREATE_FILE:11});function tu(e){return e.type===ue.CREATE_OBJECT||e.type===ue.CREATE_REGISTER||e.type===ue.CREATE_FILE||e.type===ue.CREATE_MAP||e.type===ue.CREATE_LIST||e.type===ue.CREATE_TEXT}var je=Object.freeze({OBJECT:0,LIST:1,MAP:2,REGISTER:3,TEXT:4,FILE:5});function Lv(e){return e[0]==="root"}function Jh(e){return e[1].type===je.OBJECT}function Zh(e){return e[1].type===je.LIST}function Xh(e){return e[1].type===je.MAP}function Yh(e){return e[1].type===je.REGISTER}function Qh(e){return e[1].type===je.TEXT}function ep(e){return e[1].type===je.FILE}function Uv(e){return e[0]==="root"}function*Hv(e){for(const t of e)if(Uv(t))yield[t[0],{type:je.OBJECT,data:t[1]}];else switch(t[1]){case je.OBJECT:yield[t[0],{type:je.OBJECT,parentId:t[2],parentKey:t[3],data:t[4]}];break;case je.LIST:yield[t[0],{type:je.LIST,parentId:t[2],parentKey:t[3]}];break;case je.MAP:yield[t[0],{type:je.MAP,parentId:t[2],parentKey:t[3]}];break;case je.REGISTER:yield[t[0],{type:je.REGISTER,parentId:t[2],parentKey:t[3],data:t[4]}];break;case je.TEXT:yield[t[0],{type:je.TEXT,parentId:t[2],parentKey:t[3],data:t[4],version:t[5]}];break;case je.FILE:yield[t[0],{type:je.FILE,parentId:t[2],parentKey:t[3],data:t[4]}]}}var Oe=Symbol(),Zt={};((e,t)=>{for(var n in t)_v(e,n,{get:t[n],enumerable:!0})})(Zt,{error:()=>Un,errorWithTitle:()=>op,warn:()=>mt,warnWithTitle:()=>Vv});var tp="background:#0e0d12;border-radius:9999px;color:#fff;padding:3px 7px;font-family:sans-serif;font-weight:600;";function np(e){return typeof window>"u"?console[e]:(t,...n)=>console[e]("%cLiveblocks",tp,t,...n)}var mt=np("warn"),Un=np("error");function rp(e){return typeof window>"u"?console[e]:(t,n,...r)=>console[e](`%cLiveblocks%c ${t}`,tp,"font-weight:600",n,...r)}var Vv=rp("warn"),op=rp("error"),Ut=32,Sr=126,Us=ac(0),eo=ac(1),$v=Us+ac(-1);function ac(e){const t=Ut+(e<0?95+e:e);if(t<Ut||t>Sr)throw new Error(`Invalid n value: ${e}`);return String.fromCharCode(t)}function gn(e,t){return e!==void 0&&t!==void 0?(function(n,r){if(n<r)return nu(n,r);if(n>r)return nu(r,n);throw new Error("Cannot compute value between two equal positions")})(e,t):e!==void 0?(function(n){for(let s=0;s<n.length;s++){const a=n.charCodeAt(s);if(a<Ut||a>Sr)return n+eo}for(;n.length>1&&n.charCodeAt(n.length-1)===Ut;)n=n.slice(0,-1);if(n.length===0||n===Us)return eo;let r=Ui;n.length>Ui&&(r=Ui+Math.ceil((n.length-Ui)/aa)*aa);const o=Nl(n,r);if(o!==null)return o;r+=aa;const i=Nl(n,r);return i!==null?i:n+eo})(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<=Ut))return o===r?i===33?n.substring(0,o)+$v:n.substring(0,o)+String.fromCharCode(i-1):n.substring(0,o+1)}return eo})(t):eo}var Ui=2,aa=3;function Nl(e,t){const n=[];for(let i=0;i<t;i++)i<e.length?n.push(e.charCodeAt(i)-Ut):n.push(0);let r=1;for(let i=t-1;i>=0&&r;i--){const s=n[i]+r;s>=95?(n[i]=0,r=1):(n[i]=s,r=0)}if(r)return null;let o="";for(const i of n)o+=String.fromCharCode(i+Ut);for(;o.length>1&&o.charCodeAt(o.length-1)===Ut;)o=o.slice(0,-1);return o}function nu(e,t){let n=0;const r=e.length,o=t.length;for(;;){const i=n<r?e.charCodeAt(n):Ut,s=n<o?t.charCodeAt(n):Sr;if(i!==s){if(s-i==1){const a=n+1;let u=e.substring(0,a);return u.length<a&&(u+=Us.repeat(a-u.length)),u+nu(e.substring(a),"")}return Wv(e,n)+String.fromCharCode(s+i>>1)}n++}}function Wv(e,t){return t<e.length?e.substring(0,t):e+Us.repeat(t-e.length)}function mi(e){return(function(t){if(t==="")return!1;const n=t.length-1,r=t.charCodeAt(n);if(r<33||r>Sr)return!1;for(let o=0;o<n;o++){const i=t.charCodeAt(o);if(i<Ut||i>Sr)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<Ut?Ut:o>Sr?Sr:o)}for(;n.length>0&&n[n.length-1]===Ut;)n.length--;return n.length>0?String.fromCharCode(...n):eo})(e)}var Kt={origin:"remote"},St={origin:"local",via:"edit"},zv={origin:"local",via:"undo"},Kv={origin:"local",via:"redo"};function sn(e){return e.origin==="remote"?e:{origin:"local",via:e.via}}var ip=class{#e=new Map;#t=new Map;#n=new Map;#r=new Set;#o(e,t){return`${e}
|
|
3
|
+
${t}`}get size(){return this.#e.size}get(e){return this.#e.get(e)}add(e){if(this.#e.set(e.opId,e),tu(e)){const t=this.#o(e.parentId,e.parentKey);let n=this.#t.get(t);n===void 0&&(n=new Map,this.#t.set(t,n)),n.set(e.opId,e);let r=this.#n.get(e.parentId);r===void 0&&(r=new Map,this.#n.set(e.parentId,r)),r.set(e.opId,e)}}delete(e){const t=this.#e.get(e);if(t!==void 0&&(this.#e.delete(e),this.#r.delete(e),tu(t))){const n=this.#o(t.parentId,t.parentKey),r=this.#t.get(n);r?.delete(e),r!==void 0&&r.size===0&&this.#t.delete(n);const o=this.#n.get(t.parentId);o?.delete(e),o!==void 0&&o.size===0&&this.#n.delete(t.parentId)}}getByParentIdAndKey(e,t){return this.#t.get(this.#o(e,t))?.values()??[]}getByParentId(e){return this.#n.get(e)?.values()??[]}values(){return this.#e.values()}isPossiblyStored(e){return this.#r.has(e)}markAllAsPossiblyStored(){for(const e of this.#e.keys())this.#r.add(e)}},Ll=new WeakSet;function sp(e){const{getCurrentConnectionId:t,onDispatch:n,isStorageWritable:r=()=>!0,unacknowledgedOps:o=new ip}=e;let i=0,s=0;const a=new Map;return{nodes:a,getNode:u=>a.get(u),addNode:(u,l)=>{a.set(u,l)},deleteNode:u=>{a.delete(u)},generateId:()=>`${t()}:${i++}`,generateOpId:()=>`${t()}:${s++}`,dispatch(u,l,f,c){n?.(u,l,f,c)},assertStorageIsWritable:()=>{if(!r())throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")},unacknowledgedOps:o}}function Ul(e,t,n=mi(t)){return Object.freeze({type:"HasParent",node:e,key:t,pos:n})}var Hl=Object.freeze({type:"NoParent"}),Ro=class{#e;#t;#n=Hl;constructor(){Object.defineProperty(this,Oe,{value:{getId:()=>this.#t},enumerable:!1})}_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 Ye(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 Ye(this.parent,"Unknown state")}}get _pool(){return this.#e}get _id(){return this.#t}get parent(){return this.#n}_warnIfOrphaned(){const e=this;this.parent.type!=="Orphaned"||Ll.has(e)||(Ll.add(e),mt("Cannot sync changes made to this Live structure because it is no longer part of Storage. Retrieve the current value from its parent before mutating it.",{type:e.constructor.name,formerParentKey:this.parent.oldKey}))}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return Ye(this.parent,"Unknown state")}}_apply(e,t){return e.type===ue.DELETE_CRDT&&this.parent.type==="HasParent"?this.parent.node._detachChild(this,sn(t)):{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=Ul(e,t));case"Orphaned":case"NoParent":return void(this.#n=Ul(e,t));default:return Ye(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=mi(e)){return Object.freeze({type:"Orphaned",oldKey:e,oldPos:t})})(this.parent.key,this.parent.pos);break;case"NoParent":this.#n=Hl;break;case"Orphaned":break;default:Ye(this.parent,"Unknown state")}this.#e=void 0}_toOpsWithOpId(e,t,n){return this._toOps(e,t).map((r=>({opId:n.generateOpId(),...r})))}#r;#o;#i;invalidate(){this.#r===void 0&&this.#i===void 0||(this.#r=void 0,this.#i=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toTreeNode(e){return this.#i!==void 0&&this.#o===e||(this.#o=e,this.#i=this._toTreeNode(e)),this.#i}hasCache(e){return this.#r!==void 0&&this.#r===e}toJSON(){return this.#r===void 0&&(this.#r=this._toJSON()),this.#r}};function qv(e){return typeof e=="string"?e:e.id}var mr=class ru extends Ro{#e;constructor(t){super(),this.#e=Object.freeze({...t})}get data(){return this.#e}get id(){return this.#e.id}get name(){return this.#e.name}get size(){return this.#e.size}get mimeType(){return this.#e.mimeType}static _deserialize([t,n],r,o){const i=new ru(n.data);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize LiveFile if parent is missing");return[{type:ue.CREATE_FILE,id:this._id,parentId:t,parentKey:n,data:this.#e}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveFile if parent is missing");return{type:je.FILE,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.#e}}_attachChild(t){throw new Error("A LiveFile node cannot have children")}_detachChild(t){throw new Error("A LiveFile node cannot have children")}_apply(t,n){return super._apply(t,n)}_toTreeNode(t){return{type:"LiveFile",id:this._id??st(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return new ru(this.#e)}};function Gv(e){return e!=null}function gt(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ou(e){return gt(e)&&typeof e.startsWith=="string"}function iu(e){return gt(e)&&(typeof e.lt=="number"||typeof e.gt=="number"||typeof e.lte=="number"||typeof e.gte=="number")}var _o=class ap 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?Ln(n):void 0;let o;gt(r)&&(o=r);let i,s="";s||=typeof o?.message=="string"?o.message:"",s||=typeof o?.error=="string"?o.error:"",r===void 0&&(s||=n||""),s||=t.statusText;try{i=new URL(t.url).pathname}catch{}return s+=i!==void 0?` (got status ${t.status} from ${i})`:` (got status ${t.status})`,new ap(s,t,o)}get status(){return this.response.status}},Jv=e=>e instanceof _o&&e.status>=400&&e.status<500;async function ao(e,t,n,r=Jv){const o=n.length>0?n[n.length-1]:0;let i=0;for(;;){i++;try{return await e()}catch(a){if(r(a))throw a;if(i>=t)throw new Error(`Failed after ${t} attempts: ${String(a)}`)}const s=n[i-1]??o;mt(`Attempt ${i} was unsuccessful. Retrying in ${s} milliseconds.`),await jv(s)}}function up(){let e,t;return[new Promise(((n,r)=>{e=n,t=r})),e,t]}function uo(){const[e,t,n]=up();return{promise:e,resolve:t,reject:n}}function Zv(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 Xt(e){return JSON.stringify(e,Zv)}function _r(e){try{return JSON.stringify(e)}catch(t){throw console.error(`Could not stringify: ${t.message}`),console.error(e),t}}var Xv=class{input;resolve;reject;promise;constructor(e){this.input=e;const{promise:t,resolve:n,reject:r}=uo();this.promise=t,this.resolve=n,this.reject=r}},or=class{#e=[];#t;#n;#r;#o;error=!1;constructor(e,t){this.#t=e,this.#n=t.size??50,this.#r=t.delay}#i(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#s(){this.#e.length===this.#n?this.#u():this.#e.length===1&&(this.#i(),this.#o=setTimeout((()=>{this.#u()}),this.#r))}async#u(){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=>Xt(r.input)===Xt(e)));if(t)return t.promise;const n=new Xv(e);return this.#e.push(n),this.#s(),n.promise}clear(){this.#e=[],this.error=!1,this.#i()}};function fo(e,t){const n=new Ot(new Map),r=new Map,o=new Map;function i(f){return Xt(f)}function s(f){n.mutate((c=>{if(Array.isArray(f))for(const d of f)c.set(d.key,d.state);else c.set(f.key,f.state)}))}function a(f){const c=r.get(f);c!==void 0&&(clearTimeout(c),r.delete(f))}function u(f,c){const d=i(f);if(a(d),c===void 0||!Number.isFinite(c))return;const h=setTimeout((()=>{r.delete(d),l([f])}),Math.max(0,c-Date.now()));r.set(d,h)}function l(f){if(Array.isArray(f))for(const c of f){const d=i(c);a(d),o.delete(d)}else{for(const c of r.values())clearTimeout(c);r.clear(),o.clear()}n.mutate((c=>{if(Array.isArray(f))for(const d of f)c.delete(i(d));else c.clear()}))}return{subscribe:n.subscribe,enqueue:function(f){const c=i(f),d=o.get(c);if(d!==void 0)return d.promise;if(n.get().has(c))return Promise.resolve();const h=e.get(f),g=Symbol(),y=(async function(p,w,b,C){try{const E=await b;if(o.get(w)?.id!==C)return;s({key:w,state:{isLoading:!1,data:E}}),u(p,t?.getCacheExpiry?.(E))}catch(E){if(o.get(w)?.id!==C)return;u(p,t?.getErrorCacheExpiry?.(E)),s({key:w,state:{isLoading:!1,error:E}})}finally{o.get(w)?.id===C&&o.delete(w)}})(f,c,h,g);return o.set(c,{id:g,promise:y}),s({key:c,state:{isLoading:!0}}),y},setData:function(f){s(f.map((c=>({key:i(c[0]),state:{isLoading:!1,data:c[1]}}))));for(const[c,d]of f)u(c,t?.getCacheExpiry?.(d))},getItemState:function(f){const c=i(f);return n.get().get(c)},getData:function(f){const c=i(f);return n.get().get(c)?.data},waitUntilItemCacheExpires:function(f){const c=i(f);if(!r.has(c))return;const d=n.get().get(c);return new Promise((h=>{const g=n.subscribe((()=>{n.get().get(c)!==d&&(g(),h())}))}))},invalidate:l,batch:e,_cacheKeys:function(){return[...n.get().keys()]}}}function Hs(e){return`${e}_${st()}`}function cp(){return Hs("th")}function Ds(){return Hs("cm")}function lp(){return Hs("at")}var He=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??dn("DefaultMap used without a factory function"))(e);return this.set(e,n),n}}},Yv=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function Wr(e){let t=[];const n=Object.entries(e),r=[],o=[],i=[];return n.forEach((([s,a])=>{if(!Yv.test(s))throw new Error("Key must only contain letters, numbers, _");Wl(a)?r.push([s,a]):gt(a)&&(ou(a)||iu(a)?o.push([s,a]):i.push([s,a]))})),t=[...Vl(r),...$l(o)],i.forEach((([s,a])=>{const u=Object.entries(a),l=[],f=[];u.forEach((([c,d])=>{if(Qv(c))throw new Error("Key cannot be empty");Wl(d)?l.push([zl(s,c),d]):(ou(d)||iu(d))&&f.push([zl(s,c),d])})),t=[...t,...Vl(l),...$l(f)]})),t.map((({key:s,operator:a,value:u})=>`${s}${a}${dp(u)}`)).join(" ")}var Vl=e=>{const t=[];return e.forEach((([n,r])=>{t.push({key:n,operator:":",value:r})})),t},$l=e=>{const t=[];return e.forEach((([n,r])=>{"startsWith"in r&&typeof r.startsWith=="string"&&t.push({key:n,operator:"^",value:r.startsWith}),"lt"in r&&typeof r.lt=="number"&&t.push({key:n,operator:"<",value:r.lt}),"gt"in r&&typeof r.gt=="number"&&t.push({key:n,operator:">",value:r.gt}),"gte"in r&&typeof r.gte=="number"&&t.push({key:n,operator:">=",value:r.gte}),"lte"in r&&typeof r.lte=="number"&&t.push({key:n,operator:"<=",value:r.lte})})),t},Wl=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,zl=(e,t)=>t?`${e}[${dp(t)}]`:e,Qv=e=>!e||e.toString().trim()==="";function dp(e){const t=JSON.stringify(e);return typeof e!="string"||t.includes("'")?t:`'${t.slice(1,-1).replace(/\\"/g,'"')}'`}var e1=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,t1=/\/(?:(?:\?|#).*)?$/;function n1(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[s,a]of Object.entries(o))a!=null&&i.set(s,a.toString());return i})(n)).toString()),r.toString()}function De(e,...t){return e.reduce(((n,r,o)=>n+encodeURIComponent(t[o-1]??"")+r))}function fp(e){if(e.startsWith("www.")&&(e="https://"+e),e==="#")return e;try{const t=e1.test(e),n=new URL(e,t?void 0:"https://localhost:9999");if(n.protocol!=="http:"&&n.protocol!=="https:")return null;const r=t1.test(e),o=(t?n.origin:"")+(n.pathname==="/"?r?"/":"":r&&!n.pathname.endsWith("/")?n.pathname+"/":n.pathname)+n.search+n.hash;return o!==""?o:null}catch{return null}}var Kl=5242880,Hi=[2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3],ql=class extends Error{};async function Gl({file:e,signal:t,abortErrorMessage:n,retryMultipartCompletion:r,uploadSingle:o,createMultipartUpload:i,uploadMultipartPart:s,completeMultipartUpload:a,abortMultipartUpload:u}){const l=(function(b){if(typeof DOMException=="function")return new DOMException(b,"AbortError");const C=new Error(b);return C.name="AbortError",C})(n);if(t?.aborted)throw l;const f=b=>{if(t?.aborted)throw l;return b instanceof _o&&b.status>=400&&b.status<500};if(e.size<=Kl)return ao(o,10,Hi,f);let c;const d=[],h=await ao(i,10,Hi,f),g=new AbortController,y=g.signal,p=b=>{g.abort(b)},w=()=>p();t?.aborted?w():t?.addEventListener("abort",w,{once:!0});try{if(c=h.uploadId,t?.aborted)throw l;const b=(function(E,A){const x=[];for(let I=0,T=E.length;I<T;I+=A)x.push(E.slice(I,I+A));return x})((function(E){const A=[];let x=0;for(;x<E.size;){const I=Math.min(x+Kl,E.size);A.push({partNumber:A.length+1,part:E.slice(x,I)}),x=I}return A})(e),5);for(const E of b){const A={},x=[];for(const{part:T,partNumber:F}of E)x.push(ao((()=>s(h.uploadId,F,T,y)),10,Hi,(S=>{if(t?.aborted)throw l;return y.aborted||f(S)})).catch((S=>{throw A.value===void 0&&(A.value={error:S},p(S)),S})));const I=await Promise.allSettled(x);if(A.value!==void 0)throw A.value.error;for(const T of I)T.status==="fulfilled"&&d.push(T.value)}if(t?.aborted)throw l;const C=d.sort(((E,A)=>E.partNumber-A.partNumber));return r?ao((()=>a(h.uploadId,C)),10,Hi,f):a(c,C)}catch(b){if(c)try{await u(c)}catch{}throw b}finally{t?.removeEventListener("abort",w)}}function zt(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function r1({baseUrl:e,authManager:t,fetchPolyfill:n}){const r=new o1(e,n),o=new He((d=>fo(new or((async h=>{const g=h.flat(),{urls:y}=await r.post(De`/v2/c/rooms/${d}/attachments/presigned-urls`,await t.getAuthValue({roomId:d,resource:"comments",access:"read"}),{attachmentIds:g});return y.map((p=>p??new Error("There was an error while getting this attachment's URL")))}),{delay:50}))));function i(d){return o.getOrCreate(d)}const s=new He((d=>{const h=new Map,g=new or((async y=>{const p=y.flat(),{urls:w,expiresAt:b}=await r.post(De`/v2/c/rooms/${d}/storage/files/presigned-urls`,await t.getAuthValue({roomId:d,resource:"storage",access:"read"}),{fileIds:p}),C=Date.parse(b);return w.map(((E,A)=>{const x=p[A];return E===!1?(I=>{const T=h.get(I);T!==void 0&&clearTimeout(T.cleanupTimeoutId);const F=(T?.count??0)+1;return F>=3?(h.delete(I),!1):(h.set(I,{count:F,cleanupTimeoutId:setTimeout((()=>h.delete(I)),3e4)}),!0)})(x)?new ql("There was an error while getting this file's URL"):new Error("There was an error while getting this file's URL"):((I=>{const T=h.get(I);T!==void 0&&(clearTimeout(T.cleanupTimeoutId),h.delete(I))})(x),E!==null?{url:E,expiresAt:C}:new Error("There was an error while getting this file's URL"))}))}),{delay:50});return fo(g,{getCacheExpiry:({expiresAt:y})=>y-3e4,getErrorCacheExpiry:y=>y instanceof ql?Date.now()+1e3:void 0})}));function a(d){return s.getOrCreate(d)}const u=new He((d=>new or((async h=>{const g=h.flat();return await r.post(De`/v2/c/rooms/${d}/inbox-notifications/read`,await t.getAuthValue({roomId:d,resource:"comments",access:"read"}),{inboxNotificationIds:g}),g}),{delay:50}))),l=new or((async d=>{const h=d.flat();return await(async function(g){await r.post(De`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:g})})(h),h}),{delay:50}),f=new or((async d=>{const h=d.flat(),{groups:g}=await r.post(De`/v2/c/groups/find`,await t.getAuthValue({resource:"personal",access:"write"}),{groupIds:h}),y=new Map;for(const p of g)y.set(p.id,Pl(p));return h.map((p=>y.get(p)))}),{delay:50}),c=fo(f);return{getThreads:async function(d){let h;d.query&&(h=Wr(d.query));try{const g=await r.get(De`/v2/c/rooms/${d.roomId}/threads`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.query?.visibility),access:"read"}),{cursor:d.cursor,query:h,limit:50});return{threads:g.data.map(Zn),inboxNotifications:g.inboxNotifications.map(br),subscriptions:g.subscriptions.map(Xn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt),permissionHints:g.meta.permissionHints}}catch(g){if(g instanceof _o&&g.status===404)return{threads:[],inboxNotifications:[],subscriptions:[],nextCursor:null,requestedAt:new Date(Date.now()-216e5),permissionHints:{}};throw g}},getThreadsSince:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/threads/delta`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),{since:d.since.toISOString()},{signal:d.signal});return{threads:{updated:h.data.map(Zn),deleted:h.deletedThreads.map(oa)},inboxNotifications:{updated:h.inboxNotifications.map(br),deleted:h.deletedInboxNotifications.map(ia)},subscriptions:{updated:h.subscriptions.map(Xn),deleted:h.deletedSubscriptions.map(sa)},requestedAt:new Date(h.meta.requestedAt),permissionHints:h.meta.permissionHints}},searchComments:async function(d,h){return await r.get(De`/v2/c/rooms/${d.roomId}/threads/comments/search`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),{text:d.query.text,query:Wr({threadMetadata:d.query.threadMetadata,threadResolved:d.query.threadResolved,hasAttachments:d.query.hasAttachments,hasMentions:d.query.hasMentions})},{signal:h?.signal})},createThread:async function(d){const h=d.commentId??Ds(),g=d.threadId??cp();return Zn(await r.post(De`/v2/c/rooms/${d.roomId}/threads`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility??"public"),access:"write"}),{id:g,visibility:d.visibility,comment:{id:h,body:d.body,metadata:d.commentMetadata,attachmentIds:d.attachmentIds},metadata:d.metadata}))},getThread:async function(d){const h=await r.rawGet(De`/v2/c/rooms/${d.roomId}/thread-with-notification/${d.threadId}`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}));if(h.ok){const g=await h.json();return{thread:Zn(g.thread),inboxNotification:g.inboxNotification?br(g.inboxNotification):void 0,subscription:g.subscription?Xn(g.subscription):void 0}}if(h.status===404)return{thread:void 0,inboxNotification:void 0,subscription:void 0};throw new Error(`There was an error while getting thread ${d.threadId}.`)},deleteThread:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},editThreadMetadata:async function(d){return await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/metadata`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),d.metadata)},createComment:async function(d){const h=d.commentId??Ds();return eu(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),{id:h,body:d.body,metadata:d.metadata,attachmentIds:d.attachmentIds}))},editComment:async function(d){return eu(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),{body:d.body,attachmentIds:d.attachmentIds,metadata:d.metadata}))},editCommentMetadata:async function(d){return await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/metadata`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),d.metadata)},deleteComment:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},addReaction:async function(d){return g=await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/reactions`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}),{emoji:d.emoji}),{...g,createdAt:new Date(g.createdAt)};var g},removeReaction:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/reactions/${d.emoji}`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},markThreadAsResolved:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/mark-as-resolved`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},markThreadAsUnresolved:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/mark-as-unresolved`,await t.getAuthValue({roomId:d.roomId,resource:zt(d.visibility),access:"write"}))},subscribeToThread:async function(d){return Xn(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/subscribe`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"})))},unsubscribeFromThread:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/unsubscribe`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}))},markRoomInboxNotificationAsRead:async function(d){return u.getOrCreate(d.roomId).get(d.inboxNotificationId)},getSubscriptionSettings:async function(d){return r.get(De`/v2/c/rooms/${d.roomId}/subscription-settings`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),void 0,{signal:d.signal})},updateSubscriptionSettings:async function(d){return r.post(De`/v2/c/rooms/${d.roomId}/subscription-settings`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),d.settings)},createTextMention:async function(d){if(d.mention.kind!=="user"&&d.mention.kind!=="group")return Ye(d.mention,"Unexpected mention kind");await r.rawPost(De`/v2/c/rooms/${d.roomId}/text-mentions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}),{userId:d.mention.kind==="user"?d.mention.id:void 0,groupId:d.mention.kind==="group"?d.mention.id:void 0,userIds:d.mention.kind==="group"?d.mention.userIds:void 0,mentionId:d.mentionId})},deleteTextMention:async function(d){await r.rawDelete(De`/v2/c/rooms/${d.roomId}/text-mentions/${d.mentionId}`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},fetchStorageHistoryVersion:async function(d){return r.rawGet(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}/storage`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))},fetchYjsHistoryVersion:async function(d){return r.rawGet(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}/yjs`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))},createVersionHistorySnapshot:async function(d){await r.rawPost(De`/v2/c/rooms/${d.roomId}/versions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},deleteHistoryVersion:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},reportTextEditor:async function(d){await r.rawPost(De`/v2/c/rooms/${d.roomId}/text-metadata`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{type:d.type,rootKey:d.rootKey})},listHistoryVersions:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/versions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}));return{versions:h.versions.map((({createdAt:g,...y})=>({createdAt:new Date(g),...y}))),requestedAt:new Date(h.meta.requestedAt)}},listHistoryVersionsSince:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/versions/delta`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{since:d.since.toISOString()},{signal:d.signal});return{versions:h.versions.map((({createdAt:g,...y})=>({createdAt:new Date(g),...y}))),requestedAt:new Date(h.meta.requestedAt)}},getAttachmentUrl:function(d){return i(d.roomId).batch.get(d.attachmentId)},uploadAttachment:async function(d){const h=d.roomId,g=d.attachment;return Gl({file:g.file,signal:d.signal,abortErrorMessage:`Upload of attachment ${g.id} was aborted.`,retryMultipartCompletion:!1,uploadSingle:async()=>r.putBlob(De`/v2/c/rooms/${h}/attachments/${g.id}/upload/${g.name}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),g.file,{fileSize:g.size},{signal:d.signal}),createMultipartUpload:async()=>r.post(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${g.name}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),void 0,{signal:d.signal},{fileSize:g.size}),uploadMultipartPart:async(y,p,w,b)=>r.putBlob(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}/${String(p)}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),w,void 0,{signal:b}),completeMultipartUpload:async(y,p)=>r.post(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}/complete`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),{parts:p},{signal:d.signal}),abortMultipartUpload:async y=>{await r.rawDelete(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}))}})},getOrCreateAttachmentUrlsStore:i,getFileUrl:async function(d){return(await a(d.roomId).batch.get(d.fileId)).url},uploadFile:async function(d){const h=d.roomId,g=d.file,y=Hs("fl"),p=await Gl({file:g,signal:d.signal,abortErrorMessage:`Upload of file ${y} was aborted.`,retryMultipartCompletion:!0,uploadSingle:async()=>r.putBlob(De`/v2/c/rooms/${h}/storage/files/${y}/upload/${g.name}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),g,{fileSize:g.size},{signal:d.signal}),createMultipartUpload:async()=>r.post(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${g.name}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),void 0,{signal:d.signal},{fileSize:g.size}),uploadMultipartPart:async(w,b,C,E)=>r.putBlob(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}/${String(b)}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),C,void 0,{signal:E}),completeMultipartUpload:async(w,b)=>r.post(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}/complete`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),{parts:b},{signal:d.signal}),abortMultipartUpload:async w=>{await r.rawDelete(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}))}});return new mr(p)},getOrCreateFileUrlsStore:a,streamStorage:async function(d){return await(await r.rawGet(De`/v2/c/rooms/${d.roomId}/storage`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))).json()},getInboxNotifications:async function(d){let h;d?.query&&(h=Wr(d.query));const g=await r.get(De`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:d?.cursor,limit:50,query:h}),y=g.groups.map(Pl);return c.setData(y.map((p=>[p.id,p]))),{inboxNotifications:g.inboxNotifications.map(br),threads:g.threads.map(Zn),subscriptions:g.subscriptions.map(Xn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt)}},getInboxNotificationsSince:async function(d){let h;d?.query&&(h=Wr(d.query));const g=await r.get(De`/v2/c/inbox-notifications/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:d.since.toISOString(),query:h},{signal:d.signal});return{inboxNotifications:{updated:g.inboxNotifications.map(br),deleted:g.deletedInboxNotifications.map(ia)},threads:{updated:g.threads.map(Zn),deleted:g.deletedThreads.map(oa)},subscriptions:{updated:g.subscriptions.map(Xn),deleted:g.deletedSubscriptions.map(sa)},requestedAt:new Date(g.meta.requestedAt)}},getUnreadInboxNotificationsCount:async function(d){let h;d?.query&&(h=Wr(d.query));const{count:g}=await r.get(De`/v2/c/inbox-notifications/count`,await t.getAuthValue({resource:"personal",access:"write"}),{query:h},{signal:d?.signal});return g},markAllInboxNotificationsAsRead:async function(){await r.post(De`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:"all"})},markInboxNotificationAsRead:async function(d){await l.get(d)},deleteAllInboxNotifications:async function(){await r.delete(De`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}))},deleteInboxNotification:async function(d){await r.delete(De`/v2/c/inbox-notifications/${d}`,await t.getAuthValue({resource:"personal",access:"write"}))},getNotificationSettings:async function(d){return r.get(De`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),void 0,{signal:d?.signal})},updateNotificationSettings:async function(d){return r.post(De`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),d)},getUserThreads_experimental:async function(d){let h;d?.query&&(h=Wr(d.query));const g=await r.get(De`/v2/c/threads`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:d?.cursor,query:h,limit:50});return{threads:g.threads.map(Zn),inboxNotifications:g.inboxNotifications.map(br),subscriptions:g.subscriptions.map(Xn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt),permissionHints:g.meta.permissionHints}},getUserThreadsSince_experimental:async function(d){const h=await r.get(De`/v2/c/threads/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:d.since.toISOString()},{signal:d.signal});return{threads:{updated:h.threads.map(Zn),deleted:h.deletedThreads.map(oa)},inboxNotifications:{updated:h.inboxNotifications.map(br),deleted:h.deletedInboxNotifications.map(ia)},subscriptions:{updated:h.subscriptions.map(Xn),deleted:h.deletedSubscriptions.map(sa)},requestedAt:new Date(h.meta.requestedAt),permissionHints:h.meta.permissionHints}},groupsStore:c,getGroup:function(d){return f.get(d)},executeContextualPrompt:async function(d){const h=await r.post(De`/v2/c/rooms/${d.roomId}/ai/contextual-prompt`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{prompt:d.prompt,context:{beforeSelection:d.context.beforeSelection,selection:d.context.selection,afterSelection:d.context.afterSelection},previous:d.previous},{signal:d.signal});if(!h||h.content.length===0)throw new Error("No content returned from server");return h.content[0].text},getUrlMetadata:async function(d){const{metadata:h}=await r.get(De`/v2/c/urls/metadata`,await t.getAuthValue({resource:"personal",access:"write"}),{url:d});return h}}}function uc(e){return e.type==="public"?e.publicApiKey:e.token.raw}var o1=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){e.startsWith("/v2/c/")||dn("This client can only be used to make /v2/c/* requests");const o=n1(this.#e,e,r),i=await this.#t(o,{...n,headers:{"Content-Type":"application/json; charset=utf-8",...n?.headers,Authorization:`Bearer ${uc(t)}`,"X-LB-Client":Ls}}),s=i.headers.get("X-LB-Warn");if(s){const a=`${s} (${n?.method?.toUpperCase()??"GET"} ${e})`;i.ok?mt(a):Un(a)}return i}async#r(e,t,n,r){const o=await this.#n(e,t,n,r);if(!o.ok)throw await _o.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:_r(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:_r(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)}},Ir=Symbol("fsm.ignore"),i1=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,s]=o;i!=="patch"&&(this[i]=s)}}}),n=!1}},s1=1,hp=class{id;#e;#t;#n;#r;#o;#i;events;#s;#u;#a;#c;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.#h(null),this}stop(){if(this.#e!==1)throw new Error("Cannot stop a state machine that hasn't started yet");this.#p(null),this.#e=2,this.#r=null}constructor(e){this.id=s1++,this.#e=0,this.#r=null,this.#n=new Set,this.#a=new Map,this.#s=[],this.#u=[],this.#c=new Set,this.#o=new Map,this.#t=new i1(e),this.#i={didReceiveEvent:Ue(),willTransition:Ue(),didIgnoreUnexpectedEvent:Ue(),willExitState:Ue(),didEnterState:Ue(),didExitState:Ue()},this.events={didReceiveEvent:this.#i.didReceiveEvent.observable,willTransition:this.#i.willTransition.observable,didIgnoreUnexpectedEvent:this.#i.didIgnoreUnexpectedEvent.observable,willExitState:this.#i.willExitState.observable,didEnterState:this.#i.didEnterState.observable,didExitState:this.#i.didExitState.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,s=i.signal,a=o?setTimeout((()=>{const l=new Error("Timed out");this.#d({type:"ASYNC_ERROR",reason:l},r)}),o):void 0;let u=!1;return t(this.#t.current,s).then((l=>{s.aborted||(u=!0,this.#d({type:"ASYNC_OK",data:l},n))}),(l=>{s.aborted||(u=!0,this.#d({type:"ASYNC_ERROR",reason:l},r))})),()=>{clearTimeout(a),u||i.abort()}}))}#m(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.#m(e)){let r=this.#o.get(n);r===void 0&&(r=new Map,this.#o.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 s=i;if(this.#c.add(o),s!==void 0)if(s===Ir)r.set(o,Ir);else{const a=typeof s=="function"?s:()=>s;r.set(o,a)}}}return this}addTimedTransition(e,t,n){return this.onEnter(e,(()=>{const r=typeof t=="function"?t(this.#t.current):t,o=setTimeout((()=>{this.#d({type:"TIMER"},n)}),r);return()=>{clearTimeout(o)}}))}#g(e){return this.#o.get(this.currentState)?.get(e)}#p(e){this.#i.willExitState.notify(this.currentState);const t=performance.now(),n=this.currentState.split(".");this.#t.allowPatching((r=>{e=e??this.#s.length;for(let o=0;o<e;o++){this.#s.pop()?.(r);const i=this.#u.pop();if(i!==void 0&&this.#i.didExitState.count()>0){const s=this.#u.length;if(s===0)continue;const a=s===n.length?this.currentState:`${n.slice(0,s).join(".")}.*`;this.#i.didExitState.notify({state:a,durationMs:t-i})}}}))}#h(e){const t=(function(r,o){const i=r.split(".");if(o<1||o>i.length+1)throw new Error("Invalid number of levels");const s=[];o>i.length&&s.push("*");for(let a=i.length-o+1;a<i.length;a++){const u=i.slice(0,a);u.length>0&&s.push(u.join(".")+".*")}return s.push(r),s})(this.currentState,e??this.currentState.split(".").length+1),n=performance.now();this.#t.allowPatching((r=>{for(const o of t){const i=this.#a.get(o),s=i?.(r);typeof s=="function"?this.#s.push(s):this.#s.push(null),this.#u.push(n)}})),this.#i.didEnterState.notify(this.currentState)}send(e){if(!this.#c.has(e.type))throw new Error(`Invalid event ${JSON.stringify(e.type)}`);if(this.#e===2)return;const t=this.#g(e.type);return t!==Ir?t!==void 0?this.#d(e,t):void this.#i.didIgnoreUnexpectedEvent.notify(e):void 0}#d(e,t){this.#i.didReceiveEvent.notify(e);const n=this.currentState,r=(typeof t=="function"?t:()=>t)(e,this.#t.current);let o,i;if(r===Ir)return;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.#i.willTransition.notify({from:n,to:o});const[s,a]=(function(u,l){if(u===l)return[0,0];const f=u.split("."),c=l.split("."),d=Math.min(f.length,c.length);let h=0;for(;h<d&&f[h]===c[h];h++);return[f.length-h,c.length-h]})(this.currentState,o);if(s>0&&this.#p(s),this.#r=o,i!==void 0){const u=i;this.#t.allowPatching((l=>{for(const f of u)typeof f=="function"?f(l,e):l.patch(f)}))}a>0&&this.#h(a)}},xe=Object.freeze({UPDATE_PRESENCE:100,USER_JOINED:101,USER_LEFT:102,BROADCASTED_EVENT:103,ROOM_STATE:104,STORAGE_STATE_V7:200,STORAGE_CHUNK:210,STORAGE_STREAM_END:211,UPDATE_STORAGE:201,UPDATE_YDOC:300,THREAD_CREATED:400,THREAD_DELETED:407,THREAD_METADATA_UPDATED:401,THREAD_UPDATED:408,COMMENT_CREATED:402,COMMENT_EDITED:403,COMMENT_DELETED:404,COMMENT_REACTION_ADDED:405,COMMENT_REACTION_REMOVED:406,COMMENT_METADATA_UPDATED:409,FEEDS_LIST:500,FEEDS_ADDED:501,FEEDS_UPDATED:502,FEED_DELETED:503,FEED_MESSAGES_LIST:504,FEED_MESSAGES_ADDED:505,FEED_MESSAGES_UPDATED:506,FEED_MESSAGES_DELETED:507,FEED_REQUEST_FAILED:508,REJECT_STORAGE_OP:299});function Jl(e){return e===4999||e>=4e3&&e<4100}function Zl(e){return e===1013||e>=4200&&e<4300}function pp(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 Ye(0,"Unknown state")}}var mp=[250,500,1e3,2e3,4e3,8e3,1e4],Vi=mp[0]-1,a1=[2e3,3e4,6e4,3e5],jn=class extends Error{constructor(e){super(e)}};function gp(e,t){return t.find((n=>n>e))??t[t.length-1]}function zr(e){e.patch({backoffDelay:gp(e.backoffDelay,mp)})}function Xl(e){e.patch({backoffDelay:gp(e.backoffDelay,a1)})}function Yl(e){e.patch({successCount:0})}function to(e,t){const n=e===2?Un:e===1?mt:()=>{};return()=>{n(t)}}function Ql(e){const t="Connection to Liveblocks websocket server";return n=>{vp(e)?mt(`${t} closed prematurely (code: ${e.code}). Retrying in ${n.backoffDelay}ms.`):mt(`${t} could not be established.`,e)}}function ua(e){const t=[`code: ${e.code}`];return e.reason&&t.push(`reason: ${e.reason}`),n=>{mt(`Connection to Liveblocks websocket server closed (${t.join(", ")}). Retrying in ${n.backoffDelay}ms.`)}}var u1=to(1,"Connection to WebSocket closed permanently. Won't retry.");function vp(e){return!(e instanceof Error)&&e.type==="close"}var $i=e=>t=>t.patch(e);function c1(e,t){const n=(function(){const w=Ue();let b=null;return{...w,notify:function(C){return b!==null?(b.push(C),!1):w.notify(C)},pause:function(){b=[]},unpause:function(){if(b!==null){for(const C of b)w.notify(C);b=null}},dispose(){w.dispose(),b!==null&&(b.length=0)}}})();n.pause();const r=Ue();function o(w,b){return()=>{r.notify({message:w,code:b})}}const i=new hp({successCount:0,authValue:null,socket:null,backoffDelay:Vi}).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:[zr,Yl]},DISCONNECT:"@idle.initial"}),i.onEnter("@idle.*",Yl).addTransitions("@idle.*",{CONNECT:(w,b)=>b.authValue!==null?"@connecting.busy":"@auth.busy"}),i.addTransitions("@auth.backoff",{NAVIGATOR_ONLINE:{target:"@auth.busy",effect:$i({backoffDelay:Vi})}}).addTimedTransition("@auth.backoff",(w=>w.backoffDelay),"@auth.busy").onEnterAsync("@auth.busy",(()=>_l(e.authenticate(),1e4,"Timed out during auth")),(w=>({target:"@connecting.busy",effect:$i({authValue:w.data})})),(w=>w.reason instanceof jn?{target:"@idle.failed",effect:[to(2,w.reason.message),o(w.reason.message,-1)]}:{target:"@auth.backoff",effect:[zr,to(2,`Authentication failed: ${w.reason instanceof Error?w.reason.message:String(w.reason)}`)]}));const s=w=>i.send({type:"EXPLICIT_SOCKET_ERROR",event:w}),a=w=>i.send({type:"EXPLICIT_SOCKET_CLOSE",event:w}),u=w=>{i.send({type:"ALIVE"}),w.data!=="pong"&&n.notify(w)};function l(w){w&&(w.removeEventListener("error",s),w.removeEventListener("close",a),w.removeEventListener("message",u),w.close())}i.addTransitions("@connecting.backoff",{NAVIGATOR_ONLINE:{target:"@connecting.busy",effect:$i({backoffDelay:Vi})}}).addTimedTransition("@connecting.backoff",(w=>w.backoffDelay),"@connecting.busy").onEnterAsync("@connecting.busy",(async(w,b)=>{const C=performance.now();let E=null,A=null,x=null;return _l(new Promise(((I,T)=>{if(w.authValue===null)throw new Error("No auth authValue");const F=e.createSocket(w.authValue);function S(H){A=H,F.removeEventListener("message",u),T(H)}x=F;const[k,_]=up();function M(H){if(Ln(H.data)?.type===xe.ROOM_STATE){if(t.enableDebugLogging&&E!==null){const G=performance.now()-E;mt(`[FSM #${i.id}] Socket open → ROOM_STATE: ${G.toFixed(0)}ms`)}_()}}t.waitForActorId||_(),F.addEventListener("message",u),t.waitForActorId&&F.addEventListener("message",M),F.addEventListener("error",S),F.addEventListener("close",S),F.addEventListener("open",(()=>{if(E=performance.now(),t.enableDebugLogging){const W=E-C;mt(`[FSM #${i.id}] Socket epoch → open: ${W.toFixed(0)}ms`)}F.addEventListener("error",s),F.addEventListener("close",a);const H=()=>{F.removeEventListener("error",S),F.removeEventListener("close",S),F.removeEventListener("message",M)};k.then((()=>{I([F,H])}))}))})),2e4,"Timed out during websocket connection").then((([I,T])=>{if(T(),b.aborted)throw new Error("Aborted");if(A)throw A;return I})).catch((I=>{throw l(x),I}))}),(w=>({target:"@ok.connected",effect:$i({socket:w.data,backoffDelay:Vi})})),(w=>{const b=w.reason;if(b instanceof jn)return{target:"@idle.failed",effect:[to(2,b.message),o(b.message,-1)]};if(vp(b)){if(b.code===4109)return"@auth.busy";if(Zl(b.code))return{target:"@connecting.backoff",effect:[Xl,Ql(b)]};if(Jl(b.code))return{target:"@idle.failed",effect:[to(2,b.reason),o(b.reason,b.code)]}}return{target:"@auth.backoff",effect:[zr,Ql(b)]}})).addTransitions("@connecting.busy",{ALIVE:Ir});const f={target:"@ok.awaiting-pong",effect:w=>{w.socket?.send("ping")}},c=()=>(typeof document<"u"?document:void 0)?.visibilityState==="hidden"&&e.canZombie()?"@idle.zombie":f;if(i.addTimedTransition("@ok.connected",3e4,c).addTransitions("@ok.connected",{NAVIGATOR_OFFLINE:c,WINDOW_GOT_FOCUS:f,ALIVE:Ir}),i.addTransitions("@idle.zombie",{WINDOW_GOT_FOCUS:"@connecting.backoff"}),i.onEnter("@ok.*",(w=>{w.patch({successCount:w.successCount+1});const b=setTimeout(n.unpause,0);return C=>{l(C.socket),C.patch({socket:null}),clearTimeout(b),n.pause()}})).addTransitions("@ok.awaiting-pong",{ALIVE:"@ok.connected"}).addTimedTransition("@ok.awaiting-pong",2e3,{target:"@connecting.busy",effect:to(1,"Received no pong from server, assume implicit connection loss.")}).addTransitions("@ok.*",{EXPLICIT_SOCKET_ERROR:(w,b)=>b.socket?.readyState===1?Ir:{target:"@connecting.backoff",effect:zr},EXPLICIT_SOCKET_CLOSE:w=>{return Jl(w.event.code)?{target:"@idle.failed",effect:[u1,o(w.event.reason,w.event.code)]}:(b=w.event.code)>=4100&&b<4200?w.event.code===4109?"@auth.busy":{target:"@auth.backoff",effect:[zr,ua(w.event)]}:Zl(w.event.code)?{target:"@connecting.backoff",effect:[Xl,ua(w.event)]}:{target:"@connecting.backoff",effect:[zr,ua(w.event)]};var b}}),typeof document<"u"){const w=typeof document<"u"?document:void 0,b=typeof window<"u"?window:void 0,C=b??w;i.onEnter("*",(E=>{function A(){i.send({type:"NAVIGATOR_OFFLINE"})}function x(){i.send({type:"NAVIGATOR_ONLINE"})}function I(){w?.visibilityState==="visible"&&i.send({type:"WINDOW_GOT_FOCUS"})}return b?.addEventListener("online",x),b?.addEventListener("offline",A),C?.addEventListener("visibilitychange",I),()=>{C?.removeEventListener("visibilitychange",I),b?.removeEventListener("online",x),b?.removeEventListener("offline",A),l(E.socket)}}))}const d=[],{statusDidChange:h,didConnect:g,didDisconnect:y,unsubscribe:p}=(function(w){const b=Ue(),C=Ue(),E=Ue();let A=null;const x=w.events.didEnterState.subscribe((()=>{const I=pp(w);I!==A&&b.notify(I),A==="connected"&&I!=="connected"?E.notify():A!=="connected"&&I==="connected"&&C.notify(),A=I}));return{statusDidChange:b.observable,didConnect:C.observable,didDisconnect:E.observable,unsubscribe:x}})(i);return d.push(p),t.enableDebugLogging&&d.push((function(w){function b(...E){mt(`[FSM #${w.id}]`,...E)}const C=[w.events.didReceiveEvent.subscribe((E=>b(`Event ${E.type}`))),w.events.willTransition.subscribe((({from:E,to:A})=>b("Transitioning",E,"→",A))),w.events.didExitState.subscribe((({state:E,durationMs:A})=>b(`Exited ${E} after ${A.toFixed(0)}ms`))),w.events.didIgnoreUnexpectedEvent.subscribe((E=>b("Ignored unexpected event",E.type,E,"(no transition declared)")))];return()=>{for(const E of C)E()}})(i)),i.start(),{machine:i,cleanups:d,events:{statusDidChange:h,didConnect:g,didDisconnect:y,onMessage:n.observable,onConnectionError:r.observable}}}var yp=class{#e;#t;events;constructor(e,t=!1,n=!0){const{machine:r,events:o,cleanups:i}=c1(e,{waitForActorId:n,enableDebugLogging:t});this.#e=r,this.events=o,this.#t=i}getStatus(){try{return pp(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?mt("Cannot send: not connected yet",e):t.readyState!==1?mt("Cannot send: WebSocket no longer open",e):t.send(e)}_privateSendMachineEvent(e){this.#e.send(e)}},ed=Object.freeze({}),l1=Array.from(new Set("null")),d1=Array.from(new Set("true")),f1=Array.from(new Set("false")),h1=Array.from(new Set("nulltruefalse"));function ca(e,t){const n=e[e.length-1];return t.includes(n)?e.slice(0,-1):e}var p1=class{#e="";#t;#n=0;#r=!1;#o=-1;#i=-1;#s=[];constructor(e=""){this.append(e)}get source(){return this.#e}get json(){return this.#t===void 0&&(this.#t=this.#f()),this.#t}get#u(){return this.#o>=0}append(e){e&&(this.#e===""&&(e=e.trimStart()),this.#e+=e,this.#t=void 0)}#a(e){if(this.#u)return"";const t=e.charAt(e.length-1);if(t==="")return"";if(t==="-")return"0";if(!h1.includes(t))return"";if(l1.includes(t)){if(e.endsWith("nul"))return"l";if(e.endsWith("nu"))return"ll";if(e.endsWith("n"))return"ull"}if(d1.includes(t)){if(e.endsWith("tru"))return"e";if(e.endsWith("tr"))return"ue";if(e.endsWith("t"))return"rue"}if(f1.includes(t)){if(e.endsWith("fals"))return"e";if(e.endsWith("fal"))return"se";if(e.endsWith("fa"))return"lse";if(e.endsWith("f"))return"alse"}return""}#c(){const e=this.#e.slice(this.#n);for(let t=0;t<e.length;t++){const n=e[t],r=this.#n+t;this.#u?this.#r?this.#r=!1:n==="\\"?this.#r=!0:n==='"'&&(this.#i=this.#o,this.#o=-1):n==='"'?this.#o=r:n==="{"?this.#s.push("}"):n==="["?this.#s.push("]"):(n==="}"&&this.#s.length>0&&this.#s[this.#s.length-1]==="}"||n==="]"&&this.#s.length>0&&this.#s[this.#s.length-1]==="]")&&this.#s.pop()}this.#n=this.#e.length}#f(){this.#c();let e=this.#e;if(e.charAt(0)!=="{")return ed;if(e.endsWith("}")){const n=Ln(e);if(n)return n}this.#u&&(this.#r&&(e=e.slice(0,-1)),e+='"'),e=e.trimEnd(),e=ca(e,",."),e+=this.#a(e);const t=this.#s.reduceRight(((n,r)=>n+r),"");{const n=Ln(e+t);if(n)return n}return this.#u?e=e.slice(0,this.#o):(e=ca(e,":"),e.endsWith('"')&&(e=e.slice(0,this.#i))),e=ca(e,","),e+=t,Ln(e)??ed}};function lt(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 s=0;s<o.length;s++)if(!Object.is(o[s],i[s]))return!1;return!0})(e,t):(function(o,i){if(!gt(o)||!gt(i))return!1;const s=Object.keys(o);return s.length===Object.keys(i).length&&s.every((a=>Object.prototype.hasOwnProperty.call(i,a)&&Object.is(o[a],i[a])))})(e,t)}function no(e,t){if(!gt(e)||!gt(t))return lt(e,t);const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r=>Object.prototype.hasOwnProperty.call(t,r)&<(e[r],t[r])))}var m1=class{#e;#t;#n;#r;#o;#i;constructor(e,t,n){this.#r=e,this.#o=t,this.#i=n,this.#e=new Map,this.#t=new He((()=>new Set)),this.#n=ir.with(n)}get(e){return this.#e.get(e)}getOrThrow(e){return this.get(e)??dn(`Item with id ${e} not found`)}get sorted(){return this.#n}getParentId(e){const t=this.getOrThrow(e);return this.#o(t)}getParent(e){const t=this.getParentId(e);return t?this.getOrThrow(t):null}getChildren(e){const t=this.#t.get(e);return t?Array.from(t).map((n=>this.#e.get(n))):[]}*walkUp(e,t){let n=e;do{const r=this.getOrThrow(n);t&&!t(r)||(yield r),n=this.#o(r)}while(n!==null)}*walkLeft(e,t){const n=this.getOrThrow(e),r=ir.from(this.getSiblings(e),this.#i);for(const o of r.iterReversed())this.#i(n,o)||t&&!t(o)||(yield o)}*walkRight(e,t){const n=this.getOrThrow(e),r=ir.from(this.getSiblings(e),this.#i);for(const o of r)this.#i(o,n)||t&&!t(o)||(yield o)}*walkDown(e,t){const n=ir.from(this.getChildren(e),this.#i).rawArray;for(let r=n.length-1;r>=0;r--){const o=n[r];yield*this.walkDown(this.#r(o),t),t&&!t(o)||(yield o)}}getSiblings(e){const t=this.getOrThrow(e),n=this.getParentId(e);return this.getChildren(n).filter((r=>r!==t))}[Symbol.iterator](){return this.#n[Symbol.iterator]()}upsert(e){const t=this.#r(e),n=this.#e.get(t);if(n){if(this.#o(n)!==this.#o(e))throw new Error("Cannot upsert parent ID changes that change the tree structure. Remove the entry first, and recreate it");this.#n.remove(n)}this.#e.set(t,e),this.#n.add(e);const r=this.#o(e);this.#t.getOrCreate(r).add(t)}remove(e){const t=this.#e.get(e);if(!t)return!1;if(this.#t.get(e))throw new Error(`Cannot remove item '${e}' while it still has children. Remove children first.`);const n=this.#o(t),r=this.#t.get(n);return r&&(r.delete(e),r.size===0&&this.#t.delete(n)),this.#n.remove(t),this.#t.delete(e),this.#e.delete(e),!0}clear(){return this.#e.size!==0&&(this.#t.clear(),this.#e.clear(),this.#n.clear(),!0)}},g1=class{#e;#t;#n;constructor(){this.#e=new Set,this.#t=new He((()=>new Map)),this.#n=void 0}registerLayer(e){const t=e;return this.#e.has(t)&&dn(`Layer '${t}' already exists, provide a unique layer id`),this.#e.add(t),t}deregisterLayer(e){this.#e.delete(e);let t=!1;for(const[n,r]of this.#t)r.delete(e)&&(t=!0),r.size===0&&this.#t.delete(n);t&&this.invalidate()}get(){return this.#n??=this.#r()}invalidate(){this.#n=void 0}#r(){return Array.from(this.#t.values()).flatMap((e=>Array.from(e.values()).slice(-1).filter(Gv)))}updateKnowledge(e,t,n){this.#e.has(e)||dn(`Unknown layer key: ${e}`),this.#t.getOrCreate(t).set(e,n),this.invalidate()}};function la(){return new Date().toISOString()}var ni=Symbol("*");function v1(){const e=new He((n=>new He((r=>new Tt(void 0))))),t=new He((n=>{const[r,o]=Ln(n);return $e.from((()=>(o!==void 0?e.getOrCreate(o).getOrCreate(r):void 0)?.get()??e.getOrCreate(ni).getOrCreate(r).get()))}));return{getToolDescriptions:function(n){const r=e.get(ni),o=e.get(n);return Array.from([...r?.entries()??[],...o?.entries()??[]]).flatMap((([i,s])=>{const a=s.get();return a&&(a.enabled??1)?[{name:i,description:a.description,parameters:a.parameters}]:[]}))},getToolΣ:function(n,r){const o=JSON.stringify(r!==void 0?[n,r]:[n]);return t.getOrCreate(o)},registerTool:function(n,r,o){if(!r.execute&&!r.render)throw new Error("A tool definition must have an execute() function, a render() function, or both.");const i=o??ni;return e.getOrCreate(i).getOrCreate(n).set(r),()=>(function(s,a){const u=e.get(s);if(u===void 0)return;const l=u.get(a);l!==void 0&&l.set(void 0)})(i,n)}}}function y1(e,t){const n=new Set,r=new Set,o=new He((c=>new Ot(new m1((d=>d.id),(d=>d.parentId),((d,h)=>d.createdAt<h.createdAt))))),i=new Ot(new Map);function s(c){Xe((()=>{for(const d of c)a(d)}))}function a(c){Xe((()=>{if(o.getOrCreate(c.chatId).mutate((d=>d.upsert(c))),c.role==="assistant"&&c.status==="generating"?i.mutate((d=>{d.set(c.id,structuredClone(c))})):i.mutate((d=>{d.delete(c.id)})),c.role==="assistant"&&c.status==="awaiting-tool"){if(n.has(c.id))for(const d of c.contentSoFar.filter((h=>h.type==="tool-invocation"&&h.stage==="executing"))){if(r.has(d.invocationId))continue;r.add(d.invocationId);const h=e.getToolΣ(d.name,c.chatId).get()?.execute;h&&(async()=>{const g=await h(d.args,{name:d.name,invocationId:d.invocationId});return await t(c.chatId,c.id,d.invocationId,g??{data:{}},{copilotId:c.copilotId})})().catch((g=>{Un(`Error trying to respond to tool-call: ${String(g)} (in execute())`)}))}}else c.role==="assistant"&&c.status==="generating"||n.delete(c.id)}))}function u(c){for(const d of o.values()){const h=d.get().get(c);if(h)return h}}function l(c){const d=c.next();return d.done?void 0:d.value}const f=new He((c=>new He((d=>{const h=$e.from((()=>(function(g,y){function p(E){if(!E.deletedAt)return!0;for(const A of g.walkDown(E.id,(x=>!x.deletedAt)))return!0;return!1}function w(E){const A=[];let x=null;for(const I of g.walkUp(E.id)){const T=l(g.walkLeft(I.id,p))?.id??null,F=l(g.walkRight(I.id,p))?.id??null;if(!I.deletedAt||T||F){const S={...I,navigation:{parent:null,prev:T,next:F}};x!==null&&(x.navigation.parent=S.id),x=S,A.push(S)}}return A.reverse()}function b(){const E=g.sorted.findRight((A=>!A.deletedAt));return E?w(E):[]}if(y===null)return b();const C=g.get(y);if(!C)return b();for(const E of g.walkUp(C.id)){for(const A of g.walkDown(E.id,(x=>!x.deletedAt)))return w(A);if(!E.deletedAt)return w(E)}return b()})(o.getOrCreate(c).get(),d)),no);return $e.from((()=>{const g=i.get();return h.get().map((y=>{if(y.role!=="assistant"||y.status!=="generating")return y;const p=g.get(y.id);return p===void 0?y:{...y,contentSoFar:p.contentSoFar}}))}),lt)}))));return{getMessageById:u,getChatMessagesForBranchΣ:function(c,d){return f.getOrCreate(c).getOrCreate(d||null)},getLastUsedCopilotId:function(c){return o.getOrCreate(c).get().sorted.findRight((h=>h.role==="assistant"&&!h.deletedAt))?.copilotId},createOptimistically:function(c,d,h,g){const y=`ms_${st()}`,p=la();return a(d==="user"?{id:y,chatId:c,role:d,parentId:h,createdAt:p,content:g,_optimistic:!0}:{id:y,chatId:c,role:d,parentId:h,createdAt:p,status:"generating",contentSoFar:[],copilotId:g,_optimistic:!0}),y},upsert:a,upsertMany:s,remove:function(c,d){const h=o.get(c);if(!h)return;const g=h.get().get(d);g&&!g.deletedAt&&(g.role==="assistant"&&g.status!=="completed"?a({...g,deletedAt:la(),contentSoFar:[]}):a({...g,deletedAt:la(),content:[]}))},removeByChatId:function(c){const d=o.get(c);d!==void 0&&d.mutate((h=>h.clear()))},addDelta:function(c,d){i.mutate((h=>{const g=h.get(c);return g!==void 0&&((function(y,p){if(p===null)return;const w=y.filter((A=>A.type!=="sources")),b=y.filter((A=>A.type==="sources")).flatMap((A=>A.sources)),C=new Date().toISOString(),E=w[w.length-1];switch(p.type){case"text-delta":E?.type==="text"?E.text+=p.textDelta:(su(E,C),w.push({type:"text",text:p.textDelta}));break;case"reasoning-delta":E?.type==="reasoning"?E.text+=p.textDelta:(su(E,C),w.push({type:"reasoning",text:p.textDelta,startedAt:C}));break;case"tool-stream":{const A=(function(x,I,T=""){const F=new p1(T);return{type:"tool-invocation",stage:"receiving",invocationId:x,name:I,get partialArgsText(){return F.source},get partialArgs(){return F.json},__appendDelta(S){F.append(S)}}})(p.invocationId,p.name);w.push(A);break}case"tool-delta":E?.type==="tool-invocation"&&E.stage==="receiving"&&E.__appendDelta?.(p.delta);break;case"tool-invocation":td(w,p,(A=>A.invocationId),C);break;case"retrieval":td(w,p,(A=>A.id),C);break;case"source":b.push(p);break;default:return Ye(0,"Unhandled case")}b.length>0&&w.push({type:"sources",sources:b}),y.length=0,y.push(...w)})(g.contentSoFar,d),h.set(c,g),!0)}))},failAllPending:function(){Xe((()=>{i.mutate((c=>{let d=!1;for(const[h,g]of c)g._optimistic||(c.delete(h),d=!0);return d})),s(Array.from((function*(){for(const c of o.values())for(const d of c.get())d.role!=="assistant"||d.status!=="generating"||d._optimistic||(yield d)})()).map((c=>({...c,status:"failed",errorReason:"Lost connection"}))))}))},markMine(c){n.add(c)},*getAutoExecutingMessageIds(){for(const c of n){const d=u(c);d?.role==="assistant"&&d.status==="awaiting-tool"&&d.contentSoFar.some((h=>h.type==="tool-invocation"&&h.stage==="executing"?typeof e.getToolΣ(h.name,d.chatId).get()?.execute=="function":!1))&&(yield d.id)}}}}function b1(e){const t=new yp(e.delegates,e.enableDebugLogging,!1),n=(function(){const w=new Nv;return{getChatById:function(b){return w.getEvenIfDeleted(b)},findMany:function(b){return w.signal.get().findMany(b)},upsert:function(b){w.upsert(b)},upsertMany:function(b){Xe((()=>{for(const C of b)w.upsert(C)}))},markDeleted:function(b){w.markDeleted(b)}}})(),r=v1(),o=(function(){const w=new He((b=>new g1));return{getKnowledgeStack:function(b){return w.getOrCreate(b??ni)},getKnowledgeForChat:function(b){return[...w.getOrCreate(ni).get(),...w.get(b)?.get()??[]]}}})(),i=y1(r,y),s={staticSessionInfoSig:new Tt(null),dynamicSessionInfoSig:new Tt(null),pendingCmds:new Map,chatsStore:n,messagesStore:i,toolsStore:r,knowledgeStore:o},a=new Tt("initial");let u,l,f=[],c=null;function d(){const w=f;f=[],c!==null&&(clearTimeout(c),c=null),Xe((()=>{for(const{id:b,delta:C}of w)s.messagesStore.addDelta(b,C)}))}function h(){t.getStatus()==="initial"&&t.connect()}async function g(w){h(),t.getStatus()!=="connected"&&await t.events.didConnect.waitUntil();const{promise:b,resolve:C,reject:E}=uo(),A=AbortSignal.timeout(4e3);A.addEventListener("abort",(()=>E(A.reason)),{once:!0});const x=st(7);return s.pendingCmds.set(x,{resolve:C,reject:E}),(function(I){t.send(JSON.stringify({...I}))})({...w,cmdId:x}),b.finally((()=>{s.pendingCmds.delete(x)})).catch((I=>{throw Un(I.message),I}))}async function y(w,b,C,E,A){const x=s.knowledgeStore.getKnowledgeForChat(w),I=s.toolsStore.getToolDescriptions(w),T=await g({cmd:"set-tool-result",chatId:w,messageId:b,invocationId:C,result:E,generationOptions:{copilotId:A?.copilotId,stream:A?.stream,timeout:A?.timeout,knowledge:x.length>0?x:void 0,tools:I.length>0?I:void 0}});T.ok&&i.markMine(T.message.id)}return t.events.onMessage.subscribe((function(w){if(typeof w.data!="string")return;const b=Ln(w.data);if(!b)return;const C="cmdId"in b?b.cmdId:b.event==="cmd-failed"?b.failedCmdId:void 0,E=s.pendingCmds.get(C);if(!C||E){if("event"in b)if(b.event==="delta"){const{id:A,delta:x}=b;(function(I,T){f.push({id:I,delta:T}),c===null&&(c=setTimeout(d,25))})(A,x)}else Xe((()=>{switch(d(),b.event){case"cmd-failed":E?.reject(new Error(b.error));break;case"settle":s.messagesStore.upsert(b.message);break;case"warning":mt(b.message);break;case"error":Un(b.error);break;case"rebooted":s.messagesStore.failAllPending();break;case"sync":for(const A of b["-messages"]??[])s.messagesStore.remove(A.chatId,A.id);for(const A of b["-chats"]??[])s.chatsStore.markDeleted(A),s.messagesStore.removeByChatId(A);for(const A of b.clear??[])s.messagesStore.removeByChatId(A);b.chats&&s.chatsStore.upsertMany(b.chats),b.messages&&s.messagesStore.upsertMany(b.messages);break;default:return Ye(0,"Unhandled case")}}));else switch(b.cmd){case"get-chats":s.chatsStore.upsertMany(b.chats);break;case"get-or-create-chat":s.chatsStore.upsert(b.chat);break;case"delete-chat":s.chatsStore.markDeleted(b.chatId),s.messagesStore.removeByChatId(b.chatId);break;case"get-message-tree":s.chatsStore.upsert(b.chat),s.messagesStore.upsertMany(b.messages);break;case"delete-message":s.messagesStore.remove(b.chatId,b.messageId);break;case"clear-chat":s.messagesStore.removeByChatId(b.chatId);break;case"ask-in-chat":b.sourceMessage&&s.messagesStore.upsert(b.sourceMessage),s.messagesStore.upsert(b.targetMessage);break;case"abort-ai":break;case"set-tool-result":b.ok&&s.messagesStore.upsert(b.message);break;default:return Ye(0,"Unhandled case")}E?.resolve(b)}else mt("Ignoring unexpected command response. Already timed out, or not for us?",b)})),t.events.statusDidChange.subscribe((function(w){const b=t.authValue;if(b!==null){const C=uc(b);if(C!==u)if(u=C,b.type==="secret"){const E=b.token.parsed;s.staticSessionInfoSig.set({userId:E.uid,userInfo:E.ui})}else s.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}a.set(w)})),t.events.statusDidChange.subscribe((function(w){w==="reconnecting"?l=setTimeout((()=>{}),e.lostConnectionTimeout):clearTimeout(l)})),t.events.didConnect.subscribe((function(){})),t.events.didDisconnect.subscribe((function(){d()})),t.events.onConnectionError.subscribe((({message:w,code:b})=>{})),(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",(function(){for(const w of s.messagesStore.getAutoExecutingMessageIds())g({cmd:"abort-ai",messageId:w}).catch((()=>{}))}),{once:!0}),Object.defineProperty({[Oe]:{context:s},connectInitially:h,disconnect:()=>t.disconnect(),getChats:function(w={}){return g({cmd:"get-chats",cursor:w.cursor,query:w.query})},getOrCreateChat:function(w,b){return g({cmd:"get-or-create-chat",id:w,options:b})},deleteChat:w=>g({cmd:"delete-chat",chatId:w}),getMessageTree:function(w){return g({cmd:"get-message-tree",chatId:w})},deleteMessage:(w,b)=>g({cmd:"delete-message",chatId:w,messageId:b}),clearChat:w=>g({cmd:"clear-chat",chatId:w}),askUserMessageInChat:async(w,b,C,E)=>{const A=[...s.knowledgeStore.getKnowledgeForChat(w),...E?.knowledge||[]],x=s.toolsStore.getToolDescriptions(w);return i.markMine(C),await g({cmd:"ask-in-chat",chatId:w,sourceMessage:b,targetMessageId:C,generationOptions:{copilotId:E?.copilotId,stream:E?.stream,timeout:E?.timeout,knowledge:A.length>0?A:void 0,tools:x.length>0?x:void 0}})},abort:w=>g({cmd:"abort-ai",messageId:w}),setToolResult:y,getStatus:()=>t.getStatus(),signals:{getChatMessagesForBranchΣ:s.messagesStore.getChatMessagesForBranchΣ,getToolΣ:s.toolsStore.getToolΣ,statusΣ:a},getChatById:s.chatsStore.getChatById,queryChats:s.chatsStore.findMany,getLastUsedCopilotId:s.messagesStore.getLastUsedCopilotId,registerKnowledgeLayer:(w,b)=>{const C=s.knowledgeStore.getKnowledgeStack(b),E=C.registerLayer(w);return{layerKey:E,deregister:()=>C.deregisterLayer(E)}},updateKnowledge:(w,b,C,E)=>{s.knowledgeStore.getKnowledgeStack(E).updateKnowledge(w,C??st(),b)},registerTool:s.toolsStore.registerTool},Oe,{enumerable:!1})}function C1(e,t){return n=>{const r=t??(typeof WebSocket>"u"?void 0:WebSocket);if(r===void 0)throw new jn("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const o=new URL(e);if(o.protocol=o.protocol==="http:"?"ws":"wss",o.pathname="/ai/v7",n.type!=="secret"){if(n.type==="public")throw new Error("Public key not supported with AI Copilots");return Ye(0,"Unhandled case")}return o.searchParams.set("tok",n.token.raw),o.searchParams.set("version",Ls),new r(o.toString())}}function td(e,t,n,r){const o=qh(e,(i=>i.type===t.type&&n(i)===n(t)));o>-1?e[o]=t:(su(e[e.length-1],r),e.push(t))}function su(e,t){e?.type==="reasoning"&&(e.endedAt??=t)}var rt={Read:"*:read",Write:"*:write",RoomWrite:"room:write",RoomRead:"room:read",StorageRead:"storage:read",StorageWrite:"storage:write",StorageNone:"storage:none",CommentsWrite:"comments:write",CommentsRead:"comments:read",CommentsNone:"comments:none",CommentsPublicWrite:"comments:public:write",CommentsPublicRead:"comments:public:read",CommentsPublicNone:"comments:public:none",CommentsPrivateWrite:"comments:private:write",CommentsPrivateRead:"comments:private:read",CommentsPrivateNone:"comments:private:none",FeedsRead:"feeds:read",FeedsWrite:"feeds:write",FeedsNone:"feeds:none",LegacyRoomPresenceWrite:"room:presence:write"},w1=["none","read","write"],xr={none:0,read:1,write:2},E1={room:{read:[rt.Read,rt.RoomRead],write:[rt.Write,rt.RoomWrite]},storage:{write:[rt.StorageWrite],read:[rt.StorageRead],none:[rt.StorageNone]},comments:{write:[rt.CommentsWrite],read:[rt.CommentsRead],none:[rt.CommentsNone]},"comments:public":{write:[rt.CommentsPublicWrite],read:[rt.CommentsPublicRead],none:[rt.CommentsPublicNone]},"comments:private":{write:[rt.CommentsPrivateWrite],read:[rt.CommentsPrivateRead],none:[rt.CommentsPrivateNone]},feeds:{write:[rt.FeedsWrite],read:[rt.FeedsRead],none:[rt.FeedsNone]}},D1={room:"none",storage:"none",comments:"none","comments:public":"none","comments:private":"none",feeds:"none",personal:"none"},bp=["storage","comments","comments:public","comments:private","feeds"],A1=new Set(Object.values(rt));function x1(e){return A1.has(e)}function nd(e,t){const n=E1[t];let r;for(const o of w1){const i=n[o];i!==void 0&&i.some((s=>e.includes(s)))&&(r=o)}return r}function Cp(e){const t={},n=nd(e,"room");n!==void 0&&(t.room=n);for(const r of bp){const o=nd(e,r);o!==void 0&&(t[r]=o)}return t}function wp(e){const t=e.room;if(t===void 0)return{...D1};const n=e.comments??t;return{room:t,storage:e.storage??t,comments:n,"comments:public":e["comments:public"]??n,"comments:private":e["comments:private"]??n,feeds:e.feeds??t,personal:"write"}}function cc(e){return wp(Cp(e))}function lr(e,t,n){const r=xr[n];if(t==="comments")return Math.max(xr[e.comments??"none"],xr[e["comments:public"]??"none"],xr[e["comments:private"]??"none"])>=r;const o=e[t]??"none";return xr[o]>=r}function lc(e){if(!Array.isArray(e))throw new Error("Permission list must be an array");const t=[];for(const n of e){if(!x1(n))throw new Error(`Not a valid permission: ${n}`);t.push(n)}return t}function O1(e,t){return e[t]??((function(n){return n.startsWith("comments:")})(t)?e.comments:void 0)}function rd(e,t){return xr[t]>xr[e]?t:e}function od(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=Ln((function(o){try{const i=o.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(i).split("").map((function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)})).join(""))}catch{return atob(o)}})(t[1]));if(!n||!gt(r=n)||r.k!=="acc"&&r.k!=="id")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}}var S1=[400,401,403,404,405,410,412,414,422,431,451];function I1(e,t){const n=(function(u){const{publicApiKey:l,authEndpoint:f}=u;if(f!==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 f=="string")return{type:"private",url:f};if(typeof f=="function")return{type:"custom",callback:f};throw f!==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=new Map;function s(u){const l=Math.ceil(Date.now()/1e3);for(let f=o.length-1;f>=0;f--){const c=o[f];if(c.expiresAt<=l)o.splice(f,1);else if(T1(c,u))return c.token}}async function a(u){const l=e.polyfills?.fetch??(typeof window>"u"?void 0:window.fetch);if(n.type==="private"){if(l===void 0)throw new jn("To use Liveblocks client in a non-DOM environment with a url as auth endpoint, you need to provide a fetch polyfill.");const f=od((await(async function(c,d,h){const g=await c(d,{method:"POST",headers:{"Content-Type":"application/json"},body:_r(h)});if(!g.ok){const w=`${(await g.text()).trim()||"reason not provided in auth response"} (${g.status} returned by POST ${d})`;throw S1.includes(g.status)?new jn(`Unauthorized: ${w}`):new Error(`Failed to authenticate: ${w}`)}let y;try{y=await g.json()}catch(w){throw new Error(`Expected a JSON response when doing a POST request on "${d}". ${String(w)}`)}if(!gt(y)||typeof y.token!="string")throw new Error(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${d}", but got ${_r(y)}`);const{token:p}=y;return{token:p}})(l,n.url,{room:u.roomId})).token);if(r.has(f.raw)){const c=s(u);if(c?.raw===f.raw)return c;throw new jn("The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported.")}return t?.(f.parsed),f}if(n.type==="custom"){const f=await n.callback(u.roomId);if(f&&typeof f=="object"){if(typeof f.token=="string"){const c=od(f.token);return t?.(c.parsed),c}if(typeof f.error=="string"){const c=`Authentication failed: ${"reason"in f&&typeof f.reason=="string"?f.reason:"Forbidden"}`;throw f.error==="forbidden"?new jn(c):new Error(c)}}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.clear()},getAuthValue:async function(u){if(n.type==="public")return{type:"public",publicApiKey:n.publicApiKey};const l=s(u);if(l!==void 0)return{type:"secret",token:l};let f;const c=(function(d){if(d.roomId!==void 0)return`${d.roomId}:${d.resource}:${d.access}`})(u);c!==void 0?(f=i.get(c),f===void 0&&(f=a(u),i.set(c,f))):(f=i.get("liveblocks-user-token"),f===void 0&&(f=a(u),i.set("liveblocks-user-token",f)));try{const d=await f,h=30,g=Math.floor(Date.now()/1e3)+(d.parsed.exp-d.parsed.iat)-h;r.add(d.raw);const y=(function(p,w){return p.parsed.k==="acc"?{token:p,expiresAt:w,permissions:Object.entries(p.parsed.perms).map((([b,C])=>({pattern:b,scopes:lc(C)})))}:{token:p,expiresAt:w}})(d,g);return o.push(y),{type:"secret",token:d}}finally{c!==void 0?i.delete(c):i.delete("liveblocks-user-token")}}}}function T1(e,t){if(e.token.parsed.k==="id"||t.resource==="personal")return!0;if(t.roomId===void 0)return!1;const n=(function(r,o){const i=r.filter((u=>(function(l,f){return l.includes("*")?f.startsWith(l.replace("*","")):l===f})(u.pattern,o)));if(i.length===0)return;const s={},a={};for(const u of i){const l=Cp(u.scopes),f=u.pattern.replace("*","").length;l.room!==void 0&&(s.room=rd(s.room??"none",l.room));for(const c of bp){const d=O1(l,c);if(d===void 0)continue;const h=a[c]??-1;f>h?(s[c]=d,a[c]=f):f===h&&(s[c]=rd(s[c]??"none",d))}}return wp(s)})(e.permissions??[],t.roomId);return n!==void 0&&lr(n,t.resource,t.access)}var An="@",zn=class Ep extends Ro{#e;constructor(t){super(),this.#e=t}get data(){return this.#e}static _deserialize([t,n],r,o){const i=new Ep(n.data);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:ue.CREATE_REGISTER,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:je.REGISTER,parentId:ye(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??st(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return hi(this.data)}};function k1(e,t){return e._parentPos<t._parentPos}var gr=class au extends Ro{#e;#t;constructor(t){super(),this.#t=new WeakSet;const n=[];let r;for(const o of t){const i=gn(r),s=ho(o);s._setParentLink(this,i),n.push(s),r=i}this.#e=ir.fromAlreadySorted(n,k1)}static _deserialize([t,n],r,o){const i=new au([]);i._attach(t,o);const s=r.get(t);if(s===void 0)return i;for(const a of s){const u=a[1],l=Ip(a,r,o);l._setParentLink(i,u.parentKey),i.#n(l)}return i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ue.CREATE_LIST,parentId:t,parentKey:n};r.push(o);for(const i of this.#e){const s=i._getParentKeyOrThrow(),a=zo(i._toOps(this._id,s),"set");for(const u of a)r.push(u)}return r}#n(t){const n=this.#e.add(t);return this.invalidate(),n}#r(t,n){t._setParentLink(this,n),this.#e.reposition(t),this.invalidate()}#o(t,n){const r=ye(this.#e.at(t));this.#r(r,n)}_indexOfPosition(t){return this.#e.findIndex((n=>n._getParentKeyOrThrow()===t))}#i(t){if(this._pool===void 0||this._id===void 0)return;let n;for(const r of this._pool.unacknowledgedOps.getByParentIdAndKey(this._id,t))r.intent==="set"&&(n=r.opId);return n}_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()}#s(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=Yo(t);o._attach(n,this._pool),o._setParentLink(this,r);const i=t.deletedId,s=this._indexOfPosition(r);if(s!==-1){const a=ye(this.#e.removeAt(s));if(a._id===i)return a._detach(),this.#e.add(o),{modified:ze(this,[Kr(s,o)],Kt),reverse:[]};{this.#t.add(a),this.#e.remove(a),this.#e.add(o);const u=[Kr(s,o)],l=this.#a(t.deletedId,Kt);return l&&u.push(l),{modified:ze(this,u,Kt),reverse:[]}}}{const a=[],u=this.#a(t.deletedId,Kt);return u&&a.push(u),this.#n(o),a.push(en(this._indexOfPosition(r),o)),{reverse:[],modified:ze(this,a,Kt)}}}#u(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const r=[],o=this.#a(t.deletedId,n);o&&r.push(o);const i=this.#i(t.parentKey);if(i!==void 0&&i!==t.opId)return r.length===0?{modified:!1}:{modified:ze(this,r,n),reverse:[]};const s=this._indexOfPosition(t.parentKey),a=this.#e.find((u=>u._id===t.id));if(a!==void 0){if(a._parentKey===t.parentKey)return{modified:r.length>0&&ze(this,r,n),reverse:[]};if(s!==-1){const f=ye(this.#e.removeAt(s));this.#t.add(f),r.push(Wi(s,f))}const u=this.#e.findIndex((f=>f===a));this.#r(a,t.parentKey);const l=this.#e.findIndex((f=>f===a));return l!==u&&r.push(Yn(u,l,a)),{modified:r.length>0&&ze(this,r,n),reverse:[]}}{const u=this._pool.getNode(t.id);if(u&&this.#t.has(u)){u._setParentLink(this,t.parentKey),this.#t.delete(u);const l=this.#n(u);return{modified:ze(this,[s===-1?en(l,u):Kr(l,u),...r],n),reverse:[]}}{if(s!==-1){const c=ye(this.#e.removeAt(s));this.#t.add(c)}const{newItem:l,newIndex:f}=this.#b(t,t.parentKey);return{modified:ze(this,[s===-1?en(f,l):Kr(f,l),...r],n),reverse:[]}}}}#a(t,n){if(t===void 0||this._pool===void 0)return null;const r=this._pool.getNode(t);if(r===void 0)return null;const o=this._detachChild(r,n);return o.modified===!1?null:o.modified.updates[0]}#c(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=mi(t.parentKey),r=this._indexOfPosition(n);r!==-1&&this.#C(r,n);const{newItem:o,newIndex:i}=this.#b(t,n),s=this.#m(n);return{modified:ze(this,[en(i,o),...s],Kt),reverse:[]}}*#f(){if(this._pool!==void 0&&this._id!==void 0)for(const t of this._pool.unacknowledgedOps.getByParentId(this._id)){if(t.intent!=="push"||this._pool.unacknowledgedOps.isPossiblyStored(t.opId))continue;const n=this._pool.getNode(t.id);n!==void 0&&this.#e.includes(n)&&(yield n)}}#m(t){const n=new Set(this.#f());if(n.size===0)return[];let r,o;for(const s of n){const a=s._parentPos;(r===void 0||a<r)&&(r=a)}if(t<ye(r))return[];for(const s of this.#e)n.has(s)||(o=s._parentPos);const i=[];for(const s of n){const a=this.#e.findIndex((l=>l===s));o=gn(o),this.#r(s,o);const u=this.#e.findIndex((l=>l===s));u!==a&&i.push(Yn(a,u,s))}return i}#g(t,n){const r=this.#e.find((s=>s._id===t.id)),o=mi(t.parentKey),i=this._indexOfPosition(o);if(r){if(r._parentKey===o)return{modified:!1};{const s=this.#e.findIndex((u=>u===r));i!==-1&&this.#C(i,o),this.#r(r,o);const a=this._indexOfPosition(o);return a===s?{modified:!1}:{modified:ze(this,[Yn(s,a,r)],n),reverse:[]}}}{const s=ye(this._pool).getNode(t.id);if(s&&this.#t.has(s))return s._setParentLink(this,o),this.#t.delete(s),this.#n(s),{modified:ze(this,[en(this._indexOfPosition(o),s)],n),reverse:[]};{i!==-1&&this.#C(i,o);const{newItem:a,newIndex:u}=this.#b(t,o);return{modified:ze(this,[en(u,a)],n),reverse:[]}}}}#p(t,n){const{id:r,parentKey:o}=t,i=Yo(t);if(this._pool?.getNode(r)!==void 0)return{modified:!1};i._attach(r,ye(this._pool)),i._setParentLink(this,o);const s=this._indexOfPosition(o);let a=o;if(s!==-1){const u=this.#e.at(s)?._parentPos,l=this.#e.at(s+1)?._parentPos;a=gn(u,l),i._setParentLink(this,a)}return this.#n(i),{modified:ze(this,[en(this._indexOfPosition(a),i)],n),reverse:[{type:ue.DELETE_CRDT,id:r}]}}#h(t,n){const{id:r,parentKey:o}=t,i=Yo(t);if(this._pool?.getNode(r)!==void 0)return{modified:!1};const s=this._indexOfPosition(o);i._attach(r,ye(this._pool)),i._setParentLink(this,o);const a=o;if(s!==-1){const u=this.#e.at(s);u._detach(),this.#e.remove(u),this.#e.add(i);const l=zo(u._toOps(ye(this._id),o),"set",t.id),f=[Kr(s,i)],c=this.#a(t.deletedId,n);return c&&f.push(c),{modified:ze(this,f,n),reverse:l}}{this.#n(i),this.#a(t.deletedId,n);const u=this._indexOfPosition(a);return{reverse:[{type:ue.DELETE_CRDT,id:r}],modified:ze(this,[en(u,i)],n)}}}_attachChild(t,n){const r=sn(n);if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let o;return o=t.intent==="set"?n.origin==="remote"?this.#s(t):n.optimistic?this.#h(t,r):this.#u(t,r):n.origin==="remote"?this.#c(t):n.optimistic?this.#p(t,r):this.#g(t,r),o.modified!==!1&&this.invalidate(),o}_detachChild(t,n){if(t){const r=ye(t._parentKey),o=t._toOps(ye(this._id),r),i=this.#e.findIndex((a=>a===t));if(i===-1)return{modified:!1};const s=this.#e.at(i);return this.#e.remove(t),this.invalidate(),t._detach(),{modified:ze(this,[Wi(i,s)],n),reverse:o}}return{modified:!1}}#d(t,n){if(this.#t.has(n))return this.#t.delete(n),n._setParentLink(this,t),{modified:ze(this,[en(this.#n(n),n)],Kt),reverse:[]};if(t===n._parentKey)return{modified:!1};const r=this._indexOfPosition(t);if(r===-1){const o=this.#e.findIndex((s=>s===n));this.#r(n,t);const i=this.#e.findIndex((s=>s===n));return i===o?{modified:!1}:{modified:ze(this,[Yn(o,i,n)],Kt),reverse:[]}}{this.#o(r,gn(t,this.#e.at(r+1)?._parentPos));const o=this.#e.findIndex((s=>s===n));this.#r(n,t);const i=this.#e.findIndex((s=>s===n));return i===o?{modified:!1}:{modified:ze(this,[Yn(o,i,n)],Kt),reverse:[]}}}#v(t,n,r){const o=ye(n._parentKey);if(this.#t.has(n)){const i=this._indexOfPosition(t);if(this.#t.delete(n),i!==-1){const s=this.#e.at(i);s._setParentLink(this,gn(t,this.#e.at(i+1)?._parentPos)),this.#e.reposition(s)}return n._setParentLink(this,t),{modified:ze(this,[en(this.#n(n),n)],r),reverse:[]}}{if(t===o)return{modified:!1};const i=this.#e.findIndex((u=>u===n)),s=this._indexOfPosition(t);s!==-1&&this.#o(s,gn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,t);const a=this.#e.findIndex((u=>u===n));return i===a?{modified:!1}:{modified:ze(this,[Yn(i,a,n)],r),reverse:[]}}}#y(t,n,r){const o=ye(n._parentKey),i=this.#e.findIndex((l=>l===n)),s=this._indexOfPosition(t);let a=t;s!==-1&&(a=gn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,a);const u=this.#e.findIndex((l=>l===n));return i===u?{modified:!1}:{modified:ze(this,[Yn(i,u,n)],r),reverse:[{type:ue.SET_PARENT_KEY,id:ye(n._id),parentKey:o}]}}_setChildKey(t,n,r){const o=sn(r);return r.origin==="remote"?this.#d(t,n):r.optimistic?this.#y(t,n,o):this.#v(t,n,o)}_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:je.LIST,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this.#e.length}push(t){return this.#w(t,this.length,"push")}insert(t,n){return this.#w(t,n,"insert")}#w(t,n,r){if(this._warnIfOrphaned(),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 o=this.#e.at(n-1)?._parentPos,i=this.#e.at(n)?._parentPos,s=gn(o,i),a=ho(t);if(a._setParentLink(this,s),this.#n(a),this._pool&&this._id){const u=this._pool.generateId();a._attach(u,this._pool);const l=a._toOpsWithOpId(this._id,s,this._pool);this._pool.dispatch(r==="push"?zo(l,"push"):l,[{type:ue.DELETE_CRDT,id:u}],new Map([[this._id,ze(this,[en(n,a)],St)]]))}}move(t,n){if(this._warnIfOrphaned(),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.at(n+1)?._parentPos,r=this.#e.at(n)._parentPos):(o=this.#e.at(n)._parentPos,r=n===0?void 0:this.#e.at(n-1)?._parentPos);const i=gn(r,o),s=this.#e.at(t),a=s._getParentKeyOrThrow();if(this.#o(t,i),this._pool&&this._id){const u=new Map([[this._id,ze(this,[Yn(t,n,s)],St)]]);this._pool.dispatch([{type:ue.SET_PARENT_KEY,id:ye(s._id),opId:this._pool.generateOpId(),parentKey:i}],[{type:ue.SET_PARENT_KEY,id:ye(s._id),parentKey:a}],u)}}delete(t){if(this._warnIfOrphaned(),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.at(t);if(n._detach(),this.#e.remove(n),this.invalidate(),this._pool){const r=n._id;if(r){const o=new Map;o.set(ye(this._id),ze(this,[Wi(t,n)],St)),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:ue.DELETE_CRDT}],n._toOps(ye(this._id),n._getParentKeyOrThrow()),o)}}}clear(){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const i of this.#e){i._detach();const s=i._id;s&&(t.push({type:ue.DELETE_CRDT,id:s,opId:this._pool.generateOpId()}),n.push(...i._toOps(ye(this._id),i._getParentKeyOrThrow())),r.push(Wi(0,i)))}this.#e.clear(),this.invalidate();const o=new Map;o.set(ye(this._id),ze(this,r,St)),this._pool.dispatch(t,n,o)}else{for(const t of this.#e)t._detach();this.#e.clear(),this.invalidate()}}set(t,n){if(this._warnIfOrphaned(),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.at(t),o=r._getParentKeyOrThrow(),i=r._id;r._detach();const s=ho(n);if(s._setParentLink(this,o),this.#e.remove(r),this.#e.add(s),this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();s._attach(a,this._pool);const u=new Map;u.set(this._id,ze(this,[Kr(t,s)],St));const l=zo(s._toOpsWithOpId(this._id,o,this._pool),"set",i),f=zo(r._toOps(this._id,o),"set",a);this._pool.dispatch(l,f,u)}}#l(t){return Or(t)}every(t){return this.#e.rawArray.every(((n,r)=>t(this.#l(n),r)))}filter(t){const n=[];return this.#e.rawArray.forEach(((r,o)=>{const i=this.#l(r);t(i,o)&&n.push(i)})),n}find(t){for(const[n,r]of this.#e.rawArray.entries()){const o=this.#l(r);if(t(o,n))return o}}findIndex(t){return this.#e.rawArray.findIndex(((n,r)=>t(this.#l(n),r)))}forEach(t){this.#e.rawArray.forEach(((n,r)=>t(this.#l(n),r)))}get(t){const n=this.#e.at(t);return n!==void 0?this.#l(n):void 0}indexOf(t,n){return this.#e.rawArray.findIndex(((r,o)=>o>=(n??0)&&this.#l(r)===t))}lastIndexOf(t,n){const r=this.#e.rawArray;for(let o=n??r.length-1;o>=0;o--)if(this.#l(r[o])===t)return o;return-1}map(t){return this.#e.rawArray.map(((n,r)=>t(this.#l(n),r)))}some(t){return this.#e.rawArray.some(((n,r)=>t(this.#l(n),r)))}*[Symbol.iterator](){for(const t of this.#e)yield this.#l(t)}#b(t,n){const r=Yo(t);return r._attach(t.id,ye(this._pool)),r._setParentLink(this,n),this.#n(r),{newItem:r,newIndex:this._indexOfPosition(n)}}#C(t,n){const r=gn(n,this.#e.length>t+1?this.#e.at(t+1)?._parentPos:void 0);this.#o(t,r)}_toTreeNode(t){const n=[];let r=0;for(const o of this.#e)n.push(o.toTreeNode(r.toString())),r++;return{type:"LiveList",id:this._id??st(),key:t,payload:n}}toJSON(){return super.toJSON()}_toJSON(){return Array.from(this.#e,(n=>n.toJSON()))}clone(){return new au(Array.from(this.#e,(t=>t.clone())))}};function ze(e,t,n){return{node:e,type:"LiveList",updates:t,source:n}}function Kr(e,t){return{index:e,type:"set",item:t instanceof zn?t.data:t}}function Wi(e,t){return{type:"delete",index:e,deletedItem:t instanceof zn?t.data:t}}function en(e,t){return{index:e,type:"insert",item:t instanceof zn?t.data:t}}function Yn(e,t,n){return{type:"move",index:t,item:n instanceof zn?n.data:n,previousIndex:e}}function zo(e,t,n){return e.map(((r,o)=>o===0?{...r,intent:t,deletedId:n}:r))}var Hr=class uu extends Ro{#e;#t;constructor(t){if(super(),this.#t=new Map,t){const n=[];for(const[r,o]of t){const i=ho(o);i._setParentLink(this,r),n.push([r,i])}this.#e=new Map(n)}else this.#e=new Map}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ue.CREATE_MAP,parentId:t,parentKey:n};r.push(o);for(const[i,s]of this.#e)for(const a of s._toOps(this._id,i))r.push(a);return r}static _deserialize([t,n],r,o){const i=new uu;i._attach(t,o);const s=r.get(t);if(s===void 0)return i;for(const a of s){const u=a[1],l=Ip(a,r,o);l._setParentLink(i,u.parentKey),i.#e.set(u.parentKey,l),i.invalidate()}return i}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)ot(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,s=o,a=Yo(t);if(this._pool.getNode(r)!==void 0)return{modified:!1};if(n.origin==="remote")this.#t.delete(s);else if(!n.optimistic){const f=this.#t.get(s);if(f===i)return this.#t.delete(s),{modified:!1};if(f!==void 0)return{modified:!1}}const u=this.#e.get(s);let l;if(u){const f=ye(this._id);l=u._toOps(f,s),u._detach()}else l=[{type:ue.DELETE_CRDT,id:r}];return a._setParentLink(this,s),a._attach(r,this._pool),this.#e.set(s,a),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}},source:sn(n)},reverse:l}}_detach(){super._detach();for(const t of this.#e.values())t._detach()}_detachChild(t,n){const r=ye(this._id),o=ye(t._parentKey),i=t._toOps(r,o);for(const[s,a]of this.#e)a===t&&(this.#e.delete(s),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveMap",updates:{[o]:{type:"delete",deletedItem:Or(t)}},source:n},reverse:i}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:je.MAP,parentId:ye(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 Or(n)}set(t,n){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const r=this.#e.get(t);r&&r._detach();const o=ho(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 s=new Map;s.set(this._id,{node:this,type:"LiveMap",updates:{[t]:{type:"update"}},source:St});const a=o._toOpsWithOpId(this._id,t,this._pool);this.#t.set(t,ye(a[0].opId)),this._pool.dispatch(a,r?r._toOps(this._id,t):[{type:ue.DELETE_CRDT,id:i}],s)}}get size(){return this.#e.size}has(t){return this.#e.has(t)}delete(t){this._warnIfOrphaned(),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=ye(this._id),o=new Map;o.set(r,{node:this,type:"LiveMap",updates:{[t]:{type:"delete",deletedItem:Or(n)}},source:St}),this._pool.dispatch([{type:ue.DELETE_CRDT,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],Or(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:Or(n.value)}}}}forEach(t){for(const n of this)t(n[1],n[0],this)}_toTreeNode(t){return{type:"LiveMap",id:this._id??st(),key:t,payload:Array.from(this.#e.entries()).map((([n,r])=>r.toTreeNode(n)))}}toJSON(){return super.toJSON()}_toJSON(){const t={};for(const[n,r]of this.#e)t[n]=r.toJSON();return t}clone(){return new uu(Array.from(this.#e).map((([t,n])=>[t,n.clone()])))}};function jr(e,t){if(Array.isArray(e))return new gr(e.map((n=>jr(n,t))));if(gt(e)){const n={},r={};for(const i in e){const s=e[i];if(s===void 0)continue;const a=gt(t)?t[i]:t;a===!1?r[i]=s:n[i]=a==="atomic"?s:jr(s,a)}const o=new Kn(n);for(const i in r)o.setLocal(i,r[i]);return o}return e}function Dp(e,t,n){return mc(e)&>(t)?cu(e,t,"full",n):pc(e)&&Array.isArray(t)?(function(r,o,i){const s=r.length,a=o.length;for(let u=0;u<Math.min(s,a);u++){const l=r.get(u),f=o[u];if(sr(l)){const c=Dp(l,f,i);c!==l&&r.set(u,c)}else l!==f&&r.set(u,jr(f,i))}for(let u=s;u<a;u++)r.push(jr(o[u],i));for(let u=s-1;u>=a;u--)r.delete(u);return r})(e,t,n):Tp(e)&>(t)?(function(){throw new Error("Reconciling a LiveMap is not supported yet")})():kp(e)&<(e.data,t)?e:jr(t,n)}function cu(e,t,n,r){const o=e.keys();for(const i in t){o.delete(i);const s=t[i];if(s===void 0){n==="full"&&e.delete(i);continue}const a=gt(r)?r[i]:r;if(a===!1)e.setLocal(i,s);else if(a==="atomic")e.get(i)!==s&&e.set(i,s);else{const u=e.get(i);if(u===void 0)e.set(i,jr(s,a));else if(sr(u)){const l=Dp(u,s,a);l!==u&&e.set(i,l)}else u!==s&&e.set(i,jr(s,a))}}if(n==="full")for(const i of o)e.delete(i);return e}var id=131072,Kn=class Er extends Ro{#e;#t=new Map;#n;static detectLargeObjects=!1;static#r(t){const n=new Map;let r=null;for(const o of t)if(Lv(o))r=o[1];else{const i=o[1],s=n.get(i.parentId);s!==void 0?s.push(o):n.set(i.parentId,[o])}if(r===null)throw new Error("Root can't be null");return[r,n]}static _fromItems(t,n){const[r,o]=Er.#r(t);return Er._deserialize(["root",r],o,n)}constructor(t={}){super(),this.#n=new Map;const n=pi(t);for(const r of Object.keys(n)){const o=n[r];ot(o)&&o._setParentLink(this,r)}this.#e=new Map(Object.entries(n))}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={type:ue.CREATE_OBJECT,id:this._id,parentId:t,parentKey:n,data:{}};r.push(o);for(const[i,s]of this.#e)if(ot(s))for(const a of s._toOps(this._id,i))r.push(a);else o.data[i]=s;return r}static _deserialize([t,n],r,o){const i=new Er(n.data);return i._attach(t,o),this._deserializeChildren(i,r,o)}static _deserializeChildren(t,n,r){const o=n.get(ye(t._id));if(o===void 0)return t;for(const i of o){const s=U1(i,n,r),a=i[1];sr(s)&&s._setParentLink(t,a.parentKey),t.#e.set(a.parentKey,s),t.invalidate()}return t}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)ot(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,s=Op(t);if(this._pool.getNode(r)!==void 0)return this.#n.get(i)===o&&this.#n.delete(i),{modified:!1};if(n.origin==="local"&&n.optimistic)this.#n.set(i,ye(o));else if(this.#n.get(i)!==void 0)return this.#n.get(i)===o?(this.#n.delete(i),{modified:!1}):{modified:!1};const a=ye(this._id),u=this.#e.get(i);let l;return ot(u)?(l=u._toOps(a,i),u._detach()):l=u===void 0?[{type:ue.DELETE_OBJECT_KEY,id:a,key:i}]:[{type:ue.UPDATE_OBJECT,id:a,data:{[i]:u}}],this.#t.delete(i),this.#e.set(i,s),this.invalidate(),sr(s)&&(s._setParentLink(this,i),s._attach(r,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}},source:sn(n)}}}_detachChild(t,n){if(t){const r=ye(this._id),o=ye(t._parentKey),i=t._toOps(r,o),s=Or(t);for(const[a,u]of this.#e)u===t&&(this.#e.delete(a),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveObject",updates:{[o]:{type:"delete",deletedItem:s}},source:n},reverse:i}}return{modified:!1}}_detach(){super._detach();for(const t of this.#e.values())ot(t)&&t._detach()}_apply(t,n){return t.type===ue.UPDATE_OBJECT?this.#o(t,n):t.type===ue.DELETE_OBJECT_KEY?this.#i(t,n):super._apply(t,n)}_serialize(){const t={};for(const[n,r]of this.#e)ot(r)||(t[n]=r);return this.parent.type==="HasParent"&&this.parent.node._id?{type:je.OBJECT,parentId:this.parent.node._id,parentKey:this.parent.key,data:t}:{type:je.OBJECT,data:t}}#o(t,n){let r=!1;const o=ye(this._id),i=[],s={type:ue.UPDATE_OBJECT,id:o,data:{}};for(const u in t.data){const l=this.#e.get(u);if(ot(l)){for(const f of l._toOps(o,u))i.push(f);l._detach()}else l!==void 0?s.data[u]=l:l===void 0&&i.push({type:ue.DELETE_OBJECT_KEY,id:o,key:u})}const a={};for(const u in t.data){const l=t.data[u];if(l===void 0)continue;if(n.origin==="local"&&n.optimistic)this.#n.set(u,ye(t.opId));else{if(this.#n.get(u)!==void 0){if(this.#n.get(u)===t.opId){this.#n.delete(u);continue}continue}r=!0}const f=this.#e.get(u);ot(f)&&f._detach(),r=!0,a[u]={type:"update"},this.#t.delete(u),this.#e.set(u,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),r?{modified:{node:this,type:"LiveObject",updates:a,source:sn(n)},reverse:i}:{modified:!1}}#i(t,n){const r=t.key,o=this.#e.get(r);if(o===void 0)return{modified:!1};if((n.origin!=="local"||!n.optimistic)&&this.#n.get(r)!==void 0)return{modified:!1};const i=ye(this._id);let s=[];return ot(o)?(s=o._toOps(i,t.key),o._detach()):o!==void 0&&(s=[{type:ue.UPDATE_OBJECT,id:i,data:{[r]:o}}]),this.#t.delete(r),this.#e.delete(r),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[t.key]:{type:"delete",deletedItem:o}},source:sn(n)},reverse:s}}keys(){const t=new Set(this.#e.keys());for(const n of this.#t.keys())t.add(n);return t}set(t,n){this.update({[t]:n})}setLocal(t,n){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const r=this.#s(t);if(this.#t.set(t,n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const o=r?.[0]??[],i=r?.[1]??[],s=r?.[2]??new Map,a=s.get(this._id);s.set(this._id,{node:this,type:"LiveObject",updates:{...a?.updates,[t]:{type:"update"}},source:St}),this._pool.dispatch(o,i,s)}}get(t){return this.#t.has(t)?this.#t.get(t):this.#e.get(t)}#s(t){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=t;if(this.#t.has(n)&&!this.#e.has(n)){const a=this.#t.get(n);if(this.#t.delete(n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const u=new Map;return u.set(this._id,{node:this,type:"LiveObject",updates:{[n]:{type:"delete",deletedItem:a}},source:St}),[[],[],u]}return null}this.#t.delete(n);const r=this.#e.get(n);if(r===void 0)return null;if(this._pool===void 0||this._id===void 0)return ot(r)&&r._detach(),this.#e.delete(n),this.invalidate(),null;const o=[{type:ue.DELETE_OBJECT_KEY,key:n,id:this._id,opId:this._pool.generateOpId()}];let i;ot(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:ue.UPDATE_OBJECT,data:{[n]:r},id:this._id}],this.#e.delete(n),this.invalidate();const s=new Map;return s.set(this._id,{node:this,type:"LiveObject",updates:{[t]:{type:"delete",deletedItem:r}},source:St}),[o,i,s]}delete(t){const n=this.#s(t);if(n){const[r,o,i]=n;this._pool?.dispatch(r,o,i)}}update(t){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),Er.detectLargeObjects){const l={};for(const[c,d]of this.#e)ot(d)||(l[c]=d);for(const c of Object.keys(t)){const d=t[c];d!==void 0&&(ot(d)||(l[c]=d))}const f=JSON.stringify(l);if(4*f.length>id){const c=new TextEncoder().encode(f).length;if(c>id)throw new Error(`LiveObject size exceeded limit: ${c} bytes > 131072 bytes. See https://liveblocks.io/docs/pricing/limits#Other-limits`)}}if(this._pool===void 0||this._id===void 0){for(const l in t){const f=t[l];if(f===void 0)continue;const c=this.#e.get(l);ot(c)&&c._detach(),ot(f)&&f._setParentLink(this,l),this.#t.delete(l),this.#e.set(l,f),this.invalidate()}return}const n=[],r=[],o=this._pool.generateOpId(),i={},s={id:this._id,type:ue.UPDATE_OBJECT,data:{}},a={};for(const l in t){const f=t[l];if(f===void 0)continue;const c=this.#e.get(l);if(c!==f){if(ot(c)){for(const d of c._toOps(this._id,l))r.push(d);c._detach()}else c===void 0?r.push({type:ue.DELETE_OBJECT_KEY,id:this._id,key:l}):s.data[l]=c;if(ot(f)){f._setParentLink(this,l),f._attach(this._pool.generateId(),this._pool);const d=f._toOpsWithOpId(this._id,l,this._pool),h=d.find((g=>g.parentId===this._id));h&&this.#n.set(l,ye(h.opId));for(const g of d)n.push(g)}else i[l]=f,this.#n.set(l,o);this.#t.delete(l),this.#e.set(l,f),this.invalidate(),a[l]={type:"update"}}}if(Object.keys(s.data).length!==0&&r.unshift(s),Object.keys(i).length!==0&&n.unshift({opId:o,id:this._id,type:ue.UPDATE_OBJECT,data:i}),n.length===0&&r.length===0&&Object.keys(a).length===0)return;const u=new Map;u.set(this._id,{node:this,type:"LiveObject",updates:a,source:St}),this._pool.dispatch(n,r,u)}static from(t,n){if(!gt(t))throw new Error("Expected a JSON object");const r=new Er({});return r.reconcile(t,n),r}reconcile(t,n){if(!this.hasCache(t)){if(!gt(t))throw new Error("Reconciling the document root expects a plain object value");cu(this,t,"full",n)}}reconcilePartially(t,n){if(!gt(t))throw new Error("Reconciling the document root expects a plain object value");cu(this,t,"partial",n)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??st();return{type:"LiveObject",id:n,key:t,payload:Array.from(this.#e.entries()).map((([r,o])=>ot(o)?o.toTreeNode(r):{type:"Json",id:`${n}:${r}`,key:r,payload:o}))}}toJSON(){return super.toJSON()}_toJSON(){const t={};for(const[n,r]of this.#e)t[n]=sr(r)?r.toJSON():r;for(const[n,r]of this.#t)t[n]=r;return t}clone(){const t=new Er(Object.fromEntries(Array.from(this.#e).map((([n,r])=>[n,sr(r)?r.clone():hi(r)]))));for(const[n,r]of this.#t)t.#t.set(n,hi(r));return t}};function B1(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(e[o]!==t[o])return!1;return!0}function F1(e){return e===void 0?void 0:{...e}}function Co(e){const t=[];for(const n of e){if(n.text.length===0)continue;const r=t.at(-1),o=F1(n.attributes);r!==void 0&&B1(r.attributes,o)?r.text+=n.text:t.push({text:n.text,attributes:o})}return t}function sd(e){return Co(e.map((([t,n])=>({text:t,attributes:n}))))}function da(e){return e.map((t=>t.attributes===void 0?[t.text]:[t.text,{...t.attributes}]))}function ro(e){return e.reduce(((t,n)=>t+n.text.length),0)}function Hn(e,t){const n=[];let r=0;for(const o of e){const i=r+o.text.length;if(t>r&&t<i){const s=o.text.slice(0,t-r),a=o.text.slice(t-r);n.push({text:s,attributes:o.attributes}),n.push({text:a,attributes:o.attributes})}else n.push({text:o.text,attributes:o.attributes});r=i}return n}function lu(e,t,n){const r=Math.max(0,Math.min(e,n));return{index:r,length:Math.max(r,Math.min(e+t,n))-r}}function du(e,t){const n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function Ap(e,t){const n=Math.max(0,Math.min(t,e.length));return du(e,n)?n-1:n}function fa(e,t,n){const r=lu(t,n,e.length);if(r.length===0)return{index:Ap(e,r.index),length:0};const o=r.index+r.length,i=du(e,r.index)?r.index-1:r.index;return{index:i,length:(du(e,o)?o+1:o)-i}}function dc(e,t,n,r){if(n.length===0)return Co(e);const o=Hn(e,t),i=[];let s=0,a=!1;for(const u of o)a||s!==t||(i.push({text:n,attributes:r}),a=!0),i.push(u),s+=u.text.length;return a||i.push({text:n,attributes:r}),Co(i)}function xp(e,t,n){const r=Hn(Hn(e,t),t+n),o=[];let i=0;for(const s of r){const a=i+s.text.length;i>=t&&a<=t+n&&o.push({text:s.text,attributes:s.attributes}),i=a}return Co(o)}function fc(e,t,n){const r=xp(e,t,n),o=Hn(Hn(e,t),t+n),i=[];let s=0,a="";for(const u of o){const l=s+u.text.length;s>=t&&l<=t+n?a+=u.text:i.push(u),s=l}return{segments:Co(i),deletedText:a,deletedSegments:r}}function hc(e,t,n,r){const o=Hn(Hn(e,t),t+n),i=[];let s=0;for(const a of o){const u=s+a.text.length;if(s>=t&&u<=t+n){const l={...a.attributes??{}};for(const[f,c]of Object.entries(r))c===null?delete l[f]:l[f]=c;i.push({text:a.text,attributes:Object.keys(l).length===0?void 0:l})}else i.push(a);s=u}return Co(i)}function R1(e,t,n,r){const o=Hn(Hn(e,t),t+n),i=[];let s=0;for(const a of o){const u=s+a.text.length;if(s>=t&&u<=t+n){const l={},f=a.attributes??{};for(const c of Object.keys(r)){const d=Object.hasOwn(f,c)?f[c]:void 0;l[c]=d??null}i.push({type:"format",index:s,length:a.text.length,attributes:l})}s=u}return i}function _1(e,t){return t.type==="insert"?t.index<=e?e+t.text.length:e:t.type==="delete"?t.index>=e?e:Math.max(t.index,e-t.length):e}function ha(e,t){let n=e;for(const r of t)n=_1(n,r);return n}function j1(e,t){return t.type==="insert"?e<=t.index?e:Math.max(t.index,e-t.text.length):t.type==="delete"&&t.index<=e?e+t.length:e}function ad(e,t){let n=e;for(let r=t.length-1;r>=0;r--)n=j1(n,t[r]);return n}function M1(e){return e==="before"?"after":"before"}function Ko(e,t,n){return t>=e?e:Math.max(t,e-n)}function ud(e,t,n){switch(e.type){case"insert":return(function(r,o,i){return o.type==="insert"?[o.index<r.index||o.index===r.index&&i==="after"?{...r,index:r.index+o.text.length}:{...r}]:o.type==="delete"?[{...r,index:Ko(r.index,o.index,o.length)}]:[{...r}]})(e,t,n);case"delete":return(function(r,o){const i=r.index,s=r.index+r.length;if(o.type==="insert"){const a=o.index,u=o.text.length;return a<=i?[{...r,index:i+u}]:a>=s?[{...r}]:[{type:"delete",index:i,length:a-i},{type:"delete",index:i+u,length:s-a}]}if(o.type==="delete"){const a=Ko(i,o.index,o.length),u=Ko(s,o.index,o.length);return u-a>0?[{type:"delete",index:a,length:u-a}]:[]}return[{...r}]})(e,t);case"format":return(function(r,o,i){const s=r.index,a=r.index+r.length;if(o.type==="insert"){const u=o.index,l=o.text.length;return u<=s?[{...r,index:s+l}]:u>=a?[{...r}]:[{type:"format",index:s,length:u-s,attributes:r.attributes},{type:"format",index:u+l,length:a-u,attributes:r.attributes}]}if(o.type==="delete"){const u=Ko(s,o.index,o.length),l=Ko(a,o.index,o.length);return l-u>0?[{type:"format",index:u,length:l-u,attributes:r.attributes}]:[]}{if(i==="after")return[{...r}];const u=Math.max(s,o.index),l=Math.min(a,o.index+o.length);if(u>=l)return[{...r}];if(!Object.keys(r.attributes).some((d=>Object.hasOwn(o.attributes,d))))return[{...r}];const f={};for(const[d,h]of Object.entries(r.attributes))Object.hasOwn(o.attributes,d)||(f[d]=h);const c=[];return s<u&&c.push({type:"format",index:s,length:u-s,attributes:r.attributes}),Object.keys(f).length>0&&c.push({type:"format",index:u,length:l-u,attributes:f}),l<a&&c.push({type:"format",index:l,length:a-l,attributes:r.attributes}),c}})(e,t,n)}}function Tr(e,t,n){if(e.length===0||t.length===0)return[[...e],[...t]];if(e.length===1&&t.length===1)return[ud(e[0],t[0],n),ud(t[0],e[0],M1(n))];if(e.length>1){const[a,u]=Tr([e[0]],t,n),[l,f]=Tr(e.slice(1),u,n);return[[...a,...l],f]}const[r,o]=Tr(e,[t[0]],n),[i,s]=Tr(r,t.slice(1),n);return[i,[...o,...s]]}function P1(e,t,n){return Tr(e,t,n)[0]}function pa(e,t){let n=[...e];for(const r of t)if(r.type==="insert")n=dc(n,Math.max(0,Math.min(r.index,ro(n))),r.text,r.attributes);else if(r.type==="delete"){const o=lu(Math.max(0,Math.min(r.index,ro(n))),r.length,ro(n));n=fc(n,o.index,o.length).segments}else{const o=lu(Math.max(0,Math.min(r.index,ro(n))),r.length,ro(n));n=hc(n,o.index,o.length,r.attributes)}return n}function N1(e,t){let n=[...e];const r=[];for(const o of t)if(o.type==="insert")n=dc(n,o.index,o.text,o.attributes),r.unshift({type:"delete",index:o.index,length:o.text.length});else if(o.type==="delete"){const i=xp(n,o.index,o.length);n=fc(n,o.index,o.length).segments;const s=[];let a=o.index;for(const u of i)s.push({type:"insert",index:a,text:u.text,attributes:u.attributes}),a+=u.text.length;for(let u=s.length-1;u>=0;u--)r.unshift(s[u])}else{const i=R1(n,o.index,o.length,o.attributes);n=hc(n,o.index,o.length,o.attributes),r.unshift(...i.reverse())}return r}var jo=class fu extends Ro{#e;#t;#n;#r;#o=[];#i=[];#s=[];constructor(t="",n=0){super(),this.#e=typeof t=="string"?t.length===0?[]:[{text:t}]:sd(t),this.#t=[...this.#e],this.#n=n,Object.assign(this[Oe],{encodeIndex:r=>this.#u(r),decodeIndex:(r,o)=>this.#a(r,o)})}get version(){return this.#n}get length(){return ro(this.#e)}static _deserialize([t,n],r,o){const i=new fu(n.data,n.version);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize LiveText if it is not attached");return[{type:ue.CREATE_TEXT,id:this._id,parentId:t,parentKey:n,data:this.toJSON(),version:this.#n}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveText if parent is missing");return{type:je.TEXT,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.toJSON(),version:this.#n}}_attachChild(t){throw new Error("LiveText cannot contain child nodes")}_detachChild(t){throw new Error("LiveText cannot contain child nodes")}_apply(t,n){return t.type!==ue.UPDATE_TEXT?super._apply(t,n):n.origin==="local"&&n.optimistic?this.#f(t,sn(n)):t.opId!==void 0&&t.opId===this.#r?this.#m(t,sn(n)):t.opId!==void 0&&this.#s.some((r=>r.opId===t.opId))?(this.#n=Math.max(this.#n,t.version??t.baseVersion+1),{modified:!1}):this.#g(t,sn(n))}insert(t,n,r){const o=Ap(this.toString(),t);this.#c([{type:"insert",index:o,text:n,attributes:r}])}delete(t,n){const r=fa(this.toString(),t,n);r.length!==0&&this.#c([{type:"delete",index:r.index,length:r.length}])}replace(t,n,r,o){const i=fa(this.toString(),t,n),s=[];i.length>0&&s.push({type:"delete",index:i.index,length:i.length}),r.length>0&&s.push({type:"insert",index:i.index,text:r,attributes:o}),this.#c(s)}#u(t){let n=Math.max(0,Math.min(t,this.length));return n=ad(n,this.#i),n=ad(n,this.#o),n}#a(t,n){if(n>this.#n)return null;if(n<this.#n){const o=this.#s[0]?.version;if(o===void 0||o>n+1)return null}let r=t;for(const o of this.#s)if(!(o.version<=n)){if(o.version>this.#n)break;o.ops.length!==0&&(r=ha(r,o.ops))}return r=ha(r,this.#o),r=ha(r,this.#i),Math.max(0,Math.min(r,this.length))}format(t,n,r){const o=fa(this.toString(),t,n);o.length!==0&&this.#c([{type:"format",index:o.index,length:o.length,attributes:r}])}#c(t){if(t.length===0)return;this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=this._pool!==void 0&&this._id!==void 0,r=n?this.#y(t):[],o=this.#v(t);if(!n)return;const i=ye(this._pool),s=ye(this._id),a=new Map([[s,{type:"LiveText",node:this,version:this.#n,updates:o,source:St}]]);if(this.#r===void 0){const u=i.generateOpId();this.#r=u,this.#o=[...t],i.dispatch([{type:ue.UPDATE_TEXT,id:s,opId:u,baseVersion:this.#n,ops:[...t]}],r,a)}else this.#i.push(...t),i.dispatch([],r,a,{clearRedoStack:!0})}#f(t,n){const r=t;if(t.opId!==void 0&&t.opId===this.#r)return this.#o=[...this.#o,...this.#i],this.#i=[],r.baseVersion=this.#n,r.ops=[...this.#o],{modified:!1};let o=t.ops;for(const a of this.#s)a.version>t.baseVersion&&a.ops.length>0&&(o=P1(o,a.ops,"after"));const i=this.#y(o),s=this.#v(o);return this.#r===void 0&&o.length>0?(this.#r=ye(t.opId,"Local ops must have an opId"),this.#o=[...o],r.baseVersion=this.#n,r.ops=[...o]):(this.#i.push(...o),r.baseVersion=this.#n,r.ops=[]),s.length===0?{modified:!1}:{reverse:i,modified:{type:"LiveText",node:this,version:this.#n,updates:s,source:n}}}#m(t,n){const r=t.version??Math.max(this.#n,t.baseVersion+1),o=this.#o,i=this.#r;this.#t=pa(this.#t,t.ops),this.#r=void 0,this.#o=[];let s=[],a={modified:!1};if((u=t.ops)!==(l=o)&&Xt(u)!==Xt(l)){Un("LiveText: acknowledgement did not match the local prediction; resynchronizing");const f=this.#h();s=f.appliedOps,f.changes.length>0&&(a={reverse:[],modified:{type:"LiveText",node:this,version:r,updates:f.changes,source:n}})}var u,l;return this.#n=Math.max(this.#n,r),this.#d(r,s,i),this.#p(),a}#g(t,n){const r=t.version??this.#n+1;this.#t=pa(this.#t,t.ops);const[o,i]=Tr(t.ops,this.#o,"before"),[s,a]=Tr(o,this.#i,"before");if(this.#o=i,this.#i=a,this.#d(r,s,t.opId),s.length===0)return this.#n=Math.max(this.#n,r),{modified:!1};const u=this.#y(s),l=this.#v(s);return this.#n=Math.max(this.#n,r),{reverse:u,modified:{type:"LiveText",node:this,version:this.#n,updates:l,source:n}}}#p(){if(this.#i.length===0||this._pool===void 0||this._id===void 0)return;const t=this._pool.generateOpId();this.#r=t,this.#o=this.#i,this.#i=[],this._pool.dispatch([{type:ue.UPDATE_TEXT,id:this._id,opId:t,baseVersion:this.#n,ops:[...this.#o]}],[],new Map,{clearRedoStack:!1})}#h(){const t=this.#e,n=pa(this.#t,[...this.#o,...this.#i]);if(Xt(da(t))===Xt(da(n)))return this.#e=n,{appliedOps:[],changes:[]};const r=t.map((a=>a.text)).join("");this.#e=n,this.invalidate();const o=[],i=[];r.length>0&&(o.push({type:"delete",index:0,length:r.length}),i.push({type:"delete",index:0,length:r.length,deletedText:r}));let s=0;for(const a of n)o.push({type:"insert",index:s,text:a.text,attributes:a.attributes}),i.push({type:"insert",index:s,text:a.text,attributes:a.attributes}),s+=a.text.length;return{appliedOps:o,changes:i}}_resyncText(t,n,r){this.#t=sd(t),this.#n=n,this.#s=[];const o=this.#h();if(o.changes.length!==0)return{type:"LiveText",node:this,version:this.#n,updates:o.changes,source:r}}_rejectPendingOp(t){t===this.#r&&(this.#r=void 0,this.#o=[],this.#i=[])}#d(t,n,r){this.#s.some((o=>o.version===t))||(this.#s.push({version:t,opId:r,ops:[...n]}),this.#s.sort(((o,i)=>o.version-i.version)),this.#s.length>1e3&&this.#s.splice(0,this.#s.length-1e3))}#v(t){const n=[];for(const r of t)if(r.type==="insert")this.#e=dc(this.#e,r.index,r.text,r.attributes),n.push({type:"insert",index:r.index,text:r.text,attributes:r.attributes});else if(r.type==="delete"){const o=fc(this.#e,r.index,r.length);this.#e=o.segments,n.push({type:"delete",index:r.index,length:r.length,deletedText:o.deletedText})}else this.#e=hc(this.#e,r.index,r.length,r.attributes),n.push({type:"format",index:r.index,length:r.length,attributes:r.attributes});return this.invalidate(),n}#y(t){return[{type:ue.UPDATE_TEXT,id:ye(this._id),baseVersion:this.#n,ops:N1(this.#e,t)}]}toString(){return this.#e.map((t=>t.text)).join("")}toJSON(){return super.toJSON()}_toJSON(){return da(this.#e)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??st(),r=this.toJSON().map(((o,i)=>({type:"Json",id:`${n}:${i}`,key:String(i),payload:o})));return r.push({type:"Json",id:`${n}:version`,key:"version",payload:this.version}),{type:"LiveText",id:n,key:t,payload:r}}clone(){return new fu(this.toJSON(),this.#n)}};function Yo(e){return ho(Op(e))}function Op(e){switch(e.type){case ue.CREATE_FILE:return new mr(e.data);case ue.CREATE_REGISTER:return e.data;case ue.CREATE_OBJECT:return new Kn(e.data);case ue.CREATE_MAP:return new Hr;case ue.CREATE_LIST:return new gr([]);case ue.CREATE_TEXT:return new jo(e.data,e.version);default:return Ye(0,"Unknown creation Op")}}function Sp(e,t){return e===t||e.parent.type==="HasParent"&&Sp(e.parent.node,t)}function L1(e){const t=sp({getCurrentConnectionId:()=>{throw new Error("Cannot mutate a historic storage version: it is a read-only snapshot")}});return Kn._fromItems(e,t)}function Ip(e,t,n){if(Jh(e))return Kn._deserialize(e,t,n);if(Zh(e))return gr._deserialize(e,t,n);if(Xh(e))return Hr._deserialize(e,t,n);if(Yh(e))return zn._deserialize(e,t,n);if(Qh(e))return jo._deserialize(e,t,n);if(ep(e))return mr._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function U1(e,t,n){if(Jh(e))return Kn._deserialize(e,t,n);if(Zh(e))return gr._deserialize(e,t,n);if(Xh(e))return Hr._deserialize(e,t,n);if(Yh(e))return e[1].data;if(Qh(e))return jo._deserialize(e,t,n);if(ep(e))return mr._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function sr(e){return pc(e)||Tp(e)||mc(e)||hu(e)||kp(e)}function ot(e){return sr(e)||(function(t){return t instanceof zn})(e)}function pc(e){return e instanceof gr}function Tp(e){return e instanceof Hr}function mc(e){return e instanceof Kn}function hu(e){return e instanceof jo}function kp(e){return e instanceof mr}function Or(e){return e instanceof zn?e.data:e instanceof gr||e instanceof Hr||e instanceof Kn||e instanceof jo||e instanceof mr?e:Ye(0,"Unknown AbstractCrdt")}function ho(e){return e instanceof Kn||e instanceof Hr||e instanceof gr||e instanceof jo||e instanceof mr?e:new zn(e)}function As(e,t){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!As(e[r],t[r]))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!As(e[r],t[r]))return!1;return!0}function H1(e,t){const n=[],r=e.reduce(((i,[s])=>i+s.length),0);r>0&&n.push({type:"delete",index:0,length:r});let o=0;for(const[i,s]of t)i.length!==0&&(n.push({type:"insert",index:o,text:i,attributes:s}),o+=i.length);return n}function V1(e,t,n){const r=[],o=new Set;t.forEach(((u,l)=>{const f=e.get(l);f!==void 0&&(f.type===u.type&&(f.type!==je.FILE||u.type!==je.FILE||f.data.id===u.data.id&&f.data.name===u.data.name&&f.data.size===u.data.size&&f.data.mimeType===u.data.mimeType)||o.add(l))}));let i=!0;for(;i;){i=!1;for(const u of[e,t])u.forEach(((l,f)=>{!o.has(f)&&l.parentId!==void 0&&o.has(l.parentId)&&(o.add(f),i=!0)}))}e.forEach(((u,l)=>{const f=u.parentId!==void 0&&o.has(u.parentId);t.has(l)&&!o.has(l)||f||r.push({type:ue.DELETE_CRDT,id:l})}));const s=new Set;function a(u,l){if(s.has(u))return;s.add(u);const f=l.parentId;if(f!==void 0&&(!e.has(f)||o.has(f))){const c=t.get(f);c!==void 0&&a(f,c)}switch(l.type){case je.REGISTER:r.push({type:ue.CREATE_REGISTER,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data});break;case je.FILE:r.push({type:ue.CREATE_FILE,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data});break;case je.LIST:r.push({type:ue.CREATE_LIST,id:u,parentId:l.parentId,parentKey:l.parentKey});break;case je.OBJECT:if(l.parentId===void 0||l.parentKey===void 0)throw new Error("Internal error. Cannot serialize storage root into an operation");r.push({type:ue.CREATE_OBJECT,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data});break;case je.MAP:r.push({type:ue.CREATE_MAP,id:u,parentId:l.parentId,parentKey:l.parentKey});break;case je.TEXT:r.push({type:ue.CREATE_TEXT,id:u,parentId:l.parentId,parentKey:l.parentKey,data:l.data,version:l.version})}}return t.forEach(((u,l)=>{const f=e.get(l);if(f&&!o.has(l)){if(u.type===je.OBJECT&&f.type===je.OBJECT){const c=new Map;for(const d of Object.keys(u.data)){const h=u.data[d];h===void 0||As(h,f.data[d])||c.set(d,h)}c.size>0&&r.push({type:ue.UPDATE_OBJECT,id:l,data:Object.fromEntries(c)});for(const d of Object.keys(f.data))d in u.data||r.push({type:ue.DELETE_OBJECT_KEY,id:l,key:d})}n?.includeLiveTextUpdates!==!0||u.type!==je.TEXT||f.type!==je.TEXT||As(u.data,f.data)||r.push({type:ue.UPDATE_TEXT,id:l,baseVersion:f.version,ops:H1(f.data,u.data)}),u.parentKey!==f.parentKey&&r.push({type:ue.SET_PARENT_KEY,id:l,parentKey:ye(u.parentKey,"Parent key must not be missing")})}else a(l,u)})),r}function $1(e,t){const n=e.updates;for(const[r,o]of oc(t.updates))n[r]=o;return{...t,updates:n}}function W1(e,t){const n=e.updates;for(const[r,o]of oc(t.updates))n[r]=o;return{...t,updates:n}}function z1(e,t){const n=e.updates;return{...t,updates:n.concat(t.updates)}}function K1(e,t){return{...t,updates:e.updates.concat(t.updates)}}function zi(e,t){if(e===void 0)return t;const n=(function(r,o){return r.origin==="remote"||o.origin==="remote"?Kt:o.via!=="edit"?o:r.via!=="edit"?r:St})(e.source,t.source);return e.type==="LiveObject"&&t.type==="LiveObject"?{...$1(e,t),source:n}:e.type==="LiveMap"&&t.type==="LiveMap"?{...W1(e,t),source:n}:e.type==="LiveList"&&t.type==="LiveList"?{...z1(e,t),source:n}:e.type==="LiveText"&&t.type==="LiveText"?{...K1(e,t),source:n}:{...t,source:n}}function ma(e,t,n=t){typeof e=="function"&&e()}Ue().observable;var ri=Symbol("notification-settings-plain");function xs(e){const t=["email","slack","teams","webPush"],n={[ri]:{value:e,enumerable:!1}};for(const r of t)n[r]={enumerable:!0,get(){const o=this[ri][r];return o===void 0?(Un(`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 q1(e,t){const n=xs({...e[ri]});for(const o of(r=t,Object.keys(r))){const i=t[o];if(i!==void 0){const s=Object.fromEntries(oc(i).filter((([,a])=>a!==void 0)));n[ri][o]={...n[ri][o],...s}}}var r;return n}var Qn="12px",ga=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&&dn("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&&dn("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 cd(e){return Array.isArray(e)}var at=Object.freeze({UPDATE_PRESENCE:100,BROADCAST_EVENT:103,FETCH_STORAGE:200,UPDATE_STORAGE:201,FETCH_YDOC:300,UPDATE_YDOC:301,FETCH_FEEDS:510,FETCH_FEED_MESSAGES:511,ADD_FEED:512,UPDATE_FEED:513,DELETE_FEED:514,ADD_FEED_MESSAGE:515,UPDATE_FEED_MESSAGE:516,DELETE_FEED_MESSAGE:517}),G1=class{#e;#t;signal;constructor(){this.#e=new Ot({connections:new Map,presences:new Map}),this.signal=$e.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:s,id:a,info:u,access:l}=o,{canWrite:f,canComment:c}=l;return pi({connectionId:s,id:a,info:u,canWrite:f,canComment:c,isReadOnly:!f,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,access: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,pi(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=Gh(r,t);return r!==o&&(n.presences.set(e,o),this.#r(e))}))}},pu=class Bp 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 Bp((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"AI_CONNECTION_ERROR":return r.code===4001?"Not allowed to connect to ai":"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"EDIT_COMMENT_METADATA_ERROR":return"Could not edit comment 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"SUBSCRIBE_TO_THREAD_ERROR":return"Could not subscribe to thread";case"UNSUBSCRIBE_FROM_THREAD_ERROR":return"Could not unsubscribe from thread";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_ROOM_SUBSCRIPTION_SETTINGS_ERROR":return"Could not update room subscription settings";case"UPDATE_NOTIFICATION_SETTINGS_ERROR":return"Could not update notification settings";case"LARGE_MESSAGE_ERROR":return"Could not send large message";case"FEED_REQUEST_ERROR":return r.reason??"Feed request failed";default:return Ye(0,"Unhandled case")}})(t),t,n)}},va=5e3;function ld(e){const t=cc(lc(e));return{canWrite:lr(t,"storage","write"),canComment:lr(t,"comments","write")}}function dd(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 J1(e,t){const n=t.roomId,r=e.initialPresence,o=e.initialStorage,i=t.roomHttpClient,[s,a]=(function(){const O=typeof document<"u"?document:void 0,P={current:null};function j(){P.current=O?.visibilityState==="hidden"?P.current??Date.now():null}return O?.addEventListener("visibilitychange",j),[P,()=>{O?.removeEventListener("visibilitychange",j)}]})(),u={...t.delegates,canZombie:()=>t.backgroundKeepAliveTimeout!==void 0&&s.current!==null&&Date.now()>s.current+t.backgroundKeepAliveTimeout&&ut.getStatus()!=="synchronizing"&&Vo.getStatus()!=="synchronizing"},l=new yp(u,t.enableDebugLogging),f=new ip,c={buffer:{flushTimerID:void 0,lastFlushedAt:0,presenceUpdates:{type:"full",data:r},messages:[],storageOperations:[]},staticSessionInfoSig:new Tt(null),dynamicSessionInfoSig:new Tt(null),myPresence:new Mv(r),others:new G1,initialStorage:o,idFactory:null,yjsProvider:void 0,yjsProviderDidChange:Ue(),pool:sp({getCurrentConnectionId:function(){const O=c.dynamicSessionInfoSig.get();if(O)return O.actor;throw new Error("Internal. Tried to get connection id but connection was never open")},onDispatch:function(O,P,j,L){if(c.activeBatch){for(const N of O)c.activeBatch.ops.push(N);for(const[N,ce]of j)c.activeBatch.updates.storageUpdates.set(N,zi(c.activeBatch.updates.storageUpdates.get(N),ce));c.activeBatch.reverseOps.pushLeft(P),L?.clearRedoStack&&(c.activeBatch.clearRedoStack=!0)}else P.length>0&&H(P),(L?.clearRedoStack??O.length>0)&&_(),O.length>0&&we(O),W({storageUpdates:j})},isStorageWritable:function(){const O=c.dynamicSessionInfoSig.get()?.permissionMatrix;return O===void 0||lr(O,"storage","write")},unacknowledgedOps:f}),root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,unacknowledgedOps:f};let d=0,h=0;const g=(function(){let O=new Map;return{append(P){for(const[j,L]of P)O.set(j,L)},take(){const P=O;return O=new Map,P}}})(),y=t.enableDebugLogging?(function(){let O,P=0,j=0;function L(N=performance.now()){O.push(N-j),j=N}return{start:function(){O=[],P=performance.now(),j=P},lap:L,stop:function(){const N=performance.now();return L(N),{total:N-P,laps:O}}}})():void 0;let p,w,b=!1;l.events.onMessage.subscribe(pe),l.events.statusDidChange.subscribe((function(O){const P=l.authValue;if(P!==null){const j=uc(P);if(j!==p)if(p=j,P.type==="secret"){const L=P.token.parsed;c.staticSessionInfoSig.set({userId:L.uid,userInfo:L.ui})}else c.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}C.status.notify(O),I()})),l.events.statusDidChange.subscribe((function(O){O==="reconnecting"?w=setTimeout((()=>{C.lostConnection.notify("lost"),b=!0,c.others.clearOthers(),W({others:[{type:"reset"}]})}),t.lostConnectionTimeout):(clearTimeout(w),b&&(O==="disconnected"?C.lostConnection.notify("failed"):C.lostConnection.notify("restored"),b=!1))})),l.events.didConnect.subscribe((function(){c.buffer.presenceUpdates={type:"full",data:{...c.myPresence.get()}},Ce!==null&&ge(),fe()})),l.events.didDisconnect.subscribe((function(){clearTimeout(c.buffer.flushTimerID),c.unacknowledgedOps.markAllAsPossiblyStored()})),l.events.onConnectionError.subscribe((({message:O,code:P})=>{const j=new pu(O,{type:"ROOM_CONNECTION_ERROR",code:P,roomId:n});t.errorEventSource.notify(j)}));const C={status:Ue(),lostConnection:Ue(),customEvent:Ue(),self:Ue(),myPresence:Ue(),others:Ue(),storageBatch:Ue(),history:Ue(),privateHistory:Ue(),storageDidLoad:Ue(),storageStatus:Ue(),ydoc:Ue(),comments:Ue(),feeds:Ue(),roomWillDestroy:Ue()};function E(O){l.send(_r(O))}const A=$e.from(c.staticSessionInfoSig,c.dynamicSessionInfoSig,c.myPresence,((O,P,j)=>{if(O===null||P===null)return null;{const L=lr(P.permissionMatrix,"storage","write");return{connectionId:P.actor,id:O.userId,info:O.userInfo,presence:j,canWrite:L,canComment:lr(P.permissionMatrix,"comments","write")}}}));let x;function I(){const O=A.get();O!==null&&O!==x&&(C.self.notify(O),x=O)}const T=$e.from(A,(O=>O!==null?dd("Me",O):null));function F(O,P){const j=new Map;for(const[L,N]of c.pool.nodes)j.set(L,N._serialize());return V1(j,O,P)}function S(O){if(O.size===0)throw new Error("Internal error: cannot load storage without items");if(c.root!==void 0){const N=V(F(O));for(const[ce,Ee]of O)if(Ee.type===je.TEXT){const Re=c.pool.nodes.get(ce);if(Re!==void 0&&hu(Re)){const be=Re._resyncText(Ee.data,Ee.version,Kt);be!==void 0&&N.updates.storageUpdates.set(ce,zi(N.updates.storageUpdates.get(ce),be))}}W(N.updates)}else c.root=Kn._fromItems(O,c.pool);const P=A.get()?.canWrite??!0,j=(function(N){const ce=new Set,Ee=N.get("root");for(const Re in Ee?.data)ce.add(Re);for(const Re of N.values())Re.parentId==="root"&&ce.add(Re.parentKey);return ce})(O),L=c.root;et((()=>{for(const ce in c.initialStorage)j.has(ce)||(P?L.set(ce,(N=c.initialStorage[ce])===void 0?void 0:sr(N)?N.clone():hi(N)):mt(`Attempted to populate missing storage key '${ce}', but current user has no write access`));var N}))}function k(O){h>0||C.privateHistory.notify(O)}function _(){if(c.redoStack.length===0)return;const O=c.redoStack.map((P=>P.id));c.redoStack.length=0,k({action:"discard",ids:O})}function M(O){if(c.undoStack.length>=50){const j=c.undoStack.shift();j!==void 0&&k({action:"discard",ids:[j.id]})}const P=d++;c.undoStack.push({id:P,frames:O}),k({action:"push",id:P}),X()}function H(O){c.pausedHistory!==null?c.pausedHistory.pushLeft(O):M(O)}function W(O){const P=O.storageUpdates,j=O.others;if(j!==void 0&&j.length>0){const L=c.others.get();for(const N of j)C.others.notify({...N,others:L})}if(O.presence&&(I(),C.myPresence.notify(c.myPresence.get())),P!==void 0&&P.size>0){const L=Array.from(P.values(),(N=>({...N,source:sn(N.source)})));C.storageBatch.notify(L)}Gn()}const G=new Map;function q(O){const P=G.get(O);return P===void 0?"edit":(G.delete(O),P)}function $(O,P=St){const[j,L]=(function(be,tt){const Bt=[],Ft=[];let qe=0;for(const mn of be)tt(mn,qe++)?Bt.push(mn):Ft.push(mn);return[Bt,Ft]})(O,(be=>be.type==="presence")),N=new Map;for(const be of L)be.type!==ue.CREATE_TEXT||be.opId!==void 0||c.pool.nodes.get(be.id)!==void 0||N.has(be.id)||N.set(be.id,c.pool.generateId());const ce=(N.size===0?L:L.map((be=>{if(be.opId!==void 0)return be;const tt=N.get(be.id);if(tu(be)){const Bt=N.get(be.parentId),Ft=be.deletedId===void 0?void 0:N.get(be.deletedId);return tt===void 0&&Bt===void 0&&Ft===void 0?be:be.type===ue.CREATE_TEXT&&tt!==void 0?{...be,id:tt,version:0,...Bt===void 0?{}:{parentId:Bt},...Ft===void 0?{}:{deletedId:Ft}}:{...be,...tt===void 0?{}:{id:tt},...Bt===void 0?{}:{parentId:Bt},...Ft===void 0?{}:{deletedId:Ft}}}return tt===void 0?be:{...be,id:tt}}))).map((be=>be.opId===void 0?{...be,opId:c.pool.generateOpId()}:be));if(P.via!=="edit")for(const be of ce)G.set(be.opId,P.via);const{reverse:Ee,updates:Re}=Q(j,ce,!0,P);return{opsToEmit:ce,reverse:Ee,updates:Re}}function V(O){return Q([],O,!1)}function Q(O,P,j,L=St){const N={reverse:new ga,storageUpdates:new Map,presence:!1};for(const Ee of O){const Re={type:"presence",data:{}};for(const be in Ee.data)Re.data[be]=c.myPresence.get()[be];if(c.myPresence.patch(Ee.data),c.buffer.presenceUpdates===null)c.buffer.presenceUpdates={type:"partial",data:Ee.data};else for(const be in Ee.data)c.buffer.presenceUpdates.data[be]=Ee.data[be];N.reverse.pushLeft(Re),N.presence=!0}const ce=new Set;for(const Ee of P){let Re;j?Re={...L,optimistic:!0}:Ee.opId!==void 0?(c.unacknowledgedOps.delete(Ee.opId),Re={origin:"local",via:q(Ee.opId),optimistic:!1}):Re=Kt;const be=ae(Ee,Re);if(be.modified){const tt=be.modified.node._id;tt&&ce.has(tt)||(N.storageUpdates.set(ye(be.modified.node._id),zi(N.storageUpdates.get(ye(be.modified.node._id)),be.modified)),N.reverse.pushLeft(be.reverse)),Ee.type!==ue.CREATE_LIST&&Ee.type!==ue.CREATE_MAP&&Ee.type!==ue.CREATE_OBJECT&&Ee.type!==ue.CREATE_TEXT&&Ee.type!==ue.CREATE_FILE||ce.add(Ee.id)}}return{reverse:Array.from(N.reverse),updates:{storageUpdates:N.storageUpdates,presence:N.presence}}}function ae(O,P){if((function(j){return j.type===ue.DELETE_CRDT&&j.id==="ACK"})(O))return{modified:!1};switch(O.type){case ue.DELETE_OBJECT_KEY:case ue.UPDATE_OBJECT:case ue.UPDATE_TEXT:case ue.DELETE_CRDT:{const j=c.pool.nodes.get(O.id);return j===void 0?{modified:!1}:j._apply(O,P)}case ue.SET_PARENT_KEY:{const j=c.pool.nodes.get(O.id);return j===void 0?{modified:!1}:j.parent.type==="HasParent"&&pc(j.parent.node)?j.parent.node._setChildKey(mi(O.parentKey),j,P):{modified:!1}}case ue.CREATE_OBJECT:case ue.CREATE_LIST:case ue.CREATE_MAP:case ue.CREATE_TEXT:case ue.CREATE_FILE:case ue.CREATE_REGISTER:{if(O.parentId===void 0)return{modified:!1};const j=c.pool.nodes.get(O.parentId);return j===void 0?{modified:!1}:j._attachChild(O,P)}default:return{modified:!1}}}function ie(O){if(O.targetActor!==void 0){const j=c.others.getUser(O.actor);c.others.setOther(O.actor,O.data);const L=c.others.getUser(O.actor);if(j===void 0&&L!==void 0)return{type:"enter",user:L}}else c.others.patchOther(O.actor,O.data);const P=c.others.getUser(O.actor);return P?{type:"update",updates:O.data,user:P}:void 0}function Se(O){const P=c.others.getUser(O.actor);return P?(c.others.removeConnection(O.actor),{type:"leave",user:P}):null}function Ie(O){c.dynamicSessionInfoSig.set({actor:O.actor,nonce:O.nonce,permissionMatrix:cc(lc(O.scopes)),meta:O.meta}),c.idFactory=(function(P){let j=0;return()=>`${P}:${j++}`})(O.actor),I(),O.meta.showBrand===!0&&((P="bottom-right")=>{if(typeof document>"u"||document.getElementById("liveblocks-badge"))return;const j=document.createElement("div");switch(j.id="liveblocks-badge",j.style.position="fixed",j.style.opacity="0",j.style.transition="opacity 300ms",j.style.zIndex="9999",P){case"top-right":j.style.top=Qn,j.style.right=Qn;break;case"bottom-right":j.style.bottom=Qn,j.style.right=Qn;break;case"bottom-left":j.style.bottom=Qn,j.style.left=Qn;break;case"top-left":j.style.top=Qn,j.style.left=Qn}j.onmouseenter=()=>{const Jn=document.getElementById("liveblocks-badge-hide-button");Jn&&(Jn.style.opacity="0.3")},j.onmouseleave=()=>{const Jn=document.getElementById("liveblocks-badge-hide-button");Jn&&(Jn.style.opacity="0")};const L=document.createElement("a");L.href="https://lblcks.io/badge",L.target="_blank",L.rel="noopener noreferrer",L.title="Liveblocks";const N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width","111"),N.setAttribute("height","38"),N.setAttribute("viewBox","0 0 111 38"),N.setAttribute("fill","none");const ce=document.createElementNS("http://www.w3.org/2000/svg","rect");ce.setAttribute("x","1"),ce.setAttribute("y","1"),ce.setAttribute("width","109"),ce.setAttribute("height","36"),ce.setAttribute("rx","8"),ce.setAttribute("fill","white"),N.appendChild(ce);const Ee=document.createElementNS("http://www.w3.org/2000/svg","rect");Ee.setAttribute("x","0.5"),Ee.setAttribute("y","0.5"),Ee.setAttribute("width","110"),Ee.setAttribute("height","37"),Ee.setAttribute("rx","8.5"),Ee.setAttribute("stroke","black"),Ee.setAttribute("stroke-opacity","0.1"),N.appendChild(Ee);const Re=document.createElementNS("http://www.w3.org/2000/svg","path");Re.setAttribute("d","M39.8256 18.0832H38L38.0005 28.9009H39.8256V18.0832ZM43.213 21.1757H41.3879V28.9009H43.213V21.1757ZM43.213 18H41.3879V19.9688H43.213V18ZM45.8916 21.1757H43.9302L46.6915 28.9009H48.7283L51.4896 21.1757H49.5581L48.4039 24.8348C48.3739 24.93 48.2657 25.3024 48.0795 25.9511L47.7099 27.1959C47.4914 26.406 47.2626 25.6189 47.0237 24.8348L45.8916 21.1757ZM58.9659 23.59C58.8147 23.0721 58.5934 22.6317 58.3014 22.2694C57.9743 21.8628 57.5598 21.5482 57.0571 21.3268C56.5589 21.1004 56.0058 20.9877 55.3973 20.9877C54.2407 20.9877 53.3152 21.3495 52.6212 22.0735C52.275 22.4476 52.0103 22.8896 51.844 23.3715C51.6731 23.8691 51.5876 24.4199 51.5876 25.0233C51.5876 26.3157 51.9322 27.3142 52.6217 28.0184C53.3203 28.7323 54.2509 29.0894 55.4125 29.0894C56.4083 29.0894 57.2151 28.8658 57.8342 28.4181C58.453 27.9704 58.8628 27.3068 59.0638 26.4266L57.2834 26.2908C57.198 26.7685 57.0016 27.1257 56.6948 27.3618C56.3879 27.5933 55.9555 27.7093 55.3973 27.7093C54.1201 27.7093 53.4663 26.9899 53.4363 25.5514H59.1844L59.1922 25.295C59.1922 24.6763 59.1165 24.108 58.9659 23.59ZM53.8434 23.0471C54.1654 22.5943 54.6834 22.3679 55.3973 22.3679C55.7443 22.3679 56.0363 22.4155 56.2725 22.5111C56.509 22.6067 56.7128 22.7601 56.8837 22.9713C57.0167 23.1352 57.1189 23.3218 57.1855 23.5221C57.2605 23.731 57.3062 23.9493 57.3213 24.1708H53.451C53.4964 23.7231 53.6271 23.3484 53.8434 23.0471ZM66.2836 21.4779C65.7656 21.1406 65.1673 20.9724 64.4885 20.9724H64.4875C63.995 20.9724 63.5449 21.0727 63.1374 21.2742C62.7364 21.4696 62.3931 21.7659 62.1412 22.1341V18.0832H60.316V28.9009H62.1416V27.8373C62.373 28.2195 62.7008 28.5342 63.0921 28.7499C63.4996 28.9763 63.9497 29.0894 64.4422 29.0894C65.1266 29.0894 65.7324 28.9259 66.2614 28.5992C66.7891 28.2726 67.1989 27.8045 67.4905 27.1959C67.7871 26.5823 67.9359 25.8634 67.9359 25.0386C67.9359 24.2337 67.7895 23.5248 67.4984 22.9113C67.2115 22.2926 66.8066 21.8148 66.2836 21.4779ZM65.5064 27.0828C65.2148 27.5254 64.7172 27.7463 64.0125 27.7463C63.3786 27.7463 62.9013 27.5175 62.5797 27.0601C62.2576 26.6026 62.0968 25.9336 62.0968 25.0534C62.0968 24.2032 62.24 23.5397 62.5265 23.0619C62.8185 22.579 63.3088 22.3378 63.9978 22.3378C64.7019 22.3378 65.2023 22.5592 65.499 23.0013C65.7961 23.4389 65.944 24.1181 65.944 25.0386C65.944 25.9585 65.7985 26.6401 65.5064 27.0828ZM70.901 18.0832H69.0754V28.9009H70.901V18.0832ZM73.8582 28.6066C74.452 28.9286 75.1558 29.0894 75.9708 29.0894C76.7554 29.0894 77.4444 28.9208 78.0377 28.5844C78.6268 28.2569 79.1068 27.7637 79.4183 27.1659C79.745 26.5523 79.9086 25.843 79.9086 25.0386C79.9086 24.2642 79.7478 23.5697 79.4257 22.9565C79.117 22.3516 78.6404 21.8487 78.0529 21.508C77.4592 21.161 76.7652 20.9872 75.9708 20.9872C75.171 20.9872 74.4719 21.161 73.8735 21.508C73.2876 21.8472 72.811 22.3471 72.5002 22.9486C72.1837 23.5572 72.0252 24.254 72.0252 25.0386C72.0252 25.8735 72.181 26.5948 72.4929 27.2033C72.7962 27.798 73.2722 28.2871 73.8582 28.6066ZM77.4869 27.0906C77.18 27.5231 76.6746 27.7393 75.9708 27.7393C75.493 27.7393 75.1082 27.6437 74.8166 27.4524C74.5246 27.2565 74.3134 26.9621 74.1826 26.5699C74.0518 26.1725 73.9867 25.6619 73.9867 25.0381C73.9867 24.1029 74.1401 23.419 74.4469 22.9866C74.7588 22.5541 75.2667 22.3378 75.9708 22.3378C76.6699 22.3378 77.1727 22.5541 77.4795 22.9866C77.7914 23.419 77.9471 24.1029 77.9471 25.0386C77.9471 25.9738 77.7937 26.6576 77.4869 27.0906ZM82.3982 28.6066C82.9869 28.9286 83.6883 29.0894 84.5033 29.0894C85.1369 29.0894 85.7029 28.9791 86.2005 28.7577C86.6989 28.5364 87.1031 28.2272 87.4152 27.8299C87.7279 27.4249 87.9329 26.9471 88.0109 26.4414L86.2534 26.2607C86.1328 26.7431 85.9316 27.1031 85.6497 27.3392C85.3683 27.5757 84.9857 27.694 84.5033 27.694C84.0103 27.694 83.6232 27.5933 83.3413 27.3918C83.0598 27.1858 82.8635 26.8919 82.7531 26.5093C82.6422 26.1221 82.5872 25.6318 82.5872 25.0386C82.5872 24.455 82.6422 23.9722 82.7531 23.59C82.8635 23.2028 83.0571 22.9062 83.3339 22.6997C83.6157 22.4884 84.0053 22.3831 84.5033 22.3831C85.0362 22.3831 85.4312 22.5314 85.6877 22.8281C85.949 23.1196 86.1354 23.5193 86.2456 24.0276L87.9735 23.718C87.8078 22.8932 87.4326 22.232 86.8491 21.7344C86.2708 21.2363 85.489 20.9877 84.5033 20.9877C83.6985 20.9877 83.0021 21.1587 82.4134 21.5006C81.8322 21.8351 81.3625 22.3337 81.0633 22.9339C80.7514 23.5424 80.5952 24.2439 80.5952 25.0386C80.5952 25.8781 80.7486 26.6026 81.0554 27.2112C81.3673 27.8197 81.8151 28.285 82.3982 28.6066ZM90.8104 26.0343L91.6627 25.2192L93.9257 28.9009H96.0308L92.8999 24.0498L95.9328 21.1757H93.5634L90.8104 23.9976V18.0832H88.9845V28.9009H90.8104V26.0343ZM97.6304 28.8103C98.1436 28.9965 98.7142 29.0894 99.3428 29.0894C100.303 29.0894 101.095 28.8981 101.719 28.5165C102.348 28.1339 102.663 27.5101 102.663 26.6451C102.663 26.0818 102.516 25.6392 102.225 25.3176C101.933 24.9905 101.586 24.7566 101.184 24.6157C100.786 24.4702 100.245 24.3219 99.562 24.1707C99.1642 24.0853 98.8502 24.0049 98.6188 23.9295C98.3873 23.8538 98.201 23.7558 98.0604 23.6352C97.925 23.5141 97.8567 23.3584 97.8567 23.1676C97.8567 22.8858 97.9824 22.6723 98.2338 22.5263C98.4853 22.3803 98.7973 22.3073 99.1694 22.3073C99.6619 22.3073 100.047 22.4255 100.324 22.6621C100.605 22.8987 100.756 23.2531 100.776 23.7258L102.466 23.4467C102.385 22.5817 102.046 21.9556 101.447 21.568C100.854 21.1812 100.095 20.9872 99.1694 20.9872C98.6258 20.9872 98.1236 21.0699 97.6607 21.2362C97.2029 21.397 96.8335 21.6511 96.5517 21.9986C96.27 22.3451 96.1294 22.7827 96.1294 23.3109C96.1294 23.7988 96.25 24.1934 96.4911 24.4951C96.7368 24.8001 97.0527 25.0408 97.4118 25.1965C97.7838 25.3578 98.2512 25.5112 98.8147 25.6567L99.2828 25.7699C99.5949 25.844 99.9044 25.9295 100.211 26.0264C100.421 26.092 100.595 26.1826 100.731 26.2981C100.867 26.4136 100.935 26.5647 100.935 26.7509C100.935 27.0776 100.799 27.3294 100.527 27.505C100.261 27.6815 99.8708 27.7693 99.3583 27.7693C98.8347 27.7693 98.4176 27.6385 98.1055 27.377C97.7941 27.1154 97.6355 26.7384 97.6304 26.2454L95.9109 26.4413C95.9302 27.0351 96.094 27.5304 96.4009 27.9278C96.7129 28.3252 97.1223 28.619 97.6304 28.8103Z"),Re.setAttribute("fill","black"),N.appendChild(Re);const be=document.createElementNS("http://www.w3.org/2000/svg","path");be.setAttribute("d","M37.6392 15V9.18182H39.7131C40.1657 9.18182 40.5407 9.2642 40.8381 9.42898C41.1354 9.59375 41.358 9.81913 41.5057 10.1051C41.6534 10.3892 41.7273 10.7093 41.7273 11.0653C41.7273 11.4233 41.6525 11.7453 41.5028 12.0312C41.3551 12.3153 41.1316 12.5407 40.8324 12.7074C40.535 12.8722 40.161 12.9545 39.7102 12.9545H38.2841V12.2102H39.6307C39.9167 12.2102 40.1487 12.161 40.3267 12.0625C40.5047 11.9621 40.6354 11.8258 40.7188 11.6534C40.8021 11.4811 40.8438 11.285 40.8438 11.0653C40.8438 10.8456 40.8021 10.6506 40.7188 10.4801C40.6354 10.3097 40.5038 10.1761 40.3239 10.0795C40.1458 9.98295 39.911 9.93466 39.6193 9.93466H38.517V15H37.6392ZM44.4716 15.0881C44.0625 15.0881 43.7055 14.9943 43.4006 14.8068C43.0956 14.6193 42.8589 14.357 42.6903 14.0199C42.5218 13.6828 42.4375 13.2888 42.4375 12.8381C42.4375 12.3854 42.5218 11.9896 42.6903 11.6506C42.8589 11.3116 43.0956 11.0483 43.4006 10.8608C43.7055 10.6733 44.0625 10.5795 44.4716 10.5795C44.8807 10.5795 45.2377 10.6733 45.5426 10.8608C45.8475 11.0483 46.0843 11.3116 46.2528 11.6506C46.4214 11.9896 46.5057 12.3854 46.5057 12.8381C46.5057 13.2888 46.4214 13.6828 46.2528 14.0199C46.0843 14.357 45.8475 14.6193 45.5426 14.8068C45.2377 14.9943 44.8807 15.0881 44.4716 15.0881ZM44.4744 14.375C44.7396 14.375 44.9593 14.3049 45.1335 14.1648C45.3078 14.0246 45.4366 13.8381 45.5199 13.6051C45.6051 13.3722 45.6477 13.1155 45.6477 12.8352C45.6477 12.5568 45.6051 12.3011 45.5199 12.0682C45.4366 11.8333 45.3078 11.6449 45.1335 11.5028C44.9593 11.3608 44.7396 11.2898 44.4744 11.2898C44.2074 11.2898 43.9858 11.3608 43.8097 11.5028C43.6354 11.6449 43.5057 11.8333 43.4205 12.0682C43.3371 12.3011 43.2955 12.5568 43.2955 12.8352C43.2955 13.1155 43.3371 13.3722 43.4205 13.6051C43.5057 13.8381 43.6354 14.0246 43.8097 14.1648C43.9858 14.3049 44.2074 14.375 44.4744 14.375ZM48.267 15L46.983 10.6364H47.8608L48.7159 13.8409H48.7585L49.6165 10.6364H50.4943L51.3466 13.8267H51.3892L52.2386 10.6364H53.1165L51.8352 15H50.9688L50.0824 11.8494H50.017L49.1307 15H48.267ZM55.6705 15.0881C55.2405 15.0881 54.8703 14.9962 54.5597 14.8125C54.2509 14.6269 54.0123 14.3665 53.8438 14.0312C53.6771 13.6941 53.5938 13.2992 53.5938 12.8466C53.5938 12.3996 53.6771 12.0057 53.8438 11.6648C54.0123 11.3239 54.2472 11.0578 54.5483 10.8665C54.8513 10.6752 55.2055 10.5795 55.6108 10.5795C55.857 10.5795 56.0956 10.6203 56.3267 10.7017C56.5578 10.7831 56.7652 10.911 56.9489 11.0852C57.1326 11.2595 57.2775 11.4858 57.3835 11.7642C57.4896 12.0407 57.5426 12.3769 57.5426 12.7727V13.0739H54.0739V12.4375H56.7102C56.7102 12.214 56.6648 12.0161 56.5739 11.8438C56.483 11.6695 56.3551 11.5322 56.1903 11.4318C56.0275 11.3314 55.8362 11.2812 55.6165 11.2812C55.3778 11.2812 55.1695 11.34 54.9915 11.4574C54.8153 11.5729 54.679 11.7244 54.5824 11.9119C54.4877 12.0975 54.4403 12.2992 54.4403 12.517V13.0142C54.4403 13.3059 54.4915 13.554 54.5938 13.7585C54.6979 13.9631 54.8428 14.1193 55.0284 14.2273C55.214 14.3333 55.4309 14.3864 55.679 14.3864C55.84 14.3864 55.9867 14.3636 56.1193 14.3182C56.2519 14.2708 56.3665 14.2008 56.4631 14.108C56.5597 14.0152 56.6335 13.9006 56.6847 13.7642L57.4886 13.9091C57.4242 14.1458 57.3087 14.3532 57.142 14.5312C56.9773 14.7074 56.7699 14.8447 56.5199 14.9432C56.2718 15.0398 55.9886 15.0881 55.6705 15.0881ZM58.4851 15V10.6364H59.3061V11.3295H59.3516C59.4311 11.0947 59.5713 10.91 59.772 10.7756C59.9747 10.6392 60.2038 10.571 60.4595 10.571C60.5125 10.571 60.575 10.5729 60.647 10.5767C60.7209 10.5805 60.7786 10.5852 60.8203 10.5909V11.4034C60.7862 11.3939 60.7256 11.3835 60.6385 11.3722C60.5514 11.3589 60.4643 11.3523 60.3771 11.3523C60.1764 11.3523 59.9974 11.3949 59.8402 11.4801C59.6849 11.5634 59.5618 11.6799 59.4709 11.8295C59.38 11.9773 59.3345 12.1458 59.3345 12.3352V15H58.4851ZM63.2798 15.0881C62.8499 15.0881 62.4796 14.9962 62.169 14.8125C61.8603 14.6269 61.6217 14.3665 61.4531 14.0312C61.2865 13.6941 61.2031 13.2992 61.2031 12.8466C61.2031 12.3996 61.2865 12.0057 61.4531 11.6648C61.6217 11.3239 61.8565 11.0578 62.1577 10.8665C62.4607 10.6752 62.8149 10.5795 63.2202 10.5795C63.4664 10.5795 63.705 10.6203 63.9361 10.7017C64.1671 10.7831 64.3745 10.911 64.5582 11.0852C64.742 11.2595 64.8868 11.4858 64.9929 11.7642C65.099 12.0407 65.152 12.3769 65.152 12.7727V13.0739H61.6832V12.4375H64.3196C64.3196 12.214 64.2741 12.0161 64.1832 11.8438C64.0923 11.6695 63.9645 11.5322 63.7997 11.4318C63.6368 11.3314 63.4455 11.2812 63.2259 11.2812C62.9872 11.2812 62.7789 11.34 62.6009 11.4574C62.4247 11.5729 62.2884 11.7244 62.1918 11.9119C62.0971 12.0975 62.0497 12.2992 62.0497 12.517V13.0142C62.0497 13.3059 62.1009 13.554 62.2031 13.7585C62.3073 13.9631 62.4522 14.1193 62.6378 14.2273C62.8234 14.3333 63.0402 14.3864 63.2884 14.3864C63.4493 14.3864 63.5961 14.3636 63.7287 14.3182C63.8613 14.2708 63.9759 14.2008 64.0724 14.108C64.169 14.0152 64.2429 13.9006 64.294 13.7642L65.098 13.9091C65.0336 14.1458 64.9181 14.3532 64.7514 14.5312C64.5866 14.7074 64.3793 14.8447 64.1293 14.9432C63.8812 15.0398 63.598 15.0881 63.2798 15.0881ZM67.728 15.0852C67.3757 15.0852 67.0613 14.9953 66.7848 14.8153C66.5102 14.6335 66.2943 14.375 66.1371 14.0398C65.9818 13.7027 65.9041 13.2983 65.9041 12.8267C65.9041 12.3551 65.9827 11.9517 66.1399 11.6165C66.299 11.2812 66.5168 11.0246 66.7933 10.8466C67.0698 10.6686 67.3833 10.5795 67.7337 10.5795C68.0045 10.5795 68.2223 10.625 68.3871 10.7159C68.5537 10.8049 68.6825 10.9091 68.7734 11.0284C68.8662 11.1477 68.9382 11.2528 68.9893 11.3438H69.0405V9.18182H69.8899V15H69.0604V14.321H68.9893C68.9382 14.4138 68.8643 14.5199 68.7678 14.6392C68.6731 14.7585 68.5424 14.8627 68.3757 14.9517C68.209 15.0407 67.9931 15.0852 67.728 15.0852ZM67.9155 14.3608C68.1598 14.3608 68.3662 14.2964 68.5348 14.1676C68.7053 14.0369 68.834 13.8561 68.9212 13.625C69.0102 13.3939 69.0547 13.125 69.0547 12.8182C69.0547 12.5152 69.0111 12.25 68.924 12.0227C68.8369 11.7955 68.709 11.6184 68.5405 11.4915C68.3719 11.3646 68.1636 11.3011 67.9155 11.3011C67.6598 11.3011 67.4467 11.3674 67.2763 11.5C67.1058 11.6326 66.977 11.8134 66.8899 12.0426C66.8047 12.2718 66.7621 12.5303 66.7621 12.8182C66.7621 13.1098 66.8056 13.3722 66.8928 13.6051C66.9799 13.8381 67.1087 14.0227 67.2791 14.1591C67.4515 14.2936 67.6636 14.3608 67.9155 14.3608ZM73.2876 15V9.18182H74.1371V11.3438H74.1882C74.2375 11.2528 74.3085 11.1477 74.4013 11.0284C74.4941 10.9091 74.6229 10.8049 74.7876 10.7159C74.9524 10.625 75.1702 10.5795 75.4411 10.5795C75.7933 10.5795 76.1077 10.6686 76.3842 10.8466C76.6607 11.0246 76.8776 11.2812 77.0348 11.6165C77.1939 11.9517 77.2734 12.3551 77.2734 12.8267C77.2734 13.2983 77.1948 13.7027 77.0376 14.0398C76.8804 14.375 76.6645 14.6335 76.3899 14.8153C76.1153 14.9953 75.8018 15.0852 75.4496 15.0852C75.1844 15.0852 74.9676 15.0407 74.799 14.9517C74.6323 14.8627 74.5017 14.7585 74.407 14.6392C74.3123 14.5199 74.2393 14.4138 74.1882 14.321H74.1172V15H73.2876ZM74.12 12.8182C74.12 13.125 74.1645 13.3939 74.2536 13.625C74.3426 13.8561 74.4714 14.0369 74.6399 14.1676C74.8085 14.2964 75.0149 14.3608 75.2592 14.3608C75.513 14.3608 75.7251 14.2936 75.8956 14.1591C76.0661 14.0227 76.1948 13.8381 76.282 13.6051C76.371 13.3722 76.4155 13.1098 76.4155 12.8182C76.4155 12.5303 76.3719 12.2718 76.2848 12.0426C76.1996 11.8134 76.0708 11.6326 75.8984 11.5C75.728 11.3674 75.5149 11.3011 75.2592 11.3011C75.013 11.3011 74.8047 11.3646 74.6342 11.4915C74.4657 11.6184 74.3378 11.7955 74.2507 12.0227C74.1636 12.25 74.12 12.5152 74.12 12.8182ZM78.6158 16.6364C78.4889 16.6364 78.3733 16.6259 78.2692 16.6051C78.165 16.5862 78.0874 16.5653 78.0362 16.5426L78.2408 15.8466C78.3961 15.8883 78.5343 15.9063 78.6555 15.9006C78.7768 15.8949 78.8838 15.8494 78.9766 15.7642C79.0713 15.679 79.1546 15.5398 79.2266 15.3466L79.3317 15.0568L77.7351 10.6364H78.6442L79.7493 14.0227H79.7947L80.8999 10.6364H81.8118L80.0135 15.5824C79.9302 15.8097 79.8241 16.0019 79.6953 16.1591C79.5665 16.3182 79.4131 16.4375 79.2351 16.517C79.0571 16.5966 78.8506 16.6364 78.6158 16.6364Z"),be.setAttribute("fill","black"),be.setAttribute("fill-opacity","0.5"),N.appendChild(be);const tt=document.createElementNS("http://www.w3.org/2000/svg","rect");tt.setAttribute("x","7"),tt.setAttribute("y","7"),tt.setAttribute("width","24"),tt.setAttribute("height","24"),tt.setAttribute("rx","3"),tt.setAttribute("fill","black"),N.appendChild(tt);const Bt=document.createElementNS("http://www.w3.org/2000/svg","path");Bt.setAttribute("fill-rule","evenodd"),Bt.setAttribute("clip-rule","evenodd"),Bt.setAttribute("d","M22.0455 15H12.2273L15.1364 17.9091V21.9091L22.0455 15Z"),Bt.setAttribute("fill","white"),N.appendChild(Bt);const Ft=document.createElementNS("http://www.w3.org/2000/svg","path");Ft.setAttribute("fill-rule","evenodd"),Ft.setAttribute("clip-rule","evenodd"),Ft.setAttribute("d","M16.9546 22.9999H26.7728L23.8637 20.0908V16.0908L16.9546 22.9999Z"),Ft.setAttribute("fill","white"),N.appendChild(Ft),L.appendChild(N),j.appendChild(L);const qe=document.createElement("button");qe.id="liveblocks-badge-hide-button",qe.style.position="absolute",qe.style.top="0",qe.style.right="0",qe.style.border="none",qe.style.padding="0",qe.style.margin="0",qe.style.background="none",qe.style.font="inherit",qe.style.cursor="pointer",qe.style.outline="none",qe.style.setProperty("-webkit-appearance","none"),qe.style.setProperty("-moz-appearance","none"),qe.style.setProperty("appearance","none"),qe.style.opacity="0",qe.onclick=()=>{const Jn=document.getElementById("liveblocks-badge");Jn&&(Jn.style.display="none")},qe.onmouseenter=()=>{qe.style.opacity="0.5"},qe.onmouseleave=()=>{qe.style.opacity="0.3"};const mn=document.createElementNS("http://www.w3.org/2000/svg","svg");mn.setAttribute("width","18"),mn.setAttribute("height","18"),mn.setAttribute("viewBox","0 0 18 18"),mn.setAttribute("fill","none");const na=document.createElementNS("http://www.w3.org/2000/svg","path");na.setAttribute("d","M6 6L9 9M12 12L9 9M9 9L12 6M9 9L6 12"),na.setAttribute("stroke","black"),mn.appendChild(na),qe.appendChild(mn),j.appendChild(qe),document.body.appendChild(j),requestAnimationFrame((()=>{requestAnimationFrame((()=>{j.style.opacity="1"}))}))})(t.badgeLocation??"bottom-right");for(const P of c.others.connectionIds())O.users[P]===void 0&&c.others.removeConnection(P);for(const P in O.users){const j=O.users[P],L=Number(P);c.others.setConnection(L,j.id,j.info,ld(j.scopes))}return{type:"reset"}}function ne(){return c.undoStack.length>0}function B(){return c.redoStack.length>0}function X(){h>0||C.history.notify({canUndo:ne(),canRedo:B()})}function K(O){c.others.setConnection(O.actor,O.id,O.info,ld(O.scopes)),c.buffer.messages.push({type:at.UPDATE_PRESENCE,data:c.myPresence.get(),targetActor:O.actor}),fe();const P=c.others.getUser(O.actor);return P?{type:"enter",user:P}:void 0}function Y(O){return(function(P){return!(function(j){return j===null||typeof j=="string"||typeof j=="number"||typeof j=="boolean"})(P)&&!cd(P)})(O)?O:null}function de(O){return O.type===xe.FEED_REQUEST_FAILED}function pe(O){if(typeof O.data!="string")return;const P=(function(L){const N=Ln(L);return N===void 0?null:cd(N)?Ya(N.map((ce=>Y(ce)))):Ya([Y(N)])})(O.data);if(P===null||P.length===0)return;const j={storageUpdates:new Map,others:[]};for(const L of P)switch(L.type){case xe.USER_JOINED:{const N=K(L);N&&j.others.push(N);break}case xe.UPDATE_PRESENCE:{const N=ie(L);N&&j.others.push(N);break}case xe.BROADCASTED_EVENT:{const N=c.others.get();C.customEvent.notify({connectionId:L.actor,user:L.actor<0?null:N.find((ce=>ce.connectionId===L.actor))??null,event:L.event});break}case xe.USER_LEFT:{const N=Se(L);N&&j.others.push(N);break}case xe.UPDATE_YDOC:C.ydoc.notify(L);break;case xe.ROOM_STATE:j.others.push(Ie(L));break;case xe.STORAGE_CHUNK:y?.lap(),g.append(Hv(L.nodes));break;case xe.STORAGE_STREAM_END:{const N=y?.stop();if(N){const ce=Re=>`${Re.toFixed(1)}ms`,Ee=N.laps.slice(1);mt(`Storage chunk arrival: ${[`total=${ce(N.total)}`,`first=${ce(N.laps[0])}`,`rest.n=${Ee.length}`,`rest.avg=${ce(Ee.reduce(((Re,be)=>Re+be),0)/Ee.length)}`,`rest.max=${ce(Ee.reduce(((Re,be)=>Math.max(Re,be)),0))}`].join(", ")}`)}oe(g.take());break}case xe.UPDATE_STORAGE:{const N=V(L.ops);for(const[ce,Ee]of N.updates.storageUpdates)j.storageUpdates.set(ce,zi(j.storageUpdates.get(ce),Ee));break}case xe.REJECT_STORAGE_OP:{op("Storage mutation rejection error",L.reason);let N=!1;for(const ce of L.opIds){const Ee=c.unacknowledgedOps.get(ce);if(c.unacknowledgedOps.delete(ce),c.buffer.storageOperations=c.buffer.storageOperations.filter((Re=>Re.opId!==ce)),G.delete(ce),Ee!==void 0&&Ee.type===ue.UPDATE_TEXT){const Re=c.pool.nodes.get(Ee.id);Re!==void 0&&hu(Re)&&(Re._rejectPendingOp(ce),N=!0)}}N&&(ge(),fe());break}case xe.THREAD_CREATED:case xe.THREAD_DELETED:case xe.THREAD_METADATA_UPDATED:case xe.THREAD_UPDATED:case xe.COMMENT_REACTION_ADDED:case xe.COMMENT_REACTION_REMOVED:case xe.COMMENT_CREATED:case xe.COMMENT_EDITED:case xe.COMMENT_DELETED:case xe.COMMENT_METADATA_UPDATED:C.comments.notify(L);break;case xe.FEEDS_LIST:{const N=L,ce=te.get(N.requestId);ce&&(ce.resolve({feeds:N.feeds,nextCursor:N.nextCursor}),te.delete(N.requestId)),C.feeds.notify(N);break}case xe.FEEDS_ADDED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEEDS_UPDATED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_DELETED:C.feeds.notify(L),J(L);break;case xe.FEED_MESSAGES_LIST:{const N=L,ce=me.get(N.requestId);ce&&(ce.resolve({messages:N.messages,nextCursor:N.nextCursor}),me.delete(N.requestId)),C.feeds.notify(N);break}case xe.FEED_MESSAGES_ADDED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_MESSAGES_UPDATED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_MESSAGES_DELETED:C.feeds.notify(L),J(L);break;case xe.FEED_REQUEST_FAILED:{if(!de(L))break;const{requestId:N,code:ce,reason:Ee}=L,Re=new pu(Ee??"Feed request failed",{type:"FEED_REQUEST_ERROR",roomId:n,requestId:N,code:ce,reason:Ee});if(Ae.has(N))Fe(N,"error",Re);else if(te.has(N)){const be=te.get(N);te.delete(N),be?.reject(Re)}else if(me.has(N)){const be=me.get(N);me.delete(N),be?.reject(Re)}C.feeds.notify(L);break}case xe.STORAGE_STATE_V7:}W(j)}function fe(){const O=c.buffer.storageOperations;if(O.length>0){for(const L of O)c.unacknowledgedOps.add(L);Gn()}if(l.getStatus()!=="connected")return void(c.buffer.storageOperations=[]);const P=Date.now(),j=P-c.buffer.lastFlushedAt;if(j>=t.throttleDelay){const L=(function(){const N=[];c.buffer.presenceUpdates&&N.push(c.buffer.presenceUpdates.type==="full"?{type:at.UPDATE_PRESENCE,targetActor:-1,data:c.buffer.presenceUpdates.data}:{type:at.UPDATE_PRESENCE,data:c.buffer.presenceUpdates.data});for(const ce of c.buffer.messages)N.push(ce);return c.buffer.storageOperations.length>0&&N.push({type:at.UPDATE_STORAGE,ops:c.buffer.storageOperations}),N})();if(L.length===0)return;E(L),c.buffer={flushTimerID:void 0,lastFlushedAt:P,messages:[],storageOperations:[],presenceUpdates:null}}else clearTimeout(c.buffer.flushTimerID),c.buffer.flushTimerID=setTimeout(fe,t.throttleDelay-j)}function we(O){const{storageOperations:P}=c.buffer;for(const j of O)P.push(j);fe()}let Ce=null,se=null;const te=new Map,me=new Map,Ae=new Map,Pe=new Map;function Fe(O,P,j){const L=Ae.get(O);if(L!==void 0){if(clearTimeout(L.timeoutId),Ae.delete(O),L.kind==="add-message"&&!L.expectedClientMessageId){const N=Pe.get(L.feedId);if(N!==void 0){const ce=N.indexOf(O);ce>=0&&N.splice(ce,1),N.length===0&&Pe.delete(L.feedId)}}P==="ok"?L.resolve():L.reject(j??new Error("Feed mutation failed"))}}function re(O,P,j,L){const{promise:N,resolve:ce,reject:Ee}=uo(),Re=setTimeout((()=>{Ae.has(O)&&Fe(O,"error",new Error("Feed mutation timeout"))}),va);if(Ae.set(O,{resolve:ce,reject:Ee,timeoutId:Re,kind:P,feedId:j,messageId:L?.messageId,expectedClientMessageId:L?.expectedClientMessageId}),P==="add-message"&&L?.expectedClientMessageId===void 0){const be=Pe.get(j)??[];be.push(O),Pe.set(j,be)}return N}function J(O){switch(O.type){case xe.FEEDS_ADDED:for(const P of O.feeds)for(const[j,L]of[...Ae])if(L.kind==="add-feed"&&L.feedId===P.feedId){Fe(j,"ok");break}break;case xe.FEEDS_UPDATED:for(const P of O.feeds)for(const[j,L]of[...Ae])L.kind==="update-feed"&&L.feedId===P.feedId&&Fe(j,"ok");break;case xe.FEED_DELETED:for(const[P,j]of[...Ae])if(j.kind==="delete-feed"&&j.feedId===O.feedId){Fe(P,"ok");break}break;case xe.FEED_MESSAGES_ADDED:for(const P of O.messages){let j=!1;for(const[L,N]of[...Ae])if(N.kind==="add-message"&&N.feedId===O.feedId&&N.expectedClientMessageId===P.id){Fe(L,"ok"),j=!0;break}if(!j){const L=Pe.get(O.feedId),N=L?.[0];if(N!==void 0){const ce=Ae.get(N);ce?.kind==="add-message"&&ce.expectedClientMessageId===void 0&&Fe(N,"ok")}}}break;case xe.FEED_MESSAGES_UPDATED:for(const P of O.messages)for(const[j,L]of[...Ae])L.kind==="update-message"&&L.feedId===O.feedId&&L.messageId===P.id&&Fe(j,"ok");break;case xe.FEED_MESSAGES_DELETED:for(const P of O.messageIds)for(const[j,L]of[...Ae])L.kind==="delete-message"&&L.feedId===O.feedId&&L.messageId===P&&Fe(j,"ok")}}function oe(O){const P=[...c.unacknowledgedOps.values()];S(O),(function(j){if(j.length===0)return;const L=[],N=$(j);L.push({type:at.UPDATE_STORAGE,ops:N.opsToEmit}),W(N.updates),E(L)})(P),se?.(),Gn(),C.storageDidLoad.notify()}function ge(){const O=c.buffer.messages;O.some((P=>P.type===at.FETCH_STORAGE))||(O.push({type:at.FETCH_STORAGE}),g.take(),y?.start())}function ve(){return Ce===null&&(ge(),fe(),Ce=new Promise((O=>{se=O})),Gn()),Ce}function Te(){const O=c.root;return O!==void 0?O:(ve(),null)}async function We(){return c.root!==void 0?Promise.resolve({root:c.root}):(await ve(),{root:ye(c.root)})}function Le(){const O=c.pausedHistory;c.pausedHistory=null,O!==null&&O.length>0&&M(Array.from(O))}function et(O){const P=c.undoStack,j=c.redoStack,L=[],N=[];c.undoStack=L,c.redoStack=N,h++;try{return O()}finally{if(h--,c.undoStack!==L||c.redoStack!==N)throw new Error("unexpected stack swap during history.disable()");c.undoStack=P,c.redoStack=j}}const ut=t.createSyncSource();function Nt(){return c.root===void 0?Ce===null?"not-loaded":"loading":c.unacknowledgedOps.size===0?"synchronized":"synchronizing"}let hn=Nt();function Gn(){const O=Nt();hn!==O&&(hn=O,C.storageStatus.notify(O)),ut.setSyncStatus(O==="synchronizing"?"synchronizing":"synchronized")}function pn(){return A.get()!==null}function Mi(){return Te()!==null}const ta=$e.from(c.others.signal,(O=>O.map(((P,j)=>dd(`Other ${j}`,P))))),Ho={status:C.status.observable,lostConnection:C.lostConnection.observable,customEvent:C.customEvent.observable,others:C.others.observable,self:C.self.observable,myPresence:C.myPresence.observable,storageBatch:C.storageBatch.observable,history:C.history.observable,storageDidLoad:C.storageDidLoad.observable,storageStatus:C.storageStatus.observable,ydoc:C.ydoc.observable,comments:C.comments.observable,feeds:C.feeds.observable,roomWillDestroy:C.roomWillDestroy.observable};function Pi(O){return i.getSubscriptionSettings({roomId:n,signal:O?.signal})}function Ni(O){return i.updateSubscriptionSettings({roomId:n,settings:O})}const Vo=t.createSyncSource();function $o(O){return Vo.setSyncStatus(O==="synchronizing"||O==="loading"?"synchronizing":"synchronized")}return Object.defineProperty({[Oe]:{get presenceBuffer(){return hi(c.buffer.presenceUpdates?.data??null)},get undoStack(){return structuredClone(c.undoStack.map((O=>({id:O.id,frames:O.frames}))))},get redoStack(){return structuredClone(c.redoStack.map((O=>({id:O.id,frames:O.frames}))))},get nodeCount(){return c.pool.nodes.size},history:C.privateHistory.observable,getYjsProvider:()=>c.yjsProvider,setYjsProvider(O){c.yjsProvider?.off("status",$o),c.yjsProvider=O,O?.on("status",$o),c.yjsProviderDidChange.notify()},yjsProviderDidChange:c.yjsProviderDidChange.observable,reportTextEditor:async function(O,P){await i.reportTextEditor({roomId:n,type:O,rootKey:P})},getPermissionMatrix:()=>c.dynamicSessionInfoSig.get()?.permissionMatrix,createTextMention:async function(O,P){return i.createTextMention({roomId:n,mentionId:O,mention:P})},deleteTextMention:async function(O){return i.deleteTextMention({roomId:n,mentionId:O})},listHistoryVersions:async function(){return i.listHistoryVersions({roomId:n})},listHistoryVersionsSince:async function(O){return i.listHistoryVersionsSince({roomId:n,since:O.since,signal:O.signal})},fetchStorageHistoryVersion:async function(O){return i.fetchStorageHistoryVersion({roomId:n,versionId:O})},fetchYjsHistoryVersion:async function(O){return i.fetchYjsHistoryVersion({roomId:n,versionId:O})},liveObjectFromNodeStream:L1,reconcileStorageWithNodes:function(O){if(c.root===void 0)throw new Error("Cannot reconcile storage before it is loaded");const P=F(new Map(O),{includeLiveTextUpdates:!0});if(P.length===0)return;const j=$(P);j.reverse.length>0&&H(j.reverse),c.redoStack.length=0;for(const L of j.opsToEmit)c.buffer.storageOperations.push(L);W(j.updates),X(),fe()},createVersionHistorySnapshot:async function(){return i.createVersionHistorySnapshot({roomId:n})},deleteHistoryVersion:async function(O){return i.deleteHistoryVersion({roomId:n,versionId:O})},executeContextualPrompt:async function(O){return i.executeContextualPrompt({roomId:n,...O})},getSelf_forDevTools:()=>T.get(),getOthers_forDevTools:()=>ta.get(),simulate:{explicitClose:O=>l._privateSendMachineEvent({type:"EXPLICIT_SOCKET_CLOSE",event:O}),rawSend:O=>l.send(O),incomingMessage:O=>pe(new MessageEvent("message",{data:O}))},attachmentUrlsStore:i.getOrCreateAttachmentUrlsStore(n),fileUrlsStore:i.getOrCreateFileUrlsStore(n)},id:n,subscribe:Z1(n,C,t.errorEventSource),connect:()=>l.connect(),reconnect:()=>l.reconnect(),disconnect:()=>l.disconnect(),_dump:()=>{const O=c.pool.nodes.size;return`Room "${n}" (${O} node${O===1?"":"s"}):
|
|
4
4
|
${(function(P){const j=Array.from(P.nodes.values(),(L=>{const N=L.parent,ce=N.type==="HasParent"?N.node._id??"?":N.type==="Orphaned"?"<orphaned>":"-";let Ee;return Ee=L instanceof zn?_r(L.data):L instanceof gr?"<LiveList>":L instanceof Hr?"<LiveMap>":L instanceof mr?_r(L.data):"<LiveObject>",{id:ye(L._id),parentId:ce,key:L._parentKey??"",value:Ee}}));return j.sort(((L,N)=>L.parentId!==N.parentId?L.parentId<N.parentId?-1:1:L.key!==N.key?L.key<N.key?-1:1:0)),j.map((L=>` ${L.id} parent=${L.parentId} key=${L.key||"—"} ${L.value}`)).join(`
|
|
5
|
-
`)})(c.pool)}`},destroy:()=>{te.forEach((j=>j.reject(new Error("Room destroyed")))),me.forEach((j=>j.reject(new Error("Room destroyed"))));const{roomWillDestroy:O,...P}=C;for(const j of Object.values(P))j.dispose();C.roomWillDestroy.notify(),c.yjsProvider?.off("status",$o),ut.destroy(),Vo.destroy(),a(),l.destroy(),O.dispose()},updatePresence:function(O,P){const j={};c.buffer.presenceUpdates===null&&(c.buffer.presenceUpdates={type:"partial",data:{}});for(const L in O){const N=O[L];N!==void 0&&(c.buffer.presenceUpdates.data[L]=N,j[L]=c.myPresence.get()[L])}c.myPresence.patch(O),c.activeBatch?(P?.addToHistory&&c.activeBatch.reverseOps.pushLeft({type:"presence",data:j}),c.activeBatch.updates.presence=!0):(fe(),P?.addToHistory&&H([{type:"presence",data:j}]),W({presence:!0}))},updateYDoc:function(O,P,j){const L={type:at.UPDATE_YDOC,update:O,guid:P,v2:j};c.buffer.messages.push(L),C.ydoc.notify(L),fe()},broadcastEvent:function(O,P={shouldQueueEventIfNotReady:!1}){(l.getStatus()==="connected"||P.shouldQueueEventIfNotReady)&&(c.buffer.messages.push({type:at.BROADCAST_EVENT,event:O}),fe())},batch:function(O){if(c.activeBatch)return O();let P;c.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:new ga,scheduleHistoryResume:!1};try{P=O()}finally{const j=c.activeBatch;c.activeBatch=null,j.reverseOps.length>0&&H(Array.from(j.reverseOps)),j.scheduleHistoryResume&&Le(),(j.ops.length>0||j.clearRedoStack)&&_(),j.ops.length>0&&we(j.ops),W(j.updates),fe()}return P},history:{undo:function(){if(c.activeBatch)throw new Error("undo is not allowed during a batch");const O=c.undoStack.pop();if(O===void 0)return;c.pausedHistory=null;const P=$(O.frames,zv);c.redoStack.push({id:O.id,frames:P.reverse}),k({action:"undo",id:O.id}),W(P.updates),X();for(const j of P.opsToEmit)c.buffer.storageOperations.push(j);fe()},redo:function(){if(c.activeBatch)throw new Error("redo is not allowed during a batch");const O=c.redoStack.pop();if(O===void 0)return;c.pausedHistory=null;const P=$(O.frames,Kv);c.undoStack.push({id:O.id,frames:P.reverse}),k({action:"redo",id:O.id}),W(P.updates),X();for(const j of P.opsToEmit)c.buffer.storageOperations.push(j);fe()},canUndo:ne,canRedo:B,clear:function(){c.undoStack.length=0,c.redoStack.length=0,k({action:"clear"}),X()},pause:function(){c.pausedHistory===null&&(c.pausedHistory=new ga)},resume:function(){c.activeBatch===null?Le():c.activeBatch.scheduleHistoryResume=!0},disable:et},fetchYDoc:function(O,P,j){c.buffer.messages.find((L=>L.type===at.FETCH_YDOC&&L.vector===O&&L.guid===P&&L.v2===j))||c.buffer.messages.push({type:at.FETCH_YDOC,vector:O,guid:P,v2:j}),fe()},fetchFeeds:async function(O){const P=st(),{promise:j,resolve:L,reject:N}=uo();te.set(P,{resolve:L,reject:N});const ce={type:at.FETCH_FEEDS,requestId:P,cursor:O?.cursor,since:O?.since,limit:O?.limit,metadata:O?.metadata};return c.buffer.messages.push(ce),fe(),setTimeout((()=>{te.has(P)&&(te.delete(P),N(new Error("Feeds fetch timeout")))}),va),j},fetchFeedMessages:async function(O,P){const j=st(),{promise:L,resolve:N,reject:ce}=uo();me.set(j,{resolve:N,reject:ce});const Ee={type:at.FETCH_FEED_MESSAGES,requestId:j,feedId:O,cursor:P?.cursor,since:P?.since,limit:P?.limit};return c.buffer.messages.push(Ee),fe(),setTimeout((()=>{me.has(j)&&(me.delete(j),ce(new Error("Feed messages fetch timeout")))}),va),L},addFeed:function(O,P){const j=st(),L=re(j,"add-feed",O),N={type:at.ADD_FEED,requestId:j,feedId:O,metadata:P?.metadata,createdAt:P?.createdAt};return c.buffer.messages.push(N),fe(),L},updateFeed:function(O,P){const j=st(),L=re(j,"update-feed",O),N={type:at.UPDATE_FEED,requestId:j,feedId:O,metadata:P};return c.buffer.messages.push(N),fe(),L},deleteFeed:function(O){const P=st(),j=re(P,"delete-feed",O),L={type:at.DELETE_FEED,requestId:P,feedId:O};return c.buffer.messages.push(L),fe(),j},addFeedMessage:function(O,P,j){const L=st(),N=re(L,"add-message",O,{expectedClientMessageId:j?.id}),ce={type:at.ADD_FEED_MESSAGE,requestId:L,feedId:O,data:P,id:j?.id,createdAt:j?.createdAt};return c.buffer.messages.push(ce),fe(),N},updateFeedMessage:function(O,P,j,L){const N=st(),ce=re(N,"update-message",O,{messageId:P}),Ee={type:at.UPDATE_FEED_MESSAGE,requestId:N,feedId:O,messageId:P,data:j,updatedAt:L?.updatedAt};return c.buffer.messages.push(Ee),fe(),ce},deleteFeedMessage:function(O,P){const j=st(),L=re(j,"delete-message",O,{messageId:P}),N={type:at.DELETE_FEED_MESSAGE,requestId:j,feedId:O,messageId:P};return c.buffer.messages.push(N),fe(),L},getStorage:We,getStorageOrNull:Te,getStorageSnapshot:Te,getStorageStatus:Nt,isPresenceReady:pn,isStorageReady:Mi,waitUntilPresenceReady:Ml((async function(){for(;!pn();){const{promise:O,resolve:P}=uo(),j=Ho.self.subscribeOnce(P),L=Ho.status.subscribeOnce(P);await O,j(),L()}})),waitUntilStorageReady:Ml((async function(){for(;!Mi();)await We()})),events:Ho,getStatus:()=>l.getStatus(),getSelf:()=>A.get(),getPresence:()=>c.myPresence.get(),getOthers:()=>c.others.get(),getThreads:async function(O){return i.getThreads({roomId:n,query:O?.query,cursor:O?.cursor})},getThreadsSince:async function(O){return i.getThreadsSince({roomId:n,since:O.since,signal:O.signal})},getThread:async function(O){return i.getThread({roomId:n,threadId:O})},createThread:async function(O){return i.createThread({roomId:n,threadId:O.threadId,commentId:O.commentId,visibility:O.visibility,metadata:O.metadata,body:O.body,commentMetadata:O.commentMetadata,attachmentIds:O.attachmentIds})},deleteThread:async function(O){return i.deleteThread({roomId:n,threadId:O})},editThreadMetadata:async function({metadata:O,threadId:P}){return i.editThreadMetadata({roomId:n,threadId:P,metadata:O})},markThreadAsResolved:async function(O){return i.markThreadAsResolved({roomId:n,threadId:O})},markThreadAsUnresolved:async function(O){return i.markThreadAsUnresolved({roomId:n,threadId:O})},subscribeToThread:async function(O){return i.subscribeToThread({roomId:n,threadId:O})},unsubscribeFromThread:async function(O){return i.unsubscribeFromThread({roomId:n,threadId:O})},createComment:async function(O){return i.createComment({roomId:n,threadId:O.threadId,commentId:O.commentId,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds})},editComment:async function(O){return i.editComment({roomId:n,threadId:O.threadId,commentId:O.commentId,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds})},editCommentMetadata:async function({threadId:O,commentId:P,metadata:j}){return i.editCommentMetadata({roomId:n,threadId:O,commentId:P,metadata:j})},deleteComment:async function({threadId:O,commentId:P}){return i.deleteComment({roomId:n,threadId:O,commentId:P})},addReaction:async function({threadId:O,commentId:P,emoji:j}){return i.addReaction({roomId:n,threadId:O,commentId:P,emoji:j})},removeReaction:async function({threadId:O,commentId:P,emoji:j}){return await i.removeReaction({roomId:n,threadId:O,commentId:P,emoji:j})},prepareAttachment:function(O){return{type:"localAttachment",status:"idle",id:lp(),name:O.name,size:O.size,mimeType:O.type,file:O}},uploadAttachment:async function(O,P={}){return i.uploadAttachment({roomId:n,attachment:O,signal:P.signal})},getAttachmentUrl:function(O){return i.getAttachmentUrl({roomId:n,attachmentId:O})},uploadFile:function(O,P={}){return i.uploadFile({roomId:n,file:O,signal:P.signal})},getFileUrl:function(O){return i.getFileUrl({roomId:n,fileId:qv(O)})},getNotificationSettings:Pi,getSubscriptionSettings:Pi,updateNotificationSettings:Ni,updateSubscriptionSettings:Ni,markInboxNotificationAsRead:async function(O){await i.markRoomInboxNotificationAsRead({roomId:n,inboxNotificationId:O})}},Oe,{enumerable:!1})}function Z1(e,t,n){function r(o,i){return t.storageBatch.subscribe((s=>{const a=s.filter((u=>Sp(u.node,o)));a.length>0&&i(a)}))}return function(o,i,s){if(typeof o=="string"&&((a=o)==="my-presence"||a==="others"||a==="event"||a==="error"||a==="history"||a==="status"||a==="storage-status"||a==="lost-connection"||a==="connection"||a==="comments")){if(typeof i!="function")throw new Error("Second argument must be a callback function");const u=i;switch(o){case"event":return t.customEvent.subscribe(u);case"my-presence":return t.myPresence.subscribe(u);case"others":{const l=u;return t.others.subscribe((f=>{const{others:c,...d}=f;return l(c,d)}))}case"error":return n.subscribe((l=>{if(l.roomId===e)return u(l)}));case"status":return t.status.subscribe(u);case"lost-connection":return t.lostConnection.subscribe(u);case"history":return t.history.subscribe(u);case"storage-status":return t.storageStatus.subscribe(u);case"comments":return t.comments.subscribe(u);default:return Ye(0,`"${String(o)}" is not a valid event name`)}}var a;if(i===void 0||typeof o=="function"){if(typeof o=="function"){const u=o;return t.storageBatch.subscribe(u)}throw new Error("Please specify a listener callback")}if(ot(o)){const u=o;return s?.isDeep?r(u,i):(function(l,f){return t.storageBatch.subscribe((c=>{for(const d of c)d.node._id===l._id&&f(d.node)}))})(u,i)}throw new Error(`${String(o)} is not a value that can be subscribed to.`)}}function X1(e,t){return async()=>t.getAuthValue({roomId:e,resource:"room",access:"read"})}function Y1(e,t,n){return r=>{const o=n??(typeof WebSocket>"u"?void 0:WebSocket);if(o===void 0)throw new jn("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="/v8",i.searchParams.set("roomId",e),r.type==="secret")i.searchParams.set("tok",r.token.raw);else{if(r.type!=="public")return Ye(0,"Unhandled case");i.searchParams.set("pubkey",r.publicApiKey)}return i.searchParams.set("version",Ls),new o(i.toString())}}function Q1(e){const t=e,n=(function(S){return typeof S=="string"&&S.startsWith("http")?S:"https://api.liveblocks.io"})(t.baseUrl),r=mu("throttle",t.throttle??100,16,1e3),o=(function(S){return mu("lostConnectionTimeout",S,200,3e4,1e3)})(t.lostConnectionTimeout??5e3),i=hd(t.backgroundKeepAliveTimeout),s=new Tt(void 0),a=I1(e,(S=>{s.set((()=>S.uid))})),u=t.polyfills?.fetch||globalThis.fetch?.bind(globalThis),l=r1({baseUrl:n,fetchPolyfill:u,authManager:a}),f=new Map,c=b1({userId:s.get(),lostConnectionTimeout:o,backgroundKeepAliveTimeout:hd(t.backgroundKeepAliveTimeout),polyfills:t.polyfills,delegates:{createSocket:C1(n,t.polyfills?.WebSocket),authenticate:async()=>{const S=await a.getAuthValue({resource:"personal",access:"write"});if(S.type==="public")throw new jn("Cannot use AI Copilots with a public API key");return S},canZombie:()=>!1}});function d(S){const k=()=>{const _=k;var M;S.unsubs.delete(_)?S.unsubs.size===0&&((M=S.room).id,f.delete(M.id),M.destroy()):mt("This leave function was already called. Calling it more than once has no effect.")};return S.unsubs.add(k),{room:S.room,leave:k}}const h=t.resolveUsers,g=fo(new or((async S=>{const k=S.flat(),_=await h?.({userIds:k});return ma(!h,"Set the resolveUsers option in createClient to specify user info."),_??k.map((()=>{}))}),{delay:50})),y=t.resolveRoomsInfo,p=fo(new or((async S=>{const k=S.flat(),_=await y?.({roomIds:k});return ma(!y,"Set the resolveRoomsInfo option in createClient to specify room info."),_??k.map((()=>{}))}),{delay:50})),w=t.resolveGroupsInfo,b=fo(new or((async S=>{const k=S.flat(),_=await w?.({groupIds:k});return ma(!w,"Set the resolveGroupsInfo option in createClient to specify group info."),_??k.map((()=>{}))}),{delay:50})),C=new Map,E=[],A=new Tt("synchronized"),x=Ue();function I(){A.set(E.some((S=>S.get()==="synchronizing"))?"synchronizing":E.some((S=>S.get()==="has-local-changes"))?"has-local-changes":"synchronized")}function T(){const S=new Tt("synchronized");E.push(S);const k=S.subscribe((()=>I()));return{setSyncStatus:function(_){S.set(_)},getStatus:function(){return S.get()},destroy:function(){k();const _=E.findIndex((M=>M===S));if(_>-1){const[M]=E.splice(_,1);M.get()!=="synchronized"&&I()}}}}{const S=_=>{t.preventUnsavedChanges&&A.get()!=="synchronized"&&_.preventDefault()};(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",S)}const F=Object.defineProperty({enterRoom:function(S,...k){const _=f.get(S);if(_!==void 0)return d(_);const M=k[0]??{},H=(typeof M.initialPresence=="function"?M.initialPresence(S):M.initialPresence)??{},W=(typeof M.initialStorage=="function"?M.initialStorage(S):M.initialStorage)??{};let G;if(gc(W)){const V={};for(const Q of W.keys())V[Q]=W.get(Q);G=V}else G=W;const q=J1({initialPresence:H,initialStorage:G},{roomId:S,throttleDelay:r,lostConnectionTimeout:o,backgroundKeepAliveTimeout:i,polyfills:t.polyfills,delegates:t.mockedDelegates??{createSocket:Y1(S,n,t.polyfills?.WebSocket),authenticate:X1(S,a)},enableDebugLogging:t.enableDebugLogging,baseUrl:n,errorEventSource:x,roomHttpClient:l,createSyncSource:T,badgeLocation:t.badgeLocation??"bottom-right"}),$={room:q,unsubs:new Set};if(f.set(S,$),M.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");Xa.atob=t.polyfills.atob}q.connect()}return d($)},getRoom:function(S){return f.get(S)?.room||null},_dump:()=>Array.from(f.values(),(({room:S})=>S._dump())).join(`
|
|
5
|
+
`)})(c.pool)}`},destroy:()=>{te.forEach((j=>j.reject(new Error("Room destroyed")))),me.forEach((j=>j.reject(new Error("Room destroyed"))));const{roomWillDestroy:O,...P}=C;for(const j of Object.values(P))j.dispose();C.roomWillDestroy.notify(),c.yjsProvider?.off("status",$o),ut.destroy(),Vo.destroy(),a(),l.destroy(),O.dispose()},updatePresence:function(O,P){const j={};c.buffer.presenceUpdates===null&&(c.buffer.presenceUpdates={type:"partial",data:{}});for(const L in O){const N=O[L];N!==void 0&&(c.buffer.presenceUpdates.data[L]=N,j[L]=c.myPresence.get()[L])}c.myPresence.patch(O),c.activeBatch?(P?.addToHistory&&c.activeBatch.reverseOps.pushLeft({type:"presence",data:j}),c.activeBatch.updates.presence=!0):(fe(),P?.addToHistory&&H([{type:"presence",data:j}]),W({presence:!0}))},updateYDoc:function(O,P,j){const L={type:at.UPDATE_YDOC,update:O,guid:P,v2:j};c.buffer.messages.push(L),C.ydoc.notify(L),fe()},broadcastEvent:function(O,P={shouldQueueEventIfNotReady:!1}){(l.getStatus()==="connected"||P.shouldQueueEventIfNotReady)&&(c.buffer.messages.push({type:at.BROADCAST_EVENT,event:O}),fe())},batch:function(O){if(c.activeBatch)return O();let P;c.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:new ga,scheduleHistoryResume:!1};try{P=O()}finally{const j=c.activeBatch;c.activeBatch=null,j.reverseOps.length>0&&H(Array.from(j.reverseOps)),j.scheduleHistoryResume&&Le(),(j.ops.length>0||j.clearRedoStack)&&_(),j.ops.length>0&&we(j.ops),W(j.updates),fe()}return P},history:{undo:function(){if(c.activeBatch)throw new Error("undo is not allowed during a batch");const O=c.undoStack.pop();if(O===void 0)return;c.pausedHistory=null;const P=$(O.frames,zv);c.redoStack.push({id:O.id,frames:P.reverse}),k({action:"undo",id:O.id}),W(P.updates),X();for(const j of P.opsToEmit)c.buffer.storageOperations.push(j);fe()},redo:function(){if(c.activeBatch)throw new Error("redo is not allowed during a batch");const O=c.redoStack.pop();if(O===void 0)return;c.pausedHistory=null;const P=$(O.frames,Kv);c.undoStack.push({id:O.id,frames:P.reverse}),k({action:"redo",id:O.id}),W(P.updates),X();for(const j of P.opsToEmit)c.buffer.storageOperations.push(j);fe()},canUndo:ne,canRedo:B,clear:function(){c.undoStack.length=0,c.redoStack.length=0,k({action:"clear"}),X()},pause:function(){c.pausedHistory===null&&(c.pausedHistory=new ga)},resume:function(){c.activeBatch===null?Le():c.activeBatch.scheduleHistoryResume=!0},disable:et},fetchYDoc:function(O,P,j){c.buffer.messages.find((L=>L.type===at.FETCH_YDOC&&L.vector===O&&L.guid===P&&L.v2===j))||c.buffer.messages.push({type:at.FETCH_YDOC,vector:O,guid:P,v2:j}),fe()},fetchFeeds:async function(O){const P=st(),{promise:j,resolve:L,reject:N}=uo();te.set(P,{resolve:L,reject:N});const ce={type:at.FETCH_FEEDS,requestId:P,cursor:O?.cursor,since:O?.since,limit:O?.limit,metadata:O?.metadata};return c.buffer.messages.push(ce),fe(),setTimeout((()=>{te.has(P)&&(te.delete(P),N(new Error("Feeds fetch timeout")))}),va),j},fetchFeedMessages:async function(O,P){const j=st(),{promise:L,resolve:N,reject:ce}=uo();me.set(j,{resolve:N,reject:ce});const Ee={type:at.FETCH_FEED_MESSAGES,requestId:j,feedId:O,cursor:P?.cursor,since:P?.since,limit:P?.limit};return c.buffer.messages.push(Ee),fe(),setTimeout((()=>{me.has(j)&&(me.delete(j),ce(new Error("Feed messages fetch timeout")))}),va),L},addFeed:function(O,P){const j=st(),L=re(j,"add-feed",O),N={type:at.ADD_FEED,requestId:j,feedId:O,metadata:P?.metadata,createdAt:P?.createdAt};return c.buffer.messages.push(N),fe(),L},updateFeed:function(O,P){const j=st(),L=re(j,"update-feed",O),N={type:at.UPDATE_FEED,requestId:j,feedId:O,metadata:P};return c.buffer.messages.push(N),fe(),L},deleteFeed:function(O){const P=st(),j=re(P,"delete-feed",O),L={type:at.DELETE_FEED,requestId:P,feedId:O};return c.buffer.messages.push(L),fe(),j},addFeedMessage:function(O,P,j){const L=st(),N=re(L,"add-message",O,{expectedClientMessageId:j?.id}),ce={type:at.ADD_FEED_MESSAGE,requestId:L,feedId:O,data:P,id:j?.id,createdAt:j?.createdAt};return c.buffer.messages.push(ce),fe(),N},updateFeedMessage:function(O,P,j,L){const N=st(),ce=re(N,"update-message",O,{messageId:P}),Ee={type:at.UPDATE_FEED_MESSAGE,requestId:N,feedId:O,messageId:P,data:j,updatedAt:L?.updatedAt};return c.buffer.messages.push(Ee),fe(),ce},deleteFeedMessage:function(O,P){const j=st(),L=re(j,"delete-message",O,{messageId:P}),N={type:at.DELETE_FEED_MESSAGE,requestId:j,feedId:O,messageId:P};return c.buffer.messages.push(N),fe(),L},getStorage:We,getStorageOrNull:Te,getStorageSnapshot:Te,getStorageStatus:Nt,isPresenceReady:pn,isStorageReady:Mi,waitUntilPresenceReady:jl((async function(){for(;!pn();){const{promise:O,resolve:P}=uo(),j=Ho.self.subscribeOnce(P),L=Ho.status.subscribeOnce(P);await O,j(),L()}})),waitUntilStorageReady:jl((async function(){for(;!Mi();)await We()})),events:Ho,getStatus:()=>l.getStatus(),getSelf:()=>A.get(),getPresence:()=>c.myPresence.get(),getOthers:()=>c.others.get(),getThreads:async function(O){return i.getThreads({roomId:n,query:O?.query,cursor:O?.cursor})},getThreadsSince:async function(O){return i.getThreadsSince({roomId:n,since:O.since,signal:O.signal})},getThread:async function(O){return i.getThread({roomId:n,threadId:O})},createThread:async function(O){return i.createThread({roomId:n,threadId:O.threadId,commentId:O.commentId,visibility:O.visibility,metadata:O.metadata,body:O.body,commentMetadata:O.commentMetadata,attachmentIds:O.attachmentIds})},deleteThread:async function(O){return i.deleteThread({roomId:n,threadId:O})},editThreadMetadata:async function({metadata:O,threadId:P}){return i.editThreadMetadata({roomId:n,threadId:P,metadata:O})},markThreadAsResolved:async function(O){return i.markThreadAsResolved({roomId:n,threadId:O})},markThreadAsUnresolved:async function(O){return i.markThreadAsUnresolved({roomId:n,threadId:O})},subscribeToThread:async function(O){return i.subscribeToThread({roomId:n,threadId:O})},unsubscribeFromThread:async function(O){return i.unsubscribeFromThread({roomId:n,threadId:O})},createComment:async function(O){return i.createComment({roomId:n,threadId:O.threadId,commentId:O.commentId,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds})},editComment:async function(O){return i.editComment({roomId:n,threadId:O.threadId,commentId:O.commentId,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds})},editCommentMetadata:async function({threadId:O,commentId:P,metadata:j}){return i.editCommentMetadata({roomId:n,threadId:O,commentId:P,metadata:j})},deleteComment:async function({threadId:O,commentId:P}){return i.deleteComment({roomId:n,threadId:O,commentId:P})},addReaction:async function({threadId:O,commentId:P,emoji:j}){return i.addReaction({roomId:n,threadId:O,commentId:P,emoji:j})},removeReaction:async function({threadId:O,commentId:P,emoji:j}){return await i.removeReaction({roomId:n,threadId:O,commentId:P,emoji:j})},prepareAttachment:function(O){return{type:"localAttachment",status:"idle",id:lp(),name:O.name,size:O.size,mimeType:O.type,file:O}},uploadAttachment:async function(O,P={}){return i.uploadAttachment({roomId:n,attachment:O,signal:P.signal})},getAttachmentUrl:function(O){return i.getAttachmentUrl({roomId:n,attachmentId:O})},uploadFile:function(O,P={}){return i.uploadFile({roomId:n,file:O,signal:P.signal})},getFileUrl:function(O){return i.getFileUrl({roomId:n,fileId:qv(O)})},getNotificationSettings:Pi,getSubscriptionSettings:Pi,updateNotificationSettings:Ni,updateSubscriptionSettings:Ni,markInboxNotificationAsRead:async function(O){await i.markRoomInboxNotificationAsRead({roomId:n,inboxNotificationId:O})}},Oe,{enumerable:!1})}function Z1(e,t,n){function r(o,i){return t.storageBatch.subscribe((s=>{const a=s.filter((u=>Sp(u.node,o)));a.length>0&&i(a)}))}return function(o,i,s){if(typeof o=="string"&&((a=o)==="my-presence"||a==="others"||a==="event"||a==="error"||a==="history"||a==="status"||a==="storage-status"||a==="lost-connection"||a==="connection"||a==="comments")){if(typeof i!="function")throw new Error("Second argument must be a callback function");const u=i;switch(o){case"event":return t.customEvent.subscribe(u);case"my-presence":return t.myPresence.subscribe(u);case"others":{const l=u;return t.others.subscribe((f=>{const{others:c,...d}=f;return l(c,d)}))}case"error":return n.subscribe((l=>{if(l.roomId===e)return u(l)}));case"status":return t.status.subscribe(u);case"lost-connection":return t.lostConnection.subscribe(u);case"history":return t.history.subscribe(u);case"storage-status":return t.storageStatus.subscribe(u);case"comments":return t.comments.subscribe(u);default:return Ye(0,`"${String(o)}" is not a valid event name`)}}var a;if(i===void 0||typeof o=="function"){if(typeof o=="function"){const u=o;return t.storageBatch.subscribe(u)}throw new Error("Please specify a listener callback")}if(ot(o)){const u=o;return s?.isDeep?r(u,i):(function(l,f){return t.storageBatch.subscribe((c=>{for(const d of c)d.node._id===l._id&&f(d.node)}))})(u,i)}throw new Error(`${String(o)} is not a value that can be subscribed to.`)}}function X1(e,t){return async()=>t.getAuthValue({roomId:e,resource:"room",access:"read"})}function Y1(e,t,n){return r=>{const o=n??(typeof WebSocket>"u"?void 0:WebSocket);if(o===void 0)throw new jn("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="/v8",i.searchParams.set("roomId",e),r.type==="secret")i.searchParams.set("tok",r.token.raw);else{if(r.type!=="public")return Ye(0,"Unhandled case");i.searchParams.set("pubkey",r.publicApiKey)}return i.searchParams.set("version",Ls),new o(i.toString())}}function Q1(e){const t=e,n=(function(S){return typeof S=="string"&&S.startsWith("http")?S:"https://api.liveblocks.io"})(t.baseUrl),r=mu("throttle",t.throttle??100,16,1e3),o=(function(S){return mu("lostConnectionTimeout",S,200,3e4,1e3)})(t.lostConnectionTimeout??5e3),i=fd(t.backgroundKeepAliveTimeout),s=new Tt(void 0),a=I1(e,(S=>{s.set((()=>S.uid))})),u=t.polyfills?.fetch||globalThis.fetch?.bind(globalThis),l=r1({baseUrl:n,fetchPolyfill:u,authManager:a}),f=new Map,c=b1({userId:s.get(),lostConnectionTimeout:o,backgroundKeepAliveTimeout:fd(t.backgroundKeepAliveTimeout),polyfills:t.polyfills,delegates:{createSocket:C1(n,t.polyfills?.WebSocket),authenticate:async()=>{const S=await a.getAuthValue({resource:"personal",access:"write"});if(S.type==="public")throw new jn("Cannot use AI Copilots with a public API key");return S},canZombie:()=>!1}});function d(S){const k=()=>{const _=k;var M;S.unsubs.delete(_)?S.unsubs.size===0&&((M=S.room).id,f.delete(M.id),M.destroy()):mt("This leave function was already called. Calling it more than once has no effect.")};return S.unsubs.add(k),{room:S.room,leave:k}}const h=t.resolveUsers,g=fo(new or((async S=>{const k=S.flat(),_=await h?.({userIds:k});return ma(!h,"Set the resolveUsers option in createClient to specify user info."),_??k.map((()=>{}))}),{delay:50})),y=t.resolveRoomsInfo,p=fo(new or((async S=>{const k=S.flat(),_=await y?.({roomIds:k});return ma(!y,"Set the resolveRoomsInfo option in createClient to specify room info."),_??k.map((()=>{}))}),{delay:50})),w=t.resolveGroupsInfo,b=fo(new or((async S=>{const k=S.flat(),_=await w?.({groupIds:k});return ma(!w,"Set the resolveGroupsInfo option in createClient to specify group info."),_??k.map((()=>{}))}),{delay:50})),C=new Map,E=[],A=new Tt("synchronized"),x=Ue();function I(){A.set(E.some((S=>S.get()==="synchronizing"))?"synchronizing":E.some((S=>S.get()==="has-local-changes"))?"has-local-changes":"synchronized")}function T(){const S=new Tt("synchronized");E.push(S);const k=S.subscribe((()=>I()));return{setSyncStatus:function(_){S.set(_)},getStatus:function(){return S.get()},destroy:function(){k();const _=E.findIndex((M=>M===S));if(_>-1){const[M]=E.splice(_,1);M.get()!=="synchronized"&&I()}}}}{const S=_=>{t.preventUnsavedChanges&&A.get()!=="synchronized"&&_.preventDefault()};(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",S)}const F=Object.defineProperty({enterRoom:function(S,...k){const _=f.get(S);if(_!==void 0)return d(_);const M=k[0]??{},H=(typeof M.initialPresence=="function"?M.initialPresence(S):M.initialPresence)??{},W=(typeof M.initialStorage=="function"?M.initialStorage(S):M.initialStorage)??{};let G;if(mc(W)){const V={};for(const Q of W.keys())V[Q]=W.get(Q);G=V}else G=W;const q=J1({initialPresence:H,initialStorage:G},{roomId:S,throttleDelay:r,lostConnectionTimeout:o,backgroundKeepAliveTimeout:i,polyfills:t.polyfills,delegates:t.mockedDelegates??{createSocket:Y1(S,n,t.polyfills?.WebSocket),authenticate:X1(S,a)},enableDebugLogging:t.enableDebugLogging,baseUrl:n,errorEventSource:x,roomHttpClient:l,createSyncSource:T,badgeLocation:t.badgeLocation??"bottom-right"}),$={room:q,unsubs:new Set};if(f.set(S,$),M.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");Xa.atob=t.polyfills.atob}q.connect()}return d($)},getRoom:function(S){return f.get(S)?.room||null},_dump:()=>Array.from(f.values(),(({room:S})=>S._dump())).join(`
|
|
6
6
|
|
|
7
|
-
`),logout:function(){a.reset(),s.set((()=>{}));for(const{room:k}of f.values())(S=k.getStatus())!=="initial"&&S!=="disconnected"&&k.reconnect();var S},getInboxNotifications:l.getInboxNotifications,getInboxNotificationsSince:l.getInboxNotificationsSince,getUnreadInboxNotificationsCount:l.getUnreadInboxNotificationsCount,markAllInboxNotificationsAsRead:l.markAllInboxNotificationsAsRead,markInboxNotificationAsRead:l.markInboxNotificationAsRead,deleteAllInboxNotifications:l.deleteAllInboxNotifications,deleteInboxNotification:l.deleteInboxNotification,getNotificationSettings:async function(S){return xs(await l.getNotificationSettings(S))},updateNotificationSettings:async function(S){return xs(await l.updateNotificationSettings(S))},resolvers:{invalidateUsers:function(S){g.invalidate(S)},invalidateRoomsInfo:function(S){p.invalidate(S)},invalidateGroupsInfo:function(S){b.invalidate(S)},invalidateMentionSuggestions:function(){C.clear()}},getSyncStatus:function(){const S=A.get();return S==="synchronizing"?S:"synchronized"},events:{error:x,syncStatus:A},[Oe]:{currentUserId:s,mentionSuggestionsCache:C,ai:c,resolveMentionSuggestions:t.resolveMentionSuggestions,usersStore:g,roomsInfoStore:p,groupsInfoStore:b,getRoomIds:()=>Array.from(f.keys()),httpClient:l,as:()=>F,createSyncSource:T,emitError:(S,k)=>{const _=pu.from(S,k);x.notify(_)||Un(_.message)}}},Oe,{enumerable:!1});return F}function mu(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 hd(e){if(e!==void 0)return mu("backgroundKeepAliveTimeout",e,15e3)}function Fp(e){return"type"in e&&e.type==="mention"}function Rp(e){return"type"in e&&e.type==="link"}new RegExp(Object.keys({"&":"&","<":"<",">":">",'"':""","'":"'"}).map((e=>`\\${e}`)).join("|"),"g");new RegExp(Object.keys({_:"\\_","*":"\\*","#":"\\#","`":"\\`","~":"\\~","!":"\\!","|":"\\|","(":"\\(",")":"\\)","{":"\\{","}":"\\}","[":"\\[","]":"\\]"}).map((e=>`\\${e}`)).join("|"),"g");var ya=[1e3,2e3,4e3,8e3,1e4];function kr(e,t,n){const r=performance.now(),o=typeof document<"u"?document:void 0,i=typeof window<"u"?window:void 0,s=n?.maxStaleTimeMs??Number.POSITIVE_INFINITY,a={inForeground:o?.visibilityState!=="hidden",lastSuccessfulPollAt:r,count:0,backoff:0};function u(){return a.count>0&&a.inForeground}const l=new hp({}).addState("@idle").addState("@enabled").addState("@polling");function f(){u()?l.send({type:"START"}):l.send({type:"STOP"})}function c(){performance.now()-a.lastSuccessfulPollAt>s&&l.send({type:"POLL"})}function d(g){a.inForeground=g,f(),c()}function h(){d(o?.visibilityState!=="hidden")}return l.addTransitions("@idle",{START:"@enabled"}),l.addTransitions("@enabled",{STOP:"@idle",POLL:"@polling"}),l.addTimedTransition("@enabled",(()=>{const g=a.lastSuccessfulPollAt+t;return Math.max(0,g-performance.now())+a.backoff}),"@polling"),l.onEnterAsync("@polling",(async(g,y)=>{await e(y),y.aborted||(a.lastSuccessfulPollAt=performance.now())}),(()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=0}})),(()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=ya.find((g=>g>a.backoff))??ya[ya.length-1]}})),3e4),o?.addEventListener("visibilitychange",h),i?.addEventListener("online",h),i?.addEventListener("focus",c),l.start(),{inc:function(){a.count++,f()},dec:function(){a.count--,a.count<0&&(a.count=0),f()},pollNowIfStale:c,markAsStale:function(){a.lastSuccessfulPollAt=performance.now()-s-1},setInForeground:d}}function Br(e,t){return typeof e=="string"?`${e}:${t}`:`${e.kind}:${e.subjectId}`}oc("@liveblocks/core",Ls,"esm");oc("@liveblocks/client","3.24.0","esm");var _p=m.createContext(null);function vc(){return m.useContext(_p)}function Ve(){return vc()??dn("LiveblocksProvider is missing from the React tree.")}var Vr=m.createContext(null);function Vs(e){const t=m.useRef(e);return m.useEffect((()=>{t.current=e}),[e]),t}function nn(e,t){return m.useMemo((()=>e),[t])}function qo(e,t){const n=nn(e,t),r=Vs(e),o=m.useCallback(((...i)=>r.current(...i)),[r]);return typeof n=="function"?o:n}function Si(e,t,n,r,o){const i=m.useRef(null);let s;i.current===null?(s={hasValue:!1,value:null},i.current=s):s=i.current;const[a,u]=m.useMemo((()=>{let f,c,d=!1;const h=y=>{if(!d){d=!0,f=y;const b=r(y);if(o!==void 0&&s.hasValue){const C=s.value;if(o(C,b))return c=C,C}return c=b,b}const p=c;if((function(b,C){return b===C&&(b!==0||1/b==1/C)||b!=b&&C!=C})(f,y))return p;const w=r(y);return o!==void 0&&o(p,w)?(f=y,p):(f=y,c=w,w)},g=n===void 0?null:n;return[()=>h(t()),g===null?void 0:()=>h(g())]}),[t,n,r,o]),l=m.useSyncExternalStore(e,a,u);return m.useEffect((()=>{s.hasValue=!0,s.value=l}),[l]),m.useDebugValue(l),l}m.memo((function(e){const t=m.useId(),n=Ve()[Oe].ai,{description:r,value:o,chatId:i}=e,[s,a]=m.useState();m.useEffect((()=>{const{layerKey:f,deregister:c}=n.registerKnowledgeLayer(t,i);return a(f),()=>{c(),a(void 0)}}),[n,t,i]);const u=m.useState(st)[0],l=e.id??u;return m.useEffect((()=>{s!==void 0&&n.updateKnowledge(s,{description:r,value:o},l,i)}),[n,s,l,r,o,i]),null})),m.memo((function({chatId:e,name:t,tool:n,enabled:r}){const o=Ve()[Oe].ai;return m.useEffect((()=>{const i=r!==void 0?{...n,enabled:r}:n;return o.registerTool(t,i,e)}),[o,e,t,n,r]),null}));var ey=e=>e;function Mo(e,t,n){if(e instanceof Ot)throw new Error("Using a mutable Signal with useSignal will likely not work as expected.");return Si(e.subscribe,e.get,e.get,t??ey,n)}var Rt={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,ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL:6e4,ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME:5e3,USER_NOTIFICATION_SETTINGS_INTERVAL:3e5,USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME:6e4},Os=Object.freeze({isLoading:!0}),jp=e=>Object.freeze({isLoading:!1,error:e});function rn(e,t){return arguments.length===1?Object.freeze({isLoading:!1,data:e}):Object.freeze({isLoading:!1,[e]:t})}function yc(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 ty(e,t){return n=>(function(r,o,i){let s;return i&&(s=i?.[Br("thread",r.id)]),(o.resolved===void 0||r.resolved===o.resolved)&&(o.visibility===void 0||r.visibility===o.visibility)&&(o.subscribed===void 0||o.subscribed===!0&&s!==void 0||o.subscribed===!1&&s===void 0)})(n,e,t)&&(function(r,o){const i=r.metadata;return o.metadata===void 0||Object.entries(o.metadata).every((([s,a])=>a===void 0||(function(u,l){return l===null?u===void 0:ou(l)?typeof u=="string"&&u.startsWith(l.startsWith):iu(l)?typeof u=="number"&&(function(f,c){return(c.lt===void 0||f<c.lt)&&(c.gt===void 0||f>c.gt)&&(c.lte===void 0||f<=c.lte)&&(c.gte===void 0||f>=c.gte)})(u,l):u===l})(i[s],a)))})(n,e)}var ny=class Mp{#e;#t;#n;signal;constructor(){this.#t=ir.from([],((t,n)=>{const r=t.createdAt,o=n.createdAt;return r<o||r===o&&t.id<n.id})),this.#n=ir.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 Ot(this)}clone(){const t=new Mp;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){Xe((()=>{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,o){const i=r==="desc"?this.#n:this.#t,s=[];return t!==void 0&&s.push((a=>a.roomId===t)),n!==void 0&&s.push(ty(n,o)),Array.from(i.filter((a=>s.every((u=>u(a))))))}};function Pp(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 ry=Promise.resolve(),qr=class{#e;signal;#t;#n;#r;constructor(e,t){this.#e=new Tt(Os),this.#t=e,this.#n=null,this.#r=t?.autoRetry??!0,this.signal=this.#e.asReadonly(),yc(this)}get(){return this.#e.get()}#o(e){const t=this.#e.get();t.data!==void 0&&this.#e.set(rn({...t.data,...e}))}async#i(){const e=this.#e.get();if(e.data?.cursor&&!e.data.isFetchingMore){this.#o({isFetchingMore:!0});try{const t=await this.#t(e.data.cursor);this.#n=null,this.#o({cursor:t,hasFetchedAll:t===null,fetchMoreError:void 0,isFetchingMore:!1})}catch(t){this.#n=null,this.#o({isFetchingMore:!1,fetchMoreError:t})}}}fetchMore(){return this.#e.get().data?.cursor?(this.#n||(this.#n=this.#i()),this.#n):ry}#s=null;waitUntilLoaded(){if(this.#s)return this.#s;const e=Pp(this.#r?ao((()=>this.#t(void 0)),5,[5e3,5e3,1e4,15e3]):Promise.resolve().then((()=>this.#t(void 0))));return e.then((t=>{this.#e.set(rn({cursor:t,hasFetchedAll:t===null,isFetchingMore:!1,fetchMoreError:void 0,fetchMore:this.fetchMore}))}),(t=>{this.#e.set(jp(t)),this.#r&&setTimeout((()=>{this.#s=null,this.#e.set(Os)}),5e3)})),this.#s=e,this.#s}},Cr=class{#e;signal;#t;#n=!0;constructor(e,t=!0){this.#e=new Tt(Os),this.signal=this.#e.asReadonly(),this.#t=e,this.#n=t,yc(this)}get(){return this.#e.get()}#r=null;waitUntilLoaded(){if(this.#r)return this.#r;const e=Pp(this.#n?ao((()=>this.#t()),5,[5e3,5e3,1e4,15e3]):this.#t());return e.then((()=>{this.#e.set(rn(void 0))}),(t=>{this.#e.set(jp(t)),this.#n&&setTimeout((()=>{this.#r=null,this.#e.set(Os)}),5e3)})),this.#r=e,e}};function oy(e,t){const n=new Ot(new Map);return{signal:$e.from(n,e,((r,o)=>(function(i,s,a){const u=Object.fromEntries(i);for(const l of a)if(l.type==="update-room-subscription-settings"){if(!l.settings.threads)continue;const f=s.findMany(l.roomId,void 0,"desc",void 0);for(const c of f){const d=Br("thread",c.id);switch(l.settings.threads){case"all":u[d]={kind:"thread",subjectId:c.id,createdAt:new Date};break;case"none":delete u[d];break;case"replies_and_mentions":break;default:Ye(l.settings.threads,"Unexpected thread subscription settings.")}}}return u})(r,t,o))),applyDelta:function(r,o){n.mutate((i=>{let s=!1;for(const a of r)i.set(Br(a),a),s=!0;for(const a of o)i.delete(Br(a)),s=!0;return s}))},create:function(r){n.mutate((o=>{o.set(Br(r),r)}))},delete:function(r){n.mutate((o=>{o.delete(r)}))}}}function iy(e){const t=new Ot(new Map);return{signal:$e.from(t,e,((n,r)=>(function(o,i){const s=Object.fromEntries(o);for(const a of i)switch(a.type){case"update-room-subscription-settings":{const u=s[a.roomId];if(u===void 0)break;s[a.roomId]={...u,...a.settings}}}return s})(n,r))),update:function(n,r){t.mutate((o=>{o.set(n,r)}))}}}function sy(e){const t=new Tt(xs({}));return{signal:$e.from(t,e,((n,r)=>(function(o,i){let s=o;for(const a of i)a.type==="update-notification-settings"&&(s=q1(s,a.settings));return s})(n,r))),update:function(n){t.set(n)}}}var ay=new Set(["mark-inbox-notification-as-read"]),uy=class{#e;threads;notifications;subscriptions;roomSubscriptionSettings;historyVersions;unreadNotificationsCount;urlsMetadata;permissionHints;notificationSettings;optimisticUpdates;outputs;#t=null;#n=new Map;#r=null;#o=new Map;#i;#s=(function(){const e=new Ot(new Map);return{signal:e,upsert:function(t,n){e.mutate((r=>{let o=r.get(t);o||(o=new Map,r.set(t,o));for(const i of n)o.set(i.feedId,i)}))},delete:function(t,n){e.mutate((r=>{r.get(t)?.delete(n)}))},findMany:function(t,n,r){const o=Array.from(t.get(n)?.values()??[]).filter((i=>{if(r?.since!==void 0&&i.updatedAt<r.since&&i.createdAt<r.since)return!1;if(r?.metadata!==void 0){const s=i.metadata;if(!Object.entries(r.metadata).every((([a,u])=>s[a]===u)))return!1}return!0}));return o.sort(((i,s)=>{const a=i.createdAt-s.createdAt;return a!==0?a:i.feedId<s.feedId?-1:i.feedId>s.feedId?1:0})),o}}})();#u=(function(){const e=new Ot(new Map);return{signal:e,upsert:function(t,n){e.mutate((r=>{let o=r.get(t);o||(o=new Map,r.set(t,o));for(const i of n)o.set(i.id,i)}))},delete:function(t,n){e.mutate((r=>{const o=r.get(t);if(o)for(const i of n)o.delete(i)}))},findMany:function(t,n){return Array.from(t.get(n)?.values()??[]).sort(((r,o)=>r.createdAt-o.createdAt))}}})();constructor(e){this.#e=e[Oe].as(),this.optimisticUpdates=(function(b){const C=new Tt([]),E=b[Oe].createSyncSource();return C.subscribe((()=>E.setSyncStatus(C.get().some((A=>!ay.has(A.type)))?"synchronizing":"synchronized"))),{signal:C.asReadonly(),add:function(A){const x=st(),I={...A,id:x};return C.set((T=>[...T,I])),x},remove:function(A){C.set((x=>x.filter((I=>I.id!==A))))}}})(this.#e),this.permissionHints=(function(){const b=new He((()=>new Tt(void 0)));return{getPermissionForRoomΣ:function(C){return b.getOrCreate(C)},update:function(C,E,A){Xe((()=>{const x=A===void 0?Object.keys(C):new Set([...A,...Object.keys(C)]);for(const I of x){const T=b.getOrCreate(I),F=T.get();F!==void 0&&F.requestedAt>E||T.set({requestedAt:E,permissions:lc(C[I]??[])})}}))}}})(),this.notificationSettings=sy(this.optimisticUpdates.signal),this.#i=new Cr((async()=>{const b=await this.#e.getNotificationSettings();this.notificationSettings.update(b)})),this.threads=new ny,this.subscriptions=oy(this.optimisticUpdates.signal,this.threads),this.notifications=(function(){const b=new Ot(new Map);return{signal:b.asReadonly(),markAllRead:function(C){b.mutate((E=>{for(const A of E.values())A.readAt=C}))},markRead:function(C,E){b.mutate((A=>{const x=A.get(C);return!!x&&(A.set(C,{...x,readAt:E}),!0)}))},delete:function(C){b.mutate((E=>E.delete(C)))},applyDelta:function(C,E){b.mutate((A=>{let x=!1;for(const I of C){const T=A.get(I.id);T&&cy(T,I)===1||(A.set(I.id,I),x=!0)}for(const I of E)A.delete(I.id),x=!0;return x}))},clear:function(){b.mutate((C=>C.clear()))},updateAssociatedNotification:function(C){b.mutate((E=>{const A=(function(x,I){for(const T of x)if(I(T))return T})(E.values(),(x=>x.kind==="thread"&&x.threadId===C.threadId));return!!A&&(E.set(A.id,{...A,notifiedAt:C.createdAt,readAt:C.createdAt}),!0)}))},upsert:function(C){b.mutate((E=>{E.set(C.id,C)}))}}})(),this.roomSubscriptionSettings=iy(this.optimisticUpdates.signal),this.historyVersions=(function(){const b=new Ot(new He((()=>new Map)));return{signal:$e.from(b,(C=>Object.fromEntries([...C].map((([E,A])=>[E,Object.fromEntries(A)]))))),update:function(C,E){b.mutate((A=>{const x=A.getOrCreate(C);for(const I of E)x.set(I.id,I)}))}}})(),this.unreadNotificationsCount=(function(){const b=new Ot(new Map);return{signal:$e.from(b,(C=>Object.fromEntries(C))),update:function(C,E){b.mutate((A=>{A.set(C,E)}))}}})(),this.urlsMetadata=(function(){const b=new Ot(new Map);return{signal:$e.from(b,(C=>Object.fromEntries(C))),update:function(C,E){b.mutate((A=>{A.set(C,E)}))}}})();const t=$e.from(this.threads.signal,this.notifications.signal,this.optimisticUpdates.signal,((b,C,E)=>(function(A,x,I){const T=A.clone();let F=Object.fromEntries(x);for(const S of I)switch(S.type){case"create-thread":T.upsert(S.thread);break;case"edit-thread-metadata":{const k=T.get(S.threadId);if(k===void 0||k.updatedAt>S.updatedAt)break;T.upsert({...k,updatedAt:S.updatedAt,metadata:{...k.metadata,...S.metadata}});break}case"mark-thread-as-resolved":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,resolved:!0});break}case"mark-thread-as-unresolved":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,resolved:!1});break}case"create-comment":{const k=T.get(S.comment.threadId);if(k===void 0)break;T.upsert(Go(k,S.comment));const _=Object.values(F).find((M=>M.kind==="thread"&&M.threadId===k.id));if(_===void 0)break;F[_.id]={..._,notifiedAt:S.comment.createdAt,readAt:S.comment.createdAt};break}case"edit-comment":{const k=T.get(S.comment.threadId);if(k===void 0)break;T.upsert(Go(k,S.comment));break}case"edit-comment-metadata":{const k=T.get(S.threadId);if(k===void 0||k.updatedAt>S.updatedAt)break;const _=k.comments.find((M=>M.id===S.commentId));if(_===void 0)break;T.upsert(Go(k,{..._,metadata:{..._.metadata,...S.metadata}}));break}case"delete-comment":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(pd(k,S.commentId,S.deletedAt));break}case"delete-thread":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,deletedAt:S.deletedAt,updatedAt:S.deletedAt,comments:[]});break}case"add-reaction":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(md(k,S.commentId,S.reaction));break}case"remove-reaction":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(gd(k,S.commentId,S.emoji,S.userId,S.removedAt));break}case"mark-inbox-notification-as-read":{const k=F[S.inboxNotificationId];if(k===void 0)break;F[S.inboxNotificationId]={...k,readAt:S.readAt};break}case"mark-all-inbox-notifications-as-read":for(const k in F){const _=F[k];if(_===void 0)break;F[k]={..._,readAt:S.readAt}}break;case"delete-inbox-notification":delete F[S.inboxNotificationId];break;case"delete-all-inbox-notifications":F={}}return{sortedNotifications:Object.values(F).filter((S=>S.kind!=="thread"||T.get(S.threadId)!==void 0)).sort(((S,k)=>k.notifiedAt.getTime()-S.notifiedAt.getTime())),notificationsById:F,threadsDB:T}})(b,C,E))),n=$e.from(t,(b=>b.threadsDB)),r=$e.from(t,(b=>({sortedNotifications:b.sortedNotifications,notificationsById:b.notificationsById})),lt),o=$e.from(r,this.subscriptions.signal,((b,C)=>({subscriptions:C,notifications:b.sortedNotifications}))),i=new He((b=>{const C=JSON.parse(b),E=new qr((async A=>{const x=await this.#e[Oe].httpClient.getUserThreads_experimental({cursor:A,query:C});return this.updateThreadifications(x.threads,x.inboxNotifications,x.subscriptions),this.permissionHints.update(x.permissionHints,x.requestedAt),this.#r===null&&(this.#r=x.requestedAt),x.nextCursor}));return{signal:$e.from((()=>{const A=E.get();if(A.isLoading||A.error)return A;const x=o.get().subscriptions,I=this.outputs.threads.get().findMany(void 0,C??{},"desc",x),T=A.data;return{isLoading:!1,threads:I,hasFetchedAll:T.hasFetchedAll,isFetchingMore:T.isFetchingMore,fetchMoreError:T.fetchMoreError,fetchMore:T.fetchMore}}),no),waitUntilLoaded:E.waitUntilLoaded}})),s=new He((b=>{const[C,E]=JSON.parse(b),A=new qr((async x=>{const I=await this.#e[Oe].httpClient.getThreads({roomId:C,cursor:x,query:E});this.updateThreadifications(I.threads,I.inboxNotifications,I.subscriptions),this.permissionHints.update(I.permissionHints,I.requestedAt,[C]);const T=this.#n.get(C);return(T===void 0||T>I.requestedAt)&&this.#n.set(C,I.requestedAt),I.nextCursor}));return{signal:$e.from((()=>{const x=A.get();if(x.isLoading||x.error)return x;const I=o.get().subscriptions,T=this.outputs.threads.get().findMany(C,E??{},"asc",I),F=x.data;return{isLoading:!1,threads:T,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}}),no),waitUntilLoaded:A.waitUntilLoaded}})),a=new He((b=>{const C=JSON.parse(b),E=new qr((async x=>{const I=await this.#e.getInboxNotifications({cursor:x,query:C});return this.updateThreadifications(I.threads,I.inboxNotifications,I.subscriptions),this.#t===null&&(this.#t=I.requestedAt),I.nextCursor}));return{signal:$e.from((()=>{const x=E.get();if(x.isLoading||x.error)return x;const I=[];C!==void 0&&I.push((function(S){return k=>(function(_,M){return!(M.roomId!==void 0&&M.roomId!==_.roomId||M.kind!==void 0&&M.kind!==_.kind)})(k,S)})(C));const T=this.outputs.notifications.get().sortedNotifications.filter((S=>I.every((k=>k(S))))),F=x.data;return{isLoading:!1,inboxNotifications:T,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}}),no),waitUntilLoaded:E.waitUntilLoaded}})),u=new He((b=>{const C=JSON.parse(b),E=new Cr((async()=>{const A=await this.#e.getUnreadInboxNotificationsCount({query:C});this.unreadNotificationsCount.update(b,A)}));return{signal:$e.from((()=>{const A=E.get();return A.isLoading||A.error?A:rn("count",ye(this.unreadNotificationsCount.signal.get()[b]))}),lt),waitUntilLoaded:E.waitUntilLoaded}})),l=new He((b=>{const C=new Cr((async()=>{const E=this.#e.getRoom(b);if(E===null)throw new Error(`Room '${b}' is not available on client`);const A=await E.getSubscriptionSettings();this.roomSubscriptionSettings.update(b,A)}));return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:rn("settings",ye(this.roomSubscriptionSettings.signal.get()[b]))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),f=new He((b=>{const C=new Cr((async()=>{const E=this.#e.getRoom(b);if(E===null)throw new Error(`Room '${b}' is not available on client`);const A=await E[Oe].listHistoryVersions();this.historyVersions.update(b,A.versions);const x=this.#o.get(b);(x===void 0||x>A.requestedAt)&&this.#o.set(b,A.requestedAt)}));return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:rn("versions",Object.values(this.historyVersions.signal.get()[b]??{}))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),c={signal:$e.from((()=>{const b=this.#i.get();return b.isLoading||b.error?b:rn("settings",ye(this.notificationSettings.signal.get()))}),lt),waitUntilLoaded:this.#i.waitUntilLoaded},d=new He((b=>{const C=JSON.parse(b),E=new qr((async A=>(await this.#e[Oe].ai.getChats({cursor:A,query:C})).nextCursor));return{signal:$e.from((()=>{const A=E.get();return A.isLoading||A.error?A:{isLoading:!1,chats:this.#e[Oe].ai.queryChats(C),hasFetchedAll:A.data.hasFetchedAll,isFetchingMore:A.data.isFetchingMore,fetchMore:A.data.fetchMore,fetchMoreError:A.data.fetchMoreError}}),lt),waitUntilLoaded:E.waitUntilLoaded}})),h=new He((b=>{const C=new Cr((async()=>{await this.#e[Oe].ai.getMessageTree(b)}));return new He((E=>({signal:$e.from((()=>{const A=C.get();return A.isLoading||A.error?A:rn("messages",this.#e[Oe].ai.signals.getChatMessagesForBranchΣ(b,E??void 0).get())})),waitUntilLoaded:C.waitUntilLoaded})))})),g=new He((b=>{const C=new Cr((async()=>{await this.#e[Oe].ai.getOrCreateChat(b)}));return{signal:$e.from((()=>{if(this.#e[Oe].ai.getChatById(b)===void 0){const E=C.get();return E.isLoading||E.error?E:rn("chat",ye(this.#e[Oe].ai.getChatById(b)))}return rn("chat",ye(this.#e[Oe].ai.getChatById(b)))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),y=new He((b=>{const C=new Cr((async()=>{const E=await this.#e[Oe].httpClient.getUrlMetadata(b);this.urlsMetadata.update(b,E)}),!1);return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:rn("metadata",ye(this.urlsMetadata.signal.get()[b]))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),p=new He((b=>{const[C,E]=JSON.parse(b),A=new qr((async x=>{const I=this.#e.getRoom(C);if(I===null)throw new Error(`Room '${C}' is not available on client. Make sure you're calling useFeeds inside a RoomProvider.`);const T=await I.fetchFeeds({cursor:x,since:E?.since,metadata:E?.metadata,limit:E?.limit});return this.upsertFeeds(C,T.feeds),T.nextCursor??null}),{autoRetry:!1});return{signal:$e.from(A.signal,this.#s.signal,((x,I)=>{if(x.isLoading||x.error)return x;const T=this.#s.findMany(I,C,E),F=x.data;return{isLoading:!1,feeds:T,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}}),no),waitUntilLoaded:A.waitUntilLoaded}})),w=new He((b=>{const[C,E,A]=JSON.parse(b),x=new qr((async I=>{const T=this.#e.getRoom(C);if(T===null)throw new Error(`Room '${C}' is not available on client. Make sure you're calling useFeedMessages inside a RoomProvider.`);const F=await T.fetchFeedMessages(E,{cursor:I,limit:A?.limit});return this.upsertFeedMessages(C,E,F.messages),F.nextCursor??null}),{autoRetry:!1});return{signal:$e.from(x.signal,this.#u.signal,((I,T)=>{if(I.isLoading||I.error)return I;const F=this.#u.findMany(T,E),S=I.data;return{isLoading:!1,messages:F,hasFetchedAll:S.hasFetchedAll,isFetchingMore:S.isFetchingMore,fetchMoreError:S.fetchMoreError,fetchMore:S.fetchMore}}),no),waitUntilLoaded:x.waitUntilLoaded}}));this.outputs={threadifications:t,threads:n,loadingRoomThreads:s,loadingUserThreads:i,notifications:r,loadingNotifications:a,unreadNotificationsCount:u,roomSubscriptionSettingsByRoomId:l,versionsByRoomId:f,notificationSettings:c,threadSubscriptions:o,aiChats:d,messagesByChatId:h,aiChatById:g,urlMetadataByUrl:y,loadingFeeds:p,loadingFeedMessages:w},yc(this)}markInboxNotificationRead(e,t,n){Xe((()=>{this.optimisticUpdates.remove(n),this.notifications.markRead(e,t)}))}markAllInboxNotificationsRead(e,t){Xe((()=>{this.optimisticUpdates.remove(e),this.notifications.markAllRead(t)}))}deleteInboxNotification(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.notifications.delete(e)}))}deleteAllInboxNotifications(e){Xe((()=>{this.optimisticUpdates.remove(e),this.notifications.clear()}))}createSubscription(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.subscriptions.create(e)}))}deleteSubscription(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.subscriptions.delete(e)}))}createThread(e,t){Xe((()=>{this.optimisticUpdates.remove(e),this.threads.upsert(t)}))}#a(e,t,n,r){Xe((()=>{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,...pi(n)})),r)}addReaction(e,t,n,r,o){this.#a(e,t,(i=>md(i,n,r)),o)}removeReaction(e,t,n,r,o,i){this.#a(e,t,(s=>gd(s,n,r,o,i)),i)}deleteThread(e,t){return this.#a(e,t,(n=>({...n,updatedAt:new Date,deletedAt:new Date})))}createComment(e,t){Xe((()=>{this.optimisticUpdates.remove(t);const n=this.threads.get(e.threadId);n&&(this.threads.upsert(Go(n,e)),this.notifications.updateAssociatedNotification(e))}))}editComment(e,t,n){return this.#a(e,t,(r=>Go(r,n)))}editCommentMetadata(e,t,n,r,o){return this.#a(e,n,(i=>i.comments.find((s=>s.id===t))===void 0?i:{...i,updatedAt:o,comments:i.comments.map((s=>s.id===t?{...s,metadata:r}:s))}),o)}deleteComment(e,t,n,r){return this.#a(e,t,(o=>pd(o,n,r)),r)}updateThreadifications(e,t,n,r=[],o=[],i=[]){Xe((()=>{this.threads.applyDelta(e,r),this.notifications.applyDelta(t,o),this.subscriptions.applyDelta(n,i)}))}updateRoomSubscriptionSettings(e,t,n){Xe((()=>{this.optimisticUpdates.remove(t),this.roomSubscriptionSettings.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.subscriptions.updated,n.threads.deleted,n.inboxNotifications.deleted,n.subscriptions.deleted)}upsertFeeds(e,t){this.#s.upsert(e,t)}deleteFeed(e,t){this.#s.delete(e,t)}upsertFeedMessages(e,t,n){this.#u.upsert(t,n)}deleteFeedMessages(e,t,n){this.#u.delete(t,n)}async fetchUnreadNotificationsCount(e,t){const n=JSON.parse(e),r=await this.#e.getUnreadInboxNotificationsCount({query:n,signal:t});this.unreadNotificationsCount.update(e,r)}async fetchRoomThreadsDeltaUpdate(e,t){const n=this.#n.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.subscriptions.updated,r.threads.deleted,r.inboxNotifications.deleted,r.subscriptions.deleted),this.permissionHints.update(r.permissionHints,r.requestedAt),n<r.requestedAt&&this.#n.set(e,r.requestedAt)}async fetchUserThreadsDeltaUpdate(e){const t=this.#r;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.subscriptions.updated,n.threads.deleted,n.inboxNotifications.deleted,n.subscriptions.deleted),this.permissionHints.update(n.permissionHints,n.requestedAt)}async fetchRoomVersionsDeltaUpdate(e,t){const n=this.#o.get(e);if(n===void 0)return;const r=ye(this.#e.getRoom(e),`Room with id ${e} is not available on client`),o=await r[Oe].listHistoryVersionsSince({since:n,signal:t});this.historyVersions.update(e,o.versions),n<o.requestedAt&&this.#o.set(e,o.requestedAt)}async refreshRoomSubscriptionSettings(e,t){const n=ye(this.#e.getRoom(e),`Room with id ${e} is not available on client`),r=await n.getSubscriptionSettings({signal:t});this.roomSubscriptionSettings.update(e,r)}async refreshNotificationSettings(e){const t=await this.#e.getNotificationSettings({signal:e});this.notificationSettings.update(t)}updateNotificationSettings_confirmOptimisticUpdate(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.notificationSettings.update(e)}))}};function cy(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 Go(e,t){if(e.deletedAt!==void 0)return e;if(t.threadId!==e.id)return Zt.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){const r={...n,metadata:{...n.metadata,...t.metadata}},o=e.comments.map((i=>i.id===t.id?r:i));return{...e,comments:o}}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 pd(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 md(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:ly(i.reactions,n)}:i));return{...e,updatedAt:new Date(Math.max(n.createdAt.getTime(),e.updatedAt.getTime())),comments:o}}function gd(e,t,n,r,o){if(e.deletedAt!==void 0)return e;const i=e.comments.find((a=>a.id===t));if(i===void 0||i.deletedAt!==void 0)return e;const s=e.comments.map((a=>a.id===t?{...a,reactions:a.reactions.map((u=>u.emoji===n?{...u,users:u.users.filter((l=>l.id!==r))}:u)).filter((u=>u.users.length>0))}:a));return{...e,updatedAt:new Date(Math.max(o.getTime(),e.updatedAt.getTime())),comments:s}}function ly(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}function dy(e){return new Error(`resolveUsers didn't return anything for user '${e}'`)}function fy(e){return new Error(`resolveGroupsInfo didn't return anything for group '${e}'`)}function hy(e){return e}var vd=new WeakMap,yd=new WeakMap;function Np(e){let t=vd.get(e);return t||(t=new uy(e),vd.set(e,t)),t}function bc(e){let t=yd.get(e);return t||(t=(function(n){const r=Np(n),o=kr((async u=>{try{return await r.fetchNotificationsDeltaUpdate(u)}catch(l){throw Zt.warn(`Polling new inbox notifications failed: ${String(l)}`),l}}),Rt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.NOTIFICATIONS_MAX_STALE_TIME}),i=new He((u=>kr((async l=>{try{return await r.fetchUnreadNotificationsCount(u,l)}catch(f){throw Zt.warn(`Polling unread inbox notifications countfailed: ${String(f)}`),f}}),Rt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.NOTIFICATIONS_MAX_STALE_TIME}))),s=kr((async u=>{try{return await r.fetchUserThreadsDeltaUpdate(u)}catch(l){throw Zt.warn(`Polling new user threads failed: ${String(l)}`),l}}),Rt.USER_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Rt.USER_THREADS_MAX_STALE_TIME}),a=kr((async u=>{try{return await r.refreshNotificationSettings(u)}catch(l){throw Zt.warn(`Polling new notification settings failed: ${String(l)}`),l}}),Rt.USER_NOTIFICATION_SETTINGS_INTERVAL,{maxStaleTimeMs:Rt.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME});return{store:r,notificationsPoller:o,userThreadsPoller:s,notificationSettingsPoller:a,unreadNotificationsCountPollersByQueryKey:i}})(e),yd.set(e,t)),t}function py(e,t,n,r){const{store:o,notificationsPoller:i}=bc(e),s=Xt({});return m.useEffect((()=>{o.outputs.loadingNotifications.getOrCreate(s).waitUntilLoaded()})),m.useEffect((()=>(i.inc(),i.pollNowIfStale(),()=>{i.dec()})),[i]),Mo(o.outputs.loadingNotifications.getOrCreate(s).signal,t,n)}function my(e,t){const n=e[Oe].usersStore,r=m.useCallback((()=>n.getItemState(t)),[n,t]),o=m.useCallback((s=>(function(a,u){return a===void 0||a?.isLoading?a??{isLoading:!0}:a.error?a:a.data?{isLoading:!1,user:a.data}:{isLoading:!1,error:dy(u)}})(s,t)),[t]),i=Si(n.subscribe,r,r,o,lt);return m.useEffect((()=>{n.enqueue(t)})),i}function gy(e,t){const n=e[Oe].groupsInfoStore,r=m.useCallback((()=>n.getItemState(t)),[n,t]),o=m.useCallback((s=>(function(a,u){return a===void 0||a?.isLoading?a??{isLoading:!0}:a.error?a:a.data?{isLoading:!1,info:a.data}:{isLoading:!1,error:fy(u)}})(s,t)),[t]),i=Si(n.subscribe,r,r,o,lt);return m.useEffect((()=>{n.enqueue(t)})),i}function vy(e){return(function(t){const n=vc();if(!t?.allowNesting&&n!==null)throw new Error("You cannot nest multiple LiveblocksProvider instances in the same React tree.")})(e),v.jsx(_p.Provider,{value:e.client,children:e.children})}function xx(e){const{children:t,...n}=e,r={publicApiKey:nn(n.publicApiKey),throttle:nn(n.throttle),lostConnectionTimeout:nn(n.lostConnectionTimeout),backgroundKeepAliveTimeout:nn(n.backgroundKeepAliveTimeout),polyfills:nn(n.polyfills),preventUnsavedChanges:nn(n.preventUnsavedChanges),badgeLocation:nn(n.badgeLocation),authEndpoint:qo(n.authEndpoint),resolveMentionSuggestions:qo(n.resolveMentionSuggestions),resolveUsers:qo(n.resolveUsers),resolveRoomsInfo:qo(n.resolveRoomsInfo),resolveGroupsInfo:qo(n.resolveGroupsInfo),baseUrl:nn(n.baseUrl),enableDebugLogging:nn(n.enableDebugLogging)},o=m.useMemo((()=>Q1(r)),[]);return m.useEffect((()=>()=>{o[Oe].ai.disconnect()}),[o]),v.jsx(vy,{client:o,children:t})}function Ox(e){return py(Ve(),hy,lt)}function Sx(){return e=Ve(),m.useCallback((t=>{const{store:n,unreadNotificationsCountPollersByQueryKey:r}=bc(e),o=new Date,i=n.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:t,readAt:o});e.markInboxNotificationAsRead(t).then((()=>{n.markInboxNotificationRead(t,o,i);for(const s of r.values())s.markAsStale(),s.pollNowIfStale()}),(s=>{n.optimisticUpdates.remove(i),e[Oe].emitError({type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",inboxNotificationId:t},s)}))}),[e]);var e}function Cc(e){return gy(Ve(),e)}var Lp=function(e){return my(Ve(),e)},Ix=function(e={}){const t=Ve(),{store:n,userThreadsPoller:r}=bc(t),o=Xt(e.query??{});return m.useEffect((()=>{n.outputs.loadingUserThreads.getOrCreate(o).waitUntilLoaded()})),m.useEffect((()=>(r.inc(),r.pollNowIfStale(),()=>{r.dec()})),[r]),Mo(n.outputs.loadingUserThreads.getOrCreate(o).signal)};function yy(e,t){m.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((s=>s.comments)).some((s=>s.id===o))&&i.scrollIntoView()})(e,t)}),[t.isLoading])}function $s(e){const t=e[Oe].currentUserId.get();return t===void 0?"anonymous":t}var bd=new WeakMap;function Et(e){let t=bd.get(e);return t||(t=(function(n){const r=Np(n);function o(u,l,f){if(r.optimisticUpdates.remove(u),!(f instanceof _o))throw f;if(f.status===403){const c=[f.message,f.details?.suggestion,f.details?.docs].filter(Boolean).join(`
|
|
8
|
-
`);Zt.error(c)}n[Oe].emitError(l,f)}const i=new He((u=>kr((async l=>{try{return await r.fetchRoomThreadsDeltaUpdate(u,l)}catch(f){throw Zt.warn(`Polling new threads for '${u}' failed: ${String(f)}`),f}}),Rt.ROOM_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Rt.ROOM_THREADS_MAX_STALE_TIME}))),s=new He((u=>kr((async l=>{try{return await r.fetchRoomVersionsDeltaUpdate(u,l)}catch(f){throw Zt.warn(`Polling new history versions for '${u}' failed: ${String(f)}`),f}}),Rt.HISTORY_VERSIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.HISTORY_VERSIONS_MAX_STALE_TIME}))),a=new He((u=>kr((async l=>{try{return await r.refreshRoomSubscriptionSettings(u,l)}catch(f){throw Zt.warn(`Polling subscription settings for '${u}' failed: ${String(f)}`),f}}),Rt.ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL,{maxStaleTimeMs:Rt.ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME})));return{store:r,onMutationFailure:o,pollThreadsForRoomId:u=>{const l=i.getOrCreate(u);l&&(l.markAsStale(),l.pollNowIfStale())},getOrCreateThreadsPollerForRoomId:i.getOrCreate.bind(i),getOrCreateVersionsPollerForRoomId:s.getOrCreate.bind(s),getOrCreateSubscriptionSettingsPollerForRoomId:a.getOrCreate.bind(a)}})(e),bd.set(e,t)),t}function wo(e,t){return e.outputs.threads.get().getEvenIfDeleted(t)?.visibility}function by(e){const t=Ve(),{id:n,stableEnterRoom:r,BoundRoomContext:o}=e,i=nn({initialPresence:e.initialPresence,initialStorage:e.initialStorage,autoConnect:e.autoConnect??typeof window<"u"},n),[{room:s},a]=m.useState((()=>r(n,{...i,autoConnect:!1})));return m.useEffect((()=>{const{store:u}=Et(t);return s.events.comments.subscribe((l=>{(async function(f){if(f.type===xe.THREAD_DELETED)return void u.deleteThread(f.threadId,null);const c=await s.getThread(f.threadId);if(!c.thread)return void u.deleteThread(f.threadId,null);const{thread:d,inboxNotification:h,subscription:g}=c,y=u.outputs.threads.get().getEvenIfDeleted(f.threadId);switch(f.type){case xe.COMMENT_EDITED:case xe.THREAD_METADATA_UPDATED:case xe.THREAD_UPDATED:case xe.COMMENT_REACTION_ADDED:case xe.COMMENT_REACTION_REMOVED:case xe.COMMENT_DELETED:case xe.COMMENT_METADATA_UPDATED:if(!y)break;u.updateThreadifications([d],h?[h]:[],g?[g]:[]);break;case xe.COMMENT_CREATED:u.updateThreadifications([d],h?[h]:[],g?[g]:[])}})(l)}))}),[t,s]),m.useEffect((()=>{const{store:u}=Et(t);return s.events.feeds.subscribe((l=>{(function(f){switch(f.type){case xe.FEEDS_ADDED:case xe.FEEDS_UPDATED:u.upsertFeeds(s.id,f.feeds);break;case xe.FEED_DELETED:u.deleteFeed(s.id,f.feedId);break;case xe.FEED_MESSAGES_ADDED:case xe.FEED_MESSAGES_UPDATED:u.upsertFeedMessages(s.id,f.feedId,f.messages);break;case xe.FEED_MESSAGES_DELETED:u.deleteFeedMessages(s.id,f.feedId,f.messageIds)}})(l)}))}),[t,s]),m.useEffect((()=>{const u=r(n,i);a(u);const{room:l,leave:f}=u;return i.autoConnect&&l.connect(),()=>{f()}}),[n,i,r]),v.jsx(Vr.Provider,{value:s,children:o?v.jsx(o.Provider,{value:s,children:e.children}):e.children})}function Ii(e,t){const n=(function(r=Vr){return m.useContext(r)})(e);if(n===null&&!t?.allowOutsideRoom)throw new Error("RoomProvider is missing from the React tree.");return n}function wc(){return Ve()[Oe].resolveMentionSuggestions}function Cy(e,t={}){const{scrollOnLoad:n=!0}=t,r=Ve(),o=Ii(e),{store:i,getOrCreateThreadsPollerForRoomId:s}=Et(r),a=(u=o.id,l=t.query,Xt([u,l??{}]));var u,l;const f=s(o.id);m.useEffect((()=>{i.outputs.loadingRoomThreads.getOrCreate(a).waitUntilLoaded()})),m.useEffect((()=>(f.inc(),f.pollNowIfStale(),()=>f.dec())),[f]);const c=Mo(i.outputs.loadingRoomThreads.getOrCreate(a).signal);return yy(n,c),c}function Up(e){const t=Ve();return m.useCallback((n=>{const r=n.body,o=n.metadata??{},i=n.commentMetadata??{},s=n.attachments,a=n.visibility??"public",u=cp(),l=Ds(),f=new Date,c={id:l,threadId:u,roomId:e,createdAt:f,type:"comment",userId:$s(t),body:r,reactions:[],attachments:s??[],metadata:i},d={id:u,type:"thread",createdAt:f,updatedAt:f,roomId:e,metadata:o,comments:[c],resolved:!1,visibility:a},{store:h,onMutationFailure:g}=Et(t),y=h.optimisticUpdates.add({type:"create-thread",thread:d,roomId:e}),p=s?.map((w=>w.id));return t[Oe].httpClient.createThread({roomId:e,threadId:u,commentId:l,body:r,visibility:a,metadata:o,commentMetadata:i,attachmentIds:p}).then((w=>{h.createThread(y,w)}),(w=>g(y,{type:"CREATE_THREAD_ERROR",roomId:e,threadId:u,commentId:l,body:r,visibility:a,metadata:o,commentMetadata:i},w))),d}),[t,e])}function Hp(e){const t=Ve();return m.useCallback((n=>{const{threadId:r,body:o}=n,i=n.metadata??{},s=n.attachments??[],a=Ds(),u={id:a,threadId:r,roomId:e,type:"comment",createdAt:new Date,userId:$s(t),body:o,reactions:[],attachments:s??[],metadata:i},{store:l,onMutationFailure:f}=Et(t),c=l.optimisticUpdates.add({type:"create-comment",comment:u}),d=s?.map((h=>h.id));return t[Oe].httpClient.createComment({roomId:e,threadId:r,commentId:a,body:o,metadata:i,attachmentIds:d,visibility:wo(l,r)}).then((h=>{l.createComment(h,c)}),(h=>f(c,{type:"CREATE_COMMENT_ERROR",roomId:e,threadId:r,commentId:a,body:o,metadata:i},h))),u}),[t,e])}function Vp(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,body:o,attachments:i,metadata:s})=>{const a=new Date,{store:u,onMutationFailure:l}=Et(t),f=u.outputs.threads.get().getEvenIfDeleted(n);if(f===void 0)return void Zt.warn(`Internal unexpected behavior. Cannot edit comment in thread "${n}" because the thread does not exist in the cache.`);const c=f.comments.find((y=>y.id===r));if(c===void 0||c.deletedAt!==void 0)return void Zt.warn(`Internal unexpected behavior. Cannot edit comment "${r}" in thread "${n}" because the comment does not exist in the cache.`);const d=s!==void 0?{...c.metadata,...s}:c.metadata,h=u.optimisticUpdates.add({type:"edit-comment",comment:{...c,editedAt:a,body:o,attachments:i??[],metadata:d}}),g=i?.map((y=>y.id));t[Oe].httpClient.editComment({roomId:e,threadId:n,commentId:r,body:o,attachmentIds:g,metadata:s,visibility:f.visibility}).then((y=>{u.editComment(n,h,y)}),(y=>l(h,{type:"EDIT_COMMENT_ERROR",roomId:e,threadId:n,commentId:r,body:o,metadata:d},y)))}),[t,e])}function $p(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=new Date,s=$s(t),{store:a,onMutationFailure:u}=Et(t),l=a.optimisticUpdates.add({type:"add-reaction",threadId:n,commentId:r,reaction:{emoji:o,userId:s,createdAt:i}});t[Oe].httpClient.addReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:wo(a,n)}).then((f=>{a.addReaction(n,l,r,f,i)}),(f=>u(l,{type:"ADD_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},f)))}),[t,e])}function Wp(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=$s(t),s=new Date,{store:a,onMutationFailure:u}=Et(t),l=a.optimisticUpdates.add({type:"remove-reaction",threadId:n,commentId:r,emoji:o,userId:i,removedAt:s});t[Oe].httpClient.removeReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:wo(a,n)}).then((()=>{a.removeReaction(n,l,r,o,i,s)}),(f=>u(l,{type:"REMOVE_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},f)))}),[t,e])}function wy(e,t){const n=Ve(),{store:r}=Et(n),o=m.useMemo((()=>Br("thread",t)),[t]),i=(function(l){const f=Ve();return m.useCallback((c=>{const d=new Date,{store:h,onMutationFailure:g}=Et(f),y=h.optimisticUpdates.add({type:"subscribe-to-thread",threadId:c,subscribedAt:d});f[Oe].httpClient.subscribeToThread({roomId:l,threadId:c}).then((p=>{h.createSubscription(p,y)}),(p=>g(y,{type:"SUBSCRIBE_TO_THREAD_ERROR",roomId:l,threadId:c},p)))}),[f,l])})(e),s=(function(l){const f=Ve();return m.useCallback((c=>{const d=new Date,{store:h,onMutationFailure:g}=Et(f),y=h.optimisticUpdates.add({type:"unsubscribe-from-thread",threadId:c,unsubscribedAt:d});f[Oe].httpClient.unsubscribeFromThread({roomId:l,threadId:c}).then((()=>{h.deleteSubscription(Br("thread",c),y)}),(p=>g(y,{type:"UNSUBSCRIBE_FROM_THREAD_ERROR",roomId:l,threadId:c},p)))}),[f,l])})(e),a=m.useCallback((()=>i(t)),[i,t]),u=m.useCallback((()=>s(t)),[s,t]);return Mo(r.outputs.threadSubscriptions,m.useCallback((l=>{const f=l.subscriptions[o],c=l.notifications.find((d=>d.kind==="thread"&&d.threadId===t));return f===void 0?{status:"not-subscribed",subscribe:a,unsubscribe:u}:{status:"subscribed",unreadSince:c?.readAt??null,subscribe:a,unsubscribe:u}}),[o,t,a,u]),lt)}function Ey(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:(e.data,{isLoading:!1,url:e.data})}function Ws(e,t){const n=Ve()[Oe].httpClient.getOrCreateAttachmentUrlsStore(t),r=m.useCallback((()=>n.getItemState(e)),[n,e]);return m.useEffect((()=>{n.enqueue(e)}),[n,e]),Si(n.subscribe,r,r,Ey,lt)}function Ec(e,t,n){const r=(function(i){const s=Et(Ve()).store;return Mo(s.permissionHints.getPermissionForRoomΣ(i))?.permissions})(e),o=(function(i,s,a){const u=Ii(Vr,{allowOutsideRoom:!0}),l=m.useCallback((c=>u===null||u.id!==i?()=>{}:u.events.self.subscribe(c)),[u,i]),f=m.useCallback((()=>{const c=s==="comments"||s==="comments:public"||s==="comments:private";if(u?.id===i){const d=u[Oe].getPermissionMatrix();if(d!==void 0)return lr(d,s,a)}return!(!c&&s!=="storage")}),[s,a,u,i]);return m.useSyncExternalStore(l,f,f)})(e,t,n);return r!==void 0?lr(r,t,n):o}var Tx=function(e){const t=Ve(),[n]=m.useState((()=>new Map)),r=m.useCallback(((o,i)=>{const s=n.get(o);if(s)return s;const a=t.enterRoom(o,i),u=a.leave;return a.leave=()=>{u(),n.delete(o)},n.set(o,a),a}),[t,n]);return v.jsx(by,{...e,stableEnterRoom:r})},zp=function(e){return Ii(Vr,e)},kx=function(){return Up(Ii(Vr).id)},Bx=function(){return Hp(Ii(Vr).id)},Fx=function(e={}){return Cy(Vr,e)};oc("@liveblocks/react","3.24.0","esm");var xn=typeof window<"u"?m.useLayoutEffect:m.useEffect;function Dy(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:{isLoading:!1,group:e.data}}function Ay(e,t){const[n,r]=m.useState(),o=m.useRef(),i=wc(),s=Ve()[Oe].mentionSuggestionsCache;return m.useEffect((()=>{if(t===void 0||!i)return;const a={text:t,roomId:e},u=Xt(a);let l,f=!1;const c=async()=>{try{o.current=performance.now();const d=await i(a);if(!f){const h=d.map((g=>typeof g=="string"?{kind:"user",id:g}:g));r(h),s.set(u,h)}}catch(d){console.error(d?.message)}};if(s.has(u)){const d=s.get(u);r(d)}else!o.current||Math.abs(performance.now()-o.current)>500?c():l=window.setTimeout((()=>{c()}),500);return()=>{f=!0,window.clearTimeout(l)}}),[t,e,i,s]),n}function Ne(...e){return e.filter((t=>typeof t=="string"||typeof t=="number")).join(" ")}const Dc=m.forwardRef((({emoji:e,className:t,style:n,...r},o)=>v.jsx("span",{role:"img","aria-label":e,"data-emoji":e,className:Ne("lb-emoji",t),style:{...n,fontFamily:"'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif"},...r,ref:o,children:e})));var xy=Object.defineProperty,ba=(e,t)=>xy(e,"name",{value:t,configurable:!0});function gu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Kp(...e){return t=>{let n=!1;const r=e.map((o=>{const i=gu(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():gu(e[o],null)}}}}function Qe(...e){return m.useCallback(Kp(...e),e)}ba(gu,"setRef"),ba(Kp,"composeRefs"),ba(Qe,"useComposedRefs");var Oy=Object.defineProperty,an=(e,t)=>Oy(e,"name",{value:t,configurable:!0});function Vn(e){const t=m.forwardRef(((n,r)=>{let{children:o,...i}=n,s=null,a=!1;const u=[];vu(o)&&typeof Ki=="function"&&(o=Ki(o._payload)),m.Children.forEach(o,(d=>{if(Zp(d)){a=!0;const h=d;let g="child"in h.props?h.props.child:h.props.children;vu(g)&&typeof Ki=="function"&&(g=Ki(g._payload)),s=Iy(h,g),u.push(s?.props?.children)}else u.push(d)})),s?s=m.cloneElement(s,void 0,u):!a&&m.Children.count(o)===1&&m.isValidElement(o)&&(s=o);const l=s?Jp(s):void 0,f=Qe(r,l);if(!s){if(o||o===0)throw new Error(a?By(e):ky(e));return o}const c=Gp(i,s.props??{});return s.type!==m.Fragment&&(c.ref=r?f:l),m.cloneElement(s,c)}));return t.displayName=`${e}.Slot`,t}an(Vn,"createSlot");var vt=Vn("Slot"),qp=Symbol.for("radix.slottable");function Ac(e){const t=an((n=>"child"in n?n.children(n.child):n.children),"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=qp,t}an(Ac,"createSlottable");var Sy=Ac("Slottable"),Iy=an(((e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null}),"getSlottableElementFromSlottable");function Gp(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]=(...s)=>{const a=i(...s);return o(...s),a}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Jp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Zp(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qp}an(Gp,"mergeProps"),an(Jp,"getElementRef"),an(Zp,"isSlottable");var Ty=Symbol.for("react.lazy");function vu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ty&&"_payload"in e&&Xp(e._payload)}function Xp(e){return typeof e=="object"&&e!==null&&"then"in e}an(vu,"isLazyComponent"),an(Xp,"isPromiseLike");var ky=an((e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`),"createSlotError"),By=an((e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`),"createSlottableError"),Ki=Fo[" use ".trim().toString()],Fy=Object.defineProperty,$t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,t)=>{const n=Vn(`Primitive.${t}`),r=m.forwardRef(((o,i)=>{const{asChild:s,...a}=o,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...a,ref:i})}));return r.displayName=`Primitive.${t}`,{...e,[t]:r}}),{});function xc(e,t){e&&Oi.flushSync((()=>e.dispatchEvent(t)))}Fy(xc,"name",{value:"dispatchDiscreteCustomEvent",configurable:!0});var Ry=Object.defineProperty,_y=(e,t)=>Ry(e,"name",{value:t,configurable:!0}),jy=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),My=m.forwardRef(_y((function(e,t){return v.jsx($t.span,{...e,ref:t,style:{...jy,...e.style}})}),"VisuallyHidden")),Py=Object.defineProperty,Gt=(e,t)=>Py(e,"name",{value:t,configurable:!0});function qn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s);a.displayName=i+"Context";const u=n.length;n=[...n,s];const l=Gt((c=>{const{scope:d,children:h,...g}=c,y=d?.[e]?.[u]||a,p=m.useMemo((()=>g),Object.values(g));return v.jsx(y.Provider,{value:p,children:h})}),"Provider");function f(c,d,h={}){const{optional:g=!1}=h,y=d?.[e]?.[u]||a,p=m.useContext(y);if(p)return p;if(s!==void 0)return s;if(!g)throw new Error(`\`${c}\` must be used within \`${i}\``)}return l.displayName=i+"Provider",Gt(f,"useContext"),[l,f]}Gt(r,"createContext");const o=Gt((()=>{const i=n.map((s=>m.createContext(s)));return Gt((function(s){const a=s?.[e]||i;return m.useMemo((()=>({[`__scope${e}`]:{...s,[e]:a}})),[s,a])}),"useScope")}),"createScope");return o.scopeName=e,[r,Yp(o,...t)]}function Yp(...e){const t=e[0];if(e.length===1)return t;const n=Gt((()=>{const r=e.map((o=>({useScope:o(),scopeName:o.scopeName})));return Gt((function(o){const i=r.reduce(((s,{useScope:a,scopeName:u})=>({...s,...a(o)[`__scope${u}`]})),{});return m.useMemo((()=>({[`__scope${t.scopeName}`]:i})),[i])}),"useComposedScopes")}),"createScope");return n.scopeName=t.scopeName,n}Gt((function(e,t){const n=m.createContext(t);n.displayName=e+"Context";const r=Gt((i=>{const{children:s,...a}=i,u=m.useMemo((()=>a),Object.values(a));return v.jsx(n.Provider,{value:u,children:s})}),"Provider");function o(i,s={}){const{optional:a=!1}=s,u=m.useContext(n);if(u)return u;if(t!==void 0)return t;if(!a)throw new Error(`\`${i}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",Gt(o,"useContext"),[r,o]}),"createContext"),Gt(qn,"createContextScope"),Gt(Yp,"composeContextScopes");var Ny=Object.defineProperty,ct=(e,t)=>Ny(e,"name",{value:t,configurable:!0});function Oc(e){const t=e+"CollectionProvider",[n,r]=qn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=ct((y=>{const{scope:p,children:w}=y,b=m.useRef(null),C=m.useRef(new Map).current;return v.jsx(o,{scope:p,itemMap:C,collectionRef:b,children:w})}),"CollectionProvider");s.displayName=t;const a=e+"CollectionSlot",u=Vn(a),l=m.forwardRef(((y,p)=>{const{scope:w,children:b}=y,C=Qe(p,i(a,w).collectionRef);return v.jsx(u,{ref:C,children:b})}));l.displayName=a;const f=e+"CollectionItemSlot",c="data-radix-collection-item",d=Vn(f),h=m.forwardRef(((y,p)=>{const{scope:w,children:b,...C}=y,E=m.useRef(null),A=Qe(p,E),x=i(f,w);return m.useEffect((()=>(x.itemMap.set(E,{ref:E,...C}),()=>{x.itemMap.delete(E)}))),v.jsx(d,{[c]:"",ref:A,children:b})}));function g(y){const p=i(e+"CollectionConsumer",y);return m.useCallback((()=>{const w=p.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${c}]`));return Array.from(p.itemMap.values()).sort(((C,E)=>b.indexOf(C.ref.current)-b.indexOf(E.ref.current)))}),[p.collectionRef,p.itemMap])}return h.displayName=f,ct(g,"useCollection"),[{Provider:s,Slot:l,ItemSlot:h},g,r]}ct(Oc,"createCollection");var Cd=new WeakMap,it,Lt,Ca=(Lt=class extends Map{constructor(n){super(n);Tl(this,it);ra(this,it,[...super.keys()]),Cd.set(this,!0)}set(n,r){return Cd.get(this)&&(this.has(n)?bt(this,it)[bt(this,it).indexOf(n)]=n:bt(this,it).push(n)),super.set(n,r),this}insert(n,r,o){const i=this.has(r),s=bt(this,it).length,a=Sc(n);let u=a>=0?a:s+a;const l=u<0||u>=s?-1:u;if(l===this.size||i&&l===this.size-1||l===-1)return this.set(r,o),this;const f=this.size+(i?0:1);a<0&&u++;const c=[...bt(this,it)];let d,h=!1;for(let g=u;g<f;g++)if(u===g){let y=c[g];c[g]===r&&(y=c[g+1]),i&&this.delete(r),d=this.get(y),this.set(r,o)}else{h||c[g-1]!==r||(h=!0);const y=c[h?g:g-1],p=d;d=this.get(y),this.delete(y),this.set(y,p)}return this}with(n,r,o){const i=new Lt(this);return i.insert(n,r,o),i}before(n){const r=bt(this,it).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,o){const i=bt(this,it).indexOf(n);return i===-1?this:this.insert(i,r,o)}after(n){let r=bt(this,it).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,o){const i=bt(this,it).indexOf(n);return i===-1?this:this.insert(i+1,r,o)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ra(this,it,[]),super.clear()}delete(n){const r=super.delete(n);return r&&bt(this,it).splice(bt(this,it).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0&&this.delete(r)}at(n){const r=cs(bt(this,it),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=cs(bt(this,it),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return bt(this,it).indexOf(n)}keyAt(n){return cs(bt(this,it),n)}from(n,r){const o=this.indexOf(n);if(o===-1)return;let i=o+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(n,r){const o=this.indexOf(n);if(o===-1)return;let i=o+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return i;o++}}findIndex(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return o;o++}return-1}filter(n,r){const o=[];let i=0;for(const s of this)Reflect.apply(n,r,[s,i,this])&&o.push(s),i++;return new Lt(o)}map(n,r){const o=[];let i=0;for(const s of this)o.push([s[0],Reflect.apply(n,r,[s,i,this])]),i++;return new Lt(o)}reduce(...n){const[r,o]=n;let i=0,s=o??this.at(0);for(const a of this)s=i===0&&n.length===1?a:Reflect.apply(r,this,[s,a,i,this]),i++;return s}reduceRight(...n){const[r,o]=n;let i=o??this.at(-1);for(let s=this.size-1;s>=0;s--){const a=this.at(s);i=s===this.size-1&&n.length===1?a:Reflect.apply(r,this,[i,a,s,this])}return i}toSorted(n){const r=[...this.entries()].sort(n);return new Lt(r)}toReversed(){const n=new Lt;for(let r=this.size-1;r>=0;r--){const o=this.keyAt(r),i=this.get(o);n.set(o,i)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new Lt(r)}slice(n,r){const o=new Lt;let i=this.size-1;if(n===void 0)return o;n<0&&(n+=this.size),r!==void 0&&r>0&&(i=r-1);for(let s=n;s<=i;s++){const a=this.keyAt(s),u=this.get(a);o.set(a,u)}return o}every(n,r){let o=0;for(const i of this){if(!Reflect.apply(n,r,[i,o,this]))return!1;o++}return!0}some(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return!0;o++}return!1}},it=new WeakMap,ct(Lt,"OrderedDict"),Lt);function cs(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Qp(e,t);return n===-1?void 0:e[n]}function Qp(e,t){const n=e.length,r=Sc(t),o=r>=0?r:n+r;return o<0||o>=n?-1:o}function Sc(e){return e!=e||e===0?0:Math.trunc(e)}function wd(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||e[o]!==t[o])return!1;return!0}function em(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function wa(e,t){return e[1].element&&t[1].element?em(e[1].element,t[1].element)?-1:1:0}function Ed(e){return new MutationObserver((t=>{for(const n of t)if(n.type==="childList")return void e()}))}ct(cs,"at"),ct(Qp,"toSafeIndex"),ct(Sc,"toSafeInteger"),ct((function(e){const t=e+"CollectionProvider",[n,r]=qn(t),[o,i]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ca,setItemMap:ct((()=>{}),"setItemMap")}),s=ct((({state:b,...C})=>b?v.jsx(u,{...C,state:b}):v.jsx(a,{...C})),"CollectionProvider");s.displayName=t;const a=ct((b=>{const C=p();return v.jsx(u,{...b,state:C})}),"CollectionInit");a.displayName=t+"Init";const u=ct((b=>{const{scope:C,children:E,state:A}=b,x=m.useRef(null),[I,T]=m.useState(null),F=Qe(x,T),[S,k]=A;return m.useEffect((()=>{if(!I)return;const _=Ed((()=>{}));return _.observe(I,{childList:!0,subtree:!0}),()=>{_.disconnect()}}),[I]),v.jsx(o,{scope:C,itemMap:S,setItemMap:k,collectionRef:F,collectionRefObject:x,collectionElement:I,children:E})}),"CollectionProviderImpl");u.displayName=t+"Impl";const l=e+"CollectionSlot",f=Vn(l),c=m.forwardRef(((b,C)=>{const{scope:E,children:A}=b,x=Qe(C,i(l,E).collectionRef);return v.jsx(f,{ref:x,children:A})}));c.displayName=l;const d=e+"CollectionItemSlot",h="data-radix-collection-item",g=Vn(d),y=m.forwardRef(((b,C)=>{const{scope:E,children:A,...x}=b,I=m.useRef(null),[T,F]=m.useState(null),S=Qe(C,I,F),k=i(d,E),{setItemMap:_}=k,M=m.useRef(x);wd(M.current,x)||(M.current=x);const H=M.current;return m.useEffect((()=>{const W=H;return _((G=>T?G.has(T)?G.set(T,{...W,element:T}).toSorted(wa):(G.set(T,{...W,element:T}),G.toSorted(wa)):G)),()=>{_((G=>T&&G.has(T)?(G.delete(T),new Ca(G)):G))}}),[T,H,_]),v.jsx(g,{[h]:"",ref:S,children:A})}));function p(){return m.useState(new Ca)}function w(b){const{itemMap:C}=i(e+"CollectionConsumer",b);return C}return y.displayName=d,ct(p,"useInitCollection"),ct(w,"useCollection"),[{Provider:s,Slot:c,ItemSlot:y},{createCollectionScope:r,useCollection:w,useInitCollection:p}]}),"createCollection"),ct(wd,"shallowEqual"),ct(em,"isElementPreceding"),ct(wa,"sortByDocumentPosition"),ct(Ed,"getChildListObserver");var Ly=Object.defineProperty,oo=(e,t)=>Ly(e,"name",{value:t,configurable:!0}),tm=!(typeof window>"u"||!window.document||!window.document.createElement);function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return oo((function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}),"handleEvent")}function Ea(e){if(!tm)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}function Dd(e){return e.tagName==="IFRAME"}oo(Me,"composeEventHandlers"),oo((function(e){if(!tm)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}),"getOwnerWindow"),oo(Ea,"getOwnerDocument"),oo((function e(t,n=!1){const{activeElement:r}=Ea(t);if(!r?.nodeName)return null;if(Dd(r)&&r.contentDocument)return e(r.contentDocument.body,n);if(n){const o=r.getAttribute("aria-activedescendant");if(o){const i=Ea(r).getElementById(o);if(i)return i}}return r}),"getActiveElement"),oo(Dd,"isFrame");var Yt=globalThis?.document?m.useLayoutEffect:()=>{},Uy=Object.defineProperty,Ad=Fo[" useEffectEvent ".trim().toString()],xd=Fo[" useInsertionEffect ".trim().toString()];function nm(e){if(typeof Ad=="function")return Ad(e);const t=m.useRef((()=>{throw new Error("Cannot call an event handler while rendering.")}));return typeof xd=="function"?xd((()=>{t.current=e})):Yt((()=>{t.current=e})),m.useMemo((()=>(...n)=>t.current?.(...n)),[])}((e,t)=>{Uy(e,"name",{value:t,configurable:!0})})(nm,"useEffectEvent");var Hy=Object.defineProperty,oi=(e,t)=>Hy(e,"name",{value:t,configurable:!0}),Vy=Fo[" useInsertionEffect ".trim().toString()]||Yt;function Po({prop:e,defaultProp:t,onChange:n=oi((()=>{}),"onChange"),caller:r}){const[o,i,s]=rm({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:o,m.useCallback((u=>{if(a){const l=om(u)?u(e):u;l!==e&&s.current?.(l)}else i(u)}),[a,e,i,s])]}function rm({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),i=m.useRef(t);return Vy((()=>{i.current=t}),[t]),m.useEffect((()=>{o.current!==n&&(i.current?.(n),o.current=n)}),[n,o]),[n,r,i]}function om(e){return typeof e=="function"}oi(Po,"useControllableState"),oi(rm,"useUncontrolledState"),oi(om,"isFunction");var Od=Symbol("RADIX:SYNC_STATE");oi((function(e,t,n,r){const{prop:o,defaultProp:i,onChange:s,caller:a}=t,u=o!==void 0,l=nm(s),f=[{...n,state:i}];r&&f.push(r);const[c,d]=m.useReducer(((p,w)=>{if(w.type===Od)return{...p,state:w.state};const b=e(p,w);return u&&!Object.is(b.state,p.state)&&l(b.state),b}),...f),h=c.state,g=m.useRef(h);m.useEffect((()=>{g.current!==h&&(g.current=h,u||l(h))}),[h,g,u]);const y=m.useMemo((()=>o!==void 0?{...c,state:o}:c),[c,o]);return m.useEffect((()=>{u&&!Object.is(o,c.state)&&d({type:Od,state:o})}),[o,c.state,u]),[y,d]}),"useControllableStateReducer");var $y=Object.defineProperty,_n=(e,t)=>$y(e,"name",{value:t,configurable:!0});function im(e,t){return m.useReducer(((n,r)=>t[n][r]??n),e)}_n(im,"useStateMachine");var No=_n((e=>{const{present:t,children:n}=e,r=sm(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=am(r.ref,um(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null}),"Presence");function sm(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),i=m.useRef("none"),s=m.useRef(void 0),a=e?"mounted":"unmounted",[u,l]=im(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect((()=>{u==="mounted"?(i.current=s.current??io(r.current),s.current=void 0):i.current="none"}),[u]),Yt((()=>{const f=r.current,c=o.current;if(c!==e){const d=i.current,h=io(f);e?(s.current=h,l("MOUNT")):h==="none"||f?.display==="none"?l("UNMOUNT"):l(c&&d!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}}),[e,l]),Yt((()=>{if(t){let f;const c=t.ownerDocument.defaultView??window,d=_n((g=>{const y=io(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(l("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",f=c.setTimeout((()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)}))}}),"handleAnimationEnd"),h=_n((g=>{g.target===t&&(i.current=io(r.current))}),"handleAnimationStart");return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}l("ANIMATION_END")}),[t,l]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:m.useCallback((f=>{if(f){const c=getComputedStyle(f);r.current=c,s.current=io(c)}else r.current=null;n(f)}),[])}}function yu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function am(...e){const t=m.useRef(e);return t.current=e,m.useCallback((n=>{const r=t.current;let o=!1;const i=r.map((s=>{const a=yu(s,n);return o||typeof a!="function"||(o=!0),a}));if(o)return()=>{for(let s=0;s<i.length;s++){const a=i[s];typeof a=="function"?a():yu(r[s],null)}}}),[])}function io(e){return e?.animationName||"none"}function um(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}_n(sm,"usePresence"),_n(yu,"setRef"),_n(am,"useStableComposedRefs"),_n(io,"getAnimationName"),_n(um,"getElementRef");var Wy=Object.defineProperty,zy=Fo[" useId ".trim().toString()]||(()=>{}),Ky=0;function Eo(e){const[t,n]=m.useState(zy());return Yt((()=>{e||n((r=>r??String(Ky++)))}),[e]),e||(t?`radix-${t}`:"")}((e,t)=>{Wy(e,"name",{value:t,configurable:!0})})(Eo,"useId");var qy=Object.defineProperty,Gy=m.createContext(void 0);function Ic(e){const t=m.useContext(Gy);return e||t||"ltr"}((e,t)=>{qy(e,"name",{value:t,configurable:!0})})(Ic,"useDirection");var Jy=Object.defineProperty;function $n(e){const t=m.useRef(e);return m.useEffect((()=>{t.current=e})),m.useMemo((()=>(...n)=>t.current?.(...n)),[])}((e,t)=>{Jy(e,"name",{value:t,configurable:!0})})($n,"useCallbackRef");var Sd,Zy=Object.defineProperty,dt=(e,t)=>Zy(e,"name",{value:t,configurable:!0}),bu="dismissableLayer.update",cm=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Tc=m.forwardRef(dt((function(e,t){const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:a,onDismiss:u,...l}=e,f=m.useContext(cm),[c,d]=m.useState(null),h=c?.ownerDocument??globalThis?.document,[,g]=m.useState({}),y=Qe(t,d),p=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=w?p.indexOf(w):-1,C=c?p.indexOf(c):-1,E=f.layersWithOutsidePointerEventsDisabled.size>0,A=C>=b,x=m.useRef(!1),I=lm((k=>{i?.(k),a?.(k),k.defaultPrevented||u?.()}),{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:x,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback((k=>{if(!(k instanceof Node))return!1;const _=[...f.branches].some((M=>M.contains(k)));return A&&!_}),[f.branches,A])}),T=dm((k=>{if(r&&x.current)return;const _=k.target;[...f.branches].some((M=>M.contains(_)))||(s?.(k),a?.(k),k.defaultPrevented||u?.())}),h),F=!!c&&C===p.length-1,S=$n((k=>{k.key==="Escape"&&(o?.(k),!k.defaultPrevented&&u&&(k.preventDefault(),u()))}));return m.useEffect((()=>{if(F)return h.addEventListener("keydown",S,{capture:!0}),()=>h.removeEventListener("keydown",S,{capture:!0})}),[h,F,S]),m.useEffect((()=>{if(c)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Sd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(c)),f.layers.add(c),Cu(),()=>{n&&(f.layersWithOutsidePointerEventsDisabled.delete(c),f.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Sd))}}),[c,h,n,f]),m.useEffect((()=>()=>{c&&(f.layers.delete(c),f.layersWithOutsidePointerEventsDisabled.delete(c),Cu())}),[c,f]),m.useEffect((()=>{const k=dt((()=>g({})),"handleUpdate");return document.addEventListener(bu,k),()=>document.removeEventListener(bu,k)}),[]),v.jsx($t.div,{...l,ref:y,style:{pointerEvents:E?A?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,I.onPointerDownCapture)})}),"DismissableLayer"));dt((function(){const e=m.useContext(cm),[t,n]=m.useState(null);return m.useEffect((()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}}),[t,e.dismissableSurfaces]),n}),"useDismissableLayerSurface");var Xy=dt((()=>!0),"IS_TRUE");function lm(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:s=Xy}=t,a=$n(e),u=m.useRef(!1),l=m.useRef(!1),f=m.useRef(new Map),c=m.useRef((()=>{}));return m.useEffect((()=>{function d(){l.current=!1,o.current=!1,f.current.clear()}function h(){return Array.from(f.current.values()).some(Boolean)}function g(C){if(!l.current)return;const E=C.target;E instanceof Node&&[...i].some((A=>A.contains(E)))||f.current.set(C.type,!0),C.type==="click"&&window.setTimeout((()=>{l.current&&c.current()}),0)}function y(C){l.current&&f.current.set(C.type,!1)}dt(d,"resetOutsideInteraction"),dt(h,"isOutsideInteractionIntercepted"),dt(g,"handleInteractionCapture"),dt(y,"handleInteractionBubble");const p=dt((C=>{if(C.target&&!u.current){let E=function(){n.removeEventListener("click",c.current);const x=h();d(),x||kc("dismissableLayer.pointerDownOutside",a,A,{discrete:!0})};if(dt(E,"handleAndDispatchPointerDownOutsideEvent"),!s(C.target))return n.removeEventListener("click",c.current),d(),void(u.current=!1);const A={originalEvent:C};l.current=!0,o.current=r&&C.button===0,f.current.clear(),r&&C.button===0?(n.removeEventListener("click",c.current),c.current=E,n.addEventListener("click",c.current,{once:!0})):E()}else n.removeEventListener("click",c.current),d();u.current=!1}),"handlePointerDown"),w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const C of w)n.addEventListener(C,g,!0),n.addEventListener(C,y);const b=window.setTimeout((()=>{n.addEventListener("pointerdown",p)}),0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",p),n.removeEventListener("click",c.current);for(const C of w)n.removeEventListener(C,g,!0),n.removeEventListener(C,y)}}),[n,a,r,o,i,s]),{onPointerDownCapture:dt((()=>u.current=!0),"onPointerDownCapture")}}function dm(e,t=globalThis?.document){const n=$n(e),r=m.useRef(!1);return m.useEffect((()=>{const o=dt((i=>{i.target&&!r.current&&kc("dismissableLayer.focusOutside",n,{originalEvent:i},{discrete:!1})}),"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)}),[t,n]),{onFocusCapture:dt((()=>r.current=!0),"onFocusCapture"),onBlurCapture:dt((()=>r.current=!1),"onBlurCapture")}}function Cu(){const e=new CustomEvent(bu);document.dispatchEvent(e)}function kc(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?xc(o,i):o.dispatchEvent(i)}dt(lm,"usePointerDownOutside"),dt(dm,"useFocusOutside"),dt(Cu,"dispatchUpdate"),dt(kc,"handleAndDispatchCustomEvent");var Yy=Object.defineProperty,xt=(e,t)=>Yy(e,"name",{value:t,configurable:!0}),Da="focusScope.autoFocusOnMount",Aa="focusScope.autoFocusOnUnmount",Id={bubbles:!1,cancelable:!0},fm=m.forwardRef(xt((function(e,t){const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,u]=m.useState(null),l=$n(o),f=$n(i),c=m.useRef(null),d=Qe(t,u),h=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect((()=>{if(r){let y=function(C){if(h.paused||!a)return;const E=C.target;a.contains(E)?c.current=E:Rn(c.current,{select:!0})},p=function(C){if(h.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Rn(c.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const E of C)E.removedNodes.length>0&&Rn(a)};xt(y,"handleFocusIn"),xt(p,"handleFocusOut"),xt(w,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",p);const b=new MutationObserver(w);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",p),b.disconnect()}}}),[r,a,h.paused]),m.useEffect((()=>{if(a){Td.add(h);const y=document.activeElement;if(!a.contains(y)){const p=new CustomEvent(Da,Id);a.addEventListener(Da,l),a.dispatchEvent(p),p.defaultPrevented||(hm(ym(Bc(a)),{select:!0}),document.activeElement===y&&Rn(a))}return()=>{a.removeEventListener(Da,l),setTimeout((()=>{const p=new CustomEvent(Aa,Id);a.addEventListener(Aa,f),a.dispatchEvent(p),p.defaultPrevented||Rn(y??document.body,{select:!0}),a.removeEventListener(Aa,f),Td.remove(h)}),0)}}}),[a,l,f,h]);const g=m.useCallback((y=>{if(!n&&!r||h.paused)return;const p=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,w=document.activeElement;if(p&&w){const b=y.currentTarget,[C,E]=pm(b);C&&E?y.shiftKey||w!==E?y.shiftKey&&w===C&&(y.preventDefault(),n&&Rn(E,{select:!0})):(y.preventDefault(),n&&Rn(C,{select:!0})):w===b&&y.preventDefault()}}),[n,r,h.paused]);return v.jsx($t.div,{tabIndex:-1,...s,ref:d,onKeyDown:g})}),"FocusScope"));function hm(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Rn(r,{select:t}),document.activeElement!==n)return}function pm(e){const t=Bc(e);return[wu(t,e),wu(t.reverse(),e)]}function Bc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xt((r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}function wu(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):mm(r,{upTo:t})))return r}function mm(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gm(e){return e instanceof HTMLInputElement&&"select"in e}function Rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&gm(e)&&t&&e.select()}}xt(hm,"focusFirst"),xt(pm,"getTabbableEdges"),xt(Bc,"getTabbableCandidates"),xt(wu,"findVisible"),xt(mm,"isHidden"),xt(gm,"isSelectableInput"),xt(Rn,"focus");var Td=vm();function vm(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Eu(e,t),e.unshift(t)},remove(t){e=Eu(e,t),e[0]?.resume()}}}function Eu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ym(e){return e.filter((t=>t.tagName!=="A"))}xt(vm,"createFocusScopesStack"),xt(Eu,"arrayRemove"),xt(ym,"removeLinks");var Qy=Object.defineProperty,eb=(e,t)=>Qy(e,"name",{value:t,configurable:!0}),Fc=m.forwardRef(eb((function(e,t){const{container:n,...r}=e,[o,i]=m.useState(!1);Yt((()=>i(!0)),[]);const s=n||o&&globalThis?.document?.body;return s?Oi.createPortal(v.jsx($t.div,{...r,ref:t}),s):null}),"Portal")),tb=Object.defineProperty,xa=(e,t)=>tb(e,"name",{value:t,configurable:!0}),qi=0,Gr=null;function Ss(){m.useEffect((()=>{Gr||(Gr={start:Du(),end:Du()});const{start:e,end:t}=Gr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),qi++,()=>{qi===1&&(Gr?.start.remove(),Gr?.end.remove(),Gr=null),qi=Math.max(0,qi-1)}}),[])}function Du(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}xa((function(e){return Ss(),e.children}),"FocusGuards"),xa(Ss,"useFocusGuards"),xa(Du,"createFocusGuard");var wn=function(){return wn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},wn.apply(this,arguments)};function bm(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}var ls="right-scroll-bar-position",ds="width-before-scroll-bar";function Oa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}var nb=typeof window<"u"?m.useLayoutEffect:m.useEffect,kd=new WeakMap;function rb(e,t){var n,r,o,i=(n=null,r=function(s){return e.forEach((function(a){return Oa(a,s)}))},o=m.useState((function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(s){var a=o.value;a!==s&&(o.value=s,o.callback(s,a))}}}}))[0],o.callback=r,o.facade);return nb((function(){var s=kd.get(i);if(s){var a=new Set(s),u=new Set(e),l=i.current;a.forEach((function(f){u.has(f)||Oa(f,null)})),u.forEach((function(f){a.has(f)||Oa(f,l)}))}kd.set(i,e)}),[e]),i}function ob(e){return e}var Cm=function(e){var t=e.sideCar,n=bm(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,wn({},n))};Cm.isSideCarExport=!0;var wm=(function(e){e===void 0&&(e={});var t=(function(n,r){r===void 0&&(r=ob);var o=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return o.length?o[o.length-1]:n},useMedium:function(a){var u=r(a,i);return o.push(u),function(){o=o.filter((function(l){return l!==u}))}},assignSyncMedium:function(a){for(i=!0;o.length;){var u=o;o=[],u.forEach(a)}o={push:function(l){return a(l)},filter:function(){return o}}},assignMedium:function(a){i=!0;var u=[];if(o.length){var l=o;o=[],l.forEach(a),u=o}var f=function(){var d=u;u=[],d.forEach(a)},c=function(){return Promise.resolve().then(f)};c(),o={push:function(d){u.push(d),c()},filter:function(d){return u=u.filter(d),o}}}};return s})(null);return t.options=wn({async:!0,ssr:!1},e),t})(),Sa=function(){},Is=m.forwardRef((function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Sa,onWheelCapture:Sa,onTouchMoveCapture:Sa}),o=r[0],i=r[1],s=e.forwardProps,a=e.children,u=e.className,l=e.removeScrollBar,f=e.enabled,c=e.shards,d=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,p=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,C=e.gapMode,E=bm(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=d,x=rb([n,t]),I=wn(wn({},E),o);return m.createElement(m.Fragment,null,f&&m.createElement(A,{sideCar:wm,removeScrollBar:l,shards:c,noRelative:h,noIsolation:g,inert:y,setCallbacks:i,allowPinchZoom:!!p,lockRef:n,gapMode:C}),s?m.cloneElement(m.Children.only(a),wn(wn({},I),{ref:x})):m.createElement(b,wn({},I,{className:u,ref:x}),a))}));Is.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Is.classNames={fullWidth:ds,zeroRight:ls};function ib(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=(function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__})();return t&&e.setAttribute("nonce",t),e}var sb=function(){var e=0,t=null;return{add:function(n){var r,o;e==0&&(t=ib())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),(function(i){(document.head||document.getElementsByTagName("head")[0]).appendChild(i)})(t)),e++},remove:function(){!--e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Em=function(){var e,t=(e=sb(),function(n,r){m.useEffect((function(){return e.add(n),function(){e.remove()}}),[n&&r])});return function(n){var r=n.styles,o=n.dynamic;return t(r,o),null}},ab={left:0,top:0,right:0,gap:0},Ia=function(e){return parseInt(e||"",10)||0},ub=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ab;var t=(function(o){var i=window.getComputedStyle(document.body),s=i[o==="padding"?"paddingLeft":"marginLeft"],a=i[o==="padding"?"paddingTop":"marginTop"],u=i[o==="padding"?"paddingRight":"marginRight"];return[Ia(s),Ia(a),Ia(u)]})(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},cb=Em(),po="data-scroll-locked",lb=function(e,t,n,r){var o=e.left,i=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
7
|
+
`),logout:function(){a.reset(),s.set((()=>{}));for(const{room:k}of f.values())(S=k.getStatus())!=="initial"&&S!=="disconnected"&&k.reconnect();var S},getInboxNotifications:l.getInboxNotifications,getInboxNotificationsSince:l.getInboxNotificationsSince,getUnreadInboxNotificationsCount:l.getUnreadInboxNotificationsCount,markAllInboxNotificationsAsRead:l.markAllInboxNotificationsAsRead,markInboxNotificationAsRead:l.markInboxNotificationAsRead,deleteAllInboxNotifications:l.deleteAllInboxNotifications,deleteInboxNotification:l.deleteInboxNotification,getNotificationSettings:async function(S){return xs(await l.getNotificationSettings(S))},updateNotificationSettings:async function(S){return xs(await l.updateNotificationSettings(S))},resolvers:{invalidateUsers:function(S){g.invalidate(S)},invalidateRoomsInfo:function(S){p.invalidate(S)},invalidateGroupsInfo:function(S){b.invalidate(S)},invalidateMentionSuggestions:function(){C.clear()}},getSyncStatus:function(){const S=A.get();return S==="synchronizing"?S:"synchronized"},events:{error:x,syncStatus:A},[Oe]:{currentUserId:s,mentionSuggestionsCache:C,ai:c,resolveMentionSuggestions:t.resolveMentionSuggestions,usersStore:g,roomsInfoStore:p,groupsInfoStore:b,getRoomIds:()=>Array.from(f.keys()),httpClient:l,as:()=>F,createSyncSource:T,emitError:(S,k)=>{const _=pu.from(S,k);x.notify(_)||Un(_.message)}}},Oe,{enumerable:!1});return F}function mu(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 fd(e){if(e!==void 0)return mu("backgroundKeepAliveTimeout",e,15e3)}function Fp(e){return"type"in e&&e.type==="mention"}function Rp(e){return"type"in e&&e.type==="link"}new RegExp(Object.keys({"&":"&","<":"<",">":">",'"':""","'":"'"}).map((e=>`\\${e}`)).join("|"),"g");new RegExp(Object.keys({_:"\\_","*":"\\*","#":"\\#","`":"\\`","~":"\\~","!":"\\!","|":"\\|","(":"\\(",")":"\\)","{":"\\{","}":"\\}","[":"\\[","]":"\\]"}).map((e=>`\\${e}`)).join("|"),"g");var ya=[1e3,2e3,4e3,8e3,1e4];function kr(e,t,n){const r=performance.now(),o=typeof document<"u"?document:void 0,i=typeof window<"u"?window:void 0,s=n?.maxStaleTimeMs??Number.POSITIVE_INFINITY,a={inForeground:o?.visibilityState!=="hidden",lastSuccessfulPollAt:r,count:0,backoff:0};function u(){return a.count>0&&a.inForeground}const l=new hp({}).addState("@idle").addState("@enabled").addState("@polling");function f(){u()?l.send({type:"START"}):l.send({type:"STOP"})}function c(){performance.now()-a.lastSuccessfulPollAt>s&&l.send({type:"POLL"})}function d(g){a.inForeground=g,f(),c()}function h(){d(o?.visibilityState!=="hidden")}return l.addTransitions("@idle",{START:"@enabled"}),l.addTransitions("@enabled",{STOP:"@idle",POLL:"@polling"}),l.addTimedTransition("@enabled",(()=>{const g=a.lastSuccessfulPollAt+t;return Math.max(0,g-performance.now())+a.backoff}),"@polling"),l.onEnterAsync("@polling",(async(g,y)=>{await e(y),y.aborted||(a.lastSuccessfulPollAt=performance.now())}),(()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=0}})),(()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=ya.find((g=>g>a.backoff))??ya[ya.length-1]}})),3e4),o?.addEventListener("visibilitychange",h),i?.addEventListener("online",h),i?.addEventListener("focus",c),l.start(),{inc:function(){a.count++,f()},dec:function(){a.count--,a.count<0&&(a.count=0),f()},pollNowIfStale:c,markAsStale:function(){a.lastSuccessfulPollAt=performance.now()-s-1},setInForeground:d}}function Br(e,t){return typeof e=="string"?`${e}:${t}`:`${e.kind}:${e.subjectId}`}Kh("@liveblocks/core",Ls,"esm");var _p=m.createContext(null);function gc(){return m.useContext(_p)}function Ve(){return gc()??dn("LiveblocksProvider is missing from the React tree.")}var Vr=m.createContext(null);function Vs(e){const t=m.useRef(e);return m.useEffect((()=>{t.current=e}),[e]),t}function nn(e,t){return m.useMemo((()=>e),[t])}function qo(e,t){const n=nn(e,t),r=Vs(e),o=m.useCallback(((...i)=>r.current(...i)),[r]);return typeof n=="function"?o:n}function Si(e,t,n,r,o){const i=m.useRef(null);let s;i.current===null?(s={hasValue:!1,value:null},i.current=s):s=i.current;const[a,u]=m.useMemo((()=>{let f,c,d=!1;const h=y=>{if(!d){d=!0,f=y;const b=r(y);if(o!==void 0&&s.hasValue){const C=s.value;if(o(C,b))return c=C,C}return c=b,b}const p=c;if((function(b,C){return b===C&&(b!==0||1/b==1/C)||b!=b&&C!=C})(f,y))return p;const w=r(y);return o!==void 0&&o(p,w)?(f=y,p):(f=y,c=w,w)},g=n===void 0?null:n;return[()=>h(t()),g===null?void 0:()=>h(g())]}),[t,n,r,o]),l=m.useSyncExternalStore(e,a,u);return m.useEffect((()=>{s.hasValue=!0,s.value=l}),[l]),m.useDebugValue(l),l}m.memo((function(e){const t=m.useId(),n=Ve()[Oe].ai,{description:r,value:o,chatId:i}=e,[s,a]=m.useState();m.useEffect((()=>{const{layerKey:f,deregister:c}=n.registerKnowledgeLayer(t,i);return a(f),()=>{c(),a(void 0)}}),[n,t,i]);const u=m.useState(st)[0],l=e.id??u;return m.useEffect((()=>{s!==void 0&&n.updateKnowledge(s,{description:r,value:o},l,i)}),[n,s,l,r,o,i]),null})),m.memo((function({chatId:e,name:t,tool:n,enabled:r}){const o=Ve()[Oe].ai;return m.useEffect((()=>{const i=r!==void 0?{...n,enabled:r}:n;return o.registerTool(t,i,e)}),[o,e,t,n,r]),null}));var ey=e=>e;function Mo(e,t,n){if(e instanceof Ot)throw new Error("Using a mutable Signal with useSignal will likely not work as expected.");return Si(e.subscribe,e.get,e.get,t??ey,n)}var Rt={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,ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL:6e4,ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME:5e3,USER_NOTIFICATION_SETTINGS_INTERVAL:3e5,USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME:6e4},Os=Object.freeze({isLoading:!0}),jp=e=>Object.freeze({isLoading:!1,error:e});function rn(e,t){return arguments.length===1?Object.freeze({isLoading:!1,data:e}):Object.freeze({isLoading:!1,[e]:t})}function vc(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 ty(e,t){return n=>(function(r,o,i){let s;return i&&(s=i?.[Br("thread",r.id)]),(o.resolved===void 0||r.resolved===o.resolved)&&(o.visibility===void 0||r.visibility===o.visibility)&&(o.subscribed===void 0||o.subscribed===!0&&s!==void 0||o.subscribed===!1&&s===void 0)})(n,e,t)&&(function(r,o){const i=r.metadata;return o.metadata===void 0||Object.entries(o.metadata).every((([s,a])=>a===void 0||(function(u,l){return l===null?u===void 0:ou(l)?typeof u=="string"&&u.startsWith(l.startsWith):iu(l)?typeof u=="number"&&(function(f,c){return(c.lt===void 0||f<c.lt)&&(c.gt===void 0||f>c.gt)&&(c.lte===void 0||f<=c.lte)&&(c.gte===void 0||f>=c.gte)})(u,l):u===l})(i[s],a)))})(n,e)}var ny=class Mp{#e;#t;#n;signal;constructor(){this.#t=ir.from([],((t,n)=>{const r=t.createdAt,o=n.createdAt;return r<o||r===o&&t.id<n.id})),this.#n=ir.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 Ot(this)}clone(){const t=new Mp;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){Xe((()=>{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,o){const i=r==="desc"?this.#n:this.#t,s=[];return t!==void 0&&s.push((a=>a.roomId===t)),n!==void 0&&s.push(ty(n,o)),Array.from(i.filter((a=>s.every((u=>u(a))))))}};function Pp(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 ry=Promise.resolve(),qr=class{#e;signal;#t;#n;#r;constructor(e,t){this.#e=new Tt(Os),this.#t=e,this.#n=null,this.#r=t?.autoRetry??!0,this.signal=this.#e.asReadonly(),vc(this)}get(){return this.#e.get()}#o(e){const t=this.#e.get();t.data!==void 0&&this.#e.set(rn({...t.data,...e}))}async#i(){const e=this.#e.get();if(e.data?.cursor&&!e.data.isFetchingMore){this.#o({isFetchingMore:!0});try{const t=await this.#t(e.data.cursor);this.#n=null,this.#o({cursor:t,hasFetchedAll:t===null,fetchMoreError:void 0,isFetchingMore:!1})}catch(t){this.#n=null,this.#o({isFetchingMore:!1,fetchMoreError:t})}}}fetchMore(){return this.#e.get().data?.cursor?(this.#n||(this.#n=this.#i()),this.#n):ry}#s=null;waitUntilLoaded(){if(this.#s)return this.#s;const e=Pp(this.#r?ao((()=>this.#t(void 0)),5,[5e3,5e3,1e4,15e3]):Promise.resolve().then((()=>this.#t(void 0))));return e.then((t=>{this.#e.set(rn({cursor:t,hasFetchedAll:t===null,isFetchingMore:!1,fetchMoreError:void 0,fetchMore:this.fetchMore}))}),(t=>{this.#e.set(jp(t)),this.#r&&setTimeout((()=>{this.#s=null,this.#e.set(Os)}),5e3)})),this.#s=e,this.#s}},Cr=class{#e;signal;#t;#n=!0;constructor(e,t=!0){this.#e=new Tt(Os),this.signal=this.#e.asReadonly(),this.#t=e,this.#n=t,vc(this)}get(){return this.#e.get()}#r=null;waitUntilLoaded(){if(this.#r)return this.#r;const e=Pp(this.#n?ao((()=>this.#t()),5,[5e3,5e3,1e4,15e3]):this.#t());return e.then((()=>{this.#e.set(rn(void 0))}),(t=>{this.#e.set(jp(t)),this.#n&&setTimeout((()=>{this.#r=null,this.#e.set(Os)}),5e3)})),this.#r=e,e}};function oy(e,t){const n=new Ot(new Map);return{signal:$e.from(n,e,((r,o)=>(function(i,s,a){const u=Object.fromEntries(i);for(const l of a)if(l.type==="update-room-subscription-settings"){if(!l.settings.threads)continue;const f=s.findMany(l.roomId,void 0,"desc",void 0);for(const c of f){const d=Br("thread",c.id);switch(l.settings.threads){case"all":u[d]={kind:"thread",subjectId:c.id,createdAt:new Date};break;case"none":delete u[d];break;case"replies_and_mentions":break;default:Ye(l.settings.threads,"Unexpected thread subscription settings.")}}}return u})(r,t,o))),applyDelta:function(r,o){n.mutate((i=>{let s=!1;for(const a of r)i.set(Br(a),a),s=!0;for(const a of o)i.delete(Br(a)),s=!0;return s}))},create:function(r){n.mutate((o=>{o.set(Br(r),r)}))},delete:function(r){n.mutate((o=>{o.delete(r)}))}}}function iy(e){const t=new Ot(new Map);return{signal:$e.from(t,e,((n,r)=>(function(o,i){const s=Object.fromEntries(o);for(const a of i)switch(a.type){case"update-room-subscription-settings":{const u=s[a.roomId];if(u===void 0)break;s[a.roomId]={...u,...a.settings}}}return s})(n,r))),update:function(n,r){t.mutate((o=>{o.set(n,r)}))}}}function sy(e){const t=new Tt(xs({}));return{signal:$e.from(t,e,((n,r)=>(function(o,i){let s=o;for(const a of i)a.type==="update-notification-settings"&&(s=q1(s,a.settings));return s})(n,r))),update:function(n){t.set(n)}}}var ay=new Set(["mark-inbox-notification-as-read"]),uy=class{#e;threads;notifications;subscriptions;roomSubscriptionSettings;historyVersions;unreadNotificationsCount;urlsMetadata;permissionHints;notificationSettings;optimisticUpdates;outputs;#t=null;#n=new Map;#r=null;#o=new Map;#i;#s=(function(){const e=new Ot(new Map);return{signal:e,upsert:function(t,n){e.mutate((r=>{let o=r.get(t);o||(o=new Map,r.set(t,o));for(const i of n)o.set(i.feedId,i)}))},delete:function(t,n){e.mutate((r=>{r.get(t)?.delete(n)}))},findMany:function(t,n,r){const o=Array.from(t.get(n)?.values()??[]).filter((i=>{if(r?.since!==void 0&&i.updatedAt<r.since&&i.createdAt<r.since)return!1;if(r?.metadata!==void 0){const s=i.metadata;if(!Object.entries(r.metadata).every((([a,u])=>s[a]===u)))return!1}return!0}));return o.sort(((i,s)=>{const a=i.createdAt-s.createdAt;return a!==0?a:i.feedId<s.feedId?-1:i.feedId>s.feedId?1:0})),o}}})();#u=(function(){const e=new Ot(new Map);return{signal:e,upsert:function(t,n){e.mutate((r=>{let o=r.get(t);o||(o=new Map,r.set(t,o));for(const i of n)o.set(i.id,i)}))},delete:function(t,n){e.mutate((r=>{const o=r.get(t);if(o)for(const i of n)o.delete(i)}))},findMany:function(t,n){return Array.from(t.get(n)?.values()??[]).sort(((r,o)=>r.createdAt-o.createdAt))}}})();constructor(e){this.#e=e[Oe].as(),this.optimisticUpdates=(function(b){const C=new Tt([]),E=b[Oe].createSyncSource();return C.subscribe((()=>E.setSyncStatus(C.get().some((A=>!ay.has(A.type)))?"synchronizing":"synchronized"))),{signal:C.asReadonly(),add:function(A){const x=st(),I={...A,id:x};return C.set((T=>[...T,I])),x},remove:function(A){C.set((x=>x.filter((I=>I.id!==A))))}}})(this.#e),this.permissionHints=(function(){const b=new He((()=>new Tt(void 0)));return{getPermissionForRoomΣ:function(C){return b.getOrCreate(C)},update:function(C,E,A){Xe((()=>{const x=A===void 0?Object.keys(C):new Set([...A,...Object.keys(C)]);for(const I of x){const T=b.getOrCreate(I),F=T.get();F!==void 0&&F.requestedAt>E||T.set({requestedAt:E,permissions:cc(C[I]??[])})}}))}}})(),this.notificationSettings=sy(this.optimisticUpdates.signal),this.#i=new Cr((async()=>{const b=await this.#e.getNotificationSettings();this.notificationSettings.update(b)})),this.threads=new ny,this.subscriptions=oy(this.optimisticUpdates.signal,this.threads),this.notifications=(function(){const b=new Ot(new Map);return{signal:b.asReadonly(),markAllRead:function(C){b.mutate((E=>{for(const A of E.values())A.readAt=C}))},markRead:function(C,E){b.mutate((A=>{const x=A.get(C);return!!x&&(A.set(C,{...x,readAt:E}),!0)}))},delete:function(C){b.mutate((E=>E.delete(C)))},applyDelta:function(C,E){b.mutate((A=>{let x=!1;for(const I of C){const T=A.get(I.id);T&&cy(T,I)===1||(A.set(I.id,I),x=!0)}for(const I of E)A.delete(I.id),x=!0;return x}))},clear:function(){b.mutate((C=>C.clear()))},updateAssociatedNotification:function(C){b.mutate((E=>{const A=(function(x,I){for(const T of x)if(I(T))return T})(E.values(),(x=>x.kind==="thread"&&x.threadId===C.threadId));return!!A&&(E.set(A.id,{...A,notifiedAt:C.createdAt,readAt:C.createdAt}),!0)}))},upsert:function(C){b.mutate((E=>{E.set(C.id,C)}))}}})(),this.roomSubscriptionSettings=iy(this.optimisticUpdates.signal),this.historyVersions=(function(){const b=new Ot(new He((()=>new Map)));return{signal:$e.from(b,(C=>Object.fromEntries([...C].map((([E,A])=>[E,Object.fromEntries(A)]))))),update:function(C,E){b.mutate((A=>{const x=A.getOrCreate(C);for(const I of E)x.set(I.id,I)}))}}})(),this.unreadNotificationsCount=(function(){const b=new Ot(new Map);return{signal:$e.from(b,(C=>Object.fromEntries(C))),update:function(C,E){b.mutate((A=>{A.set(C,E)}))}}})(),this.urlsMetadata=(function(){const b=new Ot(new Map);return{signal:$e.from(b,(C=>Object.fromEntries(C))),update:function(C,E){b.mutate((A=>{A.set(C,E)}))}}})();const t=$e.from(this.threads.signal,this.notifications.signal,this.optimisticUpdates.signal,((b,C,E)=>(function(A,x,I){const T=A.clone();let F=Object.fromEntries(x);for(const S of I)switch(S.type){case"create-thread":T.upsert(S.thread);break;case"edit-thread-metadata":{const k=T.get(S.threadId);if(k===void 0||k.updatedAt>S.updatedAt)break;T.upsert({...k,updatedAt:S.updatedAt,metadata:{...k.metadata,...S.metadata}});break}case"mark-thread-as-resolved":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,resolved:!0});break}case"mark-thread-as-unresolved":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,resolved:!1});break}case"create-comment":{const k=T.get(S.comment.threadId);if(k===void 0)break;T.upsert(Go(k,S.comment));const _=Object.values(F).find((M=>M.kind==="thread"&&M.threadId===k.id));if(_===void 0)break;F[_.id]={..._,notifiedAt:S.comment.createdAt,readAt:S.comment.createdAt};break}case"edit-comment":{const k=T.get(S.comment.threadId);if(k===void 0)break;T.upsert(Go(k,S.comment));break}case"edit-comment-metadata":{const k=T.get(S.threadId);if(k===void 0||k.updatedAt>S.updatedAt)break;const _=k.comments.find((M=>M.id===S.commentId));if(_===void 0)break;T.upsert(Go(k,{..._,metadata:{..._.metadata,...S.metadata}}));break}case"delete-comment":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(hd(k,S.commentId,S.deletedAt));break}case"delete-thread":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,deletedAt:S.deletedAt,updatedAt:S.deletedAt,comments:[]});break}case"add-reaction":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(pd(k,S.commentId,S.reaction));break}case"remove-reaction":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(md(k,S.commentId,S.emoji,S.userId,S.removedAt));break}case"mark-inbox-notification-as-read":{const k=F[S.inboxNotificationId];if(k===void 0)break;F[S.inboxNotificationId]={...k,readAt:S.readAt};break}case"mark-all-inbox-notifications-as-read":for(const k in F){const _=F[k];if(_===void 0)break;F[k]={..._,readAt:S.readAt}}break;case"delete-inbox-notification":delete F[S.inboxNotificationId];break;case"delete-all-inbox-notifications":F={}}return{sortedNotifications:Object.values(F).filter((S=>S.kind!=="thread"||T.get(S.threadId)!==void 0)).sort(((S,k)=>k.notifiedAt.getTime()-S.notifiedAt.getTime())),notificationsById:F,threadsDB:T}})(b,C,E))),n=$e.from(t,(b=>b.threadsDB)),r=$e.from(t,(b=>({sortedNotifications:b.sortedNotifications,notificationsById:b.notificationsById})),lt),o=$e.from(r,this.subscriptions.signal,((b,C)=>({subscriptions:C,notifications:b.sortedNotifications}))),i=new He((b=>{const C=JSON.parse(b),E=new qr((async A=>{const x=await this.#e[Oe].httpClient.getUserThreads_experimental({cursor:A,query:C});return this.updateThreadifications(x.threads,x.inboxNotifications,x.subscriptions),this.permissionHints.update(x.permissionHints,x.requestedAt),this.#r===null&&(this.#r=x.requestedAt),x.nextCursor}));return{signal:$e.from((()=>{const A=E.get();if(A.isLoading||A.error)return A;const x=o.get().subscriptions,I=this.outputs.threads.get().findMany(void 0,C??{},"desc",x),T=A.data;return{isLoading:!1,threads:I,hasFetchedAll:T.hasFetchedAll,isFetchingMore:T.isFetchingMore,fetchMoreError:T.fetchMoreError,fetchMore:T.fetchMore}}),no),waitUntilLoaded:E.waitUntilLoaded}})),s=new He((b=>{const[C,E]=JSON.parse(b),A=new qr((async x=>{const I=await this.#e[Oe].httpClient.getThreads({roomId:C,cursor:x,query:E});this.updateThreadifications(I.threads,I.inboxNotifications,I.subscriptions),this.permissionHints.update(I.permissionHints,I.requestedAt,[C]);const T=this.#n.get(C);return(T===void 0||T>I.requestedAt)&&this.#n.set(C,I.requestedAt),I.nextCursor}));return{signal:$e.from((()=>{const x=A.get();if(x.isLoading||x.error)return x;const I=o.get().subscriptions,T=this.outputs.threads.get().findMany(C,E??{},"asc",I),F=x.data;return{isLoading:!1,threads:T,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}}),no),waitUntilLoaded:A.waitUntilLoaded}})),a=new He((b=>{const C=JSON.parse(b),E=new qr((async x=>{const I=await this.#e.getInboxNotifications({cursor:x,query:C});return this.updateThreadifications(I.threads,I.inboxNotifications,I.subscriptions),this.#t===null&&(this.#t=I.requestedAt),I.nextCursor}));return{signal:$e.from((()=>{const x=E.get();if(x.isLoading||x.error)return x;const I=[];C!==void 0&&I.push((function(S){return k=>(function(_,M){return!(M.roomId!==void 0&&M.roomId!==_.roomId||M.kind!==void 0&&M.kind!==_.kind)})(k,S)})(C));const T=this.outputs.notifications.get().sortedNotifications.filter((S=>I.every((k=>k(S))))),F=x.data;return{isLoading:!1,inboxNotifications:T,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}}),no),waitUntilLoaded:E.waitUntilLoaded}})),u=new He((b=>{const C=JSON.parse(b),E=new Cr((async()=>{const A=await this.#e.getUnreadInboxNotificationsCount({query:C});this.unreadNotificationsCount.update(b,A)}));return{signal:$e.from((()=>{const A=E.get();return A.isLoading||A.error?A:rn("count",ye(this.unreadNotificationsCount.signal.get()[b]))}),lt),waitUntilLoaded:E.waitUntilLoaded}})),l=new He((b=>{const C=new Cr((async()=>{const E=this.#e.getRoom(b);if(E===null)throw new Error(`Room '${b}' is not available on client`);const A=await E.getSubscriptionSettings();this.roomSubscriptionSettings.update(b,A)}));return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:rn("settings",ye(this.roomSubscriptionSettings.signal.get()[b]))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),f=new He((b=>{const C=new Cr((async()=>{const E=this.#e.getRoom(b);if(E===null)throw new Error(`Room '${b}' is not available on client`);const A=await E[Oe].listHistoryVersions();this.historyVersions.update(b,A.versions);const x=this.#o.get(b);(x===void 0||x>A.requestedAt)&&this.#o.set(b,A.requestedAt)}));return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:rn("versions",Object.values(this.historyVersions.signal.get()[b]??{}))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),c={signal:$e.from((()=>{const b=this.#i.get();return b.isLoading||b.error?b:rn("settings",ye(this.notificationSettings.signal.get()))}),lt),waitUntilLoaded:this.#i.waitUntilLoaded},d=new He((b=>{const C=JSON.parse(b),E=new qr((async A=>(await this.#e[Oe].ai.getChats({cursor:A,query:C})).nextCursor));return{signal:$e.from((()=>{const A=E.get();return A.isLoading||A.error?A:{isLoading:!1,chats:this.#e[Oe].ai.queryChats(C),hasFetchedAll:A.data.hasFetchedAll,isFetchingMore:A.data.isFetchingMore,fetchMore:A.data.fetchMore,fetchMoreError:A.data.fetchMoreError}}),lt),waitUntilLoaded:E.waitUntilLoaded}})),h=new He((b=>{const C=new Cr((async()=>{await this.#e[Oe].ai.getMessageTree(b)}));return new He((E=>({signal:$e.from((()=>{const A=C.get();return A.isLoading||A.error?A:rn("messages",this.#e[Oe].ai.signals.getChatMessagesForBranchΣ(b,E??void 0).get())})),waitUntilLoaded:C.waitUntilLoaded})))})),g=new He((b=>{const C=new Cr((async()=>{await this.#e[Oe].ai.getOrCreateChat(b)}));return{signal:$e.from((()=>{if(this.#e[Oe].ai.getChatById(b)===void 0){const E=C.get();return E.isLoading||E.error?E:rn("chat",ye(this.#e[Oe].ai.getChatById(b)))}return rn("chat",ye(this.#e[Oe].ai.getChatById(b)))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),y=new He((b=>{const C=new Cr((async()=>{const E=await this.#e[Oe].httpClient.getUrlMetadata(b);this.urlsMetadata.update(b,E)}),!1);return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:rn("metadata",ye(this.urlsMetadata.signal.get()[b]))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),p=new He((b=>{const[C,E]=JSON.parse(b),A=new qr((async x=>{const I=this.#e.getRoom(C);if(I===null)throw new Error(`Room '${C}' is not available on client. Make sure you're calling useFeeds inside a RoomProvider.`);const T=await I.fetchFeeds({cursor:x,since:E?.since,metadata:E?.metadata,limit:E?.limit});return this.upsertFeeds(C,T.feeds),T.nextCursor??null}),{autoRetry:!1});return{signal:$e.from(A.signal,this.#s.signal,((x,I)=>{if(x.isLoading||x.error)return x;const T=this.#s.findMany(I,C,E),F=x.data;return{isLoading:!1,feeds:T,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}}),no),waitUntilLoaded:A.waitUntilLoaded}})),w=new He((b=>{const[C,E,A]=JSON.parse(b),x=new qr((async I=>{const T=this.#e.getRoom(C);if(T===null)throw new Error(`Room '${C}' is not available on client. Make sure you're calling useFeedMessages inside a RoomProvider.`);const F=await T.fetchFeedMessages(E,{cursor:I,limit:A?.limit});return this.upsertFeedMessages(C,E,F.messages),F.nextCursor??null}),{autoRetry:!1});return{signal:$e.from(x.signal,this.#u.signal,((I,T)=>{if(I.isLoading||I.error)return I;const F=this.#u.findMany(T,E),S=I.data;return{isLoading:!1,messages:F,hasFetchedAll:S.hasFetchedAll,isFetchingMore:S.isFetchingMore,fetchMoreError:S.fetchMoreError,fetchMore:S.fetchMore}}),no),waitUntilLoaded:x.waitUntilLoaded}}));this.outputs={threadifications:t,threads:n,loadingRoomThreads:s,loadingUserThreads:i,notifications:r,loadingNotifications:a,unreadNotificationsCount:u,roomSubscriptionSettingsByRoomId:l,versionsByRoomId:f,notificationSettings:c,threadSubscriptions:o,aiChats:d,messagesByChatId:h,aiChatById:g,urlMetadataByUrl:y,loadingFeeds:p,loadingFeedMessages:w},vc(this)}markInboxNotificationRead(e,t,n){Xe((()=>{this.optimisticUpdates.remove(n),this.notifications.markRead(e,t)}))}markAllInboxNotificationsRead(e,t){Xe((()=>{this.optimisticUpdates.remove(e),this.notifications.markAllRead(t)}))}deleteInboxNotification(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.notifications.delete(e)}))}deleteAllInboxNotifications(e){Xe((()=>{this.optimisticUpdates.remove(e),this.notifications.clear()}))}createSubscription(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.subscriptions.create(e)}))}deleteSubscription(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.subscriptions.delete(e)}))}createThread(e,t){Xe((()=>{this.optimisticUpdates.remove(e),this.threads.upsert(t)}))}#a(e,t,n,r){Xe((()=>{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,...pi(n)})),r)}addReaction(e,t,n,r,o){this.#a(e,t,(i=>pd(i,n,r)),o)}removeReaction(e,t,n,r,o,i){this.#a(e,t,(s=>md(s,n,r,o,i)),i)}deleteThread(e,t){return this.#a(e,t,(n=>({...n,updatedAt:new Date,deletedAt:new Date})))}createComment(e,t){Xe((()=>{this.optimisticUpdates.remove(t);const n=this.threads.get(e.threadId);n&&(this.threads.upsert(Go(n,e)),this.notifications.updateAssociatedNotification(e))}))}editComment(e,t,n){return this.#a(e,t,(r=>Go(r,n)))}editCommentMetadata(e,t,n,r,o){return this.#a(e,n,(i=>i.comments.find((s=>s.id===t))===void 0?i:{...i,updatedAt:o,comments:i.comments.map((s=>s.id===t?{...s,metadata:r}:s))}),o)}deleteComment(e,t,n,r){return this.#a(e,t,(o=>hd(o,n,r)),r)}updateThreadifications(e,t,n,r=[],o=[],i=[]){Xe((()=>{this.threads.applyDelta(e,r),this.notifications.applyDelta(t,o),this.subscriptions.applyDelta(n,i)}))}updateRoomSubscriptionSettings(e,t,n){Xe((()=>{this.optimisticUpdates.remove(t),this.roomSubscriptionSettings.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.subscriptions.updated,n.threads.deleted,n.inboxNotifications.deleted,n.subscriptions.deleted)}upsertFeeds(e,t){this.#s.upsert(e,t)}deleteFeed(e,t){this.#s.delete(e,t)}upsertFeedMessages(e,t,n){this.#u.upsert(t,n)}deleteFeedMessages(e,t,n){this.#u.delete(t,n)}async fetchUnreadNotificationsCount(e,t){const n=JSON.parse(e),r=await this.#e.getUnreadInboxNotificationsCount({query:n,signal:t});this.unreadNotificationsCount.update(e,r)}async fetchRoomThreadsDeltaUpdate(e,t){const n=this.#n.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.subscriptions.updated,r.threads.deleted,r.inboxNotifications.deleted,r.subscriptions.deleted),this.permissionHints.update(r.permissionHints,r.requestedAt),n<r.requestedAt&&this.#n.set(e,r.requestedAt)}async fetchUserThreadsDeltaUpdate(e){const t=this.#r;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.subscriptions.updated,n.threads.deleted,n.inboxNotifications.deleted,n.subscriptions.deleted),this.permissionHints.update(n.permissionHints,n.requestedAt)}async fetchRoomVersionsDeltaUpdate(e,t){const n=this.#o.get(e);if(n===void 0)return;const r=ye(this.#e.getRoom(e),`Room with id ${e} is not available on client`),o=await r[Oe].listHistoryVersionsSince({since:n,signal:t});this.historyVersions.update(e,o.versions),n<o.requestedAt&&this.#o.set(e,o.requestedAt)}async refreshRoomSubscriptionSettings(e,t){const n=ye(this.#e.getRoom(e),`Room with id ${e} is not available on client`),r=await n.getSubscriptionSettings({signal:t});this.roomSubscriptionSettings.update(e,r)}async refreshNotificationSettings(e){const t=await this.#e.getNotificationSettings({signal:e});this.notificationSettings.update(t)}updateNotificationSettings_confirmOptimisticUpdate(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.notificationSettings.update(e)}))}};function cy(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 Go(e,t){if(e.deletedAt!==void 0)return e;if(t.threadId!==e.id)return Zt.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){const r={...n,metadata:{...n.metadata,...t.metadata}},o=e.comments.map((i=>i.id===t.id?r:i));return{...e,comments:o}}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 hd(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 pd(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:ly(i.reactions,n)}:i));return{...e,updatedAt:new Date(Math.max(n.createdAt.getTime(),e.updatedAt.getTime())),comments:o}}function md(e,t,n,r,o){if(e.deletedAt!==void 0)return e;const i=e.comments.find((a=>a.id===t));if(i===void 0||i.deletedAt!==void 0)return e;const s=e.comments.map((a=>a.id===t?{...a,reactions:a.reactions.map((u=>u.emoji===n?{...u,users:u.users.filter((l=>l.id!==r))}:u)).filter((u=>u.users.length>0))}:a));return{...e,updatedAt:new Date(Math.max(o.getTime(),e.updatedAt.getTime())),comments:s}}function ly(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}function dy(e){return new Error(`resolveUsers didn't return anything for user '${e}'`)}function fy(e){return new Error(`resolveGroupsInfo didn't return anything for group '${e}'`)}function hy(e){return e}var gd=new WeakMap,vd=new WeakMap;function Np(e){let t=gd.get(e);return t||(t=new uy(e),gd.set(e,t)),t}function yc(e){let t=vd.get(e);return t||(t=(function(n){const r=Np(n),o=kr((async u=>{try{return await r.fetchNotificationsDeltaUpdate(u)}catch(l){throw Zt.warn(`Polling new inbox notifications failed: ${String(l)}`),l}}),Rt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.NOTIFICATIONS_MAX_STALE_TIME}),i=new He((u=>kr((async l=>{try{return await r.fetchUnreadNotificationsCount(u,l)}catch(f){throw Zt.warn(`Polling unread inbox notifications countfailed: ${String(f)}`),f}}),Rt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.NOTIFICATIONS_MAX_STALE_TIME}))),s=kr((async u=>{try{return await r.fetchUserThreadsDeltaUpdate(u)}catch(l){throw Zt.warn(`Polling new user threads failed: ${String(l)}`),l}}),Rt.USER_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Rt.USER_THREADS_MAX_STALE_TIME}),a=kr((async u=>{try{return await r.refreshNotificationSettings(u)}catch(l){throw Zt.warn(`Polling new notification settings failed: ${String(l)}`),l}}),Rt.USER_NOTIFICATION_SETTINGS_INTERVAL,{maxStaleTimeMs:Rt.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME});return{store:r,notificationsPoller:o,userThreadsPoller:s,notificationSettingsPoller:a,unreadNotificationsCountPollersByQueryKey:i}})(e),vd.set(e,t)),t}function py(e,t,n,r){const{store:o,notificationsPoller:i}=yc(e),s=Xt({});return m.useEffect((()=>{o.outputs.loadingNotifications.getOrCreate(s).waitUntilLoaded()})),m.useEffect((()=>(i.inc(),i.pollNowIfStale(),()=>{i.dec()})),[i]),Mo(o.outputs.loadingNotifications.getOrCreate(s).signal,t,n)}function my(e,t){const n=e[Oe].usersStore,r=m.useCallback((()=>n.getItemState(t)),[n,t]),o=m.useCallback((s=>(function(a,u){return a===void 0||a?.isLoading?a??{isLoading:!0}:a.error?a:a.data?{isLoading:!1,user:a.data}:{isLoading:!1,error:dy(u)}})(s,t)),[t]),i=Si(n.subscribe,r,r,o,lt);return m.useEffect((()=>{n.enqueue(t)})),i}function gy(e,t){const n=e[Oe].groupsInfoStore,r=m.useCallback((()=>n.getItemState(t)),[n,t]),o=m.useCallback((s=>(function(a,u){return a===void 0||a?.isLoading?a??{isLoading:!0}:a.error?a:a.data?{isLoading:!1,info:a.data}:{isLoading:!1,error:fy(u)}})(s,t)),[t]),i=Si(n.subscribe,r,r,o,lt);return m.useEffect((()=>{n.enqueue(t)})),i}function vy(e){return(function(t){const n=gc();if(!t?.allowNesting&&n!==null)throw new Error("You cannot nest multiple LiveblocksProvider instances in the same React tree.")})(e),v.jsx(_p.Provider,{value:e.client,children:e.children})}function xx(e){const{children:t,...n}=e,r={publicApiKey:nn(n.publicApiKey),throttle:nn(n.throttle),lostConnectionTimeout:nn(n.lostConnectionTimeout),backgroundKeepAliveTimeout:nn(n.backgroundKeepAliveTimeout),polyfills:nn(n.polyfills),preventUnsavedChanges:nn(n.preventUnsavedChanges),badgeLocation:nn(n.badgeLocation),authEndpoint:qo(n.authEndpoint),resolveMentionSuggestions:qo(n.resolveMentionSuggestions),resolveUsers:qo(n.resolveUsers),resolveRoomsInfo:qo(n.resolveRoomsInfo),resolveGroupsInfo:qo(n.resolveGroupsInfo),baseUrl:nn(n.baseUrl),enableDebugLogging:nn(n.enableDebugLogging)},o=m.useMemo((()=>Q1(r)),[]);return m.useEffect((()=>()=>{o[Oe].ai.disconnect()}),[o]),v.jsx(vy,{client:o,children:t})}function Ox(e){return py(Ve(),hy,lt)}function Sx(){return e=Ve(),m.useCallback((t=>{const{store:n,unreadNotificationsCountPollersByQueryKey:r}=yc(e),o=new Date,i=n.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:t,readAt:o});e.markInboxNotificationAsRead(t).then((()=>{n.markInboxNotificationRead(t,o,i);for(const s of r.values())s.markAsStale(),s.pollNowIfStale()}),(s=>{n.optimisticUpdates.remove(i),e[Oe].emitError({type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",inboxNotificationId:t},s)}))}),[e]);var e}function bc(e){return gy(Ve(),e)}var Lp=function(e){return my(Ve(),e)},Ix=function(e={}){const t=Ve(),{store:n,userThreadsPoller:r}=yc(t),o=Xt(e.query??{});return m.useEffect((()=>{n.outputs.loadingUserThreads.getOrCreate(o).waitUntilLoaded()})),m.useEffect((()=>(r.inc(),r.pollNowIfStale(),()=>{r.dec()})),[r]),Mo(n.outputs.loadingUserThreads.getOrCreate(o).signal)};function yy(e,t){m.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((s=>s.comments)).some((s=>s.id===o))&&i.scrollIntoView()})(e,t)}),[t.isLoading])}function $s(e){const t=e[Oe].currentUserId.get();return t===void 0?"anonymous":t}var yd=new WeakMap;function Et(e){let t=yd.get(e);return t||(t=(function(n){const r=Np(n);function o(u,l,f){if(r.optimisticUpdates.remove(u),!(f instanceof _o))throw f;if(f.status===403){const c=[f.message,f.details?.suggestion,f.details?.docs].filter(Boolean).join(`
|
|
8
|
+
`);Zt.error(c)}n[Oe].emitError(l,f)}const i=new He((u=>kr((async l=>{try{return await r.fetchRoomThreadsDeltaUpdate(u,l)}catch(f){throw Zt.warn(`Polling new threads for '${u}' failed: ${String(f)}`),f}}),Rt.ROOM_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Rt.ROOM_THREADS_MAX_STALE_TIME}))),s=new He((u=>kr((async l=>{try{return await r.fetchRoomVersionsDeltaUpdate(u,l)}catch(f){throw Zt.warn(`Polling new history versions for '${u}' failed: ${String(f)}`),f}}),Rt.HISTORY_VERSIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.HISTORY_VERSIONS_MAX_STALE_TIME}))),a=new He((u=>kr((async l=>{try{return await r.refreshRoomSubscriptionSettings(u,l)}catch(f){throw Zt.warn(`Polling subscription settings for '${u}' failed: ${String(f)}`),f}}),Rt.ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL,{maxStaleTimeMs:Rt.ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME})));return{store:r,onMutationFailure:o,pollThreadsForRoomId:u=>{const l=i.getOrCreate(u);l&&(l.markAsStale(),l.pollNowIfStale())},getOrCreateThreadsPollerForRoomId:i.getOrCreate.bind(i),getOrCreateVersionsPollerForRoomId:s.getOrCreate.bind(s),getOrCreateSubscriptionSettingsPollerForRoomId:a.getOrCreate.bind(a)}})(e),yd.set(e,t)),t}function wo(e,t){return e.outputs.threads.get().getEvenIfDeleted(t)?.visibility}function by(e){const t=Ve(),{id:n,stableEnterRoom:r,BoundRoomContext:o}=e,i=nn({initialPresence:e.initialPresence,initialStorage:e.initialStorage,autoConnect:e.autoConnect??typeof window<"u"},n),[{room:s},a]=m.useState((()=>r(n,{...i,autoConnect:!1})));return m.useEffect((()=>{const{store:u}=Et(t);return s.events.comments.subscribe((l=>{(async function(f){if(f.type===xe.THREAD_DELETED)return void u.deleteThread(f.threadId,null);const c=await s.getThread(f.threadId);if(!c.thread)return void u.deleteThread(f.threadId,null);const{thread:d,inboxNotification:h,subscription:g}=c,y=u.outputs.threads.get().getEvenIfDeleted(f.threadId);switch(f.type){case xe.COMMENT_EDITED:case xe.THREAD_METADATA_UPDATED:case xe.THREAD_UPDATED:case xe.COMMENT_REACTION_ADDED:case xe.COMMENT_REACTION_REMOVED:case xe.COMMENT_DELETED:case xe.COMMENT_METADATA_UPDATED:if(!y)break;u.updateThreadifications([d],h?[h]:[],g?[g]:[]);break;case xe.COMMENT_CREATED:u.updateThreadifications([d],h?[h]:[],g?[g]:[])}})(l)}))}),[t,s]),m.useEffect((()=>{const{store:u}=Et(t);return s.events.feeds.subscribe((l=>{(function(f){switch(f.type){case xe.FEEDS_ADDED:case xe.FEEDS_UPDATED:u.upsertFeeds(s.id,f.feeds);break;case xe.FEED_DELETED:u.deleteFeed(s.id,f.feedId);break;case xe.FEED_MESSAGES_ADDED:case xe.FEED_MESSAGES_UPDATED:u.upsertFeedMessages(s.id,f.feedId,f.messages);break;case xe.FEED_MESSAGES_DELETED:u.deleteFeedMessages(s.id,f.feedId,f.messageIds)}})(l)}))}),[t,s]),m.useEffect((()=>{const u=r(n,i);a(u);const{room:l,leave:f}=u;return i.autoConnect&&l.connect(),()=>{f()}}),[n,i,r]),v.jsx(Vr.Provider,{value:s,children:o?v.jsx(o.Provider,{value:s,children:e.children}):e.children})}function Ii(e,t){const n=(function(r=Vr){return m.useContext(r)})(e);if(n===null&&!t?.allowOutsideRoom)throw new Error("RoomProvider is missing from the React tree.");return n}function Cc(){return Ve()[Oe].resolveMentionSuggestions}function Cy(e,t={}){const{scrollOnLoad:n=!0}=t,r=Ve(),o=Ii(e),{store:i,getOrCreateThreadsPollerForRoomId:s}=Et(r),a=(u=o.id,l=t.query,Xt([u,l??{}]));var u,l;const f=s(o.id);m.useEffect((()=>{i.outputs.loadingRoomThreads.getOrCreate(a).waitUntilLoaded()})),m.useEffect((()=>(f.inc(),f.pollNowIfStale(),()=>f.dec())),[f]);const c=Mo(i.outputs.loadingRoomThreads.getOrCreate(a).signal);return yy(n,c),c}function Up(e){const t=Ve();return m.useCallback((n=>{const r=n.body,o=n.metadata??{},i=n.commentMetadata??{},s=n.attachments,a=n.visibility??"public",u=cp(),l=Ds(),f=new Date,c={id:l,threadId:u,roomId:e,createdAt:f,type:"comment",userId:$s(t),body:r,reactions:[],attachments:s??[],metadata:i},d={id:u,type:"thread",createdAt:f,updatedAt:f,roomId:e,metadata:o,comments:[c],resolved:!1,visibility:a},{store:h,onMutationFailure:g}=Et(t),y=h.optimisticUpdates.add({type:"create-thread",thread:d,roomId:e}),p=s?.map((w=>w.id));return t[Oe].httpClient.createThread({roomId:e,threadId:u,commentId:l,body:r,visibility:a,metadata:o,commentMetadata:i,attachmentIds:p}).then((w=>{h.createThread(y,w)}),(w=>g(y,{type:"CREATE_THREAD_ERROR",roomId:e,threadId:u,commentId:l,body:r,visibility:a,metadata:o,commentMetadata:i},w))),d}),[t,e])}function Hp(e){const t=Ve();return m.useCallback((n=>{const{threadId:r,body:o}=n,i=n.metadata??{},s=n.attachments??[],a=Ds(),u={id:a,threadId:r,roomId:e,type:"comment",createdAt:new Date,userId:$s(t),body:o,reactions:[],attachments:s??[],metadata:i},{store:l,onMutationFailure:f}=Et(t),c=l.optimisticUpdates.add({type:"create-comment",comment:u}),d=s?.map((h=>h.id));return t[Oe].httpClient.createComment({roomId:e,threadId:r,commentId:a,body:o,metadata:i,attachmentIds:d,visibility:wo(l,r)}).then((h=>{l.createComment(h,c)}),(h=>f(c,{type:"CREATE_COMMENT_ERROR",roomId:e,threadId:r,commentId:a,body:o,metadata:i},h))),u}),[t,e])}function Vp(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,body:o,attachments:i,metadata:s})=>{const a=new Date,{store:u,onMutationFailure:l}=Et(t),f=u.outputs.threads.get().getEvenIfDeleted(n);if(f===void 0)return void Zt.warn(`Internal unexpected behavior. Cannot edit comment in thread "${n}" because the thread does not exist in the cache.`);const c=f.comments.find((y=>y.id===r));if(c===void 0||c.deletedAt!==void 0)return void Zt.warn(`Internal unexpected behavior. Cannot edit comment "${r}" in thread "${n}" because the comment does not exist in the cache.`);const d=s!==void 0?{...c.metadata,...s}:c.metadata,h=u.optimisticUpdates.add({type:"edit-comment",comment:{...c,editedAt:a,body:o,attachments:i??[],metadata:d}}),g=i?.map((y=>y.id));t[Oe].httpClient.editComment({roomId:e,threadId:n,commentId:r,body:o,attachmentIds:g,metadata:s,visibility:f.visibility}).then((y=>{u.editComment(n,h,y)}),(y=>l(h,{type:"EDIT_COMMENT_ERROR",roomId:e,threadId:n,commentId:r,body:o,metadata:d},y)))}),[t,e])}function $p(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=new Date,s=$s(t),{store:a,onMutationFailure:u}=Et(t),l=a.optimisticUpdates.add({type:"add-reaction",threadId:n,commentId:r,reaction:{emoji:o,userId:s,createdAt:i}});t[Oe].httpClient.addReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:wo(a,n)}).then((f=>{a.addReaction(n,l,r,f,i)}),(f=>u(l,{type:"ADD_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},f)))}),[t,e])}function Wp(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=$s(t),s=new Date,{store:a,onMutationFailure:u}=Et(t),l=a.optimisticUpdates.add({type:"remove-reaction",threadId:n,commentId:r,emoji:o,userId:i,removedAt:s});t[Oe].httpClient.removeReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:wo(a,n)}).then((()=>{a.removeReaction(n,l,r,o,i,s)}),(f=>u(l,{type:"REMOVE_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},f)))}),[t,e])}function wy(e,t){const n=Ve(),{store:r}=Et(n),o=m.useMemo((()=>Br("thread",t)),[t]),i=(function(l){const f=Ve();return m.useCallback((c=>{const d=new Date,{store:h,onMutationFailure:g}=Et(f),y=h.optimisticUpdates.add({type:"subscribe-to-thread",threadId:c,subscribedAt:d});f[Oe].httpClient.subscribeToThread({roomId:l,threadId:c}).then((p=>{h.createSubscription(p,y)}),(p=>g(y,{type:"SUBSCRIBE_TO_THREAD_ERROR",roomId:l,threadId:c},p)))}),[f,l])})(e),s=(function(l){const f=Ve();return m.useCallback((c=>{const d=new Date,{store:h,onMutationFailure:g}=Et(f),y=h.optimisticUpdates.add({type:"unsubscribe-from-thread",threadId:c,unsubscribedAt:d});f[Oe].httpClient.unsubscribeFromThread({roomId:l,threadId:c}).then((()=>{h.deleteSubscription(Br("thread",c),y)}),(p=>g(y,{type:"UNSUBSCRIBE_FROM_THREAD_ERROR",roomId:l,threadId:c},p)))}),[f,l])})(e),a=m.useCallback((()=>i(t)),[i,t]),u=m.useCallback((()=>s(t)),[s,t]);return Mo(r.outputs.threadSubscriptions,m.useCallback((l=>{const f=l.subscriptions[o],c=l.notifications.find((d=>d.kind==="thread"&&d.threadId===t));return f===void 0?{status:"not-subscribed",subscribe:a,unsubscribe:u}:{status:"subscribed",unreadSince:c?.readAt??null,subscribe:a,unsubscribe:u}}),[o,t,a,u]),lt)}function Ey(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:(e.data,{isLoading:!1,url:e.data})}function Ws(e,t){const n=Ve()[Oe].httpClient.getOrCreateAttachmentUrlsStore(t),r=m.useCallback((()=>n.getItemState(e)),[n,e]);return m.useEffect((()=>{n.enqueue(e)}),[n,e]),Si(n.subscribe,r,r,Ey,lt)}function wc(e,t,n){const r=(function(i){const s=Et(Ve()).store;return Mo(s.permissionHints.getPermissionForRoomΣ(i))?.permissions})(e),o=(function(i,s,a){const u=Ii(Vr,{allowOutsideRoom:!0}),l=m.useCallback((c=>u===null||u.id!==i?()=>{}:u.events.self.subscribe(c)),[u,i]),f=m.useCallback((()=>{const c=s==="comments"||s==="comments:public"||s==="comments:private";if(u?.id===i){const d=u[Oe].getPermissionMatrix();if(d!==void 0)return lr(d,s,a)}return!(!c&&s!=="storage")}),[s,a,u,i]);return m.useSyncExternalStore(l,f,f)})(e,t,n);return r!==void 0?lr(r,t,n):o}var Tx=function(e){const t=Ve(),[n]=m.useState((()=>new Map)),r=m.useCallback(((o,i)=>{const s=n.get(o);if(s)return s;const a=t.enterRoom(o,i),u=a.leave;return a.leave=()=>{u(),n.delete(o)},n.set(o,a),a}),[t,n]);return v.jsx(by,{...e,stableEnterRoom:r})},zp=function(e){return Ii(Vr,e)},kx=function(){return Up(Ii(Vr).id)},Bx=function(){return Hp(Ii(Vr).id)},Fx=function(e={}){return Cy(Vr,e)};Kh("@liveblocks/react","3.24.0","esm");var xn=typeof window<"u"?m.useLayoutEffect:m.useEffect;function Dy(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:{isLoading:!1,group:e.data}}function Ay(e,t){const[n,r]=m.useState(),o=m.useRef(),i=Cc(),s=Ve()[Oe].mentionSuggestionsCache;return m.useEffect((()=>{if(t===void 0||!i)return;const a={text:t,roomId:e},u=Xt(a);let l,f=!1;const c=async()=>{try{o.current=performance.now();const d=await i(a);if(!f){const h=d.map((g=>typeof g=="string"?{kind:"user",id:g}:g));r(h),s.set(u,h)}}catch(d){console.error(d?.message)}};if(s.has(u)){const d=s.get(u);r(d)}else!o.current||Math.abs(performance.now()-o.current)>500?c():l=window.setTimeout((()=>{c()}),500);return()=>{f=!0,window.clearTimeout(l)}}),[t,e,i,s]),n}function Ne(...e){return e.filter((t=>typeof t=="string"||typeof t=="number")).join(" ")}const Ec=m.forwardRef((({emoji:e,className:t,style:n,...r},o)=>v.jsx("span",{role:"img","aria-label":e,"data-emoji":e,className:Ne("lb-emoji",t),style:{...n,fontFamily:"'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif"},...r,ref:o,children:e})));var xy=Object.defineProperty,ba=(e,t)=>xy(e,"name",{value:t,configurable:!0});function gu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Kp(...e){return t=>{let n=!1;const r=e.map((o=>{const i=gu(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():gu(e[o],null)}}}}function Qe(...e){return m.useCallback(Kp(...e),e)}ba(gu,"setRef"),ba(Kp,"composeRefs"),ba(Qe,"useComposedRefs");var Oy=Object.defineProperty,an=(e,t)=>Oy(e,"name",{value:t,configurable:!0});function Vn(e){const t=m.forwardRef(((n,r)=>{let{children:o,...i}=n,s=null,a=!1;const u=[];vu(o)&&typeof Ki=="function"&&(o=Ki(o._payload)),m.Children.forEach(o,(d=>{if(Zp(d)){a=!0;const h=d;let g="child"in h.props?h.props.child:h.props.children;vu(g)&&typeof Ki=="function"&&(g=Ki(g._payload)),s=Iy(h,g),u.push(s?.props?.children)}else u.push(d)})),s?s=m.cloneElement(s,void 0,u):!a&&m.Children.count(o)===1&&m.isValidElement(o)&&(s=o);const l=s?Jp(s):void 0,f=Qe(r,l);if(!s){if(o||o===0)throw new Error(a?By(e):ky(e));return o}const c=Gp(i,s.props??{});return s.type!==m.Fragment&&(c.ref=r?f:l),m.cloneElement(s,c)}));return t.displayName=`${e}.Slot`,t}an(Vn,"createSlot");var vt=Vn("Slot"),qp=Symbol.for("radix.slottable");function Dc(e){const t=an((n=>"child"in n?n.children(n.child):n.children),"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=qp,t}an(Dc,"createSlottable");var Sy=Dc("Slottable"),Iy=an(((e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null}),"getSlottableElementFromSlottable");function Gp(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]=(...s)=>{const a=i(...s);return o(...s),a}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Jp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Zp(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qp}an(Gp,"mergeProps"),an(Jp,"getElementRef"),an(Zp,"isSlottable");var Ty=Symbol.for("react.lazy");function vu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ty&&"_payload"in e&&Xp(e._payload)}function Xp(e){return typeof e=="object"&&e!==null&&"then"in e}an(vu,"isLazyComponent"),an(Xp,"isPromiseLike");var ky=an((e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`),"createSlotError"),By=an((e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`),"createSlottableError"),Ki=Fo[" use ".trim().toString()],Fy=Object.defineProperty,$t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,t)=>{const n=Vn(`Primitive.${t}`),r=m.forwardRef(((o,i)=>{const{asChild:s,...a}=o,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...a,ref:i})}));return r.displayName=`Primitive.${t}`,{...e,[t]:r}}),{});function Ac(e,t){e&&Oi.flushSync((()=>e.dispatchEvent(t)))}Fy(Ac,"name",{value:"dispatchDiscreteCustomEvent",configurable:!0});var Ry=Object.defineProperty,_y=(e,t)=>Ry(e,"name",{value:t,configurable:!0}),jy=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),My=m.forwardRef(_y((function(e,t){return v.jsx($t.span,{...e,ref:t,style:{...jy,...e.style}})}),"VisuallyHidden")),Py=Object.defineProperty,Gt=(e,t)=>Py(e,"name",{value:t,configurable:!0});function qn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s);a.displayName=i+"Context";const u=n.length;n=[...n,s];const l=Gt((c=>{const{scope:d,children:h,...g}=c,y=d?.[e]?.[u]||a,p=m.useMemo((()=>g),Object.values(g));return v.jsx(y.Provider,{value:p,children:h})}),"Provider");function f(c,d,h={}){const{optional:g=!1}=h,y=d?.[e]?.[u]||a,p=m.useContext(y);if(p)return p;if(s!==void 0)return s;if(!g)throw new Error(`\`${c}\` must be used within \`${i}\``)}return l.displayName=i+"Provider",Gt(f,"useContext"),[l,f]}Gt(r,"createContext");const o=Gt((()=>{const i=n.map((s=>m.createContext(s)));return Gt((function(s){const a=s?.[e]||i;return m.useMemo((()=>({[`__scope${e}`]:{...s,[e]:a}})),[s,a])}),"useScope")}),"createScope");return o.scopeName=e,[r,Yp(o,...t)]}function Yp(...e){const t=e[0];if(e.length===1)return t;const n=Gt((()=>{const r=e.map((o=>({useScope:o(),scopeName:o.scopeName})));return Gt((function(o){const i=r.reduce(((s,{useScope:a,scopeName:u})=>({...s,...a(o)[`__scope${u}`]})),{});return m.useMemo((()=>({[`__scope${t.scopeName}`]:i})),[i])}),"useComposedScopes")}),"createScope");return n.scopeName=t.scopeName,n}Gt((function(e,t){const n=m.createContext(t);n.displayName=e+"Context";const r=Gt((i=>{const{children:s,...a}=i,u=m.useMemo((()=>a),Object.values(a));return v.jsx(n.Provider,{value:u,children:s})}),"Provider");function o(i,s={}){const{optional:a=!1}=s,u=m.useContext(n);if(u)return u;if(t!==void 0)return t;if(!a)throw new Error(`\`${i}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",Gt(o,"useContext"),[r,o]}),"createContext"),Gt(qn,"createContextScope"),Gt(Yp,"composeContextScopes");var Ny=Object.defineProperty,ct=(e,t)=>Ny(e,"name",{value:t,configurable:!0});function xc(e){const t=e+"CollectionProvider",[n,r]=qn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=ct((y=>{const{scope:p,children:w}=y,b=m.useRef(null),C=m.useRef(new Map).current;return v.jsx(o,{scope:p,itemMap:C,collectionRef:b,children:w})}),"CollectionProvider");s.displayName=t;const a=e+"CollectionSlot",u=Vn(a),l=m.forwardRef(((y,p)=>{const{scope:w,children:b}=y,C=Qe(p,i(a,w).collectionRef);return v.jsx(u,{ref:C,children:b})}));l.displayName=a;const f=e+"CollectionItemSlot",c="data-radix-collection-item",d=Vn(f),h=m.forwardRef(((y,p)=>{const{scope:w,children:b,...C}=y,E=m.useRef(null),A=Qe(p,E),x=i(f,w);return m.useEffect((()=>(x.itemMap.set(E,{ref:E,...C}),()=>{x.itemMap.delete(E)}))),v.jsx(d,{[c]:"",ref:A,children:b})}));function g(y){const p=i(e+"CollectionConsumer",y);return m.useCallback((()=>{const w=p.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${c}]`));return Array.from(p.itemMap.values()).sort(((C,E)=>b.indexOf(C.ref.current)-b.indexOf(E.ref.current)))}),[p.collectionRef,p.itemMap])}return h.displayName=f,ct(g,"useCollection"),[{Provider:s,Slot:l,ItemSlot:h},g,r]}ct(xc,"createCollection");var bd=new WeakMap,it,Lt,Ca=(Lt=class extends Map{constructor(n){super(n);Il(this,it);ra(this,it,[...super.keys()]),bd.set(this,!0)}set(n,r){return bd.get(this)&&(this.has(n)?bt(this,it)[bt(this,it).indexOf(n)]=n:bt(this,it).push(n)),super.set(n,r),this}insert(n,r,o){const i=this.has(r),s=bt(this,it).length,a=Oc(n);let u=a>=0?a:s+a;const l=u<0||u>=s?-1:u;if(l===this.size||i&&l===this.size-1||l===-1)return this.set(r,o),this;const f=this.size+(i?0:1);a<0&&u++;const c=[...bt(this,it)];let d,h=!1;for(let g=u;g<f;g++)if(u===g){let y=c[g];c[g]===r&&(y=c[g+1]),i&&this.delete(r),d=this.get(y),this.set(r,o)}else{h||c[g-1]!==r||(h=!0);const y=c[h?g:g-1],p=d;d=this.get(y),this.delete(y),this.set(y,p)}return this}with(n,r,o){const i=new Lt(this);return i.insert(n,r,o),i}before(n){const r=bt(this,it).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,o){const i=bt(this,it).indexOf(n);return i===-1?this:this.insert(i,r,o)}after(n){let r=bt(this,it).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,o){const i=bt(this,it).indexOf(n);return i===-1?this:this.insert(i+1,r,o)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ra(this,it,[]),super.clear()}delete(n){const r=super.delete(n);return r&&bt(this,it).splice(bt(this,it).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0&&this.delete(r)}at(n){const r=cs(bt(this,it),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=cs(bt(this,it),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return bt(this,it).indexOf(n)}keyAt(n){return cs(bt(this,it),n)}from(n,r){const o=this.indexOf(n);if(o===-1)return;let i=o+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(n,r){const o=this.indexOf(n);if(o===-1)return;let i=o+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return i;o++}}findIndex(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return o;o++}return-1}filter(n,r){const o=[];let i=0;for(const s of this)Reflect.apply(n,r,[s,i,this])&&o.push(s),i++;return new Lt(o)}map(n,r){const o=[];let i=0;for(const s of this)o.push([s[0],Reflect.apply(n,r,[s,i,this])]),i++;return new Lt(o)}reduce(...n){const[r,o]=n;let i=0,s=o??this.at(0);for(const a of this)s=i===0&&n.length===1?a:Reflect.apply(r,this,[s,a,i,this]),i++;return s}reduceRight(...n){const[r,o]=n;let i=o??this.at(-1);for(let s=this.size-1;s>=0;s--){const a=this.at(s);i=s===this.size-1&&n.length===1?a:Reflect.apply(r,this,[i,a,s,this])}return i}toSorted(n){const r=[...this.entries()].sort(n);return new Lt(r)}toReversed(){const n=new Lt;for(let r=this.size-1;r>=0;r--){const o=this.keyAt(r),i=this.get(o);n.set(o,i)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new Lt(r)}slice(n,r){const o=new Lt;let i=this.size-1;if(n===void 0)return o;n<0&&(n+=this.size),r!==void 0&&r>0&&(i=r-1);for(let s=n;s<=i;s++){const a=this.keyAt(s),u=this.get(a);o.set(a,u)}return o}every(n,r){let o=0;for(const i of this){if(!Reflect.apply(n,r,[i,o,this]))return!1;o++}return!0}some(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return!0;o++}return!1}},it=new WeakMap,ct(Lt,"OrderedDict"),Lt);function cs(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Qp(e,t);return n===-1?void 0:e[n]}function Qp(e,t){const n=e.length,r=Oc(t),o=r>=0?r:n+r;return o<0||o>=n?-1:o}function Oc(e){return e!=e||e===0?0:Math.trunc(e)}function Cd(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||e[o]!==t[o])return!1;return!0}function em(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function wa(e,t){return e[1].element&&t[1].element?em(e[1].element,t[1].element)?-1:1:0}function wd(e){return new MutationObserver((t=>{for(const n of t)if(n.type==="childList")return void e()}))}ct(cs,"at"),ct(Qp,"toSafeIndex"),ct(Oc,"toSafeInteger"),ct((function(e){const t=e+"CollectionProvider",[n,r]=qn(t),[o,i]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ca,setItemMap:ct((()=>{}),"setItemMap")}),s=ct((({state:b,...C})=>b?v.jsx(u,{...C,state:b}):v.jsx(a,{...C})),"CollectionProvider");s.displayName=t;const a=ct((b=>{const C=p();return v.jsx(u,{...b,state:C})}),"CollectionInit");a.displayName=t+"Init";const u=ct((b=>{const{scope:C,children:E,state:A}=b,x=m.useRef(null),[I,T]=m.useState(null),F=Qe(x,T),[S,k]=A;return m.useEffect((()=>{if(!I)return;const _=wd((()=>{}));return _.observe(I,{childList:!0,subtree:!0}),()=>{_.disconnect()}}),[I]),v.jsx(o,{scope:C,itemMap:S,setItemMap:k,collectionRef:F,collectionRefObject:x,collectionElement:I,children:E})}),"CollectionProviderImpl");u.displayName=t+"Impl";const l=e+"CollectionSlot",f=Vn(l),c=m.forwardRef(((b,C)=>{const{scope:E,children:A}=b,x=Qe(C,i(l,E).collectionRef);return v.jsx(f,{ref:x,children:A})}));c.displayName=l;const d=e+"CollectionItemSlot",h="data-radix-collection-item",g=Vn(d),y=m.forwardRef(((b,C)=>{const{scope:E,children:A,...x}=b,I=m.useRef(null),[T,F]=m.useState(null),S=Qe(C,I,F),k=i(d,E),{setItemMap:_}=k,M=m.useRef(x);Cd(M.current,x)||(M.current=x);const H=M.current;return m.useEffect((()=>{const W=H;return _((G=>T?G.has(T)?G.set(T,{...W,element:T}).toSorted(wa):(G.set(T,{...W,element:T}),G.toSorted(wa)):G)),()=>{_((G=>T&&G.has(T)?(G.delete(T),new Ca(G)):G))}}),[T,H,_]),v.jsx(g,{[h]:"",ref:S,children:A})}));function p(){return m.useState(new Ca)}function w(b){const{itemMap:C}=i(e+"CollectionConsumer",b);return C}return y.displayName=d,ct(p,"useInitCollection"),ct(w,"useCollection"),[{Provider:s,Slot:c,ItemSlot:y},{createCollectionScope:r,useCollection:w,useInitCollection:p}]}),"createCollection"),ct(Cd,"shallowEqual"),ct(em,"isElementPreceding"),ct(wa,"sortByDocumentPosition"),ct(wd,"getChildListObserver");var Ly=Object.defineProperty,oo=(e,t)=>Ly(e,"name",{value:t,configurable:!0}),tm=!(typeof window>"u"||!window.document||!window.document.createElement);function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return oo((function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}),"handleEvent")}function Ea(e){if(!tm)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}function Ed(e){return e.tagName==="IFRAME"}oo(Me,"composeEventHandlers"),oo((function(e){if(!tm)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}),"getOwnerWindow"),oo(Ea,"getOwnerDocument"),oo((function e(t,n=!1){const{activeElement:r}=Ea(t);if(!r?.nodeName)return null;if(Ed(r)&&r.contentDocument)return e(r.contentDocument.body,n);if(n){const o=r.getAttribute("aria-activedescendant");if(o){const i=Ea(r).getElementById(o);if(i)return i}}return r}),"getActiveElement"),oo(Ed,"isFrame");var Yt=globalThis?.document?m.useLayoutEffect:()=>{},Uy=Object.defineProperty,Dd=Fo[" useEffectEvent ".trim().toString()],Ad=Fo[" useInsertionEffect ".trim().toString()];function nm(e){if(typeof Dd=="function")return Dd(e);const t=m.useRef((()=>{throw new Error("Cannot call an event handler while rendering.")}));return typeof Ad=="function"?Ad((()=>{t.current=e})):Yt((()=>{t.current=e})),m.useMemo((()=>(...n)=>t.current?.(...n)),[])}((e,t)=>{Uy(e,"name",{value:t,configurable:!0})})(nm,"useEffectEvent");var Hy=Object.defineProperty,oi=(e,t)=>Hy(e,"name",{value:t,configurable:!0}),Vy=Fo[" useInsertionEffect ".trim().toString()]||Yt;function Po({prop:e,defaultProp:t,onChange:n=oi((()=>{}),"onChange"),caller:r}){const[o,i,s]=rm({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:o,m.useCallback((u=>{if(a){const l=om(u)?u(e):u;l!==e&&s.current?.(l)}else i(u)}),[a,e,i,s])]}function rm({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),i=m.useRef(t);return Vy((()=>{i.current=t}),[t]),m.useEffect((()=>{o.current!==n&&(i.current?.(n),o.current=n)}),[n,o]),[n,r,i]}function om(e){return typeof e=="function"}oi(Po,"useControllableState"),oi(rm,"useUncontrolledState"),oi(om,"isFunction");var xd=Symbol("RADIX:SYNC_STATE");oi((function(e,t,n,r){const{prop:o,defaultProp:i,onChange:s,caller:a}=t,u=o!==void 0,l=nm(s),f=[{...n,state:i}];r&&f.push(r);const[c,d]=m.useReducer(((p,w)=>{if(w.type===xd)return{...p,state:w.state};const b=e(p,w);return u&&!Object.is(b.state,p.state)&&l(b.state),b}),...f),h=c.state,g=m.useRef(h);m.useEffect((()=>{g.current!==h&&(g.current=h,u||l(h))}),[h,g,u]);const y=m.useMemo((()=>o!==void 0?{...c,state:o}:c),[c,o]);return m.useEffect((()=>{u&&!Object.is(o,c.state)&&d({type:xd,state:o})}),[o,c.state,u]),[y,d]}),"useControllableStateReducer");var $y=Object.defineProperty,_n=(e,t)=>$y(e,"name",{value:t,configurable:!0});function im(e,t){return m.useReducer(((n,r)=>t[n][r]??n),e)}_n(im,"useStateMachine");var No=_n((e=>{const{present:t,children:n}=e,r=sm(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=am(r.ref,um(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null}),"Presence");function sm(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),i=m.useRef("none"),s=m.useRef(void 0),a=e?"mounted":"unmounted",[u,l]=im(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect((()=>{u==="mounted"?(i.current=s.current??io(r.current),s.current=void 0):i.current="none"}),[u]),Yt((()=>{const f=r.current,c=o.current;if(c!==e){const d=i.current,h=io(f);e?(s.current=h,l("MOUNT")):h==="none"||f?.display==="none"?l("UNMOUNT"):l(c&&d!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}}),[e,l]),Yt((()=>{if(t){let f;const c=t.ownerDocument.defaultView??window,d=_n((g=>{const y=io(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(l("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",f=c.setTimeout((()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)}))}}),"handleAnimationEnd"),h=_n((g=>{g.target===t&&(i.current=io(r.current))}),"handleAnimationStart");return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}l("ANIMATION_END")}),[t,l]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:m.useCallback((f=>{if(f){const c=getComputedStyle(f);r.current=c,s.current=io(c)}else r.current=null;n(f)}),[])}}function yu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function am(...e){const t=m.useRef(e);return t.current=e,m.useCallback((n=>{const r=t.current;let o=!1;const i=r.map((s=>{const a=yu(s,n);return o||typeof a!="function"||(o=!0),a}));if(o)return()=>{for(let s=0;s<i.length;s++){const a=i[s];typeof a=="function"?a():yu(r[s],null)}}}),[])}function io(e){return e?.animationName||"none"}function um(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}_n(sm,"usePresence"),_n(yu,"setRef"),_n(am,"useStableComposedRefs"),_n(io,"getAnimationName"),_n(um,"getElementRef");var Wy=Object.defineProperty,zy=Fo[" useId ".trim().toString()]||(()=>{}),Ky=0;function Eo(e){const[t,n]=m.useState(zy());return Yt((()=>{e||n((r=>r??String(Ky++)))}),[e]),e||(t?`radix-${t}`:"")}((e,t)=>{Wy(e,"name",{value:t,configurable:!0})})(Eo,"useId");var qy=Object.defineProperty,Gy=m.createContext(void 0);function Sc(e){const t=m.useContext(Gy);return e||t||"ltr"}((e,t)=>{qy(e,"name",{value:t,configurable:!0})})(Sc,"useDirection");var Jy=Object.defineProperty;function $n(e){const t=m.useRef(e);return m.useEffect((()=>{t.current=e})),m.useMemo((()=>(...n)=>t.current?.(...n)),[])}((e,t)=>{Jy(e,"name",{value:t,configurable:!0})})($n,"useCallbackRef");var Od,Zy=Object.defineProperty,dt=(e,t)=>Zy(e,"name",{value:t,configurable:!0}),bu="dismissableLayer.update",cm=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ic=m.forwardRef(dt((function(e,t){const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:a,onDismiss:u,...l}=e,f=m.useContext(cm),[c,d]=m.useState(null),h=c?.ownerDocument??globalThis?.document,[,g]=m.useState({}),y=Qe(t,d),p=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=w?p.indexOf(w):-1,C=c?p.indexOf(c):-1,E=f.layersWithOutsidePointerEventsDisabled.size>0,A=C>=b,x=m.useRef(!1),I=lm((k=>{i?.(k),a?.(k),k.defaultPrevented||u?.()}),{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:x,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback((k=>{if(!(k instanceof Node))return!1;const _=[...f.branches].some((M=>M.contains(k)));return A&&!_}),[f.branches,A])}),T=dm((k=>{if(r&&x.current)return;const _=k.target;[...f.branches].some((M=>M.contains(_)))||(s?.(k),a?.(k),k.defaultPrevented||u?.())}),h),F=!!c&&C===p.length-1,S=$n((k=>{k.key==="Escape"&&(o?.(k),!k.defaultPrevented&&u&&(k.preventDefault(),u()))}));return m.useEffect((()=>{if(F)return h.addEventListener("keydown",S,{capture:!0}),()=>h.removeEventListener("keydown",S,{capture:!0})}),[h,F,S]),m.useEffect((()=>{if(c)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Od=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(c)),f.layers.add(c),Cu(),()=>{n&&(f.layersWithOutsidePointerEventsDisabled.delete(c),f.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Od))}}),[c,h,n,f]),m.useEffect((()=>()=>{c&&(f.layers.delete(c),f.layersWithOutsidePointerEventsDisabled.delete(c),Cu())}),[c,f]),m.useEffect((()=>{const k=dt((()=>g({})),"handleUpdate");return document.addEventListener(bu,k),()=>document.removeEventListener(bu,k)}),[]),v.jsx($t.div,{...l,ref:y,style:{pointerEvents:E?A?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,I.onPointerDownCapture)})}),"DismissableLayer"));dt((function(){const e=m.useContext(cm),[t,n]=m.useState(null);return m.useEffect((()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}}),[t,e.dismissableSurfaces]),n}),"useDismissableLayerSurface");var Xy=dt((()=>!0),"IS_TRUE");function lm(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:s=Xy}=t,a=$n(e),u=m.useRef(!1),l=m.useRef(!1),f=m.useRef(new Map),c=m.useRef((()=>{}));return m.useEffect((()=>{function d(){l.current=!1,o.current=!1,f.current.clear()}function h(){return Array.from(f.current.values()).some(Boolean)}function g(C){if(!l.current)return;const E=C.target;E instanceof Node&&[...i].some((A=>A.contains(E)))||f.current.set(C.type,!0),C.type==="click"&&window.setTimeout((()=>{l.current&&c.current()}),0)}function y(C){l.current&&f.current.set(C.type,!1)}dt(d,"resetOutsideInteraction"),dt(h,"isOutsideInteractionIntercepted"),dt(g,"handleInteractionCapture"),dt(y,"handleInteractionBubble");const p=dt((C=>{if(C.target&&!u.current){let E=function(){n.removeEventListener("click",c.current);const x=h();d(),x||Tc("dismissableLayer.pointerDownOutside",a,A,{discrete:!0})};if(dt(E,"handleAndDispatchPointerDownOutsideEvent"),!s(C.target))return n.removeEventListener("click",c.current),d(),void(u.current=!1);const A={originalEvent:C};l.current=!0,o.current=r&&C.button===0,f.current.clear(),r&&C.button===0?(n.removeEventListener("click",c.current),c.current=E,n.addEventListener("click",c.current,{once:!0})):E()}else n.removeEventListener("click",c.current),d();u.current=!1}),"handlePointerDown"),w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const C of w)n.addEventListener(C,g,!0),n.addEventListener(C,y);const b=window.setTimeout((()=>{n.addEventListener("pointerdown",p)}),0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",p),n.removeEventListener("click",c.current);for(const C of w)n.removeEventListener(C,g,!0),n.removeEventListener(C,y)}}),[n,a,r,o,i,s]),{onPointerDownCapture:dt((()=>u.current=!0),"onPointerDownCapture")}}function dm(e,t=globalThis?.document){const n=$n(e),r=m.useRef(!1);return m.useEffect((()=>{const o=dt((i=>{i.target&&!r.current&&Tc("dismissableLayer.focusOutside",n,{originalEvent:i},{discrete:!1})}),"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)}),[t,n]),{onFocusCapture:dt((()=>r.current=!0),"onFocusCapture"),onBlurCapture:dt((()=>r.current=!1),"onBlurCapture")}}function Cu(){const e=new CustomEvent(bu);document.dispatchEvent(e)}function Tc(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ac(o,i):o.dispatchEvent(i)}dt(lm,"usePointerDownOutside"),dt(dm,"useFocusOutside"),dt(Cu,"dispatchUpdate"),dt(Tc,"handleAndDispatchCustomEvent");var Yy=Object.defineProperty,xt=(e,t)=>Yy(e,"name",{value:t,configurable:!0}),Da="focusScope.autoFocusOnMount",Aa="focusScope.autoFocusOnUnmount",Sd={bubbles:!1,cancelable:!0},fm=m.forwardRef(xt((function(e,t){const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,u]=m.useState(null),l=$n(o),f=$n(i),c=m.useRef(null),d=Qe(t,u),h=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect((()=>{if(r){let y=function(C){if(h.paused||!a)return;const E=C.target;a.contains(E)?c.current=E:Rn(c.current,{select:!0})},p=function(C){if(h.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Rn(c.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const E of C)E.removedNodes.length>0&&Rn(a)};xt(y,"handleFocusIn"),xt(p,"handleFocusOut"),xt(w,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",p);const b=new MutationObserver(w);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",p),b.disconnect()}}}),[r,a,h.paused]),m.useEffect((()=>{if(a){Id.add(h);const y=document.activeElement;if(!a.contains(y)){const p=new CustomEvent(Da,Sd);a.addEventListener(Da,l),a.dispatchEvent(p),p.defaultPrevented||(hm(ym(kc(a)),{select:!0}),document.activeElement===y&&Rn(a))}return()=>{a.removeEventListener(Da,l),setTimeout((()=>{const p=new CustomEvent(Aa,Sd);a.addEventListener(Aa,f),a.dispatchEvent(p),p.defaultPrevented||Rn(y??document.body,{select:!0}),a.removeEventListener(Aa,f),Id.remove(h)}),0)}}}),[a,l,f,h]);const g=m.useCallback((y=>{if(!n&&!r||h.paused)return;const p=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,w=document.activeElement;if(p&&w){const b=y.currentTarget,[C,E]=pm(b);C&&E?y.shiftKey||w!==E?y.shiftKey&&w===C&&(y.preventDefault(),n&&Rn(E,{select:!0})):(y.preventDefault(),n&&Rn(C,{select:!0})):w===b&&y.preventDefault()}}),[n,r,h.paused]);return v.jsx($t.div,{tabIndex:-1,...s,ref:d,onKeyDown:g})}),"FocusScope"));function hm(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Rn(r,{select:t}),document.activeElement!==n)return}function pm(e){const t=kc(e);return[wu(t,e),wu(t.reverse(),e)]}function kc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xt((r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}function wu(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):mm(r,{upTo:t})))return r}function mm(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gm(e){return e instanceof HTMLInputElement&&"select"in e}function Rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&gm(e)&&t&&e.select()}}xt(hm,"focusFirst"),xt(pm,"getTabbableEdges"),xt(kc,"getTabbableCandidates"),xt(wu,"findVisible"),xt(mm,"isHidden"),xt(gm,"isSelectableInput"),xt(Rn,"focus");var Id=vm();function vm(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Eu(e,t),e.unshift(t)},remove(t){e=Eu(e,t),e[0]?.resume()}}}function Eu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ym(e){return e.filter((t=>t.tagName!=="A"))}xt(vm,"createFocusScopesStack"),xt(Eu,"arrayRemove"),xt(ym,"removeLinks");var Qy=Object.defineProperty,eb=(e,t)=>Qy(e,"name",{value:t,configurable:!0}),Bc=m.forwardRef(eb((function(e,t){const{container:n,...r}=e,[o,i]=m.useState(!1);Yt((()=>i(!0)),[]);const s=n||o&&globalThis?.document?.body;return s?Oi.createPortal(v.jsx($t.div,{...r,ref:t}),s):null}),"Portal")),tb=Object.defineProperty,xa=(e,t)=>tb(e,"name",{value:t,configurable:!0}),qi=0,Gr=null;function Ss(){m.useEffect((()=>{Gr||(Gr={start:Du(),end:Du()});const{start:e,end:t}=Gr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),qi++,()=>{qi===1&&(Gr?.start.remove(),Gr?.end.remove(),Gr=null),qi=Math.max(0,qi-1)}}),[])}function Du(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}xa((function(e){return Ss(),e.children}),"FocusGuards"),xa(Ss,"useFocusGuards"),xa(Du,"createFocusGuard");var wn=function(){return wn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},wn.apply(this,arguments)};function bm(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}var ls="right-scroll-bar-position",ds="width-before-scroll-bar";function Oa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}var nb=typeof window<"u"?m.useLayoutEffect:m.useEffect,Td=new WeakMap;function rb(e,t){var n,r,o,i=(n=null,r=function(s){return e.forEach((function(a){return Oa(a,s)}))},o=m.useState((function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(s){var a=o.value;a!==s&&(o.value=s,o.callback(s,a))}}}}))[0],o.callback=r,o.facade);return nb((function(){var s=Td.get(i);if(s){var a=new Set(s),u=new Set(e),l=i.current;a.forEach((function(f){u.has(f)||Oa(f,null)})),u.forEach((function(f){a.has(f)||Oa(f,l)}))}Td.set(i,e)}),[e]),i}function ob(e){return e}var Cm=function(e){var t=e.sideCar,n=bm(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,wn({},n))};Cm.isSideCarExport=!0;var wm=(function(e){e===void 0&&(e={});var t=(function(n,r){r===void 0&&(r=ob);var o=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return o.length?o[o.length-1]:n},useMedium:function(a){var u=r(a,i);return o.push(u),function(){o=o.filter((function(l){return l!==u}))}},assignSyncMedium:function(a){for(i=!0;o.length;){var u=o;o=[],u.forEach(a)}o={push:function(l){return a(l)},filter:function(){return o}}},assignMedium:function(a){i=!0;var u=[];if(o.length){var l=o;o=[],l.forEach(a),u=o}var f=function(){var d=u;u=[],d.forEach(a)},c=function(){return Promise.resolve().then(f)};c(),o={push:function(d){u.push(d),c()},filter:function(d){return u=u.filter(d),o}}}};return s})(null);return t.options=wn({async:!0,ssr:!1},e),t})(),Sa=function(){},Is=m.forwardRef((function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Sa,onWheelCapture:Sa,onTouchMoveCapture:Sa}),o=r[0],i=r[1],s=e.forwardProps,a=e.children,u=e.className,l=e.removeScrollBar,f=e.enabled,c=e.shards,d=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,p=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,C=e.gapMode,E=bm(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=d,x=rb([n,t]),I=wn(wn({},E),o);return m.createElement(m.Fragment,null,f&&m.createElement(A,{sideCar:wm,removeScrollBar:l,shards:c,noRelative:h,noIsolation:g,inert:y,setCallbacks:i,allowPinchZoom:!!p,lockRef:n,gapMode:C}),s?m.cloneElement(m.Children.only(a),wn(wn({},I),{ref:x})):m.createElement(b,wn({},I,{className:u,ref:x}),a))}));Is.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Is.classNames={fullWidth:ds,zeroRight:ls};function ib(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=(function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__})();return t&&e.setAttribute("nonce",t),e}var sb=function(){var e=0,t=null;return{add:function(n){var r,o;e==0&&(t=ib())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),(function(i){(document.head||document.getElementsByTagName("head")[0]).appendChild(i)})(t)),e++},remove:function(){!--e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Em=function(){var e,t=(e=sb(),function(n,r){m.useEffect((function(){return e.add(n),function(){e.remove()}}),[n&&r])});return function(n){var r=n.styles,o=n.dynamic;return t(r,o),null}},ab={left:0,top:0,right:0,gap:0},Ia=function(e){return parseInt(e||"",10)||0},ub=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ab;var t=(function(o){var i=window.getComputedStyle(document.body),s=i[o==="padding"?"paddingLeft":"marginLeft"],a=i[o==="padding"?"paddingTop":"marginTop"],u=i[o==="padding"?"paddingRight":"marginRight"];return[Ia(s),Ia(a),Ia(u)]})(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},cb=Em(),po="data-scroll-locked",lb=function(e,t,n,r){var o=e.left,i=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
9
9
|
.`.concat("with-scroll-bars-hidden",` {
|
|
10
10
|
overflow: hidden `).concat(r,`;
|
|
11
11
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -42,18 +42,18 @@ ${(function(P){const j=Array.from(P.nodes.values(),(L=>{const N=L.parent,ce=N.ty
|
|
|
42
42
|
body[`).concat(po,`] {
|
|
43
43
|
`).concat("--removed-body-scroll-bar-size",": ").concat(a,`px;
|
|
44
44
|
}
|
|
45
|
-
`)},
|
|
45
|
+
`)},kd=function(){var e=parseInt(document.body.getAttribute(po)||"0",10);return isFinite(e)?e:0},db=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;m.useEffect((function(){return document.body.setAttribute(po,(kd()+1).toString()),function(){var s=kd()-1;s<=0?document.body.removeAttribute(po):document.body.setAttribute(po,s.toString())}}),[]);var i=m.useMemo((function(){return ub(o)}),[o]);return m.createElement(cb,{styles:lb(i,!t,o,n?"":"!important")})},Au=!1;if(typeof window<"u")try{var Gi=Object.defineProperty({},"passive",{get:function(){return Au=!0,!0}});window.addEventListener("test",Gi,Gi),window.removeEventListener("test",Gi,Gi)}catch{Au=!1}var Jr=!!Au&&{passive:!1},Bd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!(function(r){return r.tagName==="TEXTAREA"})(e)&&n[t]==="visible")},Fd=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host),Dm(e,r)){var o=Am(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Dm=function(e,t){return e==="v"?(function(n){return Bd(n,"overflowY")})(t):(function(n){return Bd(n,"overflowX")})(t)},Am=function(e,t){return e==="v"?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:(function(r){return[r.scrollLeft,r.scrollWidth,r.clientWidth]})(t);var n},Ji=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Rd=function(e){return[e.deltaX,e.deltaY]},_d=function(e){return e&&"current"in e?e.current:e},fb=function(e){return`
|
|
46
46
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
47
47
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
48
|
-
`)},hb=0,Zr=[];function pb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const mb=(Md=function(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(hb++)[0],i=m.useState(Em)[0],s=m.useRef(e);m.useEffect((function(){s.current=e}),[e]),m.useEffect((function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=(function(p,w,b){if(b||arguments.length===2)for(var C,E=0,A=w.length;E<A;E++)!C&&E in w||(C||(C=Array.prototype.slice.call(w,0,E)),C[E]=w[E]);return p.concat(C||Array.prototype.slice.call(w))})([e.lockRef.current],(e.shards||[]).map(jd),!0).filter(Boolean);return y.forEach((function(p){return p.classList.add("allow-interactivity-".concat(o))})),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach((function(p){return p.classList.remove("allow-interactivity-".concat(o))}))}}}),[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback((function(y,p){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!s.current.allowPinchZoom;var w,b=Ji(y),C=n.current,E="deltaX"in y?y.deltaX:C[0]-b[0],A="deltaY"in y?y.deltaY:C[1]-b[1],x=y.target,I=Math.abs(E)>Math.abs(A)?"h":"v";if("touches"in y&&I==="h"&&x.type==="range")return!1;var T=window.getSelection(),F=T&&T.anchorNode;if(F&&(F===x||F.contains(x)))return!1;var S=Rd(I,x);if(!S)return!0;if(S?w=I:(w=I==="v"?"h":"v",S=Rd(I,x)),!S)return!1;if(!r.current&&"changedTouches"in y&&(E||A)&&(r.current=w),!w)return!0;var k=r.current||w;return(function(_,M,H,W){var G=(function(K,Y){return K==="h"&&Y==="rtl"?-1:1})(_,window.getComputedStyle(M).direction),q=G*W,$=H.target,V=M.contains($),Q=!1,ae=q>0,ie=0,Se=0;do{if(!$)break;var Ie=Am(_,$),ne=Ie[0],B=Ie[1]-Ie[2]-G*ne;(ne||B)&&Dm(_,$)&&(ie+=B,Se+=ne);var X=$.parentNode;$=X&&X.nodeType===Node.DOCUMENT_FRAGMENT_NODE?X.host:X}while(!V&&$!==document.body||V&&(M.contains($)||M===$));return(ae&&Math.abs(ie)<1||!ae&&Math.abs(Se)<1)&&(Q=!0),Q})(k,p,y,k==="h"?E:A)}),[]),u=m.useCallback((function(y){var p=y;if(Zr.length&&Zr[Zr.length-1]===i){var w="deltaY"in p?_d(p):Ji(p),b=t.current.filter((function(E){return E.name===p.type&&(E.target===p.target||p.target===E.shadowParent)&&(function(A,x){return A[0]===x[0]&&A[1]===x[1]})(E.delta,w)}))[0];if(b&&b.should)p.cancelable&&p.preventDefault();else if(!b){var C=(s.current.shards||[]).map(jd).filter(Boolean).filter((function(E){return E.contains(p.target)}));(C.length>0?a(p,C[0]):!s.current.noIsolation)&&p.cancelable&&p.preventDefault()}}}),[]),l=m.useCallback((function(y,p,w,b){var C={name:y,delta:p,target:w,should:b,shadowParent:pb(w)};t.current.push(C),setTimeout((function(){t.current=t.current.filter((function(E){return E!==C}))}),1)}),[]),f=m.useCallback((function(y){n.current=Ji(y),r.current=void 0}),[]),c=m.useCallback((function(y){l(y.type,_d(y),y.target,a(y,e.lockRef.current))}),[]),d=m.useCallback((function(y){l(y.type,Ji(y),y.target,a(y,e.lockRef.current))}),[]);m.useEffect((function(){return Zr.push(i),e.setCallbacks({onScrollCapture:c,onWheelCapture:c,onTouchMoveCapture:d}),document.addEventListener("wheel",u,Jr),document.addEventListener("touchmove",u,Jr),document.addEventListener("touchstart",f,Jr),function(){Zr=Zr.filter((function(y){return y!==i})),document.removeEventListener("wheel",u,Jr),document.removeEventListener("touchmove",u,Jr),document.removeEventListener("touchstart",f,Jr)}}),[]);var h=e.removeScrollBar,g=e.inert;return m.createElement(m.Fragment,null,g?m.createElement(i,{styles:fb(o)}):null,h?m.createElement(db,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},wm.useMedium(Md),Cm);var Md,Rc=m.forwardRef((function(e,t){return m.createElement(Is,wn({},e,{ref:t,sideCar:mb}))}));Rc.classNames=Is.classNames;var Xr=new WeakMap,Zi=new WeakMap,Xi={},Pd=0,xm=function(e){return e&&(e.host||xm(e.parentNode))},gb=function(e,t,n,r){var o=(function(c,d){return d.map((function(h){if(c.contains(h))return h;var g=xm(h);return g&&c.contains(g)?g:(console.error("aria-hidden",h,"in not contained inside",c,". Doing nothing"),null)})).filter((function(h){return!!h}))})(t,Array.isArray(e)?e:[e]);Xi[n]||(Xi[n]=new WeakMap);var i=Xi[n],s=[],a=new Set,u=new Set(o),l=function(c){c&&!a.has(c)&&(a.add(c),l(c.parentNode))};o.forEach(l);var f=function(c){c&&!u.has(c)&&Array.prototype.forEach.call(c.children,(function(d){if(a.has(d))f(d);else try{var h=d.getAttribute(r),g=h!==null&&h!=="false",y=(Xr.get(d)||0)+1,p=(i.get(d)||0)+1;Xr.set(d,y),i.set(d,p),s.push(d),y===1&&g&&Zi.set(d,!0),p===1&&d.setAttribute(n,"true"),g||d.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",d,w)}}))};return f(t),a.clear(),Pd++,function(){s.forEach((function(c){var d=Xr.get(c)-1,h=i.get(c)-1;Xr.set(c,d),i.set(c,h),d||(Zi.has(c)||c.removeAttribute(r),Zi.delete(c)),h||c.removeAttribute(n)})),--Pd||(Xr=new WeakMap,Xr=new WeakMap,Zi=new WeakMap,Xi={})}},Om=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=(function(i){return typeof document>"u"?null:(Array.isArray(i)?i[0]:i).ownerDocument.body})(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),gb(r,o,n,"aria-hidden")):function(){return null}},vb=Object.defineProperty;function Sm(e){const[t,n]=m.useState(void 0);return Yt((()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver((o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const u=i.borderBoxSize,l=Array.isArray(u)?u[0]:u;s=l.inlineSize,a=l.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})}));return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}n(void 0)}),[e]),t}((e,t)=>{vb(e,"name",{value:t,configurable:!0})})(Sm,"useSize");const yb=["top","right","bottom","left"],fn=Math.min,wt=Math.max,Ts=Math.round,Yi=Math.floor,En=e=>({x:e,y:e}),bb={left:"right",right:"left",bottom:"top",top:"bottom"},Cb={start:"end",end:"start"};function xu(e,t,n){return wt(e,fn(t,n))}function On(e,t){return typeof e=="function"?e(t):e}function un(e){return e.split("-")[0]}function Do(e){return e.split("-")[1]}function _c(e){return e==="x"?"y":"x"}function jc(e){return e==="y"?"height":"width"}function Wn(e){return["top","bottom"].includes(un(e))?"y":"x"}function Mc(e){return _c(Wn(e))}function Ta(e){return e.replace(/start|end/g,(t=>Cb[t]))}function Qi(e){return e.replace(/left|right|bottom|top/g,(t=>bb[t]))}function Pc(e){return typeof e!="number"?(function(t){return{top:0,right:0,bottom:0,left:0,...t}})(e):{top:e,right:e,bottom:e,left:e}}function Ao(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Nd(e,t,n){let{reference:r,floating:o}=e;const i=Wn(t),s=Mc(t),a=jc(s),u=un(t),l=i==="y",f=r.x+r.width/2-o.width/2,c=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2;let h;switch(u){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:c};break;case"left":h={x:r.x-o.width,y:c};break;default:h={x:r.x,y:r.y}}switch(Do(t)){case"start":h[s]-=d*(n&&l?-1:1);break;case"end":h[s]+=d*(n&&l?-1:1)}return h}async function gi(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:c="floating",altBoundary:d=!1,padding:h=0}=On(t,e),g=Pc(h),y=a[d?c==="floating"?"reference":"floating":c],p=Ao(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:u})),w=c==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),C=await(i.isElement==null?void 0:i.isElement(b))&&await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1},E=Ao(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:u}):w);return{top:(p.top-E.top+g.top)/C.y,bottom:(E.bottom-p.bottom+g.bottom)/C.y,left:(p.left-E.left+g.left)/C.x,right:(E.right-p.right+g.right)/C.x}}function Ld(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ud(e){return yb.some((t=>e[t]>=0))}function Hd(e){const t=fn(...e.map((r=>r.left))),n=fn(...e.map((r=>r.top)));return{x:t,y:n,width:wt(...e.map((r=>r.right)))-t,height:wt(...e.map((r=>r.bottom)))-n}}function zs(){return typeof window<"u"}function xo(e){return Im(e)?(e.nodeName||"").toLowerCase():"#document"}function Ht(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dn(e){var t;return(t=(Im(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Im(e){return!!zs()&&(e instanceof Node||e instanceof Ht(e).Node)}function cn(e){return!!zs()&&(e instanceof Element||e instanceof Ht(e).Element)}function Sn(e){return!!zs()&&(e instanceof HTMLElement||e instanceof Ht(e).HTMLElement)}function Vd(e){return!(!zs()||typeof ShadowRoot>"u")&&(e instanceof ShadowRoot||e instanceof Ht(e).ShadowRoot)}function vi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function wb(e){return["table","td","th"].includes(xo(e))}function ks(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch{return!1}}))}function Ou(e){const t=Nc(),n=cn(e)?ln(e):e;return["transform","translate","scale","rotate","perspective"].some((r=>!!n[r]&&n[r]!=="none"))||!!n.containerType&&n.containerType!=="normal"||!t&&!!n.backdropFilter&&n.backdropFilter!=="none"||!t&&!!n.filter&&n.filter!=="none"||["transform","translate","scale","rotate","perspective","filter"].some((r=>(n.willChange||"").includes(r)))||["paint","layout","strict","content"].some((r=>(n.contain||"").includes(r)))}function Nc(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function mo(e){return["html","body","#document"].includes(xo(e))}function ln(e){return Ht(e).getComputedStyle(e)}function Ks(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ar(e){if(xo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Vd(e)&&e.host||Dn(e);return Vd(t)?t.host:t}function Tm(e){const t=ar(e);return mo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&vi(t)?t:Tm(t)}function yi(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Tm(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=Ht(o);if(i){const a=Su(s);return t.concat(s,s.visualViewport||[],vi(o)?o:[],a&&n?yi(a):[])}return t.concat(o,yi(o,[],n))}function Su(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function km(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Ts(n)!==i||Ts(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function Lc(e){return cn(e)?e:e.contextElement}function go(e){const t=Lc(e);if(!Sn(t))return En(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=km(t);let s=(i?Ts(n.width):n.width)/r,a=(i?Ts(n.height):n.height)/o;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const Eb=En(0);function Bm(e){const t=Ht(e);return Nc()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Eb}function Ur(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Lc(e);let s=En(1);t&&(r?cn(r)&&(s=go(r)):s=go(e));const a=(function(d,h,g){return h===void 0&&(h=!1),!(!g||h&&g!==Ht(d))&&h})(i,n,r)?Bm(i):En(0);let u=(o.left+a.x)/s.x,l=(o.top+a.y)/s.y,f=o.width/s.x,c=o.height/s.y;if(i){const d=Ht(i),h=r&&cn(r)?Ht(r):r;let g=d,y=Su(g);for(;y&&r&&h!==g;){const p=go(y),w=y.getBoundingClientRect(),b=ln(y),C=w.left+(y.clientLeft+parseFloat(b.paddingLeft))*p.x,E=w.top+(y.clientTop+parseFloat(b.paddingTop))*p.y;u*=p.x,l*=p.y,f*=p.x,c*=p.y,u+=C,l+=E,g=Ht(y),y=Su(g)}}return Ao({width:f,height:c,x:u,y:l})}function Uc(e,t){const n=Ks(e).scrollLeft;return t?t.left+n:Ur(Dn(e)).left+n}function Fm(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:Uc(e,r)),y:r.top+t.scrollTop}}function $d(e,t,n){let r;if(t==="viewport")r=(function(o,i){const s=Ht(o),a=Dn(o),u=s.visualViewport;let l=a.clientWidth,f=a.clientHeight,c=0,d=0;if(u){l=u.width,f=u.height;const h=Nc();(!h||h&&i==="fixed")&&(c=u.offsetLeft,d=u.offsetTop)}return{width:l,height:f,x:c,y:d}})(e,n);else if(t==="document")r=(function(o){const i=Dn(o),s=Ks(o),a=o.ownerDocument.body,u=wt(i.scrollWidth,i.clientWidth,a.scrollWidth,a.clientWidth),l=wt(i.scrollHeight,i.clientHeight,a.scrollHeight,a.clientHeight);let f=-s.scrollLeft+Uc(o);const c=-s.scrollTop;return ln(a).direction==="rtl"&&(f+=wt(i.clientWidth,a.clientWidth)-u),{width:u,height:l,x:f,y:c}})(Dn(e));else if(cn(t))r=(function(o,i){const s=Ur(o,!0,i==="fixed"),a=s.top+o.clientTop,u=s.left+o.clientLeft,l=Sn(o)?go(o):En(1);return{width:o.clientWidth*l.x,height:o.clientHeight*l.y,x:u*l.x,y:a*l.y}})(t,n);else{const o=Bm(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ao(r)}function Rm(e,t){const n=ar(e);return!(n===t||!cn(n)||mo(n))&&(ln(n).position==="fixed"||Rm(n,t))}function Db(e,t,n){const r=Sn(t),o=Dn(t),i=n==="fixed",s=Ur(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const u=En(0);if(r||!r&&!i)if((xo(t)!=="body"||vi(o))&&(a=Ks(t)),r){const f=Ur(t,!0,i,t);u.x=f.x+t.clientLeft,u.y=f.y+t.clientTop}else o&&(u.x=Uc(o));const l=!o||r||i?En(0):Fm(o,a);return{x:s.left+a.scrollLeft-u.x-l.x,y:s.top+a.scrollTop-u.y-l.y,width:s.width,height:s.height}}function ka(e){return ln(e).position==="static"}function Wd(e,t){if(!Sn(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Dn(e)===n&&(n=n.ownerDocument.body),n}function zd(e,t){const n=Ht(e);if(ks(e))return n;if(!Sn(e)){let o=ar(e);for(;o&&!mo(o);){if(cn(o)&&!ka(o))return o;o=ar(o)}return n}let r=Wd(e,t);for(;r&&wb(r)&&ka(r);)r=Wd(r,t);return r&&mo(r)&&ka(r)&&!Ou(r)?n:r||(function(o){let i=ar(o);for(;Sn(i)&&!mo(i);){if(Ou(i))return i;if(ks(i))return null;i=ar(i)}return null})(e)||n}const Ab={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Dn(r),a=!!t&&ks(t.floating);if(r===s||a&&i)return n;let u={scrollLeft:0,scrollTop:0},l=En(1);const f=En(0),c=Sn(r);if((c||!c&&!i)&&((xo(r)!=="body"||vi(s))&&(u=Ks(r)),Sn(r))){const h=Ur(r);l=go(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const d=!s||c||i?En(0):Fm(s,u,!0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+f.x+d.x,y:n.y*l.y-u.scrollTop*l.y+f.y+d.y}},getDocumentElement:Dn,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=n==="clippingAncestors"?ks(t)?[]:(function(l,f){const c=f.get(l);if(c)return c;let d=yi(l,[],!1).filter((p=>cn(p)&&xo(p)!=="body")),h=null;const g=ln(l).position==="fixed";let y=g?ar(l):l;for(;cn(y)&&!mo(y);){const p=ln(y),w=Ou(y);w||p.position!=="fixed"||(h=null),(g?!w&&!h:!w&&p.position==="static"&&h&&["absolute","fixed"].includes(h.position)||vi(y)&&!w&&Rm(l,y))?d=d.filter((b=>b!==y)):h=p,y=ar(y)}return f.set(l,d),d})(t,this._c):[].concat(n),s=[...i,r],a=s[0],u=s.reduce(((l,f)=>{const c=$d(t,f,o);return l.top=wt(c.top,l.top),l.right=fn(c.right,l.right),l.bottom=fn(c.bottom,l.bottom),l.left=wt(c.left,l.left),l}),$d(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:zd,getElementRects:async function(e){const t=this.getOffsetParent||zd,n=this.getDimensions,r=await n(e.floating);return{reference:Db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=km(e);return{width:t,height:n}},getScale:go,isElement:cn,isRTL:function(e){return ln(e).direction==="rtl"}};function Kd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function _m(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=Lc(e),f=o||i?[...l?yi(l):[],...yi(t)]:[];f.forEach((p=>{o&&p.addEventListener("scroll",n,{passive:!0}),i&&p.addEventListener("resize",n)}));const c=l&&a?(function(p,w){let b,C=null;const E=Dn(p);function A(){var x;clearTimeout(b),(x=C)==null||x.disconnect(),C=null}return(function x(I,T){I===void 0&&(I=!1),T===void 0&&(T=1),A();const F=p.getBoundingClientRect(),{left:S,top:k,width:_,height:M}=F;if(I||w(),!_||!M)return;const H={rootMargin:-Yi(k)+"px "+-Yi(E.clientWidth-(S+_))+"px "+-Yi(E.clientHeight-(k+M))+"px "+-Yi(S)+"px",threshold:wt(0,fn(1,T))||1};let W=!0;function G(q){const $=q[0].intersectionRatio;if($!==T){if(!W)return x();$?x(!1,$):b=setTimeout((()=>{x(!1,1e-7)}),1e3)}$!==1||Kd(F,p.getBoundingClientRect())||x(),W=!1}try{C=new IntersectionObserver(G,{...H,root:E.ownerDocument})}catch{C=new IntersectionObserver(G,H)}C.observe(p)})(!0),A})(l,n):null;let d,h=-1,g=null;s&&(g=new ResizeObserver((p=>{let[w]=p;w&&w.target===l&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var b;(b=g)==null||b.observe(t)}))),n()})),l&&!u&&g.observe(l),g.observe(t));let y=u?Ur(e):null;return u&&(function p(){const w=Ur(e);y&&!Kd(y,w)&&n(),y=w,d=requestAnimationFrame(p)})(),n(),()=>{var p;f.forEach((w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)})),c?.(),(p=g)==null||p.disconnect(),g=null,u&&cancelAnimationFrame(d)}}const xb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,u=await(async function(l,f){const{placement:c,platform:d,elements:h}=l,g=await(d.isRTL==null?void 0:d.isRTL(h.floating)),y=un(c),p=Do(c),w=Wn(c)==="y",b=["left","top"].includes(y)?-1:1,C=g&&w?-1:1,E=On(f,l);let{mainAxis:A,crossAxis:x,alignmentAxis:I}=typeof E=="number"?{mainAxis:E,crossAxis:0,alignmentAxis:null}:{mainAxis:E.mainAxis||0,crossAxis:E.crossAxis||0,alignmentAxis:E.alignmentAxis};return p&&typeof I=="number"&&(x=p==="end"?-1*I:I),w?{x:x*C,y:A*b}:{x:A*b,y:x*C}})(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},Ob=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:p=>{let{x:w,y:b}=p;return{x:w,y:b}}},...u}=On(e,t),l={x:n,y:r},f=await gi(t,u),c=Wn(un(o)),d=_c(c);let h=l[d],g=l[c];if(i){const p=d==="y"?"bottom":"right";h=xu(h+f[d==="y"?"top":"left"],h,h-f[p])}if(s){const p=c==="y"?"bottom":"right";g=xu(g+f[c==="y"?"top":"left"],g,g-f[p])}const y=a.fn({...t,[d]:h,[c]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[d]:i,[c]:s}}}}}},Sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:u,elements:l}=t,{mainAxis:f=!0,crossAxis:c=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...p}=On(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=un(o),b=Wn(a),C=un(a)===a,E=await(u.isRTL==null?void 0:u.isRTL(l.floating)),A=d||(C||!y?[Qi(a)]:(function(H){const W=Qi(H);return[Ta(H),W,Ta(W)]})(a)),x=g!=="none";!d&&x&&A.push(...(function(H,W,G,q){const $=Do(H);let V=(function(Q,ae,ie){const Se=["left","right"],Ie=["right","left"],ne=["top","bottom"],B=["bottom","top"];switch(Q){case"top":case"bottom":return ie?ae?Ie:Se:ae?Se:Ie;case"left":case"right":return ae?ne:B;default:return[]}})(un(H),G==="start",q);return $&&(V=V.map((Q=>Q+"-"+$)),W&&(V=V.concat(V.map(Ta)))),V})(a,y,g,E));const I=[a,...A],T=await gi(t,p),F=[];let S=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&F.push(T[w]),c){const H=(function(W,G,q){q===void 0&&(q=!1);const $=Do(W),V=Mc(W),Q=jc(V);let ae=V==="x"?$===(q?"end":"start")?"right":"left":$==="start"?"bottom":"top";return G.reference[Q]>G.floating[Q]&&(ae=Qi(ae)),[ae,Qi(ae)]})(o,s,E);F.push(T[H[0]],T[H[1]])}if(S=[...S,{placement:o,overflows:F}],!F.every((H=>H<=0))){var k,_;const H=(((k=i.flip)==null?void 0:k.index)||0)+1,W=I[H];if(W)return{data:{index:H,overflows:S},reset:{placement:W}};let G=(_=S.filter((q=>q.overflows[0]<=0)).sort(((q,$)=>q.overflows[1]-$.overflows[1]))[0])==null?void 0:_.placement;if(!G)switch(h){case"bestFit":{var M;const q=(M=S.filter(($=>{if(x){const V=Wn($.placement);return V===b||V==="y"}return!0})).map(($=>[$.placement,$.overflows.filter((V=>V>0)).reduce(((V,Q)=>V+Q),0)])).sort((($,V)=>$[1]-V[1]))[0])==null?void 0:M[0];q&&(G=q);break}case"initialPlacement":G=a}if(o!==G)return{reset:{placement:G}}}return{}}}},Ib=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:u=()=>{},...l}=On(e,t),f=await gi(t,l),c=un(o),d=Do(o),h=Wn(o)==="y",{width:g,height:y}=i.floating;let p,w;c==="top"||c==="bottom"?(p=c,w=d===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(w=c,p=d==="end"?"top":"bottom");const b=y-f.top-f.bottom,C=g-f.left-f.right,E=fn(y-f[p],b),A=fn(g-f[w],C),x=!t.middlewareData.shift;let I=E,T=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),x&&!d){const S=wt(f.left,0),k=wt(f.right,0),_=wt(f.top,0),M=wt(f.bottom,0);h?T=g-2*(S!==0||k!==0?S+k:wt(f.left,f.right)):I=y-2*(_!==0||M!==0?_+M:wt(f.top,f.bottom))}await u({...t,availableWidth:T,availableHeight:I});const F=await s.getDimensions(a.floating);return g!==F.width||y!==F.height?{reset:{rects:!0}}:{}}}},Tb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=On(e,t);switch(r){case"referenceHidden":{const i=Ld(await gi(t,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Ud(i)}}}case"escaped":{const i=Ld(await gi(t,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:i,escaped:Ud(i)}}}default:return{}}}}},qd=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:u}=t,{element:l,padding:f=0}=On(e,t)||{};if(l==null)return{};const c=Pc(f),d={x:n,y:r},h=Mc(o),g=jc(h),y=await s.getDimensions(l),p=h==="y",w=p?"top":"left",b=p?"bottom":"right",C=p?"clientHeight":"clientWidth",E=i.reference[g]+i.reference[h]-d[h]-i.floating[g],A=d[h]-i.reference[h],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let I=x?x[C]:0;I&&await(s.isElement==null?void 0:s.isElement(x))||(I=a.floating[C]||i.floating[g]);const T=E/2-A/2,F=I/2-y[g]/2-1,S=fn(c[w],F),k=fn(c[b],F),_=S,M=I-y[g]-k,H=I/2-y[g]/2+T,W=xu(_,H,M),G=!u.arrow&&Do(o)!=null&&H!==W&&i.reference[g]/2-(H<_?S:k)-y[g]/2<0,q=G?H<_?H-_:H-M:0;return{[h]:d[h]+q,data:{[h]:W,centerOffset:H-W-q,...G&&{alignmentOffset:q}},reset:G}}}),kb=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:r,rects:o,platform:i,strategy:s}=t,{padding:a=2,x:u,y:l}=On(e,t),f=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),c=(function(y){const p=y.slice().sort(((C,E)=>C.y-E.y)),w=[];let b=null;for(let C=0;C<p.length;C++){const E=p[C];!b||E.y-b.y>b.height/2?w.push([E]):w[w.length-1].push(E),b=E}return w.map((C=>Ao(Hd(C))))})(f),d=Ao(Hd(f)),h=Pc(a),g=await i.getElementRects({reference:{getBoundingClientRect:function(){if(c.length===2&&c[0].left>c[1].right&&u!=null&&l!=null)return c.find((y=>u>y.left-h.left&&u<y.right+h.right&&l>y.top-h.top&&l<y.bottom+h.bottom))||d;if(c.length>=2){if(Wn(n)==="y"){const A=c[0],x=c[c.length-1],I=un(n)==="top",T=A.top,F=x.bottom,S=I?A.left:x.left,k=I?A.right:x.right;return{top:T,bottom:F,left:S,right:k,width:k-S,height:F-T,x:S,y:T}}const y=un(n)==="left",p=wt(...c.map((A=>A.right))),w=fn(...c.map((A=>A.left))),b=c.filter((A=>y?A.left===w:A.right===p)),C=b[0].top,E=b[b.length-1].bottom;return{top:C,bottom:E,left:w,right:p,width:p-w,height:E-C,x:w,y:C}}return d}},floating:r.floating,strategy:s});return o.reference.x!==g.reference.x||o.reference.y!==g.reference.y||o.reference.width!==g.reference.width||o.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},Bb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:u=!0,crossAxis:l=!0}=On(e,t),f={x:n,y:r},c=Wn(o),d=_c(c);let h=f[d],g=f[c];const y=On(a,t),p=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){const C=d==="y"?"height":"width",E=i.reference[d]-i.floating[C]+p.mainAxis,A=i.reference[d]+i.reference[C]-p.mainAxis;h<E?h=E:h>A&&(h=A)}if(l){var w,b;const C=d==="y"?"width":"height",E=["top","left"].includes(un(o)),A=i.reference[c]-i.floating[C]+(E&&((w=s.offset)==null?void 0:w[c])||0)+(E?0:p.crossAxis),x=i.reference[c]+i.reference[C]+(E?0:((b=s.offset)==null?void 0:b[c])||0)-(E?p.crossAxis:0);g<A?g=A:g>x&&(g=x)}return{[d]:h,[c]:g}}}},Fb=(e,t,n)=>{const r=new Map,o={platform:Ab,...n},i={...o.platform,_c:r};return(async(s,a,u)=>{const{placement:l="bottom",strategy:f="absolute",middleware:c=[],platform:d}=u,h=c.filter(Boolean),g=await(d.isRTL==null?void 0:d.isRTL(a));let y=await d.getElementRects({reference:s,floating:a,strategy:f}),{x:p,y:w}=Nd(y,l,g),b=l,C={},E=0;for(let A=0;A<h.length;A++){const{name:x,fn:I}=h[A],{x:T,y:F,data:S,reset:k}=await I({x:p,y:w,initialPlacement:l,placement:b,strategy:f,middlewareData:C,rects:y,platform:d,elements:{reference:s,floating:a}});p=T??p,w=F??w,C={...C,[x]:{...C[x],...S}},k&&E<=50&&(E++,typeof k=="object"&&(k.placement&&(b=k.placement),k.rects&&(y=k.rects===!0?await d.getElementRects({reference:s,floating:a,strategy:f}):k.rects),{x:p,y:w}=Nd(y,b,g)),A=-1)}return{x:p,y:w,placement:b,strategy:f,middlewareData:C}})(e,t,{...o,platform:i})};var fs=typeof document<"u"?m.useLayoutEffect:m.useEffect;function Bs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!=0;)if(!Bs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!=0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!=0;){const i=o[r];if((i!=="_owner"||!e.$$typeof)&&!Bs(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}function jm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Gd(e,t){const n=jm(e);return Math.round(t*n)/n}function Ba(e){const t=m.useRef(e);return fs((()=>{t.current=e})),t}function Mm(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:u,open:l}=e,[f,c]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);Bs(d,r)||h(r);const[g,y]=m.useState(null),[p,w]=m.useState(null),b=m.useCallback(($=>{$!==x.current&&(x.current=$,y($))}),[]),C=m.useCallback(($=>{$!==I.current&&(I.current=$,w($))}),[]),E=i||g,A=s||p,x=m.useRef(null),I=m.useRef(null),T=m.useRef(f),F=u!=null,S=Ba(u),k=Ba(o),_=Ba(l),M=m.useCallback((()=>{if(!x.current||!I.current)return;const $={placement:t,strategy:n,middleware:d};k.current&&($.platform=k.current),Fb(x.current,I.current,$).then((V=>{const Q={...V,isPositioned:_.current!==!1};H.current&&!Bs(T.current,Q)&&(T.current=Q,Oi.flushSync((()=>{c(Q)})))}))}),[d,t,n,k,_]);fs((()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,c(($=>({...$,isPositioned:!1}))))}),[l]);const H=m.useRef(!1);fs((()=>(H.current=!0,()=>{H.current=!1})),[]),fs((()=>{if(E&&(x.current=E),A&&(I.current=A),E&&A){if(S.current)return S.current(E,A,M);M()}}),[E,A,M,S,F]);const W=m.useMemo((()=>({reference:x,floating:I,setReference:b,setFloating:C})),[b,C]),G=m.useMemo((()=>({reference:E,floating:A})),[E,A]),q=m.useMemo((()=>{const $={position:n,left:0,top:0};if(!G.floating)return $;const V=Gd(G.floating,f.x),Q=Gd(G.floating,f.y);return a?{...$,transform:"translate("+V+"px, "+Q+"px)",...jm(G.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:Q}}),[n,a,G.floating,f.x,f.y]);return m.useMemo((()=>({...f,update:M,refs:W,elements:G,floatingStyles:q})),[f,M,W,G,q])}const Rb=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}=typeof e=="function"?e(t):e;return n&&(function(o){return{}.hasOwnProperty.call(o,"current")})(n)?n.current!=null?qd({element:n.current,padding:r}).fn(t):{}:n?qd({element:n,padding:r}).fn(t):{}}}),Pm=(e,t)=>({...xb(e),options:[e,t]}),Nm=(e,t)=>({...Ob(e),options:[e,t]}),Lm=(e,t)=>({...Bb(e),options:[e,t]}),Um=(e,t)=>({...Sb(e),options:[e,t]}),Hm=(e,t)=>({...Ib(e),options:[e,t]}),Vm=(e,t)=>({...Tb(e),options:[e,t]}),_b=(e,t)=>({...kb(e),options:[e,t]}),jb=(e,t)=>({...Rb(e),options:[e,t]});var Mb=Object.defineProperty,dr=(e,t)=>Mb(e,"name",{value:t,configurable:!0}),$m="Popper",[Wm,Lo]=qn($m),[Pb,zm]=Wm($m),Nb=dr((e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null),[i,s]=m.useState(void 0);return v.jsx(Pb,{scope:t,anchor:r,onAnchorChange:o,placementState:i,setPlacementState:s,children:n})}),"Popper"),Lb=m.forwardRef(dr((function(e,t){const{__scopePopper:n,virtualRef:r,...o}=e,i=zm("PopperAnchor",n),s=m.useRef(null),a=i.onAnchorChange,u=m.useCallback((g=>{s.current=g,g&&a(g)}),[a]),l=Qe(t,u),f=m.useRef(null);m.useEffect((()=>{if(!r)return;const g=f.current;f.current=r.current,g!==f.current&&a(f.current)}));const c=i.placementState&&qs(i.placementState),d=c?.[0],h=c?.[1];return r?null:v.jsx($t.div,{"data-radix-popper-side":d,"data-radix-popper-align":h,...o,ref:l})}),"PopperAnchor")),Km="PopperContent",[Ub,Rx]=Wm(Km),Hb=m.forwardRef(dr((function(e,t){const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:c="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:g,...y}=e,p=zm(Km,n),[w,b]=m.useState(null),C=Qe(t,b),[E,A]=m.useState(null),x=Sm(E),I=x?.width??0,T=x?.height??0,F=r+(i!=="center"?"-"+i:""),S=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},k=Array.isArray(l)?l:[l],_=k.length>0,M={padding:S,boundary:k.filter(qm),altBoundary:_},{refs:H,floatingStyles:W,placement:G,isPositioned:q,middlewareData:$}=Mm({strategy:"fixed",placement:F,whileElementsMounted:dr(((...K)=>_m(...K,{animationFrame:h==="always"})),"whileElementsMounted"),elements:{reference:p.anchor},middleware:[Pm({mainAxis:o+T,alignmentAxis:s}),u&&Nm({mainAxis:!0,crossAxis:!1,limiter:c==="partial"?Lm():void 0,...M}),u&&Um({...M}),Hm({...M,apply:dr((({elements:K,rects:Y,availableWidth:de,availableHeight:pe})=>{const{width:fe,height:we}=Y.reference,Ce=K.floating.style;Ce.setProperty("--radix-popper-available-width",`${de}px`),Ce.setProperty("--radix-popper-available-height",`${pe}px`),Ce.setProperty("--radix-popper-anchor-width",`${fe}px`),Ce.setProperty("--radix-popper-anchor-height",`${we}px`)}),"apply")}),E&&jb({element:E,padding:a}),Vb({arrowWidth:I,arrowHeight:T}),d&&Vm({strategy:"referenceHidden",...M,boundary:_?M.boundary:void 0})]}),V=p.setPlacementState;Yt((()=>(V(G),()=>{V(void 0)})),[G,V]);const[Q,ae]=qs(G),ie=$n(g);Yt((()=>{q&&ie?.()}),[q,ie]);const Se=$.arrow?.x,Ie=$.arrow?.y,ne=$.arrow?.centerOffset!==0,[B,X]=m.useState();return Yt((()=>{w&&X(window.getComputedStyle(w).zIndex)}),[w]),v.jsx("div",{ref:H.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:q?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:B,"--radix-popper-transform-origin":[$.transformOrigin?.x,$.transformOrigin?.y].join(" "),...$.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:v.jsx(Ub,{scope:n,placedSide:Q,placedAlign:ae,onArrowChange:A,arrowX:Se,arrowY:Ie,shouldHideArrow:ne,children:v.jsx($t.div,{"data-side":Q,"data-align":ae,...y,ref:C,style:{...y.style,animation:q?y.style?.animation:"none"}})})})}),"PopperContent"));function qm(e){return e!==null}dr(qm,"isNotNull");var Vb=dr((e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,s=i?0:e.arrowWidth,a=i?0:e.arrowHeight,[u,l]=qs(n),f={start:"0%",center:"50%",end:"100%"}[l],c=(o.arrow?.x??0)+s/2,d=(o.arrow?.y??0)+a/2;let h="",g="";return u==="bottom"?(h=i?f:`${c}px`,g=-a+"px"):u==="top"?(h=i?f:`${c}px`,g=`${r.floating.height+a}px`):u==="right"?(h=-a+"px",g=i?f:`${d}px`):u==="left"&&(h=`${r.floating.width+a}px`,g=i?f:`${d}px`),{data:{x:h,y:g}}}})),"transformOrigin");function qs(e){const[t,n="center"]=e.split("-");return[t,n]}dr(qs,"getSideAndAlignFromPlacement");var Hc=Nb,Vc=Lb,$c=Hb,$b=Object.defineProperty,Iu=(e,t)=>$b(e,"name",{value:t,configurable:!0}),Fa=!1;function Gm(){const[e,t]=m.useState(Fa);return m.useEffect((()=>{Fa||(Fa=!0,t(!0))}),[]),e}Iu(Gm,"useIsHydrated");var Jm=Fo[" useSyncExternalStore ".trim().toString()];function Zm(){return()=>{}}function Xm(){return Jm(Zm,(()=>!0),(()=>!1))}Iu(Zm,"subscribe"),Iu(Xm,"useIsHydratedModern");var Wb=typeof Jm=="function"?Xm:Gm,zb=Object.defineProperty,Fr=(e,t)=>zb(e,"name",{value:t,configurable:!0}),Ra="rovingFocusGroup.onEntryFocus",Kb={bubbles:!1,cancelable:!0},Gs="RovingFocusGroup",[Tu,Ym,qb]=Oc(Gs),[Gb,Qm]=qn(Gs,[qb]),[Jb,Zb]=Gb(Gs),Xb=m.forwardRef(Fr((function(e,t){return v.jsx(Tu.Provider,{scope:e.__scopeRovingFocusGroup,children:v.jsx(Tu.Slot,{scope:e.__scopeRovingFocusGroup,children:v.jsx(Yb,{...e,ref:t})})})}),"RovingFocusGroup")),Yb=m.forwardRef(Fr((function(e,t){const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:l,preventScrollOnEntryFocus:f=!1,...c}=e,d=m.useRef(null),h=Qe(t,d),g=Ic(i),[y,p]=Po({prop:s,defaultProp:a??null,onChange:u,caller:Gs}),[w,b]=m.useState(!1),C=$n(l),E=Ym(n),A=m.useRef(!1),[x,I]=m.useState(0);return m.useEffect((()=>{const T=d.current;if(T)return T.addEventListener(Ra,C),()=>T.removeEventListener(Ra,C)}),[C]),v.jsx(Jb,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:m.useCallback((T=>p(T)),[p]),onItemShiftTab:m.useCallback((()=>b(!0)),[]),onFocusableItemAdd:m.useCallback((()=>I((T=>T+1))),[]),onFocusableItemRemove:m.useCallback((()=>I((T=>T-1))),[]),children:v.jsx($t.div,{tabIndex:w||x===0?-1:0,"data-orientation":r,...c,ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,(()=>{A.current=!0})),onFocus:Me(e.onFocus,(T=>{const F=!A.current;if(T.target===T.currentTarget&&F&&!w){const S=new CustomEvent(Ra,Kb);if(T.currentTarget.dispatchEvent(S),!S.defaultPrevented){const k=E().filter((_=>_.focusable));Wc([k.find((_=>_.active)),k.find((_=>_.id===y)),...k].filter(Boolean).map((_=>_.ref.current)),f)}}A.current=!1})),onBlur:Me(e.onBlur,(()=>b(!1)))})})}),"RovingFocusGroupImpl")),Qb=m.forwardRef(Fr((function(e,t){const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,u=Eo(),l=i||u,f=Zb("RovingFocusGroupItem",n),c=f.currentTabStopId===l,d=Ym(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:y}=f,p=Wb();return Yt((()=>{if(p&&r)return h(),()=>g()}),[p,r,h,g]),m.useEffect((()=>{if(!p&&r)return h(),()=>g()}),[p,r,h,g]),v.jsx(Tu.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:v.jsx($t.span,{tabIndex:c?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,(w=>{r?f.onItemFocus(l):w.preventDefault()})),onFocus:Me(e.onFocus,(()=>f.onItemFocus(l))),onKeyDown:Me(e.onKeyDown,(w=>{if(w.key==="Tab"&&w.shiftKey)return void f.onItemShiftTab();if(w.target!==w.currentTarget)return;const b=tg(w,f.orientation,f.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=d().filter((E=>E.focusable)).map((E=>E.ref.current));if(b==="last")C.reverse();else if(b==="prev"||b==="next"){b==="prev"&&C.reverse();const E=C.indexOf(w.currentTarget);C=f.loop?ng(C,E+1):C.slice(E+1)}setTimeout((()=>Wc(C)))}})),children:typeof s=="function"?s({isCurrentTabStop:c,hasTabStop:y!=null}):s})})}),"RovingFocusGroupItem")),eC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eg(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tg(e,t,n){const r=eg(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r)||t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return eC[r]}function Wc(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ng(e,t){return e.map(((n,r)=>e[(t+r)%e.length]))}Fr(eg,"getDirectionAwareKey"),Fr(tg,"getFocusIntent"),Fr(Wc,"focusFirst"),Fr(ng,"wrapArray");var tC=Xb,nC=Qb,rC=Object.defineProperty,Ke=(e,t)=>rC(e,"name",{value:t,configurable:!0}),oC=["Enter"," "],rg=["ArrowUp","PageDown","End"],iC=["ArrowDown","PageUp","Home",...rg],Js="Menu",[ku,sC,aC]=Oc(Js),[$r,og]=qn(Js,[aC,Lo,Qm]),zc=Lo(),ig=Qm(),[uC,Ti]=$r(Js),[cC,Kc]=$r(Js),lC=Ke((e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:s=!0}=e,a=zc(t),[u,l]=m.useState(null),f=m.useRef(!1),c=$n(i),d=Ic(o);return m.useEffect((()=>{const h=Ke((()=>{f.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})}),"handleKeyDown"),g=Ke((()=>f.current=!1),"handlePointer");return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}}),[]),m.useEffect((()=>{if(!n)return;const h=Ke((()=>c(!1)),"handleBlur");return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)}),[n,c]),v.jsx(Hc,{...a,children:v.jsx(uC,{scope:t,open:n,onOpenChange:c,content:u,onContentChange:l,children:v.jsx(cC,{scope:t,onClose:m.useCallback((()=>c(!1)),[c]),isUsingKeyboardRef:f,dir:d,modal:s,children:r})})})}),"Menu"),dC=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,...r}=e,o=zc(n);return v.jsx(Vc,{...o,...r,ref:t})}),"MenuAnchor")),sg="MenuPortal",[fC,hC]=$r(sg,{forceMount:void 0}),pC=Ke((e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=Ti(sg,t);return v.jsx(fC,{scope:t,forceMount:n,children:v.jsx(No,{present:n||i.open,children:v.jsx(Fc,{asChild:!0,container:o,children:r})})})}),"MenuPortal"),fr="MenuContent",[mC,ag]=$r(fr),gC=m.forwardRef(Ke((function(e,t){const n=hC(fr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Ti(fr,e.__scopeMenu),s=Kc(fr,e.__scopeMenu);return v.jsx(ku.Provider,{scope:e.__scopeMenu,children:v.jsx(No,{present:r||i.open,children:v.jsx(ku.Slot,{scope:e.__scopeMenu,children:s.modal?v.jsx(vC,{...o,ref:t}):v.jsx(yC,{...o,ref:t})})})})}),"MenuContent")),vC=m.forwardRef(Ke((function(e,t){const n=Ti(fr,e.__scopeMenu),r=m.useRef(null),o=Qe(t,r);return m.useEffect((()=>{const i=r.current;if(i)return Om(i)}),[]),v.jsx(ug,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Me(e.onFocusOutside,(i=>i.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),"MenuRootContentModal")),yC=m.forwardRef(Ke((function(e,t){const n=Ti(fr,e.__scopeMenu);return v.jsx(ug,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),"MenuRootContentNonModal")),bC=Vn("MenuContent.ScrollLock"),ug=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:f,onFocusOutside:c,onInteractOutside:d,onDismiss:h,disableOutsideScroll:g,...y}=e,p=Ti(fr,n),w=Kc(fr,n),b=zc(n),C=ig(n),E=sC(n),[A,x]=m.useState(null),I=m.useRef(null),T=Qe(t,I,p.onContentChange),F=m.useRef(0),S=m.useRef(""),k=m.useRef(0),_=m.useRef(null),M=m.useRef("right"),H=m.useRef(0),W=g?Rc:m.Fragment,G=g?{as:bC,allowPinchZoom:!0}:void 0,q=Ke((V=>{const Q=S.current+V,ae=E().filter((B=>!B.disabled)),ie=document.activeElement,Se=ae.find((B=>B.ref.current===ie))?.textValue,Ie=fg(ae.map((B=>B.textValue)),Q,Se),ne=ae.find((B=>B.textValue===Ie))?.ref.current;Ke((function B(X){S.current=X,window.clearTimeout(F.current),X!==""&&(F.current=window.setTimeout((()=>B("")),1e3))}),"updateSearch")(Q),ne&&setTimeout((()=>ne.focus()))}),"handleTypeaheadSearch");m.useEffect((()=>()=>window.clearTimeout(F.current)),[]),Ss();const $=m.useCallback((V=>M.current===_.current?.side&&pg(V,_.current?.area)),[]);return v.jsx(mC,{scope:n,searchRef:S,onItemEnter:m.useCallback((V=>{$(V)&&V.preventDefault()}),[$]),onItemLeave:m.useCallback((V=>{$(V)||(I.current?.focus(),x(null))}),[$]),onTriggerLeave:m.useCallback((V=>{$(V)&&V.preventDefault()}),[$]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback((V=>{_.current=V}),[]),children:v.jsx(W,{...G,children:v.jsx(fm,{asChild:!0,trapped:o,onMountAutoFocus:Me(i,(V=>{V.preventDefault(),I.current?.focus({preventScroll:!0})})),onUnmountAutoFocus:s,children:v.jsx(Tc,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:f,onFocusOutside:c,onInteractOutside:d,onDismiss:h,children:v.jsx(tC,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:x,onEntryFocus:Me(u,(V=>{w.isUsingKeyboardRef.current||V.preventDefault()})),preventScrollOnEntryFocus:!0,children:v.jsx($c,{role:"menu","aria-orientation":"vertical","data-state":cg(p.open),"data-radix-menu-content":"",dir:w.dir,...b,...y,ref:T,style:{outline:"none",...y.style},onKeyDown:Me(y.onKeyDown,(V=>{const Q=V.target.closest("[data-radix-menu-content]")===V.currentTarget,ae=V.ctrlKey||V.altKey||V.metaKey,ie=V.key.length===1;Q&&(V.key==="Tab"&&V.preventDefault(),!ae&&ie&&q(V.key));const Se=I.current;if(V.target!==Se||!iC.includes(V.key))return;V.preventDefault();const Ie=E().filter((ne=>!ne.disabled)).map((ne=>ne.ref.current));rg.includes(V.key)&&Ie.reverse(),lg(Ie)})),onBlur:Me(e.onBlur,(V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(F.current),S.current="")})),onPointerMove:Me(e.onPointerMove,Fs((V=>{const Q=V.target,ae=H.current!==V.clientX;if(V.currentTarget.contains(Q)&&ae){const ie=V.clientX>H.current?"right":"left";M.current=ie,H.current=V.clientX}})))})})})})})})}),"MenuContentImpl")),Bu="MenuItem",Jd="menu.itemSelect",CC=m.forwardRef(Ke((function(e,t){const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),s=Kc(Bu,e.__scopeMenu),a=ag(Bu,e.__scopeMenu),u=Qe(t,i),l=m.useRef(!1),f=Ke((()=>{const c=i.current;if(!n&&c){const d=new CustomEvent(Jd,{bubbles:!0,cancelable:!0});c.addEventListener(Jd,(h=>r?.(h)),{once:!0}),xc(c,d),d.defaultPrevented?l.current=!1:s.onClose()}}),"handleSelect");return v.jsx(wC,{...o,ref:u,disabled:n,onClick:Me(e.onClick,f),onPointerDown:c=>{e.onPointerDown?.(c),l.current=!0},onPointerUp:Me(e.onPointerUp,(c=>{l.current||c.currentTarget?.click()})),onKeyDown:Me(e.onKeyDown,(c=>{n||c.target!==c.currentTarget||a.searchRef.current!==""&&c.key===" "||oC.includes(c.key)&&(c.currentTarget.click(),c.preventDefault())}))})}),"MenuItem")),wC=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,s=ag(Bu,n),a=ig(n),u=m.useRef(null),l=Qe(t,u),[f,c]=m.useState(!1),[d,h]=m.useState("");return m.useEffect((()=>{const g=u.current;g&&h((g.textContent??"").trim())}),[i.children]),v.jsx(ku.ItemSlot,{scope:n,disabled:r,textValue:o??d,children:v.jsx(nC,{asChild:!0,...a,focusable:!r,children:v.jsx($t.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:l,onPointerMove:Me(e.onPointerMove,Fs((g=>{r?s.onItemLeave(g):(s.onItemEnter(g),!g.defaultPrevented&&g.currentTarget.focus({preventScroll:!0}))}))),onPointerLeave:Me(e.onPointerLeave,Fs((g=>s.onItemLeave(g)))),onFocus:Me(e.onFocus,(()=>c(!0))),onBlur:Me(e.onBlur,(()=>c(!1)))})})})}),"MenuItemImpl")),[_x,jx]=$r("MenuRadioGroup",{value:void 0,onValueChange:Ke((()=>{}),"onValueChange")}),[Mx,Px]=$r("MenuItemIndicator",{checked:!1}),[Nx,Lx]=$r("MenuSub");function cg(e){return e?"open":"closed"}function Zd(e){return e==="indeterminate"}function lg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function dg(e,t){return e.map(((n,r)=>e[(t+r)%e.length]))}function fg(e,t,n){const r=t.length>1&&Array.from(t).every((a=>a===t[0]))?t[0]:t,o=n?e.indexOf(n):-1;let i=dg(e,Math.max(o,0));r.length===1&&(i=i.filter((a=>a!==n)));const s=i.find((a=>a.toLowerCase().startsWith(r.toLowerCase())));return s!==n?s:void 0}function hg(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i],u=t[s],l=a.x,f=a.y,c=u.x,d=u.y;f>r!=d>r&&n<(c-l)*(r-f)/(d-f)+l&&(o=!o)}return o}function pg(e,t){return t?hg({x:e.clientX,y:e.clientY},t):!1}function Fs(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ke(cg,"getOpenState"),Ke(Zd,"isIndeterminate"),Ke((function(e){return Zd(e)?"indeterminate":e?"checked":"unchecked"}),"getCheckedState"),Ke(lg,"focusFirst"),Ke(dg,"wrapArray"),Ke(fg,"getNextMatch"),Ke(hg,"isPointInPolygon"),Ke(pg,"isPointerInGraceArea"),Ke(Fs,"whenMouse");var EC=lC,DC=dC,AC=pC,xC=gC,OC=CC,SC=Object.defineProperty,ki=(e,t)=>SC(e,"name",{value:t,configurable:!0}),qc="DropdownMenu",[IC,Ux]=qn(qc,[og]),Bi=og(),[TC,mg]=IC(qc),kC=ki((e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:s,modal:a=!0}=e,u=Bi(t),l=m.useRef(null),[f,c]=Po({prop:o,defaultProp:i??!1,onChange:s,caller:qc});return v.jsx(TC,{scope:t,triggerId:Eo(),triggerRef:l,contentId:Eo(),open:f,onOpenChange:c,onOpenToggle:m.useCallback((()=>c((d=>!d))),[c]),modal:a,children:v.jsx(EC,{...u,open:f,onOpenChange:c,dir:r,modal:a,children:n})})}),"DropdownMenu"),BC=m.forwardRef(ki((function(e,t){const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=mg("DropdownMenuTrigger",n),s=Bi(n),a=Qe(t,i.triggerRef);return v.jsx(DC,{asChild:!0,...s,children:v.jsx($t.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:a,onPointerDown:Me(e.onPointerDown,(u=>{r||u.button!==0||u.ctrlKey!==!1||(i.onOpenToggle(),i.open||u.preventDefault())})),onKeyDown:Me(e.onKeyDown,(u=>{r||(["Enter"," "].includes(u.key)&&i.onOpenToggle(),u.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())}))})})}),"DropdownMenuTrigger")),FC=ki((e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bi(t);return v.jsx(AC,{...r,...n})}),"DropdownMenuPortal"),RC=m.forwardRef(ki((function(e,t){const{__scopeDropdownMenu:n,...r}=e,o=mg("DropdownMenuContent",n),i=Bi(n),s=m.useRef(!1);return v.jsx(xC,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:Me(e.onCloseAutoFocus,(a=>{s.current||o.triggerRef.current?.focus(),s.current=!1,a.preventDefault()})),onInteractOutside:Me(e.onInteractOutside,(a=>{const u=a.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,f=u.button===2||l;o.modal&&!f||(s.current=!0)})),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}),"DropdownMenuContent")),_C=m.forwardRef(ki((function(e,t){const{__scopeDropdownMenu:n,...r}=e,o=Bi(n);return v.jsx(OC,{...o,...r,ref:t})}),"DropdownMenuItem")),jC=kC,MC=BC,PC=FC,NC=RC,LC=Object.defineProperty,vr=(e,t)=>LC(e,"name",{value:t,configurable:!0}),Gc="Popover",[gg,Hx]=qn(Gc,[Lo]),Jc=Lo(),[UC,Uo]=gg(Gc),HC=vr((e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Jc(t),u=m.useRef(null),[l,f]=m.useState(!1),[c,d]=Po({prop:r,defaultProp:o??!1,onChange:i,caller:Gc});return v.jsx(Hc,{...a,children:v.jsx(UC,{scope:t,contentId:Eo(),triggerRef:u,open:c,onOpenChange:d,onOpenToggle:m.useCallback((()=>d((h=>!h))),[d]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback((()=>f(!0)),[]),onCustomAnchorRemove:m.useCallback((()=>f(!1)),[]),modal:s,children:n})})}),"Popover"),VC=m.forwardRef(vr((function(e,t){const{__scopePopover:n,...r}=e,o=Uo("PopoverTrigger",n),i=Jc(n),s=Qe(t,o.triggerRef),a=v.jsx($t.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":Zc(o.open),...r,ref:s,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:v.jsx(Vc,{asChild:!0,...i,children:a})}),"PopoverTrigger")),vg="PopoverPortal",[$C,WC]=gg(vg,{forceMount:void 0}),zC=vr((e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Uo(vg,t);return v.jsx($C,{scope:t,forceMount:n,children:v.jsx(No,{present:n||i.open,children:v.jsx(Fc,{asChild:!0,container:o,children:r})})})}),"PopoverPortal"),bi="PopoverContent",KC=m.forwardRef(vr((function(e,t){const n=WC(bi,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Uo(bi,e.__scopePopover);return v.jsx(No,{present:r||i.open,children:i.modal?v.jsx(GC,{...o,ref:t}):v.jsx(JC,{...o,ref:t})})}),"PopoverContent")),qC=Vn("PopoverContent.RemoveScroll"),GC=m.forwardRef(vr((function(e,t){const n=Uo(bi,e.__scopePopover),r=m.useRef(null),o=Qe(t,r),i=m.useRef(!1);return m.useEffect((()=>{const s=r.current;if(s)return Om(s)}),[]),v.jsx(Rc,{as:qC,allowPinchZoom:!0,children:v.jsx(yg,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,(s=>{s.preventDefault(),i.current||n.triggerRef.current?.focus()})),onPointerDownOutside:Me(e.onPointerDownOutside,(s=>{const a=s.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0,l=a.button===2||u;i.current=l}),{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,(s=>s.preventDefault()),{checkForDefaultPrevented:!1})})})}),"PopoverContentModal")),JC=m.forwardRef(vr((function(e,t){const n=Uo(bi,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return v.jsx(yg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),"PopoverContentNonModal")),yg=m.forwardRef(vr((function(e,t){const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:l,onInteractOutside:f,...c}=e,d=Uo(bi,n),h=Jc(n);return Ss(),v.jsx(fm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:v.jsx(Tc,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:l,onDismiss:()=>d.onOpenChange(!1),deferPointerDownOutside:!0,children:v.jsx($c,{"data-state":Zc(d.open),role:"dialog",id:d.contentId,...h,...c,ref:t,style:{...c.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),"PopoverContentImpl"));function Zc(e){return e?"open":"closed"}vr(Zc,"getState");var ZC=HC,XC=VC,YC=zC,QC=KC,ew=Object.defineProperty,tw=(e,t)=>ew(e,"name",{value:t,configurable:!0}),Xc=m.forwardRef(tw((function(e,t){const{pressed:n,defaultPressed:r,onPressedChange:o,...i}=e,[s,a]=Po({prop:n,onChange:o,defaultProp:r??!1,caller:"Toggle"});return v.jsx($t.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:Me(e.onClick,(()=>{e.disabled||a(!s)}))})}),"Toggle")),nw=Object.defineProperty,pt=(e,t)=>nw(e,"name",{value:t,configurable:!0}),[Yc,Vx]=qn("Tooltip",[Lo]),Qc=Lo(),rw=700,Fu="tooltip.open",[ow,el]=Yc("TooltipProvider"),iw=pt((e=>{const{__scopeTooltip:t,delayDuration:n=rw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,s=m.useRef(!0),a=m.useRef(!1),u=m.useRef(0);return m.useEffect((()=>{const l=u.current;return()=>window.clearTimeout(l)}),[]),v.jsx(ow,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:m.useCallback((()=>{r<=0||(window.clearTimeout(u.current),s.current=!1)}),[r]),onClose:m.useCallback((()=>{r<=0||(window.clearTimeout(u.current),u.current=window.setTimeout((()=>s.current=!0),r))}),[r]),isPointerInTransitRef:a,onPointerInTransitChange:m.useCallback((l=>{a.current=l}),[]),disableHoverableContent:o,children:i})}),"TooltipProvider"),Ru="Tooltip",[sw,Fi]=Yc(Ru),aw=pt((e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:a}=e,u=el(Ru,e.__scopeTooltip),l=Qc(t),[f,c]=m.useState(null),[d,h]=m.useState(void 0),g=Eo(),y=m.useRef(0),p=s??u.disableHoverableContent,w=a??u.delayDuration,b=m.useRef(!1),[C,E]=Po({prop:r,defaultProp:o??!1,onChange:pt((S=>{S?(u.onOpen(),document.dispatchEvent(new CustomEvent(Fu))):u.onClose(),i?.(S)}),"onChange"),caller:Ru}),A=m.useMemo((()=>C?b.current?"delayed-open":"instant-open":"closed"),[C]),x=m.useCallback((()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,E(!0)}),[E]),I=m.useCallback((()=>{window.clearTimeout(y.current),y.current=0,E(!1)}),[E]),T=m.useCallback((()=>{window.clearTimeout(y.current),y.current=window.setTimeout((()=>{b.current=!0,E(!0),y.current=0}),w)}),[w,E]);m.useEffect((()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)}),[]);const F=d??g;return v.jsx(Hc,{...l,children:v.jsx(sw,{scope:t,contentId:F,setContentId:h,open:C,stateAttribute:A,trigger:f,onTriggerChange:c,onTriggerEnter:m.useCallback((()=>{u.isOpenDelayedRef.current?T():x()}),[u.isOpenDelayedRef,T,x]),onTriggerLeave:m.useCallback((()=>{p?I():(window.clearTimeout(y.current),y.current=0)}),[I,p]),onOpen:x,onClose:I,disableHoverableContent:p,children:n})})}),"Tooltip"),Xd="TooltipTrigger",uw=m.forwardRef(pt((function(e,t){const{__scopeTooltip:n,...r}=e,o=Fi(Xd,n),i=el(Xd,n),s=Qc(n),a=Qe(t,m.useRef(null),o.onTriggerChange),u=m.useRef(!1),l=m.useRef(!1),f=m.useCallback((()=>u.current=!1),[]);return m.useEffect((()=>()=>document.removeEventListener("pointerup",f)),[f]),v.jsx(Vc,{asChild:!0,...s,children:v.jsx($t.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:a,onPointerMove:Me(e.onPointerMove,(c=>{c.pointerType!=="touch"&&(l.current||i.isPointerInTransitRef.current||(o.onTriggerEnter(),l.current=!0))})),onPointerLeave:Me(e.onPointerLeave,(()=>{o.onTriggerLeave(),l.current=!1})),onPointerDown:Me(e.onPointerDown,(()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})})),onFocus:Me(e.onFocus,(()=>{u.current||o.onOpen()})),onBlur:Me(e.onBlur,o.onClose),onClick:Me(e.onClick,o.onClose)})})}),"TooltipTrigger")),bg="TooltipPortal",[cw,lw]=Yc(bg,{forceMount:void 0}),dw=pt((e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Fi(bg,t);return v.jsx(cw,{scope:t,forceMount:n,children:v.jsx(No,{present:n||i.open,children:v.jsx(Fc,{asChild:!0,container:o,children:r})})})}),"TooltipPortal"),Ci="TooltipContent",fw=m.forwardRef(pt((function(e,t){const n=lw(Ci,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=Fi(Ci,e.__scopeTooltip);return v.jsx(No,{present:r||s.open,children:s.disableHoverableContent?v.jsx(Cg,{side:o,...i,ref:t}):v.jsx(hw,{side:o,...i,ref:t})})}),"TooltipContent")),hw=m.forwardRef(pt((function(e,t){const n=Fi(Ci,e.__scopeTooltip),r=el(Ci,e.__scopeTooltip),o=m.useRef(null),i=Qe(t,o),[s,a]=m.useState(null),{trigger:u,onClose:l}=n,f=o.current,{onPointerInTransitChange:c}=r,d=m.useCallback((()=>{a(null),c(!1)}),[c]),h=m.useCallback(((g,y)=>{const p=g.currentTarget,w={x:g.clientX,y:g.clientY},b=xg([...Eg(w,wg(w,p.getBoundingClientRect())),...Dg(y.getBoundingClientRect())]);a(b),c(!0)}),[c]);return m.useEffect((()=>()=>d()),[d]),m.useEffect((()=>{if(u&&f){const g=pt((p=>h(p,f)),"handleTriggerLeave"),y=pt((p=>h(p,u)),"handleContentLeave");return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",y)}}}),[u,f,h,d]),m.useEffect((()=>{if(s){const g=pt((y=>{const p=y.target,w={x:y.clientX,y:y.clientY},b=u?.contains(p)||f?.contains(p),C=!Ag(w,s);b?d():C&&(d(),l())}),"handleTrackPointerGrace");return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}}),[u,f,s,l,d]),v.jsx(Cg,{...e,ref:i})}),"TooltipContentHoverable")),pw=Ac("TooltipContent"),Cg=m.forwardRef(pt((function(e,t){const{__scopeTooltip:n,children:r,"aria-label":o,id:i,onEscapeKeyDown:s,onPointerDownOutside:a,...u}=e,l=Fi(Ci,n),f=Qc(n),{onClose:c}=l;m.useEffect((()=>(document.addEventListener(Fu,c),()=>document.removeEventListener(Fu,c))),[c]),m.useEffect((()=>{if(l.trigger){const h=pt((g=>{g.target instanceof Node&&g.target.contains(l.trigger)&&c()}),"handleScroll");return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}}),[l.trigger,c]);const{setContentId:d}=l;return Yt((()=>(d(i),()=>{d(void 0)})),[i,d]),v.jsx(Tc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:c,children:v.jsxs($c,{"data-state":l.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:l.contentId,...f,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[v.jsx(pw,{children:r}),o?v.jsx(My,{id:l.contentId,role:"tooltip",children:o}):null]})})}),"TooltipContentImpl"));function wg(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Eg(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}function Dg(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function Ag(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i],u=t[s],l=a.x,f=a.y,c=u.x,d=u.y;f>r!=d>r&&n<(c-l)*(r-f)/(d-f)+l&&(o=!o)}return o}function xg(e){const t=e.slice();return t.sort(((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0)),Og(t)}function Og(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if(!((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x)))break;t.pop()}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if(!((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x)))break;n.pop()}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}pt(wg,"getExitSideFromRect"),pt(Eg,"getPaddedExitPoints"),pt(Dg,"getPointsFromRect"),pt(Ag,"isPointInPolygon"),pt(xg,"getHull"),pt(Og,"getHullPresorted");var mw=iw,gw=aw,vw=uw,yw=dw,bw=fw;function Zs(e){const t=new Map;return(...n)=>{const r=JSON.stringify(n.map((s=>Xt(s)))),o=t.get(r);if(o!==void 0)return o;const i=e(...n);return t.set(r,i),i}}const Sg=Zs(((...e)=>new Intl.DateTimeFormat(...e))),Yd=Zs(((...e)=>new Intl.RelativeTimeFormat(...e))),Cw=Zs(((...e)=>new Intl.ListFormat(...e))),Mr=Zs(((...e)=>new Intl.NumberFormat(...e)));function Ig(e,t){const n=m.useRef(e);m.useEffect((()=>{n.current=e}),[e]),m.useEffect((()=>{if(!t&&t!==0)return;const r=setInterval((()=>{n.current()===!1&&clearInterval(r)}),t);return()=>clearInterval(r)}),[t])}function Tg(){const[e,t]=m.useReducer((n=>n+1),0);return[t,e]}function tl(e){let t=Math.max(e,0);const n=t%1e3;t=Math.floor(t/1e3);const r=t%60;t=Math.floor(t/60);const o=t%60;t=Math.floor(t/60);const i=t%24;t=Math.floor(t/24);const s=t%7;return{weeks:Math.floor(t/7),days:s,hours:i,minutes:o,seconds:r,milliseconds:n}}const kg={weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second",milliseconds:"millisecond"};function ww(e,t){let n;t?n=t:n=Mr().resolvedOptions().locale;const r=tl(e),o=[];for(const[i,s]of Object.entries(r)){if(s===0||i==="milliseconds")continue;const a=Mr(n,{style:"unit",unit:kg[i],unitDisplay:"narrow"});o.push(a.format(s))}return o.length||o.push(Mr(n,{style:"unit",unit:"second",unitDisplay:"narrow"}).format(0)),o.join(" ")}function Ew(e,t){let n;t?n=t:n=Mr().resolvedOptions().locale;const r=tl(e),o=[];for(const[i,s]of Object.entries(r)){if(s===0||i==="milliseconds")continue;const a=Mr(n,{style:"unit",unit:kg[i],unitDisplay:"long"});o.push(a.format(s))}return o.length||o.push(Mr(n,{style:"unit",unit:"second",unitDisplay:"long"}).format(0)),o.join(" ")}function Qd(e){return e instanceof Date?e.getTime():new Date(e).getTime()}function Bg(e,t){return Qd(t)-Qd(e)}const _a=m.forwardRef((({duration:e,from:t,to:n,locale:r,dateTime:o,title:i=Ew,children:s=ww,interval:a=500,asChild:u,...l},f)=>{const c=u?vt:"time",[d,h]=Tg(),g=m.useMemo((()=>e!==void 0?e:t!==void 0?Bg(t,n??Date.now()):0),[e,t,n,h]),y=m.useMemo((()=>(function(b){const C=Math.max(b,0);if(C===0)return"PT0S";const{weeks:E,days:A,hours:x,minutes:I,seconds:T,milliseconds:F}=tl(C);let S="P";return E>0&&(S+=`${E}W`),A>0&&(S+=`${A}D`),(x>0||I>0||T>0||F>0)&&(S+="T",x>0&&(S+=`${x}H`),I>0&&(S+=`${I}M`),(T>0||F>0)&&(S+=F>0?`${T}.${F.toString().padStart(3,"0").replace(/0+$/,"")}S`:`${T}S`)),S})(g)),[g]),p=m.useMemo((()=>typeof i=="function"?i(g,r):i),[i,g,r]),w=m.useMemo((()=>typeof s=="function"?s(g,r):s),[s,g,r]);return Ig(d,t!==void 0&&n===void 0&&a),v.jsx(c,{...l,ref:f,dateTime:o??y,title:p,children:w})}));function es(e,t,n){return e===1?t:n??`${t}s`}function ja(e,t){return Bg(e,t??Date.now())>=3e3}const Dw={locale:"en",dir:"ltr",USER_SELF:"you",USER_UNKNOWN:"Anonymous",COPY_TO_CLIPBOARD:"Copy",LIST_REMAINING:e=>`${e} more`,LIST_REMAINING_USERS:e=>`${e} ${es(e,"other")}`,LIST_REMAINING_COMMENTS:e=>`${e} more ${es(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 Ye(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(Dc,{emoji:t})]}),COMMENT_REACTION_DESCRIPTION:(e,t)=>`${t} ${es(t,"reaction")}, react with ${e}`,THREAD_RESOLVE:"Resolve thread",THREAD_UNRESOLVE:"Re-open thread",THREAD_SUBSCRIBE:"Subscribe to thread",THREAD_UNSUBSCRIBE:"Unsubscribe from thread",THREAD_NEW_INDICATOR:"New",THREAD_NEW_INDICATOR_DESCRIPTION:"New comments",THREAD_SHOW_MORE_COMMENTS:e=>`Show ${e} more ${es(e,"reply","replies")}`,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_SUMMARY_AUTHORS_LIST:e=>e===void 0?"Unattributed":e,HISTORY_VERSION_PREVIEW_AUTHORS_LIST:e=>e===void 0?"Unattributed edits":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.",AI_COMPOSER_PLACEHOLDER:"Ask anything…",AI_COMPOSER_SEND:"Send",AI_COMPOSER_ABORT:"Abort response",AI_CHAT_MESSAGE_DELETED:"This message has been deleted.",AI_CHAT_MESSAGE_THINKING:"Thinking…",AI_CHAT_MESSAGE_REASONING:(e,t)=>e?v.jsx(v.Fragment,{children:"Reasoning…"}):v.jsxs(v.Fragment,{children:["Reasoned",ja(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(_a,{className:"lb-duration lb-ai-chat-message-reasoning-duration",from:t.startedAt,to:t.endedAt})]}):null]}),AI_CHAT_MESSAGE_RETRIEVAL:(e,t)=>t.kind==="knowledge"?e?v.jsxs(v.Fragment,{children:["Searching"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),"…"]}):v.jsxs(v.Fragment,{children:["Searched"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),ja(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(_a,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):t.kind==="web"?e?v.jsxs(v.Fragment,{children:["Searching the web",t.query?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,"…"]}):v.jsxs(v.Fragment,{children:["Searched the web",t.query?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,ja(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(_a,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):Ye(0,"Unexpected retrieval kind"),AI_CHAT_MESSAGES_ERROR:()=>"There was an error while getting the messages.",AI_TOOL_CONFIRMATION_CONFIRM:"Confirm",AI_TOOL_CONFIRMATION_CANCEL:"Cancel"},Aw=m.createContext(void 0);function Mt(e){const t=m.useContext(Aw);return m.useMemo((()=>({...Dw,...t,...e})),[t,e])}function ef(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Fg={Anchor:"a"},_u=m.createContext(void 0);function xw({children:e,components:t}){const n=m.useContext(_u),r=m.useMemo((()=>({...Fg,...n,...t})),[n,t]);return v.jsx(_u.Provider,{value:r,children:e})}const Ow=m.createContext({});function Ri(){return m.useContext(Ow)}const Sw=/Mac|iPod|iPhone|iPad/;function Rg(){return typeof window<"u"&&Sw.test(window.navigator.platform)}const Iw={title:"Alt",key:"⌥"},Ma={title:"Command",key:"⌘"},Pa={title:"Ctrl",key:"⌃"},Tw={title:"Shift",key:"⇧"},kw={title:"Enter",key:"⏎"},tf={title:"Space",key:"␣"},nf={title:"Escape",key:"⎋"},_g={alt:()=>Iw,mod:()=>Rg()?Ma:Pa,control:()=>Pa,ctrl:()=>Pa,command:()=>Ma,cmd:()=>Ma,shift:()=>Tw,enter:()=>kw," ":()=>tf,space:()=>tf,escape:()=>nf,esc:()=>nf},jt=m.forwardRef((({children:e,content:t,multiline:n,className:r,...o},i)=>{const{portalContainer:s}=Ri();return v.jsxs(gw,{disableHoverableContent:!0,children:[v.jsx(vw,{asChild:!0,ref:i,children:e}),v.jsx(yw,{container:s,children:v.jsx(bw,{className:Ne("lb-root lb-portal lb-tooltip",n&&"lb-tooltip:multiline",r),side:"top",align:"center",updatePositionStrategy:"always",sideOffset:6,collisionPadding:10,...o,children:t})})]})})),nl=m.forwardRef((({children:e,content:t,shortcut:n,...r},o)=>{const i=m.useMemo((()=>n?(function(s){const a=s.split("-");return v.jsx(v.Fragment,{children:a.map(((u,l)=>{const f=u.toLowerCase();return f in _g?v.jsx(Bw,{name:f},l):v.jsx("span",{children:u},l)}))})})(n):null),[n]);return v.jsx(jt,{content:v.jsxs(v.Fragment,{children:[t,i&&v.jsx("kbd",{className:"lb-tooltip-shortcut",children:i})]}),...r,ref:o,children:e})}));function Bw({name:e,...t}){const{title:n,key:r}=m.useMemo((()=>_g[e]?.()),[e]);return v.jsx("abbr",{title:n,...t,children:r})}const Xs=mw;function Ys({src:e,name:t,className:n,children:r,tooltip:o,outline:i,style:s,...a}){const u=m.useMemo((()=>t?(function(c){return c.trim().split(" ").reduce(((d,h,g,y)=>(g!==0&&g!==y.length-1||(d+=h.charAt(0).toLocaleUpperCase()),d)),"")})(t):void 0),[t]),l=typeof i=="object"?i:typeof i=="string"?{color:i}:i===!0?{}:void 0,f=v.jsx("div",{className:Ne("lb-avatar",n),"data-variant":l?"outline":"default",style:{"--lb-avatar-outline-color":l?.color,"--lb-avatar-outline-width":ef(l?.width),"--lb-avatar-outline-gap":ef(l?.gap),...s},...a,children:v.jsx("div",{className:"lb-avatar-content",children:r??(e?v.jsx("img",{className:"lb-avatar-image",src:e,alt:t}):u?v.jsx("span",{className:"lb-avatar-fallback","aria-label":t,title:t,children:u}):null)})});return o?v.jsx(Xs,{children:v.jsx(jt,{content:o,sideOffset:6,collisionPadding:10,side:"top",align:"center",children:f})}):f}function Fw({userId:e,icon:t,variant:n="default",tooltip:r,...o}){const{user:i,isLoading:s}=Lp(e);return v.jsx(Ys,{src:i?.avatar,name:s?void 0:i?.name??e,outline:n==="outline"&&typeof i?.color=="string"?i.color:void 0,"data-loading":s?"":void 0,tooltip:r,...o,children:!t||!s&&i?.avatar?null:t})}function Rw({groupId:e,icon:t,variant:n="default",tooltip:r,...o}){const{info:i,isLoading:s}=Cc(e);return v.jsx(Ys,{src:i?.avatar,name:s?void 0:i?.name??e,outline:n==="outline"&&typeof i?.color=="string"?i.color:void 0,"data-loading":s?"":void 0,tooltip:r,...o,children:!t||!s&&i?.avatar?null:t})}function ju({userId:e,icon:t,variant:n="default",...r}){const o=Mt();return e?v.jsx(Fw,{userId:e,icon:t,variant:n,...r}):v.jsx(Ys,{name:o.USER_UNKNOWN,outline:n==="outline",...r,children:t})}function _w({groupId:e,icon:t,variant:n="default",...r}){return e?v.jsx(Rw,{groupId:e,icon:t,variant:n,...r}):v.jsx(Ys,{outline:n==="outline",...r,children:t})}function Je({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:Ne("lb-icon",t),...n,children:e})}function jw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M14.5 8.5 10 13 5.5 8.5"})})}const rl=m.forwardRef((({variant:e="default",size:t="default",disableable:n=!0,className:r,children:o,...i},s)=>v.jsx("button",{type:"button",className:Ne("lb-button",!n&&"lb-button:non-disableable",r),"data-variant":e,"data-size":t,...i,ref:s,children:o}))),Jt=m.forwardRef((({icon:e,children:t,...n},r)=>v.jsxs(rl,{...n,ref:r,children:[e?v.jsx("span",{className:"lb-icon-container",children:e}):null,t?v.jsx("span",{className:"lb-button-label",children:t}):null]})));function ol({groupId:e,className:t,children:n,...r}){const{info:o,isLoading:i}=Cc(e);return v.jsxs("span",{className:Ne("lb-name lb-group",t),"data-loading":i?"":void 0,...r,children:[i?null:o?.name??e,n]})}function Mw({groupId:e,className:t,...n}){const{info:r}=Cc(e);return r?.description?v.jsx("span",{className:Ne("lb-group-description",t),...n,children:r.description}):null}m.forwardRef((({icon:e,children:t,className:n,...r},o)=>v.jsxs(rl,{...r,type:"button",className:Ne("lb-select-button",n),ref:o,children:[e?v.jsx("span",{className:"lb-icon-container",children:e}):null,t?v.jsx("span",{className:"lb-button-label",children:t}):null,v.jsx("span",{className:"lb-select-button-chevron",children:v.jsx(jw,{})})]})));const Pw=m.forwardRef((({values:e,formatRemaining:t,truncate:n,locale:r,className:o,asChild:i,...s},a)=>{const u=i?vt:"span",l=Mt(),f=t??l.LIST_REMAINING,c=m.useMemo((()=>{const d=n&&n<e.length-1?[...e.slice(0,n),f(e.length-n)]:[...e],h=Array(d.length).fill(".");return Cw(r).formatToParts(h).map((g=>g.type==="element"?d.shift():g.value))}),[f,r,n,e]);return v.jsx(u,{className:Ne("lb-list",o),...s,ref:a,children:c})}));function Nw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M10 4v12m6-6-6 6-6-6"})})}function jg(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m14.077 11.737-3.723 3.62c-1.55 1.507-4.128 1.507-5.678 0-1.543-1.5-1.543-4.02 0-5.52l5.731-5.573c1.034-1.006 2.754-1.007 3.789-.003 1.03 1 1.032 2.682.003 3.684l-5.744 5.572a1.377 1.377 0 0 1-1.893 0 1.283 1.283 0 0 1-.392-.92c0-.345.14-.676.392-.92L10.348 8"})})}function Lw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M10 4a3.5 3.5 0 0 0-3.5 3.5c0 3.5-2 6.5-2 6.5h11s-2-3-2-6.5A3.5 3.5 0 0 0 10 4ZM7.55 14a2.5 2.5 0 0 0 4.9 0"})})}function Uw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M14 14H4.5s2-3 2-6.5c0-.3.05-.6.12-.88M8.2 4.5a3.5 3.5 0 0 1 5.3 3c0 .96.15 1.88.37 2.7M7.55 14a2.5 2.5 0 0 0 4.9 0M4.5 4.5l11 11"})})}function Hw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M5.5 10h6.63m0 5.75H5.5V4.25h5.63M11.125 10a2.875 2.875 0 0 0 0-5.75m1 11.5a2.875 2.875 0 0 0 0-5.75"})})}function Vw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M16 6L8 14L4 10"})})}function $w(e){return v.jsxs(Je,{...e,children:[v.jsx("circle",{cx:10,cy:10,r:7}),v.jsx("path",{d:"m13 8-4 4-2-2"})]})}function Ww(e){return v.jsxs(Je,{...e,children:[v.jsx("circle",{cx:10,cy:10,r:7,fill:"currentColor"}),v.jsx("path",{d:"m13 8-4 4-2-2",stroke:"var(--lb-icon-background)"})]})}function zw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m7.5 6-4 4 4 4m5-8 4 4-4 4"})})}function il(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M15 5L5 15"}),v.jsx("path",{d:"M5 5L15 15"})]})}function Kw(e){return v.jsx(Je,{...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 qw(e){return v.jsx(Je,{...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 Gw(e){return v.jsxs(Je,{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 Jw(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14Z"}),v.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h.007"}),v.jsx("path",{d:"M12 8h.007"}),v.jsx("circle",{cx:8,cy:8,r:.25}),v.jsx("circle",{cx:12,cy:8,r:.25})]})}function rf(e){return v.jsxs(Je,{...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 Zw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M15 4.25H8m4 11.5H5m6.75-11.5-3.5 11.5"})})}function Xw(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),v.jsx("path",{d:"M13 7v3.7c0 1.105.855 2.1 1.9 2.1a2.12 2.12 0 0 0 2.1-2.1V10a7 7 0 1 0-2.8 5.6"})]})}function Yw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M9 15A6 6 0 1 0 9 3a6 6 0 0 0 0 12Zm7.5 1.5-3.25-3.25"})})}function Qw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m5 16 12-6L5 4l2 6-2 6ZM7 10h10"})})}function _i(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M3 10a7 7 0 0 1 7-7",className:"lb-icon-spinner"})})}function eE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M15.5 10h-11m4.669 0C7.599 9.44 6.5 8.484 6.5 7.125 6.5 5.537 7.79 4.25 10 4.25c1.654 0 2.793.721 3.261 1.75M6.74 14c.468 1.029 1.607 1.75 3.261 1.75 2 0 3.5-1 3.5-2.5 0-.085-.004-.169-.013-.25"})})}function tE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M8 9.75a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm0 0c-2.42 0-4.055 1.72-4.422 4.004-.087.545.37.996.922.996h7c.552 0 1.01-.45.922-.996C12.055 11.47 10.42 9.75 8 9.75ZM15 14.75h.5c.552 0 1.004-.45.912-.995-.317-1.888-1.485-4.114-3.412-4.505.863-.222 1.5-1.068 1.5-2a2 2 0 0 0-2-2"})})}function Mg(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"m3.794 13.526 5.326-9.89a1 1 0 0 1 1.76 0l5.326 9.89a1 1 0 0 1-.88 1.474H4.674a1 1 0 0 1-.88-1.474ZM10 7.5v2m0 2.5h.007"}),v.jsx("circle",{cx:10,cy:12,r:.25})]})}function hr(){return Mo(Ve()[Oe].currentUserId)??null}function sl(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function Pg({isLoading:e,name:t,className:n,children:r,...o}){return v.jsxs("span",{className:Ne("lb-name lb-user",n),"data-loading":e?"":void 0,...o,children:[e?null:t,r]})}function nE({userId:e,replaceSelf:t,...n}){const r=hr(),{user:o,isLoading:i}=Lp(e),s=Mt(),a=m.useMemo((()=>t&&r===e?s.USER_SELF:o?.name??s.USER_UNKNOWN),[t,r,e,s.USER_SELF,s.USER_UNKNOWN,o?.name]);return v.jsx(Pg,{isLoading:i,name:a,...n})}function Oo({userId:e,...t}){const n=Mt();return e?v.jsx(nE,{userId:e,...t}):v.jsx(Pg,{isLoading:!1,name:n.USER_UNKNOWN,...t})}function Mu(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ng=m.forwardRef((({asChild:e,...t},n)=>{const{portalContainer:r}=Ri(),o=r??document?.body,i=e?vt:"div";return o?Oi.createPortal(v.jsx(i,{"data-liveblocks-portal":"",...t,ref:n}),o):null}));function So(e){const[t]=m.useState(e);return t}function rE(e,t){t&&(typeof e=="function"?e(t):e&&"current"in e&&(e.current=t))}function ji(...e){return m.useCallback((t=>(function(n,...r){for(const o of r)rE(o,n)})(t,...e)),e)}function oE(e,t){const n=t,r=m.useRef(e);return r.current=e,m.useMemo((()=>i=>{const s=r.current;return s?(function(a){return!!(a.prototype&&"isReactComponent"in a.prototype)})(s)?v.jsx(s,{...i}):s(i):v.jsx(n,{...i})}),[n])}function of(e){return Object.prototype.toString.call(e)==="[object Object]"}function ft(e){var t,n;return of(e)!==!1&&((t=e.constructor)===void 0||of(n=t.prototype)!==!1&&n.hasOwnProperty("isPrototypeOf")!==!1)}var iE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=R.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},sE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=_e.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},aE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=U.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Rs=new WeakMap,_s=new WeakMap,ii=new WeakMap,sf=new WeakMap,af=new WeakMap,uf=new WeakMap,cf=new WeakMap,R={ancestors(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=R.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],s=t[n];return R.equals(r,o)&&i>s},endsAt(e,t){var n=e.length,r=e.slice(0,n),o=t.slice(0,n);return R.equals(r,o)},endsBefore(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),i=e[n],s=t[n];return R.equals(r,o)&&i<s},equals:(e,t)=>e.length===t.length&&e.every(((n,r)=>n===t[r])),hasPrevious:e=>e[e.length-1]>0,isAfter:(e,t)=>R.compare(e,t)===1,isAncestor:(e,t)=>e.length<t.length&&R.compare(e,t)===0,isBefore:(e,t)=>R.compare(e,t)===-1,isChild:(e,t)=>e.length===t.length+1&&R.compare(e,t)===0,isCommon:(e,t)=>e.length<=t.length&&R.compare(e,t)===0,isDescendant:(e,t)=>e.length>t.length&&R.compare(e,t)===0,isParent:(e,t)=>e.length+1===t.length&&R.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]&&R.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(!R.isAncestor(t,e)&&!R.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;(R.equals(i,r)||R.endsBefore(i,r)||R.isAncestor(i,r))&&(r[i.length-1]+=1);break;case"remove_node":var{path:s}=t;if(R.equals(s,r)||R.isAncestor(s,r))return null;R.endsBefore(s,r)&&(r[s.length-1]-=1);break;case"merge_node":var{path:a,position:u}=t;R.equals(a,r)||R.endsBefore(a,r)?r[a.length-1]-=1:R.isAncestor(a,r)&&(r[a.length-1]-=1,r[a.length]+=u);break;case"split_node":var{path:l,position:f}=t;if(R.equals(l,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else R.endsBefore(l,r)?r[l.length-1]+=1:R.isAncestor(l,r)&&e[l.length]>=f&&(r[l.length-1]+=1,r[l.length]-=f);break;case"move_node":var{path:c,newPath:d}=t;if(R.equals(c,d))return r;if(R.isAncestor(c,r)||R.equals(c,r)){var h=d.slice();return R.endsBefore(c,d)&&c.length<d.length&&(h[c.length-1]-=1),h.concat(r.slice(c.length))}R.isSibling(c,d)&&(R.isAncestor(d,r)||R.equals(d,r))?R.endsBefore(c,r)?r[c.length-1]-=1:r[c.length-1]+=1:R.endsBefore(d,r)||R.equals(d,r)||R.isAncestor(d,r)?(R.endsBefore(c,r)&&(r[c.length-1]-=1),r[d.length-1]+=1):R.endsBefore(c,r)&&(R.equals(d,r)&&(r[d.length-1]+=1),r[c.length-1]-=1)}return r}};function si(e){return si=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},si(e)}function uE(e){var t=(function(n,r){if(si(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(si(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return si(t)==="symbol"?t:String(t)}function kt(e,t,n){return(t=uE(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lf(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 Jo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var cE={transform(e,t){e.children=kl(e.children);var n=e.selection&&kl(e.selection);try{n=((r,o,i)=>{switch(i.type){case"insert_node":var{path:s,node:a}=i,u=ee.parent(r,s),l=s[s.length-1];if(l>u.children.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(s,"] because the destination is past the end of the node."));if(u.children.splice(l,0,a),o)for(var[f,c]of U.points(o))o[c]=_e.transform(f,i);break;case"insert_text":var{path:d,offset:h,text:g}=i;if(g.length===0)break;var y=ee.leaf(r,d),p=y.text.slice(0,h),w=y.text.slice(h);if(y.text=p+g+w,o)for(var[b,C]of U.points(o))o[C]=_e.transform(b,i);break;case"merge_node":var{path:E}=i,A=ee.get(r,E),x=R.previous(E),I=ee.get(r,x),T=ee.parent(r,E),F=E[E.length-1];if(he.isText(A)&&he.isText(I))I.text+=A.text;else{if(he.isText(A)||he.isText(I))throw new Error('Cannot apply a "merge_node" operation at path ['.concat(E,"] to nodes of different interfaces: ").concat(ht.stringify(A)," ").concat(ht.stringify(I)));I.children.push(...A.children)}if(T.children.splice(F,1),o)for(var[S,k]of U.points(o))o[k]=_e.transform(S,i);break;case"move_node":var{path:_,newPath:M}=i;if(R.isAncestor(_,M))throw new Error("Cannot move a path [".concat(_,"] to new path [").concat(M,"] because the destination is inside itself."));var H=ee.get(r,_),W=ee.parent(r,_),G=_[_.length-1];W.children.splice(G,1);var q=R.transform(_,i),$=ee.get(r,R.parent(q)),V=q[q.length-1];if($.children.splice(V,0,H),o)for(var[Q,ae]of U.points(o))o[ae]=_e.transform(Q,i);break;case"remove_node":var{path:ie}=i,Se=ie[ie.length-1];if(ee.parent(r,ie).children.splice(Se,1),o)for(var[Ie,ne]of U.points(o)){var B=_e.transform(Ie,i);if(o!=null&&B!=null)o[ne]=B;else{var X=void 0,K=void 0;for(var[Y,de]of ee.texts(r)){if(R.compare(de,ie)!==-1){K=[Y,de];break}X=[Y,de]}var pe=!1;X&&K&&(pe=R.equals(K[1],ie)?!R.hasPrevious(K[1]):R.common(X[1],ie).length<R.common(K[1],ie).length),X&&!pe?(Ie.path=X[1],Ie.offset=X[0].text.length):K?(Ie.path=K[1],Ie.offset=0):o=null}}break;case"remove_text":var{path:fe,offset:we,text:Ce}=i;if(Ce.length===0)break;var se=ee.leaf(r,fe),te=se.text.slice(0,we),me=se.text.slice(we+Ce.length);if(se.text=te+me,o)for(var[Ae,Pe]of U.points(o))o[Pe]=_e.transform(Ae,i);break;case"set_node":var{path:Fe,properties:re,newProperties:J}=i;if(Fe.length===0)throw new Error("Cannot set properties on the root node!");var oe=ee.get(r,Fe);for(var ge in J){if(ge==="children"||ge==="text")throw new Error('Cannot set the "'.concat(ge,'" property of nodes!'));var ve=J[ge];ve==null?delete oe[ge]:oe[ge]=ve}for(var Te in re)J.hasOwnProperty(Te)||delete oe[Te];break;case"set_selection":var{newProperties:We}=i;if(We==null)o=We;else{if(o==null){if(!U.isRange(We))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat(ht.stringify(We)," when there is no current selection."));o=Jo({},We)}for(var Le in We){var et=We[Le];if(et==null){if(Le==="anchor"||Le==="focus")throw new Error('Cannot remove the "'.concat(Le,'" selection property'));delete o[Le]}else o[Le]=et}}break;case"split_node":var{path:ut,position:Nt,properties:hn}=i;if(ut.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(ut,"] because the root node cannot be split."));var Gn,pn=ee.get(r,ut),Mi=ee.parent(r,ut),ta=ut[ut.length-1];if(he.isText(pn)){var Ho=pn.text.slice(0,Nt),Pi=pn.text.slice(Nt);pn.text=Ho,Gn=Jo(Jo({},hn),{},{text:Pi})}else{var Ni=pn.children.slice(0,Nt),Vo=pn.children.slice(Nt);pn.children=Ni,Gn=Jo(Jo({},hn),{},{children:Vo})}if(Mi.children.splice(ta+1,0,Gn),o)for(var[$o,O]of U.points(o))o[O]=_e.transform($o,i)}return o})(e,n,t)}finally{e.children=Bl(e.children),e.selection=n?Bv(n)?Bl(n):n:null}}},lE={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)}},dE={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)}},Lg=(e,t)=>{for(var n in e){var r=e[n],o=t[n];if(ft(r)&&ft(o)){if(!Lg(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 s in t)if(e[s]===void 0&&t[s]!==void 0)return!1;return!0};function Mn(e,t){if(e==null)return{};var n,r,o=(function(s,a){if(s==null)return{};var u,l,f={},c=Object.keys(s);for(l=0;l<c.length;l++)u=c[l],a.indexOf(u)>=0||(f[u]=s[u]);return f})(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 fE=["anchor","focus"];function df(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 U={edges(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,{anchor:r,focus:o}=e;return U.isBackward(e)===n?[r,o]:[o,r]},end(e){var[,t]=U.edges(e);return t},equals:(e,t)=>_e.equals(e.anchor,t.anchor)&&_e.equals(e.focus,t.focus),surrounds(e,t){var n=U.intersection(e,t);return!!n&&U.equals(n,t)},includes(e,t){if(U.isRange(t)){if(U.includes(e,t.anchor)||U.includes(e,t.focus))return!0;var[n,r]=U.edges(e),[o,i]=U.edges(t);return _e.isBefore(n,o)&&_e.isAfter(r,i)}var[s,a]=U.edges(e),u=!1,l=!1;return _e.isPoint(t)?(u=_e.compare(t,s)>=0,l=_e.compare(t,a)<=0):(u=R.compare(t,s.path)>=0,l=R.compare(t,a.path)<=0),u&&l},intersection(e,t){var n=Mn(e,fE),[r,o]=U.edges(e),[i,s]=U.edges(t),a=_e.isBefore(r,i)?i:r,u=_e.isBefore(o,s)?o:s;return _e.isBefore(u,a)?null:(function(l){for(var f=1;f<arguments.length;f++){var c=arguments[f]!=null?arguments[f]:{};f%2?df(Object(c),!0).forEach((function(d){kt(l,d,c[d])})):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(c)):df(Object(c)).forEach((function(d){Object.defineProperty(l,d,Object.getOwnPropertyDescriptor(c,d))}))}return l})({anchor:a,focus:u},n)},isBackward(e){var{anchor:t,focus:n}=e;return _e.isAfter(t,n)},isCollapsed(e){var{anchor:t,focus:n}=e;return _e.equals(t,n)},isExpanded:e=>!U.isCollapsed(e),isForward:e=>!U.isBackward(e),isRange:e=>ft(e)&&_e.isPoint(e.anchor)&&_e.isPoint(e.focus),*points(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]},start(e){var[t]=U.edges(e);return t},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return rc(e,(r=>{if(r===null)return null;var o,i,{affinity:s="inward"}=n;if(s==="inward"){var a=U.isCollapsed(r);U.isForward(r)?(o="forward",i=a?o:"backward"):(o="backward",i=a?o:"forward")}else s==="outward"?U.isForward(r)?(o="backward",i="forward"):(o="forward",i="backward"):(o=s,i=s);var u=_e.transform(r.anchor,t,{affinity:o}),l=_e.transform(r.focus,t,{affinity:i});if(!u||!l)return null;r.anchor=u,r.focus=l}))}},ff=e=>ft(e)&&ee.isNodeList(e.children)&&!D.isEditor(e),le={isAncestor:e=>ft(e)&&ee.isNodeList(e.children),isElement:ff,isElementList:e=>Array.isArray(e)&&e.every((t=>le.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 ff(e)&&e[n]===t},matches(e,t){for(var n in t)if(n!=="children"&&e[n]!==t[n])return!1;return!0}},hE=["children"],pE=["text"],hf=new WeakMap,ee={ancestor(e,t){var n=ee.get(e,t);if(he.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(t,"] because it refers to a text node instead: ").concat(ht.stringify(n)));return n},ancestors(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of R.ancestors(t,n)){var o=[ee.ancestor(e,r),r];yield o}})()},child(e,t){if(he.isText(e))throw new Error("Cannot get the child of a text node: ".concat(ht.stringify(e)));var n=e.children[t];if(n==null)throw new Error("Cannot get child at index `".concat(t,"` in node: ").concat(ht.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=ee.ancestor(e,t),{children:i}=o,s=r?i.length-1:0;r?s>=0:s<i.length;){var a=ee.child(o,s),u=t.concat(s);yield[a,u],s=r?s-1:s+1}})()},common(e,t,n){var r=R.common(t,n);return[ee.get(e,r),r]},descendant(e,t){var n=ee.get(e,t);if(D.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(t,"] because it refers to the root editor node instead: ").concat(ht.stringify(n)));return n},descendants(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.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 ee.nodes(e,t))le.isElement(n)&&(yield[n,r])})()},extractProps:e=>le.isAncestor(e)?Mn(e,hE):Mn(e,pE),first(e,t){for(var n=t.slice(),r=ee.get(e,n);r&&!he.isText(r)&&r.children.length!==0;)r=r.children[0],n.push(0);return[r,n]},fragment(e,t){if(he.isText(e))throw new Error("Cannot get a fragment starting from a root text node: ".concat(ht.stringify(e)));var n=rc({children:e.children},(r=>{var[o,i]=U.edges(t),s=ee.nodes(r,{reverse:!0,pass:d=>{var[,h]=d;return!U.includes(t,h)}});for(var[,a]of s){if(!U.includes(t,a)){var u=ee.parent(r,a),l=a[a.length-1];u.children.splice(l,1)}if(R.equals(a,i.path)){var f=ee.leaf(r,a);f.text=f.text.slice(0,i.offset)}if(R.equals(a,o.path)){var c=ee.leaf(r,a);c.text=c.text.slice(o.offset)}}D.isEditor(r)&&(r.selection=null)}));return n.children},get(e,t){var n=ee.getIf(e,t);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(t,"] in node: ").concat(ht.stringify(e)));return n},getIf(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(he.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(he.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode:e=>he.isText(e)||le.isElement(e)||D.isEditor(e),isNodeList(e){if(!Array.isArray(e))return!1;var t=hf.get(e);if(t!==void 0)return t;var n=e.every((r=>ee.isNode(r)));return hf.set(e,n),n},last(e,t){for(var n=t.slice(),r=ee.get(e,n);r&&!he.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=ee.get(e,t);if(!he.isText(n))throw new Error("Cannot get the leaf node at path [".concat(t,"] because it refers to a non-leaf node: ").concat(ht.stringify(n)));return n},levels(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of R.levels(t,n)){var o=ee.get(e,r);yield[o,r]}})()},matches:(e,t)=>le.isElement(e)&&le.isElementProps(t)&&le.matches(e,t)||he.isText(e)&&he.isTextProps(t)&&he.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,s=new Set,a=[],u=e;!i||!(r?R.isBefore(a,i):R.isAfter(a,i));)if(s.has(u)||(yield[u,a]),s.has(u)||he.isText(u)||u.children.length===0||n!=null&&n([u,a])!==!1){if(a.length===0)break;if(!r){var l=R.next(a);if(ee.has(e,l)){a=l,u=ee.get(e,a);continue}}r&&a[a.length-1]!==0?(a=R.previous(a),u=ee.get(e,a)):(a=R.parent(a),u=ee.get(e,a),s.add(u))}else{s.add(u);var f=r?u.children.length-1:0;R.isAncestor(a,o)&&(f=o[a.length]),a=a.concat(f),u=ee.get(e,a)}})()},parent(e,t){var n=R.parent(t),r=ee.get(e,n);if(he.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=>he.isText(e)?e.text:e.children.map(ee.string).join(""),texts(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.nodes(e,t))he.isText(n)&&(yield[n,r])})()}};function pf(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 nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ur={isNodeOperation:e=>ur.isOperation(e)&&e.type.endsWith("_node"),isOperation(e){if(!ft(e))return!1;switch(e.type){case"insert_node":case"remove_node":return R.isPath(e.path)&&ee.isNode(e.node);case"insert_text":case"remove_text":return typeof e.offset=="number"&&typeof e.text=="string"&&R.isPath(e.path);case"merge_node":return typeof e.position=="number"&&R.isPath(e.path)&&ft(e.properties);case"move_node":return R.isPath(e.path)&&R.isPath(e.newPath);case"set_node":return R.isPath(e.path)&&ft(e.properties)&&ft(e.newProperties);case"set_selection":return e.properties===null&&U.isRange(e.newProperties)||e.newProperties===null&&U.isRange(e.properties)||ft(e.properties)&&ft(e.newProperties);case"split_node":return R.isPath(e.path)&&typeof e.position=="number"&&ft(e.properties);default:return!1}},isOperationList:e=>Array.isArray(e)&&e.every((t=>ur.isOperation(t))),isSelectionOperation:e=>ur.isOperation(e)&&e.type.endsWith("_selection"),isTextOperation:e=>ur.isOperation(e)&&e.type.endsWith("_text"),inverse(e){switch(e.type){case"insert_node":return nt(nt({},e),{},{type:"remove_node"});case"insert_text":return nt(nt({},e),{},{type:"remove_text"});case"merge_node":return nt(nt({},e),{},{type:"split_node",path:R.previous(e.path)});case"move_node":var{newPath:t,path:n}=e;if(R.equals(t,n))return e;if(R.isSibling(n,t))return nt(nt({},e),{},{path:t,newPath:n});var r=R.transform(n,e),o=R.transform(R.next(n),e);return nt(nt({},e),{},{path:r,newPath:o});case"remove_node":return nt(nt({},e),{},{type:"insert_node"});case"remove_text":return nt(nt({},e),{},{type:"insert_text"});case"set_node":var{properties:i,newProperties:s}=e;return nt(nt({},e),{},{properties:s,newProperties:i});case"set_selection":var{properties:a,newProperties:u}=e;return nt(nt({},e),{},a==null?{properties:u,newProperties:null}:u==null?{properties:null,newProperties:a}:{properties:u,newProperties:a});case"split_node":return nt(nt({},e),{},{type:"merge_node",path:R.next(e.path)})}}},mf=new WeakMap,D={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=mf.get(t);if(n!==void 0)return n;if(!ft(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||ft(t.marks))&&(t.selection===null||U.isRange(t.selection))&&ee.isNodeList(t.children)&&ur.isOperationList(t.operations);return mf.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)},mE={isSpan:e=>Array.isArray(e)&&e.length===2&&e.every(R.isPath)};function gf(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 vf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var _e={compare(e,t){var n=R.compare(e.path,t.path);return n===0?e.offset<t.offset?-1:e.offset>t.offset?1:0:n},isAfter:(e,t)=>_e.compare(e,t)===1,isBefore:(e,t)=>_e.compare(e,t)===-1,equals:(e,t)=>e.offset===t.offset&&R.equals(e.path,t.path),isPoint:e=>ft(e)&&typeof e.offset=="number"&&R.isPath(e.path),transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return rc(e,(r=>{if(r===null)return null;var{affinity:o="forward"}=n,{path:i,offset:s}=r;switch(t.type){case"insert_node":case"move_node":r.path=R.transform(i,t,n);break;case"insert_text":R.equals(t.path,i)&&(t.offset<s||t.offset===s&&o==="forward")&&(r.offset+=t.text.length);break;case"merge_node":R.equals(t.path,i)&&(r.offset+=t.position),r.path=R.transform(i,t,n);break;case"remove_text":R.equals(t.path,i)&&t.offset<=s&&(r.offset-=Math.min(s-t.offset,t.text.length));break;case"remove_node":if(R.equals(t.path,i)||R.isAncestor(t.path,i))return null;r.path=R.transform(i,t,n);break;case"split_node":if(R.equals(t.path,i)){if(t.position===s&&o==null)return null;(t.position<s||t.position===s&&o==="forward")&&(r.offset-=t.position,r.path=R.transform(i,t,vf(vf({},n),{},{affinity:"forward"})))}else r.path=R.transform(i,t,n)}}))}},yf=void 0,ht={setScrubber(e){yf=e},stringify:e=>JSON.stringify(e,yf)},gE=["text"],vE=["anchor","focus"];function bf(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 kn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?bf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ke,he={equals(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(i){return Mn(i,gE)}return Lg(r?o(e):e,r?o(t):t)},isText:e=>ft(e)&&typeof e.text=="string",isTextList:e=>Array.isArray(e)&&e.every((t=>he.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=[kn({},e)];for(var r of t){var o=Mn(r,vE),[i,s]=U.edges(r),a=[],u=0,l=i.offset,f=s.offset;for(var c of n){var{length:d}=c.text,h=u;if(u+=d,l<=h&&u<=f)Object.assign(c,o),a.push(c);else if(l!==f&&(l===u||f===h)||l>u||f<h||f===h&&h!==0)a.push(c);else{var g=c,y=void 0,p=void 0;if(f<u){var w=f-h;p=kn(kn({},g),{},{text:g.text.slice(w)}),g=kn(kn({},g),{},{text:g.text.slice(0,w)})}if(l>h){var b=l-h;y=kn(kn({},g),{},{text:g.text.slice(0,b)}),g=kn(kn({},g),{},{text:g.text.slice(b)})}Object.assign(g,o),y&&a.push(y),a.push(g),p&&a.push(p)}}n=a}return n}},al=e=>e.selection?e.selection:e.children.length>0?D.end(e,[]):[0],Yr=(e,t)=>{var[n]=D.node(e,t);return r=>r===n},Pu=function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=!t,r=t?EE(e):e,o=ke.None,i=ke.None,s=0,a=null;for(var u of r){var l=u.codePointAt(0);if(!l)break;var f=_E(u,l);if([o,i]=n?[i,f]:[f,o],co(o,ke.ZWJ)&&co(i,ke.ExtPict)&&!NE(n?e.substring(0,s):e.substring(0,e.length-s))||co(o,ke.RI)&&co(i,ke.RI)&&!(a=a!==null?!a:!!n||UE(e.substring(0,e.length-s)))||o!==ke.None&&i!==ke.None&&ME(o,i))break;s+=u.length}return s||1},yE=/\s/,bE=/[\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]/,CE=/['\u2018\u2019]/,Nu=(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)]},wE=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(yE.test(t))return!1;if(CE.test(t)){var o=Pu(n,r),[i,s]=Nu(n,o,r);if(e(i,s,r))return!0}return!bE.test(t)},EE=function*(e){for(var t=e.length-1,n=0;n<e.length;n++){var r=e.charAt(t-n);if(AE(r.charCodeAt(0))){var o=e.charAt(t-n-1);if(DE(o.charCodeAt(0))){yield o+r,n++;continue}}yield r}},DE=e=>e>=55296&&e<=56319,AE=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"})(ke||(ke={}));var xE=/^(?:[\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])$/,OE=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,SE=/^(?:[\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])$/,IE=/^[\u1100-\u115F\uA960-\uA97C]$/,TE=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,kE=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,BE=/^[\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]$/,FE=/^[\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]$/,RE=/^(?:[\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])$/,_E=(e,t)=>{var n=ke.Any;return e.search(xE)!==-1&&(n|=ke.Extend),t===8205&&(n|=ke.ZWJ),t>=127462&&t<=127487&&(n|=ke.RI),e.search(OE)!==-1&&(n|=ke.Prepend),e.search(SE)!==-1&&(n|=ke.SpacingMark),e.search(IE)!==-1&&(n|=ke.L),e.search(TE)!==-1&&(n|=ke.V),e.search(kE)!==-1&&(n|=ke.T),e.search(BE)!==-1&&(n|=ke.LV),e.search(FE)!==-1&&(n|=ke.LVT),e.search(RE)!==-1&&(n|=ke.ExtPict),n};function co(e,t){return!!(e&t)}var jE=[[ke.L,ke.L|ke.V|ke.LV|ke.LVT],[ke.LV|ke.V,ke.V|ke.T],[ke.LVT|ke.T,ke.T],[ke.Any,ke.Extend|ke.ZWJ],[ke.Any,ke.SpacingMark],[ke.Prepend,ke.Any],[ke.ZWJ,ke.ExtPict],[ke.RI,ke.RI]];function ME(e,t){return jE.findIndex((n=>co(e,n[0])&&co(t,n[1])))===-1}var PE=/(?:[\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$/,NE=e=>e.search(PE)!==-1,LE=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,UE=e=>{var t=e.match(LE);return t!==null&&t[0].length/2%2==1},HE={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]:{};D.withoutNormalizing(e,(()=>{var{voids:r=!1}=n,{at:o=al(e)}=n;if(R.isPath(o)&&(o=D.range(e,o)),U.isRange(o))if(U.isCollapsed(o))o=o.anchor;else{var i=U.end(o);if(!r&&D.void(e,{at:i}))return;var s=U.start(o),a=D.pointRef(e,s),u=D.pointRef(e,i);z.delete(e,{at:o,voids:r});var l=a.unref(),f=u.unref();o=l||f,z.setSelection(e,{anchor:o,focus:o})}if(!(!r&&D.void(e,{at:o})||D.elementReadOnly(e,{at:o}))){var{path:c,offset:d}=o;t.length>0&&e.apply({type:"insert_text",path:c,offset:d,text:t})}}))}};function Cf(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 ts(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Cf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var z=ts(ts(ts(ts({},cE),lE),dE),HE),hs=new WeakMap;function Ug(e,t,n){var r,o,i=Rs.get(e)||[],s=_s.get(e)||new Set,a=f=>{if(f){var c=f.join(",");o.has(c)||(o.add(c),r.push(f))}};if(n)for(var u of(r=[],o=new Set,i))a(n(u));else r=i,o=s;for(var l of t)a(l);Rs.set(e,r),_s.set(e,o)}var VE=(e,t)=>{for(var n of D.pathRefs(e))iE.transform(n,t);for(var r of D.pointRefs(e))sE.transform(r,t);for(var o of D.rangeRefs(e))aE.transform(o,t);if(!(s=>hs.get(s)||!1)(e)){var i=R.operationCanTransformPath(t)?s=>R.transform(s,t):void 0;Ug(e,e.getDirtyPaths(t),i)}z.transform(e,t),e.operations.push(t),D.normalize(e,{operation:t}),t.type==="set_selection"&&(e.marks=null),ii.get(e)||(ii.set(e,!0),Promise.resolve().then((()=>{ii.set(e,!1),e.onChange({operation:t}),e.operations=[]})))};function wf(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 Ef(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?wf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Df(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 Af(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Df(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Df(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function xf(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 Of(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?xf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Sf(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 If(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Sf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Tf(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 kf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Tf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Bf(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 Hg=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(s){for(var a=1;a<arguments.length;a++){var u=arguments[a]!=null?arguments[a]:{};a%2?Bf(Object(u),!0).forEach((function(l){kt(s,l,u[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):Bf(Object(u)).forEach((function(l){Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(u,l))}))}return s})({text:t},o);z.insertNodes(e,i,{at:n.at,voids:n.voids})}else z.insertText(e,t,n);e.marks=null}},$E=["text"],WE=["text"],zE=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:n=!1,operation:r}=t,o=u=>Rs.get(u)||[],i=u=>{var l=o(u).pop(),f=l.join(",");return(c=>_s.get(c)||new Set)(u).delete(f),l};if(D.isNormalizing(e)){if(n){var s=Array.from(ee.nodes(e),(u=>{var[,l]=u;return l})),a=new Set(s.map((u=>u.join(","))));Rs.set(e,s),_s.set(e,a)}o(e).length!==0&&D.withoutNormalizing(e,(()=>{for(var u of o(e))if(ee.has(e,u)){var l=D.node(e,u),[f,c]=l;le.isElement(f)&&f.children.length===0&&e.normalizeNode(l,{operation:r})}for(var d=o(e),h=d.length,g=0;d.length!==0;){if(!e.shouldNormalize({dirtyPaths:d,iteration:g,initialDirtyPathsLength:h,operation:r}))return;var y=i(e);if(ee.has(e,y)){var p=D.node(e,y);e.normalizeNode(p,{operation:r})}g++,d=o(e)}}))}};function KE(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:s=!1}=t;if(n){var a=D.range(e,n),[u,l]=U.edges(a),f=o?l:u,c=!1,d="",h=0,g=0,y=0;for(var[p,w]of D.nodes(e,{at:n,reverse:o,voids:i,ignoreNonSelectable:s})){if(le.isElement(p)){if(!i&&(e.isVoid(p)||e.isElementReadOnly(p))){yield D.start(e,w);continue}if(e.isInline(p))continue;if(D.hasInlines(e,p)){var b=R.isAncestor(w,l.path)?l:D.end(e,w),C=R.isAncestor(w,u.path)?u:D.start(e,w);d=D.string(e,{anchor:C,focus:b},{voids:i}),c=!0}}if(he.isText(p)){var E=R.equals(w,f.path);for(E?(g=o?f.offset:p.text.length-f.offset,y=f.offset):(g=p.text.length,y=o?g:0),(E||c||r==="offset")&&(yield{path:w,offset:y},c=!1);;){if(h===0){if(d==="")break;h=A(d,r,o),d=Nu(d,h,o)[1]}if(y=o?y-h:y+h,(g-=h)<0){h=-g;break}h=0,yield{path:w,offset:y}}}}}function A(x,I,T){return I==="character"?Pu(x,T):I==="word"?(function(F){for(var S=arguments.length>1&&arguments[1]!==void 0&&arguments[1],k=0,_=!1;F.length>0;){var M=Pu(F,S),[H,W]=Nu(F,M,S);if(wE(H,W,S))_=!0,k+=M;else{if(_)break;k+=M}F=W}return k})(x,T):I==="line"||I==="block"?x.length:1}})()}function Ff(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 qE=(e,t)=>{var{selection:n}=e;if(n){var r=(f,c)=>{if(!he.isText(f))return!1;var[d,h]=D.parent(e,c);return!e.isVoid(d)||e.markableVoid(d)},o=U.isExpanded(n),i=!1;if(!o){var[s,a]=D.node(e,n);if(s&&r(s,a)){var[u]=D.parent(e,a);i=u&&e.markableVoid(u)}}if(o||i)z.unsetNodes(e,t,{match:r,split:!0,voids:!0});else{var l=(function(f){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?Ff(Object(d),!0).forEach((function(h){kt(f,h,d[h])})):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(d)):Ff(Object(d)).forEach((function(h){Object.defineProperty(f,h,Object.getOwnPropertyDescriptor(d,h))}))}return f})({},D.marks(e)||{});delete l[t],e.marks=l,ii.get(e)||e.onChange()}}};function Rf(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 _f(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Rf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var GE=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(e,(()=>{var{hanging:r=!1,voids:o=!1,mode:i="lowest",batchDirty:s=!0}=n,{at:a,match:u,select:l}=n;if(ee.isNode(t)&&(t=[t]),t.length!==0){var[f]=t;if(a||(a=al(e),l!==!1&&(l=!0)),l==null&&(l=!1),U.isRange(a))if(r||(a=D.unhangRange(e,a,{voids:o})),U.isCollapsed(a))a=a.anchor;else{var[,c]=U.edges(a),d=D.pointRef(e,c);z.delete(e,{at:a}),a=d.unref()}if(_e.isPoint(a)){u==null&&(u=he.isText(f)?F=>he.isText(F):e.isInline(f)?F=>he.isText(F)||D.isInline(e,F):F=>le.isElement(F)&&D.isBlock(e,F));var[h]=D.nodes(e,{at:a.path,match:u,mode:i,voids:o});if(!h)return;var[,g]=h,y=D.pathRef(e,g),p=D.isEnd(e,a,g);z.splitNodes(e,{at:a,match:u,mode:i,voids:o});var w=y.unref();a=p?R.next(w):w}var b=R.parent(a),C=a[a.length-1];if(o||!D.void(e,{at:b})){if(s){var E=[],A=R.levels(b);((F,S,k)=>{var _=hs.get(F)||!1;hs.set(F,!0);try{S(),k()}finally{hs.set(F,_)}})(e,(()=>{var F=function(){var k=b.concat(C);C++;var _={type:"insert_node",path:k,node:S};e.apply(_),a=R.next(a),E.push(_),he.isText?A.push(...Array.from(ee.nodes(S),(M=>{var[,H]=M;return k.concat(H)}))):A.push(k)};for(var S of t)F()}),(()=>{Ug(e,A,(F=>{var S=F;for(var k of E)if(R.operationCanTransformPath(k)&&!(S=R.transform(S,k)))return null;return S}))}))}else for(var x of t){var I=b.concat(C);C++,e.apply({type:"insert_node",path:I,node:x}),a=R.next(a)}if(a=R.previous(a),l){var T=D.end(e,a);T&&z.select(e,T)}}}}))},JE=["text"],ZE=["children"],Vg=(e,t)=>{if(le.isElement(t)){var n=t;return!!D.isVoid(e,t)||n.children.length===1&&Vg(e,n.children[0])}return!D.isEditor(t)},XE=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(e,(()=>{var{mode:n="lowest",voids:r=!1}=t,{match:o,at:i=e.selection,height:s=0,always:a=!1}=t;if(o==null&&(o=W=>le.isElement(W)&&D.isBlock(e,W)),U.isRange(i)&&(i=((W,G)=>{if(U.isCollapsed(G))return G.anchor;var[,q]=U.edges(G),$=D.pointRef(W,q);return z.delete(W,{at:G}),$.unref()})(e,i)),R.isPath(i)){var u=i,l=D.point(e,u),[f]=D.parent(e,u);o=W=>W===f,s=l.path.length-u.length+1,i=l,a=!0}if(i){var c,d=D.pointRef(e,i,{affinity:"backward"});try{var[h]=D.nodes(e,{at:i,match:o,mode:n,voids:r});if(!h)return;var g=D.void(e,{at:i,mode:"highest"});if(!r&&g){var[y,p]=g;if(le.isElement(y)&&e.isInline(y)){var w=D.after(e,p);if(!w){var b=R.next(p);z.insertNodes(e,{text:""},{at:b,voids:r}),w=D.point(e,b)}i=w,a=!0}s=i.path.length-p.length+1,a=!0}c=D.pointRef(e,i);var C=i.path.length-s,[,E]=h,A=i.path.slice(0,C),x=s===0?i.offset:i.path[C]+0;for(var[I,T]of D.levels(e,{at:A,reverse:!0,voids:r})){var F=!1;if(T.length<E.length||T.length===0||!r&&le.isElement(I)&&D.isVoid(e,I))break;var S=d.current,k=D.isEnd(e,S,T);if(a||!d||!D.isEdge(e,S,T)){F=!0;var _=ee.extractProps(I);e.apply({type:"split_node",path:T,position:x,properties:_})}x=T[T.length-1]+(F||k?1:0)}if(t.at==null){var M=c.current||D.end(e,[]);z.select(e,M)}}finally{var H;d.unref(),(H=c)===null||H===void 0||H.unref()}}}))};function jf(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 Mf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?jf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Na,Pf,$g=()=>{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 VE(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,s)=>{var{selection:a}=o;if(a){var u=(y,p)=>{if(!he.isText(y))return!1;var[w,b]=D.parent(o,p);return!o.isVoid(w)||o.markableVoid(w)},l=U.isExpanded(a),f=!1;if(!l){var[c,d]=D.node(o,a);if(c&&u(c,d)){var[h]=D.parent(o,d);f=h&&o.markableVoid(h)}}if(l||f)z.setNodes(o,{[i]:s},{match:u,split:!0,voids:!0});else{var g=Ef(Ef({},D.marks(o)||{}),{},{[i]:s});o.marks=g,ii.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:s}=o;s&&U.isCollapsed(s)&&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:s}=o;s&&U.isCollapsed(s)&&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:s}=o;s&&U.isExpanded(s)&&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?ee.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{hanging:a=!1,voids:u=!1}=s,{at:l=al(o),batchDirty:f=!0}=s;if(i.length){if(U.isRange(l))if(a||(l=D.unhangRange(o,l,{voids:u})),U.isCollapsed(l))l=l.anchor;else{var[,c]=U.edges(l);if(!u&&D.void(o,{at:c}))return;var d=D.pointRef(o,c);z.delete(o,{at:l}),l=d.unref()}else R.isPath(l)&&(l=D.start(o,l));if(u||!D.void(o,{at:l})){var h=D.above(o,{at:l,match:B=>le.isElement(B)&&D.isInline(o,B),mode:"highest",voids:u});if(h){var[,g]=h;D.isEnd(o,l,g)?l=D.after(o,g):D.isStart(o,l,g)&&(l=D.before(o,g))}var y=D.above(o,{match:B=>le.isElement(B)&&D.isBlock(o,B),at:l,voids:u}),[,p]=y,w=D.isStart(o,l,p),b=D.isEnd(o,l,p),C=w&&b,E=!w||w&&b,A=!b,[,x]=ee.first({children:i},[]),[,I]=ee.last({children:i},[]),T=[],F=B=>{var[X,K]=B;return!(K.length===0||!C&&(E&&R.isAncestor(K,x)&&le.isElement(X)&&!o.isVoid(X)&&!o.isInline(X)||A&&R.isAncestor(K,I)&&le.isElement(X)&&!o.isVoid(X)&&!o.isInline(X)))};for(var S of ee.nodes({children:i},{pass:F}))F(S)&&T.push(S);var k=[],_=[],M=[],H=!0,W=!1;for(var[G]of T)le.isElement(G)&&!o.isInline(G)?(H=!1,W=!0,_.push(G)):H?k.push(G):M.push(G);var[q]=D.nodes(o,{at:l,match:B=>he.isText(B)||D.isInline(o,B),mode:"highest",voids:u}),[,$]=q,V=D.isStart(o,l,$),Q=D.isEnd(o,l,$),ae=D.pathRef(o,b&&!M.length?R.next(p):p),ie=D.pathRef(o,Q?R.next($):$);z.splitNodes(o,{at:l,match:B=>W?le.isElement(B)&&D.isBlock(o,B):he.isText(B)||D.isInline(o,B),mode:W?"lowest":"highest",always:W&&(!w||k.length>0)&&(!b||M.length>0),voids:u});var Se,Ie=D.pathRef(o,!V||V&&Q?R.next($):$);if(z.insertNodes(o,k,{at:Ie.current,match:B=>he.isText(B)||D.isInline(o,B),mode:"highest",voids:u,batchDirty:f}),C&&!k.length&&_.length&&!M.length&&z.delete(o,{at:p,voids:u}),z.insertNodes(o,_,{at:ae.current,match:B=>le.isElement(B)&&D.isBlock(o,B),mode:"lowest",voids:u,batchDirty:f}),z.insertNodes(o,M,{at:ie.current,match:B=>he.isText(B)||D.isInline(o,B),mode:"highest",voids:u,batchDirty:f}),!s.at&&(M.length>0&&ie.current?Se=R.previous(ie.current):_.length>0&&ae.current?Se=R.previous(ae.current):Ie.current&&(Se=R.previous(Ie.current)),Se)){var ne=D.end(o,Se);z.select(o,ne)}Ie.unref(),ae.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,s)=>{z.insertNodes(o,i,s)})(e,...n)},insertText:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Hg(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[s,a]=i;if(!he.isText(s))if(le.isElement(s)&&s.children.length===0)z.insertNodes(o,{text:""},{at:a.concat(0),voids:!0});else for(var u=!D.isEditor(s)&&le.isElement(s)&&(o.isInline(s)||s.children.length===0||he.isText(s.children[0])||o.isInline(s.children[0])),l=0,f=0;f<s.children.length;f++,l++){var c=ee.get(o,a);if(!he.isText(c)){var d=c.children[l],h=c.children[l-1],g=f===s.children.length-1;(he.isText(d)||le.isElement(d)&&o.isInline(d))!==u?(z.removeNodes(o,{at:a.concat(l),voids:!0}),l--):le.isElement(d)?o.isInline(d)&&(h!=null&&he.isText(h)?g&&(z.insertNodes(o,{text:""},{at:a.concat(l+1),voids:!0}),l++):(z.insertNodes(o,{text:""},{at:a.concat(l),voids:!0}),l++)):(he.isText(d)||"children"in d||(d.children=[]),h!=null&&he.isText(h)&&(he.equals(d,h,{loose:!0})?(z.mergeNodes(o,{at:a.concat(l),voids:!0}),l--):h.text===""?(z.removeNodes(o,{at:a.concat(l-1),voids:!0}),l--):d.text===""&&(z.removeNodes(o,{at:a.concat(l),voids:!0}),l--)))}}})(e,...n)},removeMark:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return qE(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:s}=i;return R.levels(s);case"insert_node":var{node:a,path:u}=i,l=R.levels(u),f=he.isText(a)?[]:Array.from(ee.nodes(a),(F=>{var[,S]=F;return u.concat(S)}));return[...l,...f];case"merge_node":var{path:c}=i;return[...R.ancestors(c),R.previous(c)];case"move_node":var{path:d,newPath:h}=i;if(R.equals(d,h))return[];var g=[],y=[];for(var p of R.ancestors(d)){var w=R.transform(p,i);g.push(w)}for(var b of R.ancestors(h)){var C=R.transform(b,i);y.push(C)}var E=y[y.length-1],A=h[h.length-1],x=E.concat(A);return[...g,...y,x];case"remove_node":var{path:I}=i;return[...R.ancestors(I)];case"split_node":var{path:T}=i;return[...R.levels(T),R.next(T)];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:s,initialDirtyPathsLength:a}=i,u=42*a;if(s>u)throw new Error("Could not completely normalize the editor after ".concat(u," 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:s=!1,mode:a="lowest",at:u=o.selection,match:l}=i;if(u){var f=D.path(o,u),c=a==="lowest";for(var[d,h]of D.levels(o,{at:f,voids:s,match:l,reverse:c}))if(!he.isText(d)){if(U.isRange(u)){if(R.isAncestor(h,u.anchor.path)&&R.isAncestor(h,u.focus.path))return[d,h]}else if(!R.equals(f,h))return[d,h]}}})(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 s,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u={anchor:D.point(o,i,{edge:"end"}),focus:D.end(o,[])},{distance:l=1}=a,f=0;for(var c of D.positions(o,Af(Af({},a),{},{at:u}))){if(f>l)break;f!==0&&(s=c),f++}return s})(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 s,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u={anchor:D.start(o,[]),focus:D.point(o,i,{edge:"start"})},{distance:l=1}=a,f=0;for(var c of D.positions(o,Of(Of({},a),{},{at:u,reverse:!0}))){if(f>l)break;f!==0&&(s=c),f++}return s})(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:s="anchor"}=i,{selection:a}=o;if(a){if(s==="anchor")z.select(o,a.anchor);else if(s==="focus")z.select(o,a.focus);else if(s==="start"){var[u]=U.edges(a);z.select(o,u)}else if(s==="end"){var[,l]=U.edges(a);z.select(o,l)}}})(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]:{};D.withoutNormalizing(o,(()=>{var s,a,{reverse:u=!1,unit:l="character",distance:f=1,voids:c=!1}=i,{at:d=o.selection,hanging:h=!1}=i;if(d){var g=!1;if(U.isRange(d)&&U.isCollapsed(d)&&(g=!0,d=d.anchor),_e.isPoint(d)){var y=D.void(o,{at:d,mode:"highest"});if(!c&&y){var[,p]=y;d=p}else{var w={unit:l,distance:f};d={anchor:d,focus:u?D.before(o,d,w)||D.start(o,[]):D.after(o,d,w)||D.end(o,[])},h=!0}}if(R.isPath(d))z.removeNodes(o,{at:d,voids:c});else if(!U.isCollapsed(d)){if(!h){var[,b]=U.edges(d),C=D.end(o,[]);_e.equals(b,C)||(d=D.unhangRange(o,d,{voids:c}))}var[E,A]=U.edges(d),x=D.above(o,{match:te=>le.isElement(te)&&D.isBlock(o,te),at:E,voids:c}),I=D.above(o,{match:te=>le.isElement(te)&&D.isBlock(o,te),at:A,voids:c}),T=x&&I&&!R.equals(x[1],I[1]),F=R.equals(E.path,A.path),S=c?null:(s=D.void(o,{at:E,mode:"highest"}))!==null&&s!==void 0?s:D.elementReadOnly(o,{at:E,mode:"highest"}),k=c?null:(a=D.void(o,{at:A,mode:"highest"}))!==null&&a!==void 0?a:D.elementReadOnly(o,{at:A,mode:"highest"});if(S){var _=D.before(o,E);_&&x&&R.isAncestor(x[1],_.path)&&(E=_)}if(k){var M=D.after(o,A);M&&I&&R.isAncestor(I[1],M.path)&&(A=M)}var H,W=[];for(var G of D.nodes(o,{at:d,voids:c})){var[q,$]=G;H&&R.compare($,H)===0||(!c&&le.isElement(q)&&(D.isVoid(o,q)||D.isElementReadOnly(o,q))||!R.isCommon($,E.path)&&!R.isCommon($,A.path))&&(W.push(G),H=$)}var V=Array.from(W,(te=>{var[,me]=te;return D.pathRef(o,me)})),Q=D.pointRef(o,E),ae=D.pointRef(o,A),ie="";if(!F&&!S){var Se=Q.current,[Ie]=D.leaf(o,Se),{path:ne}=Se,{offset:B}=E,X=Ie.text.slice(B);X.length>0&&(o.apply({type:"remove_text",path:ne,offset:B,text:X}),ie=X)}if(V.reverse().map((te=>te.unref())).filter((te=>te!==null)).forEach((te=>z.removeNodes(o,{at:te,voids:c}))),!k){var K=ae.current,[Y]=D.leaf(o,K),{path:de}=K,pe=F?E.offset:0,fe=Y.text.slice(pe,A.offset);fe.length>0&&(o.apply({type:"remove_text",path:de,offset:pe,text:fe}),ie=fe)}!F&&T&&ae.current&&Q.current&&z.mergeNodes(o,{at:ae.current,hanging:!0,voids:c}),g&&u&&l==="character"&&ie.length>1&&ie.match(/[\u0E00-\u0E7F]+/)&&z.insertText(o,ie.slice(0,ie.length-f));var we=Q.unref(),Ce=ae.unref(),se=u?we||Ce:Ce||we;i.at==null&&se&&z.select(o,se)}}}))})(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)=>[D.start(o,i),D.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 D.above(o,If(If({},i),{},{match:s=>le.isElement(s)&&D.isElementReadOnly(o,s)}))})(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)=>D.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 s=D.path(o,i,{edge:"start"});return D.node(o,s)})(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 s=D.range(o,i);return ee.fragment(o,s)})(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:s}=o;if(!s)return null;var{anchor:a,focus:u}=s;if(i)return i;if(U.isExpanded(s)){if(U.isBackward(s)&&([u,a]=[a,u]),D.isEnd(o,a,a.path)){var l=D.after(o,a);l&&(a=l)}var[f]=D.nodes(o,{match:he.isText,at:{anchor:a,focus:u}});if(f){var[c]=f;return Mn(c,$E)}return{}}var{path:d}=a,[h]=D.leaf(o,d);if(a.offset===0){var g=D.previous(o,{at:d,match:he.isText}),y=D.above(o,{match:E=>le.isElement(E)&&D.isVoid(o,E)&&o.markableVoid(E)});if(!y){var p=D.above(o,{match:E=>le.isElement(E)&&D.isBlock(o,E)});if(g&&p){var[w,b]=g,[,C]=p;R.isAncestor(C,b)&&(h=w)}}}return Mn(h,WE)})(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((s=>le.isElement(s)&&D.isBlock(o,s))))(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((s=>he.isText(s)||D.isInline(o,s))))(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)=>ee.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((s=>he.isText(s))))(e,...n)},insertNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return GE(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,s)=>D.isStart(o,i,s)||D.isEnd(o,i,s))(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:s}=i,[a]=s;return s.length===0||s.length===1&&he.isText(a)&&a.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,s)=>{var a=D.end(o,s);return _e.equals(i,a)})(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=sf.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,s)=>{if(i.offset!==0)return!1;var a=D.start(o,s);return _e.equals(i,a)})(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 s=D.path(o,i,{edge:"end"});return D.node(o,s)})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s);return[ee.leaf(o,a),a]})(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:s=o.selection,reverse:a=!1,voids:u=!1}=i,{match:l}=i;if(l==null&&(l=()=>!0),s){var f=[],c=D.path(o,s);for(var[d,h]of ee.levels(o,c))if(l(d,h)&&(f.push([d,h]),!u&&le.isElement(d)&&D.isVoid(o,d)))break;a&&f.reverse(),yield*f}})()})(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]:{};D.withoutNormalizing(o,(()=>{var{at:s=o.selection,mode:a="lowest",voids:u=!1}=i,{match:l}=i;if(l==null&&(l=R.isPath(s)?Yr(o,s):I=>le.isElement(I)&&D.isBlock(o,I)),s){var f=D.nodes(o,{at:s,match:l,mode:a,voids:u}),c=Array.from(f,(I=>{var[,T]=I;return D.pathRef(o,T)}));for(var d of c){var h=d.unref();if(h.length<2)throw new Error("Cannot lift node at a path [".concat(h,"] because it has a depth of less than `2`."));var g=D.node(o,R.parent(h)),[y,p]=g,w=h[h.length-1],{length:b}=y.children;if(b===1){var C=R.next(p);z.moveNodes(o,{at:h,to:C,voids:u}),z.removeNodes(o,{at:p,voids:u})}else if(w===0)z.moveNodes(o,{at:h,to:p,voids:u});else if(w===b-1){var E=R.next(p);z.moveNodes(o,{at:h,to:E,voids:u})}else{var A=R.next(h),x=R.next(p);z.splitNodes(o,{at:A,voids:u}),z.moveNodes(o,{at:h,to:x,voids:u})}}}}))})(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]:{};D.withoutNormalizing(o,(()=>{var{match:s,at:a=o.selection}=i,{hanging:u=!1,voids:l=!1,mode:f="lowest"}=i;if(a){if(s==null)if(R.isPath(a)){var[c]=D.parent(o,a);s=M=>c.children.includes(M)}else s=M=>le.isElement(M)&&D.isBlock(o,M);if(!u&&U.isRange(a)&&(a=D.unhangRange(o,a,{voids:l})),U.isRange(a))if(U.isCollapsed(a))a=a.anchor;else{var[,d]=U.edges(a),h=D.pointRef(o,d);z.delete(o,{at:a}),a=h.unref(),i.at==null&&z.select(o,a)}var[g]=D.nodes(o,{at:a,match:s,voids:l,mode:f}),y=D.previous(o,{at:a,match:s,voids:l,mode:f});if(g&&y){var[p,w]=g,[b,C]=y;if(w.length!==0&&C.length!==0){var E,A,x=R.next(C),I=R.common(w,C),T=R.isSibling(w,C),F=Array.from(D.levels(o,{at:w}),(M=>{var[H]=M;return H})).slice(I.length).slice(0,-1),S=D.above(o,{at:w,mode:"highest",match:M=>F.includes(M)&&Vg(o,M)}),k=S&&D.pathRef(o,S[1]);if(he.isText(p)&&he.isText(b)){var _=Mn(p,JE);A=b.text.length,E=_}else{if(!le.isElement(p)||!le.isElement(b))throw new Error("Cannot merge the node at path [".concat(w,"] with the previous sibling because it is not the same kind: ").concat(ht.stringify(p)," ").concat(ht.stringify(b)));_=Mn(p,ZE),A=b.children.length,E=_}T||z.moveNodes(o,{at:w,to:x,voids:l}),k&&z.removeNodes(o,{at:k.current,voids:l}),D.shouldMergeNodesRemovePrevNode(o,y,g)?z.removeNodes(o,{at:C,voids:l}):o.apply({type:"merge_node",path:x,position:A,properties:E}),k&&k.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:s}=o,{distance:a=1,unit:u="character",reverse:l=!1}=i,{edge:f=null}=i;if(s){f==="start"&&(f=U.isBackward(s)?"focus":"anchor"),f==="end"&&(f=U.isBackward(s)?"anchor":"focus");var{anchor:c,focus:d}=s,h={distance:a,unit:u,ignoreNonSelectable:!0},g={};if(f==null||f==="anchor"){var y=l?D.before(o,c,h):D.after(o,c,h);y&&(g.anchor=y)}if(f==null||f==="focus"){var p=l?D.before(o,d,h):D.after(o,d,h);p&&(g.focus=p)}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)=>{D.withoutNormalizing(o,(()=>{var{to:s,at:a=o.selection,mode:u="lowest",voids:l=!1}=i,{match:f}=i;if(a){f==null&&(f=R.isPath(a)?Yr(o,a):w=>le.isElement(w)&&D.isBlock(o,w));var c=D.pathRef(o,s),d=D.nodes(o,{at:a,match:f,mode:u,voids:l}),h=Array.from(d,(w=>{var[,b]=w;return D.pathRef(o,b)}));for(var g of h){var y=g.unref(),p=c.current;y.length!==0&&o.apply({type:"move_node",path:y,newPath:p}),c.current&&R.isSibling(p,y)&&R.isAfter(p,y)&&(c.current=R.next(c.current))}c.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:s="lowest",voids:a=!1}=i,{match:u,at:l=o.selection}=i;if(l){var f=D.after(o,l,{voids:a});if(f){var[,c]=D.last(o,[]),d=[f.path,c];if(R.isPath(l)&&l.length===0)throw new Error("Cannot get the next node from the root node!");if(u==null)if(R.isPath(l)){var[h]=D.parent(o,l);u=y=>h.children.includes(y)}else u=()=>!0;var[g]=D.nodes(o,{at:d,match:u,mode:s,voids:a});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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s),u=ee.get(o,a);return[u,a]})(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:s=o.selection,mode:a="all",universal:u=!1,reverse:l=!1,voids:f=!1,ignoreNonSelectable:c=!1}=i,{match:d}=i;if(d||(d=()=>!0),s){var h,g;if(mE.isSpan(s))h=s[0],g=s[1];else{var y=D.path(o,s,{edge:"start"}),p=D.path(o,s,{edge:"end"});h=l?p:y,g=l?y:p}var w,b=ee.nodes(o,{reverse:l,from:h,to:g,pass:T=>{var[F]=T;return!(!le.isElement(F)||(f||!D.isVoid(o,F)&&!D.isElementReadOnly(o,F))&&(!c||D.isSelectable(o,F)))}}),C=[];for(var[E,A]of b)if(!c||!le.isElement(E)||D.isSelectable(o,E)){var x=w&&R.compare(A,w[1])===0;if(a!=="highest"||!x){if(d(E,A))if(a==="lowest"&&x)w=[E,A];else{var I=a==="lowest"?w:[E,A];I&&(u?C.push(I):yield I),w=[E,A]}else if(u&&!x&&he.isText(E))return}}a==="lowest"&&w&&(u?C.push(w):yield w),u&&(yield*C)}})()})(e,...n)},normalize:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return zE(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s),u=R.parent(a);return D.node(o,u)})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:a,edge:u}=s;if(R.isPath(i)){if(u==="start"){var[,l]=ee.first(o,i);i=l}else if(u==="end"){var[,f]=ee.last(o,i);i=f}}return U.isRange(i)&&(i=u==="start"?U.start(i):u==="end"?U.end(i):R.common(i.anchor.path,i.focus.path)),_e.isPoint(i)&&(i=i.path),a!=null&&(i=i.slice(0,a)),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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:l}=u;return D.pathRefs(o).delete(u),u.current=null,l}};return D.pathRefs(o).add(u),u})(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=af.get(o);return i||(i=new Set,af.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:a="start"}=s;if(R.isPath(i)){var u;if(a==="end"){var[,l]=ee.last(o,i);u=l}else{var[,f]=ee.first(o,i);u=f}var c=ee.get(o,u);if(!he.isText(c))throw new Error("Cannot get the ".concat(a," point in the node at path [").concat(i,"] because it has no ").concat(a," text node."));return{path:u,offset:a==="end"?c.text.length:0}}if(U.isRange(i)){var[d,h]=U.edges(i);return a==="start"?d:h}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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:l}=u;return D.pointRefs(o).delete(u),u.current=null,l}};return D.pointRefs(o).add(u),u})(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=uf.get(o);return i||(i=new Set,uf.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 KE(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:s="lowest",voids:a=!1}=i,{match:u,at:l=o.selection}=i;if(l){var f=D.before(o,l,{voids:a});if(f){var[,c]=D.first(o,[]),d=[f.path,c];if(R.isPath(l)&&l.length===0)throw new Error("Cannot get the previous node from the root node!");if(u==null)if(R.isPath(l)){var[h]=D.parent(o,l);u=y=>h.children.includes(y)}else u=()=>!0;var[g]=D.nodes(o,{reverse:!0,at:d,match:u,mode:s,voids:a});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,s)=>U.isRange(i)&&!s?i:{anchor:D.start(o,i),focus:D.end(o,s||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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:l}=u;return D.rangeRefs(o).delete(u),u.current=null,l}};return D.rangeRefs(o).add(u),u})(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=cf.get(o);return i||(i=new Set,cf.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]:{};D.withoutNormalizing(o,(()=>{var{hanging:s=!1,voids:a=!1,mode:u="lowest"}=i,{at:l=o.selection,match:f}=i;if(l){f==null&&(f=R.isPath(l)?Yr(o,l):p=>le.isElement(p)&&D.isBlock(o,p)),!s&&U.isRange(l)&&(l=D.unhangRange(o,l,{voids:a}));var c=D.nodes(o,{at:l,match:f,mode:u,voids:a}),d=Array.from(c,(p=>{var[,w]=p;return D.pathRef(o,w)}));for(var h of d){var g=h.unref();if(g){var[y]=D.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:s}=o;if(i=D.range(o,i),s)z.setSelection(o,i);else{if(!U.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(ht.stringify(i)));o.apply({type:"set_selection",properties:s,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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{match:a,at:u=o.selection,compare:l,merge:f}=s,{hanging:c=!1,mode:d="lowest",split:h=!1,voids:g=!1}=s;if(u){if(a==null&&(a=R.isPath(u)?Yr(o,u):k=>le.isElement(k)&&D.isBlock(o,k)),!c&&U.isRange(u)&&(u=D.unhangRange(o,u,{voids:g})),h&&U.isRange(u)){if(U.isCollapsed(u)&&D.leaf(o,u.anchor)[0].text.length>0)return;var y=D.rangeRef(o,u,{affinity:"inward"}),[p,w]=U.edges(u),b=d==="lowest"?"lowest":"highest",C=D.isEnd(o,w,w.path);z.splitNodes(o,{at:w,match:a,mode:b,voids:g,always:!C});var E=D.isStart(o,p,p.path);z.splitNodes(o,{at:p,match:a,mode:b,voids:g,always:!E}),u=y.unref(),s.at==null&&z.select(o,u)}for(var[A,x]of(l||(l=(k,_)=>k!==_),D.nodes(o,{at:u,match:a,mode:d,voids:g}))){var I={},T={};if(x.length!==0){var F=!1;for(var S in i)S!=="children"&&S!=="text"&&l(i[S],A[S])&&(F=!0,A.hasOwnProperty(S)&&(I[S]=A[S]),f?i[S]!=null&&(T[S]=f(A[S],i[S])):i[S]!=null&&(T[S]=i[S]));F&&o.apply({type:"set_node",path:x,properties:I,newProperties:T})}}}}))})(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)=>{sf.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:a}=o,{edge:u="both"}=s;if(a){u==="start"&&(u=U.isBackward(a)?"focus":"anchor"),u==="end"&&(u=U.isBackward(a)?"anchor":"focus");var{anchor:l,focus:f}=a,c=u==="anchor"?l:f;z.setSelection(o,{[u==="anchor"?"anchor":"focus"]:_f(_f({},c),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:s}=o,a={},u={};if(s){for(var l in i)(l==="anchor"&&i.anchor!=null&&!_e.equals(i.anchor,s.anchor)||l==="focus"&&i.focus!=null&&!_e.equals(i.focus,s.focus)||l!=="anchor"&&l!=="focus"&&i[l]!==s[l])&&(a[l]=s[l],u[l]=i[l]);Object.keys(a).length>0&&o.apply({type:"set_selection",properties:a,newProperties:u})}})(e,...n)},splitNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return XE(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)=>D.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:a=!1}=s,u=D.range(o,i),[l,f]=U.edges(u),c="";for(var[d,h]of D.nodes(o,{at:u,match:he.isText,voids:a})){var g=d.text;R.equals(h,f.path)&&(g=g.slice(0,f.offset)),R.equals(h,l.path)&&(g=g.slice(l.offset)),c+=g}return c})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:a=!1}=s,[u,l]=U.edges(i);if(u.offset!==0||l.offset!==0||U.isCollapsed(i)||R.hasPrevious(l.path))return i;var f=D.above(o,{at:l,match:p=>le.isElement(p)&&D.isBlock(o,p),voids:a}),c=f?f[1]:[],d={anchor:D.start(o,u),focus:l},h=!0;for(var[g,y]of D.nodes(o,{at:d,match:he.isText,reverse:!0,voids:a}))if(h)h=!1;else if(g.text!==""||R.isBefore(y,c)){l={path:y,offset:g.text.length};break}return{anchor:u,focus:l}})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(i)||(i=[i]);var a={};for(var u of i)a[u]=null;z.setNodes(o,a,s)})(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]:{};D.withoutNormalizing(o,(()=>{var{mode:s="lowest",split:a=!1,voids:u=!1}=i,{at:l=o.selection,match:f}=i;if(l){f==null&&(f=R.isPath(l)?Yr(o,l):p=>le.isElement(p)&&D.isBlock(o,p)),R.isPath(l)&&(l=D.range(o,l));var c=U.isRange(l)?D.rangeRef(o,l):null,d=D.nodes(o,{at:l,match:f,mode:s,voids:u}),h=Array.from(d,(p=>{var[,w]=p;return D.pathRef(o,w)})).reverse(),g=function(){var p=y.unref(),[w]=D.node(o,p),b=D.range(o,p);a&&c&&(b=U.intersection(c.current,b)),z.liftNodes(o,{at:b,match:C=>le.isAncestor(w)&&w.children.includes(C),voids:u})};for(var y of h)g();c&&c.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 D.above(o,kf(kf({},i),{},{match:s=>le.isElement(s)&&D.isVoid(o,s)}))})(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 s=D.isNormalizing(o);D.setNormalizing(o,!1);try{i()}finally{D.setNormalizing(o,s)}D.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{mode:a="lowest",split:u=!1,voids:l=!1}=s,{match:f,at:c=o.selection}=s;if(c){if(f==null&&(f=R.isPath(c)?Yr(o,c):o.isInline(i)?b=>le.isElement(b)&&D.isInline(o,b)||he.isText(b):b=>le.isElement(b)&&D.isBlock(o,b)),u&&U.isRange(c)){var[d,h]=U.edges(c),g=D.rangeRef(o,c,{affinity:"inward"});z.splitNodes(o,{at:h,match:f,voids:l}),z.splitNodes(o,{at:d,match:f,voids:l}),c=g.unref(),s.at==null&&z.select(o,c)}var y=Array.from(D.nodes(o,{at:c,match:o.isInline(i)?b=>le.isElement(b)&&D.isBlock(o,b):b=>D.isEditor(b),mode:"lowest",voids:l})),p=function(){var b=U.isRange(c)?U.intersection(c,D.range(o,w)):c;if(!b)return 0;var C=Array.from(D.nodes(o,{at:b,match:f,mode:a,voids:l}));if(C.length>0){var[E]=C,A=C[C.length-1],[,x]=E,[,I]=A;if(x.length===0&&I.length===0)return 0;var T=R.equals(x,I)?R.parent(x):R.common(x,I),F=D.range(o,x,I),S=D.node(o,T),[k]=S,_=T.length+1,M=R.next(I.slice(0,_)),H=Mf(Mf({},i),{},{children:[]});z.insertNodes(o,H,{at:M,voids:l}),z.moveNodes(o,{at:F,match:W=>le.isAncestor(k)&&k.children.includes(W),to:M.concat(0),voids:l})}};for(var[,w]of y)p()}}))})(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[s,a]=i;return le.isElement(s)&&D.isEmpty(o,s)||he.isText(s)&&s.text===""&&a[a.length-1]!==0})(e,...n)}};return e},YE={isHistory:e=>ft(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||ur.isOperationList(e.redos[0].operations))&&(e.undos.length===0||ur.isOperationList(e.undos[0].operations))},La=new WeakMap,wr=new WeakMap,ns=new WeakMap,bn={isHistoryEditor:e=>YE.isHistory(e.history)&&D.isEditor(e),isMerging:e=>wr.get(e),isSplittingOnce:e=>ns.get(e),setSplittingOnce(e,t){ns.set(e,t)},isSaving:e=>La.get(e),redo(e){e.redo()},undo(e){e.undo()},withMerging(e,t){var n=bn.isMerging(e);wr.set(e,!0),t(),wr.set(e,n)},withNewBatch(e,t){var n=bn.isMerging(e);wr.set(e,!0),ns.set(e,!0),t(),wr.set(e,n),ns.delete(e)},withoutMerging(e,t){var n=bn.isMerging(e);wr.set(e,!1),t(),wr.set(e,n)},withoutSaving(e,t){var n=bn.isSaving(e);La.set(e,!1),t(),La.set(e,n)}},QE=(e,t)=>!(!t||e.type!=="insert_text"||t.type!=="insert_text"||e.offset!==t.offset+t.text.length||!R.equals(e.path,t.path))||!(!t||e.type!=="remove_text"||t.type!=="remove_text"||e.offset+e.text.length!==t.offset||!R.equals(e.path,t.path)),eD=(e,t)=>e.type!=="set_selection",tD=(function(){if(Pf)return Na;Pf=1,Na=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 Na})();const Wg=Tv(tD),Nf=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Lf=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",Ua=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Lf(n.overflowY,t)||Lf(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},rs=(e,t,n,r,o,i,s,a)=>i<e&&s>t||i>e&&s<t?0:i<=e&&a<=n||s>=t&&a>=n?i-e-r:s>t&&a<n||i<e&&a>n?s-t+o:0,nD=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},Uf=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:u,boundary:l,skipOverflowHiddenElements:f}=t,c=typeof l=="function"?l:G=>G!==l;if(!Nf(e))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,h=[];let g=e;for(;Nf(g)&&c(g);){if(g=nD(g),g===d){h.push(g);break}g!=null&&g===document.body&&Ua(g)&&!Ua(document.documentElement)||g!=null&&Ua(g,f)&&h.push(g)}const y=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,p=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:w,scrollY:b}=window,{height:C,width:E,top:A,right:x,bottom:I,left:T}=e.getBoundingClientRect(),{top:F,right:S,bottom:k,left:_}=(G=>{const q=window.getComputedStyle(G);return{top:parseFloat(q.scrollMarginTop)||0,right:parseFloat(q.scrollMarginRight)||0,bottom:parseFloat(q.scrollMarginBottom)||0,left:parseFloat(q.scrollMarginLeft)||0}})(e);let M=a==="start"||a==="nearest"?A-F:a==="end"?I+k:A+C/2-F+k,H=u==="center"?T+E/2-_+S:u==="end"?x+S:T-_;const W=[];for(let G=0;G<h.length;G++){const q=h[G],{height:$,width:V,top:Q,right:ae,bottom:ie,left:Se}=q.getBoundingClientRect();if(s==="if-needed"&&A>=0&&T>=0&&I<=p&&x<=y&&A>=Q&&I<=ie&&T>=Se&&x<=ae)return W;const Ie=getComputedStyle(q),ne=parseInt(Ie.borderLeftWidth,10),B=parseInt(Ie.borderTopWidth,10),X=parseInt(Ie.borderRightWidth,10),K=parseInt(Ie.borderBottomWidth,10);let Y=0,de=0;const pe="offsetWidth"in q?q.offsetWidth-q.clientWidth-ne-X:0,fe="offsetHeight"in q?q.offsetHeight-q.clientHeight-B-K:0,we="offsetWidth"in q?q.offsetWidth===0?0:V/q.offsetWidth:0,Ce="offsetHeight"in q?q.offsetHeight===0?0:$/q.offsetHeight:0;if(d===q)Y=a==="start"?M:a==="end"?M-p:a==="nearest"?rs(b,b+p,p,B,K,b+M,b+M+C,C):M-p/2,de=u==="start"?H:u==="center"?H-y/2:u==="end"?H-y:rs(w,w+y,y,ne,X,w+H,w+H+E,E),Y=Math.max(0,Y+b),de=Math.max(0,de+w);else{Y=a==="start"?M-Q-B:a==="end"?M-ie+K+fe:a==="nearest"?rs(Q,ie,$,B,K+fe,M,M+C,C):M-(Q+$/2)+fe/2,de=u==="start"?H-Se-ne:u==="center"?H-(Se+V/2)+pe/2:u==="end"?H-ae+X+pe:rs(Se,ae,V,ne,X+pe,H,H+E,E);const{scrollLeft:se,scrollTop:te}=q;Y=Ce===0?0:Math.max(0,Math.min(te+Y/Ce,q.scrollHeight-$/Ce+fe)),de=we===0?0:Math.max(0,Math.min(se+de/we,q.scrollWidth-V/we+pe)),M+=te-Y,H+=se-de}W.push({el:q,top:Y,left:de})}return W};function rD(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(Uf(e,t));const r=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:o,top:i,left:s}of Uf(e,(a=>a===!1?{block:"end",inline:"nearest"}:(u=>u===Object(u)&&Object.keys(u).length!==0)(a)?a:{block:"start",inline:"nearest"})(t))){const a=i-n.top+n.bottom,u=s-n.left+n.right;o.scroll({top:a,left:u,behavior:r})}}var wi,Pr=[],Hf="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"})(wi||(wi={}));var Ha,Vf,Nr=function(e){return Object.freeze(e)},oD=function(e,t){this.inlineSize=e,this.blockSize=t,Nr(this)},zg=(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,Nr(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})(),ul=function(e){return e instanceof SVGElement&&"getBBox"in e},Kg=function(e){if(ul(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||e.getClientRects().length)},$f=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)},ai=typeof window<"u"?window:{},os=new WeakMap,Wf=/auto|scroll/,iD=/^tb|vertical/,sD=/msie|trident/i.test(ai.navigator&&ai.navigator.userAgent),vn=function(e){return parseFloat(e||"0")},vo=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new oD((n?t:e)||0,(n?e:t)||0)},zf=Nr({devicePixelContentBoxSize:vo(),borderBoxSize:vo(),contentBoxSize:vo(),contentRect:new zg(0,0,0,0)}),qg=function(e,t){if(t===void 0&&(t=!1),os.has(e)&&!t)return os.get(e);if(Kg(e))return os.set(e,zf),zf;var n=getComputedStyle(e),r=ul(e)&&e.ownerSVGElement&&e.getBBox(),o=!sD&&n.boxSizing==="border-box",i=iD.test(n.writingMode||""),s=!r&&Wf.test(n.overflowY||""),a=!r&&Wf.test(n.overflowX||""),u=r?0:vn(n.paddingTop),l=r?0:vn(n.paddingRight),f=r?0:vn(n.paddingBottom),c=r?0:vn(n.paddingLeft),d=r?0:vn(n.borderTopWidth),h=r?0:vn(n.borderRightWidth),g=r?0:vn(n.borderBottomWidth),y=c+l,p=u+f,w=(r?0:vn(n.borderLeftWidth))+h,b=d+g,C=a?e.offsetHeight-b-e.clientHeight:0,E=s?e.offsetWidth-w-e.clientWidth:0,A=o?y+w:0,x=o?p+b:0,I=r?r.width:vn(n.width)-A-E,T=r?r.height:vn(n.height)-x-C,F=I+y+E+w,S=T+p+C+b,k=Nr({devicePixelContentBoxSize:vo(Math.round(I*devicePixelRatio),Math.round(T*devicePixelRatio),i),borderBoxSize:vo(F,S,i),contentBoxSize:vo(I,T,i),contentRect:new zg(c,u,I,T)});return os.set(e,k),k},Gg=function(e,t,n){var r=qg(e,n),o=r.borderBoxSize,i=r.contentBoxSize,s=r.devicePixelContentBoxSize;switch(t){case wi.DEVICE_PIXEL_CONTENT_BOX:return s;case wi.BORDER_BOX:return o;default:return i}},aD=function(e){var t=qg(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Nr([t.borderBoxSize]),this.contentBoxSize=Nr([t.contentBoxSize]),this.devicePixelContentBoxSize=Nr([t.devicePixelContentBoxSize])},Jg=function(e){if(Kg(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},uD=function(){var e=1/0,t=[];Pr.forEach((function(o){if(o.activeTargets.length!==0){var i=[];o.activeTargets.forEach((function(s){var a=new aD(s.target),u=Jg(s.target);i.push(a),s.lastReportedSize=Gg(s.target,s.observedBox),u<e&&(e=u)})),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},Kf=function(e){Pr.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(n){n.isActive()&&(Jg(n.target)>e?t.activeTargets.push(n):t.skippedTargets.push(n))}))}))},cD=function(){var e,t=0;for(Kf(t);Pr.some((function(n){return n.activeTargets.length>0}));)t=uD(),Kf(t);return Pr.some((function(n){return n.skippedTargets.length>0}))&&(typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:Hf}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=Hf),window.dispatchEvent(e)),t>0},qf=[],lD=function(e){if(!Ha){var t=0,n=document.createTextNode("");new MutationObserver((function(){return qf.splice(0).forEach((function(r){return r()}))})).observe(n,{characterData:!0}),Ha=function(){n.textContent="".concat(t?t--:t++)}}qf.push(e),Ha()},Lu=0,dD={attributes:!0,characterData:!0,childList:!0,subtree:!0},Gf=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Jf=function(e){return e===void 0&&(e=0),Date.now()+e},Va=!1,Uu=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),!Va){Va=!0;var r,o=Jf(t);r=function(){var i=!1;try{i=cD()}finally{if(Va=!1,t=o-Jf(),!Lu)return;i?n.run(1e3):t>0?n.run(t):n.start()}},lD((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,dD)};document.body?n():ai.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Gf.forEach((function(n){return ai.addEventListener(n,t.listener,!0)})))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),Gf.forEach((function(n){return ai.removeEventListener(n,t.listener,!0)})),this.stopped=!0)},e})()),Zf=function(e){!Lu&&e>0&&Uu.start(),!(Lu+=e)&&Uu.stop()},fD=(function(){function e(t,n){this.target=t,this.observedBox=n||wi.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=Gg(this.target,this.observedBox,!0);return(function(n){return!ul(n)&&!(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})(n)&&getComputedStyle(n).display==="inline"})(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e})(),hD=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},is=new WeakMap,Xf=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},ss=(function(){function e(){}return e.connect=function(t,n){var r=new hD(t,n);is.set(t,r)},e.observe=function(t,n,r){var o=is.get(t),i=o.observationTargets.length===0;Xf(o.observationTargets,n)<0&&(i&&Pr.push(o),o.observationTargets.push(new fD(n,r&&r.box)),Zf(1),Uu.schedule())},e.unobserve=function(t,n){var r=is.get(t),o=Xf(r.observationTargets,n),i=r.observationTargets.length===1;o>=0&&(i&&Pr.splice(Pr.indexOf(r),1),r.observationTargets.splice(o,1),Zf(-1))},e.disconnect=function(t){var n=this,r=is.get(t);r.observationTargets.slice().forEach((function(o){return n.unobserve(t,o.target)})),r.activeTargets.splice(0,r.activeTargets.length)},e})(),pD=(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.");ss.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(!$f(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");ss.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(!$f(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");ss.unobserve(this,t)},e.prototype.disconnect=function(){ss.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e})(),tn={},$a=(function(){if(Vf)return tn;Vf=1,Object.defineProperty(tn,"__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(f,c,d){c&&!("byKey"in c)&&(d=c,c=null),Array.isArray(f)||(f=[f]);var h=f.map((function(y){return s(y,c)})),g=function(y){return h.some((function(p){return a(p,y)}))};return d==null?g:g(d)}function s(f,c){var d=c&&c.byKey,h={},g=(f=f.replace("++","+add")).split("+"),y=g.length;for(var p in t)h[t[p]]=!1;var w=!0,b=!1,C=void 0;try{for(var E,A=g[Symbol.iterator]();!(w=(E=A.next()).done);w=!0){var x=E.value,I=x.endsWith("?")&&x.length>1;I&&(x=x.slice(0,-1));var T=l(x),F=t[T];if(x.length>1&&!F&&!n[x]&&!r[T])throw new TypeError('Unknown modifier: "'+x+'"');y!==1&&F||(d?h.key=T:h.which=u(x)),F&&(h[F]=!I||null)}}catch(S){b=!0,C=S}finally{try{!w&&A.return&&A.return()}finally{if(b)throw C}}return h}function a(f,c){for(var d in f){var h=f[d],g=void 0;if(h!=null&&((g=d==="key"&&c.key!=null?c.key.toLowerCase():d==="which"?h===91&&c.which===93?91:c.which:c[d])!=null||h!==!1)&&g!==h)return!1}return!0}function u(f){return f=l(f),r[f]||f.toUpperCase().charCodeAt(0)}function l(f){return f=f.toLowerCase(),f=n[f]||f}return tn.default=i,tn.isHotkey=i,tn.isCodeHotkey=function(f,c){return i(f,c)},tn.isKeyHotkey=function(f,c){return i(f,{byKey:!0},c)},tn.parseHotkey=s,tn.compareHotkey=a,tn.toKeyCode=u,tn.toKeyName=l,tn})();function Io(e,t){if(e==null)return{};var n,r,o=(function(s,a){if(s==null)return{};var u,l,f={},c=Object.keys(s);for(l=0;l<c.length;l++)u=c[l],a.indexOf(u)>=0||(f[u]=s[u]);return f})(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 ui(e){return ui=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},ui(e)}function mD(e){var t=(function(n,r){if(ui(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(ui(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return ui(t)==="symbol"?t:String(t)}function Qt(e,t,n){return(t=mD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Wa,za,cl=m.createContext(null),Tn=()=>{var e=m.useContext(cl);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},Zg=parseInt(Be.version.split(".")[0],10),Xg=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Yf=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),It=typeof navigator<"u"&&/Android/.test(navigator.userAgent),lo=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Dr=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),gD=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),Yg=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),vD=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),yD=It&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),bD=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),CD=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),wD=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent),ps=!(typeof window>"u"||window.document===void 0||window.document.createElement===void 0);typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&(Wa=navigator.userAgent.match(/Version\/(\d+)/))!==null&&Wa!==void 0&&Wa[1]&&parseInt((za=navigator.userAgent.match(/Version\/(\d+)/))===null||za===void 0?void 0:za[1],10);var er=(!vD||!yD)&&!gD&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function",yo=new WeakMap,ll=new WeakMap,dl=new WeakMap,Qg=new WeakMap,ms=new WeakMap,Hu=new WeakMap,Ei=new WeakMap,Lr=new WeakMap,js=new WeakMap,Qs=new WeakMap,Vu=new WeakMap,cr=new WeakMap,Rr=new WeakMap,ci=new WeakMap,$u=new WeakMap,fl=new WeakMap,on=new WeakMap,Pn=new WeakMap,_t=new WeakMap,nr=new WeakMap,rr=new WeakMap,e0=new WeakMap,To=Symbol("placeholder"),t0=Symbol("mark-placeholder"),n0=globalThis.Node,ED=globalThis.Text,hl=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,DD=e=>pr(e)&&e.nodeType===8,qt=e=>pr(e)&&e.nodeType===1,pr=e=>{var t=hl(e);return!!t&&e instanceof t.Node},Wu=e=>{var t=e&&e.anchorNode&&hl(e.anchorNode);return!!t&&e instanceof t.Selection},r0=e=>pr(e)&&e.nodeType===3,o0=(e,t,n)=>{for(var{childNodes:r}=e,o=r[t],i=t,s=!1,a=!1;(DD(o)||qt(o)&&o.childNodes.length===0||qt(o)&&o.getAttribute("contenteditable")==="false")&&(!s||!a);)i>=r.length?(s=!0,i=t-1,n="backward"):i<0?(a=!0,i=t+1,n="forward"):(o=r[i],t=i,i+=n==="forward"?1:-1);return[o,t]},AD=(e,t,n)=>{var[r]=o0(e,t,n);return r},i0=e=>{var t="";if(r0(e)&&e.nodeValue)return e.nodeValue;if(qt(e)){for(var n of Array.from(e.childNodes))t+=i0(n);var r=getComputedStyle(e).getPropertyValue("display");r!=="block"&&r!=="list"&&e.tagName!=="BR"||(t+=`
|
|
49
|
-
`)}return t},xD=/data-slate-fragment="(.+?)"/m,li=e=>e.getSelection!=null?e.getSelection():document.getSelection(),
|
|
48
|
+
`)},hb=0,Zr=[];function pb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const mb=(jd=function(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(hb++)[0],i=m.useState(Em)[0],s=m.useRef(e);m.useEffect((function(){s.current=e}),[e]),m.useEffect((function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=(function(p,w,b){if(b||arguments.length===2)for(var C,E=0,A=w.length;E<A;E++)!C&&E in w||(C||(C=Array.prototype.slice.call(w,0,E)),C[E]=w[E]);return p.concat(C||Array.prototype.slice.call(w))})([e.lockRef.current],(e.shards||[]).map(_d),!0).filter(Boolean);return y.forEach((function(p){return p.classList.add("allow-interactivity-".concat(o))})),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach((function(p){return p.classList.remove("allow-interactivity-".concat(o))}))}}}),[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback((function(y,p){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!s.current.allowPinchZoom;var w,b=Ji(y),C=n.current,E="deltaX"in y?y.deltaX:C[0]-b[0],A="deltaY"in y?y.deltaY:C[1]-b[1],x=y.target,I=Math.abs(E)>Math.abs(A)?"h":"v";if("touches"in y&&I==="h"&&x.type==="range")return!1;var T=window.getSelection(),F=T&&T.anchorNode;if(F&&(F===x||F.contains(x)))return!1;var S=Fd(I,x);if(!S)return!0;if(S?w=I:(w=I==="v"?"h":"v",S=Fd(I,x)),!S)return!1;if(!r.current&&"changedTouches"in y&&(E||A)&&(r.current=w),!w)return!0;var k=r.current||w;return(function(_,M,H,W){var G=(function(K,Y){return K==="h"&&Y==="rtl"?-1:1})(_,window.getComputedStyle(M).direction),q=G*W,$=H.target,V=M.contains($),Q=!1,ae=q>0,ie=0,Se=0;do{if(!$)break;var Ie=Am(_,$),ne=Ie[0],B=Ie[1]-Ie[2]-G*ne;(ne||B)&&Dm(_,$)&&(ie+=B,Se+=ne);var X=$.parentNode;$=X&&X.nodeType===Node.DOCUMENT_FRAGMENT_NODE?X.host:X}while(!V&&$!==document.body||V&&(M.contains($)||M===$));return(ae&&Math.abs(ie)<1||!ae&&Math.abs(Se)<1)&&(Q=!0),Q})(k,p,y,k==="h"?E:A)}),[]),u=m.useCallback((function(y){var p=y;if(Zr.length&&Zr[Zr.length-1]===i){var w="deltaY"in p?Rd(p):Ji(p),b=t.current.filter((function(E){return E.name===p.type&&(E.target===p.target||p.target===E.shadowParent)&&(function(A,x){return A[0]===x[0]&&A[1]===x[1]})(E.delta,w)}))[0];if(b&&b.should)p.cancelable&&p.preventDefault();else if(!b){var C=(s.current.shards||[]).map(_d).filter(Boolean).filter((function(E){return E.contains(p.target)}));(C.length>0?a(p,C[0]):!s.current.noIsolation)&&p.cancelable&&p.preventDefault()}}}),[]),l=m.useCallback((function(y,p,w,b){var C={name:y,delta:p,target:w,should:b,shadowParent:pb(w)};t.current.push(C),setTimeout((function(){t.current=t.current.filter((function(E){return E!==C}))}),1)}),[]),f=m.useCallback((function(y){n.current=Ji(y),r.current=void 0}),[]),c=m.useCallback((function(y){l(y.type,Rd(y),y.target,a(y,e.lockRef.current))}),[]),d=m.useCallback((function(y){l(y.type,Ji(y),y.target,a(y,e.lockRef.current))}),[]);m.useEffect((function(){return Zr.push(i),e.setCallbacks({onScrollCapture:c,onWheelCapture:c,onTouchMoveCapture:d}),document.addEventListener("wheel",u,Jr),document.addEventListener("touchmove",u,Jr),document.addEventListener("touchstart",f,Jr),function(){Zr=Zr.filter((function(y){return y!==i})),document.removeEventListener("wheel",u,Jr),document.removeEventListener("touchmove",u,Jr),document.removeEventListener("touchstart",f,Jr)}}),[]);var h=e.removeScrollBar,g=e.inert;return m.createElement(m.Fragment,null,g?m.createElement(i,{styles:fb(o)}):null,h?m.createElement(db,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},wm.useMedium(jd),Cm);var jd,Fc=m.forwardRef((function(e,t){return m.createElement(Is,wn({},e,{ref:t,sideCar:mb}))}));Fc.classNames=Is.classNames;var Xr=new WeakMap,Zi=new WeakMap,Xi={},Md=0,xm=function(e){return e&&(e.host||xm(e.parentNode))},gb=function(e,t,n,r){var o=(function(c,d){return d.map((function(h){if(c.contains(h))return h;var g=xm(h);return g&&c.contains(g)?g:(console.error("aria-hidden",h,"in not contained inside",c,". Doing nothing"),null)})).filter((function(h){return!!h}))})(t,Array.isArray(e)?e:[e]);Xi[n]||(Xi[n]=new WeakMap);var i=Xi[n],s=[],a=new Set,u=new Set(o),l=function(c){c&&!a.has(c)&&(a.add(c),l(c.parentNode))};o.forEach(l);var f=function(c){c&&!u.has(c)&&Array.prototype.forEach.call(c.children,(function(d){if(a.has(d))f(d);else try{var h=d.getAttribute(r),g=h!==null&&h!=="false",y=(Xr.get(d)||0)+1,p=(i.get(d)||0)+1;Xr.set(d,y),i.set(d,p),s.push(d),y===1&&g&&Zi.set(d,!0),p===1&&d.setAttribute(n,"true"),g||d.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",d,w)}}))};return f(t),a.clear(),Md++,function(){s.forEach((function(c){var d=Xr.get(c)-1,h=i.get(c)-1;Xr.set(c,d),i.set(c,h),d||(Zi.has(c)||c.removeAttribute(r),Zi.delete(c)),h||c.removeAttribute(n)})),--Md||(Xr=new WeakMap,Xr=new WeakMap,Zi=new WeakMap,Xi={})}},Om=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=(function(i){return typeof document>"u"?null:(Array.isArray(i)?i[0]:i).ownerDocument.body})(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),gb(r,o,n,"aria-hidden")):function(){return null}},vb=Object.defineProperty;function Sm(e){const[t,n]=m.useState(void 0);return Yt((()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver((o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const u=i.borderBoxSize,l=Array.isArray(u)?u[0]:u;s=l.inlineSize,a=l.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})}));return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}n(void 0)}),[e]),t}((e,t)=>{vb(e,"name",{value:t,configurable:!0})})(Sm,"useSize");const yb=["top","right","bottom","left"],fn=Math.min,wt=Math.max,Ts=Math.round,Yi=Math.floor,En=e=>({x:e,y:e}),bb={left:"right",right:"left",bottom:"top",top:"bottom"},Cb={start:"end",end:"start"};function xu(e,t,n){return wt(e,fn(t,n))}function On(e,t){return typeof e=="function"?e(t):e}function un(e){return e.split("-")[0]}function Do(e){return e.split("-")[1]}function Rc(e){return e==="x"?"y":"x"}function _c(e){return e==="y"?"height":"width"}function Wn(e){return["top","bottom"].includes(un(e))?"y":"x"}function jc(e){return Rc(Wn(e))}function Ta(e){return e.replace(/start|end/g,(t=>Cb[t]))}function Qi(e){return e.replace(/left|right|bottom|top/g,(t=>bb[t]))}function Mc(e){return typeof e!="number"?(function(t){return{top:0,right:0,bottom:0,left:0,...t}})(e):{top:e,right:e,bottom:e,left:e}}function Ao(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Pd(e,t,n){let{reference:r,floating:o}=e;const i=Wn(t),s=jc(t),a=_c(s),u=un(t),l=i==="y",f=r.x+r.width/2-o.width/2,c=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2;let h;switch(u){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:c};break;case"left":h={x:r.x-o.width,y:c};break;default:h={x:r.x,y:r.y}}switch(Do(t)){case"start":h[s]-=d*(n&&l?-1:1);break;case"end":h[s]+=d*(n&&l?-1:1)}return h}async function gi(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:c="floating",altBoundary:d=!1,padding:h=0}=On(t,e),g=Mc(h),y=a[d?c==="floating"?"reference":"floating":c],p=Ao(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:u})),w=c==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),C=await(i.isElement==null?void 0:i.isElement(b))&&await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1},E=Ao(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:u}):w);return{top:(p.top-E.top+g.top)/C.y,bottom:(E.bottom-p.bottom+g.bottom)/C.y,left:(p.left-E.left+g.left)/C.x,right:(E.right-p.right+g.right)/C.x}}function Nd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ld(e){return yb.some((t=>e[t]>=0))}function Ud(e){const t=fn(...e.map((r=>r.left))),n=fn(...e.map((r=>r.top)));return{x:t,y:n,width:wt(...e.map((r=>r.right)))-t,height:wt(...e.map((r=>r.bottom)))-n}}function zs(){return typeof window<"u"}function xo(e){return Im(e)?(e.nodeName||"").toLowerCase():"#document"}function Ht(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dn(e){var t;return(t=(Im(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Im(e){return!!zs()&&(e instanceof Node||e instanceof Ht(e).Node)}function cn(e){return!!zs()&&(e instanceof Element||e instanceof Ht(e).Element)}function Sn(e){return!!zs()&&(e instanceof HTMLElement||e instanceof Ht(e).HTMLElement)}function Hd(e){return!(!zs()||typeof ShadowRoot>"u")&&(e instanceof ShadowRoot||e instanceof Ht(e).ShadowRoot)}function vi(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function wb(e){return["table","td","th"].includes(xo(e))}function ks(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch{return!1}}))}function Ou(e){const t=Pc(),n=cn(e)?ln(e):e;return["transform","translate","scale","rotate","perspective"].some((r=>!!n[r]&&n[r]!=="none"))||!!n.containerType&&n.containerType!=="normal"||!t&&!!n.backdropFilter&&n.backdropFilter!=="none"||!t&&!!n.filter&&n.filter!=="none"||["transform","translate","scale","rotate","perspective","filter"].some((r=>(n.willChange||"").includes(r)))||["paint","layout","strict","content"].some((r=>(n.contain||"").includes(r)))}function Pc(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function mo(e){return["html","body","#document"].includes(xo(e))}function ln(e){return Ht(e).getComputedStyle(e)}function Ks(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ar(e){if(xo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Hd(e)&&e.host||Dn(e);return Hd(t)?t.host:t}function Tm(e){const t=ar(e);return mo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&vi(t)?t:Tm(t)}function yi(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Tm(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=Ht(o);if(i){const a=Su(s);return t.concat(s,s.visualViewport||[],vi(o)?o:[],a&&n?yi(a):[])}return t.concat(o,yi(o,[],n))}function Su(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function km(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Ts(n)!==i||Ts(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function Nc(e){return cn(e)?e:e.contextElement}function go(e){const t=Nc(e);if(!Sn(t))return En(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=km(t);let s=(i?Ts(n.width):n.width)/r,a=(i?Ts(n.height):n.height)/o;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const Eb=En(0);function Bm(e){const t=Ht(e);return Pc()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Eb}function Ur(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Nc(e);let s=En(1);t&&(r?cn(r)&&(s=go(r)):s=go(e));const a=(function(d,h,g){return h===void 0&&(h=!1),!(!g||h&&g!==Ht(d))&&h})(i,n,r)?Bm(i):En(0);let u=(o.left+a.x)/s.x,l=(o.top+a.y)/s.y,f=o.width/s.x,c=o.height/s.y;if(i){const d=Ht(i),h=r&&cn(r)?Ht(r):r;let g=d,y=Su(g);for(;y&&r&&h!==g;){const p=go(y),w=y.getBoundingClientRect(),b=ln(y),C=w.left+(y.clientLeft+parseFloat(b.paddingLeft))*p.x,E=w.top+(y.clientTop+parseFloat(b.paddingTop))*p.y;u*=p.x,l*=p.y,f*=p.x,c*=p.y,u+=C,l+=E,g=Ht(y),y=Su(g)}}return Ao({width:f,height:c,x:u,y:l})}function Lc(e,t){const n=Ks(e).scrollLeft;return t?t.left+n:Ur(Dn(e)).left+n}function Fm(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:Lc(e,r)),y:r.top+t.scrollTop}}function Vd(e,t,n){let r;if(t==="viewport")r=(function(o,i){const s=Ht(o),a=Dn(o),u=s.visualViewport;let l=a.clientWidth,f=a.clientHeight,c=0,d=0;if(u){l=u.width,f=u.height;const h=Pc();(!h||h&&i==="fixed")&&(c=u.offsetLeft,d=u.offsetTop)}return{width:l,height:f,x:c,y:d}})(e,n);else if(t==="document")r=(function(o){const i=Dn(o),s=Ks(o),a=o.ownerDocument.body,u=wt(i.scrollWidth,i.clientWidth,a.scrollWidth,a.clientWidth),l=wt(i.scrollHeight,i.clientHeight,a.scrollHeight,a.clientHeight);let f=-s.scrollLeft+Lc(o);const c=-s.scrollTop;return ln(a).direction==="rtl"&&(f+=wt(i.clientWidth,a.clientWidth)-u),{width:u,height:l,x:f,y:c}})(Dn(e));else if(cn(t))r=(function(o,i){const s=Ur(o,!0,i==="fixed"),a=s.top+o.clientTop,u=s.left+o.clientLeft,l=Sn(o)?go(o):En(1);return{width:o.clientWidth*l.x,height:o.clientHeight*l.y,x:u*l.x,y:a*l.y}})(t,n);else{const o=Bm(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ao(r)}function Rm(e,t){const n=ar(e);return!(n===t||!cn(n)||mo(n))&&(ln(n).position==="fixed"||Rm(n,t))}function Db(e,t,n){const r=Sn(t),o=Dn(t),i=n==="fixed",s=Ur(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const u=En(0);if(r||!r&&!i)if((xo(t)!=="body"||vi(o))&&(a=Ks(t)),r){const f=Ur(t,!0,i,t);u.x=f.x+t.clientLeft,u.y=f.y+t.clientTop}else o&&(u.x=Lc(o));const l=!o||r||i?En(0):Fm(o,a);return{x:s.left+a.scrollLeft-u.x-l.x,y:s.top+a.scrollTop-u.y-l.y,width:s.width,height:s.height}}function ka(e){return ln(e).position==="static"}function $d(e,t){if(!Sn(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Dn(e)===n&&(n=n.ownerDocument.body),n}function Wd(e,t){const n=Ht(e);if(ks(e))return n;if(!Sn(e)){let o=ar(e);for(;o&&!mo(o);){if(cn(o)&&!ka(o))return o;o=ar(o)}return n}let r=$d(e,t);for(;r&&wb(r)&&ka(r);)r=$d(r,t);return r&&mo(r)&&ka(r)&&!Ou(r)?n:r||(function(o){let i=ar(o);for(;Sn(i)&&!mo(i);){if(Ou(i))return i;if(ks(i))return null;i=ar(i)}return null})(e)||n}const Ab={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Dn(r),a=!!t&&ks(t.floating);if(r===s||a&&i)return n;let u={scrollLeft:0,scrollTop:0},l=En(1);const f=En(0),c=Sn(r);if((c||!c&&!i)&&((xo(r)!=="body"||vi(s))&&(u=Ks(r)),Sn(r))){const h=Ur(r);l=go(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const d=!s||c||i?En(0):Fm(s,u,!0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+f.x+d.x,y:n.y*l.y-u.scrollTop*l.y+f.y+d.y}},getDocumentElement:Dn,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=n==="clippingAncestors"?ks(t)?[]:(function(l,f){const c=f.get(l);if(c)return c;let d=yi(l,[],!1).filter((p=>cn(p)&&xo(p)!=="body")),h=null;const g=ln(l).position==="fixed";let y=g?ar(l):l;for(;cn(y)&&!mo(y);){const p=ln(y),w=Ou(y);w||p.position!=="fixed"||(h=null),(g?!w&&!h:!w&&p.position==="static"&&h&&["absolute","fixed"].includes(h.position)||vi(y)&&!w&&Rm(l,y))?d=d.filter((b=>b!==y)):h=p,y=ar(y)}return f.set(l,d),d})(t,this._c):[].concat(n),s=[...i,r],a=s[0],u=s.reduce(((l,f)=>{const c=Vd(t,f,o);return l.top=wt(c.top,l.top),l.right=fn(c.right,l.right),l.bottom=fn(c.bottom,l.bottom),l.left=wt(c.left,l.left),l}),Vd(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:Wd,getElementRects:async function(e){const t=this.getOffsetParent||Wd,n=this.getDimensions,r=await n(e.floating);return{reference:Db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=km(e);return{width:t,height:n}},getScale:go,isElement:cn,isRTL:function(e){return ln(e).direction==="rtl"}};function zd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function _m(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=Nc(e),f=o||i?[...l?yi(l):[],...yi(t)]:[];f.forEach((p=>{o&&p.addEventListener("scroll",n,{passive:!0}),i&&p.addEventListener("resize",n)}));const c=l&&a?(function(p,w){let b,C=null;const E=Dn(p);function A(){var x;clearTimeout(b),(x=C)==null||x.disconnect(),C=null}return(function x(I,T){I===void 0&&(I=!1),T===void 0&&(T=1),A();const F=p.getBoundingClientRect(),{left:S,top:k,width:_,height:M}=F;if(I||w(),!_||!M)return;const H={rootMargin:-Yi(k)+"px "+-Yi(E.clientWidth-(S+_))+"px "+-Yi(E.clientHeight-(k+M))+"px "+-Yi(S)+"px",threshold:wt(0,fn(1,T))||1};let W=!0;function G(q){const $=q[0].intersectionRatio;if($!==T){if(!W)return x();$?x(!1,$):b=setTimeout((()=>{x(!1,1e-7)}),1e3)}$!==1||zd(F,p.getBoundingClientRect())||x(),W=!1}try{C=new IntersectionObserver(G,{...H,root:E.ownerDocument})}catch{C=new IntersectionObserver(G,H)}C.observe(p)})(!0),A})(l,n):null;let d,h=-1,g=null;s&&(g=new ResizeObserver((p=>{let[w]=p;w&&w.target===l&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var b;(b=g)==null||b.observe(t)}))),n()})),l&&!u&&g.observe(l),g.observe(t));let y=u?Ur(e):null;return u&&(function p(){const w=Ur(e);y&&!zd(y,w)&&n(),y=w,d=requestAnimationFrame(p)})(),n(),()=>{var p;f.forEach((w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)})),c?.(),(p=g)==null||p.disconnect(),g=null,u&&cancelAnimationFrame(d)}}const xb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,u=await(async function(l,f){const{placement:c,platform:d,elements:h}=l,g=await(d.isRTL==null?void 0:d.isRTL(h.floating)),y=un(c),p=Do(c),w=Wn(c)==="y",b=["left","top"].includes(y)?-1:1,C=g&&w?-1:1,E=On(f,l);let{mainAxis:A,crossAxis:x,alignmentAxis:I}=typeof E=="number"?{mainAxis:E,crossAxis:0,alignmentAxis:null}:{mainAxis:E.mainAxis||0,crossAxis:E.crossAxis||0,alignmentAxis:E.alignmentAxis};return p&&typeof I=="number"&&(x=p==="end"?-1*I:I),w?{x:x*C,y:A*b}:{x:A*b,y:x*C}})(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},Ob=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:p=>{let{x:w,y:b}=p;return{x:w,y:b}}},...u}=On(e,t),l={x:n,y:r},f=await gi(t,u),c=Wn(un(o)),d=Rc(c);let h=l[d],g=l[c];if(i){const p=d==="y"?"bottom":"right";h=xu(h+f[d==="y"?"top":"left"],h,h-f[p])}if(s){const p=c==="y"?"bottom":"right";g=xu(g+f[c==="y"?"top":"left"],g,g-f[p])}const y=a.fn({...t,[d]:h,[c]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[d]:i,[c]:s}}}}}},Sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:u,elements:l}=t,{mainAxis:f=!0,crossAxis:c=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...p}=On(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=un(o),b=Wn(a),C=un(a)===a,E=await(u.isRTL==null?void 0:u.isRTL(l.floating)),A=d||(C||!y?[Qi(a)]:(function(H){const W=Qi(H);return[Ta(H),W,Ta(W)]})(a)),x=g!=="none";!d&&x&&A.push(...(function(H,W,G,q){const $=Do(H);let V=(function(Q,ae,ie){const Se=["left","right"],Ie=["right","left"],ne=["top","bottom"],B=["bottom","top"];switch(Q){case"top":case"bottom":return ie?ae?Ie:Se:ae?Se:Ie;case"left":case"right":return ae?ne:B;default:return[]}})(un(H),G==="start",q);return $&&(V=V.map((Q=>Q+"-"+$)),W&&(V=V.concat(V.map(Ta)))),V})(a,y,g,E));const I=[a,...A],T=await gi(t,p),F=[];let S=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&F.push(T[w]),c){const H=(function(W,G,q){q===void 0&&(q=!1);const $=Do(W),V=jc(W),Q=_c(V);let ae=V==="x"?$===(q?"end":"start")?"right":"left":$==="start"?"bottom":"top";return G.reference[Q]>G.floating[Q]&&(ae=Qi(ae)),[ae,Qi(ae)]})(o,s,E);F.push(T[H[0]],T[H[1]])}if(S=[...S,{placement:o,overflows:F}],!F.every((H=>H<=0))){var k,_;const H=(((k=i.flip)==null?void 0:k.index)||0)+1,W=I[H];if(W)return{data:{index:H,overflows:S},reset:{placement:W}};let G=(_=S.filter((q=>q.overflows[0]<=0)).sort(((q,$)=>q.overflows[1]-$.overflows[1]))[0])==null?void 0:_.placement;if(!G)switch(h){case"bestFit":{var M;const q=(M=S.filter(($=>{if(x){const V=Wn($.placement);return V===b||V==="y"}return!0})).map(($=>[$.placement,$.overflows.filter((V=>V>0)).reduce(((V,Q)=>V+Q),0)])).sort((($,V)=>$[1]-V[1]))[0])==null?void 0:M[0];q&&(G=q);break}case"initialPlacement":G=a}if(o!==G)return{reset:{placement:G}}}return{}}}},Ib=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:u=()=>{},...l}=On(e,t),f=await gi(t,l),c=un(o),d=Do(o),h=Wn(o)==="y",{width:g,height:y}=i.floating;let p,w;c==="top"||c==="bottom"?(p=c,w=d===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(w=c,p=d==="end"?"top":"bottom");const b=y-f.top-f.bottom,C=g-f.left-f.right,E=fn(y-f[p],b),A=fn(g-f[w],C),x=!t.middlewareData.shift;let I=E,T=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),x&&!d){const S=wt(f.left,0),k=wt(f.right,0),_=wt(f.top,0),M=wt(f.bottom,0);h?T=g-2*(S!==0||k!==0?S+k:wt(f.left,f.right)):I=y-2*(_!==0||M!==0?_+M:wt(f.top,f.bottom))}await u({...t,availableWidth:T,availableHeight:I});const F=await s.getDimensions(a.floating);return g!==F.width||y!==F.height?{reset:{rects:!0}}:{}}}},Tb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=On(e,t);switch(r){case"referenceHidden":{const i=Nd(await gi(t,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Ld(i)}}}case"escaped":{const i=Nd(await gi(t,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:i,escaped:Ld(i)}}}default:return{}}}}},Kd=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:u}=t,{element:l,padding:f=0}=On(e,t)||{};if(l==null)return{};const c=Mc(f),d={x:n,y:r},h=jc(o),g=_c(h),y=await s.getDimensions(l),p=h==="y",w=p?"top":"left",b=p?"bottom":"right",C=p?"clientHeight":"clientWidth",E=i.reference[g]+i.reference[h]-d[h]-i.floating[g],A=d[h]-i.reference[h],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let I=x?x[C]:0;I&&await(s.isElement==null?void 0:s.isElement(x))||(I=a.floating[C]||i.floating[g]);const T=E/2-A/2,F=I/2-y[g]/2-1,S=fn(c[w],F),k=fn(c[b],F),_=S,M=I-y[g]-k,H=I/2-y[g]/2+T,W=xu(_,H,M),G=!u.arrow&&Do(o)!=null&&H!==W&&i.reference[g]/2-(H<_?S:k)-y[g]/2<0,q=G?H<_?H-_:H-M:0;return{[h]:d[h]+q,data:{[h]:W,centerOffset:H-W-q,...G&&{alignmentOffset:q}},reset:G}}}),kb=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:r,rects:o,platform:i,strategy:s}=t,{padding:a=2,x:u,y:l}=On(e,t),f=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),c=(function(y){const p=y.slice().sort(((C,E)=>C.y-E.y)),w=[];let b=null;for(let C=0;C<p.length;C++){const E=p[C];!b||E.y-b.y>b.height/2?w.push([E]):w[w.length-1].push(E),b=E}return w.map((C=>Ao(Ud(C))))})(f),d=Ao(Ud(f)),h=Mc(a),g=await i.getElementRects({reference:{getBoundingClientRect:function(){if(c.length===2&&c[0].left>c[1].right&&u!=null&&l!=null)return c.find((y=>u>y.left-h.left&&u<y.right+h.right&&l>y.top-h.top&&l<y.bottom+h.bottom))||d;if(c.length>=2){if(Wn(n)==="y"){const A=c[0],x=c[c.length-1],I=un(n)==="top",T=A.top,F=x.bottom,S=I?A.left:x.left,k=I?A.right:x.right;return{top:T,bottom:F,left:S,right:k,width:k-S,height:F-T,x:S,y:T}}const y=un(n)==="left",p=wt(...c.map((A=>A.right))),w=fn(...c.map((A=>A.left))),b=c.filter((A=>y?A.left===w:A.right===p)),C=b[0].top,E=b[b.length-1].bottom;return{top:C,bottom:E,left:w,right:p,width:p-w,height:E-C,x:w,y:C}}return d}},floating:r.floating,strategy:s});return o.reference.x!==g.reference.x||o.reference.y!==g.reference.y||o.reference.width!==g.reference.width||o.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},Bb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:u=!0,crossAxis:l=!0}=On(e,t),f={x:n,y:r},c=Wn(o),d=Rc(c);let h=f[d],g=f[c];const y=On(a,t),p=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){const C=d==="y"?"height":"width",E=i.reference[d]-i.floating[C]+p.mainAxis,A=i.reference[d]+i.reference[C]-p.mainAxis;h<E?h=E:h>A&&(h=A)}if(l){var w,b;const C=d==="y"?"width":"height",E=["top","left"].includes(un(o)),A=i.reference[c]-i.floating[C]+(E&&((w=s.offset)==null?void 0:w[c])||0)+(E?0:p.crossAxis),x=i.reference[c]+i.reference[C]+(E?0:((b=s.offset)==null?void 0:b[c])||0)-(E?p.crossAxis:0);g<A?g=A:g>x&&(g=x)}return{[d]:h,[c]:g}}}},Fb=(e,t,n)=>{const r=new Map,o={platform:Ab,...n},i={...o.platform,_c:r};return(async(s,a,u)=>{const{placement:l="bottom",strategy:f="absolute",middleware:c=[],platform:d}=u,h=c.filter(Boolean),g=await(d.isRTL==null?void 0:d.isRTL(a));let y=await d.getElementRects({reference:s,floating:a,strategy:f}),{x:p,y:w}=Pd(y,l,g),b=l,C={},E=0;for(let A=0;A<h.length;A++){const{name:x,fn:I}=h[A],{x:T,y:F,data:S,reset:k}=await I({x:p,y:w,initialPlacement:l,placement:b,strategy:f,middlewareData:C,rects:y,platform:d,elements:{reference:s,floating:a}});p=T??p,w=F??w,C={...C,[x]:{...C[x],...S}},k&&E<=50&&(E++,typeof k=="object"&&(k.placement&&(b=k.placement),k.rects&&(y=k.rects===!0?await d.getElementRects({reference:s,floating:a,strategy:f}):k.rects),{x:p,y:w}=Pd(y,b,g)),A=-1)}return{x:p,y:w,placement:b,strategy:f,middlewareData:C}})(e,t,{...o,platform:i})};var fs=typeof document<"u"?m.useLayoutEffect:m.useEffect;function Bs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!=0;)if(!Bs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!=0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!=0;){const i=o[r];if((i!=="_owner"||!e.$$typeof)&&!Bs(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}function jm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qd(e,t){const n=jm(e);return Math.round(t*n)/n}function Ba(e){const t=m.useRef(e);return fs((()=>{t.current=e})),t}function Mm(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:u,open:l}=e,[f,c]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);Bs(d,r)||h(r);const[g,y]=m.useState(null),[p,w]=m.useState(null),b=m.useCallback(($=>{$!==x.current&&(x.current=$,y($))}),[]),C=m.useCallback(($=>{$!==I.current&&(I.current=$,w($))}),[]),E=i||g,A=s||p,x=m.useRef(null),I=m.useRef(null),T=m.useRef(f),F=u!=null,S=Ba(u),k=Ba(o),_=Ba(l),M=m.useCallback((()=>{if(!x.current||!I.current)return;const $={placement:t,strategy:n,middleware:d};k.current&&($.platform=k.current),Fb(x.current,I.current,$).then((V=>{const Q={...V,isPositioned:_.current!==!1};H.current&&!Bs(T.current,Q)&&(T.current=Q,Oi.flushSync((()=>{c(Q)})))}))}),[d,t,n,k,_]);fs((()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,c(($=>({...$,isPositioned:!1}))))}),[l]);const H=m.useRef(!1);fs((()=>(H.current=!0,()=>{H.current=!1})),[]),fs((()=>{if(E&&(x.current=E),A&&(I.current=A),E&&A){if(S.current)return S.current(E,A,M);M()}}),[E,A,M,S,F]);const W=m.useMemo((()=>({reference:x,floating:I,setReference:b,setFloating:C})),[b,C]),G=m.useMemo((()=>({reference:E,floating:A})),[E,A]),q=m.useMemo((()=>{const $={position:n,left:0,top:0};if(!G.floating)return $;const V=qd(G.floating,f.x),Q=qd(G.floating,f.y);return a?{...$,transform:"translate("+V+"px, "+Q+"px)",...jm(G.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:Q}}),[n,a,G.floating,f.x,f.y]);return m.useMemo((()=>({...f,update:M,refs:W,elements:G,floatingStyles:q})),[f,M,W,G,q])}const Rb=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}=typeof e=="function"?e(t):e;return n&&(function(o){return{}.hasOwnProperty.call(o,"current")})(n)?n.current!=null?Kd({element:n.current,padding:r}).fn(t):{}:n?Kd({element:n,padding:r}).fn(t):{}}}),Pm=(e,t)=>({...xb(e),options:[e,t]}),Nm=(e,t)=>({...Ob(e),options:[e,t]}),Lm=(e,t)=>({...Bb(e),options:[e,t]}),Um=(e,t)=>({...Sb(e),options:[e,t]}),Hm=(e,t)=>({...Ib(e),options:[e,t]}),Vm=(e,t)=>({...Tb(e),options:[e,t]}),_b=(e,t)=>({...kb(e),options:[e,t]}),jb=(e,t)=>({...Rb(e),options:[e,t]});var Mb=Object.defineProperty,dr=(e,t)=>Mb(e,"name",{value:t,configurable:!0}),$m="Popper",[Wm,Lo]=qn($m),[Pb,zm]=Wm($m),Nb=dr((e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null),[i,s]=m.useState(void 0);return v.jsx(Pb,{scope:t,anchor:r,onAnchorChange:o,placementState:i,setPlacementState:s,children:n})}),"Popper"),Lb=m.forwardRef(dr((function(e,t){const{__scopePopper:n,virtualRef:r,...o}=e,i=zm("PopperAnchor",n),s=m.useRef(null),a=i.onAnchorChange,u=m.useCallback((g=>{s.current=g,g&&a(g)}),[a]),l=Qe(t,u),f=m.useRef(null);m.useEffect((()=>{if(!r)return;const g=f.current;f.current=r.current,g!==f.current&&a(f.current)}));const c=i.placementState&&qs(i.placementState),d=c?.[0],h=c?.[1];return r?null:v.jsx($t.div,{"data-radix-popper-side":d,"data-radix-popper-align":h,...o,ref:l})}),"PopperAnchor")),Km="PopperContent",[Ub,Rx]=Wm(Km),Hb=m.forwardRef(dr((function(e,t){const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:c="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:g,...y}=e,p=zm(Km,n),[w,b]=m.useState(null),C=Qe(t,b),[E,A]=m.useState(null),x=Sm(E),I=x?.width??0,T=x?.height??0,F=r+(i!=="center"?"-"+i:""),S=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},k=Array.isArray(l)?l:[l],_=k.length>0,M={padding:S,boundary:k.filter(qm),altBoundary:_},{refs:H,floatingStyles:W,placement:G,isPositioned:q,middlewareData:$}=Mm({strategy:"fixed",placement:F,whileElementsMounted:dr(((...K)=>_m(...K,{animationFrame:h==="always"})),"whileElementsMounted"),elements:{reference:p.anchor},middleware:[Pm({mainAxis:o+T,alignmentAxis:s}),u&&Nm({mainAxis:!0,crossAxis:!1,limiter:c==="partial"?Lm():void 0,...M}),u&&Um({...M}),Hm({...M,apply:dr((({elements:K,rects:Y,availableWidth:de,availableHeight:pe})=>{const{width:fe,height:we}=Y.reference,Ce=K.floating.style;Ce.setProperty("--radix-popper-available-width",`${de}px`),Ce.setProperty("--radix-popper-available-height",`${pe}px`),Ce.setProperty("--radix-popper-anchor-width",`${fe}px`),Ce.setProperty("--radix-popper-anchor-height",`${we}px`)}),"apply")}),E&&jb({element:E,padding:a}),Vb({arrowWidth:I,arrowHeight:T}),d&&Vm({strategy:"referenceHidden",...M,boundary:_?M.boundary:void 0})]}),V=p.setPlacementState;Yt((()=>(V(G),()=>{V(void 0)})),[G,V]);const[Q,ae]=qs(G),ie=$n(g);Yt((()=>{q&&ie?.()}),[q,ie]);const Se=$.arrow?.x,Ie=$.arrow?.y,ne=$.arrow?.centerOffset!==0,[B,X]=m.useState();return Yt((()=>{w&&X(window.getComputedStyle(w).zIndex)}),[w]),v.jsx("div",{ref:H.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:q?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:B,"--radix-popper-transform-origin":[$.transformOrigin?.x,$.transformOrigin?.y].join(" "),...$.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:v.jsx(Ub,{scope:n,placedSide:Q,placedAlign:ae,onArrowChange:A,arrowX:Se,arrowY:Ie,shouldHideArrow:ne,children:v.jsx($t.div,{"data-side":Q,"data-align":ae,...y,ref:C,style:{...y.style,animation:q?y.style?.animation:"none"}})})})}),"PopperContent"));function qm(e){return e!==null}dr(qm,"isNotNull");var Vb=dr((e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,s=i?0:e.arrowWidth,a=i?0:e.arrowHeight,[u,l]=qs(n),f={start:"0%",center:"50%",end:"100%"}[l],c=(o.arrow?.x??0)+s/2,d=(o.arrow?.y??0)+a/2;let h="",g="";return u==="bottom"?(h=i?f:`${c}px`,g=-a+"px"):u==="top"?(h=i?f:`${c}px`,g=`${r.floating.height+a}px`):u==="right"?(h=-a+"px",g=i?f:`${d}px`):u==="left"&&(h=`${r.floating.width+a}px`,g=i?f:`${d}px`),{data:{x:h,y:g}}}})),"transformOrigin");function qs(e){const[t,n="center"]=e.split("-");return[t,n]}dr(qs,"getSideAndAlignFromPlacement");var Uc=Nb,Hc=Lb,Vc=Hb,$b=Object.defineProperty,Iu=(e,t)=>$b(e,"name",{value:t,configurable:!0}),Fa=!1;function Gm(){const[e,t]=m.useState(Fa);return m.useEffect((()=>{Fa||(Fa=!0,t(!0))}),[]),e}Iu(Gm,"useIsHydrated");var Jm=Fo[" useSyncExternalStore ".trim().toString()];function Zm(){return()=>{}}function Xm(){return Jm(Zm,(()=>!0),(()=>!1))}Iu(Zm,"subscribe"),Iu(Xm,"useIsHydratedModern");var Wb=typeof Jm=="function"?Xm:Gm,zb=Object.defineProperty,Fr=(e,t)=>zb(e,"name",{value:t,configurable:!0}),Ra="rovingFocusGroup.onEntryFocus",Kb={bubbles:!1,cancelable:!0},Gs="RovingFocusGroup",[Tu,Ym,qb]=xc(Gs),[Gb,Qm]=qn(Gs,[qb]),[Jb,Zb]=Gb(Gs),Xb=m.forwardRef(Fr((function(e,t){return v.jsx(Tu.Provider,{scope:e.__scopeRovingFocusGroup,children:v.jsx(Tu.Slot,{scope:e.__scopeRovingFocusGroup,children:v.jsx(Yb,{...e,ref:t})})})}),"RovingFocusGroup")),Yb=m.forwardRef(Fr((function(e,t){const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:l,preventScrollOnEntryFocus:f=!1,...c}=e,d=m.useRef(null),h=Qe(t,d),g=Sc(i),[y,p]=Po({prop:s,defaultProp:a??null,onChange:u,caller:Gs}),[w,b]=m.useState(!1),C=$n(l),E=Ym(n),A=m.useRef(!1),[x,I]=m.useState(0);return m.useEffect((()=>{const T=d.current;if(T)return T.addEventListener(Ra,C),()=>T.removeEventListener(Ra,C)}),[C]),v.jsx(Jb,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:m.useCallback((T=>p(T)),[p]),onItemShiftTab:m.useCallback((()=>b(!0)),[]),onFocusableItemAdd:m.useCallback((()=>I((T=>T+1))),[]),onFocusableItemRemove:m.useCallback((()=>I((T=>T-1))),[]),children:v.jsx($t.div,{tabIndex:w||x===0?-1:0,"data-orientation":r,...c,ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,(()=>{A.current=!0})),onFocus:Me(e.onFocus,(T=>{const F=!A.current;if(T.target===T.currentTarget&&F&&!w){const S=new CustomEvent(Ra,Kb);if(T.currentTarget.dispatchEvent(S),!S.defaultPrevented){const k=E().filter((_=>_.focusable));$c([k.find((_=>_.active)),k.find((_=>_.id===y)),...k].filter(Boolean).map((_=>_.ref.current)),f)}}A.current=!1})),onBlur:Me(e.onBlur,(()=>b(!1)))})})}),"RovingFocusGroupImpl")),Qb=m.forwardRef(Fr((function(e,t){const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,u=Eo(),l=i||u,f=Zb("RovingFocusGroupItem",n),c=f.currentTabStopId===l,d=Ym(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:y}=f,p=Wb();return Yt((()=>{if(p&&r)return h(),()=>g()}),[p,r,h,g]),m.useEffect((()=>{if(!p&&r)return h(),()=>g()}),[p,r,h,g]),v.jsx(Tu.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:v.jsx($t.span,{tabIndex:c?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,(w=>{r?f.onItemFocus(l):w.preventDefault()})),onFocus:Me(e.onFocus,(()=>f.onItemFocus(l))),onKeyDown:Me(e.onKeyDown,(w=>{if(w.key==="Tab"&&w.shiftKey)return void f.onItemShiftTab();if(w.target!==w.currentTarget)return;const b=tg(w,f.orientation,f.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=d().filter((E=>E.focusable)).map((E=>E.ref.current));if(b==="last")C.reverse();else if(b==="prev"||b==="next"){b==="prev"&&C.reverse();const E=C.indexOf(w.currentTarget);C=f.loop?ng(C,E+1):C.slice(E+1)}setTimeout((()=>$c(C)))}})),children:typeof s=="function"?s({isCurrentTabStop:c,hasTabStop:y!=null}):s})})}),"RovingFocusGroupItem")),eC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eg(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tg(e,t,n){const r=eg(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r)||t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return eC[r]}function $c(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ng(e,t){return e.map(((n,r)=>e[(t+r)%e.length]))}Fr(eg,"getDirectionAwareKey"),Fr(tg,"getFocusIntent"),Fr($c,"focusFirst"),Fr(ng,"wrapArray");var tC=Xb,nC=Qb,rC=Object.defineProperty,Ke=(e,t)=>rC(e,"name",{value:t,configurable:!0}),oC=["Enter"," "],rg=["ArrowUp","PageDown","End"],iC=["ArrowDown","PageUp","Home",...rg],Js="Menu",[ku,sC,aC]=xc(Js),[$r,og]=qn(Js,[aC,Lo,Qm]),Wc=Lo(),ig=Qm(),[uC,Ti]=$r(Js),[cC,zc]=$r(Js),lC=Ke((e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:s=!0}=e,a=Wc(t),[u,l]=m.useState(null),f=m.useRef(!1),c=$n(i),d=Sc(o);return m.useEffect((()=>{const h=Ke((()=>{f.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})}),"handleKeyDown"),g=Ke((()=>f.current=!1),"handlePointer");return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}}),[]),m.useEffect((()=>{if(!n)return;const h=Ke((()=>c(!1)),"handleBlur");return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)}),[n,c]),v.jsx(Uc,{...a,children:v.jsx(uC,{scope:t,open:n,onOpenChange:c,content:u,onContentChange:l,children:v.jsx(cC,{scope:t,onClose:m.useCallback((()=>c(!1)),[c]),isUsingKeyboardRef:f,dir:d,modal:s,children:r})})})}),"Menu"),dC=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,...r}=e,o=Wc(n);return v.jsx(Hc,{...o,...r,ref:t})}),"MenuAnchor")),sg="MenuPortal",[fC,hC]=$r(sg,{forceMount:void 0}),pC=Ke((e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=Ti(sg,t);return v.jsx(fC,{scope:t,forceMount:n,children:v.jsx(No,{present:n||i.open,children:v.jsx(Bc,{asChild:!0,container:o,children:r})})})}),"MenuPortal"),fr="MenuContent",[mC,ag]=$r(fr),gC=m.forwardRef(Ke((function(e,t){const n=hC(fr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Ti(fr,e.__scopeMenu),s=zc(fr,e.__scopeMenu);return v.jsx(ku.Provider,{scope:e.__scopeMenu,children:v.jsx(No,{present:r||i.open,children:v.jsx(ku.Slot,{scope:e.__scopeMenu,children:s.modal?v.jsx(vC,{...o,ref:t}):v.jsx(yC,{...o,ref:t})})})})}),"MenuContent")),vC=m.forwardRef(Ke((function(e,t){const n=Ti(fr,e.__scopeMenu),r=m.useRef(null),o=Qe(t,r);return m.useEffect((()=>{const i=r.current;if(i)return Om(i)}),[]),v.jsx(ug,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Me(e.onFocusOutside,(i=>i.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),"MenuRootContentModal")),yC=m.forwardRef(Ke((function(e,t){const n=Ti(fr,e.__scopeMenu);return v.jsx(ug,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),"MenuRootContentNonModal")),bC=Vn("MenuContent.ScrollLock"),ug=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:f,onFocusOutside:c,onInteractOutside:d,onDismiss:h,disableOutsideScroll:g,...y}=e,p=Ti(fr,n),w=zc(fr,n),b=Wc(n),C=ig(n),E=sC(n),[A,x]=m.useState(null),I=m.useRef(null),T=Qe(t,I,p.onContentChange),F=m.useRef(0),S=m.useRef(""),k=m.useRef(0),_=m.useRef(null),M=m.useRef("right"),H=m.useRef(0),W=g?Fc:m.Fragment,G=g?{as:bC,allowPinchZoom:!0}:void 0,q=Ke((V=>{const Q=S.current+V,ae=E().filter((B=>!B.disabled)),ie=document.activeElement,Se=ae.find((B=>B.ref.current===ie))?.textValue,Ie=fg(ae.map((B=>B.textValue)),Q,Se),ne=ae.find((B=>B.textValue===Ie))?.ref.current;Ke((function B(X){S.current=X,window.clearTimeout(F.current),X!==""&&(F.current=window.setTimeout((()=>B("")),1e3))}),"updateSearch")(Q),ne&&setTimeout((()=>ne.focus()))}),"handleTypeaheadSearch");m.useEffect((()=>()=>window.clearTimeout(F.current)),[]),Ss();const $=m.useCallback((V=>M.current===_.current?.side&&pg(V,_.current?.area)),[]);return v.jsx(mC,{scope:n,searchRef:S,onItemEnter:m.useCallback((V=>{$(V)&&V.preventDefault()}),[$]),onItemLeave:m.useCallback((V=>{$(V)||(I.current?.focus(),x(null))}),[$]),onTriggerLeave:m.useCallback((V=>{$(V)&&V.preventDefault()}),[$]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback((V=>{_.current=V}),[]),children:v.jsx(W,{...G,children:v.jsx(fm,{asChild:!0,trapped:o,onMountAutoFocus:Me(i,(V=>{V.preventDefault(),I.current?.focus({preventScroll:!0})})),onUnmountAutoFocus:s,children:v.jsx(Ic,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:f,onFocusOutside:c,onInteractOutside:d,onDismiss:h,children:v.jsx(tC,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:x,onEntryFocus:Me(u,(V=>{w.isUsingKeyboardRef.current||V.preventDefault()})),preventScrollOnEntryFocus:!0,children:v.jsx(Vc,{role:"menu","aria-orientation":"vertical","data-state":cg(p.open),"data-radix-menu-content":"",dir:w.dir,...b,...y,ref:T,style:{outline:"none",...y.style},onKeyDown:Me(y.onKeyDown,(V=>{const Q=V.target.closest("[data-radix-menu-content]")===V.currentTarget,ae=V.ctrlKey||V.altKey||V.metaKey,ie=V.key.length===1;Q&&(V.key==="Tab"&&V.preventDefault(),!ae&&ie&&q(V.key));const Se=I.current;if(V.target!==Se||!iC.includes(V.key))return;V.preventDefault();const Ie=E().filter((ne=>!ne.disabled)).map((ne=>ne.ref.current));rg.includes(V.key)&&Ie.reverse(),lg(Ie)})),onBlur:Me(e.onBlur,(V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(F.current),S.current="")})),onPointerMove:Me(e.onPointerMove,Fs((V=>{const Q=V.target,ae=H.current!==V.clientX;if(V.currentTarget.contains(Q)&&ae){const ie=V.clientX>H.current?"right":"left";M.current=ie,H.current=V.clientX}})))})})})})})})}),"MenuContentImpl")),Bu="MenuItem",Gd="menu.itemSelect",CC=m.forwardRef(Ke((function(e,t){const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),s=zc(Bu,e.__scopeMenu),a=ag(Bu,e.__scopeMenu),u=Qe(t,i),l=m.useRef(!1),f=Ke((()=>{const c=i.current;if(!n&&c){const d=new CustomEvent(Gd,{bubbles:!0,cancelable:!0});c.addEventListener(Gd,(h=>r?.(h)),{once:!0}),Ac(c,d),d.defaultPrevented?l.current=!1:s.onClose()}}),"handleSelect");return v.jsx(wC,{...o,ref:u,disabled:n,onClick:Me(e.onClick,f),onPointerDown:c=>{e.onPointerDown?.(c),l.current=!0},onPointerUp:Me(e.onPointerUp,(c=>{l.current||c.currentTarget?.click()})),onKeyDown:Me(e.onKeyDown,(c=>{n||c.target!==c.currentTarget||a.searchRef.current!==""&&c.key===" "||oC.includes(c.key)&&(c.currentTarget.click(),c.preventDefault())}))})}),"MenuItem")),wC=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,s=ag(Bu,n),a=ig(n),u=m.useRef(null),l=Qe(t,u),[f,c]=m.useState(!1),[d,h]=m.useState("");return m.useEffect((()=>{const g=u.current;g&&h((g.textContent??"").trim())}),[i.children]),v.jsx(ku.ItemSlot,{scope:n,disabled:r,textValue:o??d,children:v.jsx(nC,{asChild:!0,...a,focusable:!r,children:v.jsx($t.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:l,onPointerMove:Me(e.onPointerMove,Fs((g=>{r?s.onItemLeave(g):(s.onItemEnter(g),!g.defaultPrevented&&g.currentTarget.focus({preventScroll:!0}))}))),onPointerLeave:Me(e.onPointerLeave,Fs((g=>s.onItemLeave(g)))),onFocus:Me(e.onFocus,(()=>c(!0))),onBlur:Me(e.onBlur,(()=>c(!1)))})})})}),"MenuItemImpl")),[_x,jx]=$r("MenuRadioGroup",{value:void 0,onValueChange:Ke((()=>{}),"onValueChange")}),[Mx,Px]=$r("MenuItemIndicator",{checked:!1}),[Nx,Lx]=$r("MenuSub");function cg(e){return e?"open":"closed"}function Jd(e){return e==="indeterminate"}function lg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function dg(e,t){return e.map(((n,r)=>e[(t+r)%e.length]))}function fg(e,t,n){const r=t.length>1&&Array.from(t).every((a=>a===t[0]))?t[0]:t,o=n?e.indexOf(n):-1;let i=dg(e,Math.max(o,0));r.length===1&&(i=i.filter((a=>a!==n)));const s=i.find((a=>a.toLowerCase().startsWith(r.toLowerCase())));return s!==n?s:void 0}function hg(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i],u=t[s],l=a.x,f=a.y,c=u.x,d=u.y;f>r!=d>r&&n<(c-l)*(r-f)/(d-f)+l&&(o=!o)}return o}function pg(e,t){return t?hg({x:e.clientX,y:e.clientY},t):!1}function Fs(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ke(cg,"getOpenState"),Ke(Jd,"isIndeterminate"),Ke((function(e){return Jd(e)?"indeterminate":e?"checked":"unchecked"}),"getCheckedState"),Ke(lg,"focusFirst"),Ke(dg,"wrapArray"),Ke(fg,"getNextMatch"),Ke(hg,"isPointInPolygon"),Ke(pg,"isPointerInGraceArea"),Ke(Fs,"whenMouse");var EC=lC,DC=dC,AC=pC,xC=gC,OC=CC,SC=Object.defineProperty,ki=(e,t)=>SC(e,"name",{value:t,configurable:!0}),Kc="DropdownMenu",[IC,Ux]=qn(Kc,[og]),Bi=og(),[TC,mg]=IC(Kc),kC=ki((e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:s,modal:a=!0}=e,u=Bi(t),l=m.useRef(null),[f,c]=Po({prop:o,defaultProp:i??!1,onChange:s,caller:Kc});return v.jsx(TC,{scope:t,triggerId:Eo(),triggerRef:l,contentId:Eo(),open:f,onOpenChange:c,onOpenToggle:m.useCallback((()=>c((d=>!d))),[c]),modal:a,children:v.jsx(EC,{...u,open:f,onOpenChange:c,dir:r,modal:a,children:n})})}),"DropdownMenu"),BC=m.forwardRef(ki((function(e,t){const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=mg("DropdownMenuTrigger",n),s=Bi(n),a=Qe(t,i.triggerRef);return v.jsx(DC,{asChild:!0,...s,children:v.jsx($t.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:a,onPointerDown:Me(e.onPointerDown,(u=>{r||u.button!==0||u.ctrlKey!==!1||(i.onOpenToggle(),i.open||u.preventDefault())})),onKeyDown:Me(e.onKeyDown,(u=>{r||(["Enter"," "].includes(u.key)&&i.onOpenToggle(),u.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())}))})})}),"DropdownMenuTrigger")),FC=ki((e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bi(t);return v.jsx(AC,{...r,...n})}),"DropdownMenuPortal"),RC=m.forwardRef(ki((function(e,t){const{__scopeDropdownMenu:n,...r}=e,o=mg("DropdownMenuContent",n),i=Bi(n),s=m.useRef(!1);return v.jsx(xC,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:Me(e.onCloseAutoFocus,(a=>{s.current||o.triggerRef.current?.focus(),s.current=!1,a.preventDefault()})),onInteractOutside:Me(e.onInteractOutside,(a=>{const u=a.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,f=u.button===2||l;o.modal&&!f||(s.current=!0)})),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}),"DropdownMenuContent")),_C=m.forwardRef(ki((function(e,t){const{__scopeDropdownMenu:n,...r}=e,o=Bi(n);return v.jsx(OC,{...o,...r,ref:t})}),"DropdownMenuItem")),jC=kC,MC=BC,PC=FC,NC=RC,LC=Object.defineProperty,vr=(e,t)=>LC(e,"name",{value:t,configurable:!0}),qc="Popover",[gg,Hx]=qn(qc,[Lo]),Gc=Lo(),[UC,Uo]=gg(qc),HC=vr((e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Gc(t),u=m.useRef(null),[l,f]=m.useState(!1),[c,d]=Po({prop:r,defaultProp:o??!1,onChange:i,caller:qc});return v.jsx(Uc,{...a,children:v.jsx(UC,{scope:t,contentId:Eo(),triggerRef:u,open:c,onOpenChange:d,onOpenToggle:m.useCallback((()=>d((h=>!h))),[d]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback((()=>f(!0)),[]),onCustomAnchorRemove:m.useCallback((()=>f(!1)),[]),modal:s,children:n})})}),"Popover"),VC=m.forwardRef(vr((function(e,t){const{__scopePopover:n,...r}=e,o=Uo("PopoverTrigger",n),i=Gc(n),s=Qe(t,o.triggerRef),a=v.jsx($t.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":Jc(o.open),...r,ref:s,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:v.jsx(Hc,{asChild:!0,...i,children:a})}),"PopoverTrigger")),vg="PopoverPortal",[$C,WC]=gg(vg,{forceMount:void 0}),zC=vr((e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Uo(vg,t);return v.jsx($C,{scope:t,forceMount:n,children:v.jsx(No,{present:n||i.open,children:v.jsx(Bc,{asChild:!0,container:o,children:r})})})}),"PopoverPortal"),bi="PopoverContent",KC=m.forwardRef(vr((function(e,t){const n=WC(bi,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Uo(bi,e.__scopePopover);return v.jsx(No,{present:r||i.open,children:i.modal?v.jsx(GC,{...o,ref:t}):v.jsx(JC,{...o,ref:t})})}),"PopoverContent")),qC=Vn("PopoverContent.RemoveScroll"),GC=m.forwardRef(vr((function(e,t){const n=Uo(bi,e.__scopePopover),r=m.useRef(null),o=Qe(t,r),i=m.useRef(!1);return m.useEffect((()=>{const s=r.current;if(s)return Om(s)}),[]),v.jsx(Fc,{as:qC,allowPinchZoom:!0,children:v.jsx(yg,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,(s=>{s.preventDefault(),i.current||n.triggerRef.current?.focus()})),onPointerDownOutside:Me(e.onPointerDownOutside,(s=>{const a=s.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0,l=a.button===2||u;i.current=l}),{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,(s=>s.preventDefault()),{checkForDefaultPrevented:!1})})})}),"PopoverContentModal")),JC=m.forwardRef(vr((function(e,t){const n=Uo(bi,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return v.jsx(yg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),"PopoverContentNonModal")),yg=m.forwardRef(vr((function(e,t){const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:l,onInteractOutside:f,...c}=e,d=Uo(bi,n),h=Gc(n);return Ss(),v.jsx(fm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:v.jsx(Ic,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:l,onDismiss:()=>d.onOpenChange(!1),deferPointerDownOutside:!0,children:v.jsx(Vc,{"data-state":Jc(d.open),role:"dialog",id:d.contentId,...h,...c,ref:t,style:{...c.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),"PopoverContentImpl"));function Jc(e){return e?"open":"closed"}vr(Jc,"getState");var ZC=HC,XC=VC,YC=zC,QC=KC,ew=Object.defineProperty,tw=(e,t)=>ew(e,"name",{value:t,configurable:!0}),Zc=m.forwardRef(tw((function(e,t){const{pressed:n,defaultPressed:r,onPressedChange:o,...i}=e,[s,a]=Po({prop:n,onChange:o,defaultProp:r??!1,caller:"Toggle"});return v.jsx($t.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:Me(e.onClick,(()=>{e.disabled||a(!s)}))})}),"Toggle")),nw=Object.defineProperty,pt=(e,t)=>nw(e,"name",{value:t,configurable:!0}),[Xc,Vx]=qn("Tooltip",[Lo]),Yc=Lo(),rw=700,Fu="tooltip.open",[ow,Qc]=Xc("TooltipProvider"),iw=pt((e=>{const{__scopeTooltip:t,delayDuration:n=rw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,s=m.useRef(!0),a=m.useRef(!1),u=m.useRef(0);return m.useEffect((()=>{const l=u.current;return()=>window.clearTimeout(l)}),[]),v.jsx(ow,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:m.useCallback((()=>{r<=0||(window.clearTimeout(u.current),s.current=!1)}),[r]),onClose:m.useCallback((()=>{r<=0||(window.clearTimeout(u.current),u.current=window.setTimeout((()=>s.current=!0),r))}),[r]),isPointerInTransitRef:a,onPointerInTransitChange:m.useCallback((l=>{a.current=l}),[]),disableHoverableContent:o,children:i})}),"TooltipProvider"),Ru="Tooltip",[sw,Fi]=Xc(Ru),aw=pt((e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:a}=e,u=Qc(Ru,e.__scopeTooltip),l=Yc(t),[f,c]=m.useState(null),[d,h]=m.useState(void 0),g=Eo(),y=m.useRef(0),p=s??u.disableHoverableContent,w=a??u.delayDuration,b=m.useRef(!1),[C,E]=Po({prop:r,defaultProp:o??!1,onChange:pt((S=>{S?(u.onOpen(),document.dispatchEvent(new CustomEvent(Fu))):u.onClose(),i?.(S)}),"onChange"),caller:Ru}),A=m.useMemo((()=>C?b.current?"delayed-open":"instant-open":"closed"),[C]),x=m.useCallback((()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,E(!0)}),[E]),I=m.useCallback((()=>{window.clearTimeout(y.current),y.current=0,E(!1)}),[E]),T=m.useCallback((()=>{window.clearTimeout(y.current),y.current=window.setTimeout((()=>{b.current=!0,E(!0),y.current=0}),w)}),[w,E]);m.useEffect((()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)}),[]);const F=d??g;return v.jsx(Uc,{...l,children:v.jsx(sw,{scope:t,contentId:F,setContentId:h,open:C,stateAttribute:A,trigger:f,onTriggerChange:c,onTriggerEnter:m.useCallback((()=>{u.isOpenDelayedRef.current?T():x()}),[u.isOpenDelayedRef,T,x]),onTriggerLeave:m.useCallback((()=>{p?I():(window.clearTimeout(y.current),y.current=0)}),[I,p]),onOpen:x,onClose:I,disableHoverableContent:p,children:n})})}),"Tooltip"),Zd="TooltipTrigger",uw=m.forwardRef(pt((function(e,t){const{__scopeTooltip:n,...r}=e,o=Fi(Zd,n),i=Qc(Zd,n),s=Yc(n),a=Qe(t,m.useRef(null),o.onTriggerChange),u=m.useRef(!1),l=m.useRef(!1),f=m.useCallback((()=>u.current=!1),[]);return m.useEffect((()=>()=>document.removeEventListener("pointerup",f)),[f]),v.jsx(Hc,{asChild:!0,...s,children:v.jsx($t.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:a,onPointerMove:Me(e.onPointerMove,(c=>{c.pointerType!=="touch"&&(l.current||i.isPointerInTransitRef.current||(o.onTriggerEnter(),l.current=!0))})),onPointerLeave:Me(e.onPointerLeave,(()=>{o.onTriggerLeave(),l.current=!1})),onPointerDown:Me(e.onPointerDown,(()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})})),onFocus:Me(e.onFocus,(()=>{u.current||o.onOpen()})),onBlur:Me(e.onBlur,o.onClose),onClick:Me(e.onClick,o.onClose)})})}),"TooltipTrigger")),bg="TooltipPortal",[cw,lw]=Xc(bg,{forceMount:void 0}),dw=pt((e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Fi(bg,t);return v.jsx(cw,{scope:t,forceMount:n,children:v.jsx(No,{present:n||i.open,children:v.jsx(Bc,{asChild:!0,container:o,children:r})})})}),"TooltipPortal"),Ci="TooltipContent",fw=m.forwardRef(pt((function(e,t){const n=lw(Ci,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=Fi(Ci,e.__scopeTooltip);return v.jsx(No,{present:r||s.open,children:s.disableHoverableContent?v.jsx(Cg,{side:o,...i,ref:t}):v.jsx(hw,{side:o,...i,ref:t})})}),"TooltipContent")),hw=m.forwardRef(pt((function(e,t){const n=Fi(Ci,e.__scopeTooltip),r=Qc(Ci,e.__scopeTooltip),o=m.useRef(null),i=Qe(t,o),[s,a]=m.useState(null),{trigger:u,onClose:l}=n,f=o.current,{onPointerInTransitChange:c}=r,d=m.useCallback((()=>{a(null),c(!1)}),[c]),h=m.useCallback(((g,y)=>{const p=g.currentTarget,w={x:g.clientX,y:g.clientY},b=xg([...Eg(w,wg(w,p.getBoundingClientRect())),...Dg(y.getBoundingClientRect())]);a(b),c(!0)}),[c]);return m.useEffect((()=>()=>d()),[d]),m.useEffect((()=>{if(u&&f){const g=pt((p=>h(p,f)),"handleTriggerLeave"),y=pt((p=>h(p,u)),"handleContentLeave");return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",y)}}}),[u,f,h,d]),m.useEffect((()=>{if(s){const g=pt((y=>{const p=y.target,w={x:y.clientX,y:y.clientY},b=u?.contains(p)||f?.contains(p),C=!Ag(w,s);b?d():C&&(d(),l())}),"handleTrackPointerGrace");return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}}),[u,f,s,l,d]),v.jsx(Cg,{...e,ref:i})}),"TooltipContentHoverable")),pw=Dc("TooltipContent"),Cg=m.forwardRef(pt((function(e,t){const{__scopeTooltip:n,children:r,"aria-label":o,id:i,onEscapeKeyDown:s,onPointerDownOutside:a,...u}=e,l=Fi(Ci,n),f=Yc(n),{onClose:c}=l;m.useEffect((()=>(document.addEventListener(Fu,c),()=>document.removeEventListener(Fu,c))),[c]),m.useEffect((()=>{if(l.trigger){const h=pt((g=>{g.target instanceof Node&&g.target.contains(l.trigger)&&c()}),"handleScroll");return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}}),[l.trigger,c]);const{setContentId:d}=l;return Yt((()=>(d(i),()=>{d(void 0)})),[i,d]),v.jsx(Ic,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:c,children:v.jsxs(Vc,{"data-state":l.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:l.contentId,...f,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[v.jsx(pw,{children:r}),o?v.jsx(My,{id:l.contentId,role:"tooltip",children:o}):null]})})}),"TooltipContentImpl"));function wg(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Eg(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}function Dg(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function Ag(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i],u=t[s],l=a.x,f=a.y,c=u.x,d=u.y;f>r!=d>r&&n<(c-l)*(r-f)/(d-f)+l&&(o=!o)}return o}function xg(e){const t=e.slice();return t.sort(((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0)),Og(t)}function Og(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if(!((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x)))break;t.pop()}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if(!((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x)))break;n.pop()}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}pt(wg,"getExitSideFromRect"),pt(Eg,"getPaddedExitPoints"),pt(Dg,"getPointsFromRect"),pt(Ag,"isPointInPolygon"),pt(xg,"getHull"),pt(Og,"getHullPresorted");var mw=iw,gw=aw,vw=uw,yw=dw,bw=fw;function Zs(e){const t=new Map;return(...n)=>{const r=JSON.stringify(n.map((s=>Xt(s)))),o=t.get(r);if(o!==void 0)return o;const i=e(...n);return t.set(r,i),i}}const Sg=Zs(((...e)=>new Intl.DateTimeFormat(...e))),Xd=Zs(((...e)=>new Intl.RelativeTimeFormat(...e))),Cw=Zs(((...e)=>new Intl.ListFormat(...e))),Mr=Zs(((...e)=>new Intl.NumberFormat(...e)));function Ig(e,t){const n=m.useRef(e);m.useEffect((()=>{n.current=e}),[e]),m.useEffect((()=>{if(!t&&t!==0)return;const r=setInterval((()=>{n.current()===!1&&clearInterval(r)}),t);return()=>clearInterval(r)}),[t])}function Tg(){const[e,t]=m.useReducer((n=>n+1),0);return[t,e]}function el(e){let t=Math.max(e,0);const n=t%1e3;t=Math.floor(t/1e3);const r=t%60;t=Math.floor(t/60);const o=t%60;t=Math.floor(t/60);const i=t%24;t=Math.floor(t/24);const s=t%7;return{weeks:Math.floor(t/7),days:s,hours:i,minutes:o,seconds:r,milliseconds:n}}const kg={weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second",milliseconds:"millisecond"};function ww(e,t){let n;t?n=t:n=Mr().resolvedOptions().locale;const r=el(e),o=[];for(const[i,s]of Object.entries(r)){if(s===0||i==="milliseconds")continue;const a=Mr(n,{style:"unit",unit:kg[i],unitDisplay:"narrow"});o.push(a.format(s))}return o.length||o.push(Mr(n,{style:"unit",unit:"second",unitDisplay:"narrow"}).format(0)),o.join(" ")}function Ew(e,t){let n;t?n=t:n=Mr().resolvedOptions().locale;const r=el(e),o=[];for(const[i,s]of Object.entries(r)){if(s===0||i==="milliseconds")continue;const a=Mr(n,{style:"unit",unit:kg[i],unitDisplay:"long"});o.push(a.format(s))}return o.length||o.push(Mr(n,{style:"unit",unit:"second",unitDisplay:"long"}).format(0)),o.join(" ")}function Yd(e){return e instanceof Date?e.getTime():new Date(e).getTime()}function Bg(e,t){return Yd(t)-Yd(e)}const _a=m.forwardRef((({duration:e,from:t,to:n,locale:r,dateTime:o,title:i=Ew,children:s=ww,interval:a=500,asChild:u,...l},f)=>{const c=u?vt:"time",[d,h]=Tg(),g=m.useMemo((()=>e!==void 0?e:t!==void 0?Bg(t,n??Date.now()):0),[e,t,n,h]),y=m.useMemo((()=>(function(b){const C=Math.max(b,0);if(C===0)return"PT0S";const{weeks:E,days:A,hours:x,minutes:I,seconds:T,milliseconds:F}=el(C);let S="P";return E>0&&(S+=`${E}W`),A>0&&(S+=`${A}D`),(x>0||I>0||T>0||F>0)&&(S+="T",x>0&&(S+=`${x}H`),I>0&&(S+=`${I}M`),(T>0||F>0)&&(S+=F>0?`${T}.${F.toString().padStart(3,"0").replace(/0+$/,"")}S`:`${T}S`)),S})(g)),[g]),p=m.useMemo((()=>typeof i=="function"?i(g,r):i),[i,g,r]),w=m.useMemo((()=>typeof s=="function"?s(g,r):s),[s,g,r]);return Ig(d,t!==void 0&&n===void 0&&a),v.jsx(c,{...l,ref:f,dateTime:o??y,title:p,children:w})}));function es(e,t,n){return e===1?t:n??`${t}s`}function ja(e,t){return Bg(e,t??Date.now())>=3e3}const Dw={locale:"en",dir:"ltr",USER_SELF:"you",USER_UNKNOWN:"Anonymous",COPY_TO_CLIPBOARD:"Copy",LIST_REMAINING:e=>`${e} more`,LIST_REMAINING_USERS:e=>`${e} ${es(e,"other")}`,LIST_REMAINING_COMMENTS:e=>`${e} more ${es(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 Ye(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(Ec,{emoji:t})]}),COMMENT_REACTION_DESCRIPTION:(e,t)=>`${t} ${es(t,"reaction")}, react with ${e}`,THREAD_RESOLVE:"Resolve thread",THREAD_UNRESOLVE:"Re-open thread",THREAD_SUBSCRIBE:"Subscribe to thread",THREAD_UNSUBSCRIBE:"Unsubscribe from thread",THREAD_NEW_INDICATOR:"New",THREAD_NEW_INDICATOR_DESCRIPTION:"New comments",THREAD_SHOW_MORE_COMMENTS:e=>`Show ${e} more ${es(e,"reply","replies")}`,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_SUMMARY_AUTHORS_LIST:e=>e===void 0?"Unattributed":e,HISTORY_VERSION_PREVIEW_AUTHORS_LIST:e=>e===void 0?"Unattributed edits":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.",AI_COMPOSER_PLACEHOLDER:"Ask anything…",AI_COMPOSER_SEND:"Send",AI_COMPOSER_ABORT:"Abort response",AI_CHAT_MESSAGE_DELETED:"This message has been deleted.",AI_CHAT_MESSAGE_THINKING:"Thinking…",AI_CHAT_MESSAGE_REASONING:(e,t)=>e?v.jsx(v.Fragment,{children:"Reasoning…"}):v.jsxs(v.Fragment,{children:["Reasoned",ja(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(_a,{className:"lb-duration lb-ai-chat-message-reasoning-duration",from:t.startedAt,to:t.endedAt})]}):null]}),AI_CHAT_MESSAGE_RETRIEVAL:(e,t)=>t.kind==="knowledge"?e?v.jsxs(v.Fragment,{children:["Searching"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),"…"]}):v.jsxs(v.Fragment,{children:["Searched"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),ja(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(_a,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):t.kind==="web"?e?v.jsxs(v.Fragment,{children:["Searching the web",t.query?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,"…"]}):v.jsxs(v.Fragment,{children:["Searched the web",t.query?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,ja(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(_a,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):Ye(0,"Unexpected retrieval kind"),AI_CHAT_MESSAGES_ERROR:()=>"There was an error while getting the messages.",AI_TOOL_CONFIRMATION_CONFIRM:"Confirm",AI_TOOL_CONFIRMATION_CANCEL:"Cancel"},Aw=m.createContext(void 0);function Mt(e){const t=m.useContext(Aw);return m.useMemo((()=>({...Dw,...t,...e})),[t,e])}function Qd(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Fg={Anchor:"a"},_u=m.createContext(void 0);function xw({children:e,components:t}){const n=m.useContext(_u),r=m.useMemo((()=>({...Fg,...n,...t})),[n,t]);return v.jsx(_u.Provider,{value:r,children:e})}const Ow=m.createContext({});function Ri(){return m.useContext(Ow)}const Sw=/Mac|iPod|iPhone|iPad/;function Rg(){return typeof window<"u"&&Sw.test(window.navigator.platform)}const Iw={title:"Alt",key:"⌥"},Ma={title:"Command",key:"⌘"},Pa={title:"Ctrl",key:"⌃"},Tw={title:"Shift",key:"⇧"},kw={title:"Enter",key:"⏎"},ef={title:"Space",key:"␣"},tf={title:"Escape",key:"⎋"},_g={alt:()=>Iw,mod:()=>Rg()?Ma:Pa,control:()=>Pa,ctrl:()=>Pa,command:()=>Ma,cmd:()=>Ma,shift:()=>Tw,enter:()=>kw," ":()=>ef,space:()=>ef,escape:()=>tf,esc:()=>tf},jt=m.forwardRef((({children:e,content:t,multiline:n,className:r,...o},i)=>{const{portalContainer:s}=Ri();return v.jsxs(gw,{disableHoverableContent:!0,children:[v.jsx(vw,{asChild:!0,ref:i,children:e}),v.jsx(yw,{container:s,children:v.jsx(bw,{className:Ne("lb-root lb-portal lb-tooltip",n&&"lb-tooltip:multiline",r),side:"top",align:"center",updatePositionStrategy:"always",sideOffset:6,collisionPadding:10,...o,children:t})})]})})),tl=m.forwardRef((({children:e,content:t,shortcut:n,...r},o)=>{const i=m.useMemo((()=>n?(function(s){const a=s.split("-");return v.jsx(v.Fragment,{children:a.map(((u,l)=>{const f=u.toLowerCase();return f in _g?v.jsx(Bw,{name:f},l):v.jsx("span",{children:u},l)}))})})(n):null),[n]);return v.jsx(jt,{content:v.jsxs(v.Fragment,{children:[t,i&&v.jsx("kbd",{className:"lb-tooltip-shortcut",children:i})]}),...r,ref:o,children:e})}));function Bw({name:e,...t}){const{title:n,key:r}=m.useMemo((()=>_g[e]?.()),[e]);return v.jsx("abbr",{title:n,...t,children:r})}const Xs=mw;function Ys({src:e,name:t,className:n,children:r,tooltip:o,outline:i,style:s,...a}){const u=m.useMemo((()=>t?(function(c){return c.trim().split(" ").reduce(((d,h,g,y)=>(g!==0&&g!==y.length-1||(d+=h.charAt(0).toLocaleUpperCase()),d)),"")})(t):void 0),[t]),l=typeof i=="object"?i:typeof i=="string"?{color:i}:i===!0?{}:void 0,f=v.jsx("div",{className:Ne("lb-avatar",n),"data-variant":l?"outline":"default",style:{"--lb-avatar-outline-color":l?.color,"--lb-avatar-outline-width":Qd(l?.width),"--lb-avatar-outline-gap":Qd(l?.gap),...s},...a,children:v.jsx("div",{className:"lb-avatar-content",children:r??(e?v.jsx("img",{className:"lb-avatar-image",src:e,alt:t}):u?v.jsx("span",{className:"lb-avatar-fallback","aria-label":t,title:t,children:u}):null)})});return o?v.jsx(Xs,{children:v.jsx(jt,{content:o,sideOffset:6,collisionPadding:10,side:"top",align:"center",children:f})}):f}function Fw({userId:e,icon:t,variant:n="default",tooltip:r,...o}){const{user:i,isLoading:s}=Lp(e);return v.jsx(Ys,{src:i?.avatar,name:s?void 0:i?.name??e,outline:n==="outline"&&typeof i?.color=="string"?i.color:void 0,"data-loading":s?"":void 0,tooltip:r,...o,children:!t||!s&&i?.avatar?null:t})}function Rw({groupId:e,icon:t,variant:n="default",tooltip:r,...o}){const{info:i,isLoading:s}=bc(e);return v.jsx(Ys,{src:i?.avatar,name:s?void 0:i?.name??e,outline:n==="outline"&&typeof i?.color=="string"?i.color:void 0,"data-loading":s?"":void 0,tooltip:r,...o,children:!t||!s&&i?.avatar?null:t})}function ju({userId:e,icon:t,variant:n="default",...r}){const o=Mt();return e?v.jsx(Fw,{userId:e,icon:t,variant:n,...r}):v.jsx(Ys,{name:o.USER_UNKNOWN,outline:n==="outline",...r,children:t})}function _w({groupId:e,icon:t,variant:n="default",...r}){return e?v.jsx(Rw,{groupId:e,icon:t,variant:n,...r}):v.jsx(Ys,{outline:n==="outline",...r,children:t})}function Je({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:Ne("lb-icon",t),...n,children:e})}function jw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M14.5 8.5 10 13 5.5 8.5"})})}const nl=m.forwardRef((({variant:e="default",size:t="default",disableable:n=!0,className:r,children:o,...i},s)=>v.jsx("button",{type:"button",className:Ne("lb-button",!n&&"lb-button:non-disableable",r),"data-variant":e,"data-size":t,...i,ref:s,children:o}))),Jt=m.forwardRef((({icon:e,children:t,...n},r)=>v.jsxs(nl,{...n,ref:r,children:[e?v.jsx("span",{className:"lb-icon-container",children:e}):null,t?v.jsx("span",{className:"lb-button-label",children:t}):null]})));function rl({groupId:e,className:t,children:n,...r}){const{info:o,isLoading:i}=bc(e);return v.jsxs("span",{className:Ne("lb-name lb-group",t),"data-loading":i?"":void 0,...r,children:[i?null:o?.name??e,n]})}function Mw({groupId:e,className:t,...n}){const{info:r}=bc(e);return r?.description?v.jsx("span",{className:Ne("lb-group-description",t),...n,children:r.description}):null}m.forwardRef((({icon:e,children:t,className:n,...r},o)=>v.jsxs(nl,{...r,type:"button",className:Ne("lb-select-button",n),ref:o,children:[e?v.jsx("span",{className:"lb-icon-container",children:e}):null,t?v.jsx("span",{className:"lb-button-label",children:t}):null,v.jsx("span",{className:"lb-select-button-chevron",children:v.jsx(jw,{})})]})));const Pw=m.forwardRef((({values:e,formatRemaining:t,truncate:n,locale:r,className:o,asChild:i,...s},a)=>{const u=i?vt:"span",l=Mt(),f=t??l.LIST_REMAINING,c=m.useMemo((()=>{const d=n&&n<e.length-1?[...e.slice(0,n),f(e.length-n)]:[...e],h=Array(d.length).fill(".");return Cw(r).formatToParts(h).map((g=>g.type==="element"?d.shift():g.value))}),[f,r,n,e]);return v.jsx(u,{className:Ne("lb-list",o),...s,ref:a,children:c})}));function Nw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M10 4v12m6-6-6 6-6-6"})})}function jg(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m14.077 11.737-3.723 3.62c-1.55 1.507-4.128 1.507-5.678 0-1.543-1.5-1.543-4.02 0-5.52l5.731-5.573c1.034-1.006 2.754-1.007 3.789-.003 1.03 1 1.032 2.682.003 3.684l-5.744 5.572a1.377 1.377 0 0 1-1.893 0 1.283 1.283 0 0 1-.392-.92c0-.345.14-.676.392-.92L10.348 8"})})}function Lw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M10 4a3.5 3.5 0 0 0-3.5 3.5c0 3.5-2 6.5-2 6.5h11s-2-3-2-6.5A3.5 3.5 0 0 0 10 4ZM7.55 14a2.5 2.5 0 0 0 4.9 0"})})}function Uw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M14 14H4.5s2-3 2-6.5c0-.3.05-.6.12-.88M8.2 4.5a3.5 3.5 0 0 1 5.3 3c0 .96.15 1.88.37 2.7M7.55 14a2.5 2.5 0 0 0 4.9 0M4.5 4.5l11 11"})})}function Hw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M5.5 10h6.63m0 5.75H5.5V4.25h5.63M11.125 10a2.875 2.875 0 0 0 0-5.75m1 11.5a2.875 2.875 0 0 0 0-5.75"})})}function Vw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M16 6L8 14L4 10"})})}function $w(e){return v.jsxs(Je,{...e,children:[v.jsx("circle",{cx:10,cy:10,r:7}),v.jsx("path",{d:"m13 8-4 4-2-2"})]})}function Ww(e){return v.jsxs(Je,{...e,children:[v.jsx("circle",{cx:10,cy:10,r:7,fill:"currentColor"}),v.jsx("path",{d:"m13 8-4 4-2-2",stroke:"var(--lb-icon-background)"})]})}function zw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m7.5 6-4 4 4 4m5-8 4 4-4 4"})})}function ol(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M15 5L5 15"}),v.jsx("path",{d:"M5 5L15 15"})]})}function Kw(e){return v.jsx(Je,{...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 qw(e){return v.jsx(Je,{...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 Gw(e){return v.jsxs(Je,{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 Jw(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14Z"}),v.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h.007"}),v.jsx("path",{d:"M12 8h.007"}),v.jsx("circle",{cx:8,cy:8,r:.25}),v.jsx("circle",{cx:12,cy:8,r:.25})]})}function nf(e){return v.jsxs(Je,{...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 Zw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M15 4.25H8m4 11.5H5m6.75-11.5-3.5 11.5"})})}function Xw(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),v.jsx("path",{d:"M13 7v3.7c0 1.105.855 2.1 1.9 2.1a2.12 2.12 0 0 0 2.1-2.1V10a7 7 0 1 0-2.8 5.6"})]})}function Yw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M9 15A6 6 0 1 0 9 3a6 6 0 0 0 0 12Zm7.5 1.5-3.25-3.25"})})}function Qw(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m5 16 12-6L5 4l2 6-2 6ZM7 10h10"})})}function _i(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M3 10a7 7 0 0 1 7-7",className:"lb-icon-spinner"})})}function eE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M15.5 10h-11m4.669 0C7.599 9.44 6.5 8.484 6.5 7.125 6.5 5.537 7.79 4.25 10 4.25c1.654 0 2.793.721 3.261 1.75M6.74 14c.468 1.029 1.607 1.75 3.261 1.75 2 0 3.5-1 3.5-2.5 0-.085-.004-.169-.013-.25"})})}function tE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M8 9.75a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm0 0c-2.42 0-4.055 1.72-4.422 4.004-.087.545.37.996.922.996h7c.552 0 1.01-.45.922-.996C12.055 11.47 10.42 9.75 8 9.75ZM15 14.75h.5c.552 0 1.004-.45.912-.995-.317-1.888-1.485-4.114-3.412-4.505.863-.222 1.5-1.068 1.5-2a2 2 0 0 0-2-2"})})}function Mg(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"m3.794 13.526 5.326-9.89a1 1 0 0 1 1.76 0l5.326 9.89a1 1 0 0 1-.88 1.474H4.674a1 1 0 0 1-.88-1.474ZM10 7.5v2m0 2.5h.007"}),v.jsx("circle",{cx:10,cy:12,r:.25})]})}function hr(){return Mo(Ve()[Oe].currentUserId)??null}function il(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function Pg({isLoading:e,name:t,className:n,children:r,...o}){return v.jsxs("span",{className:Ne("lb-name lb-user",n),"data-loading":e?"":void 0,...o,children:[e?null:t,r]})}function nE({userId:e,replaceSelf:t,...n}){const r=hr(),{user:o,isLoading:i}=Lp(e),s=Mt(),a=m.useMemo((()=>t&&r===e?s.USER_SELF:o?.name??s.USER_UNKNOWN),[t,r,e,s.USER_SELF,s.USER_UNKNOWN,o?.name]);return v.jsx(Pg,{isLoading:i,name:a,...n})}function Oo({userId:e,...t}){const n=Mt();return e?v.jsx(nE,{userId:e,...t}):v.jsx(Pg,{isLoading:!1,name:n.USER_UNKNOWN,...t})}function Mu(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ng=m.forwardRef((({asChild:e,...t},n)=>{const{portalContainer:r}=Ri(),o=r??document?.body,i=e?vt:"div";return o?Oi.createPortal(v.jsx(i,{"data-liveblocks-portal":"",...t,ref:n}),o):null}));function So(e){const[t]=m.useState(e);return t}function rE(e,t){t&&(typeof e=="function"?e(t):e&&"current"in e&&(e.current=t))}function ji(...e){return m.useCallback((t=>(function(n,...r){for(const o of r)rE(o,n)})(t,...e)),e)}function oE(e,t){const n=t,r=m.useRef(e);return r.current=e,m.useMemo((()=>i=>{const s=r.current;return s?(function(a){return!!(a.prototype&&"isReactComponent"in a.prototype)})(s)?v.jsx(s,{...i}):s(i):v.jsx(n,{...i})}),[n])}function rf(e){return Object.prototype.toString.call(e)==="[object Object]"}function ft(e){var t,n;return rf(e)!==!1&&((t=e.constructor)===void 0||rf(n=t.prototype)!==!1&&n.hasOwnProperty("isPrototypeOf")!==!1)}var iE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=R.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},sE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=_e.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},aE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=U.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Rs=new WeakMap,_s=new WeakMap,ii=new WeakMap,of=new WeakMap,sf=new WeakMap,af=new WeakMap,uf=new WeakMap,R={ancestors(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=R.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],s=t[n];return R.equals(r,o)&&i>s},endsAt(e,t){var n=e.length,r=e.slice(0,n),o=t.slice(0,n);return R.equals(r,o)},endsBefore(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),i=e[n],s=t[n];return R.equals(r,o)&&i<s},equals:(e,t)=>e.length===t.length&&e.every(((n,r)=>n===t[r])),hasPrevious:e=>e[e.length-1]>0,isAfter:(e,t)=>R.compare(e,t)===1,isAncestor:(e,t)=>e.length<t.length&&R.compare(e,t)===0,isBefore:(e,t)=>R.compare(e,t)===-1,isChild:(e,t)=>e.length===t.length+1&&R.compare(e,t)===0,isCommon:(e,t)=>e.length<=t.length&&R.compare(e,t)===0,isDescendant:(e,t)=>e.length>t.length&&R.compare(e,t)===0,isParent:(e,t)=>e.length+1===t.length&&R.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]&&R.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(!R.isAncestor(t,e)&&!R.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;(R.equals(i,r)||R.endsBefore(i,r)||R.isAncestor(i,r))&&(r[i.length-1]+=1);break;case"remove_node":var{path:s}=t;if(R.equals(s,r)||R.isAncestor(s,r))return null;R.endsBefore(s,r)&&(r[s.length-1]-=1);break;case"merge_node":var{path:a,position:u}=t;R.equals(a,r)||R.endsBefore(a,r)?r[a.length-1]-=1:R.isAncestor(a,r)&&(r[a.length-1]-=1,r[a.length]+=u);break;case"split_node":var{path:l,position:f}=t;if(R.equals(l,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else R.endsBefore(l,r)?r[l.length-1]+=1:R.isAncestor(l,r)&&e[l.length]>=f&&(r[l.length-1]+=1,r[l.length]-=f);break;case"move_node":var{path:c,newPath:d}=t;if(R.equals(c,d))return r;if(R.isAncestor(c,r)||R.equals(c,r)){var h=d.slice();return R.endsBefore(c,d)&&c.length<d.length&&(h[c.length-1]-=1),h.concat(r.slice(c.length))}R.isSibling(c,d)&&(R.isAncestor(d,r)||R.equals(d,r))?R.endsBefore(c,r)?r[c.length-1]-=1:r[c.length-1]+=1:R.endsBefore(d,r)||R.equals(d,r)||R.isAncestor(d,r)?(R.endsBefore(c,r)&&(r[c.length-1]-=1),r[d.length-1]+=1):R.endsBefore(c,r)&&(R.equals(d,r)&&(r[d.length-1]+=1),r[c.length-1]-=1)}return r}};function si(e){return si=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},si(e)}function uE(e){var t=(function(n,r){if(si(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(si(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return si(t)==="symbol"?t:String(t)}function kt(e,t,n){return(t=uE(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cf(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 Jo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?cf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var cE={transform(e,t){e.children=Tl(e.children);var n=e.selection&&Tl(e.selection);try{n=((r,o,i)=>{switch(i.type){case"insert_node":var{path:s,node:a}=i,u=ee.parent(r,s),l=s[s.length-1];if(l>u.children.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(s,"] because the destination is past the end of the node."));if(u.children.splice(l,0,a),o)for(var[f,c]of U.points(o))o[c]=_e.transform(f,i);break;case"insert_text":var{path:d,offset:h,text:g}=i;if(g.length===0)break;var y=ee.leaf(r,d),p=y.text.slice(0,h),w=y.text.slice(h);if(y.text=p+g+w,o)for(var[b,C]of U.points(o))o[C]=_e.transform(b,i);break;case"merge_node":var{path:E}=i,A=ee.get(r,E),x=R.previous(E),I=ee.get(r,x),T=ee.parent(r,E),F=E[E.length-1];if(he.isText(A)&&he.isText(I))I.text+=A.text;else{if(he.isText(A)||he.isText(I))throw new Error('Cannot apply a "merge_node" operation at path ['.concat(E,"] to nodes of different interfaces: ").concat(ht.stringify(A)," ").concat(ht.stringify(I)));I.children.push(...A.children)}if(T.children.splice(F,1),o)for(var[S,k]of U.points(o))o[k]=_e.transform(S,i);break;case"move_node":var{path:_,newPath:M}=i;if(R.isAncestor(_,M))throw new Error("Cannot move a path [".concat(_,"] to new path [").concat(M,"] because the destination is inside itself."));var H=ee.get(r,_),W=ee.parent(r,_),G=_[_.length-1];W.children.splice(G,1);var q=R.transform(_,i),$=ee.get(r,R.parent(q)),V=q[q.length-1];if($.children.splice(V,0,H),o)for(var[Q,ae]of U.points(o))o[ae]=_e.transform(Q,i);break;case"remove_node":var{path:ie}=i,Se=ie[ie.length-1];if(ee.parent(r,ie).children.splice(Se,1),o)for(var[Ie,ne]of U.points(o)){var B=_e.transform(Ie,i);if(o!=null&&B!=null)o[ne]=B;else{var X=void 0,K=void 0;for(var[Y,de]of ee.texts(r)){if(R.compare(de,ie)!==-1){K=[Y,de];break}X=[Y,de]}var pe=!1;X&&K&&(pe=R.equals(K[1],ie)?!R.hasPrevious(K[1]):R.common(X[1],ie).length<R.common(K[1],ie).length),X&&!pe?(Ie.path=X[1],Ie.offset=X[0].text.length):K?(Ie.path=K[1],Ie.offset=0):o=null}}break;case"remove_text":var{path:fe,offset:we,text:Ce}=i;if(Ce.length===0)break;var se=ee.leaf(r,fe),te=se.text.slice(0,we),me=se.text.slice(we+Ce.length);if(se.text=te+me,o)for(var[Ae,Pe]of U.points(o))o[Pe]=_e.transform(Ae,i);break;case"set_node":var{path:Fe,properties:re,newProperties:J}=i;if(Fe.length===0)throw new Error("Cannot set properties on the root node!");var oe=ee.get(r,Fe);for(var ge in J){if(ge==="children"||ge==="text")throw new Error('Cannot set the "'.concat(ge,'" property of nodes!'));var ve=J[ge];ve==null?delete oe[ge]:oe[ge]=ve}for(var Te in re)J.hasOwnProperty(Te)||delete oe[Te];break;case"set_selection":var{newProperties:We}=i;if(We==null)o=We;else{if(o==null){if(!U.isRange(We))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat(ht.stringify(We)," when there is no current selection."));o=Jo({},We)}for(var Le in We){var et=We[Le];if(et==null){if(Le==="anchor"||Le==="focus")throw new Error('Cannot remove the "'.concat(Le,'" selection property'));delete o[Le]}else o[Le]=et}}break;case"split_node":var{path:ut,position:Nt,properties:hn}=i;if(ut.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(ut,"] because the root node cannot be split."));var Gn,pn=ee.get(r,ut),Mi=ee.parent(r,ut),ta=ut[ut.length-1];if(he.isText(pn)){var Ho=pn.text.slice(0,Nt),Pi=pn.text.slice(Nt);pn.text=Ho,Gn=Jo(Jo({},hn),{},{text:Pi})}else{var Ni=pn.children.slice(0,Nt),Vo=pn.children.slice(Nt);pn.children=Ni,Gn=Jo(Jo({},hn),{},{children:Vo})}if(Mi.children.splice(ta+1,0,Gn),o)for(var[$o,O]of U.points(o))o[O]=_e.transform($o,i)}return o})(e,n,t)}finally{e.children=kl(e.children),e.selection=n?Bv(n)?kl(n):n:null}}},lE={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)}},dE={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)}},Lg=(e,t)=>{for(var n in e){var r=e[n],o=t[n];if(ft(r)&&ft(o)){if(!Lg(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 s in t)if(e[s]===void 0&&t[s]!==void 0)return!1;return!0};function Mn(e,t){if(e==null)return{};var n,r,o=(function(s,a){if(s==null)return{};var u,l,f={},c=Object.keys(s);for(l=0;l<c.length;l++)u=c[l],a.indexOf(u)>=0||(f[u]=s[u]);return f})(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 fE=["anchor","focus"];function lf(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 U={edges(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,{anchor:r,focus:o}=e;return U.isBackward(e)===n?[r,o]:[o,r]},end(e){var[,t]=U.edges(e);return t},equals:(e,t)=>_e.equals(e.anchor,t.anchor)&&_e.equals(e.focus,t.focus),surrounds(e,t){var n=U.intersection(e,t);return!!n&&U.equals(n,t)},includes(e,t){if(U.isRange(t)){if(U.includes(e,t.anchor)||U.includes(e,t.focus))return!0;var[n,r]=U.edges(e),[o,i]=U.edges(t);return _e.isBefore(n,o)&&_e.isAfter(r,i)}var[s,a]=U.edges(e),u=!1,l=!1;return _e.isPoint(t)?(u=_e.compare(t,s)>=0,l=_e.compare(t,a)<=0):(u=R.compare(t,s.path)>=0,l=R.compare(t,a.path)<=0),u&&l},intersection(e,t){var n=Mn(e,fE),[r,o]=U.edges(e),[i,s]=U.edges(t),a=_e.isBefore(r,i)?i:r,u=_e.isBefore(o,s)?o:s;return _e.isBefore(u,a)?null:(function(l){for(var f=1;f<arguments.length;f++){var c=arguments[f]!=null?arguments[f]:{};f%2?lf(Object(c),!0).forEach((function(d){kt(l,d,c[d])})):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(c)):lf(Object(c)).forEach((function(d){Object.defineProperty(l,d,Object.getOwnPropertyDescriptor(c,d))}))}return l})({anchor:a,focus:u},n)},isBackward(e){var{anchor:t,focus:n}=e;return _e.isAfter(t,n)},isCollapsed(e){var{anchor:t,focus:n}=e;return _e.equals(t,n)},isExpanded:e=>!U.isCollapsed(e),isForward:e=>!U.isBackward(e),isRange:e=>ft(e)&&_e.isPoint(e.anchor)&&_e.isPoint(e.focus),*points(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]},start(e){var[t]=U.edges(e);return t},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return rc(e,(r=>{if(r===null)return null;var o,i,{affinity:s="inward"}=n;if(s==="inward"){var a=U.isCollapsed(r);U.isForward(r)?(o="forward",i=a?o:"backward"):(o="backward",i=a?o:"forward")}else s==="outward"?U.isForward(r)?(o="backward",i="forward"):(o="forward",i="backward"):(o=s,i=s);var u=_e.transform(r.anchor,t,{affinity:o}),l=_e.transform(r.focus,t,{affinity:i});if(!u||!l)return null;r.anchor=u,r.focus=l}))}},df=e=>ft(e)&&ee.isNodeList(e.children)&&!D.isEditor(e),le={isAncestor:e=>ft(e)&&ee.isNodeList(e.children),isElement:df,isElementList:e=>Array.isArray(e)&&e.every((t=>le.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 df(e)&&e[n]===t},matches(e,t){for(var n in t)if(n!=="children"&&e[n]!==t[n])return!1;return!0}},hE=["children"],pE=["text"],ff=new WeakMap,ee={ancestor(e,t){var n=ee.get(e,t);if(he.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(t,"] because it refers to a text node instead: ").concat(ht.stringify(n)));return n},ancestors(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of R.ancestors(t,n)){var o=[ee.ancestor(e,r),r];yield o}})()},child(e,t){if(he.isText(e))throw new Error("Cannot get the child of a text node: ".concat(ht.stringify(e)));var n=e.children[t];if(n==null)throw new Error("Cannot get child at index `".concat(t,"` in node: ").concat(ht.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=ee.ancestor(e,t),{children:i}=o,s=r?i.length-1:0;r?s>=0:s<i.length;){var a=ee.child(o,s),u=t.concat(s);yield[a,u],s=r?s-1:s+1}})()},common(e,t,n){var r=R.common(t,n);return[ee.get(e,r),r]},descendant(e,t){var n=ee.get(e,t);if(D.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(t,"] because it refers to the root editor node instead: ").concat(ht.stringify(n)));return n},descendants(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.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 ee.nodes(e,t))le.isElement(n)&&(yield[n,r])})()},extractProps:e=>le.isAncestor(e)?Mn(e,hE):Mn(e,pE),first(e,t){for(var n=t.slice(),r=ee.get(e,n);r&&!he.isText(r)&&r.children.length!==0;)r=r.children[0],n.push(0);return[r,n]},fragment(e,t){if(he.isText(e))throw new Error("Cannot get a fragment starting from a root text node: ".concat(ht.stringify(e)));var n=rc({children:e.children},(r=>{var[o,i]=U.edges(t),s=ee.nodes(r,{reverse:!0,pass:d=>{var[,h]=d;return!U.includes(t,h)}});for(var[,a]of s){if(!U.includes(t,a)){var u=ee.parent(r,a),l=a[a.length-1];u.children.splice(l,1)}if(R.equals(a,i.path)){var f=ee.leaf(r,a);f.text=f.text.slice(0,i.offset)}if(R.equals(a,o.path)){var c=ee.leaf(r,a);c.text=c.text.slice(o.offset)}}D.isEditor(r)&&(r.selection=null)}));return n.children},get(e,t){var n=ee.getIf(e,t);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(t,"] in node: ").concat(ht.stringify(e)));return n},getIf(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(he.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(he.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode:e=>he.isText(e)||le.isElement(e)||D.isEditor(e),isNodeList(e){if(!Array.isArray(e))return!1;var t=ff.get(e);if(t!==void 0)return t;var n=e.every((r=>ee.isNode(r)));return ff.set(e,n),n},last(e,t){for(var n=t.slice(),r=ee.get(e,n);r&&!he.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=ee.get(e,t);if(!he.isText(n))throw new Error("Cannot get the leaf node at path [".concat(t,"] because it refers to a non-leaf node: ").concat(ht.stringify(n)));return n},levels(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of R.levels(t,n)){var o=ee.get(e,r);yield[o,r]}})()},matches:(e,t)=>le.isElement(e)&&le.isElementProps(t)&&le.matches(e,t)||he.isText(e)&&he.isTextProps(t)&&he.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,s=new Set,a=[],u=e;!i||!(r?R.isBefore(a,i):R.isAfter(a,i));)if(s.has(u)||(yield[u,a]),s.has(u)||he.isText(u)||u.children.length===0||n!=null&&n([u,a])!==!1){if(a.length===0)break;if(!r){var l=R.next(a);if(ee.has(e,l)){a=l,u=ee.get(e,a);continue}}r&&a[a.length-1]!==0?(a=R.previous(a),u=ee.get(e,a)):(a=R.parent(a),u=ee.get(e,a),s.add(u))}else{s.add(u);var f=r?u.children.length-1:0;R.isAncestor(a,o)&&(f=o[a.length]),a=a.concat(f),u=ee.get(e,a)}})()},parent(e,t){var n=R.parent(t),r=ee.get(e,n);if(he.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=>he.isText(e)?e.text:e.children.map(ee.string).join(""),texts(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.nodes(e,t))he.isText(n)&&(yield[n,r])})()}};function hf(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 nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ur={isNodeOperation:e=>ur.isOperation(e)&&e.type.endsWith("_node"),isOperation(e){if(!ft(e))return!1;switch(e.type){case"insert_node":case"remove_node":return R.isPath(e.path)&&ee.isNode(e.node);case"insert_text":case"remove_text":return typeof e.offset=="number"&&typeof e.text=="string"&&R.isPath(e.path);case"merge_node":return typeof e.position=="number"&&R.isPath(e.path)&&ft(e.properties);case"move_node":return R.isPath(e.path)&&R.isPath(e.newPath);case"set_node":return R.isPath(e.path)&&ft(e.properties)&&ft(e.newProperties);case"set_selection":return e.properties===null&&U.isRange(e.newProperties)||e.newProperties===null&&U.isRange(e.properties)||ft(e.properties)&&ft(e.newProperties);case"split_node":return R.isPath(e.path)&&typeof e.position=="number"&&ft(e.properties);default:return!1}},isOperationList:e=>Array.isArray(e)&&e.every((t=>ur.isOperation(t))),isSelectionOperation:e=>ur.isOperation(e)&&e.type.endsWith("_selection"),isTextOperation:e=>ur.isOperation(e)&&e.type.endsWith("_text"),inverse(e){switch(e.type){case"insert_node":return nt(nt({},e),{},{type:"remove_node"});case"insert_text":return nt(nt({},e),{},{type:"remove_text"});case"merge_node":return nt(nt({},e),{},{type:"split_node",path:R.previous(e.path)});case"move_node":var{newPath:t,path:n}=e;if(R.equals(t,n))return e;if(R.isSibling(n,t))return nt(nt({},e),{},{path:t,newPath:n});var r=R.transform(n,e),o=R.transform(R.next(n),e);return nt(nt({},e),{},{path:r,newPath:o});case"remove_node":return nt(nt({},e),{},{type:"insert_node"});case"remove_text":return nt(nt({},e),{},{type:"insert_text"});case"set_node":var{properties:i,newProperties:s}=e;return nt(nt({},e),{},{properties:s,newProperties:i});case"set_selection":var{properties:a,newProperties:u}=e;return nt(nt({},e),{},a==null?{properties:u,newProperties:null}:u==null?{properties:null,newProperties:a}:{properties:u,newProperties:a});case"split_node":return nt(nt({},e),{},{type:"merge_node",path:R.next(e.path)})}}},pf=new WeakMap,D={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=pf.get(t);if(n!==void 0)return n;if(!ft(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||ft(t.marks))&&(t.selection===null||U.isRange(t.selection))&&ee.isNodeList(t.children)&&ur.isOperationList(t.operations);return pf.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)},mE={isSpan:e=>Array.isArray(e)&&e.length===2&&e.every(R.isPath)};function mf(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 gf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?mf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var _e={compare(e,t){var n=R.compare(e.path,t.path);return n===0?e.offset<t.offset?-1:e.offset>t.offset?1:0:n},isAfter:(e,t)=>_e.compare(e,t)===1,isBefore:(e,t)=>_e.compare(e,t)===-1,equals:(e,t)=>e.offset===t.offset&&R.equals(e.path,t.path),isPoint:e=>ft(e)&&typeof e.offset=="number"&&R.isPath(e.path),transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return rc(e,(r=>{if(r===null)return null;var{affinity:o="forward"}=n,{path:i,offset:s}=r;switch(t.type){case"insert_node":case"move_node":r.path=R.transform(i,t,n);break;case"insert_text":R.equals(t.path,i)&&(t.offset<s||t.offset===s&&o==="forward")&&(r.offset+=t.text.length);break;case"merge_node":R.equals(t.path,i)&&(r.offset+=t.position),r.path=R.transform(i,t,n);break;case"remove_text":R.equals(t.path,i)&&t.offset<=s&&(r.offset-=Math.min(s-t.offset,t.text.length));break;case"remove_node":if(R.equals(t.path,i)||R.isAncestor(t.path,i))return null;r.path=R.transform(i,t,n);break;case"split_node":if(R.equals(t.path,i)){if(t.position===s&&o==null)return null;(t.position<s||t.position===s&&o==="forward")&&(r.offset-=t.position,r.path=R.transform(i,t,gf(gf({},n),{},{affinity:"forward"})))}else r.path=R.transform(i,t,n)}}))}},vf=void 0,ht={setScrubber(e){vf=e},stringify:e=>JSON.stringify(e,vf)},gE=["text"],vE=["anchor","focus"];function yf(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 kn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?yf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ke,he={equals(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(i){return Mn(i,gE)}return Lg(r?o(e):e,r?o(t):t)},isText:e=>ft(e)&&typeof e.text=="string",isTextList:e=>Array.isArray(e)&&e.every((t=>he.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=[kn({},e)];for(var r of t){var o=Mn(r,vE),[i,s]=U.edges(r),a=[],u=0,l=i.offset,f=s.offset;for(var c of n){var{length:d}=c.text,h=u;if(u+=d,l<=h&&u<=f)Object.assign(c,o),a.push(c);else if(l!==f&&(l===u||f===h)||l>u||f<h||f===h&&h!==0)a.push(c);else{var g=c,y=void 0,p=void 0;if(f<u){var w=f-h;p=kn(kn({},g),{},{text:g.text.slice(w)}),g=kn(kn({},g),{},{text:g.text.slice(0,w)})}if(l>h){var b=l-h;y=kn(kn({},g),{},{text:g.text.slice(0,b)}),g=kn(kn({},g),{},{text:g.text.slice(b)})}Object.assign(g,o),y&&a.push(y),a.push(g),p&&a.push(p)}}n=a}return n}},sl=e=>e.selection?e.selection:e.children.length>0?D.end(e,[]):[0],Yr=(e,t)=>{var[n]=D.node(e,t);return r=>r===n},Pu=function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=!t,r=t?EE(e):e,o=ke.None,i=ke.None,s=0,a=null;for(var u of r){var l=u.codePointAt(0);if(!l)break;var f=_E(u,l);if([o,i]=n?[i,f]:[f,o],co(o,ke.ZWJ)&&co(i,ke.ExtPict)&&!NE(n?e.substring(0,s):e.substring(0,e.length-s))||co(o,ke.RI)&&co(i,ke.RI)&&!(a=a!==null?!a:!!n||UE(e.substring(0,e.length-s)))||o!==ke.None&&i!==ke.None&&ME(o,i))break;s+=u.length}return s||1},yE=/\s/,bE=/[\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]/,CE=/['\u2018\u2019]/,Nu=(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)]},wE=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(yE.test(t))return!1;if(CE.test(t)){var o=Pu(n,r),[i,s]=Nu(n,o,r);if(e(i,s,r))return!0}return!bE.test(t)},EE=function*(e){for(var t=e.length-1,n=0;n<e.length;n++){var r=e.charAt(t-n);if(AE(r.charCodeAt(0))){var o=e.charAt(t-n-1);if(DE(o.charCodeAt(0))){yield o+r,n++;continue}}yield r}},DE=e=>e>=55296&&e<=56319,AE=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"})(ke||(ke={}));var xE=/^(?:[\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])$/,OE=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,SE=/^(?:[\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])$/,IE=/^[\u1100-\u115F\uA960-\uA97C]$/,TE=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,kE=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,BE=/^[\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]$/,FE=/^[\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]$/,RE=/^(?:[\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])$/,_E=(e,t)=>{var n=ke.Any;return e.search(xE)!==-1&&(n|=ke.Extend),t===8205&&(n|=ke.ZWJ),t>=127462&&t<=127487&&(n|=ke.RI),e.search(OE)!==-1&&(n|=ke.Prepend),e.search(SE)!==-1&&(n|=ke.SpacingMark),e.search(IE)!==-1&&(n|=ke.L),e.search(TE)!==-1&&(n|=ke.V),e.search(kE)!==-1&&(n|=ke.T),e.search(BE)!==-1&&(n|=ke.LV),e.search(FE)!==-1&&(n|=ke.LVT),e.search(RE)!==-1&&(n|=ke.ExtPict),n};function co(e,t){return!!(e&t)}var jE=[[ke.L,ke.L|ke.V|ke.LV|ke.LVT],[ke.LV|ke.V,ke.V|ke.T],[ke.LVT|ke.T,ke.T],[ke.Any,ke.Extend|ke.ZWJ],[ke.Any,ke.SpacingMark],[ke.Prepend,ke.Any],[ke.ZWJ,ke.ExtPict],[ke.RI,ke.RI]];function ME(e,t){return jE.findIndex((n=>co(e,n[0])&&co(t,n[1])))===-1}var PE=/(?:[\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$/,NE=e=>e.search(PE)!==-1,LE=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,UE=e=>{var t=e.match(LE);return t!==null&&t[0].length/2%2==1},HE={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]:{};D.withoutNormalizing(e,(()=>{var{voids:r=!1}=n,{at:o=sl(e)}=n;if(R.isPath(o)&&(o=D.range(e,o)),U.isRange(o))if(U.isCollapsed(o))o=o.anchor;else{var i=U.end(o);if(!r&&D.void(e,{at:i}))return;var s=U.start(o),a=D.pointRef(e,s),u=D.pointRef(e,i);z.delete(e,{at:o,voids:r});var l=a.unref(),f=u.unref();o=l||f,z.setSelection(e,{anchor:o,focus:o})}if(!(!r&&D.void(e,{at:o})||D.elementReadOnly(e,{at:o}))){var{path:c,offset:d}=o;t.length>0&&e.apply({type:"insert_text",path:c,offset:d,text:t})}}))}};function bf(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 ts(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?bf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var z=ts(ts(ts(ts({},cE),lE),dE),HE),hs=new WeakMap;function Ug(e,t,n){var r,o,i=Rs.get(e)||[],s=_s.get(e)||new Set,a=f=>{if(f){var c=f.join(",");o.has(c)||(o.add(c),r.push(f))}};if(n)for(var u of(r=[],o=new Set,i))a(n(u));else r=i,o=s;for(var l of t)a(l);Rs.set(e,r),_s.set(e,o)}var VE=(e,t)=>{for(var n of D.pathRefs(e))iE.transform(n,t);for(var r of D.pointRefs(e))sE.transform(r,t);for(var o of D.rangeRefs(e))aE.transform(o,t);if(!(s=>hs.get(s)||!1)(e)){var i=R.operationCanTransformPath(t)?s=>R.transform(s,t):void 0;Ug(e,e.getDirtyPaths(t),i)}z.transform(e,t),e.operations.push(t),D.normalize(e,{operation:t}),t.type==="set_selection"&&(e.marks=null),ii.get(e)||(ii.set(e,!0),Promise.resolve().then((()=>{ii.set(e,!1),e.onChange({operation:t}),e.operations=[]})))};function Cf(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 wf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Cf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Ef(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 Df(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ef(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ef(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Af(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 xf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Af(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Af(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Of(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 Sf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Of(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Of(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function If(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 Tf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?If(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):If(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function kf(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 Hg=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(s){for(var a=1;a<arguments.length;a++){var u=arguments[a]!=null?arguments[a]:{};a%2?kf(Object(u),!0).forEach((function(l){kt(s,l,u[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):kf(Object(u)).forEach((function(l){Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(u,l))}))}return s})({text:t},o);z.insertNodes(e,i,{at:n.at,voids:n.voids})}else z.insertText(e,t,n);e.marks=null}},$E=["text"],WE=["text"],zE=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:n=!1,operation:r}=t,o=u=>Rs.get(u)||[],i=u=>{var l=o(u).pop(),f=l.join(",");return(c=>_s.get(c)||new Set)(u).delete(f),l};if(D.isNormalizing(e)){if(n){var s=Array.from(ee.nodes(e),(u=>{var[,l]=u;return l})),a=new Set(s.map((u=>u.join(","))));Rs.set(e,s),_s.set(e,a)}o(e).length!==0&&D.withoutNormalizing(e,(()=>{for(var u of o(e))if(ee.has(e,u)){var l=D.node(e,u),[f,c]=l;le.isElement(f)&&f.children.length===0&&e.normalizeNode(l,{operation:r})}for(var d=o(e),h=d.length,g=0;d.length!==0;){if(!e.shouldNormalize({dirtyPaths:d,iteration:g,initialDirtyPathsLength:h,operation:r}))return;var y=i(e);if(ee.has(e,y)){var p=D.node(e,y);e.normalizeNode(p,{operation:r})}g++,d=o(e)}}))}};function KE(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:s=!1}=t;if(n){var a=D.range(e,n),[u,l]=U.edges(a),f=o?l:u,c=!1,d="",h=0,g=0,y=0;for(var[p,w]of D.nodes(e,{at:n,reverse:o,voids:i,ignoreNonSelectable:s})){if(le.isElement(p)){if(!i&&(e.isVoid(p)||e.isElementReadOnly(p))){yield D.start(e,w);continue}if(e.isInline(p))continue;if(D.hasInlines(e,p)){var b=R.isAncestor(w,l.path)?l:D.end(e,w),C=R.isAncestor(w,u.path)?u:D.start(e,w);d=D.string(e,{anchor:C,focus:b},{voids:i}),c=!0}}if(he.isText(p)){var E=R.equals(w,f.path);for(E?(g=o?f.offset:p.text.length-f.offset,y=f.offset):(g=p.text.length,y=o?g:0),(E||c||r==="offset")&&(yield{path:w,offset:y},c=!1);;){if(h===0){if(d==="")break;h=A(d,r,o),d=Nu(d,h,o)[1]}if(y=o?y-h:y+h,(g-=h)<0){h=-g;break}h=0,yield{path:w,offset:y}}}}}function A(x,I,T){return I==="character"?Pu(x,T):I==="word"?(function(F){for(var S=arguments.length>1&&arguments[1]!==void 0&&arguments[1],k=0,_=!1;F.length>0;){var M=Pu(F,S),[H,W]=Nu(F,M,S);if(wE(H,W,S))_=!0,k+=M;else{if(_)break;k+=M}F=W}return k})(x,T):I==="line"||I==="block"?x.length:1}})()}function Bf(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 qE=(e,t)=>{var{selection:n}=e;if(n){var r=(f,c)=>{if(!he.isText(f))return!1;var[d,h]=D.parent(e,c);return!e.isVoid(d)||e.markableVoid(d)},o=U.isExpanded(n),i=!1;if(!o){var[s,a]=D.node(e,n);if(s&&r(s,a)){var[u]=D.parent(e,a);i=u&&e.markableVoid(u)}}if(o||i)z.unsetNodes(e,t,{match:r,split:!0,voids:!0});else{var l=(function(f){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?Bf(Object(d),!0).forEach((function(h){kt(f,h,d[h])})):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(d)):Bf(Object(d)).forEach((function(h){Object.defineProperty(f,h,Object.getOwnPropertyDescriptor(d,h))}))}return f})({},D.marks(e)||{});delete l[t],e.marks=l,ii.get(e)||e.onChange()}}};function Ff(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 Rf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ff(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ff(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var GE=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(e,(()=>{var{hanging:r=!1,voids:o=!1,mode:i="lowest",batchDirty:s=!0}=n,{at:a,match:u,select:l}=n;if(ee.isNode(t)&&(t=[t]),t.length!==0){var[f]=t;if(a||(a=sl(e),l!==!1&&(l=!0)),l==null&&(l=!1),U.isRange(a))if(r||(a=D.unhangRange(e,a,{voids:o})),U.isCollapsed(a))a=a.anchor;else{var[,c]=U.edges(a),d=D.pointRef(e,c);z.delete(e,{at:a}),a=d.unref()}if(_e.isPoint(a)){u==null&&(u=he.isText(f)?F=>he.isText(F):e.isInline(f)?F=>he.isText(F)||D.isInline(e,F):F=>le.isElement(F)&&D.isBlock(e,F));var[h]=D.nodes(e,{at:a.path,match:u,mode:i,voids:o});if(!h)return;var[,g]=h,y=D.pathRef(e,g),p=D.isEnd(e,a,g);z.splitNodes(e,{at:a,match:u,mode:i,voids:o});var w=y.unref();a=p?R.next(w):w}var b=R.parent(a),C=a[a.length-1];if(o||!D.void(e,{at:b})){if(s){var E=[],A=R.levels(b);((F,S,k)=>{var _=hs.get(F)||!1;hs.set(F,!0);try{S(),k()}finally{hs.set(F,_)}})(e,(()=>{var F=function(){var k=b.concat(C);C++;var _={type:"insert_node",path:k,node:S};e.apply(_),a=R.next(a),E.push(_),he.isText?A.push(...Array.from(ee.nodes(S),(M=>{var[,H]=M;return k.concat(H)}))):A.push(k)};for(var S of t)F()}),(()=>{Ug(e,A,(F=>{var S=F;for(var k of E)if(R.operationCanTransformPath(k)&&!(S=R.transform(S,k)))return null;return S}))}))}else for(var x of t){var I=b.concat(C);C++,e.apply({type:"insert_node",path:I,node:x}),a=R.next(a)}if(a=R.previous(a),l){var T=D.end(e,a);T&&z.select(e,T)}}}}))},JE=["text"],ZE=["children"],Vg=(e,t)=>{if(le.isElement(t)){var n=t;return!!D.isVoid(e,t)||n.children.length===1&&Vg(e,n.children[0])}return!D.isEditor(t)},XE=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(e,(()=>{var{mode:n="lowest",voids:r=!1}=t,{match:o,at:i=e.selection,height:s=0,always:a=!1}=t;if(o==null&&(o=W=>le.isElement(W)&&D.isBlock(e,W)),U.isRange(i)&&(i=((W,G)=>{if(U.isCollapsed(G))return G.anchor;var[,q]=U.edges(G),$=D.pointRef(W,q);return z.delete(W,{at:G}),$.unref()})(e,i)),R.isPath(i)){var u=i,l=D.point(e,u),[f]=D.parent(e,u);o=W=>W===f,s=l.path.length-u.length+1,i=l,a=!0}if(i){var c,d=D.pointRef(e,i,{affinity:"backward"});try{var[h]=D.nodes(e,{at:i,match:o,mode:n,voids:r});if(!h)return;var g=D.void(e,{at:i,mode:"highest"});if(!r&&g){var[y,p]=g;if(le.isElement(y)&&e.isInline(y)){var w=D.after(e,p);if(!w){var b=R.next(p);z.insertNodes(e,{text:""},{at:b,voids:r}),w=D.point(e,b)}i=w,a=!0}s=i.path.length-p.length+1,a=!0}c=D.pointRef(e,i);var C=i.path.length-s,[,E]=h,A=i.path.slice(0,C),x=s===0?i.offset:i.path[C]+0;for(var[I,T]of D.levels(e,{at:A,reverse:!0,voids:r})){var F=!1;if(T.length<E.length||T.length===0||!r&&le.isElement(I)&&D.isVoid(e,I))break;var S=d.current,k=D.isEnd(e,S,T);if(a||!d||!D.isEdge(e,S,T)){F=!0;var _=ee.extractProps(I);e.apply({type:"split_node",path:T,position:x,properties:_})}x=T[T.length-1]+(F||k?1:0)}if(t.at==null){var M=c.current||D.end(e,[]);z.select(e,M)}}finally{var H;d.unref(),(H=c)===null||H===void 0||H.unref()}}}))};function _f(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 jf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?_f(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_f(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Na,Mf,$g=()=>{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 VE(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,s)=>{var{selection:a}=o;if(a){var u=(y,p)=>{if(!he.isText(y))return!1;var[w,b]=D.parent(o,p);return!o.isVoid(w)||o.markableVoid(w)},l=U.isExpanded(a),f=!1;if(!l){var[c,d]=D.node(o,a);if(c&&u(c,d)){var[h]=D.parent(o,d);f=h&&o.markableVoid(h)}}if(l||f)z.setNodes(o,{[i]:s},{match:u,split:!0,voids:!0});else{var g=wf(wf({},D.marks(o)||{}),{},{[i]:s});o.marks=g,ii.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:s}=o;s&&U.isCollapsed(s)&&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:s}=o;s&&U.isCollapsed(s)&&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:s}=o;s&&U.isExpanded(s)&&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?ee.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{hanging:a=!1,voids:u=!1}=s,{at:l=sl(o),batchDirty:f=!0}=s;if(i.length){if(U.isRange(l))if(a||(l=D.unhangRange(o,l,{voids:u})),U.isCollapsed(l))l=l.anchor;else{var[,c]=U.edges(l);if(!u&&D.void(o,{at:c}))return;var d=D.pointRef(o,c);z.delete(o,{at:l}),l=d.unref()}else R.isPath(l)&&(l=D.start(o,l));if(u||!D.void(o,{at:l})){var h=D.above(o,{at:l,match:B=>le.isElement(B)&&D.isInline(o,B),mode:"highest",voids:u});if(h){var[,g]=h;D.isEnd(o,l,g)?l=D.after(o,g):D.isStart(o,l,g)&&(l=D.before(o,g))}var y=D.above(o,{match:B=>le.isElement(B)&&D.isBlock(o,B),at:l,voids:u}),[,p]=y,w=D.isStart(o,l,p),b=D.isEnd(o,l,p),C=w&&b,E=!w||w&&b,A=!b,[,x]=ee.first({children:i},[]),[,I]=ee.last({children:i},[]),T=[],F=B=>{var[X,K]=B;return!(K.length===0||!C&&(E&&R.isAncestor(K,x)&&le.isElement(X)&&!o.isVoid(X)&&!o.isInline(X)||A&&R.isAncestor(K,I)&&le.isElement(X)&&!o.isVoid(X)&&!o.isInline(X)))};for(var S of ee.nodes({children:i},{pass:F}))F(S)&&T.push(S);var k=[],_=[],M=[],H=!0,W=!1;for(var[G]of T)le.isElement(G)&&!o.isInline(G)?(H=!1,W=!0,_.push(G)):H?k.push(G):M.push(G);var[q]=D.nodes(o,{at:l,match:B=>he.isText(B)||D.isInline(o,B),mode:"highest",voids:u}),[,$]=q,V=D.isStart(o,l,$),Q=D.isEnd(o,l,$),ae=D.pathRef(o,b&&!M.length?R.next(p):p),ie=D.pathRef(o,Q?R.next($):$);z.splitNodes(o,{at:l,match:B=>W?le.isElement(B)&&D.isBlock(o,B):he.isText(B)||D.isInline(o,B),mode:W?"lowest":"highest",always:W&&(!w||k.length>0)&&(!b||M.length>0),voids:u});var Se,Ie=D.pathRef(o,!V||V&&Q?R.next($):$);if(z.insertNodes(o,k,{at:Ie.current,match:B=>he.isText(B)||D.isInline(o,B),mode:"highest",voids:u,batchDirty:f}),C&&!k.length&&_.length&&!M.length&&z.delete(o,{at:p,voids:u}),z.insertNodes(o,_,{at:ae.current,match:B=>le.isElement(B)&&D.isBlock(o,B),mode:"lowest",voids:u,batchDirty:f}),z.insertNodes(o,M,{at:ie.current,match:B=>he.isText(B)||D.isInline(o,B),mode:"highest",voids:u,batchDirty:f}),!s.at&&(M.length>0&&ie.current?Se=R.previous(ie.current):_.length>0&&ae.current?Se=R.previous(ae.current):Ie.current&&(Se=R.previous(Ie.current)),Se)){var ne=D.end(o,Se);z.select(o,ne)}Ie.unref(),ae.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,s)=>{z.insertNodes(o,i,s)})(e,...n)},insertText:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Hg(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[s,a]=i;if(!he.isText(s))if(le.isElement(s)&&s.children.length===0)z.insertNodes(o,{text:""},{at:a.concat(0),voids:!0});else for(var u=!D.isEditor(s)&&le.isElement(s)&&(o.isInline(s)||s.children.length===0||he.isText(s.children[0])||o.isInline(s.children[0])),l=0,f=0;f<s.children.length;f++,l++){var c=ee.get(o,a);if(!he.isText(c)){var d=c.children[l],h=c.children[l-1],g=f===s.children.length-1;(he.isText(d)||le.isElement(d)&&o.isInline(d))!==u?(z.removeNodes(o,{at:a.concat(l),voids:!0}),l--):le.isElement(d)?o.isInline(d)&&(h!=null&&he.isText(h)?g&&(z.insertNodes(o,{text:""},{at:a.concat(l+1),voids:!0}),l++):(z.insertNodes(o,{text:""},{at:a.concat(l),voids:!0}),l++)):(he.isText(d)||"children"in d||(d.children=[]),h!=null&&he.isText(h)&&(he.equals(d,h,{loose:!0})?(z.mergeNodes(o,{at:a.concat(l),voids:!0}),l--):h.text===""?(z.removeNodes(o,{at:a.concat(l-1),voids:!0}),l--):d.text===""&&(z.removeNodes(o,{at:a.concat(l),voids:!0}),l--)))}}})(e,...n)},removeMark:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return qE(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:s}=i;return R.levels(s);case"insert_node":var{node:a,path:u}=i,l=R.levels(u),f=he.isText(a)?[]:Array.from(ee.nodes(a),(F=>{var[,S]=F;return u.concat(S)}));return[...l,...f];case"merge_node":var{path:c}=i;return[...R.ancestors(c),R.previous(c)];case"move_node":var{path:d,newPath:h}=i;if(R.equals(d,h))return[];var g=[],y=[];for(var p of R.ancestors(d)){var w=R.transform(p,i);g.push(w)}for(var b of R.ancestors(h)){var C=R.transform(b,i);y.push(C)}var E=y[y.length-1],A=h[h.length-1],x=E.concat(A);return[...g,...y,x];case"remove_node":var{path:I}=i;return[...R.ancestors(I)];case"split_node":var{path:T}=i;return[...R.levels(T),R.next(T)];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:s,initialDirtyPathsLength:a}=i,u=42*a;if(s>u)throw new Error("Could not completely normalize the editor after ".concat(u," 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:s=!1,mode:a="lowest",at:u=o.selection,match:l}=i;if(u){var f=D.path(o,u),c=a==="lowest";for(var[d,h]of D.levels(o,{at:f,voids:s,match:l,reverse:c}))if(!he.isText(d)){if(U.isRange(u)){if(R.isAncestor(h,u.anchor.path)&&R.isAncestor(h,u.focus.path))return[d,h]}else if(!R.equals(f,h))return[d,h]}}})(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 s,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u={anchor:D.point(o,i,{edge:"end"}),focus:D.end(o,[])},{distance:l=1}=a,f=0;for(var c of D.positions(o,Df(Df({},a),{},{at:u}))){if(f>l)break;f!==0&&(s=c),f++}return s})(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 s,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u={anchor:D.start(o,[]),focus:D.point(o,i,{edge:"start"})},{distance:l=1}=a,f=0;for(var c of D.positions(o,xf(xf({},a),{},{at:u,reverse:!0}))){if(f>l)break;f!==0&&(s=c),f++}return s})(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:s="anchor"}=i,{selection:a}=o;if(a){if(s==="anchor")z.select(o,a.anchor);else if(s==="focus")z.select(o,a.focus);else if(s==="start"){var[u]=U.edges(a);z.select(o,u)}else if(s==="end"){var[,l]=U.edges(a);z.select(o,l)}}})(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]:{};D.withoutNormalizing(o,(()=>{var s,a,{reverse:u=!1,unit:l="character",distance:f=1,voids:c=!1}=i,{at:d=o.selection,hanging:h=!1}=i;if(d){var g=!1;if(U.isRange(d)&&U.isCollapsed(d)&&(g=!0,d=d.anchor),_e.isPoint(d)){var y=D.void(o,{at:d,mode:"highest"});if(!c&&y){var[,p]=y;d=p}else{var w={unit:l,distance:f};d={anchor:d,focus:u?D.before(o,d,w)||D.start(o,[]):D.after(o,d,w)||D.end(o,[])},h=!0}}if(R.isPath(d))z.removeNodes(o,{at:d,voids:c});else if(!U.isCollapsed(d)){if(!h){var[,b]=U.edges(d),C=D.end(o,[]);_e.equals(b,C)||(d=D.unhangRange(o,d,{voids:c}))}var[E,A]=U.edges(d),x=D.above(o,{match:te=>le.isElement(te)&&D.isBlock(o,te),at:E,voids:c}),I=D.above(o,{match:te=>le.isElement(te)&&D.isBlock(o,te),at:A,voids:c}),T=x&&I&&!R.equals(x[1],I[1]),F=R.equals(E.path,A.path),S=c?null:(s=D.void(o,{at:E,mode:"highest"}))!==null&&s!==void 0?s:D.elementReadOnly(o,{at:E,mode:"highest"}),k=c?null:(a=D.void(o,{at:A,mode:"highest"}))!==null&&a!==void 0?a:D.elementReadOnly(o,{at:A,mode:"highest"});if(S){var _=D.before(o,E);_&&x&&R.isAncestor(x[1],_.path)&&(E=_)}if(k){var M=D.after(o,A);M&&I&&R.isAncestor(I[1],M.path)&&(A=M)}var H,W=[];for(var G of D.nodes(o,{at:d,voids:c})){var[q,$]=G;H&&R.compare($,H)===0||(!c&&le.isElement(q)&&(D.isVoid(o,q)||D.isElementReadOnly(o,q))||!R.isCommon($,E.path)&&!R.isCommon($,A.path))&&(W.push(G),H=$)}var V=Array.from(W,(te=>{var[,me]=te;return D.pathRef(o,me)})),Q=D.pointRef(o,E),ae=D.pointRef(o,A),ie="";if(!F&&!S){var Se=Q.current,[Ie]=D.leaf(o,Se),{path:ne}=Se,{offset:B}=E,X=Ie.text.slice(B);X.length>0&&(o.apply({type:"remove_text",path:ne,offset:B,text:X}),ie=X)}if(V.reverse().map((te=>te.unref())).filter((te=>te!==null)).forEach((te=>z.removeNodes(o,{at:te,voids:c}))),!k){var K=ae.current,[Y]=D.leaf(o,K),{path:de}=K,pe=F?E.offset:0,fe=Y.text.slice(pe,A.offset);fe.length>0&&(o.apply({type:"remove_text",path:de,offset:pe,text:fe}),ie=fe)}!F&&T&&ae.current&&Q.current&&z.mergeNodes(o,{at:ae.current,hanging:!0,voids:c}),g&&u&&l==="character"&&ie.length>1&&ie.match(/[\u0E00-\u0E7F]+/)&&z.insertText(o,ie.slice(0,ie.length-f));var we=Q.unref(),Ce=ae.unref(),se=u?we||Ce:Ce||we;i.at==null&&se&&z.select(o,se)}}}))})(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)=>[D.start(o,i),D.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 D.above(o,Sf(Sf({},i),{},{match:s=>le.isElement(s)&&D.isElementReadOnly(o,s)}))})(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)=>D.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 s=D.path(o,i,{edge:"start"});return D.node(o,s)})(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 s=D.range(o,i);return ee.fragment(o,s)})(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:s}=o;if(!s)return null;var{anchor:a,focus:u}=s;if(i)return i;if(U.isExpanded(s)){if(U.isBackward(s)&&([u,a]=[a,u]),D.isEnd(o,a,a.path)){var l=D.after(o,a);l&&(a=l)}var[f]=D.nodes(o,{match:he.isText,at:{anchor:a,focus:u}});if(f){var[c]=f;return Mn(c,$E)}return{}}var{path:d}=a,[h]=D.leaf(o,d);if(a.offset===0){var g=D.previous(o,{at:d,match:he.isText}),y=D.above(o,{match:E=>le.isElement(E)&&D.isVoid(o,E)&&o.markableVoid(E)});if(!y){var p=D.above(o,{match:E=>le.isElement(E)&&D.isBlock(o,E)});if(g&&p){var[w,b]=g,[,C]=p;R.isAncestor(C,b)&&(h=w)}}}return Mn(h,WE)})(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((s=>le.isElement(s)&&D.isBlock(o,s))))(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((s=>he.isText(s)||D.isInline(o,s))))(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)=>ee.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((s=>he.isText(s))))(e,...n)},insertNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return GE(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,s)=>D.isStart(o,i,s)||D.isEnd(o,i,s))(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:s}=i,[a]=s;return s.length===0||s.length===1&&he.isText(a)&&a.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,s)=>{var a=D.end(o,s);return _e.equals(i,a)})(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=of.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,s)=>{if(i.offset!==0)return!1;var a=D.start(o,s);return _e.equals(i,a)})(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 s=D.path(o,i,{edge:"end"});return D.node(o,s)})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s);return[ee.leaf(o,a),a]})(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:s=o.selection,reverse:a=!1,voids:u=!1}=i,{match:l}=i;if(l==null&&(l=()=>!0),s){var f=[],c=D.path(o,s);for(var[d,h]of ee.levels(o,c))if(l(d,h)&&(f.push([d,h]),!u&&le.isElement(d)&&D.isVoid(o,d)))break;a&&f.reverse(),yield*f}})()})(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]:{};D.withoutNormalizing(o,(()=>{var{at:s=o.selection,mode:a="lowest",voids:u=!1}=i,{match:l}=i;if(l==null&&(l=R.isPath(s)?Yr(o,s):I=>le.isElement(I)&&D.isBlock(o,I)),s){var f=D.nodes(o,{at:s,match:l,mode:a,voids:u}),c=Array.from(f,(I=>{var[,T]=I;return D.pathRef(o,T)}));for(var d of c){var h=d.unref();if(h.length<2)throw new Error("Cannot lift node at a path [".concat(h,"] because it has a depth of less than `2`."));var g=D.node(o,R.parent(h)),[y,p]=g,w=h[h.length-1],{length:b}=y.children;if(b===1){var C=R.next(p);z.moveNodes(o,{at:h,to:C,voids:u}),z.removeNodes(o,{at:p,voids:u})}else if(w===0)z.moveNodes(o,{at:h,to:p,voids:u});else if(w===b-1){var E=R.next(p);z.moveNodes(o,{at:h,to:E,voids:u})}else{var A=R.next(h),x=R.next(p);z.splitNodes(o,{at:A,voids:u}),z.moveNodes(o,{at:h,to:x,voids:u})}}}}))})(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]:{};D.withoutNormalizing(o,(()=>{var{match:s,at:a=o.selection}=i,{hanging:u=!1,voids:l=!1,mode:f="lowest"}=i;if(a){if(s==null)if(R.isPath(a)){var[c]=D.parent(o,a);s=M=>c.children.includes(M)}else s=M=>le.isElement(M)&&D.isBlock(o,M);if(!u&&U.isRange(a)&&(a=D.unhangRange(o,a,{voids:l})),U.isRange(a))if(U.isCollapsed(a))a=a.anchor;else{var[,d]=U.edges(a),h=D.pointRef(o,d);z.delete(o,{at:a}),a=h.unref(),i.at==null&&z.select(o,a)}var[g]=D.nodes(o,{at:a,match:s,voids:l,mode:f}),y=D.previous(o,{at:a,match:s,voids:l,mode:f});if(g&&y){var[p,w]=g,[b,C]=y;if(w.length!==0&&C.length!==0){var E,A,x=R.next(C),I=R.common(w,C),T=R.isSibling(w,C),F=Array.from(D.levels(o,{at:w}),(M=>{var[H]=M;return H})).slice(I.length).slice(0,-1),S=D.above(o,{at:w,mode:"highest",match:M=>F.includes(M)&&Vg(o,M)}),k=S&&D.pathRef(o,S[1]);if(he.isText(p)&&he.isText(b)){var _=Mn(p,JE);A=b.text.length,E=_}else{if(!le.isElement(p)||!le.isElement(b))throw new Error("Cannot merge the node at path [".concat(w,"] with the previous sibling because it is not the same kind: ").concat(ht.stringify(p)," ").concat(ht.stringify(b)));_=Mn(p,ZE),A=b.children.length,E=_}T||z.moveNodes(o,{at:w,to:x,voids:l}),k&&z.removeNodes(o,{at:k.current,voids:l}),D.shouldMergeNodesRemovePrevNode(o,y,g)?z.removeNodes(o,{at:C,voids:l}):o.apply({type:"merge_node",path:x,position:A,properties:E}),k&&k.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:s}=o,{distance:a=1,unit:u="character",reverse:l=!1}=i,{edge:f=null}=i;if(s){f==="start"&&(f=U.isBackward(s)?"focus":"anchor"),f==="end"&&(f=U.isBackward(s)?"anchor":"focus");var{anchor:c,focus:d}=s,h={distance:a,unit:u,ignoreNonSelectable:!0},g={};if(f==null||f==="anchor"){var y=l?D.before(o,c,h):D.after(o,c,h);y&&(g.anchor=y)}if(f==null||f==="focus"){var p=l?D.before(o,d,h):D.after(o,d,h);p&&(g.focus=p)}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)=>{D.withoutNormalizing(o,(()=>{var{to:s,at:a=o.selection,mode:u="lowest",voids:l=!1}=i,{match:f}=i;if(a){f==null&&(f=R.isPath(a)?Yr(o,a):w=>le.isElement(w)&&D.isBlock(o,w));var c=D.pathRef(o,s),d=D.nodes(o,{at:a,match:f,mode:u,voids:l}),h=Array.from(d,(w=>{var[,b]=w;return D.pathRef(o,b)}));for(var g of h){var y=g.unref(),p=c.current;y.length!==0&&o.apply({type:"move_node",path:y,newPath:p}),c.current&&R.isSibling(p,y)&&R.isAfter(p,y)&&(c.current=R.next(c.current))}c.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:s="lowest",voids:a=!1}=i,{match:u,at:l=o.selection}=i;if(l){var f=D.after(o,l,{voids:a});if(f){var[,c]=D.last(o,[]),d=[f.path,c];if(R.isPath(l)&&l.length===0)throw new Error("Cannot get the next node from the root node!");if(u==null)if(R.isPath(l)){var[h]=D.parent(o,l);u=y=>h.children.includes(y)}else u=()=>!0;var[g]=D.nodes(o,{at:d,match:u,mode:s,voids:a});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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s),u=ee.get(o,a);return[u,a]})(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:s=o.selection,mode:a="all",universal:u=!1,reverse:l=!1,voids:f=!1,ignoreNonSelectable:c=!1}=i,{match:d}=i;if(d||(d=()=>!0),s){var h,g;if(mE.isSpan(s))h=s[0],g=s[1];else{var y=D.path(o,s,{edge:"start"}),p=D.path(o,s,{edge:"end"});h=l?p:y,g=l?y:p}var w,b=ee.nodes(o,{reverse:l,from:h,to:g,pass:T=>{var[F]=T;return!(!le.isElement(F)||(f||!D.isVoid(o,F)&&!D.isElementReadOnly(o,F))&&(!c||D.isSelectable(o,F)))}}),C=[];for(var[E,A]of b)if(!c||!le.isElement(E)||D.isSelectable(o,E)){var x=w&&R.compare(A,w[1])===0;if(a!=="highest"||!x){if(d(E,A))if(a==="lowest"&&x)w=[E,A];else{var I=a==="lowest"?w:[E,A];I&&(u?C.push(I):yield I),w=[E,A]}else if(u&&!x&&he.isText(E))return}}a==="lowest"&&w&&(u?C.push(w):yield w),u&&(yield*C)}})()})(e,...n)},normalize:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return zE(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s),u=R.parent(a);return D.node(o,u)})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:a,edge:u}=s;if(R.isPath(i)){if(u==="start"){var[,l]=ee.first(o,i);i=l}else if(u==="end"){var[,f]=ee.last(o,i);i=f}}return U.isRange(i)&&(i=u==="start"?U.start(i):u==="end"?U.end(i):R.common(i.anchor.path,i.focus.path)),_e.isPoint(i)&&(i=i.path),a!=null&&(i=i.slice(0,a)),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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:l}=u;return D.pathRefs(o).delete(u),u.current=null,l}};return D.pathRefs(o).add(u),u})(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=sf.get(o);return i||(i=new Set,sf.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:a="start"}=s;if(R.isPath(i)){var u;if(a==="end"){var[,l]=ee.last(o,i);u=l}else{var[,f]=ee.first(o,i);u=f}var c=ee.get(o,u);if(!he.isText(c))throw new Error("Cannot get the ".concat(a," point in the node at path [").concat(i,"] because it has no ").concat(a," text node."));return{path:u,offset:a==="end"?c.text.length:0}}if(U.isRange(i)){var[d,h]=U.edges(i);return a==="start"?d:h}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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:l}=u;return D.pointRefs(o).delete(u),u.current=null,l}};return D.pointRefs(o).add(u),u})(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=af.get(o);return i||(i=new Set,af.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 KE(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:s="lowest",voids:a=!1}=i,{match:u,at:l=o.selection}=i;if(l){var f=D.before(o,l,{voids:a});if(f){var[,c]=D.first(o,[]),d=[f.path,c];if(R.isPath(l)&&l.length===0)throw new Error("Cannot get the previous node from the root node!");if(u==null)if(R.isPath(l)){var[h]=D.parent(o,l);u=y=>h.children.includes(y)}else u=()=>!0;var[g]=D.nodes(o,{reverse:!0,at:d,match:u,mode:s,voids:a});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,s)=>U.isRange(i)&&!s?i:{anchor:D.start(o,i),focus:D.end(o,s||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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:l}=u;return D.rangeRefs(o).delete(u),u.current=null,l}};return D.rangeRefs(o).add(u),u})(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=uf.get(o);return i||(i=new Set,uf.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]:{};D.withoutNormalizing(o,(()=>{var{hanging:s=!1,voids:a=!1,mode:u="lowest"}=i,{at:l=o.selection,match:f}=i;if(l){f==null&&(f=R.isPath(l)?Yr(o,l):p=>le.isElement(p)&&D.isBlock(o,p)),!s&&U.isRange(l)&&(l=D.unhangRange(o,l,{voids:a}));var c=D.nodes(o,{at:l,match:f,mode:u,voids:a}),d=Array.from(c,(p=>{var[,w]=p;return D.pathRef(o,w)}));for(var h of d){var g=h.unref();if(g){var[y]=D.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:s}=o;if(i=D.range(o,i),s)z.setSelection(o,i);else{if(!U.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(ht.stringify(i)));o.apply({type:"set_selection",properties:s,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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{match:a,at:u=o.selection,compare:l,merge:f}=s,{hanging:c=!1,mode:d="lowest",split:h=!1,voids:g=!1}=s;if(u){if(a==null&&(a=R.isPath(u)?Yr(o,u):k=>le.isElement(k)&&D.isBlock(o,k)),!c&&U.isRange(u)&&(u=D.unhangRange(o,u,{voids:g})),h&&U.isRange(u)){if(U.isCollapsed(u)&&D.leaf(o,u.anchor)[0].text.length>0)return;var y=D.rangeRef(o,u,{affinity:"inward"}),[p,w]=U.edges(u),b=d==="lowest"?"lowest":"highest",C=D.isEnd(o,w,w.path);z.splitNodes(o,{at:w,match:a,mode:b,voids:g,always:!C});var E=D.isStart(o,p,p.path);z.splitNodes(o,{at:p,match:a,mode:b,voids:g,always:!E}),u=y.unref(),s.at==null&&z.select(o,u)}for(var[A,x]of(l||(l=(k,_)=>k!==_),D.nodes(o,{at:u,match:a,mode:d,voids:g}))){var I={},T={};if(x.length!==0){var F=!1;for(var S in i)S!=="children"&&S!=="text"&&l(i[S],A[S])&&(F=!0,A.hasOwnProperty(S)&&(I[S]=A[S]),f?i[S]!=null&&(T[S]=f(A[S],i[S])):i[S]!=null&&(T[S]=i[S]));F&&o.apply({type:"set_node",path:x,properties:I,newProperties:T})}}}}))})(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)=>{of.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:a}=o,{edge:u="both"}=s;if(a){u==="start"&&(u=U.isBackward(a)?"focus":"anchor"),u==="end"&&(u=U.isBackward(a)?"anchor":"focus");var{anchor:l,focus:f}=a,c=u==="anchor"?l:f;z.setSelection(o,{[u==="anchor"?"anchor":"focus"]:Rf(Rf({},c),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:s}=o,a={},u={};if(s){for(var l in i)(l==="anchor"&&i.anchor!=null&&!_e.equals(i.anchor,s.anchor)||l==="focus"&&i.focus!=null&&!_e.equals(i.focus,s.focus)||l!=="anchor"&&l!=="focus"&&i[l]!==s[l])&&(a[l]=s[l],u[l]=i[l]);Object.keys(a).length>0&&o.apply({type:"set_selection",properties:a,newProperties:u})}})(e,...n)},splitNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return XE(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)=>D.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:a=!1}=s,u=D.range(o,i),[l,f]=U.edges(u),c="";for(var[d,h]of D.nodes(o,{at:u,match:he.isText,voids:a})){var g=d.text;R.equals(h,f.path)&&(g=g.slice(0,f.offset)),R.equals(h,l.path)&&(g=g.slice(l.offset)),c+=g}return c})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:a=!1}=s,[u,l]=U.edges(i);if(u.offset!==0||l.offset!==0||U.isCollapsed(i)||R.hasPrevious(l.path))return i;var f=D.above(o,{at:l,match:p=>le.isElement(p)&&D.isBlock(o,p),voids:a}),c=f?f[1]:[],d={anchor:D.start(o,u),focus:l},h=!0;for(var[g,y]of D.nodes(o,{at:d,match:he.isText,reverse:!0,voids:a}))if(h)h=!1;else if(g.text!==""||R.isBefore(y,c)){l={path:y,offset:g.text.length};break}return{anchor:u,focus:l}})(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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(i)||(i=[i]);var a={};for(var u of i)a[u]=null;z.setNodes(o,a,s)})(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]:{};D.withoutNormalizing(o,(()=>{var{mode:s="lowest",split:a=!1,voids:u=!1}=i,{at:l=o.selection,match:f}=i;if(l){f==null&&(f=R.isPath(l)?Yr(o,l):p=>le.isElement(p)&&D.isBlock(o,p)),R.isPath(l)&&(l=D.range(o,l));var c=U.isRange(l)?D.rangeRef(o,l):null,d=D.nodes(o,{at:l,match:f,mode:s,voids:u}),h=Array.from(d,(p=>{var[,w]=p;return D.pathRef(o,w)})).reverse(),g=function(){var p=y.unref(),[w]=D.node(o,p),b=D.range(o,p);a&&c&&(b=U.intersection(c.current,b)),z.liftNodes(o,{at:b,match:C=>le.isAncestor(w)&&w.children.includes(C),voids:u})};for(var y of h)g();c&&c.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 D.above(o,Tf(Tf({},i),{},{match:s=>le.isElement(s)&&D.isVoid(o,s)}))})(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 s=D.isNormalizing(o);D.setNormalizing(o,!1);try{i()}finally{D.setNormalizing(o,s)}D.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 s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{mode:a="lowest",split:u=!1,voids:l=!1}=s,{match:f,at:c=o.selection}=s;if(c){if(f==null&&(f=R.isPath(c)?Yr(o,c):o.isInline(i)?b=>le.isElement(b)&&D.isInline(o,b)||he.isText(b):b=>le.isElement(b)&&D.isBlock(o,b)),u&&U.isRange(c)){var[d,h]=U.edges(c),g=D.rangeRef(o,c,{affinity:"inward"});z.splitNodes(o,{at:h,match:f,voids:l}),z.splitNodes(o,{at:d,match:f,voids:l}),c=g.unref(),s.at==null&&z.select(o,c)}var y=Array.from(D.nodes(o,{at:c,match:o.isInline(i)?b=>le.isElement(b)&&D.isBlock(o,b):b=>D.isEditor(b),mode:"lowest",voids:l})),p=function(){var b=U.isRange(c)?U.intersection(c,D.range(o,w)):c;if(!b)return 0;var C=Array.from(D.nodes(o,{at:b,match:f,mode:a,voids:l}));if(C.length>0){var[E]=C,A=C[C.length-1],[,x]=E,[,I]=A;if(x.length===0&&I.length===0)return 0;var T=R.equals(x,I)?R.parent(x):R.common(x,I),F=D.range(o,x,I),S=D.node(o,T),[k]=S,_=T.length+1,M=R.next(I.slice(0,_)),H=jf(jf({},i),{},{children:[]});z.insertNodes(o,H,{at:M,voids:l}),z.moveNodes(o,{at:F,match:W=>le.isAncestor(k)&&k.children.includes(W),to:M.concat(0),voids:l})}};for(var[,w]of y)p()}}))})(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[s,a]=i;return le.isElement(s)&&D.isEmpty(o,s)||he.isText(s)&&s.text===""&&a[a.length-1]!==0})(e,...n)}};return e},YE={isHistory:e=>ft(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||ur.isOperationList(e.redos[0].operations))&&(e.undos.length===0||ur.isOperationList(e.undos[0].operations))},La=new WeakMap,wr=new WeakMap,ns=new WeakMap,bn={isHistoryEditor:e=>YE.isHistory(e.history)&&D.isEditor(e),isMerging:e=>wr.get(e),isSplittingOnce:e=>ns.get(e),setSplittingOnce(e,t){ns.set(e,t)},isSaving:e=>La.get(e),redo(e){e.redo()},undo(e){e.undo()},withMerging(e,t){var n=bn.isMerging(e);wr.set(e,!0),t(),wr.set(e,n)},withNewBatch(e,t){var n=bn.isMerging(e);wr.set(e,!0),ns.set(e,!0),t(),wr.set(e,n),ns.delete(e)},withoutMerging(e,t){var n=bn.isMerging(e);wr.set(e,!1),t(),wr.set(e,n)},withoutSaving(e,t){var n=bn.isSaving(e);La.set(e,!1),t(),La.set(e,n)}},QE=(e,t)=>!(!t||e.type!=="insert_text"||t.type!=="insert_text"||e.offset!==t.offset+t.text.length||!R.equals(e.path,t.path))||!(!t||e.type!=="remove_text"||t.type!=="remove_text"||e.offset+e.text.length!==t.offset||!R.equals(e.path,t.path)),eD=(e,t)=>e.type!=="set_selection",tD=(function(){if(Mf)return Na;Mf=1,Na=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 Na})();const Wg=Tv(tD),Pf=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Nf=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",Ua=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Nf(n.overflowY,t)||Nf(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},rs=(e,t,n,r,o,i,s,a)=>i<e&&s>t||i>e&&s<t?0:i<=e&&a<=n||s>=t&&a>=n?i-e-r:s>t&&a<n||i<e&&a>n?s-t+o:0,nD=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},Lf=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:u,boundary:l,skipOverflowHiddenElements:f}=t,c=typeof l=="function"?l:G=>G!==l;if(!Pf(e))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,h=[];let g=e;for(;Pf(g)&&c(g);){if(g=nD(g),g===d){h.push(g);break}g!=null&&g===document.body&&Ua(g)&&!Ua(document.documentElement)||g!=null&&Ua(g,f)&&h.push(g)}const y=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,p=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:w,scrollY:b}=window,{height:C,width:E,top:A,right:x,bottom:I,left:T}=e.getBoundingClientRect(),{top:F,right:S,bottom:k,left:_}=(G=>{const q=window.getComputedStyle(G);return{top:parseFloat(q.scrollMarginTop)||0,right:parseFloat(q.scrollMarginRight)||0,bottom:parseFloat(q.scrollMarginBottom)||0,left:parseFloat(q.scrollMarginLeft)||0}})(e);let M=a==="start"||a==="nearest"?A-F:a==="end"?I+k:A+C/2-F+k,H=u==="center"?T+E/2-_+S:u==="end"?x+S:T-_;const W=[];for(let G=0;G<h.length;G++){const q=h[G],{height:$,width:V,top:Q,right:ae,bottom:ie,left:Se}=q.getBoundingClientRect();if(s==="if-needed"&&A>=0&&T>=0&&I<=p&&x<=y&&A>=Q&&I<=ie&&T>=Se&&x<=ae)return W;const Ie=getComputedStyle(q),ne=parseInt(Ie.borderLeftWidth,10),B=parseInt(Ie.borderTopWidth,10),X=parseInt(Ie.borderRightWidth,10),K=parseInt(Ie.borderBottomWidth,10);let Y=0,de=0;const pe="offsetWidth"in q?q.offsetWidth-q.clientWidth-ne-X:0,fe="offsetHeight"in q?q.offsetHeight-q.clientHeight-B-K:0,we="offsetWidth"in q?q.offsetWidth===0?0:V/q.offsetWidth:0,Ce="offsetHeight"in q?q.offsetHeight===0?0:$/q.offsetHeight:0;if(d===q)Y=a==="start"?M:a==="end"?M-p:a==="nearest"?rs(b,b+p,p,B,K,b+M,b+M+C,C):M-p/2,de=u==="start"?H:u==="center"?H-y/2:u==="end"?H-y:rs(w,w+y,y,ne,X,w+H,w+H+E,E),Y=Math.max(0,Y+b),de=Math.max(0,de+w);else{Y=a==="start"?M-Q-B:a==="end"?M-ie+K+fe:a==="nearest"?rs(Q,ie,$,B,K+fe,M,M+C,C):M-(Q+$/2)+fe/2,de=u==="start"?H-Se-ne:u==="center"?H-(Se+V/2)+pe/2:u==="end"?H-ae+X+pe:rs(Se,ae,V,ne,X+pe,H,H+E,E);const{scrollLeft:se,scrollTop:te}=q;Y=Ce===0?0:Math.max(0,Math.min(te+Y/Ce,q.scrollHeight-$/Ce+fe)),de=we===0?0:Math.max(0,Math.min(se+de/we,q.scrollWidth-V/we+pe)),M+=te-Y,H+=se-de}W.push({el:q,top:Y,left:de})}return W};function rD(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(Lf(e,t));const r=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:o,top:i,left:s}of Lf(e,(a=>a===!1?{block:"end",inline:"nearest"}:(u=>u===Object(u)&&Object.keys(u).length!==0)(a)?a:{block:"start",inline:"nearest"})(t))){const a=i-n.top+n.bottom,u=s-n.left+n.right;o.scroll({top:a,left:u,behavior:r})}}var wi,Pr=[],Uf="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"})(wi||(wi={}));var Ha,Hf,Nr=function(e){return Object.freeze(e)},oD=function(e,t){this.inlineSize=e,this.blockSize=t,Nr(this)},zg=(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,Nr(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})(),al=function(e){return e instanceof SVGElement&&"getBBox"in e},Kg=function(e){if(al(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||e.getClientRects().length)},Vf=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)},ai=typeof window<"u"?window:{},os=new WeakMap,$f=/auto|scroll/,iD=/^tb|vertical/,sD=/msie|trident/i.test(ai.navigator&&ai.navigator.userAgent),vn=function(e){return parseFloat(e||"0")},vo=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new oD((n?t:e)||0,(n?e:t)||0)},Wf=Nr({devicePixelContentBoxSize:vo(),borderBoxSize:vo(),contentBoxSize:vo(),contentRect:new zg(0,0,0,0)}),qg=function(e,t){if(t===void 0&&(t=!1),os.has(e)&&!t)return os.get(e);if(Kg(e))return os.set(e,Wf),Wf;var n=getComputedStyle(e),r=al(e)&&e.ownerSVGElement&&e.getBBox(),o=!sD&&n.boxSizing==="border-box",i=iD.test(n.writingMode||""),s=!r&&$f.test(n.overflowY||""),a=!r&&$f.test(n.overflowX||""),u=r?0:vn(n.paddingTop),l=r?0:vn(n.paddingRight),f=r?0:vn(n.paddingBottom),c=r?0:vn(n.paddingLeft),d=r?0:vn(n.borderTopWidth),h=r?0:vn(n.borderRightWidth),g=r?0:vn(n.borderBottomWidth),y=c+l,p=u+f,w=(r?0:vn(n.borderLeftWidth))+h,b=d+g,C=a?e.offsetHeight-b-e.clientHeight:0,E=s?e.offsetWidth-w-e.clientWidth:0,A=o?y+w:0,x=o?p+b:0,I=r?r.width:vn(n.width)-A-E,T=r?r.height:vn(n.height)-x-C,F=I+y+E+w,S=T+p+C+b,k=Nr({devicePixelContentBoxSize:vo(Math.round(I*devicePixelRatio),Math.round(T*devicePixelRatio),i),borderBoxSize:vo(F,S,i),contentBoxSize:vo(I,T,i),contentRect:new zg(c,u,I,T)});return os.set(e,k),k},Gg=function(e,t,n){var r=qg(e,n),o=r.borderBoxSize,i=r.contentBoxSize,s=r.devicePixelContentBoxSize;switch(t){case wi.DEVICE_PIXEL_CONTENT_BOX:return s;case wi.BORDER_BOX:return o;default:return i}},aD=function(e){var t=qg(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Nr([t.borderBoxSize]),this.contentBoxSize=Nr([t.contentBoxSize]),this.devicePixelContentBoxSize=Nr([t.devicePixelContentBoxSize])},Jg=function(e){if(Kg(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},uD=function(){var e=1/0,t=[];Pr.forEach((function(o){if(o.activeTargets.length!==0){var i=[];o.activeTargets.forEach((function(s){var a=new aD(s.target),u=Jg(s.target);i.push(a),s.lastReportedSize=Gg(s.target,s.observedBox),u<e&&(e=u)})),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},zf=function(e){Pr.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(n){n.isActive()&&(Jg(n.target)>e?t.activeTargets.push(n):t.skippedTargets.push(n))}))}))},cD=function(){var e,t=0;for(zf(t);Pr.some((function(n){return n.activeTargets.length>0}));)t=uD(),zf(t);return Pr.some((function(n){return n.skippedTargets.length>0}))&&(typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:Uf}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=Uf),window.dispatchEvent(e)),t>0},Kf=[],lD=function(e){if(!Ha){var t=0,n=document.createTextNode("");new MutationObserver((function(){return Kf.splice(0).forEach((function(r){return r()}))})).observe(n,{characterData:!0}),Ha=function(){n.textContent="".concat(t?t--:t++)}}Kf.push(e),Ha()},Lu=0,dD={attributes:!0,characterData:!0,childList:!0,subtree:!0},qf=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Gf=function(e){return e===void 0&&(e=0),Date.now()+e},Va=!1,Uu=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),!Va){Va=!0;var r,o=Gf(t);r=function(){var i=!1;try{i=cD()}finally{if(Va=!1,t=o-Gf(),!Lu)return;i?n.run(1e3):t>0?n.run(t):n.start()}},lD((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,dD)};document.body?n():ai.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),qf.forEach((function(n){return ai.addEventListener(n,t.listener,!0)})))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),qf.forEach((function(n){return ai.removeEventListener(n,t.listener,!0)})),this.stopped=!0)},e})()),Jf=function(e){!Lu&&e>0&&Uu.start(),!(Lu+=e)&&Uu.stop()},fD=(function(){function e(t,n){this.target=t,this.observedBox=n||wi.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=Gg(this.target,this.observedBox,!0);return(function(n){return!al(n)&&!(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})(n)&&getComputedStyle(n).display==="inline"})(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e})(),hD=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},is=new WeakMap,Zf=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},ss=(function(){function e(){}return e.connect=function(t,n){var r=new hD(t,n);is.set(t,r)},e.observe=function(t,n,r){var o=is.get(t),i=o.observationTargets.length===0;Zf(o.observationTargets,n)<0&&(i&&Pr.push(o),o.observationTargets.push(new fD(n,r&&r.box)),Jf(1),Uu.schedule())},e.unobserve=function(t,n){var r=is.get(t),o=Zf(r.observationTargets,n),i=r.observationTargets.length===1;o>=0&&(i&&Pr.splice(Pr.indexOf(r),1),r.observationTargets.splice(o,1),Jf(-1))},e.disconnect=function(t){var n=this,r=is.get(t);r.observationTargets.slice().forEach((function(o){return n.unobserve(t,o.target)})),r.activeTargets.splice(0,r.activeTargets.length)},e})(),pD=(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.");ss.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(!Vf(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");ss.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(!Vf(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");ss.unobserve(this,t)},e.prototype.disconnect=function(){ss.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e})(),tn={},$a=(function(){if(Hf)return tn;Hf=1,Object.defineProperty(tn,"__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(f,c,d){c&&!("byKey"in c)&&(d=c,c=null),Array.isArray(f)||(f=[f]);var h=f.map((function(y){return s(y,c)})),g=function(y){return h.some((function(p){return a(p,y)}))};return d==null?g:g(d)}function s(f,c){var d=c&&c.byKey,h={},g=(f=f.replace("++","+add")).split("+"),y=g.length;for(var p in t)h[t[p]]=!1;var w=!0,b=!1,C=void 0;try{for(var E,A=g[Symbol.iterator]();!(w=(E=A.next()).done);w=!0){var x=E.value,I=x.endsWith("?")&&x.length>1;I&&(x=x.slice(0,-1));var T=l(x),F=t[T];if(x.length>1&&!F&&!n[x]&&!r[T])throw new TypeError('Unknown modifier: "'+x+'"');y!==1&&F||(d?h.key=T:h.which=u(x)),F&&(h[F]=!I||null)}}catch(S){b=!0,C=S}finally{try{!w&&A.return&&A.return()}finally{if(b)throw C}}return h}function a(f,c){for(var d in f){var h=f[d],g=void 0;if(h!=null&&((g=d==="key"&&c.key!=null?c.key.toLowerCase():d==="which"?h===91&&c.which===93?91:c.which:c[d])!=null||h!==!1)&&g!==h)return!1}return!0}function u(f){return f=l(f),r[f]||f.toUpperCase().charCodeAt(0)}function l(f){return f=f.toLowerCase(),f=n[f]||f}return tn.default=i,tn.isHotkey=i,tn.isCodeHotkey=function(f,c){return i(f,c)},tn.isKeyHotkey=function(f,c){return i(f,{byKey:!0},c)},tn.parseHotkey=s,tn.compareHotkey=a,tn.toKeyCode=u,tn.toKeyName=l,tn})();function Io(e,t){if(e==null)return{};var n,r,o=(function(s,a){if(s==null)return{};var u,l,f={},c=Object.keys(s);for(l=0;l<c.length;l++)u=c[l],a.indexOf(u)>=0||(f[u]=s[u]);return f})(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 ui(e){return ui=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},ui(e)}function mD(e){var t=(function(n,r){if(ui(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(ui(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return ui(t)==="symbol"?t:String(t)}function Qt(e,t,n){return(t=mD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Wa,za,ul=m.createContext(null),Tn=()=>{var e=m.useContext(ul);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},Zg=parseInt(Be.version.split(".")[0],10),Xg=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Xf=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),It=typeof navigator<"u"&&/Android/.test(navigator.userAgent),lo=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Dr=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),gD=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),Yg=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),vD=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),yD=It&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),bD=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),CD=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),wD=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent),ps=!(typeof window>"u"||window.document===void 0||window.document.createElement===void 0);typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&(Wa=navigator.userAgent.match(/Version\/(\d+)/))!==null&&Wa!==void 0&&Wa[1]&&parseInt((za=navigator.userAgent.match(/Version\/(\d+)/))===null||za===void 0?void 0:za[1],10);var er=(!vD||!yD)&&!gD&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function",yo=new WeakMap,cl=new WeakMap,ll=new WeakMap,Qg=new WeakMap,ms=new WeakMap,Hu=new WeakMap,Ei=new WeakMap,Lr=new WeakMap,js=new WeakMap,Qs=new WeakMap,Vu=new WeakMap,cr=new WeakMap,Rr=new WeakMap,ci=new WeakMap,$u=new WeakMap,dl=new WeakMap,on=new WeakMap,Pn=new WeakMap,_t=new WeakMap,nr=new WeakMap,rr=new WeakMap,e0=new WeakMap,To=Symbol("placeholder"),t0=Symbol("mark-placeholder"),n0=globalThis.Node,ED=globalThis.Text,fl=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,DD=e=>pr(e)&&e.nodeType===8,qt=e=>pr(e)&&e.nodeType===1,pr=e=>{var t=fl(e);return!!t&&e instanceof t.Node},Wu=e=>{var t=e&&e.anchorNode&&fl(e.anchorNode);return!!t&&e instanceof t.Selection},r0=e=>pr(e)&&e.nodeType===3,o0=(e,t,n)=>{for(var{childNodes:r}=e,o=r[t],i=t,s=!1,a=!1;(DD(o)||qt(o)&&o.childNodes.length===0||qt(o)&&o.getAttribute("contenteditable")==="false")&&(!s||!a);)i>=r.length?(s=!0,i=t-1,n="backward"):i<0?(a=!0,i=t+1,n="forward"):(o=r[i],t=i,i+=n==="forward"?1:-1);return[o,t]},AD=(e,t,n)=>{var[r]=o0(e,t,n);return r},i0=e=>{var t="";if(r0(e)&&e.nodeValue)return e.nodeValue;if(qt(e)){for(var n of Array.from(e.childNodes))t+=i0(n);var r=getComputedStyle(e).getPropertyValue("display");r!=="block"&&r!=="list"&&e.tagName!=="BR"||(t+=`
|
|
49
|
+
`)}return t},xD=/data-slate-fragment="(.+?)"/m,li=e=>e.getSelection!=null?e.getSelection():document.getSelection(),hl=(e,t,n)=>{var{target:r}=t;if(qt(r)&&r.matches('[contentEditable="false"]'))return!1;var{document:o}=Z.getWindow(e);if(o.contains(r))return Z.hasDOMNode(e,r,{editable:!0});var i=n.find((s=>{var{addedNodes:a,removedNodes:u}=s;for(var l of a)if(l===r||l.contains(r))return!0;for(var f of u)if(f===r||f.contains(r))return!0}));return!(!i||i===t)&&hl(e,i,n)},Yf=(e,t)=>!!(e.compareDocumentPosition(t)&n0.DOCUMENT_POSITION_PRECEDING),OD=0;class SD{constructor(){Qt(this,"id",void 0),this.id="".concat(OD++)}}var Z={androidPendingDiffs:e=>_t.get(e),androidScheduleFlush:e=>{var t;(t=dl.get(e))===null||t===void 0||t()},blur:e=>{var t=Z.toDOMNode(e,e),n=Z.findDocumentOrShadowRoot(e);cr.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{var{selection:t}=e,n=Z.findDocumentOrShadowRoot(e),r=li(n);r&&r.rangeCount>0&&r.removeAllRanges(),t&&z.deselect(e)},findDocumentOrShadowRoot:e=>{var t=Z.toDOMNode(e,e),n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},findEventRange:(e,t)=>{"nativeEvent"in t&&(t=t.nativeEvent);var{clientX:n,clientY:r,target:o}=t;if(n==null||r==null)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var i,s=Z.toSlateNode(e,t.target),a=Z.findPath(e,s);if(le.isElement(s)&&D.isVoid(e,s)){var u=o.getBoundingClientRect(),l=e.isInline(s)?n-u.left<u.left+u.width-n:r-u.top<u.top+u.height-r,f=D.point(e,a,{edge:l?"start":"end"}),c=l?D.before(e,f):D.after(e,f);if(c)return D.range(e,c)}var{document:d}=Z.getWindow(e);if(d.caretRangeFromPoint)i=d.caretRangeFromPoint(n,r);else{var h=d.caretPositionFromPoint(n,r);h&&((i=d.createRange()).setStart(h.offsetNode,h.offset),i.setEnd(h.offsetNode,h.offset))}if(!i)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));return Z.toSlateRange(e,i,{exactMatch:!1,suppressThrow:!1})},findKey:(e,t)=>{var n=js.get(t);return n||(n=new SD,js.set(t,n)),n},findPath:(e,t)=>{for(var n=[],r=t;;){var o=ll.get(r);if(o==null){if(D.isEditor(r))return n;break}var i=cl.get(r);if(i==null)break;n.unshift(i),r=o}throw new Error("Unable to find the path for Slate node: ".concat(ht.stringify(t)))},focus:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{retries:5};if(!cr.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((()=>{Z.focus(e,{retries:t.retries-1})}),10);else{var n=Z.toDOMNode(e,e),r=Z.findDocumentOrShadowRoot(e);if(r.activeElement!==n){if(e.selection&&r instanceof Document){var o=li(r),i=Z.toDOMRange(e,e.selection);o?.removeAllRanges(),o?.addRange(i)}e.selection||z.select(e,D.start(e,[])),cr.set(e,!0),n.focus({preventScroll:!0})}}}},getWindow:e=>{var t=Qg.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=Z.toDOMNode(e,e);try{n=qt(t)?t:t.parentElement}catch(s){if(s instanceof Error&&!s.message.includes('Permission denied to access property "nodeType"'))throw s}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)=>pr(t)&&Z.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{var{anchor:n,focus:r}=t;return D.hasPath(e,n.path)&&D.hasPath(e,r.path)},hasSelectableTarget:(e,t)=>Z.hasEditableTarget(e,t)||Z.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>pr(t)&&Z.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!Rr.get(e),isFocused:e=>!!cr.get(e),isReadOnly:e=>!!Vu.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(Vu.get(e))return!1;var n=Z.hasTarget(e,t)&&Z.toSlateNode(e,t);return le.isElement(n)&&D.isVoid(e,n)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{var n=Qs.get(e),r=D.isEditor(t)?ms.get(e):n?.get(Z.findKey(e,t));if(!r)throw new Error("Cannot resolve a DOM node from Slate node: ".concat(ht.stringify(t)));return r},toDOMPoint:(e,t)=>{var n,[r]=D.node(e,t.path),o=Z.toDOMNode(e,r);D.void(e,{at:t})&&(t={path:t.path,offset:0});for(var i=Array.from(o.querySelectorAll("[data-slate-string], [data-slate-zero-width]")),s=0,a=0;a<i.length;a++){var u=i[a],l=u.childNodes[0];if(l!=null&&l.textContent!=null){var{length:f}=l.textContent,c=u.getAttribute("data-slate-length"),d=s+(c==null?f:parseInt(c,10)),h=i[a+1];if(t.offset===d&&h!=null&&h.hasAttribute("data-slate-mark-placeholder")){var g,y=h.childNodes[0];n=[y instanceof ED?y:h,(g=h.textContent)!==null&&g!==void 0&&g.startsWith("\uFEFF")?1:0];break}if(t.offset<=d){n=[l,Math.min(f,Math.max(0,t.offset-s))];break}s=d}}if(!n)throw new Error("Cannot resolve a DOM point from Slate point: ".concat(ht.stringify(t)));return n},toDOMRange:(e,t)=>{var{anchor:n,focus:r}=t,o=U.isBackward(t),i=Z.toDOMPoint(e,n),s=U.isCollapsed(t)?i:Z.toDOMPoint(e,r),a=Z.getWindow(e).document.createRange(),[u,l]=o?s:i,[f,c]=o?i:s,d=!!(qt(u)?u:u.parentElement).getAttribute("data-slate-zero-width"),h=!!(qt(f)?f:f.parentElement).getAttribute("data-slate-zero-width");return a.setStart(u,d?1:l),a.setEnd(f,h?1:c),a},toSlateNode:(e,t)=>{var n=qt(t)?t:t.parentElement;n&&!n.hasAttribute("data-slate-node")&&(n=n.closest("[data-slate-node]"));var r=n?Ei.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,[s,a]=r?t:($=>{var[V,Q]=$;if(qt(V)&&V.childNodes.length){var ae=Q===V.childNodes.length,ie=ae?Q-1:Q;for([V,ie]=o0(V,ie,ae?"backward":"forward"),ae=ie<Q;qt(V)&&V.childNodes.length;){var Se=ae?V.childNodes.length-1:0;V=AD(V,Se,ae?"backward":"forward")}Q=ae&&V.textContent!=null?V.textContent.length:0}return[V,Q]})(t),u=s.parentNode,l=null,f=0;if(u){var c,d,h=Z.toDOMNode(e,e),g=u.closest('[data-slate-void="true"]'),y=g&&h.contains(g)?g:null,p=u.closest('[contenteditable="false"]'),w=p&&h.contains(p)?p:null,b=u.closest("[data-slate-leaf]"),C=null;if(b){if(l=b.closest('[data-slate-node="text"]')){var E=Z.getWindow(e).document.createRange();E.setStart(l,0),E.setEnd(s,a);var A=E.cloneContents();[...Array.prototype.slice.call(A.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(A.querySelectorAll("[contenteditable=false]"))].forEach(($=>{It&&!r&&$.hasAttribute("data-slate-zero-width")&&$.textContent.length>0&&$.textContext!=="\uFEFF"?$.textContent.startsWith("\uFEFF")&&($.textContent=$.textContent.slice(1)):$.parentNode.removeChild($)})),f=A.textContent.length,C=l}}else if(y){for(var x=y.querySelectorAll("[data-slate-leaf]"),I=0;I<x.length;I++){var T=x[I];if(Z.hasDOMNode(e,T)){b=T;break}}b?(l=b.closest('[data-slate-node="text"]'),f=(C=b).textContent.length,C.querySelectorAll("[data-slate-zero-width]").forEach(($=>{f-=$.textContent.length}))):f=1}else if(w){var F,S,k=$=>$?$.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],_=w.closest('[data-slate-node="element"]');i==="forward"?b=(F=[...k(_),...k(_?.nextElementSibling)].find(($=>((V,Q)=>!!(V.compareDocumentPosition(Q)&n0.DOCUMENT_POSITION_FOLLOWING))(w,$))))!==null&&F!==void 0?F:null:b=(S=[...k(_?.previousElementSibling),...k(_)].findLast(($=>Yf(w,$))))!==null&&S!==void 0?S:null,b&&(l=b.closest('[data-slate-node="text"]'),C=b,i==="forward"?f=0:(f=C.textContent.length,C.querySelectorAll("[data-slate-zero-width]").forEach(($=>{f-=$.textContent.length}))))}C&&f===C.textContent.length&&It&&C.getAttribute("data-slate-zero-width")==="z"&&(c=C.textContent)!==null&&c!==void 0&&c.startsWith("\uFEFF")&&(u.hasAttribute("data-slate-zero-width")||lo&&(d=C.textContent)!==null&&d!==void 0&&d.endsWith(`
|
|
50
50
|
|
|
51
51
|
`))&&f--}if(It&&!l&&!r){var M=u.hasAttribute("data-slate-node")?u:u.closest("[data-slate-node]");if(M&&Z.hasDOMNode(e,M,{editable:!0})){var H=Z.toSlateNode(e,M),{path:W,offset:G}=D.start(e,Z.findPath(e,H));return M.querySelector("[data-slate-leaf]")||(G=a),{path:W,offset:G}}}if(!l){if(o)return null;throw new Error("Cannot resolve a Slate point from DOM point: ".concat(t))}var q=Z.toSlateNode(e,l);return{path:Z.findPath(e,q),offset:f}},toSlateRange:(e,t,n)=>{var r,o,i,s,a,u,{exactMatch:l,suppressThrow:f}=n;if(Wu(t)?t.anchorNode:t.startContainer)if(Wu(t)){if(lo&&t.rangeCount>1){s=t.focusNode;var c=t.getRangeAt(0),d=t.getRangeAt(t.rangeCount-1);if(s instanceof HTMLTableRowElement&&c.startContainer instanceof HTMLTableRowElement&&d.startContainer instanceof HTMLTableRowElement){let A=function(x){return x.childElementCount>0?A(x.children[0]):x};var h=c.startContainer,g=d.startContainer,y=A(h.children[c.startOffset]),p=A(g.children[d.startOffset]);a=0,o=p.childNodes.length>0?p.childNodes[0]:p,s=y.childNodes.length>0?y.childNodes[0]:y,i=p instanceof HTMLElement?p.innerHTML.length:0}else c.startContainer===s?(o=d.endContainer,i=d.endOffset,a=c.startOffset):(o=c.startContainer,i=c.endOffset,a=d.startOffset)}else o=t.anchorNode,i=t.anchorOffset,s=t.focusNode,a=t.focusOffset;u=Yg&&(A=>{for(var x=A&&A.parentNode;x;){if(x.toString()==="[object ShadowRoot]")return!0;x=x.parentNode}return!1})(o)||lo?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed}else o=t.startContainer,i=t.startOffset,s=t.endContainer,a=t.endOffset,u=t.collapsed;if(o==null||s==null||i==null||a==null)throw new Error("Cannot resolve a Slate range from DOM range: ".concat(t));lo&&(r=s.textContent)!==null&&r!==void 0&&r.endsWith(`
|
|
52
52
|
|
|
53
|
-
`)&&a===s.textContent.length&&a--;var w=Z.toSlatePoint(e,[o,i],{exactMatch:l,suppressThrow:f});if(!w)return null;var b=
|
|
53
|
+
`)&&a===s.textContent.length&&a--;var w=Z.toSlatePoint(e,[o,i],{exactMatch:l,suppressThrow:f});if(!w)return null;var b=Yf(o,s)||o===s&&a<i,C=u?w:Z.toSlatePoint(e,[s,a],{exactMatch:l,suppressThrow:f,searchDirection:b?"forward":"backward"});if(!C)return null;var E={anchor:w,focus:C};return U.isExpanded(E)&&U.isForward(E)&&qt(s)&&D.void(e,{at:E.focus,mode:"highest"})&&(E=D.unhangRange(e,E,{voids:!0})),E}};function ID(e,t){var{path:n,diff:r}=t;if(!D.hasPath(e,n))return!1;var o=ee.get(e,n);if(!he.isText(o))return!1;if(r.start!==o.text.length||r.text.length===0)return o.text.slice(r.start,r.start+r.text.length)===r.text;var i=R.next(n);if(!D.hasPath(e,i))return!1;var s=ee.get(e,i);return he.isText(s)&&s.text.startsWith(r.text)}function Qf(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce(((o,i)=>o.slice(0,i.start)+i.text+o.slice(i.end)),e)}function eh(e,t){var{start:n,end:r,text:o}=t,i=e.slice(n,r),s=(function(l,f){for(var c=Math.min(l.length,f.length),d=0;d<c;d++)if(l.charAt(d)!==f.charAt(d))return d;return c})(i,o),a=(function(l,f,c){for(var d=Math.min(l.length,f.length,c),h=0;h<d;h++)if(l.charAt(l.length-h-1)!==f.charAt(f.length-h-1))return h;return d})(i,o,Math.min(i.length-s,o.length-s)),u={start:n+s,end:r-a,text:o.slice(s,o.length-a)};return u.start===u.end&&u.text.length===0?null:u}function TD(e){var{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}function zu(e,t){var{path:n,offset:r}=t;if(!D.hasPath(e,n))return null;var o=ee.get(e,n);if(!he.isText(o))return null;var i=D.above(e,{match:a=>le.isElement(a)&&D.isBlock(e,a),at:n});if(!i)return null;for(;r>o.text.length;){var s=D.next(e,{at:n,match:he.isText});if(!s||!R.isDescendant(s[1],i[1]))return null;r-=o.text.length,o=s[0],n=s[1]}return{path:n,offset:r}}function th(e,t){var n=zu(e,t.anchor);if(!n)return null;if(U.isCollapsed(t))return{anchor:n,focus:n};var r=zu(e,t.focus);return r?{anchor:n,focus:r}:null}function Ku(e,t,n){var r=_t.get(e),o=r?.find((f=>{var{path:c}=f;return R.equals(c,t.path)}));if(!o||t.offset<=o.diff.start)return _e.transform(t,n,{affinity:"backward"});var{diff:i}=o;if(t.offset<=i.start+i.text.length){var s={path:t.path,offset:i.start},a=_e.transform(s,n,{affinity:"backward"});return a?{path:a.path,offset:a.offset+t.offset-i.start}:null}var u={path:t.path,offset:t.offset-i.text.length+i.end-i.start},l=_e.transform(u,n,{affinity:"backward"});return l?n.type==="split_node"&&R.equals(n.path,t.path)&&u.offset<n.position&&i.start<n.position?l:{path:l.path,offset:l.offset+i.text.length-i.end+i.start}:null}function nh(e,t,n){var r=Ku(e,t.anchor,n);if(!r)return null;if(U.isCollapsed(t))return{anchor:r,focus:r};var o=Ku(e,t.focus,n);return o?{anchor:r,focus:o}:null}function rh(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 as(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?rh(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function kD(e){var{editor:t,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:r}=e,o=!1,i=null,s=null,a=null,u=0,l=!1,f=()=>{var C=rr.get(t);if(rr.delete(t),C){var{selection:E}=t,A=th(t,C);!A||E&&U.equals(A,E)||z.select(t,A)}},c=()=>{if(s&&(clearTimeout(s),s=null),a&&(clearTimeout(a),a=null),p()||y()){o||(o=!0,setTimeout((()=>o=!1))),y()&&(o="action");var C=t.selection&&D.rangeRef(t,t.selection,{affinity:"forward"});Pn.set(t,t.marks),nr.get(t),_t.get(t);for(var E,A=p();E=(x=_t.get(t))===null||x===void 0?void 0:x[0];){var x,I,T=on.get(t);T!==void 0&&(on.delete(t),t.marks=T),T&&l===!1&&(l=null);var F=TD(E);t.selection&&U.equals(t.selection,F)||z.select(t,F),E.diff.text?D.insertText(t,E.diff.text):D.deleteFragment(t),_t.set(t,(I=_t.get(t))===null||I===void 0?void 0:I.filter((_=>{var{id:M}=_;return M!==E.id}))),ID(t,E)||(A=!1,nr.delete(t),Pn.delete(t),o="action",rr.delete(t),n.cancel(),r.cancel(),C?.unref())}var S=C?.unref();if(!S||rr.get(t)||t.selection&&U.equals(S,t.selection)||z.select(t,S),y())(()=>{var _=nr.get(t);if(nr.delete(t),_){if(_.at){var M=_e.isPoint(_.at)?zu(t,_.at):th(t,_.at);if(!M)return;var H=D.range(t,M);t.selection&&U.equals(t.selection,H)||z.select(t,M)}_.run()}})();else{A&&n(),n.flush(),r.flush(),f();var k=Pn.get(t);Pn.delete(t),k!==void 0&&(t.marks=k,t.onChange())}}else f()},d=function(){var C=arguments.length>0&&arguments[0]!==void 0&&arguments[0],E=Hu.get(t);E&&(p()||C?E.style.display="none":E.style.removeProperty("display"))},h=(C,E)=>{var A,x=(A=_t.get(t))!==null&&A!==void 0?A:[];_t.set(t,x);var I=ee.leaf(t,C),T=x.findIndex((S=>R.equals(S.path,C)));if(T<0)return eh(I.text,E)&&x.push({path:C,diff:E,id:u++}),void d();var F=(function(S,k,_){var M=Math.min(k.start,_.start),H=Math.max(0,Math.min(k.start+k.text.length,_.end)-_.start),W=Qf(S,k,_),G=Math.max(_.start+_.text.length,k.start+k.text.length+(k.start+k.text.length>_.start?_.text.length:0)-H),q=W.slice(M,G);return eh(S,{start:M,end:Math.max(k.end,_.end-k.text.length+(k.end-k.start)),text:q})})(I.text,x[T].diff,E);if(!F)return x.splice(T,1),void d();x[T]=as(as({},x[T]),{},{diff:F})},g=function(C){var{at:E}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};l=!1,rr.delete(t),n.cancel(),r.cancel(),y()&&c(),nr.set(t,{at:E,run:C}),a=setTimeout(c)},y=()=>!!nr.get(t),p=()=>{var C;return!((C=_t.get(t))===null||C===void 0||!C.length)},w=C=>{rr.set(t,C),s&&(clearTimeout(s),s=null);var{selection:E}=t;if(C){var A=!E||!R.equals(E.anchor.path,C.anchor.path),x=!E||!R.equals(E.anchor.path.slice(0,-1),C.anchor.path.slice(0,-1));(A&&l||x)&&(l=!1),(A||p())&&(s=setTimeout(c,200))}},b=()=>{y()||(a=setTimeout(c))};return{flush:c,scheduleFlush:b,hasPendingDiffs:p,hasPendingAction:y,hasPendingChanges:()=>y()||p(),isFlushing:()=>o,handleUserSelect:w,handleCompositionEnd:C=>{i&&clearTimeout(i),i=setTimeout((()=>{Rr.set(t,!1),c()}),25)},handleCompositionStart:C=>{Rr.set(t,!0),i&&(clearTimeout(i),i=null)},handleDOMBeforeInput:C=>{var E;if(s&&(clearTimeout(s),s=null),!yo.get(t)){var{inputType:A}=C,x=null,I=C.dataTransfer||C.data||void 0;l!==!1&&A!=="insertText"&&A!=="insertCompositionText"&&(l=!1);var[T]=C.getTargetRanges();T&&(x=Z.toSlateRange(t,T,{exactMatch:!1,suppressThrow:!0}));var F=Z.getWindow(t).getSelection();if(!x&&F&&(T=F,x=Z.toSlateRange(t,F,{exactMatch:!1,suppressThrow:!0})),x=(E=x)!==null&&E!==void 0?E:t.selection){var S=!0;if(A.startsWith("delete")){if(U.isExpanded(x)){var[k,_]=U.edges(x);if(ee.leaf(t,k.path).text.length===k.offset&&_.offset===0){var M=D.next(t,{at:k.path,match:he.isText});M&&R.equals(M[1],_.path)&&(x={anchor:_,focus:_})}}var H=A.endsWith("Backward")?"backward":"forward",[W,G]=U.edges(x),[q,$]=D.leaf(t,W.path),V={text:"",start:W.offset,end:G.offset},Q=_t.get(t),ae=Q?.find((se=>R.equals(se.path,$))),ie=ae?[ae.diff,V]:[V];if(Qf(q.text,...ie).length===0&&(S=!1),U.isExpanded(x)){if(S&&R.equals(x.anchor.path,x.focus.path)){var Se={path:x.anchor.path,offset:W.offset},Ie=D.range(t,Se,Se);return w(Ie),h(x.anchor.path,{text:"",end:G.offset,start:W.offset})}return g((()=>D.deleteFragment(t,{direction:H})),{at:x})}}switch(A){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return g((()=>D.deleteFragment(t)),{at:x});case"deleteContent":case"deleteContentForward":var{anchor:ne}=x;if(S&&U.isCollapsed(x)){var B=ee.leaf(t,ne.path);if(ne.offset<B.text.length)return h(ne.path,{text:"",start:ne.offset,end:ne.offset+1})}return g((()=>D.deleteForward(t)),{at:x});case"deleteContentBackward":var X,{anchor:K}=x,Y=Wu(T)?T.isCollapsed:!((X=T)===null||X===void 0||!X.collapsed);return S&&Y&&U.isCollapsed(x)&&K.offset>0?h(K.path,{text:"",start:K.offset-1,end:K.offset}):g((()=>D.deleteBackward(t)),{at:x});case"deleteEntireSoftLine":return g((()=>{D.deleteBackward(t,{unit:"line"}),D.deleteForward(t,{unit:"line"})}),{at:x});case"deleteHardLineBackward":return g((()=>D.deleteBackward(t,{unit:"block"})),{at:x});case"deleteSoftLineBackward":return g((()=>D.deleteBackward(t,{unit:"line"})),{at:x});case"deleteHardLineForward":return g((()=>D.deleteForward(t,{unit:"block"})),{at:x});case"deleteSoftLineForward":return g((()=>D.deleteForward(t,{unit:"line"})),{at:x});case"deleteWordBackward":return g((()=>D.deleteBackward(t,{unit:"word"})),{at:x});case"deleteWordForward":return g((()=>D.deleteForward(t,{unit:"word"})),{at:x});case"insertLineBreak":return g((()=>D.insertSoftBreak(t)),{at:x});case"insertParagraph":return g((()=>D.insertBreak(t)),{at:x});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if((se=>se?.constructor.name==="DataTransfer")(I))return g((()=>Z.insertData(t,I)),{at:x});var de=I??"";if(on.get(t)&&(de=de.replace("\uFEFF","")),A==="insertText"&&/.*\n.*\n$/.test(de)&&(de=de.slice(0,-1)),de.includes(`
|
|
54
54
|
`))return g((()=>{var se=de.split(`
|
|
55
|
-
`);se.forEach(((te,me)=>{te&&D.insertText(t,te),me!==se.length-1&&D.insertSoftBreak(t)}))}),{at:x});if(R.equals(x.anchor.path,x.focus.path)){var[pe,fe]=U.edges(x),we={start:pe.offset,end:fe.offset,text:de};if(de&&l&&A==="insertCompositionText"){var Ce=l.start+l.text.search(/\S|$/);we.start+we.text.search(/\S|$/)===Ce+1&&we.end===l.start+l.text.length?(we.start-=1,l=null,b()):l=!1}else l=A==="insertText"&&(l===null?we:!(!l||!U.isCollapsed(x)||l.end+l.text.length!==pe.offset)&&as(as({},l),{},{text:l.text+de}));if(S)return void h(pe.path,we)}return g((()=>D.insertText(t,de)),{at:x})}}}},handleKeyDown:C=>{p()||(d(!0),setTimeout(d))},handleDomMutations:C=>{var E;p()||y()||C.some((A=>
|
|
56
|
-
`?Be.createElement(
|
|
57
|
-
`:""),[i]=m.useState(o);return Di((()=>{var s=o();r.current&&r.current.textContent!==s&&(r.current.textContent=s)})),Be.createElement(PD,{ref:r},i)},PD=m.memo(m.forwardRef(((e,t)=>Be.createElement("span",{"data-slate-string":!0,ref:t},e.children)))),Ka=e=>{var{length:t=0,isLineBreak:n=!1,isMarkPlaceholder:r=!1}=e,o={"data-slate-zero-width":n?"n":"z","data-slate-length":t};return r&&(o["data-slate-mark-placeholder"]=!0),Be.createElement("span",(function(i){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?sh(Object(a),!0).forEach((function(u){Qt(i,u,a[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):sh(Object(a)).forEach((function(u){Object.defineProperty(i,u,Object.getOwnPropertyDescriptor(a,u))}))}return i})({},o),(It||Xg)&&n?null:"\uFEFF",n?Be.createElement("br",null):null)};function uh(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 a0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?uh(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ND=It?300:0;function ch(e){e.current&&(clearTimeout(e.current),e.current=null)}var LD=e=>{var{leaf:t,isLast:n,text:r,parent:o,renderPlaceholder:i,renderLeaf:s=w=>Be.createElement(HD,a0({},w))}=e,a=Tn(),u=m.useRef(null),l=m.useRef(null),[f,c]=m.useState(!1),d=m.useRef(null),h=m.useCallback((w=>{if((function(E,A){E.current&&(E.current.disconnect(),A&&(E.current=null))})(u,w==null),w==null){var b;Hu.delete(a),(b=t.onPlaceholderResize)===null||b===void 0||b.call(t,null)}else{if(Hu.set(a,w),!u.current){var C=window.ResizeObserver||pD;u.current=new C((()=>{var E;(E=t.onPlaceholderResize)===null||E===void 0||E.call(t,w)}))}u.current.observe(w),l.current=w}}),[l,t,a]),g=Be.createElement(MD,{isLast:n,leaf:t,parent:o,text:r}),y=!!t[To];if(m.useEffect((()=>(y?d.current||(d.current=setTimeout((()=>{c(!0),d.current=null}),ND)):(ch(d),c(!1)),()=>ch(d))),[y,c]),y&&f){var p={children:t.placeholder,attributes:{"data-slate-placeholder":!0,style:{position:"absolute",top:0,pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",textDecoration:"none",WebkitUserModify:Dr?"inherit":void 0},contentEditable:!1,ref:h}};g=Be.createElement(Be.Fragment,null,i(p),g)}return s({attributes:{"data-slate-leaf":!0},children:g,leaf:t,text:r})},UD=Be.memo(LD,((e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&he.equals(t.leaf,e.leaf)&&t.leaf[To]===e.leaf[To])),HD=e=>{var{attributes:t,children:n}=e;return Be.createElement("span",a0({},t),n)},VD=e=>{for(var{decorations:t,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:i,text:s}=e,a=Tn(),u=m.useRef(null),l=he.decorations(s,t),f=Z.findKey(a,s),c=[],d=0;d<l.length;d++){var h=l[d];c.push(Be.createElement(UD,{isLast:n&&d===l.length-1,key:"".concat(f.id,"-").concat(d),renderPlaceholder:o,leaf:h,text:s,parent:r,renderLeaf:i}))}var g=m.useCallback((y=>{var p=Qs.get(a);y?(p?.set(f,y),Lr.set(s,y),Ei.set(y,s)):(p?.delete(f),Lr.delete(s),u.current&&Ei.delete(u.current)),u.current=y}),[u,a,f,s]);return Be.createElement("span",{"data-slate-node":"text",ref:g},c)},u0=Be.memo(VD,((e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&((n,r)=>{if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++){var i=n[o],s=r[o];if(i.anchor.offset!==s.anchor.offset||i.focus.offset!==s.focus.offset||!s0(i,s))return!1}return!0})(t.decorations,e.decorations)));function lh(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 qu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lh(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var $D=e=>{var{decorations:t,element:n,renderElement:r=b=>Be.createElement(zD,qu({},b)),renderPlaceholder:o,renderLeaf:i,selection:s}=e,a=Tn(),u=KD(),l=a.isInline(n),f=Z.findKey(a,n),c=m.useCallback((b=>{var C=Qs.get(a);b?(C?.set(f,b),Lr.set(n,b),Ei.set(b,n)):(C?.delete(f),Lr.delete(n))}),[a,f,n]),d=f0({decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:s}),h={"data-slate-node":"element",ref:c};if(l&&(h["data-slate-inline"]=!0),!l&&D.hasInlines(a,n)){var g=ee.string(n),y=Wg(g);y==="rtl"&&(h.dir=y)}if(D.isVoid(a,n)){h["data-slate-void"]=!0,!u&&l&&(h.contentEditable=!1);var p=l?"span":"div",[[w]]=ee.texts(n);d=Be.createElement(p,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},Be.createElement(u0,{renderPlaceholder:o,decorations:[],isLast:!1,parent:n,text:w})),ll.set(w,0),dl.set(w,n)}return r({attributes:h,children:d,element:n})},WD=Be.memo($D,((e,t)=>e.element===t.element&&e.renderElement===t.renderElement&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&((n,r)=>{if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++){var i=n[o],s=r[o];if(!U.equals(i,s)||!s0(i,s))return!1}return!0})(e.decorations,t.decorations)&&(e.selection===t.selection||!!e.selection&&!!t.selection&&U.equals(e.selection,t.selection)))),zD=e=>{var{attributes:t,children:n,element:r}=e,o=Tn().isInline(r)?"span":"div";return Be.createElement(o,qu(qu({},t),{},{style:{position:"relative"}}),n)},c0=m.createContext((()=>[])),l0=m.createContext(!1),d0=()=>m.useContext(l0),f0=e=>{var{decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:s}=e,a=m.useContext(c0),u=Tn();yo.set(u,!1);for(var l=Z.findPath(u,n),f=[],c=le.isElement(n)&&!u.isInline(n)&&D.hasInlines(u,n),d=0;d<n.children.length;d++){var h=l.concat(d),g=n.children[d],y=Z.findKey(u,g),p=D.range(u,h),w=s&&U.intersection(p,s),b=a([g,h]);for(var C of t){var E=U.intersection(C,p);E&&b.push(E)}le.isElement(g)?f.push(Be.createElement(l0.Provider,{key:"provider-".concat(y.id),value:!!w},Be.createElement(WD,{decorations:b,element:g,key:y.id,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:w}))):f.push(Be.createElement(u0,{decorations:b,key:y.id,isLast:c&&d===n.children.length-1,parent:n,renderPlaceholder:o,renderLeaf:i,text:g})),ll.set(g,d),dl.set(g,n)}return f},h0=m.createContext(!1),KD=()=>m.useContext(h0),p0=m.createContext(null),qD={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"left",moveForward:"right",moveWordBackward:"ctrl+left",moveWordForward:"ctrl+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",insertSoftBreak:"shift+enter",splitBlock:"enter",undo:"mod+z"},GD={moveLineBackward:"opt+up",moveLineForward:"opt+down",moveWordBackward:"opt+left",moveWordForward:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},JD={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Ge=e=>{var t=qD[e],n=GD[e],r=JD[e],o=t&&$a.isHotkey(t),i=n&&$a.isHotkey(n),s=r&&$a.isHotkey(r);return a=>!(!o||!o(a))||!!(Yf&&i&&i(a))||!(Yf||!s||!s(a))},Ze={isBold:Ge("bold"),isCompose:Ge("compose"),isMoveBackward:Ge("moveBackward"),isMoveForward:Ge("moveForward"),isDeleteBackward:Ge("deleteBackward"),isDeleteForward:Ge("deleteForward"),isDeleteLineBackward:Ge("deleteLineBackward"),isDeleteLineForward:Ge("deleteLineForward"),isDeleteWordBackward:Ge("deleteWordBackward"),isDeleteWordForward:Ge("deleteWordForward"),isExtendBackward:Ge("extendBackward"),isExtendForward:Ge("extendForward"),isExtendLineBackward:Ge("extendLineBackward"),isExtendLineForward:Ge("extendLineForward"),isItalic:Ge("italic"),isMoveLineBackward:Ge("moveLineBackward"),isMoveLineForward:Ge("moveLineForward"),isMoveWordBackward:Ge("moveWordBackward"),isMoveWordForward:Ge("moveWordForward"),isRedo:Ge("redo"),isSoftBreak:Ge("insertSoftBreak"),isSplitBlock:Ge("splitBlock"),isTransposeCharacter:Ge("transposeCharacter"),isUndo:Ge("undo")},ZD={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class m0 extends m.Component{constructor(){super(...arguments),Qt(this,"context",null),Qt(this,"manager",null),Qt(this,"mutationObserver",null)}observe(){var t,{node:n}=this.props;if(!n.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");(t=this.mutationObserver)===null||t===void 0||t.observe(n.current,ZD)}componentDidMount(){var{receivedUserInput:t}=this.props,n=this.context;this.manager=((r,o)=>{var i=[],s=()=>{i=[]};return{registerMutations:a=>{if(o.current){var u=a.filter((l=>pl(r,l,a)));i.push(...u)}},restoreDOM:function(){i.length>0&&(i.reverse().forEach((a=>{a.type!=="characterData"&&(a.removedNodes.forEach((u=>{a.target.insertBefore(u,a.nextSibling)})),a.addedNodes.forEach((u=>{a.target.removeChild(u)})))})),s())},clear:s}})(n,t),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var t,n,r,o,i=(t=this.mutationObserver)===null||t===void 0?void 0:t.takeRecords();return i!=null&&i.length&&((o=this.manager)===null||o===void 0||o.registerMutations(i)),(n=this.mutationObserver)===null||n===void 0||n.disconnect(),(r=this.manager)===null||r===void 0||r.restoreDOM(),null}componentDidUpdate(){var t;(t=this.manager)===null||t===void 0||t.clear(),this.observe()}componentWillUnmount(){var t;(t=this.mutationObserver)===null||t===void 0||t.disconnect()}render(){return this.props.children}}Qt(m0,"contextType",cl);var XD=It?m0:e=>{var{children:t}=e;return Be.createElement(Be.Fragment,null,t)},YD=m.createContext(!1),QD=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderLeaf","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],e2=["text"];function dh(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 yn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dh(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var t2=e=>Be.createElement(Be.Fragment,null,f0(e)),n2=m.forwardRef(((e,t)=>{var n=m.useCallback((B=>Be.createElement(r2,yn({},B))),[]),{autoFocus:r,decorate:o=o2,onDOMBeforeInput:i,placeholder:s,readOnly:a=!1,renderElement:u,renderLeaf:l,renderPlaceholder:f=n,scrollSelectionIntoView:c=i2,style:d={},as:h="div",disableDefaultStyles:g=!1}=e,y=Io(e,QD),p=(()=>{var B=m.useContext(p0);if(!B)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");var{editor:X}=B;return X})(),[w,b]=m.useState(!1),C=m.useRef(null),E=m.useRef([]),[A,x]=m.useState(),I=m.useRef(!1),{onUserInput:T,receivedUserInput:F}=(function(){var B=Tn(),X=m.useRef(!1),K=m.useRef(0),Y=m.useCallback((()=>{if(!X.current){X.current=!0;var de=Z.getWindow(B);de.cancelAnimationFrame(K.current),K.current=de.requestAnimationFrame((()=>{X.current=!1}))}}),[B]);return m.useEffect((()=>()=>cancelAnimationFrame(K.current)),[]),{receivedUserInput:X,onUserInput:Y}})(),[,S]=m.useReducer((B=>B+1),0);e0.set(p,S),Vu.set(p,a);var k=m.useMemo((()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1})),[]);m.useEffect((()=>{C.current&&r&&C.current.focus()}),[r]);var _=m.useRef(),M=m.useMemo((()=>Fv((()=>{if(yo.get(p))M();else{var B=Z.toDOMNode(p,p).getRootNode();if(!I.current&&Dr&&B instanceof ShadowRoot){I.current=!0;var X=(()=>{for(var Ae=document.activeElement;(Pe=Ae)!==null&&Pe!==void 0&&Pe.shadowRoot&&(Fe=Ae.shadowRoot)!==null&&Fe!==void 0&&Fe.activeElement;){var Pe,Fe,re;Ae=(re=Ae)===null||re===void 0||(re=re.shadowRoot)===null||re===void 0?void 0:re.activeElement}return Ae})();return X?document.execCommand("indent"):z.deselect(p),void(I.current=!1)}var K=_.current;if((It||!Z.isComposing(p))&&(!k.isUpdatingSelection||K!=null&&K.isFlushing())&&!k.isDraggingInternally){var Y=Z.findDocumentOrShadowRoot(p),{activeElement:de}=Y,pe=Z.toDOMNode(p,p),fe=li(Y);if(de===pe?(k.latestElement=de,cr.set(p,!0)):cr.delete(p),!fe)return z.deselect(p);var{anchorNode:we,focusNode:Ce}=fe,se=Z.hasEditableTarget(p,we)||Z.isTargetInsideNonReadonlyVoid(p,we),te=Z.hasTarget(p,Ce);if(se&&te){var me=Z.toSlateRange(p,fe,{exactMatch:!1,suppressThrow:!0});me&&(Z.isComposing(p)||K!=null&&K.hasPendingChanges()||K!=null&&K.isFlushing()?K?.handleUserSelect(me):z.select(p,me))}!a||se&&te||z.deselect(p)}}}),100)),[p,a,k]),H=m.useMemo((()=>Rv(M,0)),[M]);_.current=RD({node:C,onDOMSelectionChange:M,scheduleOnDOMSelectionChange:H}),Di((()=>{var B,X,K;C.current&&(K=hl(C.current))?(Qg.set(p,K),ms.set(p,C.current),Lr.set(p,C.current),Ei.set(C.current,p)):Lr.delete(p);var{selection:Y}=p,de=Z.findDocumentOrShadowRoot(p),pe=li(de);if(pe&&Z.isFocused(p)&&((B=_.current)===null||B===void 0||!B.hasPendingAction())){var fe=te=>{var me=pe.type!=="None";if(Y||me){var Ae,Pe=pe.focusNode;if(lo&&pe.rangeCount>1){var Fe=pe.getRangeAt(0),re=pe.getRangeAt(pe.rangeCount-1);Ae=Fe.startContainer===Pe?re.endContainer:Fe.startContainer}else Ae=pe.anchorNode;var J=ms.get(p),oe=!1;if(J.contains(Ae)&&J.contains(Pe)&&(oe=!0),me&&oe&&Y&&!te){var ge=Z.toSlateRange(p,pe,{exactMatch:!0,suppressThrow:!0});if(ge&&U.equals(ge,Y)){var ve;if(!k.hasMarkPlaceholder||(ve=Ae)!==null&&ve!==void 0&&(ve=ve.parentElement)!==null&&ve!==void 0&&ve.hasAttribute("data-slate-mark-placeholder"))return}}if(!Y||Z.hasRange(p,Y)){k.isUpdatingSelection=!0;var Te=Y&&Z.toDOMRange(p,Y);return Te?(Z.isComposing(p)&&!It?pe.collapseToEnd():U.isBackward(Y)?pe.setBaseAndExtent(Te.endContainer,Te.endOffset,Te.startContainer,Te.startOffset):pe.setBaseAndExtent(Te.startContainer,Te.startOffset,Te.endContainer,Te.endOffset),c(p,Te)):pe.removeAllRanges(),Te}p.selection=Z.toSlateRange(p,pe,{exactMatch:!1,suppressThrow:!0})}};pe.rangeCount<=1&&fe();var we=((X=_.current)===null||X===void 0?void 0:X.isFlushing())==="action";if(It&&we){var Ce=null,se=requestAnimationFrame((()=>{if(we){var te=me=>{try{Z.toDOMNode(p,p).focus(),fe(me)}catch{}};te(),Ce=setTimeout((()=>{te(!0),k.isUpdatingSelection=!1}))}}));return()=>{cancelAnimationFrame(se),Ce&&clearTimeout(Ce)}}setTimeout((()=>{k.isUpdatingSelection=!1}))}}));var W=m.useCallback((B=>{var X=Z.toDOMNode(p,p).getRootNode();if(I!=null&&I.current&&Dr&&X instanceof ShadowRoot){var K=B.getTargetRanges()[0],Y=new window.Range;Y.setStart(K.startContainer,K.startOffset),Y.setEnd(K.endContainer,K.endOffset);var de=Z.toSlateRange(p,Y,{exactMatch:!1,suppressThrow:!1});return z.select(p,de),B.preventDefault(),void B.stopImmediatePropagation()}if(T(),!a&&Z.hasEditableTarget(p,B.target)&&!s2(B,i)){var pe;if(_.current)return _.current.handleDOMBeforeInput(B);H.flush(),M.flush();var{selection:fe}=p,{inputType:we}=B,Ce=B.dataTransfer||B.data||void 0,se=we==="insertCompositionText"||we==="deleteCompositionText";if(se&&Z.isComposing(p))return;var te=!1;if(we==="insertText"&&fe&&U.isCollapsed(fe)&&B.data&&B.data.length===1&&/[a-z ]/i.test(B.data)&&fe.anchor.offset!==0&&(te=!0,p.marks&&(te=!1),!yo.get(p))){var me,Ae,{anchor:Pe}=fe,[Fe,re]=Z.toDOMPoint(p,Pe),J=(me=Fe.parentElement)===null||me===void 0?void 0:me.closest("a"),oe=Z.getWindow(p);if(te&&J&&Z.hasDOMNode(p,J)){var ge,ve=oe?.document.createTreeWalker(J,NodeFilter.SHOW_TEXT).lastChild();ve===Fe&&((ge=ve.textContent)===null||ge===void 0?void 0:ge.length)===re&&(te=!1)}if(te&&Fe.parentElement&&(oe==null||(Ae=oe.getComputedStyle(Fe.parentElement))===null||Ae===void 0?void 0:Ae.whiteSpace)==="pre"){var Te=D.above(p,{at:Pe.path,match:hn=>le.isElement(hn)&&D.isBlock(p,hn)});Te&&ee.string(Te[0]).includes(" ")&&(te=!1)}}if((!we.startsWith("delete")||we.startsWith("deleteBy"))&&!yo.get(p)){var[We]=B.getTargetRanges();if(We){var Le=Z.toSlateRange(p,We,{exactMatch:!1,suppressThrow:!1});if(!fe||!U.equals(fe,Le)){te=!1;var et=!se&&p.selection&&D.rangeRef(p,p.selection);z.select(p,Le),et&&ci.set(p,et)}}}if(se)return;if(te||B.preventDefault(),fe&&U.isExpanded(fe)&&we.startsWith("delete")){var ut=we.endsWith("Backward")?"backward":"forward";return void D.deleteFragment(p,{direction:ut})}switch(we){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":D.deleteFragment(p);break;case"deleteContent":case"deleteContentForward":D.deleteForward(p);break;case"deleteContentBackward":D.deleteBackward(p);break;case"deleteEntireSoftLine":D.deleteBackward(p,{unit:"line"}),D.deleteForward(p,{unit:"line"});break;case"deleteHardLineBackward":D.deleteBackward(p,{unit:"block"});break;case"deleteSoftLineBackward":D.deleteBackward(p,{unit:"line"});break;case"deleteHardLineForward":D.deleteForward(p,{unit:"block"});break;case"deleteSoftLineForward":D.deleteForward(p,{unit:"line"});break;case"deleteWordBackward":D.deleteBackward(p,{unit:"word"});break;case"deleteWordForward":D.deleteForward(p,{unit:"word"});break;case"insertLineBreak":D.insertSoftBreak(p);break;case"insertParagraph":D.insertBreak(p);break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":we==="insertFromComposition"&&Z.isComposing(p)&&(b(!1),Rr.set(p,!1)),Ce?.constructor.name==="DataTransfer"?Z.insertData(p,Ce):typeof Ce=="string"&&(te?E.current.push((()=>D.insertText(p,Ce))):D.insertText(p,Ce))}var Nt=(pe=ci.get(p))===null||pe===void 0?void 0:pe.unref();ci.delete(p),!Nt||p.selection&&U.equals(p.selection,Nt)||z.select(p,Nt)}}),[p,M,T,i,a,H]),G=m.useCallback((B=>{B==null?(M.cancel(),H.cancel(),ms.delete(p),Lr.delete(p),C.current&&er&&C.current.removeEventListener("beforeinput",W)):er&&B.addEventListener("beforeinput",W),C.current=B,typeof t=="function"?t(B):t&&(t.current=B)}),[M,H,p,W,t]);Di((()=>{var B=Z.getWindow(p);B.document.addEventListener("selectionchange",H);var X=()=>{k.isDraggingInternally=!1};return B.document.addEventListener("dragend",X),B.document.addEventListener("drop",X),()=>{B.document.removeEventListener("selectionchange",H),B.document.removeEventListener("dragend",X),B.document.removeEventListener("drop",X)}}),[H,k]);var q=o([p,[]]),$=s&&p.children.length===1&&Array.from(ee.texts(p)).length===1&&ee.string(p)===""&&!w,V=m.useCallback((B=>{var X;x(B&&$?(X=B.getBoundingClientRect())===null||X===void 0?void 0:X.height:void 0)}),[$]);if($){var Q=D.start(p,[]);q.push({[To]:!0,placeholder:s,onPlaceholderResize:V,anchor:Q,focus:Q})}var{marks:ae}=p;if(k.hasMarkPlaceholder=!1,p.selection&&U.isCollapsed(p.selection)&&ae){var{anchor:ie}=p.selection,Se=ee.leaf(p,ie.path),Ie=Io(Se,e2);if(!he.equals(Se,ae,{loose:!0})){k.hasMarkPlaceholder=!0;var ne=Object.fromEntries(Object.keys(Ie).map((B=>[B,null])));q.push(yn(yn(yn({[t0]:!0},ne),ae),{},{anchor:ie,focus:ie}))}}return m.useEffect((()=>{setTimeout((()=>{var{selection:B}=p;if(B){var{anchor:X}=B,K=ee.leaf(p,X.path);if(ae&&!he.equals(K,ae,{loose:!0}))return void on.set(p,ae)}on.delete(p)}))})),Be.createElement(h0.Provider,{value:a},Be.createElement(YD.Provider,{value:w},Be.createElement(c0.Provider,{value:o},Be.createElement(XD,{node:C,receivedUserInput:F},Be.createElement(h,yn(yn({role:a?void 0:"textbox","aria-multiline":!a||void 0},y),{},{spellCheck:!(!er&&ps)&&y.spellCheck,autoCorrect:er||!ps?y.autoCorrect:"false",autoCapitalize:er||!ps?y.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:G,style:yn(yn({},g?{}:yn({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},A?{minHeight:A}:{})),d),onBeforeInput:m.useCallback((B=>{if(!er&&!a&&!Dt(B,y.onBeforeInput)&&Z.hasSelectableTarget(p,B.target)&&(B.preventDefault(),!Z.isComposing(p))){var X=B.data;D.insertText(p,X)}}),[y.onBeforeInput,p,a]),onInput:m.useCallback((B=>{if(!Dt(B,y.onInput))if(_.current)_.current.handleInput();else{for(var X of E.current)X();if(E.current=[],!Z.isFocused(p)){var K=B.nativeEvent,Y=p;if(K.inputType==="historyUndo"&&typeof Y.undo=="function")return void Y.undo();if(K.inputType==="historyRedo"&&typeof Y.redo=="function")return void Y.redo()}}}),[y.onInput,p]),onBlur:m.useCallback((B=>{if(!a&&!k.isUpdatingSelection&&Z.hasSelectableTarget(p,B.target)&&!Dt(B,y.onBlur)){var X=Z.findDocumentOrShadowRoot(p);if(k.latestElement!==X.activeElement){var{relatedTarget:K}=B;if(!(K===Z.toDOMNode(p,p)||qt(K)&&K.hasAttribute("data-slate-spacer"))){if(K!=null&&pr(K)&&Z.hasDOMNode(p,K)){var Y=Z.toSlateNode(p,K);if(le.isElement(Y)&&!p.isVoid(Y))return}if(Dr){var de=li(X);de?.removeAllRanges()}cr.delete(p)}}}}),[a,k.isUpdatingSelection,k.latestElement,p,y.onBlur]),onClick:m.useCallback((B=>{if(Z.hasTarget(p,B.target)&&!Dt(B,y.onClick)&&pr(B.target)){var X=Z.toSlateNode(p,B.target),K=Z.findPath(p,X);if(!D.hasPath(p,K)||ee.get(p,K)!==X)return;if(B.detail===3&&K.length>=1){var Y=K;if(!le.isElement(X)||!D.isBlock(p,X)){var de,pe=D.above(p,{match:Ae=>le.isElement(Ae)&&D.isBlock(p,Ae),at:K});Y=(de=pe?.[1])!==null&&de!==void 0?de:K.slice(0,1)}var fe=D.range(p,Y);return void z.select(p,fe)}if(a)return;var we=D.start(p,K),Ce=D.end(p,K),se=D.void(p,{at:we}),te=D.void(p,{at:Ce});if(se&&te&&R.equals(se[1],te[1])){var me=D.range(p,we);z.select(p,me)}}}),[p,y.onClick,a]),onCompositionEnd:m.useCallback((B=>{if(Z.hasSelectableTarget(p,B.target)){var X;if(Z.isComposing(p)&&Promise.resolve().then((()=>{b(!1),Rr.set(p,!1)})),(X=_.current)===null||X===void 0||X.handleCompositionEnd(B),Dt(B,y.onCompositionEnd)||It)return;if(!Dr&&!bD&&!Xg&&!wD&&!CD&&B.data){var K=on.get(p);on.delete(p),K!==void 0&&(Pn.set(p,p.marks),p.marks=K),D.insertText(p,B.data);var Y=Pn.get(p);Pn.delete(p),Y!==void 0&&(p.marks=Y)}}}),[y.onCompositionEnd,p]),onCompositionUpdate:m.useCallback((B=>{Z.hasSelectableTarget(p,B.target)&&!Dt(B,y.onCompositionUpdate)&&(Z.isComposing(p)||(b(!0),Rr.set(p,!0)))}),[y.onCompositionUpdate,p]),onCompositionStart:m.useCallback((B=>{if(Z.hasSelectableTarget(p,B.target)){var X;if((X=_.current)===null||X===void 0||X.handleCompositionStart(B),Dt(B,y.onCompositionStart)||It)return;b(!0);var{selection:K}=p;if(K&&U.isExpanded(K))return void D.deleteFragment(p)}}),[y.onCompositionStart,p]),onCopy:m.useCallback((B=>{!Z.hasSelectableTarget(p,B.target)||Dt(B,y.onCopy)||fh(B)||(B.preventDefault(),Z.setFragmentData(p,B.clipboardData,"copy"))}),[y.onCopy,p]),onCut:m.useCallback((B=>{if(!a&&Z.hasSelectableTarget(p,B.target)&&!Dt(B,y.onCut)&&!fh(B)){B.preventDefault(),Z.setFragmentData(p,B.clipboardData,"cut");var{selection:X}=p;if(X)if(U.isExpanded(X))D.deleteFragment(p);else{var K=ee.parent(p,X.anchor.path);D.isVoid(p,K)&&z.delete(p)}}}),[a,p,y.onCut]),onDragOver:m.useCallback((B=>{if(Z.hasTarget(p,B.target)&&!Dt(B,y.onDragOver)){var X=Z.toSlateNode(p,B.target);le.isElement(X)&&D.isVoid(p,X)&&B.preventDefault()}}),[y.onDragOver,p]),onDragStart:m.useCallback((B=>{if(!a&&Z.hasTarget(p,B.target)&&!Dt(B,y.onDragStart)){var X=Z.toSlateNode(p,B.target),K=Z.findPath(p,X);if(le.isElement(X)&&D.isVoid(p,X)||D.void(p,{at:K,voids:!0})){var Y=D.range(p,K);z.select(p,Y)}k.isDraggingInternally=!0,Z.setFragmentData(p,B.dataTransfer,"drag")}}),[a,p,y.onDragStart,k]),onDrop:m.useCallback((B=>{if(!a&&Z.hasTarget(p,B.target)&&!Dt(B,y.onDrop)){B.preventDefault();var X=p.selection,K=Z.findEventRange(p,B),Y=B.dataTransfer;z.select(p,K),k.isDraggingInternally&&(!X||U.equals(X,K)||D.void(p,{at:K,voids:!0})||z.delete(p,{at:X})),Z.insertData(p,Y),Z.isFocused(p)||Z.focus(p)}}),[a,p,y.onDrop,k]),onDragEnd:m.useCallback((B=>{!a&&k.isDraggingInternally&&y.onDragEnd&&Z.hasTarget(p,B.target)&&y.onDragEnd(B)}),[a,k,y,p]),onFocus:m.useCallback((B=>{if(!a&&!k.isUpdatingSelection&&Z.hasEditableTarget(p,B.target)&&!Dt(B,y.onFocus)){var X=Z.toDOMNode(p,p),K=Z.findDocumentOrShadowRoot(p);if(k.latestElement=K.activeElement,lo&&B.target!==X)return void X.focus();cr.set(p,!0)}}),[a,k,p,y.onFocus]),onKeyDown:m.useCallback((B=>{if(!a&&Z.hasEditableTarget(p,B.target)){var X;(X=_.current)===null||X===void 0||X.handleKeyDown(B);var{nativeEvent:K}=B;if(Z.isComposing(p)&&K.isComposing===!1&&(Rr.set(p,!1),b(!1)),Dt(B,y.onKeyDown)||Z.isComposing(p))return;var{selection:Y}=p,de=p.children[Y!==null?Y.focus.path[0]:0],pe=Wg(ee.string(de))==="rtl";if(Ze.isRedo(K)){B.preventDefault();var fe=p;return void(typeof fe.redo=="function"&&fe.redo())}if(Ze.isUndo(K)){B.preventDefault();var we=p;return void(typeof we.undo=="function"&&we.undo())}if(Ze.isMoveLineBackward(K))return B.preventDefault(),void z.move(p,{unit:"line",reverse:!0});if(Ze.isMoveLineForward(K))return B.preventDefault(),void z.move(p,{unit:"line"});if(Ze.isExtendLineBackward(K))return B.preventDefault(),void z.move(p,{unit:"line",edge:"focus",reverse:!0});if(Ze.isExtendLineForward(K))return B.preventDefault(),void z.move(p,{unit:"line",edge:"focus"});if(Ze.isMoveBackward(K))return B.preventDefault(),void(Y&&U.isCollapsed(Y)?z.move(p,{reverse:!pe}):z.collapse(p,{edge:pe?"end":"start"}));if(Ze.isMoveForward(K))return B.preventDefault(),void(Y&&U.isCollapsed(Y)?z.move(p,{reverse:pe}):z.collapse(p,{edge:pe?"start":"end"}));if(Ze.isMoveWordBackward(K))return B.preventDefault(),Y&&U.isExpanded(Y)&&z.collapse(p,{edge:"focus"}),void z.move(p,{unit:"word",reverse:!pe});if(Ze.isMoveWordForward(K))return B.preventDefault(),Y&&U.isExpanded(Y)&&z.collapse(p,{edge:"focus"}),void z.move(p,{unit:"word",reverse:pe});if(er){if((Yg||Dr)&&Y&&(Ze.isDeleteBackward(K)||Ze.isDeleteForward(K))&&U.isCollapsed(Y)){var Ce=ee.parent(p,Y.anchor.path);if(le.isElement(Ce)&&D.isVoid(p,Ce)&&(D.isInline(p,Ce)||D.isBlock(p,Ce)))return B.preventDefault(),void D.deleteBackward(p,{unit:"block"})}}else{if(Ze.isBold(K)||Ze.isItalic(K)||Ze.isTransposeCharacter(K))return void B.preventDefault();if(Ze.isSoftBreak(K))return B.preventDefault(),void D.insertSoftBreak(p);if(Ze.isSplitBlock(K))return B.preventDefault(),void D.insertBreak(p);if(Ze.isDeleteBackward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p));if(Ze.isDeleteForward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p));if(Ze.isDeleteLineBackward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p,{unit:"line"}));if(Ze.isDeleteLineForward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p,{unit:"line"}));if(Ze.isDeleteWordBackward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p,{unit:"word"}));if(Ze.isDeleteWordForward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p,{unit:"word"}))}}}),[a,p,y.onKeyDown]),onPaste:m.useCallback((B=>{a||!Z.hasEditableTarget(p,B.target)||Dt(B,y.onPaste)||(!er||(X=>X.clipboardData&&X.clipboardData.getData("text/plain")!==""&&X.clipboardData.types.length===1)(B.nativeEvent)||Dr)&&(B.preventDefault(),Z.insertData(p,B.clipboardData))}),[a,p,y.onPaste])}),Be.createElement(t2,{decorations:q,node:p,renderElement:u,renderPlaceholder:f,renderLeaf:l,selection:p.selection}))))))})),r2=e=>{var{attributes:t,children:n}=e;return Be.createElement("span",yn({},t),n,It&&Be.createElement("br",null))},o2=()=>[],i2=(e,t)=>{if(t.getBoundingClientRect&&(!e.selection||e.selection&&U.isCollapsed(e.selection))){var n=t.startContainer.parentElement;n.getBoundingClientRect=t.getBoundingClientRect.bind(t),rD(n,{scrollMode:"if-needed"}),delete n.getBoundingClientRect}},Dt=(e,t)=>{if(!t)return!1;var n=t(e);return n??(e.isDefaultPrevented()||e.isPropagationStopped())},fh=e=>pr(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement),s2=(e,t)=>{if(!t)return!1;var n=t(e);return n??e.defaultPrevented},a2=m.createContext(!1),u2=m.createContext({}),c2=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],l2=e=>{var{editor:t,children:n,onChange:r,onSelectionChange:o,onValueChange:i,initialValue:s}=e,a=Io(e,c2),[u,l]=Be.useState((()=>{if(!ee.isNodeList(s))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(ht.stringify(s)));if(!D.isEditor(t))throw new Error("[Slate] editor is invalid! You passed: ".concat(ht.stringify(t)));return t.children=s,Object.assign(t,a),{v:0,editor:t}})),{selectorContext:f,onChange:c}=(function(y){var p=m.useRef([]).current,w=m.useRef({editor:y}).current,b=m.useCallback((C=>{w.editor=C,p.forEach((E=>E(C)))}),[p,w]);return{selectorContext:m.useMemo((()=>({getSlate:()=>w.editor,addEventListener:C=>(p.push(C),()=>{p.splice(p.indexOf(C),1)})})),[p,w]),onChange:b}})(t),d=m.useCallback((y=>{var p;r&&r(t.children),(y==null||(p=y.operation)===null||p===void 0?void 0:p.type)==="set_selection"?o?.(t.selection):i?.(t.children),l((w=>({v:w.v+1,editor:t}))),c(t)}),[t,c,r,o,i]);m.useEffect((()=>($u.set(t,d),()=>{$u.set(t,(()=>{}))})),[t,d]);var[h,g]=m.useState(Z.isFocused(t));return m.useEffect((()=>{g(Z.isFocused(t))}),[t]),Di((()=>{var y=()=>g(Z.isFocused(t));return Zg>=17?(document.addEventListener("focusin",y),document.addEventListener("focusout",y),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",y)}):(document.addEventListener("focus",y,!0),document.addEventListener("blur",y,!0),()=>{document.removeEventListener("focus",y,!0),document.removeEventListener("blur",y,!0)})}),[]),Be.createElement(u2.Provider,{value:f},Be.createElement(p0.Provider,{value:u},Be.createElement(cl.Provider,{value:u.editor},Be.createElement(a2.Provider,{value:h},n))))},hh=(e,t)=>{var n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n},ph=(e,t,n)=>{var r=Z.toDOMRange(e,t).getBoundingClientRect(),o=Z.toDOMRange(e,n).getBoundingClientRect();return hh(r,o)&&hh(o,r)};function mh(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 gh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?mh(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var d2=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",n=e,{apply:r,onChange:o,deleteBackward:i,addMark:s,removeMark:a}=n;return Qs.set(n,new WeakMap),n.addMark=(u,l)=>{var f,c;(f=fl.get(n))===null||f===void 0||f(),!on.get(n)&&(c=_t.get(n))!==null&&c!==void 0&&c.length&&on.set(n,null),Pn.delete(n),s(u,l)},n.removeMark=u=>{var l;!on.get(n)&&(l=_t.get(n))!==null&&l!==void 0&&l.length&&on.set(n,null),Pn.delete(n),a(u)},n.deleteBackward=u=>{if(u!=="line")return i(u);if(n.selection&&U.isCollapsed(n.selection)){var l=D.above(n,{match:h=>le.isElement(h)&&D.isBlock(n,h),at:n.selection});if(l){var[,f]=l,c=D.range(n,f,n.selection.anchor),d=((h,g)=>{var y=D.range(h,U.end(g)),p=Array.from(D.positions(h,{at:g})),w=0,b=p.length,C=Math.floor(b/2);if(ph(h,D.range(h,p[w]),y))return D.range(h,p[w],y);if(p.length<2)return D.range(h,p[p.length-1],y);for(;C!==p.length&&C!==w;)ph(h,D.range(h,p[C]),y)?b=C:w=C,C=Math.floor((w+b)/2);return D.range(h,p[b],y)})(n,c);U.isCollapsed(d)||z.delete(n,{at:d})}}},n.apply=u=>{var l=[],f=[],c=_t.get(n);if(c!=null&&c.length){var d=c.map((M=>(function(H,W){var{path:G,diff:q,id:$}=H;switch(W.type){case"insert_text":return!R.equals(W.path,G)||W.offset>=q.end?H:W.offset<=q.start?{diff:{start:W.text.length+q.start,end:W.text.length+q.end,text:q.text},id:$,path:G}:{diff:{start:q.start,end:q.end+W.text.length,text:q.text},id:$,path:G};case"remove_text":return!R.equals(W.path,G)||W.offset>=q.end?H:W.offset+W.text.length<=q.start?{diff:{start:q.start-W.text.length,end:q.end-W.text.length,text:q.text},id:$,path:G}:{diff:{start:q.start,end:q.end-W.text.length,text:q.text},id:$,path:G};case"split_node":return!R.equals(W.path,G)||W.position>=q.end?{diff:q,id:$,path:R.transform(G,W,{affinity:"backward"})}:W.position>q.start?{diff:{start:q.start,end:Math.min(W.position,q.end),text:q.text},id:$,path:G}:{diff:{start:q.start-W.position,end:q.end-W.position,text:q.text},id:$,path:R.transform(G,W,{affinity:"forward"})};case"merge_node":return R.equals(W.path,G)?{diff:{start:q.start+W.position,end:q.end+W.position,text:q.text},id:$,path:R.transform(G,W)}:{diff:q,id:$,path:R.transform(G,W)}}var V=R.transform(G,W);return V?{diff:q,path:V,id:$}:null})(M,u))).filter(Boolean);_t.set(n,d)}var h=rr.get(n);h&&rr.set(n,rh(n,h,u));var g=nr.get(n);if(g!=null&&g.at){var y=_e.isPoint(g?.at)?Ku(n,g.at,u):rh(n,g.at,u);nr.set(n,y?gh(gh({},g),{},{at:y}):null)}switch(u.type){case"insert_text":case"remove_text":case"set_node":case"split_node":l.push(...Qr(n,u.path));break;case"set_selection":var p;(p=ci.get(n))===null||p===void 0||p.unref(),ci.delete(n);break;case"insert_node":case"remove_node":l.push(...Qr(n,R.parent(u.path)));break;case"merge_node":var w=R.previous(u.path);l.push(...Qr(n,w));break;case"move_node":var b,C=R.common(R.parent(u.path),R.parent(u.newPath));l.push(...Qr(n,C)),R.isBefore(u.path,u.newPath)?(l.push(...Qr(n,R.parent(u.path))),b=u.newPath):(l.push(...Qr(n,R.parent(u.newPath))),b=u.path);var E=ee.get(e,R.parent(b)),A=Z.findKey(n,E),x=D.pathRef(n,R.parent(b));f.push([x,A])}switch(r(u),u.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":yo.set(n,!0)}for(var[I,T]of l){var[F]=D.node(n,I);js.set(F,T)}for(var[S,k]of f){if(S.current){var[_]=D.node(n,S.current);js.set(_,k)}S.unref()}},n.setFragmentData=u=>{var{selection:l}=n;if(l){var[f,c]=U.edges(l),d=D.void(n,{at:f.path}),h=D.void(n,{at:c.path});if(!U.isCollapsed(l)||d){var g=Z.toDOMRange(n,l),y=g.cloneContents(),p=y.childNodes[0];if(y.childNodes.forEach((F=>{F.textContent&&F.textContent.trim()!==""&&(p=F)})),h){var[w]=h,b=g.cloneRange(),C=Z.toDOMNode(n,w);b.setEndAfter(C),y=b.cloneContents()}if(d&&(p=y.querySelector("[data-slate-spacer]")),Array.from(y.querySelectorAll("[data-slate-zero-width]")).forEach((F=>{var S=F.getAttribute("data-slate-zero-width")==="n";F.textContent=S?`
|
|
58
|
-
`:""})),r0(p)){var E=p.ownerDocument.createElement("span");E.style.whiteSpace="pre",E.appendChild(p),y.appendChild(E),p=E}var A=n.getFragment(),x=JSON.stringify(A),I=window.btoa(encodeURIComponent(x));p.setAttribute("data-slate-fragment",I),u.setData("application/".concat(t),I);var T=y.ownerDocument.createElement("div");return T.appendChild(y),T.setAttribute("hidden","true"),y.ownerDocument.body.appendChild(T),u.setData("text/html",T.innerHTML),u.setData("text/plain",i0(T)),y.ownerDocument.body.removeChild(T),u}}},n.insertData=u=>{n.insertFragmentData(u)||n.insertTextData(u)},n.insertFragmentData=u=>{var l=u.getData("application/".concat(t))||(d=>{var h=d.getData("text/html"),[,g]=h.match(xD)||[];return g})(u);if(l){var f=decodeURIComponent(window.atob(l)),c=JSON.parse(f);return n.insertFragment(c),!0}return!1},n.insertTextData=u=>{var l=u.getData("text/plain");if(l){var f=l.split(/\r\n|\r|\n/),c=!1;for(var d of f)c&&z.splitNodes(n,{always:!0}),n.insertText(d),c=!0;return!0}return!1},n.onChange=u=>{(Zg<18?kv.unstable_batchedUpdates:l=>l())((()=>{var l=$u.get(n);l&&l(u),o(u)}))},n},Qr=(e,t)=>{var n=[];for(var[r,o]of D.levels(e,{at:t})){var i=Z.findKey(e,r);n.push([o,i])}return n};function ml(e,t,n=3){if(!(n<=0))try{return Z.toDOMRange(e,t)}catch{return ml(e,{anchor:t.anchor,focus:t.anchor},n-1)}}function ko(e){return!e.trim()}function In(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function Gu(e){return In(e)&&Object.keys(e).length===1}function Ju(e,t){for(const n of t)if(In(n)){if(!ko(n.text))return!1}else if(n.type==="paragraph"){if(n.children.length>1||n.children[0]&&(!In(n.children[0])||!ko(n.children[0].text)))return!1}else if(!D.isEmpty(e,n))return!1;return!0}let gs;const Zu=new WeakMap,Xu=new WeakMap;function vh(e,t){t?(Xu.get(e)?.unobserve(e),Xu.delete(e)):(Zu.delete(e),gs?.unobserve(e))}function f2(e,t,n){const r=n?.enabled??!0,o=Vs(t),{root:i,rootMargin:s,threshold:a}=n??{};m.useEffect((()=>{const u=e.current;if(!u)return;const l={root:i,rootMargin:s,threshold:a};return r?(function(f,c,d){if(d){const h=new IntersectionObserver((g=>{for(const y of g)c?.(y)}),{root:d.root?.current,rootMargin:typeof d.rootMargin=="number"?`${d.rootMargin}px`:d.rootMargin,threshold:d.threshold});Xu.set(f,h),h.observe(f)}else gs||(gs=new IntersectionObserver((h=>{for(const g of h)Zu.get(g.target)?.(g)}))),Zu.set(f,c),gs.observe(f)})(u,(f=>{o.current(f.isIntersecting,f)}),l):vh(u,l),()=>{vh(u,l)}}),[e,r,o,i,s,a])}const gl=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"span";return v.jsx(o,{...n,ref:r,children:e})})),g0=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),h2={Mention:({mention:e})=>v.jsxs(gl,{children:[An,e.id]}),Link:({href:e,children:t})=>v.jsx(g0,{href:e,children:t})},p2=m.forwardRef((({body:e,components:t,style:n,asChild:r,...o},i)=>{const s=r?vt:"div",{Mention:a,Link:u}=m.useMemo((()=>({...h2,...t})),[t]);return e&&e?.content?v.jsx(s,{...o,style:{whiteSpace:"break-spaces",...n},ref:i,children:e.content.map(((l,f)=>l.type==="paragraph"?v.jsx("p",{style:{minHeight:"1lh"},children:l.children.map(((c,d)=>{if(Fp(c)){const{type:g,...y}=c;return y.id?v.jsx(a,{mention:y},d):null}if(Rp(c)){const g=fp(c.url);return g===null?v.jsx("span",{children:c.text??c.url},d):v.jsx(u,{href:g,children:c.text??c.url},d)}let h=c.text;return c.bold&&(h=v.jsx("strong",{children:h},d)),c.italic&&(h=v.jsx("em",{children:h},d)),c.strikethrough&&(h=v.jsx("s",{children:h},d)),c.code&&(h=v.jsx("code",{children:h},d)),v.jsx("span",{children:h},d)}))},f):null))}):null})),m2={alt:()=>"altKey",ctrl:()=>"ctrlKey",meta:()=>"metaKey",mod:()=>Rg()?"metaKey":"ctrlKey",shift:()=>"shiftKey"};function At(e,t,n={}){return e.key!==t?!1:Object.entries(n).filter((([,o])=>typeof o=="boolean")).every((([o,i])=>{const s=m2[o]();return e[s]===i}))}const v0=m.createContext(null);function vl(){return ye(m.useContext(v0),"Persist is missing from the React tree.")}function y0(e){const[t,n]=vl(),r=m.useRef(null),o=m.useRef(null);xn((()=>{const i=e.current;if(!i)return;const s=a=>{a.animationName===o.current&&n(),r.current=a.animationName};return i.addEventListener("animationcancel",s),i.addEventListener("animationend",s),()=>{i.removeEventListener("animationcancel",s),i.removeEventListener("animationend",s)}}),[e,n]),xn((()=>{const i=e.current;let s;if(i)return t||(s=requestAnimationFrame((()=>{const a=getComputedStyle(i);o.current=a.animationName,a.animationName!=="none"&&a.animationName!==r.current&&a.display!=="none"||n()}))),()=>{cancelAnimationFrame(s)}}),[t,e,n])}function b0({children:e}){const[t,n]=m.useState(!0),r=m.useRef(null),o=(function(s){const a=Array.isArray(s)?m.Children.only(s):s;return m.isValidElement(a)?a:void 0})(e),i=m.useCallback((()=>{Oi.flushSync((()=>n(!1)))}),[]);return xn((()=>{o&&(n(!0),r.current=o)}),[o]),v.jsx(v0.Provider,{value:[!!o,i],children:o??(t?r.current:null)})}function yh(e,t,n){return Math.min(Math.max(e,t),n)}function g2(e,t,n){const r=n-t;return r>0?((e-t)%r+r)%r+t:0}const v2={wrap:!0};function yl(e,t){const n=Vs(t);m.useEffect((()=>e.subscribe((()=>n.current()))),[e,n])}function Ai(e,t,n={}){const{filterVoids:r}=n,o=D.before(e,t,{unit:"character",voids:r});if(o){const i=D.range(e,o,U.isRange(t)?U.start(t):t),s=D.string(e,i);return{range:i,text:s,void:s.length===0}}}function bl(e,t,n={}){const{filterVoids:r}=n,o=D.after(e,t,{unit:"character",voids:r});if(o){const i=D.range(e,o,U.isRange(t)?U.end(t):t),s=D.string(e,i);return{range:i,text:s,void:s.length===0}}}const bh={bold:!1,italic:!1,strikethrough:!1,code:!1};function Ch(e){if(!e)return{...bh};const t=D.marks(e);return{...bh,...t}}function C0(e){return Object.keys(e??{}).filter((t=>t!=="text"))}function Qo(e,t){(function(r,o){const i=D.marks(r);return!!i&&i[o]===!0})(e,t)?D.removeMark(e,t):D.addMark(e,t,!0)}function w0(e){const t=D.marks(e);if(t)for(const n in t)D.removeMark(e,n)}function wh(e,t){e.selection&&U.isCollapsed(e.selection)&&Object.keys(D.marks(e)??{}).length>0&&((t==="start"?Ai(e,e.selection):bl(e,e.selection))||w0(e))}const E0=m.createContext(null),D0=m.createContext(null),A0=m.createContext(null),x0=m.createContext(null),O0=m.createContext(null);function ea(){return ye(m.useContext(D0),"Composer.Form is missing from the React tree.")}function S0(){return m.useContext(A0)}function Cl(){return ye(S0(),"Composer.Form is missing from the React tree.")}function wl(e="useComposerSuggestionsContext"){return ye(m.useContext(x0),`${e} can’t be used outside of Composer.Editor.`)}function Wt(){return ye(m.useContext(E0),"Composer.Form is missing from the React tree.")}const y2=/\s/;function Ms(e){return!!e&&y2.test(e)}const Eh={direction:"before",allowConsecutiveWhitespace:!0};function I0(e,t,n=[" "],r=Eh){const{include:o,direction:i,ignoreTerminator:s,allowConsecutiveWhitespace:a}={...Eh,...r};let[u,l]=U.edges(t),f=u,c=!1;function d(h){const g=h==="after"?D.after(e,f,{unit:"character"}):D.before(e,f,{unit:"character"});if(!g||R.compare(g.path,f.path)!==0)return!1;const y=g&&D.string(e,h==="after"?{anchor:f,focus:g}:{anchor:g,focus:f}),p=y&&y[h==="after"?0:y.length-1];return!(!a&&c&&Ms(p))&&!(!g||!p||n.includes(p)&&!s?.(p,g,h))&&(c=Ms(p),f=g,f.offset!==0)}if(i!=="before"){for(f=l;d("after"););l=f}if(i!=="after"){for(f=u;d("before"););u=f}return o?{anchor:i==="before"||i==="both"?D.before(e,u,{unit:"offset"})??u:u,focus:i==="after"||i==="both"?D.after(e,l,{unit:"offset"})??l:l}:{anchor:u,focus:l}}const T0=[{type:"mark",mark:"bold",character:"*"},{type:"mark",mark:"italic",character:"_"},{type:"mark",mark:"strikethrough",character:"~"},{type:"mark",mark:"code",character:"`"}],b2=T0.filter((e=>e.type==="mark")).map((e=>e.character));function C2(e,t,n){if(t!==n.character)return!1;const r=I0(e,e.selection,[n.character]);if(!r||U.isCollapsed(r))return!1;const o=Ai(e,r);if(!o||o.text!==n.character)return!1;const i=Ai(e,o.range);if(i&&!b2.includes(i.text)&&!ko(i.text))return!1;const s=D.string(e,r);return s.trim()===s&&(z.select(e,r),e.addMark(n.mark,!0),z.collapse(e,{edge:"end"}),e.removeMark(n.mark),z.delete(e,{at:o.range}),!0)}function w2(e){const{isInline:t,normalizeNode:n,insertData:r}=e;return e.isInline=o=>o.type==="custom-link"||t(o),e.normalizeNode=o=>{const[i,s]=o;if(le.isElement(i)&&i.type==="custom-link"&&(i.children.length===0||i.children.length===1&&i.children[0]?.text==="")&&z.removeNodes(e,{at:s}),In(i)&&Ps(ee.parent(e,s))&&!Gu(i)){const a=C0(i);z.unsetNodes(e,a,{at:s})}n(o)},e.insertData=o=>{const{selection:i}=e,s=o.getData("text/plain");let a=!0;i&&!U.isCollapsed(i)&&i.anchor.path[0]===i.focus.path[0]&&(function(u){try{return new URL(u),!0}catch{return!1}})(s)&&((function(u,l){const{selection:f}=u;if(!f)return!1;const c=Array.from(D.nodes(u,{at:f,match:d=>le.isElement(d)&&D.isBlock(u,d),mode:"lowest"}));for(const[,d]of c){const h=U.isRange(f)?U.intersection(f,D.range(u,d)):f;if(!h)continue;if(Array.from(D.nodes(u,{at:h,match:y=>D.isInline(u,y)&&l(y)})).length>0)return!0}return!1})(e,(u=>!In(u)))||(z.wrapNodes(e,{type:"custom-link",url:s,children:[]},{at:i,split:!0,match:Gu}),a=!1)),a&&r(o)},e}function Ps(e){return le.isElement(e)&&e.type==="custom-link"}function bo(e){return le.isElement(e)&&e.type==="auto-link"}const k0=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9().@:%_+~#?&//=]*)/,E2=/[.,;!?\s()]/,D2=/^[.?][a-zA-Z0-9]+/,A2=/[()]/;function Ns(e){return E2.test(e)}function B0(e){const t=e[e.length-1];return t!==void 0&&Ns(t)}function F0(e){const t=e[0];return t!==void 0&&Ns(t)}function R0(e,t){const n=D.previous(e,{at:t});return!n||In(n[0])&&(B0(n[0].text)||n[0].text==="")}function _0(e,t){const n=D.next(e,{at:t});return!n||In(n[0])&&(F0(n[0].text)||n[0].text==="")}const x2=(e,t)=>{const[n,r]=t,o=ee.children(e,r);for(const[f]of o)if(!In(f))return void z.unwrapNodes(e,{at:r});const i=ee.string(n),s=k0.exec(i),a=s?.[0];if(!s||a!==i)return void z.unwrapNodes(e,{at:r});if((u=i)[u.length-1]==="."||u[u.length-1]==="?"){z.unwrapNodes(e,{at:r});const f=i.slice(0,i.length-1);return void z.wrapNodes(e,{type:"auto-link",url:f,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:f.length}},split:!0})}var u;const l=(function(f){if(!A2.test(f))return f.length;let c=0,d=0;for(const h of f){if(h==="("&&d++,h===")"&&(d--,d<0))break;c++}return c})(i);if(l<i.length){z.unwrapNodes(e,{at:r});const f=i.slice(0,l);z.wrapNodes(e,{type:"auto-link",url:f,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:f.length}},split:!0})}else R0(e,r)&&_0(e,r)?n.url===i||z.setNodes(e,{url:a},{at:r}):z.unwrapNodes(e,{at:r})},O2=(e,t)=>{const[n,r]=t,o=k0.exec(n.text),i=o?.[0];if(!o||i===void 0)return;const s=o.index,a=s+i.length;(function(u,l,f,c){const[d,h]=l,g=d.text,y=g[f-1],p=f>0&&y?Ns(y):R0(u,h),w=g[c],b=c<g.length&&w?Ns(w):_0(u,h);return p&&b})(e,t,s,a)&&z.wrapNodes(e,{type:"auto-link",url:i,children:[]},{at:{anchor:{path:r,offset:s},focus:{path:r,offset:a}},split:!0})},S2=(e,t)=>{const[n,r]=t,o=n.text,i=D.previous(e,{at:r});if(i&&bo(i[0])){if(D2.test(o))return z.unwrapNodes(e,{at:i[1]}),void z.mergeNodes(e,{at:r});if(!F0(o))return void z.unwrapNodes(e,{at:i[1]})}const s=D.next(e,{at:r});s&&bo(s[0])&&!B0(o)&&z.unwrapNodes(e,{at:s[1]})},I2=new RegExp("\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\uFE0F|\\u200D","u"),T2=new Set(['"',"'",".","!","?",",",";","(",")","[","]","<",">"]);function ei(e){return le.isElement(e)&&e.type==="mention"}function di(e){return di=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},di(e)}function k2(e){var t=(function(n,r){if(di(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(di(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return di(t)==="symbol"?t:String(t)}function Bo(e,t,n){return(t=k2(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j0=new WeakMap,M0=new WeakMap;class El{}class vs extends El{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),Bo(this,"offset",void 0),Bo(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}class ys extends El{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),Bo(this,"offset",void 0),Bo(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}var B2=e=>M0.get(e);function Dh(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 Yu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dh(Object(n),!0).forEach((function(r){Bo(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var bs=new WeakSet,Cs=e=>{var t=[],n=o=>{if(o!=null){var i=t[t.length-1];if(typeof o=="string"){var s={text:o};bs.add(s),o=s}if(he.isText(o)){var a=o;he.isText(i)&&bs.has(i)&&bs.has(a)&&he.equals(i,a,{loose:!0})?i.text+=a.text:t.push(a)}else if(le.isElement(o))t.push(o);else{if(!(o instanceof El))throw new Error("Unexpected hyperscript child object: ".concat(o));var u=t[t.length-1];he.isText(u)||(n(""),u=t[t.length-1]),o instanceof vs?((l,f)=>{var c=l.text.length;j0.set(l,[c,f])})(u,o):o instanceof ys&&((l,f)=>{var c=l.text.length;M0.set(l,[c,f])})(u,o)}}};for(var r of e.flat(1/0))n(r);return t};function P0(e,t,n){return Yu(Yu({},t),{},{children:Cs(n)})}function Ah(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 fi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ah(Object(n),!0).forEach((function(r){Bo(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ah(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var xh,F2={anchor:function(e,t,n){return new vs(t)},cursor:function(e,t,n){return[new vs(t),new ys(t)]},editor:(xh=$g,(e,t,n)=>{var r,o=[];for(var i of n)U.isRange(i)?r=i:o.push(i);var s,a=Cs(o),u={},l=xh();for(var[f,c]of(Object.assign(l,t),l.children=a,ee.texts(l))){var d=(s=f,j0.get(s)),h=B2(f);if(d!=null){var[g]=d;u.anchor={path:c,offset:g}}if(h!=null){var[y]=h;u.focus={path:c,offset:y}}}if(u.anchor&&!u.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!u.anchor&&u.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return r!=null?l.selection=r:U.isRange(u)&&(l.selection=u),l}),element:P0,focus:function(e,t,n){return new ys(t)},fragment:function(e,t,n){return Cs(n)},selection:function(e,t,n){var r=n.find((i=>i instanceof vs)),o=n.find((i=>i instanceof ys));if(!r||r.offset==null||r.path==null)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||o.offset==null||o.path==null)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return Yu({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Cs(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(o==null&&(o={text:""}),!he.isText(o))throw new Error(`
|
|
59
|
-
The <text> hyperscript tag can only contain text content as children.`);return bs.delete(o),Object.assign(o,t),o}},R2=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var s=e[t];if(!s)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return n==null&&(n={}),ft(n)||(o=[n].concat(o),n={}),s(t,n,o=o.filter((a=>!!a)).flat())},_2=e=>{var t={},n=function(){var o=e[r];if(typeof o!="object")throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(r,"> tag you passed: ").concat(o));t[r]=(i,s,a)=>P0(0,fi(fi({},o),s),a)};for(var r in e)n();return t},ti=(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{elements:t={}}=e,n=_2(t),r=fi(fi(fi({},F2),n),e.creators);return R2(r)})();function xi(e){return e!=null}function N0(e){if(!e.types.includes("Files"))return[];let t=Array.from(e.items).map((n=>{const r=n.webkitGetAsEntry();return r&&r.isFile?n.getAsFile():null})).filter(xi);return t.length||(t=Array.from(e.files).filter((n=>n.type!==""))),t}const j2=/[\r\n]/g,M2=/\s+/g;function P2(e,t){try{const n=new URL(e),r=new URL(t);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}}const Bn=()=>({type:"paragraph"}),Oh={A:e=>{const t=e.getAttribute("href"),n=e.innerText;return{type:t&&P2(t,n)?"auto-link":"custom-link",url:t??""}},P:Bn,BLOCKQUOTE:Bn,H1:Bn,H2:Bn,H3:Bn,H4:Bn,H5:Bn,H6:Bn,LI:Bn},Sh={CODE:()=>({code:!0}),DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),B:()=>({bold:!0})};function L0(e){const t=[];return e.nodeName==="LI"&&t.push(e),e.childNodes.forEach((n=>{n.nodeType===1&&t.push(...L0(n))})),t}function Ih(e,t){return e.map((n=>ti("text",t,n)))}function Qu(e){if(e.nodeType===3){let n=e.textContent;const r=n&&j2.test(n);return n&&r&&(n=n.replace(M2," ").trim()),n?{text:n}:null}if(e.nodeType!==1)return null;if(e.nodeName==="BR")return ti("element",{type:"paragraph"},[]);let t=Array.from(e.childNodes).map(Qu).flat();if((e.nodeName==="UL"||e.nodeName==="OL")&&(t=L0(e).map((n=>Qu(n))).flat()),t.length===0&&(t=[{text:""}]),e.nodeName==="BODY")return t.length>0&&t.every((n=>typeof n=="string"))&&(t=[{type:"paragraph",children:[{text:t.join("")}]}]),ti("fragment",{},t.filter((n=>typeof n!="string")));if(Oh[e.nodeName]){const n=Oh[e.nodeName](e);return ti("element",n,t)}if(Sh[e.nodeName]){const n=Sh[e.nodeName](e);return t.some((r=>r&&typeof r!="string"&&"type"in r))?ti("fragment",{},t):Ih(t,n)}if(e.nodeName==="SPAN"){const n=e.style,r={};return n.fontWeight!=="bold"&&n.fontWeight!=="700"&&n.fontWeight!=="800"&&n.fontWeight!=="900"||(r.bold=!0),n.fontStyle==="italic"&&(r.italic=!0),n.textDecoration==="line-through"&&(r.strikethrough=!0),Ih(t,r)}return t}const N2=[];function L2(e){switch(e){case"start":return"end";case"end":return"start";default:return"center"}}function U0(e){const[t,n="center"]=e.split("-");return[t,n]}function H0(){const[e,t]=m.useState(null),n=m.useCallback(t,[t]),[r,o]=m.useState();return xn((()=>{if(e){const i=window.getComputedStyle(e).zIndex,s=parseInt(i,10);o(Number.isNaN(s)?void 0:s)}}),[e]),[n,r]}function V0({type:e="bounds",position:t,alignment:n,dir:r,open:o}){return Mm({...m.useMemo((()=>{const i={padding:10},s=[e==="range"?_b(i):null,Um({...i,crossAxis:!1}),Vm(i),Nm({...i,limiter:Lm()}),e==="range"?Pm(6):null,Hm({...i,apply({availableWidth:a,availableHeight:u,elements:l}){l.floating.style.setProperty("--lb-composer-floating-available-width",`${a}px`),l.floating.style.setProperty("--lb-composer-floating-available-height",`${u}px`)}})];return{strategy:"fixed",placement:n==="center"?t:`${t}-${r==="rtl"?L2(n):n}`,middleware:s,whileElementsMounted:(...a)=>_m(...a,{animationFrame:!0})}}),[n,t,r,e]),open:o})}function $0({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o}){const{isDisabled:i}=Wt(),s=i||o,{createAttachments:a}=Cl(),[u,l]=m.useState(!1),f=Vs(u);return[u,{onDragEnter:m.useCallback((c=>{e?.(c),!(f.current||s||c.isDefaultPrevented())&&c.dataTransfer.types.includes("Files")&&(c.preventDefault(),c.stopPropagation(),l(!0))}),[e,s]),onDragLeave:m.useCallback((c=>{t?.(c),!f.current||s||c.isDefaultPrevented()||(c.relatedTarget?c.relatedTarget===c.currentTarget||c.currentTarget.contains(c.relatedTarget):c.currentTarget!==c.target)||(c.preventDefault(),c.stopPropagation(),l(!1))}),[t,s]),onDragOver:m.useCallback((c=>{n?.(c),s||c.isDefaultPrevented()||(c.preventDefault(),c.stopPropagation())}),[n,s]),onDrop:m.useCallback((c=>{if(r?.(c),!f.current||s||c.isDefaultPrevented())return;c.preventDefault(),c.stopPropagation(),l(!1);const d=N0(c.dataTransfer);a(d)}),[r,s,a]),"data-drop":u?"":void 0,"data-disabled":s?"":void 0}]}class ec extends Error{origin;name="AttachmentTooLargeError";constructor(t,n="client"){super(t),this.origin=n}}function Th(e){e.preventDefault()}function U2(e,t){const n=Ve(),r=So(e),o=So((()=>(function(a,u,l){const f=new Map,c=new Map,d=Ue();let h=null;function g(){h=null,d.notify()}function y(p){const w=new AbortController;c.set(p.id,w),a[Oe].httpClient.uploadAttachment({roomId:u,attachment:p,signal:w.signal}).then((()=>{f.set(p.id,{...p,status:"uploaded"}),g()})).catch((b=>{b instanceof Error&&b.name!=="AbortError"&&b.name!=="TimeoutError"&&(f.set(p.id,{...p,status:"error",error:b instanceof _o&&b.status===413?new ec("File is too large.","server"):b}),g())}))}return{addAttachments:function(p){if(p.length===0)return;const w=p.filter((C=>!f.has(C.id))),b=[];for(const C of w)if(C.type==="localAttachment"){if(C.file.size>l.maxFileSize){f.set(C.id,{...C,status:"error",error:new ec("File is too large.","client")});continue}f.set(C.id,{...C,status:"uploading"}),b.push(C)}else f.set(C.id,C);w.length>0&&g();for(const C of b)y(C)},removeAttachment:function(p){c.get(p)?.abort(),f.delete(p),c.delete(p),g()},getSnapshot:function(){return h||(h=Array.from(f.values())),h},subscribe:d.subscribe,clear:function(){c.forEach((p=>p.abort())),c.clear(),f.clear(),g()}}})(n,t.roomId,t)));m.useEffect((()=>{o.addAttachments(r)}),[r,o]),m.useEffect((()=>()=>{o.clear()}),[o]);const i=m.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot),s=m.useMemo((()=>i.some((a=>a.type==="localAttachment"&&a.status==="uploading"))),[i]);return m.useEffect((()=>{if(s)return window.addEventListener("beforeunload",Th),()=>{window.removeEventListener("beforeunload",Th)}}),[s]),{attachments:i,isUploadingAttachments:s,addAttachments:o.addAttachments,removeAttachment:o.removeAttachment,clearAttachments:o.clear}}const H2={version:1,content:[{type:"paragraph",children:[{text:""}]}]};function V2({createAttachments:e,pasteFilesAsAttachments:t}){return(function(n){const{normalizeNode:r}=n;return n.normalizeNode=o=>{const[i,s]=o;if(le.isElement(i)&&i.type==="paragraph"){for(const[a,u]of ee.children(n,s))if(le.isElement(a)&&!n.isInline(a))return void z.unwrapNodes(n,{at:u})}r(o)},n})((function(n){const{isInline:r,isVoid:o,markableVoid:i,deleteBackward:s}=n;return n.isInline=a=>ei(a)||r(a),n.isVoid=a=>ei(a)||o(a),n.markableVoid=a=>ei(a)||i(a),n.deleteBackward=a=>{const{selection:u}=n;if(u&&U.isCollapsed(u)){const[l]=D.nodes(n,{at:a==="character"?D.before(n,u,{unit:"character"}):u,match:ei});s(a),l&&z.insertText(n,An)}else s(a)},n})(w2((function(n){const{isInline:r,normalizeNode:o,deleteBackward:i}=n;return n.isInline=s=>s.type==="auto-link"||r(s),n.normalizeNode=s=>{const[a,u]=s;if(!Ps(a)){if(le.isElement(a)&&a.type==="auto-link"&&(a.children.length===0||a.children.length===1&&a.children[0]?.text==="")&&z.removeNodes(n,{at:u}),In(a)){const l=ee.parent(n,u);if(Ps(l))return;if(bo(l)){const f=R.parent(u);if(x2(n,[l,f]),!Gu(a)){const c=C0(a);z.unsetNodes(n,c,{at:u})}}else O2(n,[a,u]),S2(n,[a,u])}o(s)}},n.deleteBackward=s=>{i(s);const{selection:a}=n;if(!a||!U.isCollapsed(a))return;const[u]=D.nodes(n,{at:a,match:bo,mode:"lowest"});u&&z.unwrapNodes(n,{match:bo})},n})((function(n){const{insertText:r}=n;return n.insertText=(o,i)=>{if(!n.selection||!U.isCollapsed(n.selection))return r(o,i);let s=!0;for(const a of T0)a.type==="mark"&&C2(n,o,a)&&(s=!1);s&&r(o,i)},n})((function(n){const{onChange:r}=n;return n.onChange=o=>{Ju(n,n.children)&&w0(n),r(o)},n})((function(n,{createAttachments:r,pasteFilesAsAttachments:o}){const{insertData:i}=n;return n.insertData=s=>{if(s.types.includes("Files")&&o){const a=N0(s);if(a.length>0)return void r(a)}if(s.types.includes("text/html")&&!s.types.includes("application/x-slate-fragment")){const a=s.getData("text/html");try{const{body:u}=new DOMParser().parseFromString(a,"text/html");if(u.querySelector("br.Apple-interchange-newline")?.remove(),u.children.length===1&&u.children[0]?.nodeName==="B"){const f=u.children[0];for(;f.firstChild;)u.insertBefore(f.firstChild,f);u.removeChild(f)}const l=Qu(u);if(l!==null&&Array.isArray(l))return void z.insertFragment(n,l)}catch{}}i(s)},n})((n=>{var r=n,{apply:o}=r;return r.history={undos:[],redos:[]},r.redo=()=>{var{history:i}=r,{redos:s}=i;if(s.length>0){var a=s[s.length-1];a.selectionBefore&&z.setSelection(r,a.selectionBefore),bn.withoutSaving(r,(()=>{D.withoutNormalizing(r,(()=>{for(var u of a.operations)r.apply(u)}))})),i.redos.pop(),r.writeHistory("undos",a)}},r.undo=()=>{var{history:i}=r,{undos:s}=i;if(s.length>0){var a=s[s.length-1];bn.withoutSaving(r,(()=>{D.withoutNormalizing(r,(()=>{var u=a.operations.map(ur.inverse).reverse();for(var l of u)r.apply(l);a.selectionBefore&&z.setSelection(r,a.selectionBefore)}))})),r.writeHistory("redos",a),i.undos.pop()}},r.apply=i=>{var{operations:s,history:a}=r,{undos:u}=a,l=u[u.length-1],f=l&&l.operations[l.operations.length-1],c=bn.isSaving(r),d=bn.isMerging(r);if(c==null&&(c=eD(i)),c){if(d==null&&(d=l!=null&&(s.length!==0||QE(i,f))),bn.isSplittingOnce(r)&&(d=!1,bn.setSplittingOnce(r,void 0)),l&&d)l.operations.push(i);else{var h={operations:[i],selectionBefore:r.selection};r.writeHistory("undos",h)}for(;u.length>100;)u.shift();a.redos=[]}o(i)},r.writeHistory=(i,s)=>{r.history[i].push(s)},r})(d2($g())),{createAttachments:e,pasteFilesAsAttachments:t})))))))}function $2({Mention:e,attributes:t,children:n,element:r}){const o=d0(),{children:i,...s}=r;return v.jsxs("span",{...t,children:[r.id?v.jsx(e,{mention:s,isSelected:o}):null,n]})}function W2({Link:e,attributes:t,element:n,children:r}){const o=m.useMemo((()=>fp(n.url)??""),[n.url]);return v.jsx("span",{...t,children:v.jsx(e,{href:o,children:r})})}function z2({id:e,itemId:t,mentions:n,selectedMentionId:r,setSelectedMentionId:o,mentionDraft:i,setMentionDraft:s,onItemSelect:a,position:u="top",dir:l,MentionSuggestions:f}){const c=Tn(),{onEditorChange:d}=ea(),{isFocused:h}=Wt(),[g,y]=H0(),p=h&&i?.range!==void 0&&n!==void 0,{refs:{setReference:w,setFloating:b},strategy:C,isPositioned:E,placement:A,x,y:I,update:T,elements:F}=V0({position:u,dir:l,alignment:"start",open:p});return yl(d,(()=>{s((function(S){const{selection:k}=S;if(!k||!U.isCollapsed(k))return;const _=I0(S,k,["@"],{include:!0,allowConsecutiveWhitespace:!1,ignoreTerminator:(H,W)=>{const G=Ai(S,W);return!(!G||T2.has(G.text)||I2.test(G.text)||Ms(G.text))}});if(!_)return;const M=D.string(S,_);return!M.startsWith(An)||M.length>1&&Ms(M[1])?void 0:{range:_,text:M.substring(1)}})(c))})),xn((()=>{if(!i)return void w(null);const S=ml(c,i.range);w(S??null)}),[w,c,i]),xn((()=>{if(!p)return;const S=F.floating?.firstChild;if(!S)return;S.style.overflowY="visible",S.style.maxHeight="none",T();const k=requestAnimationFrame((()=>{S.style.overflowY="auto",S.style.maxHeight="var(--lb-composer-floating-available-height)"}));return()=>{cancelAnimationFrame(k)}}),[n?.length,p,F.floating,T]),v.jsx(b0,{children:p?v.jsx(x0.Provider,{value:{id:e,itemId:t,selectedValue:r,setSelectedValue:o,onItemSelect:a,placement:A,dir:l,ref:g},children:v.jsx(Ng,{ref:b,style:{position:C,top:0,left:0,transform:E?`translate3d(${Math.round(x)}px, ${Math.round(I)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:y},children:v.jsx(f,{mentions:n,selectedMentionId:r})})}):null})}function K2({id:e,position:t="top",dir:n,FloatingToolbar:r,hasFloatingToolbarRange:o,setHasFloatingToolbarRange:i}){const s=Tn(),{onEditorChange:a}=ea(),{isFocused:u}=Wt(),[l,f]=H0(),[c,d]=m.useState(!1),h=u&&!c&&o,{refs:{setReference:g,setFloating:y},strategy:p,isPositioned:w,placement:b,x:C,y:E}=V0({type:"range",position:t,dir:n,alignment:"center",open:h});return xn((()=>{if(!u)return;const A=()=>d(!0),x=()=>d(!1);return document.addEventListener("pointerdown",A),document.addEventListener("pointerup",x),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("pointerup",x)}}),[u]),yl(a,(()=>{g(null),requestAnimationFrame((()=>{const A=window.getSelection();if(s.selection&&!U.isCollapsed(s.selection)&&A&&A.rangeCount){i(!0);const x=A.getRangeAt(0);g(x)}else i(!1),g(null)}))})),v.jsx(b0,{children:h?v.jsx(O0.Provider,{value:{id:e,placement:b,dir:n,ref:l},children:v.jsx(Ng,{ref:y,style:{position:p,top:0,left:0,transform:w?`translate3d(${Math.round(C)}px, ${Math.round(E)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:f},children:v.jsx(r,{})})}):null})}const q2=m.forwardRef((({children:e,onPointerDown:t,style:n,asChild:r,...o},i)=>{const[s]=vl(),a=m.useRef(null),{id:u,ref:l,placement:f,dir:c}=(function(w="useComposerFloatingToolbarContext"){return ye(m.useContext(O0),`${w} can’t be used outside of Composer.Editor.`)})("ComposerFloatingToolbar"),d=ji(i,l,a),[h,g]=m.useMemo((()=>U0(f)),[f]),y=r?vt:"div";y0(a);const p=m.useCallback((w=>{t?.(w),w.preventDefault(),w.stopPropagation()}),[t]);return v.jsx(y,{dir:c,role:"toolbar",id:u,"aria-label":"Floating toolbar",...o,onPointerDown:p,"data-state":s?"open":"closed","data-side":h,"data-align":g,style:{display:"flex",flexDirection:"row",maxWidth:"var(--lb-composer-floating-available-width)",overflowX:"auto",...n},ref:d,children:e})}));function G2({Mention:e,Link:t,...n}){const{attributes:r,children:o,element:i}=n;switch(i.type){case"mention":return v.jsx($2,{Mention:e,...n});case"auto-link":case"custom-link":return v.jsx(W2,{Link:t,...n});case"paragraph":return v.jsx("p",{...r,style:{position:"relative"},children:o});default:return null}}function J2({attributes:e,children:t,leaf:n}){return n.bold&&(t=v.jsx("strong",{children:t})),n.italic&&(t=v.jsx("em",{children:t})),n.strikethrough&&(t=v.jsx("s",{children:t})),n.code&&(t=v.jsx("code",{children:t})),v.jsx("span",{...e,children:t})}function Z2({attributes:e,children:t}){const{opacity:n,...r}=e.style;return v.jsx("span",{...e,style:r,"data-placeholder":"",children:t})}const Dl=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"span",i=d0();return v.jsx(o,{"data-selected":i||void 0,...n,ref:r,children:e})})),W0=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),z0=m.forwardRef((({children:e,style:t,asChild:n,...r},o)=>{const[i]=vl(),s=m.useRef(null),{ref:a,placement:u,dir:l}=wl("ComposerSuggestions"),f=ji(o,a,s),[c,d]=m.useMemo((()=>U0(u)),[u]),h=n?vt:"div";return y0(s),v.jsx(h,{dir:l,...r,"data-state":i?"open":"closed","data-side":c,"data-align":d,style:{display:"flex",flexDirection:"column",maxHeight:"var(--lb-composer-floating-available-height)",overflowY:"auto",...t},ref:f,children:e})})),K0=m.forwardRef((({children:e,asChild:t,...n},r)=>{const{id:o}=wl("ComposerSuggestionsList"),i=t?vt:"ul";return v.jsx(i,{role:"listbox",id:o,"aria-label":"Suggestions list",...n,ref:r,children:e})})),q0=m.forwardRef((({value:e,children:t,onPointerMove:n,onPointerDown:r,onClick:o,asChild:i,...s},a)=>{const u=m.useRef(null),l=ji(a,u),{selectedValue:f,setSelectedValue:c,itemId:d,onItemSelect:h}=wl("ComposerSuggestionsListItem"),g=i?vt:"li",y=m.useMemo((()=>f===e),[f,e]),p=m.useMemo((()=>d(e)),[d,e]);m.useEffect((()=>{u?.current&&y&&u.current.scrollIntoView({block:"nearest"})}),[y]);const w=m.useCallback((E=>{n?.(E),E.isDefaultPrevented()||c(e)}),[n,c,e]),b=m.useCallback((E=>{r?.(E),E.preventDefault(),E.stopPropagation()}),[r]),C=m.useCallback((E=>{o?.(E);const A=E.isDefaultPrevented();E.preventDefault(),E.stopPropagation(),A||h(e)}),[o,h,e]);return v.jsx(g,{role:"option",id:p,"data-selected":y||void 0,"aria-selected":y||void 0,onPointerMove:w,onPointerDown:b,onClick:C,...s,ref:l,children:t})})),X2={Link:({href:e,children:t})=>v.jsx(W0,{href:e,children:t}),Mention:({mention:e})=>v.jsxs(Dl,{children:[An,e.id]}),MentionSuggestions:({mentions:e})=>e.length>0?v.jsx(z0,{children:v.jsx(K0,{children:e.map((t=>v.jsx(q0,{value:t.id,children:t.id},t.id)))})}):null},Y2=m.forwardRef((({defaultValue:e,onKeyDown:t,onFocus:n,onBlur:r,disabled:o,autoFocus:i,components:s,dir:a,...u},l)=>{const f=vc(),{editor:c,validate:d,setFocused:h,onEditorChange:g,roomId:y}=ea(),{submit:p,focus:w,blur:b,select:C,canSubmit:E,isDisabled:A,isFocused:x}=Wt(),I=hr(),T=(function(){const J=Ve();return m.useCallback((oe=>{J[Oe].usersStore.enqueue(oe)}),[J])})(),F=A||o,S=So(e??H2),k=m.useMemo((()=>{return(J=S)&&J?.content?J.content.map((oe=>{if(oe.type!=="paragraph")return null;const ge=oe.children.map((ve=>{return Fp(ve)?(Te=ve,{...Te,children:[{text:""}]}):Rp(ve)?(We=ve).text?{type:"custom-link",url:We.url,children:[{text:We.text}]}:{type:"auto-link",url:We.url,children:[{text:We.url}]}:!("type"in(Le=ve))&&"text"in Le&&typeof Le.text=="string"?ve:null;var Te,We,Le})).filter(xi);return{...oe,children:ge}})).filter(xi):N2;var J}),[S]),{Link:_,Mention:M,MentionSuggestions:H,FloatingToolbar:W}=m.useMemo((()=>({...X2,...s})),[s]),[G,q]=m.useState(!1),$=wc(),V=!f||$,[Q,ae]=m.useState(),ie=Ay(y,Q?.text),[Se,Ie,ne,B]=(function(J,oe,ge){const{wrap:ve}=m.useMemo((()=>({...v2,...ge})),[ge]),Te=m.useMemo((()=>ve?g2:yh),[ve]),[We,Le]=m.useState(J);return m.useEffect((()=>{Le((et=>yh(et,0,Math.max(oe-1,0))))}),[oe]),[We,m.useCallback((()=>{Le((et=>Te(et-1,0,Math.max(oe,0))))}),[oe,Te]),m.useCallback((()=>{Le((et=>Te(et+1,0,Math.max(oe,0))))}),[oe,Te]),Le]})(0,ie?.length??0),X=m.useId(),K=`liveblocks-floating-toolbar-${X}`,Y=`liveblocks-suggestions-list-${X}`,de=m.useCallback((J=>J?`liveblocks-suggestions-list-item-${X}-${J}`:void 0),[X]),pe=m.useCallback((J=>v.jsx(G2,{Mention:M,Link:_,...J})),[_,M]),fe=m.useCallback((J=>{d(J),g.notify()}),[d,g]),we=m.useCallback((J=>{Q&&J&&(z.select(c,Q.range),(function(oe,ge){const ve={type:"mention",...ge,children:[{text:""}]};z.insertNodes(oe,ve),z.move(oe);const Te=oe.selection?bl(oe,oe.selection):void 0;!Te||Te.void?z.insertText(oe," "):ko(Te.text)&&z.move(oe)})(c,J),ae(void 0),B(0))}),[c,Q,B]),Ce=m.useCallback((J=>{if(t?.(J),!J.isDefaultPrevented())if(At(J,"ArrowLeft")&&wh(c,"start"),At(J,"ArrowRight")&&wh(c,"end"),Q&&ie?.length){if(At(J,"ArrowDown")&&(J.preventDefault(),ne()),At(J,"ArrowUp")&&(J.preventDefault(),Ie()),At(J,"Enter")||At(J,"Tab")){J.preventDefault();const oe=ie?.[Se];we(oe)}At(J,"Escape")&&(J.preventDefault(),ae(void 0),B(0))}else G&&At(J,"Escape")&&(J.preventDefault(),q(!1)),At(J,"Escape")&&b(),At(J,"Enter",{shift:!1})&&(J.preventDefault(),E&&p()),At(J,"Enter",{shift:!0})&&(J.preventDefault(),c.insertBreak()),At(J,"b",{mod:!0})&&(J.preventDefault(),Qo(c,"bold")),At(J,"i",{mod:!0})&&(J.preventDefault(),Qo(c,"italic")),At(J,"s",{mod:!0,shift:!0})&&(J.preventDefault(),Qo(c,"strikethrough")),At(J,"e",{mod:!0})&&(J.preventDefault(),Qo(c,"code"))}),[t,Q,ie,G,c,ne,Ie,Se,we,B,b,E,p]),se=m.useCallback((J=>{n?.(J),J.isDefaultPrevented()||(h(!0),I&&T(I))}),[n,h,I,T]),te=m.useCallback((J=>{r?.(J),J.isDefaultPrevented()||h(!1)}),[r,h]),me=ie?.[Se],Ae=me?.id,Pe=m.useCallback((J=>{const oe=ie?.findIndex((ge=>ge.id===J));oe!==void 0&&oe>=0&&B(oe)}),[B,ie]),Fe=m.useMemo((()=>Q?{role:"combobox","aria-autocomplete":"list","aria-expanded":!0,"aria-controls":Y,"aria-activedescendant":de(Ae)}:G?{"aria-haspopup":!0,"aria-controls":K}:{}),[Q,Y,de,Ae,G,K]);m.useImperativeHandle(l,(()=>Z.toDOMNode(c,c)),[c]),xn((()=>{if(!i)return;const J=setTimeout((()=>w()),0);return()=>clearTimeout(J)}),[i,c,w]),xn((()=>{x&&c.selection===null&&C()}),[c,C,x]);const re=m.useCallback((J=>{const oe=ie?.find((ge=>ge.id===J));we(oe)}),[we,ie]);return v.jsxs(l2,{editor:c,initialValue:k,onChange:fe,children:[v.jsx(n2,{dir:a,tabIndex:F?-1:0,enterKeyHint:Q?"enter":"send",autoCapitalize:"sentences","aria-label":"Composer editor","data-focused":x||void 0,"data-disabled":F||void 0,...Fe,...u,readOnly:F,disabled:F,onKeyDown:Ce,onFocus:se,onBlur:te,renderElement:pe,renderLeaf:J2,renderPlaceholder:Z2}),V&&v.jsx(z2,{dir:a,mentionDraft:Q,setMentionDraft:ae,selectedMentionId:Ae,setSelectedMentionId:Pe,mentions:ie,id:Y,itemId:de,onItemSelect:re,MentionSuggestions:H}),W&&v.jsx(K2,{dir:a,id:K,hasFloatingToolbarRange:G,setHasFloatingToolbarRange:q,FloatingToolbar:W})]})})),Q2=m.forwardRef((({children:e,onSubmit:t,onComposerSubmit:n,defaultAttachments:r=[],pasteFilesAsAttachments:o,blurOnSubmit:i=!0,preventUnsavedChanges:s=!0,disabled:a,asChild:u,roomId:l,...f},c)=>{const d=u?vt:"form",[h,g]=m.useState(!0),[y,p]=m.useState(!1),[w,b]=m.useState(!1),C=zp({allowOutsideRoom:!0}),E=l!==void 0?l:C?.id;if(E===void 0)throw new Error("Composer.Form must be a descendant of RoomProvider.");const A=1073741824,{attachments:x,isUploadingAttachments:I,addAttachments:T,removeAttachment:F,clearAttachments:S}=U2(r,{maxFileSize:A,roomId:E}),k=x.length,_=k>=10,M=m.useMemo((()=>y||a===!0),[y,a]),H=m.useMemo((()=>!h&&!I),[h,I]),[W,G]=m.useState(Ch),q=m.useRef(null),$=ji(c,q),V=m.useRef(null),Q=(function(){const re=Ve()[Oe].createSyncSource,[J,oe]=m.useState();return m.useEffect((()=>{const ge=re();return oe(ge),()=>ge.destroy()}),[re]),J})(),ae=!!s&&(!h||I||x.length>0);m.useEffect((()=>{Q?.setSyncStatus(ae?"has-local-changes":"synchronized")}),[Q,ae]);const ie=m.useCallback((re=>{if(!re.length)return;const J=Math.max(0,10-k);re.splice(J);const oe=re.map((ge=>(function(ve){return{type:"localAttachment",status:"idle",id:lp(),name:ve.name,size:ve.size,mimeType:ve.type,file:ve}})(ge)));T(oe)}),[T,10,k]),Se=m.useRef(ie);m.useEffect((()=>{Se.current=ie}),[ie]);const Ie=m.useCallback((re=>{Se.current(re)}),[]),ne=So((()=>V2({createAttachments:Ie,pasteFilesAsAttachments:o}))),B=So(Ue),X=m.useCallback((re=>{g(Ju(ne,re))}),[ne]),K=m.useCallback((()=>{H&&requestAnimationFrame((()=>{q.current&&(function(re,J){if(typeof re.requestSubmit=="function")return re.requestSubmit(J);J?J.click():((J=document.createElement("input")).type="submit",J.hidden=!0,re.appendChild(J),J.click(),re.removeChild(J))})(q.current)}))}),[H]),Y=m.useCallback((()=>{z.delete(ne,{at:{anchor:D.start(ne,[]),focus:D.end(ne,[])}})}),[ne]),de=m.useCallback((()=>{z.select(ne,D.end(ne,[]))}),[ne]),pe=m.useCallback(((re=!0)=>{try{if(!Z.isFocused(ne)){z.select(ne,re||!ne.selection?D.end(ne,[]):ne.selection);const J=Z.toDOMNode(ne,ne);if(ne.selection){const oe=window.getSelection(),ge=ml(ne,ne.selection);ge&&(oe?.removeAllRanges(),oe?.addRange(ge))}J.focus({preventScroll:!0})}}catch{}}),[ne]),fe=m.useCallback((()=>{try{Z.blur(ne)}catch{}}),[ne]),we=m.useCallback((()=>{a||(pe(),(function(re){if(!re.selection)return;const J=Ai(re,re.selection,{filterVoids:!0}),oe=bl(re,re.selection,{filterVoids:!0}),ge=J&&!ko(J.text),ve=oe&&!ko(oe.text);if(U.isCollapsed(re.selection)){const Te=(ge?" ":"")+An;re.insertText(Te,{at:U.start(re.selection)}),ve&&re.insertText(" ",{at:U.end(re.selection)}),z.collapse(re,{edge:"end"})}else{const Te=(ge?" ":"")+An+(ve?" ":"");re.insertText(Te),ve&&z.move(re,{distance:1,unit:"character",reverse:!0})}})(ne))}),[a,ne,pe]),Ce=m.useCallback((re=>{a||(pe(!1),Hg(ne,re))}),[a,ne,pe]),se=m.useCallback((()=>{a||V.current&&V.current.click()}),[a]),te=m.useCallback((re=>{a||re.target.files&&(ie(Array.from(re.target.files)),re.target.value="")}),[ie,a]),me=m.useCallback((()=>{Y(),S(),p(!1),i&&fe()}),[fe,i,Y,S]),Ae=m.useCallback((re=>{if(a)return;if(Ju(ne,ne.children)||(t?.(re),!n||re.isDefaultPrevented()))return void re.preventDefault();const J=(function(ve){return{version:1,content:ve.map((Te=>{if(Te.type!=="paragraph")return null;const We=Te.children.map((Le=>{return ei(Le)?(function(ut){const{children:Nt,...hn}=ut;return hn})(Le):bo(Le)?{type:"link",url:Le.url}:Ps(Le)?{type:"link",url:(et=Le).url,text:et.children.map((ut=>ut.text)).join("")}:In(Le)?Le:null;var et})).filter(xi);return{...Te,children:We}})).filter(xi)}})(ne.children),oe=x.filter((ve=>ve.type==="attachment"||ve.type==="localAttachment"&&ve.status==="uploaded")).map((ve=>({id:ve.id,type:"attachment",mimeType:ve.mimeType,size:ve.size,name:ve.name}))),ge=n({body:J,attachments:oe},re);re.preventDefault(),ge?(p(!0),ge.then(me)):me()}),[a,ne,x,n,t,me]),Pe=m.useCallback((re=>{re.stopPropagation()}),[]),Fe=m.useCallback((re=>{Qo(ne,re)}),[ne]);return yl(B,(()=>{G(Ch(ne))})),v.jsx(D0.Provider,{value:{editor:ne,validate:X,setFocused:b,onEditorChange:B,roomId:E},children:v.jsx(A0.Provider,{value:{createAttachments:ie,isUploadingAttachments:I,hasMaxAttachments:_,maxAttachments:10,maxAttachmentSize:A},children:v.jsx(E0.Provider,{value:{isDisabled:M,isFocused:w,isEmpty:h,canSubmit:H,submit:K,clear:Y,select:de,focus:pe,blur:fe,createMention:we,insertText:Ce,attachments:x,attachFiles:se,removeAttachment:F,toggleMark:Fe,marks:W},children:v.jsxs(d,{...f,onSubmit:Ae,ref:$,children:[v.jsx("input",{type:"file",multiple:!0,ref:V,onChange:te,onClick:Pe,tabIndex:-1,style:{display:"none"}}),v.jsx(Sy,{children:e})]})})})})})),G0=m.forwardRef((({children:e,disabled:t,asChild:n,...r},o)=>{const i=n?vt:"button",{canSubmit:s,isDisabled:a}=Wt(),u=a||t||!s;return v.jsx(i,{type:"submit",...r,ref:o,disabled:u,children:e})})),eA=m.forwardRef((({children:e,onClick:t,disabled:n,asChild:r,...o},i)=>{const s=r?vt:"button",{hasMaxAttachments:a}=Cl(),{isDisabled:u,attachFiles:l}=Wt(),f=u||a||n,c=m.useCallback((d=>{t?.(d),d.isDefaultPrevented()||l()}),[l,t]);return v.jsx(s,{type:"button",...o,onClick:c,ref:i,disabled:f,children:e})}));m.forwardRef((({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o,asChild:i,...s},a)=>{const u=i?vt:"div",{isDisabled:l}=Wt(),f=l||o,[,c]=$0({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:f});return v.jsx(u,{...c,"data-disabled":f?"":void 0,...s,ref:a})}));const tA=m.forwardRef((({children:e,mark:t,onValueChange:n,onClick:r,onPointerDown:o,asChild:i,...s},a)=>{const u=i?vt:"button",{marks:l,toggleMark:f}=Wt(),c=m.useCallback((h=>{o?.(h),h.preventDefault(),h.stopPropagation()}),[o]),d=m.useCallback((h=>{r?.(h),h.isDefaultPrevented()||(h.preventDefault(),h.stopPropagation(),f(t),n?.(t))}),[t,r,n,f]);return v.jsx(Xc,{asChild:!0,pressed:l[t],onClick:d,onPointerDown:c,...s,children:v.jsx(u,{...s,ref:a,children:e})})})),kh={seconds:60,minutes:60,hours:24,days:7,weeks:4.34524,months:12};function nA(e,t){return Mu(Sg(t,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).format(e))}const rA=["br","fr","nb","nn","no","ro","sv"];function oA(e,t){return Math.abs(e.getTime()-Date.now())<=2592e5?(function(n,r){let o;r?o=r:o=Yd().resolvedOptions().locale;const i=rA.some((u=>o===u||o.startsWith(`${u}-`))),s=Yd(o,{style:i?"short":"narrow",numeric:"auto"});let a=(n.getTime()-Date.now())/1e3;if(a>-60&&a<kh.seconds)return s.format(0,"seconds");for(const[u,l]of Object.entries(kh)){if(Math.abs(a)<l)return s.format(Math.round(a),u);a/=l}return Mu(s.format(Math.round(a),"years"))})(e,t):(function(n,r){return Mu(Sg(r,{month:"short",day:"numeric"}).format(n))})(e,t)}const iA=m.forwardRef((({date:e,locale:t,children:n=oA,title:r=nA,dateTime:o,interval:i=3e4,asChild:s,...a},u)=>{const l=s?vt:"time",[f,c]=Tg(),d=m.useMemo((()=>new Date(e)),[e]),h=m.useMemo((()=>d.toISOString()),[d]),g=m.useMemo((()=>typeof r=="function"?r(d,t):r),[r,d,t,c]),y=m.useMemo((()=>typeof n=="function"?n(d,t):n),[n,d,t,c]);return Ig(f,i),v.jsx(l,{...a,ref:u,dateTime:o??h,title:g,children:y})}));function J0(e){const t=So(e),n=t.userIds;if(t.kind!=="group")return!1;if(Array.isArray(n)){const r=hr();return m.useMemo((()=>n.some((o=>o===r))),[n,r])}{const r=hr(),{group:o}=(function(i){const s=Ve()[Oe].httpClient.groupsStore,a=m.useCallback((()=>s.getItemState(i)),[s,i]);return m.useEffect((()=>{s.enqueue(i)}),[s,i]),Si(s.subscribe,a,a,Dy,lt)})(t.id);return m.useMemo((()=>!!o?.members.some((i=>i.id===r))),[o,r])}}const qa=["B","KB","MB","GB"];function Bh(e,t){if(e===0)return`0 ${qa[1]}`;let n;n=e===0?1:Math.max(1,Math.min(Math.floor(Math.log(Math.abs(e))/Math.log(1e3)),qa.length-1));let r=e/1e3**n,o=1;n===1&&(r>=10&&(o=0),r<.1&&r>0&&(o=2),r<.01&&(r=.01));const i=qa[n];return`${Mr(t,{minimumFractionDigits:0,maximumFractionDigits:o}).format(r)} ${i}`}const Z0=62914560,sA=/^(.+?)(\.[^.]+)?$/,aA=m.memo((({mimeType:e})=>{const t=m.useMemo((()=>(function(n){return n==="application/zip"||n==="application/gzip"||n==="application/vnd.rar"||n==="application/x-rar-compressed"||n==="application/x-7z-compressed"||n==="application/x-zip-compressed"||n==="application/x-tar"||n==="application/x-bzip"||n==="application/x-bzip2"?v.jsx("path",{d:"M13 15h2v1h-1.5a.5.5 0 0 0 0 1H15v1h-1.5a.5.5 0 0 0 0 1H15v1h-1.5a.5.5 0 0 0 0 1h1a.5.5 0 0 0 .5-.5V20h1.5a.5.5 0 0 0 0-1H15v-1h1.5a.5.5 0 0 0 0-1H15v-1h1.5a.5.5 0 0 0 .5-.5V15a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2Z"}):n.startsWith("text/")||n.startsWith("font/")||n.startsWith("application/")?v.jsx("path",{d:"M10 16a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1h-8a.5.5 0 0 1-.5-.5Z"}):n.startsWith("image/")?v.jsx("path",{d:"M12 16h6a1 1 0 0 1 1 1v3l-1.293-1.293a1 1 0 0 0-1.414 0L14.09 20.91l-.464-.386a1 1 0 0 0-1.265-.013l-1.231.985A.995.995 0 0 1 11 21v-4a1 1 0 0 1 1-1Zm-2 1a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-4Zm3 2a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}):n.startsWith("video/")?v.jsx("path",{d:"M12 15.71a1 1 0 0 1 1.49-.872l4.96 2.79a1 1 0 0 1 0 1.744l-4.96 2.79A1 1 0 0 1 12 21.29v-5.58Z"}):n.startsWith("audio/")?v.jsx("path",{d:"M15 15a.5.5 0 0 0-.5.5v7a.5.5 0 0 0 1 0v-7a.5.5 0 0 0-.5-.5Zm-2.5 2.5a.5.5 0 0 1 1 0v3a.5.5 0 0 1-1 0v-3Zm-2 1a.5.5 0 0 1 1 0v1a.5.5 0 0 1-1 0v-1Zm6-1a.5.5 0 0 1 1 0v3a.5.5 0 0 1-1 0v-3ZM19 16a.5.5 0 0 0-.5.5v5a.5.5 0 0 0 1 0v-5a.5.5 0 0 0-.5-.5Z"}):null})(e)),[e]);return v.jsxs("svg",{className:"lb-attachment-icon",width:30,height:30,viewBox:"0 0 30 30",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",className:"lb-attachment-icon-shadow"}),v.jsx("path",{d:"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",className:"lb-attachment-icon-background"}),v.jsx("path",{d:"M14.382 3.037a4 4 0 0 1 2.29 1.135l6.156 6.157a4 4 0 0 1 1.136 2.289A2 2 0 0 0 22 11h-4a2 2 0 0 1-2-2V5a2 2 0 0 0-1.618-1.963Z",className:"lb-attachment-icon-fold"}),t&&v.jsx("g",{className:"lb-attachment-icon-glyph",children:t})]})}));function uA({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=Ws(e.id,n),[o,i]=m.useState(!1),s=m.useCallback((()=>{i(!0)}),[]);return v.jsxs(v.Fragment,{children:[o?null:v.jsx(_i,{}),r?v.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:v.jsx("img",{src:r,loading:"lazy",onLoad:s,onError:t})}):null]})}function cA({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=Ws(e.id,n),[o,i]=m.useState(!1),s=m.useCallback((()=>{i(!0)}),[]);return v.jsxs(v.Fragment,{children:[o?null:v.jsx(_i,{}),r?v.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:v.jsx("video",{src:r,onLoadedData:s,onError:t})}):null]})}function X0({attachment:e,allowMediaPreview:t=!0,roomId:n}){const[r,o]=m.useState(!1),i=e.type==="attachment"||e.status==="uploaded";function s(){o(!0)}if(!r&&t&&i&&e.size<=Z0){if(e.mimeType.startsWith("image/"))return v.jsx(uA,{attachment:e,markPreviewAsUnsupported:s,roomId:n});if(e.mimeType.startsWith("video/"))return v.jsx(cA,{attachment:e,markPreviewAsUnsupported:s,roomId:n})}return v.jsx(aA,{mimeType:e.mimeType})}function Y0({attachment:e}){const{base:t,extension:n}=m.useMemo((()=>(function(r){const o=r.match(sA);return{base:o?.[1]??r,extension:o?.[2]}})(e.name)),[e.name]);return v.jsxs("span",{className:"lb-attachment-name",title:e.name,children:[v.jsx("span",{className:"lb-attachment-name-base",children:t}),n&&v.jsx("span",{className:"lb-attachment-name-extension",children:n})]})}function Q0(e){return m.useCallback((t=>{if(e?.(t),!t.isDefaultPrevented()&&(t.key==="Enter"||t.key===" ")){t.preventDefault();const n=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});t.target.dispatchEvent(n)}}),[e])}function ev(e,t){const n=Mt(t),r=S0(),o=!!r,i=r?.maxAttachmentSize,s=e.type==="localAttachment"?e.status:void 0,a=s==="uploading",u=s==="error";let l;return l=e.type==="localAttachment"&&e.status==="error"?e.error instanceof ec?e.error.origin==="server"?n.ATTACHMENT_TOO_LARGE():n.ATTACHMENT_TOO_LARGE(i?Bh(i,n.locale):void 0):n.ATTACHMENT_ERROR(e.error):Bh(e.size,n.locale),{isUploading:a,isError:u,description:l,deleteLabel:o?n.COMPOSER_REMOVE_ATTACHMENT:n.COMMENT_DELETE_ATTACHMENT}}function lA({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:i=!0,roomId:s,className:a,onKeyDown:u,...l}){const{isUploading:f,isError:c,description:d,deleteLabel:h}=ev(e,t),g=m.useCallback((p=>{o&&p.preventDefault()}),[o]),y=Q0(u);return v.jsxs("div",{className:Ne("lb-attachment lb-media-attachment",a),"data-error":c?"":void 0,...l,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?y:void 0,children:[v.jsx("div",{className:"lb-attachment-preview",children:f?v.jsx(_i,{}):c?v.jsx(Mg,{}):v.jsx(X0,{attachment:e,allowMediaPreview:i,roomId:s})}),v.jsxs("div",{className:"lb-attachment-details",children:[v.jsx(Y0,{attachment:e}),v.jsx("span",{className:"lb-attachment-description",title:d,children:d})]}),r&&v.jsx(jt,{content:h,children:v.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:g,"aria-label":h,children:v.jsx(il,{})})})]})}function tv({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:i=!0,roomId:s,className:a,onKeyDown:u,...l}){const{isUploading:f,isError:c,description:d,deleteLabel:h}=ev(e,t),g=m.useCallback((p=>{o&&p.preventDefault()}),[o]),y=Q0(u);return v.jsxs("div",{className:Ne("lb-attachment lb-file-attachment",a),"data-error":c?"":void 0,...l,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?y:void 0,children:[v.jsx("div",{className:"lb-attachment-preview",children:f?v.jsx(_i,{}):c?v.jsx(Mg,{}):v.jsx(X0,{attachment:e,allowMediaPreview:i,roomId:s})}),v.jsxs("div",{className:"lb-attachment-details",children:[v.jsx(Y0,{attachment:e}),v.jsx("span",{className:"lb-attachment-description",title:d,children:d})]}),r&&v.jsx(jt,{content:h,children:v.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:g,"aria-label":h,children:v.jsx(il,{})})})]})}function dA({className:e,...t}){return v.jsx("a",{href:"https://liveblocks.io",target:"_blank",rel:"noopener noreferrer",className:Ne("lb-composer-attribution",e),...t,children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 72","aria-label":"Made with Liveblocks",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M86 10h-8v50h8V10Zm16 14h-8v36h8V24Zm0-15h-8v9h8V9Zm13 15h-9l12 36h10l13-36h-9l-9 28-8-28Zm44-1c-11 0-18 8-18 19s7 19 18 19c8 0 15-4 17-13h-8c-1 4-5 6-9 6-6 0-9-3-9-10h27c0-10-6-21-18-21Zm0 7c5 0 9 3 9 8h-18c0-5 4-8 9-8Zm42-7c-4 0-8 2-11 6V10h-8v50h8v-5c3 4 7 6 11 6 11 0 16-9 16-19s-5-19-16-19Zm-2 32c-7 0-9-7-9-13s2-13 9-13 9 7 9 13-2 13-9 13Zm32-45h-8v50h8V10Zm24 51c11 0 18-8 18-19s-8-19-18-19c-11 0-19 8-19 19s7 19 19 19Zm0-6c-8 0-10-7-10-13s2-13 10-13c7 0 9 7 9 13s-2 13-9 13Zm39 6c8 0 15-4 17-12l-8-1c-2 4-4 6-9 6-7 0-9-6-9-12s2-12 9-12c5 0 8 3 8 7l9-1c-2-8-9-13-17-13-11 0-18 9-18 19 0 11 7 19 18 19Zm30-14 4-4 10 17h10l-15-23 15-13h-11l-13 13V10h-9v50h9V47Zm39 14c8 0 16-3 16-12 0-8-8-10-15-11-2-1-7-1-7-5 0-3 3-4 6-4 4 0 7 3 7 7l8-1c-1-9-8-12-15-12s-15 3-15 11 9 10 15 11c3 1 8 2 8 5 0 4-4 5-7 5-5 0-8-3-9-7l-8 1c1 8 9 12 16 12ZM41 27H0l12 12v17l29-29ZM20 60h40L48 48V32L20 60Z",fill:"currentColor"})})})}var fA=Object.defineProperty,Fn={};((e,t)=>{for(var n in t)fA(e,n,{get:t[n],enumerable:!0})})(Fn,{ActiveEmoji:()=>Dv,Empty:()=>Ev,List:()=>bv,Loading:()=>wv,Root:()=>fv,Search:()=>hv,SkinTone:()=>Av,SkinToneSelector:()=>Cv,Viewport:()=>pv});var nv="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",Al=["none","light","medium-light","medium","medium-dark","dark"];function Ga(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ct=null;function Fh(e){try{Ct??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!Ct||(queueMicrotask((()=>{Ct&&(Ct=null)})),Ct.canvas.width=2,Ct.canvas.height=2,Ct.font=`2px ${nv}`,Ct.textBaseline="middle",Ct.measureText(e).width>=4))return!1;Ct.fillStyle="#00f",Ct.fillText(e,0,0);let t=Ct.getImageData(0,0,2,2).data;Ct.clearRect(0,0,2,2),Ct.fillStyle="#f00",Ct.fillText(e,0,0);let n=Ct.getImageData(0,0,2,2).data;for(let r=0;r<16;r+=4)if(t[r]!==n[r]||t[r+1]!==n[r+1]||t[r+2]!==n[r+2])return!1;return!0}function Rh(e,t,n){try{let r=e.getItem(t);if(!r)throw new Error(`No value found for "${t}".`);return n(JSON.parse(r))}catch{return null}}function rv(e,t,n){e.setItem(t,JSON.stringify(n))}function _h(e){return t=>t===void 0?void 0:e(t)}function jh(e){return t=>t===null?null:e(t)}function yt(e){if(typeof e!="string")throw new Error;return e}function ws(e){if(typeof e!="number")throw new Error;return e}function ov(e){if(typeof e!="boolean")throw new Error;return e}function tr(e){return t=>{if(typeof t!="object"||t===null)throw new Error;let n={};for(let r in e){let o=t[r];o===void 0&&e[r](void 0),n[r]=e[r](o)}return n}}function Ja(e){return t=>{if(!Array.isArray(t))throw new Error;return t.length>0&&e(t[0]),t}}var iv=(e,t)=>`${e}/${t}/data.json`,sv=(e,t)=>`${e}/${t}/messages.json`,hA=["bn","da","de","en-gb","en","es-mx","es","et","fi","fr","hi","hu","it","ja","ko","lt","ms","nb","nl","pl","pt","ru","sv","th","uk","vi","zh-hant","zh"],av=e=>`frimousse/data/${e}`,Mh="frimousse/metadata";async function Ph(e,t){try{return(await fetch(e,{method:"HEAD",signal:t})).headers.get("etag")}catch{return null}}function pA(e){return e.skins?e.skins.filter((t=>typeof t.tone=="number")).reduce(((t,n)=>(t[Al[n.tone]]=n.emoji,t)),{}):void 0}async function Nh(e,t,n){let{emojis:r,emojisEtag:o,messages:i,messagesEtag:s}=await(async function(g,y,p){let[{emojis:w,emojisEtag:b},{messages:C,messagesEtag:E}]=await Promise.all([fetch(iv(g,y),{signal:p}).then((async A=>({emojis:await A.json(),emojisEtag:A.headers.get("etag")}))),fetch(sv(g,y),{signal:p}).then((async A=>({messages:await A.json(),messagesEtag:A.headers.get("etag")})))]);return{emojis:w,messages:C,emojisEtag:b,messagesEtag:E}})(e,t,n),a=i.subgroups.find((g=>g.key==="country-flag"||g.key==="subdivision-flag")),u=i.groups.filter((g=>g.key!=="component")),l=r.filter((g=>"group"in g)),f=u.map((g=>({index:g.order,label:Ga(g.message)}))),c=i.skinTones.reduce(((g,y)=>(g[y.key]=Ga(y.message),g)),{}),d=l.map((g=>({emoji:g.emoji,category:g.group,version:g.version,label:Ga(g.label),tags:g.tags??[],countryFlag:a&&g.subgroup===a.order||void 0,skins:pA(g)}))),h={locale:t,emojis:d,categories:f,skinTones:c};return rv(localStorage,av(t),{data:h,metadata:{emojisEtag:o,messagesEtag:s}}),h}var mA=tr({emojiVersion:ws,countryFlags:ov}),gA=tr({data:tr({locale:yt,emojis:Ja(tr({emoji:yt,category:ws,label:yt,version:ws,tags:Ja(yt),countryFlag:_h(ov),skins:_h(tr({light:yt,"medium-light":yt,medium:yt,"medium-dark":yt,dark:yt}))})),categories:Ja(tr({index:ws,label:yt})),skinTones:tr({light:yt,"medium-light":yt,medium:yt,"medium-dark":yt,dark:yt})}),metadata:tr({emojisEtag:jh(yt),messagesEtag:jh(yt)})});async function vA({locale:e,emojiVersion:t,emojibaseUrl:n,signal:r}){let o,i=typeof n=="string"?n:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof t=="number"?Math.floor(t):"latest"}`,s=Rh(sessionStorage,Mh,mA),a=Rh(localStorage,av(e),gA);if(a)if(s)o=a.data;else try{let{emojisEtag:u,messagesEtag:l}=await(async function(f,c,d){let[h,g]=await Promise.all([Ph(iv(f,c),d),Ph(sv(f,c),d)]);return{emojisEtag:h,messagesEtag:g}})(i,e,r);o=u&&l&&u===a.metadata.emojisEtag&&l===a.metadata.messagesEtag?a.data:await Nh(i,e,r)}catch{o=a.data}else o=await Nh(i,e,r);return s??=(function(u,l){let f=new Map;for(let g of u)f.has(g.version)||f.set(g.version,g.emoji);let c=[...f.keys()].sort(((g,y)=>y-g)),d=c[0]??0,h=Fh("🇪🇺");if(typeof l=="number")return{emojiVersion:l,countryFlags:h};for(let g of c)if(Fh(f.get(g)))return{emojiVersion:g,countryFlags:h};return{emojiVersion:d,countryFlags:h}})(o.emojis,t),rv(sessionStorage,Mh,s),{locale:e,emojis:o.emojis.filter((u=>{let l=u.version<=s.emojiVersion;return u.countryFlag?l&&s.countryFlags:l})),categories:o.categories,skinTones:o.skinTones}}function Lh(e){return hA.includes(e)?e:(console.warn(`Locale "${e}" is not supported, using "en" instead.`),"en")}function Uh(e){return Al.includes(e)?e:(console.warn(`Skin tone "${e}" is not valid, using "none" instead.`),"none")}function yA(e,t){let n=[];if(t<=0)return n;for(let r=0,o=e.length;r<o;r+=t)n.push(e.slice(r,r+t));return n}function bA(e,t,n,r){let o=(function(c,d){if(!d)return c;let h=d.toLowerCase().trim(),g=new WeakMap;return c.filter((y=>{let p=0;y.label.toLowerCase().includes(h)&&(p+=10);for(let w of y.tags)w.toLowerCase().includes(h)&&(p+=1);return p>0&&(g.set(y,p),!0)})).sort(((y,p)=>(g.get(p)??0)-(g.get(y)??0)))})(e.emojis,r),i=[],s=[],a=[],u={},l=0,f=0;for(let c of o)u[c.category]||(u[c.category]=[]),u[c.category].push({emoji:n&&n!=="none"&&c.skins?c.skins[n]:c.emoji,label:c.label});for(let c of e.categories){let d=u[c.index];if(!d||d.length===0)continue;let h=yA(Array.from(d),t).map((g=>({categoryIndex:l,emojis:g})));i.push(...h),s.push({label:c.label,rowsCount:h.length,startRowIndex:f}),a.push(f),l++,f+=h.length}return{count:o.length,categories:s,categoriesStartRowIndices:a,rows:i,skinTones:e.skinTones}}function Vt(e,t,n=Object.is){let[r,o]=m.useState((()=>t(e.get())));return m.useEffect((()=>e.subscribe((()=>{let i=t(e.get());o((s=>n(s,i)?s:i))}))),[e,t,n]),m.useDebugValue(r),r}function Nn(e,t,n){let r=m.useCallback((o=>o[t]),[t]);return Vt(e,r,n)}function CA(e,t,n,r){let o=0;return(function(i){let s={},a=null,u=null,l=new Set,f=()=>{if(a){s=a,a=null;for(let h of l)h(s)}u=null},c=()=>a??s,d=h=>{a??=s,Object.assign(a,typeof h=="function"?h(c()):h),u||(u=requestAnimationFrame(f))};return s=i(d,c),{get:c,set:d,subscribe:h=>(l.add(h),()=>l.delete(h))}})(((i,s)=>({locale:t,columns:n,skinTone:r,onEmojiSelect:e,data:null,search:"",interaction:"none",activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:a=>{let u=s(),l=a?.data??u.data,f=a?.categoryHeaderHeight??u.categoryHeaderHeight,c=a?.rowHeight??u.rowHeight,d=a?.viewportHeight??u.viewportHeight;if(!(l&&l.rows.length!==0&&f&&c&&d))return i({...a,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let h=0,g=0;for(let I of l.categories){if(!(g++*f+I.startRowIndex*c<o))break;h+=f}let y=l.categories.length*f+l.rows.length*c,p=Math.floor(2*c/2),w=Math.ceil(2*c/2),b=Math.min(o-h-p,y-d),C=b+d+w,E=Math.max(0,Math.floor(b/c)),A=Math.min(l.rows.length-1,Math.ceil(C/c)),x=l.rows[E]?.categoryIndex;return i(x===void 0&&a?a:{...a,viewportStartCategoryIndex:x,viewportStartRowIndex:E,viewportEndRowIndex:A})},onDataChange:a=>{s().updateViewportState({data:a,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:a=>{i({search:a,interaction:a?"keyboard":"none"})},onActiveEmojiChange:(a,u,l)=>{if(i({interaction:a,activeColumnIndex:u,activeRowIndex:l}),a!=="keyboard")return;let{listRef:f,viewportRef:c,rowHeight:d,viewportHeight:h,categoryHeaderHeight:g}=s(),y=f?.current,p=c?.current;if(!(y&&p&&d&&g&&h))return;let w=l;w===0&&p.scrollTo({top:0,behavior:"instant"});let b=y.querySelector(`[aria-rowindex="${w}"]`);if(!(b instanceof HTMLElement))return;let C=b.offsetTop,E=getComputedStyle(b),A=Number.parseFloat(E.scrollMarginTop),x=Number.parseFloat(E.scrollMarginBottom),I=o+A;C<o+h/2&&(I+=g),(C<I||C+d>I+h-x)&&p.scrollTo({top:Math.max(C<I+g?C-Math.max(g,A):C-h+d+x,0),behavior:"instant"})},onActiveEmojiReset:()=>{i({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:a=>{s().updateViewportState({rowHeight:a})},onCategoryHeaderHeightChange:a=>{s().updateViewportState({categoryHeaderHeight:a})},onViewportSizeChange:(a,u)=>{s().updateViewportState({viewportWidth:a,viewportHeight:u})},onViewportScroll:a=>{o=a,s().updateViewportState()}})))}var{useStore:Pt,Provider:wA}=(function(e){let t=m.createContext(null);return{useStore:()=>{let n=m.useContext(t);if(!n)throw new Error(e);return n},Provider:({store:n,children:r})=>v.jsx(t.Provider,{value:n,children:r})}})("EmojiPicker.Root is missing.");function EA(e){return e.search}function xl(e){return e.interaction==="none"?void 0:e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex]}function DA(e){return e.data===void 0||typeof e.data?.count=="number"&&e.data.count===0}function AA(e){return e.data===null||e.viewportHeight===null||e.rowHeight===null||e.categoryHeaderHeight===null}function uv(e){return e.data?.rows.length}function xA(e){return e.data?.categories.length}function OA(e){return e.data?.categoriesStartRowIndices}function SA(e){return e.data?.skinTones}function cv(e,t){return e?.emoji===t?.emoji}function IA(e,t){return e?.categoryIndex===t?.categoryIndex&&e?.emojis.length===t?.emojis.length&&!!e?.emojis.every(((n,r)=>cv(n,t?.emojis[r])))}var Zo="",Hh=new RegExp("\\p{Emoji_Modifier_Base}","u"),TA=/\uFE0F$/,kA=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,BA={light:"🏻","medium-light":"🏼",medium:"🏽","medium-dark":"🏾",dark:"🏿"};function FA(e,t){if(!e.split(Zo).some((r=>Hh.test(r))))return e;let n=e.split(Zo).map((r=>r.replace(kA,""))).join(Zo);return t==="none"?n:n.split(Zo).map(((r,o,i)=>{let s=i.length>1;return!Hh.test(r)||s&&r==="🤝"?r:r.replace(TA,"")+BA[t]})).join(Zo)}function lv(){let e=Vt(Pt(),xl,cv);return m.useDeferredValue(e)}function dv(e="✋"){let t=Pt(),n=Nn(t,"skinTone"),r=m.useMemo((()=>(function(o){return Al.map((i=>({skinTone:i,emoji:FA(o,i)})))})(e)),[e]);return[n,m.useCallback((o=>{t.set({skinTone:o})}),[]),r]}function Ol(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((o=>o in t&&e[o]===t[o]))}function RA(...e){}var Cn=typeof window<"u"?m.useLayoutEffect:m.useEffect;function _A({emojiVersion:e,emojibaseUrl:t}){let[n,r]=m.useState(void 0),o=Pt(),i=Nn(o,"locale"),s=Nn(o,"columns"),a=Nn(o,"skinTone"),u=Nn(o,"search");return m.useEffect((()=>{let l=new AbortController,f=l.signal;return vA({locale:i,emojiVersion:e,emojibaseUrl:t,signal:f}).then((c=>{r(c)})).catch((c=>{f.aborted||console.error(c)})),()=>{l.abort()}}),[e,t,i]),m.useEffect((()=>{if(n)return(function(l,f){let c=null;if(typeof window.requestIdleCallback=="function")c=window.requestIdleCallback(l,f);else{let d=Date.now();c=window.setTimeout((()=>{l({didTimeout:!1,timeRemaining:()=>Math.max(0,f?.timeout-(Date.now()-d))})}),10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback(c):window.clearTimeout(c)}})((()=>{o.get().onDataChange(bA(n,s,a,u))}),{timeout:100})}),[n,s,a,u]),null}var fv=m.forwardRef((({locale:e="en",columns:t=9,skinTone:n="none",onEmojiSelect:r=RA,emojiVersion:o,emojibaseUrl:i,onFocusCapture:s,onBlurCapture:a,children:u,style:l,...f},c)=>{let d=(function(E){let A=m.useRef(E);return Cn((()=>{A.current=E})),m.useCallback(((...x)=>A.current(...x)),[])})(r),h=(function(E){let[A]=m.useState(E);return A})((()=>CA(d,Lh(e),t,Uh(n)))),[g,y]=m.useState(!1),p=m.useRef(null),w=m.useCallback((E=>{E&&(p.current=E,h.set({rootRef:p}))}),[]);Cn((()=>{h.set({locale:Lh(e)})}),[e]),Cn((()=>{h.set({columns:t})}),[t]),Cn((()=>{h.set({skinTone:Uh(n)})}),[n]);let b=m.useCallback((E=>{s?.(E);let{searchRef:A,viewportRef:x}=h.get(),I=E.target===A?.current||E.target.hasAttribute("frimousse-search"),T=E.target===x?.current||E.target.hasAttribute("frimousse-viewport");E.isDefaultPrevented()||(y(I||T),E.isDefaultPrevented()||(y(I||T),T?h.get().onActiveEmojiChange("keyboard",0,0):I&&h.get().search===""&&h.set({interaction:"none"})))}),[s]),C=m.useCallback((E=>{a?.(E),!E.isDefaultPrevented()&&!E.currentTarget.contains(E.relatedTarget)&&y(!1)}),[a]);return Cn((()=>{g||h.get().onActiveEmojiReset()}),[g]),m.useImperativeHandle(c,(()=>p.current)),m.useEffect((()=>{if(g)return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)};function E(A){if(A.defaultPrevented||!A.key.startsWith("Arrow")&&A.key!=="Enter")return;let{data:x,onEmojiSelect:I,onActiveEmojiChange:T,interaction:F,activeColumnIndex:S,activeRowIndex:k}=h.get();if(A.key==="Enter"){let _=xl(h.get());_&&(A.preventDefault(),I(_))}if(A.key.startsWith("Arrow")){let _=S,M=k;if(A.preventDefault(),F!=="none"){if(x?.rows&&x.rows.length>0)switch(A.key){case"ArrowLeft":if(_===0){let H=M-1,W=x.rows[H];W&&(M=H,_=W.emojis.length-1)}else _-=1;break;case"ArrowRight":if(_===x.rows[M].emojis.length-1){let H=M+1;x.rows[H]&&(M=H,_=0)}else _+=1;break;case"ArrowUp":{let H=x.rows[M-1];H&&(M-=1,H.emojis[_]||(_=H.emojis.length-1));break}case"ArrowDown":{let H=x.rows[M+1];H&&(M+=1,H.emojis[_]||(_=H.emojis.length-1));break}}T("keyboard",_,M)}else T("keyboard",0,0)}}}),[g]),Cn((()=>{let E=null,A=null,x=null,I=null,T=h.subscribe((M=>{p.current&&(E!==M.viewportWidth&&(E=M.viewportWidth,p.current.style.setProperty("--frimousse-viewport-width",`${M.viewportWidth}px`)),A!==M.viewportHeight&&(A=M.viewportHeight,p.current.style.setProperty("--frimousse-viewport-height",`${M.viewportHeight}px`)),x!==M.rowHeight&&(x=M.rowHeight,p.current.style.setProperty("--frimousse-row-height",`${M.rowHeight}px`)),I!==M.categoryHeaderHeight&&(I=M.categoryHeaderHeight,p.current.style.setProperty("--frimousse-category-header-height",`${M.categoryHeaderHeight}px`)))})),{viewportWidth:F,viewportHeight:S,rowHeight:k,categoryHeaderHeight:_}=h.get();return F&&p.current.style.setProperty("--frimousse-viewport-width",`${F}px`),S&&p.current.style.setProperty("--frimousse-viewport-height",`${S}px`),k&&p.current.style.setProperty("--frimousse-row-height",`${k}px`),_&&p.current.style.setProperty("--frimousse-category-header-height",`${_}px`),T}),[]),v.jsx("div",{"data-focused":g?"":void 0,"frimousse-root":"",onBlurCapture:C,onFocusCapture:b,...f,ref:w,style:{"--frimousse-emoji-font":nv,...l},children:v.jsxs(wA,{store:h,children:[v.jsx(_A,{emojiVersion:o,emojibaseUrl:i}),u]})})})),hv=m.forwardRef((({value:e,defaultValue:t,onChange:n,...r},o)=>{let i=Pt(),s=m.useRef(null),a=m.useCallback((c=>{c&&(s.current=c,i.set({searchRef:s}))}),[]),u=typeof e=="string",l=m.useRef(u);m.useEffect((()=>{l.current=u}),[u]),Cn((()=>{i.set({search:typeof e=="string"?e:typeof t=="string"?t:""})}),[]),Cn((()=>{typeof e=="string"&&i.get().onSearchChange(e)}),[e]);let f=m.useCallback((c=>{n?.(c),c.isDefaultPrevented()||i.get().onSearchChange(c.target.value)}),[n]);return m.useImperativeHandle(o,(()=>s.current)),v.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...r,defaultValue:t,onChange:f,ref:a,value:e})})),jA=m.memo((()=>{let e=lv();return e?v.jsx("div",{"aria-live":"polite",style:{border:0,clip:"rect(0, 0, 0, 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1,wordWrap:"normal"},children:e.label}):null})),pv=m.forwardRef((({children:e,onScroll:t,onKeyDown:n,style:r,...o},i)=>{let s=Pt(),a=m.useRef(null),u=m.useCallback((d=>{d&&(a.current=d,s.set({viewportRef:a}))}),[]),l=Vt(s,uv),f=Vt(s,xA),c=m.useCallback((d=>{t?.(d),s.get().onViewportScroll(d.currentTarget.scrollTop)}),[t]);return Cn((()=>{if(!a.current)return;let d=new ResizeObserver((([h])=>{let g=h?.borderBoxSize[0]?.inlineSize??0,y=h?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:p,viewportHeight:w,viewportWidth:b}=s.get();(w!==y||b!==g)&&p(g,y)}));return d.observe(a.current),s.get().onViewportSizeChange(a.current.offsetWidth,a.current.clientHeight),()=>{d.disconnect()}}),[]),m.useImperativeHandle(i,(()=>a.current)),v.jsxs("div",{"frimousse-viewport":"",...o,onScroll:c,ref:u,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof l=="number"&&typeof f=="number"?`var(--frimousse-viewport-width, auto) calc(${l} * var(--frimousse-row-height) + ${f} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...r},children:[v.jsx(jA,{}),e]})}));function mv(e,t,n){return{emoji:{...e,isActive:n},role:"gridcell","aria-colindex":t,"aria-selected":n||void 0,"aria-label":e.label,"data-active":n?"":void 0,"frimousse-emoji":"",style:{fontFamily:"var(--frimousse-emoji-font)"},tabIndex:-1}}function gv(e,t=!1){return{role:t?void 0:"row","aria-rowindex":t?void 0:e,"frimousse-row":"",style:{contain:t?void 0:"content",height:t?void 0:"var(--frimousse-row-height)",display:"flex"}}}function vv(e,t){return{"frimousse-category":"",style:{contain:"content",top:t?`calc(${e} * var(--frimousse-category-header-height) + ${t.startRowIndex} * var(--frimousse-row-height))`:void 0,height:t?`calc(var(--frimousse-category-header-height) + ${t.rowsCount} * var(--frimousse-row-height))`:void 0,width:"100%",pointerEvents:"none",position:"absolute"}}}function yv(e,t=!1){return{category:e,"frimousse-category-header":"",style:{contain:t?void 0:"layout paint",height:t?void 0:"var(--frimousse-category-header-height)",pointerEvents:"auto",position:"sticky",top:0}}}function Vh(e,t,n,r){return{"frimousse-list-sizer":"",style:{position:"relative",boxSizing:"border-box",height:`calc(${e} * var(--frimousse-row-height) + ${t} * var(--frimousse-category-header-height))`,paddingTop:`calc(${n} * var(--frimousse-row-height) + ${r} * var(--frimousse-category-header-height))`}}}function $h(e,t,n){return{"aria-colcount":e,"aria-rowcount":t,"frimousse-list":"",style:{"--frimousse-list-columns":e,...n},role:"grid"}}function MA(e){e.preventDefault()}var PA=m.memo((({Emoji:e,emoji:t,columnIndex:n,rowIndex:r})=>{let o=Pt(),i=Vt(o,(l=>xl(l)?.emoji===t.emoji)),s=m.useCallback((()=>{o.get().onEmojiSelect(t)}),[t]),a=m.useCallback((()=>{o.get().onActiveEmojiChange("pointer",n,r)}),[n,r]),u=m.useCallback((()=>{o.get().onActiveEmojiReset()}),[]);return v.jsx(e,{...mv(t,n,i),onClick:s,onPointerDown:MA,onPointerEnter:a,onPointerLeave:u})})),NA=m.memo((({Row:e,Emoji:t,rowIndex:n})=>{let r=Vt(Pt(),(o=>o.data?.rows[n]),IA);return r?v.jsx(e,{...gv(n),children:r.emojis.map(((o,i)=>v.jsx(PA,{Emoji:t,columnIndex:i,emoji:o,rowIndex:n},o.label)))}):null})),LA=m.memo((({CategoryHeader:e,categoryIndex:t})=>{let n=Vt(Pt(),(r=>r.data?.categories[t]),Ol);return n?v.jsx("div",{...vv(t,n),children:v.jsx(e,{...yv({label:n.label})})}):null})),Wh=m.memo((({CategoryHeader:e,Row:t,Emoji:n})=>{let r=m.useRef(null),o=Pt(),i=Nn(o,"columns"),s=m.useMemo((()=>Array(i).fill({emoji:"🙂",label:""})),[i]),a=m.useMemo((()=>({label:"Category"})),[]),u=m.useRef(null),l=m.useRef(null);return Cn((()=>{let f=r.current?.parentElement?.parentElement;if(!f||!u.current||!l.current)return;let c=new ResizeObserver((g=>{for(let y of g){let p=y.contentRect.height,{onRowHeightChange:w,onCategoryHeaderHeightChange:b,rowHeight:C,categoryHeaderHeight:E}=o.get();y.target===u.current&&C!==p&&w(p),y.target===l.current&&E!==p&&b(p)}}));c.observe(f),c.observe(u.current),c.observe(l.current);let{onRowHeightChange:d,onCategoryHeaderHeightChange:h}=o.get();return d(u.current.clientHeight),h(l.current.clientHeight),()=>{c.disconnect()}}),[]),v.jsxs("div",{"aria-hidden":!0,ref:r,style:{height:0,visibility:"hidden"},children:[v.jsx("div",{"frimousse-row-sizer":"",ref:u,children:v.jsx(t,{...gv(-1,!0),children:s.map(((f,c)=>v.jsx(n,{...mv(f,c,!1)},c)))})}),v.jsx("div",{...vv(-1),children:v.jsx("div",{"frimousse-category-header-sizer":"",ref:l,children:v.jsx(e,{...yv(a,!0)})})})]})}));function UA({category:e,...t}){return v.jsx("div",{...t,children:e.label})}function HA({emoji:e,...t}){return v.jsx("button",{type:"button",...t,children:e.emoji})}function VA({...e}){return v.jsx("div",{...e})}var bv=m.forwardRef((({style:e,components:t,...n},r)=>{let o=Pt(),i=m.useRef(null),s=m.useCallback((w=>{w&&(i.current=w,o.set({listRef:i}))}),[]),a=t?.CategoryHeader??UA,u=t?.Emoji??HA,l=t?.Row??VA,f=Nn(o,"columns"),c=Nn(o,"viewportStartRowIndex"),d=Nn(o,"viewportEndRowIndex"),h=Vt(o,uv),g=Vt(o,OA,Ol),y=m.useMemo((()=>g?.filter((w=>w<c)).length??0),[g,c]),p=g?.length??0;return m.useImperativeHandle(r,(()=>i.current)),h&&g&&p!==0?v.jsx("div",{...$h(f,h,e),...n,ref:s,children:v.jsxs("div",{...Vh(h,p,c,y),children:[v.jsx(Wh,{CategoryHeader:a,Emoji:u,Row:l}),Array.from({length:d-c+1},((w,b)=>{let C=c+b,E=g.indexOf(C);return v.jsxs(m.Fragment,{children:[E>=0&&v.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),v.jsx(NA,{Emoji:u,Row:l,rowIndex:C})]},C)})),Array.from({length:p},((w,b)=>v.jsx(LA,{CategoryHeader:a,categoryIndex:b},b)))]})}):v.jsx("div",{...$h(f,0,e),...n,children:v.jsx("div",{...Vh(0,0,0,0),children:v.jsx(Wh,{CategoryHeader:a,Emoji:u,Row:l})})})})),Cv=m.forwardRef((({emoji:e,onClick:t,"aria-label":n="Change skin tone",...r},o)=>{let i=Vt(Pt(),SA,Ol),[s,a,u]=dv(e),l=m.useMemo((()=>Math.max(0,u.findIndex((y=>y.skinTone===s)))),[s,u]),f=u[l],c=u[(l+1)%u.length].skinTone,d=s==="none"?void 0:i?.[s],h=c==="none"?void 0:i?.[c],g=m.useCallback((y=>{t?.(y),y.isDefaultPrevented()||a(c)}),[t,a,c]);return v.jsx("button",{type:"button",...r,"aria-label":n+(h?` (${h})`:""),"aria-live":"polite","aria-valuetext":d,"frimousse-skin-tone-selector":"",onClick:g,ref:o,children:f.emoji})}));function wv({children:e,...t}){return Vt(Pt(),AA)?v.jsx("span",{"frimousse-loading":"",...t,children:e}):null}function $A({children:e}){return e({search:Vt(Pt(),EA)})}function Ev({children:e,...t}){return Vt(Pt(),DA)?v.jsx("span",{"frimousse-empty":"",...t,children:typeof e=="function"?v.jsx($A,{children:e}):e}):null}function Dv({children:e}){return e({emoji:lv()})}function Av({children:e,emoji:t}){let[n,r,o]=dv(t);return e({skinTone:n,setSkinTone:r,skinToneVariations:o})}function WA({emoji:e,className:t,...n}){return v.jsx("button",{className:Ne("lb-emoji-picker-emoji",t),...n,children:v.jsx(Dc,{emoji:e.emoji})})}function zA({children:e,className:t,...n}){return v.jsx("div",{className:Ne("lb-emoji-picker-row",t),...n,children:e})}function KA({category:e,className:t,...n}){return v.jsx("div",{className:Ne("lb-emoji-picker-category-header",t),...n,children:v.jsx("span",{className:"lb-emoji-picker-category-header-title",children:e.label})})}fv.displayName="EmojiPicker.Root",hv.displayName="EmojiPicker.Search",pv.displayName="EmojiPicker.Viewport",bv.displayName="EmojiPicker.List",wv.displayName="EmojiPicker.Loading",Ev.displayName="EmojiPicker.Empty",Cv.displayName="EmojiPicker.SkinToneSelector",Dv.displayName="EmojiPicker.ActiveEmoji",Av.displayName="EmojiPicker.SkinTone";const tc=m.forwardRef((({onEmojiSelect:e,onOpenChange:t,children:n,className:r,...o},i)=>{const[s,a]=m.useState(!1),{portalContainer:u,emojibaseUrl:l}=Ri(),f=Mt(),c=m.useCallback((g=>{a(g),t?.(g)}),[t]),d=m.useCallback((({emoji:g})=>{a(!1),e?.(g)}),[e]),h=m.useCallback((g=>{g.stopPropagation()}),[]);return v.jsxs(ZC,{open:s,onOpenChange:c,children:[n,v.jsx(YC,{container:u,children:v.jsx(QC,{side:"top",align:"center",updatePositionStrategy:"always",sideOffset:6,collisionPadding:10,className:Ne("lb-root lb-portal lb-elevation lb-emoji-picker",r),...o,ref:i,asChild:!0,children:v.jsxs(Fn.Root,{onEmojiSelect:d,locale:f.locale,columns:10,emojiVersion:15.1,emojibaseUrl:l,onClick:h,children:[v.jsx("div",{className:"lb-emoji-picker-header",children:v.jsxs("div",{className:"lb-emoji-picker-search-container",children:[v.jsx(Fn.Search,{className:"lb-emoji-picker-search",placeholder:f.EMOJI_PICKER_SEARCH_PLACEHOLDER,autoFocus:!0}),v.jsx(Yw,{})]})}),v.jsxs(Fn.Viewport,{className:"lb-emoji-picker-content",children:[v.jsx(Fn.Loading,{className:"lb-loading lb-emoji-picker-loading",children:v.jsx(_i,{})}),v.jsx(Fn.Empty,{className:"lb-empty lb-emoji-picker-empty",children:f.EMOJI_PICKER_EMPTY}),v.jsx(Fn.List,{className:"lb-emoji-picker-list",components:{CategoryHeader:KA,Row:zA,Emoji:WA}})]}),v.jsxs("div",{className:"lb-emoji-picker-footer",children:[v.jsx(Fn.ActiveEmoji,{children:({emoji:g})=>g?v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"lb-emoji-picker-active-emoji",children:g.emoji}),v.jsx("span",{className:"lb-emoji-picker-active-emoji-label",children:g.label})]}):v.jsx("span",{className:"lb-emoji-picker-active-emoji-label lb-emoji-picker-active-emoji-label-placeholder",children:"Select an emoji…"})}),v.jsx(jt,{content:f.EMOJI_PICKER_CHANGE_SKIN_TONE,children:v.jsx(Fn.SkinToneSelector,{className:"lb-button lb-emoji-picker-skin-tone-selector"})})]})]})})})]})})),nc=XC;function qA({label:e,tooltipLabel:t,className:n,onClick:r,...o}){const{createMention:i}=Wt(),s=m.useCallback((u=>{u.preventDefault()}),[]),a=m.useCallback((u=>{r?.(u),u.isDefaultPrevented()||(u.stopPropagation(),i())}),[i,r]);return v.jsx(jt,{content:t??e,children:v.jsx(Jt,{className:Ne("lb-composer-editor-action",n),onPointerDown:s,onClick:a,"aria-label":e,icon:v.jsx(Xw,{}),...o})})}function GA({label:e,tooltipLabel:t,onPickerOpenChange:n,className:r,...o}){const{insertText:i}=Wt(),s=m.useCallback((u=>{u.preventDefault()}),[]),a=m.useCallback((u=>{u.stopPropagation()}),[]);return v.jsx(tc,{onEmojiSelect:i,onOpenChange:n,children:v.jsx(jt,{content:t??e,children:v.jsx(nc,{asChild:!0,children:v.jsx(Jt,{className:Ne("lb-composer-editor-action",r),onPointerDown:s,onClick:a,"aria-label":e,icon:v.jsx(Jw,{}),...o})})})})}function JA({label:e,tooltipLabel:t,className:n,...r}){const o=m.useCallback((s=>{s.preventDefault()}),[]),i=m.useCallback((s=>{s.stopPropagation()}),[]);return v.jsx(jt,{content:t??e,children:v.jsx(eA,{asChild:!0,children:v.jsx(Jt,{className:Ne("lb-composer-editor-action",n),onPointerDown:o,onClick:i,"aria-label":e,icon:v.jsx(jg,{}),...r})})})}function ZA({mention:e}){return v.jsxs(Dl,{className:"lb-mention lb-composer-mention",children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(Oo,{userId:e.id})]})}function XA({mention:e}){const t=J0(e);return v.jsxs(Dl,{className:"lb-mention lb-composer-mention","data-self":t?"":void 0,children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(ol,{groupId:e.id})]})}function us({mark:e,icon:t,shortcut:n,children:r,...o}){const i=Mt(),s=m.useMemo((()=>i.COMPOSER_TOGGLE_MARK(e)),[i,e]);return v.jsx(nl,{content:s,shortcut:n,sideOffset:8,children:v.jsx(tA,{mark:e,asChild:!0,...o,children:v.jsx(Jt,{"aria-label":s,variant:"toolbar",icon:t,children:r})})})}const YA={bold:()=>v.jsx(us,{mark:"bold",shortcut:"Mod-B",icon:v.jsx(Hw,{})}),italic:()=>v.jsx(us,{mark:"italic",shortcut:"Mod-I",icon:v.jsx(Zw,{})}),strikethrough:()=>v.jsx(us,{mark:"strikethrough",shortcut:"Mod-Shift-S",icon:v.jsx(eE,{})}),code:()=>v.jsx(us,{mark:"code",shortcut:"Mod-E",icon:v.jsx(zw,{})})},QA=Object.entries(YA).map((([e,t])=>v.jsx(t,{},e)));function ex(){return v.jsx(q2,{className:"lb-root lb-portal lb-elevation lb-composer-floating-toolbar",children:QA})}function tx({attachment:e,className:t,overrides:n,...r}){const{removeAttachment:o}=Wt(),{roomId:i}=ea(),s=m.useCallback((()=>{o(e.id)}),[e.id,o]);return v.jsx(tv,{className:Ne("lb-composer-attachment",t),...r,attachment:e,onDeleteClick:s,preventFocusOnDelete:!0,overrides:n,roomId:i})}function nx({overrides:e,className:t,...n}){const{attachments:r}=Wt();return r.length===0?null:v.jsx("div",{className:Ne("lb-composer-attachments",t),...n,children:v.jsx("div",{className:"lb-attachments",children:r.map((o=>v.jsx(tx,{attachment:o,overrides:e},o.id)))})})}const rx={Mention:function({mention:e,...t}){switch(e.kind){case"user":return v.jsx(ZA,{mention:e,...t});case"group":return v.jsx(XA,{mention:e,...t});default:return Ye(0,"Unhandled mention kind")}},MentionSuggestions:function({mentions:e}){return e.length>0?v.jsx(z0,{className:"lb-root lb-portal lb-elevation lb-composer-suggestions lb-composer-mention-suggestions",children:v.jsx(K0,{className:"lb-composer-suggestions-list lb-composer-mention-suggestions-list",children:e.map((t=>v.jsx(q0,{className:"lb-composer-suggestions-list-item lb-composer-mention-suggestion",value:t.id,children:t.kind==="user"?v.jsxs(v.Fragment,{children:[v.jsx(ju,{userId:t.id,className:"lb-composer-mention-suggestion-avatar"}),v.jsx(Oo,{userId:t.id,className:"lb-composer-mention-suggestion-user"})]}):t.kind==="group"?v.jsxs(v.Fragment,{children:[v.jsx(_w,{groupId:t.id,className:"lb-composer-mention-suggestion-avatar",icon:v.jsx(tE,{})}),v.jsx(ol,{groupId:t.id,className:"lb-composer-mention-suggestion-group",children:v.jsx(Mw,{groupId:t.id,className:"lb-composer-mention-suggestion-group-description"})})]}):Ye(0,"Unhandled mention kind")},t.id)))})}):null},Link:function({href:e,children:t}){return v.jsx(W0,{href:e,className:"lb-composer-link",children:t})}};function ox({showAttachments:e=!0,showFormattingControls:t=!0,showAttribution:n,defaultValue:r,isCollapsed:o,overrides:i,actions:s,autoFocus:a,disabled:u,hasResolveMentionSuggestions:l,onEmojiPickerOpenChange:f,onEmptyChange:c,onEditorClick:d}){const{isEmpty:h}=Wt(),{hasMaxAttachments:g}=Cl(),y=Mt(i),p=m.useMemo((()=>({...rx,FloatingToolbar:t?ex:void 0})),[t]),[w,b]=$0({disabled:u||!e||g});xn((()=>{c(h)}),[h,c]);const C=m.useCallback((A=>{A.preventDefault()}),[]),E=m.useCallback((A=>{A.stopPropagation()}),[]);return v.jsxs("div",{className:"lb-composer-editor-container",...b,children:[v.jsx(Y2,{className:"lb-composer-editor",onClick:d,placeholder:y.COMPOSER_PLACEHOLDER,defaultValue:r,autoFocus:a,components:p,disabled:u,dir:y.dir}),e&&v.jsx(nx,{overrides:i}),(!o||w)&&v.jsxs("div",{className:"lb-composer-footer",children:[v.jsxs("div",{className:"lb-composer-editor-actions",children:[l&&v.jsx(qA,{label:y.COMPOSER_INSERT_MENTION,disabled:u}),v.jsx(GA,{label:y.COMPOSER_INSERT_EMOJI,onPickerOpenChange:f,disabled:u}),e&&v.jsx(JA,{label:y.COMPOSER_ATTACH_FILES,disabled:u})]}),n&&v.jsx(dA,{}),v.jsx("div",{className:"lb-composer-actions",children:s??v.jsx(v.Fragment,{children:v.jsx(nl,{content:y.COMPOSER_SEND,shortcut:"Enter",children:v.jsx(G0,{asChild:!0,children:v.jsx(Jt,{onPointerDown:C,onClick:E,className:"lb-composer-action",variant:"primary","aria-label":y.COMPOSER_SEND,icon:v.jsx(Qw,{})})})})})})]}),e&&w&&v.jsx("div",{className:"lb-composer-attachments-drop-area",children:v.jsxs("div",{className:"lb-composer-attachments-drop-area-label",children:[v.jsx(jg,{}),y.COMPOSER_ATTACH_FILES]})})]})}m.createContext(null);const xv=m.forwardRef((({threadId:e,commentId:t,metadata:n,visibility:r,commentMetadata:o,defaultValue:i,defaultAttachments:s,onComposerSubmit:a,collapsed:u,defaultCollapsed:l,onCollapsedChange:f,overrides:c,actions:d,onBlur:h,className:g,onFocus:y,autoFocus:p,disabled:w,blurOnSubmit:b=!0,showAttachments:C=!0,showFormattingControls:E=!0,showAttribution:A,roomId:x,...I},T)=>{const F=zp({allowOutsideRoom:!0}),S=x!==void 0?x:F?.id;if(S===void 0)throw new Error("Composer must be a descendant of RoomProvider component");const k=Up(S),_=Hp(S),M=Vp(S),{preventUnsavedComposerChanges:H}=Ri(),W=wc()!==void 0,G=m.useRef(!0),q=m.useRef(!1),$=Mt(c),[V,Q]=(function(Y,de,pe){const[fe,we]=m.useState(Y),Ce=de!==void 0,se=m.useRef(Ce);return m.useEffect((()=>{se.current=Ce}),[Ce]),[Ce?de:fe,m.useCallback((te=>(Ce||we(te),pe?.(te))),[Ce,pe])]})(l??!1,u,f),ae=u!==void 0||l===!0,ie=Ec(S,sl(e===void 0?r??"public":r),"write"),Se=m.useCallback((Y=>{G.current=Y}),[]),Ie=m.useCallback((Y=>{q.current=Y}),[]),ne=m.useCallback((Y=>{y?.(Y),Y.isDefaultPrevented()||G.current&&ie&&Q?.(!1)}),[Q,y,ie]),B=m.useCallback((Y=>{if(h?.(Y),Y.isDefaultPrevented())return;const de=!Y.currentTarget.contains(Y.relatedTarget??document.activeElement);ae&&de&&G.current&&!q.current&&Q?.(!0)}),[h,Q,ae]),X=m.useCallback((Y=>{Y.stopPropagation(),G.current&&ie&&Q?.(!1)}),[Q,ie]),K=m.useCallback(((Y,de)=>{a?.(Y,de),de.isDefaultPrevented()||(de.stopPropagation(),t&&e?M({commentId:t,threadId:e,body:Y.body,metadata:o,attachments:Y.attachments}):e?_({threadId:e,body:Y.body,metadata:o,attachments:Y.attachments}):k({body:Y.body,metadata:n,visibility:r,commentMetadata:o,attachments:Y.attachments}))}),[t,_,k,M,o,n,r,a,e]);return v.jsx(Xs,{children:v.jsx(Q2,{onComposerSubmit:K,className:Ne("lb-root lb-composer lb-composer-form",g),dir:$.dir,...I,ref:T,"data-collapsed":V?"":void 0,onFocus:ne,onBlur:B,disabled:w||!ie,defaultAttachments:s,pasteFilesAsAttachments:C,preventUnsavedChanges:H,blurOnSubmit:b,roomId:S,children:v.jsx(ox,{defaultValue:i,actions:d,overrides:c,isCollapsed:V,showAttachments:C,showAttribution:A,showFormattingControls:E,hasResolveMentionSuggestions:W,onEmptyChange:Se,onEmojiPickerOpenChange:Ie,onEditorClick:X,autoFocus:p,disabled:w})})})}));function ix({children:e,content:t,defaultOpen:n,open:r,onOpenChange:o,className:i,...s}){const a=Mt(),{portalContainer:u}=Ri();return v.jsxs(jC,{defaultOpen:n,open:r,onOpenChange:o,dir:a.dir,children:[e,v.jsx(PC,{container:u,children:v.jsx(NC,{className:Ne("lb-root lb-portal lb-elevation lb-dropdown",i),sideOffset:6,collisionPadding:10,updatePositionStrategy:"always",...s,children:t})})]})}const sx=m.forwardRef((({children:e,className:t,icon:n,...r},o)=>v.jsxs(_C,{className:Ne("lb-dropdown-item",t),...r,ref:o,children:[n?v.jsx("span",{className:"lb-dropdown-item-icon lb-icon-container",children:n}):null,e?v.jsx("span",{className:"lb-dropdown-item-label",children:e}):null]}))),ax=MC;function zh({locale:e,date:t,className:n,...r}){return v.jsx(iA,{locale:e,date:t,className:Ne("lb-date",n),...r})}function ux({mention:e,className:t,...n}){const r=hr();return v.jsxs(gl,{className:Ne("lb-mention lb-comment-mention",t),"data-self":e.id===r?"":void 0,...n,children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(Oo,{userId:e.id})]})}function cx({mention:e,className:t,...n}){const r=J0(e);return v.jsxs(gl,{className:Ne("lb-mention lb-comment-mention",t),"data-self":r?"":void 0,...n,children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(ol,{groupId:e.id})]})}function lx({mention:e,...t}){switch(e.kind){case"user":return v.jsx(ux,{mention:e,...t});case"group":return v.jsx(cx,{mention:e,...t});default:return Ye(0,"Unhandled mention kind")}}function dx({href:e,children:t,className:n,...r}){const{Anchor:o}=(function(i){const s=m.useContext(_u);return m.useMemo((()=>({...Fg,...s,...i})),[s,i])})();return v.jsx(g0,{className:Ne("lb-comment-link",n),href:e,...r,asChild:!0,children:v.jsx(o,{...r,children:t})})}const Ov=m.forwardRef((({reaction:e,overrides:t,className:n,...r},o)=>{const i=Mt(t);return v.jsxs(rl,{className:Ne("lb-comment-reaction",n),variant:"outline","aria-label":i.COMMENT_REACTION_DESCRIPTION(e.emoji,e.users.length),...r,ref:o,children:[v.jsx(Dc,{className:"lb-comment-reaction-emoji",emoji:e.emoji}),v.jsx("span",{className:"lb-comment-reaction-count",children:e.users.length})]})})),fx=m.forwardRef((({comment:e,reaction:t,overrides:n,disabled:r,...o},i)=>{const s=$p(e.roomId),a=Wp(e.roomId),u=hr(),l=m.useMemo((()=>t.users.some((g=>g.id===u))),[u,t]),f=Mt(n),c=m.useMemo((()=>v.jsx("span",{children:f.COMMENT_REACTION_LIST(v.jsx(Pw,{values:t.users.map((g=>v.jsx(Oo,{userId:g.id,replaceSelf:!0},g.id))),formatRemaining:f.LIST_REMAINING_USERS,truncate:5,locale:f.locale}),t.emoji,t.users.length)})),[f,t]),d=m.useCallback((g=>{g.stopPropagation()}),[]),h=m.useCallback((g=>{g?s({threadId:e.threadId,commentId:e.id,emoji:t.emoji}):a({threadId:e.threadId,commentId:e.id,emoji:t.emoji})}),[s,e.threadId,e.id,t.emoji,a]);return v.jsx(jt,{content:c,multiline:!0,className:"lb-comment-reaction-tooltip",children:v.jsx(Xc,{asChild:!0,pressed:l,onPressedChange:h,onClick:d,disabled:r,ref:i,children:v.jsx(Ov,{"data-self":l?"":void 0,reaction:t,overrides:n,...o})})})}));function Sv({attachment:e,url:t}){e.mimeType==="application/pdf"||e.mimeType.startsWith("image/")||e.mimeType.startsWith("video/")||e.mimeType.startsWith("audio/")?window.open(t,"_blank"):(function(n,r){const o=document.createElement("a");o.href=n,o.download=r,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)})(t,e.name)}function hx({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...i}){const{url:s}=Ws(e.id,n),a=m.useCallback((u=>{if(!s)return;const l={attachment:e,url:s};t?.(l,u),u.isDefaultPrevented()||Sv(l)}),[e,t,s]);return v.jsx(lA,{className:Ne("lb-comment-attachment",r),...i,attachment:e,overrides:o,onClick:s?a:void 0,roomId:n})}function px({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...i}){const{url:s}=Ws(e.id,n),a=m.useCallback((u=>{if(!s)return;const l={attachment:e,url:s};t?.(l,u),u.isDefaultPrevented()||Sv(l)}),[e,t,s]);return v.jsx(tv,{className:Ne("lb-comment-attachment",r),...i,attachment:e,overrides:o,onClick:s?a:void 0,roomId:n})}m.forwardRef((({reaction:e,overrides:t,...n},r)=>{const o=hr(),i=m.useMemo((()=>e.users.some((s=>s.id===o))),[o,e]);return v.jsx(Ov,{disableable:!1,"data-self":i?"":void 0,reaction:e,overrides:t,...n,ref:r})}));const Za=m.forwardRef((({children:e,icon:t,onSelect:n,onClick:r,...o},i)=>{const s=m.useCallback((a=>{r?.(a),a.isDefaultPrevented()||a.stopPropagation()}),[r]);return v.jsx(sx,{icon:t,onSelect:n,onClick:s,...o,ref:i,children:e})})),Kh=Object.assign(m.forwardRef((({comment:e,visibility:t,indentContent:n=!0,showDeleted:r,showActions:o="hover",showReactions:i=!0,showAttachments:s=!0,showComposerFormattingControls:a=!0,onAuthorClick:u,onMentionClick:l,onAttachmentClick:f,onCommentEdit:c,onCommentDelete:d,dropdownItems:h,overrides:g,components:y,additionalContent:p,body:w,avatar:b,author:C,date:E,className:A,actions:x,actionsClassName:I,internalDropdownItems:T,children:F,...S},k)=>{const _=`${e.id}:body`,M=ji(k,m.useRef(null)),H=hr(),W=(function(J){const oe=Ve();return m.useCallback((({threadId:ge,commentId:ve})=>{const Te=new Date,{store:We,onMutationFailure:Le}=Et(oe),et=We.optimisticUpdates.add({type:"delete-comment",threadId:ge,commentId:ve,deletedAt:Te,roomId:J});oe[Oe].httpClient.deleteComment({roomId:J,threadId:ge,commentId:ve,visibility:wo(We,ge)}).then((()=>{We.deleteComment(ge,et,ve,Te)}),(ut=>Le(et,{type:"DELETE_COMMENT_ERROR",roomId:J,threadId:ge,commentId:ve},ut)))}),[oe,J])})(e.roomId),G=Vp(e.roomId),q=$p(e.roomId),$=Wp(e.roomId),V=Mt(g),[Q,ae]=m.useState(!1),[ie,Se]=m.useState(!1),[Ie,ne]=m.useState(!1),[B,X]=m.useState(!1),{mediaAttachments:K,fileAttachments:Y}=m.useMemo((()=>(function(J){const oe=[],ge=[];for(const ve of J)(ve.mimeType.startsWith("image/")||ve.mimeType.startsWith("video/"))&&ve.size<=Z0?oe.push(ve):ge.push(ve);return{mediaAttachments:oe,fileAttachments:ge}})(e.attachments)),[e.attachments]),de=Ec(e.roomId,sl(t),"write"),pe=m.useCallback((J=>{J.stopPropagation()}),[]),fe=m.useCallback((()=>{ae(!0)}),[]),we=m.useCallback((J=>{J.stopPropagation(),ae(!1)}),[]),Ce=m.useCallback((({body:J,attachments:oe},ge)=>{c?.(e),ge.isDefaultPrevented()||(ge.stopPropagation(),ge.preventDefault(),ae(!1),G({commentId:e.id,threadId:e.threadId,body:J,attachments:oe}))}),[e,G,c]),se=m.useCallback((()=>{d?.(e),W({commentId:e.id,threadId:e.threadId})}),[e,W,d]),te=m.useCallback((J=>{u?.(e.userId,J)}),[e.userId,u]),me=m.useCallback((J=>{const oe=e.reactions.findIndex((ge=>ge.emoji===J));oe>=0&&H&&e.reactions[oe]?.users.some((ge=>ge.id===H))?$({threadId:e.threadId,commentId:e.id,emoji:J}):q({threadId:e.threadId,commentId:e.id,emoji:J})}),[q,e.id,e.reactions,e.threadId,$,H]);if(m.useEffect((()=>{typeof window<"u"&&window.location.hash.slice(1)===e.id&&Se(!0)}),[]),!r&&!e.body)return null;const Ae=e.userId===H?v.jsxs(v.Fragment,{children:[v.jsx(Za,{onSelect:fe,icon:v.jsx(qw,{}),children:V.COMMENT_EDIT}),v.jsx(Za,{onSelect:se,icon:v.jsx(Kw,{}),children:V.COMMENT_DELETE})]}):null,Pe=T||Ae?v.jsxs(v.Fragment,{children:[T,Ae]}):null,Fe=typeof h=="function"?h({children:Pe,comment:e}):Pe||h?v.jsxs(v.Fragment,{children:[Pe,h]}):null;let re;if(Q)re=v.jsx(xv,{className:"lb-comment-composer",threadId:e.threadId,commentId:e.id,visibility:t,onComposerSubmit:Ce,defaultValue:e.body,defaultAttachments:e.attachments,autoFocus:!0,showAttribution:!1,showAttachments:s,showFormattingControls:a,actions:v.jsxs(v.Fragment,{children:[v.jsx(jt,{content:V.COMMENT_EDIT_COMPOSER_CANCEL,"aria-label":V.COMMENT_EDIT_COMPOSER_CANCEL,children:v.jsx(Jt,{className:"lb-composer-action",onClick:we,icon:v.jsx(il,{})})}),v.jsx(nl,{content:V.COMMENT_EDIT_COMPOSER_SAVE,shortcut:"Enter",children:v.jsx(G0,{asChild:!0,children:v.jsx(Jt,{variant:"primary",className:"lb-composer-action",onClick:pe,"aria-label":V.COMMENT_EDIT_COMPOSER_SAVE,icon:v.jsx(Vw,{})})})})]}),overrides:{COMPOSER_PLACEHOLDER:V.COMMENT_EDIT_COMPOSER_PLACEHOLDER},roomId:e.roomId});else{const J=v.jsx(p2,{className:"lb-comment-body",id:_,body:e.body,components:{Mention:({mention:oe})=>v.jsx(lx,{mention:oe,onClick:ge=>l?.(oe,ge),overrides:g}),Link:dx}});re=e.body?v.jsxs(v.Fragment,{children:[w===void 0?J:typeof w=="function"?w({comment:e,children:J}):w,p,s&&(K.length>0||Y.length>0)?v.jsxs("div",{className:"lb-comment-attachments",children:[K.length>0?v.jsx("div",{className:"lb-attachments",children:K.map((oe=>v.jsx(hx,{attachment:oe,overrides:g,onAttachmentClick:f,roomId:e.roomId},oe.id)))}):null,Y.length>0?v.jsx("div",{className:"lb-attachments",children:Y.map((oe=>v.jsx(px,{attachment:oe,overrides:g,onAttachmentClick:f,roomId:e.roomId},oe.id)))}):null]}):null,i&&e.reactions.length>0&&v.jsxs("div",{className:"lb-comment-reactions",children:[e.reactions.map((oe=>v.jsx(fx,{comment:e,reaction:oe,overrides:g,disabled:!de},oe.emoji))),de?v.jsx(tc,{onEmojiSelect:me,children:v.jsx(jt,{content:V.COMMENT_ADD_REACTION,children:v.jsx(nc,{asChild:!0,children:v.jsx(Jt,{className:"lb-comment-reaction lb-comment-reaction-add",variant:"outline",onClick:pe,"aria-label":V.COMMENT_ADD_REACTION,icon:v.jsx(rf,{})})})})}):null]})]}):v.jsx("div",{className:"lb-comment-body",children:v.jsx("p",{className:"lb-comment-deleted",children:V.COMMENT_DELETED})}),re=typeof F=="function"?F({comment:e,children:re}):F??re}return v.jsx(Xs,{children:v.jsx(xw,{components:y,children:v.jsxs("div",{role:"article",id:e.id,className:Ne("lb-root lb-comment",n&&"lb-comment:indent-content",o==="hover"&&"lb-comment:show-actions-hover",(Ie||B)&&"lb-comment:action-open",A),"data-deleted":e.body?void 0:"","data-editing":Q?"":void 0,"data-target":ie?"":void 0,"aria-labelledby":_,dir:V.dir,...S,ref:M,children:[v.jsxs("div",{className:"lb-comment-header",children:[v.jsxs("div",{className:"lb-comment-details",children:[b?v.jsx("div",{className:"lb-comment-avatar",onClick:te,children:b}):v.jsx(ju,{className:"lb-comment-avatar",userId:e.userId,onClick:te}),v.jsxs("span",{className:"lb-comment-details-labels",children:[C?v.jsx("span",{className:"lb-comment-author",onClick:te,children:C}):v.jsx(Oo,{className:"lb-comment-author",userId:e.userId,onClick:te}),E?v.jsx("span",{className:"lb-comment-date",children:E}):v.jsxs("span",{className:"lb-comment-date",children:[v.jsx(zh,{locale:V.locale,date:e.createdAt,className:"lb-comment-date-created"}),e.editedAt&&e.body&&v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{className:"lb-comment-date-edited",children:V.COMMENT_EDITED})]})]})]})]}),o&&!Q&&v.jsxs("div",{className:Ne("lb-comment-actions",I),children:[x??null,i&&de?v.jsx(tc,{onEmojiSelect:me,onOpenChange:X,children:v.jsx(jt,{content:V.COMMENT_ADD_REACTION,children:v.jsx(nc,{asChild:!0,children:v.jsx(Jt,{className:"lb-comment-action",onClick:pe,"aria-label":V.COMMENT_ADD_REACTION,icon:v.jsx(rf,{})})})})}):null,Fe?v.jsx(ix,{open:Ie,onOpenChange:ne,align:"end",content:Fe,children:v.jsx(jt,{content:V.COMMENT_MORE,children:v.jsx(ax,{asChild:!0,children:v.jsx(Jt,{className:"lb-comment-action",disabled:!e.body,onClick:pe,"aria-label":V.COMMENT_MORE,icon:v.jsx(Gw,{})})})})}):null]})]}),v.jsx("div",{className:"lb-comment-content",children:re})]})})})})),{DropdownItem:Za,Avatar:function(e){return v.jsx(ju,{...e})},Author:function(e){return v.jsx(Oo,{...e})},Date:zh});function mx(e){return window.addEventListener("blur",e),window.addEventListener("focus",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("focus",e)}}function gx(){return document.hasFocus()}function vx(){return!0}function yx({thread:e}){const{id:t,roomId:n}=e,r=m.useRef(null),o=(function(i){const s=Ve();return m.useCallback((a=>{const{store:u,onMutationFailure:l}=Et(s),f=Object.values(u.outputs.notifications.get().notificationsById).find((h=>h.kind==="thread"&&h.threadId===a));if(!f)return;const c=new Date,d=u.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:f.id,readAt:c});s[Oe].httpClient.markRoomInboxNotificationAsRead({roomId:i,inboxNotificationId:f.id}).then((()=>{u.markInboxNotificationRead(f.id,c,d)}),(h=>{l(d,{type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",roomId:i,inboxNotificationId:f.id},h)}))}),[s,i])})(n);return f2(r,(i=>{i&&o(t)}),{enabled:m.useSyncExternalStore(mx,gx,vx)}),v.jsx("div",{ref:r,style:{height:0},"aria-hidden":!0,"data-mark-as-read-marker":""})}const $x=m.forwardRef((({thread:e,indentCommentContent:t=!0,showActions:n="hover",showDeletedComments:r,showResolveAction:o=!0,showReactions:i=!0,showComposer:s="collapsed",showAttachments:a=!0,showSubscription:u=!0,showComposerFormattingControls:l=!0,maxVisibleComments:f,commentDropdownItems:c,onResolvedChange:d,onCommentEdit:h,onCommentDelete:g,onThreadDelete:y,onAuthorClick:p,onMentionClick:w,onAttachmentClick:b,onComposerSubmit:C,blurComposerOnSubmit:E,autoFocus:A,overrides:x,components:I,className:T,...F},S)=>{const k=oE(I?.Comment,Kh),_=(function(se){const te=Ve();return m.useCallback((me=>{const Ae=new Date,{store:Pe,onMutationFailure:Fe}=Et(te),re=Pe.optimisticUpdates.add({type:"mark-thread-as-resolved",threadId:me,updatedAt:Ae});te[Oe].httpClient.markThreadAsResolved({roomId:se,threadId:me,visibility:wo(Pe,me)}).then((()=>{Pe.patchThread(me,re,{resolved:!0},Ae)}),(J=>Fe(re,{type:"MARK_THREAD_AS_RESOLVED_ERROR",roomId:se,threadId:me},J)))}),[te,se])})(e.roomId),M=(function(se){const te=Ve();return m.useCallback((me=>{const Ae=new Date,{store:Pe,onMutationFailure:Fe}=Et(te),re=Pe.optimisticUpdates.add({type:"mark-thread-as-unresolved",threadId:me,updatedAt:Ae});te[Oe].httpClient.markThreadAsUnresolved({roomId:se,threadId:me,visibility:wo(Pe,me)}).then((()=>{Pe.patchThread(me,re,{resolved:!1},Ae)}),(J=>Fe(re,{type:"MARK_THREAD_AS_UNRESOLVED_ERROR",roomId:se,threadId:me},J)))}),[te,se])})(e.roomId),H=Mt(x),[W,G]=m.useState(!1),q=m.useMemo((()=>r?0:e.comments.findIndex((se=>se.body))),[r,e.comments]),$=m.useMemo((()=>r?e.comments.length-1:qh(e.comments,(se=>!!se.body))),[r,e.comments]),V=m.useMemo((()=>r?e.comments.length:e.comments.filter((se=>se.body)).length),[r,e.comments]),Q=m.useMemo((()=>{const se=typeof f=="number"?f:f?.max,te=(typeof f=="object"?f?.show:void 0)??"newest";if(W||se===void 0)return;const me=e.comments.map(((ve,Te)=>({comment:ve,index:Te}))).filter((({comment:ve})=>r||ve.body));if(me.length<=Math.max(se,2))return;const Ae=me[0],Pe=me[me.length-1];if(se<=2)return{firstIndex:me[1]?.index??Ae.index,lastIndex:me[me.length-2]?.index??Pe.index,count:me.slice(1,me.length-1).length};const Fe=se-2,re=te==="oldest"?Fe:te==="newest"?0:Math.floor(Fe/2),J=te==="oldest"?0:te==="newest"?Fe:Math.ceil(Fe/2),oe=me[1+re],ge=me[me.length-2-J];return!oe||!ge||oe.index>ge.index?void 0:{firstIndex:oe.index,lastIndex:ge.index,count:e.comments.slice(oe.index,ge.index+1).filter((ve=>r||ve.body)).length}}),[f,W,r,e.comments]),{status:ae,unreadSince:ie,subscribe:Se,unsubscribe:Ie}=wy(e.roomId,e.id),ne=m.useMemo((()=>{if(ae!=="subscribed")return;if(ie===null)return q;const se=e.comments.findIndex((te=>(!!r||te.body)&&te.createdAt>ie));return se>=0&&se<e.comments.length?se:void 0}),[q,r,ae,e.comments,ie]),[B,X]=m.useState(),K=B===void 0?ne:B;m.useEffect((()=>{ne&&X((se=>Math.min(se??1/0,ne)))}),[ne]);const Y=Ec(e.roomId,sl(e.visibility),"write"),de=m.useCallback((se=>{se.stopPropagation()}),[]),pe=m.useCallback((se=>{d?.(se),se?_(e.id):M(e.id)}),[_,M,d,e.id]),fe=m.useCallback((se=>{g?.(se),e.comments.filter((te=>te.body)).length<=1&&y?.(e)}),[g,y,e]),we=m.useCallback((()=>{ae==="subscribed"?Ie():Se()}),[ae,Se,Ie]);let Ce=0;return v.jsx(Xs,{children:v.jsxs("div",{className:Ne("lb-root lb-thread",n==="hover"&&"lb-thread:show-actions-hover",T),"data-resolved":e.resolved?"":void 0,"data-unread":ne!==void 0?"":void 0,dir:H.dir,...F,ref:S,children:[v.jsx("div",{className:"lb-thread-comments",role:"feed",children:e.comments.map(((se,te)=>{const me=r||se.body,Ae=te===q,Pe=ne!==void 0&&te>=ne,Fe=Q&&te>=Q.firstIndex&&te<=Q.lastIndex,re=!r&&!se.body;if(Fe&&te===Q.firstIndex)return v.jsx("div",{className:"lb-thread-show-more",children:v.jsx(Jt,{variant:"ghost",className:"lb-thread-show-more-button",onClick:()=>G(!0),children:H.THREAD_SHOW_MORE_COMMENTS(Q.count)})},`${se.id}:show-more`);if(Fe||re)return null;me&&Ce++;const J=v.jsx(k,{tabIndex:0,"aria-posinset":Ce,"aria-setsize":V,overrides:x,className:"lb-thread-comment","data-unread":Pe?"":void 0,comment:se,visibility:e.visibility,indentContent:t,showDeleted:r,showActions:n,showReactions:i,showAttachments:a,showComposerFormattingControls:l,onCommentEdit:h,onCommentDelete:fe,onAuthorClick:p,onMentionClick:w,onAttachmentClick:b,components:I,actionsClassName:Ae?"lb-thread-actions":void 0,actions:Ae&&o?v.jsx(jt,{content:e.resolved?H.THREAD_UNRESOLVE:H.THREAD_RESOLVE,children:v.jsx(Xc,{pressed:e.resolved,onPressedChange:pe,asChild:!0,children:v.jsx(Jt,{className:"lb-comment-action",onClick:de,"aria-label":e.resolved?H.THREAD_UNRESOLVE:H.THREAD_RESOLVE,icon:e.resolved?v.jsx(Ww,{}):v.jsx($w,{}),disabled:!Y})})}):null,internalDropdownItems:Ae&&u?v.jsx(Kh.DropdownItem,{onSelect:we,icon:ae==="subscribed"?v.jsx(Uw,{}):v.jsx(Lw,{}),children:ae==="subscribed"?H.THREAD_UNSUBSCRIBE:H.THREAD_SUBSCRIBE}):void 0,dropdownItems:c},se.id);return te===K&&K!==q&&K<=$?v.jsxs(m.Fragment,{children:[v.jsx("div",{className:"lb-thread-new-indicator","aria-label":H.THREAD_NEW_INDICATOR_DESCRIPTION,children:v.jsxs("span",{className:"lb-thread-new-indicator-label",children:[v.jsx(Nw,{className:"lb-thread-new-indicator-label-icon"}),H.THREAD_NEW_INDICATOR]})}),J]},se.id):J}))}),ne!==void 0&&v.jsx(yx,{thread:e}),s&&v.jsx(xv,{className:"lb-thread-composer",threadId:e.id,visibility:e.visibility,defaultCollapsed:s==="collapsed"||void 0,showAttachments:a,showFormattingControls:l,onComposerSubmit:C,blurOnSubmit:E,overrides:{COMPOSER_PLACEHOLDER:H.THREAD_COMPOSER_PLACEHOLDER,COMPOSER_SEND:H.THREAD_COMPOSER_SEND,...x},roomId:e.roomId,autoFocus:A})]})})}));export{xv as C,xx as L,iA as T,Tx as _,Fx as a,kx as b,p2 as c,Kh as d,Ax as e,Bx as f,$x as g,Lp as h,g0 as i,v as j,gl as k,zp as l,Ix as m,Ox as n,Sx as o,Mt as u};
|
|
55
|
+
`);se.forEach(((te,me)=>{te&&D.insertText(t,te),me!==se.length-1&&D.insertSoftBreak(t)}))}),{at:x});if(R.equals(x.anchor.path,x.focus.path)){var[pe,fe]=U.edges(x),we={start:pe.offset,end:fe.offset,text:de};if(de&&l&&A==="insertCompositionText"){var Ce=l.start+l.text.search(/\S|$/);we.start+we.text.search(/\S|$/)===Ce+1&&we.end===l.start+l.text.length?(we.start-=1,l=null,b()):l=!1}else l=A==="insertText"&&(l===null?we:!(!l||!U.isCollapsed(x)||l.end+l.text.length!==pe.offset)&&as(as({},l),{},{text:l.text+de}));if(S)return void h(pe.path,we)}return g((()=>D.insertText(t,de)),{at:x})}}}},handleKeyDown:C=>{p()||(d(!0),setTimeout(d))},handleDomMutations:C=>{var E;p()||y()||C.some((A=>hl(t,A,C)))&&((E=e0.get(t))===null||E===void 0||E())},handleInput:()=>{!y()&&p()||c()}}}var Di=ps?m.useLayoutEffect:m.useEffect,BD=["node"];function oh(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 FD={subtree:!0,childList:!0,characterData:!0},RD=It?e=>{var{node:t}=e,n=Io(e,BD);if(!It)return null;var r,o=Tn(),i=(r=m.useRef(!1),m.useEffect((()=>(r.current=!0,()=>{r.current=!1})),[]),r.current),[s]=m.useState((()=>kD((function(a){for(var u=1;u<arguments.length;u++){var l=arguments[u]!=null?arguments[u]:{};u%2?oh(Object(l),!0).forEach((function(f){Qt(a,f,l[f])})):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(l)):oh(Object(l)).forEach((function(f){Object.defineProperty(a,f,Object.getOwnPropertyDescriptor(l,f))}))}return a})({editor:o},n))));return(function(a,u,l){var[f]=m.useState((()=>new MutationObserver(u)));Di((()=>{f.takeRecords()})),m.useEffect((()=>{if(!a.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");return f.observe(a.current,l),()=>f.disconnect()}),[f,a,l])})(t,s.handleDomMutations,FD),dl.set(o,s.scheduleFlush),i&&s.flush(),s}:()=>null,_D=["anchor","focus"],jD=["anchor","focus"],s0=(e,t)=>{var n,r,o=Io(e,_D),i=Io(t,jD);return e[To]===t[To]&&(n=o,r=i,Object.keys(n).length===Object.keys(r).length&&Object.keys(n).every((s=>r.hasOwnProperty(s)&&n[s]===r[s])))};function ih(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 MD=e=>{var{isLast:t,leaf:n,parent:r,text:o}=e,i=Tn(),s=Z.findPath(i,o),a=R.parent(s),u=!!n[t0];return i.isVoid(r)?Be.createElement(Ka,{length:ee.string(r).length}):n.text!==""||r.children[r.children.length-1]!==o||i.isInline(r)||D.string(i,a)!==""?n.text===""?Be.createElement(Ka,{isMarkPlaceholder:u}):t&&n.text.slice(-1)===`
|
|
56
|
+
`?Be.createElement(sh,{isTrailing:!0,text:n.text}):Be.createElement(sh,{text:n.text}):Be.createElement(Ka,{isLineBreak:!0,isMarkPlaceholder:u})},sh=e=>{var{text:t,isTrailing:n=!1}=e,r=m.useRef(null),o=()=>"".concat(t??"").concat(n?`
|
|
57
|
+
`:""),[i]=m.useState(o);return Di((()=>{var s=o();r.current&&r.current.textContent!==s&&(r.current.textContent=s)})),Be.createElement(PD,{ref:r},i)},PD=m.memo(m.forwardRef(((e,t)=>Be.createElement("span",{"data-slate-string":!0,ref:t},e.children)))),Ka=e=>{var{length:t=0,isLineBreak:n=!1,isMarkPlaceholder:r=!1}=e,o={"data-slate-zero-width":n?"n":"z","data-slate-length":t};return r&&(o["data-slate-mark-placeholder"]=!0),Be.createElement("span",(function(i){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?ih(Object(a),!0).forEach((function(u){Qt(i,u,a[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):ih(Object(a)).forEach((function(u){Object.defineProperty(i,u,Object.getOwnPropertyDescriptor(a,u))}))}return i})({},o),(It||Xg)&&n?null:"\uFEFF",n?Be.createElement("br",null):null)};function ah(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 a0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ah(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ah(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ND=It?300:0;function uh(e){e.current&&(clearTimeout(e.current),e.current=null)}var LD=e=>{var{leaf:t,isLast:n,text:r,parent:o,renderPlaceholder:i,renderLeaf:s=w=>Be.createElement(HD,a0({},w))}=e,a=Tn(),u=m.useRef(null),l=m.useRef(null),[f,c]=m.useState(!1),d=m.useRef(null),h=m.useCallback((w=>{if((function(E,A){E.current&&(E.current.disconnect(),A&&(E.current=null))})(u,w==null),w==null){var b;Hu.delete(a),(b=t.onPlaceholderResize)===null||b===void 0||b.call(t,null)}else{if(Hu.set(a,w),!u.current){var C=window.ResizeObserver||pD;u.current=new C((()=>{var E;(E=t.onPlaceholderResize)===null||E===void 0||E.call(t,w)}))}u.current.observe(w),l.current=w}}),[l,t,a]),g=Be.createElement(MD,{isLast:n,leaf:t,parent:o,text:r}),y=!!t[To];if(m.useEffect((()=>(y?d.current||(d.current=setTimeout((()=>{c(!0),d.current=null}),ND)):(uh(d),c(!1)),()=>uh(d))),[y,c]),y&&f){var p={children:t.placeholder,attributes:{"data-slate-placeholder":!0,style:{position:"absolute",top:0,pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",textDecoration:"none",WebkitUserModify:Dr?"inherit":void 0},contentEditable:!1,ref:h}};g=Be.createElement(Be.Fragment,null,i(p),g)}return s({attributes:{"data-slate-leaf":!0},children:g,leaf:t,text:r})},UD=Be.memo(LD,((e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&he.equals(t.leaf,e.leaf)&&t.leaf[To]===e.leaf[To])),HD=e=>{var{attributes:t,children:n}=e;return Be.createElement("span",a0({},t),n)},VD=e=>{for(var{decorations:t,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:i,text:s}=e,a=Tn(),u=m.useRef(null),l=he.decorations(s,t),f=Z.findKey(a,s),c=[],d=0;d<l.length;d++){var h=l[d];c.push(Be.createElement(UD,{isLast:n&&d===l.length-1,key:"".concat(f.id,"-").concat(d),renderPlaceholder:o,leaf:h,text:s,parent:r,renderLeaf:i}))}var g=m.useCallback((y=>{var p=Qs.get(a);y?(p?.set(f,y),Lr.set(s,y),Ei.set(y,s)):(p?.delete(f),Lr.delete(s),u.current&&Ei.delete(u.current)),u.current=y}),[u,a,f,s]);return Be.createElement("span",{"data-slate-node":"text",ref:g},c)},u0=Be.memo(VD,((e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&((n,r)=>{if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++){var i=n[o],s=r[o];if(i.anchor.offset!==s.anchor.offset||i.focus.offset!==s.focus.offset||!s0(i,s))return!1}return!0})(t.decorations,e.decorations)));function ch(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 qu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ch(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ch(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var $D=e=>{var{decorations:t,element:n,renderElement:r=b=>Be.createElement(zD,qu({},b)),renderPlaceholder:o,renderLeaf:i,selection:s}=e,a=Tn(),u=KD(),l=a.isInline(n),f=Z.findKey(a,n),c=m.useCallback((b=>{var C=Qs.get(a);b?(C?.set(f,b),Lr.set(n,b),Ei.set(b,n)):(C?.delete(f),Lr.delete(n))}),[a,f,n]),d=f0({decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:s}),h={"data-slate-node":"element",ref:c};if(l&&(h["data-slate-inline"]=!0),!l&&D.hasInlines(a,n)){var g=ee.string(n),y=Wg(g);y==="rtl"&&(h.dir=y)}if(D.isVoid(a,n)){h["data-slate-void"]=!0,!u&&l&&(h.contentEditable=!1);var p=l?"span":"div",[[w]]=ee.texts(n);d=Be.createElement(p,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},Be.createElement(u0,{renderPlaceholder:o,decorations:[],isLast:!1,parent:n,text:w})),cl.set(w,0),ll.set(w,n)}return r({attributes:h,children:d,element:n})},WD=Be.memo($D,((e,t)=>e.element===t.element&&e.renderElement===t.renderElement&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&((n,r)=>{if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++){var i=n[o],s=r[o];if(!U.equals(i,s)||!s0(i,s))return!1}return!0})(e.decorations,t.decorations)&&(e.selection===t.selection||!!e.selection&&!!t.selection&&U.equals(e.selection,t.selection)))),zD=e=>{var{attributes:t,children:n,element:r}=e,o=Tn().isInline(r)?"span":"div";return Be.createElement(o,qu(qu({},t),{},{style:{position:"relative"}}),n)},c0=m.createContext((()=>[])),l0=m.createContext(!1),d0=()=>m.useContext(l0),f0=e=>{var{decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:s}=e,a=m.useContext(c0),u=Tn();yo.set(u,!1);for(var l=Z.findPath(u,n),f=[],c=le.isElement(n)&&!u.isInline(n)&&D.hasInlines(u,n),d=0;d<n.children.length;d++){var h=l.concat(d),g=n.children[d],y=Z.findKey(u,g),p=D.range(u,h),w=s&&U.intersection(p,s),b=a([g,h]);for(var C of t){var E=U.intersection(C,p);E&&b.push(E)}le.isElement(g)?f.push(Be.createElement(l0.Provider,{key:"provider-".concat(y.id),value:!!w},Be.createElement(WD,{decorations:b,element:g,key:y.id,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:w}))):f.push(Be.createElement(u0,{decorations:b,key:y.id,isLast:c&&d===n.children.length-1,parent:n,renderPlaceholder:o,renderLeaf:i,text:g})),cl.set(g,d),ll.set(g,n)}return f},h0=m.createContext(!1),KD=()=>m.useContext(h0),p0=m.createContext(null),qD={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"left",moveForward:"right",moveWordBackward:"ctrl+left",moveWordForward:"ctrl+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",insertSoftBreak:"shift+enter",splitBlock:"enter",undo:"mod+z"},GD={moveLineBackward:"opt+up",moveLineForward:"opt+down",moveWordBackward:"opt+left",moveWordForward:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},JD={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Ge=e=>{var t=qD[e],n=GD[e],r=JD[e],o=t&&$a.isHotkey(t),i=n&&$a.isHotkey(n),s=r&&$a.isHotkey(r);return a=>!(!o||!o(a))||!!(Xf&&i&&i(a))||!(Xf||!s||!s(a))},Ze={isBold:Ge("bold"),isCompose:Ge("compose"),isMoveBackward:Ge("moveBackward"),isMoveForward:Ge("moveForward"),isDeleteBackward:Ge("deleteBackward"),isDeleteForward:Ge("deleteForward"),isDeleteLineBackward:Ge("deleteLineBackward"),isDeleteLineForward:Ge("deleteLineForward"),isDeleteWordBackward:Ge("deleteWordBackward"),isDeleteWordForward:Ge("deleteWordForward"),isExtendBackward:Ge("extendBackward"),isExtendForward:Ge("extendForward"),isExtendLineBackward:Ge("extendLineBackward"),isExtendLineForward:Ge("extendLineForward"),isItalic:Ge("italic"),isMoveLineBackward:Ge("moveLineBackward"),isMoveLineForward:Ge("moveLineForward"),isMoveWordBackward:Ge("moveWordBackward"),isMoveWordForward:Ge("moveWordForward"),isRedo:Ge("redo"),isSoftBreak:Ge("insertSoftBreak"),isSplitBlock:Ge("splitBlock"),isTransposeCharacter:Ge("transposeCharacter"),isUndo:Ge("undo")},ZD={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class m0 extends m.Component{constructor(){super(...arguments),Qt(this,"context",null),Qt(this,"manager",null),Qt(this,"mutationObserver",null)}observe(){var t,{node:n}=this.props;if(!n.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");(t=this.mutationObserver)===null||t===void 0||t.observe(n.current,ZD)}componentDidMount(){var{receivedUserInput:t}=this.props,n=this.context;this.manager=((r,o)=>{var i=[],s=()=>{i=[]};return{registerMutations:a=>{if(o.current){var u=a.filter((l=>hl(r,l,a)));i.push(...u)}},restoreDOM:function(){i.length>0&&(i.reverse().forEach((a=>{a.type!=="characterData"&&(a.removedNodes.forEach((u=>{a.target.insertBefore(u,a.nextSibling)})),a.addedNodes.forEach((u=>{a.target.removeChild(u)})))})),s())},clear:s}})(n,t),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var t,n,r,o,i=(t=this.mutationObserver)===null||t===void 0?void 0:t.takeRecords();return i!=null&&i.length&&((o=this.manager)===null||o===void 0||o.registerMutations(i)),(n=this.mutationObserver)===null||n===void 0||n.disconnect(),(r=this.manager)===null||r===void 0||r.restoreDOM(),null}componentDidUpdate(){var t;(t=this.manager)===null||t===void 0||t.clear(),this.observe()}componentWillUnmount(){var t;(t=this.mutationObserver)===null||t===void 0||t.disconnect()}render(){return this.props.children}}Qt(m0,"contextType",ul);var XD=It?m0:e=>{var{children:t}=e;return Be.createElement(Be.Fragment,null,t)},YD=m.createContext(!1),QD=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderLeaf","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],e2=["text"];function lh(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 yn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lh(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var t2=e=>Be.createElement(Be.Fragment,null,f0(e)),n2=m.forwardRef(((e,t)=>{var n=m.useCallback((B=>Be.createElement(r2,yn({},B))),[]),{autoFocus:r,decorate:o=o2,onDOMBeforeInput:i,placeholder:s,readOnly:a=!1,renderElement:u,renderLeaf:l,renderPlaceholder:f=n,scrollSelectionIntoView:c=i2,style:d={},as:h="div",disableDefaultStyles:g=!1}=e,y=Io(e,QD),p=(()=>{var B=m.useContext(p0);if(!B)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");var{editor:X}=B;return X})(),[w,b]=m.useState(!1),C=m.useRef(null),E=m.useRef([]),[A,x]=m.useState(),I=m.useRef(!1),{onUserInput:T,receivedUserInput:F}=(function(){var B=Tn(),X=m.useRef(!1),K=m.useRef(0),Y=m.useCallback((()=>{if(!X.current){X.current=!0;var de=Z.getWindow(B);de.cancelAnimationFrame(K.current),K.current=de.requestAnimationFrame((()=>{X.current=!1}))}}),[B]);return m.useEffect((()=>()=>cancelAnimationFrame(K.current)),[]),{receivedUserInput:X,onUserInput:Y}})(),[,S]=m.useReducer((B=>B+1),0);e0.set(p,S),Vu.set(p,a);var k=m.useMemo((()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1})),[]);m.useEffect((()=>{C.current&&r&&C.current.focus()}),[r]);var _=m.useRef(),M=m.useMemo((()=>Fv((()=>{if(yo.get(p))M();else{var B=Z.toDOMNode(p,p).getRootNode();if(!I.current&&Dr&&B instanceof ShadowRoot){I.current=!0;var X=(()=>{for(var Ae=document.activeElement;(Pe=Ae)!==null&&Pe!==void 0&&Pe.shadowRoot&&(Fe=Ae.shadowRoot)!==null&&Fe!==void 0&&Fe.activeElement;){var Pe,Fe,re;Ae=(re=Ae)===null||re===void 0||(re=re.shadowRoot)===null||re===void 0?void 0:re.activeElement}return Ae})();return X?document.execCommand("indent"):z.deselect(p),void(I.current=!1)}var K=_.current;if((It||!Z.isComposing(p))&&(!k.isUpdatingSelection||K!=null&&K.isFlushing())&&!k.isDraggingInternally){var Y=Z.findDocumentOrShadowRoot(p),{activeElement:de}=Y,pe=Z.toDOMNode(p,p),fe=li(Y);if(de===pe?(k.latestElement=de,cr.set(p,!0)):cr.delete(p),!fe)return z.deselect(p);var{anchorNode:we,focusNode:Ce}=fe,se=Z.hasEditableTarget(p,we)||Z.isTargetInsideNonReadonlyVoid(p,we),te=Z.hasTarget(p,Ce);if(se&&te){var me=Z.toSlateRange(p,fe,{exactMatch:!1,suppressThrow:!0});me&&(Z.isComposing(p)||K!=null&&K.hasPendingChanges()||K!=null&&K.isFlushing()?K?.handleUserSelect(me):z.select(p,me))}!a||se&&te||z.deselect(p)}}}),100)),[p,a,k]),H=m.useMemo((()=>Rv(M,0)),[M]);_.current=RD({node:C,onDOMSelectionChange:M,scheduleOnDOMSelectionChange:H}),Di((()=>{var B,X,K;C.current&&(K=fl(C.current))?(Qg.set(p,K),ms.set(p,C.current),Lr.set(p,C.current),Ei.set(C.current,p)):Lr.delete(p);var{selection:Y}=p,de=Z.findDocumentOrShadowRoot(p),pe=li(de);if(pe&&Z.isFocused(p)&&((B=_.current)===null||B===void 0||!B.hasPendingAction())){var fe=te=>{var me=pe.type!=="None";if(Y||me){var Ae,Pe=pe.focusNode;if(lo&&pe.rangeCount>1){var Fe=pe.getRangeAt(0),re=pe.getRangeAt(pe.rangeCount-1);Ae=Fe.startContainer===Pe?re.endContainer:Fe.startContainer}else Ae=pe.anchorNode;var J=ms.get(p),oe=!1;if(J.contains(Ae)&&J.contains(Pe)&&(oe=!0),me&&oe&&Y&&!te){var ge=Z.toSlateRange(p,pe,{exactMatch:!0,suppressThrow:!0});if(ge&&U.equals(ge,Y)){var ve;if(!k.hasMarkPlaceholder||(ve=Ae)!==null&&ve!==void 0&&(ve=ve.parentElement)!==null&&ve!==void 0&&ve.hasAttribute("data-slate-mark-placeholder"))return}}if(!Y||Z.hasRange(p,Y)){k.isUpdatingSelection=!0;var Te=Y&&Z.toDOMRange(p,Y);return Te?(Z.isComposing(p)&&!It?pe.collapseToEnd():U.isBackward(Y)?pe.setBaseAndExtent(Te.endContainer,Te.endOffset,Te.startContainer,Te.startOffset):pe.setBaseAndExtent(Te.startContainer,Te.startOffset,Te.endContainer,Te.endOffset),c(p,Te)):pe.removeAllRanges(),Te}p.selection=Z.toSlateRange(p,pe,{exactMatch:!1,suppressThrow:!0})}};pe.rangeCount<=1&&fe();var we=((X=_.current)===null||X===void 0?void 0:X.isFlushing())==="action";if(It&&we){var Ce=null,se=requestAnimationFrame((()=>{if(we){var te=me=>{try{Z.toDOMNode(p,p).focus(),fe(me)}catch{}};te(),Ce=setTimeout((()=>{te(!0),k.isUpdatingSelection=!1}))}}));return()=>{cancelAnimationFrame(se),Ce&&clearTimeout(Ce)}}setTimeout((()=>{k.isUpdatingSelection=!1}))}}));var W=m.useCallback((B=>{var X=Z.toDOMNode(p,p).getRootNode();if(I!=null&&I.current&&Dr&&X instanceof ShadowRoot){var K=B.getTargetRanges()[0],Y=new window.Range;Y.setStart(K.startContainer,K.startOffset),Y.setEnd(K.endContainer,K.endOffset);var de=Z.toSlateRange(p,Y,{exactMatch:!1,suppressThrow:!1});return z.select(p,de),B.preventDefault(),void B.stopImmediatePropagation()}if(T(),!a&&Z.hasEditableTarget(p,B.target)&&!s2(B,i)){var pe;if(_.current)return _.current.handleDOMBeforeInput(B);H.flush(),M.flush();var{selection:fe}=p,{inputType:we}=B,Ce=B.dataTransfer||B.data||void 0,se=we==="insertCompositionText"||we==="deleteCompositionText";if(se&&Z.isComposing(p))return;var te=!1;if(we==="insertText"&&fe&&U.isCollapsed(fe)&&B.data&&B.data.length===1&&/[a-z ]/i.test(B.data)&&fe.anchor.offset!==0&&(te=!0,p.marks&&(te=!1),!yo.get(p))){var me,Ae,{anchor:Pe}=fe,[Fe,re]=Z.toDOMPoint(p,Pe),J=(me=Fe.parentElement)===null||me===void 0?void 0:me.closest("a"),oe=Z.getWindow(p);if(te&&J&&Z.hasDOMNode(p,J)){var ge,ve=oe?.document.createTreeWalker(J,NodeFilter.SHOW_TEXT).lastChild();ve===Fe&&((ge=ve.textContent)===null||ge===void 0?void 0:ge.length)===re&&(te=!1)}if(te&&Fe.parentElement&&(oe==null||(Ae=oe.getComputedStyle(Fe.parentElement))===null||Ae===void 0?void 0:Ae.whiteSpace)==="pre"){var Te=D.above(p,{at:Pe.path,match:hn=>le.isElement(hn)&&D.isBlock(p,hn)});Te&&ee.string(Te[0]).includes(" ")&&(te=!1)}}if((!we.startsWith("delete")||we.startsWith("deleteBy"))&&!yo.get(p)){var[We]=B.getTargetRanges();if(We){var Le=Z.toSlateRange(p,We,{exactMatch:!1,suppressThrow:!1});if(!fe||!U.equals(fe,Le)){te=!1;var et=!se&&p.selection&&D.rangeRef(p,p.selection);z.select(p,Le),et&&ci.set(p,et)}}}if(se)return;if(te||B.preventDefault(),fe&&U.isExpanded(fe)&&we.startsWith("delete")){var ut=we.endsWith("Backward")?"backward":"forward";return void D.deleteFragment(p,{direction:ut})}switch(we){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":D.deleteFragment(p);break;case"deleteContent":case"deleteContentForward":D.deleteForward(p);break;case"deleteContentBackward":D.deleteBackward(p);break;case"deleteEntireSoftLine":D.deleteBackward(p,{unit:"line"}),D.deleteForward(p,{unit:"line"});break;case"deleteHardLineBackward":D.deleteBackward(p,{unit:"block"});break;case"deleteSoftLineBackward":D.deleteBackward(p,{unit:"line"});break;case"deleteHardLineForward":D.deleteForward(p,{unit:"block"});break;case"deleteSoftLineForward":D.deleteForward(p,{unit:"line"});break;case"deleteWordBackward":D.deleteBackward(p,{unit:"word"});break;case"deleteWordForward":D.deleteForward(p,{unit:"word"});break;case"insertLineBreak":D.insertSoftBreak(p);break;case"insertParagraph":D.insertBreak(p);break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":we==="insertFromComposition"&&Z.isComposing(p)&&(b(!1),Rr.set(p,!1)),Ce?.constructor.name==="DataTransfer"?Z.insertData(p,Ce):typeof Ce=="string"&&(te?E.current.push((()=>D.insertText(p,Ce))):D.insertText(p,Ce))}var Nt=(pe=ci.get(p))===null||pe===void 0?void 0:pe.unref();ci.delete(p),!Nt||p.selection&&U.equals(p.selection,Nt)||z.select(p,Nt)}}),[p,M,T,i,a,H]),G=m.useCallback((B=>{B==null?(M.cancel(),H.cancel(),ms.delete(p),Lr.delete(p),C.current&&er&&C.current.removeEventListener("beforeinput",W)):er&&B.addEventListener("beforeinput",W),C.current=B,typeof t=="function"?t(B):t&&(t.current=B)}),[M,H,p,W,t]);Di((()=>{var B=Z.getWindow(p);B.document.addEventListener("selectionchange",H);var X=()=>{k.isDraggingInternally=!1};return B.document.addEventListener("dragend",X),B.document.addEventListener("drop",X),()=>{B.document.removeEventListener("selectionchange",H),B.document.removeEventListener("dragend",X),B.document.removeEventListener("drop",X)}}),[H,k]);var q=o([p,[]]),$=s&&p.children.length===1&&Array.from(ee.texts(p)).length===1&&ee.string(p)===""&&!w,V=m.useCallback((B=>{var X;x(B&&$?(X=B.getBoundingClientRect())===null||X===void 0?void 0:X.height:void 0)}),[$]);if($){var Q=D.start(p,[]);q.push({[To]:!0,placeholder:s,onPlaceholderResize:V,anchor:Q,focus:Q})}var{marks:ae}=p;if(k.hasMarkPlaceholder=!1,p.selection&&U.isCollapsed(p.selection)&&ae){var{anchor:ie}=p.selection,Se=ee.leaf(p,ie.path),Ie=Io(Se,e2);if(!he.equals(Se,ae,{loose:!0})){k.hasMarkPlaceholder=!0;var ne=Object.fromEntries(Object.keys(Ie).map((B=>[B,null])));q.push(yn(yn(yn({[t0]:!0},ne),ae),{},{anchor:ie,focus:ie}))}}return m.useEffect((()=>{setTimeout((()=>{var{selection:B}=p;if(B){var{anchor:X}=B,K=ee.leaf(p,X.path);if(ae&&!he.equals(K,ae,{loose:!0}))return void on.set(p,ae)}on.delete(p)}))})),Be.createElement(h0.Provider,{value:a},Be.createElement(YD.Provider,{value:w},Be.createElement(c0.Provider,{value:o},Be.createElement(XD,{node:C,receivedUserInput:F},Be.createElement(h,yn(yn({role:a?void 0:"textbox","aria-multiline":!a||void 0},y),{},{spellCheck:!(!er&&ps)&&y.spellCheck,autoCorrect:er||!ps?y.autoCorrect:"false",autoCapitalize:er||!ps?y.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:G,style:yn(yn({},g?{}:yn({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},A?{minHeight:A}:{})),d),onBeforeInput:m.useCallback((B=>{if(!er&&!a&&!Dt(B,y.onBeforeInput)&&Z.hasSelectableTarget(p,B.target)&&(B.preventDefault(),!Z.isComposing(p))){var X=B.data;D.insertText(p,X)}}),[y.onBeforeInput,p,a]),onInput:m.useCallback((B=>{if(!Dt(B,y.onInput))if(_.current)_.current.handleInput();else{for(var X of E.current)X();if(E.current=[],!Z.isFocused(p)){var K=B.nativeEvent,Y=p;if(K.inputType==="historyUndo"&&typeof Y.undo=="function")return void Y.undo();if(K.inputType==="historyRedo"&&typeof Y.redo=="function")return void Y.redo()}}}),[y.onInput,p]),onBlur:m.useCallback((B=>{if(!a&&!k.isUpdatingSelection&&Z.hasSelectableTarget(p,B.target)&&!Dt(B,y.onBlur)){var X=Z.findDocumentOrShadowRoot(p);if(k.latestElement!==X.activeElement){var{relatedTarget:K}=B;if(!(K===Z.toDOMNode(p,p)||qt(K)&&K.hasAttribute("data-slate-spacer"))){if(K!=null&&pr(K)&&Z.hasDOMNode(p,K)){var Y=Z.toSlateNode(p,K);if(le.isElement(Y)&&!p.isVoid(Y))return}if(Dr){var de=li(X);de?.removeAllRanges()}cr.delete(p)}}}}),[a,k.isUpdatingSelection,k.latestElement,p,y.onBlur]),onClick:m.useCallback((B=>{if(Z.hasTarget(p,B.target)&&!Dt(B,y.onClick)&&pr(B.target)){var X=Z.toSlateNode(p,B.target),K=Z.findPath(p,X);if(!D.hasPath(p,K)||ee.get(p,K)!==X)return;if(B.detail===3&&K.length>=1){var Y=K;if(!le.isElement(X)||!D.isBlock(p,X)){var de,pe=D.above(p,{match:Ae=>le.isElement(Ae)&&D.isBlock(p,Ae),at:K});Y=(de=pe?.[1])!==null&&de!==void 0?de:K.slice(0,1)}var fe=D.range(p,Y);return void z.select(p,fe)}if(a)return;var we=D.start(p,K),Ce=D.end(p,K),se=D.void(p,{at:we}),te=D.void(p,{at:Ce});if(se&&te&&R.equals(se[1],te[1])){var me=D.range(p,we);z.select(p,me)}}}),[p,y.onClick,a]),onCompositionEnd:m.useCallback((B=>{if(Z.hasSelectableTarget(p,B.target)){var X;if(Z.isComposing(p)&&Promise.resolve().then((()=>{b(!1),Rr.set(p,!1)})),(X=_.current)===null||X===void 0||X.handleCompositionEnd(B),Dt(B,y.onCompositionEnd)||It)return;if(!Dr&&!bD&&!Xg&&!wD&&!CD&&B.data){var K=on.get(p);on.delete(p),K!==void 0&&(Pn.set(p,p.marks),p.marks=K),D.insertText(p,B.data);var Y=Pn.get(p);Pn.delete(p),Y!==void 0&&(p.marks=Y)}}}),[y.onCompositionEnd,p]),onCompositionUpdate:m.useCallback((B=>{Z.hasSelectableTarget(p,B.target)&&!Dt(B,y.onCompositionUpdate)&&(Z.isComposing(p)||(b(!0),Rr.set(p,!0)))}),[y.onCompositionUpdate,p]),onCompositionStart:m.useCallback((B=>{if(Z.hasSelectableTarget(p,B.target)){var X;if((X=_.current)===null||X===void 0||X.handleCompositionStart(B),Dt(B,y.onCompositionStart)||It)return;b(!0);var{selection:K}=p;if(K&&U.isExpanded(K))return void D.deleteFragment(p)}}),[y.onCompositionStart,p]),onCopy:m.useCallback((B=>{!Z.hasSelectableTarget(p,B.target)||Dt(B,y.onCopy)||dh(B)||(B.preventDefault(),Z.setFragmentData(p,B.clipboardData,"copy"))}),[y.onCopy,p]),onCut:m.useCallback((B=>{if(!a&&Z.hasSelectableTarget(p,B.target)&&!Dt(B,y.onCut)&&!dh(B)){B.preventDefault(),Z.setFragmentData(p,B.clipboardData,"cut");var{selection:X}=p;if(X)if(U.isExpanded(X))D.deleteFragment(p);else{var K=ee.parent(p,X.anchor.path);D.isVoid(p,K)&&z.delete(p)}}}),[a,p,y.onCut]),onDragOver:m.useCallback((B=>{if(Z.hasTarget(p,B.target)&&!Dt(B,y.onDragOver)){var X=Z.toSlateNode(p,B.target);le.isElement(X)&&D.isVoid(p,X)&&B.preventDefault()}}),[y.onDragOver,p]),onDragStart:m.useCallback((B=>{if(!a&&Z.hasTarget(p,B.target)&&!Dt(B,y.onDragStart)){var X=Z.toSlateNode(p,B.target),K=Z.findPath(p,X);if(le.isElement(X)&&D.isVoid(p,X)||D.void(p,{at:K,voids:!0})){var Y=D.range(p,K);z.select(p,Y)}k.isDraggingInternally=!0,Z.setFragmentData(p,B.dataTransfer,"drag")}}),[a,p,y.onDragStart,k]),onDrop:m.useCallback((B=>{if(!a&&Z.hasTarget(p,B.target)&&!Dt(B,y.onDrop)){B.preventDefault();var X=p.selection,K=Z.findEventRange(p,B),Y=B.dataTransfer;z.select(p,K),k.isDraggingInternally&&(!X||U.equals(X,K)||D.void(p,{at:K,voids:!0})||z.delete(p,{at:X})),Z.insertData(p,Y),Z.isFocused(p)||Z.focus(p)}}),[a,p,y.onDrop,k]),onDragEnd:m.useCallback((B=>{!a&&k.isDraggingInternally&&y.onDragEnd&&Z.hasTarget(p,B.target)&&y.onDragEnd(B)}),[a,k,y,p]),onFocus:m.useCallback((B=>{if(!a&&!k.isUpdatingSelection&&Z.hasEditableTarget(p,B.target)&&!Dt(B,y.onFocus)){var X=Z.toDOMNode(p,p),K=Z.findDocumentOrShadowRoot(p);if(k.latestElement=K.activeElement,lo&&B.target!==X)return void X.focus();cr.set(p,!0)}}),[a,k,p,y.onFocus]),onKeyDown:m.useCallback((B=>{if(!a&&Z.hasEditableTarget(p,B.target)){var X;(X=_.current)===null||X===void 0||X.handleKeyDown(B);var{nativeEvent:K}=B;if(Z.isComposing(p)&&K.isComposing===!1&&(Rr.set(p,!1),b(!1)),Dt(B,y.onKeyDown)||Z.isComposing(p))return;var{selection:Y}=p,de=p.children[Y!==null?Y.focus.path[0]:0],pe=Wg(ee.string(de))==="rtl";if(Ze.isRedo(K)){B.preventDefault();var fe=p;return void(typeof fe.redo=="function"&&fe.redo())}if(Ze.isUndo(K)){B.preventDefault();var we=p;return void(typeof we.undo=="function"&&we.undo())}if(Ze.isMoveLineBackward(K))return B.preventDefault(),void z.move(p,{unit:"line",reverse:!0});if(Ze.isMoveLineForward(K))return B.preventDefault(),void z.move(p,{unit:"line"});if(Ze.isExtendLineBackward(K))return B.preventDefault(),void z.move(p,{unit:"line",edge:"focus",reverse:!0});if(Ze.isExtendLineForward(K))return B.preventDefault(),void z.move(p,{unit:"line",edge:"focus"});if(Ze.isMoveBackward(K))return B.preventDefault(),void(Y&&U.isCollapsed(Y)?z.move(p,{reverse:!pe}):z.collapse(p,{edge:pe?"end":"start"}));if(Ze.isMoveForward(K))return B.preventDefault(),void(Y&&U.isCollapsed(Y)?z.move(p,{reverse:pe}):z.collapse(p,{edge:pe?"start":"end"}));if(Ze.isMoveWordBackward(K))return B.preventDefault(),Y&&U.isExpanded(Y)&&z.collapse(p,{edge:"focus"}),void z.move(p,{unit:"word",reverse:!pe});if(Ze.isMoveWordForward(K))return B.preventDefault(),Y&&U.isExpanded(Y)&&z.collapse(p,{edge:"focus"}),void z.move(p,{unit:"word",reverse:pe});if(er){if((Yg||Dr)&&Y&&(Ze.isDeleteBackward(K)||Ze.isDeleteForward(K))&&U.isCollapsed(Y)){var Ce=ee.parent(p,Y.anchor.path);if(le.isElement(Ce)&&D.isVoid(p,Ce)&&(D.isInline(p,Ce)||D.isBlock(p,Ce)))return B.preventDefault(),void D.deleteBackward(p,{unit:"block"})}}else{if(Ze.isBold(K)||Ze.isItalic(K)||Ze.isTransposeCharacter(K))return void B.preventDefault();if(Ze.isSoftBreak(K))return B.preventDefault(),void D.insertSoftBreak(p);if(Ze.isSplitBlock(K))return B.preventDefault(),void D.insertBreak(p);if(Ze.isDeleteBackward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p));if(Ze.isDeleteForward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p));if(Ze.isDeleteLineBackward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p,{unit:"line"}));if(Ze.isDeleteLineForward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p,{unit:"line"}));if(Ze.isDeleteWordBackward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p,{unit:"word"}));if(Ze.isDeleteWordForward(K))return B.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p,{unit:"word"}))}}}),[a,p,y.onKeyDown]),onPaste:m.useCallback((B=>{a||!Z.hasEditableTarget(p,B.target)||Dt(B,y.onPaste)||(!er||(X=>X.clipboardData&&X.clipboardData.getData("text/plain")!==""&&X.clipboardData.types.length===1)(B.nativeEvent)||Dr)&&(B.preventDefault(),Z.insertData(p,B.clipboardData))}),[a,p,y.onPaste])}),Be.createElement(t2,{decorations:q,node:p,renderElement:u,renderPlaceholder:f,renderLeaf:l,selection:p.selection}))))))})),r2=e=>{var{attributes:t,children:n}=e;return Be.createElement("span",yn({},t),n,It&&Be.createElement("br",null))},o2=()=>[],i2=(e,t)=>{if(t.getBoundingClientRect&&(!e.selection||e.selection&&U.isCollapsed(e.selection))){var n=t.startContainer.parentElement;n.getBoundingClientRect=t.getBoundingClientRect.bind(t),rD(n,{scrollMode:"if-needed"}),delete n.getBoundingClientRect}},Dt=(e,t)=>{if(!t)return!1;var n=t(e);return n??(e.isDefaultPrevented()||e.isPropagationStopped())},dh=e=>pr(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement),s2=(e,t)=>{if(!t)return!1;var n=t(e);return n??e.defaultPrevented},a2=m.createContext(!1),u2=m.createContext({}),c2=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],l2=e=>{var{editor:t,children:n,onChange:r,onSelectionChange:o,onValueChange:i,initialValue:s}=e,a=Io(e,c2),[u,l]=Be.useState((()=>{if(!ee.isNodeList(s))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(ht.stringify(s)));if(!D.isEditor(t))throw new Error("[Slate] editor is invalid! You passed: ".concat(ht.stringify(t)));return t.children=s,Object.assign(t,a),{v:0,editor:t}})),{selectorContext:f,onChange:c}=(function(y){var p=m.useRef([]).current,w=m.useRef({editor:y}).current,b=m.useCallback((C=>{w.editor=C,p.forEach((E=>E(C)))}),[p,w]);return{selectorContext:m.useMemo((()=>({getSlate:()=>w.editor,addEventListener:C=>(p.push(C),()=>{p.splice(p.indexOf(C),1)})})),[p,w]),onChange:b}})(t),d=m.useCallback((y=>{var p;r&&r(t.children),(y==null||(p=y.operation)===null||p===void 0?void 0:p.type)==="set_selection"?o?.(t.selection):i?.(t.children),l((w=>({v:w.v+1,editor:t}))),c(t)}),[t,c,r,o,i]);m.useEffect((()=>($u.set(t,d),()=>{$u.set(t,(()=>{}))})),[t,d]);var[h,g]=m.useState(Z.isFocused(t));return m.useEffect((()=>{g(Z.isFocused(t))}),[t]),Di((()=>{var y=()=>g(Z.isFocused(t));return Zg>=17?(document.addEventListener("focusin",y),document.addEventListener("focusout",y),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",y)}):(document.addEventListener("focus",y,!0),document.addEventListener("blur",y,!0),()=>{document.removeEventListener("focus",y,!0),document.removeEventListener("blur",y,!0)})}),[]),Be.createElement(u2.Provider,{value:f},Be.createElement(p0.Provider,{value:u},Be.createElement(ul.Provider,{value:u.editor},Be.createElement(a2.Provider,{value:h},n))))},fh=(e,t)=>{var n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n},hh=(e,t,n)=>{var r=Z.toDOMRange(e,t).getBoundingClientRect(),o=Z.toDOMRange(e,n).getBoundingClientRect();return fh(r,o)&&fh(o,r)};function ph(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 mh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ph(Object(n),!0).forEach((function(r){Qt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ph(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var d2=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",n=e,{apply:r,onChange:o,deleteBackward:i,addMark:s,removeMark:a}=n;return Qs.set(n,new WeakMap),n.addMark=(u,l)=>{var f,c;(f=dl.get(n))===null||f===void 0||f(),!on.get(n)&&(c=_t.get(n))!==null&&c!==void 0&&c.length&&on.set(n,null),Pn.delete(n),s(u,l)},n.removeMark=u=>{var l;!on.get(n)&&(l=_t.get(n))!==null&&l!==void 0&&l.length&&on.set(n,null),Pn.delete(n),a(u)},n.deleteBackward=u=>{if(u!=="line")return i(u);if(n.selection&&U.isCollapsed(n.selection)){var l=D.above(n,{match:h=>le.isElement(h)&&D.isBlock(n,h),at:n.selection});if(l){var[,f]=l,c=D.range(n,f,n.selection.anchor),d=((h,g)=>{var y=D.range(h,U.end(g)),p=Array.from(D.positions(h,{at:g})),w=0,b=p.length,C=Math.floor(b/2);if(hh(h,D.range(h,p[w]),y))return D.range(h,p[w],y);if(p.length<2)return D.range(h,p[p.length-1],y);for(;C!==p.length&&C!==w;)hh(h,D.range(h,p[C]),y)?b=C:w=C,C=Math.floor((w+b)/2);return D.range(h,p[b],y)})(n,c);U.isCollapsed(d)||z.delete(n,{at:d})}}},n.apply=u=>{var l=[],f=[],c=_t.get(n);if(c!=null&&c.length){var d=c.map((M=>(function(H,W){var{path:G,diff:q,id:$}=H;switch(W.type){case"insert_text":return!R.equals(W.path,G)||W.offset>=q.end?H:W.offset<=q.start?{diff:{start:W.text.length+q.start,end:W.text.length+q.end,text:q.text},id:$,path:G}:{diff:{start:q.start,end:q.end+W.text.length,text:q.text},id:$,path:G};case"remove_text":return!R.equals(W.path,G)||W.offset>=q.end?H:W.offset+W.text.length<=q.start?{diff:{start:q.start-W.text.length,end:q.end-W.text.length,text:q.text},id:$,path:G}:{diff:{start:q.start,end:q.end-W.text.length,text:q.text},id:$,path:G};case"split_node":return!R.equals(W.path,G)||W.position>=q.end?{diff:q,id:$,path:R.transform(G,W,{affinity:"backward"})}:W.position>q.start?{diff:{start:q.start,end:Math.min(W.position,q.end),text:q.text},id:$,path:G}:{diff:{start:q.start-W.position,end:q.end-W.position,text:q.text},id:$,path:R.transform(G,W,{affinity:"forward"})};case"merge_node":return R.equals(W.path,G)?{diff:{start:q.start+W.position,end:q.end+W.position,text:q.text},id:$,path:R.transform(G,W)}:{diff:q,id:$,path:R.transform(G,W)}}var V=R.transform(G,W);return V?{diff:q,path:V,id:$}:null})(M,u))).filter(Boolean);_t.set(n,d)}var h=rr.get(n);h&&rr.set(n,nh(n,h,u));var g=nr.get(n);if(g!=null&&g.at){var y=_e.isPoint(g?.at)?Ku(n,g.at,u):nh(n,g.at,u);nr.set(n,y?mh(mh({},g),{},{at:y}):null)}switch(u.type){case"insert_text":case"remove_text":case"set_node":case"split_node":l.push(...Qr(n,u.path));break;case"set_selection":var p;(p=ci.get(n))===null||p===void 0||p.unref(),ci.delete(n);break;case"insert_node":case"remove_node":l.push(...Qr(n,R.parent(u.path)));break;case"merge_node":var w=R.previous(u.path);l.push(...Qr(n,w));break;case"move_node":var b,C=R.common(R.parent(u.path),R.parent(u.newPath));l.push(...Qr(n,C)),R.isBefore(u.path,u.newPath)?(l.push(...Qr(n,R.parent(u.path))),b=u.newPath):(l.push(...Qr(n,R.parent(u.newPath))),b=u.path);var E=ee.get(e,R.parent(b)),A=Z.findKey(n,E),x=D.pathRef(n,R.parent(b));f.push([x,A])}switch(r(u),u.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":yo.set(n,!0)}for(var[I,T]of l){var[F]=D.node(n,I);js.set(F,T)}for(var[S,k]of f){if(S.current){var[_]=D.node(n,S.current);js.set(_,k)}S.unref()}},n.setFragmentData=u=>{var{selection:l}=n;if(l){var[f,c]=U.edges(l),d=D.void(n,{at:f.path}),h=D.void(n,{at:c.path});if(!U.isCollapsed(l)||d){var g=Z.toDOMRange(n,l),y=g.cloneContents(),p=y.childNodes[0];if(y.childNodes.forEach((F=>{F.textContent&&F.textContent.trim()!==""&&(p=F)})),h){var[w]=h,b=g.cloneRange(),C=Z.toDOMNode(n,w);b.setEndAfter(C),y=b.cloneContents()}if(d&&(p=y.querySelector("[data-slate-spacer]")),Array.from(y.querySelectorAll("[data-slate-zero-width]")).forEach((F=>{var S=F.getAttribute("data-slate-zero-width")==="n";F.textContent=S?`
|
|
58
|
+
`:""})),r0(p)){var E=p.ownerDocument.createElement("span");E.style.whiteSpace="pre",E.appendChild(p),y.appendChild(E),p=E}var A=n.getFragment(),x=JSON.stringify(A),I=window.btoa(encodeURIComponent(x));p.setAttribute("data-slate-fragment",I),u.setData("application/".concat(t),I);var T=y.ownerDocument.createElement("div");return T.appendChild(y),T.setAttribute("hidden","true"),y.ownerDocument.body.appendChild(T),u.setData("text/html",T.innerHTML),u.setData("text/plain",i0(T)),y.ownerDocument.body.removeChild(T),u}}},n.insertData=u=>{n.insertFragmentData(u)||n.insertTextData(u)},n.insertFragmentData=u=>{var l=u.getData("application/".concat(t))||(d=>{var h=d.getData("text/html"),[,g]=h.match(xD)||[];return g})(u);if(l){var f=decodeURIComponent(window.atob(l)),c=JSON.parse(f);return n.insertFragment(c),!0}return!1},n.insertTextData=u=>{var l=u.getData("text/plain");if(l){var f=l.split(/\r\n|\r|\n/),c=!1;for(var d of f)c&&z.splitNodes(n,{always:!0}),n.insertText(d),c=!0;return!0}return!1},n.onChange=u=>{(Zg<18?kv.unstable_batchedUpdates:l=>l())((()=>{var l=$u.get(n);l&&l(u),o(u)}))},n},Qr=(e,t)=>{var n=[];for(var[r,o]of D.levels(e,{at:t})){var i=Z.findKey(e,r);n.push([o,i])}return n};function pl(e,t,n=3){if(!(n<=0))try{return Z.toDOMRange(e,t)}catch{return pl(e,{anchor:t.anchor,focus:t.anchor},n-1)}}function ko(e){return!e.trim()}function In(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function Gu(e){return In(e)&&Object.keys(e).length===1}function Ju(e,t){for(const n of t)if(In(n)){if(!ko(n.text))return!1}else if(n.type==="paragraph"){if(n.children.length>1||n.children[0]&&(!In(n.children[0])||!ko(n.children[0].text)))return!1}else if(!D.isEmpty(e,n))return!1;return!0}let gs;const Zu=new WeakMap,Xu=new WeakMap;function gh(e,t){t?(Xu.get(e)?.unobserve(e),Xu.delete(e)):(Zu.delete(e),gs?.unobserve(e))}function f2(e,t,n){const r=n?.enabled??!0,o=Vs(t),{root:i,rootMargin:s,threshold:a}=n??{};m.useEffect((()=>{const u=e.current;if(!u)return;const l={root:i,rootMargin:s,threshold:a};return r?(function(f,c,d){if(d){const h=new IntersectionObserver((g=>{for(const y of g)c?.(y)}),{root:d.root?.current,rootMargin:typeof d.rootMargin=="number"?`${d.rootMargin}px`:d.rootMargin,threshold:d.threshold});Xu.set(f,h),h.observe(f)}else gs||(gs=new IntersectionObserver((h=>{for(const g of h)Zu.get(g.target)?.(g)}))),Zu.set(f,c),gs.observe(f)})(u,(f=>{o.current(f.isIntersecting,f)}),l):gh(u,l),()=>{gh(u,l)}}),[e,r,o,i,s,a])}const ml=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"span";return v.jsx(o,{...n,ref:r,children:e})})),g0=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),h2={Mention:({mention:e})=>v.jsxs(ml,{children:[An,e.id]}),Link:({href:e,children:t})=>v.jsx(g0,{href:e,children:t})},p2=m.forwardRef((({body:e,components:t,style:n,asChild:r,...o},i)=>{const s=r?vt:"div",{Mention:a,Link:u}=m.useMemo((()=>({...h2,...t})),[t]);return e&&e?.content?v.jsx(s,{...o,style:{whiteSpace:"break-spaces",...n},ref:i,children:e.content.map(((l,f)=>l.type==="paragraph"?v.jsx("p",{style:{minHeight:"1lh"},children:l.children.map(((c,d)=>{if(Fp(c)){const{type:g,...y}=c;return y.id?v.jsx(a,{mention:y},d):null}if(Rp(c)){const g=fp(c.url);return g===null?v.jsx("span",{children:c.text??c.url},d):v.jsx(u,{href:g,children:c.text??c.url},d)}let h=c.text;return c.bold&&(h=v.jsx("strong",{children:h},d)),c.italic&&(h=v.jsx("em",{children:h},d)),c.strikethrough&&(h=v.jsx("s",{children:h},d)),c.code&&(h=v.jsx("code",{children:h},d)),v.jsx("span",{children:h},d)}))},f):null))}):null})),m2={alt:()=>"altKey",ctrl:()=>"ctrlKey",meta:()=>"metaKey",mod:()=>Rg()?"metaKey":"ctrlKey",shift:()=>"shiftKey"};function At(e,t,n={}){return e.key!==t?!1:Object.entries(n).filter((([,o])=>typeof o=="boolean")).every((([o,i])=>{const s=m2[o]();return e[s]===i}))}const v0=m.createContext(null);function gl(){return ye(m.useContext(v0),"Persist is missing from the React tree.")}function y0(e){const[t,n]=gl(),r=m.useRef(null),o=m.useRef(null);xn((()=>{const i=e.current;if(!i)return;const s=a=>{a.animationName===o.current&&n(),r.current=a.animationName};return i.addEventListener("animationcancel",s),i.addEventListener("animationend",s),()=>{i.removeEventListener("animationcancel",s),i.removeEventListener("animationend",s)}}),[e,n]),xn((()=>{const i=e.current;let s;if(i)return t||(s=requestAnimationFrame((()=>{const a=getComputedStyle(i);o.current=a.animationName,a.animationName!=="none"&&a.animationName!==r.current&&a.display!=="none"||n()}))),()=>{cancelAnimationFrame(s)}}),[t,e,n])}function b0({children:e}){const[t,n]=m.useState(!0),r=m.useRef(null),o=(function(s){const a=Array.isArray(s)?m.Children.only(s):s;return m.isValidElement(a)?a:void 0})(e),i=m.useCallback((()=>{Oi.flushSync((()=>n(!1)))}),[]);return xn((()=>{o&&(n(!0),r.current=o)}),[o]),v.jsx(v0.Provider,{value:[!!o,i],children:o??(t?r.current:null)})}function vh(e,t,n){return Math.min(Math.max(e,t),n)}function g2(e,t,n){const r=n-t;return r>0?((e-t)%r+r)%r+t:0}const v2={wrap:!0};function vl(e,t){const n=Vs(t);m.useEffect((()=>e.subscribe((()=>n.current()))),[e,n])}function Ai(e,t,n={}){const{filterVoids:r}=n,o=D.before(e,t,{unit:"character",voids:r});if(o){const i=D.range(e,o,U.isRange(t)?U.start(t):t),s=D.string(e,i);return{range:i,text:s,void:s.length===0}}}function yl(e,t,n={}){const{filterVoids:r}=n,o=D.after(e,t,{unit:"character",voids:r});if(o){const i=D.range(e,o,U.isRange(t)?U.end(t):t),s=D.string(e,i);return{range:i,text:s,void:s.length===0}}}const yh={bold:!1,italic:!1,strikethrough:!1,code:!1};function bh(e){if(!e)return{...yh};const t=D.marks(e);return{...yh,...t}}function C0(e){return Object.keys(e??{}).filter((t=>t!=="text"))}function Qo(e,t){(function(r,o){const i=D.marks(r);return!!i&&i[o]===!0})(e,t)?D.removeMark(e,t):D.addMark(e,t,!0)}function w0(e){const t=D.marks(e);if(t)for(const n in t)D.removeMark(e,n)}function Ch(e,t){e.selection&&U.isCollapsed(e.selection)&&Object.keys(D.marks(e)??{}).length>0&&((t==="start"?Ai(e,e.selection):yl(e,e.selection))||w0(e))}const E0=m.createContext(null),D0=m.createContext(null),A0=m.createContext(null),x0=m.createContext(null),O0=m.createContext(null);function ea(){return ye(m.useContext(D0),"Composer.Form is missing from the React tree.")}function S0(){return m.useContext(A0)}function bl(){return ye(S0(),"Composer.Form is missing from the React tree.")}function Cl(e="useComposerSuggestionsContext"){return ye(m.useContext(x0),`${e} can’t be used outside of Composer.Editor.`)}function Wt(){return ye(m.useContext(E0),"Composer.Form is missing from the React tree.")}const y2=/\s/;function Ms(e){return!!e&&y2.test(e)}const wh={direction:"before",allowConsecutiveWhitespace:!0};function I0(e,t,n=[" "],r=wh){const{include:o,direction:i,ignoreTerminator:s,allowConsecutiveWhitespace:a}={...wh,...r};let[u,l]=U.edges(t),f=u,c=!1;function d(h){const g=h==="after"?D.after(e,f,{unit:"character"}):D.before(e,f,{unit:"character"});if(!g||R.compare(g.path,f.path)!==0)return!1;const y=g&&D.string(e,h==="after"?{anchor:f,focus:g}:{anchor:g,focus:f}),p=y&&y[h==="after"?0:y.length-1];return!(!a&&c&&Ms(p))&&!(!g||!p||n.includes(p)&&!s?.(p,g,h))&&(c=Ms(p),f=g,f.offset!==0)}if(i!=="before"){for(f=l;d("after"););l=f}if(i!=="after"){for(f=u;d("before"););u=f}return o?{anchor:i==="before"||i==="both"?D.before(e,u,{unit:"offset"})??u:u,focus:i==="after"||i==="both"?D.after(e,l,{unit:"offset"})??l:l}:{anchor:u,focus:l}}const T0=[{type:"mark",mark:"bold",character:"*"},{type:"mark",mark:"italic",character:"_"},{type:"mark",mark:"strikethrough",character:"~"},{type:"mark",mark:"code",character:"`"}],b2=T0.filter((e=>e.type==="mark")).map((e=>e.character));function C2(e,t,n){if(t!==n.character)return!1;const r=I0(e,e.selection,[n.character]);if(!r||U.isCollapsed(r))return!1;const o=Ai(e,r);if(!o||o.text!==n.character)return!1;const i=Ai(e,o.range);if(i&&!b2.includes(i.text)&&!ko(i.text))return!1;const s=D.string(e,r);return s.trim()===s&&(z.select(e,r),e.addMark(n.mark,!0),z.collapse(e,{edge:"end"}),e.removeMark(n.mark),z.delete(e,{at:o.range}),!0)}function w2(e){const{isInline:t,normalizeNode:n,insertData:r}=e;return e.isInline=o=>o.type==="custom-link"||t(o),e.normalizeNode=o=>{const[i,s]=o;if(le.isElement(i)&&i.type==="custom-link"&&(i.children.length===0||i.children.length===1&&i.children[0]?.text==="")&&z.removeNodes(e,{at:s}),In(i)&&Ps(ee.parent(e,s))&&!Gu(i)){const a=C0(i);z.unsetNodes(e,a,{at:s})}n(o)},e.insertData=o=>{const{selection:i}=e,s=o.getData("text/plain");let a=!0;i&&!U.isCollapsed(i)&&i.anchor.path[0]===i.focus.path[0]&&(function(u){try{return new URL(u),!0}catch{return!1}})(s)&&((function(u,l){const{selection:f}=u;if(!f)return!1;const c=Array.from(D.nodes(u,{at:f,match:d=>le.isElement(d)&&D.isBlock(u,d),mode:"lowest"}));for(const[,d]of c){const h=U.isRange(f)?U.intersection(f,D.range(u,d)):f;if(!h)continue;if(Array.from(D.nodes(u,{at:h,match:y=>D.isInline(u,y)&&l(y)})).length>0)return!0}return!1})(e,(u=>!In(u)))||(z.wrapNodes(e,{type:"custom-link",url:s,children:[]},{at:i,split:!0,match:Gu}),a=!1)),a&&r(o)},e}function Ps(e){return le.isElement(e)&&e.type==="custom-link"}function bo(e){return le.isElement(e)&&e.type==="auto-link"}const k0=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9().@:%_+~#?&//=]*)/,E2=/[.,;!?\s()]/,D2=/^[.?][a-zA-Z0-9]+/,A2=/[()]/;function Ns(e){return E2.test(e)}function B0(e){const t=e[e.length-1];return t!==void 0&&Ns(t)}function F0(e){const t=e[0];return t!==void 0&&Ns(t)}function R0(e,t){const n=D.previous(e,{at:t});return!n||In(n[0])&&(B0(n[0].text)||n[0].text==="")}function _0(e,t){const n=D.next(e,{at:t});return!n||In(n[0])&&(F0(n[0].text)||n[0].text==="")}const x2=(e,t)=>{const[n,r]=t,o=ee.children(e,r);for(const[f]of o)if(!In(f))return void z.unwrapNodes(e,{at:r});const i=ee.string(n),s=k0.exec(i),a=s?.[0];if(!s||a!==i)return void z.unwrapNodes(e,{at:r});if((u=i)[u.length-1]==="."||u[u.length-1]==="?"){z.unwrapNodes(e,{at:r});const f=i.slice(0,i.length-1);return void z.wrapNodes(e,{type:"auto-link",url:f,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:f.length}},split:!0})}var u;const l=(function(f){if(!A2.test(f))return f.length;let c=0,d=0;for(const h of f){if(h==="("&&d++,h===")"&&(d--,d<0))break;c++}return c})(i);if(l<i.length){z.unwrapNodes(e,{at:r});const f=i.slice(0,l);z.wrapNodes(e,{type:"auto-link",url:f,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:f.length}},split:!0})}else R0(e,r)&&_0(e,r)?n.url===i||z.setNodes(e,{url:a},{at:r}):z.unwrapNodes(e,{at:r})},O2=(e,t)=>{const[n,r]=t,o=k0.exec(n.text),i=o?.[0];if(!o||i===void 0)return;const s=o.index,a=s+i.length;(function(u,l,f,c){const[d,h]=l,g=d.text,y=g[f-1],p=f>0&&y?Ns(y):R0(u,h),w=g[c],b=c<g.length&&w?Ns(w):_0(u,h);return p&&b})(e,t,s,a)&&z.wrapNodes(e,{type:"auto-link",url:i,children:[]},{at:{anchor:{path:r,offset:s},focus:{path:r,offset:a}},split:!0})},S2=(e,t)=>{const[n,r]=t,o=n.text,i=D.previous(e,{at:r});if(i&&bo(i[0])){if(D2.test(o))return z.unwrapNodes(e,{at:i[1]}),void z.mergeNodes(e,{at:r});if(!F0(o))return void z.unwrapNodes(e,{at:i[1]})}const s=D.next(e,{at:r});s&&bo(s[0])&&!B0(o)&&z.unwrapNodes(e,{at:s[1]})},I2=new RegExp("\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\uFE0F|\\u200D","u"),T2=new Set(['"',"'",".","!","?",",",";","(",")","[","]","<",">"]);function ei(e){return le.isElement(e)&&e.type==="mention"}function di(e){return di=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},di(e)}function k2(e){var t=(function(n,r){if(di(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(di(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return di(t)==="symbol"?t:String(t)}function Bo(e,t,n){return(t=k2(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j0=new WeakMap,M0=new WeakMap;class wl{}class vs extends wl{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),Bo(this,"offset",void 0),Bo(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}class ys extends wl{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),Bo(this,"offset",void 0),Bo(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}var B2=e=>M0.get(e);function Eh(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 Yu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Eh(Object(n),!0).forEach((function(r){Bo(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Eh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var bs=new WeakSet,Cs=e=>{var t=[],n=o=>{if(o!=null){var i=t[t.length-1];if(typeof o=="string"){var s={text:o};bs.add(s),o=s}if(he.isText(o)){var a=o;he.isText(i)&&bs.has(i)&&bs.has(a)&&he.equals(i,a,{loose:!0})?i.text+=a.text:t.push(a)}else if(le.isElement(o))t.push(o);else{if(!(o instanceof wl))throw new Error("Unexpected hyperscript child object: ".concat(o));var u=t[t.length-1];he.isText(u)||(n(""),u=t[t.length-1]),o instanceof vs?((l,f)=>{var c=l.text.length;j0.set(l,[c,f])})(u,o):o instanceof ys&&((l,f)=>{var c=l.text.length;M0.set(l,[c,f])})(u,o)}}};for(var r of e.flat(1/0))n(r);return t};function P0(e,t,n){return Yu(Yu({},t),{},{children:Cs(n)})}function Dh(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 fi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dh(Object(n),!0).forEach((function(r){Bo(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Ah,F2={anchor:function(e,t,n){return new vs(t)},cursor:function(e,t,n){return[new vs(t),new ys(t)]},editor:(Ah=$g,(e,t,n)=>{var r,o=[];for(var i of n)U.isRange(i)?r=i:o.push(i);var s,a=Cs(o),u={},l=Ah();for(var[f,c]of(Object.assign(l,t),l.children=a,ee.texts(l))){var d=(s=f,j0.get(s)),h=B2(f);if(d!=null){var[g]=d;u.anchor={path:c,offset:g}}if(h!=null){var[y]=h;u.focus={path:c,offset:y}}}if(u.anchor&&!u.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!u.anchor&&u.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return r!=null?l.selection=r:U.isRange(u)&&(l.selection=u),l}),element:P0,focus:function(e,t,n){return new ys(t)},fragment:function(e,t,n){return Cs(n)},selection:function(e,t,n){var r=n.find((i=>i instanceof vs)),o=n.find((i=>i instanceof ys));if(!r||r.offset==null||r.path==null)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||o.offset==null||o.path==null)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return Yu({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Cs(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(o==null&&(o={text:""}),!he.isText(o))throw new Error(`
|
|
59
|
+
The <text> hyperscript tag can only contain text content as children.`);return bs.delete(o),Object.assign(o,t),o}},R2=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var s=e[t];if(!s)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return n==null&&(n={}),ft(n)||(o=[n].concat(o),n={}),s(t,n,o=o.filter((a=>!!a)).flat())},_2=e=>{var t={},n=function(){var o=e[r];if(typeof o!="object")throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(r,"> tag you passed: ").concat(o));t[r]=(i,s,a)=>P0(0,fi(fi({},o),s),a)};for(var r in e)n();return t},ti=(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{elements:t={}}=e,n=_2(t),r=fi(fi(fi({},F2),n),e.creators);return R2(r)})();function xi(e){return e!=null}function N0(e){if(!e.types.includes("Files"))return[];let t=Array.from(e.items).map((n=>{const r=n.webkitGetAsEntry();return r&&r.isFile?n.getAsFile():null})).filter(xi);return t.length||(t=Array.from(e.files).filter((n=>n.type!==""))),t}const j2=/[\r\n]/g,M2=/\s+/g;function P2(e,t){try{const n=new URL(e),r=new URL(t);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}}const Bn=()=>({type:"paragraph"}),xh={A:e=>{const t=e.getAttribute("href"),n=e.innerText;return{type:t&&P2(t,n)?"auto-link":"custom-link",url:t??""}},P:Bn,BLOCKQUOTE:Bn,H1:Bn,H2:Bn,H3:Bn,H4:Bn,H5:Bn,H6:Bn,LI:Bn},Oh={CODE:()=>({code:!0}),DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),B:()=>({bold:!0})};function L0(e){const t=[];return e.nodeName==="LI"&&t.push(e),e.childNodes.forEach((n=>{n.nodeType===1&&t.push(...L0(n))})),t}function Sh(e,t){return e.map((n=>ti("text",t,n)))}function Qu(e){if(e.nodeType===3){let n=e.textContent;const r=n&&j2.test(n);return n&&r&&(n=n.replace(M2," ").trim()),n?{text:n}:null}if(e.nodeType!==1)return null;if(e.nodeName==="BR")return ti("element",{type:"paragraph"},[]);let t=Array.from(e.childNodes).map(Qu).flat();if((e.nodeName==="UL"||e.nodeName==="OL")&&(t=L0(e).map((n=>Qu(n))).flat()),t.length===0&&(t=[{text:""}]),e.nodeName==="BODY")return t.length>0&&t.every((n=>typeof n=="string"))&&(t=[{type:"paragraph",children:[{text:t.join("")}]}]),ti("fragment",{},t.filter((n=>typeof n!="string")));if(xh[e.nodeName]){const n=xh[e.nodeName](e);return ti("element",n,t)}if(Oh[e.nodeName]){const n=Oh[e.nodeName](e);return t.some((r=>r&&typeof r!="string"&&"type"in r))?ti("fragment",{},t):Sh(t,n)}if(e.nodeName==="SPAN"){const n=e.style,r={};return n.fontWeight!=="bold"&&n.fontWeight!=="700"&&n.fontWeight!=="800"&&n.fontWeight!=="900"||(r.bold=!0),n.fontStyle==="italic"&&(r.italic=!0),n.textDecoration==="line-through"&&(r.strikethrough=!0),Sh(t,r)}return t}const N2=[];function L2(e){switch(e){case"start":return"end";case"end":return"start";default:return"center"}}function U0(e){const[t,n="center"]=e.split("-");return[t,n]}function H0(){const[e,t]=m.useState(null),n=m.useCallback(t,[t]),[r,o]=m.useState();return xn((()=>{if(e){const i=window.getComputedStyle(e).zIndex,s=parseInt(i,10);o(Number.isNaN(s)?void 0:s)}}),[e]),[n,r]}function V0({type:e="bounds",position:t,alignment:n,dir:r,open:o}){return Mm({...m.useMemo((()=>{const i={padding:10},s=[e==="range"?_b(i):null,Um({...i,crossAxis:!1}),Vm(i),Nm({...i,limiter:Lm()}),e==="range"?Pm(6):null,Hm({...i,apply({availableWidth:a,availableHeight:u,elements:l}){l.floating.style.setProperty("--lb-composer-floating-available-width",`${a}px`),l.floating.style.setProperty("--lb-composer-floating-available-height",`${u}px`)}})];return{strategy:"fixed",placement:n==="center"?t:`${t}-${r==="rtl"?L2(n):n}`,middleware:s,whileElementsMounted:(...a)=>_m(...a,{animationFrame:!0})}}),[n,t,r,e]),open:o})}function $0({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o}){const{isDisabled:i}=Wt(),s=i||o,{createAttachments:a}=bl(),[u,l]=m.useState(!1),f=Vs(u);return[u,{onDragEnter:m.useCallback((c=>{e?.(c),!(f.current||s||c.isDefaultPrevented())&&c.dataTransfer.types.includes("Files")&&(c.preventDefault(),c.stopPropagation(),l(!0))}),[e,s]),onDragLeave:m.useCallback((c=>{t?.(c),!f.current||s||c.isDefaultPrevented()||(c.relatedTarget?c.relatedTarget===c.currentTarget||c.currentTarget.contains(c.relatedTarget):c.currentTarget!==c.target)||(c.preventDefault(),c.stopPropagation(),l(!1))}),[t,s]),onDragOver:m.useCallback((c=>{n?.(c),s||c.isDefaultPrevented()||(c.preventDefault(),c.stopPropagation())}),[n,s]),onDrop:m.useCallback((c=>{if(r?.(c),!f.current||s||c.isDefaultPrevented())return;c.preventDefault(),c.stopPropagation(),l(!1);const d=N0(c.dataTransfer);a(d)}),[r,s,a]),"data-drop":u?"":void 0,"data-disabled":s?"":void 0}]}class ec extends Error{origin;name="AttachmentTooLargeError";constructor(t,n="client"){super(t),this.origin=n}}function Ih(e){e.preventDefault()}function U2(e,t){const n=Ve(),r=So(e),o=So((()=>(function(a,u,l){const f=new Map,c=new Map,d=Ue();let h=null;function g(){h=null,d.notify()}function y(p){const w=new AbortController;c.set(p.id,w),a[Oe].httpClient.uploadAttachment({roomId:u,attachment:p,signal:w.signal}).then((()=>{f.set(p.id,{...p,status:"uploaded"}),g()})).catch((b=>{b instanceof Error&&b.name!=="AbortError"&&b.name!=="TimeoutError"&&(f.set(p.id,{...p,status:"error",error:b instanceof _o&&b.status===413?new ec("File is too large.","server"):b}),g())}))}return{addAttachments:function(p){if(p.length===0)return;const w=p.filter((C=>!f.has(C.id))),b=[];for(const C of w)if(C.type==="localAttachment"){if(C.file.size>l.maxFileSize){f.set(C.id,{...C,status:"error",error:new ec("File is too large.","client")});continue}f.set(C.id,{...C,status:"uploading"}),b.push(C)}else f.set(C.id,C);w.length>0&&g();for(const C of b)y(C)},removeAttachment:function(p){c.get(p)?.abort(),f.delete(p),c.delete(p),g()},getSnapshot:function(){return h||(h=Array.from(f.values())),h},subscribe:d.subscribe,clear:function(){c.forEach((p=>p.abort())),c.clear(),f.clear(),g()}}})(n,t.roomId,t)));m.useEffect((()=>{o.addAttachments(r)}),[r,o]),m.useEffect((()=>()=>{o.clear()}),[o]);const i=m.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot),s=m.useMemo((()=>i.some((a=>a.type==="localAttachment"&&a.status==="uploading"))),[i]);return m.useEffect((()=>{if(s)return window.addEventListener("beforeunload",Ih),()=>{window.removeEventListener("beforeunload",Ih)}}),[s]),{attachments:i,isUploadingAttachments:s,addAttachments:o.addAttachments,removeAttachment:o.removeAttachment,clearAttachments:o.clear}}const H2={version:1,content:[{type:"paragraph",children:[{text:""}]}]};function V2({createAttachments:e,pasteFilesAsAttachments:t}){return(function(n){const{normalizeNode:r}=n;return n.normalizeNode=o=>{const[i,s]=o;if(le.isElement(i)&&i.type==="paragraph"){for(const[a,u]of ee.children(n,s))if(le.isElement(a)&&!n.isInline(a))return void z.unwrapNodes(n,{at:u})}r(o)},n})((function(n){const{isInline:r,isVoid:o,markableVoid:i,deleteBackward:s}=n;return n.isInline=a=>ei(a)||r(a),n.isVoid=a=>ei(a)||o(a),n.markableVoid=a=>ei(a)||i(a),n.deleteBackward=a=>{const{selection:u}=n;if(u&&U.isCollapsed(u)){const[l]=D.nodes(n,{at:a==="character"?D.before(n,u,{unit:"character"}):u,match:ei});s(a),l&&z.insertText(n,An)}else s(a)},n})(w2((function(n){const{isInline:r,normalizeNode:o,deleteBackward:i}=n;return n.isInline=s=>s.type==="auto-link"||r(s),n.normalizeNode=s=>{const[a,u]=s;if(!Ps(a)){if(le.isElement(a)&&a.type==="auto-link"&&(a.children.length===0||a.children.length===1&&a.children[0]?.text==="")&&z.removeNodes(n,{at:u}),In(a)){const l=ee.parent(n,u);if(Ps(l))return;if(bo(l)){const f=R.parent(u);if(x2(n,[l,f]),!Gu(a)){const c=C0(a);z.unsetNodes(n,c,{at:u})}}else O2(n,[a,u]),S2(n,[a,u])}o(s)}},n.deleteBackward=s=>{i(s);const{selection:a}=n;if(!a||!U.isCollapsed(a))return;const[u]=D.nodes(n,{at:a,match:bo,mode:"lowest"});u&&z.unwrapNodes(n,{match:bo})},n})((function(n){const{insertText:r}=n;return n.insertText=(o,i)=>{if(!n.selection||!U.isCollapsed(n.selection))return r(o,i);let s=!0;for(const a of T0)a.type==="mark"&&C2(n,o,a)&&(s=!1);s&&r(o,i)},n})((function(n){const{onChange:r}=n;return n.onChange=o=>{Ju(n,n.children)&&w0(n),r(o)},n})((function(n,{createAttachments:r,pasteFilesAsAttachments:o}){const{insertData:i}=n;return n.insertData=s=>{if(s.types.includes("Files")&&o){const a=N0(s);if(a.length>0)return void r(a)}if(s.types.includes("text/html")&&!s.types.includes("application/x-slate-fragment")){const a=s.getData("text/html");try{const{body:u}=new DOMParser().parseFromString(a,"text/html");if(u.querySelector("br.Apple-interchange-newline")?.remove(),u.children.length===1&&u.children[0]?.nodeName==="B"){const f=u.children[0];for(;f.firstChild;)u.insertBefore(f.firstChild,f);u.removeChild(f)}const l=Qu(u);if(l!==null&&Array.isArray(l))return void z.insertFragment(n,l)}catch{}}i(s)},n})((n=>{var r=n,{apply:o}=r;return r.history={undos:[],redos:[]},r.redo=()=>{var{history:i}=r,{redos:s}=i;if(s.length>0){var a=s[s.length-1];a.selectionBefore&&z.setSelection(r,a.selectionBefore),bn.withoutSaving(r,(()=>{D.withoutNormalizing(r,(()=>{for(var u of a.operations)r.apply(u)}))})),i.redos.pop(),r.writeHistory("undos",a)}},r.undo=()=>{var{history:i}=r,{undos:s}=i;if(s.length>0){var a=s[s.length-1];bn.withoutSaving(r,(()=>{D.withoutNormalizing(r,(()=>{var u=a.operations.map(ur.inverse).reverse();for(var l of u)r.apply(l);a.selectionBefore&&z.setSelection(r,a.selectionBefore)}))})),r.writeHistory("redos",a),i.undos.pop()}},r.apply=i=>{var{operations:s,history:a}=r,{undos:u}=a,l=u[u.length-1],f=l&&l.operations[l.operations.length-1],c=bn.isSaving(r),d=bn.isMerging(r);if(c==null&&(c=eD(i)),c){if(d==null&&(d=l!=null&&(s.length!==0||QE(i,f))),bn.isSplittingOnce(r)&&(d=!1,bn.setSplittingOnce(r,void 0)),l&&d)l.operations.push(i);else{var h={operations:[i],selectionBefore:r.selection};r.writeHistory("undos",h)}for(;u.length>100;)u.shift();a.redos=[]}o(i)},r.writeHistory=(i,s)=>{r.history[i].push(s)},r})(d2($g())),{createAttachments:e,pasteFilesAsAttachments:t})))))))}function $2({Mention:e,attributes:t,children:n,element:r}){const o=d0(),{children:i,...s}=r;return v.jsxs("span",{...t,children:[r.id?v.jsx(e,{mention:s,isSelected:o}):null,n]})}function W2({Link:e,attributes:t,element:n,children:r}){const o=m.useMemo((()=>fp(n.url)??""),[n.url]);return v.jsx("span",{...t,children:v.jsx(e,{href:o,children:r})})}function z2({id:e,itemId:t,mentions:n,selectedMentionId:r,setSelectedMentionId:o,mentionDraft:i,setMentionDraft:s,onItemSelect:a,position:u="top",dir:l,MentionSuggestions:f}){const c=Tn(),{onEditorChange:d}=ea(),{isFocused:h}=Wt(),[g,y]=H0(),p=h&&i?.range!==void 0&&n!==void 0,{refs:{setReference:w,setFloating:b},strategy:C,isPositioned:E,placement:A,x,y:I,update:T,elements:F}=V0({position:u,dir:l,alignment:"start",open:p});return vl(d,(()=>{s((function(S){const{selection:k}=S;if(!k||!U.isCollapsed(k))return;const _=I0(S,k,["@"],{include:!0,allowConsecutiveWhitespace:!1,ignoreTerminator:(H,W)=>{const G=Ai(S,W);return!(!G||T2.has(G.text)||I2.test(G.text)||Ms(G.text))}});if(!_)return;const M=D.string(S,_);return!M.startsWith(An)||M.length>1&&Ms(M[1])?void 0:{range:_,text:M.substring(1)}})(c))})),xn((()=>{if(!i)return void w(null);const S=pl(c,i.range);w(S??null)}),[w,c,i]),xn((()=>{if(!p)return;const S=F.floating?.firstChild;if(!S)return;S.style.overflowY="visible",S.style.maxHeight="none",T();const k=requestAnimationFrame((()=>{S.style.overflowY="auto",S.style.maxHeight="var(--lb-composer-floating-available-height)"}));return()=>{cancelAnimationFrame(k)}}),[n?.length,p,F.floating,T]),v.jsx(b0,{children:p?v.jsx(x0.Provider,{value:{id:e,itemId:t,selectedValue:r,setSelectedValue:o,onItemSelect:a,placement:A,dir:l,ref:g},children:v.jsx(Ng,{ref:b,style:{position:C,top:0,left:0,transform:E?`translate3d(${Math.round(x)}px, ${Math.round(I)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:y},children:v.jsx(f,{mentions:n,selectedMentionId:r})})}):null})}function K2({id:e,position:t="top",dir:n,FloatingToolbar:r,hasFloatingToolbarRange:o,setHasFloatingToolbarRange:i}){const s=Tn(),{onEditorChange:a}=ea(),{isFocused:u}=Wt(),[l,f]=H0(),[c,d]=m.useState(!1),h=u&&!c&&o,{refs:{setReference:g,setFloating:y},strategy:p,isPositioned:w,placement:b,x:C,y:E}=V0({type:"range",position:t,dir:n,alignment:"center",open:h});return xn((()=>{if(!u)return;const A=()=>d(!0),x=()=>d(!1);return document.addEventListener("pointerdown",A),document.addEventListener("pointerup",x),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("pointerup",x)}}),[u]),vl(a,(()=>{g(null),requestAnimationFrame((()=>{const A=window.getSelection();if(s.selection&&!U.isCollapsed(s.selection)&&A&&A.rangeCount){i(!0);const x=A.getRangeAt(0);g(x)}else i(!1),g(null)}))})),v.jsx(b0,{children:h?v.jsx(O0.Provider,{value:{id:e,placement:b,dir:n,ref:l},children:v.jsx(Ng,{ref:y,style:{position:p,top:0,left:0,transform:w?`translate3d(${Math.round(C)}px, ${Math.round(E)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:f},children:v.jsx(r,{})})}):null})}const q2=m.forwardRef((({children:e,onPointerDown:t,style:n,asChild:r,...o},i)=>{const[s]=gl(),a=m.useRef(null),{id:u,ref:l,placement:f,dir:c}=(function(w="useComposerFloatingToolbarContext"){return ye(m.useContext(O0),`${w} can’t be used outside of Composer.Editor.`)})("ComposerFloatingToolbar"),d=ji(i,l,a),[h,g]=m.useMemo((()=>U0(f)),[f]),y=r?vt:"div";y0(a);const p=m.useCallback((w=>{t?.(w),w.preventDefault(),w.stopPropagation()}),[t]);return v.jsx(y,{dir:c,role:"toolbar",id:u,"aria-label":"Floating toolbar",...o,onPointerDown:p,"data-state":s?"open":"closed","data-side":h,"data-align":g,style:{display:"flex",flexDirection:"row",maxWidth:"var(--lb-composer-floating-available-width)",overflowX:"auto",...n},ref:d,children:e})}));function G2({Mention:e,Link:t,...n}){const{attributes:r,children:o,element:i}=n;switch(i.type){case"mention":return v.jsx($2,{Mention:e,...n});case"auto-link":case"custom-link":return v.jsx(W2,{Link:t,...n});case"paragraph":return v.jsx("p",{...r,style:{position:"relative"},children:o});default:return null}}function J2({attributes:e,children:t,leaf:n}){return n.bold&&(t=v.jsx("strong",{children:t})),n.italic&&(t=v.jsx("em",{children:t})),n.strikethrough&&(t=v.jsx("s",{children:t})),n.code&&(t=v.jsx("code",{children:t})),v.jsx("span",{...e,children:t})}function Z2({attributes:e,children:t}){const{opacity:n,...r}=e.style;return v.jsx("span",{...e,style:r,"data-placeholder":"",children:t})}const El=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"span",i=d0();return v.jsx(o,{"data-selected":i||void 0,...n,ref:r,children:e})})),W0=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),z0=m.forwardRef((({children:e,style:t,asChild:n,...r},o)=>{const[i]=gl(),s=m.useRef(null),{ref:a,placement:u,dir:l}=Cl("ComposerSuggestions"),f=ji(o,a,s),[c,d]=m.useMemo((()=>U0(u)),[u]),h=n?vt:"div";return y0(s),v.jsx(h,{dir:l,...r,"data-state":i?"open":"closed","data-side":c,"data-align":d,style:{display:"flex",flexDirection:"column",maxHeight:"var(--lb-composer-floating-available-height)",overflowY:"auto",...t},ref:f,children:e})})),K0=m.forwardRef((({children:e,asChild:t,...n},r)=>{const{id:o}=Cl("ComposerSuggestionsList"),i=t?vt:"ul";return v.jsx(i,{role:"listbox",id:o,"aria-label":"Suggestions list",...n,ref:r,children:e})})),q0=m.forwardRef((({value:e,children:t,onPointerMove:n,onPointerDown:r,onClick:o,asChild:i,...s},a)=>{const u=m.useRef(null),l=ji(a,u),{selectedValue:f,setSelectedValue:c,itemId:d,onItemSelect:h}=Cl("ComposerSuggestionsListItem"),g=i?vt:"li",y=m.useMemo((()=>f===e),[f,e]),p=m.useMemo((()=>d(e)),[d,e]);m.useEffect((()=>{u?.current&&y&&u.current.scrollIntoView({block:"nearest"})}),[y]);const w=m.useCallback((E=>{n?.(E),E.isDefaultPrevented()||c(e)}),[n,c,e]),b=m.useCallback((E=>{r?.(E),E.preventDefault(),E.stopPropagation()}),[r]),C=m.useCallback((E=>{o?.(E);const A=E.isDefaultPrevented();E.preventDefault(),E.stopPropagation(),A||h(e)}),[o,h,e]);return v.jsx(g,{role:"option",id:p,"data-selected":y||void 0,"aria-selected":y||void 0,onPointerMove:w,onPointerDown:b,onClick:C,...s,ref:l,children:t})})),X2={Link:({href:e,children:t})=>v.jsx(W0,{href:e,children:t}),Mention:({mention:e})=>v.jsxs(El,{children:[An,e.id]}),MentionSuggestions:({mentions:e})=>e.length>0?v.jsx(z0,{children:v.jsx(K0,{children:e.map((t=>v.jsx(q0,{value:t.id,children:t.id},t.id)))})}):null},Y2=m.forwardRef((({defaultValue:e,onKeyDown:t,onFocus:n,onBlur:r,disabled:o,autoFocus:i,components:s,dir:a,...u},l)=>{const f=gc(),{editor:c,validate:d,setFocused:h,onEditorChange:g,roomId:y}=ea(),{submit:p,focus:w,blur:b,select:C,canSubmit:E,isDisabled:A,isFocused:x}=Wt(),I=hr(),T=(function(){const J=Ve();return m.useCallback((oe=>{J[Oe].usersStore.enqueue(oe)}),[J])})(),F=A||o,S=So(e??H2),k=m.useMemo((()=>{return(J=S)&&J?.content?J.content.map((oe=>{if(oe.type!=="paragraph")return null;const ge=oe.children.map((ve=>{return Fp(ve)?(Te=ve,{...Te,children:[{text:""}]}):Rp(ve)?(We=ve).text?{type:"custom-link",url:We.url,children:[{text:We.text}]}:{type:"auto-link",url:We.url,children:[{text:We.url}]}:!("type"in(Le=ve))&&"text"in Le&&typeof Le.text=="string"?ve:null;var Te,We,Le})).filter(xi);return{...oe,children:ge}})).filter(xi):N2;var J}),[S]),{Link:_,Mention:M,MentionSuggestions:H,FloatingToolbar:W}=m.useMemo((()=>({...X2,...s})),[s]),[G,q]=m.useState(!1),$=Cc(),V=!f||$,[Q,ae]=m.useState(),ie=Ay(y,Q?.text),[Se,Ie,ne,B]=(function(J,oe,ge){const{wrap:ve}=m.useMemo((()=>({...v2,...ge})),[ge]),Te=m.useMemo((()=>ve?g2:vh),[ve]),[We,Le]=m.useState(J);return m.useEffect((()=>{Le((et=>vh(et,0,Math.max(oe-1,0))))}),[oe]),[We,m.useCallback((()=>{Le((et=>Te(et-1,0,Math.max(oe,0))))}),[oe,Te]),m.useCallback((()=>{Le((et=>Te(et+1,0,Math.max(oe,0))))}),[oe,Te]),Le]})(0,ie?.length??0),X=m.useId(),K=`liveblocks-floating-toolbar-${X}`,Y=`liveblocks-suggestions-list-${X}`,de=m.useCallback((J=>J?`liveblocks-suggestions-list-item-${X}-${J}`:void 0),[X]),pe=m.useCallback((J=>v.jsx(G2,{Mention:M,Link:_,...J})),[_,M]),fe=m.useCallback((J=>{d(J),g.notify()}),[d,g]),we=m.useCallback((J=>{Q&&J&&(z.select(c,Q.range),(function(oe,ge){const ve={type:"mention",...ge,children:[{text:""}]};z.insertNodes(oe,ve),z.move(oe);const Te=oe.selection?yl(oe,oe.selection):void 0;!Te||Te.void?z.insertText(oe," "):ko(Te.text)&&z.move(oe)})(c,J),ae(void 0),B(0))}),[c,Q,B]),Ce=m.useCallback((J=>{if(t?.(J),!J.isDefaultPrevented())if(At(J,"ArrowLeft")&&Ch(c,"start"),At(J,"ArrowRight")&&Ch(c,"end"),Q&&ie?.length){if(At(J,"ArrowDown")&&(J.preventDefault(),ne()),At(J,"ArrowUp")&&(J.preventDefault(),Ie()),At(J,"Enter")||At(J,"Tab")){J.preventDefault();const oe=ie?.[Se];we(oe)}At(J,"Escape")&&(J.preventDefault(),ae(void 0),B(0))}else G&&At(J,"Escape")&&(J.preventDefault(),q(!1)),At(J,"Escape")&&b(),At(J,"Enter",{shift:!1})&&(J.preventDefault(),E&&p()),At(J,"Enter",{shift:!0})&&(J.preventDefault(),c.insertBreak()),At(J,"b",{mod:!0})&&(J.preventDefault(),Qo(c,"bold")),At(J,"i",{mod:!0})&&(J.preventDefault(),Qo(c,"italic")),At(J,"s",{mod:!0,shift:!0})&&(J.preventDefault(),Qo(c,"strikethrough")),At(J,"e",{mod:!0})&&(J.preventDefault(),Qo(c,"code"))}),[t,Q,ie,G,c,ne,Ie,Se,we,B,b,E,p]),se=m.useCallback((J=>{n?.(J),J.isDefaultPrevented()||(h(!0),I&&T(I))}),[n,h,I,T]),te=m.useCallback((J=>{r?.(J),J.isDefaultPrevented()||h(!1)}),[r,h]),me=ie?.[Se],Ae=me?.id,Pe=m.useCallback((J=>{const oe=ie?.findIndex((ge=>ge.id===J));oe!==void 0&&oe>=0&&B(oe)}),[B,ie]),Fe=m.useMemo((()=>Q?{role:"combobox","aria-autocomplete":"list","aria-expanded":!0,"aria-controls":Y,"aria-activedescendant":de(Ae)}:G?{"aria-haspopup":!0,"aria-controls":K}:{}),[Q,Y,de,Ae,G,K]);m.useImperativeHandle(l,(()=>Z.toDOMNode(c,c)),[c]),xn((()=>{if(!i)return;const J=setTimeout((()=>w()),0);return()=>clearTimeout(J)}),[i,c,w]),xn((()=>{x&&c.selection===null&&C()}),[c,C,x]);const re=m.useCallback((J=>{const oe=ie?.find((ge=>ge.id===J));we(oe)}),[we,ie]);return v.jsxs(l2,{editor:c,initialValue:k,onChange:fe,children:[v.jsx(n2,{dir:a,tabIndex:F?-1:0,enterKeyHint:Q?"enter":"send",autoCapitalize:"sentences","aria-label":"Composer editor","data-focused":x||void 0,"data-disabled":F||void 0,...Fe,...u,readOnly:F,disabled:F,onKeyDown:Ce,onFocus:se,onBlur:te,renderElement:pe,renderLeaf:J2,renderPlaceholder:Z2}),V&&v.jsx(z2,{dir:a,mentionDraft:Q,setMentionDraft:ae,selectedMentionId:Ae,setSelectedMentionId:Pe,mentions:ie,id:Y,itemId:de,onItemSelect:re,MentionSuggestions:H}),W&&v.jsx(K2,{dir:a,id:K,hasFloatingToolbarRange:G,setHasFloatingToolbarRange:q,FloatingToolbar:W})]})})),Q2=m.forwardRef((({children:e,onSubmit:t,onComposerSubmit:n,defaultAttachments:r=[],pasteFilesAsAttachments:o,blurOnSubmit:i=!0,preventUnsavedChanges:s=!0,disabled:a,asChild:u,roomId:l,...f},c)=>{const d=u?vt:"form",[h,g]=m.useState(!0),[y,p]=m.useState(!1),[w,b]=m.useState(!1),C=zp({allowOutsideRoom:!0}),E=l!==void 0?l:C?.id;if(E===void 0)throw new Error("Composer.Form must be a descendant of RoomProvider.");const A=1073741824,{attachments:x,isUploadingAttachments:I,addAttachments:T,removeAttachment:F,clearAttachments:S}=U2(r,{maxFileSize:A,roomId:E}),k=x.length,_=k>=10,M=m.useMemo((()=>y||a===!0),[y,a]),H=m.useMemo((()=>!h&&!I),[h,I]),[W,G]=m.useState(bh),q=m.useRef(null),$=ji(c,q),V=m.useRef(null),Q=(function(){const re=Ve()[Oe].createSyncSource,[J,oe]=m.useState();return m.useEffect((()=>{const ge=re();return oe(ge),()=>ge.destroy()}),[re]),J})(),ae=!!s&&(!h||I||x.length>0);m.useEffect((()=>{Q?.setSyncStatus(ae?"has-local-changes":"synchronized")}),[Q,ae]);const ie=m.useCallback((re=>{if(!re.length)return;const J=Math.max(0,10-k);re.splice(J);const oe=re.map((ge=>(function(ve){return{type:"localAttachment",status:"idle",id:lp(),name:ve.name,size:ve.size,mimeType:ve.type,file:ve}})(ge)));T(oe)}),[T,10,k]),Se=m.useRef(ie);m.useEffect((()=>{Se.current=ie}),[ie]);const Ie=m.useCallback((re=>{Se.current(re)}),[]),ne=So((()=>V2({createAttachments:Ie,pasteFilesAsAttachments:o}))),B=So(Ue),X=m.useCallback((re=>{g(Ju(ne,re))}),[ne]),K=m.useCallback((()=>{H&&requestAnimationFrame((()=>{q.current&&(function(re,J){if(typeof re.requestSubmit=="function")return re.requestSubmit(J);J?J.click():((J=document.createElement("input")).type="submit",J.hidden=!0,re.appendChild(J),J.click(),re.removeChild(J))})(q.current)}))}),[H]),Y=m.useCallback((()=>{z.delete(ne,{at:{anchor:D.start(ne,[]),focus:D.end(ne,[])}})}),[ne]),de=m.useCallback((()=>{z.select(ne,D.end(ne,[]))}),[ne]),pe=m.useCallback(((re=!0)=>{try{if(!Z.isFocused(ne)){z.select(ne,re||!ne.selection?D.end(ne,[]):ne.selection);const J=Z.toDOMNode(ne,ne);if(ne.selection){const oe=window.getSelection(),ge=pl(ne,ne.selection);ge&&(oe?.removeAllRanges(),oe?.addRange(ge))}J.focus({preventScroll:!0})}}catch{}}),[ne]),fe=m.useCallback((()=>{try{Z.blur(ne)}catch{}}),[ne]),we=m.useCallback((()=>{a||(pe(),(function(re){if(!re.selection)return;const J=Ai(re,re.selection,{filterVoids:!0}),oe=yl(re,re.selection,{filterVoids:!0}),ge=J&&!ko(J.text),ve=oe&&!ko(oe.text);if(U.isCollapsed(re.selection)){const Te=(ge?" ":"")+An;re.insertText(Te,{at:U.start(re.selection)}),ve&&re.insertText(" ",{at:U.end(re.selection)}),z.collapse(re,{edge:"end"})}else{const Te=(ge?" ":"")+An+(ve?" ":"");re.insertText(Te),ve&&z.move(re,{distance:1,unit:"character",reverse:!0})}})(ne))}),[a,ne,pe]),Ce=m.useCallback((re=>{a||(pe(!1),Hg(ne,re))}),[a,ne,pe]),se=m.useCallback((()=>{a||V.current&&V.current.click()}),[a]),te=m.useCallback((re=>{a||re.target.files&&(ie(Array.from(re.target.files)),re.target.value="")}),[ie,a]),me=m.useCallback((()=>{Y(),S(),p(!1),i&&fe()}),[fe,i,Y,S]),Ae=m.useCallback((re=>{if(a)return;if(Ju(ne,ne.children)||(t?.(re),!n||re.isDefaultPrevented()))return void re.preventDefault();const J=(function(ve){return{version:1,content:ve.map((Te=>{if(Te.type!=="paragraph")return null;const We=Te.children.map((Le=>{return ei(Le)?(function(ut){const{children:Nt,...hn}=ut;return hn})(Le):bo(Le)?{type:"link",url:Le.url}:Ps(Le)?{type:"link",url:(et=Le).url,text:et.children.map((ut=>ut.text)).join("")}:In(Le)?Le:null;var et})).filter(xi);return{...Te,children:We}})).filter(xi)}})(ne.children),oe=x.filter((ve=>ve.type==="attachment"||ve.type==="localAttachment"&&ve.status==="uploaded")).map((ve=>({id:ve.id,type:"attachment",mimeType:ve.mimeType,size:ve.size,name:ve.name}))),ge=n({body:J,attachments:oe},re);re.preventDefault(),ge?(p(!0),ge.then(me)):me()}),[a,ne,x,n,t,me]),Pe=m.useCallback((re=>{re.stopPropagation()}),[]),Fe=m.useCallback((re=>{Qo(ne,re)}),[ne]);return vl(B,(()=>{G(bh(ne))})),v.jsx(D0.Provider,{value:{editor:ne,validate:X,setFocused:b,onEditorChange:B,roomId:E},children:v.jsx(A0.Provider,{value:{createAttachments:ie,isUploadingAttachments:I,hasMaxAttachments:_,maxAttachments:10,maxAttachmentSize:A},children:v.jsx(E0.Provider,{value:{isDisabled:M,isFocused:w,isEmpty:h,canSubmit:H,submit:K,clear:Y,select:de,focus:pe,blur:fe,createMention:we,insertText:Ce,attachments:x,attachFiles:se,removeAttachment:F,toggleMark:Fe,marks:W},children:v.jsxs(d,{...f,onSubmit:Ae,ref:$,children:[v.jsx("input",{type:"file",multiple:!0,ref:V,onChange:te,onClick:Pe,tabIndex:-1,style:{display:"none"}}),v.jsx(Sy,{children:e})]})})})})})),G0=m.forwardRef((({children:e,disabled:t,asChild:n,...r},o)=>{const i=n?vt:"button",{canSubmit:s,isDisabled:a}=Wt(),u=a||t||!s;return v.jsx(i,{type:"submit",...r,ref:o,disabled:u,children:e})})),eA=m.forwardRef((({children:e,onClick:t,disabled:n,asChild:r,...o},i)=>{const s=r?vt:"button",{hasMaxAttachments:a}=bl(),{isDisabled:u,attachFiles:l}=Wt(),f=u||a||n,c=m.useCallback((d=>{t?.(d),d.isDefaultPrevented()||l()}),[l,t]);return v.jsx(s,{type:"button",...o,onClick:c,ref:i,disabled:f,children:e})}));m.forwardRef((({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o,asChild:i,...s},a)=>{const u=i?vt:"div",{isDisabled:l}=Wt(),f=l||o,[,c]=$0({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:f});return v.jsx(u,{...c,"data-disabled":f?"":void 0,...s,ref:a})}));const tA=m.forwardRef((({children:e,mark:t,onValueChange:n,onClick:r,onPointerDown:o,asChild:i,...s},a)=>{const u=i?vt:"button",{marks:l,toggleMark:f}=Wt(),c=m.useCallback((h=>{o?.(h),h.preventDefault(),h.stopPropagation()}),[o]),d=m.useCallback((h=>{r?.(h),h.isDefaultPrevented()||(h.preventDefault(),h.stopPropagation(),f(t),n?.(t))}),[t,r,n,f]);return v.jsx(Zc,{asChild:!0,pressed:l[t],onClick:d,onPointerDown:c,...s,children:v.jsx(u,{...s,ref:a,children:e})})})),Th={seconds:60,minutes:60,hours:24,days:7,weeks:4.34524,months:12};function nA(e,t){return Mu(Sg(t,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).format(e))}const rA=["br","fr","nb","nn","no","ro","sv"];function oA(e,t){return Math.abs(e.getTime()-Date.now())<=2592e5?(function(n,r){let o;r?o=r:o=Xd().resolvedOptions().locale;const i=rA.some((u=>o===u||o.startsWith(`${u}-`))),s=Xd(o,{style:i?"short":"narrow",numeric:"auto"});let a=(n.getTime()-Date.now())/1e3;if(a>-60&&a<Th.seconds)return s.format(0,"seconds");for(const[u,l]of Object.entries(Th)){if(Math.abs(a)<l)return s.format(Math.round(a),u);a/=l}return Mu(s.format(Math.round(a),"years"))})(e,t):(function(n,r){return Mu(Sg(r,{month:"short",day:"numeric"}).format(n))})(e,t)}const iA=m.forwardRef((({date:e,locale:t,children:n=oA,title:r=nA,dateTime:o,interval:i=3e4,asChild:s,...a},u)=>{const l=s?vt:"time",[f,c]=Tg(),d=m.useMemo((()=>new Date(e)),[e]),h=m.useMemo((()=>d.toISOString()),[d]),g=m.useMemo((()=>typeof r=="function"?r(d,t):r),[r,d,t,c]),y=m.useMemo((()=>typeof n=="function"?n(d,t):n),[n,d,t,c]);return Ig(f,i),v.jsx(l,{...a,ref:u,dateTime:o??h,title:g,children:y})}));function J0(e){const t=So(e),n=t.userIds;if(t.kind!=="group")return!1;if(Array.isArray(n)){const r=hr();return m.useMemo((()=>n.some((o=>o===r))),[n,r])}{const r=hr(),{group:o}=(function(i){const s=Ve()[Oe].httpClient.groupsStore,a=m.useCallback((()=>s.getItemState(i)),[s,i]);return m.useEffect((()=>{s.enqueue(i)}),[s,i]),Si(s.subscribe,a,a,Dy,lt)})(t.id);return m.useMemo((()=>!!o?.members.some((i=>i.id===r))),[o,r])}}const qa=["B","KB","MB","GB"];function kh(e,t){if(e===0)return`0 ${qa[1]}`;let n;n=e===0?1:Math.max(1,Math.min(Math.floor(Math.log(Math.abs(e))/Math.log(1e3)),qa.length-1));let r=e/1e3**n,o=1;n===1&&(r>=10&&(o=0),r<.1&&r>0&&(o=2),r<.01&&(r=.01));const i=qa[n];return`${Mr(t,{minimumFractionDigits:0,maximumFractionDigits:o}).format(r)} ${i}`}const Z0=62914560,sA=/^(.+?)(\.[^.]+)?$/,aA=m.memo((({mimeType:e})=>{const t=m.useMemo((()=>(function(n){return n==="application/zip"||n==="application/gzip"||n==="application/vnd.rar"||n==="application/x-rar-compressed"||n==="application/x-7z-compressed"||n==="application/x-zip-compressed"||n==="application/x-tar"||n==="application/x-bzip"||n==="application/x-bzip2"?v.jsx("path",{d:"M13 15h2v1h-1.5a.5.5 0 0 0 0 1H15v1h-1.5a.5.5 0 0 0 0 1H15v1h-1.5a.5.5 0 0 0 0 1h1a.5.5 0 0 0 .5-.5V20h1.5a.5.5 0 0 0 0-1H15v-1h1.5a.5.5 0 0 0 0-1H15v-1h1.5a.5.5 0 0 0 .5-.5V15a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2Z"}):n.startsWith("text/")||n.startsWith("font/")||n.startsWith("application/")?v.jsx("path",{d:"M10 16a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1h-8a.5.5 0 0 1-.5-.5Z"}):n.startsWith("image/")?v.jsx("path",{d:"M12 16h6a1 1 0 0 1 1 1v3l-1.293-1.293a1 1 0 0 0-1.414 0L14.09 20.91l-.464-.386a1 1 0 0 0-1.265-.013l-1.231.985A.995.995 0 0 1 11 21v-4a1 1 0 0 1 1-1Zm-2 1a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-4Zm3 2a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}):n.startsWith("video/")?v.jsx("path",{d:"M12 15.71a1 1 0 0 1 1.49-.872l4.96 2.79a1 1 0 0 1 0 1.744l-4.96 2.79A1 1 0 0 1 12 21.29v-5.58Z"}):n.startsWith("audio/")?v.jsx("path",{d:"M15 15a.5.5 0 0 0-.5.5v7a.5.5 0 0 0 1 0v-7a.5.5 0 0 0-.5-.5Zm-2.5 2.5a.5.5 0 0 1 1 0v3a.5.5 0 0 1-1 0v-3Zm-2 1a.5.5 0 0 1 1 0v1a.5.5 0 0 1-1 0v-1Zm6-1a.5.5 0 0 1 1 0v3a.5.5 0 0 1-1 0v-3ZM19 16a.5.5 0 0 0-.5.5v5a.5.5 0 0 0 1 0v-5a.5.5 0 0 0-.5-.5Z"}):null})(e)),[e]);return v.jsxs("svg",{className:"lb-attachment-icon",width:30,height:30,viewBox:"0 0 30 30",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",className:"lb-attachment-icon-shadow"}),v.jsx("path",{d:"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",className:"lb-attachment-icon-background"}),v.jsx("path",{d:"M14.382 3.037a4 4 0 0 1 2.29 1.135l6.156 6.157a4 4 0 0 1 1.136 2.289A2 2 0 0 0 22 11h-4a2 2 0 0 1-2-2V5a2 2 0 0 0-1.618-1.963Z",className:"lb-attachment-icon-fold"}),t&&v.jsx("g",{className:"lb-attachment-icon-glyph",children:t})]})}));function uA({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=Ws(e.id,n),[o,i]=m.useState(!1),s=m.useCallback((()=>{i(!0)}),[]);return v.jsxs(v.Fragment,{children:[o?null:v.jsx(_i,{}),r?v.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:v.jsx("img",{src:r,loading:"lazy",onLoad:s,onError:t})}):null]})}function cA({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=Ws(e.id,n),[o,i]=m.useState(!1),s=m.useCallback((()=>{i(!0)}),[]);return v.jsxs(v.Fragment,{children:[o?null:v.jsx(_i,{}),r?v.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:v.jsx("video",{src:r,onLoadedData:s,onError:t})}):null]})}function X0({attachment:e,allowMediaPreview:t=!0,roomId:n}){const[r,o]=m.useState(!1),i=e.type==="attachment"||e.status==="uploaded";function s(){o(!0)}if(!r&&t&&i&&e.size<=Z0){if(e.mimeType.startsWith("image/"))return v.jsx(uA,{attachment:e,markPreviewAsUnsupported:s,roomId:n});if(e.mimeType.startsWith("video/"))return v.jsx(cA,{attachment:e,markPreviewAsUnsupported:s,roomId:n})}return v.jsx(aA,{mimeType:e.mimeType})}function Y0({attachment:e}){const{base:t,extension:n}=m.useMemo((()=>(function(r){const o=r.match(sA);return{base:o?.[1]??r,extension:o?.[2]}})(e.name)),[e.name]);return v.jsxs("span",{className:"lb-attachment-name",title:e.name,children:[v.jsx("span",{className:"lb-attachment-name-base",children:t}),n&&v.jsx("span",{className:"lb-attachment-name-extension",children:n})]})}function Q0(e){return m.useCallback((t=>{if(e?.(t),!t.isDefaultPrevented()&&(t.key==="Enter"||t.key===" ")){t.preventDefault();const n=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});t.target.dispatchEvent(n)}}),[e])}function ev(e,t){const n=Mt(t),r=S0(),o=!!r,i=r?.maxAttachmentSize,s=e.type==="localAttachment"?e.status:void 0,a=s==="uploading",u=s==="error";let l;return l=e.type==="localAttachment"&&e.status==="error"?e.error instanceof ec?e.error.origin==="server"?n.ATTACHMENT_TOO_LARGE():n.ATTACHMENT_TOO_LARGE(i?kh(i,n.locale):void 0):n.ATTACHMENT_ERROR(e.error):kh(e.size,n.locale),{isUploading:a,isError:u,description:l,deleteLabel:o?n.COMPOSER_REMOVE_ATTACHMENT:n.COMMENT_DELETE_ATTACHMENT}}function lA({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:i=!0,roomId:s,className:a,onKeyDown:u,...l}){const{isUploading:f,isError:c,description:d,deleteLabel:h}=ev(e,t),g=m.useCallback((p=>{o&&p.preventDefault()}),[o]),y=Q0(u);return v.jsxs("div",{className:Ne("lb-attachment lb-media-attachment",a),"data-error":c?"":void 0,...l,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?y:void 0,children:[v.jsx("div",{className:"lb-attachment-preview",children:f?v.jsx(_i,{}):c?v.jsx(Mg,{}):v.jsx(X0,{attachment:e,allowMediaPreview:i,roomId:s})}),v.jsxs("div",{className:"lb-attachment-details",children:[v.jsx(Y0,{attachment:e}),v.jsx("span",{className:"lb-attachment-description",title:d,children:d})]}),r&&v.jsx(jt,{content:h,children:v.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:g,"aria-label":h,children:v.jsx(ol,{})})})]})}function tv({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:i=!0,roomId:s,className:a,onKeyDown:u,...l}){const{isUploading:f,isError:c,description:d,deleteLabel:h}=ev(e,t),g=m.useCallback((p=>{o&&p.preventDefault()}),[o]),y=Q0(u);return v.jsxs("div",{className:Ne("lb-attachment lb-file-attachment",a),"data-error":c?"":void 0,...l,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?y:void 0,children:[v.jsx("div",{className:"lb-attachment-preview",children:f?v.jsx(_i,{}):c?v.jsx(Mg,{}):v.jsx(X0,{attachment:e,allowMediaPreview:i,roomId:s})}),v.jsxs("div",{className:"lb-attachment-details",children:[v.jsx(Y0,{attachment:e}),v.jsx("span",{className:"lb-attachment-description",title:d,children:d})]}),r&&v.jsx(jt,{content:h,children:v.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:g,"aria-label":h,children:v.jsx(ol,{})})})]})}function dA({className:e,...t}){return v.jsx("a",{href:"https://liveblocks.io",target:"_blank",rel:"noopener noreferrer",className:Ne("lb-composer-attribution",e),...t,children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 72","aria-label":"Made with Liveblocks",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M86 10h-8v50h8V10Zm16 14h-8v36h8V24Zm0-15h-8v9h8V9Zm13 15h-9l12 36h10l13-36h-9l-9 28-8-28Zm44-1c-11 0-18 8-18 19s7 19 18 19c8 0 15-4 17-13h-8c-1 4-5 6-9 6-6 0-9-3-9-10h27c0-10-6-21-18-21Zm0 7c5 0 9 3 9 8h-18c0-5 4-8 9-8Zm42-7c-4 0-8 2-11 6V10h-8v50h8v-5c3 4 7 6 11 6 11 0 16-9 16-19s-5-19-16-19Zm-2 32c-7 0-9-7-9-13s2-13 9-13 9 7 9 13-2 13-9 13Zm32-45h-8v50h8V10Zm24 51c11 0 18-8 18-19s-8-19-18-19c-11 0-19 8-19 19s7 19 19 19Zm0-6c-8 0-10-7-10-13s2-13 10-13c7 0 9 7 9 13s-2 13-9 13Zm39 6c8 0 15-4 17-12l-8-1c-2 4-4 6-9 6-7 0-9-6-9-12s2-12 9-12c5 0 8 3 8 7l9-1c-2-8-9-13-17-13-11 0-18 9-18 19 0 11 7 19 18 19Zm30-14 4-4 10 17h10l-15-23 15-13h-11l-13 13V10h-9v50h9V47Zm39 14c8 0 16-3 16-12 0-8-8-10-15-11-2-1-7-1-7-5 0-3 3-4 6-4 4 0 7 3 7 7l8-1c-1-9-8-12-15-12s-15 3-15 11 9 10 15 11c3 1 8 2 8 5 0 4-4 5-7 5-5 0-8-3-9-7l-8 1c1 8 9 12 16 12ZM41 27H0l12 12v17l29-29ZM20 60h40L48 48V32L20 60Z",fill:"currentColor"})})})}var fA=Object.defineProperty,Fn={};((e,t)=>{for(var n in t)fA(e,n,{get:t[n],enumerable:!0})})(Fn,{ActiveEmoji:()=>Dv,Empty:()=>Ev,List:()=>bv,Loading:()=>wv,Root:()=>fv,Search:()=>hv,SkinTone:()=>Av,SkinToneSelector:()=>Cv,Viewport:()=>pv});var nv="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",Dl=["none","light","medium-light","medium","medium-dark","dark"];function Ga(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ct=null;function Bh(e){try{Ct??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!Ct||(queueMicrotask((()=>{Ct&&(Ct=null)})),Ct.canvas.width=2,Ct.canvas.height=2,Ct.font=`2px ${nv}`,Ct.textBaseline="middle",Ct.measureText(e).width>=4))return!1;Ct.fillStyle="#00f",Ct.fillText(e,0,0);let t=Ct.getImageData(0,0,2,2).data;Ct.clearRect(0,0,2,2),Ct.fillStyle="#f00",Ct.fillText(e,0,0);let n=Ct.getImageData(0,0,2,2).data;for(let r=0;r<16;r+=4)if(t[r]!==n[r]||t[r+1]!==n[r+1]||t[r+2]!==n[r+2])return!1;return!0}function Fh(e,t,n){try{let r=e.getItem(t);if(!r)throw new Error(`No value found for "${t}".`);return n(JSON.parse(r))}catch{return null}}function rv(e,t,n){e.setItem(t,JSON.stringify(n))}function Rh(e){return t=>t===void 0?void 0:e(t)}function _h(e){return t=>t===null?null:e(t)}function yt(e){if(typeof e!="string")throw new Error;return e}function ws(e){if(typeof e!="number")throw new Error;return e}function ov(e){if(typeof e!="boolean")throw new Error;return e}function tr(e){return t=>{if(typeof t!="object"||t===null)throw new Error;let n={};for(let r in e){let o=t[r];o===void 0&&e[r](void 0),n[r]=e[r](o)}return n}}function Ja(e){return t=>{if(!Array.isArray(t))throw new Error;return t.length>0&&e(t[0]),t}}var iv=(e,t)=>`${e}/${t}/data.json`,sv=(e,t)=>`${e}/${t}/messages.json`,hA=["bn","da","de","en-gb","en","es-mx","es","et","fi","fr","hi","hu","it","ja","ko","lt","ms","nb","nl","pl","pt","ru","sv","th","uk","vi","zh-hant","zh"],av=e=>`frimousse/data/${e}`,jh="frimousse/metadata";async function Mh(e,t){try{return(await fetch(e,{method:"HEAD",signal:t})).headers.get("etag")}catch{return null}}function pA(e){return e.skins?e.skins.filter((t=>typeof t.tone=="number")).reduce(((t,n)=>(t[Dl[n.tone]]=n.emoji,t)),{}):void 0}async function Ph(e,t,n){let{emojis:r,emojisEtag:o,messages:i,messagesEtag:s}=await(async function(g,y,p){let[{emojis:w,emojisEtag:b},{messages:C,messagesEtag:E}]=await Promise.all([fetch(iv(g,y),{signal:p}).then((async A=>({emojis:await A.json(),emojisEtag:A.headers.get("etag")}))),fetch(sv(g,y),{signal:p}).then((async A=>({messages:await A.json(),messagesEtag:A.headers.get("etag")})))]);return{emojis:w,messages:C,emojisEtag:b,messagesEtag:E}})(e,t,n),a=i.subgroups.find((g=>g.key==="country-flag"||g.key==="subdivision-flag")),u=i.groups.filter((g=>g.key!=="component")),l=r.filter((g=>"group"in g)),f=u.map((g=>({index:g.order,label:Ga(g.message)}))),c=i.skinTones.reduce(((g,y)=>(g[y.key]=Ga(y.message),g)),{}),d=l.map((g=>({emoji:g.emoji,category:g.group,version:g.version,label:Ga(g.label),tags:g.tags??[],countryFlag:a&&g.subgroup===a.order||void 0,skins:pA(g)}))),h={locale:t,emojis:d,categories:f,skinTones:c};return rv(localStorage,av(t),{data:h,metadata:{emojisEtag:o,messagesEtag:s}}),h}var mA=tr({emojiVersion:ws,countryFlags:ov}),gA=tr({data:tr({locale:yt,emojis:Ja(tr({emoji:yt,category:ws,label:yt,version:ws,tags:Ja(yt),countryFlag:Rh(ov),skins:Rh(tr({light:yt,"medium-light":yt,medium:yt,"medium-dark":yt,dark:yt}))})),categories:Ja(tr({index:ws,label:yt})),skinTones:tr({light:yt,"medium-light":yt,medium:yt,"medium-dark":yt,dark:yt})}),metadata:tr({emojisEtag:_h(yt),messagesEtag:_h(yt)})});async function vA({locale:e,emojiVersion:t,emojibaseUrl:n,signal:r}){let o,i=typeof n=="string"?n:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof t=="number"?Math.floor(t):"latest"}`,s=Fh(sessionStorage,jh,mA),a=Fh(localStorage,av(e),gA);if(a)if(s)o=a.data;else try{let{emojisEtag:u,messagesEtag:l}=await(async function(f,c,d){let[h,g]=await Promise.all([Mh(iv(f,c),d),Mh(sv(f,c),d)]);return{emojisEtag:h,messagesEtag:g}})(i,e,r);o=u&&l&&u===a.metadata.emojisEtag&&l===a.metadata.messagesEtag?a.data:await Ph(i,e,r)}catch{o=a.data}else o=await Ph(i,e,r);return s??=(function(u,l){let f=new Map;for(let g of u)f.has(g.version)||f.set(g.version,g.emoji);let c=[...f.keys()].sort(((g,y)=>y-g)),d=c[0]??0,h=Bh("🇪🇺");if(typeof l=="number")return{emojiVersion:l,countryFlags:h};for(let g of c)if(Bh(f.get(g)))return{emojiVersion:g,countryFlags:h};return{emojiVersion:d,countryFlags:h}})(o.emojis,t),rv(sessionStorage,jh,s),{locale:e,emojis:o.emojis.filter((u=>{let l=u.version<=s.emojiVersion;return u.countryFlag?l&&s.countryFlags:l})),categories:o.categories,skinTones:o.skinTones}}function Nh(e){return hA.includes(e)?e:(console.warn(`Locale "${e}" is not supported, using "en" instead.`),"en")}function Lh(e){return Dl.includes(e)?e:(console.warn(`Skin tone "${e}" is not valid, using "none" instead.`),"none")}function yA(e,t){let n=[];if(t<=0)return n;for(let r=0,o=e.length;r<o;r+=t)n.push(e.slice(r,r+t));return n}function bA(e,t,n,r){let o=(function(c,d){if(!d)return c;let h=d.toLowerCase().trim(),g=new WeakMap;return c.filter((y=>{let p=0;y.label.toLowerCase().includes(h)&&(p+=10);for(let w of y.tags)w.toLowerCase().includes(h)&&(p+=1);return p>0&&(g.set(y,p),!0)})).sort(((y,p)=>(g.get(p)??0)-(g.get(y)??0)))})(e.emojis,r),i=[],s=[],a=[],u={},l=0,f=0;for(let c of o)u[c.category]||(u[c.category]=[]),u[c.category].push({emoji:n&&n!=="none"&&c.skins?c.skins[n]:c.emoji,label:c.label});for(let c of e.categories){let d=u[c.index];if(!d||d.length===0)continue;let h=yA(Array.from(d),t).map((g=>({categoryIndex:l,emojis:g})));i.push(...h),s.push({label:c.label,rowsCount:h.length,startRowIndex:f}),a.push(f),l++,f+=h.length}return{count:o.length,categories:s,categoriesStartRowIndices:a,rows:i,skinTones:e.skinTones}}function Vt(e,t,n=Object.is){let[r,o]=m.useState((()=>t(e.get())));return m.useEffect((()=>e.subscribe((()=>{let i=t(e.get());o((s=>n(s,i)?s:i))}))),[e,t,n]),m.useDebugValue(r),r}function Nn(e,t,n){let r=m.useCallback((o=>o[t]),[t]);return Vt(e,r,n)}function CA(e,t,n,r){let o=0;return(function(i){let s={},a=null,u=null,l=new Set,f=()=>{if(a){s=a,a=null;for(let h of l)h(s)}u=null},c=()=>a??s,d=h=>{a??=s,Object.assign(a,typeof h=="function"?h(c()):h),u||(u=requestAnimationFrame(f))};return s=i(d,c),{get:c,set:d,subscribe:h=>(l.add(h),()=>l.delete(h))}})(((i,s)=>({locale:t,columns:n,skinTone:r,onEmojiSelect:e,data:null,search:"",interaction:"none",activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:a=>{let u=s(),l=a?.data??u.data,f=a?.categoryHeaderHeight??u.categoryHeaderHeight,c=a?.rowHeight??u.rowHeight,d=a?.viewportHeight??u.viewportHeight;if(!(l&&l.rows.length!==0&&f&&c&&d))return i({...a,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let h=0,g=0;for(let I of l.categories){if(!(g++*f+I.startRowIndex*c<o))break;h+=f}let y=l.categories.length*f+l.rows.length*c,p=Math.floor(2*c/2),w=Math.ceil(2*c/2),b=Math.min(o-h-p,y-d),C=b+d+w,E=Math.max(0,Math.floor(b/c)),A=Math.min(l.rows.length-1,Math.ceil(C/c)),x=l.rows[E]?.categoryIndex;return i(x===void 0&&a?a:{...a,viewportStartCategoryIndex:x,viewportStartRowIndex:E,viewportEndRowIndex:A})},onDataChange:a=>{s().updateViewportState({data:a,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:a=>{i({search:a,interaction:a?"keyboard":"none"})},onActiveEmojiChange:(a,u,l)=>{if(i({interaction:a,activeColumnIndex:u,activeRowIndex:l}),a!=="keyboard")return;let{listRef:f,viewportRef:c,rowHeight:d,viewportHeight:h,categoryHeaderHeight:g}=s(),y=f?.current,p=c?.current;if(!(y&&p&&d&&g&&h))return;let w=l;w===0&&p.scrollTo({top:0,behavior:"instant"});let b=y.querySelector(`[aria-rowindex="${w}"]`);if(!(b instanceof HTMLElement))return;let C=b.offsetTop,E=getComputedStyle(b),A=Number.parseFloat(E.scrollMarginTop),x=Number.parseFloat(E.scrollMarginBottom),I=o+A;C<o+h/2&&(I+=g),(C<I||C+d>I+h-x)&&p.scrollTo({top:Math.max(C<I+g?C-Math.max(g,A):C-h+d+x,0),behavior:"instant"})},onActiveEmojiReset:()=>{i({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:a=>{s().updateViewportState({rowHeight:a})},onCategoryHeaderHeightChange:a=>{s().updateViewportState({categoryHeaderHeight:a})},onViewportSizeChange:(a,u)=>{s().updateViewportState({viewportWidth:a,viewportHeight:u})},onViewportScroll:a=>{o=a,s().updateViewportState()}})))}var{useStore:Pt,Provider:wA}=(function(e){let t=m.createContext(null);return{useStore:()=>{let n=m.useContext(t);if(!n)throw new Error(e);return n},Provider:({store:n,children:r})=>v.jsx(t.Provider,{value:n,children:r})}})("EmojiPicker.Root is missing.");function EA(e){return e.search}function Al(e){return e.interaction==="none"?void 0:e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex]}function DA(e){return e.data===void 0||typeof e.data?.count=="number"&&e.data.count===0}function AA(e){return e.data===null||e.viewportHeight===null||e.rowHeight===null||e.categoryHeaderHeight===null}function uv(e){return e.data?.rows.length}function xA(e){return e.data?.categories.length}function OA(e){return e.data?.categoriesStartRowIndices}function SA(e){return e.data?.skinTones}function cv(e,t){return e?.emoji===t?.emoji}function IA(e,t){return e?.categoryIndex===t?.categoryIndex&&e?.emojis.length===t?.emojis.length&&!!e?.emojis.every(((n,r)=>cv(n,t?.emojis[r])))}var Zo="",Uh=new RegExp("\\p{Emoji_Modifier_Base}","u"),TA=/\uFE0F$/,kA=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,BA={light:"🏻","medium-light":"🏼",medium:"🏽","medium-dark":"🏾",dark:"🏿"};function FA(e,t){if(!e.split(Zo).some((r=>Uh.test(r))))return e;let n=e.split(Zo).map((r=>r.replace(kA,""))).join(Zo);return t==="none"?n:n.split(Zo).map(((r,o,i)=>{let s=i.length>1;return!Uh.test(r)||s&&r==="🤝"?r:r.replace(TA,"")+BA[t]})).join(Zo)}function lv(){let e=Vt(Pt(),Al,cv);return m.useDeferredValue(e)}function dv(e="✋"){let t=Pt(),n=Nn(t,"skinTone"),r=m.useMemo((()=>(function(o){return Dl.map((i=>({skinTone:i,emoji:FA(o,i)})))})(e)),[e]);return[n,m.useCallback((o=>{t.set({skinTone:o})}),[]),r]}function xl(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((o=>o in t&&e[o]===t[o]))}function RA(...e){}var Cn=typeof window<"u"?m.useLayoutEffect:m.useEffect;function _A({emojiVersion:e,emojibaseUrl:t}){let[n,r]=m.useState(void 0),o=Pt(),i=Nn(o,"locale"),s=Nn(o,"columns"),a=Nn(o,"skinTone"),u=Nn(o,"search");return m.useEffect((()=>{let l=new AbortController,f=l.signal;return vA({locale:i,emojiVersion:e,emojibaseUrl:t,signal:f}).then((c=>{r(c)})).catch((c=>{f.aborted||console.error(c)})),()=>{l.abort()}}),[e,t,i]),m.useEffect((()=>{if(n)return(function(l,f){let c=null;if(typeof window.requestIdleCallback=="function")c=window.requestIdleCallback(l,f);else{let d=Date.now();c=window.setTimeout((()=>{l({didTimeout:!1,timeRemaining:()=>Math.max(0,f?.timeout-(Date.now()-d))})}),10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback(c):window.clearTimeout(c)}})((()=>{o.get().onDataChange(bA(n,s,a,u))}),{timeout:100})}),[n,s,a,u]),null}var fv=m.forwardRef((({locale:e="en",columns:t=9,skinTone:n="none",onEmojiSelect:r=RA,emojiVersion:o,emojibaseUrl:i,onFocusCapture:s,onBlurCapture:a,children:u,style:l,...f},c)=>{let d=(function(E){let A=m.useRef(E);return Cn((()=>{A.current=E})),m.useCallback(((...x)=>A.current(...x)),[])})(r),h=(function(E){let[A]=m.useState(E);return A})((()=>CA(d,Nh(e),t,Lh(n)))),[g,y]=m.useState(!1),p=m.useRef(null),w=m.useCallback((E=>{E&&(p.current=E,h.set({rootRef:p}))}),[]);Cn((()=>{h.set({locale:Nh(e)})}),[e]),Cn((()=>{h.set({columns:t})}),[t]),Cn((()=>{h.set({skinTone:Lh(n)})}),[n]);let b=m.useCallback((E=>{s?.(E);let{searchRef:A,viewportRef:x}=h.get(),I=E.target===A?.current||E.target.hasAttribute("frimousse-search"),T=E.target===x?.current||E.target.hasAttribute("frimousse-viewport");E.isDefaultPrevented()||(y(I||T),E.isDefaultPrevented()||(y(I||T),T?h.get().onActiveEmojiChange("keyboard",0,0):I&&h.get().search===""&&h.set({interaction:"none"})))}),[s]),C=m.useCallback((E=>{a?.(E),!E.isDefaultPrevented()&&!E.currentTarget.contains(E.relatedTarget)&&y(!1)}),[a]);return Cn((()=>{g||h.get().onActiveEmojiReset()}),[g]),m.useImperativeHandle(c,(()=>p.current)),m.useEffect((()=>{if(g)return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)};function E(A){if(A.defaultPrevented||!A.key.startsWith("Arrow")&&A.key!=="Enter")return;let{data:x,onEmojiSelect:I,onActiveEmojiChange:T,interaction:F,activeColumnIndex:S,activeRowIndex:k}=h.get();if(A.key==="Enter"){let _=Al(h.get());_&&(A.preventDefault(),I(_))}if(A.key.startsWith("Arrow")){let _=S,M=k;if(A.preventDefault(),F!=="none"){if(x?.rows&&x.rows.length>0)switch(A.key){case"ArrowLeft":if(_===0){let H=M-1,W=x.rows[H];W&&(M=H,_=W.emojis.length-1)}else _-=1;break;case"ArrowRight":if(_===x.rows[M].emojis.length-1){let H=M+1;x.rows[H]&&(M=H,_=0)}else _+=1;break;case"ArrowUp":{let H=x.rows[M-1];H&&(M-=1,H.emojis[_]||(_=H.emojis.length-1));break}case"ArrowDown":{let H=x.rows[M+1];H&&(M+=1,H.emojis[_]||(_=H.emojis.length-1));break}}T("keyboard",_,M)}else T("keyboard",0,0)}}}),[g]),Cn((()=>{let E=null,A=null,x=null,I=null,T=h.subscribe((M=>{p.current&&(E!==M.viewportWidth&&(E=M.viewportWidth,p.current.style.setProperty("--frimousse-viewport-width",`${M.viewportWidth}px`)),A!==M.viewportHeight&&(A=M.viewportHeight,p.current.style.setProperty("--frimousse-viewport-height",`${M.viewportHeight}px`)),x!==M.rowHeight&&(x=M.rowHeight,p.current.style.setProperty("--frimousse-row-height",`${M.rowHeight}px`)),I!==M.categoryHeaderHeight&&(I=M.categoryHeaderHeight,p.current.style.setProperty("--frimousse-category-header-height",`${M.categoryHeaderHeight}px`)))})),{viewportWidth:F,viewportHeight:S,rowHeight:k,categoryHeaderHeight:_}=h.get();return F&&p.current.style.setProperty("--frimousse-viewport-width",`${F}px`),S&&p.current.style.setProperty("--frimousse-viewport-height",`${S}px`),k&&p.current.style.setProperty("--frimousse-row-height",`${k}px`),_&&p.current.style.setProperty("--frimousse-category-header-height",`${_}px`),T}),[]),v.jsx("div",{"data-focused":g?"":void 0,"frimousse-root":"",onBlurCapture:C,onFocusCapture:b,...f,ref:w,style:{"--frimousse-emoji-font":nv,...l},children:v.jsxs(wA,{store:h,children:[v.jsx(_A,{emojiVersion:o,emojibaseUrl:i}),u]})})})),hv=m.forwardRef((({value:e,defaultValue:t,onChange:n,...r},o)=>{let i=Pt(),s=m.useRef(null),a=m.useCallback((c=>{c&&(s.current=c,i.set({searchRef:s}))}),[]),u=typeof e=="string",l=m.useRef(u);m.useEffect((()=>{l.current=u}),[u]),Cn((()=>{i.set({search:typeof e=="string"?e:typeof t=="string"?t:""})}),[]),Cn((()=>{typeof e=="string"&&i.get().onSearchChange(e)}),[e]);let f=m.useCallback((c=>{n?.(c),c.isDefaultPrevented()||i.get().onSearchChange(c.target.value)}),[n]);return m.useImperativeHandle(o,(()=>s.current)),v.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...r,defaultValue:t,onChange:f,ref:a,value:e})})),jA=m.memo((()=>{let e=lv();return e?v.jsx("div",{"aria-live":"polite",style:{border:0,clip:"rect(0, 0, 0, 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1,wordWrap:"normal"},children:e.label}):null})),pv=m.forwardRef((({children:e,onScroll:t,onKeyDown:n,style:r,...o},i)=>{let s=Pt(),a=m.useRef(null),u=m.useCallback((d=>{d&&(a.current=d,s.set({viewportRef:a}))}),[]),l=Vt(s,uv),f=Vt(s,xA),c=m.useCallback((d=>{t?.(d),s.get().onViewportScroll(d.currentTarget.scrollTop)}),[t]);return Cn((()=>{if(!a.current)return;let d=new ResizeObserver((([h])=>{let g=h?.borderBoxSize[0]?.inlineSize??0,y=h?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:p,viewportHeight:w,viewportWidth:b}=s.get();(w!==y||b!==g)&&p(g,y)}));return d.observe(a.current),s.get().onViewportSizeChange(a.current.offsetWidth,a.current.clientHeight),()=>{d.disconnect()}}),[]),m.useImperativeHandle(i,(()=>a.current)),v.jsxs("div",{"frimousse-viewport":"",...o,onScroll:c,ref:u,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof l=="number"&&typeof f=="number"?`var(--frimousse-viewport-width, auto) calc(${l} * var(--frimousse-row-height) + ${f} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...r},children:[v.jsx(jA,{}),e]})}));function mv(e,t,n){return{emoji:{...e,isActive:n},role:"gridcell","aria-colindex":t,"aria-selected":n||void 0,"aria-label":e.label,"data-active":n?"":void 0,"frimousse-emoji":"",style:{fontFamily:"var(--frimousse-emoji-font)"},tabIndex:-1}}function gv(e,t=!1){return{role:t?void 0:"row","aria-rowindex":t?void 0:e,"frimousse-row":"",style:{contain:t?void 0:"content",height:t?void 0:"var(--frimousse-row-height)",display:"flex"}}}function vv(e,t){return{"frimousse-category":"",style:{contain:"content",top:t?`calc(${e} * var(--frimousse-category-header-height) + ${t.startRowIndex} * var(--frimousse-row-height))`:void 0,height:t?`calc(var(--frimousse-category-header-height) + ${t.rowsCount} * var(--frimousse-row-height))`:void 0,width:"100%",pointerEvents:"none",position:"absolute"}}}function yv(e,t=!1){return{category:e,"frimousse-category-header":"",style:{contain:t?void 0:"layout paint",height:t?void 0:"var(--frimousse-category-header-height)",pointerEvents:"auto",position:"sticky",top:0}}}function Hh(e,t,n,r){return{"frimousse-list-sizer":"",style:{position:"relative",boxSizing:"border-box",height:`calc(${e} * var(--frimousse-row-height) + ${t} * var(--frimousse-category-header-height))`,paddingTop:`calc(${n} * var(--frimousse-row-height) + ${r} * var(--frimousse-category-header-height))`}}}function Vh(e,t,n){return{"aria-colcount":e,"aria-rowcount":t,"frimousse-list":"",style:{"--frimousse-list-columns":e,...n},role:"grid"}}function MA(e){e.preventDefault()}var PA=m.memo((({Emoji:e,emoji:t,columnIndex:n,rowIndex:r})=>{let o=Pt(),i=Vt(o,(l=>Al(l)?.emoji===t.emoji)),s=m.useCallback((()=>{o.get().onEmojiSelect(t)}),[t]),a=m.useCallback((()=>{o.get().onActiveEmojiChange("pointer",n,r)}),[n,r]),u=m.useCallback((()=>{o.get().onActiveEmojiReset()}),[]);return v.jsx(e,{...mv(t,n,i),onClick:s,onPointerDown:MA,onPointerEnter:a,onPointerLeave:u})})),NA=m.memo((({Row:e,Emoji:t,rowIndex:n})=>{let r=Vt(Pt(),(o=>o.data?.rows[n]),IA);return r?v.jsx(e,{...gv(n),children:r.emojis.map(((o,i)=>v.jsx(PA,{Emoji:t,columnIndex:i,emoji:o,rowIndex:n},o.label)))}):null})),LA=m.memo((({CategoryHeader:e,categoryIndex:t})=>{let n=Vt(Pt(),(r=>r.data?.categories[t]),xl);return n?v.jsx("div",{...vv(t,n),children:v.jsx(e,{...yv({label:n.label})})}):null})),$h=m.memo((({CategoryHeader:e,Row:t,Emoji:n})=>{let r=m.useRef(null),o=Pt(),i=Nn(o,"columns"),s=m.useMemo((()=>Array(i).fill({emoji:"🙂",label:""})),[i]),a=m.useMemo((()=>({label:"Category"})),[]),u=m.useRef(null),l=m.useRef(null);return Cn((()=>{let f=r.current?.parentElement?.parentElement;if(!f||!u.current||!l.current)return;let c=new ResizeObserver((g=>{for(let y of g){let p=y.contentRect.height,{onRowHeightChange:w,onCategoryHeaderHeightChange:b,rowHeight:C,categoryHeaderHeight:E}=o.get();y.target===u.current&&C!==p&&w(p),y.target===l.current&&E!==p&&b(p)}}));c.observe(f),c.observe(u.current),c.observe(l.current);let{onRowHeightChange:d,onCategoryHeaderHeightChange:h}=o.get();return d(u.current.clientHeight),h(l.current.clientHeight),()=>{c.disconnect()}}),[]),v.jsxs("div",{"aria-hidden":!0,ref:r,style:{height:0,visibility:"hidden"},children:[v.jsx("div",{"frimousse-row-sizer":"",ref:u,children:v.jsx(t,{...gv(-1,!0),children:s.map(((f,c)=>v.jsx(n,{...mv(f,c,!1)},c)))})}),v.jsx("div",{...vv(-1),children:v.jsx("div",{"frimousse-category-header-sizer":"",ref:l,children:v.jsx(e,{...yv(a,!0)})})})]})}));function UA({category:e,...t}){return v.jsx("div",{...t,children:e.label})}function HA({emoji:e,...t}){return v.jsx("button",{type:"button",...t,children:e.emoji})}function VA({...e}){return v.jsx("div",{...e})}var bv=m.forwardRef((({style:e,components:t,...n},r)=>{let o=Pt(),i=m.useRef(null),s=m.useCallback((w=>{w&&(i.current=w,o.set({listRef:i}))}),[]),a=t?.CategoryHeader??UA,u=t?.Emoji??HA,l=t?.Row??VA,f=Nn(o,"columns"),c=Nn(o,"viewportStartRowIndex"),d=Nn(o,"viewportEndRowIndex"),h=Vt(o,uv),g=Vt(o,OA,xl),y=m.useMemo((()=>g?.filter((w=>w<c)).length??0),[g,c]),p=g?.length??0;return m.useImperativeHandle(r,(()=>i.current)),h&&g&&p!==0?v.jsx("div",{...Vh(f,h,e),...n,ref:s,children:v.jsxs("div",{...Hh(h,p,c,y),children:[v.jsx($h,{CategoryHeader:a,Emoji:u,Row:l}),Array.from({length:d-c+1},((w,b)=>{let C=c+b,E=g.indexOf(C);return v.jsxs(m.Fragment,{children:[E>=0&&v.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),v.jsx(NA,{Emoji:u,Row:l,rowIndex:C})]},C)})),Array.from({length:p},((w,b)=>v.jsx(LA,{CategoryHeader:a,categoryIndex:b},b)))]})}):v.jsx("div",{...Vh(f,0,e),...n,children:v.jsx("div",{...Hh(0,0,0,0),children:v.jsx($h,{CategoryHeader:a,Emoji:u,Row:l})})})})),Cv=m.forwardRef((({emoji:e,onClick:t,"aria-label":n="Change skin tone",...r},o)=>{let i=Vt(Pt(),SA,xl),[s,a,u]=dv(e),l=m.useMemo((()=>Math.max(0,u.findIndex((y=>y.skinTone===s)))),[s,u]),f=u[l],c=u[(l+1)%u.length].skinTone,d=s==="none"?void 0:i?.[s],h=c==="none"?void 0:i?.[c],g=m.useCallback((y=>{t?.(y),y.isDefaultPrevented()||a(c)}),[t,a,c]);return v.jsx("button",{type:"button",...r,"aria-label":n+(h?` (${h})`:""),"aria-live":"polite","aria-valuetext":d,"frimousse-skin-tone-selector":"",onClick:g,ref:o,children:f.emoji})}));function wv({children:e,...t}){return Vt(Pt(),AA)?v.jsx("span",{"frimousse-loading":"",...t,children:e}):null}function $A({children:e}){return e({search:Vt(Pt(),EA)})}function Ev({children:e,...t}){return Vt(Pt(),DA)?v.jsx("span",{"frimousse-empty":"",...t,children:typeof e=="function"?v.jsx($A,{children:e}):e}):null}function Dv({children:e}){return e({emoji:lv()})}function Av({children:e,emoji:t}){let[n,r,o]=dv(t);return e({skinTone:n,setSkinTone:r,skinToneVariations:o})}function WA({emoji:e,className:t,...n}){return v.jsx("button",{className:Ne("lb-emoji-picker-emoji",t),...n,children:v.jsx(Ec,{emoji:e.emoji})})}function zA({children:e,className:t,...n}){return v.jsx("div",{className:Ne("lb-emoji-picker-row",t),...n,children:e})}function KA({category:e,className:t,...n}){return v.jsx("div",{className:Ne("lb-emoji-picker-category-header",t),...n,children:v.jsx("span",{className:"lb-emoji-picker-category-header-title",children:e.label})})}fv.displayName="EmojiPicker.Root",hv.displayName="EmojiPicker.Search",pv.displayName="EmojiPicker.Viewport",bv.displayName="EmojiPicker.List",wv.displayName="EmojiPicker.Loading",Ev.displayName="EmojiPicker.Empty",Cv.displayName="EmojiPicker.SkinToneSelector",Dv.displayName="EmojiPicker.ActiveEmoji",Av.displayName="EmojiPicker.SkinTone";const tc=m.forwardRef((({onEmojiSelect:e,onOpenChange:t,children:n,className:r,...o},i)=>{const[s,a]=m.useState(!1),{portalContainer:u,emojibaseUrl:l}=Ri(),f=Mt(),c=m.useCallback((g=>{a(g),t?.(g)}),[t]),d=m.useCallback((({emoji:g})=>{a(!1),e?.(g)}),[e]),h=m.useCallback((g=>{g.stopPropagation()}),[]);return v.jsxs(ZC,{open:s,onOpenChange:c,children:[n,v.jsx(YC,{container:u,children:v.jsx(QC,{side:"top",align:"center",updatePositionStrategy:"always",sideOffset:6,collisionPadding:10,className:Ne("lb-root lb-portal lb-elevation lb-emoji-picker",r),...o,ref:i,asChild:!0,children:v.jsxs(Fn.Root,{onEmojiSelect:d,locale:f.locale,columns:10,emojiVersion:15.1,emojibaseUrl:l,onClick:h,children:[v.jsx("div",{className:"lb-emoji-picker-header",children:v.jsxs("div",{className:"lb-emoji-picker-search-container",children:[v.jsx(Fn.Search,{className:"lb-emoji-picker-search",placeholder:f.EMOJI_PICKER_SEARCH_PLACEHOLDER,autoFocus:!0}),v.jsx(Yw,{})]})}),v.jsxs(Fn.Viewport,{className:"lb-emoji-picker-content",children:[v.jsx(Fn.Loading,{className:"lb-loading lb-emoji-picker-loading",children:v.jsx(_i,{})}),v.jsx(Fn.Empty,{className:"lb-empty lb-emoji-picker-empty",children:f.EMOJI_PICKER_EMPTY}),v.jsx(Fn.List,{className:"lb-emoji-picker-list",components:{CategoryHeader:KA,Row:zA,Emoji:WA}})]}),v.jsxs("div",{className:"lb-emoji-picker-footer",children:[v.jsx(Fn.ActiveEmoji,{children:({emoji:g})=>g?v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"lb-emoji-picker-active-emoji",children:g.emoji}),v.jsx("span",{className:"lb-emoji-picker-active-emoji-label",children:g.label})]}):v.jsx("span",{className:"lb-emoji-picker-active-emoji-label lb-emoji-picker-active-emoji-label-placeholder",children:"Select an emoji…"})}),v.jsx(jt,{content:f.EMOJI_PICKER_CHANGE_SKIN_TONE,children:v.jsx(Fn.SkinToneSelector,{className:"lb-button lb-emoji-picker-skin-tone-selector"})})]})]})})})]})})),nc=XC;function qA({label:e,tooltipLabel:t,className:n,onClick:r,...o}){const{createMention:i}=Wt(),s=m.useCallback((u=>{u.preventDefault()}),[]),a=m.useCallback((u=>{r?.(u),u.isDefaultPrevented()||(u.stopPropagation(),i())}),[i,r]);return v.jsx(jt,{content:t??e,children:v.jsx(Jt,{className:Ne("lb-composer-editor-action",n),onPointerDown:s,onClick:a,"aria-label":e,icon:v.jsx(Xw,{}),...o})})}function GA({label:e,tooltipLabel:t,onPickerOpenChange:n,className:r,...o}){const{insertText:i}=Wt(),s=m.useCallback((u=>{u.preventDefault()}),[]),a=m.useCallback((u=>{u.stopPropagation()}),[]);return v.jsx(tc,{onEmojiSelect:i,onOpenChange:n,children:v.jsx(jt,{content:t??e,children:v.jsx(nc,{asChild:!0,children:v.jsx(Jt,{className:Ne("lb-composer-editor-action",r),onPointerDown:s,onClick:a,"aria-label":e,icon:v.jsx(Jw,{}),...o})})})})}function JA({label:e,tooltipLabel:t,className:n,...r}){const o=m.useCallback((s=>{s.preventDefault()}),[]),i=m.useCallback((s=>{s.stopPropagation()}),[]);return v.jsx(jt,{content:t??e,children:v.jsx(eA,{asChild:!0,children:v.jsx(Jt,{className:Ne("lb-composer-editor-action",n),onPointerDown:o,onClick:i,"aria-label":e,icon:v.jsx(jg,{}),...r})})})}function ZA({mention:e}){return v.jsxs(El,{className:"lb-mention lb-composer-mention",children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(Oo,{userId:e.id})]})}function XA({mention:e}){const t=J0(e);return v.jsxs(El,{className:"lb-mention lb-composer-mention","data-self":t?"":void 0,children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(rl,{groupId:e.id})]})}function us({mark:e,icon:t,shortcut:n,children:r,...o}){const i=Mt(),s=m.useMemo((()=>i.COMPOSER_TOGGLE_MARK(e)),[i,e]);return v.jsx(tl,{content:s,shortcut:n,sideOffset:8,children:v.jsx(tA,{mark:e,asChild:!0,...o,children:v.jsx(Jt,{"aria-label":s,variant:"toolbar",icon:t,children:r})})})}const YA={bold:()=>v.jsx(us,{mark:"bold",shortcut:"Mod-B",icon:v.jsx(Hw,{})}),italic:()=>v.jsx(us,{mark:"italic",shortcut:"Mod-I",icon:v.jsx(Zw,{})}),strikethrough:()=>v.jsx(us,{mark:"strikethrough",shortcut:"Mod-Shift-S",icon:v.jsx(eE,{})}),code:()=>v.jsx(us,{mark:"code",shortcut:"Mod-E",icon:v.jsx(zw,{})})},QA=Object.entries(YA).map((([e,t])=>v.jsx(t,{},e)));function ex(){return v.jsx(q2,{className:"lb-root lb-portal lb-elevation lb-composer-floating-toolbar",children:QA})}function tx({attachment:e,className:t,overrides:n,...r}){const{removeAttachment:o}=Wt(),{roomId:i}=ea(),s=m.useCallback((()=>{o(e.id)}),[e.id,o]);return v.jsx(tv,{className:Ne("lb-composer-attachment",t),...r,attachment:e,onDeleteClick:s,preventFocusOnDelete:!0,overrides:n,roomId:i})}function nx({overrides:e,className:t,...n}){const{attachments:r}=Wt();return r.length===0?null:v.jsx("div",{className:Ne("lb-composer-attachments",t),...n,children:v.jsx("div",{className:"lb-attachments",children:r.map((o=>v.jsx(tx,{attachment:o,overrides:e},o.id)))})})}const rx={Mention:function({mention:e,...t}){switch(e.kind){case"user":return v.jsx(ZA,{mention:e,...t});case"group":return v.jsx(XA,{mention:e,...t});default:return Ye(0,"Unhandled mention kind")}},MentionSuggestions:function({mentions:e}){return e.length>0?v.jsx(z0,{className:"lb-root lb-portal lb-elevation lb-composer-suggestions lb-composer-mention-suggestions",children:v.jsx(K0,{className:"lb-composer-suggestions-list lb-composer-mention-suggestions-list",children:e.map((t=>v.jsx(q0,{className:"lb-composer-suggestions-list-item lb-composer-mention-suggestion",value:t.id,children:t.kind==="user"?v.jsxs(v.Fragment,{children:[v.jsx(ju,{userId:t.id,className:"lb-composer-mention-suggestion-avatar"}),v.jsx(Oo,{userId:t.id,className:"lb-composer-mention-suggestion-user"})]}):t.kind==="group"?v.jsxs(v.Fragment,{children:[v.jsx(_w,{groupId:t.id,className:"lb-composer-mention-suggestion-avatar",icon:v.jsx(tE,{})}),v.jsx(rl,{groupId:t.id,className:"lb-composer-mention-suggestion-group",children:v.jsx(Mw,{groupId:t.id,className:"lb-composer-mention-suggestion-group-description"})})]}):Ye(0,"Unhandled mention kind")},t.id)))})}):null},Link:function({href:e,children:t}){return v.jsx(W0,{href:e,className:"lb-composer-link",children:t})}};function ox({showAttachments:e=!0,showFormattingControls:t=!0,showAttribution:n,defaultValue:r,isCollapsed:o,overrides:i,actions:s,autoFocus:a,disabled:u,hasResolveMentionSuggestions:l,onEmojiPickerOpenChange:f,onEmptyChange:c,onEditorClick:d}){const{isEmpty:h}=Wt(),{hasMaxAttachments:g}=bl(),y=Mt(i),p=m.useMemo((()=>({...rx,FloatingToolbar:t?ex:void 0})),[t]),[w,b]=$0({disabled:u||!e||g});xn((()=>{c(h)}),[h,c]);const C=m.useCallback((A=>{A.preventDefault()}),[]),E=m.useCallback((A=>{A.stopPropagation()}),[]);return v.jsxs("div",{className:"lb-composer-editor-container",...b,children:[v.jsx(Y2,{className:"lb-composer-editor",onClick:d,placeholder:y.COMPOSER_PLACEHOLDER,defaultValue:r,autoFocus:a,components:p,disabled:u,dir:y.dir}),e&&v.jsx(nx,{overrides:i}),(!o||w)&&v.jsxs("div",{className:"lb-composer-footer",children:[v.jsxs("div",{className:"lb-composer-editor-actions",children:[l&&v.jsx(qA,{label:y.COMPOSER_INSERT_MENTION,disabled:u}),v.jsx(GA,{label:y.COMPOSER_INSERT_EMOJI,onPickerOpenChange:f,disabled:u}),e&&v.jsx(JA,{label:y.COMPOSER_ATTACH_FILES,disabled:u})]}),n&&v.jsx(dA,{}),v.jsx("div",{className:"lb-composer-actions",children:s??v.jsx(v.Fragment,{children:v.jsx(tl,{content:y.COMPOSER_SEND,shortcut:"Enter",children:v.jsx(G0,{asChild:!0,children:v.jsx(Jt,{onPointerDown:C,onClick:E,className:"lb-composer-action",variant:"primary","aria-label":y.COMPOSER_SEND,icon:v.jsx(Qw,{})})})})})})]}),e&&w&&v.jsx("div",{className:"lb-composer-attachments-drop-area",children:v.jsxs("div",{className:"lb-composer-attachments-drop-area-label",children:[v.jsx(jg,{}),y.COMPOSER_ATTACH_FILES]})})]})}m.createContext(null);const xv=m.forwardRef((({threadId:e,commentId:t,metadata:n,visibility:r,commentMetadata:o,defaultValue:i,defaultAttachments:s,onComposerSubmit:a,collapsed:u,defaultCollapsed:l,onCollapsedChange:f,overrides:c,actions:d,onBlur:h,className:g,onFocus:y,autoFocus:p,disabled:w,blurOnSubmit:b=!0,showAttachments:C=!0,showFormattingControls:E=!0,showAttribution:A,roomId:x,...I},T)=>{const F=zp({allowOutsideRoom:!0}),S=x!==void 0?x:F?.id;if(S===void 0)throw new Error("Composer must be a descendant of RoomProvider component");const k=Up(S),_=Hp(S),M=Vp(S),{preventUnsavedComposerChanges:H}=Ri(),W=Cc()!==void 0,G=m.useRef(!0),q=m.useRef(!1),$=Mt(c),[V,Q]=(function(Y,de,pe){const[fe,we]=m.useState(Y),Ce=de!==void 0,se=m.useRef(Ce);return m.useEffect((()=>{se.current=Ce}),[Ce]),[Ce?de:fe,m.useCallback((te=>(Ce||we(te),pe?.(te))),[Ce,pe])]})(l??!1,u,f),ae=u!==void 0||l===!0,ie=wc(S,il(e===void 0?r??"public":r),"write"),Se=m.useCallback((Y=>{G.current=Y}),[]),Ie=m.useCallback((Y=>{q.current=Y}),[]),ne=m.useCallback((Y=>{y?.(Y),Y.isDefaultPrevented()||G.current&&ie&&Q?.(!1)}),[Q,y,ie]),B=m.useCallback((Y=>{if(h?.(Y),Y.isDefaultPrevented())return;const de=!Y.currentTarget.contains(Y.relatedTarget??document.activeElement);ae&&de&&G.current&&!q.current&&Q?.(!0)}),[h,Q,ae]),X=m.useCallback((Y=>{Y.stopPropagation(),G.current&&ie&&Q?.(!1)}),[Q,ie]),K=m.useCallback(((Y,de)=>{a?.(Y,de),de.isDefaultPrevented()||(de.stopPropagation(),t&&e?M({commentId:t,threadId:e,body:Y.body,metadata:o,attachments:Y.attachments}):e?_({threadId:e,body:Y.body,metadata:o,attachments:Y.attachments}):k({body:Y.body,metadata:n,visibility:r,commentMetadata:o,attachments:Y.attachments}))}),[t,_,k,M,o,n,r,a,e]);return v.jsx(Xs,{children:v.jsx(Q2,{onComposerSubmit:K,className:Ne("lb-root lb-composer lb-composer-form",g),dir:$.dir,...I,ref:T,"data-collapsed":V?"":void 0,onFocus:ne,onBlur:B,disabled:w||!ie,defaultAttachments:s,pasteFilesAsAttachments:C,preventUnsavedChanges:H,blurOnSubmit:b,roomId:S,children:v.jsx(ox,{defaultValue:i,actions:d,overrides:c,isCollapsed:V,showAttachments:C,showAttribution:A,showFormattingControls:E,hasResolveMentionSuggestions:W,onEmptyChange:Se,onEmojiPickerOpenChange:Ie,onEditorClick:X,autoFocus:p,disabled:w})})})}));function ix({children:e,content:t,defaultOpen:n,open:r,onOpenChange:o,className:i,...s}){const a=Mt(),{portalContainer:u}=Ri();return v.jsxs(jC,{defaultOpen:n,open:r,onOpenChange:o,dir:a.dir,children:[e,v.jsx(PC,{container:u,children:v.jsx(NC,{className:Ne("lb-root lb-portal lb-elevation lb-dropdown",i),sideOffset:6,collisionPadding:10,updatePositionStrategy:"always",...s,children:t})})]})}const sx=m.forwardRef((({children:e,className:t,icon:n,...r},o)=>v.jsxs(_C,{className:Ne("lb-dropdown-item",t),...r,ref:o,children:[n?v.jsx("span",{className:"lb-dropdown-item-icon lb-icon-container",children:n}):null,e?v.jsx("span",{className:"lb-dropdown-item-label",children:e}):null]}))),ax=MC;function Wh({locale:e,date:t,className:n,...r}){return v.jsx(iA,{locale:e,date:t,className:Ne("lb-date",n),...r})}function ux({mention:e,className:t,...n}){const r=hr();return v.jsxs(ml,{className:Ne("lb-mention lb-comment-mention",t),"data-self":e.id===r?"":void 0,...n,children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(Oo,{userId:e.id})]})}function cx({mention:e,className:t,...n}){const r=J0(e);return v.jsxs(ml,{className:Ne("lb-mention lb-comment-mention",t),"data-self":r?"":void 0,...n,children:[v.jsx("span",{className:"lb-mention-symbol",children:An}),v.jsx(rl,{groupId:e.id})]})}function lx({mention:e,...t}){switch(e.kind){case"user":return v.jsx(ux,{mention:e,...t});case"group":return v.jsx(cx,{mention:e,...t});default:return Ye(0,"Unhandled mention kind")}}function dx({href:e,children:t,className:n,...r}){const{Anchor:o}=(function(i){const s=m.useContext(_u);return m.useMemo((()=>({...Fg,...s,...i})),[s,i])})();return v.jsx(g0,{className:Ne("lb-comment-link",n),href:e,...r,asChild:!0,children:v.jsx(o,{...r,children:t})})}const Ov=m.forwardRef((({reaction:e,overrides:t,className:n,...r},o)=>{const i=Mt(t);return v.jsxs(nl,{className:Ne("lb-comment-reaction",n),variant:"outline","aria-label":i.COMMENT_REACTION_DESCRIPTION(e.emoji,e.users.length),...r,ref:o,children:[v.jsx(Ec,{className:"lb-comment-reaction-emoji",emoji:e.emoji}),v.jsx("span",{className:"lb-comment-reaction-count",children:e.users.length})]})})),fx=m.forwardRef((({comment:e,reaction:t,overrides:n,disabled:r,...o},i)=>{const s=$p(e.roomId),a=Wp(e.roomId),u=hr(),l=m.useMemo((()=>t.users.some((g=>g.id===u))),[u,t]),f=Mt(n),c=m.useMemo((()=>v.jsx("span",{children:f.COMMENT_REACTION_LIST(v.jsx(Pw,{values:t.users.map((g=>v.jsx(Oo,{userId:g.id,replaceSelf:!0},g.id))),formatRemaining:f.LIST_REMAINING_USERS,truncate:5,locale:f.locale}),t.emoji,t.users.length)})),[f,t]),d=m.useCallback((g=>{g.stopPropagation()}),[]),h=m.useCallback((g=>{g?s({threadId:e.threadId,commentId:e.id,emoji:t.emoji}):a({threadId:e.threadId,commentId:e.id,emoji:t.emoji})}),[s,e.threadId,e.id,t.emoji,a]);return v.jsx(jt,{content:c,multiline:!0,className:"lb-comment-reaction-tooltip",children:v.jsx(Zc,{asChild:!0,pressed:l,onPressedChange:h,onClick:d,disabled:r,ref:i,children:v.jsx(Ov,{"data-self":l?"":void 0,reaction:t,overrides:n,...o})})})}));function Sv({attachment:e,url:t}){e.mimeType==="application/pdf"||e.mimeType.startsWith("image/")||e.mimeType.startsWith("video/")||e.mimeType.startsWith("audio/")?window.open(t,"_blank"):(function(n,r){const o=document.createElement("a");o.href=n,o.download=r,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)})(t,e.name)}function hx({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...i}){const{url:s}=Ws(e.id,n),a=m.useCallback((u=>{if(!s)return;const l={attachment:e,url:s};t?.(l,u),u.isDefaultPrevented()||Sv(l)}),[e,t,s]);return v.jsx(lA,{className:Ne("lb-comment-attachment",r),...i,attachment:e,overrides:o,onClick:s?a:void 0,roomId:n})}function px({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...i}){const{url:s}=Ws(e.id,n),a=m.useCallback((u=>{if(!s)return;const l={attachment:e,url:s};t?.(l,u),u.isDefaultPrevented()||Sv(l)}),[e,t,s]);return v.jsx(tv,{className:Ne("lb-comment-attachment",r),...i,attachment:e,overrides:o,onClick:s?a:void 0,roomId:n})}m.forwardRef((({reaction:e,overrides:t,...n},r)=>{const o=hr(),i=m.useMemo((()=>e.users.some((s=>s.id===o))),[o,e]);return v.jsx(Ov,{disableable:!1,"data-self":i?"":void 0,reaction:e,overrides:t,...n,ref:r})}));const Za=m.forwardRef((({children:e,icon:t,onSelect:n,onClick:r,...o},i)=>{const s=m.useCallback((a=>{r?.(a),a.isDefaultPrevented()||a.stopPropagation()}),[r]);return v.jsx(sx,{icon:t,onSelect:n,onClick:s,...o,ref:i,children:e})})),zh=Object.assign(m.forwardRef((({comment:e,visibility:t,indentContent:n=!0,showDeleted:r,showActions:o="hover",showReactions:i=!0,showAttachments:s=!0,showComposerFormattingControls:a=!0,onAuthorClick:u,onMentionClick:l,onAttachmentClick:f,onCommentEdit:c,onCommentDelete:d,dropdownItems:h,overrides:g,components:y,additionalContent:p,body:w,avatar:b,author:C,date:E,className:A,actions:x,actionsClassName:I,internalDropdownItems:T,children:F,...S},k)=>{const _=`${e.id}:body`,M=ji(k,m.useRef(null)),H=hr(),W=(function(J){const oe=Ve();return m.useCallback((({threadId:ge,commentId:ve})=>{const Te=new Date,{store:We,onMutationFailure:Le}=Et(oe),et=We.optimisticUpdates.add({type:"delete-comment",threadId:ge,commentId:ve,deletedAt:Te,roomId:J});oe[Oe].httpClient.deleteComment({roomId:J,threadId:ge,commentId:ve,visibility:wo(We,ge)}).then((()=>{We.deleteComment(ge,et,ve,Te)}),(ut=>Le(et,{type:"DELETE_COMMENT_ERROR",roomId:J,threadId:ge,commentId:ve},ut)))}),[oe,J])})(e.roomId),G=Vp(e.roomId),q=$p(e.roomId),$=Wp(e.roomId),V=Mt(g),[Q,ae]=m.useState(!1),[ie,Se]=m.useState(!1),[Ie,ne]=m.useState(!1),[B,X]=m.useState(!1),{mediaAttachments:K,fileAttachments:Y}=m.useMemo((()=>(function(J){const oe=[],ge=[];for(const ve of J)(ve.mimeType.startsWith("image/")||ve.mimeType.startsWith("video/"))&&ve.size<=Z0?oe.push(ve):ge.push(ve);return{mediaAttachments:oe,fileAttachments:ge}})(e.attachments)),[e.attachments]),de=wc(e.roomId,il(t),"write"),pe=m.useCallback((J=>{J.stopPropagation()}),[]),fe=m.useCallback((()=>{ae(!0)}),[]),we=m.useCallback((J=>{J.stopPropagation(),ae(!1)}),[]),Ce=m.useCallback((({body:J,attachments:oe},ge)=>{c?.(e),ge.isDefaultPrevented()||(ge.stopPropagation(),ge.preventDefault(),ae(!1),G({commentId:e.id,threadId:e.threadId,body:J,attachments:oe}))}),[e,G,c]),se=m.useCallback((()=>{d?.(e),W({commentId:e.id,threadId:e.threadId})}),[e,W,d]),te=m.useCallback((J=>{u?.(e.userId,J)}),[e.userId,u]),me=m.useCallback((J=>{const oe=e.reactions.findIndex((ge=>ge.emoji===J));oe>=0&&H&&e.reactions[oe]?.users.some((ge=>ge.id===H))?$({threadId:e.threadId,commentId:e.id,emoji:J}):q({threadId:e.threadId,commentId:e.id,emoji:J})}),[q,e.id,e.reactions,e.threadId,$,H]);if(m.useEffect((()=>{typeof window<"u"&&window.location.hash.slice(1)===e.id&&Se(!0)}),[]),!r&&!e.body)return null;const Ae=e.userId===H?v.jsxs(v.Fragment,{children:[v.jsx(Za,{onSelect:fe,icon:v.jsx(qw,{}),children:V.COMMENT_EDIT}),v.jsx(Za,{onSelect:se,icon:v.jsx(Kw,{}),children:V.COMMENT_DELETE})]}):null,Pe=T||Ae?v.jsxs(v.Fragment,{children:[T,Ae]}):null,Fe=typeof h=="function"?h({children:Pe,comment:e}):Pe||h?v.jsxs(v.Fragment,{children:[Pe,h]}):null;let re;if(Q)re=v.jsx(xv,{className:"lb-comment-composer",threadId:e.threadId,commentId:e.id,visibility:t,onComposerSubmit:Ce,defaultValue:e.body,defaultAttachments:e.attachments,autoFocus:!0,showAttribution:!1,showAttachments:s,showFormattingControls:a,actions:v.jsxs(v.Fragment,{children:[v.jsx(jt,{content:V.COMMENT_EDIT_COMPOSER_CANCEL,"aria-label":V.COMMENT_EDIT_COMPOSER_CANCEL,children:v.jsx(Jt,{className:"lb-composer-action",onClick:we,icon:v.jsx(ol,{})})}),v.jsx(tl,{content:V.COMMENT_EDIT_COMPOSER_SAVE,shortcut:"Enter",children:v.jsx(G0,{asChild:!0,children:v.jsx(Jt,{variant:"primary",className:"lb-composer-action",onClick:pe,"aria-label":V.COMMENT_EDIT_COMPOSER_SAVE,icon:v.jsx(Vw,{})})})})]}),overrides:{COMPOSER_PLACEHOLDER:V.COMMENT_EDIT_COMPOSER_PLACEHOLDER},roomId:e.roomId});else{const J=v.jsx(p2,{className:"lb-comment-body",id:_,body:e.body,components:{Mention:({mention:oe})=>v.jsx(lx,{mention:oe,onClick:ge=>l?.(oe,ge),overrides:g}),Link:dx}});re=e.body?v.jsxs(v.Fragment,{children:[w===void 0?J:typeof w=="function"?w({comment:e,children:J}):w,p,s&&(K.length>0||Y.length>0)?v.jsxs("div",{className:"lb-comment-attachments",children:[K.length>0?v.jsx("div",{className:"lb-attachments",children:K.map((oe=>v.jsx(hx,{attachment:oe,overrides:g,onAttachmentClick:f,roomId:e.roomId},oe.id)))}):null,Y.length>0?v.jsx("div",{className:"lb-attachments",children:Y.map((oe=>v.jsx(px,{attachment:oe,overrides:g,onAttachmentClick:f,roomId:e.roomId},oe.id)))}):null]}):null,i&&e.reactions.length>0&&v.jsxs("div",{className:"lb-comment-reactions",children:[e.reactions.map((oe=>v.jsx(fx,{comment:e,reaction:oe,overrides:g,disabled:!de},oe.emoji))),de?v.jsx(tc,{onEmojiSelect:me,children:v.jsx(jt,{content:V.COMMENT_ADD_REACTION,children:v.jsx(nc,{asChild:!0,children:v.jsx(Jt,{className:"lb-comment-reaction lb-comment-reaction-add",variant:"outline",onClick:pe,"aria-label":V.COMMENT_ADD_REACTION,icon:v.jsx(nf,{})})})})}):null]})]}):v.jsx("div",{className:"lb-comment-body",children:v.jsx("p",{className:"lb-comment-deleted",children:V.COMMENT_DELETED})}),re=typeof F=="function"?F({comment:e,children:re}):F??re}return v.jsx(Xs,{children:v.jsx(xw,{components:y,children:v.jsxs("div",{role:"article",id:e.id,className:Ne("lb-root lb-comment",n&&"lb-comment:indent-content",o==="hover"&&"lb-comment:show-actions-hover",(Ie||B)&&"lb-comment:action-open",A),"data-deleted":e.body?void 0:"","data-editing":Q?"":void 0,"data-target":ie?"":void 0,"aria-labelledby":_,dir:V.dir,...S,ref:M,children:[v.jsxs("div",{className:"lb-comment-header",children:[v.jsxs("div",{className:"lb-comment-details",children:[b?v.jsx("div",{className:"lb-comment-avatar",onClick:te,children:b}):v.jsx(ju,{className:"lb-comment-avatar",userId:e.userId,onClick:te}),v.jsxs("span",{className:"lb-comment-details-labels",children:[C?v.jsx("span",{className:"lb-comment-author",onClick:te,children:C}):v.jsx(Oo,{className:"lb-comment-author",userId:e.userId,onClick:te}),E?v.jsx("span",{className:"lb-comment-date",children:E}):v.jsxs("span",{className:"lb-comment-date",children:[v.jsx(Wh,{locale:V.locale,date:e.createdAt,className:"lb-comment-date-created"}),e.editedAt&&e.body&&v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{className:"lb-comment-date-edited",children:V.COMMENT_EDITED})]})]})]})]}),o&&!Q&&v.jsxs("div",{className:Ne("lb-comment-actions",I),children:[x??null,i&&de?v.jsx(tc,{onEmojiSelect:me,onOpenChange:X,children:v.jsx(jt,{content:V.COMMENT_ADD_REACTION,children:v.jsx(nc,{asChild:!0,children:v.jsx(Jt,{className:"lb-comment-action",onClick:pe,"aria-label":V.COMMENT_ADD_REACTION,icon:v.jsx(nf,{})})})})}):null,Fe?v.jsx(ix,{open:Ie,onOpenChange:ne,align:"end",content:Fe,children:v.jsx(jt,{content:V.COMMENT_MORE,children:v.jsx(ax,{asChild:!0,children:v.jsx(Jt,{className:"lb-comment-action",disabled:!e.body,onClick:pe,"aria-label":V.COMMENT_MORE,icon:v.jsx(Gw,{})})})})}):null]})]}),v.jsx("div",{className:"lb-comment-content",children:re})]})})})})),{DropdownItem:Za,Avatar:function(e){return v.jsx(ju,{...e})},Author:function(e){return v.jsx(Oo,{...e})},Date:Wh});function mx(e){return window.addEventListener("blur",e),window.addEventListener("focus",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("focus",e)}}function gx(){return document.hasFocus()}function vx(){return!0}function yx({thread:e}){const{id:t,roomId:n}=e,r=m.useRef(null),o=(function(i){const s=Ve();return m.useCallback((a=>{const{store:u,onMutationFailure:l}=Et(s),f=Object.values(u.outputs.notifications.get().notificationsById).find((h=>h.kind==="thread"&&h.threadId===a));if(!f)return;const c=new Date,d=u.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:f.id,readAt:c});s[Oe].httpClient.markRoomInboxNotificationAsRead({roomId:i,inboxNotificationId:f.id}).then((()=>{u.markInboxNotificationRead(f.id,c,d)}),(h=>{l(d,{type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",roomId:i,inboxNotificationId:f.id},h)}))}),[s,i])})(n);return f2(r,(i=>{i&&o(t)}),{enabled:m.useSyncExternalStore(mx,gx,vx)}),v.jsx("div",{ref:r,style:{height:0},"aria-hidden":!0,"data-mark-as-read-marker":""})}const $x=m.forwardRef((({thread:e,indentCommentContent:t=!0,showActions:n="hover",showDeletedComments:r,showResolveAction:o=!0,showReactions:i=!0,showComposer:s="collapsed",showAttachments:a=!0,showSubscription:u=!0,showComposerFormattingControls:l=!0,maxVisibleComments:f,commentDropdownItems:c,onResolvedChange:d,onCommentEdit:h,onCommentDelete:g,onThreadDelete:y,onAuthorClick:p,onMentionClick:w,onAttachmentClick:b,onComposerSubmit:C,blurComposerOnSubmit:E,autoFocus:A,overrides:x,components:I,className:T,...F},S)=>{const k=oE(I?.Comment,zh),_=(function(se){const te=Ve();return m.useCallback((me=>{const Ae=new Date,{store:Pe,onMutationFailure:Fe}=Et(te),re=Pe.optimisticUpdates.add({type:"mark-thread-as-resolved",threadId:me,updatedAt:Ae});te[Oe].httpClient.markThreadAsResolved({roomId:se,threadId:me,visibility:wo(Pe,me)}).then((()=>{Pe.patchThread(me,re,{resolved:!0},Ae)}),(J=>Fe(re,{type:"MARK_THREAD_AS_RESOLVED_ERROR",roomId:se,threadId:me},J)))}),[te,se])})(e.roomId),M=(function(se){const te=Ve();return m.useCallback((me=>{const Ae=new Date,{store:Pe,onMutationFailure:Fe}=Et(te),re=Pe.optimisticUpdates.add({type:"mark-thread-as-unresolved",threadId:me,updatedAt:Ae});te[Oe].httpClient.markThreadAsUnresolved({roomId:se,threadId:me,visibility:wo(Pe,me)}).then((()=>{Pe.patchThread(me,re,{resolved:!1},Ae)}),(J=>Fe(re,{type:"MARK_THREAD_AS_UNRESOLVED_ERROR",roomId:se,threadId:me},J)))}),[te,se])})(e.roomId),H=Mt(x),[W,G]=m.useState(!1),q=m.useMemo((()=>r?0:e.comments.findIndex((se=>se.body))),[r,e.comments]),$=m.useMemo((()=>r?e.comments.length-1:qh(e.comments,(se=>!!se.body))),[r,e.comments]),V=m.useMemo((()=>r?e.comments.length:e.comments.filter((se=>se.body)).length),[r,e.comments]),Q=m.useMemo((()=>{const se=typeof f=="number"?f:f?.max,te=(typeof f=="object"?f?.show:void 0)??"newest";if(W||se===void 0)return;const me=e.comments.map(((ve,Te)=>({comment:ve,index:Te}))).filter((({comment:ve})=>r||ve.body));if(me.length<=Math.max(se,2))return;const Ae=me[0],Pe=me[me.length-1];if(se<=2)return{firstIndex:me[1]?.index??Ae.index,lastIndex:me[me.length-2]?.index??Pe.index,count:me.slice(1,me.length-1).length};const Fe=se-2,re=te==="oldest"?Fe:te==="newest"?0:Math.floor(Fe/2),J=te==="oldest"?0:te==="newest"?Fe:Math.ceil(Fe/2),oe=me[1+re],ge=me[me.length-2-J];return!oe||!ge||oe.index>ge.index?void 0:{firstIndex:oe.index,lastIndex:ge.index,count:e.comments.slice(oe.index,ge.index+1).filter((ve=>r||ve.body)).length}}),[f,W,r,e.comments]),{status:ae,unreadSince:ie,subscribe:Se,unsubscribe:Ie}=wy(e.roomId,e.id),ne=m.useMemo((()=>{if(ae!=="subscribed")return;if(ie===null)return q;const se=e.comments.findIndex((te=>(!!r||te.body)&&te.createdAt>ie));return se>=0&&se<e.comments.length?se:void 0}),[q,r,ae,e.comments,ie]),[B,X]=m.useState(),K=B===void 0?ne:B;m.useEffect((()=>{ne&&X((se=>Math.min(se??1/0,ne)))}),[ne]);const Y=wc(e.roomId,il(e.visibility),"write"),de=m.useCallback((se=>{se.stopPropagation()}),[]),pe=m.useCallback((se=>{d?.(se),se?_(e.id):M(e.id)}),[_,M,d,e.id]),fe=m.useCallback((se=>{g?.(se),e.comments.filter((te=>te.body)).length<=1&&y?.(e)}),[g,y,e]),we=m.useCallback((()=>{ae==="subscribed"?Ie():Se()}),[ae,Se,Ie]);let Ce=0;return v.jsx(Xs,{children:v.jsxs("div",{className:Ne("lb-root lb-thread",n==="hover"&&"lb-thread:show-actions-hover",T),"data-resolved":e.resolved?"":void 0,"data-unread":ne!==void 0?"":void 0,dir:H.dir,...F,ref:S,children:[v.jsx("div",{className:"lb-thread-comments",role:"feed",children:e.comments.map(((se,te)=>{const me=r||se.body,Ae=te===q,Pe=ne!==void 0&&te>=ne,Fe=Q&&te>=Q.firstIndex&&te<=Q.lastIndex,re=!r&&!se.body;if(Fe&&te===Q.firstIndex)return v.jsx("div",{className:"lb-thread-show-more",children:v.jsx(Jt,{variant:"ghost",className:"lb-thread-show-more-button",onClick:()=>G(!0),children:H.THREAD_SHOW_MORE_COMMENTS(Q.count)})},`${se.id}:show-more`);if(Fe||re)return null;me&&Ce++;const J=v.jsx(k,{tabIndex:0,"aria-posinset":Ce,"aria-setsize":V,overrides:x,className:"lb-thread-comment","data-unread":Pe?"":void 0,comment:se,visibility:e.visibility,indentContent:t,showDeleted:r,showActions:n,showReactions:i,showAttachments:a,showComposerFormattingControls:l,onCommentEdit:h,onCommentDelete:fe,onAuthorClick:p,onMentionClick:w,onAttachmentClick:b,components:I,actionsClassName:Ae?"lb-thread-actions":void 0,actions:Ae&&o?v.jsx(jt,{content:e.resolved?H.THREAD_UNRESOLVE:H.THREAD_RESOLVE,children:v.jsx(Zc,{pressed:e.resolved,onPressedChange:pe,asChild:!0,children:v.jsx(Jt,{className:"lb-comment-action",onClick:de,"aria-label":e.resolved?H.THREAD_UNRESOLVE:H.THREAD_RESOLVE,icon:e.resolved?v.jsx(Ww,{}):v.jsx($w,{}),disabled:!Y})})}):null,internalDropdownItems:Ae&&u?v.jsx(zh.DropdownItem,{onSelect:we,icon:ae==="subscribed"?v.jsx(Uw,{}):v.jsx(Lw,{}),children:ae==="subscribed"?H.THREAD_UNSUBSCRIBE:H.THREAD_SUBSCRIBE}):void 0,dropdownItems:c},se.id);return te===K&&K!==q&&K<=$?v.jsxs(m.Fragment,{children:[v.jsx("div",{className:"lb-thread-new-indicator","aria-label":H.THREAD_NEW_INDICATOR_DESCRIPTION,children:v.jsxs("span",{className:"lb-thread-new-indicator-label",children:[v.jsx(Nw,{className:"lb-thread-new-indicator-label-icon"}),H.THREAD_NEW_INDICATOR]})}),J]},se.id):J}))}),ne!==void 0&&v.jsx(yx,{thread:e}),s&&v.jsx(xv,{className:"lb-thread-composer",threadId:e.id,visibility:e.visibility,defaultCollapsed:s==="collapsed"||void 0,showAttachments:a,showFormattingControls:l,onComposerSubmit:C,blurOnSubmit:E,overrides:{COMPOSER_PLACEHOLDER:H.THREAD_COMPOSER_PLACEHOLDER,COMPOSER_SEND:H.THREAD_COMPOSER_SEND,...x},roomId:e.roomId,autoFocus:A})]})})}));export{Ax as C,xx as L,iA as T,Tx as _,zp as a,Fx as b,Ix as c,kx as d,xv as e,p2 as f,zh as g,Bx as h,$x as i,v as j,Lp as k,g0 as l,ml as m,Ox as n,Sx as o,Mt as u};
|