@zeniai/web-cockpit-ui 2.1.24-qa → 2.1.25-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/CreditAgentRoutes-DCEqkbP3.js +4 -0
- package/dist/assets/{Preview-fdOCM8pI.js → Preview-l-YNNTfe.js} +1 -1
- package/dist/assets/{ScreenRoutes-Dxzap3kT.js → ScreenRoutes-C8NQCfat.js} +65 -65
- package/dist/assets/SignInScreen-DZpfpkvi.js +1 -0
- package/dist/assets/{analytics-cF9vsVE6.js → analytics-BKKnoe9v.js} +1 -1
- package/dist/assets/{analyticsHelper-RU0Hd7D_.js → analyticsHelper-CR4Kcrpe.js} +1 -1
- package/dist/assets/{core-Cw1yuiX5.js → core-B8yM-a3I.js} +1 -1
- package/dist/assets/{dash.all.min-BeTswrxh.js → dash.all.min-CcJ79Ii3.js} +1 -1
- package/dist/assets/{empty-Cqj0IL-P.js → empty-Bt9zcLFB.js} +1 -1
- package/dist/assets/{empty-Cf_UaBBV.js → empty-KBOV5st3.js} +1 -1
- package/dist/assets/epic-DLoGYW3i.js +2 -0
- package/dist/assets/{index-C7Sx4C96.js → index-6BVex5Y5.js} +1 -1
- package/dist/assets/{index-B9jPQwSi.js → index-BZR7LESy.js} +10013 -10838
- package/dist/assets/{index-DAQKBzBG.js → index-BaOHPO6-.js} +1 -1
- package/dist/assets/{index-DKRg22Sn.js → index-BjbQC7rk.js} +1 -1
- package/dist/assets/{index-DM2KJMvg.js → index-CRPpHtvj.js} +1 -1
- package/dist/assets/{index-CePGsY91.js → index-CnxOo-gg.js} +1 -1
- package/dist/assets/{index-T6sL0mkT.js → index-DQx59sRE.js} +2 -2
- package/dist/assets/index-DcGIrthm.css +1 -0
- package/dist/assets/{lexical-CcCdpURS.js → lexical-VWyRQHrp.js} +1 -1
- package/dist/assets/liveblocks-DSIQKZKW.js +59 -0
- package/dist/assets/{lottie-Cbbk4dn5.js → lottie-DkKIGfGz.js} +1 -1
- package/dist/assets/{mui-BXu8LgeK.js → mui-CoMFoc_7.js} +1 -1
- package/dist/assets/{react-DAfSfktL.js → react-BBqZQnID.js} +1 -1
- package/dist/assets/{react-CjDhz93a.js → react-Bp902q8Y.js} +1 -1
- package/dist/assets/{react-5WMbFZwS.js → react-BvS9dCGv.js} +1 -1
- package/dist/assets/{react-XhY8OjAR.js → react-CILNlWQk.js} +1 -1
- package/dist/assets/{react-DK062qhg.js → react-CvKpIpd_.js} +1 -1
- package/dist/assets/{react-BKRhUOEt.js → react-DXmk1laB.js} +2 -2
- package/dist/assets/{react-DpKC_OsU.js → react-qzdVTL09.js} +1 -1
- package/dist/assets/{react-DVT-sKZH.js → react-yY1OKJku.js} +1 -1
- package/dist/assets/{recharts-DU6GYwaM.js → recharts-BdsKV7VX.js} +1 -1
- package/dist/assets/{sentry-b4QdPnV1.js → sentry-LloEE0qc.js} +1 -1
- package/dist/assets/{url-Dkj5n2jh.js → url-BQ7S0ImG.js} +1 -1
- package/dist/assets/{url-Di7Xg8S3.js → url-CT86oRm_.js} +1 -1
- package/dist/assets/{utils-B99CtaZi.js → utils-CQI03c-m.js} +1 -1
- package/dist/assets/{zeni-epic-state-X3dL-kq4.js → zeni-epic-state-XyiIYchy.js} +6 -6
- package/dist/index.html +1 -1
- package/package.json +6 -6
- package/dist/assets/CreditAgentRoutes-D7_HQgOw.js +0 -4
- package/dist/assets/SignInScreen-C5xe5Y15.js +0 -1
- package/dist/assets/epic-Cz7yBnY1.js +0 -2
- package/dist/assets/index-B9p5bBUx.css +0 -1
- package/dist/assets/liveblocks-BHLGTX81.js +0 -54
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{r as WC,a as f,c as tu,R as Oi,g as zC,b as Re}from"./sentry-LloEE0qc.js";import{r as hs,R as KC}from"./core-B8yM-a3I.js";import{t as GC,d as qC}from"./recharts-BdsKV7VX.js";(function(){try{var e=typeof window<"u"?window:typeof Dr<"u"?Dr:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="84ac0537-2322-4ec8-adff-8e521b838fc8",e._sentryDebugIdIdentifier="sentry-dbid-84ac0537-2322-4ec8-adff-8e521b838fc8")}catch{}})();var fa={exports:{}},To={};var Bl;function YC(){if(Bl)return To;Bl=1;var e=WC(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,u,c){var d,l={},m=null,g=null;c!==void 0&&(m=""+c),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(g=u.ref);for(d in u)r.call(u,d)&&!s.hasOwnProperty(d)&&(l[d]=u[d]);if(a&&a.defaultProps)for(d in u=a.defaultProps,u)l[d]===void 0&&(l[d]=u[d]);return{$$typeof:t,type:a,key:m,ref:g,props:l,_owner:o.current}}return To.Fragment=n,To.jsx=i,To.jsxs=i,To}var Fl;function JC(){return Fl||(Fl=1,fa.exports=YC()),fa.exports}var h=JC(),ZC="@liveblocks/react",XC="3.22.0",QC="esm";function p4(e){const[t,n]=f.useState(!1);return f.useEffect(()=>{n(!0)},[]),h.jsx(f.Suspense,{fallback:e.fallback,children:t?typeof e.children=="function"?e.children():e.children:e.fallback})}var e1=Object.defineProperty,t1=(e,t)=>{for(var n in t)e1(e,n,{get:t[n],enumerable:!0})},n1="@liveblocks/core",Ti="3.22.0",r1="esm",Rs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof tu<"u"?tu:{},o1="https://liveblocks.io/docs/errors/dupes",s1=" ";function i1(e){console.error(e)}function Yu(e,t,n){const r=Symbol.for(e),o=`${t} (${n})`;if(!Rs[r])Rs[r]=o;else if(Rs[r]!==o){const s=[`Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See ${o1+s1}`,"","Conflicts:",`- ${e} ${Rs[r]} (already loaded)`,`- ${e} ${o} (trying to load this now)`].join(`
|
|
2
|
+
`);i1(s)}}function Ne(){const e=new Set;function t(i){return e.add(i),()=>e.delete(i)}function n(i){const a=t(u=>(a(),i(u)));return a}async function r(i){let a;return new Promise(u=>{a=t(c=>{(i===void 0||i(c))&&u(c)})}).finally(()=>a?.())}function o(i){let a=!1;for(const u of e)u(i),a=!0;return a}function s(){return e.size}return{notify:o,subscribe:t,subscribeOnce:n,count:s,waitUntil:r,dispose(){e.clear()},observable:{subscribe:t,subscribeOnce:n,waitUntil:r}}}function a1(){const e=Ne();let t=null;function n(){t=[]}function r(){if(t!==null){for(const s of t)e.notify(s);t=null}}function o(s){return t!==null?(t.push(s),!1):e.notify(s)}return{...e,notify:o,pause:n,unpause:r,dispose(){e.dispose(),t!==null&&(t.length=0)}}}var hn=(e=>e);function Ft(e){throw new Error(e)}function Ju(e){return Object.entries(e)}function u1(e){return Object.keys(e)}function c1(e,t){return typeof t<"u"?Object.create(e,t):Object.create(e)}function Sn(e){try{return JSON.parse(e)}catch{return}}function ao(e){return JSON.parse(JSON.stringify(e))}function l1(e){try{const t=e.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))}catch{return atob(e)}}function nu(e){return e.filter(t=>t!=null)}function ps(e){const t={...e};return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function d1(e){return new Promise(t=>setTimeout(t,e))}async function Pl(e,t,n){let r;const o=new Promise((s,i)=>{r=setTimeout(()=>{i(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 Lh(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n],n,e))return n;return-1}function f1(e,t){const n=[],r=[];let o=0;for(const s of e)t(s,o++)?n.push(s):r.push(s);return[n,r]}var or=Symbol("kSinks"),ii=Symbol("kTrigger"),Yr=null,fr=null;function Ze(e){if(Yr!==null){e();return}Yr=new Set;try{e()}finally{for(const t of Yr)t[ii]();Yr=null}}function Zu(e){Yr||Ft("Expected to be in an active batch"),Yr.add(e)}function Uh(e,t){let n=!1;const r={...e};return Object.keys(t).forEach(o=>{const s=o,i=t[s];r[s]!==i&&(i===void 0?delete r[s]:r[s]=i,n=!0)}),n?r:e}var Xu=class{equals;#e;[or];constructor(e){this.equals=e??Object.is,this.#e=Ne(),this[or]=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[or])if(e.hasWatchers)return!0;return!1}[ii](){this.#e.notify();for(const e of this[or])Zu(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[or])e.markDirty()}addSink(e){this[or].add(e)}removeSink(e){this[or].delete(e)}asReadonly(){return this}},St=class extends Xu{#e;constructor(e,t){super(t),this.#e=hn(e)}dispose(){super.dispose(),this.#e="(disposed)"}get(){return fr?.add(this),this.#e}set(e){Ze(()=>{typeof e=="function"&&(e=e(this.#e)),this.equals(this.#e,e)||(this.#e=hn(e),this.markSinksDirty(),Zu(this))})}},h1=class extends St{constructor(e){super(hn(ps(e)))}set(){throw new Error("Don't call .set() directly, use .patch()")}patch(e){super.set(t=>Uh(t,e))}},p1=Symbol(),je=class ru extends Xu{#e;#t;#n;#r;#o;static from(...t){const n=t.pop();if(typeof n!="function"&&Ft("Invalid .from() call, last argument expected to be a function"),typeof t[t.length-1]=="function"){const r=n,o=t.pop();return new ru(t,o,r)}else{const r=n;return new ru(t,r)}}constructor(t,n,r){super(r),this.#t=!0,this.#e=p1,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}#s(){const t=fr;let n;fr=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 fr)this.#n.add(o),r.delete(o);for(const o of r)o.removeSink(this);for(const o of this.#n)o.addSink(this);fr=t}return this.#t=!1,this.equals(this.#e,n)?!1:(this.#e=n,!0)}markDirty(){this.#t||(this.#t=!0,this.markSinksDirty())}get(){return this.#t&&this.#s(),fr?.add(this),this.#e}[ii](){if(!this.hasWatchers)return;this.#s()&&super[ii]()}},xt=class extends Xu{#e;constructor(e){super(),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return fr?.add(this),this.#e}mutate(e){Ze(()=>{const t=e?e(this.#e):!0;t!==null&&typeof t=="object"&&"then"in t&&Ft("MutableSignal.mutate() does not support async callbacks"),t!==!1&&(this.markSinksDirty(),Zu(this))})}};function _l(e,t,n){let r=0,o=e.length;for(;r<o;){const s=r+(o-r>>1);n(t,e[s])?o=s:r=s+1}return r}var zn=class Mo{#e;#t;constructor(t,n){this.#t=n,this.#e=t}static with(t){return Mo.fromAlreadySorted([],t)}static from(t,n){const r=new Mo([],n);for(const o of t)r.add(o);return r}static fromAlreadySorted(t,n){return new Mo(t,n)}clone(){return new Mo(this.#e.slice(),this.#t)}add(t){const n=_l(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):!1}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],s=r===void 0||this.#t(r,t),i=o===void 0||this.#t(t,o);if(s&&i)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=_l(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}},m1=class{#e;#t;signal;constructor(){this.#e=new Map,this.#t=zn.from([],(e,t)=>{const n=t.lastMessageAt??t.createdAt,r=e.lastMessageAt??e.createdAt;return n<r?!0:n===r?t.id<e.id:!1}),this.signal=new xt(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(s=>o.includes(s)))return!1}return!0}))}};function ou(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 _n(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.comments.map(o=>ou(o));return{...e,createdAt:t,updatedAt:n,comments:r}}function g1(e){return{...e,createdAt:new Date(e.createdAt)}}function sr(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 kn(e){const t=new Date(e.createdAt);return{...e,createdAt:t}}function ha(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function pa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function ma(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function kl(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 Je(e,t){throw new Error(t)}function ge(e,t="Expected value to be non-nullable"){return e}var Vt={};t1(Vt,{error:()=>Jn,errorWithTitle:()=>Wh,warn:()=>ft,warnWithTitle:()=>C1});var $h="background:#0e0d12;border-radius:9999px;color:#fff;padding:3px 7px;font-family:sans-serif;font-weight:600;",v1="font-weight:600";function Hh(e){return typeof window>"u"?console[e]:((t,...n)=>console[e]("%cLiveblocks",$h,t,...n))}var ft=Hh("warn"),Jn=Hh("error");function Vh(e){return typeof window>"u"?console[e]:((t,n,...r)=>console[e](`%cLiveblocks%c ${t}`,$h,v1,n,...r))}var C1=Vh("warn"),Wh=Vh("error");function E1(e){return e!=null}function lt(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function su(e){return lt(e)&&typeof e.startsWith=="string"}function iu(e){return lt(e)&&(typeof e.lt=="number"||typeof e.gt=="number"||typeof e.lte=="number"||typeof e.gte=="number")}var uo=class zh 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?Sn(n):void 0;let o;lt(r)&&(o=r);let s="";s||=typeof o?.message=="string"?o.message:"",s||=typeof o?.error=="string"?o.error:"",r===void 0&&(s||=n||""),s||=t.statusText;let i;try{i=new URL(t.url).pathname}catch{}s+=i!==void 0?` (got status ${t.status} from ${i})`:` (got status ${t.status})`;const a=o;return new zh(s,t,a)}get status(){return this.response.status}},y1=e=>e instanceof uo&&e.status>=400&&e.status<500;async function Uo(e,t,n,r=y1){const o=n.length>0?n[n.length-1]:0;let s=0;for(;;){s++;try{return await e()}catch(a){if(r(a))throw a;if(s>=t)throw new Error(`Failed after ${t} attempts: ${String(a)}`)}const i=n[s-1]??o;ft(`Attempt ${s} was unsuccessful. Retrying in ${i} milliseconds.`),await d1(i)}}function Kh(){let e,t;return[new Promise((r,o)=>{e=r,t=o}),e,t]}function Jr(){const[e,t,n]=Kh();return{promise:e,resolve:t,reject:n}}function b1(e,t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).sort().reduce((n,r)=>(n[r]=t[r],n),{}):t}function Zn(e){return JSON.stringify(e,b1)}function co(e){try{return JSON.stringify(e)}catch(t){throw console.error(`Could not stringify: ${t.message}`),console.error(e),t}}var w1=50,D1=class{input;resolve;reject;promise;constructor(e){this.input=e;const{promise:t,resolve:n,reject:r}=Jr();this.promise=t,this.resolve=n,this.reject=r}},mr=class{#e=[];#t;#n;#r;#o;error=!1;constructor(e,t){this.#t=e,this.#n=t.size??w1,this.#r=t.delay}#s(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#i(){this.#e.length===this.#n?this.#u():this.#e.length===1&&(this.#s(),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 s=n?.[o];Array.isArray(n)?e.length!==n.length?r.reject(new Error(`Callback must return an array of the same length as the number of provided items. Expected ${e.length}, but got ${n.length}.`)):s instanceof Error?r.reject(s):r.resolve(s):r.reject(new Error("Callback must return an array."))})}catch(n){this.error=!0,e.forEach(r=>{r.reject(n)})}}get(e){const t=this.#e.find(r=>Zn(r.input)===Zn(e));if(t)return t.promise;const n=new D1(e);return this.#e.push(n),this.#i(),n.promise}clear(){this.#e=[],this.error=!1,this.#s()}};function $o(e){const t=new xt(new Map);function n(d){return Zn(d)}function r(d){t.mutate(l=>{if(Array.isArray(d))for(const m of d)l.set(m.key,m.state);else l.set(d.key,d.state)})}function o(d){t.mutate(l=>{if(Array.isArray(d))for(const m of d)l.delete(n(m));else l.clear()})}async function s(d){const l=n(d);if(!t.get().has(l))try{r({key:l,state:{isLoading:!0}});const g=await e.get(d);r({key:l,state:{isLoading:!1,data:g}})}catch(g){r({key:l,state:{isLoading:!1,error:g}})}}function i(d){r(d.map(l=>({key:n(l[0]),state:{isLoading:!1,data:l[1]}})))}function a(d){const l=n(d);return t.get().get(l)}function u(d){const l=n(d);return t.get().get(l)?.data}function c(){return[...t.get().keys()]}return{subscribe:t.subscribe,enqueue:s,setData:i,getItemState:a,getData:u,invalidate:o,batch:e,_cacheKeys:c}}function A1(e,t){const n=[];for(let r=0,o=e.length;r<o;r+=t)n.push(e.slice(r,r+t));return n}var it=(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?"_":"-",""),S1="th",x1="cm",O1="at";function Qu(e){return`${e}_${it()}`}function Gh(){return Qu(S1)}function ai(){return Qu(x1)}function qh(){return Qu(O1)}var Le=class extends Map{#e;constructor(e,t){super(t),this.#e=e}getOrCreate(e,t){if(super.has(e))return super.get(e);{const r=(t??this.#e??Ft("DefaultMap used without a factory function"))(e);return this.set(e,r),r}}},T1=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function Nr(e){let t=[];const n=Object.entries(e),r=[],o=[],s=[];return n.forEach(([i,a])=>{if(!T1.test(i))throw new Error("Key must only contain letters, numbers, _");Ll(a)?r.push([i,a]):lt(a)&&(su(a)||iu(a)?o.push([i,a]):s.push([i,a]))}),t=[...Nl(r),...jl(o)],s.forEach(([i,a])=>{const u=Object.entries(a),c=[],d=[];u.forEach(([l,m])=>{if(R1(l))throw new Error("Key cannot be empty");Ll(m)?c.push([Ul(i,l),m]):(su(m)||iu(m))&&d.push([Ul(i,l),m])}),t=[...t,...Nl(c),...jl(d)]}),t.map(({key:i,operator:a,value:u})=>`${i}${a}${Yh(u)}`).join(" ")}var Nl=e=>{const t=[];return e.forEach(([n,r])=>{t.push({key:n,operator:":",value:r})}),t},jl=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},Ll=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Ul=(e,t)=>t?`${e}[${Yh(t)}]`:e,R1=e=>!e||e.toString().trim()==="";function Yh(e){const t=JSON.stringify(e);return typeof e!="string"||t.includes("'")?t:`'${t.slice(1,-1).replace(/\\"/g,'"')}'`}var au="https://localhost:9999",Jh=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,I1=/\/(?:(?:\?|#).*)?$/;function B1(e){const t=new URLSearchParams;for(const[n,r]of Object.entries(e))r!=null&&t.set(n,r.toString());return t}function F1(e,t,n){const r=new URL(t,e);return n!==void 0&&(r.search=(n instanceof URLSearchParams?n:B1(n)).toString()),r.toString()}function Ae(e,...t){return e.reduce((n,r,o)=>n+encodeURIComponent(t[o-1]??"")+r)}function ec(e){if(e.startsWith("www.")&&(e="https://"+e),e==="#")return e;try{const t=Jh.test(e),n=new URL(e,t?void 0:au);if(n.protocol!=="http:"&&n.protocol!=="https:")return null;const r=I1.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}}function P1(e,t,n){const r=Jh.test(e),o=new URL(e,r?void 0:au);return!o.hash&&n!==void 0&&(o.hash=`#${n}`),r?o.href:o.href.replace(au,"")}function M1(e){try{return new URL(e),!0}catch{return!1}}function $t(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function _1({baseUrl:e,authManager:t,fetchPolyfill:n}){const r=new k1(e,n);async function o(O){const k=await r.get(Ae`/v2/c/rooms/${O.roomId}/threads/delta`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}),{since:O.since.toISOString()},{signal:O.signal});return{threads:{updated:k.data.map(_n),deleted:k.deletedThreads.map(ha)},inboxNotifications:{updated:k.inboxNotifications.map(sr),deleted:k.deletedInboxNotifications.map(pa)},subscriptions:{updated:k.subscriptions.map(kn),deleted:k.deletedSubscriptions.map(ma)},requestedAt:new Date(k.meta.requestedAt),permissionHints:k.meta.permissionHints}}async function s(O){let k;O.query&&(k=Nr(O.query));const ne=50;try{const re=await r.get(Ae`/v2/c/rooms/${O.roomId}/threads`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.query?.visibility),access:"read"}),{cursor:O.cursor,query:k,limit:ne});return{threads:re.data.map(_n),inboxNotifications:re.inboxNotifications.map(sr),subscriptions:re.subscriptions.map(kn),nextCursor:re.meta.nextCursor,requestedAt:new Date(re.meta.requestedAt),permissionHints:re.meta.permissionHints}}catch(re){if(re instanceof uo&&re.status===404)return{threads:[],inboxNotifications:[],subscriptions:[],nextCursor:null,requestedAt:new Date(Date.now()-360*60*1e3),permissionHints:{}};throw re}}async function i(O,k){return await r.get(Ae`/v2/c/rooms/${O.roomId}/threads/comments/search`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}),{text:O.query.text,query:Nr({threadMetadata:O.query.threadMetadata,threadResolved:O.query.threadResolved,hasAttachments:O.query.hasAttachments,hasMentions:O.query.hasMentions})},{signal:k?.signal})}async function a(O){const k=O.commentId??ai(),ne=O.threadId??Gh(),re=await r.post(Ae`/v2/c/rooms/${O.roomId}/threads`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility??"public"),access:"write"}),{id:ne,visibility:O.visibility,comment:{id:k,body:O.body,metadata:O.commentMetadata,attachmentIds:O.attachmentIds},metadata:O.metadata});return _n(re)}async function u(O){await r.delete(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}))}async function c(O){const k=await r.rawGet(Ae`/v2/c/rooms/${O.roomId}/thread-with-notification/${O.threadId}`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}));if(k.ok){const ne=await k.json();return{thread:_n(ne.thread),inboxNotification:ne.inboxNotification?sr(ne.inboxNotification):void 0,subscription:ne.subscription?kn(ne.subscription):void 0}}else{if(k.status===404)return{thread:void 0,inboxNotification:void 0,subscription:void 0};throw new Error(`There was an error while getting thread ${O.threadId}.`)}}async function d(O){return await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/metadata`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}),O.metadata)}async function l(O){return await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/comments/${O.commentId}/metadata`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}),O.metadata)}async function m(O){const k=O.commentId??ai(),ne=await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/comments`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}),{id:k,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds});return ou(ne)}async function g(O){const k=await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/comments/${O.commentId}`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}),{body:O.body,attachmentIds:O.attachmentIds,metadata:O.metadata});return ou(k)}async function v(O){await r.delete(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/comments/${O.commentId}`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}))}async function C(O){const k=await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/comments/${O.commentId}/reactions`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}),{emoji:O.emoji});return g1(k)}async function p(O){await r.delete(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/comments/${O.commentId}/reactions/${O.emoji}`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}))}async function D(O){await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/mark-as-resolved`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}))}async function w(O){await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/mark-as-unresolved`,await t.getAuthValue({roomId:O.roomId,resource:$t(O.visibility),access:"write"}))}async function b(O){const k=await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/subscribe`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}));return kn(k)}async function y(O){await r.post(Ae`/v2/c/rooms/${O.roomId}/threads/${O.threadId}/unsubscribe`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}))}async function A(O){const k=O.roomId,ne=O.signal,re=O.attachment,he=ne?new DOMException(`Upload of attachment ${O.attachment.id} was aborted.`,"AbortError"):void 0;if(ne?.aborted)throw he;const Ie=He=>{if(ne?.aborted)throw he;if(He instanceof uo&&He.status===413)throw He;return!1},Fe=5*1024*1024,Xe=10,ht=[2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3];function Gt(He){const pt=[];let mt=0;for(;mt<He.size;){const Ve=Math.min(mt+Fe,He.size);pt.push({partNumber:pt.length+1,part:He.slice(mt,Ve)}),mt=Ve}return pt}if(re.size<=Fe)return Uo(async()=>r.putBlob(Ae`/v2/c/rooms/${k}/attachments/${re.id}/upload/${re.name}`,await t.getAuthValue({roomId:k,resource:"comments",access:"write"}),re.file,{fileSize:re.size},{signal:ne}),Xe,ht,Ie);{let He;const pt=[],mt=await Uo(async()=>r.post(Ae`/v2/c/rooms/${k}/attachments/${re.id}/multipart/${re.name}`,await t.getAuthValue({roomId:k,resource:"comments",access:"write"}),void 0,{signal:ne},{fileSize:re.size}),Xe,ht,Ie);try{He=mt.uploadId;const Ve=Gt(re.file);if(ne?.aborted)throw he;const Mt=A1(Ve,5);for(const qt of Mt){const vt=[];for(const{part:rn,partNumber:on}of qt)vt.push(Uo(async()=>r.putBlob(Ae`/v2/c/rooms/${k}/attachments/${re.id}/multipart/${mt.uploadId}/${String(on)}`,await t.getAuthValue({roomId:k,resource:"comments",access:"write"}),rn,void 0,{signal:ne}),Xe,ht,Ie));pt.push(...await Promise.all(vt))}if(ne?.aborted)throw he;const gt=pt.sort((qt,vt)=>qt.partNumber-vt.partNumber);return r.post(Ae`/v2/c/rooms/${k}/attachments/${re.id}/multipart/${He}/complete`,await t.getAuthValue({roomId:k,resource:"comments",access:"write"}),{parts:gt},{signal:ne})}catch(Ve){if(He&&Ve?.name&&(Ve.name==="AbortError"||Ve.name==="TimeoutError"))try{await r.rawDelete(Ae`/v2/c/rooms/${k}/attachments/${re.id}/multipart/${He}`,await t.getAuthValue({roomId:k,resource:"comments",access:"write"}))}catch{}throw Ve}}}const T=new Le(O=>{const k=new mr(async ne=>{const re=ne.flat(),{urls:he}=await r.post(Ae`/v2/c/rooms/${O}/attachments/presigned-urls`,await t.getAuthValue({roomId:O,resource:"comments",access:"read"}),{attachmentIds:re});return he.map(Ie=>Ie??new Error("There was an error while getting this attachment's URL"))},{delay:50});return $o(k)});function S(O){return T.getOrCreate(O)}function P(O){return S(O.roomId).batch.get(O.attachmentId)}async function L(O){return r.get(Ae`/v2/c/rooms/${O.roomId}/subscription-settings`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}),void 0,{signal:O.signal})}async function F(O){return r.post(Ae`/v2/c/rooms/${O.roomId}/subscription-settings`,await t.getAuthValue({roomId:O.roomId,resource:"comments",access:"read"}),O.settings)}const M=new Le(O=>new mr(async k=>{const ne=k.flat();return await r.post(Ae`/v2/c/rooms/${O}/inbox-notifications/read`,await t.getAuthValue({roomId:O,resource:"comments",access:"read"}),{inboxNotificationIds:ne}),ne},{delay:50}));async function N(O){return M.getOrCreate(O.roomId).get(O.inboxNotificationId)}async function _(O){if(O.mention.kind!=="user"&&O.mention.kind!=="group")return Je(O.mention,"Unexpected mention kind");await r.rawPost(Ae`/v2/c/rooms/${O.roomId}/text-mentions`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"write"}),{userId:O.mention.kind==="user"?O.mention.id:void 0,groupId:O.mention.kind==="group"?O.mention.id:void 0,userIds:O.mention.kind==="group"?O.mention.userIds:void 0,mentionId:O.mentionId})}async function I(O){await r.rawDelete(Ae`/v2/c/rooms/${O.roomId}/text-mentions/${O.mentionId}`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"write"}))}async function j(O){return r.rawGet(Ae`/v2/c/rooms/${O.roomId}/versions/${O.versionId}/storage`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}))}async function z(O){return r.rawGet(Ae`/v2/c/rooms/${O.roomId}/versions/${O.versionId}/yjs`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}))}async function Y(O){await r.rawPost(Ae`/v2/c/rooms/${O.roomId}/versions`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"write"}))}async function oe(O){await r.delete(Ae`/v2/c/rooms/${O.roomId}/versions/${O.versionId}`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"write"}))}async function G(O){await r.rawPost(Ae`/v2/c/rooms/${O.roomId}/text-metadata`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}),{type:O.type,rootKey:O.rootKey})}async function Z(O){const k=await r.post(Ae`/v2/c/rooms/${O.roomId}/ai/contextual-prompt`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}),{prompt:O.prompt,context:{beforeSelection:O.context.beforeSelection,selection:O.context.selection,afterSelection:O.context.afterSelection},previous:O.previous},{signal:O.signal});if(!k||k.content.length===0)throw new Error("No content returned from server");return k.content[0].text}async function le(O){const k=await r.get(Ae`/v2/c/rooms/${O.roomId}/versions`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}));return{versions:k.versions.map(({createdAt:ne,...re})=>({createdAt:new Date(ne),...re})),requestedAt:new Date(k.meta.requestedAt)}}async function de(O){const k=await r.get(Ae`/v2/c/rooms/${O.roomId}/versions/delta`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}),{since:O.since.toISOString()},{signal:O.signal});return{versions:k.versions.map(({createdAt:ne,...re})=>({createdAt:new Date(ne),...re})),requestedAt:new Date(k.meta.requestedAt)}}async function ue(O){return await(await r.rawGet(Ae`/v2/c/rooms/${O.roomId}/storage`,await t.getAuthValue({roomId:O.roomId,resource:"storage",access:"read"}))).json()}async function ee(O){let ne;O?.query&&(ne=Nr(O.query));const re=await r.get(Ae`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:O?.cursor,limit:50,query:ne}),he=re.groups.map(kl);return xe.setData(he.map(Ie=>[Ie.id,Ie])),{inboxNotifications:re.inboxNotifications.map(sr),threads:re.threads.map(_n),subscriptions:re.subscriptions.map(kn),nextCursor:re.meta.nextCursor,requestedAt:new Date(re.meta.requestedAt)}}async function te(O){let k;O?.query&&(k=Nr(O.query));const ne=await r.get(Ae`/v2/c/inbox-notifications/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:O.since.toISOString(),query:k},{signal:O.signal});return{inboxNotifications:{updated:ne.inboxNotifications.map(sr),deleted:ne.deletedInboxNotifications.map(pa)},threads:{updated:ne.threads.map(_n),deleted:ne.deletedThreads.map(ha)},subscriptions:{updated:ne.subscriptions.map(kn),deleted:ne.deletedSubscriptions.map(ma)},requestedAt:new Date(ne.meta.requestedAt)}}async function R(O){let k;O?.query&&(k=Nr(O.query));const{count:ne}=await r.get(Ae`/v2/c/inbox-notifications/count`,await t.getAuthValue({resource:"personal",access:"write"}),{query:k},{signal:O?.signal});return ne}async function q(){await r.post(Ae`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:"all"})}async function J(O){await r.post(Ae`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:O})}const X=new mr(async O=>{const k=O.flat();return await J(k),k},{delay:50});async function ie(O){await X.get(O)}async function ae(){await r.delete(Ae`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}))}async function we(O){await r.delete(Ae`/v2/c/inbox-notifications/${O}`,await t.getAuthValue({resource:"personal",access:"write"}))}async function Se(O){return r.get(Ae`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),void 0,{signal:O?.signal})}async function me(O){return r.post(Ae`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),O)}async function fe(O){let k;O?.query&&(k=Nr(O.query));const re=await r.get(Ae`/v2/c/threads`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:O?.cursor,query:k,limit:50});return{threads:re.threads.map(_n),inboxNotifications:re.inboxNotifications.map(sr),subscriptions:re.subscriptions.map(kn),nextCursor:re.meta.nextCursor,requestedAt:new Date(re.meta.requestedAt),permissionHints:re.meta.permissionHints}}async function ye(O){const k=await r.get(Ae`/v2/c/threads/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:O.since.toISOString()},{signal:O.signal});return{threads:{updated:k.threads.map(_n),deleted:k.deletedThreads.map(ha)},inboxNotifications:{updated:k.inboxNotifications.map(sr),deleted:k.deletedInboxNotifications.map(pa)},subscriptions:{updated:k.subscriptions.map(kn),deleted:k.deletedSubscriptions.map(ma)},requestedAt:new Date(k.meta.requestedAt),permissionHints:k.meta.permissionHints}}const be=new mr(async O=>{const k=O.flat(),{groups:ne}=await r.post(Ae`/v2/c/groups/find`,await t.getAuthValue({resource:"personal",access:"write"}),{groupIds:k}),re=new Map;for(const he of ne)re.set(he.id,kl(he));return k.map(he=>re.get(he))},{delay:50}),xe=$o(be);function ke(O){return be.get(O)}async function Me(O){const{metadata:k}=await r.get(Ae`/v2/c/urls/metadata`,await t.getAuthValue({resource:"personal",access:"write"}),{url:O});return k}return{getThreads:s,getThreadsSince:o,searchComments:i,createThread:a,getThread:c,deleteThread:u,editThreadMetadata:d,createComment:m,editComment:g,editCommentMetadata:l,deleteComment:v,addReaction:C,removeReaction:p,markThreadAsResolved:D,markThreadAsUnresolved:w,subscribeToThread:b,unsubscribeFromThread:y,markRoomInboxNotificationAsRead:N,getSubscriptionSettings:L,updateSubscriptionSettings:F,createTextMention:_,deleteTextMention:I,fetchStorageHistoryVersion:j,fetchYjsHistoryVersion:z,createVersionHistorySnapshot:Y,deleteHistoryVersion:oe,reportTextEditor:G,listHistoryVersions:le,listHistoryVersionsSince:de,getAttachmentUrl:P,uploadAttachment:A,getOrCreateAttachmentUrlsStore:S,streamStorage:ue,getInboxNotifications:ee,getInboxNotificationsSince:te,getUnreadInboxNotificationsCount:R,markAllInboxNotificationsAsRead:q,markInboxNotificationAsRead:ie,deleteAllInboxNotifications:ae,deleteInboxNotification:we,getNotificationSettings:Se,updateNotificationSettings:me,getUserThreads_experimental:fe,getUserThreadsSince_experimental:ye,groupsStore:xe,getGroup:ke,executeContextualPrompt:Z,getUrlMetadata:Me}}function tc(e){return e.type==="public"?e.publicApiKey:e.token.raw}var k1=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){e.startsWith("/v2/c/")||Ft("This client can only be used to make /v2/c/* requests");const o=F1(this.#e,e,r),s=await this.#t(o,{...n,headers:{"Content-Type":"application/json; charset=utf-8",...n?.headers,Authorization:`Bearer ${tc(t)}`,"X-LB-Client":Ti}}),i=s.headers.get("X-LB-Warn");if(i){const a=n?.method?.toUpperCase()??"GET",u=`${i} (${a} ${e})`;s.ok?ft(u):Jn(u)}return s}async#r(e,t,n,r){const o=await this.#n(e,t,n,r);if(!o.ok)throw await uo.fromResponse(o);let s;try{s=await o.json()}catch{s={}}return s}async rawGet(e,t,n,r){return await this.#n(e,t,r,n)}async rawPost(e,t,n){return await this.#n(e,t,{method:"POST",body:co(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:co(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)}},gr=Symbol("fsm.ignore");function N1(e,t){if(e===t)return[0,0];const n=e.split("."),r=t.split("."),o=Math.min(n.length,r.length);let s=0;for(;s<o&&n[s]===r[s];s++);const i=n.length-s,a=r.length-s;return[i,a]}function j1(e,t){const n=e.split(".");if(t<1||t>n.length+1)throw new Error("Invalid number of levels");const r=[];t>n.length&&r.push("*");for(let o=n.length-t+1;o<n.length;o++){const s=n.slice(0,o);s.length>0&&r.push(s.join(".")+".*")}return r.push(e),r}var L1=class{#e;constructor(e){this.#e=e}get current(){return this.#e}allowPatching(e){const t=this;let n=!0;const r={...this.#e,patch(o){if(n){t.#e=Object.assign({},t.#e,o);for(const s of Object.entries(o)){const[i,a]=s;i!=="patch"&&(this[i]=a)}}else throw new Error("Can no longer patch stale context")}};e(r),n=!1}},U1=1,Zh=class{id;#e;#t;#n;#r;#o;#s;events;#i;#u;#a;#l;get#f(){const e=this.#n.values()[Symbol.iterator]().next();if(e.done)throw new Error("No states defined yet");return e.value}get currentState(){if(this.#r===null)throw this.#e===0?new Error("Not started yet"):new Error("Already stopped");return this.#r}start(){if(this.#e!==0)throw new Error("State machine has already started");return this.#e=1,this.#r=this.#f,this.#p(null),this}stop(){if(this.#e!==1)throw new Error("Cannot stop a state machine that hasn't started yet");this.#h(null),this.#e=2,this.#r=null}constructor(e){this.id=U1++,this.#e=0,this.#r=null,this.#n=new Set,this.#a=new Map,this.#i=[],this.#u=[],this.#l=new Set,this.#o=new Map,this.#t=new L1(e),this.#s={didReceiveEvent:Ne(),willTransition:Ne(),didIgnoreUnexpectedEvent:Ne(),willExitState:Ne(),didEnterState:Ne(),didExitState:Ne()},this.events={didReceiveEvent:this.#s.didReceiveEvent.observable,willTransition:this.#s.willTransition.observable,didIgnoreUnexpectedEvent:this.#s.didIgnoreUnexpectedEvent.observable,willExitState:this.#s.willExitState.observable,didEnterState:this.#s.didEnterState.observable,didExitState:this.#s.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 s=new AbortController,i=s.signal,a=o?setTimeout(()=>{const c=new Error("Timed out");this.#d({type:"ASYNC_ERROR",reason:c},r)},o):void 0;let u=!1;return t(this.#t.current,i).then(c=>{i.aborted||(u=!0,this.#d({type:"ASYNC_OK",data:c},n))},c=>{i.aborted||(u=!0,this.#d({type:"ASYNC_ERROR",reason:c},r))}),()=>{clearTimeout(a),u||s.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,s]of Object.entries(t)){if(r.has(o))throw new Error(`Trying to set transition "${o}" on "${n}" (via "${e}"), but a transition already exists there.`);const i=s;if(this.#l.add(o),i!==void 0)if(i===gr)r.set(o,gr);else{const a=typeof i=="function"?i:()=>i;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)}#h(e){this.#s.willExitState.notify(this.currentState);const t=performance.now(),n=this.currentState.split(".");this.#t.allowPatching(r=>{e=e??this.#i.length;for(let o=0;o<e;o++){this.#i.pop()?.(r);const s=this.#u.pop();if(s!==void 0&&this.#s.didExitState.count()>0){const i=this.#u.length;if(i===0)continue;const a=i===n.length?this.currentState:`${n.slice(0,i).join(".")}.*`;this.#s.didExitState.notify({state:a,durationMs:t-s})}}})}#p(e){const t=j1(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)?.(r);typeof i=="function"?this.#i.push(i):this.#i.push(null),this.#u.push(n)}}),this.#s.didEnterState.notify(this.currentState)}send(e){if(!this.#l.has(e.type))throw new Error(`Invalid event ${JSON.stringify(e.type)}`);if(this.#e===2)return;const t=this.#g(e.type);if(t!==gr){if(t!==void 0)return this.#d(e,t);this.#s.didIgnoreUnexpectedEvent.notify(e)}}#d(e,t){this.#s.didReceiveEvent.notify(e);const n=this.currentState,o=(typeof t=="function"?t:()=>t)(e,this.#t.current);let s,i;if(o===gr)return;if(typeof o=="string"?s=o:(s=o.target,i=Array.isArray(o.effect)?o.effect:[o.effect]),!this.#n.has(s))throw new Error(`Invalid next state name: ${JSON.stringify(s)}`);this.#s.willTransition.notify({from:n,to:s});const[a,u]=N1(this.currentState,s);if(a>0&&this.#h(a),this.#r=s,i!==void 0){const c=i;this.#t.allowPatching(d=>{for(const l of c)typeof l=="function"?l(d,e):d.patch(l)})}u>0&&this.#p(u)}},Ee=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 $l(e){return e===4999||e>=4e3&&e<4100}function $1(e){return e>=4100&&e<4200}function Hl(e){return e===1013||e>=4200&&e<4300}function H1(e){return e==="initial"||e==="disconnected"}function Xh(e){const t=e.currentState;switch(t){case"@ok.connected":case"@ok.awaiting-pong":return"connected";case"@idle.initial":return"initial";case"@auth.busy":case"@auth.backoff":case"@connecting.busy":case"@connecting.backoff":case"@idle.zombie":return e.context.successCount>0?"reconnecting":"connecting";case"@idle.failed":return"disconnected";default:return Je(t,"Unknown state")}}var Qh=[250,500,1e3,2e3,4e3,8e3,1e4],Is=Qh[0]-1,V1=[2e3,3e4,6e4,3e5],W1=3e4,z1=2e3,K1=1e4,G1=2e4,xn=class extends Error{constructor(e){super(e)}};function ep(e,t){return t.find(n=>n>e)??t[t.length-1]}function jr(e){e.patch({backoffDelay:ep(e.backoffDelay,Qh)})}function Vl(e){e.patch({backoffDelay:ep(e.backoffDelay,V1)})}function Wl(e){e.patch({successCount:0})}function Kr(e,t){const n=e===2?Jn:e===1?ft:(()=>{});return()=>{n(t)}}function zl(e){const t="Connection to Liveblocks websocket server";return n=>{tp(e)?ft(`${t} closed prematurely (code: ${e.code}). Retrying in ${n.backoffDelay}ms.`):ft(`${t} could not be established.`,e)}}function ga(e){const t=[`code: ${e.code}`];return e.reason&&t.push(`reason: ${e.reason}`),n=>{ft(`Connection to Liveblocks websocket server closed (${t.join(", ")}). Retrying in ${n.backoffDelay}ms.`)}}var q1=Kr(1,"Connection to WebSocket closed permanently. Won't retry.");function tp(e){return!(e instanceof Error)&&e.type==="close"}function Y1(e){function t(...r){ft(`[FSM #${e.id}]`,...r)}const n=[e.events.didReceiveEvent.subscribe(r=>t(`Event ${r.type}`)),e.events.willTransition.subscribe(({from:r,to:o})=>t("Transitioning",r,"→",o)),e.events.didExitState.subscribe(({state:r,durationMs:o})=>t(`Exited ${r} after ${o.toFixed(0)}ms`)),e.events.didIgnoreUnexpectedEvent.subscribe(r=>t("Ignored unexpected event",r.type,r,"(no transition declared)"))];return()=>{for(const r of n)r()}}function J1(e){const t=Ne(),n=Ne(),r=Ne();let o=null;const s=e.events.didEnterState.subscribe(()=>{const i=Xh(e);i!==o&&t.notify(i),o==="connected"&&i!=="connected"?r.notify():o!=="connected"&&i==="connected"&&n.notify(),o=i});return{statusDidChange:t.observable,didConnect:n.observable,didDisconnect:r.observable,unsubscribe:s}}var Bs=e=>t=>t.patch(e);function Z1(e,t){const n=a1();n.pause();const r=Ne();function o(w,b){return()=>{r.notify({message:w,code:b})}}const s={successCount:0,authValue:null,socket:null,backoffDelay:Is},i=new Zh(s).addState("@idle.initial").addState("@idle.failed").addState("@idle.zombie").addState("@auth.busy").addState("@auth.backoff").addState("@connecting.busy").addState("@connecting.backoff").addState("@ok.connected").addState("@ok.awaiting-pong");i.addTransitions("*",{RECONNECT:{target:"@auth.backoff",effect:[jr,Wl]},DISCONNECT:"@idle.initial"}),i.onEnter("@idle.*",Wl).addTransitions("@idle.*",{CONNECT:(w,b)=>b.authValue!==null?"@connecting.busy":"@auth.busy"}),i.addTransitions("@auth.backoff",{NAVIGATOR_ONLINE:{target:"@auth.busy",effect:Bs({backoffDelay:Is})}}).addTimedTransition("@auth.backoff",w=>w.backoffDelay,"@auth.busy").onEnterAsync("@auth.busy",()=>Pl(e.authenticate(),K1,"Timed out during auth"),w=>({target:"@connecting.busy",effect:Bs({authValue:w.data})}),w=>w.reason instanceof xn?{target:"@idle.failed",effect:[Kr(2,w.reason.message),o(w.reason.message,-1)]}:{target:"@auth.backoff",effect:[jr,Kr(2,`Authentication failed: ${w.reason instanceof Error?w.reason.message:String(w.reason)}`)]});const a=w=>i.send({type:"EXPLICIT_SOCKET_ERROR",event:w}),u=w=>i.send({type:"EXPLICIT_SOCKET_CLOSE",event:w}),c=w=>{i.send({type:"ALIVE"}),w.data!=="pong"&&n.notify(w)};function d(w){w&&(w.removeEventListener("error",a),w.removeEventListener("close",u),w.removeEventListener("message",c),w.close())}i.addTransitions("@connecting.backoff",{NAVIGATOR_ONLINE:{target:"@connecting.busy",effect:Bs({backoffDelay:Is})}}).addTimedTransition("@connecting.backoff",w=>w.backoffDelay,"@connecting.busy").onEnterAsync("@connecting.busy",async(w,b)=>{const y=performance.now();let A=null,T=null,S=null;const P=new Promise((L,F)=>{if(w.authValue===null)throw new Error("No auth authValue");const M=e.createSocket(w.authValue);S=M;function N(z){T=z,M.removeEventListener("message",c),F(z)}const[_,I]=Kh();t.waitForActorId||I();function j(z){if(Sn(z.data)?.type===Ee.ROOM_STATE){if(t.enableDebugLogging&&A!==null){const oe=performance.now()-A;ft(`[FSM #${i.id}] Socket open → ROOM_STATE: ${oe.toFixed(0)}ms`)}I()}}M.addEventListener("message",c),t.waitForActorId&&M.addEventListener("message",j),M.addEventListener("error",N),M.addEventListener("close",N),M.addEventListener("open",()=>{if(A=performance.now(),t.enableDebugLogging){const Y=A-y;ft(`[FSM #${i.id}] Socket epoch → open: ${Y.toFixed(0)}ms`)}M.addEventListener("error",a),M.addEventListener("close",u);const z=()=>{M.removeEventListener("error",N),M.removeEventListener("close",N),M.removeEventListener("message",j)};_.then(()=>{L([M,z])})})});return Pl(P,G1,"Timed out during websocket connection").then(([L,F])=>{if(F(),b.aborted)throw new Error("Aborted");if(T)throw T;return L}).catch(L=>{throw d(S),L})},w=>({target:"@ok.connected",effect:Bs({socket:w.data,backoffDelay:Is})}),w=>{const b=w.reason;if(b instanceof xn)return{target:"@idle.failed",effect:[Kr(2,b.message),o(b.message,-1)]};if(tp(b)){if(b.code===4109)return"@auth.busy";if(Hl(b.code))return{target:"@connecting.backoff",effect:[Vl,zl(b)]};if($l(b.code))return{target:"@idle.failed",effect:[Kr(2,b.reason),o(b.reason,b.code)]}}return{target:"@auth.backoff",effect:[jr,zl(b)]}}).addTransitions("@connecting.busy",{ALIVE:gr});const l={target:"@ok.awaiting-pong",effect:w=>{w.socket?.send("ping")}},m=()=>(typeof document<"u"?document:void 0)?.visibilityState==="hidden"&&e.canZombie()?"@idle.zombie":l;if(i.addTimedTransition("@ok.connected",W1,m).addTransitions("@ok.connected",{NAVIGATOR_OFFLINE:m,WINDOW_GOT_FOCUS:l,ALIVE:gr}),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 y=>{d(y.socket),y.patch({socket:null}),clearTimeout(b),n.pause()}}).addTransitions("@ok.awaiting-pong",{ALIVE:"@ok.connected"}).addTimedTransition("@ok.awaiting-pong",z1,{target:"@connecting.busy",effect:Kr(1,"Received no pong from server, assume implicit connection loss.")}).addTransitions("@ok.*",{EXPLICIT_SOCKET_ERROR:(w,b)=>b.socket?.readyState===1?gr:{target:"@connecting.backoff",effect:jr},EXPLICIT_SOCKET_CLOSE:w=>$l(w.event.code)?{target:"@idle.failed",effect:[q1,o(w.event.reason,w.event.code)]}:$1(w.event.code)?w.event.code===4109?"@auth.busy":{target:"@auth.backoff",effect:[jr,ga(w.event)]}:Hl(w.event.code)?{target:"@connecting.backoff",effect:[Vl,ga(w.event)]}:{target:"@connecting.backoff",effect:[jr,ga(w.event)]}}),typeof document<"u"){const w=typeof document<"u"?document:void 0,b=typeof window<"u"?window:void 0,y=b??w;i.onEnter("*",A=>{function T(){i.send({type:"NAVIGATOR_OFFLINE"})}function S(){i.send({type:"NAVIGATOR_ONLINE"})}function P(){w?.visibilityState==="visible"&&i.send({type:"WINDOW_GOT_FOCUS"})}return b?.addEventListener("online",S),b?.addEventListener("offline",T),y?.addEventListener("visibilitychange",P),()=>{y?.removeEventListener("visibilitychange",P),b?.removeEventListener("online",S),b?.removeEventListener("offline",T),d(A.socket)}})}const g=[],{statusDidChange:v,didConnect:C,didDisconnect:p,unsubscribe:D}=J1(i);return g.push(D),t.enableDebugLogging&&g.push(Y1(i)),i.start(),{machine:i,cleanups:g,events:{statusDidChange:v,didConnect:C,didDisconnect:p,onMessage:n.observable,onConnectionError:r.observable}}}var np=class{#e;#t;events;constructor(e,t=!1,n=!0){const{machine:r,events:o,cleanups:s}=Z1(e,{waitForActorId:n,enableDebugLogging:t});this.#e=r,this.events=o,this.#t=s}getStatus(){try{return Xh(this.#e)}catch{return"initial"}}get authValue(){return this.#e.context.authValue}connect(){this.#e.send({type:"CONNECT"})}reconnect(){this.#e.send({type:"RECONNECT"})}disconnect(){this.#e.send({type:"DISCONNECT"})}destroy(){this.#e.stop();let e;for(;e=this.#t.pop();)e()}send(e){const t=this.#e.context?.socket;t===null?ft("Cannot send: not connected yet",e):t.readyState!==1?ft("Cannot send: WebSocket no longer open",e):t.send(e)}_privateSendMachineEvent(e){this.#e.send(e)}},Ce=Symbol(),Kl=Object.freeze({}),X1=Array.from(new Set("null")),Q1=Array.from(new Set("true")),eE=Array.from(new Set("false")),tE=Array.from(new Set("nulltruefalse"));function va(e,t){const n=e[e.length-1];return t.includes(n)?e.slice(0,-1):e}var nE=class{#e="";#t;#n=0;#r=!1;#o=-1;#s=-1;#i=[];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(!tE.includes(t))return"";if(X1.includes(t)){if(e.endsWith("nul"))return"l";if(e.endsWith("nu"))return"ll";if(e.endsWith("n"))return"ull"}if(Q1.includes(t)){if(e.endsWith("tru"))return"e";if(e.endsWith("tr"))return"ue";if(e.endsWith("t"))return"rue"}if(eE.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""}#l(){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.#s=this.#o,this.#o=-1):n==='"'?this.#o=r:n==="{"?this.#i.push("}"):n==="["?this.#i.push("]"):n==="}"&&this.#i.length>0&&this.#i[this.#i.length-1]==="}"?this.#i.pop():n==="]"&&this.#i.length>0&&this.#i[this.#i.length-1]==="]"&&this.#i.pop()}this.#n=this.#e.length}#f(){this.#l();let e=this.#e;if(e.charAt(0)!=="{")return Kl;if(e.endsWith("}")){const n=Sn(e);if(n)return n}this.#u&&(this.#r&&(e=e.slice(0,-1)),e+='"'),e=e.trimEnd(),e=va(e,",."),e=e+this.#a(e);const t=this.#i.reduceRight((n,r)=>n+r,"");{const n=Sn(e+t);if(n)return n}return this.#u?e=e.slice(0,this.#o):(e=va(e,":"),e.endsWith('"')&&(e=e.slice(0,this.#s))),e=va(e,","),e+=t,Sn(e)??Kl}};function rE(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function oE(e,t){if(!lt(e)||!lt(t))return!1;const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function at(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:rE(e,t):oE(e,t)}function Gr(e,t){if(!lt(e)||!lt(t))return at(e,t);const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&at(e[r],t[r]))}var sE=class{#e;#t;#n;#r;#o;#s;constructor(e,t,n){this.#r=e,this.#o=t,this.#s=n,this.#e=new Map,this.#t=new Le(()=>new Set),this.#n=zn.with(n)}get(e){return this.#e.get(e)}getOrThrow(e){return this.get(e)??Ft(`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=zn.from(this.getSiblings(e),this.#s);for(const o of r.iterReversed())this.#s(n,o)||(!t||t(o))&&(yield o)}*walkRight(e,t){const n=this.getOrThrow(e),r=zn.from(this.getSiblings(e),this.#s);for(const o of r)this.#s(o,n)||(!t||t(o))&&(yield o)}*walkDown(e,t){const n=zn.from(this.getChildren(e),this.#s).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 r=this.#o(t),o=this.#t.get(r);return o&&(o.delete(e),o.size===0&&this.#t.delete(r)),this.#n.remove(t),this.#t.delete(e),this.#e.delete(e),!0}clear(){return this.#e.size===0?!1:(this.#t.clear(),this.#e.clear(),this.#n.clear(),!0)}},iE=4e3,aE=class{#e;#t;#n;constructor(){this.#e=new Set,this.#t=new Le(()=>new Map),this.#n=void 0}registerLayer(e){const t=e;return this.#e.has(t)&&Ft(`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(E1))}updateKnowledge(e,t,n){this.#e.has(e)||Ft(`Unknown layer key: ${e}`),this.#t.getOrCreate(t).set(e,n),this.invalidate()}};function uE(){const e=new Le(r=>new aE);function t(r){return e.getOrCreate(r??Ho)}function n(r){const o=e.getOrCreate(Ho).get(),s=e.get(r)?.get()??[];return[...o,...s]}return{getKnowledgeStack:t,getKnowledgeForChat:n}}function Ca(){return new Date().toISOString()}var Ho=Symbol("*");function cE(){const e=new Le(i=>new Le(a=>new St(void 0))),t=new Le(i=>{const[a,u]=Sn(i);return je.from(()=>(u!==void 0?e.getOrCreate(u).getOrCreate(a):void 0)?.get()??e.getOrCreate(Ho).getOrCreate(a).get())});function n(i,a){const u=JSON.stringify(a!==void 0?[i,a]:[i]);return t.getOrCreate(u)}function r(i,a,u){if(!a.execute&&!a.render)throw new Error("A tool definition must have an execute() function, a render() function, or both.");const c=u??Ho;return e.getOrCreate(c).getOrCreate(i).set(a),()=>o(c,i)}function o(i,a){const u=e.get(i);if(u===void 0)return;const c=u.get(a);c!==void 0&&c.set(void 0)}function s(i){const a=e.get(Ho),u=e.get(i);return Array.from([...a?.entries()??[],...u?.entries()??[]]).flatMap(([c,d])=>{const l=d.get();return l&&(l.enabled??!0)?[{name:c,description:l.description,parameters:l.parameters}]:[]})}return{getToolDescriptions:s,getToolΣ:n,registerTool:r}}function lE(e,t){const n=new Set,r=new Set,o=new Le(y=>new xt(new sE(A=>A.id,A=>A.parentId,(A,T)=>A.createdAt<T.createdAt))),s=new xt(new Map);function i(y,A,T,S){const P=`ms_${it()}`,L=Ca();return d(A==="user"?{id:P,chatId:y,role:A,parentId:T,createdAt:L,content:S,_optimistic:!0}:{id:P,chatId:y,role:A,parentId:T,createdAt:L,status:"generating",contentSoFar:[],copilotId:S,_optimistic:!0}),P}function a(y){Ze(()=>{for(const A of y)d(A)})}function u(y,A){const T=o.get(y);if(!T)return;const S=T.get().get(A);!S||S.deletedAt||(S.role==="assistant"&&S.status!=="completed"?d({...S,deletedAt:Ca(),contentSoFar:[]}):d({...S,deletedAt:Ca(),content:[]}))}function c(y){const A=o.get(y);A!==void 0&&A.mutate(T=>T.clear())}function d(y){Ze(()=>{if(o.getOrCreate(y.chatId).mutate(T=>T.upsert(y)),y.role==="assistant"&&y.status==="generating"?s.mutate(T=>{T.set(y.id,structuredClone(y))}):s.mutate(T=>{T.delete(y.id)}),y.role==="assistant"&&y.status==="awaiting-tool"){if(n.has(y.id))for(const T of y.contentSoFar.filter(S=>S.type==="tool-invocation"&&S.stage==="executing")){if(!r.has(T.invocationId))r.add(T.invocationId);else continue;const S=e.getToolΣ(T.name,y.chatId).get()?.execute;S&&(async()=>{const P=await S(T.args,{name:T.name,invocationId:T.invocationId});return await t(y.chatId,y.id,T.invocationId,P??{data:{}},{copilotId:y.copilotId})})().catch(P=>{Jn(`Error trying to respond to tool-call: ${String(P)} (in execute())`)})}}else y.role==="assistant"&&y.status==="generating"||n.delete(y.id)})}function l(y,A){s.mutate(T=>{const S=T.get(y);return S===void 0?!1:(pE(S.contentSoFar,A),T.set(y,S),!0)})}function*m(){for(const y of o.values())for(const A of y.get())A.role==="assistant"&&A.status==="generating"&&!A._optimistic&&(yield A)}function g(){Ze(()=>{s.mutate(y=>{let A=!1;for(const[T,S]of y)S._optimistic||(y.delete(T),A=!0);return A}),a(Array.from(m()).map(y=>({...y,status:"failed",errorReason:"Lost connection"})))})}function v(y){for(const A of o.values()){const T=A.get().get(y);if(T)return T}}function C(y){const A=y.next();return A.done?void 0:A.value}function p(y,A){function T(F){if(!F.deletedAt)return!0;for(const M of y.walkDown(F.id,N=>!N.deletedAt))return!0;return!1}function S(F){const M=[];let N=null;for(const _ of y.walkUp(F.id)){const I=C(y.walkLeft(_.id,T))?.id??null,j=C(y.walkRight(_.id,T))?.id??null;if(!_.deletedAt||I||j){const z={..._,navigation:{parent:null,prev:I,next:j}};N!==null&&(N.navigation.parent=z.id),N=z,M.push(z)}}return M.reverse()}function P(){const F=y.sorted.findRight(M=>!M.deletedAt);return F?S(F):[]}if(A===null)return P();const L=y.get(A);if(!L)return P();for(const F of y.walkUp(L.id)){for(const M of y.walkDown(F.id,N=>!N.deletedAt))return S(M);if(!F.deletedAt)return S(F)}return P()}const D=new Le(y=>new Le(A=>{const T=je.from(()=>{const S=o.getOrCreate(y).get();return p(S,A)},Gr);return je.from(()=>{const S=s.get();return T.get().map(P=>{if(P.role!=="assistant"||P.status!=="generating")return P;const L=S.get(P.id);return L===void 0?P:{...P,contentSoFar:L.contentSoFar}})},at)}));function w(y,A){return D.getOrCreate(y).getOrCreate(A||null)}function b(y){return o.getOrCreate(y).get().sorted.findRight(S=>S.role==="assistant"&&!S.deletedAt)?.copilotId}return{getMessageById:v,getChatMessagesForBranchΣ:w,getLastUsedCopilotId:b,createOptimistically:i,upsert:d,upsertMany:a,remove:u,removeByChatId:c,addDelta:l,failAllPending:g,markMine(y){n.add(y)},*getAutoExecutingMessageIds(){for(const y of n){const A=v(y);A?.role==="assistant"&&A.status==="awaiting-tool"&&A.contentSoFar.some(S=>S.type==="tool-invocation"&&S.stage==="executing"?typeof e.getToolΣ(S.name,A.chatId).get()?.execute=="function":!1)&&(yield A.id)}}}}function dE(){const e=new m1;function t(i){Ze(()=>{for(const a of i)e.upsert(a)})}function n(i){e.upsert(i)}function r(i){e.markDeleted(i)}function o(i){return e.getEvenIfDeleted(i)}function s(i){return e.signal.get().findMany(i)}return{getChatById:o,findMany:s,upsert:n,upsertMany:t,markDeleted:r}}function fE(e){const t=new np(e.delegates,e.enableDebugLogging,!1),n=dE(),r=cE(),o=uE(),s=lE(r,F),i={staticSessionInfoSig:new St(null),dynamicSessionInfoSig:new St(null),pendingCmds:new Map,chatsStore:n,messagesStore:s,toolsStore:r,knowledgeStore:o},a=new St("initial"),u=25;let c=[],d=null;function l(){const _=c;c=[],d!==null&&(clearTimeout(d),d=null),Ze(()=>{for(const{id:I,delta:j}of _)i.messagesStore.addDelta(I,j)})}function m(_,I){c.push({id:_,delta:I}),d===null&&(d=setTimeout(l,u))}let g;function v(_){const I=t.authValue;if(I!==null){const j=tc(I);if(j!==g)if(g=j,I.type==="secret"){const z=I.token.parsed;i.staticSessionInfoSig.set({userId:z.uid,userInfo:z.ui})}else i.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}a.set(_)}let C;function p(_){_==="reconnecting"?C=setTimeout(()=>{},e.lostConnectionTimeout):clearTimeout(C)}function D(){}function w(){l()}function b(_){if(typeof _.data!="string")return;const I=Sn(_.data);if(!I)return;const j="cmdId"in I?I.cmdId:I.event==="cmd-failed"?I.failedCmdId:void 0,z=i.pendingCmds.get(j);if(j&&!z){ft("Ignoring unexpected command response. Already timed out, or not for us?",I);return}if("event"in I)if(I.event==="delta"){const{id:Y,delta:oe}=I;m(Y,oe)}else Ze(()=>{switch(l(),I.event){case"cmd-failed":z?.reject(new Error(I.error));break;case"settle":{i.messagesStore.upsert(I.message);break}case"warning":ft(I.message);break;case"error":Jn(I.error);break;case"rebooted":i.messagesStore.failAllPending();break;case"sync":for(const Y of I["-messages"]??[])i.messagesStore.remove(Y.chatId,Y.id);for(const Y of I["-chats"]??[])i.chatsStore.markDeleted(Y),i.messagesStore.removeByChatId(Y);for(const Y of I.clear??[])i.messagesStore.removeByChatId(Y);I.chats&&i.chatsStore.upsertMany(I.chats),I.messages&&i.messagesStore.upsertMany(I.messages);break;default:return Je(I,"Unhandled case")}});else switch(I.cmd){case"get-chats":i.chatsStore.upsertMany(I.chats);break;case"get-or-create-chat":i.chatsStore.upsert(I.chat);break;case"delete-chat":i.chatsStore.markDeleted(I.chatId),i.messagesStore.removeByChatId(I.chatId);break;case"get-message-tree":i.chatsStore.upsert(I.chat),i.messagesStore.upsertMany(I.messages);break;case"delete-message":i.messagesStore.remove(I.chatId,I.messageId);break;case"clear-chat":i.messagesStore.removeByChatId(I.chatId);break;case"ask-in-chat":I.sourceMessage&&i.messagesStore.upsert(I.sourceMessage),i.messagesStore.upsert(I.targetMessage);break;case"abort-ai":break;case"set-tool-result":I.ok&&i.messagesStore.upsert(I.message);break;default:return Je(I,"Unhandled case")}z?.resolve(I)}t.events.onMessage.subscribe(b),t.events.statusDidChange.subscribe(v),t.events.statusDidChange.subscribe(p),t.events.didConnect.subscribe(D),t.events.didDisconnect.subscribe(w),t.events.onConnectionError.subscribe(({message:_,code:I})=>{});function y(){t.getStatus()==="initial"&&t.connect()}async function A(_){y(),t.getStatus()!=="connected"&&await t.events.didConnect.waitUntil();const{promise:I,resolve:j,reject:z}=Jr(),Y=AbortSignal.timeout(iE);Y.addEventListener("abort",()=>z(Y.reason),{once:!0});const oe=it(7);return i.pendingCmds.set(oe,{resolve:j,reject:z}),T({..._,cmdId:oe}),I.finally(()=>{i.pendingCmds.delete(oe)}).catch(G=>{throw Jn(G.message),G})}function T(_){t.send(JSON.stringify({..._}))}function S(_={}){return A({cmd:"get-chats",cursor:_.cursor,query:_.query})}function P(_,I){return A({cmd:"get-or-create-chat",id:_,options:I})}function L(_){return A({cmd:"get-message-tree",chatId:_})}async function F(_,I,j,z,Y){const oe=i.knowledgeStore.getKnowledgeForChat(_),G=i.toolsStore.getToolDescriptions(_),Z=await A({cmd:"set-tool-result",chatId:_,messageId:I,invocationId:j,result:z,generationOptions:{copilotId:Y?.copilotId,stream:Y?.stream,timeout:Y?.timeout,knowledge:oe.length>0?oe:void 0,tools:G.length>0?G:void 0}});Z.ok&&s.markMine(Z.message.id)}function M(){for(const _ of i.messagesStore.getAutoExecutingMessageIds())A({cmd:"abort-ai",messageId:_}).catch(()=>{})}return(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",M,{once:!0}),Object.defineProperty({[Ce]:{context:i},connectInitially:y,disconnect:()=>t.disconnect(),getChats:S,getOrCreateChat:P,deleteChat:_=>A({cmd:"delete-chat",chatId:_}),getMessageTree:L,deleteMessage:(_,I)=>A({cmd:"delete-message",chatId:_,messageId:I}),clearChat:_=>A({cmd:"clear-chat",chatId:_}),askUserMessageInChat:async(_,I,j,z)=>{const Y=i.knowledgeStore.getKnowledgeForChat(_),oe=z?.knowledge||[],G=[...Y,...oe],Z=i.toolsStore.getToolDescriptions(_);return s.markMine(j),await A({cmd:"ask-in-chat",chatId:_,sourceMessage:I,targetMessageId:j,generationOptions:{copilotId:z?.copilotId,stream:z?.stream,timeout:z?.timeout,knowledge:G.length>0?G:void 0,tools:Z.length>0?Z:void 0}})},abort:_=>A({cmd:"abort-ai",messageId:_}),setToolResult:F,getStatus:()=>t.getStatus(),signals:{getChatMessagesForBranchΣ:i.messagesStore.getChatMessagesForBranchΣ,getToolΣ:i.toolsStore.getToolΣ,statusΣ:a},getChatById:i.chatsStore.getChatById,queryChats:i.chatsStore.findMany,getLastUsedCopilotId:i.messagesStore.getLastUsedCopilotId,registerKnowledgeLayer:(_,I)=>{const j=i.knowledgeStore.getKnowledgeStack(I),z=j.registerLayer(_);return{layerKey:z,deregister:()=>j.deregisterLayer(z)}},updateKnowledge:(_,I,j,z)=>{i.knowledgeStore.getKnowledgeStack(z).updateKnowledge(_,j??it(),I)},registerTool:i.toolsStore.registerTool},Ce,{enumerable:!1})}function hE(e,t){return n=>{const r=t??(typeof WebSocket>"u"?void 0:WebSocket);if(r===void 0)throw new xn("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")o.searchParams.set("tok",n.token.raw);else{if(n.type==="public")throw new Error("Public key not supported with AI Copilots");return Je(n,"Unhandled case")}return o.searchParams.set("version",Ti),new r(o.toString())}}function Gl(e,t,n,r){const o=Lh(e,s=>s.type===t.type&&n(s)===n(t));o>-1?e[o]=t:(uu(e[e.length-1],r),e.push(t))}function uu(e,t){e?.type==="reasoning"&&(e.endedAt??=t)}function pE(e,t){if(t===null)return;const n=e.filter(i=>i.type!=="sources"),r=e.filter(i=>i.type==="sources").flatMap(i=>i.sources),o=new Date().toISOString(),s=n[n.length-1];switch(t.type){case"text-delta":s?.type==="text"?s.text+=t.textDelta:(uu(s,o),n.push({type:"text",text:t.textDelta}));break;case"reasoning-delta":s?.type==="reasoning"?s.text+=t.textDelta:(uu(s,o),n.push({type:"reasoning",text:t.textDelta,startedAt:o}));break;case"tool-stream":{const i=mE(t.invocationId,t.name);n.push(i);break}case"tool-delta":{s?.type==="tool-invocation"&&s.stage==="receiving"&&s.__appendDelta?.(t.delta);break}case"tool-invocation":Gl(n,t,i=>i.invocationId,o);break;case"retrieval":Gl(n,t,i=>i.id,o);break;case"source":{r.push(t);break}default:return Je(t,"Unhandled case")}r.length>0&&n.push({type:"sources",sources:r}),e.length=0,e.push(...n)}function mE(e,t,n=""){const r=new nE(n);return{type:"tool-invocation",stage:"receiving",invocationId:e,name:t,get partialArgsText(){return r.source},get partialArgs(){return r.json},__appendDelta(o){r.append(o)}}}var Qe={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"},gE=["none","read","write"],hr={none:0,read:1,write:2},vE={room:{read:[Qe.Read,Qe.RoomRead],write:[Qe.Write,Qe.RoomWrite]},storage:{write:[Qe.StorageWrite],read:[Qe.StorageRead],none:[Qe.StorageNone]},comments:{write:[Qe.CommentsWrite],read:[Qe.CommentsRead],none:[Qe.CommentsNone]},"comments:public":{write:[Qe.CommentsPublicWrite],read:[Qe.CommentsPublicRead],none:[Qe.CommentsPublicNone]},"comments:private":{write:[Qe.CommentsPrivateWrite],read:[Qe.CommentsPrivateRead],none:[Qe.CommentsPrivateNone]},feeds:{write:[Qe.FeedsWrite],read:[Qe.FeedsRead],none:[Qe.FeedsNone]}},CE={room:"none",storage:"none",comments:"none","comments:public":"none","comments:private":"none",feeds:"none",personal:"none"},EE="room",rp=["storage","comments","comments:public","comments:private","feeds"],yE=new Set(Object.values(Qe));function bE(e){return yE.has(e)}function ql(e,t){const n=vE[t];let r;for(const o of gE){const s=n[o];s!==void 0&&s.some(i=>e.includes(i))&&(r=o)}return r}function op(e){const t={},n=ql(e,EE);n!==void 0&&(t.room=n);for(const r of rp){const o=ql(e,r);o!==void 0&&(t[r]=o)}return t}function sp(e){const t=e.room;if(t===void 0)return{...CE};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 nc(e){return sp(op(e))}function Yn(e,t,n){const r=hr[n];if(t==="comments")return Math.max(hr[e.comments??"none"],hr[e["comments:public"]??"none"],hr[e["comments:private"]??"none"])>=r;const o=e[t]??"none";return hr[o]>=r}function wE(e,t){const n=e.filter(s=>AE(s.pattern,t));if(n.length===0)return;const r={},o={};for(const s of n){const i=op(s.scopes),a=SE(s.pattern);i.room!==void 0&&(r.room=Yl(r.room??"none",i.room));for(const u of rp){const c=DE(i,u);if(c===void 0)continue;const d=o[u]??-1;a>d?(r[u]=c,o[u]=a):a===d&&(r[u]=Yl(r[u]??"none",c))}}return sp(r)}function rc(e){if(!Array.isArray(e))throw new Error("Permission list must be an array");const t=[];for(const n of e){if(!bE(n))throw new Error(`Not a valid permission: ${n}`);t.push(n)}return t}function DE(e,t){return e[t]??(xE(t)?e.comments:void 0)}function Yl(e,t){return hr[t]>hr[e]?t:e}function AE(e,t){return e.includes("*")?t.startsWith(e.replace("*","")):e===t}function SE(e){return e.replace("*","").length}function xE(e){return e.startsWith("comments:")}function OE(e){return lt(e)&&(e.k==="acc"||e.k==="id")}function Jl(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=Sn(l1(t[1]));if(!(n&&OE(n)))throw new Error("Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback");return{raw:e,parsed:n}}var TE=[400,401,403,404,405,410,412,414,422,431,451];function RE(e,t){const n=PE(e),r=new Set,o=[],s=new Map;function i(){r.clear(),o.length=0,s.clear()}function a(d){const l=Math.ceil(Date.now()/1e3);for(let m=o.length-1;m>=0;m--){const g=o[m];if(g.expiresAt<=l){o.splice(m,1);continue}if(FE(g,d))return g.token}}async function u(d){const l=e.polyfills?.fetch??(typeof window>"u"?void 0:window.fetch);if(n.type==="private"){if(l===void 0)throw new xn("To use Liveblocks client in a non-DOM environment with a url as auth endpoint, you need to provide a fetch polyfill.");const m=await ME(l,n.url,{room:d.roomId}),g=Jl(m.token);if(r.has(g.raw)){const v=a(d);if(v?.raw===g.raw)return v;throw new xn("The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported.")}return t?.(g.parsed),g}if(n.type==="custom"){const m=await n.callback(d.roomId);if(m&&typeof m=="object"){if(typeof m.token=="string"){const g=Jl(m.token);return t?.(g.parsed),g}else if(typeof m.error=="string"){const g=`Authentication failed: ${"reason"in m&&typeof m.reason=="string"?m.reason:"Forbidden"}`;throw m.error==="forbidden"?new xn(g):new Error(g)}}throw new Error('Your authentication callback function should return a token, but it did not. Hint: the return value should look like: { token: "..." }')}throw new Error("Unexpected authentication type. Must be private or custom.")}async function c(d){if(n.type==="public")return{type:"public",publicApiKey:n.publicApiKey};const l=a(d);if(l!==void 0)return{type:"secret",token:l};let m;const g=IE(d);g!==void 0?(m=s.get(g),m===void 0&&(m=u(d),s.set(g,m))):(m=s.get("liveblocks-user-token"),m===void 0&&(m=u(d),s.set("liveblocks-user-token",m)));try{const v=await m,p=Math.floor(Date.now()/1e3)+(v.parsed.exp-v.parsed.iat)-30;r.add(v.raw);const D=BE(v,p);return o.push(D),{type:"secret",token:v}}finally{g!==void 0?s.delete(g):s.delete("liveblocks-user-token")}}return{reset:i,getAuthValue:c}}function IE(e){if(e.roomId!==void 0)return`${e.roomId}:${e.resource}:${e.access}`}function BE(e,t){return e.parsed.k==="acc"?{token:e,expiresAt:t,permissions:Object.entries(e.parsed.perms).map(([n,r])=>({pattern:n,scopes:rc(r)}))}:{token:e,expiresAt:t}}function FE(e,t){if(e.token.parsed.k==="id"||t.resource==="personal")return!0;if(t.roomId===void 0)return!1;const n=wE(e.permissions??[],t.roomId);return n===void 0?!1:Yn(n,t.resource,t.access)}function PE(e){const{publicApiKey:t,authEndpoint:n}=e;if(n!==void 0&&t!==void 0)throw new Error("You cannot simultaneously use `publicApiKey` and `authEndpoint` options. Please pick one and leave the other option unspecified. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient");if(typeof t=="string"){if(t.startsWith("sk_"))throw new Error("Invalid `publicApiKey` option. The value you passed is a secret key, which should not be used from the client. Please only ever pass a public key here. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");if(!t.startsWith("pk_"))throw new Error("Invalid key. Please use the public key format: pk_<public key>. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:t}}if(typeof n=="string")return{type:"private",url:n};if(typeof n=="function")return{type:"custom",callback:n};throw n!==void 0?new Error("The `authEndpoint` option must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"):new Error("Invalid Liveblocks client options. Please provide either a `publicApiKey` or `authEndpoint` option. They cannot both be empty. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient")}async function ME(e,t,n){const r=await e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:co(n)});if(!r.ok){const i=`${(await r.text()).trim()||"reason not provided in auth response"} (${r.status} returned by POST ${t})`;throw TE.includes(r.status)?new xn(`Unauthorized: ${i}`):new Error(`Failed to authenticate: ${i}`)}let o;try{o=await r.json()}catch(i){throw new Error(`Expected a JSON response when doing a POST request on "${t}". ${String(i)}`)}if(!lt(o)||typeof o.token!="string")throw new Error(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${co(o)}`);const{token:s}=o;return{token:s}}var _E="https://api.liveblocks.io",mn="@",ve=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});function kE(e){return e.type===ve.DELETE_CRDT&&e.id==="ACK"}function Zl(e){return e.type===ve.CREATE_OBJECT||e.type===ve.CREATE_REGISTER||e.type===ve.CREATE_MAP||e.type===ve.CREATE_LIST}var qe=Object.freeze({OBJECT:0,LIST:1,MAP:2,REGISTER:3});function NE(e){return e[0]==="root"}function ip(e){return e[1].type===qe.OBJECT}function ap(e){return e[1].type===qe.LIST}function up(e){return e[1].type===qe.MAP}function cp(e){return e[1].type===qe.REGISTER}function jE(e){return e[0]==="root"}function*LE(e){for(const t of e){if(jE(t)){yield[t[0],{type:qe.OBJECT,data:t[1]}];continue}switch(t[1]){case qe.OBJECT:yield[t[0],{type:qe.OBJECT,parentId:t[2],parentKey:t[3],data:t[4]}];break;case qe.LIST:yield[t[0],{type:qe.LIST,parentId:t[2],parentKey:t[3]}];break;case qe.MAP:yield[t[0],{type:qe.MAP,parentId:t[2],parentKey:t[3]}];break;case qe.REGISTER:yield[t[0],{type:qe.REGISTER,parentId:t[2],parentKey:t[3],data:t[4]}];break}}}var yt=32,Xn=126,lp=Xn-yt+1,Ri=oc(0),Qr=oc(1),UE=Ri+oc(-1);function oc(e){const t=yt+(e<0?lp+e:e);if(t<yt||t>Xn)throw new Error(`Invalid n value: ${e}`);return String.fromCharCode(t)}function sn(e,t){return e!==void 0&&t!==void 0?VE(e,t):e!==void 0?HE(e):t!==void 0?$E(t):Qr}function $E(e){const t=e.length-1;for(let n=0;n<=t;n++){const r=e.charCodeAt(n);if(!(r<=yt))return n===t?r===yt+1?e.substring(0,n)+UE:e.substring(0,n)+String.fromCharCode(r-1):e.substring(0,n+1)}return Qr}var Fs=2,Ea=3;function HE(e){for(let o=0;o<e.length;o++){const s=e.charCodeAt(o);if(s<yt||s>Xn)return e+Qr}for(;e.length>1&&e.charCodeAt(e.length-1)===yt;)e=e.slice(0,-1);if(e.length===0||e===Ri)return Qr;let t=Fs;e.length>Fs&&(t=Fs+Math.ceil((e.length-Fs)/Ea)*Ea);const n=Xl(e,t);if(n!==null)return n;t+=Ea;const r=Xl(e,t);return r!==null?r:e+Qr}function Xl(e,t){const n=[];for(let s=0;s<t;s++)s<e.length?n.push(e.charCodeAt(s)-yt):n.push(0);let r=1;for(let s=t-1;s>=0&&r;s--){const i=n[s]+r;i>=lp?(n[s]=0,r=1):(n[s]=i,r=0)}if(r)return null;let o="";for(const s of n)o+=String.fromCharCode(s+yt);for(;o.length>1&&o.charCodeAt(o.length-1)===yt;)o=o.slice(0,-1);return o}function VE(e,t){if(e<t)return cu(e,t);if(e>t)return cu(t,e);throw new Error("Cannot compute value between two equal positions")}function cu(e,t){let n=0;const r=e.length,o=t.length;for(;;){const s=n<r?e.charCodeAt(n):yt,i=n<o?t.charCodeAt(n):Xn;if(s===i){n++;continue}if(i-s===1){const a=n+1;let u=e.substring(0,a);u.length<a&&(u+=Ri.repeat(a-u.length));const c=e.substring(a);return u+cu(c,"")}else return WE(e,n)+String.fromCharCode(i+s>>1)}}function WE(e,t){return t<e.length?e.substring(0,t):e+Ri.repeat(t-e.length)}var zE=yt+1;function KE(e){if(e==="")return!1;const t=e.length-1,n=e.charCodeAt(t);if(n<zE||n>Xn)return!1;for(let r=0;r<t;r++){const o=e.charCodeAt(r);if(o<yt||o>Xn)return!1}return!0}function GE(e){const t=[];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t.push(r<yt?yt:r>Xn?Xn:r)}for(;t.length>0&&t[t.length-1]===yt;)t.length--;return t.length>0?String.fromCharCode(...t):Qr}function Yo(e){return KE(e)?e:GE(e)}var dp=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}add(e){if(this.#e.set(e.opId,e),Zl(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),Zl(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)}};function fp(e){const{getCurrentConnectionId:t,onDispatch:n,isStorageWritable:r=()=>!0,unacknowledgedOps:o=new dp}=e;let s=0,i=0;const a=new Map;return{nodes:a,getNode:u=>a.get(u),addNode:(u,c)=>{a.set(u,c)},deleteNode:u=>{a.delete(u)},generateId:()=>`${t()}:${s++}`,generateOpId:()=>`${t()}:${i++}`,dispatch(u,c,d){n?.(u,c,d)},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 Ql(e,t,n=Yo(t)){return Object.freeze({type:"HasParent",node:e,key:t,pos:n})}var ed=Object.freeze({type:"NoParent"});function qE(e,t=Yo(e)){return Object.freeze({type:"Orphaned",oldKey:e,oldPos:t})}var Ii=class{#e;#t;#n=ed;_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 Je(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 Je(this.parent,"Unknown state")}}get _pool(){return this.#e}get _id(){return this.#t}get parent(){return this.#n}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return Je(this.parent,"Unknown state")}}_apply(e,t){return e.type===ve.DELETE_CRDT?this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}:{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this.#n=Ql(e,t);return;case"Orphaned":case"NoParent":{this.#n=Ql(e,t);return}default:return Je(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=qE(this.parent.key,this.parent.pos);break}case"NoParent":{this.#n=ed;break}case"Orphaned":break;default:Je(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;#s;invalidate(){(this.#r!==void 0||this.#s!==void 0)&&(this.#r=void 0,this.#s=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toTreeNode(e){return(this.#s===void 0||this.#o!==e)&&(this.#o=e,this.#s=this._toTreeNode(e)),this.#s}hasCache(e){return this.#r!==void 0&&this.#r===e}toJSON(){return this.#r===void 0&&(this.#r=this._toJSON()),this.#r}},Bn=class hp extends Ii{#e;constructor(t){super(),this.#e=t}get data(){return this.#e}static _deserialize([t,n],r,o){const s=new hp(n.data);return s._attach(t,o),s}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:ve.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:qe.REGISTER,parentId:ge(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??it(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return ao(this.data)}};function YE(e,t){return e._parentPos<t._parentPos}var nr=class lu extends Ii{#e;#t;constructor(t){super(),this.#t=new WeakSet;const n=[];let r;for(const o of t){const s=sn(r),i=eo(o);i._setParentLink(this,s),n.push(i),r=s}this.#e=zn.fromAlreadySorted(n,YE)}static _deserialize([t,n],r,o){const s=new lu([]);s._attach(t,o);const i=r.get(t);if(i===void 0)return s;for(const a of i){const u=a[1],c=vp(a,r,o);c._setParentLink(s,u.parentKey),s.#n(c)}return s}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ve.CREATE_LIST,parentId:t,parentKey:n};r.push(o);for(const s of this.#e){const i=s._getParentKeyOrThrow(),a=Ro(s._toOps(this._id,i),"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=ge(this.#e.at(t));this.#r(r,n)}_indexOfPosition(t){return this.#e.findIndex(n=>n._getParentKeyOrThrow()===t)}#s(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()}#i(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=_o(t);o._attach(n,this._pool),o._setParentLink(this,r);const s=t.deletedId,i=this._indexOfPosition(r);if(i!==-1){const a=ge(this.#e.removeAt(i));if(a._id===s)return a._detach(),this.#e.add(o),{modified:$e(this,[Lr(i,o)]),reverse:[]};{this.#t.add(a),this.#e.remove(a),this.#e.add(o);const u=[Lr(i,o)],c=this.#a(t.deletedId);return c&&u.push(c),{modified:$e(this,u),reverse:[]}}}else{const a=[],u=this.#a(t.deletedId);return u&&a.push(u),this.#n(o),a.push(Yt(this._indexOfPosition(r),o)),{reverse:[],modified:$e(this,a)}}}#u(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=[],r=this.#a(t.deletedId);r&&n.push(r);const o=this.#s(t.parentKey);if(o!==void 0&&o!==t.opId)return n.length===0?{modified:!1}:{modified:$e(this,n),reverse:[]};const s=this._indexOfPosition(t.parentKey),i=this.#e.find(a=>a._id===t.id);if(i!==void 0){if(i._parentKey===t.parentKey)return{modified:n.length>0?$e(this,n):!1,reverse:[]};if(s!==-1){const c=ge(this.#e.removeAt(s));this.#t.add(c),n.push(Ps(s,c))}const a=this.#e.findIndex(c=>c===i);this.#r(i,t.parentKey);const u=this.#e.findIndex(c=>c===i);return u!==a&&n.push(Nn(a,u,i)),{modified:n.length>0?$e(this,n):!1,reverse:[]}}else{const a=this._pool.getNode(t.id);if(a&&this.#t.has(a)){a._setParentLink(this,t.parentKey),this.#t.delete(a);const u=this.#n(a);return{modified:$e(this,[s===-1?Yt(u,a):Lr(u,a),...n]),reverse:[]}}else{if(s!==-1){const d=ge(this.#e.removeAt(s));this.#t.add(d)}const{newItem:u,newIndex:c}=this.#v(t,t.parentKey);return{modified:$e(this,[s===-1?Yt(c,u):Lr(c,u),...n]),reverse:[]}}}}#a(t){if(t===void 0||this._pool===void 0)return null;const n=this._pool.getNode(t);if(n===void 0)return null;const r=this._detachChild(n);return r.modified===!1?null:r.modified.updates[0]}#l(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=Yo(t.parentKey),r=this._indexOfPosition(n);r!==-1&&this.#C(r,n);const{newItem:o,newIndex:s}=this.#v(t,n),i=this.#m(n);return{modified:$e(this,[Yt(s,o),...i]),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;for(const i of n){const a=i._parentPos;(r===void 0||a<r)&&(r=a)}if(t<ge(r))return[];let o;for(const i of this.#e)n.has(i)||(o=i._parentPos);const s=[];for(const i of n){const a=this.#e.findIndex(c=>c===i);o=sn(o),this.#r(i,o);const u=this.#e.findIndex(c=>c===i);u!==a&&s.push(Nn(a,u,i))}return s}#g(t){const n=this.#e.find(s=>s._id===t.id),r=Yo(t.parentKey),o=this._indexOfPosition(r);if(n){if(n._parentKey===r)return{modified:!1};{const s=this.#e.findIndex(a=>a===n);o!==-1&&this.#C(o,r),this.#r(n,r);const i=this._indexOfPosition(r);return i===s?{modified:!1}:{modified:$e(this,[Nn(s,i,n)]),reverse:[]}}}else{const s=ge(this._pool).getNode(t.id);if(s&&this.#t.has(s)){s._setParentLink(this,r),this.#t.delete(s),this.#n(s);const i=this._indexOfPosition(r);return{modified:$e(this,[Yt(i,s)]),reverse:[]}}else{o!==-1&&this.#C(o,r);const{newItem:i,newIndex:a}=this.#v(t,r);return{modified:$e(this,[Yt(a,i)]),reverse:[]}}}}#h(t){const{id:n,parentKey:r}=t,o=_o(t);if(this._pool?.getNode(n)!==void 0)return{modified:!1};o._attach(n,ge(this._pool)),o._setParentLink(this,r);const s=this._indexOfPosition(r);let i=r;if(s!==-1){const u=this.#e.at(s)?._parentPos,c=this.#e.at(s+1)?._parentPos;i=sn(u,c),o._setParentLink(this,i)}this.#n(o);const a=this._indexOfPosition(i);return{modified:$e(this,[Yt(a,o)]),reverse:[{type:ve.DELETE_CRDT,id:n}]}}#p(t){const{id:n,parentKey:r}=t,o=_o(t);if(this._pool?.getNode(n)!==void 0)return{modified:!1};const s=this._indexOfPosition(r);o._attach(n,ge(this._pool)),o._setParentLink(this,r);const i=r;if(s!==-1){const a=this.#e.at(s);a._detach(),this.#e.remove(a),this.#e.add(o);const u=Ro(a._toOps(ge(this._id),r),"set",t.id),c=[Lr(s,o)],d=this.#a(t.deletedId);return d&&c.push(d),{modified:$e(this,c),reverse:u}}else{this.#n(o),this.#a(t.deletedId);const a=this._indexOfPosition(i);return{reverse:[{type:ve.DELETE_CRDT,id:n}],modified:$e(this,[Yt(a,o)])}}}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let r;return t.intent==="set"?n===1?r=this.#i(t):n===2?r=this.#u(t):r=this.#p(t):n===1?r=this.#l(t):n===2?r=this.#g(t):r=this.#h(t),r.modified!==!1&&this.invalidate(),r}_detachChild(t){if(t){const n=ge(t._parentKey),r=t._toOps(ge(this._id),n),o=this.#e.findIndex(i=>i===t);if(o===-1)return{modified:!1};const s=this.#e.at(o);return this.#e.remove(t),this.invalidate(),t._detach(),{modified:$e(this,[Ps(o,s)]),reverse:r}}return{modified:!1}}#d(t,n){if(this.#t.has(n)){this.#t.delete(n),n._setParentLink(this,t);const s=this.#n(n);return{modified:$e(this,[Yt(s,n)]),reverse:[]}}const r=n._parentKey;if(t===r)return{modified:!1};const o=this._indexOfPosition(t);if(o===-1){const s=this.#e.findIndex(a=>a===n);this.#r(n,t);const i=this.#e.findIndex(a=>a===n);return i===s?{modified:!1}:{modified:$e(this,[Nn(s,i,n)]),reverse:[]}}else{this.#o(o,sn(t,this.#e.at(o+1)?._parentPos));const s=this.#e.findIndex(a=>a===n);this.#r(n,t);const i=this.#e.findIndex(a=>a===n);return i===s?{modified:!1}:{modified:$e(this,[Nn(s,i,n)]),reverse:[]}}}#y(t,n){const r=ge(n._parentKey);if(this.#t.has(n)){const o=this._indexOfPosition(t);if(this.#t.delete(n),o!==-1){const i=this.#e.at(o);i._setParentLink(this,sn(t,this.#e.at(o+1)?._parentPos)),this.#e.reposition(i)}n._setParentLink(this,t);const s=this.#n(n);return{modified:$e(this,[Yt(s,n)]),reverse:[]}}else{if(t===r)return{modified:!1};const o=this.#e.findIndex(a=>a===n),s=this._indexOfPosition(t);s!==-1&&this.#o(s,sn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,t);const i=this.#e.findIndex(a=>a===n);return o===i?{modified:!1}:{modified:$e(this,[Nn(o,i,n)]),reverse:[]}}}#b(t,n){const r=ge(n._parentKey),o=this.#e.findIndex(u=>u===n),s=this._indexOfPosition(t);let i=t;s!==-1&&(i=sn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,i);const a=this.#e.findIndex(u=>u===n);return o===a?{modified:!1}:{modified:$e(this,[Nn(o,a,n)]),reverse:[{type:ve.SET_PARENT_KEY,id:ge(n._id),parentKey:r}]}}_setChildKey(t,n,r){return r===1?this.#d(t,n):r===2?this.#y(t,n):this.#b(t,n)}_apply(t,n){return super._apply(t,n)}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveList if parent is missing");return{type:qe.LIST,parentId:ge(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this.#e.length}push(t){return this.#E(t,this.length,"push")}insert(t,n){return this.#E(t,n,"insert")}#E(t,n,r){if(this._pool?.assertStorageIsWritable(),n<0||n>this.#e.length)throw new Error(`Cannot insert list item at index "${n}". index should be between 0 and ${this.#e.length}`);const o=this.#e.at(n-1)?._parentPos,s=this.#e.at(n)?._parentPos,i=sn(o,s),a=eo(t);if(a._setParentLink(this,i),this.#n(a),this._pool&&this._id){const u=this._pool.generateId();a._attach(u,this._pool);const c=a._toOpsWithOpId(this._id,i,this._pool);this._pool.dispatch(r==="push"?Ro(c,"push"):c,[{type:ve.DELETE_CRDT,id:u}],new Map([[this._id,$e(this,[Yt(n,a)])]]))}}move(t,n){if(this._pool?.assertStorageIsWritable(),n<0)throw new Error("targetIndex cannot be less than 0");if(n>=this.#e.length)throw new Error("targetIndex cannot be greater or equal than the list length");if(t<0)throw new Error("index cannot be less than 0");if(t>=this.#e.length)throw new Error("index cannot be greater or equal than the list length");let r=null,o=null;t<n?(o=n===this.#e.length-1?void 0:this.#e.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 s=sn(r,o),i=this.#e.at(t),a=i._getParentKeyOrThrow();if(this.#o(t,s),this._pool&&this._id){const u=new Map([[this._id,$e(this,[Nn(t,n,i)])]]);this._pool.dispatch([{type:ve.SET_PARENT_KEY,id:ge(i._id),opId:this._pool.generateOpId(),parentKey:s}],[{type:ve.SET_PARENT_KEY,id:ge(i._id),parentKey:a}],u)}}delete(t){if(this._pool?.assertStorageIsWritable(),t<0||t>=this.#e.length)throw new Error(`Cannot delete list item at index "${t}". index should be between 0 and ${this.#e.length-1}`);const n=this.#e.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(ge(this._id),$e(this,[Ps(t,n)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:ve.DELETE_CRDT}],n._toOps(ge(this._id),n._getParentKeyOrThrow()),o)}}}clear(){if(this._pool?.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const s of this.#e){s._detach();const i=s._id;i&&(t.push({type:ve.DELETE_CRDT,id:i,opId:this._pool.generateOpId()}),n.push(...s._toOps(ge(this._id),s._getParentKeyOrThrow())),r.push(Ps(0,s)))}this.#e.clear(),this.invalidate();const o=new Map;o.set(ge(this._id),$e(this,r)),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._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(),s=r._id;r._detach();const i=eo(n);if(i._setParentLink(this,o),this.#e.remove(r),this.#e.add(i),this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();i._attach(a,this._pool);const u=new Map;u.set(this._id,$e(this,[Lr(t,i)]));const c=Ro(i._toOpsWithOpId(this._id,o,this._pool),"set",s),d=Ro(r._toOps(this._id,o),"set",a);this._pool.dispatch(c,d,u)}}#c(t){return pr(t)}every(t){return this.#e.rawArray.every((n,r)=>t(this.#c(n),r))}filter(t){const n=[];return this.#e.rawArray.forEach((r,o)=>{const s=this.#c(r);t(s,o)&&n.push(s)}),n}find(t){for(const[n,r]of this.#e.rawArray.entries()){const o=this.#c(r);if(t(o,n))return o}}findIndex(t){return this.#e.rawArray.findIndex((n,r)=>t(this.#c(n),r))}forEach(t){this.#e.rawArray.forEach((n,r)=>t(this.#c(n),r))}get(t){const n=this.#e.at(t);return n!==void 0?this.#c(n):void 0}indexOf(t,n){return this.#e.rawArray.findIndex((r,o)=>o>=(n??0)&&this.#c(r)===t)}lastIndexOf(t,n){const r=this.#e.rawArray;for(let o=n??r.length-1;o>=0;o--)if(this.#c(r[o])===t)return o;return-1}map(t){return this.#e.rawArray.map((n,r)=>t(this.#c(n),r))}some(t){return this.#e.rawArray.some((n,r)=>t(this.#c(n),r))}*[Symbol.iterator](){for(const t of this.#e)yield this.#c(t)}#v(t,n){const r=_o(t);r._attach(t.id,ge(this._pool)),r._setParentLink(this,n),this.#n(r);const o=this._indexOfPosition(n);return{newItem:r,newIndex:o}}#C(t,n){const r=sn(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??it(),key:t,payload:n}}toJSON(){return super.toJSON()}_toJSON(){const t=Array.from(this.#e,n=>n.toJSON());return hn(t)}clone(){return new lu(Array.from(this.#e,t=>t.clone()))}};function $e(e,t){return{node:e,type:"LiveList",updates:t}}function Lr(e,t){return{index:e,type:"set",item:t instanceof Bn?t.data:t}}function Ps(e,t){return{type:"delete",index:e,deletedItem:t instanceof Bn?t.data:t}}function Yt(e,t){return{index:e,type:"insert",item:t instanceof Bn?t.data:t}}function Nn(e,t,n){return{type:"move",index:t,item:n instanceof Bn?n.data:n,previousIndex:e}}function Ro(e,t,n){return e.map((r,o)=>o===0?{...r,intent:t,deletedId:n}:r)}var Ir=class du extends Ii{#e;#t;constructor(t){if(super(),this.#t=new Map,t){const n=[];for(const[r,o]of t){const s=eo(o);s._setParentLink(this,r),n.push([r,s])}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:ve.CREATE_MAP,parentId:t,parentKey:n};r.push(o);for(const[s,i]of this.#e)for(const a of i._toOps(this._id,s))r.push(a);return r}static _deserialize([t,n],r,o){const s=new du;s._attach(t,o);const i=r.get(t);if(i===void 0)return s;for(const a of i){const u=a[1],c=vp(a,r,o);c._setParentLink(s,u.parentKey),s.#e.set(u.parentKey,c),s.invalidate()}return s}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)et(o)&&o._attach(n.generateId(),n)}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:r,parentKey:o,opId:s}=t,i=o,a=_o(t);if(this._pool.getNode(r)!==void 0)return{modified:!1};if(n===2){const d=this.#t.get(i);if(d===s)return this.#t.delete(i),{modified:!1};if(d!==void 0)return{modified:!1}}else n===1&&this.#t.delete(i);const u=this.#e.get(i);let c;if(u){const d=ge(this._id);c=u._toOps(d,i),u._detach()}else c=[{type:ve.DELETE_CRDT,id:r}];return a._setParentLink(this,i),a._attach(r,this._pool),this.#e.set(i,a),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[i]:{type:"update"}}},reverse:c}}_detach(){super._detach();for(const t of this.#e.values())t._detach()}_detachChild(t){const n=ge(this._id),r=ge(t._parentKey),o=t._toOps(n,r);for(const[i,a]of this.#e)a===t&&(this.#e.delete(i),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveMap",updates:{[r]:{type:"delete",deletedItem:pr(t)}}},reverse:o}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:qe.MAP,parentId:ge(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 pr(n)}set(t,n){this._pool?.assertStorageIsWritable();const r=this.#e.get(t);r&&r._detach();const o=eo(n);if(o._setParentLink(this,t),this.#e.set(t,o),this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();o._attach(s,this._pool);const i=new Map;i.set(this._id,{node:this,type:"LiveMap",updates:{[t]:{type:"update"}}});const a=o._toOpsWithOpId(this._id,t,this._pool);this.#t.set(t,ge(a[0].opId)),this._pool.dispatch(a,r?r._toOps(this._id,t):[{type:ve.DELETE_CRDT,id:s}],i)}}get size(){return this.#e.size}has(t){return this.#e.has(t)}delete(t){this._pool?.assertStorageIsWritable();const n=this.#e.get(t);if(n===void 0)return!1;if(n._detach(),this.#e.delete(t),this.invalidate(),this._pool&&n._id){const r=ge(this._id),o=new Map;o.set(r,{node:this,type:"LiveMap",updates:{[t]:{type:"delete",deletedItem:pr(n)}}}),this._pool.dispatch([{type:ve.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();if(n.done)return{done:!0,value:void 0};const o=n.value[0],s=pr(n.value[1]);return{value:[o,s]}}}}[Symbol.iterator](){return this.entries()}keys(){return this.#e.keys()}values(){const t=this.#e.values();return{[Symbol.iterator](){return this},next(){const n=t.next();return n.done?{done:!0,value:void 0}:{value:pr(n.value)}}}}forEach(t){for(const n of this)t(n[1],n[0],this)}_toTreeNode(t){return{type:"LiveMap",id:this._id??it(),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 hn(t)}clone(){return new du(Array.from(this.#e).map(([t,n])=>[t,n.clone()]))}};function Sr(e,t){if(Array.isArray(e))return new nr(e.map(n=>Sr(n,t)));if(lt(e)){const n={},r={};for(const s in e){const i=e[s];if(i===void 0)continue;const a=lt(t)?t[s]:t;a===!1?r[s]=i:a==="atomic"?n[s]=i:n[s]=Sr(i,a)}const o=new Fn(n);for(const s in r)o.setLocal(s,r[s]);return o}else return e}function pp(e,t,n){return ic(e)&<(t)?fu(e,t,"full",n):sc(e)&&Array.isArray(t)?ZE(e,t,n):Cp(e)&<(t)?JE():Sr(t,n)}function JE(e,t){throw new Error("Reconciling a LiveMap is not supported yet")}function fu(e,t,n,r){const o=e.keys();for(const s in t){o.delete(s);const i=t[s];if(i===void 0){n==="full"&&e.delete(s);continue}const a=lt(r)?r[s]:r;if(a===!1)e.setLocal(s,i);else if(a==="atomic")e.get(s)!==i&&e.set(s,i);else{const u=e.get(s);if(u===void 0)e.set(s,Sr(i,a));else if(Kn(u)){const c=pp(u,i,a);c!==u&&e.set(s,c)}else u!==i&&e.set(s,Sr(i,a))}}if(n==="full")for(const s of o)e.delete(s);return e}function ZE(e,t,n){const r=e.length,o=t.length;for(let s=0;s<Math.min(r,o);s++){const i=e.get(s),a=t[s];if(Kn(i)){const u=pp(i,a,n);u!==i&&e.set(s,u)}else i!==a&&e.set(s,Sr(a,n))}for(let s=r;s<o;s++)e.push(Sr(t[s],n));for(let s=r-1;s>=o;s--)e.delete(s);return e}var ya=128*1024,Fn=class cr extends Ii{#e;#t=new Map;#n;static detectLargeObjects=!1;static#r(t){const n=new Map;let r=null;for(const o of t)if(NE(o))r=o[1];else{const s=o[1],i=n.get(s.parentId);i!==void 0?i.push(o):n.set(s.parentId,[o])}if(r===null)throw new Error("Root can't be null");return[r,n]}static _fromItems(t,n){const[r,o]=cr.#r(t);return cr._deserialize(["root",r],o,n)}constructor(t={}){super(),this.#n=new Map;const n=ps(t);for(const r of Object.keys(n)){const o=n[r];et(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:ve.CREATE_OBJECT,id:this._id,parentId:t,parentKey:n,data:{}};r.push(o);for(const[s,i]of this.#e)if(et(i))for(const a of i._toOps(this._id,s))r.push(a);else o.data[s]=i;return r}static _deserialize([t,n],r,o){const s=new cr(n.data);return s._attach(t,o),this._deserializeChildren(s,r,o)}static _deserializeChildren(t,n,r){const o=n.get(ge(t._id));if(o===void 0)return t;for(const s of o){const i=QE(s,n,r),a=s[1];Kn(i)&&i._setParentLink(t,a.parentKey),t.#e.set(a.parentKey,i),t.invalidate()}return t}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)et(o)&&o._attach(n.generateId(),n)}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:r,opId:o,parentKey:s}=t,i=mp(t);if(this._pool.getNode(r)!==void 0)return this.#n.get(s)===o&&this.#n.delete(s),{modified:!1};if(n===0)this.#n.set(s,ge(o));else if(this.#n.get(s)!==void 0)return this.#n.get(s)===o?(this.#n.delete(s),{modified:!1}):{modified:!1};const a=ge(this._id),u=this.#e.get(s);let c;return et(u)?(c=u._toOps(a,s),u._detach()):u===void 0?c=[{type:ve.DELETE_OBJECT_KEY,id:a,key:s}]:c=[{type:ve.UPDATE_OBJECT,id:a,data:{[s]:u}}],this.#t.delete(s),this.#e.set(s,i),this.invalidate(),Kn(i)&&(i._setParentLink(this,s),i._attach(r,this._pool)),{reverse:c,modified:{node:this,type:"LiveObject",updates:{[s]:{type:"update"}}}}}_detachChild(t){if(t){const n=ge(this._id),r=ge(t._parentKey),o=t._toOps(n,r),s=pr(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:{[r]:{type:"delete",deletedItem:s}}},reverse:o}}return{modified:!1}}_detach(){super._detach();for(const t of this.#e.values())et(t)&&t._detach()}_apply(t,n){return t.type===ve.UPDATE_OBJECT?this.#o(t,n):t.type===ve.DELETE_OBJECT_KEY?this.#s(t,n):super._apply(t,n)}_serialize(){const t={};for(const[n,r]of this.#e)et(r)||(t[n]=r);return this.parent.type==="HasParent"&&this.parent.node._id?{type:qe.OBJECT,parentId:this.parent.node._id,parentKey:this.parent.key,data:t}:{type:qe.OBJECT,data:t}}#o(t,n){let r=!1;const o=ge(this._id),s=[],i={type:ve.UPDATE_OBJECT,id:o,data:{}};for(const u in t.data){const c=this.#e.get(u);if(et(c)){for(const d of c._toOps(o,u))s.push(d);c._detach()}else c!==void 0?i.data[u]=c:c===void 0&&s.push({type:ve.DELETE_OBJECT_KEY,id:o,key:u})}const a={};for(const u in t.data){const c=t.data[u];if(c===void 0)continue;if(n)this.#n.set(u,ge(t.opId));else if(this.#n.get(u)===void 0)r=!0;else if(this.#n.get(u)===t.opId){this.#n.delete(u);continue}else continue;const d=this.#e.get(u);et(d)&&d._detach(),r=!0,a[u]={type:"update"},this.#t.delete(u),this.#e.set(u,c),this.invalidate()}return Object.keys(i.data).length!==0&&s.unshift(i),r?{modified:{node:this,type:"LiveObject",updates:a},reverse:s}:{modified:!1}}#s(t,n){const r=t.key,o=this.#e.get(r);if(o===void 0)return{modified:!1};if(!n&&this.#n.get(r)!==void 0)return{modified:!1};const s=ge(this._id);let i=[];return et(o)?(i=o._toOps(s,t.key),o._detach()):o!==void 0&&(i=[{type:ve.UPDATE_OBJECT,id:s,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}}},reverse:i}}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._pool?.assertStorageIsWritable();const r=this.#i(t);if(this.#t.set(t,n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const o=r?.[0]??[],s=r?.[1]??[],i=r?.[2]??new Map,a=i.get(this._id);i.set(this._id,{node:this,type:"LiveObject",updates:{...a?.updates,[t]:{type:"update"}}}),this._pool.dispatch(o,s,i)}}get(t){return this.#t.has(t)?this.#t.get(t):this.#e.get(t)}#i(t){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}}}),[[],[],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 et(r)&&r._detach(),this.#e.delete(n),this.invalidate(),null;const o=[{type:ve.DELETE_OBJECT_KEY,key:n,id:this._id,opId:this._pool.generateOpId()}];let s;et(r)?(r._detach(),s=r._toOps(this._id,n)):s=[{type:ve.UPDATE_OBJECT,data:{[n]:r},id:this._id}],this.#e.delete(n),this.invalidate();const i=new Map;return i.set(this._id,{node:this,type:"LiveObject",updates:{[t]:{type:"delete",deletedItem:r}}}),[o,s,i]}delete(t){const n=this.#i(t);if(n){const[r,o,s]=n;this._pool?.dispatch(r,o,s)}}update(t){if(this._pool?.assertStorageIsWritable(),cr.detectLargeObjects){const c={};for(const[m,g]of this.#e)et(g)||(c[m]=g);for(const m of Object.keys(t)){const g=t[m];g!==void 0&&(et(g)||(c[m]=g))}const d=JSON.stringify(c);if(d.length*4>ya){const m=new TextEncoder().encode(d).length;if(m>ya)throw new Error(`LiveObject size exceeded limit: ${m} bytes > ${ya} bytes. See https://liveblocks.io/docs/pricing/limits#Other-limits`)}}if(this._pool===void 0||this._id===void 0){for(const c in t){const d=t[c];if(d===void 0)continue;const l=this.#e.get(c);et(l)&&l._detach(),et(d)&&d._setParentLink(this,c),this.#t.delete(c),this.#e.set(c,d),this.invalidate()}return}const n=[],r=[],o=this._pool.generateOpId(),s={},i={id:this._id,type:ve.UPDATE_OBJECT,data:{}},a={};for(const c in t){const d=t[c];if(d===void 0)continue;const l=this.#e.get(c);if(l!==d){if(et(l)){for(const m of l._toOps(this._id,c))r.push(m);l._detach()}else l===void 0?r.push({type:ve.DELETE_OBJECT_KEY,id:this._id,key:c}):i.data[c]=l;if(et(d)){d._setParentLink(this,c),d._attach(this._pool.generateId(),this._pool);const m=d._toOpsWithOpId(this._id,c,this._pool),g=m.find(v=>v.parentId===this._id);g&&this.#n.set(c,ge(g.opId));for(const v of m)n.push(v)}else s[c]=d,this.#n.set(c,o);this.#t.delete(c),this.#e.set(c,d),this.invalidate(),a[c]={type:"update"}}}if(Object.keys(i.data).length!==0&&r.unshift(i),Object.keys(s).length!==0&&n.unshift({opId:o,id:this._id,type:ve.UPDATE_OBJECT,data:s}),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}),this._pool.dispatch(n,r,u)}static from(t,n){if(!lt(t))throw new Error("Expected a JSON object");const r=new cr({});return r.reconcile(t,n),r}reconcile(t,n){if(!this.hasCache(t)){if(!lt(t))throw new Error("Reconciling the document root expects a plain object value");fu(this,t,"full",n)}}reconcilePartially(t,n){if(!lt(t))throw new Error("Reconciling the document root expects a plain object value");fu(this,t,"partial",n)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??it();return{type:"LiveObject",id:n,key:t,payload:Array.from(this.#e.entries()).map(([r,o])=>et(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]=Kn(r)?r.toJSON():r;for(const[n,r]of this.#t)t[n]=r;return hn(t)}clone(){const t=new cr(Object.fromEntries(Array.from(this.#e).map(([n,r])=>[n,Kn(r)?r.clone():ao(r)])));for(const[n,r]of this.#t)t.#t.set(n,ao(r));return t}};function _o(e){return eo(mp(e))}function mp(e){switch(e.type){case ve.CREATE_REGISTER:return e.data;case ve.CREATE_OBJECT:return new Fn(e.data);case ve.CREATE_MAP:return new Ir;case ve.CREATE_LIST:return new nr([]);default:return Je(e,"Unknown creation Op")}}function gp(e,t){return e===t?!0:e.parent.type==="HasParent"?gp(e.parent.node,t):!1}function XE(e){const t=fp({getCurrentConnectionId:()=>{throw new Error("Cannot mutate a historic storage version: it is a read-only snapshot")}});return Fn._fromItems(e,t)}function vp(e,t,n){if(ip(e))return Fn._deserialize(e,t,n);if(ap(e))return nr._deserialize(e,t,n);if(up(e))return Ir._deserialize(e,t,n);if(cp(e))return Bn._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function QE(e,t,n){if(ip(e))return Fn._deserialize(e,t,n);if(ap(e))return nr._deserialize(e,t,n);if(up(e))return Ir._deserialize(e,t,n);if(cp(e))return e[1].data;throw new Error("Unexpected CRDT type")}function Kn(e){return sc(e)||Cp(e)||ic(e)}function et(e){return Kn(e)||ey(e)}function sc(e){return e instanceof nr}function Cp(e){return e instanceof Ir}function ic(e){return e instanceof Fn}function ey(e){return e instanceof Bn}function ty(e){return e===void 0?void 0:Kn(e)?e.clone():ao(e)}function pr(e){return e instanceof Bn?e.data:e instanceof nr||e instanceof Ir||e instanceof Fn?e:Je(e,"Unknown AbstractCrdt")}function eo(e){return e instanceof Fn||e instanceof Ir||e instanceof nr?e:new Bn(e)}function ny(e){const t=Array.from(e.nodes.values(),n=>{const r=n.parent,o=r.type==="HasParent"?r.node._id??"?":r.type==="Orphaned"?"<orphaned>":"-";let s;return n instanceof Bn?s=co(n.data):n instanceof nr?s="<LiveList>":n instanceof Ir?s="<LiveMap>":s="<LiveObject>",{id:ge(n._id),parentId:o,key:n._parentKey??"",value:s}});return t.sort((n,r)=>n.parentId!==r.parentId?n.parentId<r.parentId?-1:1:n.key!==r.key?n.key<r.key?-1:1:0),t.map(n=>` ${n.id} parent=${n.parentId} key=${n.key||"—"} ${n.value}`).join(`
|
|
4
|
+
`)}function hu(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(!hu(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(!hu(e[r],t[r]))return!1;return!0}function ry(e,t){const n=[];e.forEach((s,i)=>{t.get(i)||n.push({type:ve.DELETE_CRDT,id:i})});const r=new Set;function o(s,i){if(r.has(s))return;r.add(s);const a=i.parentId;if(a!==void 0&&!e.has(a)){const u=t.get(a);u!==void 0&&o(a,u)}switch(i.type){case qe.REGISTER:n.push({type:ve.CREATE_REGISTER,id:s,parentId:i.parentId,parentKey:i.parentKey,data:i.data});break;case qe.LIST:n.push({type:ve.CREATE_LIST,id:s,parentId:i.parentId,parentKey:i.parentKey});break;case qe.OBJECT:if(i.parentId===void 0||i.parentKey===void 0)throw new Error("Internal error. Cannot serialize storage root into an operation");n.push({type:ve.CREATE_OBJECT,id:s,parentId:i.parentId,parentKey:i.parentKey,data:i.data});break;case qe.MAP:n.push({type:ve.CREATE_MAP,id:s,parentId:i.parentId,parentKey:i.parentKey});break}}return t.forEach((s,i)=>{const a=e.get(i);if(a){if(s.type===qe.OBJECT)if(a.type!==qe.OBJECT)n.push({type:ve.UPDATE_OBJECT,id:i,data:s.data});else{const u=new Map;for(const c of Object.keys(s.data)){const d=s.data[c];d!==void 0&&!hu(d,a.data[c])&&u.set(c,d)}u.size>0&&n.push({type:ve.UPDATE_OBJECT,id:i,data:Object.fromEntries(u)});for(const c of Object.keys(a.data))c in s.data||n.push({type:ve.DELETE_OBJECT_KEY,id:i,key:c})}s.parentKey!==a.parentKey&&n.push({type:ve.SET_PARENT_KEY,id:i,parentKey:ge(s.parentKey,"Parent key must not be missing")})}else o(i,s)}),n}function oy(e,t){const n=e.updates;for(const[r,o]of Ju(t.updates))n[r]=o;return{...t,updates:n}}function sy(e,t){const n=e.updates;for(const[r,o]of Ju(t.updates))n[r]=o;return{...t,updates:n}}function iy(e,t){const n=e.updates;return{...t,updates:n.concat(t.updates)}}function ba(e,t){return e===void 0?t:e.type==="LiveObject"&&t.type==="LiveObject"?oy(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?sy(e,t):e.type==="LiveList"&&t.type==="LiveList"?iy(e,t):t}var ay=Ne();ay.observable;function wa(e,t,n=t){typeof e=="function"&&e()}var Vo=Symbol("notification-settings-plain");function ui(e){const t=["email","slack","teams","webPush"],n={[Vo]:{value:e,enumerable:!1}};for(const r of t)n[r]={enumerable:!0,get(){const o=this[Vo][r];return typeof o>"u"?(Jn(`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 c1(null,n)}function uy(e,t){const n=ui({...e[Vo]});for(const r of u1(t)){const o=t[r];if(o!==void 0){const s=Object.fromEntries(Ju(o).filter(([,i])=>i!==void 0));n[Vo][r]={...n[Vo][r],...s}}}return n}var jn="12px",cy=(e="bottom-right")=>{if(typeof document>"u"||document.getElementById("liveblocks-badge"))return;const t=document.createElement("div");switch(t.id="liveblocks-badge",t.style.position="fixed",t.style.opacity="0",t.style.transition="opacity 300ms",t.style.zIndex="9999",e){case"top-right":t.style.top=jn,t.style.right=jn;break;case"bottom-right":t.style.bottom=jn,t.style.right=jn;break;case"bottom-left":t.style.bottom=jn,t.style.left=jn;break;case"top-left":t.style.top=jn,t.style.left=jn;break}t.onmouseenter=()=>{const v=document.getElementById("liveblocks-badge-hide-button");v&&(v.style.opacity="0.3")},t.onmouseleave=()=>{const v=document.getElementById("liveblocks-badge-hide-button");v&&(v.style.opacity="0")};const n=document.createElement("a");n.href="https://lblcks.io/badge",n.target="_blank",n.rel="noopener noreferrer",n.title="Liveblocks";const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width","111"),r.setAttribute("height","38"),r.setAttribute("viewBox","0 0 111 38"),r.setAttribute("fill","none");const o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("x","1"),o.setAttribute("y","1"),o.setAttribute("width","109"),o.setAttribute("height","36"),o.setAttribute("rx","8"),o.setAttribute("fill","white"),r.appendChild(o);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.setAttribute("x","0.5"),s.setAttribute("y","0.5"),s.setAttribute("width","110"),s.setAttribute("height","37"),s.setAttribute("rx","8.5"),s.setAttribute("stroke","black"),s.setAttribute("stroke-opacity","0.1"),r.appendChild(s);const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.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"),i.setAttribute("fill","black"),r.appendChild(i);const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.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"),a.setAttribute("fill","black"),a.setAttribute("fill-opacity","0.5"),r.appendChild(a);const u=document.createElementNS("http://www.w3.org/2000/svg","rect");u.setAttribute("x","7"),u.setAttribute("y","7"),u.setAttribute("width","24"),u.setAttribute("height","24"),u.setAttribute("rx","3"),u.setAttribute("fill","black"),r.appendChild(u);const c=document.createElementNS("http://www.w3.org/2000/svg","path");c.setAttribute("fill-rule","evenodd"),c.setAttribute("clip-rule","evenodd"),c.setAttribute("d","M22.0455 15H12.2273L15.1364 17.9091V21.9091L22.0455 15Z"),c.setAttribute("fill","white"),r.appendChild(c);const d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("fill-rule","evenodd"),d.setAttribute("clip-rule","evenodd"),d.setAttribute("d","M16.9546 22.9999H26.7728L23.8637 20.0908V16.0908L16.9546 22.9999Z"),d.setAttribute("fill","white"),r.appendChild(d),n.appendChild(r),t.appendChild(n);const l=document.createElement("button");l.id="liveblocks-badge-hide-button",l.style.position="absolute",l.style.top="0",l.style.right="0",l.style.border="none",l.style.padding="0",l.style.margin="0",l.style.background="none",l.style.font="inherit",l.style.cursor="pointer",l.style.outline="none",l.style.setProperty("-webkit-appearance","none"),l.style.setProperty("-moz-appearance","none"),l.style.setProperty("appearance","none"),l.style.opacity="0",l.onclick=()=>{const v=document.getElementById("liveblocks-badge");v&&(v.style.display="none")},l.onmouseenter=()=>{l.style.opacity="0.5"},l.onmouseleave=()=>{l.style.opacity="0.3"};const m=document.createElementNS("http://www.w3.org/2000/svg","svg");m.setAttribute("width","18"),m.setAttribute("height","18"),m.setAttribute("viewBox","0 0 18 18"),m.setAttribute("fill","none");const g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d","M6 6L9 9M12 12L9 9M9 9L12 6M9 9L6 12"),g.setAttribute("stroke","black"),m.appendChild(g),l.appendChild(m),t.appendChild(l),document.body.appendChild(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.opacity="1"})})},Da=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&&Ft("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&&Ft("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 ly(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Ep(e){return Array.isArray(e)}function dy(e){return!ly(e)&&!Ep(e)}function fy(){let e=0,t=0,n;function r(){n=[],e=performance.now(),t=e}function o(i=performance.now()){n.push(i-t),t=i}function s(){const i=performance.now();return o(i),{total:i-e,laps:n}}return{start:r,lap:o,stop:s}}var rt=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});function hy(e,t){const{connectionId:n,id:r,info:o,access:s}=e,{canWrite:i,canComment:a}=s;return hn(ps({connectionId:n,id:r,info:o,canWrite:i,canComment:a,isReadOnly:!i,presence:t}))}var py=class{#e;#t;signal;constructor(){this.#e=new xt({connections:new Map,presences:new Map}),this.signal=je.from(this.#e,e=>nu(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 hy(n,r)}getUser(e){const t=this.#t.get(e);if(t)return t;const n=this.#n(e);if(n)return this.#t.set(e,n),n}#r(e){this.#t.delete(e)}setConnection(e,t,n,r){this.#e.mutate(o=>(o.connections.set(e,hn({connectionId:e,id:t,info:n,access:r})),o.presences.has(e)?this.#r(e):!1))}removeConnection(e){this.#e.mutate(t=>{t.connections.delete(e),t.presences.delete(e),this.#r(e)})}setOther(e,t){this.#e.mutate(n=>(n.presences.set(e,hn(ps(t))),n.connections.has(e)?this.#r(e):!1))}patchOther(e,t){this.#e.mutate(n=>{const r=n.presences.get(e);if(r===void 0)return!1;const o=Uh(r,t);return r===o?!1:(n.presences.set(e,hn(o)),this.#r(e))})}},pu=class yp 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 yp(my(t),t,n)}};function my(e){switch(e.type){case"ROOM_CONNECTION_ERROR":switch(e.code){case 4001:return"Not allowed to connect to the room";case 4005:return"Room is already full";case 4006:return"Kicked out of the room, because the room ID changed";default:return"Could not connect to the room"}case"AI_CONNECTION_ERROR":return e.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 e.reason??"Feed request failed";default:return Je(e,"Unhandled case")}}var Aa=5e3;function td(e){const t=rc(e),n=nc(t);return{canWrite:Yn(n,"storage","write"),canComment:Yn(n,"comments","write")}}function gy(e){let t=0;return()=>`${e}:${t++}`}function nd(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 vy(){const e=typeof document<"u"?document:void 0,t={current:null};function n(){e?.visibilityState==="hidden"?t.current=t.current??Date.now():t.current=null}return e?.addEventListener("visibilitychange",n),[t,()=>{e?.removeEventListener("visibilitychange",n)}]}function Cy(){let e=new Map;return{append(t){for(const[n,r]of t)e.set(n,r)},take(){const t=e;return e=new Map,t}}}function Ey(e){const t=new Set,n=e.get("root");for(const r in n?.data)t.add(r);for(const r of e.values())r.parentId==="root"&&t.add(r.parentKey);return t}function yy(e,t){const n=t.roomId,r=e.initialPresence,o=e.initialStorage,s=t.roomHttpClient,[i,a]=vy(),u={...t.delegates,canZombie(){return t.backgroundKeepAliveTimeout!==void 0&&i.current!==null&&Date.now()>i.current+t.backgroundKeepAliveTimeout&&aa.getStatus()!=="synchronizing"&&la.getStatus()!=="synchronizing"}},c=new np(u,t.enableDebugLogging),d=new dp,l={buffer:{flushTimerID:void 0,lastFlushedAt:0,presenceUpdates:{type:"full",data:r},messages:[],storageOperations:[]},staticSessionInfoSig:new St(null),dynamicSessionInfoSig:new St(null),myPresence:new h1(r),others:new py,initialStorage:o,idFactory:null,yjsProvider:void 0,yjsProviderDidChange:Ne(),pool:fp({getCurrentConnectionId:X,onDispatch:A,isStorageWritable:T,unacknowledgedOps:d}),root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,unacknowledgedOps:d},m=Cy(),g=t.enableDebugLogging?fy():void 0;let v;function C(x){const U=c.authValue;if(U!==null){const H=tc(U);if(H!==v)if(v=H,U.type==="secret"){const V=U.token.parsed;l.staticSessionInfoSig.set({userId:V.uid,userInfo:V.ui})}else l.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}S.status.notify(x),le()}let p,D=!1;function w(x){x==="reconnecting"?p=setTimeout(()=>{S.lostConnection.notify("lost"),D=!0,l.others.clearOthers(),J({others:[{type:"reset"}]})},t.lostConnectionTimeout):(clearTimeout(p),D&&(x==="disconnected"?S.lostConnection.notify("failed"):S.lostConnection.notify("restored"),D=!1))}function b(){l.buffer.presenceUpdates={type:"full",data:{...l.myPresence.get()}},pt!==null&&bl(),Fe()}function y(){clearTimeout(l.buffer.flushTimerID),l.unacknowledgedOps.markAllAsPossiblyStored()}c.events.onMessage.subscribe(Ie),c.events.statusDidChange.subscribe(C),c.events.statusDidChange.subscribe(w),c.events.didConnect.subscribe(b),c.events.didDisconnect.subscribe(y),c.events.onConnectionError.subscribe(({message:x,code:U})=>{const H="ROOM_CONNECTION_ERROR",V=new pu(x,{type:H,code:U,roomId:n});t.errorEventSource.notify(V)});function A(x,U,H){if(l.activeBatch){for(const V of x)l.activeBatch.ops.push(V);for(const[V,Q]of H)l.activeBatch.updates.storageUpdates.set(V,ba(l.activeBatch.updates.storageUpdates.get(V),Q));l.activeBatch.reverseOps.pushLeft(U)}else U.length>0&&q(U),x.length>0&&(l.redoStack.length=0,He(x)),J({storageUpdates:H})}function T(){const x=l.dynamicSessionInfoSig.get()?.permissionMatrix;return x!==void 0?Yn(x,"storage","write"):!0}const S={status:Ne(),lostConnection:Ne(),customEvent:Ne(),self:Ne(),myPresence:Ne(),others:Ne(),storageBatch:Ne(),history:Ne(),storageDidLoad:Ne(),storageStatus:Ne(),ydoc:Ne(),comments:Ne(),feeds:Ne(),roomWillDestroy:Ne()};async function P(x,U){return s.createTextMention({roomId:n,mentionId:x,mention:U})}async function L(x){return s.deleteTextMention({roomId:n,mentionId:x})}async function F(x,U){await s.reportTextEditor({roomId:n,type:x,rootKey:U})}async function M(){return s.listHistoryVersions({roomId:n})}async function N(x){return s.listHistoryVersionsSince({roomId:n,since:x.since,signal:x.signal})}async function _(x){return s.fetchStorageHistoryVersion({roomId:n,versionId:x})}async function I(x){return s.fetchYjsHistoryVersion({roomId:n,versionId:x})}async function j(){return s.createVersionHistorySnapshot({roomId:n})}async function z(x){return s.deleteHistoryVersion({roomId:n,versionId:x})}async function Y(x){return s.executeContextualPrompt({roomId:n,...x})}function oe(x){c.send(co(x))}const G=je.from(l.staticSessionInfoSig,l.dynamicSessionInfoSig,l.myPresence,(x,U,H)=>{if(x===null||U===null)return null;{const V=Yn(U.permissionMatrix,"storage","write");return{connectionId:U.actor,id:x.userId,info:x.userInfo,presence:H,canWrite:V,canComment:Yn(U.permissionMatrix,"comments","write")}}});let Z;function le(){const x=G.get();x!==null&&x!==Z&&(S.self.notify(x),Z=x)}const de=je.from(G,x=>x!==null?nd("Me",x):null);function ue(x){const U=new Map;for(const[H,V]of l.pool.nodes)U.set(H,V._serialize());return ry(U,x)}function ee(x){if(x.size===0)throw new Error("Internal error: cannot load storage without items");if(l.root!==void 0){const Q=ae(ue(x));J(Q.updates)}else l.root=Fn._fromItems(x,l.pool);const U=G.get()?.canWrite??!0,H=Ey(x),V=l.root;Sl(()=>{for(const Q in l.initialStorage)H.has(Q)||(U?V.set(Q,ty(l.initialStorage[Q])):ft(`Attempted to populate missing storage key '${Q}', but current user has no write access`))})}function te(x){if(l.root===void 0)throw new Error("Cannot reconcile storage before it is loaded");const U=ue(new Map(x));if(U.length===0)return;const H=ie(U);H.reverse.length>0&&q(H.reverse),l.redoStack.length=0;for(const V of H.opsToEmit)l.buffer.storageOperations.push(V);J(H.updates),Me(),Fe()}function R(x){l.undoStack.length>=50&&l.undoStack.shift(),l.undoStack.push(x),Me()}function q(x){l.pausedHistory!==null?l.pausedHistory.pushLeft(x):R(x)}function J(x){const U=x.storageUpdates,H=x.others;if(H!==void 0&&H.length>0){const V=l.others.get();for(const Q of H)S.others.notify({...Q,others:V})}if((x.presence??!1)&&(le(),S.myPresence.notify(l.myPresence.get())),U!==void 0&&U.size>0){const V=Array.from(U.values());S.storageBatch.notify(V)}Ts()}function X(){const x=l.dynamicSessionInfoSig.get();if(x)return x.actor;throw new Error("Internal. Tried to get connection id but connection was never open")}function ie(x){const[U,H]=f1(x,Ue=>Ue.type==="presence"),V=H.map(Ue=>Ue.opId===void 0?{...Ue,opId:l.pool.generateOpId()}:Ue),{reverse:Q,updates:De}=we(U,V,!0);return{opsToEmit:V,reverse:Q,updates:De}}function ae(x){return we([],x,!1)}function we(x,U,H){const V={reverse:new Da,storageUpdates:new Map,presence:!1};for(const De of x){const Ue={type:"presence",data:{}};for(const ze in De.data)Ue.data[ze]=l.myPresence.get()[ze];if(l.myPresence.patch(De.data),l.buffer.presenceUpdates===null)l.buffer.presenceUpdates={type:"partial",data:De.data};else for(const ze in De.data)l.buffer.presenceUpdates.data[ze]=De.data[ze];V.reverse.pushLeft(Ue),V.presence=!0}const Q=new Set;for(const De of U){let Ue;H?Ue=0:De.opId!==void 0?(l.unacknowledgedOps.delete(De.opId),Ue=2):Ue=1;const ze=Se(De,Ue);if(ze.modified){const _t=ze.modified.node._id;_t&&Q.has(_t)||(V.storageUpdates.set(ge(ze.modified.node._id),ba(V.storageUpdates.get(ge(ze.modified.node._id)),ze.modified)),V.reverse.pushLeft(ze.reverse)),(De.type===ve.CREATE_LIST||De.type===ve.CREATE_MAP||De.type===ve.CREATE_OBJECT)&&Q.add(De.id)}}return{reverse:Array.from(V.reverse),updates:{storageUpdates:V.storageUpdates,presence:V.presence}}}function Se(x,U){if(kE(x))return{modified:!1};switch(x.type){case ve.DELETE_OBJECT_KEY:case ve.UPDATE_OBJECT:case ve.DELETE_CRDT:{const H=l.pool.nodes.get(x.id);return H===void 0?{modified:!1}:H._apply(x,U===0)}case ve.SET_PARENT_KEY:{const H=l.pool.nodes.get(x.id);return H===void 0?{modified:!1}:H.parent.type==="HasParent"&&sc(H.parent.node)?H.parent.node._setChildKey(Yo(x.parentKey),H,U):{modified:!1}}case ve.CREATE_OBJECT:case ve.CREATE_LIST:case ve.CREATE_MAP:case ve.CREATE_REGISTER:{if(x.parentId===void 0)return{modified:!1};const H=l.pool.nodes.get(x.parentId);return H===void 0?{modified:!1}:H._attachChild(x,U)}default:return{modified:!1}}}function me(x,U){const H={};l.buffer.presenceUpdates===null&&(l.buffer.presenceUpdates={type:"partial",data:{}});for(const V in x){const Q=x[V];Q!==void 0&&(l.buffer.presenceUpdates.data[V]=Q,H[V]=l.myPresence.get()[V])}l.myPresence.patch(x),l.activeBatch?(U?.addToHistory&&l.activeBatch.reverseOps.pushLeft({type:"presence",data:H}),l.activeBatch.updates.presence=!0):(Fe(),U?.addToHistory&&q([{type:"presence",data:H}]),J({presence:!0}))}function fe(x){if(x.targetActor!==void 0){const H=l.others.getUser(x.actor);l.others.setOther(x.actor,x.data);const V=l.others.getUser(x.actor);if(H===void 0&&V!==void 0)return{type:"enter",user:V}}else l.others.patchOther(x.actor,x.data);const U=l.others.getUser(x.actor);if(U)return{type:"update",updates:x.data,user:U}}function ye(x){const U=l.others.getUser(x.actor);return U?(l.others.removeConnection(x.actor),{type:"leave",user:U}):null}function be(x){l.dynamicSessionInfoSig.set({actor:x.actor,nonce:x.nonce,permissionMatrix:nc(rc(x.scopes)),meta:x.meta}),l.idFactory=gy(x.actor),le(),x.meta.showBrand===!0&&cy(t.badgeLocation??"bottom-right");for(const U of l.others.connectionIds())x.users[U]===void 0&&l.others.removeConnection(U);for(const U in x.users){const H=x.users[U],V=Number(U);l.others.setConnection(V,H.id,H.info,td(H.scopes))}return{type:"reset"}}function xe(){return l.undoStack.length>0}function ke(){return l.redoStack.length>0}function Me(){ia>0||S.history.notify({canUndo:xe(),canRedo:ke()})}function O(x){l.others.setConnection(x.actor,x.id,x.info,td(x.scopes)),l.buffer.messages.push({type:rt.UPDATE_PRESENCE,data:l.myPresence.get(),targetActor:x.actor}),Fe();const U=l.others.getUser(x.actor);return U?{type:"enter",user:U}:void 0}function k(x){return dy(x)?x:null}function ne(x){const U=Sn(x);return U===void 0?null:Ep(U)?nu(U.map(H=>k(H))):nu([k(U)])}function re(x){if(x.length===0)return;const U=[],H=ie(x);U.push({type:rt.UPDATE_STORAGE,ops:H.opsToEmit}),J(H.updates),oe(U)}function he(x){return x.type===Ee.FEED_REQUEST_FAILED}function Ie(x){if(typeof x.data!="string")return;const U=ne(x.data);if(U===null||U.length===0)return;const H={storageUpdates:new Map,others:[]};for(const V of U)switch(V.type){case Ee.USER_JOINED:{const Q=O(V);Q&&H.others.push(Q);break}case Ee.UPDATE_PRESENCE:{const Q=fe(V);Q&&H.others.push(Q);break}case Ee.BROADCASTED_EVENT:{const Q=l.others.get();S.customEvent.notify({connectionId:V.actor,user:V.actor<0?null:Q.find(De=>De.connectionId===V.actor)??null,event:V.event});break}case Ee.USER_LEFT:{const Q=ye(V);Q&&H.others.push(Q);break}case Ee.UPDATE_YDOC:{S.ydoc.notify(V);break}case Ee.ROOM_STATE:{H.others.push(be(V));break}case Ee.STORAGE_CHUNK:g?.lap(),m.append(LE(V.nodes));break;case Ee.STORAGE_STREAM_END:{const Q=g?.stop();if(Q){const De=ze=>`${ze.toFixed(1)}ms`,Ue=Q.laps.slice(1);ft(`Storage chunk arrival: ${[`total=${De(Q.total)}`,`first=${De(Q.laps[0])}`,`rest.n=${Ue.length}`,`rest.avg=${De(Ue.reduce((ze,_t)=>ze+_t,0)/Ue.length)}`,`rest.max=${De(Ue.reduce((ze,_t)=>Math.max(ze,_t),0))}`].join(", ")}`)}sC(m.take());break}case Ee.UPDATE_STORAGE:{const Q=ae(V.ops);for(const[De,Ue]of Q.updates.storageUpdates)H.storageUpdates.set(De,ba(H.storageUpdates.get(De),Ue));break}case Ee.REJECT_STORAGE_OP:{Wh("Storage mutation rejection error",V.reason);break}case Ee.THREAD_CREATED:case Ee.THREAD_DELETED:case Ee.THREAD_METADATA_UPDATED:case Ee.THREAD_UPDATED:case Ee.COMMENT_REACTION_ADDED:case Ee.COMMENT_REACTION_REMOVED:case Ee.COMMENT_CREATED:case Ee.COMMENT_EDITED:case Ee.COMMENT_DELETED:case Ee.COMMENT_METADATA_UPDATED:{S.comments.notify(V);break}case Ee.FEEDS_LIST:{const Q=V,De=Ve.get(Q.requestId);De&&(De.resolve({feeds:Q.feeds,nextCursor:Q.nextCursor}),Ve.delete(Q.requestId)),S.feeds.notify(Q);break}case Ee.FEEDS_ADDED:{const Q=V;S.feeds.notify(Q),on(Q);break}case Ee.FEEDS_UPDATED:{const Q=V;S.feeds.notify(Q),on(Q);break}case Ee.FEED_DELETED:{S.feeds.notify(V),on(V);break}case Ee.FEED_MESSAGES_LIST:{const Q=V,De=Mt.get(Q.requestId);De&&(De.resolve({messages:Q.messages,nextCursor:Q.nextCursor}),Mt.delete(Q.requestId)),S.feeds.notify(Q);break}case Ee.FEED_MESSAGES_ADDED:{const Q=V;S.feeds.notify(Q),on(Q);break}case Ee.FEED_MESSAGES_UPDATED:{const Q=V;S.feeds.notify(Q),on(Q);break}case Ee.FEED_MESSAGES_DELETED:{S.feeds.notify(V),on(V);break}case Ee.FEED_REQUEST_FAILED:{if(!he(V))break;const{requestId:Q,code:De,reason:Ue}=V,ze=new pu(Ue??"Feed request failed",{type:"FEED_REQUEST_ERROR",roomId:n,requestId:Q,code:De,reason:Ue});if(gt.has(Q))vt(Q,"error",ze);else if(Ve.has(Q)){const _t=Ve.get(Q);Ve.delete(Q),_t?.reject(ze)}else if(Mt.has(Q)){const _t=Mt.get(Q);Mt.delete(Q),_t?.reject(ze)}S.feeds.notify(V);break}case Ee.STORAGE_STATE_V7:}J(H)}function Fe(){const x=l.buffer.storageOperations;if(x.length>0){for(const V of x)l.unacknowledgedOps.add(V);Ts()}if(c.getStatus()!=="connected"){l.buffer.storageOperations=[];return}const U=Date.now(),H=U-l.buffer.lastFlushedAt;if(H>=t.throttleDelay){const V=Xe();if(V.length===0)return;oe(V),l.buffer={flushTimerID:void 0,lastFlushedAt:U,messages:[],storageOperations:[],presenceUpdates:null}}else clearTimeout(l.buffer.flushTimerID),l.buffer.flushTimerID=setTimeout(Fe,t.throttleDelay-H)}function Xe(){const x=[];l.buffer.presenceUpdates&&x.push(l.buffer.presenceUpdates.type==="full"?{type:rt.UPDATE_PRESENCE,targetActor:-1,data:l.buffer.presenceUpdates.data}:{type:rt.UPDATE_PRESENCE,data:l.buffer.presenceUpdates.data});for(const U of l.buffer.messages)x.push(U);return l.buffer.storageOperations.length>0&&x.push({type:rt.UPDATE_STORAGE,ops:l.buffer.storageOperations}),x}function ht(x,U,H){const V={type:rt.UPDATE_YDOC,update:x,guid:U,v2:H};l.buffer.messages.push(V),S.ydoc.notify(V),Fe()}function Gt(x,U={shouldQueueEventIfNotReady:!1}){c.getStatus()!=="connected"&&!U.shouldQueueEventIfNotReady||(l.buffer.messages.push({type:rt.BROADCAST_EVENT,event:x}),Fe())}function He(x){const{storageOperations:U}=l.buffer;for(const H of x)U.push(H);Fe()}let pt=null,mt=null;const Ve=new Map,Mt=new Map,gt=new Map,qt=new Map;function vt(x,U,H){const V=gt.get(x);if(V!==void 0){if(clearTimeout(V.timeoutId),gt.delete(x),V.kind==="add-message"&&!V.expectedClientMessageId){const Q=qt.get(V.feedId);if(Q!==void 0){const De=Q.indexOf(x);De>=0&&Q.splice(De,1),Q.length===0&&qt.delete(V.feedId)}}U==="ok"?V.resolve():V.reject(H??new Error("Feed mutation failed"))}}function rn(x,U,H,V){const{promise:Q,resolve:De,reject:Ue}=Jr(),ze=setTimeout(()=>{gt.has(x)&&vt(x,"error",new Error("Feed mutation timeout"))},Aa);if(gt.set(x,{resolve:De,reject:Ue,timeoutId:ze,kind:U,feedId:H,messageId:V?.messageId,expectedClientMessageId:V?.expectedClientMessageId}),U==="add-message"&&V?.expectedClientMessageId===void 0){const _t=qt.get(H)??[];_t.push(x),qt.set(H,_t)}return Q}function on(x){switch(x.type){case Ee.FEEDS_ADDED:{for(const U of x.feeds)for(const[H,V]of[...gt])if(V.kind==="add-feed"&&V.feedId===U.feedId){vt(H,"ok");break}break}case Ee.FEEDS_UPDATED:{for(const U of x.feeds)for(const[H,V]of[...gt])V.kind==="update-feed"&&V.feedId===U.feedId&&vt(H,"ok");break}case Ee.FEED_DELETED:{for(const[U,H]of[...gt])if(H.kind==="delete-feed"&&H.feedId===x.feedId){vt(U,"ok");break}break}case Ee.FEED_MESSAGES_ADDED:{for(const U of x.messages){let H=!1;for(const[V,Q]of[...gt])if(Q.kind==="add-message"&&Q.feedId===x.feedId&&Q.expectedClientMessageId===U.id){vt(V,"ok"),H=!0;break}if(!H){const Q=qt.get(x.feedId)?.[0];if(Q!==void 0){const De=gt.get(Q);De?.kind==="add-message"&&De.expectedClientMessageId===void 0&&vt(Q,"ok")}}}break}case Ee.FEED_MESSAGES_UPDATED:{for(const U of x.messages)for(const[H,V]of[...gt])V.kind==="update-message"&&V.feedId===x.feedId&&V.messageId===U.id&&vt(H,"ok");break}case Ee.FEED_MESSAGES_DELETED:{for(const U of x.messageIds)for(const[H,V]of[...gt])V.kind==="delete-message"&&V.feedId===x.feedId&&V.messageId===U&&vt(H,"ok");break}}}function sC(x){const U=[...l.unacknowledgedOps.values()];ee(x),re(U),mt?.(),Ts(),S.storageDidLoad.notify()}function bl(){const x=l.buffer.messages;x.some(U=>U.type===rt.FETCH_STORAGE)||(x.push({type:rt.FETCH_STORAGE}),m.take(),g?.start())}function wl(){return pt===null&&(bl(),Fe(),pt=new Promise(x=>{mt=x}),Ts()),pt}function sa(){const x=l.root;return x!==void 0?x:(wl(),null)}async function Dl(){return l.root!==void 0?Promise.resolve({root:l.root}):(await wl(),{root:ge(l.root)})}function iC(x,U,H){l.buffer.messages.find(V=>V.type===rt.FETCH_YDOC&&V.vector===x&&V.guid===U&&V.v2===H)||l.buffer.messages.push({type:rt.FETCH_YDOC,vector:x,guid:U,v2:H}),Fe()}async function aC(x){const U=it(),{promise:H,resolve:V,reject:Q}=Jr();Ve.set(U,{resolve:V,reject:Q});const De={type:rt.FETCH_FEEDS,requestId:U,cursor:x?.cursor,since:x?.since,limit:x?.limit,metadata:x?.metadata};return l.buffer.messages.push(De),Fe(),setTimeout(()=>{Ve.has(U)&&(Ve.delete(U),Q(new Error("Feeds fetch timeout")))},Aa),H}async function uC(x,U){const H=it(),{promise:V,resolve:Q,reject:De}=Jr();Mt.set(H,{resolve:Q,reject:De});const Ue={type:rt.FETCH_FEED_MESSAGES,requestId:H,feedId:x,cursor:U?.cursor,since:U?.since,limit:U?.limit};return l.buffer.messages.push(Ue),Fe(),setTimeout(()=>{Mt.has(H)&&(Mt.delete(H),De(new Error("Feed messages fetch timeout")))},Aa),V}function cC(x,U){const H=it(),V=rn(H,"add-feed",x),Q={type:rt.ADD_FEED,requestId:H,feedId:x,metadata:U?.metadata,createdAt:U?.createdAt};return l.buffer.messages.push(Q),Fe(),V}function lC(x,U){const H=it(),V=rn(H,"update-feed",x),Q={type:rt.UPDATE_FEED,requestId:H,feedId:x,metadata:U};return l.buffer.messages.push(Q),Fe(),V}function dC(x){const U=it(),H=rn(U,"delete-feed",x),V={type:rt.DELETE_FEED,requestId:U,feedId:x};return l.buffer.messages.push(V),Fe(),H}function fC(x,U,H){const V=it(),Q=rn(V,"add-message",x,{expectedClientMessageId:H?.id}),De={type:rt.ADD_FEED_MESSAGE,requestId:V,feedId:x,data:U,id:H?.id,createdAt:H?.createdAt};return l.buffer.messages.push(De),Fe(),Q}function hC(x,U,H,V){const Q=it(),De=rn(Q,"update-message",x,{messageId:U}),Ue={type:rt.UPDATE_FEED_MESSAGE,requestId:Q,feedId:x,messageId:U,data:H,updatedAt:V?.updatedAt};return l.buffer.messages.push(Ue),Fe(),De}function pC(x,U){const H=it(),V=rn(H,"delete-message",x,{messageId:U}),Q={type:rt.DELETE_FEED_MESSAGE,requestId:H,feedId:x,messageId:U};return l.buffer.messages.push(Q),Fe(),V}function mC(){if(l.activeBatch)throw new Error("undo is not allowed during a batch");const x=l.undoStack.pop();if(x===void 0)return;l.pausedHistory=null;const U=ie(x);J(U.updates),l.redoStack.push(U.reverse),Me();for(const H of U.opsToEmit)l.buffer.storageOperations.push(H);Fe()}function gC(){if(l.activeBatch)throw new Error("redo is not allowed during a batch");const x=l.redoStack.pop();if(x===void 0)return;l.pausedHistory=null;const U=ie(x);J(U.updates),l.undoStack.push(U.reverse),Me();for(const H of U.opsToEmit)l.buffer.storageOperations.push(H);Fe()}function vC(){l.undoStack.length=0,l.redoStack.length=0}function CC(x){if(l.activeBatch)return x();let U;l.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:new Da,scheduleHistoryResume:!1};try{U=x()}finally{const H=l.activeBatch;l.activeBatch=null,H.reverseOps.length>0&&q(Array.from(H.reverseOps)),H.scheduleHistoryResume&&Al(),H.ops.length>0&&(l.redoStack.length=0),H.ops.length>0&&He(H.ops),J(H.updates),Fe()}return U}function EC(){l.pausedHistory===null&&(l.pausedHistory=new Da)}function Al(){const x=l.pausedHistory;l.pausedHistory=null,x!==null&&x.length>0&&R(Array.from(x))}function yC(){if(l.activeBatch!==null){l.activeBatch.scheduleHistoryResume=!0;return}Al()}let ia=0;function Sl(x){const U=l.undoStack,H=l.redoStack,V=[],Q=[];l.undoStack=V,l.redoStack=Q,ia++;try{return x()}finally{if(ia--,l.undoStack!==V||l.redoStack!==Q)throw new Error("unexpected stack swap during history.disable()");l.undoStack=U,l.redoStack=H}}const aa=t.createSyncSource();function ua(){return l.root===void 0?pt===null?"not-loaded":"loading":l.unacknowledgedOps.size===0?"synchronized":"synchronizing"}let xl=ua();function Ts(){const x=ua();xl!==x&&(xl=x,S.storageStatus.notify(x)),aa.setSyncStatus(x==="synchronizing"?"synchronizing":"synchronized")}function Ol(){return G.get()!==null}async function bC(){for(;!Ol();){const{promise:x,resolve:U}=Jr(),H=ca.self.subscribeOnce(U),V=ca.status.subscribeOnce(U);await x,H(),V()}}function Tl(){return sa()!==null}async function wC(){for(;!Tl();)await Dl()}const DC=je.from(l.others.signal,x=>x.map((U,H)=>nd(`Other ${H}`,U))),ca={status:S.status.observable,lostConnection:S.lostConnection.observable,customEvent:S.customEvent.observable,others:S.others.observable,self:S.self.observable,myPresence:S.myPresence.observable,storageBatch:S.storageBatch.observable,history:S.history.observable,storageDidLoad:S.storageDidLoad.observable,storageStatus:S.storageStatus.observable,ydoc:S.ydoc.observable,comments:S.comments.observable,feeds:S.feeds.observable,roomWillDestroy:S.roomWillDestroy.observable};async function AC(x){return s.getThreadsSince({roomId:n,since:x.since,signal:x.signal})}async function SC(x){return s.getThreads({roomId:n,query:x?.query,cursor:x?.cursor})}async function xC(x){return s.getThread({roomId:n,threadId:x})}async function OC(x){return s.createThread({roomId:n,threadId:x.threadId,commentId:x.commentId,visibility:x.visibility,metadata:x.metadata,body:x.body,commentMetadata:x.commentMetadata,attachmentIds:x.attachmentIds})}async function TC(x){return s.deleteThread({roomId:n,threadId:x})}async function RC({metadata:x,threadId:U}){return s.editThreadMetadata({roomId:n,threadId:U,metadata:x})}async function IC({threadId:x,commentId:U,metadata:H}){return s.editCommentMetadata({roomId:n,threadId:x,commentId:U,metadata:H})}async function BC(x){return s.markThreadAsResolved({roomId:n,threadId:x})}async function FC(x){return s.markThreadAsUnresolved({roomId:n,threadId:x})}async function PC(x){return s.subscribeToThread({roomId:n,threadId:x})}async function MC(x){return s.unsubscribeFromThread({roomId:n,threadId:x})}async function _C(x){return s.createComment({roomId:n,threadId:x.threadId,commentId:x.commentId,body:x.body,metadata:x.metadata,attachmentIds:x.attachmentIds})}async function kC(x){return s.editComment({roomId:n,threadId:x.threadId,commentId:x.commentId,body:x.body,metadata:x.metadata,attachmentIds:x.attachmentIds})}async function NC({threadId:x,commentId:U}){return s.deleteComment({roomId:n,threadId:x,commentId:U})}async function jC({threadId:x,commentId:U,emoji:H}){return s.addReaction({roomId:n,threadId:x,commentId:U,emoji:H})}async function LC({threadId:x,commentId:U,emoji:H}){return await s.removeReaction({roomId:n,threadId:x,commentId:U,emoji:H})}function UC(x){return{type:"localAttachment",status:"idle",id:qh(),name:x.name,size:x.size,mimeType:x.type,file:x}}async function $C(x,U={}){return s.uploadAttachment({roomId:n,attachment:x,signal:U.signal})}function HC(x){return s.getAttachmentUrl({roomId:n,attachmentId:x})}function Rl(x){return s.getSubscriptionSettings({roomId:n,signal:x?.signal})}function Il(x){return s.updateSubscriptionSettings({roomId:n,settings:x})}async function VC(x){await s.markRoomInboxNotificationAsRead({roomId:n,inboxNotificationId:x})}const la=t.createSyncSource();function da(x){return la.setSyncStatus(x==="synchronizing"||x==="loading"?"synchronizing":"synchronized")}return Object.defineProperty({[Ce]:{get presenceBuffer(){return ao(l.buffer.presenceUpdates?.data??null)},get undoStack(){return ao(l.undoStack)},get nodeCount(){return l.pool.nodes.size},getYjsProvider(){return l.yjsProvider},setYjsProvider(x){l.yjsProvider?.off("status",da),l.yjsProvider=x,x?.on("status",da),l.yjsProviderDidChange.notify()},yjsProviderDidChange:l.yjsProviderDidChange.observable,reportTextEditor:F,getPermissionMatrix:()=>l.dynamicSessionInfoSig.get()?.permissionMatrix,createTextMention:P,deleteTextMention:L,listHistoryVersions:M,listHistoryVersionsSince:N,fetchStorageHistoryVersion:_,fetchYjsHistoryVersion:I,liveObjectFromNodeStream:XE,reconcileStorageWithNodes:te,createVersionHistorySnapshot:j,deleteHistoryVersion:z,executeContextualPrompt:Y,getSelf_forDevTools:()=>de.get(),getOthers_forDevTools:()=>DC.get(),simulate:{explicitClose:x=>c._privateSendMachineEvent({type:"EXPLICIT_SOCKET_CLOSE",event:x}),rawSend:x=>c.send(x),incomingMessage:x=>Ie(new MessageEvent("message",{data:x}))},attachmentUrlsStore:s.getOrCreateAttachmentUrlsStore(n)},id:n,subscribe:by(n,S,t.errorEventSource),connect:()=>c.connect(),reconnect:()=>c.reconnect(),disconnect:()=>c.disconnect(),_dump:()=>{const x=l.pool.nodes.size;return`Room "${n}" (${x} node${x===1?"":"s"}):
|
|
5
|
+
${ny(l.pool)}`},destroy:()=>{Ve.forEach(H=>H.reject(new Error("Room destroyed"))),Mt.forEach(H=>H.reject(new Error("Room destroyed")));const{roomWillDestroy:x,...U}=S;for(const H of Object.values(U))H.dispose();S.roomWillDestroy.notify(),l.yjsProvider?.off("status",da),aa.destroy(),la.destroy(),a(),c.destroy(),x.dispose()},updatePresence:me,updateYDoc:ht,broadcastEvent:Gt,batch:CC,history:{undo:mC,redo:gC,canUndo:xe,canRedo:ke,clear:vC,pause:EC,resume:yC,disable:Sl},fetchYDoc:iC,fetchFeeds:aC,fetchFeedMessages:uC,addFeed:cC,updateFeed:lC,deleteFeed:dC,addFeedMessage:fC,updateFeedMessage:hC,deleteFeedMessage:pC,getStorage:Dl,getStorageOrNull:sa,getStorageSnapshot:sa,getStorageStatus:ua,isPresenceReady:Ol,isStorageReady:Tl,waitUntilPresenceReady:Ml(bC),waitUntilStorageReady:Ml(wC),events:ca,getStatus:()=>c.getStatus(),getSelf:()=>G.get(),getPresence:()=>l.myPresence.get(),getOthers:()=>l.others.get(),getThreads:SC,getThreadsSince:AC,getThread:xC,createThread:OC,deleteThread:TC,editThreadMetadata:RC,markThreadAsResolved:BC,markThreadAsUnresolved:FC,subscribeToThread:PC,unsubscribeFromThread:MC,createComment:_C,editComment:kC,editCommentMetadata:IC,deleteComment:NC,addReaction:jC,removeReaction:LC,prepareAttachment:UC,uploadAttachment:$C,getAttachmentUrl:HC,getNotificationSettings:Rl,getSubscriptionSettings:Rl,updateNotificationSettings:Il,updateSubscriptionSettings:Il,markInboxNotificationAsRead:VC},Ce,{enumerable:!1})}function by(e,t,n){function r(i,a){return t.storageBatch.subscribe(u=>{const c=u.filter(d=>gp(d.node,i));c.length>0&&a(c)})}function o(i,a){return t.storageBatch.subscribe(u=>{for(const c of u)c.node._id===i._id&&a(c.node)})}function s(i,a,u){if(typeof i=="string"&&wy(i)){if(typeof a!="function")throw new Error("Second argument must be a callback function");const c=a;switch(i){case"event":return t.customEvent.subscribe(c);case"my-presence":return t.myPresence.subscribe(c);case"others":{const d=c;return t.others.subscribe(l=>{const{others:m,...g}=l;return d(m,g)})}case"error":return n.subscribe(d=>{if(d.roomId===e)return c(d)});case"status":return t.status.subscribe(c);case"lost-connection":return t.lostConnection.subscribe(c);case"history":return t.history.subscribe(c);case"storage-status":return t.storageStatus.subscribe(c);case"comments":return t.comments.subscribe(c);default:return Je(i,`"${String(i)}" is not a valid event name`)}}if(a===void 0||typeof i=="function")if(typeof i=="function"){const c=i;return t.storageBatch.subscribe(c)}else throw new Error("Please specify a listener callback");if(et(i)){const c=i;return u?.isDeep?r(c,a):o(c,a)}throw new Error(`${String(i)} is not a value that can be subscribed to.`)}return s}function wy(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="history"||e==="status"||e==="storage-status"||e==="lost-connection"||e==="connection"||e==="comments"}function Dy(e,t){return async()=>t.getAuthValue({roomId:e,resource:"room",access:"read"})}function Ay(e,t,n){return r=>{const o=n??(typeof WebSocket>"u"?void 0:WebSocket);if(o===void 0)throw new xn("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const s=new URL(t);if(s.protocol=s.protocol==="http:"?"ws":"wss",s.pathname="/v8",s.searchParams.set("roomId",e),r.type==="secret")s.searchParams.set("tok",r.token.raw);else if(r.type==="public")s.searchParams.set("pubkey",r.publicApiKey);else return Je(r,"Unhandled case");return s.searchParams.set("version",Ti),new o(s.toString())}}var Sy=16,xy=1e3,Oy=100,Ty=15e3,Ry=200,Iy=1e3,By=3e4,Fy=5e3,Py=50,My=50,_y=50;function ky(e){return typeof e=="string"&&e.startsWith("http")?e:_E}function Ny(e){const t=e,n=ky(t.baseUrl),r=jy(t.throttle??Oy),o=Ly(t.lostConnectionTimeout??Fy),s=rd(t.backgroundKeepAliveTimeout),i=new St(void 0),a=RE(e,ee=>{i.set(()=>ee.uid)}),u=t.polyfills?.fetch||globalThis.fetch?.bind(globalThis),c=_1({baseUrl:n,fetchPolyfill:u,authManager:a}),d=new Map,l=fE({userId:i.get(),lostConnectionTimeout:o,backgroundKeepAliveTimeout:rd(t.backgroundKeepAliveTimeout),polyfills:t.polyfills,delegates:{createSocket:hE(n,t.polyfills?.WebSocket),authenticate:async()=>{const ee=await a.getAuthValue({resource:"personal",access:"write"});if(ee.type==="public")throw new xn("Cannot use AI Copilots with a public API key");return ee},canZombie:()=>!1}});function m(ee){ee.id,d.delete(ee.id),ee.destroy()}function g(ee){const te=()=>{const R=te;ee.unsubs.delete(R)?ee.unsubs.size===0&&m(ee.room):ft("This leave function was already called. Calling it more than once has no effect.")};return ee.unsubs.add(te),{room:ee.room,leave:te}}function v(ee,...te){const R=d.get(ee);if(R!==void 0)return g(R);const q=te[0]??{},J=(typeof q.initialPresence=="function"?q.initialPresence(ee):q.initialPresence)??{},X=(typeof q.initialStorage=="function"?q.initialStorage(ee):q.initialStorage)??{};let ie;if(ic(X)){const me={};for(const fe of X.keys())me[fe]=X.get(fe);ie=me}else ie=X;const ae=yy({initialPresence:J,initialStorage:ie},{roomId:ee,throttleDelay:r,lostConnectionTimeout:o,backgroundKeepAliveTimeout:s,polyfills:t.polyfills,delegates:t.mockedDelegates??{createSocket:Ay(ee,n,t.polyfills?.WebSocket),authenticate:Dy(ee,a)},enableDebugLogging:t.enableDebugLogging,baseUrl:n,errorEventSource:Y,roomHttpClient:c,createSyncSource:Z,badgeLocation:t.badgeLocation??"bottom-right"}),we={room:ae,unsubs:new Set};if(d.set(ee,we),q.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");tu.atob=t.polyfills.atob}ae.connect()}return g(we)}function C(ee){const te=d.get(ee)?.room;return te||null}function p(){a.reset(),i.set(()=>{});for(const{room:ee}of d.values())H1(ee.getStatus())||ee.reconnect()}const D=t.resolveUsers,w=new mr(async ee=>{const te=ee.flat(),R=await D?.({userIds:te});return wa(!D,"Set the resolveUsers option in createClient to specify user info."),R??te.map(()=>{})},{delay:Py}),b=$o(w);function y(ee){b.invalidate(ee)}const A=t.resolveRoomsInfo,T=new mr(async ee=>{const te=ee.flat(),R=await A?.({roomIds:te});return wa(!A,"Set the resolveRoomsInfo option in createClient to specify room info."),R??te.map(()=>{})},{delay:My}),S=$o(T);function P(ee){S.invalidate(ee)}const L=t.resolveGroupsInfo,F=new mr(async ee=>{const te=ee.flat(),R=await L?.({groupIds:te});return wa(!L,"Set the resolveGroupsInfo option in createClient to specify group info."),R??te.map(()=>{})},{delay:_y}),M=$o(F);function N(ee){M.invalidate(ee)}const _=new Map;function I(){_.clear()}const j=[],z=new St("synchronized"),Y=Ne();function oe(){const ee=z.get();return ee==="synchronizing"?ee:"synchronized"}function G(){z.set(j.some(ee=>ee.get()==="synchronizing")?"synchronizing":j.some(ee=>ee.get()==="has-local-changes")?"has-local-changes":"synchronized")}function Z(){const ee=new St("synchronized");j.push(ee);const te=ee.subscribe(()=>G());function R(X){ee.set(X)}function q(){return ee.get()}function J(){te();const X=j.findIndex(ie=>ie===ee);if(X>-1){const[ie]=j.splice(X,1);ie.get()!=="synchronized"&&G()}}return{setSyncStatus:R,getStatus:q,destroy:J}}{const ee=R=>{t.preventUnsavedChanges&&z.get()!=="synchronized"&&R.preventDefault()};(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",ee)}async function le(ee){const te=await c.getNotificationSettings(ee);return ui(te)}async function de(ee){const te=await c.updateNotificationSettings(ee);return ui(te)}const ue=Object.defineProperty({enterRoom:v,getRoom:C,_dump:()=>Array.from(d.values(),({room:ee})=>ee._dump()).join(`
|
|
6
|
+
|
|
7
|
+
`),logout:p,getInboxNotifications:c.getInboxNotifications,getInboxNotificationsSince:c.getInboxNotificationsSince,getUnreadInboxNotificationsCount:c.getUnreadInboxNotificationsCount,markAllInboxNotificationsAsRead:c.markAllInboxNotificationsAsRead,markInboxNotificationAsRead:c.markInboxNotificationAsRead,deleteAllInboxNotifications:c.deleteAllInboxNotifications,deleteInboxNotification:c.deleteInboxNotification,getNotificationSettings:le,updateNotificationSettings:de,resolvers:{invalidateUsers:y,invalidateRoomsInfo:P,invalidateGroupsInfo:N,invalidateMentionSuggestions:I},getSyncStatus:oe,events:{error:Y,syncStatus:z},[Ce]:{currentUserId:i,mentionSuggestionsCache:_,ai:l,resolveMentionSuggestions:t.resolveMentionSuggestions,usersStore:b,roomsInfoStore:S,groupsInfoStore:M,getRoomIds(){return Array.from(d.keys())},httpClient:c,as:()=>ue,createSyncSource:Z,emitError:(ee,te)=>{const R=pu.from(ee,te);Y.notify(R)||Jn(R.message)}}},Ce,{enumerable:!1});return ue}function ac(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 rd(e){if(e!==void 0)return ac("backgroundKeepAliveTimeout",e,Ty)}function jy(e){return ac("throttle",e,Sy,xy)}function Ly(e){return ac("lostConnectionTimeout",e,Ry,By,Iy)}function Uy(e){return"type"in e&&e.type==="paragraph"}function bp(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function uc(e){return"type"in e&&e.type==="mention"}function cc(e){return"type"in e&&e.type==="link"}var $y={paragraph:Uy,text:bp,link:cc,mention:uc};function Hy(e,t,n){if(!e||!e?.content)return;const o=$y[t],s=n;for(const i of e.content)for(const a of i.children)o(a)&&s?.(a)}function Vy(e,t){const n=new Set,r=[];return Hy(e,"mention",o=>{n.has(o.id)||(n.add(o.id),r.push(o))}),r}var Wy={"&":"&","<":"<",">":">",'"':""","'":"'"};new RegExp(Object.keys(Wy).map(e=>`\\${e}`).join("|"),"g");var zy={_:"\\_","*":"\\*","#":"\\#","`":"\\`","~":"\\~","!":"\\!","|":"\\|","(":"\\(",")":"\\)","{":"\\{","}":"\\}","[":"\\[","]":"\\]"};new RegExp(Object.keys(zy).map(e=>`\\${e}`).join("|"),"g");var Sa=[1e3,2e3,4e3,8e3,1e4];function vr(e,t,n){const r=performance.now(),o=typeof document<"u"?document:void 0,s=typeof window<"u"?window:void 0,i=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 c=new Zh({}).addState("@idle").addState("@enabled").addState("@polling");c.addTransitions("@idle",{START:"@enabled"}),c.addTransitions("@enabled",{STOP:"@idle",POLL:"@polling"}),c.addTimedTransition("@enabled",()=>{const w=a.lastSuccessfulPollAt+t;return Math.max(0,w-performance.now())+a.backoff},"@polling"),c.onEnterAsync("@polling",async(D,w)=>{await e(w),w.aborted||(a.lastSuccessfulPollAt=performance.now())},()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=0}}),()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=Sa.find(D=>D>a.backoff)??Sa[Sa.length-1]}}),3e4);function d(){u()?c.send({type:"START"}):c.send({type:"STOP"})}function l(){a.count++,d()}function m(){a.count--,a.count<0&&(a.count=0),d()}function g(){performance.now()-a.lastSuccessfulPollAt>i&&c.send({type:"POLL"})}function v(){a.lastSuccessfulPollAt=performance.now()-i-1}function C(D){a.inForeground=D,d(),g()}function p(){C(o?.visibilityState!=="hidden")}return o?.addEventListener("visibilitychange",p),s?.addEventListener("online",p),s?.addEventListener("focus",g),c.start(),{inc:l,dec:m,pollNowIfStale:g,markAsStale:v,setInForeground:C}}function Er(e,t){return typeof e=="string"?`${e}:${t}`:`${e.kind}:${e.subjectId}`}Yu(n1,Ti,r1);var Ky="@liveblocks/client",Gy="3.22.0",qy="esm";Yu(Ky,Gy,qy);var wp=f.createContext(null);function lc(){return f.useContext(wp)}function _e(){return lc()??Ft("LiveblocksProvider is missing from the React tree.")}var Br=f.createContext(null);function Yy(e=Br){return f.useContext(e)}function Bi(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e},[e]),t}function Xt(e,t){return f.useMemo(()=>e,[t])}function Io(e,t){const n=Xt(e,t),r=Bi(e),o=f.useCallback(((...s)=>r.current(...s)),[r]);return typeof n=="function"?o:n}function Jy(){return _e()[Ce].ai}function Zy(){return f.useState(it)[0]}f.memo(function(t){const n=f.useId(),r=Jy(),{description:o,value:s,chatId:i}=t,[a,u]=f.useState();f.useEffect(()=>{const{layerKey:l,deregister:m}=r.registerKnowledgeLayer(n,i);return u(l),()=>{m(),u(void 0)}},[r,n,i]);const c=Zy(),d=t.id??c;return f.useEffect(()=>{a!==void 0&&r.updateKnowledge(a,{description:o,value:s},d,i)},[r,a,d,o,s,i]),null});f.memo(function({chatId:t,name:n,tool:r,enabled:o}){const i=_e()[Ce].ai;return f.useEffect(()=>{const a=o!==void 0?{...r,enabled:o}:r;return i.registerTool(n,a,t)},[i,t,n,r,o]),null});function Xy(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}function bo(e,t,n,r,o){const s=f.useRef(null);let i;s.current===null?(i={hasValue:!1,value:null},s.current=i):i=s.current;const[a,u]=f.useMemo(()=>{let d=!1,l,m;const g=D=>{if(!d){d=!0,l=D;const A=r(D);if(o!==void 0&&i.hasValue){const T=i.value;if(o(T,A))return m=T,T}return m=A,A}const w=l,b=m;if(Xy(w,D))return b;const y=r(D);return o!==void 0&&o(b,y)?(l=D,b):(l=D,m=y,y)},v=n===void 0?null:n;return[()=>g(t()),v===null?void 0:()=>g(v())]},[t,n,r,o]),c=f.useSyncExternalStore(e,a,u);return f.useEffect(()=>{i.hasValue=!0,i.value=c},[c]),f.useDebugValue(c),c}var Qy=e=>e;function Fr(e,t,n){if(e instanceof xt)throw new Error("Using a mutable Signal with useSignal will likely not work as expected.");return bo(e.subscribe,e.get,e.get,t??Qy,n)}var qr=1e3,ir=60*qr,Rt={NOTIFICATIONS_POLL_INTERVAL:1*ir,NOTIFICATIONS_MAX_STALE_TIME:5*qr,ROOM_THREADS_POLL_INTERVAL:5*ir,ROOM_THREADS_MAX_STALE_TIME:5*qr,USER_THREADS_POLL_INTERVAL:1*ir,USER_THREADS_MAX_STALE_TIME:30*qr,HISTORY_VERSIONS_POLL_INTERVAL:1*ir,HISTORY_VERSIONS_MAX_STALE_TIME:5*qr,ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL:1*ir,ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME:5*qr,USER_NOTIFICATION_SETTINGS_INTERVAL:5*ir,USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME:1*ir},ci=Object.freeze({isLoading:!0}),Dp=e=>Object.freeze({isLoading:!1,error:e});function Qt(e,t){return arguments.length===1?Object.freeze({isLoading:!1,data:e}):Object.freeze({isLoading:!1,[e]:t})}function dc(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 eb(e,t){for(const n of e)if(t(n))return n}function tb(e,t){return n=>nb(n,e,t)&&rb(n,e)}function nb(e,t,n){let r;return n&&(r=n?.[Er("thread",e.id)]),(t.resolved===void 0||e.resolved===t.resolved)&&(t.visibility===void 0||e.visibility===t.visibility)&&(t.subscribed===void 0||t.subscribed===!0&&r!==void 0||t.subscribed===!1&&r===void 0)}function rb(e,t){const n=e.metadata;return t.metadata===void 0||Object.entries(t.metadata).every(([r,o])=>o===void 0||ob(n[r],o))}function ob(e,t){return t===null?e===void 0:su(t)?typeof e=="string"&&e.startsWith(t.startsWith):iu(t)?typeof e=="number"&&sb(e,t):e===t}function sb(e,t){return(t.lt===void 0||e<t.lt)&&(t.gt===void 0||e>t.gt)&&(t.lte===void 0||e<=t.lte)&&(t.gte===void 0||e>=t.gte)}function ib(e){return t=>ab(t,e)}function ab(e,t){return(t.roomId===void 0||t.roomId===e.roomId)&&(t.kind===void 0||t.kind===e.kind)}function ub(e){return e.deletedAt&&e.comments.length>0?{...e,comments:[]}:e.comments.some(n=>!n.deletedAt)?e:{...e,deletedAt:new Date,comments:[]}}var cb=class Ap{#e;#t;#n;signal;constructor(){this.#t=zn.from([],(t,n)=>{const r=t.createdAt,o=n.createdAt;return r<o?!0:r===o?t.id<n.id:!1}),this.#n=zn.from([],(t,n)=>{const r=n.updatedAt,o=t.updatedAt;return r<o?!0:r===o?n.id<t.id:!1}),this.#e=new Map,this.signal=new xt(this)}clone(){const t=new Ap;return t.#e=new Map(this.#e),t.#t=this.#t.clone(),t.#n=this.#n.clone(),t}get(t){const n=this.getEvenIfDeleted(t);return n?.deletedAt?void 0:n}getEvenIfDeleted(t){return this.#e.get(t)}upsert(t){this.signal.mutate(()=>{t=ub(t);const n=t.id,r=this.#e.get(n);if(r){if(r.deletedAt)return!1;this.#t.remove(r),this.#n.remove(r)}return t.deletedAt||(this.#t.add(t),this.#n.add(t)),this.#e.set(n,t),!0})}upsertIfNewer(t){const n=this.get(t.id);(!n||t.updatedAt>=n.updatedAt)&&this.upsert(t)}applyDelta(t,n){Ze(()=>{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 s=r==="desc"?this.#n:this.#t,i=[];return t!==void 0&&i.push(a=>a.roomId===t),n!==void 0&&i.push(tb(n,o)),Array.from(s.filter(a=>i.every(u=>u(a))))}};function lb(e,t){return Zn([e,t??{}])}function db(e){return Zn(e??{})}function fb(e){return Zn({})}function Sp(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 hb=Promise.resolve(),Ur=class{#e;signal;#t;#n;#r;constructor(e,t){this.#e=new St(ci),this.#t=e,this.#n=null,this.#r=t?.autoRetry??!0,this.signal=this.#e.asReadonly(),dc(this)}get(){return this.#e.get()}#o(e){const t=this.#e.get();t.data!==void 0&&this.#e.set(Qt({...t.data,...e}))}async#s(){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.#s()),this.#n):hb}#i=null;waitUntilLoaded(){if(this.#i)return this.#i;const e=this.#r?Uo(()=>this.#t(void 0),5,[5e3,5e3,1e4,15e3]):Promise.resolve().then(()=>this.#t(void 0)),t=Sp(e);return t.then(n=>{this.#e.set(Qt({cursor:n,hasFetchedAll:n===null,isFetchingMore:!1,fetchMoreError:void 0,fetchMore:this.fetchMore}))},n=>{this.#e.set(Dp(n)),this.#r&&setTimeout(()=>{this.#i=null,this.#e.set(ci)},5e3)}),this.#i=t,this.#i}},ar=class{#e;signal;#t;#n=!0;constructor(e,t=!0){this.#e=new St(ci),this.signal=this.#e.asReadonly(),this.#t=e,this.#n=t,dc(this)}get(){return this.#e.get()}#r=null;waitUntilLoaded(){if(this.#r)return this.#r;const e=this.#n?Uo(()=>this.#t(),5,[5e3,5e3,1e4,15e3]):this.#t(),t=Sp(e);return t.then(()=>{this.#e.set(Qt(void 0))},n=>{this.#e.set(Dp(n)),this.#n&&setTimeout(()=>{this.#r=null,this.#e.set(ci)},5e3)}),this.#r=t,t}};function pb(){const e=new xt(new Map);function t(u,c){e.mutate(d=>{const l=d.get(u);return l?(d.set(u,{...l,readAt:c}),!0):!1})}function n(u){e.mutate(c=>{for(const d of c.values())d.readAt=u})}function r(u){e.mutate(c=>c.delete(u))}function o(){e.mutate(u=>u.clear())}function s(u,c){e.mutate(d=>{let l=!1;for(const m of u){const g=d.get(m.id);g&&Bb(g,m)===1||(d.set(m.id,m),l=!0)}for(const m of c)d.delete(m.id),l=!0;return l})}function i(u){e.mutate(c=>{const d=eb(c.values(),l=>l.kind==="thread"&&l.threadId===u.threadId);return d?(c.set(d.id,{...d,notifiedAt:u.createdAt,readAt:u.createdAt}),!0):!1})}function a(u){e.mutate(c=>{c.set(u.id,u)})}return{signal:e.asReadonly(),markAllRead:n,markRead:t,delete:r,applyDelta:s,clear:o,updateAssociatedNotification:i,upsert:a}}function mb(){const e=new xt(new Map);function t(n,r){e.mutate(o=>{o.set(n,r)})}return{signal:je.from(e,n=>Object.fromEntries(n)),update:t}}function gb(e,t){const n=new xt(new Map);function r(i,a){n.mutate(u=>{let c=!1;for(const d of i)u.set(Er(d),d),c=!0;for(const d of a)u.delete(Er(d)),c=!0;return c})}function o(i){n.mutate(a=>{a.set(Er(i),i)})}function s(i){n.mutate(a=>{a.delete(i)})}return{signal:je.from(n,e,(i,a)=>Rb(i,t,a)),applyDelta:r,create:o,delete:s}}function vb(e){const t=new xt(new Map);function n(r,o){t.mutate(s=>{s.set(r,o)})}return{signal:je.from(t,e,(r,o)=>Tb(r,o)),update:n}}function Cb(){const e=new xt(new Le(()=>new Map));function t(n,r){e.mutate(o=>{const s=o.getOrCreate(n);for(const i of r)s.set(i.id,i)})}return{signal:je.from(e,n=>Object.fromEntries([...n].map(([r,o])=>[r,Object.fromEntries(o)]))),update:t}}function Eb(){const e=new xt(new Map);function t(n,r){e.mutate(o=>{o.set(n,r)})}return{signal:je.from(e,n=>Object.fromEntries(n)),update:t}}function yb(){const e=new Le(()=>new St(void 0));function t(r,o,s){Ze(()=>{const i=s===void 0?Object.keys(r):new Set([...s,...Object.keys(r)]);for(const a of i){const u=e.getOrCreate(a),c=u.get();c!==void 0&&c.requestedAt>o||u.set({requestedAt:o,permissions:nc(r[a]??[])})}})}function n(r){return e.getOrCreate(r)}return{getPermissionForRoomΣ:n,update:t}}function bb(e){const t=new St(ui({}));function n(r){t.set(r)}return{signal:je.from(t,e,(r,o)=>Ib(r,o)),update:n}}var wb=new Set(["mark-inbox-notification-as-read"]);function Db(e){const t=new St([]),n=e[Ce].createSyncSource();t.subscribe(()=>n.setSyncStatus(t.get().some(s=>!wb.has(s.type))?"synchronizing":"synchronized"));function r(s){const i=it(),a={...s,id:i};return t.set(u=>[...u,a]),i}function o(s){t.set(i=>i.filter(a=>a.id!==s))}return{signal:t.asReadonly(),add:r,remove:o}}function Ab(){const e=new xt(new Map);function t(o,s){e.mutate(i=>{let a=i.get(o);a||(a=new Map,i.set(o,a));for(const u of s)a.set(u.feedId,u)})}function n(o,s){e.mutate(i=>{i.get(o)?.delete(s)})}function r(o,s,i){const a=Array.from(o.get(s)?.values()??[]).filter(u=>{if(i?.since!==void 0&&u.updatedAt<i.since&&u.createdAt<i.since)return!1;if(i?.metadata!==void 0){const c=u.metadata;if(!Object.entries(i.metadata).every(([d,l])=>c[d]===l))return!1}return!0});return a.sort((u,c)=>{const d=u.createdAt-c.createdAt;return d!==0?d:u.feedId<c.feedId?-1:u.feedId>c.feedId?1:0}),a}return{signal:e,upsert:t,delete:n,findMany:r}}function Sb(){const e=new xt(new Map);function t(o,s){e.mutate(i=>{let a=i.get(o);a||(a=new Map,i.set(o,a));for(const u of s)a.set(u.id,u)})}function n(o,s){e.mutate(i=>{const a=i.get(o);if(a)for(const u of s)a.delete(u)})}function r(o,s){return Array.from(o.get(s)?.values()??[]).sort((i,a)=>i.createdAt-a.createdAt)}return{signal:e,upsert:t,delete:n,findMany:r}}var xb=class{#e;threads;notifications;subscriptions;roomSubscriptionSettings;historyVersions;unreadNotificationsCount;urlsMetadata;permissionHints;notificationSettings;optimisticUpdates;outputs;#t=null;#n=new Map;#r=null;#o=new Map;#s;#i=Ab();#u=Sb();constructor(e){this.#e=e[Ce].as(),this.optimisticUpdates=Db(this.#e),this.permissionHints=yb();const t=async()=>{const b=await this.#e.getNotificationSettings();this.notificationSettings.update(b)};this.notificationSettings=bb(this.optimisticUpdates.signal),this.#s=new ar(t),this.threads=new cb,this.subscriptions=gb(this.optimisticUpdates.signal,this.threads),this.notifications=pb(),this.roomSubscriptionSettings=vb(this.optimisticUpdates.signal),this.historyVersions=Cb(),this.unreadNotificationsCount=mb(),this.urlsMetadata=Eb();const n=je.from(this.threads.signal,this.notifications.signal,this.optimisticUpdates.signal,(b,y,A)=>Ob(b,y,A)),r=je.from(n,b=>b.threadsDB),o=je.from(n,b=>({sortedNotifications:b.sortedNotifications,notificationsById:b.notificationsById}),at),s=je.from(o,this.subscriptions.signal,(b,y)=>({subscriptions:y,notifications:b.sortedNotifications})),i=new Le(b=>{const y=JSON.parse(b),A=new Ur(async S=>{const P=await this.#e[Ce].httpClient.getUserThreads_experimental({cursor:S,query:y});return this.updateThreadifications(P.threads,P.inboxNotifications,P.subscriptions),this.permissionHints.update(P.permissionHints,P.requestedAt),this.#r===null&&(this.#r=P.requestedAt),P.nextCursor});return{signal:je.from(()=>{const S=A.get();if(S.isLoading||S.error)return S;const P=s.get().subscriptions,L=this.outputs.threads.get().findMany(void 0,y??{},"desc",P),F=S.data;return{isLoading:!1,threads:L,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}},Gr),waitUntilLoaded:A.waitUntilLoaded}}),a=new Le(b=>{const[y,A]=JSON.parse(b),T=new Ur(async P=>{const L=await this.#e[Ce].httpClient.getThreads({roomId:y,cursor:P,query:A});this.updateThreadifications(L.threads,L.inboxNotifications,L.subscriptions),this.permissionHints.update(L.permissionHints,L.requestedAt,[y]);const F=this.#n.get(y);return(F===void 0||F>L.requestedAt)&&this.#n.set(y,L.requestedAt),L.nextCursor});return{signal:je.from(()=>{const P=T.get();if(P.isLoading||P.error)return P;const L=s.get().subscriptions,F=this.outputs.threads.get().findMany(y,A??{},"asc",L),M=P.data;return{isLoading:!1,threads:F,hasFetchedAll:M.hasFetchedAll,isFetchingMore:M.isFetchingMore,fetchMoreError:M.fetchMoreError,fetchMore:M.fetchMore}},Gr),waitUntilLoaded:T.waitUntilLoaded}}),u=new Le(b=>{const y=JSON.parse(b),A=new Ur(async S=>{const P=await this.#e.getInboxNotifications({cursor:S,query:y});return this.updateThreadifications(P.threads,P.inboxNotifications,P.subscriptions),this.#t===null&&(this.#t=P.requestedAt),P.nextCursor});return{signal:je.from(()=>{const S=A.get();if(S.isLoading||S.error)return S;const P=[];y!==void 0&&P.push(ib(y));const L=this.outputs.notifications.get().sortedNotifications.filter(M=>P.every(N=>N(M))),F=S.data;return{isLoading:!1,inboxNotifications:L,hasFetchedAll:F.hasFetchedAll,isFetchingMore:F.isFetchingMore,fetchMoreError:F.fetchMoreError,fetchMore:F.fetchMore}},Gr),waitUntilLoaded:A.waitUntilLoaded}}),c=new Le(b=>{const y=JSON.parse(b),A=new ar(async()=>{const S=await this.#e.getUnreadInboxNotificationsCount({query:y});this.unreadNotificationsCount.update(b,S)});return{signal:je.from(()=>{const S=A.get();return S.isLoading||S.error?S:Qt("count",ge(this.unreadNotificationsCount.signal.get()[b]))},at),waitUntilLoaded:A.waitUntilLoaded}}),d=new Le(b=>{const y=new ar(async()=>{const T=this.#e.getRoom(b);if(T===null)throw new Error(`Room '${b}' is not available on client`);const S=await T.getSubscriptionSettings();this.roomSubscriptionSettings.update(b,S)});return{signal:je.from(()=>{const T=y.get();return T.isLoading||T.error?T:Qt("settings",ge(this.roomSubscriptionSettings.signal.get()[b]))},at),waitUntilLoaded:y.waitUntilLoaded}}),l=new Le(b=>{const y=new ar(async()=>{const T=this.#e.getRoom(b);if(T===null)throw new Error(`Room '${b}' is not available on client`);const S=await T[Ce].listHistoryVersions();this.historyVersions.update(b,S.versions);const P=this.#o.get(b);(P===void 0||P>S.requestedAt)&&this.#o.set(b,S.requestedAt)});return{signal:je.from(()=>{const T=y.get();return T.isLoading||T.error?T:Qt("versions",Object.values(this.historyVersions.signal.get()[b]??{}))},at),waitUntilLoaded:y.waitUntilLoaded}}),m={signal:je.from(()=>{const b=this.#s.get();return b.isLoading||b.error?b:Qt("settings",ge(this.notificationSettings.signal.get()))},at),waitUntilLoaded:this.#s.waitUntilLoaded},g=new Le(b=>{const y=JSON.parse(b),A=new Ur(async S=>(await this.#e[Ce].ai.getChats({cursor:S,query:y})).nextCursor);return{signal:je.from(()=>{const S=A.get();return S.isLoading||S.error?S:{isLoading:!1,chats:this.#e[Ce].ai.queryChats(y),hasFetchedAll:S.data.hasFetchedAll,isFetchingMore:S.data.isFetchingMore,fetchMore:S.data.fetchMore,fetchMoreError:S.data.fetchMoreError}},at),waitUntilLoaded:A.waitUntilLoaded}}),v=new Le(b=>{const y=new ar(async()=>{await this.#e[Ce].ai.getMessageTree(b)});return new Le(A=>({signal:je.from(()=>{const S=y.get();return S.isLoading||S.error?S:Qt("messages",this.#e[Ce].ai.signals.getChatMessagesForBranchΣ(b,A??void 0).get())}),waitUntilLoaded:y.waitUntilLoaded}))}),C=new Le(b=>{const y=new ar(async()=>{await this.#e[Ce].ai.getOrCreateChat(b)});return{signal:je.from(()=>{if(this.#e[Ce].ai.getChatById(b)===void 0){const S=y.get();return S.isLoading||S.error?S:Qt("chat",ge(this.#e[Ce].ai.getChatById(b)))}else return Qt("chat",ge(this.#e[Ce].ai.getChatById(b)))},at),waitUntilLoaded:y.waitUntilLoaded}}),p=new Le(b=>{const y=new ar(async()=>{const T=await this.#e[Ce].httpClient.getUrlMetadata(b);this.urlsMetadata.update(b,T)},!1);return{signal:je.from(()=>{const T=y.get();return T.isLoading||T.error?T:Qt("metadata",ge(this.urlsMetadata.signal.get()[b]))},at),waitUntilLoaded:y.waitUntilLoaded}}),D=new Le(b=>{const[y,A]=JSON.parse(b),T=new Ur(async P=>{const L=this.#e.getRoom(y);if(L===null)throw new Error(`Room '${y}' is not available on client. Make sure you're calling useFeeds inside a RoomProvider.`);const F=await L.fetchFeeds({cursor:P,since:A?.since,metadata:A?.metadata,limit:A?.limit});return this.upsertFeeds(y,F.feeds),F.nextCursor??null},{autoRetry:!1});return{signal:je.from(T.signal,this.#i.signal,(P,L)=>{if(P.isLoading||P.error)return P;const F=this.#i.findMany(L,y,A),M=P.data;return{isLoading:!1,feeds:F,hasFetchedAll:M.hasFetchedAll,isFetchingMore:M.isFetchingMore,fetchMoreError:M.fetchMoreError,fetchMore:M.fetchMore}},Gr),waitUntilLoaded:T.waitUntilLoaded}}),w=new Le(b=>{const[y,A,T]=JSON.parse(b),S=new Ur(async L=>{const F=this.#e.getRoom(y);if(F===null)throw new Error(`Room '${y}' is not available on client. Make sure you're calling useFeedMessages inside a RoomProvider.`);const M=await F.fetchFeedMessages(A,{cursor:L,limit:T?.limit});return this.upsertFeedMessages(y,A,M.messages),M.nextCursor??null},{autoRetry:!1});return{signal:je.from(S.signal,this.#u.signal,(L,F)=>{if(L.isLoading||L.error)return L;const M=this.#u.findMany(F,A),N=L.data;return{isLoading:!1,messages:M,hasFetchedAll:N.hasFetchedAll,isFetchingMore:N.isFetchingMore,fetchMoreError:N.fetchMoreError,fetchMore:N.fetchMore}},Gr),waitUntilLoaded:S.waitUntilLoaded}});this.outputs={threadifications:n,threads:r,loadingRoomThreads:a,loadingUserThreads:i,notifications:o,loadingNotifications:u,unreadNotificationsCount:c,roomSubscriptionSettingsByRoomId:d,versionsByRoomId:l,notificationSettings:m,threadSubscriptions:s,aiChats:g,messagesByChatId:v,aiChatById:C,urlMetadataByUrl:p,loadingFeeds:D,loadingFeedMessages:w},dc(this)}markInboxNotificationRead(e,t,n){Ze(()=>{this.optimisticUpdates.remove(n),this.notifications.markRead(e,t)})}markAllInboxNotificationsRead(e,t){Ze(()=>{this.optimisticUpdates.remove(e),this.notifications.markAllRead(t)})}deleteInboxNotification(e,t){Ze(()=>{this.optimisticUpdates.remove(t),this.notifications.delete(e)})}deleteAllInboxNotifications(e){Ze(()=>{this.optimisticUpdates.remove(e),this.notifications.clear()})}createSubscription(e,t){Ze(()=>{this.optimisticUpdates.remove(t),this.subscriptions.create(e)})}deleteSubscription(e,t){Ze(()=>{this.optimisticUpdates.remove(t),this.subscriptions.delete(e)})}createThread(e,t){Ze(()=>{this.optimisticUpdates.remove(e),this.threads.upsert(t)})}#a(e,t,n,r){Ze(()=>{t!==null&&this.optimisticUpdates.remove(t);const o=this.threads,s=o.get(e);s&&(r&&s.updatedAt>r||o.upsert(n(s)))})}patchThread(e,t,n,r){return this.#a(e,t,o=>({...o,...ps(n)}),r)}addReaction(e,t,n,r,o){this.#a(e,t,s=>Op(s,n,r),o)}removeReaction(e,t,n,r,o,s){this.#a(e,t,i=>Tp(i,n,r,o,s),s)}deleteThread(e,t){return this.#a(e,t,n=>({...n,updatedAt:new Date,deletedAt:new Date}))}createComment(e,t){Ze(()=>{this.optimisticUpdates.remove(t);const n=this.threads.get(e.threadId);n&&(this.threads.upsert(Wo(n,e)),this.notifications.updateAssociatedNotification(e))})}editComment(e,t,n){return this.#a(e,t,r=>Wo(r,n))}editCommentMetadata(e,t,n,r,o){return this.#a(e,n,s=>s.comments.find(a=>a.id===t)===void 0?s:{...s,updatedAt:o,comments:s.comments.map(a=>a.id===t?{...a,metadata:r}:a)},o)}deleteComment(e,t,n,r){return this.#a(e,t,o=>xp(o,n,r),r)}updateThreadifications(e,t,n,r=[],o=[],s=[]){Ze(()=>{this.threads.applyDelta(e,r),this.notifications.applyDelta(t,o),this.subscriptions.applyDelta(n,s)})}updateRoomSubscriptionSettings(e,t,n){Ze(()=>{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.#i.upsert(e,t)}deleteFeed(e,t){this.#i.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[Ce].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[Ce].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 o=await ge(this.#e.getRoom(e),`Room with id ${e} is not available on client`)[Ce].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 r=await ge(this.#e.getRoom(e),`Room with id ${e} is not available on client`).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){Ze(()=>{this.optimisticUpdates.remove(t),this.notificationSettings.update(e)})}};function Ob(e,t,n){const r=e.clone();let o=Object.fromEntries(t);for(const i of n)switch(i.type){case"create-thread":{r.upsert(i.thread);break}case"edit-thread-metadata":{const a=r.get(i.threadId);if(a===void 0||a.updatedAt>i.updatedAt)break;r.upsert({...a,updatedAt:i.updatedAt,metadata:{...a.metadata,...i.metadata}});break}case"mark-thread-as-resolved":{const a=r.get(i.threadId);if(a===void 0)break;r.upsert({...a,resolved:!0});break}case"mark-thread-as-unresolved":{const a=r.get(i.threadId);if(a===void 0)break;r.upsert({...a,resolved:!1});break}case"create-comment":{const a=r.get(i.comment.threadId);if(a===void 0)break;r.upsert(Wo(a,i.comment));const u=Object.values(o).find(c=>c.kind==="thread"&&c.threadId===a.id);if(u===void 0)break;o[u.id]={...u,notifiedAt:i.comment.createdAt,readAt:i.comment.createdAt};break}case"edit-comment":{const a=r.get(i.comment.threadId);if(a===void 0)break;r.upsert(Wo(a,i.comment));break}case"edit-comment-metadata":{const a=r.get(i.threadId);if(a===void 0||a.updatedAt>i.updatedAt)break;const u=a.comments.find(c=>c.id===i.commentId);if(u===void 0)break;r.upsert(Wo(a,{...u,metadata:{...u.metadata,...i.metadata}}));break}case"delete-comment":{const a=r.get(i.threadId);if(a===void 0)break;r.upsert(xp(a,i.commentId,i.deletedAt));break}case"delete-thread":{const a=r.get(i.threadId);if(a===void 0)break;r.upsert({...a,deletedAt:i.deletedAt,updatedAt:i.deletedAt,comments:[]});break}case"add-reaction":{const a=r.get(i.threadId);if(a===void 0)break;r.upsert(Op(a,i.commentId,i.reaction));break}case"remove-reaction":{const a=r.get(i.threadId);if(a===void 0)break;r.upsert(Tp(a,i.commentId,i.emoji,i.userId,i.removedAt));break}case"mark-inbox-notification-as-read":{const a=o[i.inboxNotificationId];if(a===void 0)break;o[i.inboxNotificationId]={...a,readAt:i.readAt};break}case"mark-all-inbox-notifications-as-read":{for(const a in o){const u=o[a];if(u===void 0)break;o[a]={...u,readAt:i.readAt}}break}case"delete-inbox-notification":{delete o[i.inboxNotificationId];break}case"delete-all-inbox-notifications":{o={};break}}return{sortedNotifications:Object.values(o).filter(i=>i.kind==="thread"?r.get(i.threadId)!==void 0:!0).sort((i,a)=>a.notifiedAt.getTime()-i.notifiedAt.getTime()),notificationsById:o,threadsDB:r}}function Tb(e,t){const n=Object.fromEntries(e);for(const r of t)switch(r.type){case"update-room-subscription-settings":{const o=n[r.roomId];if(o===void 0)break;n[r.roomId]={...o,...r.settings}}}return n}function Rb(e,t,n){const r=Object.fromEntries(e);for(const o of n)switch(o.type){case"update-room-subscription-settings":{if(!o.settings.threads)continue;const s=t.findMany(o.roomId,void 0,"desc",void 0);for(const i of s){const a=Er("thread",i.id);switch(o.settings.threads){case"all":{r[a]={kind:"thread",subjectId:i.id,createdAt:new Date};break}case"none":{delete r[a];break}case"replies_and_mentions":break;default:Je(o.settings.threads,"Unexpected thread subscription settings.")}}}}return r}function Ib(e,t){let n=e;for(const r of t)r.type==="update-notification-settings"&&(n=uy(n,r.settings));return n}function Bb(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 Wo(e,t){if(e.deletedAt!==void 0)return e;if(t.threadId!==e.id)return Vt.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(s=>s.id===t.id?r:s);return{...e,comments:o}}if(n.editedAt===void 0||t.editedAt===void 0||n.editedAt<=t.editedAt){const r=e.comments.map(s=>s.id===t.id?t:s);return{...e,updatedAt:new Date(Math.max(e.updatedAt.getTime(),t.editedAt?.getTime()||t.createdAt.getTime())),comments:r}}return e}function xp(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find(s=>s.id===t);if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map(s=>s.id===t?{...s,deletedAt:n,body:void 0,attachments:[]}:s);return o.every(s=>s.deletedAt!==void 0)?{...e,deletedAt:n,updatedAt:n}:{...e,updatedAt:n,comments:o}}function Op(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find(s=>s.id===t);if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map(s=>s.id===t?{...s,reactions:Fb(s.reactions,n)}:s);return{...e,updatedAt:new Date(Math.max(n.createdAt.getTime(),e.updatedAt.getTime())),comments:o}}function Tp(e,t,n,r,o){if(e.deletedAt!==void 0)return e;const s=e.comments.find(a=>a.id===t);if(s===void 0||s.deletedAt!==void 0)return e;const i=e.comments.map(a=>a.id===t?{...a,reactions:a.reactions.map(u=>u.emoji===n?{...u,users:u.users.filter(c=>c.id!==r)}:u).filter(u=>u.users.length>0)}:a);return{...e,updatedAt:new Date(Math.max(o.getTime(),e.updatedAt.getTime())),comments:i}}function Fb(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 Rp(e){return new Error(`resolveUsers didn't return anything for user '${e}'`)}function Pb(e){return new Error(`resolveRoomsInfo didn't return anything for room '${e}'`)}function Mb(e){return new Error(`resolveGroupsInfo didn't return anything for group '${e}'`)}function _b(e){return e}var od=new WeakMap,sd=new WeakMap;function kb(e,t){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:e.data?{isLoading:!1,user:e.data}:{isLoading:!1,error:Rp(t)}}function Nb(e,t){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:e.data?{isLoading:!1,info:e.data}:{isLoading:!1,error:Pb(t)}}function jb(e,t){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:e.data?{isLoading:!1,info:e.data}:{isLoading:!1,error:Mb(t)}}function Ip(e){let t=od.get(e);return t||(t=new xb(e),od.set(e,t)),t}function ms(e){let t=sd.get(e);return t||(t=Lb(e),sd.set(e,t)),t}function Lb(e){const t=Ip(e),n=vr(async i=>{try{return await t.fetchNotificationsDeltaUpdate(i)}catch(a){throw Vt.warn(`Polling new inbox notifications failed: ${String(a)}`),a}},Rt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.NOTIFICATIONS_MAX_STALE_TIME}),r=new Le(i=>vr(async a=>{try{return await t.fetchUnreadNotificationsCount(i,a)}catch(u){throw Vt.warn(`Polling unread inbox notifications countfailed: ${String(u)}`),u}},Rt.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.NOTIFICATIONS_MAX_STALE_TIME})),o=vr(async i=>{try{return await t.fetchUserThreadsDeltaUpdate(i)}catch(a){throw Vt.warn(`Polling new user threads failed: ${String(a)}`),a}},Rt.USER_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Rt.USER_THREADS_MAX_STALE_TIME}),s=vr(async i=>{try{return await t.refreshNotificationSettings(i)}catch(a){throw Vt.warn(`Polling new notification settings failed: ${String(a)}`),a}},Rt.USER_NOTIFICATION_SETTINGS_INTERVAL,{maxStaleTimeMs:Rt.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME});return{store:t,notificationsPoller:n,userThreadsPoller:o,notificationSettingsPoller:s,unreadNotificationsCountPollersByQueryKey:r}}function Ub(e,t,n,r){const{store:o,notificationsPoller:s}=ms(e),i=fb();return f.useEffect(()=>{o.outputs.loadingNotifications.getOrCreate(i).waitUntilLoaded()}),f.useEffect(()=>(s.inc(),s.pollNowIfStale(),()=>{s.dec()}),[s]),Fr(o.outputs.loadingNotifications.getOrCreate(i).signal,t,n)}function $b(e){return f.useCallback(t=>{const{store:n,unreadNotificationsCountPollersByQueryKey:r}=ms(e),o=new Date,s=n.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:t,readAt:o});e.markInboxNotificationAsRead(t).then(()=>{n.markInboxNotificationRead(t,o,s);for(const i of r.values())i.markAsStale(),i.pollNowIfStale()},i=>{n.optimisticUpdates.remove(s),e[Ce].emitError({type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",inboxNotificationId:t},i)})},[e])}function Hb(e){return f.useCallback(t=>{const{store:n,unreadNotificationsCountPollersByQueryKey:r}=ms(e),o=new Date,s=n.optimisticUpdates.add({type:"delete-inbox-notification",inboxNotificationId:t,deletedAt:o});e.deleteInboxNotification(t).then(()=>{n.deleteInboxNotification(t,s);for(const i of r.values())i.markAsStale(),i.pollNowIfStale()},i=>{n.optimisticUpdates.remove(s),e[Ce].emitError({type:"DELETE_INBOX_NOTIFICATION_ERROR",inboxNotificationId:t},i)})},[e])}function Vb(e,t){const{store:n}=ms(e);return Fr(n.outputs.threadifications,f.useCallback(r=>{const o=r.notificationsById[t]??Ft(`Inbox notification with ID "${t}" not found`);return o.kind!=="thread"&&Ft(`Inbox notification with ID "${t}" is not of kind "thread"`),r.threadsDB.get(o.threadId)??Ft(`Thread with ID "${o.threadId}" not found, this inbox notification might not be of kind "thread"`)},[t]))}function Wb(e,t){const n=e[Ce].usersStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=f.useCallback(i=>kb(i,t),[t]),s=bo(n.subscribe,r,r,o,at);return f.useEffect(()=>{n.enqueue(t)}),s}function zb(e,t){const n=e[Ce].usersStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=r();if(!o||o.isLoading)throw n.enqueue(t);if(o.error)throw o.error;if(!o.data)throw Rp(t);const s=f.useSyncExternalStore(n.subscribe,r,r);return s.isLoading,s.error,{isLoading:!1,user:s.data,error:void 0}}function Kb(e,t){const n=e[Ce].roomsInfoStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=f.useCallback(i=>Nb(i,t),[t]),s=bo(n.subscribe,r,r,o,at);return f.useEffect(()=>{n.enqueue(t)}),s}function Gb(e,t){const n=e[Ce].groupsInfoStore,r=f.useCallback(()=>n.getItemState(t),[n,t]),o=f.useCallback(i=>jb(i,t),[t]),s=bo(n.subscribe,r,r,o,at);return f.useEffect(()=>{n.enqueue(t)}),s}function qb(e){const t=lc();if(!e?.allowNesting&&t!==null)throw new Error("You cannot nest multiple LiveblocksProvider instances in the same React tree.")}function Yb(e){return qb(e),h.jsx(wp.Provider,{value:e.client,children:e.children})}function m4(e){const{children:t,...n}=e,r={publicApiKey:Xt(n.publicApiKey),throttle:Xt(n.throttle),lostConnectionTimeout:Xt(n.lostConnectionTimeout),backgroundKeepAliveTimeout:Xt(n.backgroundKeepAliveTimeout),polyfills:Xt(n.polyfills),preventUnsavedChanges:Xt(n.preventUnsavedChanges),badgeLocation:Xt(n.badgeLocation),authEndpoint:Io(n.authEndpoint),resolveMentionSuggestions:Io(n.resolveMentionSuggestions),resolveUsers:Io(n.resolveUsers),resolveRoomsInfo:Io(n.resolveRoomsInfo),resolveGroupsInfo:Io(n.resolveGroupsInfo),baseUrl:Xt(n.baseUrl),enableDebugLogging:Xt(n.enableDebugLogging)},o=f.useMemo(()=>Ny(r),[]);return f.useEffect(()=>()=>{o[Ce].ai.disconnect()},[o]),h.jsx(Yb,{client:o,children:t})}function Jb(e={}){const t=_e(),{store:n,userThreadsPoller:r}=ms(t),o=db(e.query);return f.useEffect(()=>{n.outputs.loadingUserThreads.getOrCreate(o).waitUntilLoaded()}),f.useEffect(()=>(r.inc(),r.pollNowIfStale(),()=>{r.dec()}),[r]),Fr(n.outputs.loadingUserThreads.getOrCreate(o).signal)}function g4(e){return Ub(_e(),_b,at)}function Zb(e){return Vb(_e(),e)}function Xb(){return $b(_e())}function Qb(){return Hb(_e())}function ew(e){const t=_e();return Wb(t,e)}function tw(e){const t=_e();return zb(t,e)}function fc(e){return Kb(_e(),e)}function hc(e){return Gb(_e(),e)}var nw=Zb,Bp=ew,v4=tw,C4=Jb;function rw(e,t){if(e===!1||!t.threads||!(typeof window<"u"))return;const o=window.location.hash.slice(1);if(!o.startsWith("cm_"))return;const s=document.getElementById(o);s===null||!t.threads.flatMap(u=>u.comments).some(u=>u.id===o)||s.scrollIntoView()}function ow(e,t){f.useEffect(()=>{rw(e,t)},[t.isLoading])}function Fi(e){const t=e[Ce].currentUserId.get();return t===void 0?"anonymous":t}var id=new WeakMap;function bt(e){let t=id.get(e);return t||(t=sw(e),id.set(e,t)),t}function wo(e,t){return e.outputs.threads.get().getEvenIfDeleted(t)?.visibility}function sw(e){const t=Ip(e);function n(i,a,u){if(t.optimisticUpdates.remove(i),u instanceof uo){if(u.status===403){const c=[u.message,u.details?.suggestion,u.details?.docs].filter(Boolean).join(`
|
|
8
|
+
`);Vt.error(c)}e[Ce].emitError(a,u)}else throw u}const r=new Le(i=>vr(async a=>{try{return await t.fetchRoomThreadsDeltaUpdate(i,a)}catch(u){throw Vt.warn(`Polling new threads for '${i}' failed: ${String(u)}`),u}},Rt.ROOM_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Rt.ROOM_THREADS_MAX_STALE_TIME})),o=new Le(i=>vr(async a=>{try{return await t.fetchRoomVersionsDeltaUpdate(i,a)}catch(u){throw Vt.warn(`Polling new history versions for '${i}' failed: ${String(u)}`),u}},Rt.HISTORY_VERSIONS_POLL_INTERVAL,{maxStaleTimeMs:Rt.HISTORY_VERSIONS_MAX_STALE_TIME})),s=new Le(i=>vr(async a=>{try{return await t.refreshRoomSubscriptionSettings(i,a)}catch(u){throw Vt.warn(`Polling subscription settings for '${i}' failed: ${String(u)}`),u}},Rt.ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL,{maxStaleTimeMs:Rt.ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME}));return{store:t,onMutationFailure:n,pollThreadsForRoomId:i=>{const a=r.getOrCreate(i);a&&(a.markAsStale(),a.pollNowIfStale())},getOrCreateThreadsPollerForRoomId:r.getOrCreate.bind(r),getOrCreateVersionsPollerForRoomId:o.getOrCreate.bind(o),getOrCreateSubscriptionSettingsPollerForRoomId:s.getOrCreate.bind(s)}}function iw(e){const t=_e(),[n]=f.useState(()=>new Map),r=f.useCallback((o,s)=>{const i=n.get(o);if(i)return i;const a=t.enterRoom(o,s),u=a.leave;return a.leave=()=>{u(),n.delete(o)},n.set(o,a),a},[t,n]);return h.jsx(aw,{...e,stableEnterRoom:r})}function aw(e){const t=_e(),{id:n,stableEnterRoom:r,BoundRoomContext:o}=e,s=Xt({initialPresence:e.initialPresence,initialStorage:e.initialStorage,autoConnect:e.autoConnect??typeof window<"u"},n),[{room:i},a]=f.useState(()=>r(n,{...s,autoConnect:!1}));return f.useEffect(()=>{const{store:u}=bt(t);async function c(d){if(d.type===Ee.THREAD_DELETED){u.deleteThread(d.threadId,null);return}const l=await i.getThread(d.threadId);if(!l.thread){u.deleteThread(d.threadId,null);return}const{thread:m,inboxNotification:g,subscription:v}=l,C=u.outputs.threads.get().getEvenIfDeleted(d.threadId);switch(d.type){case Ee.COMMENT_EDITED:case Ee.THREAD_METADATA_UPDATED:case Ee.THREAD_UPDATED:case Ee.COMMENT_REACTION_ADDED:case Ee.COMMENT_REACTION_REMOVED:case Ee.COMMENT_DELETED:case Ee.COMMENT_METADATA_UPDATED:if(!C)break;u.updateThreadifications([m],g?[g]:[],v?[v]:[]);break;case Ee.COMMENT_CREATED:u.updateThreadifications([m],g?[g]:[],v?[v]:[]);break}}return i.events.comments.subscribe(d=>{c(d)})},[t,i]),f.useEffect(()=>{const{store:u}=bt(t);function c(d){switch(d.type){case Ee.FEEDS_ADDED:case Ee.FEEDS_UPDATED:u.upsertFeeds(i.id,d.feeds);break;case Ee.FEED_DELETED:u.deleteFeed(i.id,d.feedId);break;case Ee.FEED_MESSAGES_ADDED:case Ee.FEED_MESSAGES_UPDATED:u.upsertFeedMessages(i.id,d.feedId,d.messages);break;case Ee.FEED_MESSAGES_DELETED:u.deleteFeedMessages(i.id,d.feedId,d.messageIds);break}}return i.events.feeds.subscribe(d=>{c(d)})},[t,i]),f.useEffect(()=>{const u=r(n,s);a(u);const{room:c,leave:d}=u;return s.autoConnect&&c.connect(),()=>{d()}},[n,s,r]),h.jsx(Br.Provider,{value:i,children:o?h.jsx(o.Provider,{value:i,children:e.children}):e.children})}function gs(e,t){const n=Yy(e);if(n===null&&!t?.allowOutsideRoom)throw new Error("RoomProvider is missing from the React tree.");return n}function uw(e){return gs(Br,e)}function pc(){return _e()[Ce].resolveMentionSuggestions}function cw(){return _e()[Ce].mentionSuggestionsCache}function lw(e,t={}){const{scrollOnLoad:n=!0}=t,r=_e(),o=gs(e),{store:s,getOrCreateThreadsPollerForRoomId:i}=bt(r),a=lb(o.id,t.query),u=i(o.id);f.useEffect(()=>{s.outputs.loadingRoomThreads.getOrCreate(a).waitUntilLoaded()}),f.useEffect(()=>(u.inc(),u.pollNowIfStale(),()=>u.dec()),[u]);const c=Fr(s.outputs.loadingRoomThreads.getOrCreate(a).signal);return ow(n,c),c}function dw(e={}){return lw(Br,e)}function fw(e){return Fp(gs(e).id)}function hw(){return fw(Br)}function Fp(e){const t=_e();return f.useCallback(n=>{const r=n.body,o=n.metadata??{},s=n.commentMetadata??{},i=n.attachments,a=n.visibility??"public",u=Gh(),c=ai(),d=new Date,l={id:c,threadId:u,roomId:e,createdAt:d,type:"comment",userId:Fi(t),body:r,reactions:[],attachments:i??[],metadata:s},m={id:u,type:"thread",createdAt:d,updatedAt:d,roomId:e,metadata:o,comments:[l],resolved:!1,visibility:a},{store:g,onMutationFailure:v}=bt(t),C=g.optimisticUpdates.add({type:"create-thread",thread:m,roomId:e}),p=i?.map(D=>D.id);return t[Ce].httpClient.createThread({roomId:e,threadId:u,commentId:c,body:r,visibility:a,metadata:o,commentMetadata:s,attachmentIds:p}).then(D=>{g.createThread(C,D)},D=>v(C,{type:"CREATE_THREAD_ERROR",roomId:e,threadId:u,commentId:c,body:r,visibility:a,metadata:o,commentMetadata:s},D)),m},[t,e])}function pw(e){return Pp(gs(e).id)}function mw(){return pw(Br)}function Pp(e){const t=_e();return f.useCallback(n=>{const{threadId:r,body:o}=n,s=n.metadata??{},i=n.attachments??[],a=ai(),c={id:a,threadId:r,roomId:e,type:"comment",createdAt:new Date,userId:Fi(t),body:o,reactions:[],attachments:i??[],metadata:s},{store:d,onMutationFailure:l}=bt(t),m=d.optimisticUpdates.add({type:"create-comment",comment:c}),g=i?.map(v=>v.id);return t[Ce].httpClient.createComment({roomId:e,threadId:r,commentId:a,body:o,metadata:s,attachmentIds:g,visibility:wo(d,r)}).then(v=>{d.createComment(v,m)},v=>l(m,{type:"CREATE_COMMENT_ERROR",roomId:e,threadId:r,commentId:a,body:o,metadata:s},v)),c},[t,e])}function Mp(e){const t=_e();return f.useCallback(({threadId:n,commentId:r,body:o,attachments:s,metadata:i})=>{const a=new Date,{store:u,onMutationFailure:c}=bt(t),d=u.outputs.threads.get().getEvenIfDeleted(n);if(d===void 0){Vt.warn(`Internal unexpected behavior. Cannot edit comment in thread "${n}" because the thread does not exist in the cache.`);return}const l=d.comments.find(C=>C.id===r);if(l===void 0||l.deletedAt!==void 0){Vt.warn(`Internal unexpected behavior. Cannot edit comment "${r}" in thread "${n}" because the comment does not exist in the cache.`);return}const m=i!==void 0?{...l.metadata,...i}:l.metadata,g=u.optimisticUpdates.add({type:"edit-comment",comment:{...l,editedAt:a,body:o,attachments:s??[],metadata:m}}),v=s?.map(C=>C.id);t[Ce].httpClient.editComment({roomId:e,threadId:n,commentId:r,body:o,attachmentIds:v,metadata:i,visibility:d.visibility}).then(C=>{u.editComment(n,g,C)},C=>c(g,{type:"EDIT_COMMENT_ERROR",roomId:e,threadId:n,commentId:r,body:o,metadata:m},C))},[t,e])}function gw(e){const t=_e();return f.useCallback(({threadId:n,commentId:r})=>{const o=new Date,{store:s,onMutationFailure:i}=bt(t),a=s.optimisticUpdates.add({type:"delete-comment",threadId:n,commentId:r,deletedAt:o,roomId:e});t[Ce].httpClient.deleteComment({roomId:e,threadId:n,commentId:r,visibility:wo(s,n)}).then(()=>{s.deleteComment(n,a,r,o)},u=>i(a,{type:"DELETE_COMMENT_ERROR",roomId:e,threadId:n,commentId:r},u))},[t,e])}function _p(e){const t=_e();return f.useCallback(({threadId:n,commentId:r,emoji:o})=>{const s=new Date,i=Fi(t),{store:a,onMutationFailure:u}=bt(t),c=a.optimisticUpdates.add({type:"add-reaction",threadId:n,commentId:r,reaction:{emoji:o,userId:i,createdAt:s}});t[Ce].httpClient.addReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:wo(a,n)}).then(d=>{a.addReaction(n,c,r,d,s)},d=>u(c,{type:"ADD_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},d))},[t,e])}function kp(e){const t=_e();return f.useCallback(({threadId:n,commentId:r,emoji:o})=>{const s=Fi(t),i=new Date,{store:a,onMutationFailure:u}=bt(t),c=a.optimisticUpdates.add({type:"remove-reaction",threadId:n,commentId:r,emoji:o,userId:s,removedAt:i});t[Ce].httpClient.removeReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:wo(a,n)}).then(()=>{a.removeReaction(n,c,r,o,s,i)},d=>u(c,{type:"REMOVE_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},d))},[t,e])}function vw(e){const t=_e();return f.useCallback(n=>{const{store:r,onMutationFailure:o}=bt(t),s=Object.values(r.outputs.notifications.get().notificationsById).find(u=>u.kind==="thread"&&u.threadId===n);if(!s)return;const i=new Date,a=r.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:s.id,readAt:i});t[Ce].httpClient.markRoomInboxNotificationAsRead({roomId:e,inboxNotificationId:s.id}).then(()=>{r.markInboxNotificationRead(s.id,i,a)},u=>{o(a,{type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",roomId:e,inboxNotificationId:s.id},u)})},[t,e])}function Cw(e){const t=_e();return f.useCallback(n=>{const r=new Date,{store:o,onMutationFailure:s}=bt(t),i=o.optimisticUpdates.add({type:"mark-thread-as-resolved",threadId:n,updatedAt:r});t[Ce].httpClient.markThreadAsResolved({roomId:e,threadId:n,visibility:wo(o,n)}).then(()=>{o.patchThread(n,i,{resolved:!0},r)},a=>s(i,{type:"MARK_THREAD_AS_RESOLVED_ERROR",roomId:e,threadId:n},a))},[t,e])}function Ew(e){const t=_e();return f.useCallback(n=>{const r=new Date,{store:o,onMutationFailure:s}=bt(t),i=o.optimisticUpdates.add({type:"mark-thread-as-unresolved",threadId:n,updatedAt:r});t[Ce].httpClient.markThreadAsUnresolved({roomId:e,threadId:n,visibility:wo(o,n)}).then(()=>{o.patchThread(n,i,{resolved:!1},r)},a=>s(i,{type:"MARK_THREAD_AS_UNRESOLVED_ERROR",roomId:e,threadId:n},a))},[t,e])}function yw(e){const t=_e();return f.useCallback(n=>{const r=new Date,{store:o,onMutationFailure:s}=bt(t),i=o.optimisticUpdates.add({type:"subscribe-to-thread",threadId:n,subscribedAt:r});t[Ce].httpClient.subscribeToThread({roomId:e,threadId:n}).then(a=>{o.createSubscription(a,i)},a=>s(i,{type:"SUBSCRIBE_TO_THREAD_ERROR",roomId:e,threadId:n},a))},[t,e])}function bw(e){const t=_e();return f.useCallback(n=>{const r=new Date,{store:o,onMutationFailure:s}=bt(t),i=o.optimisticUpdates.add({type:"unsubscribe-from-thread",threadId:n,unsubscribedAt:r});t[Ce].httpClient.unsubscribeFromThread({roomId:e,threadId:n}).then(()=>{o.deleteSubscription(Er("thread",n),i)},a=>s(i,{type:"UNSUBSCRIBE_FROM_THREAD_ERROR",roomId:e,threadId:n},a))},[t,e])}function Np(e,t){const n=_e(),{store:r}=bt(n),o=f.useMemo(()=>Er("thread",t),[t]),s=yw(e),i=bw(e),a=f.useCallback(()=>s(t),[s,t]),u=f.useCallback(()=>i(t),[i,t]),c=r.outputs.threadSubscriptions,d=f.useCallback(l=>{const m=l.subscriptions[o],g=l.notifications.find(v=>v.kind==="thread"&&v.threadId===t);return m===void 0?{status:"not-subscribed",subscribe:a,unsubscribe:u}:{status:"subscribed",unreadSince:g?.readAt??null,subscribe:a,unsubscribe:u}},[o,t,a,u]);return Fr(c,d,at)}function ww(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:(e.data,{isLoading:!1,url:e.data})}function Pi(e,t){const r=_e()[Ce].httpClient.getOrCreateAttachmentUrlsStore(t),o=f.useCallback(()=>r.getItemState(e),[r,e]);return f.useEffect(()=>{r.enqueue(e)},[r,e]),bo(r.subscribe,o,o,ww,at)}function Dw(e){const t=_e(),n=bt(t).store;return Fr(n.permissionHints.getPermissionForRoomΣ(e))?.permissions}function mc(e,t,n){const r=Dw(e),o=Aw(e,t,n);return r!==void 0?Yn(r,t,n):o}function Aw(e,t,n){const r=gs(Br,{allowOutsideRoom:!0}),o=f.useCallback(i=>r===null||r.id!==e?()=>{}:r.events.self.subscribe(i),[r,e]),s=f.useCallback(()=>{const i=t==="comments"||t==="comments:public"||t==="comments:private";if(r?.id===e){const a=r[Ce].getPermissionMatrix();if(a!==void 0)return Yn(a,t,n)}return!!(i||t==="storage")},[t,n,r,e]);return f.useSyncExternalStore(o,s,s)}var E4=iw,jp=uw,y4=hw,b4=mw,w4=dw;Yu(ZC,XC,QC);var gn=typeof window<"u"?f.useLayoutEffect:f.useEffect;function Sw(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:{isLoading:!1,group:e.data}}function xw(e){const n=_e()[Ce].httpClient.groupsStore,r=f.useCallback(()=>n.getItemState(e),[n,e]);return f.useEffect(()=>{n.enqueue(e)},[n,e]),bo(n.subscribe,r,r,Sw,at)}var ad=500;function Ow(e){return e.map(t=>typeof t=="string"?{kind:"user",id:t}:t)}function Tw(e,t){const[n,r]=f.useState(),o=f.useRef(),s=pc(),i=cw();return f.useEffect(()=>{if(t===void 0||!s)return;const a={text:t,roomId:e},u=Zn(a);let c,d=!1;const l=async()=>{try{o.current=performance.now();const m=await s(a);if(!d){const g=Ow(m);r(g),i.set(u,g)}}catch(m){console.error(m?.message)}};if(i.has(u)){const m=i.get(u);r(m)}else!o.current||Math.abs(performance.now()-o.current)>ad?l():c=window.setTimeout(()=>{l()},ad);return()=>{d=!0,window.clearTimeout(c)}},[t,e,s,i]),n}function Rw(){const t=_e()[Ce].createSyncSource,[n,r]=f.useState();return f.useEffect(()=>{const o=t();return r(o),()=>o.destroy()},[t]),n}const Do=6,vs=10,Iw="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif";function Be(...e){return e.filter(t=>typeof t=="string"||typeof t=="number").join(" ")}const gc=f.forwardRef(({emoji:e,className:t,style:n,...r},o)=>h.jsx("span",{role:"img","aria-label":e,"data-emoji":e,className:Be("lb-emoji",t),style:{...n,fontFamily:Iw},...r,ref:o,children:e}));function ud(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bw(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ud(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ud(e[o],null)}}}}function tt(...e){return f.useCallback(Bw(...e),e)}function lo(e){const t=f.forwardRef((n,r)=>{let{children:o,...s}=n,i=null,a=!1;const u=[];cd(o)&&typeof Ms=="function"&&(o=Ms(o._payload)),f.Children.forEach(o,m=>{if(kw(m)){a=!0;const g=m;let v="child"in g.props?g.props.child:g.props.children;cd(v)&&typeof Ms=="function"&&(v=Ms(v._payload)),i=Pw(g,v),u.push(i?.props?.children)}else u.push(m)}),i?i=f.cloneElement(i,void 0,u):!a&&f.Children.count(o)===1&&f.isValidElement(o)&&(i=o);const c=i?_w(i):void 0,d=tt(r,c);if(!i){if(o||o===0)throw new Error(a?Uw(e):Lw(e));return o}const l=Mw(s,i.props??{});return i.type!==f.Fragment&&(l.ref=r?d:c),f.cloneElement(i,l)});return t.displayName=`${e}.Slot`,t}var ot=lo("Slot"),Lp=Symbol.for("radix.slottable");function Up(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=Lp,t}var Fw=Up("Slottable"),Pw=(e,t)=>{if("child"in e.props){const n=e.props.child;return f.isValidElement(n)?f.cloneElement(n,void 0,e.props.children(n.props.children)):null}return f.isValidElement(t)?t:null};function Mw(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const u=s(...a);return o(...a),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function _w(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 kw(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lp}var Nw=Symbol.for("react.lazy");function cd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Nw&&"_payload"in e&&jw(e._payload)}function jw(e){return typeof e=="object"&&e!==null&&"then"in e}var Lw=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Uw=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Ms=Oi[" use ".trim().toString()],$w=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nt=$w.reduce((e,t)=>{const n=lo(`Primitive.${t}`),r=f.forwardRef((o,s)=>{const{asChild:i,...a}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(u,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function $p(e,t){e&&hs.flushSync(()=>e.dispatchEvent(t))}var Hw=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"}),Vw="VisuallyHidden",Hp=f.forwardRef((e,t)=>h.jsx(nt.span,{...e,ref:t,style:{...Hw,...e.style}}));Hp.displayName=Vw;var Ww=Hp;function Pr(e,t=[]){let n=[];function r(s,i){const a=f.createContext(i);a.displayName=s+"Context";const u=n.length;n=[...n,i];const c=l=>{const{scope:m,children:g,...v}=l,C=m?.[e]?.[u]||a,p=f.useMemo(()=>v,Object.values(v));return h.jsx(C.Provider,{value:p,children:g})};c.displayName=s+"Provider";function d(l,m,g={}){const{optional:v=!1}=g,C=m?.[e]?.[u]||a,p=f.useContext(C);if(p)return p;if(i!==void 0)return i;if(!v)throw new Error(`\`${l}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>f.createContext(i));return function(a){const u=a?.[e]||s;return f.useMemo(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return o.scopeName=e,[r,zw(o,...t)]}function zw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:u,scopeName:c})=>{const l=u(s)[`__scope${c}`];return{...a,...l}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Vp(e){const t=e+"CollectionProvider",[n,r]=Pr(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=C=>{const{scope:p,children:D}=C,w=f.useRef(null),b=f.useRef(new Map).current;return h.jsx(o,{scope:p,itemMap:b,collectionRef:w,children:D})};i.displayName=t;const a=e+"CollectionSlot",u=lo(a),c=f.forwardRef((C,p)=>{const{scope:D,children:w}=C,b=s(a,D),y=tt(p,b.collectionRef);return h.jsx(u,{ref:y,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",l="data-radix-collection-item",m=lo(d),g=f.forwardRef((C,p)=>{const{scope:D,children:w,...b}=C,y=f.useRef(null),A=tt(p,y),T=s(d,D);return f.useEffect(()=>(T.itemMap.set(y,{ref:y,...b}),()=>{T.itemMap.delete(y)})),h.jsx(m,{[l]:"",ref:A,children:w})});g.displayName=d;function v(C){const p=s(e+"CollectionConsumer",C);return f.useCallback(()=>{const w=p.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${l}]`));return Array.from(p.itemMap.values()).sort((T,S)=>b.indexOf(T.ref.current)-b.indexOf(S.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:i,Slot:c,ItemSlot:g},v,r]}function Oe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}var pn=globalThis?.document?f.useLayoutEffect:()=>{},Kw=Oi[" useInsertionEffect ".trim().toString()]||pn;function Cs({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Gw({defaultProp:t,onChange:n}),a=e!==void 0,u=a?e:o;{const d=f.useRef(e!==void 0);f.useEffect(()=>{const l=d.current;l!==a&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=f.useCallback(d=>{if(a){const l=qw(d)?d(e):d;l!==e&&i.current?.(l)}else s(d)},[a,e,s,i]);return[u,c]}function Gw({defaultProp:e,onChange:t}){const[n,r]=f.useState(e),o=f.useRef(n),s=f.useRef(t);return Kw(()=>{s.current=t},[t]),f.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function qw(e){return typeof e=="function"}function Yw(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}var Pn=e=>{const{present:t,children:n}=e,r=Jw(t),o=typeof n=="function"?n({present:r.isPresent}):f.Children.only(n),s=Zw(r.ref,Xw(o));return typeof n=="function"||r.isPresent?f.cloneElement(o,{ref:s}):null};Pn.displayName="Presence";function Jw(e){const[t,n]=f.useState(),r=f.useRef(null),o=f.useRef(e),s=f.useRef("none"),i=f.useRef(void 0),a=e?"mounted":"unmounted",[u,c]=Yw(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{u==="mounted"?(s.current=i.current??Bo(r.current),i.current=void 0):s.current="none"},[u]),pn(()=>{const d=r.current,l=o.current;if(l!==e){const g=s.current,v=Bo(d);e?(i.current=v,c("MOUNT")):v==="none"||d?.display==="none"?c("UNMOUNT"):c(l&&g!==v?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),pn(()=>{if(t){let d;const l=t.ownerDocument.defaultView??window,m=v=>{const p=Bo(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&p&&(c("ANIMATION_END"),!o.current)){const D=t.style.animationFillMode;t.style.animationFillMode="forwards",d=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=D)})}},g=v=>{v.target===t&&(s.current=Bo(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{l.clearTimeout(d),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:f.useCallback(d=>{if(d){const l=getComputedStyle(d);r.current=l,i.current=Bo(l)}else r.current=null;n(d)},[])}}function ld(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Zw(...e){const t=f.useRef(e);return t.current=e,f.useCallback(n=>{const r=t.current;let o=!1;const s=r.map(i=>{const a=ld(i,n);return!o&&typeof a=="function"&&(o=!0),a});if(o)return()=>{for(let i=0;i<s.length;i++){const a=s[i];typeof a=="function"?a():ld(r[i],null)}}},[])}function Bo(e){return e?.animationName||"none"}function Xw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qw=Oi[" useId ".trim().toString()]||(()=>{}),eD=0;function Jo(e){const[t,n]=f.useState(Qw());return pn(()=>{n(r=>r??String(eD++))},[e]),t?`radix-${t}`:""}var tD=f.createContext(void 0);function Wp(e){const t=f.useContext(tD);return e||t||"ltr"}function On(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>((...n)=>t.current?.(...n)),[])}var nD="DismissableLayer",mu="dismissableLayer.update",rD="dismissableLayer.pointerDownOutside",oD="dismissableLayer.focusOutside",dd,zp=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Mi=f.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:u,...c}=e,d=f.useContext(zp),[l,m]=f.useState(null),g=l?.ownerDocument??globalThis?.document,[,v]=f.useState({}),C=tt(t,m),p=Array.from(d.layers),[D]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=D?p.indexOf(D):-1,b=l?p.indexOf(l):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,A=b>=w,T=f.useRef(!1),S=uD(M=>{s?.(M),a?.(M),M.defaultPrevented||u?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:T,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:f.useCallback(M=>{if(!(M instanceof Node))return!1;const N=[...d.branches].some(_=>_.contains(M));return A&&!N},[d.branches,A])}),P=cD(M=>{if(r&&T.current)return;const N=M.target;[...d.branches].some(I=>I.contains(N))||(i?.(M),a?.(M),M.defaultPrevented||u?.())},g),L=l?b===p.length-1:!1,F=On(M=>{M.key==="Escape"&&(o?.(M),!M.defaultPrevented&&u&&(M.preventDefault(),u()))});return f.useEffect(()=>{if(L)return g.addEventListener("keydown",F,{capture:!0}),()=>g.removeEventListener("keydown",F,{capture:!0})},[g,L,F]),f.useEffect(()=>{if(l)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(dd=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(l)),d.layers.add(l),fd(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(l),d.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=dd))}},[l,g,n,d]),f.useEffect(()=>()=>{l&&(d.layers.delete(l),d.layersWithOutsidePointerEventsDisabled.delete(l),fd())},[l,d]),f.useEffect(()=>{const M=()=>v({});return document.addEventListener(mu,M),()=>document.removeEventListener(mu,M)},[]),h.jsx(nt.div,{...c,ref:C,style:{pointerEvents:y?A?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,P.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,S.onPointerDownCapture)})});Mi.displayName=nD;var sD="DismissableLayerBranch",iD=f.forwardRef((e,t)=>{const n=f.useContext(zp),r=f.useRef(null),o=tt(t,r);return f.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(nt.div,{...e,ref:o})});iD.displayName=sD;var aD=()=>!0;function uD(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:s,shouldHandlePointerDownOutside:i=aD}=t,a=On(e),u=f.useRef(!1),c=f.useRef(!1),d=f.useRef(new Map),l=f.useRef(()=>{});return f.useEffect(()=>{function m(){c.current=!1,o.current=!1,d.current.clear()}function g(){return Array.from(d.current.values()).some(Boolean)}function v(b){if(!c.current)return;const y=b.target;y instanceof Node&&[...s].some(T=>T.contains(y))||d.current.set(b.type,!0),b.type==="click"&&window.setTimeout(()=>{c.current&&l.current()},0)}function C(b){c.current&&d.current.set(b.type,!1)}const p=b=>{if(b.target&&!u.current){let y=function(){n.removeEventListener("click",l.current);const T=g();m(),T||Kp(rD,a,A,{discrete:!0})};if(!i(b.target)){n.removeEventListener("click",l.current),m(),u.current=!1;return}const A={originalEvent:b};c.current=!0,o.current=r&&b.button===0,d.current.clear(),!r||b.button!==0?y():(n.removeEventListener("click",l.current),l.current=y,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),m();u.current=!1},D=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const b of D)n.addEventListener(b,v,!0),n.addEventListener(b,C);const w=window.setTimeout(()=>{n.addEventListener("pointerdown",p)},0);return()=>{window.clearTimeout(w),n.removeEventListener("pointerdown",p),n.removeEventListener("click",l.current);for(const b of D)n.removeEventListener(b,v,!0),n.removeEventListener(b,C)}},[n,a,r,o,s,i]),{onPointerDownCapture:()=>u.current=!0}}function cD(e,t=globalThis?.document){const n=On(e),r=f.useRef(!1);return f.useEffect(()=>{const o=s=>{s.target&&!r.current&&Kp(oD,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function fd(){const e=new CustomEvent(mu);document.dispatchEvent(e)}function Kp(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?$p(o,s):o.dispatchEvent(s)}var xa="focusScope.autoFocusOnMount",Oa="focusScope.autoFocusOnUnmount",hd={bubbles:!1,cancelable:!0},lD="FocusScope",vc=f.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,u]=f.useState(null),c=On(o),d=On(s),l=f.useRef(null),m=tt(t,u),g=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(r){let C=function(b){if(g.paused||!a)return;const y=b.target;a.contains(y)?l.current=y:Un(l.current,{select:!0})},p=function(b){if(g.paused||!a)return;const y=b.relatedTarget;y!==null&&(a.contains(y)||Un(l.current,{select:!0}))},D=function(b){if(document.activeElement===document.body)for(const A of b)A.removedNodes.length>0&&Un(a)};document.addEventListener("focusin",C),document.addEventListener("focusout",p);const w=new MutationObserver(D);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",p),w.disconnect()}}},[r,a,g.paused]),f.useEffect(()=>{if(a){md.add(g);const C=document.activeElement;if(!a.contains(C)){const D=new CustomEvent(xa,hd);a.addEventListener(xa,c),a.dispatchEvent(D),D.defaultPrevented||(dD(gD(Gp(a)),{select:!0}),document.activeElement===C&&Un(a))}return()=>{a.removeEventListener(xa,c),setTimeout(()=>{const D=new CustomEvent(Oa,hd);a.addEventListener(Oa,d),a.dispatchEvent(D),D.defaultPrevented||Un(C??document.body,{select:!0}),a.removeEventListener(Oa,d),md.remove(g)},0)}}},[a,c,d,g]);const v=f.useCallback(C=>{if(!n&&!r||g.paused)return;const p=C.key==="Tab"&&!C.altKey&&!C.ctrlKey&&!C.metaKey,D=document.activeElement;if(p&&D){const w=C.currentTarget,[b,y]=fD(w);b&&y?!C.shiftKey&&D===y?(C.preventDefault(),n&&Un(b,{select:!0})):C.shiftKey&&D===b&&(C.preventDefault(),n&&Un(y,{select:!0})):D===w&&C.preventDefault()}},[n,r,g.paused]);return h.jsx(nt.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});vc.displayName=lD;function dD(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Un(r,{select:t}),document.activeElement!==n)return}function fD(e){const t=Gp(e),n=pd(t,e),r=pd(t.reverse(),e);return[n,r]}function Gp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode: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}});for(;n.nextNode();)t.push(n.currentNode);return t}function pd(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):hD(r,{upTo:t})))return r}function hD(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 pD(e){return e instanceof HTMLInputElement&&"select"in e}function Un(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&pD(e)&&t&&e.select()}}var md=mD();function mD(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=gd(e,t),e.unshift(t)},remove(t){e=gd(e,t),e[0]?.resume()}}}function gd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function gD(e){return e.filter(t=>t.tagName!=="A")}var vD="Portal",_i=f.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=f.useState(!1);pn(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?hs.createPortal(h.jsx(nt.div,{...r,ref:t}),i):null});_i.displayName=vD;var _s=0,$r=null;function qp(){f.useEffect(()=>{$r||($r={start:vd(),end:vd()});const{start:e,end:t}=$r;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),_s++,()=>{_s===1&&($r?.start.remove(),$r?.end.remove(),$r=null),_s=Math.max(0,_s-1)}},[])}function vd(){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}var dn=function(){return dn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},dn.apply(this,arguments)};function Yp(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")for(var o=0,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}function CD(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Js="right-scroll-bar-position",Zs="width-before-scroll-bar",ED="with-scroll-bars-hidden",yD="--removed-body-scroll-bar-size";function Ta(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function bD(e,t){var n=f.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var wD=typeof window<"u"?f.useLayoutEffect:f.useEffect,Cd=new WeakMap;function DD(e,t){var n=bD(null,function(r){return e.forEach(function(o){return Ta(o,r)})});return wD(function(){var r=Cd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ta(a,null)}),s.forEach(function(a){o.has(a)||Ta(a,i)})}Cd.set(n,e)},[e]),n}function AD(e){return e}function SD(e,t){t===void 0&&(t=AD);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var u=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(u)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function xD(e){e===void 0&&(e={});var t=SD(null);return t.options=dn({async:!0,ssr:!1},e),t}var Jp=function(e){var t=e.sideCar,n=Yp(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 f.createElement(r,dn({},n))};Jp.isSideCarExport=!0;function OD(e,t){return e.useMedium(t),Jp}var Zp=xD(),Ra=function(){},ki=f.forwardRef(function(e,t){var n=f.useRef(null),r=f.useState({onScrollCapture:Ra,onWheelCapture:Ra,onTouchMoveCapture:Ra}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,u=e.className,c=e.removeScrollBar,d=e.enabled,l=e.shards,m=e.sideCar,g=e.noRelative,v=e.noIsolation,C=e.inert,p=e.allowPinchZoom,D=e.as,w=D===void 0?"div":D,b=e.gapMode,y=Yp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=m,T=DD([n,t]),S=dn(dn({},y),o);return f.createElement(f.Fragment,null,d&&f.createElement(A,{sideCar:Zp,removeScrollBar:c,shards:l,noRelative:g,noIsolation:v,inert:C,setCallbacks:s,allowPinchZoom:!!p,lockRef:n,gapMode:b}),i?f.cloneElement(f.Children.only(a),dn(dn({},S),{ref:T})):f.createElement(w,dn({},S,{className:u,ref:T}),a))});ki.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ki.classNames={fullWidth:Zs,zeroRight:Js};var TD=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function RD(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=TD();return t&&e.setAttribute("nonce",t),e}function ID(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BD(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var FD=function(){var e=0,t=null;return{add:function(n){e==0&&(t=RD())&&(ID(t,n),BD(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},PD=function(){var e=FD();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Xp=function(){var e=PD(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},MD={left:0,top:0,right:0,gap:0},Ia=function(e){return parseInt(e||"",10)||0},_D=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Ia(n),Ia(r),Ia(o)]},kD=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return MD;var t=_D(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])}},ND=Xp(),to="data-scroll-locked",jD=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
9
|
+
.`.concat(ED,` {
|
|
10
|
+
overflow: hidden `).concat(r,`;
|
|
11
|
+
padding-right: `).concat(a,"px ").concat(r,`;
|
|
12
|
+
}
|
|
13
|
+
body[`).concat(to,`] {
|
|
14
|
+
overflow: hidden `).concat(r,`;
|
|
15
|
+
overscroll-behavior: contain;
|
|
16
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
17
|
+
padding-left: `.concat(o,`px;
|
|
18
|
+
padding-top: `).concat(s,`px;
|
|
19
|
+
padding-right: `).concat(i,`px;
|
|
20
|
+
margin-left:0;
|
|
21
|
+
margin-top:0;
|
|
22
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
23
|
+
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.`).concat(Js,` {
|
|
27
|
+
right: `).concat(a,"px ").concat(r,`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.`).concat(Zs,` {
|
|
31
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.`).concat(Js," .").concat(Js,` {
|
|
35
|
+
right: 0 `).concat(r,`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.`).concat(Zs," .").concat(Zs,` {
|
|
39
|
+
margin-right: 0 `).concat(r,`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
body[`).concat(to,`] {
|
|
43
|
+
`).concat(yD,": ").concat(a,`px;
|
|
44
|
+
}
|
|
45
|
+
`)},Ed=function(){var e=parseInt(document.body.getAttribute(to)||"0",10);return isFinite(e)?e:0},LD=function(){f.useEffect(function(){return document.body.setAttribute(to,(Ed()+1).toString()),function(){var e=Ed()-1;e<=0?document.body.removeAttribute(to):document.body.setAttribute(to,e.toString())}},[])},UD=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;LD();var s=f.useMemo(function(){return kD(o)},[o]);return f.createElement(ND,{styles:jD(s,!t,o,n?"":"!important")})},gu=!1;if(typeof window<"u")try{var ks=Object.defineProperty({},"passive",{get:function(){return gu=!0,!0}});window.addEventListener("test",ks,ks),window.removeEventListener("test",ks,ks)}catch{gu=!1}var Hr=gu?{passive:!1}:!1,$D=function(e){return e.tagName==="TEXTAREA"},Qp=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!$D(e)&&n[t]==="visible")},HD=function(e){return Qp(e,"overflowY")},VD=function(e){return Qp(e,"overflowX")},yd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=em(e,r);if(o){var s=tm(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},WD=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},zD=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},em=function(e,t){return e==="v"?HD(t):VD(t)},tm=function(e,t){return e==="v"?WD(t):zD(t)},KD=function(e,t){return e==="h"&&t==="rtl"?-1:1},GD=function(e,t,n,r,o){var s=KD(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,u=t.contains(a),c=!1,d=i>0,l=0,m=0;do{if(!a)break;var g=tm(e,a),v=g[0],C=g[1],p=g[2],D=C-p-s*v;(v||D)&&em(e,a)&&(l+=D,m+=v);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!u&&a!==document.body||u&&(t.contains(a)||t===a));return(d&&Math.abs(l)<1||!d&&Math.abs(m)<1)&&(c=!0),c},Ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},bd=function(e){return[e.deltaX,e.deltaY]},wd=function(e){return e&&"current"in e?e.current:e},qD=function(e,t){return e[0]===t[0]&&e[1]===t[1]},YD=function(e){return`
|
|
46
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
47
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
48
|
+
`)},JD=0,Vr=[];function ZD(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),o=f.useState(JD++)[0],s=f.useState(Xp)[0],i=f.useRef(e);f.useEffect(function(){i.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var C=CD([e.lockRef.current],(e.shards||[]).map(wd),!0).filter(Boolean);return C.forEach(function(p){return p.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),C.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=f.useCallback(function(C,p){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!i.current.allowPinchZoom;var D=Ns(C),w=n.current,b="deltaX"in C?C.deltaX:w[0]-D[0],y="deltaY"in C?C.deltaY:w[1]-D[1],A,T=C.target,S=Math.abs(b)>Math.abs(y)?"h":"v";if("touches"in C&&S==="h"&&T.type==="range")return!1;var P=window.getSelection(),L=P&&P.anchorNode,F=L?L===T||L.contains(T):!1;if(F)return!1;var M=yd(S,T);if(!M)return!0;if(M?A=S:(A=S==="v"?"h":"v",M=yd(S,T)),!M)return!1;if(!r.current&&"changedTouches"in C&&(b||y)&&(r.current=A),!A)return!0;var N=r.current||A;return GD(N,p,C,N==="h"?b:y)},[]),u=f.useCallback(function(C){var p=C;if(!(!Vr.length||Vr[Vr.length-1]!==s)){var D="deltaY"in p?bd(p):Ns(p),w=t.current.filter(function(A){return A.name===p.type&&(A.target===p.target||p.target===A.shadowParent)&&qD(A.delta,D)})[0];if(w&&w.should){p.cancelable&&p.preventDefault();return}if(!w){var b=(i.current.shards||[]).map(wd).filter(Boolean).filter(function(A){return A.contains(p.target)}),y=b.length>0?a(p,b[0]):!i.current.noIsolation;y&&p.cancelable&&p.preventDefault()}}},[]),c=f.useCallback(function(C,p,D,w){var b={name:C,delta:p,target:D,should:w,shadowParent:XD(D)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(y){return y!==b})},1)},[]),d=f.useCallback(function(C){n.current=Ns(C),r.current=void 0},[]),l=f.useCallback(function(C){c(C.type,bd(C),C.target,a(C,e.lockRef.current))},[]),m=f.useCallback(function(C){c(C.type,Ns(C),C.target,a(C,e.lockRef.current))},[]);f.useEffect(function(){return Vr.push(s),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:m}),document.addEventListener("wheel",u,Hr),document.addEventListener("touchmove",u,Hr),document.addEventListener("touchstart",d,Hr),function(){Vr=Vr.filter(function(C){return C!==s}),document.removeEventListener("wheel",u,Hr),document.removeEventListener("touchmove",u,Hr),document.removeEventListener("touchstart",d,Hr)}},[]);var g=e.removeScrollBar,v=e.inert;return f.createElement(f.Fragment,null,v?f.createElement(s,{styles:YD(o)}):null,g?f.createElement(UD,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function XD(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const QD=OD(Zp,ZD);var Cc=f.forwardRef(function(e,t){return f.createElement(ki,dn({},e,{ref:t,sideCar:QD}))});Cc.classNames=ki.classNames;var eA=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Wr=new WeakMap,js=new WeakMap,Ls={},Ba=0,nm=function(e){return e&&(e.host||nm(e.parentNode))},tA=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=nm(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},nA=function(e,t,n,r){var o=tA(t,Array.isArray(e)?e:[e]);Ls[n]||(Ls[n]=new WeakMap);var s=Ls[n],i=[],a=new Set,u=new Set(o),c=function(l){!l||a.has(l)||(a.add(l),c(l.parentNode))};o.forEach(c);var d=function(l){!l||u.has(l)||Array.prototype.forEach.call(l.children,function(m){if(a.has(m))d(m);else try{var g=m.getAttribute(r),v=g!==null&&g!=="false",C=(Wr.get(m)||0)+1,p=(s.get(m)||0)+1;Wr.set(m,C),s.set(m,p),i.push(m),C===1&&v&&js.set(m,!0),p===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(D){console.error("aria-hidden: cannot operate on ",m,D)}})};return d(t),a.clear(),Ba++,function(){i.forEach(function(l){var m=Wr.get(l)-1,g=s.get(l)-1;Wr.set(l,m),s.set(l,g),m||(js.has(l)||l.removeAttribute(r),js.delete(l)),g||l.removeAttribute(n)}),Ba--,Ba||(Wr=new WeakMap,Wr=new WeakMap,js=new WeakMap,Ls={})}},rm=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=eA(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),nA(r,o,n,"aria-hidden")):function(){return null}};function rA(e){const[t,n]=f.useState(void 0);return pn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const u=s.borderBoxSize,c=Array.isArray(u)?u[0]:u;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function Ao(e){return e.split("-")[1]}function Ec(e){return e==="y"?"height":"width"}function nn(e){return e.split("-")[0]}function Mr(e){return["top","bottom"].includes(nn(e))?"x":"y"}function Dd(e,t,n){let{reference:r,floating:o}=e;const s=r.x+r.width/2-o.width/2,i=r.y+r.height/2-o.height/2,a=Mr(t),u=Ec(a),c=r[u]/2-o[u]/2,d=a==="x";let l;switch(nn(t)){case"top":l={x:s,y:r.y-o.height};break;case"bottom":l={x:s,y:r.y+r.height};break;case"right":l={x:r.x+r.width,y:i};break;case"left":l={x:r.x-o.width,y:i};break;default:l={x:r.x,y:r.y}}switch(Ao(t)){case"start":l[a]-=c*(n&&d?-1:1);break;case"end":l[a]+=c*(n&&d?-1:1)}return l}const oA=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:l}=Dd(c,r,u),m=r,g={},v=0;for(let C=0;C<a.length;C++){const{name:p,fn:D}=a[C],{x:w,y:b,data:y,reset:A}=await D({x:d,y:l,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,l=b??l,g={...g,[p]:{...g[p],...y}},A&&v<=50&&(v++,typeof A=="object"&&(A.placement&&(m=A.placement),A.rects&&(c=A.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):A.rects),{x:d,y:l}=Dd(c,m,u)),C=-1)}return{x:d,y:l,placement:m,strategy:o,middlewareData:g}};function yc(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 Zo(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function Xo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:u}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:l="floating",altBoundary:m=!1,padding:g=0}=t,v=yc(g),C=a[m?l==="floating"?"reference":"floating":l],p=Zo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:u})),D=l==="floating"?{...i.floating,x:r,y:o}:i.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),b=await(s.isElement==null?void 0:s.isElement(w))&&await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1},y=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({rect:D,offsetParent:w,strategy:u}):D);return{top:(p.top-y.top+v.top)/b.y,bottom:(y.bottom-p.bottom+v.bottom)/b.y,left:(p.left-y.left+v.left)/b.x,right:(y.right-p.right+v.right)/b.x}}const om=Math.min,Hn=Math.max;function vu(e,t,n){return Hn(e,om(t,n))}const sA=e=>({name:"arrow",options:e,async fn(t){const{element:n,padding:r=0}=e||{},{x:o,y:s,placement:i,rects:a,platform:u}=t;if(n==null)return{};const c=yc(r),d={x:o,y:s},l=Mr(i),m=Ec(l),g=await u.getDimensions(n),v=l==="y"?"top":"left",C=l==="y"?"bottom":"right",p=a.reference[m]+a.reference[l]-d[l]-a.floating[m],D=d[l]-a.reference[l],w=await(u.getOffsetParent==null?void 0:u.getOffsetParent(n));let b=w?l==="y"?w.clientHeight||0:w.clientWidth||0:0;b===0&&(b=a.floating[m]);const y=p/2-D/2,A=c[v],T=b-g[m]-c[C],S=b/2-g[m]/2+y,P=vu(A,S,T),L=Ao(i)!=null&&S!=P&&a.reference[m]/2-(S<A?c[v]:c[C])-g[m]/2<0;return{[l]:d[l]-(L?S<A?A-S:T-S:0),data:{[l]:P,centerOffset:S-P}}}}),sm=["top","right","bottom","left"];sm.reduce(((e,t)=>e.concat(t,t+"-start",t+"-end")),[]);const iA={left:"right",right:"left",bottom:"top",top:"bottom"};function li(e){return e.replace(/left|right|bottom|top/g,(t=>iA[t]))}function aA(e,t,n){n===void 0&&(n=!1);const r=Ao(e),o=Mr(e),s=Ec(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=li(i)),{main:i,cross:li(i)}}const uA={start:"end",end:"start"};function Fa(e){return e.replace(/start|end/g,(t=>uA[t]))}const cA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n;const{placement:r,middlewareData:o,rects:s,initialPlacement:i,platform:a,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:l,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...C}=e,p=nn(r),D=nn(i)===i,w=await(a.isRTL==null?void 0:a.isRTL(u.floating)),b=l||(D||!v?[li(i)]:(function(F){const M=li(F);return[Fa(F),M,Fa(M)]})(i));l||g==="none"||b.push(...(function(F,M,N,_){const I=Ao(F);let j=(function(z,Y,oe){const G=["left","right"],Z=["right","left"],le=["top","bottom"],de=["bottom","top"];switch(z){case"top":case"bottom":return oe?Y?Z:G:Y?G:Z;case"left":case"right":return Y?le:de;default:return[]}})(nn(F),N==="start",_);return I&&(j=j.map((z=>z+"-"+I)),M&&(j=j.concat(j.map(Fa)))),j})(i,v,g,w));const y=[i,...b],A=await Xo(t,C),T=[];let S=((n=o.flip)==null?void 0:n.overflows)||[];if(c&&T.push(A[p]),d){const{main:F,cross:M}=aA(r,s,w);T.push(A[F],A[M])}if(S=[...S,{placement:r,overflows:T}],!T.every((F=>F<=0))){var P;const F=(((P=o.flip)==null?void 0:P.index)||0)+1,M=y[F];if(M)return{data:{index:F,overflows:S},reset:{placement:M}};let N="bottom";switch(m){case"bestFit":{var L;const _=(L=S.map((I=>[I,I.overflows.filter((j=>j>0)).reduce(((j,z)=>j+z),0)])).sort(((I,j)=>I[1]-j[1]))[0])==null?void 0:L[0].placement;_&&(N=_);break}case"initialPlacement":N=i}if(r!==N)return{reset:{placement:N}}}return{}}}};function Ad(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Sd(e){return sm.some((t=>e[t]>=0))}const lA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{strategy:n="referenceHidden",...r}=e,{rects:o}=t;switch(n){case"referenceHidden":{const s=Ad(await Xo(t,{...r,elementContext:"reference"}),o.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Sd(s)}}}case"escaped":{const s=Ad(await Xo(t,{...r,altBoundary:!0}),o.floating);return{data:{escapedOffsets:s,escaped:Sd(s)}}}default:return{}}}}},dA=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:r,rects:o,platform:s,strategy:i}=t,{padding:a=2,x:u,y:c}=e,d=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({rect:o.reference,offsetParent:await(s.getOffsetParent==null?void 0:s.getOffsetParent(r.floating)),strategy:i}):o.reference),l=await(s.getClientRects==null?void 0:s.getClientRects(r.reference))||[],m=yc(a),g=await s.getElementRects({reference:{getBoundingClientRect:function(){if(l.length===2&&l[0].left>l[1].right&&u!=null&&c!=null)return l.find((v=>u>v.left-m.left&&u<v.right+m.right&&c>v.top-m.top&&c<v.bottom+m.bottom))||d;if(l.length>=2){if(Mr(n)==="x"){const y=l[0],A=l[l.length-1],T=nn(n)==="top",S=y.top,P=A.bottom,L=T?y.left:A.left,F=T?y.right:A.right;return{top:S,bottom:P,left:L,right:F,width:F-L,height:P-S,x:L,y:S}}const v=nn(n)==="left",C=Hn(...l.map((y=>y.right))),p=om(...l.map((y=>y.left))),D=l.filter((y=>v?y.left===p:y.right===C)),w=D[0].top,b=D[D.length-1].bottom;return{top:w,bottom:b,left:p,right:C,width:C-p,height:b-w,x:p,y:w}}return d}},floating:r.floating,strategy:i});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}}:{}}}},fA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){const{x:n,y:r}=t,o=await(async function(s,i){const{placement:a,platform:u,elements:c}=s,d=await(u.isRTL==null?void 0:u.isRTL(c.floating)),l=nn(a),m=Ao(a),g=Mr(a)==="x",v=["left","top"].includes(l)?-1:1,C=d&&g?-1:1,p=typeof i=="function"?i(s):i;let{mainAxis:D,crossAxis:w,alignmentAxis:b}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return m&&typeof b=="number"&&(w=m==="end"?-1*b:b),g?{x:w*C,y:D*v}:{x:D*v,y:w*C}})(t,e);return{x:n+o.x,y:r+o.y,data:o}}}};function im(e){return e==="x"?"y":"x"}const hA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:p=>{let{x:D,y:w}=p;return{x:D,y:w}}},...u}=e,c={x:n,y:r},d=await Xo(t,u),l=Mr(nn(o)),m=im(l);let g=c[l],v=c[m];if(s){const p=l==="y"?"bottom":"right";g=vu(g+d[l==="y"?"top":"left"],g,g-d[p])}if(i){const p=m==="y"?"bottom":"right";v=vu(v+d[m==="y"?"top":"left"],v,v-d[p])}const C=a.fn({...t,[l]:g,[m]:v});return{...C,data:{x:C.x-n,y:C.y-r}}}}},pA=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:u=!0,crossAxis:c=!0}=e,d={x:n,y:r},l=Mr(o),m=im(l);let g=d[l],v=d[m];const C=typeof a=="function"?a(t):a,p=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(u){const b=l==="y"?"height":"width",y=s.reference[l]-s.floating[b]+p.mainAxis,A=s.reference[l]+s.reference[b]-p.mainAxis;g<y?g=y:g>A&&(g=A)}if(c){var D,w;const b=l==="y"?"width":"height",y=["top","left"].includes(nn(o)),A=s.reference[m]-s.floating[b]+(y&&((D=i.offset)==null?void 0:D[m])||0)+(y?0:p.crossAxis),T=s.reference[m]+s.reference[b]+(y?0:((w=i.offset)==null?void 0:w[m])||0)-(y?p.crossAxis:0);v<A?v=A:v>T&&(v=T)}return{[l]:g,[m]:v}}}},mA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:s}=t,{apply:i=(()=>{}),...a}=e,u=await Xo(t,a),c=nn(n),d=Ao(n);let l,m;c==="top"||c==="bottom"?(l=c,m=d===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(m=c,l=d==="end"?"top":"bottom");const g=Hn(u.left,0),v=Hn(u.right,0),C=Hn(u.top,0),p=Hn(u.bottom,0),D={availableHeight:r.floating.height-(["left","right"].includes(n)?2*(C!==0||p!==0?C+p:Hn(u.top,u.bottom)):u[l]),availableWidth:r.floating.width-(["top","bottom"].includes(n)?2*(g!==0||v!==0?g+v:Hn(u.left,u.right)):u[m])};await i({...t,...D});const w=await o.getDimensions(s.floating);return r.floating.width!==w.width||r.floating.height!==w.height?{reset:{rects:!0}}:{}}}},Cu=Math.min,no=Math.max,di=Math.round,Us=Math.floor,Qn=e=>({x:e,y:e});function er(e){return am(e)?(e.nodeName||"").toLowerCase():"#document"}function kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Mn(e){var t;return(t=(am(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function am(e){return e instanceof Node||e instanceof kt(e).Node}function Tn(e){return e instanceof Element||e instanceof kt(e).Element}function vn(e){return e instanceof HTMLElement||e instanceof kt(e).HTMLElement}function xd(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof kt(e).ShadowRoot}function Es(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Kt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function gA(e){return["table","td","th"].includes(er(e))}function bc(e){const t=wc(),n=Kt(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function vA(e){let t=fo(e);for(;vn(t)&&!Ni(t);){if(bc(t))return t;t=fo(t)}return null}function wc(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ni(e){return["html","body","#document"].includes(er(e))}function Kt(e){return kt(e).getComputedStyle(e)}function ji(e){return Tn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function fo(e){if(er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xd(e)&&e.host||Mn(e);return xd(t)?t.host:t}function um(e){const t=fo(e);return Ni(t)?e.ownerDocument?e.ownerDocument.body:e.body:vn(t)&&Es(t)?t:um(t)}function Qo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=um(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=kt(o);return s?t.concat(i,i.visualViewport||[],Es(o)?o:[],i.frameElement&&n?Qo(i.frameElement):[]):t.concat(o,Qo(o,[],n))}function cm(e){const t=Kt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=di(n)!==s||di(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Dc(e){return Tn(e)?e:e.contextElement}function ro(e){const t=Dc(e);if(!vn(t))return Qn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=cm(t);let i=(s?di(n.width):n.width)/r,a=(s?di(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const CA=Qn(0);function lm(e){const t=kt(e);return!wc()||!t.visualViewport?CA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function EA(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==kt(e)?!1:t}function xr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Dc(e);let i=Qn(1);t&&(r?Tn(r)&&(i=ro(r)):i=ro(e));const a=EA(s,n,r)?lm(s):Qn(0);let u=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,l=o.height/i.y;if(s){const m=kt(s),g=r&&Tn(r)?kt(r):r;let v=m,C=v.frameElement;for(;C&&r&&g!==v;){const p=ro(C),D=C.getBoundingClientRect(),w=Kt(C),b=D.left+(C.clientLeft+parseFloat(w.paddingLeft))*p.x,y=D.top+(C.clientTop+parseFloat(w.paddingTop))*p.y;u*=p.x,c*=p.y,d*=p.x,l*=p.y,u+=b,c+=y,v=kt(C),C=v.frameElement}}return Zo({width:d,height:l,x:u,y:c})}const yA=[":popover-open",":modal"];function dm(e){return yA.some(t=>{try{return e.matches(t)}catch{return!1}})}function bA(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Mn(r),a=t?dm(t.floating):!1;if(r===i||a&&s)return n;let u={scrollLeft:0,scrollTop:0},c=Qn(1);const d=Qn(0),l=vn(r);if((l||!l&&!s)&&((er(r)!=="body"||Es(i))&&(u=ji(r)),vn(r))){const m=xr(r);c=ro(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-u.scrollLeft*c.x+d.x,y:n.y*c.y-u.scrollTop*c.y+d.y}}function wA(e){return Array.from(e.getClientRects())}function fm(e){return xr(Mn(e)).left+ji(e).scrollLeft}function DA(e){const t=Mn(e),n=ji(e),r=e.ownerDocument.body,o=no(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=no(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+fm(e);const a=-n.scrollTop;return Kt(r).direction==="rtl"&&(i+=no(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function AA(e,t){const n=kt(e),r=Mn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,u=0;if(o){s=o.width,i=o.height;const c=wc();(!c||c&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:s,height:i,x:a,y:u}}function SA(e,t){const n=xr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vn(e)?ro(e):Qn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,u=o*s.x,c=r*s.y;return{width:i,height:a,x:u,y:c}}function Od(e,t,n){let r;if(t==="viewport")r=AA(e,n);else if(t==="document")r=DA(Mn(e));else if(Tn(t))r=SA(t,n);else{const o=lm(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return Zo(r)}function hm(e,t){const n=fo(e);return n===t||!Tn(n)||Ni(n)?!1:Kt(n).position==="fixed"||hm(n,t)}function xA(e,t){const n=t.get(e);if(n)return n;let r=Qo(e,[],!1).filter(a=>Tn(a)&&er(a)!=="body"),o=null;const s=Kt(e).position==="fixed";let i=s?fo(e):e;for(;Tn(i)&&!Ni(i);){const a=Kt(i),u=bc(i);!u&&a.position==="fixed"&&(o=null),(s?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Es(i)&&!u&&hm(e,i))?r=r.filter(d=>d!==i):o=a,i=fo(i)}return t.set(e,r),r}function OA(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?xA(t,this._c):[].concat(n),r],a=i[0],u=i.reduce((c,d)=>{const l=Od(t,d,o);return c.top=no(l.top,c.top),c.right=Cu(l.right,c.right),c.bottom=Cu(l.bottom,c.bottom),c.left=no(l.left,c.left),c},Od(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function TA(e){const{width:t,height:n}=cm(e);return{width:t,height:n}}function RA(e,t,n){const r=vn(t),o=Mn(t),s=n==="fixed",i=xr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const u=Qn(0);if(r||!r&&!s)if((er(t)!=="body"||Es(o))&&(a=ji(t)),r){const l=xr(t,!0,s,t);u.x=l.x+t.clientLeft,u.y=l.y+t.clientTop}else o&&(u.x=fm(o));const c=i.left+a.scrollLeft-u.x,d=i.top+a.scrollTop-u.y;return{x:c,y:d,width:i.width,height:i.height}}function Td(e,t){return!vn(e)||Kt(e).position==="fixed"?null:t?t(e):e.offsetParent}function pm(e,t){const n=kt(e);if(!vn(e)||dm(e))return n;let r=Td(e,t);for(;r&&gA(r)&&Kt(r).position==="static";)r=Td(r,t);return r&&(er(r)==="html"||er(r)==="body"&&Kt(r).position==="static"&&!bc(r))?n:r||vA(e)||n}const IA=async function(e){const t=this.getOffsetParent||pm,n=this.getDimensions;return{reference:RA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,...await n(e.floating)}}};function BA(e){return Kt(e).direction==="rtl"}const FA={convertOffsetParentRelativeRectToViewportRelativeRect:bA,getDocumentElement:Mn,getClippingRect:OA,getOffsetParent:pm,getElementRects:IA,getClientRects:wA,getDimensions:TA,getScale:ro,isElement:Tn,isRTL:BA};function PA(e,t){let n=null,r;const o=Mn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),s();const{left:c,top:d,width:l,height:m}=e.getBoundingClientRect();if(a||t(),!l||!m)return;const g=Us(d),v=Us(o.clientWidth-(c+l)),C=Us(o.clientHeight-(d+m)),p=Us(c),w={rootMargin:-g+"px "+-v+"px "+-C+"px "+-p+"px",threshold:no(0,Cu(1,u))||1};let b=!0;function y(A){const T=A[0].intersectionRatio;if(T!==u){if(!b)return i();T?i(!1,T):r=setTimeout(()=>{i(!1,1e-7)},100)}b=!1}try{n=new IntersectionObserver(y,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(y,w)}n.observe(e)}return i(!0),s}function mm(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,c=Dc(e),d=o||s?[...c?Qo(c):[],...Qo(t)]:[];d.forEach(D=>{o&&D.addEventListener("scroll",n,{passive:!0}),s&&D.addEventListener("resize",n)});const l=c&&a?PA(c,n):null;let m=-1,g=null;i&&(g=new ResizeObserver(D=>{let[w]=D;w&&w.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var b;(b=g)==null||b.observe(t)})),n()}),c&&!u&&g.observe(c),g.observe(t));let v,C=u?xr(e):null;u&&p();function p(){const D=xr(e);C&&(D.x!==C.x||D.y!==C.y||D.width!==C.width||D.height!==C.height)&&n(),C=D,v=requestAnimationFrame(p)}return n(),()=>{var D;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),l?.(),(D=g)==null||D.disconnect(),g=null,u&&cancelAnimationFrame(v)}}const MA=hA,_A=cA,kA=mA,NA=lA,Rd=sA,jA=dA,LA=pA,UA=(e,t,n)=>{const r=new Map,o={platform:FA,...n},s={...o.platform,_c:r};return oA(e,t,{...o,platform:s})};var Xs=typeof document<"u"?f.useLayoutEffect:f.useEffect;function fi(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(!fi(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 s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!fi(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function gm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Id(e,t){const n=gm(e);return Math.round(t*n)/n}function Pa(e){const t=f.useRef(e);return Xs(()=>{t.current=e}),t}function vm(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:u,open:c}=e,[d,l]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=f.useState(r);fi(m,r)||g(r);const[v,C]=f.useState(null),[p,D]=f.useState(null),w=f.useCallback(oe=>{oe!==T.current&&(T.current=oe,C(oe))},[]),b=f.useCallback(oe=>{oe!==S.current&&(S.current=oe,D(oe))},[]),y=s||v,A=i||p,T=f.useRef(null),S=f.useRef(null),P=f.useRef(d),L=u!=null,F=Pa(u),M=Pa(o),N=Pa(c),_=f.useCallback(()=>{if(!T.current||!S.current)return;const oe={placement:t,strategy:n,middleware:m};M.current&&(oe.platform=M.current),UA(T.current,S.current,oe).then(G=>{const Z={...G,isPositioned:N.current!==!1};I.current&&!fi(P.current,Z)&&(P.current=Z,hs.flushSync(()=>{l(Z)}))})},[m,t,n,M,N]);Xs(()=>{c===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,l(oe=>({...oe,isPositioned:!1})))},[c]);const I=f.useRef(!1);Xs(()=>(I.current=!0,()=>{I.current=!1}),[]),Xs(()=>{if(y&&(T.current=y),A&&(S.current=A),y&&A){if(F.current)return F.current(y,A,_);_()}},[y,A,_,F,L]);const j=f.useMemo(()=>({reference:T,floating:S,setReference:w,setFloating:b}),[w,b]),z=f.useMemo(()=>({reference:y,floating:A}),[y,A]),Y=f.useMemo(()=>{const oe={position:n,left:0,top:0};if(!z.floating)return oe;const G=Id(z.floating,d.x),Z=Id(z.floating,d.y);return a?{...oe,transform:"translate("+G+"px, "+Z+"px)",...gm(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:Z}},[n,a,z.floating,d.x,d.y]);return f.useMemo(()=>({...d,update:_,refs:j,elements:z,floatingStyles:Y}),[d,_,j,z,Y])}const $A=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Rd({element:r.current,padding:o}).fn(n):{}:r?Rd({element:r,padding:o}).fn(n):{}}}},Cm=(e,t)=>({...fA(e),options:[e,t]}),Em=(e,t)=>({...MA(e),options:[e,t]}),ym=(e,t)=>({...LA(e),options:[e,t]}),bm=(e,t)=>({..._A(e),options:[e,t]}),wm=(e,t)=>({...kA(e),options:[e,t]}),Dm=(e,t)=>({...NA(e),options:[e,t]}),HA=(e,t)=>({...jA(e),options:[e,t]}),VA=(e,t)=>({...$A(e),options:[e,t]});var WA="Arrow",Am=f.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return h.jsx(nt.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});Am.displayName=WA;var zA=Am,Ac="Popper",[Sm,So]=Pr(Ac),[KA,xm]=Sm(Ac),Om=e=>{const{__scopePopper:t,children:n}=e,[r,o]=f.useState(null),[s,i]=f.useState(void 0);return h.jsx(KA,{scope:t,anchor:r,onAnchorChange:o,placementState:s,setPlacementState:i,children:n})};Om.displayName=Ac;var Tm="PopperAnchor",Rm=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=xm(Tm,n),i=f.useRef(null),a=s.onAnchorChange,u=f.useCallback(v=>{i.current=v,v&&a(v)},[a]),c=tt(t,u),d=f.useRef(null);f.useEffect(()=>{if(!r)return;const v=d.current;d.current=r.current,v!==d.current&&a(d.current)});const l=s.placementState&&xc(s.placementState),m=l?.[0],g=l?.[1];return r?null:h.jsx(nt.div,{"data-radix-popper-side":m,"data-radix-popper-align":g,...o,ref:c})});Rm.displayName=Tm;var Sc="PopperContent",[GA,qA]=Sm(Sc),Im=f.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:l="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:v,...C}=e,p=xm(Sc,n),[D,w]=f.useState(null),b=tt(t,w),[y,A]=f.useState(null),T=rA(y),S=T?.width??0,P=T?.height??0,L=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(c)?c:[c],N=M.length>0,_={padding:F,boundary:M.filter(JA),altBoundary:N},{refs:I,floatingStyles:j,placement:z,isPositioned:Y,middlewareData:oe}=vm({strategy:"fixed",placement:L,whileElementsMounted:(...J)=>mm(...J,{animationFrame:g==="always"}),elements:{reference:p.anchor},middleware:[Cm({mainAxis:o+P,alignmentAxis:i}),u&&Em({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?ym():void 0,..._}),u&&bm({..._}),wm({..._,apply:({elements:J,rects:X,availableWidth:ie,availableHeight:ae})=>{const{width:we,height:Se}=X.reference,me=J.floating.style;me.setProperty("--radix-popper-available-width",`${ie}px`),me.setProperty("--radix-popper-available-height",`${ae}px`),me.setProperty("--radix-popper-anchor-width",`${we}px`),me.setProperty("--radix-popper-anchor-height",`${Se}px`)}}),y&&VA({element:y,padding:a}),ZA({arrowWidth:S,arrowHeight:P}),m&&Dm({strategy:"referenceHidden",..._,boundary:N?_.boundary:void 0})]}),G=p.setPlacementState;pn(()=>(G(z),()=>{G(void 0)}),[z,G]);const[Z,le]=xc(z),de=On(v);pn(()=>{Y&&de?.()},[Y,de]);const ue=oe.arrow?.x,ee=oe.arrow?.y,te=oe.arrow?.centerOffset!==0,[R,q]=f.useState();return pn(()=>{D&&q(window.getComputedStyle(D).zIndex)},[D]),h.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:Y?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:R,"--radix-popper-transform-origin":[oe.transformOrigin?.x,oe.transformOrigin?.y].join(" "),...oe.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(GA,{scope:n,placedSide:Z,placedAlign:le,onArrowChange:A,arrowX:ue,arrowY:ee,shouldHideArrow:te,children:h.jsx(nt.div,{"data-side":Z,"data-align":le,...C,ref:b,style:{...C.style,animation:Y?void 0:"none"}})})})});Im.displayName=Sc;var Bm="PopperArrow",YA={top:"bottom",right:"left",bottom:"top",left:"right"},Fm=f.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=qA(Bm,r),i=YA[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(zA,{...o,ref:n,style:{...o.style,display:"block"}})})});Fm.displayName=Bm;function JA(e){return e!==null}var ZA=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[c,d]=xc(n),l={start:"0%",center:"50%",end:"100%"}[d],m=(o.arrow?.x??0)+a/2,g=(o.arrow?.y??0)+u/2;let v="",C="";return c==="bottom"?(v=i?l:`${m}px`,C=`${-u}px`):c==="top"?(v=i?l:`${m}px`,C=`${r.floating.height+u}px`):c==="right"?(v=`${-u}px`,C=i?l:`${g}px`):c==="left"&&(v=`${r.floating.width+u}px`,C=i?l:`${g}px`),{data:{x:v,y:C}}}});function xc(e){const[t,n="center"]=e.split("-");return[t,n]}var Oc=Om,Li=Rm,Tc=Im,Rc=Fm,Ma=!1;function XA(){const[e,t]=f.useState(Ma);return f.useEffect(()=>{Ma||(Ma=!0,t(!0))},[]),e}var Pm=Oi[" useSyncExternalStore ".trim().toString()];function QA(){return()=>{}}function eS(){return Pm(QA,()=>!0,()=>!1)}var tS=typeof Pm=="function"?eS:XA,_a="rovingFocusGroup.onEntryFocus",nS={bubbles:!1,cancelable:!0},ys="RovingFocusGroup",[Eu,Mm,rS]=Vp(ys),[oS,_m]=Pr(ys,[rS]),[sS,iS]=oS(ys),km=f.forwardRef((e,t)=>h.jsx(Eu.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Eu.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(aS,{...e,ref:t})})}));km.displayName=ys;var aS=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...l}=e,m=f.useRef(null),g=tt(t,m),v=Wp(s),[C,p]=Cs({prop:i,defaultProp:a??null,onChange:u,caller:ys}),[D,w]=f.useState(!1),b=On(c),y=Mm(n),A=f.useRef(!1),[T,S]=f.useState(0);return f.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(_a,b),()=>P.removeEventListener(_a,b)},[b]),h.jsx(sS,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:C,onItemFocus:f.useCallback(P=>p(P),[p]),onItemShiftTab:f.useCallback(()=>w(!0),[]),onFocusableItemAdd:f.useCallback(()=>S(P=>P+1),[]),onFocusableItemRemove:f.useCallback(()=>S(P=>P-1),[]),children:h.jsx(nt.div,{tabIndex:D||T===0?-1:0,"data-orientation":r,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:Oe(e.onMouseDown,()=>{A.current=!0}),onFocus:Oe(e.onFocus,P=>{const L=!A.current;if(P.target===P.currentTarget&&L&&!D){const F=new CustomEvent(_a,nS);if(P.currentTarget.dispatchEvent(F),!F.defaultPrevented){const M=y().filter(z=>z.focusable),N=M.find(z=>z.active),_=M.find(z=>z.id===C),j=[N,_,...M].filter(Boolean).map(z=>z.ref.current);Lm(j,d)}}A.current=!1}),onBlur:Oe(e.onBlur,()=>w(!1))})})}),Nm="RovingFocusGroupItem",jm=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,u=Jo(),c=s||u,d=iS(Nm,n),l=d.currentTabStopId===c,m=Mm(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:C}=d,p=tS();return pn(()=>{if(!(!p||!r))return g(),()=>v()},[p,r,g,v]),f.useEffect(()=>{if(!(p||!r))return g(),()=>v()},[p,r,g,v]),h.jsx(Eu.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:h.jsx(nt.span,{tabIndex:l?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:Oe(e.onMouseDown,D=>{r?d.onItemFocus(c):D.preventDefault()}),onFocus:Oe(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:Oe(e.onKeyDown,D=>{if(D.key==="Tab"&&D.shiftKey){d.onItemShiftTab();return}if(D.target!==D.currentTarget)return;const w=lS(D,d.orientation,d.dir);if(w!==void 0){if(D.metaKey||D.ctrlKey||D.altKey||D.shiftKey)return;D.preventDefault();let y=m().filter(A=>A.focusable).map(A=>A.ref.current);if(w==="last")y.reverse();else if(w==="prev"||w==="next"){w==="prev"&&y.reverse();const A=y.indexOf(D.currentTarget);y=d.loop?dS(y,A+1):y.slice(A+1)}setTimeout(()=>Lm(y))}}),children:typeof i=="function"?i({isCurrentTabStop:l,hasTabStop:C!=null}):i})})});jm.displayName=Nm;var uS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function lS(e,t,n){const r=cS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return uS[r]}function Lm(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fS=km,hS=jm,yu=["Enter"," "],pS=["ArrowDown","PageUp","Home"],Um=["ArrowUp","PageDown","End"],mS=[...pS,...Um],gS={ltr:[...yu,"ArrowRight"],rtl:[...yu,"ArrowLeft"]},vS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bs="Menu",[es,CS,ES]=Vp(bs),[_r,$m]=Pr(bs,[ES,So,_m]),Ui=So(),Hm=_m(),[yS,kr]=_r(bs),[bS,ws]=_r(bs),Vm=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ui(t),[u,c]=f.useState(null),d=f.useRef(!1),l=On(s),m=Wp(o);return f.useEffect(()=>{const g=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),f.useEffect(()=>{if(!n)return;const g=()=>l(!1);return window.addEventListener("blur",g),()=>window.removeEventListener("blur",g)},[n,l]),h.jsx(Oc,{...a,children:h.jsx(yS,{scope:t,open:n,onOpenChange:l,content:u,onContentChange:c,children:h.jsx(bS,{scope:t,onClose:f.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Vm.displayName=bs;var wS="MenuAnchor",Ic=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ui(n);return h.jsx(Li,{...o,...r,ref:t})});Ic.displayName=wS;var Bc="MenuPortal",[DS,Wm]=_r(Bc,{forceMount:void 0}),zm=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=kr(Bc,t);return h.jsx(DS,{scope:t,forceMount:n,children:h.jsx(Pn,{present:n||s.open,children:h.jsx(_i,{asChild:!0,container:o,children:r})})})};zm.displayName=Bc;var Wt="MenuContent",[AS,Fc]=_r(Wt),Km=f.forwardRef((e,t)=>{const n=Wm(Wt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kr(Wt,e.__scopeMenu),i=ws(Wt,e.__scopeMenu);return h.jsx(es.Provider,{scope:e.__scopeMenu,children:h.jsx(Pn,{present:r||s.open,children:h.jsx(es.Slot,{scope:e.__scopeMenu,children:i.modal?h.jsx(SS,{...o,ref:t}):h.jsx(xS,{...o,ref:t})})})})}),SS=f.forwardRef((e,t)=>{const n=kr(Wt,e.__scopeMenu),r=f.useRef(null),o=tt(t,r);return f.useEffect(()=>{const s=r.current;if(s)return rm(s)},[]),h.jsx(Pc,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Oe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),xS=f.forwardRef((e,t)=>{const n=kr(Wt,e.__scopeMenu);return h.jsx(Pc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),OS=lo("MenuContent.ScrollLock"),Pc=f.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:u,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:l,onInteractOutside:m,onDismiss:g,disableOutsideScroll:v,...C}=e,p=kr(Wt,n),D=ws(Wt,n),w=Ui(n),b=Hm(n),y=CS(n),[A,T]=f.useState(null),S=f.useRef(null),P=tt(t,S,p.onContentChange),L=f.useRef(0),F=f.useRef(""),M=f.useRef(0),N=f.useRef(null),_=f.useRef("right"),I=f.useRef(0),j=v?Cc:f.Fragment,z=v?{as:OS,allowPinchZoom:!0}:void 0,Y=G=>{const Z=F.current+G,le=y().filter(q=>!q.disabled),de=document.activeElement,ue=le.find(q=>q.ref.current===de)?.textValue,ee=le.map(q=>q.textValue),te=LS(ee,Z,ue),R=le.find(q=>q.textValue===te)?.ref.current;(function q(J){F.current=J,window.clearTimeout(L.current),J!==""&&(L.current=window.setTimeout(()=>q(""),1e3))})(Z),R&&setTimeout(()=>R.focus())};f.useEffect(()=>()=>window.clearTimeout(L.current),[]),qp();const oe=f.useCallback(G=>_.current===N.current?.side&&$S(G,N.current?.area),[]);return h.jsx(AS,{scope:n,searchRef:F,onItemEnter:f.useCallback(G=>{oe(G)&&G.preventDefault()},[oe]),onItemLeave:f.useCallback(G=>{oe(G)||(S.current?.focus(),T(null))},[oe]),onTriggerLeave:f.useCallback(G=>{oe(G)&&G.preventDefault()},[oe]),pointerGraceTimerRef:M,onPointerGraceIntentChange:f.useCallback(G=>{N.current=G},[]),children:h.jsx(j,{...z,children:h.jsx(vc,{asChild:!0,trapped:o,onMountAutoFocus:Oe(s,G=>{G.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:h.jsx(Mi,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:l,onInteractOutside:m,onDismiss:g,children:h.jsx(fS,{asChild:!0,...b,dir:D.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:T,onEntryFocus:Oe(u,G=>{D.isUsingKeyboardRef.current||G.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(Tc,{role:"menu","aria-orientation":"vertical","data-state":ug(p.open),"data-radix-menu-content":"",dir:D.dir,...w,...C,ref:P,style:{outline:"none",...C.style},onKeyDown:Oe(C.onKeyDown,G=>{const le=G.target.closest("[data-radix-menu-content]")===G.currentTarget,de=G.ctrlKey||G.altKey||G.metaKey,ue=G.key.length===1;le&&(G.key==="Tab"&&G.preventDefault(),!de&&ue&&Y(G.key));const ee=S.current;if(G.target!==ee||!mS.includes(G.key))return;G.preventDefault();const R=y().filter(q=>!q.disabled).map(q=>q.ref.current);Um.includes(G.key)&&R.reverse(),NS(R)}),onBlur:Oe(e.onBlur,G=>{G.currentTarget.contains(G.target)||(window.clearTimeout(L.current),F.current="")}),onPointerMove:Oe(e.onPointerMove,ts(G=>{const Z=G.target,le=I.current!==G.clientX;if(G.currentTarget.contains(Z)&&le){const de=G.clientX>I.current?"right":"left";_.current=de,I.current=G.clientX}}))})})})})})})});Km.displayName=Wt;var TS="MenuGroup",Mc=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(nt.div,{role:"group",...r,ref:t})});Mc.displayName=TS;var RS="MenuLabel",Gm=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(nt.div,{...r,ref:t})});Gm.displayName=RS;var hi="MenuItem",Bd="menu.itemSelect",$i=f.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=f.useRef(null),i=ws(hi,e.__scopeMenu),a=Fc(hi,e.__scopeMenu),u=tt(t,s),c=f.useRef(!1),d=()=>{const l=s.current;if(!n&&l){const m=new CustomEvent(Bd,{bubbles:!0,cancelable:!0});l.addEventListener(Bd,g=>r?.(g),{once:!0}),$p(l,m),m.defaultPrevented?c.current=!1:i.onClose()}};return h.jsx(qm,{...o,ref:u,disabled:n,onClick:Oe(e.onClick,d),onPointerDown:l=>{e.onPointerDown?.(l),c.current=!0},onPointerUp:Oe(e.onPointerUp,l=>{c.current||l.currentTarget?.click()}),onKeyDown:Oe(e.onKeyDown,l=>{n||l.target!==l.currentTarget||a.searchRef.current!==""&&l.key===" "||yu.includes(l.key)&&(l.currentTarget.click(),l.preventDefault())})})});$i.displayName=hi;var qm=f.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Fc(hi,n),a=Hm(n),u=f.useRef(null),c=tt(t,u),[d,l]=f.useState(!1),[m,g]=f.useState("");return f.useEffect(()=>{const v=u.current;v&&g((v.textContent??"").trim())},[s.children]),h.jsx(es.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:h.jsx(hS,{asChild:!0,...a,focusable:!r,children:h.jsx(nt.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Oe(e.onPointerMove,ts(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Oe(e.onPointerLeave,ts(v=>i.onItemLeave(v))),onFocus:Oe(e.onFocus,()=>l(!0)),onBlur:Oe(e.onBlur,()=>l(!1))})})})}),IS="MenuCheckboxItem",Ym=f.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return h.jsx(eg,{scope:e.__scopeMenu,checked:n,children:h.jsx($i,{role:"menuitemcheckbox","aria-checked":pi(n)?"mixed":n,...o,ref:t,"data-state":kc(n),onSelect:Oe(o.onSelect,()=>r?.(pi(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ym.displayName=IS;var Jm="MenuRadioGroup",[BS,FS]=_r(Jm,{value:void 0,onValueChange:()=>{}}),Zm=f.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=On(r);return h.jsx(BS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(Mc,{...o,ref:t})})});Zm.displayName=Jm;var Xm="MenuRadioItem",Qm=f.forwardRef((e,t)=>{const{value:n,...r}=e,o=FS(Xm,e.__scopeMenu),s=n===o.value;return h.jsx(eg,{scope:e.__scopeMenu,checked:s,children:h.jsx($i,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":kc(s),onSelect:Oe(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Qm.displayName=Xm;var _c="MenuItemIndicator",[eg,PS]=_r(_c,{checked:!1}),tg=f.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=PS(_c,n);return h.jsx(Pn,{present:r||pi(s.checked)||s.checked===!0,children:h.jsx(nt.span,{...o,ref:t,"data-state":kc(s.checked)})})});tg.displayName=_c;var MS="MenuSeparator",ng=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(nt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ng.displayName=MS;var _S="MenuArrow",rg=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ui(n);return h.jsx(Rc,{...o,...r,ref:t})});rg.displayName=_S;var kS="MenuSub",[D4,og]=_r(kS),ko="MenuSubTrigger",sg=f.forwardRef((e,t)=>{const n=kr(ko,e.__scopeMenu),r=ws(ko,e.__scopeMenu),o=og(ko,e.__scopeMenu),s=Fc(ko,e.__scopeMenu),i=f.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:u}=s,c={__scopeMenu:e.__scopeMenu},d=f.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);f.useEffect(()=>d,[d]),f.useEffect(()=>{const m=a.current;return()=>{window.clearTimeout(m),u(null)}},[a,u]);const l=tt(t,o.onTriggerChange);return h.jsx(Ic,{asChild:!0,...c,children:h.jsx(qm,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.open?o.contentId:void 0,"data-state":ug(n.open),...e,ref:l,onClick:m=>{e.onClick?.(m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Oe(e.onPointerMove,ts(m=>{s.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:Oe(e.onPointerLeave,ts(m=>{d();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,C=v==="right",p=C?-5:5,D=g[C?"left":"right"],w=g[C?"right":"left"];s.onPointerGraceIntentChange({area:[{x:m.clientX+p,y:m.clientY},{x:D,y:g.top},{x:w,y:g.top},{x:w,y:g.bottom},{x:D,y:g.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(m),m.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Oe(e.onKeyDown,m=>{e.disabled||m.target!==m.currentTarget||s.searchRef.current!==""&&m.key===" "||gS[r.dir].includes(m.key)&&(n.onOpenChange(!0),n.content?.focus(),m.preventDefault())})})})});sg.displayName=ko;var ig="MenuSubContent",ag=f.forwardRef((e,t)=>{const n=Wm(Wt,e.__scopeMenu),{forceMount:r=n.forceMount,align:o="start",...s}=e,i=kr(Wt,e.__scopeMenu),a=ws(Wt,e.__scopeMenu),u=og(ig,e.__scopeMenu),c=f.useRef(null),d=tt(t,c);return h.jsx(es.Provider,{scope:e.__scopeMenu,children:h.jsx(Pn,{present:r||i.open,children:h.jsx(es.Slot,{scope:e.__scopeMenu,children:h.jsx(Pc,{id:u.contentId,"aria-labelledby":u.triggerId,...s,ref:d,align:o,side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:l=>{a.isUsingKeyboardRef.current&&c.current?.focus(),l.preventDefault()},onCloseAutoFocus:l=>l.preventDefault(),onFocusOutside:Oe(e.onFocusOutside,l=>{l.target!==u.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Oe(e.onEscapeKeyDown,l=>{a.onClose(),l.preventDefault()}),onKeyDown:Oe(e.onKeyDown,l=>{const m=l.currentTarget.contains(l.target),g=vS[a.dir].includes(l.key);m&&g&&(i.onOpenChange(!1),u.trigger?.focus(),l.preventDefault())})})})})})});ag.displayName=ig;function ug(e){return e?"open":"closed"}function pi(e){return e==="indeterminate"}function kc(e){return pi(e)?"indeterminate":e?"checked":"unchecked"}function NS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function jS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function LS(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=jS(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const u=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function US(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],u=t[i],c=a.x,d=a.y,l=u.x,m=u.y;d>r!=m>r&&n<(l-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $S(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return US(n,t)}function ts(e){return t=>t.pointerType==="mouse"?e(t):void 0}var HS=Vm,VS=Ic,WS=zm,zS=Km,KS=Mc,GS=Gm,qS=$i,YS=Ym,JS=Zm,ZS=Qm,XS=tg,QS=ng,e2=rg,t2=sg,n2=ag,Hi="DropdownMenu",[r2]=Pr(Hi,[$m]),Ot=$m(),[o2,cg]=r2(Hi),lg=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,u=Ot(t),c=f.useRef(null),[d,l]=Cs({prop:o,defaultProp:s??!1,onChange:i,caller:Hi});return h.jsx(o2,{scope:t,triggerId:Jo(),triggerRef:c,contentId:Jo(),open:d,onOpenChange:l,onOpenToggle:f.useCallback(()=>l(m=>!m),[l]),modal:a,children:h.jsx(HS,{...u,open:d,onOpenChange:l,dir:r,modal:a,children:n})})};lg.displayName=Hi;var dg="DropdownMenuTrigger",fg=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=cg(dg,n),i=Ot(n),a=tt(t,s.triggerRef);return h.jsx(VS,{asChild:!0,...i,children:h.jsx(nt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:a,onPointerDown:Oe(e.onPointerDown,u=>{!r&&u.button===0&&u.ctrlKey===!1&&(s.onOpenToggle(),s.open||u.preventDefault())}),onKeyDown:Oe(e.onKeyDown,u=>{r||(["Enter"," "].includes(u.key)&&s.onOpenToggle(),u.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});fg.displayName=dg;var s2="DropdownMenuPortal",hg=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return h.jsx(WS,{...r,...n})};hg.displayName=s2;var pg="DropdownMenuContent",mg=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=cg(pg,n),s=Ot(n),i=f.useRef(!1);return h.jsx(zS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{i.current||o.triggerRef.current?.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:Oe(e.onInteractOutside,a=>{const u=a.detail.originalEvent,c=u.button===0&&u.ctrlKey===!0,d=u.button===2||c;(!o.modal||d)&&(i.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)"}})});mg.displayName=pg;var i2="DropdownMenuGroup",a2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(KS,{...o,...r,ref:t})});a2.displayName=i2;var u2="DropdownMenuLabel",c2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(GS,{...o,...r,ref:t})});c2.displayName=u2;var l2="DropdownMenuItem",gg=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(qS,{...o,...r,ref:t})});gg.displayName=l2;var d2="DropdownMenuCheckboxItem",f2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(YS,{...o,...r,ref:t})});f2.displayName=d2;var h2="DropdownMenuRadioGroup",p2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(JS,{...o,...r,ref:t})});p2.displayName=h2;var m2="DropdownMenuRadioItem",g2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(ZS,{...o,...r,ref:t})});g2.displayName=m2;var v2="DropdownMenuItemIndicator",C2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(XS,{...o,...r,ref:t})});C2.displayName=v2;var E2="DropdownMenuSeparator",y2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(QS,{...o,...r,ref:t})});y2.displayName=E2;var b2="DropdownMenuArrow",w2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(e2,{...o,...r,ref:t})});w2.displayName=b2;var D2="DropdownMenuSubTrigger",A2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(t2,{...o,...r,ref:t})});A2.displayName=D2;var S2="DropdownMenuSubContent",x2=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return h.jsx(n2,{...o,...r,ref:t,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)"}})});x2.displayName=S2;var O2=lg,T2=fg,R2=hg,I2=mg,Vi="Popover",[vg]=Pr(Vi,[So]),Ds=So(),[B2,rr]=vg(Vi),Cg=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Ds(t),u=f.useRef(null),[c,d]=f.useState(!1),[l,m]=Cs({prop:r,defaultProp:o??!1,onChange:s,caller:Vi});return h.jsx(Oc,{...a,children:h.jsx(B2,{scope:t,contentId:Jo(),triggerRef:u,open:l,onOpenChange:m,onOpenToggle:f.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:c,onCustomAnchorAdd:f.useCallback(()=>d(!0),[]),onCustomAnchorRemove:f.useCallback(()=>d(!1),[]),modal:i,children:n})})};Cg.displayName=Vi;var Eg="PopoverAnchor",F2=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=rr(Eg,n),s=Ds(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return f.useEffect(()=>(i(),()=>a()),[i,a]),h.jsx(Li,{...s,...r,ref:t})});F2.displayName=Eg;var yg="PopoverTrigger",bg=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=rr(yg,n),s=Ds(n),i=tt(t,o.triggerRef),a=h.jsx(nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":xg(o.open),...r,ref:i,onClick:Oe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:h.jsx(Li,{asChild:!0,...s,children:a})});bg.displayName=yg;var Nc="PopoverPortal",[P2,M2]=vg(Nc,{forceMount:void 0}),wg=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=rr(Nc,t);return h.jsx(P2,{scope:t,forceMount:n,children:h.jsx(Pn,{present:n||s.open,children:h.jsx(_i,{asChild:!0,container:o,children:r})})})};wg.displayName=Nc;var ho="PopoverContent",Dg=f.forwardRef((e,t)=>{const n=M2(ho,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=rr(ho,e.__scopePopover);return h.jsx(Pn,{present:r||s.open,children:s.modal?h.jsx(k2,{...o,ref:t}):h.jsx(N2,{...o,ref:t})})});Dg.displayName=ho;var _2=lo("PopoverContent.RemoveScroll"),k2=f.forwardRef((e,t)=>{const n=rr(ho,e.__scopePopover),r=f.useRef(null),o=tt(t,r),s=f.useRef(!1);return f.useEffect(()=>{const i=r.current;if(i)return rm(i)},[]),h.jsx(Cc,{as:_2,allowPinchZoom:!0,children:h.jsx(Ag,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0,c=a.button===2||u;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Oe(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),N2=f.forwardRef((e,t)=>{const n=rr(ho,e.__scopePopover),r=f.useRef(!1),o=f.useRef(!1);return h.jsx(Ag,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Ag=f.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:c,onInteractOutside:d,...l}=e,m=rr(ho,n),g=Ds(n);return qp(),h.jsx(vc,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:h.jsx(Mi,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:c,onDismiss:()=>m.onOpenChange(!1),deferPointerDownOutside:!0,children:h.jsx(Tc,{"data-state":xg(m.open),role:"dialog",id:m.contentId,...g,...l,ref:t,style:{...l.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)"}})})})}),Sg="PopoverClose",j2=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=rr(Sg,n);return h.jsx(nt.button,{type:"button",...r,ref:t,onClick:Oe(e.onClick,()=>o.onOpenChange(!1))})});j2.displayName=Sg;var L2="PopoverArrow",U2=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ds(n);return h.jsx(Rc,{...o,...r,ref:t})});U2.displayName=L2;function xg(e){return e?"open":"closed"}var $2=Cg,H2=bg,V2=wg,W2=Dg,Og="Toggle",Tg=f.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=Cs({prop:n,onChange:o,defaultProp:r??!1,caller:Og});return h.jsx(nt.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:Oe(e.onClick,()=>{e.disabled||a(!i)})})});Tg.displayName=Og;var jc=Tg,[Wi]=Pr("Tooltip",[So]),zi=So(),Rg="TooltipProvider",z2=700,bu="tooltip.open",[K2,Lc]=Wi(Rg),Ig=e=>{const{__scopeTooltip:t,delayDuration:n=z2,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=f.useRef(!0),a=f.useRef(!1),u=f.useRef(0);return f.useEffect(()=>{const c=u.current;return()=>window.clearTimeout(c)},[]),h.jsx(K2,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:f.useCallback(()=>{r<=0||(window.clearTimeout(u.current),i.current=!1)},[r]),onClose:f.useCallback(()=>{r<=0||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:f.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Ig.displayName=Rg;var ns="Tooltip",[G2,As]=Wi(ns),Bg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,u=Lc(ns,e.__scopeTooltip),c=zi(t),[d,l]=f.useState(null),m=Jo(),g=f.useRef(0),v=i??u.disableHoverableContent,C=a??u.delayDuration,p=f.useRef(!1),[D,w]=Cs({prop:r,defaultProp:o??!1,onChange:S=>{S?(u.onOpen(),document.dispatchEvent(new CustomEvent(bu))):u.onClose(),s?.(S)},caller:ns}),b=f.useMemo(()=>D?p.current?"delayed-open":"instant-open":"closed",[D]),y=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,p.current=!1,w(!0)},[w]),A=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w(!1)},[w]),T=f.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{p.current=!0,w(!0),g.current=0},C)},[C,w]);return f.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),h.jsx(Oc,{...c,children:h.jsx(G2,{scope:t,contentId:m,open:D,stateAttribute:b,trigger:d,onTriggerChange:l,onTriggerEnter:f.useCallback(()=>{u.isOpenDelayedRef.current?T():y()},[u.isOpenDelayedRef,T,y]),onTriggerLeave:f.useCallback(()=>{v?A():(window.clearTimeout(g.current),g.current=0)},[A,v]),onOpen:y,onClose:A,disableHoverableContent:v,children:n})})};Bg.displayName=ns;var wu="TooltipTrigger",Fg=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=As(wu,n),s=Lc(wu,n),i=zi(n),a=f.useRef(null),u=tt(t,a,o.onTriggerChange),c=f.useRef(!1),d=f.useRef(!1),l=f.useCallback(()=>c.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",l),[l]),h.jsx(Li,{asChild:!0,...i,children:h.jsx(nt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:Oe(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",l,{once:!0})}),onFocus:Oe(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:Oe(e.onBlur,o.onClose),onClick:Oe(e.onClick,o.onClose)})})});Fg.displayName=wu;var Uc="TooltipPortal",[q2,Y2]=Wi(Uc,{forceMount:void 0}),Pg=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=As(Uc,t);return h.jsx(q2,{scope:t,forceMount:n,children:h.jsx(Pn,{present:n||s.open,children:h.jsx(_i,{asChild:!0,container:o,children:r})})})};Pg.displayName=Uc;var po="TooltipContent",Mg=f.forwardRef((e,t)=>{const n=Y2(po,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=As(po,e.__scopeTooltip);return h.jsx(Pn,{present:r||i.open,children:i.disableHoverableContent?h.jsx(_g,{side:o,...s,ref:t}):h.jsx(J2,{side:o,...s,ref:t})})}),J2=f.forwardRef((e,t)=>{const n=As(po,e.__scopeTooltip),r=Lc(po,e.__scopeTooltip),o=f.useRef(null),s=tt(t,o),[i,a]=f.useState(null),{trigger:u,onClose:c}=n,d=o.current,{onPointerInTransitChange:l}=r,m=f.useCallback(()=>{a(null),l(!1)},[l]),g=f.useCallback((v,C)=>{const p=v.currentTarget,D={x:v.clientX,y:v.clientY},w=tx(D,p.getBoundingClientRect()),b=nx(D,w),y=rx(C.getBoundingClientRect()),A=sx([...b,...y]);a(A),l(!0)},[l]);return f.useEffect(()=>()=>m(),[m]),f.useEffect(()=>{if(u&&d){const v=p=>g(p,d),C=p=>g(p,u);return u.addEventListener("pointerleave",v),d.addEventListener("pointerleave",C),()=>{u.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",C)}}},[u,d,g,m]),f.useEffect(()=>{if(i){const v=C=>{const p=C.target,D={x:C.clientX,y:C.clientY},w=u?.contains(p)||d?.contains(p),b=!ox(D,i);w?m():b&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,d,i,c,m]),h.jsx(_g,{...e,ref:s})}),[Z2,X2]=Wi(ns,{isInside:!1}),Q2=Up("TooltipContent"),_g=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,u=As(po,n),c=zi(n),{onClose:d}=u;return f.useEffect(()=>(document.addEventListener(bu,d),()=>document.removeEventListener(bu,d)),[d]),f.useEffect(()=>{if(u.trigger){const l=m=>{m.target instanceof Node&&m.target.contains(u.trigger)&&d()};return window.addEventListener("scroll",l,{capture:!0}),()=>window.removeEventListener("scroll",l,{capture:!0})}},[u.trigger,d]),h.jsx(Mi,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:l=>l.preventDefault(),onDismiss:d,children:h.jsxs(Tc,{"data-state":u.stateAttribute,...c,...a,ref:t,style:{...a.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:[h.jsx(Q2,{children:r}),h.jsx(Z2,{scope:n,isInside:!0,children:h.jsx(Ww,{id:u.contentId,role:"tooltip",children:o||r})})]})})});Mg.displayName=po;var kg="TooltipArrow",ex=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=zi(n);return X2(kg,n).isInside?null:h.jsx(Rc,{...o,...r,ref:t})});ex.displayName=kg;function tx(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function nx(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});break}return r}function rx(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 ox(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],u=t[i],c=a.x,d=a.y,l=u.x,m=u.y;d>r!=m>r&&n<(l-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function sx(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),ix(t)}function ix(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 s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}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 s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}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)}var ax=Ig,ux=Bg,cx=Fg,lx=Pg,dx=Mg;function Ki(e){const t=new Map;return(...n)=>{const r=JSON.stringify(n.map(i=>Zn(i))),o=t.get(r);if(o!==void 0)return o;const s=e(...n);return t.set(r,s),s}}const Ng=Ki((...e)=>new Intl.DateTimeFormat(...e)),Fd=Ki((...e)=>new Intl.RelativeTimeFormat(...e)),fx=Ki((...e)=>new Intl.ListFormat(...e)),yr=Ki((...e)=>new Intl.NumberFormat(...e));function jg(e,t){const n=f.useRef(e);f.useEffect(()=>{n.current=e},[e]),f.useEffect(()=>{if(!t&&t!==0)return;const r=setInterval(()=>{n.current()===!1&&clearInterval(r)},t);return()=>clearInterval(r)},[t])}function Lg(){const[e,t]=f.useReducer(n=>n+1,0);return[t,e]}const hx=.5*1e3;function $c(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 s=t%24;t=Math.floor(t/24);const i=t%7;return{weeks:Math.floor(t/7),days:i,hours:s,minutes:o,seconds:r,milliseconds:n}}const Ug={weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second",milliseconds:"millisecond"};function px(e,t){let n;t?n=t:n=yr().resolvedOptions().locale;const r=$c(e),o=[];for(const[s,i]of Object.entries(r)){if(i===0||s==="milliseconds")continue;const a=yr(n,{style:"unit",unit:Ug[s],unitDisplay:"narrow"});o.push(a.format(i))}return o.length||o.push(yr(n,{style:"unit",unit:"second",unitDisplay:"narrow"}).format(0)),o.join(" ")}function mx(e,t){let n;t?n=t:n=yr().resolvedOptions().locale;const r=$c(e),o=[];for(const[s,i]of Object.entries(r)){if(i===0||s==="milliseconds")continue;const a=yr(n,{style:"unit",unit:Ug[s],unitDisplay:"long"});o.push(a.format(i))}return o.length||o.push(yr(n,{style:"unit",unit:"second",unitDisplay:"long"}).format(0)),o.join(" ")}function gx(e){const t=Math.max(e,0);if(t===0)return"PT0S";const{weeks:n,days:r,hours:o,minutes:s,seconds:i,milliseconds:a}=$c(t);let u="P";return n>0&&(u+=`${n}W`),r>0&&(u+=`${r}D`),(o>0||s>0||i>0||a>0)&&(u+="T",o>0&&(u+=`${o}H`),s>0&&(u+=`${s}M`),(i>0||a>0)&&(a>0?u+=`${i}.${a.toString().padStart(3,"0").replace(/0+$/,"")}S`:u+=`${i}S`)),u}function Pd(e){return e instanceof Date?e.getTime():new Date(e).getTime()}function $g(e,t){return Pd(t)-Pd(e)}const ka=f.forwardRef(({duration:e,from:t,to:n,locale:r,dateTime:o,title:s=mx,children:i=px,interval:a=hx,asChild:u,...c},d)=>{const l=u?ot:"time",[m,g]=Lg(),v=f.useMemo(()=>e!==void 0?e:t!==void 0?$g(t,n??Date.now()):0,[e,t,n,g]),C=f.useMemo(()=>gx(v),[v]),p=f.useMemo(()=>typeof s=="function"?s(v,r):s,[s,v,r]),D=f.useMemo(()=>typeof i=="function"?i(v,r):i,[i,v,r]);return jg(m,t!==void 0&&n===void 0?a:!1),h.jsx(l,{...c,ref:d,dateTime:o??C,title:p,children:D})});function $s(e,t,n){return e===1?t:n??`${t}s`}const vx=3*1e3;function Na(e,t){return $g(e,t??Date.now())>=vx}const Cx={locale:"en",dir:"ltr",USER_SELF:"you",USER_UNKNOWN:"Anonymous",COPY_TO_CLIPBOARD:"Copy",LIST_REMAINING:e=>`${e} more`,LIST_REMAINING_USERS:e=>`${e} ${$s(e,"other")}`,LIST_REMAINING_COMMENTS:e=>`${e} more ${$s(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 Je(e,"Unexpected mark")}},COMMENT_EDITED:"(edited)",COMMENT_DELETED:"This comment has been deleted.",COMMENT_MORE:"More",COMMENT_EDIT:"Edit comment",COMMENT_EDIT_COMPOSER_PLACEHOLDER:"Edit comment…",COMMENT_EDIT_COMPOSER_CANCEL:"Cancel",COMMENT_EDIT_COMPOSER_SAVE:"Save",COMMENT_DELETE:"Delete comment",COMMENT_DELETE_ATTACHMENT:"Delete attachment",COMMENT_ADD_REACTION:"Add reaction",COMMENT_REACTION_LIST:(e,t)=>h.jsxs(h.Fragment,{children:[e," reacted with ",h.jsx(gc,{emoji:t})]}),COMMENT_REACTION_DESCRIPTION:(e,t)=>`${t} ${$s(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 ${$s(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)=>h.jsxs(h.Fragment,{children:[e," commented",t?h.jsxs(h.Fragment,{children:[" in ",t]}):h.jsx(h.Fragment,{children:" in a thread"})]}),INBOX_NOTIFICATION_THREAD_MENTION:(e,t)=>h.jsxs(h.Fragment,{children:[e," mentioned you",t?h.jsxs(h.Fragment,{children:[" in ",t]}):null]}),INBOX_NOTIFICATION_TEXT_MENTION:(e,t)=>h.jsxs(h.Fragment,{children:[e," mentioned you",t?h.jsxs(h.Fragment,{children:[" in ",t]}):null]}),HISTORY_VERSION_PREVIEW_AUTHORS_LIST:e=>h.jsxs(h.Fragment,{children:["Edits from ",e]}),HISTORY_VERSION_PREVIEW_RESTORE:"Restore",HISTORY_VERSION_PREVIEW_EMPTY:"No content.",HISTORY_VERSION_PREVIEW_ERROR:()=>"There was an error while getting this version.",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?h.jsx(h.Fragment,{children:"Reasoning…"}):h.jsxs(h.Fragment,{children:["Reasoned",Na(t.startedAt,t.endedAt)?h.jsxs(h.Fragment,{children:[" ","for"," ",h.jsx(ka,{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?h.jsxs(h.Fragment,{children:["Searching"," ",h.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),"…"]}):h.jsxs(h.Fragment,{children:["Searched"," ",h.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),Na(t.startedAt,t.endedAt)?h.jsxs(h.Fragment,{children:[" ","for"," ",h.jsx(ka,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):t.kind==="web"?e?h.jsxs(h.Fragment,{children:["Searching the web",t.query?h.jsxs(h.Fragment,{children:[" ","for"," ",h.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,"…"]}):h.jsxs(h.Fragment,{children:["Searched the web",t.query?h.jsxs(h.Fragment,{children:[" ","for"," ",h.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,Na(t.startedAt,t.endedAt)?h.jsxs(h.Fragment,{children:[" ","for"," ",h.jsx(ka,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):Je(t,"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"},Ex=f.createContext(void 0);function st(e){const t=f.useContext(Ex);return f.useMemo(()=>({...Cx,...t,...e}),[t,e])}function yx(e){return e.trim().split(" ").reduce((t,n,r,o)=>((r===0||r===o.length-1)&&(t+=n.charAt(0).toLocaleUpperCase()),t),"")}function Md(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Hg={Anchor:"a"},Du=f.createContext(void 0);function Vg(e){const t=f.useContext(Du);return f.useMemo(()=>({...Hg,...t,...e}),[t,e])}function bx({children:e,components:t}){const n=f.useContext(Du),r=f.useMemo(()=>({...Hg,...n,...t}),[n,t]);return h.jsx(Du.Provider,{value:r,children:e})}const wx=f.createContext({});function Ss(){return f.useContext(wx)}const Dx=/Mac|iPod|iPhone|iPad/;function Wg(){return typeof window<"u"&&Dx.test(window.navigator.platform)}const Ax={title:"Alt",key:"⌥"},ja={title:"Command",key:"⌘"},La={title:"Ctrl",key:"⌃"},Sx={title:"Shift",key:"⇧"},xx={title:"Enter",key:"⏎"},_d={title:"Space",key:"␣"},kd={title:"Escape",key:"⎋"},zg={alt:()=>Ax,mod:()=>Wg()?ja:La,control:()=>La,ctrl:()=>La,command:()=>ja,cmd:()=>ja,shift:()=>Sx,enter:()=>xx," ":()=>_d,space:()=>_d,escape:()=>kd,esc:()=>kd};function Ox(e){const t=e.split("-");return h.jsx(h.Fragment,{children:t.map((n,r)=>{const o=n.toLowerCase();return o in zg?h.jsx(Tx,{name:o},r):h.jsx("span",{children:n},r)})})}const Et=f.forwardRef(({children:e,content:t,multiline:n,className:r,...o},s)=>{const{portalContainer:i}=Ss();return h.jsxs(ux,{disableHoverableContent:!0,children:[h.jsx(cx,{asChild:!0,ref:s,children:e}),h.jsx(lx,{container:i,children:h.jsx(dx,{className:Be("lb-root lb-portal lb-tooltip",n&&"lb-tooltip:multiline",r),side:"top",align:"center",updatePositionStrategy:"always",sideOffset:Do,collisionPadding:vs,...o,children:t})})]})}),Hc=f.forwardRef(({children:e,content:t,shortcut:n,...r},o)=>{const s=f.useMemo(()=>n?Ox(n):null,[n]);return h.jsx(Et,{content:h.jsxs(h.Fragment,{children:[t,s&&h.jsx("kbd",{className:"lb-tooltip-shortcut",children:s})]}),...r,ref:o,children:e})});function Tx({name:e,...t}){const{title:n,key:r}=f.useMemo(()=>zg[e]?.(),[e]);return h.jsx("abbr",{title:n,...t,children:r})}const xo=ax;function Gi({src:e,name:t,className:n,children:r,tooltip:o,outline:s,style:i,...a}){const u=f.useMemo(()=>t?yx(t):void 0,[t]),c=typeof s=="object"?s:typeof s=="string"?{color:s}:s===!0?{}:void 0,d=h.jsx("div",{className:Be("lb-avatar",n),"data-variant":c?"outline":"default",style:{"--lb-avatar-outline-color":c?.color,"--lb-avatar-outline-width":Md(c?.width),"--lb-avatar-outline-gap":Md(c?.gap),...i},...a,children:h.jsx("div",{className:"lb-avatar-content",children:r??(e?h.jsx("img",{className:"lb-avatar-image",src:e,alt:t}):u?h.jsx("span",{className:"lb-avatar-fallback","aria-label":t,title:t,children:u}):null)})});return o?h.jsx(xo,{children:h.jsx(Et,{content:o,sideOffset:Do,collisionPadding:vs,side:"top",align:"center",children:d})}):d}function Rx({userId:e,icon:t,variant:n="default",tooltip:r,...o}){const{user:s,isLoading:i}=Bp(e);return h.jsx(Gi,{src:s?.avatar,name:i?void 0:s?.name??e,outline:n==="outline"&&typeof s?.color=="string"?s.color:void 0,"data-loading":i?"":void 0,tooltip:r,...o,children:t&&(i||!s?.avatar)?t:null})}function Ix({groupId:e,icon:t,variant:n="default",tooltip:r,...o}){const{info:s,isLoading:i}=hc(e);return h.jsx(Gi,{src:s?.avatar,name:i?void 0:s?.name??e,outline:n==="outline"&&typeof s?.color=="string"?s.color:void 0,"data-loading":i?"":void 0,tooltip:r,...o,children:t&&(i||!s?.avatar)?t:null})}function qi({userId:e,icon:t,variant:n="default",...r}){const o=st();return e?h.jsx(Rx,{userId:e,icon:t,variant:n,...r}):h.jsx(Gi,{name:o.USER_UNKNOWN,outline:n==="outline",...r,children:t})}function Bx({groupId:e,icon:t,variant:n="default",...r}){return e?h.jsx(Ix,{groupId:e,icon:t,variant:n,...r}):h.jsx(Gi,{outline:n==="outline",...r,children:t})}const Nd=20,jd=20;function We({children:e,className:t,...n}){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:Nd,height:jd,viewBox:`0 0 ${Nd} ${jd}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",role:"presentation",className:Be("lb-icon",t),...n,children:e})}function Fx(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"M14.5 8.5 10 13 5.5 8.5"})})}const Vc=f.forwardRef(({variant:e="default",size:t="default",disableable:n=!0,className:r,children:o,...s},i)=>h.jsx("button",{type:"button",className:Be("lb-button",!n&&"lb-button:non-disableable",r),"data-variant":e,"data-size":t,...s,ref:i,children:o})),Bt=f.forwardRef(({icon:e,children:t,...n},r)=>h.jsxs(Vc,{...n,ref:r,children:[e?h.jsx("span",{className:"lb-icon-container",children:e}):null,t?h.jsx("span",{className:"lb-button-label",children:t}):null]}));f.forwardRef(({icon:e,children:t,className:n,...r},o)=>h.jsxs(Vc,{...r,type:"button",className:Be("lb-select-button",n),ref:o,children:[e?h.jsx("span",{className:"lb-icon-container",children:e}):null,t?h.jsx("span",{className:"lb-button-label",children:t}):null,h.jsx("span",{className:"lb-select-button-chevron",children:h.jsx(Fx,{})})]}));function Wc({groupId:e,className:t,children:n,...r}){const{info:o,isLoading:s}=hc(e);return h.jsxs("span",{className:Be("lb-name lb-group",t),"data-loading":s?"":void 0,...r,children:[s?null:o?.name??e,n]})}function Px({groupId:e,className:t,...n}){const{info:r}=hc(e);return r?.description?h.jsx("span",{className:Be("lb-group-description",t),...n,children:r.description}):null}const Kg=f.forwardRef(({values:e,formatRemaining:t,truncate:n,locale:r,className:o,asChild:s,...i},a)=>{const u=s?ot:"span",c=st(),d=t??c.LIST_REMAINING,l=f.useMemo(()=>{const m=n&&n<e.length-1?[...e.slice(0,n),d(e.length-n)]:[...e],g=Array(m.length).fill(".");return fx(r).formatToParts(g).map(C=>C.type==="element"?m.shift():C.value)},[d,r,n,e]);return h.jsx(u,{className:Be("lb-list",o),...i,ref:a,children:l})});function Mx(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"M10 4v12m6-6-6 6-6-6"})})}function Gg(e){return h.jsx(We,{...e,children:h.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 qg(e){return h.jsx(We,{...e,children:h.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 Yg(e){return h.jsx(We,{...e,children:h.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 _x(e){return h.jsx(We,{...e,children:h.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 zc(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"M16 6L8 14L4 10"})})}function kx(e){return h.jsxs(We,{...e,children:[h.jsx("circle",{cx:10,cy:10,r:7}),h.jsx("path",{d:"m13 8-4 4-2-2"})]})}function Nx(e){return h.jsxs(We,{...e,children:[h.jsx("circle",{cx:10,cy:10,r:7,fill:"currentColor"}),h.jsx("path",{d:"m13 8-4 4-2-2",stroke:"var(--lb-icon-background)"})]})}function jx(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"m7.5 6-4 4 4 4m5-8 4 4-4 4"})})}function Lx(e){return h.jsxs(We,{...e,children:[h.jsx("path",{d:"M4.5 12.91c-.58-.2-1-.76-1-1.41v-6c0-1.1.9-2 2-2h6c.65 0 1.2.42 1.41 1"}),h.jsx("rect",{x:7,y:7,width:9.5,height:9.5,rx:1.5})]})}function Kc(e){return h.jsxs(We,{...e,children:[h.jsx("path",{d:"M15 5L5 15"}),h.jsx("path",{d:"M5 5L15 15"})]})}function Jg(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"M4.5 6.5h11M14 6.5V14a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 6 14V6.5M7.5 6.5V5a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1.5"})})}function Ux(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"m11.784 5.797-6.13 6.138a4 4 0 0 0-1.03 1.775L4 16l2.285-.624a4 4 0 0 0 1.776-1.032l6.145-6.152m-2.422-2.395 1.244-1.246c.608-.608 1.826-.81 2.53-.104.7.7.499 1.893-.122 2.515l-1.23 1.23m-2.422-2.395 2.422 2.395"})})}function Zg(e){return h.jsxs(We,{fill:"currentColor",...e,children:[h.jsx("circle",{cx:5,cy:10,r:.75}),h.jsx("circle",{cx:10,cy:10,r:.75}),h.jsx("circle",{cx:15,cy:10,r:.75})]})}function $x(e){return h.jsxs(We,{...e,children:[h.jsx("path",{d:"M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14Z"}),h.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h.007"}),h.jsx("path",{d:"M12 8h.007"}),h.jsx("circle",{cx:8,cy:8,r:.25}),h.jsx("circle",{cx:12,cy:8,r:.25})]})}function Ld(e){return h.jsxs(We,{...e,children:[h.jsx("path",{d:"M11 3.07A7 7 0 1 0 16.93 9"}),h.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h0"}),h.jsx("path",{d:"M12 8h0"}),h.jsx("path",{d:"M13 5h4m-2-2v4"}),h.jsx("circle",{cx:"8",cy:"8",r:".25"}),h.jsx("circle",{cx:"12",cy:"8",r:".25"})]})}function Hx(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"M15 4.25H8m4 11.5H5m6.75-11.5-3.5 11.5"})})}function Vx(e){return h.jsxs(We,{...e,children:[h.jsx("path",{d:"M10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),h.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 Wx(e){return h.jsx(We,{...e,children:h.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 zx(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"m5 16 12-6L5 4l2 6-2 6ZM7 10h10"})})}function xs(e){return h.jsx(We,{...e,children:h.jsx("path",{d:"M3 10a7 7 0 0 1 7-7",className:"lb-icon-spinner"})})}function Kx(e){return h.jsx(We,{...e,children:h.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 Gx(e){return h.jsx(We,{...e,children:h.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 Gc(e){return h.jsxs(We,{...e,children:[h.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"}),h.jsx("circle",{cx:10,cy:12,r:.25})]})}const qx=1500;function Yx({title:e,code:t,overrides:n}){const r=st(n),[o,s]=f.useState(!1),i=f.useRef(null);f.useEffect(()=>(o&&(i.current=setTimeout(()=>{s(!1)},qx)),()=>{i.current&&clearTimeout(i.current)}),[o]);const a=f.useCallback(()=>{try{navigator.clipboard.writeText(t),s(!0)}catch(u){console.error(u)}},[t]);return h.jsx(xo,{children:h.jsxs("div",{className:"lb-root lb-code-block",children:[h.jsxs("div",{className:"lb-code-block-header",children:[h.jsx("span",{className:"lb-code-block-title",children:e}),h.jsx("div",{className:"lb-code-block-header-actions",children:h.jsx(Et,{content:o?null:r.COPY_TO_CLIPBOARD,children:h.jsx(Bt,{className:"lb-code-block-header-action",icon:o?h.jsx(zc,{}):h.jsx(Lx,{}),onClick:a,"aria-label":r.COPY_TO_CLIPBOARD})})})]}),h.jsx("pre",{className:"lb-code-block-content",children:h.jsx("code",{children:t})})]})})}function Rn(){const e=_e();return Fr(e[Ce].currentUserId)??null}function mi(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function Xg({isLoading:e,name:t,className:n,children:r,...o}){return h.jsxs("span",{className:Be("lb-name lb-user",n),"data-loading":e?"":void 0,...o,children:[e?null:t,r]})}function Jx({userId:e,replaceSelf:t,...n}){const r=Rn(),{user:o,isLoading:s}=Bp(e),i=st(),a=f.useMemo(()=>t&&r===e?i.USER_SELF:o?.name??i.USER_UNKNOWN,[t,r,e,i.USER_SELF,i.USER_UNKNOWN,o?.name]);return h.jsx(Xg,{isLoading:s,name:a,...n})}function Cn({userId:e,...t}){const n=st();return e?h.jsx(Jx,{userId:e,...t}):h.jsx(Xg,{isLoading:!1,name:n.USER_UNKNOWN,...t})}function qc(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Qg=f.forwardRef(({asChild:e,...t},n)=>{const{portalContainer:r}=Ss(),o=r??document?.body,s=e?ot:"div";return o?hs.createPortal(h.jsx(s,{"data-liveblocks-portal":"",...t,ref:n}),o):null});function mo(e){const[t]=f.useState(e);return t}function Zx(e,t){t&&(typeof e=="function"?e(t):e&&"current"in e&&(e.current=t))}function Xx(e,...t){for(const n of t)Zx(n,e)}function Os(...e){return f.useCallback(t=>Xx(t,...e),e)}function Qx(e){return!!(e.prototype&&"isReactComponent"in e.prototype)}function eO(e,t){const n=t,r=f.useRef(e);return r.current=e,f.useMemo(()=>s=>{const i=r.current;return i?Qx(i)?h.jsx(i,{...s}):i(s):h.jsx(n,{...s})},[n])}function Ud(e){return Object.prototype.toString.call(e)==="[object Object]"}function ut(e){var t,n;return Ud(e)===!1?!1:(t=e.constructor,t===void 0?!0:(n=t.prototype,!(Ud(n)===!1||n.hasOwnProperty("isPrototypeOf")===!1)))}var ev=Symbol.for("immer-nothing"),$d=Symbol.for("immer-draftable"),Nt=Symbol.for("immer-state");function en(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var go=Object.getPrototypeOf;function Or(e){return!!e&&!!e[Nt]}function Tr(e){return e?tv(e)||Array.isArray(e)||!!e[$d]||!!e.constructor?.[$d]||Ji(e)||Zi(e):!1}var tO=Object.prototype.constructor.toString();function tv(e){if(!e||typeof e!="object")return!1;const t=go(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===tO}function gi(e,t){Yi(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Yi(e){const t=e[Nt];return t?t.type_:Array.isArray(e)?1:Ji(e)?2:Zi(e)?3:0}function Au(e,t){return Yi(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function nv(e,t,n){const r=Yi(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function nO(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ji(e){return e instanceof Map}function Zi(e){return e instanceof Set}function lr(e){return e.copy_||e.base_}function Su(e,t){if(Ji(e))return new Map(e);if(Zi(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&tv(e))return go(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[Nt];let r=Reflect.ownKeys(n);for(let o=0;o<r.length;o++){const s=r[o],i=n[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(n[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(go(e),n)}function Yc(e,t=!1){return Xi(e)||Or(e)||!Tr(e)||(Yi(e)>1&&(e.set=e.add=e.clear=e.delete=rO),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Yc(r,!0))),e}function rO(){en(2)}function Xi(e){return Object.isFrozen(e)}var oO={};function Rr(e){const t=oO[e];return t||en(0,e),t}var rs;function rv(){return rs}function sO(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Hd(e,t){t&&(Rr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function xu(e){Ou(e),e.drafts_.forEach(iO),e.drafts_=null}function Ou(e){e===rs&&(rs=e.parent_)}function Vd(e){return rs=sO(rs,e)}function iO(e){const t=e[Nt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Wd(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Nt].modified_&&(xu(t),en(4)),Tr(e)&&(e=vi(t,e),t.parent_||Ci(t,e)),t.patches_&&Rr("Patches").generateReplacementPatches_(n[Nt].base_,e,t.patches_,t.inversePatches_)):e=vi(t,n,[]),xu(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ev?e:void 0}function vi(e,t,n){if(Xi(t))return t;const r=t[Nt];if(!r)return gi(t,(o,s)=>zd(e,r,t,o,s,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Ci(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let s=o,i=!1;r.type_===3&&(s=new Set(o),o.clear(),i=!0),gi(s,(a,u)=>zd(e,r,o,a,u,n,i)),Ci(e,o,!1),n&&e.patches_&&Rr("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function zd(e,t,n,r,o,s,i){if(Or(o)){const a=s&&t&&t.type_!==3&&!Au(t.assigned_,r)?s.concat(r):void 0,u=vi(e,o,a);if(nv(n,r,u),Or(u))e.canAutoFreeze_=!1;else return}else i&&n.add(o);if(Tr(o)&&!Xi(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;vi(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&Ci(e,o)}}function Ci(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Yc(t,n)}function aO(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:rv(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,s=Jc;n&&(o=[r],s=os);const{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,a}var Jc={get(e,t){if(t===Nt)return e;const n=lr(e);if(!Au(n,t))return uO(e,n,t);const r=n[t];return e.finalized_||!Tr(r)?r:r===Ua(e.base_,t)?($a(e),e.copy_[t]=Ru(r,e)):r},has(e,t){return t in lr(e)},ownKeys(e){return Reflect.ownKeys(lr(e))},set(e,t,n){const r=ov(lr(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Ua(lr(e),t),s=o?.[Nt];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(nO(n,o)&&(n!==void 0||Au(e.base_,t)))return!0;$a(e),Tu(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Ua(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,$a(e),Tu(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=lr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){en(11)},getPrototypeOf(e){return go(e.base_)},setPrototypeOf(){en(12)}},os={};gi(Jc,(e,t)=>{os[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});os.deleteProperty=function(e,t){return os.set.call(this,e,t,void 0)};os.set=function(e,t,n){return Jc.set.call(this,e[0],t,n,e[0])};function Ua(e,t){const n=e[Nt];return(n?lr(n):e)[t]}function uO(e,t,n){const r=ov(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function ov(e,t){if(!(t in e))return;let n=go(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=go(n)}}function Tu(e){e.modified_||(e.modified_=!0,e.parent_&&Tu(e.parent_))}function $a(e){e.copy_||(e.copy_=Su(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var cO=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const s=n;n=t;const i=this;return function(u=s,...c){return i.produce(u,d=>n.call(this,d,...c))}}typeof n!="function"&&en(6),r!==void 0&&typeof r!="function"&&en(7);let o;if(Tr(t)){const s=Vd(this),i=Ru(t,void 0);let a=!0;try{o=n(i),a=!1}finally{a?xu(s):Ou(s)}return Hd(s,r),Wd(o,s)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===ev&&(o=void 0),this.autoFreeze_&&Yc(o,!0),r){const s=[],i=[];Rr("Patches").generateReplacementPatches_(t,o,s,i),r(s,i)}return o}else en(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(i,...a)=>this.produceWithPatches(i,u=>t(u,...a));let r,o;return[this.produce(t,n,(i,a)=>{r=i,o=a}),r,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Tr(e)||en(8),Or(e)&&(e=lO(e));const t=Vd(this),n=Ru(e,void 0);return n[Nt].isManual_=!0,Ou(t),n}finishDraft(e,t){const n=e&&e[Nt];(!n||!n.isManual_)&&en(9);const{scope_:r}=n;return Hd(r,t),Wd(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=Rr("Patches").applyPatches_;return Or(e)?r(e,t):this.produce(e,o=>r(o,t))}};function Ru(e,t){const n=Ji(e)?Rr("MapSet").proxyMap_(e,t):Zi(e)?Rr("MapSet").proxySet_(e,t):aO(e,t);return(t?t.scope_:rv()).drafts_.push(n),n}function lO(e){return Or(e)||en(10,e),sv(e)}function sv(e){if(!Tr(e)||Xi(e))return e;const t=e[Nt];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Su(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Su(e,!0);return gi(n,(r,o)=>{nv(n,r,sv(o))}),t&&(t.finalized_=!1),n}var jt=new cO,Zc=jt.produce;jt.produceWithPatches.bind(jt);jt.setAutoFreeze.bind(jt);jt.setUseStrictShallowCopy.bind(jt);jt.applyPatches.bind(jt);var Kd=jt.createDraft.bind(jt),Gd=jt.finishDraft.bind(jt),dO={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=B.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},fO={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=Pe.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},hO={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=$.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Ei=new WeakMap,yi=new WeakMap,zo=new WeakMap,iv=new WeakMap,qd=new WeakMap,Yd=new WeakMap,Jd=new WeakMap,B={ancestors(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=B.levels(e,t);return n?r=r.slice(1):r=r.slice(0,-1),r},common(e,t){for(var n=[],r=0;r<e.length&&r<t.length;r++){var o=e[r],s=t[r];if(o!==s)break;n.push(o)}return n},compare(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return 0},endsAfter(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),s=e[n],i=t[n];return B.equals(r,o)&&s>i},endsAt(e,t){var n=e.length,r=e.slice(0,n),o=t.slice(0,n);return B.equals(r,o)},endsBefore(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),s=e[n],i=t[n];return B.equals(r,o)&&s<i},equals(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])},hasPrevious(e){return e[e.length-1]>0},isAfter(e,t){return B.compare(e,t)===1},isAncestor(e,t){return e.length<t.length&&B.compare(e,t)===0},isBefore(e,t){return B.compare(e,t)===-1},isChild(e,t){return e.length===t.length+1&&B.compare(e,t)===0},isCommon(e,t){return e.length<=t.length&&B.compare(e,t)===0},isDescendant(e,t){return e.length>t.length&&B.compare(e,t)===0},isParent(e,t){return e.length+1===t.length&&B.compare(e,t)===0},isPath(e){return Array.isArray(e)&&(e.length===0||typeof e[0]=="number")},isSibling(e,t){if(e.length!==t.length)return!1;var n=e.slice(0,-1),r=t.slice(0,-1),o=e[e.length-1],s=t[t.length-1];return o!==s&&B.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(!B.isAncestor(t,e)&&!B.equals(e,t))throw new Error("Cannot get the relative path of [".concat(e,"] inside ancestor [").concat(t,"], because it is not above or equal to the path."));return e.slice(t.length)},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e)return null;var r=[...e],{affinity:o="forward"}=n;if(e.length===0)return r;switch(t.type){case"insert_node":{var{path:s}=t;(B.equals(s,r)||B.endsBefore(s,r)||B.isAncestor(s,r))&&(r[s.length-1]+=1);break}case"remove_node":{var{path:i}=t;if(B.equals(i,r)||B.isAncestor(i,r))return null;B.endsBefore(i,r)&&(r[i.length-1]-=1);break}case"merge_node":{var{path:a,position:u}=t;B.equals(a,r)||B.endsBefore(a,r)?r[a.length-1]-=1:B.isAncestor(a,r)&&(r[a.length-1]-=1,r[a.length]+=u);break}case"split_node":{var{path:c,position:d}=t;if(B.equals(c,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else B.endsBefore(c,r)?r[c.length-1]+=1:B.isAncestor(c,r)&&e[c.length]>=d&&(r[c.length-1]+=1,r[c.length]-=d);break}case"move_node":{var{path:l,newPath:m}=t;if(B.equals(l,m))return r;if(B.isAncestor(l,r)||B.equals(l,r)){var g=m.slice();return B.endsBefore(l,m)&&l.length<m.length&&(g[l.length-1]-=1),g.concat(r.slice(l.length))}else B.isSibling(l,m)&&(B.isAncestor(m,r)||B.equals(m,r))?B.endsBefore(l,r)?r[l.length-1]-=1:r[l.length-1]+=1:B.endsBefore(m,r)||B.equals(m,r)||B.isAncestor(m,r)?(B.endsBefore(l,r)&&(r[l.length-1]-=1),r[m.length-1]+=1):B.endsBefore(l,r)&&(B.equals(m,r)&&(r[m.length-1]+=1),r[l.length-1]-=1);break}}return r}};function ss(e){"@babel/helpers - typeof";return ss=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},ss(e)}function pO(e,t){if(ss(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ss(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function mO(e){var t=pO(e,"string");return ss(t)==="symbol"?t:String(t)}function Tt(e,t,n){return t=mO(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zd(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 Fo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Zd(Object(n),!0).forEach(function(r){Tt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zd(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var gO=(e,t,n)=>{switch(n.type){case"insert_node":{var{path:r,node:o}=n,s=se.parent(e,r),i=r[r.length-1];if(i>s.children.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(r,"] because the destination is past the end of the node."));if(s.children.splice(i,0,o),t)for(var[a,u]of $.points(t))t[u]=Pe.transform(a,n);break}case"insert_text":{var{path:c,offset:d,text:l}=n;if(l.length===0)break;var m=se.leaf(e,c),g=m.text.slice(0,d),v=m.text.slice(d);if(m.text=g+l+v,t)for(var[C,p]of $.points(t))t[p]=Pe.transform(C,n);break}case"merge_node":{var{path:D}=n,w=se.get(e,D),b=B.previous(D),y=se.get(e,b),A=se.parent(e,D),T=D[D.length-1];if(pe.isText(w)&&pe.isText(y))y.text+=w.text;else if(!pe.isText(w)&&!pe.isText(y))y.children.push(...w.children);else throw new Error('Cannot apply a "merge_node" operation at path ['.concat(D,"] to nodes of different interfaces: ").concat(ct.stringify(w)," ").concat(ct.stringify(y)));if(A.children.splice(T,1),t)for(var[S,P]of $.points(t))t[P]=Pe.transform(S,n);break}case"move_node":{var{path:L,newPath:F}=n;if(B.isAncestor(L,F))throw new Error("Cannot move a path [".concat(L,"] to new path [").concat(F,"] because the destination is inside itself."));var M=se.get(e,L),N=se.parent(e,L),_=L[L.length-1];N.children.splice(_,1);var I=B.transform(L,n),j=se.get(e,B.parent(I)),z=I[I.length-1];if(j.children.splice(z,0,M),t)for(var[Y,oe]of $.points(t))t[oe]=Pe.transform(Y,n);break}case"remove_node":{var{path:G}=n,Z=G[G.length-1],le=se.parent(e,G);if(le.children.splice(Z,1),t)for(var[de,ue]of $.points(t)){var ee=Pe.transform(de,n);if(t!=null&&ee!=null)t[ue]=ee;else{var te=void 0,R=void 0;for(var[q,J]of se.texts(e))if(B.compare(J,G)===-1)te=[q,J];else{R=[q,J];break}var X=!1;te&&R&&(B.equals(R[1],G)?X=!B.hasPrevious(R[1]):X=B.common(te[1],G).length<B.common(R[1],G).length),te&&!X?(de.path=te[1],de.offset=te[0].text.length):R?(de.path=R[1],de.offset=0):t=null}}break}case"remove_text":{var{path:ie,offset:ae,text:we}=n;if(we.length===0)break;var Se=se.leaf(e,ie),me=Se.text.slice(0,ae),fe=Se.text.slice(ae+we.length);if(Se.text=me+fe,t)for(var[ye,be]of $.points(t))t[be]=Pe.transform(ye,n);break}case"set_node":{var{path:xe,properties:ke,newProperties:Me}=n;if(xe.length===0)throw new Error("Cannot set properties on the root node!");var O=se.get(e,xe);for(var k in Me){if(k==="children"||k==="text")throw new Error('Cannot set the "'.concat(k,'" property of nodes!'));var ne=Me[k];ne==null?delete O[k]:O[k]=ne}for(var re in ke)Me.hasOwnProperty(re)||delete O[re];break}case"set_selection":{var{newProperties:he}=n;if(he==null)t=he;else{if(t==null){if(!$.isRange(he))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat(ct.stringify(he)," when there is no current selection."));t=Fo({},he)}for(var Ie in he){var Fe=he[Ie];if(Fe==null){if(Ie==="anchor"||Ie==="focus")throw new Error('Cannot remove the "'.concat(Ie,'" selection property'));delete t[Ie]}else t[Ie]=Fe}}break}case"split_node":{var{path:Xe,position:ht,properties:Gt}=n;if(Xe.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(Xe,"] because the root node cannot be split."));var He=se.get(e,Xe),pt=se.parent(e,Xe),mt=Xe[Xe.length-1],Ve;if(pe.isText(He)){var Mt=He.text.slice(0,ht),gt=He.text.slice(ht);He.text=Mt,Ve=Fo(Fo({},Gt),{},{text:gt})}else{var qt=He.children.slice(0,ht),vt=He.children.slice(ht);He.children=qt,Ve=Fo(Fo({},Gt),{},{children:vt})}if(pt.children.splice(mt+1,0,Ve),t)for(var[rn,on]of $.points(t))t[on]=Pe.transform(rn,n);break}}return t},vO={transform(e,t){e.children=Kd(e.children);var n=e.selection&&Kd(e.selection);try{n=gO(e,n,t)}finally{e.children=Gd(e.children),n?e.selection=Or(n)?Gd(n):n:e.selection=null}}},CO={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)}},EO={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)}},av=(e,t)=>{for(var n in e){var r=e[n],o=t[n];if(ut(r)&&ut(o)){if(!av(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var s=0;s<r.length;s++)if(r[s]!==o[s])return!1}else if(r!==o)return!1}for(var i in t)if(e[i]===void 0&&t[i]!==void 0)return!1;return!0};function yO(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function In(e,t){if(e==null)return{};var n=yO(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var bO=["anchor","focus"];function Xd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function wO(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Xd(Object(n),!0).forEach(function(r){Tt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xd(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var $={edges(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,{anchor:r,focus:o}=e;return $.isBackward(e)===n?[r,o]:[o,r]},end(e){var[,t]=$.edges(e);return t},equals(e,t){return Pe.equals(e.anchor,t.anchor)&&Pe.equals(e.focus,t.focus)},surrounds(e,t){var n=$.intersection(e,t);return n?$.equals(n,t):!1},includes(e,t){if($.isRange(t)){if($.includes(e,t.anchor)||$.includes(e,t.focus))return!0;var[n,r]=$.edges(e),[o,s]=$.edges(t);return Pe.isBefore(n,o)&&Pe.isAfter(r,s)}var[i,a]=$.edges(e),u=!1,c=!1;return Pe.isPoint(t)?(u=Pe.compare(t,i)>=0,c=Pe.compare(t,a)<=0):(u=B.compare(t,i.path)>=0,c=B.compare(t,a.path)<=0),u&&c},intersection(e,t){var n=In(e,bO),[r,o]=$.edges(e),[s,i]=$.edges(t),a=Pe.isBefore(r,s)?s:r,u=Pe.isBefore(o,i)?o:i;return Pe.isBefore(u,a)?null:wO({anchor:a,focus:u},n)},isBackward(e){var{anchor:t,focus:n}=e;return Pe.isAfter(t,n)},isCollapsed(e){var{anchor:t,focus:n}=e;return Pe.equals(t,n)},isExpanded(e){return!$.isCollapsed(e)},isForward(e){return!$.isBackward(e)},isRange(e){return ut(e)&&Pe.isPoint(e.anchor)&&Pe.isPoint(e.focus)},*points(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]},start(e){var[t]=$.edges(e);return t},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Zc(e,r=>{if(r===null)return null;var{affinity:o="inward"}=n,s,i;if(o==="inward"){var a=$.isCollapsed(r);$.isForward(r)?(s="forward",i=a?s:"backward"):(s="backward",i=a?s:"forward")}else o==="outward"?$.isForward(r)?(s="backward",i="forward"):(s="forward",i="backward"):(s=o,i=o);var u=Pe.transform(r.anchor,t,{affinity:s}),c=Pe.transform(r.focus,t,{affinity:i});if(!u||!c)return null;r.anchor=u,r.focus=c})}},Qd=e=>ut(e)&&se.isNodeList(e.children)&&!E.isEditor(e),ce={isAncestor(e){return ut(e)&&se.isNodeList(e.children)},isElement:Qd,isElementList(e){return Array.isArray(e)&&e.every(t=>ce.isElement(t))},isElementProps(e){return e.children!==void 0},isElementType:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"type";return Qd(t)&&t[r]===n},matches(e,t){for(var n in t)if(n!=="children"&&e[n]!==t[n])return!1;return!0}},DO=["children"],AO=["text"],ef=new WeakMap,se={ancestor(e,t){var n=se.get(e,t);if(pe.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(t,"] because it refers to a text node instead: ").concat(ct.stringify(n)));return n},ancestors(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of B.ancestors(t,n)){var o=se.ancestor(e,r),s=[o,r];yield s}})()},child(e,t){if(pe.isText(e))throw new Error("Cannot get the child of a text node: ".concat(ct.stringify(e)));var n=e.children[t];if(n==null)throw new Error("Cannot get child at index `".concat(t,"` in node: ").concat(ct.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=se.ancestor(e,t),{children:s}=o,i=r?s.length-1:0;r?i>=0:i<s.length;){var a=se.child(o,i),u=t.concat(i);yield[a,u],i=r?i-1:i+1}})()},common(e,t,n){var r=B.common(t,n),o=se.get(e,r);return[o,r]},descendant(e,t){var n=se.get(e,t);if(E.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(t,"] because it refers to the root editor node instead: ").concat(ct.stringify(n)));return n},descendants(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of se.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 se.nodes(e,t))ce.isElement(n)&&(yield[n,r])})()},extractProps(e){if(ce.isAncestor(e)){var t=In(e,DO);return t}else{var t=In(e,AO);return t}},first(e,t){for(var n=t.slice(),r=se.get(e,n);r&&!(pe.isText(r)||r.children.length===0);)r=r.children[0],n.push(0);return[r,n]},fragment(e,t){if(pe.isText(e))throw new Error("Cannot get a fragment starting from a root text node: ".concat(ct.stringify(e)));var n=Zc({children:e.children},r=>{var[o,s]=$.edges(t),i=se.nodes(r,{reverse:!0,pass:m=>{var[,g]=m;return!$.includes(t,g)}});for(var[,a]of i){if(!$.includes(t,a)){var u=se.parent(r,a),c=a[a.length-1];u.children.splice(c,1)}if(B.equals(a,s.path)){var d=se.leaf(r,a);d.text=d.text.slice(0,s.offset)}if(B.equals(a,o.path)){var l=se.leaf(r,a);l.text=l.text.slice(o.offset)}}E.isEditor(r)&&(r.selection=null)});return n.children},get(e,t){var n=se.getIf(e,t);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(t,"] in node: ").concat(ct.stringify(e)));return n},getIf(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(pe.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(pe.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode(e){return pe.isText(e)||ce.isElement(e)||E.isEditor(e)},isNodeList(e){if(!Array.isArray(e))return!1;var t=ef.get(e);if(t!==void 0)return t;var n=e.every(r=>se.isNode(r));return ef.set(e,n),n},last(e,t){for(var n=t.slice(),r=se.get(e,n);r&&!(pe.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=se.get(e,t);if(!pe.isText(n))throw new Error("Cannot get the leaf node at path [".concat(t,"] because it refers to a non-leaf node: ").concat(ct.stringify(n)));return n},levels(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of B.levels(t,n)){var o=se.get(e,r);yield[o,r]}})()},matches(e,t){return ce.isElement(e)&&ce.isElementProps(t)&&ce.matches(e,t)||pe.isText(e)&&pe.isTextProps(t)&&pe.matches(e,t)},nodes(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var{pass:n,reverse:r=!1}=t,{from:o=[],to:s}=t,i=new Set,a=[],u=e;!(s&&(r?B.isBefore(a,s):B.isAfter(a,s)));){if(i.has(u)||(yield[u,a]),!i.has(u)&&!pe.isText(u)&&u.children.length!==0&&(n==null||n([u,a])===!1)){i.add(u);var c=r?u.children.length-1:0;B.isAncestor(a,o)&&(c=o[a.length]),a=a.concat(c),u=se.get(e,a);continue}if(a.length===0)break;if(!r){var d=B.next(a);if(se.has(e,d)){a=d,u=se.get(e,a);continue}}if(r&&a[a.length-1]!==0){var l=B.previous(a);a=l,u=se.get(e,a);continue}a=B.parent(a),u=se.get(e,a),i.add(u)}})()},parent(e,t){var n=B.parent(t),r=se.get(e,n);if(pe.isText(r))throw new Error("Cannot get the parent of path [".concat(t,"] because it does not exist in the root."));return r},string(e){return pe.isText(e)?e.text:e.children.map(se.string).join("")},texts(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of se.nodes(e,t))pe.isText(n)&&(yield[n,r])})()}};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 Ke(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){Tt(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}var Gn={isNodeOperation(e){return Gn.isOperation(e)&&e.type.endsWith("_node")},isOperation(e){if(!ut(e))return!1;switch(e.type){case"insert_node":return B.isPath(e.path)&&se.isNode(e.node);case"insert_text":return typeof e.offset=="number"&&typeof e.text=="string"&&B.isPath(e.path);case"merge_node":return typeof e.position=="number"&&B.isPath(e.path)&&ut(e.properties);case"move_node":return B.isPath(e.path)&&B.isPath(e.newPath);case"remove_node":return B.isPath(e.path)&&se.isNode(e.node);case"remove_text":return typeof e.offset=="number"&&typeof e.text=="string"&&B.isPath(e.path);case"set_node":return B.isPath(e.path)&&ut(e.properties)&&ut(e.newProperties);case"set_selection":return e.properties===null&&$.isRange(e.newProperties)||e.newProperties===null&&$.isRange(e.properties)||ut(e.properties)&&ut(e.newProperties);case"split_node":return B.isPath(e.path)&&typeof e.position=="number"&&ut(e.properties);default:return!1}},isOperationList(e){return Array.isArray(e)&&e.every(t=>Gn.isOperation(t))},isSelectionOperation(e){return Gn.isOperation(e)&&e.type.endsWith("_selection")},isTextOperation(e){return Gn.isOperation(e)&&e.type.endsWith("_text")},inverse(e){switch(e.type){case"insert_node":return Ke(Ke({},e),{},{type:"remove_node"});case"insert_text":return Ke(Ke({},e),{},{type:"remove_text"});case"merge_node":return Ke(Ke({},e),{},{type:"split_node",path:B.previous(e.path)});case"move_node":{var{newPath:t,path:n}=e;if(B.equals(t,n))return e;if(B.isSibling(n,t))return Ke(Ke({},e),{},{path:t,newPath:n});var r=B.transform(n,e),o=B.transform(B.next(n),e);return Ke(Ke({},e),{},{path:r,newPath:o})}case"remove_node":return Ke(Ke({},e),{},{type:"insert_node"});case"remove_text":return Ke(Ke({},e),{},{type:"insert_text"});case"set_node":{var{properties:s,newProperties:i}=e;return Ke(Ke({},e),{},{properties:i,newProperties:s})}case"set_selection":{var{properties:a,newProperties:u}=e;return a==null?Ke(Ke({},e),{},{properties:u,newProperties:null}):u==null?Ke(Ke({},e),{},{properties:null,newProperties:a}):Ke(Ke({},e),{},{properties:u,newProperties:a})}case"split_node":return Ke(Ke({},e),{},{type:"merge_node",path:B.next(e.path)})}}},nf=new WeakMap,SO=e=>{var t=nf.get(e);if(t!==void 0)return t;if(!ut(e))return!1;var n=typeof e.addMark=="function"&&typeof e.apply=="function"&&typeof e.deleteFragment=="function"&&typeof e.insertBreak=="function"&&typeof e.insertSoftBreak=="function"&&typeof e.insertFragment=="function"&&typeof e.insertNode=="function"&&typeof e.insertText=="function"&&typeof e.isElementReadOnly=="function"&&typeof e.isInline=="function"&&typeof e.isSelectable=="function"&&typeof e.isVoid=="function"&&typeof e.normalizeNode=="function"&&typeof e.onChange=="function"&&typeof e.removeMark=="function"&&typeof e.getDirtyPaths=="function"&&(e.marks===null||ut(e.marks))&&(e.selection===null||$.isRange(e.selection))&&se.isNodeList(e.children)&&Gn.isOperationList(e.operations);return nf.set(e,n),n},E={above(e,t){return e.above(t)},addMark(e,t,n){e.addMark(t,n)},after(e,t,n){return e.after(t,n)},before(e,t,n){return e.before(t,n)},deleteBackward(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=t;e.deleteBackward(n)},deleteForward(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=t;e.deleteForward(n)},deleteFragment(e,t){e.deleteFragment(t)},edges(e,t){return e.edges(t)},elementReadOnly(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.elementReadOnly(t)},end(e,t){return e.end(t)},first(e,t){return e.first(t)},fragment(e,t){return e.fragment(t)},hasBlocks(e,t){return e.hasBlocks(t)},hasInlines(e,t){return e.hasInlines(t)},hasPath(e,t){return e.hasPath(t)},hasTexts(e,t){return e.hasTexts(t)},insertBreak(e){e.insertBreak()},insertFragment(e,t,n){e.insertFragment(t,n)},insertNode(e,t){e.insertNode(t)},insertSoftBreak(e){e.insertSoftBreak()},insertText(e,t){e.insertText(t)},isBlock(e,t){return e.isBlock(t)},isEdge(e,t,n){return e.isEdge(t,n)},isEditor(e){return SO(e)},isElementReadOnly(e,t){return e.isElementReadOnly(t)},isEmpty(e,t){return e.isEmpty(t)},isEnd(e,t,n){return e.isEnd(t,n)},isInline(e,t){return e.isInline(t)},isNormalizing(e){return e.isNormalizing()},isSelectable(e,t){return e.isSelectable(t)},isStart(e,t,n){return e.isStart(t,n)},isVoid(e,t){return e.isVoid(t)},last(e,t){return e.last(t)},leaf(e,t,n){return e.leaf(t,n)},levels(e,t){return e.levels(t)},marks(e){return e.getMarks()},next(e,t){return e.next(t)},node(e,t,n){return e.node(t,n)},nodes(e,t){return e.nodes(t)},normalize(e,t){e.normalize(t)},parent(e,t,n){return e.parent(t,n)},path(e,t,n){return e.path(t,n)},pathRef(e,t,n){return e.pathRef(t,n)},pathRefs(e){return e.pathRefs()},point(e,t,n){return e.point(t,n)},pointRef(e,t,n){return e.pointRef(t,n)},pointRefs(e){return e.pointRefs()},positions(e,t){return e.positions(t)},previous(e,t){return e.previous(t)},range(e,t,n){return e.range(t,n)},rangeRef(e,t,n){return e.rangeRef(t,n)},rangeRefs(e){return e.rangeRefs()},removeMark(e,t){e.removeMark(t)},setNormalizing(e,t){e.setNormalizing(t)},start(e,t){return e.start(t)},string(e,t,n){return e.string(t,n)},unhangRange(e,t,n){return e.unhangRange(t,n)},void(e,t){return e.void(t)},withoutNormalizing(e,t){e.withoutNormalizing(t)},shouldMergeNodesRemovePrevNode:(e,t,n)=>e.shouldMergeNodesRemovePrevNode(t,n)},xO={isSpan(e){return Array.isArray(e)&&e.length===2&&e.every(B.isPath)}};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 of(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){Tt(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 Pe={compare(e,t){var n=B.compare(e.path,t.path);return n===0?e.offset<t.offset?-1:e.offset>t.offset?1:0:n},isAfter(e,t){return Pe.compare(e,t)===1},isBefore(e,t){return Pe.compare(e,t)===-1},equals(e,t){return e.offset===t.offset&&B.equals(e.path,t.path)},isPoint(e){return ut(e)&&typeof e.offset=="number"&&B.isPath(e.path)},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Zc(e,r=>{if(r===null)return null;var{affinity:o="forward"}=n,{path:s,offset:i}=r;switch(t.type){case"insert_node":case"move_node":{r.path=B.transform(s,t,n);break}case"insert_text":{B.equals(t.path,s)&&(t.offset<i||t.offset===i&&o==="forward")&&(r.offset+=t.text.length);break}case"merge_node":{B.equals(t.path,s)&&(r.offset+=t.position),r.path=B.transform(s,t,n);break}case"remove_text":{B.equals(t.path,s)&&t.offset<=i&&(r.offset-=Math.min(i-t.offset,t.text.length));break}case"remove_node":{if(B.equals(t.path,s)||B.isAncestor(t.path,s))return null;r.path=B.transform(s,t,n);break}case"split_node":{if(B.equals(t.path,s)){if(t.position===i&&o==null)return null;(t.position<i||t.position===i&&o==="forward")&&(r.offset-=t.position,r.path=B.transform(s,t,of(of({},n),{},{affinity:"forward"})))}else r.path=B.transform(s,t,n);break}}})}},sf=void 0,ct={setScrubber(e){sf=e},stringify(e){return JSON.stringify(e,sf)}},OO=["text"],TO=["anchor","focus"];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 bn(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){Tt(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}var pe={equals(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(s){var i=In(s,OO);return i}return av(r?o(e):e,r?o(t):t)},isText(e){return ut(e)&&typeof e.text=="string"},isTextList(e){return Array.isArray(e)&&e.every(t=>pe.isText(t))},isTextProps(e){return e.text!==void 0},matches(e,t){for(var n in t)if(n!=="text"&&(!e.hasOwnProperty(n)||e[n]!==t[n]))return!1;return!0},decorations(e,t){var n=[bn({},e)];for(var r of t){var o=In(r,TO),[s,i]=$.edges(r),a=[],u=0,c=s.offset,d=i.offset;for(var l of n){var{length:m}=l.text,g=u;if(u+=m,c<=g&&u<=d){Object.assign(l,o),a.push(l);continue}if(c!==d&&(c===u||d===g)||c>u||d<g||d===g&&g!==0){a.push(l);continue}var v=l,C=void 0,p=void 0;if(d<u){var D=d-g;p=bn(bn({},v),{},{text:v.text.slice(D)}),v=bn(bn({},v),{},{text:v.text.slice(0,D)})}if(c>g){var w=c-g;C=bn(bn({},v),{},{text:v.text.slice(0,w)}),v=bn(bn({},v),{},{text:v.text.slice(w)})}Object.assign(v,o),C&&a.push(C),a.push(v),p&&a.push(p)}n=a}return n}},Xc=e=>e.selection?e.selection:e.children.length>0?E.end(e,[]):[0],Oo=(e,t)=>{var[n]=E.node(e,t);return r=>r===n},Qc=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=!n,o=n?MO(t):t,s=Te.None,i=Te.None,a=0,u=null,c=null;for(var d of o){var l=d.codePointAt(0);if(!l)break;var m=KO(d,l);if([s,i]=r?[i,m]:[m,s],Zr(s,Te.ZWJ)&&Zr(i,Te.ExtPict)&&(r?u=uf(t.substring(0,a)):u=uf(t.substring(0,t.length-a)),!u)||Zr(s,Te.RI)&&Zr(i,Te.RI)&&(c!==null?c=!c:r?c=!0:c=ZO(t.substring(0,t.length-a)),!c)||s!==Te.None&&i!==Te.None&&qO(s,i))break;a+=d.length}return a||1},RO=/\s/,IO=/[\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]/,BO=/['\u2018\u2019]/,FO=function(t){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=0,o=!1;t.length>0;){var s=Qc(t,n),[i,a]=el(t,s,n);if(PO(i,a,n))o=!0,r+=s;else if(!o)r+=s;else break;t=a}return r},el=(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)]},PO=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(RO.test(t))return!1;if(BO.test(t)){var o=Qc(n,r),[s,i]=el(n,o,r);if(e(s,i,r))return!0}return!IO.test(t)},MO=function*(t){for(var n=t.length-1,r=0;r<t.length;r++){var o=t.charAt(n-r);if(kO(o.charCodeAt(0))){var s=t.charAt(n-r-1);if(_O(s.charCodeAt(0))){yield s+o,r++;continue}}yield o}},_O=e=>e>=55296&&e<=56319,kO=e=>e>=56320&&e<=57343,Te;(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"})(Te||(Te={}));var NO=/^(?:[\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])$/,jO=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,LO=/^(?:[\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])$/,UO=/^[\u1100-\u115F\uA960-\uA97C]$/,$O=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,HO=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,VO=/^[\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]$/,WO=/^[\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]$/,zO=/^(?:[\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])$/,KO=(e,t)=>{var n=Te.Any;return e.search(NO)!==-1&&(n|=Te.Extend),t===8205&&(n|=Te.ZWJ),t>=127462&&t<=127487&&(n|=Te.RI),e.search(jO)!==-1&&(n|=Te.Prepend),e.search(LO)!==-1&&(n|=Te.SpacingMark),e.search(UO)!==-1&&(n|=Te.L),e.search($O)!==-1&&(n|=Te.V),e.search(HO)!==-1&&(n|=Te.T),e.search(VO)!==-1&&(n|=Te.LV),e.search(WO)!==-1&&(n|=Te.LVT),e.search(zO)!==-1&&(n|=Te.ExtPict),n};function Zr(e,t){return(e&t)!==0}var GO=[[Te.L,Te.L|Te.V|Te.LV|Te.LVT],[Te.LV|Te.V,Te.V|Te.T],[Te.LVT|Te.T,Te.T],[Te.Any,Te.Extend|Te.ZWJ],[Te.Any,Te.SpacingMark],[Te.Prepend,Te.Any],[Te.ZWJ,Te.ExtPict],[Te.RI,Te.RI]];function qO(e,t){return GO.findIndex(n=>Zr(e,n[0])&&Zr(t,n[1]))===-1}var YO=/(?:[\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$/,uf=e=>e.search(YO)!==-1,JO=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,ZO=e=>{var t=e.match(JO);if(t===null)return!1;var n=t[0].length/2;return n%2===1},XO={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]:{};E.withoutNormalizing(e,()=>{var{voids:r=!1}=n,{at:o=Xc(e)}=n;if(B.isPath(o)&&(o=E.range(e,o)),$.isRange(o))if($.isCollapsed(o))o=o.anchor;else{var s=$.end(o);if(!r&&E.void(e,{at:s}))return;var i=$.start(o),a=E.pointRef(e,i),u=E.pointRef(e,s);W.delete(e,{at:o,voids:r});var c=a.unref(),d=u.unref();o=c||d,W.setSelection(e,{anchor:o,focus:o})}if(!(!r&&E.void(e,{at:o})||E.elementReadOnly(e,{at:o}))){var{path:l,offset:m}=o;t.length>0&&e.apply({type:"insert_text",path:l,offset:m,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 Hs(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){Tt(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 W=Hs(Hs(Hs(Hs({},vO),CO),EO),XO),Qs=new WeakMap,QO=e=>Qs.get(e)||!1,eT=(e,t,n)=>{var r=Qs.get(e)||!1;Qs.set(e,!0);try{t(),n()}finally{Qs.set(e,r)}};function uv(e,t,n){var r=Ei.get(e)||[],o=yi.get(e)||new Set,s,i,a=l=>{if(l){var m=l.join(",");i.has(m)||(i.add(m),s.push(l))}};if(n){s=[],i=new Set;for(var u of r){var c=n(u);a(c)}}else s=r,i=o;for(var d of t)a(d);Ei.set(e,s),yi.set(e,i)}var tT=(e,t)=>{for(var n of E.pathRefs(e))dO.transform(n,t);for(var r of E.pointRefs(e))fO.transform(r,t);for(var o of E.rangeRefs(e))hO.transform(o,t);if(!QO(e)){var s=B.operationCanTransformPath(t)?i=>B.transform(i,t):void 0;uv(e,e.getDirtyPaths(t),s)}W.transform(e,t),e.operations.push(t),E.normalize(e,{operation:t}),t.type==="set_selection"&&(e.marks=null),zo.get(e)||(zo.set(e,!0),Promise.resolve().then(()=>{zo.set(e,!1),e.onChange({operation:t}),e.operations=[]}))},nT=(e,t)=>{switch(t.type){case"insert_text":case"remove_text":case"set_node":{var{path:n}=t;return B.levels(n)}case"insert_node":{var{node:r,path:o}=t,s=B.levels(o),i=pe.isText(r)?[]:Array.from(se.nodes(r),F=>{var[,M]=F;return o.concat(M)});return[...s,...i]}case"merge_node":{var{path:a}=t,u=B.ancestors(a),c=B.previous(a);return[...u,c]}case"move_node":{var{path:d,newPath:l}=t;if(B.equals(d,l))return[];var m=[],g=[];for(var v of B.ancestors(d)){var C=B.transform(v,t);m.push(C)}for(var p of B.ancestors(l)){var D=B.transform(p,t);g.push(D)}var w=g[g.length-1],b=l[l.length-1],y=w.concat(b);return[...m,...g,y]}case"remove_node":{var{path:A}=t,T=B.ancestors(A);return[...T]}case"split_node":{var{path:S}=t,P=B.levels(S),L=B.next(S);return[...P,L]}default:return[]}},rT=e=>{var{selection:t}=e;return t?se.fragment(e,t):[]},oT=(e,t)=>{var[n,r]=t;if(!pe.isText(n)){if(ce.isElement(n)&&n.children.length===0){var o={text:""};W.insertNodes(e,o,{at:r.concat(0),voids:!0});return}for(var s=E.isEditor(n)?!1:ce.isElement(n)&&(e.isInline(n)||n.children.length===0||pe.isText(n.children[0])||e.isInline(n.children[0])),i=0,a=0;a<n.children.length;a++,i++){var u=se.get(e,r);if(!pe.isText(u)){var c=u.children[i],d=u.children[i-1],l=a===n.children.length-1,m=pe.isText(c)||ce.isElement(c)&&e.isInline(c);if(m!==s)W.removeNodes(e,{at:r.concat(i),voids:!0}),i--;else if(ce.isElement(c)){if(e.isInline(c)){if(d==null||!pe.isText(d)){var g={text:""};W.insertNodes(e,g,{at:r.concat(i),voids:!0}),i++}else if(l){var v={text:""};W.insertNodes(e,v,{at:r.concat(i+1),voids:!0}),i++}}}else{if(!pe.isText(c)&&!("children"in c)){var C=c;C.children=[]}d!=null&&pe.isText(d)&&(pe.equals(c,d,{loose:!0})?(W.mergeNodes(e,{at:r.concat(i),voids:!0}),i--):d.text===""?(W.removeNodes(e,{at:r.concat(i-1),voids:!0}),i--):c.text===""&&(W.removeNodes(e,{at:r.concat(i),voids:!0}),i--))}}}}},sT=(e,t)=>{var{iteration:n,initialDirtyPathsLength:r}=t,o=r*42;if(n>o)throw new Error("Could not completely normalize the editor after ".concat(o," iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));return!0},iT=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{voids:r=!1,mode:o="lowest",at:s=t.selection,match:i}=n;if(s){var a=E.path(t,s),u=o==="lowest";for(var[c,d]of E.levels(t,{at:a,voids:r,match:i,reverse:u}))if(!pe.isText(c)){if($.isRange(s)){if(B.isAncestor(d,s.anchor.path)&&B.isAncestor(d,s.focus.path))return[c,d]}else if(!B.equals(a,d))return[c,d]}}};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 df(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){Tt(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 aT=(e,t,n)=>{var{selection:r}=e;if(r){var o=(l,m)=>{if(!pe.isText(l))return!1;var[g,v]=E.parent(e,m);return!e.isVoid(g)||e.markableVoid(g)},s=$.isExpanded(r),i=!1;if(!s){var[a,u]=E.node(e,r);if(a&&o(a,u)){var[c]=E.parent(e,u);i=c&&e.markableVoid(c)}}if(s||i)W.setNodes(e,{[t]:n},{match:o,split:!0,voids:!0});else{var d=df(df({},E.marks(e)||{}),{},{[t]:n});e.marks=d,zo.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 hf(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){Tt(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 uT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=E.point(t,n,{edge:"end"}),s=E.end(t,[]),i={anchor:o,focus:s},{distance:a=1}=r,u=0,c;for(var d of E.positions(t,hf(hf({},r),{},{at:i}))){if(u>a)break;u!==0&&(c=d),u++}return c};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 mf(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){Tt(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 cT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=E.start(t,[]),s=E.point(t,n,{edge:"start"}),i={anchor:o,focus:s},{distance:a=1}=r,u=0,c;for(var d of E.positions(t,mf(mf({},r),{},{at:i,reverse:!0}))){if(u>a)break;u!==0&&(c=d),u++}return c},lT=(e,t)=>{var{selection:n}=e;n&&$.isCollapsed(n)&&W.delete(e,{unit:t,reverse:!0})},dT=(e,t)=>{var{selection:n}=e;n&&$.isCollapsed(n)&&W.delete(e,{unit:t})},fT=function(t){var{direction:n="forward"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=t;r&&$.isExpanded(r)&&W.delete(t,{reverse:n==="backward"})},hT=(e,t)=>[E.start(e,t),E.end(e,t)];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){Tt(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 pT=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return E.above(t,vf(vf({},n),{},{match:r=>ce.isElement(r)&&E.isElementReadOnly(t,r)}))},mT=(e,t)=>E.point(e,t,{edge:"end"}),gT=(e,t)=>{var n=E.path(e,t,{edge:"start"});return E.node(e,n)},vT=(e,t)=>{var n=E.range(e,t);return se.fragment(e,n)};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 Ef(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){Tt(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 CT=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return E.above(t,Ef(Ef({},n),{},{match:r=>ce.isElement(r)&&E.isVoid(t,r)}))},ET=(e,t)=>t.children.some(n=>ce.isElement(n)&&E.isBlock(e,n)),yT=(e,t)=>t.children.some(n=>pe.isText(n)||E.isInline(e,n)),bT=(e,t)=>se.has(e,t),wT=(e,t)=>t.children.every(n=>pe.isText(n)),DT=e=>{W.splitNodes(e,{always:!0})},AT=(e,t,n)=>{W.insertNodes(e,t,n)},ST=e=>{W.splitNodes(e,{always:!0})};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 xT(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){Tt(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 cv=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o,marks:s}=t;if(o){if(s){var i=xT({text:n},s);W.insertNodes(t,i,{at:r.at,voids:r.voids})}else W.insertText(t,n,r);t.marks=null}},OT=(e,t)=>!e.isInline(t),TT=(e,t,n)=>E.isStart(e,t,n)||E.isEnd(e,t,n),RT=(e,t)=>{var{children:n}=t,[r]=n;return n.length===0||n.length===1&&pe.isText(r)&&r.text===""&&!e.isVoid(t)},IT=(e,t,n)=>{var r=E.end(e,n);return Pe.equals(t,r)},BT=e=>{var t=iv.get(e);return t===void 0?!0:t},FT=(e,t,n)=>{if(t.offset!==0)return!1;var r=E.start(e,n);return Pe.equals(t,r)},PT=(e,t)=>{var n=E.path(e,t,{edge:"end"});return E.node(e,n)},MT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=E.path(t,n,r),s=se.leaf(t,o);return[s,o]};function _T(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=e.selection,reverse:r=!1,voids:o=!1}=t,{match:s}=t;if(s==null&&(s=()=>!0),!!n){var i=[],a=E.path(e,n);for(var[u,c]of se.levels(e,a))if(s(u,c)&&(i.push([u,c]),!o&&ce.isElement(u)&&E.isVoid(e,u)))break;r&&i.reverse(),yield*i}})()}var kT=["text"],NT=["text"],jT=function(t){var{marks:n,selection:r}=t;if(!r)return null;var{anchor:o,focus:s}=r;if(n)return n;if($.isExpanded(r)){var i=$.isBackward(r);i&&([s,o]=[o,s]);var a=E.isEnd(t,o,o.path);if(a){var u=E.after(t,o);u&&(o=u)}var[c]=E.nodes(t,{match:pe.isText,at:{anchor:o,focus:s}});if(c){var[d]=c,l=In(d,kT);return l}else return{}}var{path:m}=o,[g]=E.leaf(t,m);if(o.offset===0){var v=E.previous(t,{at:m,match:pe.isText}),C=E.above(t,{match:A=>ce.isElement(A)&&E.isVoid(t,A)&&t.markableVoid(A)});if(!C){var p=E.above(t,{match:A=>ce.isElement(A)&&E.isBlock(t,A)});if(v&&p){var[D,w]=v,[,b]=p;B.isAncestor(b,w)&&(g=D)}}}var y=In(g,NT);return y},LT=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:s,at:i=t.selection}=n;if(i){var a=E.after(t,i,{voids:o});if(a){var[,u]=E.last(t,[]),c=[a.path,u];if(B.isPath(i)&&i.length===0)throw new Error("Cannot get the next node from the root node!");if(s==null)if(B.isPath(i)){var[d]=E.parent(t,i);s=m=>d.children.includes(m)}else s=()=>!0;var[l]=E.nodes(t,{at:c,match:s,mode:r,voids:o});return l}}},UT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=E.path(t,n,r),s=se.get(t,o);return[s,o]};function $T(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=e.selection,mode:r="all",universal:o=!1,reverse:s=!1,voids:i=!1,ignoreNonSelectable:a=!1}=t,{match:u}=t;if(u||(u=()=>!0),!!n){var c,d;if(xO.isSpan(n))c=n[0],d=n[1];else{var l=E.path(e,n,{edge:"start"}),m=E.path(e,n,{edge:"end"});c=s?m:l,d=s?l:m}var g=se.nodes(e,{reverse:s,from:c,to:d,pass:y=>{var[A]=y;return ce.isElement(A)?!!(!i&&(E.isVoid(e,A)||E.isElementReadOnly(e,A))||a&&!E.isSelectable(e,A)):!1}}),v=[],C;for(var[p,D]of g)if(!(a&&ce.isElement(p)&&!E.isSelectable(e,p))){var w=C&&B.compare(D,C[1])===0;if(!(r==="highest"&&w)){if(!u(p,D)){if(o&&!w&&pe.isText(p))return;continue}if(r==="lowest"&&w){C=[p,D];continue}var b=r==="lowest"?C:[p,D];b&&(o?v.push(b):yield b),C=[p,D]}}r==="lowest"&&C&&(o?v.push(C):yield C),o&&(yield*v)}})()}var HT=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:r=!1,operation:o}=n,s=d=>Ei.get(d)||[],i=d=>yi.get(d)||new Set,a=d=>{var l=s(d).pop(),m=l.join(",");return i(d).delete(m),l};if(E.isNormalizing(t)){if(r){var u=Array.from(se.nodes(t),d=>{var[,l]=d;return l}),c=new Set(u.map(d=>d.join(",")));Ei.set(t,u),yi.set(t,c)}s(t).length!==0&&E.withoutNormalizing(t,()=>{for(var d of s(t))if(se.has(t,d)){var l=E.node(t,d),[m,g]=l;ce.isElement(m)&&m.children.length===0&&t.normalizeNode(l,{operation:o})}for(var v=s(t),C=v.length,p=0;v.length!==0;){if(!t.shouldNormalize({dirtyPaths:v,iteration:p,initialDirtyPathsLength:C,operation:o}))return;var D=a(t);if(se.has(t,D)){var w=E.node(t,D);t.normalizeNode(w,{operation:o})}p++,v=s(t)}})}},VT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=E.path(t,n,r),s=B.parent(o),i=E.node(t,s);return i},WT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,s={current:n,affinity:o,unref(){var{current:a}=s,u=E.pathRefs(t);return u.delete(s),s.current=null,a}},i=E.pathRefs(t);return i.add(s),s},zT=e=>{var t=qd.get(e);return t||(t=new Set,qd.set(e,t)),t},KT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:o,edge:s}=r;if(B.isPath(n)){if(s==="start"){var[,i]=se.first(t,n);n=i}else if(s==="end"){var[,a]=se.last(t,n);n=a}}return $.isRange(n)&&(s==="start"?n=$.start(n):s==="end"?n=$.end(n):n=B.common(n.anchor.path,n.focus.path)),Pe.isPoint(n)&&(n=n.path),o!=null&&(n=n.slice(0,o)),n},GT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,s={current:n,affinity:o,unref(){var{current:a}=s,u=E.pointRefs(t);return u.delete(s),s.current=null,a}},i=E.pointRefs(t);return i.add(s),s},qT=e=>{var t=Yd.get(e);return t||(t=new Set,Yd.set(e,t)),t},YT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:o="start"}=r;if(B.isPath(n)){var s;if(o==="end"){var[,i]=se.last(t,n);s=i}else{var[,a]=se.first(t,n);s=a}var u=se.get(t,s);if(!pe.isText(u))throw new Error("Cannot get the ".concat(o," point in the node at path [").concat(n,"] because it has no ").concat(o," text node."));return{path:s,offset:o==="end"?u.text.length:0}}if($.isRange(n)){var[c,d]=$.edges(n);return o==="start"?c:d}return n};function JT(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=e.selection,unit:r="offset",reverse:o=!1,voids:s=!1,ignoreNonSelectable:i=!1}=t;if(!n)return;var a=E.range(e,n),[u,c]=$.edges(a),d=o?c:u,l=!1,m="",g=0,v=0,C=0;for(var[p,D]of E.nodes(e,{at:n,reverse:o,voids:s,ignoreNonSelectable:i})){if(ce.isElement(p)){if(!s&&(e.isVoid(p)||e.isElementReadOnly(p))){yield E.start(e,D);continue}if(e.isInline(p))continue;if(E.hasInlines(e,p)){var w=B.isAncestor(D,c.path)?c:E.end(e,D),b=B.isAncestor(D,u.path)?u:E.start(e,D);m=E.string(e,{anchor:b,focus:w},{voids:s}),l=!0}}if(pe.isText(p)){var y=B.equals(D,d.path);for(y?(v=o?d.offset:p.text.length-d.offset,C=d.offset):(v=p.text.length,C=o?v:0),(y||l||r==="offset")&&(yield{path:D,offset:C},l=!1);;){if(g===0){if(m==="")break;g=A(m,r,o),m=el(m,g,o)[1]}if(C=o?C-g:C+g,v=v-g,v<0){g=-v;break}g=0,yield{path:D,offset:C}}}}function A(T,S,P){return S==="character"?Qc(T,P):S==="word"?FO(T,P):S==="line"||S==="block"?T.length:1}})()}var ZT=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:s,at:i=t.selection}=n;if(i){var a=E.before(t,i,{voids:o});if(a){var[,u]=E.first(t,[]),c=[a.path,u];if(B.isPath(i)&&i.length===0)throw new Error("Cannot get the previous node from the root node!");if(s==null)if(B.isPath(i)){var[d]=E.parent(t,i);s=m=>d.children.includes(m)}else s=()=>!0;var[l]=E.nodes(t,{reverse:!0,at:c,match:s,mode:r,voids:o});return l}}},XT=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,s={current:n,affinity:o,unref(){var{current:a}=s,u=E.rangeRefs(t);return u.delete(s),s.current=null,a}},i=E.rangeRefs(t);return i.add(s),s},QT=e=>{var t=Jd.get(e);return t||(t=new Set,Jd.set(e,t)),t},eR=(e,t,n)=>{if($.isRange(t)&&!n)return t;var r=E.start(e,t),o=E.end(e,n||t);return{anchor:r,focus:o}};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 tR(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){Tt(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 nR=(e,t)=>{var{selection:n}=e;if(n){var r=(d,l)=>{if(!pe.isText(d))return!1;var[m,g]=E.parent(e,l);return!e.isVoid(m)||e.markableVoid(m)},o=$.isExpanded(n),s=!1;if(!o){var[i,a]=E.node(e,n);if(i&&r(i,a)){var[u]=E.parent(e,a);s=u&&e.markableVoid(u)}}if(o||s)W.unsetNodes(e,t,{match:r,split:!0,voids:!0});else{var c=tR({},E.marks(e)||{});delete c[t],e.marks=c,zo.get(e)||e.onChange()}}},rR=(e,t)=>{iv.set(e,t)},oR=(e,t)=>E.point(e,t,{edge:"start"}),sR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,s=E.range(t,n),[i,a]=$.edges(s),u="";for(var[c,d]of E.nodes(t,{at:s,match:pe.isText,voids:o})){var l=c.text;B.equals(d,a.path)&&(l=l.slice(0,a.offset)),B.equals(d,i.path)&&(l=l.slice(i.offset)),u+=l}return u},iR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,[s,i]=$.edges(n);if(s.offset!==0||i.offset!==0||$.isCollapsed(n)||B.hasPrevious(i.path))return n;var a=E.above(t,{at:i,match:v=>ce.isElement(v)&&E.isBlock(t,v),voids:o}),u=a?a[1]:[],c=E.start(t,s),d={anchor:c,focus:i},l=!0;for(var[m,g]of E.nodes(t,{at:d,match:pe.isText,reverse:!0,voids:o})){if(l){l=!1;continue}if(m.text!==""||B.isBefore(g,u)){i={path:g,offset:m.text.length};break}}return{anchor:s,focus:i}},aR=(e,t)=>{var n=E.isNormalizing(e);E.setNormalizing(e,!1);try{t()}finally{E.setNormalizing(e,n)}E.normalize(e)},uR=(e,t,n)=>{var[r,o]=t;return ce.isElement(r)&&E.isEmpty(e,r)||pe.isText(r)&&r.text===""&&o[o.length-1]!==0},cR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.withoutNormalizing(t,()=>{var r,o,{reverse:s=!1,unit:i="character",distance:a=1,voids:u=!1}=n,{at:c=t.selection,hanging:d=!1}=n;if(c){var l=!1;if($.isRange(c)&&$.isCollapsed(c)&&(l=!0,c=c.anchor),Pe.isPoint(c)){var m=E.void(t,{at:c,mode:"highest"});if(!u&&m){var[,g]=m;c=g}else{var v={unit:i,distance:a},C=s?E.before(t,c,v)||E.start(t,[]):E.after(t,c,v)||E.end(t,[]);c={anchor:c,focus:C},d=!0}}if(B.isPath(c)){W.removeNodes(t,{at:c,voids:u});return}if(!$.isCollapsed(c)){if(!d){var[,p]=$.edges(c),D=E.end(t,[]);Pe.equals(p,D)||(c=E.unhangRange(t,c,{voids:u}))}var[w,b]=$.edges(c),y=E.above(t,{match:me=>ce.isElement(me)&&E.isBlock(t,me),at:w,voids:u}),A=E.above(t,{match:me=>ce.isElement(me)&&E.isBlock(t,me),at:b,voids:u}),T=y&&A&&!B.equals(y[1],A[1]),S=B.equals(w.path,b.path),P=u?null:(r=E.void(t,{at:w,mode:"highest"}))!==null&&r!==void 0?r:E.elementReadOnly(t,{at:w,mode:"highest"}),L=u?null:(o=E.void(t,{at:b,mode:"highest"}))!==null&&o!==void 0?o:E.elementReadOnly(t,{at:b,mode:"highest"});if(P){var F=E.before(t,w);F&&y&&B.isAncestor(y[1],F.path)&&(w=F)}if(L){var M=E.after(t,b);M&&A&&B.isAncestor(A[1],M.path)&&(b=M)}var N=[],_;for(var I of E.nodes(t,{at:c,voids:u})){var[j,z]=I;_&&B.compare(z,_)===0||(!u&&ce.isElement(j)&&(E.isVoid(t,j)||E.isElementReadOnly(t,j))||!B.isCommon(z,w.path)&&!B.isCommon(z,b.path))&&(N.push(I),_=z)}var Y=Array.from(N,me=>{var[,fe]=me;return E.pathRef(t,fe)}),oe=E.pointRef(t,w),G=E.pointRef(t,b),Z="";if(!S&&!P){var le=oe.current,[de]=E.leaf(t,le),{path:ue}=le,{offset:ee}=w,te=de.text.slice(ee);te.length>0&&(t.apply({type:"remove_text",path:ue,offset:ee,text:te}),Z=te)}if(Y.reverse().map(me=>me.unref()).filter(me=>me!==null).forEach(me=>W.removeNodes(t,{at:me,voids:u})),!L){var R=G.current,[q]=E.leaf(t,R),{path:J}=R,X=S?w.offset:0,ie=q.text.slice(X,b.offset);ie.length>0&&(t.apply({type:"remove_text",path:J,offset:X,text:ie}),Z=ie)}!S&&T&&G.current&&oe.current&&W.mergeNodes(t,{at:G.current,hanging:!0,voids:u}),l&&s&&i==="character"&&Z.length>1&&Z.match(/[\u0E00-\u0E7F]+/)&&W.insertText(t,Z.slice(0,Z.length-a));var ae=oe.unref(),we=G.unref(),Se=s?ae||we:we||ae;n.at==null&&Se&&W.select(t,Se)}}})},lR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};E.withoutNormalizing(t,()=>{var{hanging:o=!1,voids:s=!1}=r,{at:i=Xc(t),batchDirty:a=!0}=r;if(n.length){if($.isRange(i))if(o||(i=E.unhangRange(t,i,{voids:s})),$.isCollapsed(i))i=i.anchor;else{var[,u]=$.edges(i);if(!s&&E.void(t,{at:u}))return;var c=E.pointRef(t,u);W.delete(t,{at:i}),i=c.unref()}else B.isPath(i)&&(i=E.start(t,i));if(!(!s&&E.void(t,{at:i}))){var d=E.above(t,{at:i,match:te=>ce.isElement(te)&&E.isInline(t,te),mode:"highest",voids:s});if(d){var[,l]=d;if(E.isEnd(t,i,l)){var m=E.after(t,l);i=m}else if(E.isStart(t,i,l)){var g=E.before(t,l);i=g}}var v=E.above(t,{match:te=>ce.isElement(te)&&E.isBlock(t,te),at:i,voids:s}),[,C]=v,p=E.isStart(t,i,C),D=E.isEnd(t,i,C),w=p&&D,b=!p||p&&D,y=!D,[,A]=se.first({children:n},[]),[,T]=se.last({children:n},[]),S=[],P=te=>{var[R,q]=te,J=q.length===0;return J?!1:w?!0:!(b&&B.isAncestor(q,A)&&ce.isElement(R)&&!t.isVoid(R)&&!t.isInline(R)||y&&B.isAncestor(q,T)&&ce.isElement(R)&&!t.isVoid(R)&&!t.isInline(R))};for(var L of se.nodes({children:n},{pass:P}))P(L)&&S.push(L);var F=[],M=[],N=[],_=!0,I=!1;for(var[j]of S)ce.isElement(j)&&!t.isInline(j)?(_=!1,I=!0,M.push(j)):_?F.push(j):N.push(j);var[z]=E.nodes(t,{at:i,match:te=>pe.isText(te)||E.isInline(t,te),mode:"highest",voids:s}),[,Y]=z,oe=E.isStart(t,i,Y),G=E.isEnd(t,i,Y),Z=E.pathRef(t,D&&!N.length?B.next(C):C),le=E.pathRef(t,G?B.next(Y):Y);W.splitNodes(t,{at:i,match:te=>I?ce.isElement(te)&&E.isBlock(t,te):pe.isText(te)||E.isInline(t,te),mode:I?"lowest":"highest",always:I&&(!p||F.length>0)&&(!D||N.length>0),voids:s});var de=E.pathRef(t,!oe||oe&&G?B.next(Y):Y);if(W.insertNodes(t,F,{at:de.current,match:te=>pe.isText(te)||E.isInline(t,te),mode:"highest",voids:s,batchDirty:a}),w&&!F.length&&M.length&&!N.length&&W.delete(t,{at:C,voids:s}),W.insertNodes(t,M,{at:Z.current,match:te=>ce.isElement(te)&&E.isBlock(t,te),mode:"lowest",voids:s,batchDirty:a}),W.insertNodes(t,N,{at:le.current,match:te=>pe.isText(te)||E.isInline(t,te),mode:"highest",voids:s,batchDirty:a}),!r.at){var ue;if(N.length>0&&le.current?ue=B.previous(le.current):M.length>0&&Z.current?ue=B.previous(Z.current):de.current&&(ue=B.previous(de.current)),ue){var ee=E.end(t,ue);W.select(t,ee)}}de.unref(),Z.unref(),le.unref()}}})},dR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{edge:r="anchor"}=n,{selection:o}=t;if(o){if(r==="anchor")W.select(t,o.anchor);else if(r==="focus")W.select(t,o.focus);else if(r==="start"){var[s]=$.edges(o);W.select(t,s)}else if(r==="end"){var[,i]=$.edges(o);W.select(t,i)}}else return},fR=e=>{var{selection:t}=e;t&&e.apply({type:"set_selection",properties:t,newProperties:null})},hR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=t,{distance:o=1,unit:s="character",reverse:i=!1}=n,{edge:a=null}=n;if(r){a==="start"&&(a=$.isBackward(r)?"focus":"anchor"),a==="end"&&(a=$.isBackward(r)?"anchor":"focus");var{anchor:u,focus:c}=r,d={distance:o,unit:s,ignoreNonSelectable:!0},l={};if(a==null||a==="anchor"){var m=i?E.before(t,u,d):E.after(t,u,d);m&&(l.anchor=m)}if(a==null||a==="focus"){var g=i?E.before(t,c,d):E.after(t,c,d);g&&(l.focus=g)}W.setSelection(t,l)}},pR=(e,t)=>{var{selection:n}=e;if(t=E.range(e,t),n){W.setSelection(e,t);return}if(!$.isRange(t))throw new Error("When setting the selection and the current selection is `null` you must provide at least an `anchor` and `focus`, but you passed: ".concat(ct.stringify(t)));e.apply({type:"set_selection",properties:n,newProperties:t})};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 Df(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){Tt(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}var mR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o}=t,{edge:s="both"}=r;if(o){s==="start"&&(s=$.isBackward(o)?"focus":"anchor"),s==="end"&&(s=$.isBackward(o)?"anchor":"focus");var{anchor:i,focus:a}=o,u=s==="anchor"?i:a;W.setSelection(t,{[s==="anchor"?"anchor":"focus"]:Df(Df({},u),n)})}},gR=(e,t)=>{var{selection:n}=e,r={},o={};if(n){for(var s in t)(s==="anchor"&&t.anchor!=null&&!Pe.equals(t.anchor,n.anchor)||s==="focus"&&t.focus!=null&&!Pe.equals(t.focus,n.focus)||s!=="anchor"&&s!=="focus"&&t[s]!==n[s])&&(r[s]=n[s],o[s]=t[s]);Object.keys(r).length>0&&e.apply({type:"set_selection",properties:r,newProperties:o})}},vR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};E.withoutNormalizing(t,()=>{var{hanging:o=!1,voids:s=!1,mode:i="lowest",batchDirty:a=!0}=r,{at:u,match:c,select:d}=r;if(se.isNode(n)&&(n=[n]),n.length!==0){var[l]=n;if(u||(u=Xc(t),d!==!1&&(d=!0)),d==null&&(d=!1),$.isRange(u))if(o||(u=E.unhangRange(t,u,{voids:s})),$.isCollapsed(u))u=u.anchor;else{var[,m]=$.edges(u),g=E.pointRef(t,m);W.delete(t,{at:u}),u=g.unref()}if(Pe.isPoint(u)){c==null&&(pe.isText(l)?c=F=>pe.isText(F):t.isInline(l)?c=F=>pe.isText(F)||E.isInline(t,F):c=F=>ce.isElement(F)&&E.isBlock(t,F));var[v]=E.nodes(t,{at:u.path,match:c,mode:i,voids:s});if(v){var[,C]=v,p=E.pathRef(t,C),D=E.isEnd(t,u,C);W.splitNodes(t,{at:u,match:c,mode:i,voids:s});var w=p.unref();u=D?B.next(w):w}else return}var b=B.parent(u),y=u[u.length-1];if(!(!s&&E.void(t,{at:b}))){if(a){var A=[],T=B.levels(b);eT(t,()=>{var F=function(){var _=b.concat(y);y++;var I={type:"insert_node",path:_,node:M};t.apply(I),u=B.next(u),A.push(I),pe.isText?T.push(...Array.from(se.nodes(M),j=>{var[,z]=j;return _.concat(z)})):T.push(_)};for(var M of n)F()},()=>{uv(t,T,F=>{var M=F;for(var N of A)if(B.operationCanTransformPath(N)&&(M=B.transform(M,N),!M))return null;return M})})}else for(var S of n){var P=b.concat(y);y++,t.apply({type:"insert_node",path:P,node:S}),u=B.next(u)}if(u=B.previous(u),d){var L=E.end(t,u);L&&W.select(t,L)}}}})},CR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.withoutNormalizing(t,()=>{var{at:r=t.selection,mode:o="lowest",voids:s=!1}=n,{match:i}=n;if(i==null&&(i=B.isPath(r)?Oo(t,r):y=>ce.isElement(y)&&E.isBlock(t,y)),!!r){var a=E.nodes(t,{at:r,match:i,mode:o,voids:s}),u=Array.from(a,y=>{var[,A]=y;return E.pathRef(t,A)});for(var c of u){var d=c.unref();if(d.length<2)throw new Error("Cannot lift node at a path [".concat(d,"] because it has a depth of less than `2`."));var l=E.node(t,B.parent(d)),[m,g]=l,v=d[d.length-1],{length:C}=m.children;if(C===1){var p=B.next(g);W.moveNodes(t,{at:d,to:p,voids:s}),W.removeNodes(t,{at:g,voids:s})}else if(v===0)W.moveNodes(t,{at:d,to:g,voids:s});else if(v===C-1){var D=B.next(g);W.moveNodes(t,{at:d,to:D,voids:s})}else{var w=B.next(d),b=B.next(g);W.splitNodes(t,{at:w,voids:s}),W.moveNodes(t,{at:d,to:b,voids:s})}}}})},ER=["text"],yR=["children"],lv=(e,t)=>{if(ce.isElement(t)){var n=t;return E.isVoid(e,t)?!0:n.children.length===1?lv(e,n.children[0]):!1}else return!E.isEditor(t)},bR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.withoutNormalizing(t,()=>{var{match:r,at:o=t.selection}=n,{hanging:s=!1,voids:i=!1,mode:a="lowest"}=n;if(o){if(r==null)if(B.isPath(o)){var[u]=E.parent(t,o);r=F=>u.children.includes(F)}else r=F=>ce.isElement(F)&&E.isBlock(t,F);if(!s&&$.isRange(o)&&(o=E.unhangRange(t,o,{voids:i})),$.isRange(o))if($.isCollapsed(o))o=o.anchor;else{var[,c]=$.edges(o),d=E.pointRef(t,c);W.delete(t,{at:o}),o=d.unref(),n.at==null&&W.select(t,o)}var[l]=E.nodes(t,{at:o,match:r,voids:i,mode:a}),m=E.previous(t,{at:o,match:r,voids:i,mode:a});if(!(!l||!m)){var[g,v]=l,[C,p]=m;if(!(v.length===0||p.length===0)){var D=B.next(p),w=B.common(v,p),b=B.isSibling(v,p),y=Array.from(E.levels(t,{at:v}),F=>{var[M]=F;return M}).slice(w.length).slice(0,-1),A=E.above(t,{at:v,mode:"highest",match:F=>y.includes(F)&&lv(t,F)}),T=A&&E.pathRef(t,A[1]),S,P;if(pe.isText(g)&&pe.isText(C)){var L=In(g,ER);P=C.text.length,S=L}else if(ce.isElement(g)&&ce.isElement(C)){var L=In(g,yR);P=C.children.length,S=L}else throw new Error("Cannot merge the node at path [".concat(v,"] with the previous sibling because it is not the same kind: ").concat(ct.stringify(g)," ").concat(ct.stringify(C)));b||W.moveNodes(t,{at:v,to:D,voids:i}),T&&W.removeNodes(t,{at:T.current,voids:i}),E.shouldMergeNodesRemovePrevNode(t,m,l)?W.removeNodes(t,{at:p,voids:i}):t.apply({type:"merge_node",path:D,position:P,properties:S}),T&&T.unref()}}}})},wR=(e,t)=>{E.withoutNormalizing(e,()=>{var{to:n,at:r=e.selection,mode:o="lowest",voids:s=!1}=t,{match:i}=t;if(r){i==null&&(i=B.isPath(r)?Oo(e,r):g=>ce.isElement(g)&&E.isBlock(e,g));var a=E.pathRef(e,n),u=E.nodes(e,{at:r,match:i,mode:o,voids:s}),c=Array.from(u,g=>{var[,v]=g;return E.pathRef(e,v)});for(var d of c){var l=d.unref(),m=a.current;l.length!==0&&e.apply({type:"move_node",path:l,newPath:m}),a.current&&B.isSibling(m,l)&&B.isAfter(m,l)&&(a.current=B.next(a.current))}a.unref()}})},DR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.withoutNormalizing(t,()=>{var{hanging:r=!1,voids:o=!1,mode:s="lowest"}=n,{at:i=t.selection,match:a}=n;if(i){a==null&&(a=B.isPath(i)?Oo(t,i):g=>ce.isElement(g)&&E.isBlock(t,g)),!r&&$.isRange(i)&&(i=E.unhangRange(t,i,{voids:o}));var u=E.nodes(t,{at:i,match:a,mode:s,voids:o}),c=Array.from(u,g=>{var[,v]=g;return E.pathRef(t,v)});for(var d of c){var l=d.unref();if(l){var[m]=E.node(t,l);t.apply({type:"remove_node",path:l,node:m})}}}})},AR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};E.withoutNormalizing(t,()=>{var{match:o,at:s=t.selection,compare:i,merge:a}=r,{hanging:u=!1,mode:c="lowest",split:d=!1,voids:l=!1}=r;if(s){if(o==null&&(o=B.isPath(s)?Oo(t,s):P=>ce.isElement(P)&&E.isBlock(t,P)),!u&&$.isRange(s)&&(s=E.unhangRange(t,s,{voids:l})),d&&$.isRange(s)){if($.isCollapsed(s)&&E.leaf(t,s.anchor)[0].text.length>0)return;var m=E.rangeRef(t,s,{affinity:"inward"}),[g,v]=$.edges(s),C=c==="lowest"?"lowest":"highest",p=E.isEnd(t,v,v.path);W.splitNodes(t,{at:v,match:o,mode:C,voids:l,always:!p});var D=E.isStart(t,g,g.path);W.splitNodes(t,{at:g,match:o,mode:C,voids:l,always:!D}),s=m.unref(),r.at==null&&W.select(t,s)}i||(i=(P,L)=>P!==L);for(var[w,b]of E.nodes(t,{at:s,match:o,mode:c,voids:l})){var y={},A={};if(b.length!==0){var T=!1;for(var S in n)S==="children"||S==="text"||i(n[S],w[S])&&(T=!0,w.hasOwnProperty(S)&&(y[S]=w[S]),a?n[S]!=null&&(A[S]=a(w[S],n[S])):n[S]!=null&&(A[S]=n[S]));T&&t.apply({type:"set_node",path:b,properties:y,newProperties:A})}}}})},SR=(e,t)=>{if($.isCollapsed(t))return t.anchor;var[,n]=$.edges(t),r=E.pointRef(e,n);return W.delete(e,{at:t}),r.unref()},xR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.withoutNormalizing(t,()=>{var{mode:r="lowest",voids:o=!1}=n,{match:s,at:i=t.selection,height:a=0,always:u=!1}=n;if(s==null&&(s=G=>ce.isElement(G)&&E.isBlock(t,G)),$.isRange(i)&&(i=SR(t,i)),B.isPath(i)){var c=i,d=E.point(t,c),[l]=E.parent(t,c);s=G=>G===l,a=d.path.length-c.length+1,i=d,u=!0}if(i){var m=E.pointRef(t,i,{affinity:"backward"}),g;try{var[v]=E.nodes(t,{at:i,match:s,mode:r,voids:o});if(!v)return;var C=E.void(t,{at:i,mode:"highest"}),p=0;if(!o&&C){var[D,w]=C;if(ce.isElement(D)&&t.isInline(D)){var b=E.after(t,w);if(!b){var y={text:""},A=B.next(w);W.insertNodes(t,y,{at:A,voids:o}),b=E.point(t,A)}i=b,u=!0}var T=i.path.length-w.length;a=T+1,u=!0}g=E.pointRef(t,i);var S=i.path.length-a,[,P]=v,L=i.path.slice(0,S),F=a===0?i.offset:i.path[S]+p;for(var[M,N]of E.levels(t,{at:L,reverse:!0,voids:o})){var _=!1;if(N.length<P.length||N.length===0||!o&&ce.isElement(M)&&E.isVoid(t,M))break;var I=m.current,j=E.isEnd(t,I,N);if(u||!m||!E.isEdge(t,I,N)){_=!0;var z=se.extractProps(M);t.apply({type:"split_node",path:N,position:F,properties:z})}F=N[N.length-1]+(_||j?1:0)}if(n.at==null){var Y=g.current||E.end(t,[]);W.select(t,Y)}}finally{var oe;m.unref(),(oe=g)===null||oe===void 0||oe.unref()}}})},OR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(n)||(n=[n]);var o={};for(var s of n)o[s]=null;W.setNodes(t,o,r)},TR=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.withoutNormalizing(t,()=>{var{mode:r="lowest",split:o=!1,voids:s=!1}=n,{at:i=t.selection,match:a}=n;if(i){a==null&&(a=B.isPath(i)?Oo(t,i):g=>ce.isElement(g)&&E.isBlock(t,g)),B.isPath(i)&&(i=E.range(t,i));var u=$.isRange(i)?E.rangeRef(t,i):null,c=E.nodes(t,{at:i,match:a,mode:r,voids:s}),d=Array.from(c,g=>{var[,v]=g;return E.pathRef(t,v)}).reverse(),l=function(){var v=m.unref(),[C]=E.node(t,v),p=E.range(t,v);o&&u&&(p=$.intersection(u.current,p)),W.liftNodes(t,{at:p,match:D=>ce.isAncestor(C)&&C.children.includes(D),voids:s})};for(var m of d)l();u&&u.unref()}})};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 Sf(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){Tt(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}var RR=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};E.withoutNormalizing(t,()=>{var{mode:o="lowest",split:s=!1,voids:i=!1}=r,{match:a,at:u=t.selection}=r;if(u){if(a==null&&(B.isPath(u)?a=Oo(t,u):t.isInline(n)?a=p=>ce.isElement(p)&&E.isInline(t,p)||pe.isText(p):a=p=>ce.isElement(p)&&E.isBlock(t,p)),s&&$.isRange(u)){var[c,d]=$.edges(u),l=E.rangeRef(t,u,{affinity:"inward"});W.splitNodes(t,{at:d,match:a,voids:i}),W.splitNodes(t,{at:c,match:a,voids:i}),u=l.unref(),r.at==null&&W.select(t,u)}var m=Array.from(E.nodes(t,{at:u,match:t.isInline(n)?p=>ce.isElement(p)&&E.isBlock(t,p):p=>E.isEditor(p),mode:"lowest",voids:i})),g=function(){var D=$.isRange(u)?$.intersection(u,E.range(t,C)):u;if(!D)return 0;var w=Array.from(E.nodes(t,{at:D,match:a,mode:o,voids:i}));if(w.length>0){var[b]=w,y=w[w.length-1],[,A]=b,[,T]=y;if(A.length===0&&T.length===0)return 0;var S=B.equals(A,T)?B.parent(A):B.common(A,T),P=E.range(t,A,T),L=E.node(t,S),[F]=L,M=S.length+1,N=B.next(T.slice(0,M)),_=Sf(Sf({},n),{},{children:[]});W.insertNodes(t,_,{at:N,voids:i}),W.moveNodes(t,{at:P,match:I=>ce.isAncestor(F)&&F.children.includes(I),to:N.concat(0),voids:i})}},v;for(var[,C]of m)v=g()}})},dv=()=>{var e={children:[],operations:[],selection:null,marks:null,isElementReadOnly:()=>!1,isInline:()=>!1,isSelectable:()=>!0,isVoid:()=>!1,markableVoid:()=>!1,onChange:()=>{},apply:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return tT(e,...r)},addMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return aT(e,...r)},deleteBackward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return lT(e,...r)},deleteForward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return dT(e,...r)},deleteFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return fT(e,...r)},getFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return rT(e,...r)},insertBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DT(e,...r)},insertSoftBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ST(e,...r)},insertFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return lR(e,...r)},insertNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AT(e,...r)},insertText:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return cv(e,...r)},normalizeNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return oT(e,...r)},removeMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return nR(e,...r)},getDirtyPaths:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return nT(e,...r)},shouldNormalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return sT(e,...r)},above:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return iT(e,...r)},after:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return uT(e,...r)},before:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return cT(e,...r)},collapse:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return dR(e,...r)},delete:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return cR(e,...r)},deselect:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return fR(e,...r)},edges:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return hT(e,...r)},elementReadOnly:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return pT(e,...r)},end:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return mT(e,...r)},first:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return gT(e,...r)},fragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return vT(e,...r)},getMarks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return jT(e,...r)},hasBlocks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ET(e,...r)},hasInlines:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return yT(e,...r)},hasPath:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return bT(e,...r)},hasTexts:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return wT(e,...r)},insertNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return vR(e,...r)},isBlock:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OT(e,...r)},isEdge:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TT(e,...r)},isEmpty:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return RT(e,...r)},isEnd:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return IT(e,...r)},isNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return BT(e,...r)},isStart:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return FT(e,...r)},last:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return PT(e,...r)},leaf:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return MT(e,...r)},levels:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _T(e,...r)},liftNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CR(e,...r)},mergeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return bR(e,...r)},move:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return hR(e,...r)},moveNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return wR(e,...r)},next:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LT(e,...r)},node:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UT(e,...r)},nodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $T(e,...r)},normalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HT(e,...r)},parent:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VT(e,...r)},path:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KT(e,...r)},pathRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WT(e,...r)},pathRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return zT(e,...r)},point:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YT(e,...r)},pointRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return GT(e,...r)},pointRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qT(e,...r)},positions:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return JT(e,...r)},previous:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ZT(e,...r)},range:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return eR(e,...r)},rangeRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XT(e,...r)},rangeRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return QT(e,...r)},removeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DR(e,...r)},select:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return pR(e,...r)},setNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AR(e,...r)},setNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return rR(e,...r)},setPoint:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return mR(e,...r)},setSelection:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return gR(e,...r)},splitNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return xR(e,...r)},start:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return oR(e,...r)},string:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return sR(e,...r)},unhangRange:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return iR(e,...r)},unsetNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OR(e,...r)},unwrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TR(e,...r)},void:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CT(e,...r)},withoutNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return aR(e,...r)},wrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return RR(e,...r)},shouldMergeNodesRemovePrevNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return uR(e,...r)}};return e},IR={isHistory(e){return ut(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||Gn.isOperationList(e.redos[0].operations))&&(e.undos.length===0||Gn.isOperationList(e.undos[0].operations))}},Ha=new WeakMap,ur=new WeakMap,Vs=new WeakMap,ln={isHistoryEditor(e){return IR.isHistory(e.history)&&E.isEditor(e)},isMerging(e){return ur.get(e)},isSplittingOnce(e){return Vs.get(e)},setSplittingOnce(e,t){Vs.set(e,t)},isSaving(e){return Ha.get(e)},redo(e){e.redo()},undo(e){e.undo()},withMerging(e,t){var n=ln.isMerging(e);ur.set(e,!0),t(),ur.set(e,n)},withNewBatch(e,t){var n=ln.isMerging(e);ur.set(e,!0),Vs.set(e,!0),t(),ur.set(e,n),Vs.delete(e)},withoutMerging(e,t){var n=ln.isMerging(e);ur.set(e,!1),t(),ur.set(e,n)},withoutSaving(e,t){var n=ln.isSaving(e);Ha.set(e,!1),t(),Ha.set(e,n)}},BR=e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:r}=t,{redos:o}=r;if(o.length>0){var s=o[o.length-1];s.selectionBefore&&W.setSelection(t,s.selectionBefore),ln.withoutSaving(t,()=>{E.withoutNormalizing(t,()=>{for(var i of s.operations)t.apply(i)})}),r.redos.pop(),t.writeHistory("undos",s)}},t.undo=()=>{var{history:r}=t,{undos:o}=r;if(o.length>0){var s=o[o.length-1];ln.withoutSaving(t,()=>{E.withoutNormalizing(t,()=>{var i=s.operations.map(Gn.inverse).reverse();for(var a of i)t.apply(a);s.selectionBefore&&W.setSelection(t,s.selectionBefore)})}),t.writeHistory("redos",s),r.undos.pop()}},t.apply=r=>{var{operations:o,history:s}=t,{undos:i}=s,a=i[i.length-1],u=a&&a.operations[a.operations.length-1],c=ln.isSaving(t),d=ln.isMerging(t);if(c==null&&(c=PR(r)),c){if(d==null&&(a==null?d=!1:o.length!==0?d=!0:d=FR(r,u)),ln.isSplittingOnce(t)&&(d=!1,ln.setSplittingOnce(t,void 0)),a&&d)a.operations.push(r);else{var l={operations:[r],selectionBefore:t.selection};t.writeHistory("undos",l)}for(;i.length>100;)i.shift();s.redos=[]}n(r)},t.writeHistory=(r,o)=>{t.history[r].push(o)},t},FR=(e,t)=>!!(t&&e.type==="insert_text"&&t.type==="insert_text"&&e.offset===t.offset+t.text.length&&B.equals(e.path,t.path)||t&&e.type==="remove_text"&&t.type==="remove_text"&&e.offset+e.text.length===t.offset&&B.equals(e.path,t.path)),PR=(e,t)=>e.type!=="set_selection",Va,xf;function MR(){if(xf)return Va;xf=1,Va=o;var e="֑-߿יִ-﷽ﹰ-ﻼ",t="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",n=new RegExp("^[^"+t+"]*["+e+"]"),r=new RegExp("^[^"+e+"]*["+t+"]");function o(s){return s=String(s||""),n.test(s)?"rtl":r.test(s)?"ltr":"neutral"}return Va}var _R=MR();const fv=zC(_R),Of=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Tf=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",Wa=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Tf(n.overflowY,t)||Tf(n.overflowX,t)||(r=>{const o=(s=>{if(!s.ownerDocument||!s.ownerDocument.defaultView)return null;try{return s.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(e)}return!1},Ws=(e,t,n,r,o,s,i,a)=>s<e&&i>t||s>e&&i<t?0:s<=e&&a<=n||i>=t&&a>=n?s-e-r:i>t&&a<n||s<e&&a>n?i-t+o:0,kR=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},Rf=(e,t)=>{var n,r,o,s;if(typeof document>"u")return[];const{scrollMode:i,block:a,inline:u,boundary:c,skipOverflowHiddenElements:d}=t,l=typeof c=="function"?c:z=>z!==c;if(!Of(e))throw new TypeError("Invalid target");const m=document.scrollingElement||document.documentElement,g=[];let v=e;for(;Of(v)&&l(v);){if(v=kR(v),v===m){g.push(v);break}v!=null&&v===document.body&&Wa(v)&&!Wa(document.documentElement)||v!=null&&Wa(v,d)&&g.push(v)}const C=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,p=(s=(o=window.visualViewport)==null?void 0:o.height)!=null?s:innerHeight,{scrollX:D,scrollY:w}=window,{height:b,width:y,top:A,right:T,bottom:S,left:P}=e.getBoundingClientRect(),{top:L,right:F,bottom:M,left:N}=(z=>{const Y=window.getComputedStyle(z);return{top:parseFloat(Y.scrollMarginTop)||0,right:parseFloat(Y.scrollMarginRight)||0,bottom:parseFloat(Y.scrollMarginBottom)||0,left:parseFloat(Y.scrollMarginLeft)||0}})(e);let _=a==="start"||a==="nearest"?A-L:a==="end"?S+M:A+b/2-L+M,I=u==="center"?P+y/2-N+F:u==="end"?T+F:P-N;const j=[];for(let z=0;z<g.length;z++){const Y=g[z],{height:oe,width:G,top:Z,right:le,bottom:de,left:ue}=Y.getBoundingClientRect();if(i==="if-needed"&&A>=0&&P>=0&&S<=p&&T<=C&&A>=Z&&S<=de&&P>=ue&&T<=le)return j;const ee=getComputedStyle(Y),te=parseInt(ee.borderLeftWidth,10),R=parseInt(ee.borderTopWidth,10),q=parseInt(ee.borderRightWidth,10),J=parseInt(ee.borderBottomWidth,10);let X=0,ie=0;const ae="offsetWidth"in Y?Y.offsetWidth-Y.clientWidth-te-q:0,we="offsetHeight"in Y?Y.offsetHeight-Y.clientHeight-R-J:0,Se="offsetWidth"in Y?Y.offsetWidth===0?0:G/Y.offsetWidth:0,me="offsetHeight"in Y?Y.offsetHeight===0?0:oe/Y.offsetHeight:0;if(m===Y)X=a==="start"?_:a==="end"?_-p:a==="nearest"?Ws(w,w+p,p,R,J,w+_,w+_+b,b):_-p/2,ie=u==="start"?I:u==="center"?I-C/2:u==="end"?I-C:Ws(D,D+C,C,te,q,D+I,D+I+y,y),X=Math.max(0,X+w),ie=Math.max(0,ie+D);else{X=a==="start"?_-Z-R:a==="end"?_-de+J+we:a==="nearest"?Ws(Z,de,oe,R,J+we,_,_+b,b):_-(Z+oe/2)+we/2,ie=u==="start"?I-ue-te:u==="center"?I-(ue+G/2)+ae/2:u==="end"?I-le+q+ae:Ws(ue,le,G,te,q+ae,I,I+y,y);const{scrollLeft:fe,scrollTop:ye}=Y;X=me===0?0:Math.max(0,Math.min(ye+X/me,Y.scrollHeight-oe/me+we)),ie=Se===0?0:Math.max(0,Math.min(fe+ie/Se,Y.scrollWidth-G/Se+ae)),_+=ye-X,I+=fe-ie}j.push({el:Y,top:X,left:ie})}return j},NR=e=>e===!1?{block:"end",inline:"nearest"}:(t=>t===Object(t)&&Object.keys(t).length!==0)(e)?e:{block:"start",inline:"nearest"};function jR(e,t){if(!e.isConnected||!(o=>{let s=o;for(;s&&s.parentNode;){if(s.parentNode===document)return!0;s=s.parentNode instanceof ShadowRoot?s.parentNode.host:s.parentNode}return!1})(e))return;const n=(o=>{const s=window.getComputedStyle(o);return{top:parseFloat(s.scrollMarginTop)||0,right:parseFloat(s.scrollMarginRight)||0,bottom:parseFloat(s.scrollMarginBottom)||0,left:parseFloat(s.scrollMarginLeft)||0}})(e);if((o=>typeof o=="object"&&typeof o.behavior=="function")(t))return t.behavior(Rf(e,t));const r=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:o,top:s,left:i}of Rf(e,NR(t))){const a=s-n.top+n.bottom,u=i-n.left+n.right;o.scroll({top:a,left:u,behavior:r})}}var br=[],LR=function(){return br.some(function(e){return e.activeTargets.length>0})},UR=function(){return br.some(function(e){return e.skippedTargets.length>0})},If="ResizeObserver loop completed with undelivered notifications.",$R=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:If}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=If),window.dispatchEvent(e)},is;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(is||(is={}));var wr=function(e){return Object.freeze(e)},HR=(function(){function e(t,n){this.inlineSize=t,this.blockSize=n,wr(this)}return e})(),hv=(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,wr(this)}return e.prototype.toJSON=function(){var t=this,n=t.x,r=t.y,o=t.top,s=t.right,i=t.bottom,a=t.left,u=t.width,c=t.height;return{x:n,y:r,top:o,right:s,bottom:i,left:a,width:u,height:c}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e})(),tl=function(e){return e instanceof SVGElement&&"getBBox"in e},pv=function(e){if(tl(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,s=o.offsetWidth,i=o.offsetHeight;return!(s||i||e.getClientRects().length)},Bf=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)},VR=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},Dr=typeof window<"u"?window:{},zs=new WeakMap,Ff=/auto|scroll/,WR=/^tb|vertical/,zR=/msie|trident/i.test(Dr.navigator&&Dr.navigator.userAgent),an=function(e){return parseFloat(e||"0")},oo=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new HR((n?t:e)||0,(n?e:t)||0)},Pf=wr({devicePixelContentBoxSize:oo(),borderBoxSize:oo(),contentBoxSize:oo(),contentRect:new hv(0,0,0,0)}),mv=function(e,t){if(t===void 0&&(t=!1),zs.has(e)&&!t)return zs.get(e);if(pv(e))return zs.set(e,Pf),Pf;var n=getComputedStyle(e),r=tl(e)&&e.ownerSVGElement&&e.getBBox(),o=!zR&&n.boxSizing==="border-box",s=WR.test(n.writingMode||""),i=!r&&Ff.test(n.overflowY||""),a=!r&&Ff.test(n.overflowX||""),u=r?0:an(n.paddingTop),c=r?0:an(n.paddingRight),d=r?0:an(n.paddingBottom),l=r?0:an(n.paddingLeft),m=r?0:an(n.borderTopWidth),g=r?0:an(n.borderRightWidth),v=r?0:an(n.borderBottomWidth),C=r?0:an(n.borderLeftWidth),p=l+c,D=u+d,w=C+g,b=m+v,y=a?e.offsetHeight-b-e.clientHeight:0,A=i?e.offsetWidth-w-e.clientWidth:0,T=o?p+w:0,S=o?D+b:0,P=r?r.width:an(n.width)-T-A,L=r?r.height:an(n.height)-S-y,F=P+p+A+w,M=L+D+y+b,N=wr({devicePixelContentBoxSize:oo(Math.round(P*devicePixelRatio),Math.round(L*devicePixelRatio),s),borderBoxSize:oo(F,M,s),contentBoxSize:oo(P,L,s),contentRect:new hv(l,u,P,L)});return zs.set(e,N),N},gv=function(e,t,n){var r=mv(e,n),o=r.borderBoxSize,s=r.contentBoxSize,i=r.devicePixelContentBoxSize;switch(t){case is.DEVICE_PIXEL_CONTENT_BOX:return i;case is.BORDER_BOX:return o;default:return s}},KR=(function(){function e(t){var n=mv(t);this.target=t,this.contentRect=n.contentRect,this.borderBoxSize=wr([n.borderBoxSize]),this.contentBoxSize=wr([n.contentBoxSize]),this.devicePixelContentBoxSize=wr([n.devicePixelContentBoxSize])}return e})(),vv=function(e){if(pv(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},GR=function(){var e=1/0,t=[];br.forEach(function(i){if(i.activeTargets.length!==0){var a=[];i.activeTargets.forEach(function(c){var d=new KR(c.target),l=vv(c.target);a.push(d),c.lastReportedSize=gv(c.target,c.observedBox),l<e&&(e=l)}),t.push(function(){i.callback.call(i.observer,a,i.observer)}),i.activeTargets.splice(0,i.activeTargets.length)}});for(var n=0,r=t;n<r.length;n++){var o=r[n];o()}return e},Mf=function(e){br.forEach(function(n){n.activeTargets.splice(0,n.activeTargets.length),n.skippedTargets.splice(0,n.skippedTargets.length),n.observationTargets.forEach(function(o){o.isActive()&&(vv(o.target)>e?n.activeTargets.push(o):n.skippedTargets.push(o))})})},qR=function(){var e=0;for(Mf(e);LR();)e=GR(),Mf(e);return UR()&&$R(),e>0},za,Cv=[],YR=function(){return Cv.splice(0).forEach(function(e){return e()})},JR=function(e){if(!za){var t=0,n=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return YR()}).observe(n,r),za=function(){n.textContent="".concat(t?t--:t++)}}Cv.push(e),za()},ZR=function(e){JR(function(){requestAnimationFrame(e)})},ei=0,XR=function(){return!!ei},QR=250,eI={attributes:!0,characterData:!0,childList:!0,subtree:!0},_f=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],kf=function(e){return e===void 0&&(e=0),Date.now()+e},Ka=!1,tI=(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=QR),!Ka){Ka=!0;var r=kf(t);ZR(function(){var o=!1;try{o=qR()}finally{if(Ka=!1,t=r-kf(),!XR())return;o?n.run(1e3):t>0?n.run(t):n.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,n=function(){return t.observer&&t.observer.observe(document.body,eI)};document.body?n():Dr.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),_f.forEach(function(n){return Dr.addEventListener(n,t.listener,!0)}))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),_f.forEach(function(n){return Dr.removeEventListener(n,t.listener,!0)}),this.stopped=!0)},e})(),Iu=new tI,Nf=function(e){!ei&&e>0&&Iu.start(),ei+=e,!ei&&Iu.stop()},nI=function(e){return!tl(e)&&!VR(e)&&getComputedStyle(e).display==="inline"},rI=(function(){function e(t,n){this.target=t,this.observedBox=n||is.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=gv(this.target,this.observedBox,!0);return nI(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e})(),oI=(function(){function e(t,n){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=n}return e})(),Ks=new WeakMap,jf=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},Gs=(function(){function e(){}return e.connect=function(t,n){var r=new oI(t,n);Ks.set(t,r)},e.observe=function(t,n,r){var o=Ks.get(t),s=o.observationTargets.length===0;jf(o.observationTargets,n)<0&&(s&&br.push(o),o.observationTargets.push(new rI(n,r&&r.box)),Nf(1),Iu.schedule())},e.unobserve=function(t,n){var r=Ks.get(t),o=jf(r.observationTargets,n),s=r.observationTargets.length===1;o>=0&&(s&&br.splice(br.indexOf(r),1),r.observationTargets.splice(o,1),Nf(-1))},e.disconnect=function(t){var n=this,r=Ks.get(t);r.observationTargets.slice().forEach(function(o){return n.unobserve(t,o.target)}),r.activeTargets.splice(0,r.activeTargets.length)},e})(),sI=(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.");Gs.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(!Bf(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Gs.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(!Bf(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Gs.unobserve(this,t)},e.prototype.disconnect=function(){Gs.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e})(),Jt={},Lf;function iI(){if(Lf)return Jt;Lf=1,Object.defineProperty(Jt,"__esModule",{value:!0});for(var e=typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),t={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},n={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:e?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},r={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=1;o<20;o++)r["f"+o]=111+o;function s(m,g,v){g&&!("byKey"in g)&&(v=g,g=null),Array.isArray(m)||(m=[m]);var C=m.map(function(w){return u(w,g)}),p=function(b){return C.some(function(y){return c(y,b)})},D=v==null?p:p(v);return D}function i(m,g){return s(m,g)}function a(m,g){return s(m,{byKey:!0},g)}function u(m,g){var v=g&&g.byKey,C={};m=m.replace("++","+add");var p=m.split("+"),D=p.length;for(var w in t)C[t[w]]=!1;var b=!0,y=!1,A=void 0;try{for(var T=p[Symbol.iterator](),S;!(b=(S=T.next()).done);b=!0){var P=S.value,L=P.endsWith("?")&&P.length>1;L&&(P=P.slice(0,-1));var F=l(P),M=t[F];if(P.length>1&&!M&&!n[P]&&!r[F])throw new TypeError('Unknown modifier: "'+P+'"');(D===1||!M)&&(v?C.key=F:C.which=d(P)),M&&(C[M]=L?null:!0)}}catch(N){y=!0,A=N}finally{try{!b&&T.return&&T.return()}finally{if(y)throw A}}return C}function c(m,g){for(var v in m){var C=m[v],p=void 0;if(C!=null&&(v==="key"&&g.key!=null?p=g.key.toLowerCase():v==="which"?p=C===91&&g.which===93?91:g.which:p=g[v],!(p==null&&C===!1)&&p!==C))return!1}return!0}function d(m){m=l(m);var g=r[m]||m.toUpperCase().charCodeAt(0);return g}function l(m){return m=m.toLowerCase(),m=n[m]||m,m}return Jt.default=s,Jt.isHotkey=s,Jt.isCodeHotkey=i,Jt.isKeyHotkey=a,Jt.parseHotkey=u,Jt.compareHotkey=c,Jt.toKeyCode=d,Jt.toKeyName=l,Jt}var Ga=iI();function aI(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function vo(e,t){if(e==null)return{};var n=aI(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function as(e){"@babel/helpers - typeof";return as=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},as(e)}function uI(e,t){if(as(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(as(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function cI(e){var t=uI(e,"string");return as(t)==="symbol"?t:String(t)}function zt(e,t,n){return t=cI(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var nl=f.createContext(null),yn=()=>{var e=f.useContext(nl);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},qa,Ya,Ev=parseInt(Re.version.split(".")[0],10),yv=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Uf=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),At=typeof navigator<"u"&&/Android/.test(navigator.userAgent),Xr=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),dr=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),lI=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),bv=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),dI=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),fI=At&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),hI=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),pI=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),mI=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent),ti=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&((qa=navigator.userAgent.match(/Version\/(\d+)/))!==null&&qa!==void 0&&qa[1]&&parseInt((Ya=navigator.userAgent.match(/Version\/(\d+)/))===null||Ya===void 0?void 0:Ya[1],10)<17);var Ln=(!dI||!fI)&&!lI&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function",so=new WeakMap,rl=new WeakMap,ol=new WeakMap,wv=new WeakMap,ni=new WeakMap,Bu=new WeakMap,us=new WeakMap,Ar=new WeakMap,bi=new WeakMap,Qi=new WeakMap,Fu=new WeakMap,qn=new WeakMap,Cr=new WeakMap,Ko=new WeakMap,Pu=new WeakMap,sl=new WeakMap,tn=new WeakMap,Dn=new WeakMap,It=new WeakMap,Vn=new WeakMap,Wn=new WeakMap,Dv=new WeakMap,Co=Symbol("placeholder"),Av=Symbol("mark-placeholder"),Sv=globalThis.Node,gI=globalThis.Text,il=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,vI=e=>tr(e)&&e.nodeType===8,Ht=e=>tr(e)&&e.nodeType===1,tr=e=>{var t=il(e);return!!t&&e instanceof t.Node},Mu=e=>{var t=e&&e.anchorNode&&il(e.anchorNode);return!!t&&e instanceof t.Selection},xv=e=>tr(e)&&e.nodeType===3,CI=e=>e.clipboardData&&e.clipboardData.getData("text/plain")!==""&&e.clipboardData.types.length===1,EI=e=>{var[t,n]=e;if(Ht(t)&&t.childNodes.length){var r=n===t.childNodes.length,o=r?n-1:n;for([t,o]=Ov(t,o,r?"backward":"forward"),r=o<n;Ht(t)&&t.childNodes.length;){var s=r?t.childNodes.length-1:0;t=bI(t,s,r?"backward":"forward")}n=r&&t.textContent!=null?t.textContent.length:0}return[t,n]},yI=e=>{for(var t=e&&e.parentNode;t;){if(t.toString()==="[object ShadowRoot]")return!0;t=t.parentNode}return!1},Ov=(e,t,n)=>{for(var{childNodes:r}=e,o=r[t],s=t,i=!1,a=!1;(vI(o)||Ht(o)&&o.childNodes.length===0||Ht(o)&&o.getAttribute("contenteditable")==="false")&&!(i&&a);){if(s>=r.length){i=!0,s=t-1,n="backward";continue}if(s<0){a=!0,s=t+1,n="forward";continue}o=r[s],t=s,s+=n==="forward"?1:-1}return[o,t]},bI=(e,t,n)=>{var[r]=Ov(e,t,n);return r},Tv=e=>{var t="";if(xv(e)&&e.nodeValue)return e.nodeValue;if(Ht(e)){for(var n of Array.from(e.childNodes))t+=Tv(n);var r=getComputedStyle(e).getPropertyValue("display");(r==="block"||r==="list"||e.tagName==="BR")&&(t+=`
|
|
49
|
+
`)}return t},wI=/data-slate-fragment="(.+?)"/m,DI=e=>{var t=e.getData("text/html"),[,n]=t.match(wI)||[];return n},Go=e=>e.getSelection!=null?e.getSelection():document.getSelection(),al=(e,t,n)=>{var{target:r}=t;if(Ht(r)&&r.matches('[contentEditable="false"]'))return!1;var{document:o}=K.getWindow(e);if(o.contains(r))return K.hasDOMNode(e,r,{editable:!0});var s=n.find(i=>{var{addedNodes:a,removedNodes:u}=i;for(var c of a)if(c===r||c.contains(r))return!0;for(var d of u)if(d===r||d.contains(r))return!0});return!s||s===t?!1:al(e,s,n)},AI=()=>{for(var e=document.activeElement;(t=e)!==null&&t!==void 0&&t.shadowRoot&&(n=e.shadowRoot)!==null&&n!==void 0&&n.activeElement;){var t,n,r;e=(r=e)===null||r===void 0||(r=r.shadowRoot)===null||r===void 0?void 0:r.activeElement}return e},$f=(e,t)=>!!(e.compareDocumentPosition(t)&Sv.DOCUMENT_POSITION_PRECEDING),SI=(e,t)=>!!(e.compareDocumentPosition(t)&Sv.DOCUMENT_POSITION_FOLLOWING),xI=0;class OI{constructor(){zt(this,"id",void 0),this.id="".concat(xI++)}}var K={androidPendingDiffs:e=>It.get(e),androidScheduleFlush:e=>{var t;(t=sl.get(e))===null||t===void 0||t()},blur:e=>{var t=K.toDOMNode(e,e),n=K.findDocumentOrShadowRoot(e);qn.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{var{selection:t}=e,n=K.findDocumentOrShadowRoot(e),r=Go(n);r&&r.rangeCount>0&&r.removeAllRanges(),t&&W.deselect(e)},findDocumentOrShadowRoot:e=>{var t=K.toDOMNode(e,e),n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},findEventRange:(e,t)=>{"nativeEvent"in t&&(t=t.nativeEvent);var{clientX:n,clientY:r,target:o}=t;if(n==null||r==null)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var s=K.toSlateNode(e,t.target),i=K.findPath(e,s);if(ce.isElement(s)&&E.isVoid(e,s)){var a=o.getBoundingClientRect(),u=e.isInline(s)?n-a.left<a.left+a.width-n:r-a.top<a.top+a.height-r,c=E.point(e,i,{edge:u?"start":"end"}),d=u?E.before(e,c):E.after(e,c);if(d){var l=E.range(e,d);return l}}var m,{document:g}=K.getWindow(e);if(g.caretRangeFromPoint)m=g.caretRangeFromPoint(n,r);else{var v=g.caretPositionFromPoint(n,r);v&&(m=g.createRange(),m.setStart(v.offsetNode,v.offset),m.setEnd(v.offsetNode,v.offset))}if(!m)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var C=K.toSlateRange(e,m,{exactMatch:!1,suppressThrow:!1});return C},findKey:(e,t)=>{var n=bi.get(t);return n||(n=new OI,bi.set(t,n)),n},findPath:(e,t)=>{for(var n=[],r=t;;){var o=ol.get(r);if(o==null){if(E.isEditor(r))return n;break}var s=rl.get(r);if(s==null)break;n.unshift(s),r=o}throw new Error("Unable to find the path for Slate node: ".concat(ct.stringify(t)))},focus:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{retries:5};if(!qn.get(t)){if(n.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(t.operations.length>0){setTimeout(()=>{K.focus(t,{retries:n.retries-1})},10);return}var r=K.toDOMNode(t,t),o=K.findDocumentOrShadowRoot(t);if(o.activeElement!==r){if(t.selection&&o instanceof Document){var s=Go(o),i=K.toDOMRange(t,t.selection);s?.removeAllRanges(),s?.addRange(i)}t.selection||W.select(t,E.start(t,[])),qn.set(t,!0),r.focus({preventScroll:!0})}}},getWindow:e=>{var t=wv.get(e);if(!t)throw new Error("Unable to find a host window element for this editor");return t},hasDOMNode:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{editable:o=!1}=r,s=K.toDOMNode(t,t),i;try{i=Ht(n)?n:n.parentElement}catch(a){if(a instanceof Error&&!a.message.includes('Permission denied to access property "nodeType"'))throw a}return i?i.closest("[data-slate-editor]")===s&&(!o||i.isContentEditable?!0:typeof i.isContentEditable=="boolean"&&i.closest('[contenteditable="false"]')===s||!!i.getAttribute("data-slate-zero-width")):!1},hasEditableTarget:(e,t)=>tr(t)&&K.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{var{anchor:n,focus:r}=t;return E.hasPath(e,n.path)&&E.hasPath(e,r.path)},hasSelectableTarget:(e,t)=>K.hasEditableTarget(e,t)||K.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>tr(t)&&K.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!Cr.get(e),isFocused:e=>!!qn.get(e),isReadOnly:e=>!!Fu.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(Fu.get(e))return!1;var n=K.hasTarget(e,t)&&K.toSlateNode(e,t);return ce.isElement(n)&&E.isVoid(e,n)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{var n=Qi.get(e),r=E.isEditor(t)?ni.get(e):n?.get(K.findKey(e,t));if(!r)throw new Error("Cannot resolve a DOM node from Slate node: ".concat(ct.stringify(t)));return r},toDOMPoint:(e,t)=>{var[n]=E.node(e,t.path),r=K.toDOMNode(e,n),o;E.void(e,{at:t})&&(t={path:t.path,offset:0});for(var s="[data-slate-string], [data-slate-zero-width]",i=Array.from(r.querySelectorAll(s)),a=0,u=0;u<i.length;u++){var c=i[u],d=c.childNodes[0];if(!(d==null||d.textContent==null)){var{length:l}=d.textContent,m=c.getAttribute("data-slate-length"),g=m==null?l:parseInt(m,10),v=a+g,C=i[u+1];if(t.offset===v&&C!==null&&C!==void 0&&C.hasAttribute("data-slate-mark-placeholder")){var p,D=C.childNodes[0];o=[D instanceof gI?D:C,(p=C.textContent)!==null&&p!==void 0&&p.startsWith("\uFEFF")?1:0];break}if(t.offset<=v){var w=Math.min(l,Math.max(0,t.offset-a));o=[d,w];break}a=v}}if(!o)throw new Error("Cannot resolve a DOM point from Slate point: ".concat(ct.stringify(t)));return o},toDOMRange:(e,t)=>{var{anchor:n,focus:r}=t,o=$.isBackward(t),s=K.toDOMPoint(e,n),i=$.isCollapsed(t)?s:K.toDOMPoint(e,r),a=K.getWindow(e),u=a.document.createRange(),[c,d]=o?i:s,[l,m]=o?s:i,g=Ht(c)?c:c.parentElement,v=!!g.getAttribute("data-slate-zero-width"),C=Ht(l)?l:l.parentElement,p=!!C.getAttribute("data-slate-zero-width");return u.setStart(c,v?1:d),u.setEnd(l,p?1:m),u},toSlateNode:(e,t)=>{var n=Ht(t)?t:t.parentElement;n&&!n.hasAttribute("data-slate-node")&&(n=n.closest("[data-slate-node]"));var r=n?us.get(n):null;if(!r)throw new Error("Cannot resolve a Slate node from DOM node: ".concat(n));return r},toSlatePoint:(e,t,n)=>{var{exactMatch:r,suppressThrow:o,searchDirection:s="backward"}=n,[i,a]=r?t:EI(t),u=i.parentNode,c=null,d=0;if(u){var l,m,g=K.toDOMNode(e,e),v=u.closest('[data-slate-void="true"]'),C=v&&g.contains(v)?v:null,p=u.closest('[contenteditable="false"]'),D=p&&g.contains(p)?p:null,w=u.closest("[data-slate-leaf]"),b=null;if(w){if(c=w.closest('[data-slate-node="text"]'),c){var y=K.getWindow(e),A=y.document.createRange();A.setStart(c,0),A.setEnd(i,a);var T=A.cloneContents(),S=[...Array.prototype.slice.call(T.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(T.querySelectorAll("[contenteditable=false]"))];S.forEach(ue=>{if(At&&!r&&ue.hasAttribute("data-slate-zero-width")&&ue.textContent.length>0&&ue.textContext!=="\uFEFF"){ue.textContent.startsWith("\uFEFF")&&(ue.textContent=ue.textContent.slice(1));return}ue.parentNode.removeChild(ue)}),d=T.textContent.length,b=c}}else if(C){for(var P=C.querySelectorAll("[data-slate-leaf]"),L=0;L<P.length;L++){var F=P[L];if(K.hasDOMNode(e,F)){w=F;break}}w?(c=w.closest('[data-slate-node="text"]'),b=w,d=b.textContent.length,b.querySelectorAll("[data-slate-zero-width]").forEach(ue=>{d-=ue.textContent.length})):d=1}else if(D){var M=ue=>ue?ue.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],N=D.closest('[data-slate-node="element"]');if(s==="forward"){var _,I=[...M(N),...M(N?.nextElementSibling)];w=(_=I.find(ue=>SI(D,ue)))!==null&&_!==void 0?_:null}else{var j,z=[...M(N?.previousElementSibling),...M(N)];w=(j=z.findLast(ue=>$f(D,ue)))!==null&&j!==void 0?j:null}w&&(c=w.closest('[data-slate-node="text"]'),b=w,s==="forward"?d=0:(d=b.textContent.length,b.querySelectorAll("[data-slate-zero-width]").forEach(ue=>{d-=ue.textContent.length})))}b&&d===b.textContent.length&&At&&b.getAttribute("data-slate-zero-width")==="z"&&(l=b.textContent)!==null&&l!==void 0&&l.startsWith("\uFEFF")&&(u.hasAttribute("data-slate-zero-width")||Xr&&(m=b.textContent)!==null&&m!==void 0&&m.endsWith(`
|
|
50
|
+
|
|
51
|
+
`))&&d--}if(At&&!c&&!r){var Y=u.hasAttribute("data-slate-node")?u:u.closest("[data-slate-node]");if(Y&&K.hasDOMNode(e,Y,{editable:!0})){var oe=K.toSlateNode(e,Y),{path:G,offset:Z}=E.start(e,K.findPath(e,oe));return Y.querySelector("[data-slate-leaf]")||(Z=a),{path:G,offset:Z}}}if(!c){if(o)return null;throw new Error("Cannot resolve a Slate point from DOM point: ".concat(t))}var le=K.toSlateNode(e,c),de=K.findPath(e,le);return{path:de,offset:d}},toSlateRange:(e,t,n)=>{var r,{exactMatch:o,suppressThrow:s}=n,i=Mu(t)?t.anchorNode:t.startContainer,a,u,c,d,l;if(i)if(Mu(t)){if(Xr&&t.rangeCount>1){c=t.focusNode;var m=t.getRangeAt(0),g=t.getRangeAt(t.rangeCount-1);if(c instanceof HTMLTableRowElement&&m.startContainer instanceof HTMLTableRowElement&&g.startContainer instanceof HTMLTableRowElement){let T=function(S){return S.childElementCount>0?T(S.children[0]):S};var v=m.startContainer,C=g.startContainer,p=T(v.children[m.startOffset]),D=T(C.children[g.startOffset]);d=0,D.childNodes.length>0?a=D.childNodes[0]:a=D,p.childNodes.length>0?c=p.childNodes[0]:c=p,D instanceof HTMLElement?u=D.innerHTML.length:u=0}else m.startContainer===c?(a=g.endContainer,u=g.endOffset,d=m.startOffset):(a=m.startContainer,u=m.endOffset,d=g.startOffset)}else a=t.anchorNode,u=t.anchorOffset,c=t.focusNode,d=t.focusOffset;bv&&yI(a)||Xr?l=t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:l=t.isCollapsed}else a=t.startContainer,u=t.startOffset,c=t.endContainer,d=t.endOffset,l=t.collapsed;if(a==null||c==null||u==null||d==null)throw new Error("Cannot resolve a Slate range from DOM range: ".concat(t));Xr&&(r=c.textContent)!==null&&r!==void 0&&r.endsWith(`
|
|
52
|
+
|
|
53
|
+
`)&&d===c.textContent.length&&d--;var w=K.toSlatePoint(e,[a,u],{exactMatch:o,suppressThrow:s});if(!w)return null;var b=$f(a,c)||a===c&&d<u,y=l?w:K.toSlatePoint(e,[c,d],{exactMatch:o,suppressThrow:s,searchDirection:b?"forward":"backward"});if(!y)return null;var A={anchor:w,focus:y};return $.isExpanded(A)&&$.isForward(A)&&Ht(c)&&E.void(e,{at:A.focus,mode:"highest"})&&(A=E.unhangRange(e,A,{voids:!0})),A}};function TI(e,t){var{path:n,diff:r}=t;if(!E.hasPath(e,n))return!1;var o=se.get(e,n);if(!pe.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 s=B.next(n);if(!E.hasPath(e,s))return!1;var i=se.get(e,s);return pe.isText(i)&&i.text.startsWith(r.text)}function Rv(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,s)=>o.slice(0,s.start)+s.text+o.slice(s.end),e)}function RI(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++)if(e.charAt(r)!==t.charAt(r))return r;return n}function II(e,t,n){for(var r=Math.min(e.length,t.length,n),o=0;o<r;o++)if(e.charAt(e.length-o-1)!==t.charAt(t.length-o-1))return o;return r}function Iv(e,t){var{start:n,end:r,text:o}=t,s=e.slice(n,r),i=RI(s,o),a=Math.min(s.length-i,o.length-i),u=II(s,o,a),c={start:n+i,end:r-u,text:o.slice(i,o.length-u)};return c.start===c.end&&c.text.length===0?null:c}function BI(e,t,n){var r=Math.min(t.start,n.start),o=Math.max(0,Math.min(t.start+t.text.length,n.end)-n.start),s=Rv(e,t,n),i=Math.max(n.start+n.text.length,t.start+t.text.length+(t.start+t.text.length>n.start?n.text.length:0)-o),a=s.slice(r,i),u=Math.max(t.end,n.end-t.text.length+(t.end-t.start));return Iv(e,{start:r,end:u,text:a})}function FI(e){var{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}function _u(e,t){var{path:n,offset:r}=t;if(!E.hasPath(e,n))return null;var o=se.get(e,n);if(!pe.isText(o))return null;var s=E.above(e,{match:a=>ce.isElement(a)&&E.isBlock(e,a),at:n});if(!s)return null;for(;r>o.text.length;){var i=E.next(e,{at:n,match:pe.isText});if(!i||!B.isDescendant(i[1],s[1]))return null;r-=o.text.length,o=i[0],n=i[1]}return{path:n,offset:r}}function Hf(e,t){var n=_u(e,t.anchor);if(!n)return null;if($.isCollapsed(t))return{anchor:n,focus:n};var r=_u(e,t.focus);return r?{anchor:n,focus:r}:null}function ku(e,t,n){var r=It.get(e),o=r?.find(d=>{var{path:l}=d;return B.equals(l,t.path)});if(!o||t.offset<=o.diff.start)return Pe.transform(t,n,{affinity:"backward"});var{diff:s}=o;if(t.offset<=s.start+s.text.length){var i={path:t.path,offset:s.start},a=Pe.transform(i,n,{affinity:"backward"});return a?{path:a.path,offset:a.offset+t.offset-s.start}:null}var u={path:t.path,offset:t.offset-s.text.length+s.end-s.start},c=Pe.transform(u,n,{affinity:"backward"});return c?n.type==="split_node"&&B.equals(n.path,t.path)&&u.offset<n.position&&s.start<n.position?c:{path:c.path,offset:c.offset+s.text.length-s.end+s.start}:null}function Vf(e,t,n){var r=ku(e,t.anchor,n);if(!r)return null;if($.isCollapsed(t))return{anchor:r,focus:r};var o=ku(e,t.focus,n);return o?{anchor:r,focus:o}:null}function PI(e,t){var{path:n,diff:r,id:o}=e;switch(t.type){case"insert_text":return!B.equals(t.path,n)||t.offset>=r.end?e:t.offset<=r.start?{diff:{start:t.text.length+r.start,end:t.text.length+r.end,text:r.text},id:o,path:n}:{diff:{start:r.start,end:r.end+t.text.length,text:r.text},id:o,path:n};case"remove_text":return!B.equals(t.path,n)||t.offset>=r.end?e:t.offset+t.text.length<=r.start?{diff:{start:r.start-t.text.length,end:r.end-t.text.length,text:r.text},id:o,path:n}:{diff:{start:r.start,end:r.end-t.text.length,text:r.text},id:o,path:n};case"split_node":return!B.equals(t.path,n)||t.position>=r.end?{diff:r,id:o,path:B.transform(n,t,{affinity:"backward"})}:t.position>r.start?{diff:{start:r.start,end:Math.min(t.position,r.end),text:r.text},id:o,path:n}:{diff:{start:r.start-t.position,end:r.end-t.position,text:r.text},id:o,path:B.transform(n,t,{affinity:"forward"})};case"merge_node":return B.equals(t.path,n)?{diff:{start:r.start+t.position,end:r.end+t.position,text:r.text},id:o,path:B.transform(n,t)}:{diff:r,id:o,path:B.transform(n,t)}}var s=B.transform(n,t);return s?{diff:r,path:s,id:o}:null}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 qs(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){zt(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}var MI=25,_I=200,kI=function(){},NI=e=>e?.constructor.name==="DataTransfer";function jI(e){var{editor:t,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:r}=e,o=!1,s=null,i=null,a=null,u=0,c=!1,d=()=>{var N=Wn.get(t);if(Wn.delete(t),N){var{selection:_}=t,I=Hf(t,N);I&&(!_||!$.equals(I,_))&&W.select(t,I)}},l=()=>{var N=Vn.get(t);if(Vn.delete(t),!!N){if(N.at){var _=Pe.isPoint(N.at)?_u(t,N.at):Hf(t,N.at);if(!_)return;var I=E.range(t,_);(!t.selection||!$.equals(t.selection,I))&&W.select(t,_)}N.run()}},m=()=>{if(i&&(clearTimeout(i),i=null),a&&(clearTimeout(a),a=null),!y()&&!b()){d();return}o||(o=!0,setTimeout(()=>o=!1)),b()&&(o="action");var N=t.selection&&E.rangeRef(t,t.selection,{affinity:"forward"});Dn.set(t,t.marks),kI("flush",Vn.get(t),It.get(t));for(var _=y(),I;I=(j=It.get(t))===null||j===void 0?void 0:j[0];){var j,z,Y=tn.get(t);Y!==void 0&&(tn.delete(t),t.marks=Y),Y&&c===!1&&(c=null);var oe=FI(I);(!t.selection||!$.equals(t.selection,oe))&&W.select(t,oe),I.diff.text?E.insertText(t,I.diff.text):E.deleteFragment(t),It.set(t,(z=It.get(t))===null||z===void 0?void 0:z.filter(le=>{var{id:de}=le;return de!==I.id})),TI(t,I)||(_=!1,Vn.delete(t),Dn.delete(t),o="action",Wn.delete(t),n.cancel(),r.cancel(),N?.unref())}var G=N?.unref();if(G&&!Wn.get(t)&&(!t.selection||!$.equals(G,t.selection))&&W.select(t,G),b()){l();return}_&&n(),n.flush(),r.flush(),d();var Z=Dn.get(t);Dn.delete(t),Z!==void 0&&(t.marks=Z,t.onChange())},g=N=>{s&&clearTimeout(s),s=setTimeout(()=>{Cr.set(t,!1),m()},MI)},v=N=>{Cr.set(t,!0),s&&(clearTimeout(s),s=null)},C=function(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,I=Bu.get(t);if(I){if(y()||_){I.style.display="none";return}I.style.removeProperty("display")}},p=(N,_)=>{var I,j=(I=It.get(t))!==null&&I!==void 0?I:[];It.set(t,j);var z=se.leaf(t,N),Y=j.findIndex(Z=>B.equals(Z.path,N));if(Y<0){var oe=Iv(z.text,_);oe&&j.push({path:N,diff:_,id:u++}),C();return}var G=BI(z.text,j[Y].diff,_);if(!G){j.splice(Y,1),C();return}j[Y]=qs(qs({},j[Y]),{},{diff:G})},D=function(_){var{at:I}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};c=!1,Wn.delete(t),n.cancel(),r.cancel(),b()&&m(),Vn.set(t,{at:I,run:_}),a=setTimeout(m)},w=N=>{var _;if(i&&(clearTimeout(i),i=null),!so.get(t)){var{inputType:I}=N,j=null,z=N.dataTransfer||N.data||void 0;c!==!1&&I!=="insertText"&&I!=="insertCompositionText"&&(c=!1);var[Y]=N.getTargetRanges();Y&&(j=K.toSlateRange(t,Y,{exactMatch:!1,suppressThrow:!0}));var oe=K.getWindow(t),G=oe.getSelection();if(!j&&G&&(Y=G,j=K.toSlateRange(t,G,{exactMatch:!1,suppressThrow:!0})),j=(_=j)!==null&&_!==void 0?_:t.selection,!!j){var Z=!0;if(I.startsWith("delete")){if($.isExpanded(j)){var[le,de]=$.edges(j),ue=se.leaf(t,le.path);if(ue.text.length===le.offset&&de.offset===0){var ee=E.next(t,{at:le.path,match:pe.isText});ee&&B.equals(ee[1],de.path)&&(j={anchor:de,focus:de})}}var te=I.endsWith("Backward")?"backward":"forward",[R,q]=$.edges(j),[J,X]=E.leaf(t,R.path),ie={text:"",start:R.offset,end:q.offset},ae=It.get(t),we=ae?.find(Xe=>B.equals(Xe.path,X)),Se=we?[we.diff,ie]:[ie],me=Rv(J.text,...Se);if(me.length===0&&(Z=!1),$.isExpanded(j)){if(Z&&B.equals(j.anchor.path,j.focus.path)){var fe={path:j.anchor.path,offset:R.offset},ye=E.range(t,fe,fe);return S(ye),p(j.anchor.path,{text:"",end:q.offset,start:R.offset})}return D(()=>E.deleteFragment(t,{direction:te}),{at:j})}}switch(I){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return D(()=>E.deleteFragment(t),{at:j});case"deleteContent":case"deleteContentForward":{var{anchor:be}=j;if(Z&&$.isCollapsed(j)){var xe=se.leaf(t,be.path);if(be.offset<xe.text.length)return p(be.path,{text:"",start:be.offset,end:be.offset+1})}return D(()=>E.deleteForward(t),{at:j})}case"deleteContentBackward":{var ke,{anchor:Me}=j,O=Mu(Y)?Y.isCollapsed:!!((ke=Y)!==null&&ke!==void 0&&ke.collapsed);return Z&&O&&$.isCollapsed(j)&&Me.offset>0?p(Me.path,{text:"",start:Me.offset-1,end:Me.offset}):D(()=>E.deleteBackward(t),{at:j})}case"deleteEntireSoftLine":return D(()=>{E.deleteBackward(t,{unit:"line"}),E.deleteForward(t,{unit:"line"})},{at:j});case"deleteHardLineBackward":return D(()=>E.deleteBackward(t,{unit:"block"}),{at:j});case"deleteSoftLineBackward":return D(()=>E.deleteBackward(t,{unit:"line"}),{at:j});case"deleteHardLineForward":return D(()=>E.deleteForward(t,{unit:"block"}),{at:j});case"deleteSoftLineForward":return D(()=>E.deleteForward(t,{unit:"line"}),{at:j});case"deleteWordBackward":return D(()=>E.deleteBackward(t,{unit:"word"}),{at:j});case"deleteWordForward":return D(()=>E.deleteForward(t,{unit:"word"}),{at:j});case"insertLineBreak":return D(()=>E.insertSoftBreak(t),{at:j});case"insertParagraph":return D(()=>E.insertBreak(t),{at:j});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{if(NI(z))return D(()=>K.insertData(t,z),{at:j});var k=z??"";if(tn.get(t)&&(k=k.replace("\uFEFF","")),I==="insertText"&&/.*\n.*\n$/.test(k)&&(k=k.slice(0,-1)),k.includes(`
|
|
54
|
+
`))return D(()=>{var Xe=k.split(`
|
|
55
|
+
`);Xe.forEach((ht,Gt)=>{ht&&E.insertText(t,ht),Gt!==Xe.length-1&&E.insertSoftBreak(t)})},{at:j});if(B.equals(j.anchor.path,j.focus.path)){var[ne,re]=$.edges(j),he={start:ne.offset,end:re.offset,text:k};if(k&&c&&I==="insertCompositionText"){var Ie=c.start+c.text.search(/\S|$/),Fe=he.start+he.text.search(/\S|$/);Fe===Ie+1&&he.end===c.start+c.text.length?(he.start-=1,c=null,F()):c=!1}else I==="insertText"?c===null?c=he:c&&$.isCollapsed(j)&&c.end+c.text.length===ne.offset?c=qs(qs({},c),{},{text:c.text+k}):c=!1:c=!1;if(Z){p(ne.path,he);return}}return D(()=>E.insertText(t,k),{at:j})}}}}},b=()=>!!Vn.get(t),y=()=>{var N;return!!((N=It.get(t))!==null&&N!==void 0&&N.length)},A=()=>b()||y(),T=()=>o,S=N=>{Wn.set(t,N),i&&(clearTimeout(i),i=null);var{selection:_}=t;if(N){var I=!_||!B.equals(_.anchor.path,N.anchor.path),j=!_||!B.equals(_.anchor.path.slice(0,-1),N.anchor.path.slice(0,-1));(I&&c||j)&&(c=!1),(I||y())&&(i=setTimeout(m,_I))}},P=()=>{(b()||!y())&&m()},L=N=>{y()||(C(!0),setTimeout(C))},F=()=>{b()||(a=setTimeout(m))},M=N=>{if(!(y()||b())&&N.some(I=>al(t,I,N))){var _;(_=Dv.get(t))===null||_===void 0||_()}};return{flush:m,scheduleFlush:F,hasPendingDiffs:y,hasPendingAction:b,hasPendingChanges:A,isFlushing:T,handleUserSelect:S,handleCompositionEnd:g,handleCompositionStart:v,handleDOMBeforeInput:w,handleKeyDown:L,handleDomMutations:M,handleInput:P}}function LI(){var e=f.useRef(!1);return f.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e.current}var cs=ti?f.useLayoutEffect:f.useEffect;function UI(e,t,n){var[r]=f.useState(()=>new MutationObserver(t));cs(()=>{r.takeRecords()}),f.useEffect(()=>{if(!e.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");return r.observe(e.current,n),()=>r.disconnect()},[r,e,n])}var $I=["node"];function zf(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 HI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?zf(Object(n),!0).forEach(function(r){zt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zf(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var VI={subtree:!0,childList:!0,characterData:!0},WI=At?e=>{var{node:t}=e,n=vo(e,$I);if(!At)return null;var r=yn(),o=LI(),[s]=f.useState(()=>jI(HI({editor:r},n)));return UI(t,s.handleDomMutations,VI),sl.set(r,s.scheduleFlush),o&&s.flush(),s}:()=>null,zI=["anchor","focus"],KI=["anchor","focus"],GI=(e,t)=>Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>t.hasOwnProperty(n)&&e[n]===t[n]),Bv=(e,t)=>{var n=vo(e,zI),r=vo(t,KI);return e[Co]===t[Co]&&GI(n,r)},qI=(e,t)=>{if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],o=t[n];if(!$.equals(r,o)||!Bv(r,o))return!1}return!0},YI=(e,t)=>{if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],o=t[n];if(r.anchor.offset!==o.anchor.offset||r.focus.offset!==o.focus.offset||!Bv(r,o))return!1}return!0};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}function JI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Kf(Object(n),!0).forEach(function(r){zt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kf(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var ZI=e=>{var{isLast:t,leaf:n,parent:r,text:o}=e,s=yn(),i=K.findPath(s,o),a=B.parent(i),u=!!n[Av];return s.isVoid(r)?Re.createElement(Ja,{length:se.string(r).length}):n.text===""&&r.children[r.children.length-1]===o&&!s.isInline(r)&&E.string(s,a)===""?Re.createElement(Ja,{isLineBreak:!0,isMarkPlaceholder:u}):n.text===""?Re.createElement(Ja,{isMarkPlaceholder:u}):t&&n.text.slice(-1)===`
|
|
56
|
+
`?Re.createElement(Gf,{isTrailing:!0,text:n.text}):Re.createElement(Gf,{text:n.text})},Gf=e=>{var{text:t,isTrailing:n=!1}=e,r=f.useRef(null),o=()=>"".concat(t??"").concat(n?`
|
|
57
|
+
`:""),[s]=f.useState(o);return cs(()=>{var i=o();r.current&&r.current.textContent!==i&&(r.current.textContent=i)}),Re.createElement(XI,{ref:r},s)},XI=f.memo(f.forwardRef((e,t)=>Re.createElement("span",{"data-slate-string":!0,ref:t},e.children))),Ja=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),Re.createElement("span",JI({},o),!(At||yv)||!n?"\uFEFF":null,n?Re.createElement("br",null):null)};function qf(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 Fv(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?qf(Object(n),!0).forEach(function(r){zt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qf(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var QI=At?300:0;function e5(e,t){e.current&&(e.current.disconnect(),t&&(e.current=null))}function Yf(e){e.current&&(clearTimeout(e.current),e.current=null)}var t5=e=>{var{leaf:t,isLast:n,text:r,parent:o,renderPlaceholder:s,renderLeaf:i=w=>Re.createElement(r5,Fv({},w))}=e,a=yn(),u=f.useRef(null),c=f.useRef(null),[d,l]=f.useState(!1),m=f.useRef(null),g=f.useCallback(w=>{if(e5(u,w==null),w==null){var b;Bu.delete(a),(b=t.onPlaceholderResize)===null||b===void 0||b.call(t,null)}else{if(Bu.set(a,w),!u.current){var y=window.ResizeObserver||sI;u.current=new y(()=>{var A;(A=t.onPlaceholderResize)===null||A===void 0||A.call(t,w)})}u.current.observe(w),c.current=w}},[c,t,a]),v=Re.createElement(ZI,{isLast:n,leaf:t,parent:o,text:r}),C=!!t[Co];if(f.useEffect(()=>(C?m.current||(m.current=setTimeout(()=>{l(!0),m.current=null},QI)):(Yf(m),l(!1)),()=>Yf(m)),[C,l]),C&&d){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:g}};v=Re.createElement(Re.Fragment,null,s(p),v)}var D={"data-slate-leaf":!0};return i({attributes:D,children:v,leaf:t,text:r})},n5=Re.memo(t5,(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&pe.equals(t.leaf,e.leaf)&&t.leaf[Co]===e.leaf[Co]),r5=e=>{var{attributes:t,children:n}=e;return Re.createElement("span",Fv({},t),n)},o5=e=>{for(var{decorations:t,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:s,text:i}=e,a=yn(),u=f.useRef(null),c=pe.decorations(i,t),d=K.findKey(a,i),l=[],m=0;m<c.length;m++){var g=c[m];l.push(Re.createElement(n5,{isLast:n&&m===c.length-1,key:"".concat(d.id,"-").concat(m),renderPlaceholder:o,leaf:g,text:i,parent:r,renderLeaf:s}))}var v=f.useCallback(C=>{var p=Qi.get(a);C?(p?.set(d,C),Ar.set(i,C),us.set(C,i)):(p?.delete(d),Ar.delete(i),u.current&&us.delete(u.current)),u.current=C},[u,a,d,i]);return Re.createElement("span",{"data-slate-node":"text",ref:v},l)},Pv=Re.memo(o5,(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&YI(t.decorations,e.decorations));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 Nu(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){zt(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 s5=e=>{var{decorations:t,element:n,renderElement:r=w=>Re.createElement(a5,Nu({},w)),renderPlaceholder:o,renderLeaf:s,selection:i}=e,a=yn(),u=c5(),c=a.isInline(n),d=K.findKey(a,n),l=f.useCallback(w=>{var b=Qi.get(a);w?(b?.set(d,w),Ar.set(n,w),us.set(w,n)):(b?.delete(d),Ar.delete(n))},[a,d,n]),m=Nv({decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:s,selection:i}),g={"data-slate-node":"element",ref:l};if(c&&(g["data-slate-inline"]=!0),!c&&E.hasInlines(a,n)){var v=se.string(n),C=fv(v);C==="rtl"&&(g.dir=C)}if(E.isVoid(a,n)){g["data-slate-void"]=!0,!u&&c&&(g.contentEditable=!1);var p=c?"span":"div",[[D]]=se.texts(n);m=Re.createElement(p,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},Re.createElement(Pv,{renderPlaceholder:o,decorations:[],isLast:!1,parent:n,text:D})),rl.set(D,0),ol.set(D,n)}return r({attributes:g,children:m,element:n})},i5=Re.memo(s5,(e,t)=>e.element===t.element&&e.renderElement===t.renderElement&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&qI(e.decorations,t.decorations)&&(e.selection===t.selection||!!e.selection&&!!t.selection&&$.equals(e.selection,t.selection))),a5=e=>{var{attributes:t,children:n,element:r}=e,o=yn(),s=o.isInline(r)?"span":"div";return Re.createElement(s,Nu(Nu({},t),{},{style:{position:"relative"}}),n)},Mv=f.createContext(()=>[]),u5=()=>f.useContext(Mv),_v=f.createContext(!1),kv=()=>f.useContext(_v),Nv=e=>{var{decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:s,selection:i}=e,a=u5(),u=yn();so.set(u,!1);for(var c=K.findPath(u,n),d=[],l=ce.isElement(n)&&!u.isInline(n)&&E.hasInlines(u,n),m=0;m<n.children.length;m++){var g=c.concat(m),v=n.children[m],C=K.findKey(u,v),p=E.range(u,g),D=i&&$.intersection(p,i),w=a([v,g]);for(var b of t){var y=$.intersection(b,p);y&&w.push(y)}ce.isElement(v)?d.push(Re.createElement(_v.Provider,{key:"provider-".concat(C.id),value:!!D},Re.createElement(i5,{decorations:w,element:v,key:C.id,renderElement:r,renderPlaceholder:o,renderLeaf:s,selection:D}))):d.push(Re.createElement(Pv,{decorations:w,key:C.id,isLast:l&&m===n.children.length-1,parent:n,renderPlaceholder:o,renderLeaf:s,text:v})),rl.set(v,m),ol.set(v,n)}return d},jv=f.createContext(!1),c5=()=>f.useContext(jv),Lv=f.createContext(null),l5=()=>{var e=f.useContext(Lv);if(!e)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");var{editor:t}=e;return t};function d5(){var e=yn(),t=f.useRef(!1),n=f.useRef(0),r=f.useCallback(()=>{if(!t.current){t.current=!0;var o=K.getWindow(e);o.cancelAnimationFrame(n.current),n.current=o.requestAnimationFrame(()=>{t.current=!1})}},[e]);return f.useEffect(()=>()=>cancelAnimationFrame(n.current),[]),{receivedUserInput:t,onUserInput:r}}var f5=3,h5={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"},p5={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"},m5={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Ge=e=>{var t=h5[e],n=p5[e],r=m5[e],o=t&&Ga.isHotkey(t),s=n&&Ga.isHotkey(n),i=r&&Ga.isHotkey(r);return a=>!!(o&&o(a)||Uf&&s&&s(a)||!Uf&&i&&i(a))},Ye={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")},g5=(e,t)=>{var n=[],r=()=>{n=[]},o=i=>{if(t.current){var a=i.filter(u=>al(e,u,i));n.push(...a)}};function s(){n.length>0&&(n.reverse().forEach(i=>{i.type!=="characterData"&&(i.removedNodes.forEach(a=>{i.target.insertBefore(a,i.nextSibling)}),i.addedNodes.forEach(a=>{i.target.removeChild(a)}))}),r())}return{registerMutations:o,restoreDOM:s,clear:r}},v5={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class Uv extends f.Component{constructor(){super(...arguments),zt(this,"context",null),zt(this,"manager",null),zt(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,v5)}componentDidMount(){var{receivedUserInput:t}=this.props,n=this.context;this.manager=g5(n,t),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var t,n,r,o=(t=this.mutationObserver)===null||t===void 0?void 0:t.takeRecords();if(o!=null&&o.length){var s;(s=this.manager)===null||s===void 0||s.registerMutations(o)}return(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}}zt(Uv,"contextType",nl);var C5=At?Uv:e=>{var{children:t}=e;return Re.createElement(Re.Fragment,null,t)},E5=f.createContext(!1),y5=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderLeaf","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],b5=["text"];function Zf(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 un(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Zf(Object(n),!0).forEach(function(r){zt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zf(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var w5=e=>Re.createElement(Re.Fragment,null,Nv(e)),D5=f.forwardRef((e,t)=>{var n=f.useCallback(R=>Re.createElement(A5,un({},R)),[]),{autoFocus:r,decorate:o=S5,onDOMBeforeInput:s,placeholder:i,readOnly:a=!1,renderElement:u,renderLeaf:c,renderPlaceholder:d=n,scrollSelectionIntoView:l=x5,style:m={},as:g="div",disableDefaultStyles:v=!1}=e,C=vo(e,y5),p=l5(),[D,w]=f.useState(!1),b=f.useRef(null),y=f.useRef([]),[A,T]=f.useState(),S=f.useRef(!1),{onUserInput:P,receivedUserInput:L}=d5(),[,F]=f.useReducer(R=>R+1,0);Dv.set(p,F),Fu.set(p,a);var M=f.useMemo(()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}),[]);f.useEffect(()=>{b.current&&r&&b.current.focus()},[r]);var N=f.useRef(),_=f.useMemo(()=>GC(()=>{if(so.get(p)){_();return}var R=K.toDOMNode(p,p),q=R.getRootNode();if(!S.current&&dr&&q instanceof ShadowRoot){S.current=!0;var J=AI();J?document.execCommand("indent"):W.deselect(p),S.current=!1;return}var X=N.current;if((At||!K.isComposing(p))&&(!M.isUpdatingSelection||X!=null&&X.isFlushing())&&!M.isDraggingInternally){var ie=K.findDocumentOrShadowRoot(p),{activeElement:ae}=ie,we=K.toDOMNode(p,p),Se=Go(ie);if(ae===we?(M.latestElement=ae,qn.set(p,!0)):qn.delete(p),!Se)return W.deselect(p);var{anchorNode:me,focusNode:fe}=Se,ye=K.hasEditableTarget(p,me)||K.isTargetInsideNonReadonlyVoid(p,me),be=K.hasTarget(p,fe);if(ye&&be){var xe=K.toSlateRange(p,Se,{exactMatch:!1,suppressThrow:!0});xe&&(!K.isComposing(p)&&!(X!=null&&X.hasPendingChanges())&&!(X!=null&&X.isFlushing())?W.select(p,xe):X?.handleUserSelect(xe))}a&&(!ye||!be)&&W.deselect(p)}},100),[p,a,M]),I=f.useMemo(()=>qC(_,0),[_]);N.current=WI({node:b,onDOMSelectionChange:_,scheduleOnDOMSelectionChange:I}),cs(()=>{var R,q,J;b.current&&(J=il(b.current))?(wv.set(p,J),ni.set(p,b.current),Ar.set(p,b.current),us.set(b.current,p)):Ar.delete(p);var{selection:X}=p,ie=K.findDocumentOrShadowRoot(p),ae=Go(ie);if(!(!ae||!K.isFocused(p)||(R=N.current)!==null&&R!==void 0&&R.hasPendingAction())){var we=ye=>{var be=ae.type!=="None";if(!(!X&&!be)){var xe=ae.focusNode,ke;if(Xr&&ae.rangeCount>1){var Me=ae.getRangeAt(0),O=ae.getRangeAt(ae.rangeCount-1);Me.startContainer===xe?ke=O.endContainer:ke=Me.startContainer}else ke=ae.anchorNode;var k=ni.get(p),ne=!1;if(k.contains(ke)&&k.contains(xe)&&(ne=!0),be&&ne&&X&&!ye){var re=K.toSlateRange(p,ae,{exactMatch:!0,suppressThrow:!0});if(re&&$.equals(re,X)){var he;if(!M.hasMarkPlaceholder||(he=ke)!==null&&he!==void 0&&(he=he.parentElement)!==null&&he!==void 0&&he.hasAttribute("data-slate-mark-placeholder"))return}}if(X&&!K.hasRange(p,X)){p.selection=K.toSlateRange(p,ae,{exactMatch:!1,suppressThrow:!0});return}M.isUpdatingSelection=!0;var Ie=X&&K.toDOMRange(p,X);return Ie?(K.isComposing(p)&&!At?ae.collapseToEnd():$.isBackward(X)?ae.setBaseAndExtent(Ie.endContainer,Ie.endOffset,Ie.startContainer,Ie.startOffset):ae.setBaseAndExtent(Ie.startContainer,Ie.startOffset,Ie.endContainer,Ie.endOffset),l(p,Ie)):ae.removeAllRanges(),Ie}};ae.rangeCount<=1&&we();var Se=((q=N.current)===null||q===void 0?void 0:q.isFlushing())==="action";if(!At||!Se){setTimeout(()=>{M.isUpdatingSelection=!1});return}var me=null,fe=requestAnimationFrame(()=>{if(Se){var ye=be=>{try{var xe=K.toDOMNode(p,p);xe.focus(),we(be)}catch{}};ye(),me=setTimeout(()=>{ye(!0),M.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(fe),me&&clearTimeout(me)}}});var j=f.useCallback(R=>{var q=K.toDOMNode(p,p),J=q.getRootNode();if(S!=null&&S.current&&dr&&J instanceof ShadowRoot){var X=R.getTargetRanges(),ie=X[0],ae=new window.Range;ae.setStart(ie.startContainer,ie.startOffset),ae.setEnd(ie.endContainer,ie.endOffset);var we=K.toSlateRange(p,ae,{exactMatch:!1,suppressThrow:!1});W.select(p,we),R.preventDefault(),R.stopImmediatePropagation();return}if(P(),!a&&K.hasEditableTarget(p,R.target)&&!O5(R,s)){var Se;if(N.current)return N.current.handleDOMBeforeInput(R);I.flush(),_.flush();var{selection:me}=p,{inputType:fe}=R,ye=R.dataTransfer||R.data||void 0,be=fe==="insertCompositionText"||fe==="deleteCompositionText";if(be&&K.isComposing(p))return;var xe=!1;if(fe==="insertText"&&me&&$.isCollapsed(me)&&R.data&&R.data.length===1&&/[a-z ]/i.test(R.data)&&me.anchor.offset!==0&&(xe=!0,p.marks&&(xe=!1),!so.get(p))){var ke,Me,{anchor:O}=me,[k,ne]=K.toDOMPoint(p,O),re=(ke=k.parentElement)===null||ke===void 0?void 0:ke.closest("a"),he=K.getWindow(p);if(xe&&re&&K.hasDOMNode(p,re)){var Ie,Fe=he?.document.createTreeWalker(re,NodeFilter.SHOW_TEXT).lastChild();Fe===k&&((Ie=Fe.textContent)===null||Ie===void 0?void 0:Ie.length)===ne&&(xe=!1)}if(xe&&k.parentElement&&(he==null||(Me=he.getComputedStyle(k.parentElement))===null||Me===void 0?void 0:Me.whiteSpace)==="pre"){var Xe=E.above(p,{at:O.path,match:Ve=>ce.isElement(Ve)&&E.isBlock(p,Ve)});Xe&&se.string(Xe[0]).includes(" ")&&(xe=!1)}}if((!fe.startsWith("delete")||fe.startsWith("deleteBy"))&&!so.get(p)){var[ht]=R.getTargetRanges();if(ht){var Gt=K.toSlateRange(p,ht,{exactMatch:!1,suppressThrow:!1});if(!me||!$.equals(me,Gt)){xe=!1;var He=!be&&p.selection&&E.rangeRef(p,p.selection);W.select(p,Gt),He&&Ko.set(p,He)}}}if(be)return;if(xe||R.preventDefault(),me&&$.isExpanded(me)&&fe.startsWith("delete")){var pt=fe.endsWith("Backward")?"backward":"forward";E.deleteFragment(p,{direction:pt});return}switch(fe){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":{E.deleteFragment(p);break}case"deleteContent":case"deleteContentForward":{E.deleteForward(p);break}case"deleteContentBackward":{E.deleteBackward(p);break}case"deleteEntireSoftLine":{E.deleteBackward(p,{unit:"line"}),E.deleteForward(p,{unit:"line"});break}case"deleteHardLineBackward":{E.deleteBackward(p,{unit:"block"});break}case"deleteSoftLineBackward":{E.deleteBackward(p,{unit:"line"});break}case"deleteHardLineForward":{E.deleteForward(p,{unit:"block"});break}case"deleteSoftLineForward":{E.deleteForward(p,{unit:"line"});break}case"deleteWordBackward":{E.deleteBackward(p,{unit:"word"});break}case"deleteWordForward":{E.deleteForward(p,{unit:"word"});break}case"insertLineBreak":E.insertSoftBreak(p);break;case"insertParagraph":{E.insertBreak(p);break}case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{fe==="insertFromComposition"&&K.isComposing(p)&&(w(!1),Cr.set(p,!1)),ye?.constructor.name==="DataTransfer"?K.insertData(p,ye):typeof ye=="string"&&(xe?y.current.push(()=>E.insertText(p,ye)):E.insertText(p,ye));break}}var mt=(Se=Ko.get(p))===null||Se===void 0?void 0:Se.unref();Ko.delete(p),mt&&(!p.selection||!$.equals(p.selection,mt))&&W.select(p,mt)}},[p,_,P,s,a,I]),z=f.useCallback(R=>{R==null?(_.cancel(),I.cancel(),ni.delete(p),Ar.delete(p),b.current&&Ln&&b.current.removeEventListener("beforeinput",j)):Ln&&R.addEventListener("beforeinput",j),b.current=R,typeof t=="function"?t(R):t&&(t.current=R)},[_,I,p,j,t]);cs(()=>{var R=K.getWindow(p);R.document.addEventListener("selectionchange",I);var q=()=>{M.isDraggingInternally=!1};return R.document.addEventListener("dragend",q),R.document.addEventListener("drop",q),()=>{R.document.removeEventListener("selectionchange",I),R.document.removeEventListener("dragend",q),R.document.removeEventListener("drop",q)}},[I,M]);var Y=o([p,[]]),oe=i&&p.children.length===1&&Array.from(se.texts(p)).length===1&&se.string(p)===""&&!D,G=f.useCallback(R=>{if(R&&oe){var q;T((q=R.getBoundingClientRect())===null||q===void 0?void 0:q.height)}else T(void 0)},[oe]);if(oe){var Z=E.start(p,[]);Y.push({[Co]:!0,placeholder:i,onPlaceholderResize:G,anchor:Z,focus:Z})}var{marks:le}=p;if(M.hasMarkPlaceholder=!1,p.selection&&$.isCollapsed(p.selection)&&le){var{anchor:de}=p.selection,ue=se.leaf(p,de.path),ee=vo(ue,b5);if(!pe.equals(ue,le,{loose:!0})){M.hasMarkPlaceholder=!0;var te=Object.fromEntries(Object.keys(ee).map(R=>[R,null]));Y.push(un(un(un({[Av]:!0},te),le),{},{anchor:de,focus:de}))}}return f.useEffect(()=>{setTimeout(()=>{var{selection:R}=p;if(R){var{anchor:q}=R,J=se.leaf(p,q.path);if(le&&!pe.equals(J,le,{loose:!0})){tn.set(p,le);return}}tn.delete(p)})}),Re.createElement(jv.Provider,{value:a},Re.createElement(E5.Provider,{value:D},Re.createElement(Mv.Provider,{value:o},Re.createElement(C5,{node:b,receivedUserInput:L},Re.createElement(g,un(un({role:a?void 0:"textbox","aria-multiline":a?void 0:!0},C),{},{spellCheck:Ln||!ti?C.spellCheck:!1,autoCorrect:Ln||!ti?C.autoCorrect:"false",autoCapitalize:Ln||!ti?C.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:z,style:un(un({},v?{}:un({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},A?{minHeight:A}:{})),m),onBeforeInput:f.useCallback(R=>{if(!Ln&&!a&&!wt(R,C.onBeforeInput)&&K.hasSelectableTarget(p,R.target)&&(R.preventDefault(),!K.isComposing(p))){var q=R.data;E.insertText(p,q)}},[C.onBeforeInput,p,a]),onInput:f.useCallback(R=>{if(!wt(R,C.onInput)){if(N.current){N.current.handleInput();return}for(var q of y.current)q();if(y.current=[],!K.isFocused(p)){var J=R.nativeEvent,X=p;if(J.inputType==="historyUndo"&&typeof X.undo=="function"){X.undo();return}if(J.inputType==="historyRedo"&&typeof X.redo=="function"){X.redo();return}}}},[C.onInput,p]),onBlur:f.useCallback(R=>{if(!(a||M.isUpdatingSelection||!K.hasSelectableTarget(p,R.target)||wt(R,C.onBlur))){var q=K.findDocumentOrShadowRoot(p);if(M.latestElement!==q.activeElement){var{relatedTarget:J}=R,X=K.toDOMNode(p,p);if(J!==X&&!(Ht(J)&&J.hasAttribute("data-slate-spacer"))){if(J!=null&&tr(J)&&K.hasDOMNode(p,J)){var ie=K.toSlateNode(p,J);if(ce.isElement(ie)&&!p.isVoid(ie))return}if(dr){var ae=Go(q);ae?.removeAllRanges()}qn.delete(p)}}}},[a,M.isUpdatingSelection,M.latestElement,p,C.onBlur]),onClick:f.useCallback(R=>{if(K.hasTarget(p,R.target)&&!wt(R,C.onClick)&&tr(R.target)){var q=K.toSlateNode(p,R.target),J=K.findPath(p,q);if(!E.hasPath(p,J)||se.get(p,J)!==q)return;if(R.detail===f5&&J.length>=1){var X=J;if(!(ce.isElement(q)&&E.isBlock(p,q))){var ie,ae=E.above(p,{match:xe=>ce.isElement(xe)&&E.isBlock(p,xe),at:J});X=(ie=ae?.[1])!==null&&ie!==void 0?ie:J.slice(0,1)}var we=E.range(p,X);W.select(p,we);return}if(a)return;var Se=E.start(p,J),me=E.end(p,J),fe=E.void(p,{at:Se}),ye=E.void(p,{at:me});if(fe&&ye&&B.equals(fe[1],ye[1])){var be=E.range(p,Se);W.select(p,be)}}},[p,C.onClick,a]),onCompositionEnd:f.useCallback(R=>{if(K.hasSelectableTarget(p,R.target)){var q;if(K.isComposing(p)&&Promise.resolve().then(()=>{w(!1),Cr.set(p,!1)}),(q=N.current)===null||q===void 0||q.handleCompositionEnd(R),wt(R,C.onCompositionEnd)||At)return;if(!dr&&!hI&&!yv&&!mI&&!pI&&R.data){var J=tn.get(p);tn.delete(p),J!==void 0&&(Dn.set(p,p.marks),p.marks=J),E.insertText(p,R.data);var X=Dn.get(p);Dn.delete(p),X!==void 0&&(p.marks=X)}}},[C.onCompositionEnd,p]),onCompositionUpdate:f.useCallback(R=>{K.hasSelectableTarget(p,R.target)&&!wt(R,C.onCompositionUpdate)&&(K.isComposing(p)||(w(!0),Cr.set(p,!0)))},[C.onCompositionUpdate,p]),onCompositionStart:f.useCallback(R=>{if(K.hasSelectableTarget(p,R.target)){var q;if((q=N.current)===null||q===void 0||q.handleCompositionStart(R),wt(R,C.onCompositionStart)||At)return;w(!0);var{selection:J}=p;if(J&&$.isExpanded(J)){E.deleteFragment(p);return}}},[C.onCompositionStart,p]),onCopy:f.useCallback(R=>{K.hasSelectableTarget(p,R.target)&&!wt(R,C.onCopy)&&!Xf(R)&&(R.preventDefault(),K.setFragmentData(p,R.clipboardData,"copy"))},[C.onCopy,p]),onCut:f.useCallback(R=>{if(!a&&K.hasSelectableTarget(p,R.target)&&!wt(R,C.onCut)&&!Xf(R)){R.preventDefault(),K.setFragmentData(p,R.clipboardData,"cut");var{selection:q}=p;if(q)if($.isExpanded(q))E.deleteFragment(p);else{var J=se.parent(p,q.anchor.path);E.isVoid(p,J)&&W.delete(p)}}},[a,p,C.onCut]),onDragOver:f.useCallback(R=>{if(K.hasTarget(p,R.target)&&!wt(R,C.onDragOver)){var q=K.toSlateNode(p,R.target);ce.isElement(q)&&E.isVoid(p,q)&&R.preventDefault()}},[C.onDragOver,p]),onDragStart:f.useCallback(R=>{if(!a&&K.hasTarget(p,R.target)&&!wt(R,C.onDragStart)){var q=K.toSlateNode(p,R.target),J=K.findPath(p,q),X=ce.isElement(q)&&E.isVoid(p,q)||E.void(p,{at:J,voids:!0});if(X){var ie=E.range(p,J);W.select(p,ie)}M.isDraggingInternally=!0,K.setFragmentData(p,R.dataTransfer,"drag")}},[a,p,C.onDragStart,M]),onDrop:f.useCallback(R=>{if(!a&&K.hasTarget(p,R.target)&&!wt(R,C.onDrop)){R.preventDefault();var q=p.selection,J=K.findEventRange(p,R),X=R.dataTransfer;W.select(p,J),M.isDraggingInternally&&q&&!$.equals(q,J)&&!E.void(p,{at:J,voids:!0})&&W.delete(p,{at:q}),K.insertData(p,X),K.isFocused(p)||K.focus(p)}},[a,p,C.onDrop,M]),onDragEnd:f.useCallback(R=>{!a&&M.isDraggingInternally&&C.onDragEnd&&K.hasTarget(p,R.target)&&C.onDragEnd(R)},[a,M,C,p]),onFocus:f.useCallback(R=>{if(!a&&!M.isUpdatingSelection&&K.hasEditableTarget(p,R.target)&&!wt(R,C.onFocus)){var q=K.toDOMNode(p,p),J=K.findDocumentOrShadowRoot(p);if(M.latestElement=J.activeElement,Xr&&R.target!==q){q.focus();return}qn.set(p,!0)}},[a,M,p,C.onFocus]),onKeyDown:f.useCallback(R=>{if(!a&&K.hasEditableTarget(p,R.target)){var q;(q=N.current)===null||q===void 0||q.handleKeyDown(R);var{nativeEvent:J}=R;if(K.isComposing(p)&&J.isComposing===!1&&(Cr.set(p,!1),w(!1)),wt(R,C.onKeyDown)||K.isComposing(p))return;var{selection:X}=p,ie=p.children[X!==null?X.focus.path[0]:0],ae=fv(se.string(ie))==="rtl";if(Ye.isRedo(J)){R.preventDefault();var we=p;typeof we.redo=="function"&&we.redo();return}if(Ye.isUndo(J)){R.preventDefault();var Se=p;typeof Se.undo=="function"&&Se.undo();return}if(Ye.isMoveLineBackward(J)){R.preventDefault(),W.move(p,{unit:"line",reverse:!0});return}if(Ye.isMoveLineForward(J)){R.preventDefault(),W.move(p,{unit:"line"});return}if(Ye.isExtendLineBackward(J)){R.preventDefault(),W.move(p,{unit:"line",edge:"focus",reverse:!0});return}if(Ye.isExtendLineForward(J)){R.preventDefault(),W.move(p,{unit:"line",edge:"focus"});return}if(Ye.isMoveBackward(J)){R.preventDefault(),X&&$.isCollapsed(X)?W.move(p,{reverse:!ae}):W.collapse(p,{edge:ae?"end":"start"});return}if(Ye.isMoveForward(J)){R.preventDefault(),X&&$.isCollapsed(X)?W.move(p,{reverse:ae}):W.collapse(p,{edge:ae?"start":"end"});return}if(Ye.isMoveWordBackward(J)){R.preventDefault(),X&&$.isExpanded(X)&&W.collapse(p,{edge:"focus"}),W.move(p,{unit:"word",reverse:!ae});return}if(Ye.isMoveWordForward(J)){R.preventDefault(),X&&$.isExpanded(X)&&W.collapse(p,{edge:"focus"}),W.move(p,{unit:"word",reverse:ae});return}if(Ln){if((bv||dr)&&X&&(Ye.isDeleteBackward(J)||Ye.isDeleteForward(J))&&$.isCollapsed(X)){var me=se.parent(p,X.anchor.path);if(ce.isElement(me)&&E.isVoid(p,me)&&(E.isInline(p,me)||E.isBlock(p,me))){R.preventDefault(),E.deleteBackward(p,{unit:"block"});return}}}else{if(Ye.isBold(J)||Ye.isItalic(J)||Ye.isTransposeCharacter(J)){R.preventDefault();return}if(Ye.isSoftBreak(J)){R.preventDefault(),E.insertSoftBreak(p);return}if(Ye.isSplitBlock(J)){R.preventDefault(),E.insertBreak(p);return}if(Ye.isDeleteBackward(J)){R.preventDefault(),X&&$.isExpanded(X)?E.deleteFragment(p,{direction:"backward"}):E.deleteBackward(p);return}if(Ye.isDeleteForward(J)){R.preventDefault(),X&&$.isExpanded(X)?E.deleteFragment(p,{direction:"forward"}):E.deleteForward(p);return}if(Ye.isDeleteLineBackward(J)){R.preventDefault(),X&&$.isExpanded(X)?E.deleteFragment(p,{direction:"backward"}):E.deleteBackward(p,{unit:"line"});return}if(Ye.isDeleteLineForward(J)){R.preventDefault(),X&&$.isExpanded(X)?E.deleteFragment(p,{direction:"forward"}):E.deleteForward(p,{unit:"line"});return}if(Ye.isDeleteWordBackward(J)){R.preventDefault(),X&&$.isExpanded(X)?E.deleteFragment(p,{direction:"backward"}):E.deleteBackward(p,{unit:"word"});return}if(Ye.isDeleteWordForward(J)){R.preventDefault(),X&&$.isExpanded(X)?E.deleteFragment(p,{direction:"forward"}):E.deleteForward(p,{unit:"word"});return}}}},[a,p,C.onKeyDown]),onPaste:f.useCallback(R=>{!a&&K.hasEditableTarget(p,R.target)&&!wt(R,C.onPaste)&&(!Ln||CI(R.nativeEvent)||dr)&&(R.preventDefault(),K.insertData(p,R.clipboardData))},[a,p,C.onPaste])}),Re.createElement(w5,{decorations:Y,node:p,renderElement:u,renderPlaceholder:d,renderLeaf:c,selection:p.selection}))))))}),A5=e=>{var{attributes:t,children:n}=e;return Re.createElement("span",un({},t),n,At&&Re.createElement("br",null))},S5=()=>[],x5=(e,t)=>{if(t.getBoundingClientRect&&(!e.selection||e.selection&&$.isCollapsed(e.selection))){var n=t.startContainer.parentElement;n.getBoundingClientRect=t.getBoundingClientRect.bind(t),jR(n,{scrollMode:"if-needed"}),delete n.getBoundingClientRect}},wt=(e,t)=>{if(!t)return!1;var n=t(e);return n??(e.isDefaultPrevented()||e.isPropagationStopped())},Xf=e=>tr(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement),O5=(e,t)=>{if(!t)return!1;var n=t(e);return n??e.defaultPrevented},T5=f.createContext(!1),R5=f.createContext({});function I5(e){var t=f.useRef([]).current,n=f.useRef({editor:e}).current,r=f.useCallback(s=>{n.editor=s,t.forEach(i=>i(s))},[t,n]),o=f.useMemo(()=>({getSlate:()=>n.editor,addEventListener:s=>(t.push(s),()=>{t.splice(t.indexOf(s),1)})}),[t,n]);return{selectorContext:o,onChange:r}}var B5=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],F5=e=>{var{editor:t,children:n,onChange:r,onSelectionChange:o,onValueChange:s,initialValue:i}=e,a=vo(e,B5),[u,c]=Re.useState(()=>{if(!se.isNodeList(i))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(ct.stringify(i)));if(!E.isEditor(t))throw new Error("[Slate] editor is invalid! You passed: ".concat(ct.stringify(t)));return t.children=i,Object.assign(t,a),{v:0,editor:t}}),{selectorContext:d,onChange:l}=I5(t),m=f.useCallback(C=>{var p;r&&r(t.children),(C==null||(p=C.operation)===null||p===void 0?void 0:p.type)==="set_selection"?o?.(t.selection):s?.(t.children),c(D=>({v:D.v+1,editor:t})),l(t)},[t,l,r,o,s]);f.useEffect(()=>(Pu.set(t,m),()=>{Pu.set(t,()=>{})}),[t,m]);var[g,v]=f.useState(K.isFocused(t));return f.useEffect(()=>{v(K.isFocused(t))},[t]),cs(()=>{var C=()=>v(K.isFocused(t));return Ev>=17?(document.addEventListener("focusin",C),document.addEventListener("focusout",C),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",C)}):(document.addEventListener("focus",C,!0),document.addEventListener("blur",C,!0),()=>{document.removeEventListener("focus",C,!0),document.removeEventListener("blur",C,!0)})},[]),Re.createElement(R5.Provider,{value:d},Re.createElement(Lv.Provider,{value:u},Re.createElement(nl.Provider,{value:u.editor},Re.createElement(T5.Provider,{value:g},n))))},Qf=(e,t)=>{var n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n},eh=(e,t,n)=>{var r=K.toDOMRange(e,t).getBoundingClientRect(),o=K.toDOMRange(e,n).getBoundingClientRect();return Qf(r,o)&&Qf(o,r)},P5=(e,t)=>{var n=E.range(e,$.end(t)),r=Array.from(E.positions(e,{at:t})),o=0,s=r.length,i=Math.floor(s/2);if(eh(e,E.range(e,r[o]),n))return E.range(e,r[o],n);if(r.length<2)return E.range(e,r[r.length-1],n);for(;i!==r.length&&i!==o;)eh(e,E.range(e,r[i]),n)?s=i:o=i,i=Math.floor((o+s)/2);return E.range(e,r[s],n)};function th(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 nh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?th(Object(n),!0).forEach(function(r){zt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):th(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var M5=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",r=t,{apply:o,onChange:s,deleteBackward:i,addMark:a,removeMark:u}=r;return Qi.set(r,new WeakMap),r.addMark=(c,d)=>{var l,m;(l=sl.get(r))===null||l===void 0||l(),!tn.get(r)&&(m=It.get(r))!==null&&m!==void 0&&m.length&&tn.set(r,null),Dn.delete(r),a(c,d)},r.removeMark=c=>{var d;!tn.get(r)&&(d=It.get(r))!==null&&d!==void 0&&d.length&&tn.set(r,null),Dn.delete(r),u(c)},r.deleteBackward=c=>{if(c!=="line")return i(c);if(r.selection&&$.isCollapsed(r.selection)){var d=E.above(r,{match:v=>ce.isElement(v)&&E.isBlock(r,v),at:r.selection});if(d){var[,l]=d,m=E.range(r,l,r.selection.anchor),g=P5(r,m);$.isCollapsed(g)||W.delete(r,{at:g})}}},r.apply=c=>{var d=[],l=[],m=It.get(r);if(m!=null&&m.length){var g=m.map(I=>PI(I,c)).filter(Boolean);It.set(r,g)}var v=Wn.get(r);v&&Wn.set(r,Vf(r,v,c));var C=Vn.get(r);if(C!=null&&C.at){var p=Pe.isPoint(C?.at)?ku(r,C.at,c):Vf(r,C.at,c);Vn.set(r,p?nh(nh({},C),{},{at:p}):null)}switch(c.type){case"insert_text":case"remove_text":case"set_node":case"split_node":{d.push(...zr(r,c.path));break}case"set_selection":{var D;(D=Ko.get(r))===null||D===void 0||D.unref(),Ko.delete(r);break}case"insert_node":case"remove_node":{d.push(...zr(r,B.parent(c.path)));break}case"merge_node":{var w=B.previous(c.path);d.push(...zr(r,w));break}case"move_node":{var b=B.common(B.parent(c.path),B.parent(c.newPath));d.push(...zr(r,b));var y;B.isBefore(c.path,c.newPath)?(d.push(...zr(r,B.parent(c.path))),y=c.newPath):(d.push(...zr(r,B.parent(c.newPath))),y=c.path);var A=se.get(t,B.parent(y)),T=K.findKey(r,A),S=E.pathRef(r,B.parent(y));l.push([S,T]);break}}switch(o(c),c.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":so.set(r,!0)}for(var[P,L]of d){var[F]=E.node(r,P);bi.set(F,L)}for(var[M,N]of l){if(M.current){var[_]=E.node(r,M.current);bi.set(_,N)}M.unref()}},r.setFragmentData=c=>{var{selection:d}=r;if(d){var[l,m]=$.edges(d),g=E.void(r,{at:l.path}),v=E.void(r,{at:m.path});if(!($.isCollapsed(d)&&!g)){var C=K.toDOMRange(r,d),p=C.cloneContents(),D=p.childNodes[0];if(p.childNodes.forEach(F=>{F.textContent&&F.textContent.trim()!==""&&(D=F)}),v){var[w]=v,b=C.cloneRange(),y=K.toDOMNode(r,w);b.setEndAfter(y),p=b.cloneContents()}if(g&&(D=p.querySelector("[data-slate-spacer]")),Array.from(p.querySelectorAll("[data-slate-zero-width]")).forEach(F=>{var M=F.getAttribute("data-slate-zero-width")==="n";F.textContent=M?`
|
|
58
|
+
`:""}),xv(D)){var A=D.ownerDocument.createElement("span");A.style.whiteSpace="pre",A.appendChild(D),p.appendChild(A),D=A}var T=r.getFragment(),S=JSON.stringify(T),P=window.btoa(encodeURIComponent(S));D.setAttribute("data-slate-fragment",P),c.setData("application/".concat(n),P);var L=p.ownerDocument.createElement("div");return L.appendChild(p),L.setAttribute("hidden","true"),p.ownerDocument.body.appendChild(L),c.setData("text/html",L.innerHTML),c.setData("text/plain",Tv(L)),p.ownerDocument.body.removeChild(L),c}}},r.insertData=c=>{r.insertFragmentData(c)||r.insertTextData(c)},r.insertFragmentData=c=>{var d=c.getData("application/".concat(n))||DI(c);if(d){var l=decodeURIComponent(window.atob(d)),m=JSON.parse(l);return r.insertFragment(m),!0}return!1},r.insertTextData=c=>{var d=c.getData("text/plain");if(d){var l=d.split(/\r\n|\r|\n/),m=!1;for(var g of l)m&&W.splitNodes(r,{always:!0}),r.insertText(g),m=!0;return!0}return!1},r.onChange=c=>{var d=Ev<18?KC.unstable_batchedUpdates:l=>l();d(()=>{var l=Pu.get(r);l&&l(c),s(c)})},r},zr=(e,t)=>{var n=[];for(var[r,o]of E.levels(e,{at:t})){var s=K.findKey(e,r);n.push([o,s])}return n};function _5(e,t){if(typeof e.requestSubmit=="function")return e.requestSubmit(t);t?t.click():(t=document.createElement("input"),t.type="submit",t.hidden=!0,e.appendChild(t),t.click(),e.removeChild(t))}function k5(e){const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r,o]=n;if(ce.isElement(r)&&r.type==="paragraph"){for(const[s,i]of se.children(e,o))if(ce.isElement(s)&&!e.isInline(s)){W.unwrapNodes(e,{at:i});return}}t(n)},e}const N5=3;function ul(e,t,n=N5){if(!(n<=0))try{return K.toDOMRange(e,t)}catch{return ul(e,{anchor:t.anchor,focus:t.anchor},n-1)}}function Eo(e){return!e.trim()}function En(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function ju(e){return En(e)&&Object.keys(e).length===1}function Lu(e,t){for(const n of t)if(En(n)){if(!Eo(n.text))return!1}else if(n.type==="paragraph"){if(n.children.length>1||n.children[0]&&!(En(n.children[0])&&Eo(n.children[0].text)))return!1}else if(!E.isEmpty(e,n))return!1;return!0}function j5(e,t,n){const[r,o]=f.useState(e),s=t!==void 0,i=f.useRef(s);f.useEffect(()=>{i.current=s},[s]);const a=s?t:r,u=f.useCallback(c=>(s||o(c),n?.(c)),[s,n]);return[a,u]}let ri;const Uu=new WeakMap,$u=new WeakMap;function L5(e,t,n){if(!n)ri||(ri=new IntersectionObserver(r=>{for(const o of r)Uu.get(o.target)?.(o)})),Uu.set(e,t),ri.observe(e);else{const r=new IntersectionObserver(o=>{for(const s of o)t?.(s)},{root:n.root?.current,rootMargin:typeof n.rootMargin=="number"?`${n.rootMargin}px`:n.rootMargin,threshold:n.threshold});$u.set(e,r),r.observe(e)}}function rh(e,t){t?($u.get(e)?.unobserve(e),$u.delete(e)):(Uu.delete(e),ri?.unobserve(e))}function U5(e,t,n){const r=n?.enabled??!0,o=Bi(t),{root:s,rootMargin:i,threshold:a}=n??{};f.useEffect(()=>{const u=e.current;if(!u)return;const c={root:s,rootMargin:i,threshold:a};return r?L5(u,d=>{o.current(d.isIntersecting,d)},c):rh(u,c),()=>{rh(u,c)}},[e,r,o,s,i,a])}const cl=f.forwardRef(({children:e,asChild:t,...n},r)=>{const o=t?ot:"span";return h.jsx(o,{...n,ref:r,children:e})}),$v=f.forwardRef(({children:e,asChild:t,...n},r)=>{const o=t?ot:"a";return h.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})}),$5={Mention:({mention:e})=>h.jsxs(cl,{children:[mn,e.id]}),Link:({href:e,children:t})=>h.jsx($v,{href:e,children:t})},Hv=f.forwardRef(({body:e,components:t,style:n,asChild:r,...o},s)=>{const i=r?ot:"div",{Mention:a,Link:u}=f.useMemo(()=>({...$5,...t}),[t]);return!e||!e?.content?null:h.jsx(i,{...o,style:{whiteSpace:"break-spaces",...n},ref:s,children:e.content.map((c,d)=>c.type==="paragraph"?h.jsx("p",{style:{minHeight:"1lh"},children:c.children.map((l,m)=>{if(uc(l)){const{type:v,...C}=l;return C.id?h.jsx(a,{mention:C},m):null}if(cc(l)){const v=ec(l.url);return v===null?h.jsx("span",{children:l.text??l.url},m):h.jsx(u,{href:v,children:l.text??l.url},m)}let g=l.text;return l.bold&&(g=h.jsx("strong",{children:g},m)),l.italic&&(g=h.jsx("em",{children:g},m)),l.strikethrough&&(g=h.jsx("s",{children:g},m)),l.code&&(g=h.jsx("code",{children:g},m)),h.jsx("span",{children:g},m)})},d):null)})}),H5={alt:()=>"altKey",ctrl:()=>"ctrlKey",meta:()=>"metaKey",mod:()=>Wg()?"metaKey":"ctrlKey",shift:()=>"shiftKey"};function Dt(e,t,n={}){return e.key!==t?!1:Object.entries(n).filter(([,o])=>typeof o=="boolean").every(([o,s])=>{const i=H5[o]();return e[i]===s})}const Vv=f.createContext(null);function ll(){const e=f.useContext(Vv);return ge(e,"Persist is missing from the React tree.")}function V5(e){const t=Array.isArray(e)?f.Children.only(e):e;return f.isValidElement(t)?t:void 0}function Wv(e){const[t,n]=ll(),r=f.useRef(null),o=f.useRef(null);gn(()=>{const s=e.current;if(!s)return;const i=a=>{a.animationName===o.current&&n(),r.current=a.animationName};return s.addEventListener("animationcancel",i),s.addEventListener("animationend",i),()=>{s.removeEventListener("animationcancel",i),s.removeEventListener("animationend",i)}},[e,n]),gn(()=>{const s=e.current;let i;if(s)return t||(i=requestAnimationFrame(()=>{const a=getComputedStyle(s);o.current=a.animationName,(a.animationName==="none"||a.animationName===r.current||a.display==="none")&&n()})),()=>{cancelAnimationFrame(i)}},[t,e,n])}function zv({children:e}){const[t,n]=f.useState(!0),r=f.useRef(null),o=V5(e),s=f.useCallback(()=>{hs.flushSync(()=>n(!1))},[]);return gn(()=>{o&&(n(!0),r.current=o)},[o]),h.jsx(Vv.Provider,{value:[!!o,s],children:o??(t?r.current:null)})}function oh(e,t,n){return Math.min(Math.max(e,t),n)}function W5(e,t,n){const r=n-t;return r>0?((e-t)%r+r)%r+t:0}const z5={wrap:!0};function K5(e,t,n){const{wrap:r}=f.useMemo(()=>({...z5,...n}),[n]),o=f.useMemo(()=>r?W5:oh,[r]),[s,i]=f.useState(e);f.useEffect(()=>{i(c=>oh(c,0,Math.max(t-1,0)))},[t]);const a=f.useCallback(()=>{i(c=>o(c-1,0,Math.max(t,0)))},[t,o]),u=f.useCallback(()=>{i(c=>o(c+1,0,Math.max(t,0)))},[t,o]);return[s,a,u,i]}function dl(e,t){const n=Bi(t);f.useEffect(()=>e.subscribe(()=>n.current()),[e,n])}function G5(){const e=_e();return f.useCallback(t=>{e[Ce].usersStore.enqueue(t)},[e])}function ls(e,t,n={}){const{filterVoids:r}=n,o=E.before(e,t,{unit:"character",voids:r});if(o){const s=E.range(e,o,$.isRange(t)?$.start(t):t),i=E.string(e,s);return{range:s,text:i,void:i.length===0}}}function fl(e,t,n={}){const{filterVoids:r}=n,o=E.after(e,t,{unit:"character",voids:r});if(o){const s=E.range(e,o,$.isRange(t)?$.end(t):t),i=E.string(e,s);return{range:s,text:i,void:i.length===0}}}const sh={bold:!1,italic:!1,strikethrough:!1,code:!1};function ih(e){if(!e)return{...sh};const t=E.marks(e);return{...sh,...t}}function q5(e,t){const n=E.marks(e);return n?n[t]===!0:!1}function Kv(e){return Object.keys(e??{}).filter(t=>t!=="text")}function No(e,t){q5(e,t)?E.removeMark(e,t):E.addMark(e,t,!0)}function Gv(e){const t=E.marks(e);if(t)for(const n in t)E.removeMark(e,n)}function ah(e,t){e.selection&&$.isCollapsed(e.selection)&&Object.keys(E.marks(e)??{}).length>0&&((t==="start"?ls(e,e.selection):fl(e,e.selection))||Gv(e))}function Y5(e){const{onChange:t}=e;return e.onChange=n=>{Lu(e,e.children)&&Gv(e),t(n)},e}const qv=f.createContext(null),Yv=f.createContext(null),Jv=f.createContext(null),Zv=f.createContext(null),Xv=f.createContext(null);function ea(){const e=f.useContext(Yv);return ge(e,"Composer.Form is missing from the React tree.")}function Qv(){return f.useContext(Jv)}function hl(){const e=Qv();return ge(e,"Composer.Form is missing from the React tree.")}function pl(e="useComposerSuggestionsContext"){const t=f.useContext(Zv);return ge(t,`${e} can’t be used outside of Composer.Editor.`)}function J5(e="useComposerFloatingToolbarContext"){const t=f.useContext(Xv);return ge(t,`${e} can’t be used outside of Composer.Editor.`)}function Ut(){const e=f.useContext(qv);return ge(e,"Composer.Form is missing from the React tree.")}const Z5=/\s/;function wi(e){return e?Z5.test(e):!1}const uh={direction:"before",allowConsecutiveWhitespace:!0};function e0(e,t,n=[" "],r=uh){const{include:o,direction:s,ignoreTerminator:i,allowConsecutiveWhitespace:a}={...uh,...r};let[u,c]=$.edges(t),d=u,l=!1;function m(g){const v=g==="after"?E.after(e,d,{unit:"character"}):E.before(e,d,{unit:"character"});if(!v||B.compare(v.path,d.path)!==0)return!1;const C=v&&E.string(e,g==="after"?{anchor:d,focus:v}:{anchor:v,focus:d}),p=C&&C[g==="after"?0:C.length-1];if(!a&&l&&wi(p))return!1;if(v&&p&&(!n.includes(p)||i?.(p,v,g))){if(l=wi(p),d=v,d.offset===0)return!1}else return!1;return!0}if(s!=="before"){for(d=c;m("after"););c=d}if(s!=="after"){for(d=u;m("before"););u=d}return o?{anchor:s==="before"||s==="both"?E.before(e,u,{unit:"offset"})??u:u,focus:s==="after"||s==="both"?E.after(e,c,{unit:"offset"})??c:c}:{anchor:u,focus:c}}const t0=[{type:"mark",mark:"bold",character:"*"},{type:"mark",mark:"italic",character:"_"},{type:"mark",mark:"strikethrough",character:"~"},{type:"mark",mark:"code",character:"`"}],X5=t0.filter(e=>e.type==="mark").map(e=>e.character);function Q5(e,t,n){if(t!==n.character)return!1;const r=e0(e,e.selection,[n.character]);if(!r||$.isCollapsed(r))return!1;const o=ls(e,r);if(!o||o.text!==n.character)return!1;const s=ls(e,o.range);if(s&&!X5.includes(s.text)&&!Eo(s.text))return!1;const i=E.string(e,r);return i.trim()!==i?!1:(W.select(e,r),e.addMark(n.mark,!0),W.collapse(e,{edge:"end"}),e.removeMark(n.mark),W.delete(e,{at:o.range}),!0)}function e3(e){const{insertText:t}=e;return e.insertText=(n,r)=>{if(!e.selection||!$.isCollapsed(e.selection))return t(n,r);let o=!0;for(const s of t0)s.type==="mark"&&Q5(e,n,s)&&(o=!1);o&&t(n,r)},e}function t3(e,t){const{selection:n}=e;if(!n)return!1;const r=Array.from(E.nodes(e,{at:n,match:o=>ce.isElement(o)&&E.isBlock(e,o),mode:"lowest"}));for(const[,o]of r){const s=$.isRange(n)?$.intersection(n,E.range(e,o)):n;if(!s)continue;if(Array.from(E.nodes(e,{at:s,match:a=>E.isInline(e,a)&&t(a)})).length>0)return!0}return!1}function n3(e){const{isInline:t,normalizeNode:n,insertData:r}=e;return e.isInline=o=>o.type==="custom-link"?!0:t(o),e.normalizeNode=o=>{const[s,i]=o;if(ce.isElement(s)&&s.type==="custom-link"&&(s.children.length===0||s.children.length===1&&s.children[0]?.text==="")&&W.removeNodes(e,{at:i}),En(s)){const a=se.parent(e,i);if(Di(a)&&!ju(s)){const u=Kv(s);W.unsetNodes(e,u,{at:i})}}n(o)},e.insertData=o=>{const{selection:s}=e,i=o.getData("text/plain");let a=!0;s&&!$.isCollapsed(s)&&s.anchor.path[0]===s.focus.path[0]&&M1(i)&&(t3(e,u=>!En(u))||(W.wrapNodes(e,{type:"custom-link",url:i,children:[]},{at:s,split:!0,match:ju}),a=!1)),a&&r(o)},e}function Di(e){return ce.isElement(e)&&e.type==="custom-link"}function r3(e){const{isInline:t,normalizeNode:n,deleteBackward:r}=e;return e.isInline=o=>o.type==="auto-link"?!0:t(o),e.normalizeNode=o=>{const[s,i]=o;if(!Di(s)){if(ce.isElement(s)&&s.type==="auto-link"&&(s.children.length===0||s.children.length===1&&s.children[0]?.text==="")&&W.removeNodes(e,{at:i}),En(s)){const a=se.parent(e,i);if(Di(a))return;if(io(a)){const u=B.parent(i);if(l3(e,[a,u]),!ju(s)){const c=Kv(s);W.unsetNodes(e,c,{at:i})}}else d3(e,[s,i]),f3(e,[s,i])}n(o)}},e.deleteBackward=o=>{r(o);const{selection:s}=e;if(!s||!$.isCollapsed(s))return;const[i]=E.nodes(e,{at:s,match:io,mode:"lowest"});i&&W.unwrapNodes(e,{match:io})},e}function io(e){return ce.isElement(e)&&e.type==="auto-link"}const n0=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9().@:%_+~#?&//=]*)/,o3=/[.,;!?\s()]/,s3=/^[.?][a-zA-Z0-9]+/,i3=/[()]/;function Ai(e){return o3.test(e)}function r0(e){const t=e[e.length-1];return t!==void 0?Ai(t):!1}function o0(e){const t=e[0];return t!==void 0?Ai(t):!1}function a3(e){return e[e.length-1]==="."||e[e.length-1]==="?"}function u3(e){if(!i3.test(e))return e.length;let t=0,n=0;for(const r of e){if(r==="("&&n++,r===")"&&(n--,n<0))break;t++}return t}function s0(e,t){const n=E.previous(e,{at:t});return n?En(n[0])&&(r0(n[0].text)||n[0].text===""):!0}function i0(e,t){const n=E.next(e,{at:t});return n?En(n[0])&&(o0(n[0].text)||n[0].text===""):!0}function c3(e,t,n,r){const[o,s]=t,i=o.text,a=i[n-1],u=n>0&&a?Ai(a):s0(e,s),c=i[r],d=r<i.length&&c?Ai(c):i0(e,s);return u&&d}const l3=(e,t)=>{const[n,r]=t,o=se.children(e,r);for(const[c]of o)if(!En(c)){W.unwrapNodes(e,{at:r});return}const s=se.string(n),i=n0.exec(s),a=i?.[0];if(!i||a!==s){W.unwrapNodes(e,{at:r});return}if(a3(s)){W.unwrapNodes(e,{at:r});const c=s.slice(0,s.length-1);W.wrapNodes(e,{type:"auto-link",url:c,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:c.length}},split:!0});return}const u=u3(s);if(u<s.length){W.unwrapNodes(e,{at:r});const c=s.slice(0,u);W.wrapNodes(e,{type:"auto-link",url:c,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:c.length}},split:!0});return}if(!s0(e,r)||!i0(e,r)){W.unwrapNodes(e,{at:r});return}if(n.url!==s){W.setNodes(e,{url:a},{at:r});return}},d3=(e,t)=>{const[n,r]=t,o=n0.exec(n.text),s=o?.[0];if(!o||s===void 0)return;const i=o.index,a=i+s.length;c3(e,t,i,a)&&W.wrapNodes(e,{type:"auto-link",url:s,children:[]},{at:{anchor:{path:r,offset:i},focus:{path:r,offset:a}},split:!0})},f3=(e,t)=>{const[n,r]=t,o=n.text,s=E.previous(e,{at:r});if(s&&io(s[0])){if(s3.test(o)){W.unwrapNodes(e,{at:s[1]}),W.mergeNodes(e,{at:r});return}if(!o0(o)){W.unwrapNodes(e,{at:s[1]});return}}const i=E.next(e,{at:r});if(i&&io(i[0])&&!r0(o)){W.unwrapNodes(e,{at:i[1]});return}},h3=new RegExp("\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\uFE0F|\\u200D","u"),p3=new Set(['"',"'",".","!","?",",",";","(",")","[","]","<",">"]);function m3(e){const{selection:t}=e;if(!t||!$.isCollapsed(t))return;const n=e0(e,t,["@"],{include:!0,allowConsecutiveWhitespace:!1,ignoreTerminator:(o,s)=>{const i=ls(e,s);return!i||p3.has(i.text)||h3.test(i.text)?!1:!wi(i.text)}});if(!n)return;const r=E.string(e,n);if(!(!r.startsWith(mn)||r.length>1&&wi(r[1])))return{range:n,text:r.substring(1)}}function jo(e){return ce.isElement(e)&&e.type==="mention"}function g3(e,t){const n={type:"mention",...t,children:[{text:""}]};W.insertNodes(e,n),W.move(e);const r=e.selection?fl(e,e.selection):void 0;!r||r.void?W.insertText(e," "):Eo(r.text)&&W.move(e)}function v3(e){if(!e.selection)return;const t=ls(e,e.selection,{filterVoids:!0}),n=fl(e,e.selection,{filterVoids:!0}),r=t&&!Eo(t.text),o=n&&!Eo(n.text);if($.isCollapsed(e.selection)){const s=(r?" ":"")+mn;e.insertText(s,{at:$.start(e.selection)}),o&&e.insertText(" ",{at:$.end(e.selection)}),W.collapse(e,{edge:"end"})}else{const s=(r?" ":"")+mn+(o?" ":"");e.insertText(s),o&&W.move(e,{distance:1,unit:"character",reverse:!0})}}function C3(e){const{isInline:t,isVoid:n,markableVoid:r,deleteBackward:o}=e;return e.isInline=s=>jo(s)||t(s),e.isVoid=s=>jo(s)||n(s),e.markableVoid=s=>jo(s)||r(s),e.deleteBackward=s=>{const{selection:i}=e;if(i&&$.isCollapsed(i)){const[a]=E.nodes(e,{at:s==="character"?E.before(e,i,{unit:"character"}):i,match:jo});o(s),a&&W.insertText(e,mn)}else o(s)},e}function ds(e){"@babel/helpers - typeof";return ds=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},ds(e)}function E3(e,t){if(ds(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ds(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function y3(e){var t=E3(e,"string");return ds(t)==="symbol"?t:String(t)}function yo(e,t,n){return t=y3(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a0=new WeakMap,u0=new WeakMap;class ml{}class ta extends ml{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),yo(this,"offset",void 0),yo(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}class na extends ml{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),yo(this,"offset",void 0),yo(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}var b3=(e,t)=>{var n=e.text.length;a0.set(e,[n,t])},w3=e=>a0.get(e),D3=(e,t)=>{var n=e.text.length;u0.set(e,[n,t])},A3=e=>u0.get(e);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 Hu(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){yo(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 oi=new WeakSet,ra=e=>{var t=[],n=o=>{if(o!=null){var s=t[t.length-1];if(typeof o=="string"){var i={text:o};oi.add(i),o=i}if(pe.isText(o)){var a=o;pe.isText(s)&&oi.has(s)&&oi.has(a)&&pe.equals(s,a,{loose:!0})?s.text+=a.text:t.push(a)}else if(ce.isElement(o))t.push(o);else if(o instanceof ml){var u=t[t.length-1];pe.isText(u)||(n(""),u=t[t.length-1]),o instanceof ta?b3(u,o):o instanceof na&&D3(u,o)}else throw new Error("Unexpected hyperscript child object: ".concat(o))}};for(var r of e.flat(1/0))n(r);return t};function S3(e,t,n){return new ta(t)}function x3(e,t,n){return[new ta(t),new na(t)]}function c0(e,t,n){return Hu(Hu({},t),{},{children:ra(n)})}function O3(e,t,n){return new na(t)}function T3(e,t,n){return ra(n)}function R3(e,t,n){var r=n.find(s=>s instanceof ta),o=n.find(s=>s instanceof na);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 Hu({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)}function I3(e,t,n){var r=ra(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:""}),!pe.isText(o))throw new Error(`
|
|
59
|
+
The <text> hyperscript tag can only contain text content as children.`);return oi.delete(o),Object.assign(o,t),o}var B3=e=>(t,n,r)=>{var o=[],s;for(var i of r)$.isRange(i)?s=i:o.push(i);var a=ra(o),u={},c=e();Object.assign(c,n),c.children=a;for(var[d,l]of se.texts(c)){var m=w3(d),g=A3(d);if(m!=null){var[v]=m;u.anchor={path:l,offset:v}}if(g!=null){var[C]=g;u.focus={path:l,offset:C}}}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 s!=null?c.selection=s:$.isRange(u)&&(c.selection=u),c};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 qo(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){yo(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 F3={anchor:S3,cursor:x3,editor:B3(dv),element:c0,focus:O3,fragment:T3,selection:R3,text:I3},P3=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{elements:n={}}=t,r=_3(n),o=qo(qo(qo({},F3),r),t.creators),s=M3(o);return s},M3=e=>{var t=function(r,o){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];var u=e[r];if(!u)throw new Error("No hyperscript creator found for tag: <".concat(r,">"));o==null&&(o={}),ut(o)||(i=[o].concat(i),o={}),i=i.filter(d=>!!d).flat();var c=u(r,o,i);return c};return t},_3=e=>{var t={},n=function(){var s=e[r];if(typeof s!="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(s));t[r]=(i,a,u)=>c0("element",qo(qo({},s),a),u)};for(var r in e)n();return t},Lo=P3();function fs(e){return e!=null}function l0(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(fs);return t.length||(t=Array.from(e.files).filter(n=>n.type!=="")),t}const k3=/[\r\n]/g,N3=/\s+/g;function j3(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 cn=()=>({type:"paragraph"}),dh={A:e=>{const t=e.getAttribute("href"),n=e.innerText;return{type:t&&j3(t,n)?"auto-link":"custom-link",url:t??""}},P:cn,BLOCKQUOTE:cn,H1:cn,H2:cn,H3:cn,H4:cn,H5:cn,H6:cn,LI:cn},fh={CODE:()=>({code:!0}),DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),B:()=>({bold:!0})};function d0(e){const t=[];return e.nodeName==="LI"&&t.push(e),e.childNodes.forEach(n=>{n.nodeType===1&&t.push(...d0(n))}),t}function hh(e,t){return e.map(n=>Lo("text",t,n))}function Vu(e){if(e.nodeType===3){let r=e.textContent;const o=r&&k3.test(r);return r&&o&&(r=r.replace(N3," ").trim()),r?{text:r}:null}else{if(e.nodeType!==1)return null;if(e.nodeName==="BR")return Lo("element",cn(),[])}let n=Array.from(e.childNodes).map(Vu).flat();if((e.nodeName==="UL"||e.nodeName==="OL")&&(n=d0(e).map(o=>Vu(o)).flat()),n.length===0&&(n=[{text:""}]),e.nodeName==="BODY")return n.length>0&&n.every(r=>typeof r=="string")&&(n=[{type:"paragraph",children:[{text:n.join("")}]}]),Lo("fragment",{},n.filter(r=>typeof r!="string"));if(dh[e.nodeName]){const r=dh[e.nodeName](e);return Lo("element",r,n)}if(fh[e.nodeName]){const r=fh[e.nodeName](e);return n.some(o=>o&&typeof o!="string"&&"type"in o)?Lo("fragment",{},n):hh(n,r)}if(e.nodeName==="SPAN"){const r=e.style,o={};return(r.fontWeight==="bold"||r.fontWeight==="700"||r.fontWeight==="800"||r.fontWeight==="900")&&(o.bold=!0),r.fontStyle==="italic"&&(o.italic=!0),r.textDecoration==="line-through"&&(o.strikethrough=!0),hh(n,o)}return n}function L3(e,{createAttachments:t,pasteFilesAsAttachments:n}){const{insertData:r}=e;return e.insertData=o=>{if(o.types.includes("Files")&&n){const s=l0(o);if(s.length>0){t(s);return}}if(o.types.includes("text/html")&&!o.types.includes("application/x-slate-fragment")){const s=o.getData("text/html");try{const{body:i}=new DOMParser().parseFromString(s,"text/html");if(i.querySelector("br.Apple-interchange-newline")?.remove(),i.children.length===1&&i.children[0]?.nodeName==="B"){const u=i.children[0];for(;u.firstChild;)i.insertBefore(u.firstChild,u);i.removeChild(u)}const a=Vu(i);if(a!==null&&Array.isArray(a)){W.insertFragment(e,a);return}}catch{}}r(o)},e}function U3(e){const{children:t,...n}=e;return n}function $3(e){return{type:"link",url:e.url}}function H3(e){return{type:"link",url:e.url,text:e.children.map(t=>t.text).join("")}}function V3(e){return{...e,children:[{text:""}]}}function W3(e){return e.text?{type:"custom-link",url:e.url,children:[{text:e.text}]}:{type:"auto-link",url:e.url,children:[{text:e.url}]}}function z3(e){return{version:1,content:e.map(t=>{if(t.type!=="paragraph")return null;const n=t.children.map(r=>jo(r)?U3(r):io(r)?$3(r):Di(r)?H3(r):En(r)?r:null).filter(fs);return{...t,children:n}}).filter(fs)}}const K3=[];function G3(e){return!e||!e?.content?K3:e.content.map(t=>{if(t.type!=="paragraph")return null;const n=t.children.map(r=>uc(r)?V3(r):cc(r)?W3(r):bp(r)?r:null).filter(fs);return{...t,children:n}}).filter(fs)}function q3(e){switch(e){case"start":return"end";case"end":return"start";default:return"center"}}function f0(e){const[t,n="center"]=e.split("-");return[t,n]}function h0(){const[e,t]=f.useState(null),n=f.useCallback(t,[t]),[r,o]=f.useState();return gn(()=>{if(e){const s=window.getComputedStyle(e).zIndex,i=parseInt(s,10);o(Number.isNaN(i)?void 0:i)}},[e]),[n,r]}function p0({type:e="bounds",position:t,alignment:n,dir:r,open:o}){const s=f.useMemo(()=>{const i={padding:vs},a=[e==="range"?HA(i):null,bm({...i,crossAxis:!1}),Dm(i),Em({...i,limiter:ym()}),e==="range"?Cm(Do):null,wm({...i,apply({availableWidth:u,availableHeight:c,elements:d}){d.floating.style.setProperty("--lb-composer-floating-available-width",`${u}px`),d.floating.style.setProperty("--lb-composer-floating-available-height",`${c}px`)}})];return{strategy:"fixed",placement:n==="center"?t:`${t}-${r==="rtl"?q3(n):n}`,middleware:a,whileElementsMounted:(...u)=>mm(...u,{animationFrame:!0})}},[n,t,r,e]);return vm({...s,open:o})}function m0({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o}){const{isDisabled:s}=Ut(),i=s||o,{createAttachments:a}=hl(),[u,c]=f.useState(!1),d=Bi(u),l=f.useCallback(C=>{e?.(C),!(d.current||i||C.isDefaultPrevented()||!C.dataTransfer.types.includes("Files"))&&(C.preventDefault(),C.stopPropagation(),c(!0))},[e,i]),m=f.useCallback(C=>{t?.(C),!(!d.current||i||C.isDefaultPrevented())&&((C.relatedTarget?C.relatedTarget===C.currentTarget||C.currentTarget.contains(C.relatedTarget):C.currentTarget!==C.target)||(C.preventDefault(),C.stopPropagation(),c(!1)))},[t,i]),g=f.useCallback(C=>{n?.(C),!(i||C.isDefaultPrevented())&&(C.preventDefault(),C.stopPropagation())},[n,i]),v=f.useCallback(C=>{if(r?.(C),!d.current||i||C.isDefaultPrevented())return;C.preventDefault(),C.stopPropagation(),c(!1);const p=l0(C.dataTransfer);a(p)},[r,i,a]);return[u,{onDragEnter:l,onDragLeave:m,onDragOver:g,onDrop:v,"data-drop":u?"":void 0,"data-disabled":i?"":void 0}]}class Wu extends Error{origin;name="AttachmentTooLargeError";constructor(t,n="client"){super(t),this.origin=n}}function Y3(e,t,n){const r=new Map,o=new Map,s=Ne();let i=null;function a(){i=null,s.notify()}function u(g){const v=new AbortController;o.set(g.id,v),e[Ce].httpClient.uploadAttachment({roomId:t,attachment:g,signal:v.signal}).then(()=>{r.set(g.id,{...g,status:"uploaded"}),a()}).catch(C=>{C instanceof Error&&C.name!=="AbortError"&&C.name!=="TimeoutError"&&(r.set(g.id,{...g,status:"error",error:C instanceof uo&&C.status===413?new Wu("File is too large.","server"):C}),a())})}function c(g){if(g.length===0)return;const v=g.filter(p=>!r.has(p.id)),C=[];for(const p of v)if(p.type==="localAttachment"){if(p.file.size>n.maxFileSize){r.set(p.id,{...p,status:"error",error:new Wu("File is too large.","client")});continue}r.set(p.id,{...p,status:"uploading"}),C.push(p)}else r.set(p.id,p);v.length>0&&a();for(const p of C)u(p)}function d(g){o.get(g)?.abort(),r.delete(g),o.delete(g),a()}function l(){return i||(i=Array.from(r.values())),i}function m(){o.forEach(g=>g.abort()),o.clear(),r.clear(),a()}return{addAttachments:c,removeAttachment:d,getSnapshot:l,subscribe:s.subscribe,clear:m}}function ph(e){e.preventDefault()}function J3(e,t){const n=_e(),r=mo(e),o=mo(()=>Y3(n,t.roomId,t));f.useEffect(()=>{o.addAttachments(r)},[r,o]),f.useEffect(()=>()=>{o.clear()},[o]);const s=f.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot),i=f.useMemo(()=>s.some(a=>a.type==="localAttachment"&&a.status==="uploading"),[s]);return f.useEffect(()=>{if(i)return window.addEventListener("beforeunload",ph),()=>{window.removeEventListener("beforeunload",ph)}},[i]),{attachments:s,isUploadingAttachments:i,addAttachments:o.addAttachments,removeAttachment:o.removeAttachment,clearAttachments:o.clear}}const Z3="top",X3="top",Q3="ComposerFloatingToolbar",eB="ComposerSuggestions",tB="ComposerSuggestionsList",nB="ComposerSuggestionsListItem",rB={version:1,content:[{type:"paragraph",children:[{text:""}]}]};function oB({createAttachments:e,pasteFilesAsAttachments:t}){return k5(C3(n3(r3(e3(Y5(L3(BR(M5(dv())),{createAttachments:e,pasteFilesAsAttachments:t})))))))}function sB({Mention:e,attributes:t,children:n,element:r}){const o=kv(),{children:s,...i}=r;return h.jsxs("span",{...t,children:[r.id?h.jsx(e,{mention:i,isSelected:o}):null,n]})}function iB({Link:e,attributes:t,element:n,children:r}){const o=f.useMemo(()=>ec(n.url)??"",[n.url]);return h.jsx("span",{...t,children:h.jsx(e,{href:o,children:r})})}function aB({id:e,itemId:t,mentions:n,selectedMentionId:r,setSelectedMentionId:o,mentionDraft:s,setMentionDraft:i,onItemSelect:a,position:u=Z3,dir:c,MentionSuggestions:d}){const l=yn(),{onEditorChange:m}=ea(),{isFocused:g}=Ut(),[v,C]=h0(),p=g&&s?.range!==void 0&&n!==void 0,{refs:{setReference:D,setFloating:w},strategy:b,isPositioned:y,placement:A,x:T,y:S,update:P,elements:L}=p0({position:u,dir:c,alignment:"start",open:p});return dl(m,()=>{i(m3(l))}),gn(()=>{if(!s){D(null);return}const F=ul(l,s.range);D(F??null)},[D,l,s]),gn(()=>{if(!p)return;const F=L.floating?.firstChild;if(!F)return;F.style.overflowY="visible",F.style.maxHeight="none",P();const M=requestAnimationFrame(()=>{F.style.overflowY="auto",F.style.maxHeight="var(--lb-composer-floating-available-height)"});return()=>{cancelAnimationFrame(M)}},[n?.length,p,L.floating,P]),h.jsx(zv,{children:p?h.jsx(Zv.Provider,{value:{id:e,itemId:t,selectedValue:r,setSelectedValue:o,onItemSelect:a,placement:A,dir:c,ref:v},children:h.jsx(Qg,{ref:w,style:{position:b,top:0,left:0,transform:y?`translate3d(${Math.round(T)}px, ${Math.round(S)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:C},children:h.jsx(d,{mentions:n,selectedMentionId:r})})}):null})}function uB({id:e,position:t=X3,dir:n,FloatingToolbar:r,hasFloatingToolbarRange:o,setHasFloatingToolbarRange:s}){const i=yn(),{onEditorChange:a}=ea(),{isFocused:u}=Ut(),[c,d]=h0(),[l,m]=f.useState(!1),g=u&&!l&&o,{refs:{setReference:v,setFloating:C},strategy:p,isPositioned:D,placement:w,x:b,y}=p0({type:"range",position:t,dir:n,alignment:"center",open:g});return gn(()=>{if(!u)return;const A=()=>m(!0),T=()=>m(!1);return document.addEventListener("pointerdown",A),document.addEventListener("pointerup",T),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("pointerup",T)}},[u]),dl(a,()=>{v(null),requestAnimationFrame(()=>{const A=window.getSelection();if(!i.selection||$.isCollapsed(i.selection)||!A||!A.rangeCount)s(!1),v(null);else{s(!0);const T=A.getRangeAt(0);v(T)}})}),h.jsx(zv,{children:g?h.jsx(Xv.Provider,{value:{id:e,placement:w,dir:n,ref:c},children:h.jsx(Qg,{ref:C,style:{position:p,top:0,left:0,transform:D?`translate3d(${Math.round(b)}px, ${Math.round(y)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:d},children:h.jsx(r,{})})}):null})}const cB=f.forwardRef(({children:e,onPointerDown:t,style:n,asChild:r,...o},s)=>{const[i]=ll(),a=f.useRef(null),{id:u,ref:c,placement:d,dir:l}=J5(Q3),m=Os(s,c,a),[g,v]=f.useMemo(()=>f0(d),[d]),C=r?ot:"div";Wv(a);const p=f.useCallback(D=>{t?.(D),D.preventDefault(),D.stopPropagation()},[t]);return h.jsx(C,{dir:l,role:"toolbar",id:u,"aria-label":"Floating toolbar",...o,onPointerDown:p,"data-state":i?"open":"closed","data-side":g,"data-align":v,style:{display:"flex",flexDirection:"row",maxWidth:"var(--lb-composer-floating-available-width)",overflowX:"auto",...n},ref:m,children:e})});function lB({Mention:e,Link:t,...n}){const{attributes:r,children:o,element:s}=n;switch(s.type){case"mention":return h.jsx(sB,{Mention:e,...n});case"auto-link":case"custom-link":return h.jsx(iB,{Link:t,...n});case"paragraph":return h.jsx("p",{...r,style:{position:"relative"},children:o});default:return null}}function dB({attributes:e,children:t,leaf:n}){return n.bold&&(t=h.jsx("strong",{children:t})),n.italic&&(t=h.jsx("em",{children:t})),n.strikethrough&&(t=h.jsx("s",{children:t})),n.code&&(t=h.jsx("code",{children:t})),h.jsx("span",{...e,children:t})}function fB({attributes:e,children:t}){const{opacity:n,...r}=e.style;return h.jsx("span",{...e,style:r,"data-placeholder":"",children:t})}const gl=f.forwardRef(({children:e,asChild:t,...n},r)=>{const o=t?ot:"span",s=kv();return h.jsx(o,{"data-selected":s||void 0,...n,ref:r,children:e})}),g0=f.forwardRef(({children:e,asChild:t,...n},r)=>{const o=t?ot:"a";return h.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})}),v0=f.forwardRef(({children:e,style:t,asChild:n,...r},o)=>{const[s]=ll(),i=f.useRef(null),{ref:a,placement:u,dir:c}=pl(eB),d=Os(o,a,i),[l,m]=f.useMemo(()=>f0(u),[u]),g=n?ot:"div";return Wv(i),h.jsx(g,{dir:c,...r,"data-state":s?"open":"closed","data-side":l,"data-align":m,style:{display:"flex",flexDirection:"column",maxHeight:"var(--lb-composer-floating-available-height)",overflowY:"auto",...t},ref:d,children:e})}),C0=f.forwardRef(({children:e,asChild:t,...n},r)=>{const{id:o}=pl(tB),s=t?ot:"ul";return h.jsx(s,{role:"listbox",id:o,"aria-label":"Suggestions list",...n,ref:r,children:e})}),E0=f.forwardRef(({value:e,children:t,onPointerMove:n,onPointerDown:r,onClick:o,asChild:s,...i},a)=>{const u=f.useRef(null),c=Os(a,u),{selectedValue:d,setSelectedValue:l,itemId:m,onItemSelect:g}=pl(nB),v=s?ot:"li",C=f.useMemo(()=>d===e,[d,e]),p=f.useMemo(()=>m(e),[m,e]);f.useEffect(()=>{u?.current&&C&&u.current.scrollIntoView({block:"nearest"})},[C]);const D=f.useCallback(y=>{n?.(y),y.isDefaultPrevented()||l(e)},[n,l,e]),w=f.useCallback(y=>{r?.(y),y.preventDefault(),y.stopPropagation()},[r]),b=f.useCallback(y=>{o?.(y);const A=y.isDefaultPrevented();y.preventDefault(),y.stopPropagation(),A||g(e)},[o,g,e]);return h.jsx(v,{role:"option",id:p,"data-selected":C||void 0,"aria-selected":C||void 0,onPointerMove:D,onPointerDown:w,onClick:b,...i,ref:c,children:t})}),hB={Link:({href:e,children:t})=>h.jsx(g0,{href:e,children:t}),Mention:({mention:e})=>h.jsxs(gl,{children:[mn,e.id]}),MentionSuggestions:({mentions:e})=>e.length>0?h.jsx(v0,{children:h.jsx(C0,{children:e.map(t=>h.jsx(E0,{value:t.id,children:t.id},t.id))})}):null},pB=f.forwardRef(({defaultValue:e,onKeyDown:t,onFocus:n,onBlur:r,disabled:o,autoFocus:s,components:i,dir:a,...u},c)=>{const d=lc(),{editor:l,validate:m,setFocused:g,onEditorChange:v,roomId:C}=ea(),{submit:p,focus:D,blur:w,select:b,canSubmit:y,isDisabled:A,isFocused:T}=Ut(),S=Rn(),P=G5(),L=A||o,F=mo(e??rB),M=f.useMemo(()=>G3(F),[F]),{Link:N,Mention:_,MentionSuggestions:I,FloatingToolbar:j}=f.useMemo(()=>({...hB,...i}),[i]),[z,Y]=f.useState(!1),oe=pc(),G=d?oe:!0,[Z,le]=f.useState(),de=Tw(C,Z?.text),[ue,ee,te,R]=K5(0,de?.length??0),q=f.useId(),J=`liveblocks-floating-toolbar-${q}`,X=`liveblocks-suggestions-list-${q}`,ie=f.useCallback(k=>k?`liveblocks-suggestions-list-item-${q}-${k}`:void 0,[q]),ae=f.useCallback(k=>h.jsx(lB,{Mention:_,Link:N,...k}),[N,_]),we=f.useCallback(k=>{m(k),v.notify()},[m,v]),Se=f.useCallback(k=>{!Z||!k||(W.select(l,Z.range),g3(l,k),le(void 0),R(0))},[l,Z,R]),me=f.useCallback(k=>{if(t?.(k),!k.isDefaultPrevented())if(Dt(k,"ArrowLeft")&&ah(l,"start"),Dt(k,"ArrowRight")&&ah(l,"end"),Z&&de?.length){if(Dt(k,"ArrowDown")&&(k.preventDefault(),te()),Dt(k,"ArrowUp")&&(k.preventDefault(),ee()),Dt(k,"Enter")||Dt(k,"Tab")){k.preventDefault();const ne=de?.[ue];Se(ne)}Dt(k,"Escape")&&(k.preventDefault(),le(void 0),R(0))}else z&&Dt(k,"Escape")&&(k.preventDefault(),Y(!1)),Dt(k,"Escape")&&w(),Dt(k,"Enter",{shift:!1})&&(k.preventDefault(),y&&p()),Dt(k,"Enter",{shift:!0})&&(k.preventDefault(),l.insertBreak()),Dt(k,"b",{mod:!0})&&(k.preventDefault(),No(l,"bold")),Dt(k,"i",{mod:!0})&&(k.preventDefault(),No(l,"italic")),Dt(k,"s",{mod:!0,shift:!0})&&(k.preventDefault(),No(l,"strikethrough")),Dt(k,"e",{mod:!0})&&(k.preventDefault(),No(l,"code"))},[t,Z,de,z,l,te,ee,ue,Se,R,w,y,p]),fe=f.useCallback(k=>{n?.(k),k.isDefaultPrevented()||(g(!0),S&&P(S))},[n,g,S,P]),ye=f.useCallback(k=>{r?.(k),k.isDefaultPrevented()||g(!1)},[r,g]),xe=de?.[ue]?.id,ke=f.useCallback(k=>{const ne=de?.findIndex(re=>re.id===k);ne!==void 0&&ne>=0&&R(ne)},[R,de]),Me=f.useMemo(()=>Z?{role:"combobox","aria-autocomplete":"list","aria-expanded":!0,"aria-controls":X,"aria-activedescendant":ie(xe)}:z?{"aria-haspopup":!0,"aria-controls":J}:{},[Z,X,ie,xe,z,J]);f.useImperativeHandle(c,()=>K.toDOMNode(l,l),[l]),gn(()=>{if(!s)return;const k=setTimeout(()=>D(),0);return()=>clearTimeout(k)},[s,l,D]),gn(()=>{T&&l.selection===null&&b()},[l,b,T]);const O=f.useCallback(k=>{const ne=de?.find(re=>re.id===k);Se(ne)},[Se,de]);return h.jsxs(F5,{editor:l,initialValue:M,onChange:we,children:[h.jsx(D5,{dir:a,tabIndex:L?-1:0,enterKeyHint:Z?"enter":"send",autoCapitalize:"sentences","aria-label":"Composer editor","data-focused":T||void 0,"data-disabled":L||void 0,...Me,...u,readOnly:L,disabled:L,onKeyDown:me,onFocus:fe,onBlur:ye,renderElement:ae,renderLeaf:dB,renderPlaceholder:fB}),G&&h.jsx(aB,{dir:a,mentionDraft:Z,setMentionDraft:le,selectedMentionId:xe,setSelectedMentionId:ke,mentions:de,id:X,itemId:ie,onItemSelect:O,MentionSuggestions:I}),j&&h.jsx(uB,{dir:a,id:J,hasFloatingToolbarRange:z,setHasFloatingToolbarRange:Y,FloatingToolbar:j})]})}),mB=10,gB=1024*1024*1024;function vB(e){return{type:"localAttachment",status:"idle",id:qh(),name:e.name,size:e.size,mimeType:e.type,file:e}}const CB=f.forwardRef(({children:e,onSubmit:t,onComposerSubmit:n,defaultAttachments:r=[],pasteFilesAsAttachments:o,blurOnSubmit:s=!0,preventUnsavedChanges:i=!0,disabled:a,asChild:u,roomId:c,...d},l)=>{const m=u?ot:"form",[g,v]=f.useState(!0),[C,p]=f.useState(!1),[D,w]=f.useState(!1),b=jp({allowOutsideRoom:!0}),y=c!==void 0?c:b?.id;if(y===void 0)throw new Error("Composer.Form must be a descendant of RoomProvider.");const A=mB,T=gB,{attachments:S,isUploadingAttachments:P,addAttachments:L,removeAttachment:F,clearAttachments:M}=J3(r,{maxFileSize:T,roomId:y}),N=S.length,_=N>=A,I=f.useMemo(()=>C||a===!0,[C,a]),j=f.useMemo(()=>!g&&!P,[g,P]),[z,Y]=f.useState(ih),oe=f.useRef(null),G=Os(l,oe),Z=f.useRef(null),le=Rw(),de=i?!g||P||S.length>0:!1;f.useEffect(()=>{le?.setSyncStatus(de?"has-local-changes":"synchronized")},[le,de]);const ue=f.useCallback(k=>{if(!k.length)return;const ne=Math.max(0,A-N);k.splice(ne);const re=k.map(he=>vB(he));L(re)},[L,A,N]),ee=f.useRef(ue);f.useEffect(()=>{ee.current=ue},[ue]);const te=f.useCallback(k=>{ee.current(k)},[]),R=mo(()=>oB({createAttachments:te,pasteFilesAsAttachments:o})),q=mo(Ne),J=f.useCallback(k=>{v(Lu(R,k))},[R]),X=f.useCallback(()=>{j&&requestAnimationFrame(()=>{oe.current&&_5(oe.current)})},[j]),ie=f.useCallback(()=>{W.delete(R,{at:{anchor:E.start(R,[]),focus:E.end(R,[])}})},[R]),ae=f.useCallback(()=>{W.select(R,E.end(R,[]))},[R]),we=f.useCallback((k=!0)=>{try{if(!K.isFocused(R)){W.select(R,k||!R.selection?E.end(R,[]):R.selection);const ne=K.toDOMNode(R,R);if(R.selection){const re=window.getSelection(),he=ul(R,R.selection);he&&(re?.removeAllRanges(),re?.addRange(he))}ne.focus({preventScroll:!0})}}catch{}},[R]),Se=f.useCallback(()=>{try{K.blur(R)}catch{}},[R]),me=f.useCallback(()=>{a||(we(),v3(R))},[a,R,we]),fe=f.useCallback(k=>{a||(we(!1),cv(R,k))},[a,R,we]),ye=f.useCallback(()=>{a||Z.current&&Z.current.click()},[a]),be=f.useCallback(k=>{a||k.target.files&&(ue(Array.from(k.target.files)),k.target.value="")},[ue,a]),xe=f.useCallback(()=>{ie(),M(),p(!1),s&&Se()},[Se,s,ie,M]),ke=f.useCallback(k=>{if(a)return;if(Lu(R,R.children)){k.preventDefault();return}if(t?.(k),!n||k.isDefaultPrevented()){k.preventDefault();return}const re=z3(R.children),he=S.filter(Fe=>Fe.type==="attachment"||Fe.type==="localAttachment"&&Fe.status==="uploaded").map(Fe=>({id:Fe.id,type:"attachment",mimeType:Fe.mimeType,size:Fe.size,name:Fe.name})),Ie=n({body:re,attachments:he},k);k.preventDefault(),Ie?(p(!0),Ie.then(xe)):xe()},[a,R,S,n,t,xe]),Me=f.useCallback(k=>{k.stopPropagation()},[]),O=f.useCallback(k=>{No(R,k)},[R]);return dl(q,()=>{Y(ih(R))}),h.jsx(Yv.Provider,{value:{editor:R,validate:J,setFocused:w,onEditorChange:q,roomId:y},children:h.jsx(Jv.Provider,{value:{createAttachments:ue,isUploadingAttachments:P,hasMaxAttachments:_,maxAttachments:A,maxAttachmentSize:T},children:h.jsx(qv.Provider,{value:{isDisabled:I,isFocused:D,isEmpty:g,canSubmit:j,submit:X,clear:ie,select:ae,focus:we,blur:Se,createMention:me,insertText:fe,attachments:S,attachFiles:ye,removeAttachment:F,toggleMark:O,marks:z},children:h.jsxs(m,{...d,onSubmit:ke,ref:G,children:[h.jsx("input",{type:"file",multiple:!0,ref:Z,onChange:be,onClick:Me,tabIndex:-1,style:{display:"none"}}),h.jsx(Fw,{children:e})]})})})})}),y0=f.forwardRef(({children:e,disabled:t,asChild:n,...r},o)=>{const s=n?ot:"button",{canSubmit:i,isDisabled:a}=Ut(),u=a||t||!i;return h.jsx(s,{type:"submit",...r,ref:o,disabled:u,children:e})}),EB=f.forwardRef(({children:e,onClick:t,disabled:n,asChild:r,...o},s)=>{const i=r?ot:"button",{hasMaxAttachments:a}=hl(),{isDisabled:u,attachFiles:c}=Ut(),d=u||a||n,l=f.useCallback(m=>{t?.(m),m.isDefaultPrevented()||c()},[c,t]);return h.jsx(i,{type:"button",...o,onClick:l,ref:s,disabled:d,children:e})});f.forwardRef(({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o,asChild:s,...i},a)=>{const u=s?ot:"div",{isDisabled:c}=Ut(),d=c||o,[,l]=m0({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:d});return h.jsx(u,{...l,"data-disabled":d?"":void 0,...i,ref:a})});const yB=f.forwardRef(({children:e,mark:t,onValueChange:n,onClick:r,onPointerDown:o,asChild:s,...i},a)=>{const u=s?ot:"button",{marks:c,toggleMark:d}=Ut(),l=f.useCallback(g=>{o?.(g),g.preventDefault(),g.stopPropagation()},[o]),m=f.useCallback(g=>{r?.(g),g.isDefaultPrevented()||(g.preventDefault(),g.stopPropagation(),d(t),n?.(t))},[t,r,n,d]);return h.jsx(jc,{asChild:!0,pressed:c[t],onClick:m,onPointerDown:l,...i,children:h.jsx(u,{...i,ref:a,children:e})})}),bB=4320*60*1e3,wB=30*1e3,mh={seconds:60,minutes:60,hours:24,days:7,weeks:4.34524,months:12};function DB(e,t){const n=Ng(t,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"});return qc(n.format(e))}function AB(e,t){const n=Ng(t,{month:"short",day:"numeric"});return qc(n.format(e))}const SB=["br","fr","nb","nn","no","ro","sv"];function xB(e,t){let n;t?n=t:n=Fd().resolvedOptions().locale;const r=SB.some(i=>n===i||n.startsWith(`${i}-`)),o=Fd(n,{style:r?"short":"narrow",numeric:"auto"});let s=(e.getTime()-Date.now())/1e3;if(s>-60&&s<mh.seconds)return o.format(0,"seconds");for(const[i,a]of Object.entries(mh)){if(Math.abs(s)<a)return o.format(Math.round(s),i);s/=a}return qc(o.format(Math.round(s),"years"))}function OB(e,t){return Math.abs(e.getTime()-Date.now())<=bB?xB(e,t):AB(e,t)}const b0=f.forwardRef(({date:e,locale:t,children:n=OB,title:r=DB,dateTime:o,interval:s=wB,asChild:i,...a},u)=>{const c=i?ot:"time",[d,l]=Lg(),m=f.useMemo(()=>new Date(e),[e]),g=f.useMemo(()=>m.toISOString(),[m]),v=f.useMemo(()=>typeof r=="function"?r(m,t):r,[r,m,t,l]),C=f.useMemo(()=>typeof n=="function"?n(m,t):n,[n,m,t,l]);return jg(d,s),h.jsx(c,{...a,ref:u,dateTime:o??g,title:v,children:C})});function TB(e,t){const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}function w0(e){const t=mo(e),n=t.userIds;if(t.kind!=="group")return!1;if(Array.isArray(n)){const r=Rn();return f.useMemo(()=>n.some(s=>s===r),[n,r])}else{const r=Rn(),{group:o}=xw(t.id);return f.useMemo(()=>!!o?.members.some(i=>i.id===r),[o,r])}}const gh=1e3,Za=["B","KB","MB","GB"];function vh(e,t){if(e===0)return`0 ${Za[1]}`;let n;e===0?n=1:n=Math.max(1,Math.min(Math.floor(Math.log(Math.abs(e))/Math.log(gh)),Za.length-1));let r=e/gh**n,o=1;n===1&&(r>=10&&(o=0),r<.1&&r>0&&(o=2),r<.01&&(r=.01));const s=Za[n];return`${yr(t,{minimumFractionDigits:0,maximumFractionDigits:o}).format(r)} ${s}`}const D0=60*1024*1024,RB=/^(.+?)(\.[^.]+)?$/;function IB(e){const t=e.match(RB);return{base:t?.[1]??e,extension:t?.[2]}}function BB(e){return e==="application/zip"||e==="application/gzip"||e==="application/vnd.rar"||e==="application/x-rar-compressed"||e==="application/x-7z-compressed"||e==="application/x-zip-compressed"||e==="application/x-tar"||e==="application/x-bzip"||e==="application/x-bzip2"?h.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"}):e.startsWith("text/")||e.startsWith("font/")||e.startsWith("application/")?h.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"}):e.startsWith("image/")?h.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"}):e.startsWith("video/")?h.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"}):e.startsWith("audio/")?h.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}const FB=f.memo(({mimeType:e})=>{const t=f.useMemo(()=>BB(e),[e]);return h.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:[h.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"}),h.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"}),h.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&&h.jsx("g",{className:"lb-attachment-icon-glyph",children:t})]})});function PB({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=Pi(e.id,n),[o,s]=f.useState(!1),i=f.useCallback(()=>{s(!0)},[]);return h.jsxs(h.Fragment,{children:[o?null:h.jsx(xs,{}),r?h.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:h.jsx("img",{src:r,loading:"lazy",onLoad:i,onError:t})}):null]})}function MB({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=Pi(e.id,n),[o,s]=f.useState(!1),i=f.useCallback(()=>{s(!0)},[]);return h.jsxs(h.Fragment,{children:[o?null:h.jsx(xs,{}),r?h.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:h.jsx("video",{src:r,onLoadedData:i,onError:t})}):null]})}function A0({attachment:e,allowMediaPreview:t=!0,roomId:n}){const[r,o]=f.useState(!1),s=e.type==="attachment"||e.status==="uploaded";function i(){o(!0)}if(!r&&t&&s&&e.size<=D0){if(e.mimeType.startsWith("image/"))return h.jsx(PB,{attachment:e,markPreviewAsUnsupported:i,roomId:n});if(e.mimeType.startsWith("video/"))return h.jsx(MB,{attachment:e,markPreviewAsUnsupported:i,roomId:n})}return h.jsx(FB,{mimeType:e.mimeType})}function S0({attachment:e}){const{base:t,extension:n}=f.useMemo(()=>IB(e.name),[e.name]);return h.jsxs("span",{className:"lb-attachment-name",title:e.name,children:[h.jsx("span",{className:"lb-attachment-name-base",children:t}),n&&h.jsx("span",{className:"lb-attachment-name-extension",children:n})]})}function x0(e){return f.useCallback(n=>{if(e?.(n),!n.isDefaultPrevented()&&(n.key==="Enter"||n.key===" ")){n.preventDefault();const r=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});n.target.dispatchEvent(r)}},[e])}function O0(e,t){const n=st(t),r=Qv(),o=!!r,s=r?.maxAttachmentSize,i=e.type==="localAttachment"?e.status:void 0,a=i==="uploading",u=i==="error";let c;e.type==="localAttachment"&&e.status==="error"?e.error instanceof Wu?e.error.origin==="server"?c=n.ATTACHMENT_TOO_LARGE():c=n.ATTACHMENT_TOO_LARGE(s?vh(s,n.locale):void 0):c=n.ATTACHMENT_ERROR(e.error):c=vh(e.size,n.locale);const d=o?n.COMPOSER_REMOVE_ATTACHMENT:n.COMMENT_DELETE_ATTACHMENT;return{isUploading:a,isError:u,description:c,deleteLabel:d}}function _B({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:s=!0,roomId:i,className:a,onKeyDown:u,...c}){const{isUploading:d,isError:l,description:m,deleteLabel:g}=O0(e,t),v=f.useCallback(p=>{o&&p.preventDefault()},[o]),C=x0(u);return h.jsxs("div",{className:Be("lb-attachment lb-media-attachment",a),"data-error":l?"":void 0,...c,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?C:void 0,children:[h.jsx("div",{className:"lb-attachment-preview",children:d?h.jsx(xs,{}):l?h.jsx(Gc,{}):h.jsx(A0,{attachment:e,allowMediaPreview:s,roomId:i})}),h.jsxs("div",{className:"lb-attachment-details",children:[h.jsx(S0,{attachment:e}),h.jsx("span",{className:"lb-attachment-description",title:m,children:m})]}),r&&h.jsx(Et,{content:g,children:h.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:v,"aria-label":g,children:h.jsx(Kc,{})})})]})}function vl({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:s=!0,roomId:i,className:a,onKeyDown:u,...c}){const{isUploading:d,isError:l,description:m,deleteLabel:g}=O0(e,t),v=f.useCallback(p=>{o&&p.preventDefault()},[o]),C=x0(u);return h.jsxs("div",{className:Be("lb-attachment lb-file-attachment",a),"data-error":l?"":void 0,...c,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?C:void 0,children:[h.jsx("div",{className:"lb-attachment-preview",children:d?h.jsx(xs,{}):l?h.jsx(Gc,{}):h.jsx(A0,{attachment:e,allowMediaPreview:s,roomId:i})}),h.jsxs("div",{className:"lb-attachment-details",children:[h.jsx(S0,{attachment:e}),h.jsx("span",{className:"lb-attachment-description",title:m,children:m})]}),r&&h.jsx(Et,{content:g,children:h.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:v,"aria-label":g,children:h.jsx(Kc,{})})})]})}function kB(e){const t=[],n=[];for(const r of e)(r.mimeType.startsWith("image/")||r.mimeType.startsWith("video/"))&&r.size<=D0?t.push(r):n.push(r);return{mediaAttachments:t,fileAttachments:n}}function NB({className:e,...t}){return h.jsx("a",{href:"https://liveblocks.io",target:"_blank",rel:"noopener noreferrer",className:Be("lb-composer-attribution",e),...t,children:h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 72","aria-label":"Made with Liveblocks",children:h.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 jB=Object.defineProperty,LB=(e,t)=>{for(var n in t)jB(e,n,{get:t[n],enumerable:!0})},wn={};LB(wn,{ActiveEmoji:()=>Y0,Empty:()=>q0,List:()=>z0,Loading:()=>G0,Root:()=>j0,Search:()=>L0,SkinTone:()=>J0,SkinToneSelector:()=>K0,Viewport:()=>U0});var T0="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",Cl=["none","light","medium-light","medium","medium-dark","dark"];function Xa(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Zt=2,Ct=null;function Ch(e){try{Ct??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!Ct||(queueMicrotask(()=>{Ct&&(Ct=null)}),Ct.canvas.width=Zt,Ct.canvas.height=Zt,Ct.font=`2px ${T0}`,Ct.textBaseline="middle",Ct.measureText(e).width>=Zt*2))return!1;Ct.fillStyle="#00f",Ct.fillText(e,0,0);let t=Ct.getImageData(0,0,Zt,Zt).data;Ct.clearRect(0,0,Zt,Zt),Ct.fillStyle="#f00",Ct.fillText(e,0,0);let n=Ct.getImageData(0,0,Zt,Zt).data;for(let r=0;r<Zt*Zt*4;r+=4)if(t[r]!==n[r]||t[r+1]!==n[r+1]||t[r+2]!==n[r+2])return!1;return!0}function Eh(e,t,n){try{let r=e.getItem(t);if(!r)throw new Error(`No value found for "${t}".`);let o=JSON.parse(r);return n(o)}catch{return null}}function R0(e,t,n){e.setItem(t,JSON.stringify(n))}function yh(e){return t=>t===void 0?void 0:e(t)}function bh(e){return t=>t===null?null:e(t)}function dt(e){if(typeof e!="string")throw new Error;return e}function si(e){if(typeof e!="number")throw new Error;return e}function I0(e){if(typeof e!="boolean")throw new Error;return e}function $n(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 Qa(e){return t=>{if(!Array.isArray(t))throw new Error;return t.length>0&&e(t[0]),t}}var B0=(e,t)=>`${e}/${t}/data.json`,F0=(e,t)=>`${e}/${t}/messages.json`,UB=["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"],wh="en",P0=e=>`frimousse/data/${e}`,Dh="frimousse/metadata";async function Ah(e,t){try{return(await fetch(e,{method:"HEAD",signal:t})).headers.get("etag")}catch{return null}}async function $B(e,t,n){let[{emojis:r,emojisEtag:o},{messages:s,messagesEtag:i}]=await Promise.all([fetch(B0(e,t),{signal:n}).then(async a=>({emojis:await a.json(),emojisEtag:a.headers.get("etag")})),fetch(F0(e,t),{signal:n}).then(async a=>({messages:await a.json(),messagesEtag:a.headers.get("etag")}))]);return{emojis:r,messages:s,emojisEtag:o,messagesEtag:i}}async function HB(e,t,n){let[r,o]=await Promise.all([Ah(B0(e,t),n),Ah(F0(e,t),n)]);return{emojisEtag:r,messagesEtag:o}}function VB(e){return e.skins?e.skins.filter(t=>typeof t.tone=="number").reduce((t,n)=>{let r=Cl[n.tone];return t[r]=n.emoji,t},{}):void 0}async function Sh(e,t,n){let{emojis:r,emojisEtag:o,messages:s,messagesEtag:i}=await $B(e,t,n),a=s.subgroups.find(v=>v.key==="country-flag"||v.key==="subdivision-flag"),u=s.groups.filter(v=>v.key!=="component"),c=r.filter(v=>"group"in v),d=u.map(v=>({index:v.order,label:Xa(v.message)})),l=s.skinTones.reduce((v,C)=>(v[C.key]=Xa(C.message),v),{}),m=c.map(v=>({emoji:v.emoji,category:v.group,version:v.version,label:Xa(v.label),tags:v.tags??[],countryFlag:a&&v.subgroup===a.order||void 0,skins:VB(v)})),g={locale:t,emojis:m,categories:d,skinTones:l};return R0(localStorage,P0(t),{data:g,metadata:{emojisEtag:o,messagesEtag:i}}),g}function WB(e,t){let n=new Map;for(let i of e)n.has(i.version)||n.set(i.version,i.emoji);let r=[...n.keys()].sort((i,a)=>a-i),o=r[0]??0,s=Ch("🇪🇺");if(typeof t=="number")return{emojiVersion:t,countryFlags:s};for(let i of r){let a=n.get(i);if(Ch(a))return{emojiVersion:i,countryFlags:s}}return{emojiVersion:o,countryFlags:s}}var zB=$n({emojiVersion:si,countryFlags:I0}),KB=$n({data:$n({locale:dt,emojis:Qa($n({emoji:dt,category:si,label:dt,version:si,tags:Qa(dt),countryFlag:yh(I0),skins:yh($n({light:dt,"medium-light":dt,medium:dt,"medium-dark":dt,dark:dt}))})),categories:Qa($n({index:si,label:dt})),skinTones:$n({light:dt,"medium-light":dt,medium:dt,"medium-dark":dt,dark:dt})}),metadata:$n({emojisEtag:bh(dt),messagesEtag:bh(dt)})});async function GB({locale:e,emojiVersion:t,emojibaseUrl:n,signal:r}){let o=typeof n=="string"?n:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof t=="number"?Math.floor(t):"latest"}`,s=Eh(sessionStorage,Dh,zB),i=Eh(localStorage,P0(e),KB),a;if(!i)a=await Sh(o,e,r);else if(s)a=i.data;else try{let{emojisEtag:c,messagesEtag:d}=await HB(o,e,r);a=!c||!d||c!==i.metadata.emojisEtag||d!==i.metadata.messagesEtag?await Sh(o,e,r):i.data}catch{a=i.data}s??=WB(a.emojis,t),R0(sessionStorage,Dh,s);let u=a.emojis.filter(c=>{let d=c.version<=s.emojiVersion;return c.countryFlag?d&&s.countryFlags:d});return{locale:e,emojis:u,categories:a.categories,skinTones:a.skinTones}}function xh(e){return UB.includes(e)?e:(console.warn(`Locale "${e}" is not supported, using "${wh}" instead.`),wh)}function Oh(e){return Cl.includes(e)?e:(console.warn(`Skin tone "${e}" is not valid, using "none" instead.`),"none")}function qB(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 YB(e,t){if(!t)return e;let n=t.toLowerCase().trim(),r=new WeakMap;return e.filter(o=>{let s=0;o.label.toLowerCase().includes(n)&&(s+=10);for(let i of o.tags)i.toLowerCase().includes(n)&&(s+=1);return s>0?(r.set(o,s),!0):!1}).sort((o,s)=>(r.get(s)??0)-(r.get(o)??0))}function JB(e,t,n,r){let o=YB(e.emojis,r),s=[],i=[],a=[],u={},c=0,d=0;for(let l of o)u[l.category]||(u[l.category]=[]),u[l.category].push({emoji:n&&n!=="none"&&l.skins?l.skins[n]:l.emoji,label:l.label});for(let l of e.categories){let m=u[l.index];if(!m||m.length===0)continue;let g=qB(Array.from(m),t).map(v=>({categoryIndex:c,emojis:v}));s.push(...g),i.push({label:l.label,rowsCount:g.length,startRowIndex:d}),a.push(d),c++,d+=g.length}return{count:o.length,categories:i,categoriesStartRowIndices:a,rows:s,skinTones:e.skinTones}}function ZB(e){let t={},n=null,r=null,o=new Set,s=()=>{if(n){t=n,n=null;for(let c of o)c(t)}r=null},i=()=>n??t,a=c=>{n??=t,Object.assign(n,typeof c=="function"?c(i()):c),r||(r=requestAnimationFrame(s))},u=c=>(o.add(c),()=>o.delete(c));return t=e(a,i),{get:i,set:a,subscribe:u}}function XB(e){let[t]=f.useState(e);return t}function QB(e){let t=f.createContext(null);return{useStore:()=>{let n=f.useContext(t);if(!n)throw new Error(e);return n},Provider:({store:n,children:r})=>h.jsx(t.Provider,{value:n,children:r})}}function Lt(e,t,n=Object.is){let[r,o]=f.useState(()=>t(e.get()));return f.useEffect(()=>e.subscribe(()=>{let s=t(e.get());o(i=>n(i,s)?i:s)}),[e,t,n]),f.useDebugValue(r),r}function An(e,t,n){let r=f.useCallback(o=>o[t],[t]);return Lt(e,r,n)}var Th=2;function eF(e,t,n,r){let o=0;return ZB((s,i)=>({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=i(),c=a?.data??u.data,d=a?.categoryHeaderHeight??u.categoryHeaderHeight,l=a?.rowHeight??u.rowHeight,m=a?.viewportHeight??u.viewportHeight;if(!c||c.rows.length===0||!d||!l||!m)return s({...a,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let g=0,v=0;for(let S of c.categories)if(v++*d+S.startRowIndex*l<o)g+=d;else break;let C=c.categories.length*d+c.rows.length*l,p=Math.floor(Th*l/2),D=Math.ceil(Th*l/2),w=Math.min(o-g-p,C-m),b=w+m+D,y=Math.max(0,Math.floor(w/l)),A=Math.min(c.rows.length-1,Math.ceil(b/l)),T=c.rows[y]?.categoryIndex;return s(T===void 0&&a?a:{...a,viewportStartCategoryIndex:T,viewportStartRowIndex:y,viewportEndRowIndex:A})},onDataChange:a=>{i().updateViewportState({data:a,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:a=>{s({search:a,interaction:a?"keyboard":"none"})},onActiveEmojiChange:(a,u,c)=>{if(s({interaction:a,activeColumnIndex:u,activeRowIndex:c}),a!=="keyboard")return;let{listRef:d,viewportRef:l,rowHeight:m,viewportHeight:g,categoryHeaderHeight:v}=i(),C=d?.current,p=l?.current;if(!C||!p||!m||!v||!g)return;let D=c;D===0&&p.scrollTo({top:0,behavior:"instant"});let w=C.querySelector(`[aria-rowindex="${D}"]`);if(!(w instanceof HTMLElement))return;let b=w.offsetTop,y=getComputedStyle(w),A=Number.parseFloat(y.scrollMarginTop),T=Number.parseFloat(y.scrollMarginBottom),S=o+A;b<o+g/2&&(S+=v);let P=S+g-T;(b<S||b+m>P)&&p.scrollTo({top:Math.max(b<S+v?b-Math.max(v,A):b-g+m+T,0),behavior:"instant"})},onActiveEmojiReset:()=>{s({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:a=>{i().updateViewportState({rowHeight:a})},onCategoryHeaderHeightChange:a=>{i().updateViewportState({categoryHeaderHeight:a})},onViewportSizeChange:(a,u)=>{i().updateViewportState({viewportWidth:a,viewportHeight:u})},onViewportScroll:a=>{o=a,i().updateViewportState()}}))}var{useStore:Pt,Provider:tF}=QB("EmojiPicker.Root is missing.");function nF(e){return e.search}function El(e){return e.interaction==="none"?void 0:e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex]}function rF(e){return e.data===void 0||typeof e.data?.count=="number"&&e.data.count===0}function oF(e){return e.data===null||e.viewportHeight===null||e.rowHeight===null||e.categoryHeaderHeight===null}function M0(e){return e.data?.rows.length}function sF(e){return e.data?.categories.length}function iF(e){return e.data?.categoriesStartRowIndices}function aF(e){return e.data?.skinTones}function _0(e,t){return e?.emoji===t?.emoji}function uF(e,t){return e?.categoryIndex!==t?.categoryIndex||e?.emojis.length!==t?.emojis.length?!1:!!e?.emojis.every((n,r)=>_0(n,t?.emojis[r]))}var Po="",Rh=new RegExp("\\p{Emoji_Modifier_Base}","u"),cF=/\uFE0F$/,lF=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,dF={light:"🏻","medium-light":"🏼",medium:"🏽","medium-dark":"🏾",dark:"🏿"};function fF(e,t){if(!e.split(Po).some(r=>Rh.test(r)))return e;let n=e.split(Po).map(r=>r.replace(lF,"")).join(Po);return t==="none"?n:n.split(Po).map((r,o,s)=>{let i=s.length>1;return!Rh.test(r)||i&&r==="🤝"?r:r.replace(cF,"")+dF[t]}).join(Po)}function hF(e){return Cl.map(t=>({skinTone:t,emoji:fF(e,t)}))}function k0(){let e=Pt(),t=Lt(e,El,_0);return f.useDeferredValue(t)}function N0(e="✋"){let t=Pt(),n=An(t,"skinTone"),r=f.useMemo(()=>hF(e),[e]),o=f.useCallback(s=>{t.set({skinTone:s})},[]);return[n,o,r]}function yl(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?!1:n.every(o=>o in t&&e[o]===t[o])}function pF(...e){}function mF(e,t){let n=null;if(typeof window.requestIdleCallback=="function")n=window.requestIdleCallback(e,t);else{let r=Date.now();n=window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,t?.timeout-(Date.now()-r))})},10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback(n):window.clearTimeout(n)}}var fn=typeof window<"u"?f.useLayoutEffect:f.useEffect;function gF(e){let t=f.useRef(e);return fn(()=>{t.current=e}),f.useCallback((...n)=>t.current(...n),[])}function vF({emojiVersion:e,emojibaseUrl:t}){let[n,r]=f.useState(void 0),o=Pt(),s=An(o,"locale"),i=An(o,"columns"),a=An(o,"skinTone"),u=An(o,"search");return f.useEffect(()=>{let c=new AbortController,d=c.signal;return GB({locale:s,emojiVersion:e,emojibaseUrl:t,signal:d}).then(l=>{r(l)}).catch(l=>{d.aborted||console.error(l)}),()=>{c.abort()}},[e,t,s]),f.useEffect(()=>{if(n)return mF(()=>{o.get().onDataChange(JB(n,i,a,u))},{timeout:100})},[n,i,a,u]),null}var j0=f.forwardRef(({locale:e="en",columns:t=9,skinTone:n="none",onEmojiSelect:r=pF,emojiVersion:o,emojibaseUrl:s,onFocusCapture:i,onBlurCapture:a,children:u,style:c,...d},l)=>{let m=gF(r),g=XB(()=>eF(m,xh(e),t,Oh(n))),[v,C]=f.useState(!1),p=f.useRef(null),D=f.useCallback(y=>{y&&(p.current=y,g.set({rootRef:p}))},[]);fn(()=>{g.set({locale:xh(e)})},[e]),fn(()=>{g.set({columns:t})},[t]),fn(()=>{g.set({skinTone:Oh(n)})},[n]);let w=f.useCallback(y=>{i?.(y);let{searchRef:A,viewportRef:T}=g.get(),S=y.target===A?.current||y.target.hasAttribute("frimousse-search"),P=y.target===T?.current||y.target.hasAttribute("frimousse-viewport");y.isDefaultPrevented()||(C(S||P),y.isDefaultPrevented()||(C(S||P),P?g.get().onActiveEmojiChange("keyboard",0,0):S&&g.get().search===""&&g.set({interaction:"none"})))},[i]),b=f.useCallback(y=>{a?.(y),!y.isDefaultPrevented()&&!y.currentTarget.contains(y.relatedTarget)&&C(!1)},[a]);return fn(()=>{v||g.get().onActiveEmojiReset()},[v]),f.useImperativeHandle(l,()=>p.current),f.useEffect(()=>{if(!v)return;function y(A){if(A.defaultPrevented||!A.key.startsWith("Arrow")&&A.key!=="Enter")return;let{data:T,onEmojiSelect:S,onActiveEmojiChange:P,interaction:L,activeColumnIndex:F,activeRowIndex:M}=g.get();if(A.key==="Enter"){let N=El(g.get());N&&(A.preventDefault(),S(N))}if(A.key.startsWith("Arrow")){let N=F,_=M;if(A.preventDefault(),L!=="none"){if(T?.rows&&T.rows.length>0)switch(A.key){case"ArrowLeft":{if(N===0){let I=_-1,j=T.rows[I];j&&(_=I,N=j.emojis.length-1)}else N-=1;break}case"ArrowRight":{if(N===T.rows[_].emojis.length-1){let I=_+1;T.rows[I]&&(_=I,N=0)}else N+=1;break}case"ArrowUp":{let I=T.rows[_-1];I&&(_-=1,I.emojis[N]||(N=I.emojis.length-1));break}case"ArrowDown":{let I=T.rows[_+1];I&&(_+=1,I.emojis[N]||(N=I.emojis.length-1));break}}P("keyboard",N,_)}else P("keyboard",0,0)}}return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[v]),fn(()=>{let y=null,A=null,T=null,S=null,P=g.subscribe(_=>{p.current&&(y!==_.viewportWidth&&(y=_.viewportWidth,p.current.style.setProperty("--frimousse-viewport-width",`${_.viewportWidth}px`)),A!==_.viewportHeight&&(A=_.viewportHeight,p.current.style.setProperty("--frimousse-viewport-height",`${_.viewportHeight}px`)),T!==_.rowHeight&&(T=_.rowHeight,p.current.style.setProperty("--frimousse-row-height",`${_.rowHeight}px`)),S!==_.categoryHeaderHeight&&(S=_.categoryHeaderHeight,p.current.style.setProperty("--frimousse-category-header-height",`${_.categoryHeaderHeight}px`)))}),{viewportWidth:L,viewportHeight:F,rowHeight:M,categoryHeaderHeight:N}=g.get();return L&&p.current.style.setProperty("--frimousse-viewport-width",`${L}px`),F&&p.current.style.setProperty("--frimousse-viewport-height",`${F}px`),M&&p.current.style.setProperty("--frimousse-row-height",`${M}px`),N&&p.current.style.setProperty("--frimousse-category-header-height",`${N}px`),P},[]),h.jsx("div",{"data-focused":v?"":void 0,"frimousse-root":"",onBlurCapture:b,onFocusCapture:w,...d,ref:D,style:{"--frimousse-emoji-font":T0,...c},children:h.jsxs(tF,{store:g,children:[h.jsx(vF,{emojiVersion:o,emojibaseUrl:s}),u]})})}),L0=f.forwardRef(({value:e,defaultValue:t,onChange:n,...r},o)=>{let s=Pt(),i=f.useRef(null),a=f.useCallback(l=>{l&&(i.current=l,s.set({searchRef:i}))},[]),u=typeof e=="string",c=f.useRef(u);f.useEffect(()=>{c.current=u},[u]),fn(()=>{s.set({search:typeof e=="string"?e:typeof t=="string"?t:""})},[]),fn(()=>{typeof e=="string"&&s.get().onSearchChange(e)},[e]);let d=f.useCallback(l=>{n?.(l),l.isDefaultPrevented()||s.get().onSearchChange(l.target.value)},[n]);return f.useImperativeHandle(o,()=>i.current),h.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...r,defaultValue:t,onChange:d,ref:a,value:e})}),CF=f.memo(()=>{let e=k0();return e?h.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}),U0=f.forwardRef(({children:e,onScroll:t,onKeyDown:n,style:r,...o},s)=>{let i=Pt(),a=f.useRef(null),u=f.useCallback(m=>{m&&(a.current=m,i.set({viewportRef:a}))},[]),c=Lt(i,M0),d=Lt(i,sF),l=f.useCallback(m=>{t?.(m),i.get().onViewportScroll(m.currentTarget.scrollTop)},[t]);return fn(()=>{if(!a.current)return;let m=new ResizeObserver(([g])=>{let v=g?.borderBoxSize[0]?.inlineSize??0,C=g?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:p,viewportHeight:D,viewportWidth:w}=i.get();(D!==C||w!==v)&&p(v,C)});return m.observe(a.current),i.get().onViewportSizeChange(a.current.offsetWidth,a.current.clientHeight),()=>{m.disconnect()}},[]),f.useImperativeHandle(s,()=>a.current),h.jsxs("div",{"frimousse-viewport":"",...o,onScroll:l,ref:u,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof c=="number"&&typeof d=="number"?`var(--frimousse-viewport-width, auto) calc(${c} * var(--frimousse-row-height) + ${d} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...r},children:[h.jsx(CF,{}),e]})});function $0(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 H0(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 V0(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 W0(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 Ih(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 Bh(e,t,n){return{"aria-colcount":e,"aria-rowcount":t,"frimousse-list":"",style:{"--frimousse-list-columns":e,...n},role:"grid"}}function EF(e){e.preventDefault()}var yF=f.memo(({Emoji:e,emoji:t,columnIndex:n,rowIndex:r})=>{let o=Pt(),s=Lt(o,c=>El(c)?.emoji===t.emoji),i=f.useCallback(()=>{o.get().onEmojiSelect(t)},[t]),a=f.useCallback(()=>{o.get().onActiveEmojiChange("pointer",n,r)},[n,r]),u=f.useCallback(()=>{o.get().onActiveEmojiReset()},[]);return h.jsx(e,{...$0(t,n,s),onClick:i,onPointerDown:EF,onPointerEnter:a,onPointerLeave:u})}),bF=f.memo(({Row:e,Emoji:t,rowIndex:n})=>{let r=Pt(),o=Lt(r,s=>s.data?.rows[n],uF);return o?h.jsx(e,{...H0(n),children:o.emojis.map((s,i)=>h.jsx(yF,{Emoji:t,columnIndex:i,emoji:s,rowIndex:n},s.label))}):null}),wF=f.memo(({CategoryHeader:e,categoryIndex:t})=>{let n=Pt(),r=Lt(n,o=>o.data?.categories[t],yl);return r?h.jsx("div",{...V0(t,r),children:h.jsx(e,{...W0({label:r.label})})}):null}),Fh=f.memo(({CategoryHeader:e,Row:t,Emoji:n})=>{let r=f.useRef(null),o=Pt(),s=An(o,"columns"),i=f.useMemo(()=>Array(s).fill({emoji:"🙂",label:""}),[s]),a=f.useMemo(()=>({label:"Category"}),[]),u=f.useRef(null),c=f.useRef(null);return fn(()=>{let d=r.current?.parentElement?.parentElement;if(!d||!u.current||!c.current)return;let l=new ResizeObserver(v=>{for(let C of v){let p=C.contentRect.height,{onRowHeightChange:D,onCategoryHeaderHeightChange:w,rowHeight:b,categoryHeaderHeight:y}=o.get();C.target===u.current&&b!==p&&D(p),C.target===c.current&&y!==p&&w(p)}});l.observe(d),l.observe(u.current),l.observe(c.current);let{onRowHeightChange:m,onCategoryHeaderHeightChange:g}=o.get();return m(u.current.clientHeight),g(c.current.clientHeight),()=>{l.disconnect()}},[]),h.jsxs("div",{"aria-hidden":!0,ref:r,style:{height:0,visibility:"hidden"},children:[h.jsx("div",{"frimousse-row-sizer":"",ref:u,children:h.jsx(t,{...H0(-1,!0),children:i.map((d,l)=>h.jsx(n,{...$0(d,l,!1)},l))})}),h.jsx("div",{...V0(-1),children:h.jsx("div",{"frimousse-category-header-sizer":"",ref:c,children:h.jsx(e,{...W0(a,!0)})})})]})});function DF({category:e,...t}){return h.jsx("div",{...t,children:e.label})}function AF({emoji:e,...t}){return h.jsx("button",{type:"button",...t,children:e.emoji})}function SF({...e}){return h.jsx("div",{...e})}var z0=f.forwardRef(({style:e,components:t,...n},r)=>{let o=Pt(),s=f.useRef(null),i=f.useCallback(D=>{D&&(s.current=D,o.set({listRef:s}))},[]),a=t?.CategoryHeader??DF,u=t?.Emoji??AF,c=t?.Row??SF,d=An(o,"columns"),l=An(o,"viewportStartRowIndex"),m=An(o,"viewportEndRowIndex"),g=Lt(o,M0),v=Lt(o,iF,yl),C=f.useMemo(()=>v?.filter(D=>D<l).length??0,[v,l]),p=v?.length??0;return f.useImperativeHandle(r,()=>s.current),!g||!v||p===0?h.jsx("div",{...Bh(d,0,e),...n,children:h.jsx("div",{...Ih(0,0,0,0),children:h.jsx(Fh,{CategoryHeader:a,Emoji:u,Row:c})})}):h.jsx("div",{...Bh(d,g,e),...n,ref:i,children:h.jsxs("div",{...Ih(g,p,l,C),children:[h.jsx(Fh,{CategoryHeader:a,Emoji:u,Row:c}),Array.from({length:m-l+1},(D,w)=>{let b=l+w,y=v.indexOf(b);return h.jsxs(f.Fragment,{children:[y>=0&&h.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),h.jsx(bF,{Emoji:u,Row:c,rowIndex:b})]},b)}),Array.from({length:p},(D,w)=>h.jsx(wF,{CategoryHeader:a,categoryIndex:w},w))]})})}),K0=f.forwardRef(({emoji:e,onClick:t,"aria-label":n="Change skin tone",...r},o)=>{let s=Pt(),i=Lt(s,aF,yl),[a,u,c]=N0(e),d=f.useMemo(()=>Math.max(0,c.findIndex(p=>p.skinTone===a)),[a,c]),l=c[d],m=c[(d+1)%c.length].skinTone,g=a==="none"?void 0:i?.[a],v=m==="none"?void 0:i?.[m],C=f.useCallback(p=>{t?.(p),p.isDefaultPrevented()||u(m)},[t,u,m]);return h.jsx("button",{type:"button",...r,"aria-label":n+(v?` (${v})`:""),"aria-live":"polite","aria-valuetext":g,"frimousse-skin-tone-selector":"",onClick:C,ref:o,children:l.emoji})});function G0({children:e,...t}){let n=Pt();return Lt(n,oF)?h.jsx("span",{"frimousse-loading":"",...t,children:e}):null}function xF({children:e}){let t=Pt(),n=Lt(t,nF);return e({search:n})}function q0({children:e,...t}){let n=Pt();return Lt(n,rF)?h.jsx("span",{"frimousse-empty":"",...t,children:typeof e=="function"?h.jsx(xF,{children:e}):e}):null}function Y0({children:e}){let t=k0();return e({emoji:t})}function J0({children:e,emoji:t}){let[n,r,o]=N0(t);return e({skinTone:n,setSkinTone:r,skinToneVariations:o})}j0.displayName="EmojiPicker.Root";L0.displayName="EmojiPicker.Search";U0.displayName="EmojiPicker.Viewport";z0.displayName="EmojiPicker.List";G0.displayName="EmojiPicker.Loading";q0.displayName="EmojiPicker.Empty";K0.displayName="EmojiPicker.SkinToneSelector";Y0.displayName="EmojiPicker.ActiveEmoji";J0.displayName="EmojiPicker.SkinTone";function OF({emoji:e,className:t,...n}){return h.jsx("button",{className:Be("lb-emoji-picker-emoji",t),...n,children:h.jsx(gc,{emoji:e.emoji})})}function TF({children:e,className:t,...n}){return h.jsx("div",{className:Be("lb-emoji-picker-row",t),...n,children:e})}function RF({category:e,className:t,...n}){return h.jsx("div",{className:Be("lb-emoji-picker-category-header",t),...n,children:h.jsx("span",{className:"lb-emoji-picker-category-header-title",children:e.label})})}const zu=f.forwardRef(({onEmojiSelect:e,onOpenChange:t,children:n,className:r,...o},s)=>{const[i,a]=f.useState(!1),{portalContainer:u,emojibaseUrl:c}=Ss(),d=st(),l=f.useCallback(v=>{a(v),t?.(v)},[t]),m=f.useCallback(({emoji:v})=>{a(!1),e?.(v)},[e]),g=f.useCallback(v=>{v.stopPropagation()},[]);return h.jsxs($2,{open:i,onOpenChange:l,children:[n,h.jsx(V2,{container:u,children:h.jsx(W2,{side:"top",align:"center",updatePositionStrategy:"always",sideOffset:Do,collisionPadding:vs,className:Be("lb-root lb-portal lb-elevation lb-emoji-picker",r),...o,ref:s,asChild:!0,children:h.jsxs(wn.Root,{onEmojiSelect:m,locale:d.locale,columns:10,emojiVersion:15.1,emojibaseUrl:c,onClick:g,children:[h.jsx("div",{className:"lb-emoji-picker-header",children:h.jsxs("div",{className:"lb-emoji-picker-search-container",children:[h.jsx(wn.Search,{className:"lb-emoji-picker-search",placeholder:d.EMOJI_PICKER_SEARCH_PLACEHOLDER,autoFocus:!0}),h.jsx(Wx,{})]})}),h.jsxs(wn.Viewport,{className:"lb-emoji-picker-content",children:[h.jsx(wn.Loading,{className:"lb-loading lb-emoji-picker-loading",children:h.jsx(xs,{})}),h.jsx(wn.Empty,{className:"lb-empty lb-emoji-picker-empty",children:d.EMOJI_PICKER_EMPTY}),h.jsx(wn.List,{className:"lb-emoji-picker-list",components:{CategoryHeader:RF,Row:TF,Emoji:OF}})]}),h.jsxs("div",{className:"lb-emoji-picker-footer",children:[h.jsx(wn.ActiveEmoji,{children:({emoji:v})=>v?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"lb-emoji-picker-active-emoji",children:v.emoji}),h.jsx("span",{className:"lb-emoji-picker-active-emoji-label",children:v.label})]}):h.jsx("span",{className:"lb-emoji-picker-active-emoji-label lb-emoji-picker-active-emoji-label-placeholder",children:"Select an emoji…"})}),h.jsx(Et,{content:d.EMOJI_PICKER_CHANGE_SKIN_TONE,children:h.jsx(wn.SkinToneSelector,{className:"lb-button lb-emoji-picker-skin-tone-selector"})})]})]})})})]})}),Ku=H2;function IF({label:e,tooltipLabel:t,className:n,onClick:r,...o}){const{createMention:s}=Ut(),i=f.useCallback(u=>{u.preventDefault()},[]),a=f.useCallback(u=>{r?.(u),u.isDefaultPrevented()||(u.stopPropagation(),s())},[s,r]);return h.jsx(Et,{content:t??e,children:h.jsx(Bt,{className:Be("lb-composer-editor-action",n),onPointerDown:i,onClick:a,"aria-label":e,icon:h.jsx(Vx,{}),...o})})}function BF({label:e,tooltipLabel:t,onPickerOpenChange:n,className:r,...o}){const{insertText:s}=Ut(),i=f.useCallback(u=>{u.preventDefault()},[]),a=f.useCallback(u=>{u.stopPropagation()},[]);return h.jsx(zu,{onEmojiSelect:s,onOpenChange:n,children:h.jsx(Et,{content:t??e,children:h.jsx(Ku,{asChild:!0,children:h.jsx(Bt,{className:Be("lb-composer-editor-action",r),onPointerDown:i,onClick:a,"aria-label":e,icon:h.jsx($x,{}),...o})})})})}function FF({label:e,tooltipLabel:t,className:n,...r}){const o=f.useCallback(i=>{i.preventDefault()},[]),s=f.useCallback(i=>{i.stopPropagation()},[]);return h.jsx(Et,{content:t??e,children:h.jsx(EB,{asChild:!0,children:h.jsx(Bt,{className:Be("lb-composer-editor-action",n),onPointerDown:o,onClick:s,"aria-label":e,icon:h.jsx(Gg,{}),...r})})})}function PF({mention:e}){return h.jsxs(gl,{className:"lb-mention lb-composer-mention",children:[h.jsx("span",{className:"lb-mention-symbol",children:mn}),h.jsx(Cn,{userId:e.id})]})}function MF({mention:e}){const t=w0(e);return h.jsxs(gl,{className:"lb-mention lb-composer-mention","data-self":t?"":void 0,children:[h.jsx("span",{className:"lb-mention-symbol",children:mn}),h.jsx(Wc,{groupId:e.id})]})}function _F({mention:e,...t}){switch(e.kind){case"user":return h.jsx(PF,{mention:e,...t});case"group":return h.jsx(MF,{mention:e,...t});default:return Je(e,"Unhandled mention kind")}}function kF({mentions:e}){return e.length>0?h.jsx(v0,{className:"lb-root lb-portal lb-elevation lb-composer-suggestions lb-composer-mention-suggestions",children:h.jsx(C0,{className:"lb-composer-suggestions-list lb-composer-mention-suggestions-list",children:e.map(t=>h.jsx(E0,{className:"lb-composer-suggestions-list-item lb-composer-mention-suggestion",value:t.id,children:t.kind==="user"?h.jsxs(h.Fragment,{children:[h.jsx(qi,{userId:t.id,className:"lb-composer-mention-suggestion-avatar"}),h.jsx(Cn,{userId:t.id,className:"lb-composer-mention-suggestion-user"})]}):t.kind==="group"?h.jsxs(h.Fragment,{children:[h.jsx(Bx,{groupId:t.id,className:"lb-composer-mention-suggestion-avatar",icon:h.jsx(Gx,{})}),h.jsx(Wc,{groupId:t.id,className:"lb-composer-mention-suggestion-group",children:h.jsx(Px,{groupId:t.id,className:"lb-composer-mention-suggestion-group-description"})})]}):Je(t,"Unhandled mention kind")},t.id))})}):null}function Ys({mark:e,icon:t,shortcut:n,children:r,...o}){const s=st(),i=f.useMemo(()=>s.COMPOSER_TOGGLE_MARK(e),[s,e]);return h.jsx(Hc,{content:i,shortcut:n,sideOffset:Do+2,children:h.jsx(yB,{mark:e,asChild:!0,...o,children:h.jsx(Bt,{"aria-label":i,variant:"toolbar",icon:t,children:r})})})}const NF={bold:()=>h.jsx(Ys,{mark:"bold",shortcut:"Mod-B",icon:h.jsx(_x,{})}),italic:()=>h.jsx(Ys,{mark:"italic",shortcut:"Mod-I",icon:h.jsx(Hx,{})}),strikethrough:()=>h.jsx(Ys,{mark:"strikethrough",shortcut:"Mod-Shift-S",icon:h.jsx(Kx,{})}),code:()=>h.jsx(Ys,{mark:"code",shortcut:"Mod-E",icon:h.jsx(jx,{})})},jF=Object.entries(NF).map(([e,t])=>h.jsx(t,{},e));function LF(){return h.jsx(cB,{className:"lb-root lb-portal lb-elevation lb-composer-floating-toolbar",children:jF})}function UF({href:e,children:t}){return h.jsx(g0,{href:e,className:"lb-composer-link",children:t})}function $F({attachment:e,className:t,overrides:n,...r}){const{removeAttachment:o}=Ut(),{roomId:s}=ea(),i=f.useCallback(()=>{o(e.id)},[e.id,o]);return h.jsx(vl,{className:Be("lb-composer-attachment",t),...r,attachment:e,onDeleteClick:i,preventFocusOnDelete:!0,overrides:n,roomId:s})}function HF({overrides:e,className:t,...n}){const{attachments:r}=Ut();return r.length===0?null:h.jsx("div",{className:Be("lb-composer-attachments",t),...n,children:h.jsx("div",{className:"lb-attachments",children:r.map(o=>h.jsx($F,{attachment:o,overrides:e},o.id))})})}const VF={Mention:_F,MentionSuggestions:kF,Link:UF};function WF({showAttachments:e=!0,showFormattingControls:t=!0,showAttribution:n,defaultValue:r,isCollapsed:o,overrides:s,actions:i,autoFocus:a,disabled:u,hasResolveMentionSuggestions:c,onEmojiPickerOpenChange:d,onEmptyChange:l,onEditorClick:m}){const{isEmpty:g}=Ut(),{hasMaxAttachments:v}=hl(),C=st(s),p=f.useMemo(()=>({...VF,FloatingToolbar:t?LF:void 0}),[t]),[D,w]=m0({disabled:u||!e||v});gn(()=>{l(g)},[g,l]);const b=f.useCallback(A=>{A.preventDefault()},[]),y=f.useCallback(A=>{A.stopPropagation()},[]);return h.jsxs("div",{className:"lb-composer-editor-container",...w,children:[h.jsx(pB,{className:"lb-composer-editor",onClick:m,placeholder:C.COMPOSER_PLACEHOLDER,defaultValue:r,autoFocus:a,components:p,disabled:u,dir:C.dir}),e&&h.jsx(HF,{overrides:s}),(!o||D)&&h.jsxs("div",{className:"lb-composer-footer",children:[h.jsxs("div",{className:"lb-composer-editor-actions",children:[c&&h.jsx(IF,{label:C.COMPOSER_INSERT_MENTION,disabled:u}),h.jsx(BF,{label:C.COMPOSER_INSERT_EMOJI,onPickerOpenChange:d,disabled:u}),e&&h.jsx(FF,{label:C.COMPOSER_ATTACH_FILES,disabled:u})]}),n&&h.jsx(NB,{}),h.jsx("div",{className:"lb-composer-actions",children:i??h.jsx(h.Fragment,{children:h.jsx(Hc,{content:C.COMPOSER_SEND,shortcut:"Enter",children:h.jsx(y0,{asChild:!0,children:h.jsx(Bt,{onPointerDown:b,onClick:y,className:"lb-composer-action",variant:"primary","aria-label":C.COMPOSER_SEND,icon:h.jsx(zx,{})})})})})})]}),e&&D&&h.jsx("div",{className:"lb-composer-attachments-drop-area",children:h.jsxs("div",{className:"lb-composer-attachments-drop-area-label",children:[h.jsx(Gg,{}),C.COMPOSER_ATTACH_FILES]})})]})}f.createContext(null);const Z0=f.forwardRef(({threadId:e,commentId:t,metadata:n,visibility:r,commentMetadata:o,defaultValue:s,defaultAttachments:i,onComposerSubmit:a,collapsed:u,defaultCollapsed:c,onCollapsedChange:d,overrides:l,actions:m,onBlur:g,className:v,onFocus:C,autoFocus:p,disabled:D,blurOnSubmit:w=!0,showAttachments:b=!0,showFormattingControls:y=!0,showAttribution:A,roomId:T,...S},P)=>{const L=jp({allowOutsideRoom:!0}),F=T!==void 0?T:L?.id;if(F===void 0)throw new Error("Composer must be a descendant of RoomProvider component");const M=Fp(F),N=Pp(F),_=Mp(F),{preventUnsavedComposerChanges:I}=Ss(),j=pc()!==void 0,z=f.useRef(!0),Y=f.useRef(!1),oe=st(l),[G,Z]=j5(c??!1,u,d),le=u!==void 0||c===!0,de=mi(e===void 0?r??"public":r),ue=mc(F,de,"write"),ee=f.useCallback(ie=>{z.current=ie},[]),te=f.useCallback(ie=>{Y.current=ie},[]),R=f.useCallback(ie=>{C?.(ie),!ie.isDefaultPrevented()&&z.current&&ue&&Z?.(!1)},[Z,C,ue]),q=f.useCallback(ie=>{if(g?.(ie),ie.isDefaultPrevented())return;const ae=!ie.currentTarget.contains(ie.relatedTarget??document.activeElement);le&&ae&&z.current&&!Y.current&&Z?.(!0)},[g,Z,le]),J=f.useCallback(ie=>{ie.stopPropagation(),z.current&&ue&&Z?.(!1)},[Z,ue]),X=f.useCallback((ie,ae)=>{a?.(ie,ae),!ae.isDefaultPrevented()&&(ae.stopPropagation(),t&&e?_({commentId:t,threadId:e,body:ie.body,metadata:o,attachments:ie.attachments}):e?N({threadId:e,body:ie.body,metadata:o,attachments:ie.attachments}):M({body:ie.body,metadata:n,visibility:r,commentMetadata:o,attachments:ie.attachments}))},[t,N,M,_,o,n,r,a,e]);return h.jsx(xo,{children:h.jsx(CB,{onComposerSubmit:X,className:Be("lb-root lb-composer lb-composer-form",v),dir:oe.dir,...S,ref:P,"data-collapsed":G?"":void 0,onFocus:R,onBlur:q,disabled:D||!ue,defaultAttachments:i,pasteFilesAsAttachments:b,preventUnsavedChanges:I,blurOnSubmit:w,roomId:F,children:h.jsx(WF,{defaultValue:s,actions:m,overrides:l,isCollapsed:G,showAttachments:b,showAttribution:A,showFormattingControls:y,hasResolveMentionSuggestions:j,onEmptyChange:ee,onEmojiPickerOpenChange:te,onEditorClick:J,autoFocus:p,disabled:D})})})});function X0({children:e,content:t,defaultOpen:n,open:r,onOpenChange:o,className:s,...i}){const a=st(),{portalContainer:u}=Ss();return h.jsxs(O2,{defaultOpen:n,open:r,onOpenChange:o,dir:a.dir,children:[e,h.jsx(R2,{container:u,children:h.jsx(I2,{className:Be("lb-root lb-portal lb-elevation lb-dropdown",s),sideOffset:Do,collisionPadding:vs,updatePositionStrategy:"always",...i,children:t})})]})}const Si=f.forwardRef(({children:e,className:t,icon:n,...r},o)=>h.jsxs(gg,{className:Be("lb-dropdown-item",t),...r,ref:o,children:[n?h.jsx("span",{className:"lb-dropdown-item-icon lb-icon-container",children:n}):null,e?h.jsx("span",{className:"lb-dropdown-item-label",children:e}):null]})),Q0=T2,zF=5;function KF(e){return h.jsx(qi,{...e})}function GF(e){return h.jsx(Cn,{...e})}function Ph({locale:e,date:t,className:n,...r}){return h.jsx(b0,{locale:e,date:t,className:Be("lb-date",n),...r})}function qF({mention:e,className:t,...n}){const r=Rn();return h.jsxs(cl,{className:Be("lb-mention lb-comment-mention",t),"data-self":e.id===r?"":void 0,...n,children:[h.jsx("span",{className:"lb-mention-symbol",children:mn}),h.jsx(Cn,{userId:e.id})]})}function YF({mention:e,className:t,...n}){const r=w0(e);return h.jsxs(cl,{className:Be("lb-mention lb-comment-mention",t),"data-self":r?"":void 0,...n,children:[h.jsx("span",{className:"lb-mention-symbol",children:mn}),h.jsx(Wc,{groupId:e.id})]})}function eC({mention:e,...t}){switch(e.kind){case"user":return h.jsx(qF,{mention:e,...t});case"group":return h.jsx(YF,{mention:e,...t});default:return Je(e,"Unhandled mention kind")}}function JF({href:e,children:t,className:n,...r}){const{Anchor:o}=Vg();return h.jsx($v,{className:Be("lb-comment-link",n),href:e,...r,asChild:!0,children:h.jsx(o,{...r,children:t})})}function ZF({href:e,children:t,className:n,...r}){return h.jsx("span",{className:Be("lb-comment-link",n),...r,children:t})}const tC=f.forwardRef(({reaction:e,overrides:t,className:n,...r},o)=>{const s=st(t);return h.jsxs(Vc,{className:Be("lb-comment-reaction",n),variant:"outline","aria-label":s.COMMENT_REACTION_DESCRIPTION(e.emoji,e.users.length),...r,ref:o,children:[h.jsx(gc,{className:"lb-comment-reaction-emoji",emoji:e.emoji}),h.jsx("span",{className:"lb-comment-reaction-count",children:e.users.length})]})}),XF=f.forwardRef(({comment:e,reaction:t,overrides:n,disabled:r,...o},s)=>{const i=_p(e.roomId),a=kp(e.roomId),u=Rn(),c=f.useMemo(()=>t.users.some(v=>v.id===u),[u,t]),d=st(n),l=f.useMemo(()=>h.jsx("span",{children:d.COMMENT_REACTION_LIST(h.jsx(Kg,{values:t.users.map(v=>h.jsx(Cn,{userId:v.id,replaceSelf:!0},v.id)),formatRemaining:d.LIST_REMAINING_USERS,truncate:zF,locale:d.locale}),t.emoji,t.users.length)}),[d,t]),m=f.useCallback(v=>{v.stopPropagation()},[]),g=f.useCallback(v=>{v?i({threadId:e.threadId,commentId:e.id,emoji:t.emoji}):a({threadId:e.threadId,commentId:e.id,emoji:t.emoji})},[i,e.threadId,e.id,t.emoji,a]);return h.jsx(Et,{content:l,multiline:!0,className:"lb-comment-reaction-tooltip",children:h.jsx(jc,{asChild:!0,pressed:c,onPressedChange:g,onClick:m,disabled:r,ref:s,children:h.jsx(tC,{"data-self":c?"":void 0,reaction:t,overrides:n,...o})})})}),QF=f.forwardRef(({reaction:e,overrides:t,...n},r)=>{const o=Rn(),s=f.useMemo(()=>e.users.some(i=>i.id===o),[o,e]);return h.jsx(tC,{disableable:!1,"data-self":s?"":void 0,reaction:e,overrides:t,...n,ref:r})});function nC({attachment:e,url:t}){e.mimeType==="application/pdf"||e.mimeType.startsWith("image/")||e.mimeType.startsWith("video/")||e.mimeType.startsWith("audio/")?window.open(t,"_blank"):TB(t,e.name)}function e4({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...s}){const{url:i}=Pi(e.id,n),a=f.useCallback(u=>{if(!i)return;const c={attachment:e,url:i};t?.(c,u),!u.isDefaultPrevented()&&nC(c)},[e,t,i]);return h.jsx(_B,{className:Be("lb-comment-attachment",r),...s,attachment:e,overrides:o,onClick:i?a:void 0,roomId:n})}function t4({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...s}){const{url:i}=Pi(e.id,n),a=f.useCallback(u=>{if(!i)return;const c={attachment:e,url:i};t?.(c,u),!u.isDefaultPrevented()&&nC(c)},[e,t,i]);return h.jsx(vl,{className:Be("lb-comment-attachment",r),...s,attachment:e,overrides:o,onClick:i?a:void 0,roomId:n})}function n4({className:e,...t}){return h.jsx(vl,{className:Be("lb-comment-attachment",e),allowMediaPreview:!1,...t})}const eu=f.forwardRef(({children:e,icon:t,onSelect:n,onClick:r,...o},s)=>{const i=f.useCallback(a=>{r?.(a),a.isDefaultPrevented()||a.stopPropagation()},[r]);return h.jsx(Si,{icon:t,onSelect:n,onClick:i,...o,ref:s,children:e})}),Mh=Object.assign(f.forwardRef(({comment:e,visibility:t,indentContent:n=!0,showDeleted:r,showActions:o="hover",showReactions:s=!0,showAttachments:i=!0,showComposerFormattingControls:a=!0,onAuthorClick:u,onMentionClick:c,onAttachmentClick:d,onCommentEdit:l,onCommentDelete:m,dropdownItems:g,overrides:v,components:C,additionalContent:p,body:D,avatar:w,author:b,date:y,className:A,actions:T,actionsClassName:S,internalDropdownItems:P,children:L,...F},M)=>{const N=`${e.id}:body`,_=f.useRef(null),I=Os(M,_),j=Rn(),z=gw(e.roomId),Y=Mp(e.roomId),oe=_p(e.roomId),G=kp(e.roomId),Z=st(v),[le,de]=f.useState(!1),[ue,ee]=f.useState(!1),[te,R]=f.useState(!1),[q,J]=f.useState(!1),{mediaAttachments:X,fileAttachments:ie}=f.useMemo(()=>kB(e.attachments),[e.attachments]),ae=mc(e.roomId,mi(t),"write"),we=f.useCallback(ne=>{ne.stopPropagation()},[]),Se=f.useCallback(()=>{de(!0)},[]),me=f.useCallback(ne=>{ne.stopPropagation(),de(!1)},[]),fe=f.useCallback(({body:ne,attachments:re},he)=>{l?.(e),!he.isDefaultPrevented()&&(he.stopPropagation(),he.preventDefault(),de(!1),Y({commentId:e.id,threadId:e.threadId,body:ne,attachments:re}))},[e,Y,l]),ye=f.useCallback(()=>{m?.(e),z({commentId:e.id,threadId:e.threadId})},[e,z,m]),be=f.useCallback(ne=>{u?.(e.userId,ne)},[e.userId,u]),xe=f.useCallback(ne=>{const re=e.reactions.findIndex(he=>he.emoji===ne);re>=0&&j&&e.reactions[re]?.users.some(he=>he.id===j)?G({threadId:e.threadId,commentId:e.id,emoji:ne}):oe({threadId:e.threadId,commentId:e.id,emoji:ne})},[oe,e.id,e.reactions,e.threadId,G,j]);if(f.useEffect(()=>{if(!(typeof window<"u"))return;window.location.hash.slice(1)===e.id&&ee(!0)},[]),!r&&!e.body)return null;const ke=e.userId===j?h.jsxs(h.Fragment,{children:[h.jsx(eu,{onSelect:Se,icon:h.jsx(Ux,{}),children:Z.COMMENT_EDIT}),h.jsx(eu,{onSelect:ye,icon:h.jsx(Jg,{}),children:Z.COMMENT_DELETE})]}):null,Me=P||ke?h.jsxs(h.Fragment,{children:[P,ke]}):null,O=typeof g=="function"?g({children:Me,comment:e}):Me||g?h.jsxs(h.Fragment,{children:[Me,g]}):null;let k;if(le)k=h.jsx(Z0,{className:"lb-comment-composer",threadId:e.threadId,commentId:e.id,visibility:t,onComposerSubmit:fe,defaultValue:e.body,defaultAttachments:e.attachments,autoFocus:!0,showAttribution:!1,showAttachments:i,showFormattingControls:a,actions:h.jsxs(h.Fragment,{children:[h.jsx(Et,{content:Z.COMMENT_EDIT_COMPOSER_CANCEL,"aria-label":Z.COMMENT_EDIT_COMPOSER_CANCEL,children:h.jsx(Bt,{className:"lb-composer-action",onClick:me,icon:h.jsx(Kc,{})})}),h.jsx(Hc,{content:Z.COMMENT_EDIT_COMPOSER_SAVE,shortcut:"Enter",children:h.jsx(y0,{asChild:!0,children:h.jsx(Bt,{variant:"primary",className:"lb-composer-action",onClick:we,"aria-label":Z.COMMENT_EDIT_COMPOSER_SAVE,icon:h.jsx(zc,{})})})})]}),overrides:{COMPOSER_PLACEHOLDER:Z.COMMENT_EDIT_COMPOSER_PLACEHOLDER},roomId:e.roomId});else{const ne=h.jsx(Hv,{className:"lb-comment-body",id:N,body:e.body,components:{Mention:({mention:re})=>h.jsx(eC,{mention:re,onClick:he=>c?.(re,he),overrides:v}),Link:JF}});k=e.body?h.jsxs(h.Fragment,{children:[D===void 0?ne:typeof D=="function"?D({comment:e,children:ne}):D,p,i&&(X.length>0||ie.length>0)?h.jsxs("div",{className:"lb-comment-attachments",children:[X.length>0?h.jsx("div",{className:"lb-attachments",children:X.map(re=>h.jsx(e4,{attachment:re,overrides:v,onAttachmentClick:d,roomId:e.roomId},re.id))}):null,ie.length>0?h.jsx("div",{className:"lb-attachments",children:ie.map(re=>h.jsx(t4,{attachment:re,overrides:v,onAttachmentClick:d,roomId:e.roomId},re.id))}):null]}):null,s&&e.reactions.length>0&&h.jsxs("div",{className:"lb-comment-reactions",children:[e.reactions.map(re=>h.jsx(XF,{comment:e,reaction:re,overrides:v,disabled:!ae},re.emoji)),ae?h.jsx(zu,{onEmojiSelect:xe,children:h.jsx(Et,{content:Z.COMMENT_ADD_REACTION,children:h.jsx(Ku,{asChild:!0,children:h.jsx(Bt,{className:"lb-comment-reaction lb-comment-reaction-add",variant:"outline",onClick:we,"aria-label":Z.COMMENT_ADD_REACTION,icon:h.jsx(Ld,{})})})})}):null]})]}):h.jsx("div",{className:"lb-comment-body",children:h.jsx("p",{className:"lb-comment-deleted",children:Z.COMMENT_DELETED})}),k=typeof L=="function"?L({comment:e,children:k}):L??k}return h.jsx(xo,{children:h.jsx(bx,{components:C,children:h.jsxs("div",{role:"article",id:e.id,className:Be("lb-root lb-comment",n&&"lb-comment:indent-content",o==="hover"&&"lb-comment:show-actions-hover",(te||q)&&"lb-comment:action-open",A),"data-deleted":e.body?void 0:"","data-editing":le?"":void 0,"data-target":ue?"":void 0,"aria-labelledby":N,dir:Z.dir,...F,ref:I,children:[h.jsxs("div",{className:"lb-comment-header",children:[h.jsxs("div",{className:"lb-comment-details",children:[w?h.jsx("div",{className:"lb-comment-avatar",onClick:be,children:w}):h.jsx(qi,{className:"lb-comment-avatar",userId:e.userId,onClick:be}),h.jsxs("span",{className:"lb-comment-details-labels",children:[b?h.jsx("span",{className:"lb-comment-author",onClick:be,children:b}):h.jsx(Cn,{className:"lb-comment-author",userId:e.userId,onClick:be}),y?h.jsx("span",{className:"lb-comment-date",children:y}):h.jsxs("span",{className:"lb-comment-date",children:[h.jsx(Ph,{locale:Z.locale,date:e.createdAt,className:"lb-comment-date-created"}),e.editedAt&&e.body&&h.jsxs(h.Fragment,{children:[" ",h.jsx("span",{className:"lb-comment-date-edited",children:Z.COMMENT_EDITED})]})]})]})]}),o&&!le&&h.jsxs("div",{className:Be("lb-comment-actions",S),children:[T??null,s&&ae?h.jsx(zu,{onEmojiSelect:xe,onOpenChange:J,children:h.jsx(Et,{content:Z.COMMENT_ADD_REACTION,children:h.jsx(Ku,{asChild:!0,children:h.jsx(Bt,{className:"lb-comment-action",onClick:we,"aria-label":Z.COMMENT_ADD_REACTION,icon:h.jsx(Ld,{})})})})}):null,O?h.jsx(X0,{open:te,onOpenChange:R,align:"end",content:O,children:h.jsx(Et,{content:Z.COMMENT_MORE,children:h.jsx(Q0,{asChild:!0,children:h.jsx(Bt,{className:"lb-comment-action",disabled:!e.body,onClick:we,"aria-label":Z.COMMENT_MORE,icon:h.jsx(Zg,{})})})})}):null]})]}),h.jsx("div",{className:"lb-comment-content",children:k})]})})})}),{DropdownItem:eu,Avatar:KF,Author:GF,Date:Ph});function r4(e){return window.addEventListener("blur",e),window.addEventListener("focus",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("focus",e)}}function o4(){return document.hasFocus()}function s4(){return!0}function i4(){return f.useSyncExternalStore(r4,o4,s4)}function a4({thread:e}){const{id:t,roomId:n}=e,r=f.useRef(null),o=vw(n),s=i4();return U5(r,i=>{i&&o(t)},{enabled:s}),h.jsx("div",{ref:r,style:{height:0},"aria-hidden":!0,"data-mark-as-read-marker":""})}const A4=f.forwardRef(({thread:e,indentCommentContent:t=!0,showActions:n="hover",showDeletedComments:r,showResolveAction:o=!0,showReactions:s=!0,showComposer:i="collapsed",showAttachments:a=!0,showSubscription:u=!0,showComposerFormattingControls:c=!0,maxVisibleComments:d,commentDropdownItems:l,onResolvedChange:m,onCommentEdit:g,onCommentDelete:v,onThreadDelete:C,onAuthorClick:p,onMentionClick:D,onAttachmentClick:w,onComposerSubmit:b,blurComposerOnSubmit:y,autoFocus:A,overrides:T,components:S,className:P,...L},F)=>{const M=eO(S?.Comment,Mh),N=Cw(e.roomId),_=Ew(e.roomId),I=st(T),[j,z]=f.useState(!1),Y=f.useMemo(()=>r?0:e.comments.findIndex(fe=>fe.body),[r,e.comments]),oe=f.useMemo(()=>r?e.comments.length-1:Lh(e.comments,fe=>!!fe.body),[r,e.comments]),G=f.useMemo(()=>r?e.comments.length:e.comments.filter(fe=>fe.body).length,[r,e.comments]),Z=f.useMemo(()=>{const fe=typeof d=="number"?d:d?.max,ye=(typeof d=="object"?d?.show:void 0)??"newest";if(j||fe===void 0)return;const be=e.comments.map((he,Ie)=>({comment:he,index:Ie})).filter(({comment:he})=>r||he.body);if(be.length<=Math.max(fe,2))return;const xe=be[0],ke=be[be.length-1];if(fe<=2){const he=be[1]?.index??xe.index,Ie=be[be.length-2]?.index??ke.index;return{firstIndex:he,lastIndex:Ie,count:be.slice(1,be.length-1).length}}const Me=fe-2,O=ye==="oldest"?Me:ye==="newest"?0:Math.floor(Me/2),k=ye==="oldest"?0:ye==="newest"?Me:Math.ceil(Me/2),ne=be[1+O],re=be[be.length-2-k];if(!(!ne||!re||ne.index>re.index))return{firstIndex:ne.index,lastIndex:re.index,count:e.comments.slice(ne.index,re.index+1).filter(he=>r||he.body).length}},[d,j,r,e.comments]),{status:le,unreadSince:de,subscribe:ue,unsubscribe:ee}=Np(e.roomId,e.id),te=f.useMemo(()=>{if(le!=="subscribed")return;if(de===null)return Y;const fe=e.comments.findIndex(ye=>(r?!0:ye.body)&&ye.createdAt>de);return fe>=0&&fe<e.comments.length?fe:void 0},[Y,r,le,e.comments,de]),[R,q]=f.useState(),J=R===void 0?te:R;f.useEffect(()=>{te&&q(fe=>Math.min(fe??1/0,te))},[te]);const X=mc(e.roomId,mi(e.visibility),"write"),ie=f.useCallback(fe=>{fe.stopPropagation()},[]),ae=f.useCallback(fe=>{m?.(fe),fe?N(e.id):_(e.id)},[N,_,m,e.id]),we=f.useCallback(fe=>{v?.(fe),e.comments.filter(be=>be.body).length<=1&&C?.(e)},[v,C,e]),Se=f.useCallback(()=>{le==="subscribed"?ee():ue()},[le,ue,ee]);let me=0;return h.jsx(xo,{children:h.jsxs("div",{className:Be("lb-root lb-thread",n==="hover"&&"lb-thread:show-actions-hover",P),"data-resolved":e.resolved?"":void 0,"data-unread":te!==void 0?"":void 0,dir:I.dir,...L,ref:F,children:[h.jsx("div",{className:"lb-thread-comments",role:"feed",children:e.comments.map((fe,ye)=>{const be=r||fe.body,xe=ye===Y,ke=te!==void 0&&ye>=te,Me=Z&&ye>=Z.firstIndex&&ye<=Z.lastIndex,O=!r&&!fe.body;if(Me&&ye===Z.firstIndex)return h.jsx("div",{className:"lb-thread-show-more",children:h.jsx(Bt,{variant:"ghost",className:"lb-thread-show-more-button",onClick:()=>z(!0),children:I.THREAD_SHOW_MORE_COMMENTS(Z.count)})},`${fe.id}:show-more`);if(Me||O)return null;be&&me++;const ne=h.jsx(M,{tabIndex:0,"aria-posinset":me,"aria-setsize":G,overrides:T,className:"lb-thread-comment","data-unread":ke?"":void 0,comment:fe,visibility:e.visibility,indentContent:t,showDeleted:r,showActions:n,showReactions:s,showAttachments:a,showComposerFormattingControls:c,onCommentEdit:g,onCommentDelete:we,onAuthorClick:p,onMentionClick:D,onAttachmentClick:w,components:S,actionsClassName:xe?"lb-thread-actions":void 0,actions:xe&&o?h.jsx(Et,{content:e.resolved?I.THREAD_UNRESOLVE:I.THREAD_RESOLVE,children:h.jsx(jc,{pressed:e.resolved,onPressedChange:ae,asChild:!0,children:h.jsx(Bt,{className:"lb-comment-action",onClick:ie,"aria-label":e.resolved?I.THREAD_UNRESOLVE:I.THREAD_RESOLVE,icon:e.resolved?h.jsx(Nx,{}):h.jsx(kx,{}),disabled:!X})})}):null,internalDropdownItems:xe&&u?h.jsx(Mh.DropdownItem,{onSelect:Se,icon:le==="subscribed"?h.jsx(Yg,{}):h.jsx(qg,{}),children:le==="subscribed"?I.THREAD_UNSUBSCRIBE:I.THREAD_SUBSCRIBE}):void 0,dropdownItems:l},fe.id);return ye===J&&J!==Y&&J<=oe?h.jsxs(f.Fragment,{children:[h.jsx("div",{className:"lb-thread-new-indicator","aria-label":I.THREAD_NEW_INDICATOR_DESCRIPTION,children:h.jsxs("span",{className:"lb-thread-new-indicator-label",children:[h.jsx(Mx,{className:"lb-thread-new-indicator-label-icon"}),I.THREAD_NEW_INDICATOR]})}),ne]},fe.id):ne})}),te!==void 0&&h.jsx(a4,{thread:e}),i&&h.jsx(Z0,{className:"lb-thread-composer",threadId:e.id,visibility:e.visibility,defaultCollapsed:i==="collapsed"?!0:void 0,showAttachments:a,showFormattingControls:c,onComposerSubmit:b,blurOnSubmit:y,overrides:{COMPOSER_PLACEHOLDER:I.THREAD_COMPOSER_PLACEHOLDER,COMPOSER_SEND:I.THREAD_COMPOSER_SEND,...T},roomId:e.roomId,autoFocus:A})]})})}),Gu=3;function _h({comment:e,showHeader:t=!0,showAttachments:n=!0,showReactions:r=!0,overrides:o,className:s,...i}){const a=st(o);return h.jsxs("div",{className:Be("lb-root lb-inbox-notification-comment lb-comment",s),...i,children:[t&&h.jsx("div",{className:"lb-comment-header",children:h.jsx(Cn,{className:"lb-comment-author",userId:e.userId})}),h.jsx("div",{className:"lb-comment-content",children:e.body?h.jsxs(h.Fragment,{children:[h.jsx(Hv,{className:"lb-comment-body",body:e.body,components:{Mention:eC,Link:ZF}}),r&&e.reactions.length>0&&h.jsx("div",{className:"lb-comment-reactions",children:e.reactions.map(u=>h.jsx(QF,{reaction:u,overrides:o,disabled:!0},u.emoji))}),n&&e.attachments.length>0?h.jsx("div",{className:"lb-comment-attachments",children:h.jsx("div",{className:"lb-attachments",children:e.attachments.map(u=>h.jsx(n4,{attachment:u,overrides:o,roomId:e.roomId},u.id))})}):null]}):h.jsx("div",{className:"lb-comment-body",children:h.jsx("p",{className:"lb-comment-deleted",children:a.COMMENT_DELETED})})})]})}function u4(e,t,n){if(t.length)for(let r=t.length-1;r>=0;r--){const o=t[r];if(o.userId!==n&&o.body){const s=Vy(o.body);for(const i of s)if(i.kind==="user"&&i.id===n||i.kind==="group"&&i.userIds?.includes(n)||i.kind==="group"&&i.userIds===void 0&&e[Ce].httpClient.groupsStore.getData(i.id)?.members.some(u=>u.id===n))return o}}}function kh(e){return Array.from(new Set(e.map(t=>t.userId)))}function c4(e,t,n,r){const o=n.comments.filter(a=>a.body?t.readAt?a.createdAt>t.readAt&&a.createdAt<=t.notifiedAt:a.createdAt<=t.notifiedAt:!1);if(o.length===0){const a=n.comments.filter(u=>u.body).slice(-Gu);return{type:"comments",unread:!1,comments:a,userIds:kh(a),date:t.notifiedAt}}const s=u4(e,o,r);return s?{type:"mention",unread:!0,comments:[s],userIds:[s.userId],date:s.createdAt}:{type:"comments",unread:!0,comments:o.slice(-Gu),userIds:kh(o),date:t.notifiedAt}}function qu({roomId:e,className:t,...n}){const{info:r,isLoading:o}=fc(e),s=f.useMemo(()=>r?.name??e,[r?.name,e]);return h.jsx("span",{className:Be("lb-name lb-room",t),"data-loading":o?"":void 0,...n,children:o?null:s})}const oa=f.forwardRef(({inboxNotification:e,children:t,aside:n,title:r,date:o,unread:s,markAsReadOnClick:i,onClick:a,href:u,showActions:c,overrides:d,components:l,className:m,asChild:g,additionalDropdownItemsBefore:v,additionalDropdownItemsAfter:C,...p},D)=>{const w=st(d),{Anchor:b}=Vg(l),y=g?ot:b,[A,T]=f.useState(!1),S=Xb(),P=Qb(),L=f.useCallback(j=>{a?.(j),s&&(i??!!u)&&S(e.id)},[u,e.id,i,S,a,s]),F=f.useCallback(j=>{j.stopPropagation()},[]),M=f.useCallback(j=>{j.preventDefault(),j.stopPropagation()},[]),N=f.useCallback(j=>{j.preventDefault(),j.stopPropagation(),T(z=>!z)},[]),_=f.useCallback(()=>{S(e.id)},[e.id,S]),I=f.useCallback(()=>{P(e.id)},[e.id,P]);return h.jsx(xo,{children:h.jsxs(y,{className:Be("lb-root lb-inbox-notification",c==="hover"&&"lb-inbox-notification:show-actions-hover",A&&"lb-inbox-notification:action-open",m),dir:w.dir,"data-unread":s?"":void 0,"data-kind":e.kind,onClick:L,href:u,...p,ref:D,children:[n&&h.jsx("div",{className:"lb-inbox-notification-aside",children:n}),h.jsxs("div",{className:"lb-inbox-notification-content",children:[h.jsxs("div",{className:"lb-inbox-notification-header",children:[h.jsx("span",{className:"lb-inbox-notification-title",children:r}),h.jsx("div",{className:"lb-inbox-notification-details",children:h.jsxs("span",{className:"lb-inbox-notification-details-labels",children:[h.jsx(b0,{locale:w.locale,date:o,className:"lb-date lb-inbox-notification-date"}),s&&h.jsx("span",{className:"lb-inbox-notification-unread-indicator",role:"presentation"})]})}),c&&h.jsx("div",{className:"lb-inbox-notification-actions",children:h.jsx(X0,{open:A,onOpenChange:T,align:"end",content:h.jsxs(h.Fragment,{children:[v,s?h.jsx(Si,{onSelect:_,onClick:F,icon:h.jsx(zc,{}),children:w.INBOX_NOTIFICATION_MARK_AS_READ}):null,h.jsx(Si,{onSelect:I,onClick:F,icon:h.jsx(Jg,{}),children:w.INBOX_NOTIFICATION_DELETE}),C]}),children:h.jsx(Et,{content:w.INBOX_NOTIFICATION_MORE,children:h.jsx(Q0,{asChild:!0,children:h.jsx(Bt,{className:"lb-inbox-notification-action",onClick:N,onPointerDown:M,onPointerUp:M,"aria-label":w.INBOX_NOTIFICATION_MORE,icon:h.jsx(Zg,{})})})})})})]}),h.jsx("div",{className:"lb-inbox-notification-body",children:t})]})]})})});function rC({className:e,...t}){return h.jsx("div",{className:Be("lb-inbox-notification-icon",e),...t})}function xi({className:e,...t}){return h.jsx(qi,{className:Be("lb-inbox-notification-avatar",e),...t})}const Nh=f.forwardRef(({inboxNotification:e,href:t,showRoomName:n=!0,showReactions:r=!0,showAttachments:o=!0,showActions:s="hover",overrides:i,...a},u)=>{const c=st(i),d=_e(),l=nw(e.id),{status:m,subscribe:g,unsubscribe:v}=Np(l.roomId,l.id),C=Rn(),{info:p}=fc(e.roomId),D=f.useMemo(()=>{const F=c4(d,e,l,C??"");if(F.comments.length===0||F.userIds.length===0)return null;switch(F.type){case"comments":{const M=[...F.userIds].reverse(),N=M[0],_=h.jsx(xi,{userId:N}),I=c.INBOX_NOTIFICATION_THREAD_COMMENTS_LIST(h.jsx(Kg,{values:M.map(z=>h.jsx(Cn,{userId:z,replaceSelf:!0},z)),formatRemaining:c.LIST_REMAINING_USERS,truncate:Gu-1,locale:c.locale}),n?h.jsx(qu,{roomId:l.roomId}):void 0,M.length),j=h.jsx("div",{className:"lb-inbox-notification-comments",children:F.comments.map(z=>h.jsx(_h,{comment:z,showHeader:F.comments.length>1,showAttachments:o,showReactions:r,overrides:i},z.id))});return{unread:F.unread,date:F.date,aside:_,title:I,content:j,threadId:l.id,commentId:F.comments[F.comments.length-1].id}}case"mention":{const M=F.userIds[0],N=F.comments[0],_=h.jsx(xi,{userId:M}),I=c.INBOX_NOTIFICATION_THREAD_MENTION(h.jsx(Cn,{userId:M},M),n?h.jsx(qu,{roomId:l.roomId}):void 0),j=h.jsx("div",{className:"lb-inbox-notification-comments",children:h.jsx(_h,{comment:N,showHeader:!1,showAttachments:o,showReactions:r,overrides:i},N.id)});return{unread:F.unread,date:F.date,aside:_,title:I,content:j,threadId:l.id,commentId:N.id}}default:return Je(F,"Unexpected thread inbox notification type")}},[c,d,C,e,i,n,o,r,l]),w=f.useMemo(()=>{const F=t??p?.url;return F?P1(F,void 0,D?.commentId):void 0},[D?.commentId,t,p?.url]),b=f.useCallback(()=>{m==="subscribed"?v():g()},[m,g,v]),y=f.useCallback(F=>{F.stopPropagation()},[]);if(!D)return null;const{aside:A,title:T,content:S,date:P,unread:L}=D;return h.jsx(oa,{inboxNotification:e,aside:A,title:T,date:P,unread:L,overrides:i,href:w,showActions:s,markAsReadOnClick:!1,additionalDropdownItemsBefore:h.jsx(Si,{onSelect:b,onClick:y,icon:m==="subscribed"?h.jsx(Yg,{}):h.jsx(qg,{}),children:m==="subscribed"?c.THREAD_UNSUBSCRIBE:c.THREAD_SUBSCRIBE}),...a,ref:u,children:S})}),jh=f.forwardRef(({inboxNotification:e,showActions:t="hover",showRoomName:n=!0,href:r,overrides:o,...s},i)=>{const a=st(o),{info:u}=fc(e.roomId),c=f.useMemo(()=>{const l=r??u?.url;return l?ec(l)??void 0:void 0},[r,u?.url]),d=f.useMemo(()=>!e.readAt||e.notifiedAt>e.readAt,[e.notifiedAt,e.readAt]);return h.jsx(oa,{inboxNotification:e,aside:h.jsx(xi,{userId:e.createdBy}),title:a.INBOX_NOTIFICATION_TEXT_MENTION(h.jsx(Cn,{userId:e.createdBy},e.createdBy),n?h.jsx(qu,{roomId:e.roomId}):void 0),date:e.notifiedAt,unread:d,overrides:o,showActions:t,href:c,...s,ref:i})}),oC=f.forwardRef(({inboxNotification:e,showActions:t="hover",title:n,aside:r,children:o,overrides:s,...i},a)=>{const u=f.useMemo(()=>!e.readAt||e.notifiedAt>e.readAt,[e.notifiedAt,e.readAt]);return h.jsx(oa,{inboxNotification:e,aside:r,title:n,date:e.notifiedAt,unread:u,overrides:s,showActions:t,...i,ref:a,children:o})}),l4=f.forwardRef(({inboxNotification:e,showActions:t="hover",overrides:n,...r},o)=>{const s=f.useMemo(()=>!e.readAt||e.notifiedAt>e.readAt,[e.notifiedAt,e.readAt]);return h.jsx(oa,{inboxNotification:e,title:h.jsx("code",{children:e.id}),date:e.notifiedAt,unread:s,overrides:n,showActions:t,...r,ref:o,"data-inspector":"",children:h.jsx(Yx,{title:"Data",code:JSON.stringify(e,null,2)})})});f.forwardRef(({inboxNotification:e,...t},n)=>h.jsxs(oC,{inboxNotification:e,...t,title:h.jsxs(h.Fragment,{children:["Custom notification kind ",h.jsx("code",{children:e.kind})," is not handled"]}),aside:h.jsx(rC,{children:h.jsx(Gc,{})}),ref:n,"data-missing":"",children:["Notifications of this kind won’t be displayed in production. Use the"," ",h.jsx("code",{children:"kinds"})," prop to define how they should be rendered, learn more in the console."]}));const S4=Object.assign(f.forwardRef(({inboxNotification:e,kinds:t,...n},r)=>{switch(e.kind){case"thread":{const o=t?.thread??Nh;return h.jsx(o,{inboxNotification:e,...n,ref:r})}case"textMention":{const o=t?.textMention??jh;return h.jsx(o,{inboxNotification:e,...n,ref:r})}default:{const o=t?.[e.kind];return o?h.jsx(o,{inboxNotification:e,...n,ref:r}):null}}}),{Thread:Nh,TextMention:jh,Custom:oC,Inspector:l4,Icon:rC,Avatar:xi});export{gl as A,Ut as B,Hv as C,E0 as D,S4 as I,m4 as L,QC as P,b0 as T,w4 as _,E4 as a,Mh as b,y4 as c,Z0 as d,b4 as e,A4 as f,Bp as g,$v as h,cl as i,h as j,p4 as k,C4 as l,Yu as m,XC as n,ZC as o,g4 as p,Xb as q,nw as r,CB as s,pB as t,st as u,y0 as v,g0 as w,v0 as x,C0 as y,v4 as z};
|