@fileverse-dev/ddoc 1.7.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.umd.js CHANGED
@@ -470,7 +470,7 @@ img.ProseMirror-separator {
470
470
 
471
471
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
472
472
 
473
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return V.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},UH="DialogDescriptionWarning",VH=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$3(UH).contentName}}.`;return V.useEffect(()=>{var i;const s=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},G3=_3,W3=N3,K3=P3,Tw=I3,Dw=L3,Ow=F3,_w=U3,q3=H3;function HH(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const Q3=N.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,handleOnly:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{},direction:"bottom"}),H0=()=>{const t=N.useContext(Q3);if(!t)throw new Error("useDrawerContext must be used within a Drawer.Root");return t};HH("[vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1)}[vaul-drawer][vaul-drawer-direction=bottom]{transform:translate3d(0,100%,0)}[vaul-drawer][vaul-drawer-direction=top]{transform:translate3d(0,-100%,0)}[vaul-drawer][vaul-drawer-direction=left]{transform:translate3d(-100%,0,0)}[vaul-drawer][vaul-drawer-direction=right]{transform:translate3d(100%,0,0)}.vaul-dragging .vaul-scrollable [vault-drawer-direction=top]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=bottom]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=left]{overflow-x:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=right]{overflow-x:hidden!important}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]::after{content:'';position:absolute;background:inherit;background-color:inherit}[vaul-drawer][vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[vaul-drawer][vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[vaul-handle]{display:block;position:relative;opacity:.8;margin-left:auto;margin-right:auto;height:5px;width:56px;border-radius:1rem;touch-action:pan-y;cursor:grab}[vaul-handle]:active,[vaul-handle]:hover{opacity:1}[vaul-handle]:active{cursor:grabbing}[vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay=true]):not([data-state=closed]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible=false]){opacity:1}@media (hover:hover) and (pointer:fine){[vaul-drawer]{user-select:none}}@media (pointer:fine){[vaul-handle-hitarea]:{width:100%;height:100%}}");const zH=typeof window<"u"?N.useLayoutEffect:N.useEffect;function Mw(...t){return(...e)=>{for(let n of t)typeof n=="function"&&n(...e)}}function $H(){return Nw(/^Mac/)}function GH(){return Nw(/^iPhone/)}function WH(){return Nw(/^iPad/)||$H()&&navigator.maxTouchPoints>1}function J3(){return GH()||WH()}function Nw(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.platform):void 0}const Rw=typeof document<"u"&&window.visualViewport;function Y3(t){let e=window.getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowX+e.overflowY)}function X3(t){for(Y3(t)&&(t=t.parentElement);t&&!Y3(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}const KH=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let z0=0,Pw;function qH(t={}){let{isDisabled:e}=t;zH(()=>{if(!e)return z0++,z0===1&&(J3()?Pw=JH():Pw=QH()),()=>{z0--,z0===0&&Pw()}},[e])}function QH(){return Mw(Z3(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`))}function JH(){let t,e=0,n=f=>{t=X3(f.target),!(t===document.documentElement&&t===document.body)&&(e=f.changedTouches[0].pageY)},r=f=>{if(!t||t===document.documentElement||t===document.body){f.preventDefault();return}let d=f.changedTouches[0].pageY,h=t.scrollTop,p=t.scrollHeight-t.clientHeight;p!==0&&((h<=0&&d>e||h>=p&&d<e)&&f.preventDefault(),e=d)},s=f=>{let d=f.target;Iw(d)&&d!==document.activeElement&&(f.preventDefault(),d.style.transform="translateY(-2000px)",d.focus(),requestAnimationFrame(()=>{d.style.transform=""}))},i=f=>{let d=f.target;Iw(d)&&(d.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{d.style.transform="",Rw&&(Rw.height<window.innerHeight?requestAnimationFrame(()=>{eD(d)}):Rw.addEventListener("resize",()=>eD(d),{once:!0}))}))},o=()=>{window.scrollTo(0,0)},a=window.pageXOffset,l=window.pageYOffset,u=Mw(Z3(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let c=Mw(Rd(document,"touchstart",n,{passive:!1,capture:!0}),Rd(document,"touchmove",r,{passive:!1,capture:!0}),Rd(document,"touchend",s,{passive:!1,capture:!0}),Rd(document,"focus",i,!0),Rd(window,"scroll",o));return()=>{u(),c(),window.scrollTo(a,l)}}function Z3(t,e,n){let r=t.style[e];return t.style[e]=n,()=>{t.style[e]=r}}function Rd(t,e,n,r){return t.addEventListener(e,n,r),()=>{t.removeEventListener(e,n,r)}}function eD(t){let e=document.scrollingElement||document.documentElement;for(;t&&t!==e;){let n=X3(t);if(n!==document.documentElement&&n!==document.body&&n!==t){let r=n.getBoundingClientRect().top,s=t.getBoundingClientRect().top,i=t.getBoundingClientRect().bottom;const o=n.getBoundingClientRect().bottom;i>o&&(n.scrollTop+=s-r)}t=n.parentElement}}function Iw(t){return t instanceof HTMLInputElement&&!KH.has(t.type)||t instanceof HTMLTextAreaElement||t instanceof HTMLElement&&t.isContentEditable}function YH(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function XH(...t){return e=>t.forEach(n=>YH(n,e))}function tD(...t){return V.useCallback(XH(...t),t)}let Pd=null;function ZH({isOpen:t,modal:e,nested:n,hasBeenOpened:r,preventScrollRestoration:s,noBodyStyles:i}){const[o,a]=N.useState(()=>typeof window<"u"?window.location.href:""),l=N.useRef(0),u=N.useCallback(()=>{if(Pd===null&&t&&!i){Pd={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:d}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-l.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const h=d-window.innerHeight;h&&l.current>=d&&(document.body.style.top=`${-(l.current+h)}px`)}),300)}},[t]),c=N.useCallback(()=>{if(Pd!==null&&!i){const f=-parseInt(document.body.style.top,10),d=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Pd),window.requestAnimationFrame(()=>{if(s&&o!==window.location.href){a(window.location.href);return}window.scrollTo(d,f)}),Pd=null}},[o]);return N.useEffect(()=>{function f(){l.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),N.useEffect(()=>{n||!r||(t?(!window.matchMedia("(display-mode: standalone)").matches&&u(),e||window.setTimeout(()=>{c()},500)):c())},[t,r,o,e,n,u,c]),{restorePositionSetting:c}}const nD=new WeakMap;function Dt(t,e,n=!1){if(!t||!(t instanceof HTMLElement))return;let r={};Object.entries(e).forEach(([s,i])=>{if(s.startsWith("--")){t.style.setProperty(s,i);return}r[s]=t.style[s],t.style[s]=i}),!n&&nD.set(t,r)}function $0(t,e){if(!t||!(t instanceof HTMLElement))return;let n=nD.get(t);n&&(e?t.style[e]=n[e]:Object.entries(n).forEach(([r,s])=>{t.style[r]=s}))}const Xt=t=>{switch(t){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return t}};function G0(t,e){if(!t)return null;const n=window.getComputedStyle(t),r=n.transform||n.webkitTransform||n.mozTransform;let s=r.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[Xt(e)?13:12]):(s=r.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[Xt(e)?5:4]):null)}function ez(t){return 8*(Math.log(t+1)-2)}const At={DURATION:.5,EASE:[.32,.72,0,1]},rD=.4;function sD(t){const e=N.useRef(t);return N.useEffect(()=>{e.current=t}),N.useMemo(()=>(...n)=>e.current==null?void 0:e.current.call(e,...n),[])}function tz({defaultProp:t,onChange:e}){const n=N.useState(t),[r]=n,s=N.useRef(r),i=sD(e);return N.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),n}function nz({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,s]=tz({defaultProp:e,onChange:n}),i=t!==void 0,o=i?t:r,a=sD(n),l=N.useCallback(u=>{if(i){const f=typeof u=="function"?u(t):u;f!==t&&a(f)}else s(u)},[i,t,s,a]);return[o,l]}function rz({activeSnapPointProp:t,setActiveSnapPointProp:e,snapPoints:n,drawerRef:r,overlayRef:s,fadeFromIndex:i,onSnapPointChange:o,direction:a="bottom"}){const[l,u]=nz({prop:t,defaultProp:n==null?void 0:n[0],onChange:e}),c=N.useMemo(()=>l===(n==null?void 0:n[n.length-1])||null,[n,l]),f=n&&n.length>0&&(i||i===0)&&!Number.isNaN(i)&&n[i]===l||!n,d=N.useMemo(()=>n==null?void 0:n.findIndex(w=>w===l),[n,l]),h=N.useMemo(()=>{var w;return(w=n==null?void 0:n.map(A=>{const x=typeof window<"u",k=typeof A=="string";let C=0;if(k&&(C=parseInt(A,10)),Xt(a)){const _=k?C:x?A*window.innerHeight:0;return x?a==="bottom"?window.innerHeight-_:-window.innerHeight+_:_}const O=k?C:x?A*window.innerWidth:0;return x?a==="right"?window.innerWidth-O:-window.innerWidth+O:O}))!=null?w:[]},[n]),p=N.useMemo(()=>d!==null?h==null?void 0:h[d]:null,[h,d]),m=N.useCallback(w=>{var A;const x=(A=h==null?void 0:h.findIndex(k=>k===w))!=null?A:null;o(x),Dt(r.current,{transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,transform:Xt(a)?`translate3d(0, ${w}px, 0)`:`translate3d(${w}px, 0, 0)`}),h&&x!==h.length-1&&x!==i?Dt(s.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,opacity:"0"}):Dt(s.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,opacity:"1"}),u(x!==null?n==null?void 0:n[x]:null)},[r.current,n,h,i,s,u]);N.useEffect(()=>{if(l||t){var w;const A=(w=n==null?void 0:n.findIndex(x=>x===t||x===l))!=null?w:-1;h&&A!==-1&&typeof h[A]=="number"&&m(h[A])}},[l,t,n,h,m]);function g({draggedDistance:w,closeDrawer:A,velocity:x,dismissible:k}){if(i===void 0)return;const C=a==="bottom"||a==="right"?(p??0)-w:(p??0)+w,O=d===i-1,_=d===0,D=w>0;if(O&&Dt(s.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),x>2&&!D){k?A():m(h[0]);return}if(x>2&&D&&h&&n){m(h[n.length-1]);return}const R=h==null?void 0:h.reduce((F,G)=>typeof F!="number"||typeof G!="number"?F:Math.abs(G-C)<Math.abs(F-C)?G:F),L=Xt(a)?window.innerHeight:window.innerWidth;if(x>rD&&Math.abs(w)<L*.4){const F=D?1:-1;if(F>0&&c){m(h[n.length-1]);return}if(_&&F<0&&k&&A(),d===null)return;m(h[d+F]);return}m(R)}function y({draggedDistance:w}){if(p===null)return;const A=a==="bottom"||a==="right"?p-w:p+w;(a==="bottom"||a==="right")&&A<h[h.length-1]||(a==="top"||a==="left")&&A>h[h.length-1]||Dt(r.current,{transform:Xt(a)?`translate3d(0, ${A}px, 0)`:`translate3d(${A}px, 0, 0)`})}function v(w,A){if(!n||typeof d!="number"||!h||i===void 0)return null;const x=d===i-1;if(d>=i&&A)return 0;if(x&&!A)return 1;if(!f&&!x)return null;const C=x?d+1:d-1,O=x?h[C]-h[C-1]:h[C+1]-h[C],_=w/Math.abs(O);return x?1-_:_}return{isLastSnapPoint:c,activeSnapPoint:l,shouldFade:f,getPercentageDragged:v,setActiveSnapPoint:u,activeSnapPointIndex:d,onRelease:g,onDrag:y,snapPointsOffset:h}}const sz=.25,iz=100,iD=8,nl=16,oD=26,Lw="vaul-dragging";function aD({open:t,onOpenChange:e,children:n,shouldScaleBackground:r,onDrag:s,onRelease:i,snapPoints:o,nested:a=!1,setBackgroundColorOnScale:l=!0,closeThreshold:u=sz,scrollLockTimeout:c=iz,dismissible:f=!0,handleOnly:d=!1,fadeFromIndex:h=o&&o.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:y=!0,onClose:v,noBodyStyles:w,direction:A="bottom",preventScrollRestoration:x=!0,disablePreventScroll:k=!1}){var C;const[O=!1,_]=N.useState(!1),[D,R]=N.useState(!1),[L,F]=N.useState(!1),[G,B]=N.useState(!1),[H,Q]=N.useState(!1),[te,Z]=N.useState(!1),pe=N.useRef(null),Ee=N.useRef(null),Re=N.useRef(null),Ce=N.useRef(null),ke=N.useRef(null),He=N.useRef(!1),Ue=N.useRef(null),ze=N.useRef(0),Le=N.useRef(!1),tt=N.useRef(0),le=N.useRef(null),$e=N.useRef(((C=le.current)==null?void 0:C.getBoundingClientRect().height)||0),ae=N.useRef(0),be=N.useCallback(ne=>{o&&ne===ue.length-1&&(Ee.current=new Date)},[]),{activeSnapPoint:Be,activeSnapPointIndex:z,setActiveSnapPoint:q,onRelease:re,snapPointsOffset:ue,onDrag:P,shouldFade:b,getPercentageDragged:E}=rz({snapPoints:o,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:le,fadeFromIndex:h,overlayRef:pe,onSnapPointChange:be,direction:A});qH({isDisabled:!O||H||!y||te||!D||k});const{restorePositionSetting:M}=ZH({isOpen:O,modal:y,nested:a,hasBeenOpened:D,preventScrollRestoration:x,noBodyStyles:w});function j(){return(window.innerWidth-oD)/window.innerWidth}function K(ne){var ie;!f&&!o||le.current&&!le.current.contains(ne.target)||($e.current=((ie=le.current)==null?void 0:ie.getBoundingClientRect().height)||0,Q(!0),Re.current=new Date,J3()&&window.addEventListener("touchend",()=>He.current=!1,{once:!0}),ne.target.setPointerCapture(ne.pointerId),ze.current=Xt(A)?ne.clientY:ne.clientX)}function Y(ne,ie){var Te;let me=ne;const qe=(Te=window.getSelection())==null?void 0:Te.toString(),nt=le.current?G0(le.current,A):null,yt=new Date;if(me.hasAttribute("data-vaul-no-drag")||me.closest("[data-vaul-no-drag]"))return!1;if(A==="right"||A==="left")return!0;if(Ee.current&&yt.getTime()-Ee.current.getTime()<500)return!1;if(nt!==null&&(A==="bottom"?nt>0:nt<0))return!0;if(qe&&qe.length>0)return!1;if(ke.current&&yt.getTime()-ke.current.getTime()<c&&nt===0||ie)return ke.current=yt,!1;for(;me;){if(me.scrollHeight>me.clientHeight){if(me.scrollTop!==0)return ke.current=new Date,!1;if(me.getAttribute("role")==="dialog")return!0}me=me.parentNode}return!0}function ye(ne){if(le.current&&H){const ie=A==="bottom"||A==="right"?1:-1,Te=(ze.current-(Xt(A)?ne.clientY:ne.clientX))*ie,me=Te>0,qe=o&&!f&&!me;if(qe&&z===0)return;const nt=Math.abs(Te),yt=document.querySelector("[vaul-drawer-wrapper]");let sn=nt/$e.current;const Ft=E(nt,me);if(Ft!==null&&(sn=Ft),qe&&sn>=1||!He.current&&!Y(ne.target,me))return;if(le.current.classList.add(Lw),He.current=!0,Dt(le.current,{transition:"none"}),Dt(pe.current,{transition:"none"}),o&&P({draggedDistance:Te}),me&&!o){const wr=ez(Te),Ar=Math.min(wr*-1,0)*ie;Dt(le.current,{transform:Xt(A)?`translate3d(0, ${Ar}px, 0)`:`translate3d(${Ar}px, 0, 0)`});return}const Is=1-sn;if((b||h&&z===h-1)&&(s==null||s(ne,sn),Dt(pe.current,{opacity:`${Is}`,transition:"none"},!0)),yt&&pe.current&&r){const wr=Math.min(j()+sn*(1-j()),1),Ar=8-sn*8,Wf=Math.max(0,14-sn*14);Dt(yt,{borderRadius:`${Ar}px`,transform:Xt(A)?`scale(${wr}) translate3d(0, ${Wf}px, 0)`:`scale(${wr}) translate3d(${Wf}px, 0, 0)`,transition:"none"},!0)}if(!o){const wr=nt*ie;Dt(le.current,{transform:Xt(A)?`translate3d(0, ${wr}px, 0)`:`translate3d(${wr}px, 0, 0)`})}}}N.useEffect(()=>()=>{ft(!1),M()},[]),N.useEffect(()=>{var ne;function ie(){if(!le.current)return;const Te=document.activeElement;if(Iw(Te)||Le.current){var me;const qe=((me=window.visualViewport)==null?void 0:me.height)||0;let nt=window.innerHeight-qe;const yt=le.current.getBoundingClientRect().height||0;ae.current||(ae.current=yt);const sn=le.current.getBoundingClientRect().top;if(Math.abs(tt.current-nt)>60&&(Le.current=!Le.current),o&&o.length>0&&ue&&z){const Ft=ue[z]||0;nt+=Ft}if(tt.current=nt,yt>qe||Le.current){const Ft=le.current.getBoundingClientRect().height;let Is=Ft;Ft>qe&&(Is=qe-oD),g?le.current.style.height=`${Ft-Math.max(nt,0)}px`:le.current.style.height=`${Math.max(Is,qe-sn)}px`}else le.current.style.height=`${ae.current}px`;o&&o.length>0&&!Le.current?le.current.style.bottom="0px":le.current.style.bottom=`${Math.max(nt,0)}px`}}return(ne=window.visualViewport)==null||ne.addEventListener("resize",ie),()=>{var Te;return(Te=window.visualViewport)==null?void 0:Te.removeEventListener("resize",ie)}},[z,o,ue]);function Se(){le.current&&(Ve(),v==null||v(),Dt(le.current,{transform:Xt(A)?`translate3d(0, ${A==="bottom"?"100%":"-100%"}, 0)`:`translate3d(${A==="right"?"100%":"-100%"}, 0, 0)`,transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),Dt(pe.current,{opacity:"0",transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),ft(!1),setTimeout(()=>{F(!1),_(!1)},300),setTimeout(()=>{o&&q(o[0])},At.DURATION*1e3))}N.useEffect(()=>{if(!O&&r){const ne=setTimeout(()=>{$0(document.body)},200);return()=>clearTimeout(ne)}},[O,r]),N.useLayoutEffect(()=>{t?(_(!0),R(!0)):Se()},[t]),N.useEffect(()=>{G&&(e==null||e(O))},[O]),N.useEffect(()=>{B(!0)},[]);function Je(){if(!le.current)return;const ne=document.querySelector("[vaul-drawer-wrapper]"),ie=G0(le.current,A);Dt(le.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),Dt(pe.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,opacity:"1"}),r&&ie&&ie>0&&O&&Dt(ne,{borderRadius:`${iD}px`,overflow:"hidden",...Xt(A)?{transform:`scale(${j()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${j()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${At.DURATION}s`,transitionTimingFunction:`cubic-bezier(${At.EASE.join(",")})`},!0)}function Ve(){!H||!le.current||(le.current.classList.remove(Lw),He.current=!1,Q(!1),Ce.current=new Date)}function Fe(ne){if(!H||!le.current)return;le.current.classList.remove(Lw),He.current=!1,Q(!1),Ce.current=new Date;const ie=G0(le.current,A);if(!Y(ne.target,!1)||!ie||Number.isNaN(ie)||Re.current===null)return;const Te=Ce.current.getTime()-Re.current.getTime(),me=ze.current-(Xt(A)?ne.clientY:ne.clientX),qe=Math.abs(me)/Te;if(qe>.05&&(Z(!0),setTimeout(()=>{Z(!1)},200)),o){re({draggedDistance:me*(A==="bottom"||A==="right"?1:-1),closeDrawer:Se,velocity:qe,dismissible:f}),i==null||i(ne,!0);return}if(A==="bottom"||A==="right"?me>0:me<0){Je(),i==null||i(ne,!0);return}if(qe>rD){Se(),i==null||i(ne,!1);return}var nt;const yt=Math.min((nt=le.current.getBoundingClientRect().height)!=null?nt:0,window.innerHeight);if(ie>=yt*u){Se(),i==null||i(ne,!1);return}i==null||i(ne,!0),Je()}N.useEffect(()=>{O&&(Dt(document.documentElement,{scrollBehavior:"auto"}),Ee.current=new Date,ft(!0))},[O]),N.useEffect(()=>{if(le.current&&L){var ne;const ie=le==null||(ne=le.current)==null?void 0:ne.querySelectorAll("*");ie==null||ie.forEach(Te=>{const me=Te;(me.scrollHeight>me.clientHeight||me.scrollWidth>me.clientWidth)&&me.classList.add("vaul-scrollable")})}},[L]);function ft(ne){const ie=document.querySelector("[vaul-drawer-wrapper]");!ie||!r||(ne?(l&&(w||(Dt(document.body,{background:document.body.style.backgroundColor||document.body.style.background}),Dt(document.body,{background:"black"},!0))),Dt(ie,{borderRadius:`${iD}px`,overflow:"hidden",...Xt(A)?{transform:`scale(${j()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${j()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${At.DURATION}s`,transitionTimingFunction:`cubic-bezier(${At.EASE.join(",")})`})):($0(ie,"overflow"),$0(ie,"transform"),$0(ie,"borderRadius"),Dt(ie,{transitionProperty:"transform, border-radius",transitionDuration:`${At.DURATION}s`,transitionTimingFunction:`cubic-bezier(${At.EASE.join(",")})`})))}function Xn(ne){const ie=ne?(window.innerWidth-nl)/window.innerWidth:1,Te=ne?-nl:0;Ue.current&&window.clearTimeout(Ue.current),Dt(le.current,{transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,transform:`scale(${ie}) translate3d(0, ${Te}px, 0)`}),!ne&&le.current&&(Ue.current=setTimeout(()=>{const me=G0(le.current,A);Dt(le.current,{transition:"none",transform:Xt(A)?`translate3d(0, ${me}px, 0)`:`translate3d(${me}px, 0, 0)`})},500))}function br(ne,ie){if(ie<0)return;const Te=Xt(A)?window.innerHeight:window.innerWidth,me=(Te-nl)/Te,qe=me+ie*(1-me),nt=-nl+ie*nl;Dt(le.current,{transform:Xt(A)?`scale(${qe}) translate3d(0, ${nt}px, 0)`:`scale(${qe}) translate3d(${nt}px, 0, 0)`,transition:"none"})}function X(ne,ie){const Te=Xt(A)?window.innerHeight:window.innerWidth,me=ie?(Te-nl)/Te:1,qe=ie?-nl:0;ie&&Dt(le.current,{transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,transform:Xt(A)?`scale(${me}) translate3d(0, ${qe}px, 0)`:`scale(${me}) translate3d(${qe}px, 0, 0)`})}return N.createElement(G3,{modal:y,onOpenChange:ne=>{if(t!==void 0){e==null||e(ne);return}ne?(R(!0),_(ne)):Se()},open:O},N.createElement(Q3.Provider,{value:{visible:L,activeSnapPoint:Be,snapPoints:o,setActiveSnapPoint:q,drawerRef:le,overlayRef:pe,scaleBackground:ft,onOpenChange:e,onPress:K,setVisible:F,onRelease:Fe,onDrag:ye,dismissible:f,handleOnly:d,isOpen:O,isDragging:H,shouldFade:b,closeDrawer:Se,onNestedDrag:br,onNestedOpenChange:Xn,onNestedRelease:X,keyboardIsOpen:Le,openProp:t,modal:y,snapPointsOffset:ue,direction:A}},n))}const oz=250,az=120,lD=N.forwardRef(function({preventCycle:t=!1,children:e,...n},r){const{visible:s,closeDrawer:i,isDragging:o,snapPoints:a,activeSnapPoint:l,setActiveSnapPoint:u,dismissible:c,handleOnly:f,onPress:d,onDrag:h}=H0(),p=N.useRef(null),m=N.useRef(!1);function g(){if(m.current){w();return}window.setTimeout(()=>{y()},az)}function y(){if(o||t||m.current){w();return}if(w(),(!a||a.length===0)&&c){i();return}if(l===a[a.length-1]&&c){i();return}const x=a.findIndex(C=>C===l);if(x===-1)return;const k=a[x+1];u(k)}function v(){p.current=window.setTimeout(()=>{m.current=!0},oz)}function w(){window.clearTimeout(p.current),m.current=!1}return N.createElement("div",{onClick:g,onDoubleClick:()=>{m.current=!0,i()},onPointerCancel:w,onPointerDown:A=>{f&&d(A),v()},onPointerMove:A=>{f&&h(A)},ref:r,"vaul-drawer-visible":s?"true":"false","vaul-handle":"","aria-hidden":"true",...n},N.createElement("span",{"vaul-handle-hitarea":"","aria-hidden":"true"},e))});lD.displayName="Drawer.Handle";const uD=N.forwardRef(function({children:t,...e},n){const{overlayRef:r,snapPoints:s,onRelease:i,shouldFade:o,isOpen:a,visible:l}=H0(),u=tD(n,r),c=s&&s.length>0;return N.createElement(Tw,{onMouseUp:i,ref:u,"vaul-drawer-visible":l?"true":"false","vaul-overlay":"","vaul-snap-points":a&&c?"true":"false","vaul-snap-points-overlay":a&&o?"true":"false",...e})});uD.displayName="Drawer.Overlay";const cD=N.forwardRef(function({onOpenAutoFocus:t,onPointerDownOutside:e,onAnimationEnd:n,style:r,...s},i){const{drawerRef:o,onPress:a,onRelease:l,onDrag:u,dismissible:c,keyboardIsOpen:f,snapPointsOffset:d,visible:h,closeDrawer:p,modal:m,openProp:g,onOpenChange:y,setVisible:v,handleOnly:w,direction:A}=H0(),x=tD(i,o),k=N.useRef(null),C=N.useRef(!1),O=(_,D,R=0)=>{if(C.current)return!0;const L=Math.abs(_.y),F=Math.abs(_.x),G=F>L,B=["bottom","right"].includes(D)?1:-1;if(D==="left"||D==="right"){if(!(_.x*B<0)&&F>=0&&F<=R)return G}else if(!(_.y*B<0)&&L>=0&&L<=R)return!G;return C.current=!0,!0};return N.useEffect(()=>{v(!0)},[]),N.createElement(Dw,{"vaul-drawer":"","vaul-drawer-direction":A,"vaul-drawer-visible":h?"true":"false",...s,ref:x,style:d&&d.length>0?{"--snap-point-height":`${d[0]}px`,...r}:r,onOpenAutoFocus:_=>{if(t)t(_);else{var D;_.preventDefault(),(D=o.current)==null||D.focus()}},onPointerDown:_=>{w||(s.onPointerDown==null||s.onPointerDown.call(s,_),k.current={x:_.clientX,y:_.clientY},a(_))},onPointerDownOutside:_=>{if(e==null||e(_),!m||_.defaultPrevented){_.preventDefault();return}f.current&&(f.current=!1),_.preventDefault(),y==null||y(!1),!(!c||g!==void 0)&&p()},onFocusOutside:_=>{if(!m){_.preventDefault();return}},onEscapeKeyDown:_=>{if(!m){_.preventDefault();return}},onPointerMove:_=>{if(w||(s.onPointerMove==null||s.onPointerMove.call(s,_),!k.current))return;const D=_.clientY-k.current.y,R=_.clientX-k.current.x,L=_.pointerType==="touch"?10:2;O({x:R,y:D},A,L)?u(_):(Math.abs(R)>L||Math.abs(D)>L)&&(k.current=null)},onPointerUp:_=>{s.onPointerUp==null||s.onPointerUp.call(s,_),k.current=null,C.current=!1,l(_)}})});cD.displayName="Drawer.Content";function lz({onDrag:t,onOpenChange:e,...n}){const{onNestedDrag:r,onNestedOpenChange:s,onNestedRelease:i}=H0();if(!r)throw new Error("Drawer.NestedRoot must be placed in another drawer");return N.createElement(aD,{nested:!0,onClose:()=>{s(!1)},onDrag:(o,a)=>{r(o,a),t==null||t(o,a)},onOpenChange:o=>{o&&s(o),e==null||e(o)},onRelease:i,...n})}const ps={Root:aD,NestedRoot:lz,Content:cD,Handle:lD,Overlay:uD,Trigger:W3,Portal:K3,Close:q3,Title:Ow,Description:_w},fD=({shouldScaleBackground:t=!0,...e})=>S.jsx(ps.Root,{shouldScaleBackground:t,...e});fD.displayName="Drawer";const dD=ps.Trigger,uz=ps.Portal,hD=N.forwardRef(({className:t,...e},n)=>S.jsx(ps.Overlay,{ref:n,className:he("fixed inset-0 z-50 bg-black/5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));hD.displayName=ps.Overlay.displayName;const pD=N.forwardRef(({className:t,children:e,...n},r)=>S.jsxs(uz,{children:[S.jsx(hD,{}),S.jsx(Vu,{trapped:!1,children:S.jsxs(ps.Content,{ref:r,className:he("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-[16px] drop-shadow-2xl bg-white",t),...n,children:[S.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-white"}),e,S.jsx(ps.Close,{className:"absolute right-2 top-4 hover:bg-gray-200 rounded-full p-2 ring-offset-white transition focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2 disabled:pointer-events-none text-black data-[state=open]:bg-gray-100 data-[state=open]:text-black",children:S.jsx(cV,{size:20,fill:"black"})})]})})]}));pD.displayName="DrawerContent";const mD=({className:t,...e})=>S.jsx("div",{className:he("grid gap-1.5 p-4 text-center sm:text-left",t),...e});mD.displayName="DrawerHeader";const gD=N.forwardRef(({className:t,...e},n)=>S.jsx(ps.Title,{ref:n,className:he("text-lg font-semibold leading-none tracking-tight",t),...e}));gD.displayName=ps.Title.displayName;const cz=N.forwardRef(({className:t,...e},n)=>S.jsx(ps.Description,{ref:n,className:he("text-sm text-black",t),...e}));cz.displayName=ps.Description.displayName;const fz=({title:t,content:e,contentClassName:n})=>S.jsxs(pD,{className:"w-full z-20",children:[S.jsx(mD,{className:"px-4 pt-0",children:S.jsx(gD,{className:"text-left sm:text-center text-base",children:t})}),S.jsx("div",{className:he("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",n),children:e&&e})]}),dz=G3,hz=W3,pz=K3,mz=q3,yD=V.forwardRef(({className:t,...e},n)=>S.jsx(Tw,{ref:n,className:he("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));yD.displayName=Tw.displayName;const bD=V.forwardRef(({className:t,children:e,...n},r)=>S.jsxs(pz,{children:[S.jsx(yD,{}),S.jsx(Vu,{trapped:!1,children:S.jsxs(Dw,{ref:r,className:he("fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 bg-white duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",t),...n,children:[S.jsx("div",{}),e]})})]}));bD.displayName=Dw.displayName;const wD=({className:t,...e})=>S.jsx("div",{className:he("grid gap-1.5 p-4 text-center sm:text-left",t),...e});wD.displayName="DialogHeader";const AD=({className:t,...e})=>S.jsx("div",{className:he("flex space-x-2",t),...e});AD.displayName="DialogFooter";const vD=V.forwardRef(({className:t,...e},n)=>S.jsx(Ow,{ref:n,className:he("text-lg font-semibold leading-none tracking-tight",t),...e}));vD.displayName=Ow.displayName;const gz=V.forwardRef(({className:t,...e},n)=>S.jsx(_w,{ref:n,className:he("text-sm text-black",t),...e}));gz.displayName=_w.displayName;function yz(t){return Object.prototype.toString.call(t)==="[object Object]"}function xD(t){return yz(t)||Array.isArray(t)}function bz(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function Bw(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;const s=JSON.stringify(Object.keys(t.breakpoints||{})),i=JSON.stringify(Object.keys(e.breakpoints||{}));return s!==i?!1:n.every(o=>{const a=t[o],l=e[o];return typeof a=="function"?`${a}`==`${l}`:!xD(a)||!xD(l)?a===l:Bw(a,l)})}function kD(t){return t.concat().sort((e,n)=>e.name>n.name?1:-1).map(e=>e.options)}function wz(t,e){if(t.length!==e.length)return!1;const n=kD(t),r=kD(e);return n.every((s,i)=>{const o=r[i];return Bw(s,o)})}function Fw(t){return typeof t=="number"}function jw(t){return typeof t=="string"}function Uw(t){return typeof t=="boolean"}function ED(t){return Object.prototype.toString.call(t)==="[object Object]"}function Mt(t){return Math.abs(t)}function Vw(t){return Math.sign(t)}function Id(t,e){return Mt(t-e)}function Az(t,e){if(t===0||e===0||Mt(t)<=Mt(e))return 0;const n=Id(Mt(t),Mt(e));return Mt(n/t)}function Ld(t){return Fd(t).map(Number)}function ms(t){return t[Bd(t)]}function Bd(t){return Math.max(0,t.length-1)}function Hw(t,e){return e===Bd(t)}function CD(t,e=0){return Array.from(Array(t),(n,r)=>e+r)}function Fd(t){return Object.keys(t)}function SD(t,e){return[t,e].reduce((n,r)=>(Fd(r).forEach(s=>{const i=n[s],o=r[s],a=ED(i)&&ED(o);n[s]=a?SD(i,o):o}),n),{})}function zw(t,e){return typeof e.MouseEvent<"u"&&t instanceof e.MouseEvent}function vz(t,e){const n={start:r,center:s,end:i};function r(){return 0}function s(l){return i(l)/2}function i(l){return e-l}function o(l,u){return jw(t)?n[t](l):t(e,l,u)}return{measure:o}}function jd(){let t=[];function e(s,i,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(i,o,a),l=()=>s.removeEventListener(i,o,a);else{const u=s;u.addListener(o),l=()=>u.removeListener(o)}return t.push(l),r}function n(){t=t.filter(s=>s())}const r={add:e,clear:n};return r}function xz(t,e,n,r){const s=jd(),i=1e3/60;let o=null,a=0,l=0;function u(){s.add(t,"visibilitychange",()=>{t.hidden&&p()})}function c(){h(),s.clear()}function f(g){if(!l)return;o||(o=g);const y=g-o;for(o=g,a+=y;a>=i;)n(),a-=i;const v=Mt(a/i);r(v),l&&e.requestAnimationFrame(f)}function d(){l||(l=e.requestAnimationFrame(f))}function h(){e.cancelAnimationFrame(l),o=null,a=0,l=0}function p(){o=null,a=0}return{init:u,destroy:c,start:d,stop:h,update:n,render:r}}function kz(t,e){const n=e==="rtl",r=t==="y",s=r?"y":"x",i=r?"x":"y",o=!r&&n?-1:1,a=c(),l=f();function u(p){const{height:m,width:g}=p;return r?m:g}function c(){return r?"top":n?"right":"left"}function f(){return r?"bottom":n?"left":"right"}function d(p){return p*o}return{scroll:s,cross:i,startEdge:a,endEdge:l,measureSize:u,direction:d}}function rl(t=0,e=0){const n=Mt(t-e);function r(u){return u<t}function s(u){return u>e}function i(u){return r(u)||s(u)}function o(u){return i(u)?r(u)?t:e:u}function a(u){return n?u-n*Math.ceil((u-e)/n):u}return{length:n,max:e,min:t,constrain:o,reachedAny:i,reachedMax:s,reachedMin:r,removeOffset:a}}function TD(t,e,n){const{constrain:r}=rl(0,t),s=t+1;let i=o(e);function o(d){return n?Mt((s+d)%s):r(d)}function a(){return i}function l(d){return i=o(d),f}function u(d){return c().set(a()+d)}function c(){return TD(t,a(),n)}const f={get:a,set:l,add:u,clone:c};return f}function Ez(t,e,n,r,s,i,o,a,l,u,c,f,d,h,p,m,g,y,v){const{cross:w,direction:A}=t,x=["INPUT","SELECT","TEXTAREA"],k={passive:!1},C=jd(),O=jd(),_=rl(50,225).constrain(h.measure(20)),D={mouse:300,touch:400},R={mouse:500,touch:600},L=p?43:25;let F=!1,G=0,B=0,H=!1,Q=!1,te=!1,Z=!1;function pe(ae){if(!v)return;function be(z){(Uw(v)||v(ae,z))&&Ue(z)}const Be=e;C.add(Be,"dragstart",z=>z.preventDefault(),k).add(Be,"touchmove",()=>{},k).add(Be,"touchend",()=>{}).add(Be,"touchstart",be).add(Be,"mousedown",be).add(Be,"touchcancel",Le).add(Be,"contextmenu",Le).add(Be,"click",tt,!0)}function Ee(){C.clear(),O.clear()}function Re(){const ae=Z?n:e;O.add(ae,"touchmove",ze,k).add(ae,"touchend",Le).add(ae,"mousemove",ze,k).add(ae,"mouseup",Le)}function Ce(ae){const be=ae.nodeName||"";return x.includes(be)}function ke(){return(p?R:D)[Z?"mouse":"touch"]}function He(ae,be){const Be=f.add(Vw(ae)*-1),z=c.byDistance(ae,!p).distance;return p||Mt(ae)<_?z:g&&be?z*.5:c.byIndex(Be.get(),0).distance}function Ue(ae){const be=zw(ae,r);Z=be,te=p&&be&&!ae.buttons&&F,F=Id(s.get(),o.get())>=2,!(be&&ae.button!==0)&&(Ce(ae.target)||(H=!0,i.pointerDown(ae),u.useFriction(0).useDuration(0),s.set(o),Re(),G=i.readPoint(ae),B=i.readPoint(ae,w),d.emit("pointerDown")))}function ze(ae){if(!zw(ae,r)&&ae.touches.length>=2)return Le(ae);const Be=i.readPoint(ae),z=i.readPoint(ae,w),q=Id(Be,G),re=Id(z,B);if(!Q&&!Z&&(!ae.cancelable||(Q=q>re,!Q)))return Le(ae);const ue=i.pointerMove(ae);q>m&&(te=!0),u.useFriction(.3).useDuration(.75),a.start(),s.add(A(ue)),ae.preventDefault()}function Le(ae){const Be=c.byDistance(0,!1).index!==f.get(),z=i.pointerUp(ae)*ke(),q=He(A(z),Be),re=Az(z,q),ue=L-10*re,P=y+re/50;Q=!1,H=!1,O.clear(),u.useDuration(ue).useFriction(P),l.distance(q,!p),Z=!1,d.emit("pointerUp")}function tt(ae){te&&(ae.stopPropagation(),ae.preventDefault(),te=!1)}function le(){return H}return{init:pe,destroy:Ee,pointerDown:le}}function Cz(t,e){let r,s;function i(f){return f.timeStamp}function o(f,d){const p=`client${(d||t.scroll)==="x"?"X":"Y"}`;return(zw(f,e)?f:f.touches[0])[p]}function a(f){return r=f,s=f,o(f)}function l(f){const d=o(f)-o(s),h=i(f)-i(r)>170;return s=f,h&&(r=f),d}function u(f){if(!r||!s)return 0;const d=o(s)-o(r),h=i(f)-i(r),p=i(f)-i(s)>170,m=d/h;return h&&!p&&Mt(m)>.1?m:0}return{pointerDown:a,pointerMove:l,pointerUp:u,readPoint:o}}function Sz(){function t(n){const{offsetTop:r,offsetLeft:s,offsetWidth:i,offsetHeight:o}=n;return{top:r,right:s+i,bottom:r+o,left:s,width:i,height:o}}return{measure:t}}function Tz(t){function e(r){return t*(r/100)}return{measure:e}}function Dz(t,e,n,r,s,i,o){let a,l,u=[],c=!1;function f(m){return s.measureSize(o.measure(m))}function d(m){if(!i)return;l=f(t),u=r.map(f);function g(v){for(const w of v){const A=w.target===t,x=r.indexOf(w.target),k=A?l:u[x],C=f(A?t:r[x]);if(Mt(C-k)>=.5){n.requestAnimationFrame(()=>{m.reInit(),e.emit("resize")});break}}}a=new ResizeObserver(v=>{c||(Uw(i)||i(m,v))&&g(v)}),[t].concat(r).forEach(v=>a.observe(v))}function h(){a&&a.disconnect(),c=!0}return{init:d,destroy:h}}function Oz(t,e,n,r,s){let i=0,o=0,a=r,l=s,u=t.get(),c=0;function f(){const x=n.get()-t.get(),k=!a;let C=0;return k?(i=0,t.set(n),C=x):(i+=x/a,i*=l,u+=i,t.add(i),C=u-c),o=Vw(C),c=u,A}function d(){const x=n.get()-e.get();return Mt(x)<.001}function h(){return a}function p(){return o}function m(){return i}function g(){return v(r)}function y(){return w(s)}function v(x){return a=x,A}function w(x){return l=x,A}const A={direction:p,duration:h,velocity:m,seek:f,settled:d,useBaseFriction:y,useBaseDuration:g,useFriction:w,useDuration:v};return A}function _z(t,e,n,r,s){const i=s.measure(10),o=s.measure(50),a=rl(.1,.99);let l=!1;function u(){return!(l||!t.reachedAny(n.get())||!t.reachedAny(e.get()))}function c(h){if(!u())return;const p=t.reachedMin(e.get())?"min":"max",m=Mt(t[p]-e.get()),g=n.get()-e.get(),y=a.constrain(m/o);n.subtract(g*y),!h&&Mt(g)<i&&(n.set(t.constrain(n.get())),r.useDuration(25).useBaseFriction())}function f(h){l=!h}return{shouldConstrain:u,constrain:c,toggleActive:f}}function Mz(t,e,n,r,s){const i=rl(-e+t,0),o=f(),a=c(),l=d();function u(p,m){return Id(p,m)<1}function c(){const p=o[0],m=ms(o),g=o.lastIndexOf(p),y=o.indexOf(m)+1;return rl(g,y)}function f(){return n.map((p,m)=>{const{min:g,max:y}=i,v=i.constrain(p),w=!m,A=Hw(n,m);return w?y:A||u(g,v)?g:u(y,v)?y:v}).map(p=>parseFloat(p.toFixed(3)))}function d(){if(e<=t+s)return[i.max];if(r==="keepSnaps")return o;const{min:p,max:m}=a;return o.slice(p,m)}return{snapsContained:l,scrollContainLimit:a}}function Nz(t,e,n){const r=e[0],s=n?r-t:ms(e);return{limit:rl(s,r)}}function Rz(t,e,n,r){const i=e.min+.1,o=e.max+.1,{reachedMin:a,reachedMax:l}=rl(i,o);function u(d){return d===1?l(n.get()):d===-1?a(n.get()):!1}function c(d){if(!u(d))return;const h=t*(d*-1);r.forEach(p=>p.add(h))}return{loop:c}}function Pz(t){const{max:e,length:n}=t;function r(i){const o=i-e;return n?o/-n:0}return{get:r}}function Iz(t,e,n,r,s){const{startEdge:i,endEdge:o}=t,{groupSlides:a}=s,l=f().map(e.measure),u=d(),c=h();function f(){return a(r).map(m=>ms(m)[o]-m[0][i]).map(Mt)}function d(){return r.map(m=>n[i]-m[i]).map(m=>-Mt(m))}function h(){return a(u).map(m=>m[0]).map((m,g)=>m+l[g])}return{snaps:u,snapsAligned:c}}function Lz(t,e,n,r,s,i){const{groupSlides:o}=s,{min:a,max:l}=r,u=c();function c(){const d=o(i),h=!t||e==="keepSnaps";return n.length===1?[i]:h?d:d.slice(a,l).map((p,m,g)=>{const y=!m,v=Hw(g,m);if(y){const w=ms(g[0])+1;return CD(w)}if(v){const w=Bd(i)-ms(g)[0]+1;return CD(w,ms(g)[0])}return p})}return{slideRegistry:u}}function Bz(t,e,n,r,s){const{reachedAny:i,removeOffset:o,constrain:a}=r;function l(p){return p.concat().sort((m,g)=>Mt(m)-Mt(g))[0]}function u(p){const m=t?o(p):a(p),g=e.map((v,w)=>({diff:c(v-m,0),index:w})).sort((v,w)=>Mt(v.diff)-Mt(w.diff)),{index:y}=g[0];return{index:y,distance:m}}function c(p,m){const g=[p,p+n,p-n];if(!t)return p;if(!m)return l(g);const y=g.filter(v=>Vw(v)===m);return y.length?l(y):ms(g)-n}function f(p,m){const g=e[p]-s.get(),y=c(g,m);return{index:p,distance:y}}function d(p,m){const g=s.get()+p,{index:y,distance:v}=u(g),w=!t&&i(g);if(!m||w)return{index:y,distance:p};const A=e[y]-v,x=p+c(A,0);return{index:y,distance:x}}return{byDistance:d,byIndex:f,shortcut:c}}function Fz(t,e,n,r,s,i,o){function a(f){const d=f.distance,h=f.index!==e.get();i.add(d),d&&(r.duration()?t.start():(t.update(),t.render(1),t.update())),h&&(n.set(e.get()),e.set(f.index),o.emit("select"))}function l(f,d){const h=s.byDistance(f,d);a(h)}function u(f,d){const h=e.clone().set(f),p=s.byIndex(h.get(),d);a(p)}return{distance:l,index:u}}function jz(t,e,n,r,s,i,o){let a=0;function l(){i.add(document,"keydown",u,!1),e.forEach(c)}function u(d){d.code==="Tab"&&(a=new Date().getTime())}function c(d){const h=()=>{if(new Date().getTime()-a>10)return;t.scrollLeft=0;const g=e.indexOf(d),y=n.findIndex(v=>v.includes(g));Fw(y)&&(s.useDuration(0),r.index(y,0),o.emit("slideFocus"))};i.add(d,"focus",h,{passive:!0,capture:!0})}return{init:l}}function W0(t){let e=t;function n(){return e}function r(l){e=o(l)}function s(l){e+=o(l)}function i(l){e-=o(l)}function o(l){return Fw(l)?l:l.get()}return{get:n,set:r,add:s,subtract:i}}function DD(t,e){const n=t.scroll==="x"?i:o,r=e.style;let s=!1;function i(f){return`translate3d(${f}px,0px,0px)`}function o(f){return`translate3d(0px,${f}px,0px)`}function a(f){s||(r.transform=n(t.direction(f)))}function l(f){s=!f}function u(){s||(r.transform="",e.getAttribute("style")||e.removeAttribute("style"))}return{clear:u,to:a,toggleActive:l}}function Uz(t,e,n,r,s,i,o,a,l){const c=Ld(s),f=Ld(s).reverse(),d=y().concat(v());function h(C,O){return C.reduce((_,D)=>_-s[D],O)}function p(C,O){return C.reduce((_,D)=>h(_,O)>0?_.concat([D]):_,[])}function m(C){return i.map((O,_)=>({start:O-r[_]+.5+C,end:O+e-.5+C}))}function g(C,O,_){const D=m(O);return C.map(R=>{const L=_?0:-n,F=_?n:0,G=_?"end":"start",B=D[R][G];return{index:R,loopPoint:B,slideLocation:W0(-1),translate:DD(t,l[R]),target:()=>a.get()>B?L:F}})}function y(){const C=o[0],O=p(f,C);return g(O,n,!1)}function v(){const C=e-o[0]-1,O=p(c,C);return g(O,-n,!0)}function w(){return d.every(({index:C})=>{const O=c.filter(_=>_!==C);return h(O,e)<=.1})}function A(){d.forEach(C=>{const{target:O,translate:_,slideLocation:D}=C,R=O();R!==D.get()&&(_.to(R),D.set(R))})}function x(){d.forEach(C=>C.translate.clear())}return{canLoop:w,clear:x,loop:A,loopPoints:d}}function Vz(t,e,n){let r,s=!1;function i(l){if(!n)return;function u(c){for(const f of c)if(f.type==="childList"){l.reInit(),e.emit("slidesChanged");break}}r=new MutationObserver(c=>{s||(Uw(n)||n(l,c))&&u(c)}),r.observe(t,{childList:!0})}function o(){r&&r.disconnect(),s=!0}return{init:i,destroy:o}}function Hz(t,e,n,r){const s={};let i=null,o=null,a,l=!1;function u(){a=new IntersectionObserver(p=>{l||(p.forEach(m=>{const g=e.indexOf(m.target);s[g]=m}),i=null,o=null,n.emit("slidesInView"))},{root:t.parentElement,threshold:r}),e.forEach(p=>a.observe(p))}function c(){a&&a.disconnect(),l=!0}function f(p){return Fd(s).reduce((m,g)=>{const y=parseInt(g),{isIntersecting:v}=s[y];return(p&&v||!p&&!v)&&m.push(y),m},[])}function d(p=!0){if(p&&i)return i;if(!p&&o)return o;const m=f(p);return p&&(i=m),p||(o=m),m}return{init:u,destroy:c,get:d}}function zz(t,e,n,r,s,i){const{measureSize:o,startEdge:a,endEdge:l}=t,u=n[0]&&s,c=p(),f=m(),d=n.map(o),h=g();function p(){if(!u)return 0;const v=n[0];return Mt(e[a]-v[a])}function m(){if(!u)return 0;const v=i.getComputedStyle(ms(r));return parseFloat(v.getPropertyValue(`margin-${l}`))}function g(){return n.map((v,w,A)=>{const x=!w,k=Hw(A,w);return x?d[w]+c:k?d[w]+f:A[w+1][a]-v[a]}).map(Mt)}return{slideSizes:d,slideSizesWithGaps:h,startGap:c,endGap:f}}function $z(t,e,n,r,s,i,o,a,l){const{startEdge:u,endEdge:c,direction:f}=t,d=Fw(n);function h(y,v){return Ld(y).filter(w=>w%v===0).map(w=>y.slice(w,w+v))}function p(y){return y.length?Ld(y).reduce((v,w,A)=>{const x=ms(v)||0,k=x===0,C=w===Bd(y),O=s[u]-i[x][u],_=s[u]-i[w][c],D=!r&&k?f(o):0,R=!r&&C?f(a):0,L=Mt(_-R-(O+D));return A&&L>e+l&&v.push(w),C&&v.push(y.length),v},[]).map((v,w,A)=>{const x=Math.max(A[w-1]||0);return y.slice(x,v)}):[]}function m(y){return d?h(y,n):p(y)}return{groupSlides:m}}function Gz(t,e,n,r,s,i,o){const{align:a,axis:l,direction:u,startIndex:c,loop:f,duration:d,dragFree:h,dragThreshold:p,inViewThreshold:m,slidesToScroll:g,skipSnaps:y,containScroll:v,watchResize:w,watchSlides:A,watchDrag:x}=i,k=2,C=Sz(),O=C.measure(e),_=n.map(C.measure),D=kz(l,u),R=D.measureSize(O),L=Tz(R),F=vz(a,R),G=!f&&!!v,B=f||!!v,{slideSizes:H,slideSizesWithGaps:Q,startGap:te,endGap:Z}=zz(D,O,_,n,B,s),pe=$z(D,R,g,f,O,_,te,Z,k),{snaps:Ee,snapsAligned:Re}=Iz(D,F,O,_,pe),Ce=-ms(Ee)+ms(Q),{snapsContained:ke,scrollContainLimit:He}=Mz(R,Ce,Re,v,k),Ue=G?ke:Re,{limit:ze}=Nz(Ce,Ue,f),Le=TD(Bd(Ue),c,f),tt=Le.clone(),le=Ld(n),$e=({dragHandler:Je,scrollBody:Ve,scrollBounds:Fe,options:{loop:ft}})=>{ft||Fe.constrain(Je.pointerDown()),Ve.seek()},ae=({scrollBody:Je,translate:Ve,location:Fe,offsetLocation:ft,scrollLooper:Xn,slideLooper:br,dragHandler:X,animation:ne,eventHandler:ie,scrollBounds:Te,options:{loop:me}},qe)=>{const nt=Je.velocity(),yt=Je.settled(),sn=!Te.shouldConstrain(),Ft=me?yt:yt&&sn;Ft&&!X.pointerDown()&&(ne.stop(),ie.emit("settle")),Ft||ie.emit("scroll"),ft.set(Fe.get()-nt+nt*qe),me&&(Xn.loop(Je.direction()),br.loop()),Ve.to(ft.get())},be=xz(r,s,()=>$e(Se),Je=>ae(Se,Je)),Be=.68,z=Ue[Le.get()],q=W0(z),re=W0(z),ue=W0(z),P=Oz(q,re,ue,d,Be),b=Bz(f,Ue,Ce,ze,ue),E=Fz(be,Le,tt,P,b,ue,o),M=Pz(ze),j=jd(),K=Hz(e,n,o,m),{slideRegistry:Y}=Lz(G,v,Ue,He,pe,le),ye=jz(t,n,Y,E,P,j,o),Se={ownerDocument:r,ownerWindow:s,eventHandler:o,containerRect:O,slideRects:_,animation:be,axis:D,dragHandler:Ez(D,t,r,s,ue,Cz(D,s),q,be,E,P,b,Le,o,L,h,p,y,Be,x),eventStore:j,percentOfView:L,index:Le,indexPrevious:tt,limit:ze,location:q,offsetLocation:re,options:i,resizeHandler:Dz(e,o,s,n,D,w,C),scrollBody:P,scrollBounds:_z(ze,re,ue,P,L),scrollLooper:Rz(Ce,ze,re,[q,re,ue]),scrollProgress:M,scrollSnapList:Ue.map(M.get),scrollSnaps:Ue,scrollTarget:b,scrollTo:E,slideLooper:Uz(D,R,Ce,H,Q,Ee,Ue,re,n),slideFocus:ye,slidesHandler:Vz(e,o,A),slidesInView:K,slideIndexes:le,slideRegistry:Y,slidesToScroll:pe,target:ue,translate:DD(D,e)};return Se}function Wz(){let t={},e;function n(u){e=u}function r(u){return t[u]||[]}function s(u){return r(u).forEach(c=>c(e,u)),l}function i(u,c){return t[u]=r(u).concat([c]),l}function o(u,c){return t[u]=r(u).filter(f=>f!==c),l}function a(){t={}}const l={init:n,emit:s,off:o,on:i,clear:a};return l}const Kz={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function qz(t){function e(i,o){return SD(i,o||{})}function n(i){const o=i.breakpoints||{},a=Fd(o).filter(l=>t.matchMedia(l).matches).map(l=>o[l]).reduce((l,u)=>e(l,u),{});return e(i,a)}function r(i){return i.map(o=>Fd(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(t.matchMedia)}return{mergeOptions:e,optionsAtMedia:n,optionsMediaQueries:r}}function Qz(t){let e=[];function n(i,o){return e=o.filter(({options:a})=>t.optionsAtMedia(a).active!==!1),e.forEach(a=>a.init(i,t)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function r(){e=e.filter(i=>i.destroy())}return{init:n,destroy:r}}function K0(t,e,n){const r=t.ownerDocument,s=r.defaultView,i=qz(s),o=Qz(i),a=jd(),l=Wz(),{mergeOptions:u,optionsAtMedia:c,optionsMediaQueries:f}=i,{on:d,off:h,emit:p}=l,m=R;let g=!1,y,v=u(Kz,K0.globalOptions),w=u(v),A=[],x,k,C;function O(){const{container:$e,slides:ae}=w;k=(jw($e)?t.querySelector($e):$e)||t.children[0];const Be=jw(ae)?k.querySelectorAll(ae):ae;C=[].slice.call(Be||k.children)}function _($e){const ae=Gz(t,k,C,r,s,$e,l);if($e.loop&&!ae.slideLooper.canLoop()){const be=Object.assign({},$e,{loop:!1});return _(be)}return ae}function D($e,ae){g||(v=u(v,$e),w=c(v),A=ae||A,O(),y=_(w),f([v,...A.map(({options:be})=>be)]).forEach(be=>a.add(be,"change",R)),w.active&&(y.translate.to(y.location.get()),y.animation.init(),y.slidesInView.init(),y.slideFocus.init(),y.eventHandler.init(le),y.resizeHandler.init(le),y.slidesHandler.init(le),y.options.loop&&y.slideLooper.loop(),k.offsetParent&&C.length&&y.dragHandler.init(le),x=o.init(le,A)))}function R($e,ae){const be=Ee();L(),D(u({startIndex:be},$e),ae),l.emit("reInit")}function L(){y.dragHandler.destroy(),y.eventStore.clear(),y.translate.clear(),y.slideLooper.clear(),y.resizeHandler.destroy(),y.slidesHandler.destroy(),y.slidesInView.destroy(),y.animation.destroy(),o.destroy(),a.clear()}function F(){g||(g=!0,a.clear(),L(),l.emit("destroy"),l.clear())}function G($e,ae,be){!w.active||g||(y.scrollBody.useBaseFriction().useDuration(ae===!0?0:w.duration),y.scrollTo.index($e,be||0))}function B($e){const ae=y.index.add(1).get();G(ae,$e,-1)}function H($e){const ae=y.index.add(-1).get();G(ae,$e,1)}function Q(){return y.index.add(1).get()!==Ee()}function te(){return y.index.add(-1).get()!==Ee()}function Z(){return y.scrollSnapList}function pe(){return y.scrollProgress.get(y.location.get())}function Ee(){return y.index.get()}function Re(){return y.indexPrevious.get()}function Ce(){return y.slidesInView.get()}function ke(){return y.slidesInView.get(!1)}function He(){return x}function Ue(){return y}function ze(){return t}function Le(){return k}function tt(){return C}const le={canScrollNext:Q,canScrollPrev:te,containerNode:Le,internalEngine:Ue,destroy:F,off:h,on:d,emit:p,plugins:He,previousScrollSnap:Re,reInit:m,rootNode:ze,scrollNext:B,scrollPrev:H,scrollProgress:pe,scrollSnapList:Z,scrollTo:G,selectedScrollSnap:Ee,slideNodes:tt,slidesInView:Ce,slidesNotInView:ke};return D(e,n),setTimeout(()=>l.emit("init"),0),le}K0.globalOptions=void 0;function $w(t={},e=[]){const n=N.useRef(t),r=N.useRef(e),[s,i]=N.useState(),[o,a]=N.useState(),l=N.useCallback(()=>{s&&s.reInit(n.current,r.current)},[s]);return N.useEffect(()=>{if(bz()&&o){K0.globalOptions=$w.globalOptions;const u=K0(o,n.current,r.current);return i(u),()=>u.destroy()}else i(void 0)},[o,i]),N.useEffect(()=>{Bw(n.current,t)||(n.current=t,l())},[t,l]),N.useEffect(()=>{wz(r.current,e)||(r.current=e,l())},[e,l]),[a,s]}$w.globalOptions=void 0;const OD=N.createContext(null);function Ud(){const t=N.useContext(OD);if(!t)throw new Error("useCarousel must be used within a <Carousel />");return t}const _D=N.forwardRef(({orientation:t="horizontal",opts:e,setApi:n,plugins:r,className:s,children:i,...o},a)=>{const[l,u]=$w({...e,axis:t==="horizontal"?"x":"y"},r),[c,f]=N.useState(!1),[d,h]=N.useState(!1),p=N.useCallback(v=>{v&&(f(v.canScrollPrev()),h(v.canScrollNext()))},[]),m=N.useCallback(()=>{u==null||u.scrollPrev()},[u]),g=N.useCallback(()=>{u==null||u.scrollNext()},[u]),y=N.useCallback(v=>{v.key==="ArrowLeft"?(v.preventDefault(),m()):v.key==="ArrowRight"&&(v.preventDefault(),g())},[m,g]);return N.useEffect(()=>{!u||!n||n(u)},[u,n]),N.useEffect(()=>{if(u)return p(u),u.on("reInit",p),u.on("select",p),()=>{u==null||u.off("select",p)}},[u,p]),S.jsx(OD.Provider,{value:{carouselRef:l,api:u,opts:e,orientation:t||((e==null?void 0:e.axis)==="y"?"vertical":"horizontal"),scrollPrev:m,scrollNext:g,canScrollPrev:c,canScrollNext:d},children:S.jsx("div",{ref:a,onKeyDownCapture:y,className:he("relative",s),role:"region","aria-roledescription":"carousel",...o,children:i})})});_D.displayName="Carousel";const MD=N.forwardRef(({className:t,...e},n)=>{const{carouselRef:r,orientation:s}=Ud();return S.jsx("div",{ref:r,className:"overflow-hidden",children:S.jsx("div",{ref:n,className:he("flex",s==="horizontal"?"-ml-4":"-mt-4 flex-col",t),...e})})});MD.displayName="CarouselContent";const Gw=N.forwardRef(({className:t,...e},n)=>{const{orientation:r}=Ud();return S.jsx("div",{ref:n,role:"group","aria-roledescription":"slide",className:he("min-w-0 shrink-0 grow-0 basis-full",r==="horizontal"?"pl-4":"pt-4",t),...e})});Gw.displayName="CarouselItem";const ND=N.forwardRef(({index:t,className:e,...n},r)=>{const{api:s}=Ud(),[i,o]=N.useState(0),[,a]=N.useState([]),l=N.useCallback(d=>{s&&s.scrollTo(d)},[s]),u=N.useCallback(d=>{d&&a(d.scrollSnapList())},[]),c=N.useCallback(d=>{d&&o(d.selectedScrollSnap())},[]);N.useEffect(()=>{s&&(u(s),c(s),s.on("reInit",u),s.on("reInit",c),s.on("select",c))},[s,u,c]);const f=i===t;return S.jsx("button",{ref:r,className:he("w-2 h-2 transition-colors duration-200 rounded-full",f?"bg-black":"bg-[#E8EBEC] hover:bg-black/50",e),onClick:()=>l(t),...n})});ND.displayName="CarouselIndicator";const Jz=N.forwardRef(({className:t,...e},n)=>{const{scrollPrev:r,canScrollPrev:s}=Ud();return S.jsx("button",{ref:n,className:he("btn bg-white hover:bg-[#F2F4F5] transition text-black flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",t),disabled:!s,onClick:r,...e,children:S.jsx("span",{children:"Back"})})});Jz.displayName="CarouselPrevious";const Yz=N.forwardRef(({className:t,...e},n)=>{const{scrollNext:r,canScrollNext:s}=Ud();return S.jsx("button",{ref:n,className:he("btn bg-black hover:bg-black text-white flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",t),disabled:!s,onClick:r,...e,children:S.jsx("span",{children:"Next"})})});Yz.displayName="CarouselNext";const q0=V.forwardRef(({className:t,label:e,type:n="text",isValid:r=!0,message:s,onChange:i,leftIcon:o,rightIcon:a,...l},u)=>{const c=V.useRef(null),f=Gr(u,c),d=V.useCallback(()=>{var m;(m=c.current)==null||m.focus()},[]),h=V.useMemo(()=>{if(o==null)return;const m=V.Children.only(o);if(V.isValidElement(m))return V.cloneElement(m,{...m.props,onClick:g=>{var y,v;(v=(y=m.props).onClick)==null||v.call(y,g),d()},className:he("absolute left-3 text-[#A1AAB1]",{"cursor-not-allowed":l.disabled})})},[d,o,l.disabled]),p=V.useMemo(()=>{if(a==null)return;const m=V.Children.only(a);if(V.isValidElement(m))return V.cloneElement(m,{...m.props,onClick:g=>{var y,v;(v=(y=m.props).onClick)==null||v.call(y,g),d()},className:he("absolute right-3 cursor-pointer text-[#A1AAB1]",{"cursor-not-allowed":l.disabled},{"text-red-500":!r})})},[d,a,l.disabled,r]);return S.jsxs("div",{className:"flex flex-col",children:[e?S.jsx("label",{className:"mb-2 text-sm font-medium",children:e}):null,S.jsxs("div",{className:"relative flex items-center group",children:[h,S.jsx("input",{type:n,className:he("flex h-9 w-full rounded border-[1px] border-[#E8EBEC] hover:border-black bg-transparent px-3 py-2 text-sm text-black transition-colors file:border-0 file:bg-transparent file:text-sm placeholder:text-[#A1AAB1] focus-visible:outline-none focus-visible:border-black",{"pr-3 pl-10":h},{"pr-10":p},{"border-red-500":!r},{"disabled:cursor-not-allowed disabled:bg-[#E8EBEC] disabled:border-[#A1AAB1] disabled:text-[#A1AAB1]":l.disabled},t),onChange:i,ref:f,...l}),p]}),s?S.jsx("p",{className:he("text-sm mt-2 font-normal text-wrap text-justify",{"text-red-500":!r,"text-black":r}),children:s}):null]})});q0.displayName="TextField";const sl=N.forwardRef(({active:t,buttonSize:e="medium",children:n,disabled:r,variant:s="primary",className:i,activeClassname:o,isLoading:a=!1,...l},u)=>{const c=he("flex items-center justify-center border-2 gap-2 transition text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",s==="primary"&&he("text-white bg-black border-black",!r&&!t&&"hover:bg-neutral-800 active:bg-neutral-900",t&&he("bg-neutral-900 dark:bg-neutral-300",o)),s==="secondary"&&he("text-neutral-900 border-black",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200",t&&"bg-neutral-200"),s==="tertiary"&&he("bg-neutral-50 text-neutral-900 border-transparent",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200",t&&he("bg-neutral-200",o)),s==="ghost"&&he("bg-transparent border-transparent text-neutral-900",!r&&!t&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10",t&&he("bg-black/10",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return S.jsx("button",{ref:u,disabled:r,className:c,...l,children:a?S.jsx(eV,{size:20,className:"animate-spin",fill:"transparent",stroke:"currentColor"}):n})});sl.displayName="Button";const RD=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:t=>{t.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:t=>{t.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:t=>{t.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:t=>{t.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:t=>{t.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:t=>{t.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:t=>{t.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:t=>{t.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:t=>{t.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:t=>{t.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:t=>{t.chain().focus().setFontFamily("cursive").run()}}],Ww=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}],Vd=2*1024*1024,Kw={IMAGE_SIZE:"Image size should be less than 2 MB"},qw=({editor:t,onError:e})=>{const{ref:n,toolVisibilty:r,setToolVisibility:s}=hV(Me.NONE),i=[{icon:S.jsx(KU,{size:20}),title:"Text Color",onClick:()=>s(Me.TEXT_COLOR),isActive:r===Me.TEXT_COLOR},{icon:S.jsx(QT,{size:20}),title:"Highlight",onClick:()=>s(Me.HIGHLIGHT),isActive:r===Me.HIGHLIGHT},null,{icon:S.jsx(ew,{size:20}),title:"Bold",onClick:()=>t==null?void 0:t.chain().focus().toggleBold().run(),isActive:t==null?void 0:t.isActive("bold")},{icon:S.jsx(tw,{size:20}),title:"Italic",onClick:()=>t==null?void 0:t.chain().focus().toggleItalic().run(),isActive:t==null?void 0:t.isActive("italic")},{icon:S.jsx(lw,{size:20}),title:"Underlined",onClick:()=>t==null?void 0:t.chain().focus().toggleUnderline().run(),isActive:t==null?void 0:t.isActive("underline")},{icon:S.jsx(sw,{size:20}),title:"Strikethrough",onClick:()=>t==null?void 0:t.chain().focus().toggleStrike().run(),isActive:t==null?void 0:t.isActive("strike")},null,{icon:S.jsx(D0,{size:20}),title:"List",onClick:()=>{t==null||t.chain().focus().toggleBulletList().run(),s(Me.NONE)},isActive:t==null?void 0:t.isActive("bulletList")},{icon:S.jsx(Uu,{size:20}),title:"Ordered List",onClick:()=>{t==null||t.chain().focus().toggleOrderedList().run(),s(Me.NONE)},isActive:t==null?void 0:t.isActive("orderedList")},{icon:S.jsx(rw,{size:20}),title:"To-do List",onClick:()=>{t==null||t.chain().focus().toggleTaskList().run(),s(Me.NONE)},isActive:t==null?void 0:t.isActive("taskList")},{icon:S.jsx(Od,{size:20}),title:"Alignment",onClick:()=>s(Me.ALIGNMENT),isActive:r===Me.ALIGNMENT},{icon:S.jsx(O0,{size:20}),title:"Quote",onClick:()=>t==null?void 0:t.chain().focus().toggleBlockquote().run(),isActive:t==null?void 0:t.isActive("blockquote")},null,{icon:S.jsx(JT,{size:20}),title:"Upload Image",onClick:()=>{t==null||t.chain().focus().deleteRange(t.state.selection).run();const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=async()=>{var l;if((l=a.files)!=null&&l.length){const u=a.files[0];if(u.size>Vd){e&&typeof e=="function"&&e(Kw.IMAGE_SIZE);return}const f=t.view.state.selection.from;uw(u,t.view,f)}},a.click()},isActive:!1},{icon:S.jsx(nw,{size:20}),title:"Link",onClick:()=>s(Me.LINK),isActive:t==null?void 0:t.isActive("link")},{icon:S.jsx(Md,{size:20}),title:"Code",onClick:()=>t==null?void 0:t.chain().focus().toggleCodeBlock().run(),isActive:t==null?void 0:t.isActive("codeBlock")},{icon:S.jsx(iw,{size:20}),title:"Add table",onClick:()=>t==null?void 0:t.chain().focus().insertTable({rows:3,cols:2,withHeaderRow:!0}).run(),isActive:r===Me.TEXT_COLOR}],o=[{icon:S.jsx(aw,{size:24}),title:"Text formating",onClick:()=>s(Me.TEXT_FORMATING),isActive:r===Me.TEXT_FORMATING},{icon:S.jsx(iw,{size:24}),title:"Add table",onClick:()=>t==null?void 0:t.chain().focus().insertTable({rows:3,cols:2,withHeaderRow:!0}).run(),isActive:!0},{icon:S.jsx(rw,{size:24}),title:"To-do list",onClick:()=>{t==null||t.chain().focus().toggleTaskList().run(),s(Me.NONE)},isActive:!0},{icon:S.jsx(JT,{size:24}),title:"Add image",onClick:()=>{t==null||t.chain().focus().deleteRange(t.state.selection).run();const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=async()=>{var l;if((l=a.files)!=null&&l.length){const u=a.files[0];if(u.size>Vd){e&&typeof e=="function"&&e(Kw.IMAGE_SIZE);return}const f=t.view.state.selection.from;uw(u,t.view,f)}},a.click()},isActive:!0},{icon:S.jsx(uV,{size:24}),title:"Undo",onClick:()=>{t==null||t.chain().focus().undo().run()},isActive:t==null?void 0:t.can().undo()},{icon:S.jsx(oV,{size:24}),title:"Redo",onClick:()=>{t==null||t.chain().focus().redo().run()},isActive:t==null?void 0:t.can().redo()}];return{toolbar:i,bottomToolbar:o,toolRef:n,toolVisibilty:r,setToolVisibility:s}},PD=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return S.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[S.jsx(Z1,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetHighlight().run(),e(Me.NONE)}}),r.map(s=>S.jsx("div",{onClick:()=>{t.chain().focus().toggleHighlight({color:s.color}).run(),e(Me.NONE)},className:he("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:S.jsx(_d,{size:14,className:he(t.isActive("highlight",{color:s.color})?"visible":"invisible")})},s.color))]})},Xz=({elementRef:t,editor:e,setToolVisibility:n})=>S.jsx("div",{ref:t,className:he("z-50 h-auto absolute top-14 left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-lg transition-all rounded animate-in fade-in slide-in-from-top-1"),children:RD.map(r=>S.jsx("button",{onClick:()=>{r.command(e),n(Me.NONE)},style:{fontFamily:r.title},className:he("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm text-black transition",e.isActive("textStyle",{fontFamily:r.value})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx("p",{className:"font-medium",children:r.title})},r.title))}),ID=({elementRef:t,editor:e,setToolVisibility:n})=>S.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-14 left-[60%] translate-x-1/2 flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[S.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),n(Me.NONE)},className:he("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"left"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx(Od,{})}),S.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),n(Me.NONE)},className:he("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"center"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx(Y1,{})}),S.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),n(Me.NONE)},className:he("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"right"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx(X1,{})})]}),Zz=({elementRef:t,editor:e,setToolVisibility:n})=>S.jsxs("div",{ref:t,className:he("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all"),children:[S.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:S.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),n(Me.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:S.jsx(D0,{size:20})})}),S.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:S.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),n(Me.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:S.jsx(Uu,{size:20})})}),S.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:S.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),n(Me.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:S.jsx(rw,{size:20})})})]}),LD=({elementRef:t,editor:e,setToolVisibility:n,bubbleMenu:r,setIsLinkPopupOpen:s})=>{const[i,o]=N.useState(e.getAttributes("link").href),a=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let l=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(l="https://"+i);try{l.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:l}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:l}).run(),n(Me.NONE),r&&s&&s(!1)};return S.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-14 translate-x-1/2 items-center flex max-h-[330px] overflow-y-auto scroll-smooth rounded-lg bg-white p-2 shadow-lg transition-all",children:[S.jsx(q0,{onChange:l=>o(l.target.value),className:"w-full",placeholder:"Add link here",value:i}),S.jsx("div",{className:"h-full flex items-center",children:S.jsx(sl,{variant:"secondary",onClick:()=>a(),className:"min-w-fit h-[36px]",children:"Apply"})})]})},e$=({editor:t,setVisibility:e,elementRef:n})=>S.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[S.jsx(Z1,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetColor().run(),e(Me.NONE)}}),Ww.map(r=>S.jsx("div",{onClick:()=>{t.chain().focus().setColor(r.color).run(),e(Me.NONE)},className:he("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",r.code),children:S.jsx(_d,{size:14,className:he(t.isActive("textStyle",{color:r.color})?"visible":"invisible")})},r.color))]}),t$=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{title:"Text",description:"Normal",icon:S.jsx(aw,{size:20}),command:s=>s.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:S.jsx(C0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:1}).run()},isActive:()=>t.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:S.jsx(S0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:2}).run()},isActive:()=>t.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:S.jsx(T0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:3}).run()},isActive:()=>t.isActive("heading",{level:3})}];return S.jsx("div",{ref:n,className:he("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-lg animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(s=>S.jsxs("button",{onClick:()=>{s.command(t),e(Me.NONE)},className:he("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":s.isActive(),"hover:bg-[#f2f2f2]":!s.isActive()}),children:[S.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:s.icon}),S.jsxs("div",{children:[S.jsx("p",{className:"font-medium",children:s.title}),S.jsxs("p",{className:"text-xs text-stone-500",children:[" ",s.description," "]})]})]},s.title))})},n$=({editor:t,setToolVisibility:e})=>{const n=[{title:"Text",description:"Normal",icon:S.jsx(aw,{size:20}),command:r=>r.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:S.jsx(C0,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:1}).run()},isActive:()=>t.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:S.jsx(S0,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:2}).run()},isActive:()=>t.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:S.jsx(T0,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:3}).run()},isActive:()=>t.isActive("heading",{level:3})}];return S.jsx(fz,{title:"Text formating",content:S.jsxs("div",{className:"px-4 flex flex-col gap-2 w-full",children:[S.jsx("div",{className:"flex justify-start sm:justify-center items-center gap-1",children:n.map(r=>S.jsx("button",{onClick:()=>r.command(t),className:he("flex w-fit items-center font-medium space-x-2 rounded p-2 text-center text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":r.isActive(),"hover:bg-[#f2f2f2]":!r.isActive()}),children:r.title},r.title))}),S.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-1 justify-evenly w-full sm:w-fit p-1",children:[S.jsx("button",{onClick:()=>{t==null||t.chain().focus().setTextAlign("left").run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive({textAlign:"left"}),"hover:bg-[#f2f2f2]":!t.isActive({textAlign:"left"})}),children:S.jsx(Od,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().setTextAlign("center").run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive({textAlign:"center"}),"hover:bg-[#f2f2f2]":!t.isActive({textAlign:"center"})}),children:S.jsx(Y1,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().setTextAlign("right").run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive({textAlign:"right"}),"hover:bg-[#f2f2f2]":!t.isActive({textAlign:"right"})}),children:S.jsx(X1,{size:20})})]}),S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-1 justify-evenly w-full sm:w-fit p-1",children:[S.jsx(hz,{asChild:!0,children:S.jsx("button",{onClick:()=>e(Me.LINK_POPUP),className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("link"),"hover:bg-[#f2f2f2]":!t.isActive("link")}),children:S.jsx(nw,{size:20})})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleCodeBlock().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("codeBlock"),"hover:bg-[#f2f2f2]":!t.isActive("codeBlock")}),children:S.jsx(Md,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleBlockquote().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("blockquote"),"hover:bg-[#f2f2f2]":!t.isActive("blockquote")}),children:S.jsx(O0,{size:20})})]})]}),S.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-1 justify-evenly w-full sm:w-fit p-1",children:[S.jsx("button",{onClick:()=>{t.chain().focus().toggleBold().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("bold"),"hover:bg-[#f2f2f2]":!t.isActive("bold")}),children:S.jsx(ew,{size:20})}),S.jsx("button",{onClick:()=>{t.chain().focus().toggleItalic().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("italic"),"hover:bg-[#f2f2f2]":!t.isActive("italic")}),children:S.jsx(tw,{size:20})}),S.jsx("button",{onClick:()=>{t.chain().focus().toggleUnderline().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("underline"),"hover:bg-[#f2f2f2]":!t.isActive("bold")}),children:S.jsx(lw,{size:20})}),S.jsx("button",{onClick:()=>{t.chain().focus().toggleStrike().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("strike"),"hover:bg-[#f2f2f2]":!t.isActive("bold")}),children:S.jsx(sw,{size:20})})]}),S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex flex-[0.5] sm:flex-none gap-2 justify-evenly w-full sm:w-fit p-1",children:[S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleBulletList().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("bulletList"),"hover:bg-[#f2f2f2]":!t.isActive("bulletList")}),children:S.jsx(D0,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleOrderedList().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("orderedList"),"hover:bg-[#f2f2f2]":!t.isActive("orderedList")}),children:S.jsx(Uu,{size:20})})]})]}),S.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[S.jsx("p",{className:"text-left sm:text-center text-lg font-semibold leading-none tracking-tight",children:"Text color"}),S.jsxs(_D,{opts:{align:"start",dragFree:!0,slidesToScroll:"auto"},className:"w-full max-w-md mx-auto",children:[S.jsxs(MD,{children:[S.jsx(Gw,{style:{flexBasis:"calc(100% / 12)"},children:S.jsx(Z1,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetColor().run()}})}),Ww.map((r,s)=>S.jsx(Gw,{style:{flexBasis:"calc(100% / 12)"},children:S.jsx("button",{onClick:()=>{t.chain().focus().setColor(r.color).run()},className:he("w-6 h-6 mb-1 drop-shadow rounded-full flex justify-center items-center cursor-pointer transition",r.code),children:S.jsx(_d,{size:14,className:he(t.isActive("textStyle",{color:r.color})?"visible":"invisible")})},r.color)},s))]}),S.jsx("div",{className:"flex justify-center gap-2 mt-4 w-full max-w-sm",children:Array.from({length:Ww.length/8}).map((r,s)=>S.jsx(ND,{index:s},s))})]})]})]})})},r$=t=>{const e=[{name:"Bold",isActive:()=>t.editor.isActive("bold"),command:()=>t.editor.chain().focus().toggleBold().run(),icon:S.jsx(ew,{size:20})},{name:"Italic",isActive:()=>t.editor.isActive("italic"),command:()=>t.editor.chain().focus().toggleItalic().run(),icon:S.jsx(tw,{size:20})},{name:"Underline",isActive:()=>t.editor.isActive("underline"),command:()=>t.editor.chain().focus().toggleUnderline().run(),icon:S.jsx(lw,{size:20})},{name:"Strikethrough",isActive:()=>t.editor.isActive("strike"),command:()=>t.editor.chain().focus().toggleStrike().run(),icon:S.jsx(sw,{size:20})},{name:"Alignment",isActive:()=>f===Me.ALIGNMENT,command:()=>c(Me.ALIGNMENT),icon:S.jsx(Od,{size:20})},{name:"Code",isActive:()=>t.editor.isActive("codeBlock"),command:()=>t.editor.chain().focus().toggleCodeBlock().run(),icon:S.jsx(Md,{size:20})},{name:"Link",isActive:()=>t.editor.isActive("link"),command:()=>l(!a),icon:S.jsx(nw,{size:20})}],n={...t,shouldShow:({state:h,editor:p})=>{const{selection:m}=h,{empty:g}=m;return!(p.isActive("image")||g||k1(m))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{s(!1),o(!1),l(!1)}}},[r,s]=N.useState(!1),[i,o]=N.useState(!1),[a,l]=N.useState(!1),{toolRef:u,setToolVisibility:c,toolVisibilty:f}=qw({editor:t.editor}),d=({editor:h})=>{const{from:p,to:m}=h.state.selection;if(p===m)return!1;let g=!1;return h.state.doc.nodesBetween(p,m,y=>{y.marks&&y.marks.forEach(v=>{v.type.name==="highlight"&&v.attrs.color==="yellow"&&(g=!0)})}),!g};return S.jsxs(VT,{...n,shouldShow:d,className:"hidden lg:flex gap-2 overflow-hidden rounded-[12px] h-[52px] min-w-[550px] w-full py-2 px-4 bg-white items-center shadow-lg",children:[S.jsx(fV,{editor:t.editor,isOpen:r,setIsOpen:()=>{s(!r),o(!1)}}),e.map((h,p)=>S.jsxs("div",{className:"flex items-center",children:[S.jsx("button",{onClick:h.command,className:he("min-w-fit w-8 h-8 px-2 rounded",{"bg-yellow-300":h.isActive()}),children:h.icon}),(p===4||p===6)&&S.jsx("div",{className:"w-1.5 h-4 bg-gray-300 mx-2"})]},p)),S.jsx(dV,{editor:t.editor,isOpen:i,setIsOpen:()=>{o(!i),s(!1)}}),S.jsx("button",{onClick:()=>c(Me.HIGHLIGHT),className:he("min-w-fit w-8 h-8 px-2",{"bg-yellow-300":f===Me.HIGHLIGHT}),children:S.jsx(QT,{size:20})}),f===Me.ALIGNMENT&&S.jsx(ID,{setToolVisibility:c,editor:t.editor,elementRef:u}),a&&S.jsx(LD,{setToolVisibility:c,editor:t.editor,elementRef:u,bubbleMenu:!0,setIsLinkPopupOpen:l}),f===Me.HIGHLIGHT&&S.jsx(PD,{setVisibility:c,editor:t.editor,elementRef:u})]})};function s$(){const t=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let n=0;n<36;n++)n===8||n===13||n===18||n===23?e[n]="-":e[n]=t[Math.ceil(Math.random()*t.length-1)];return e.join("")}var i$=s$;const o$=Np(i$),BD=Ye.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:t=>t.getAttribute("data-position"),renderHTML:t=>({"data-position":t.position})}}},renderHTML({HTMLAttributes:t}){return["div",rt(t,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),a$=(t,e)=>Array.from({length:t},(n,r)=>e(r)),Q0=({type:t,content:e})=>e?{type:t,content:e}:{type:t},l$=({content:t})=>Q0({type:"paragraph",content:t}),FD=({content:t})=>Q0({type:"dBlock",content:t}),jD=({content:t})=>Q0({type:"column",content:t}),UD=({content:t})=>Q0({type:"columns",content:t}),VD=t=>{const e=[FD({content:[l$({})]})];return a$(t,()=>jD({content:e}))},HD=(t,e)=>{for(let n=t.depth;n>0;n--){const r=t.node(n),s=n>0?t.before(n):0,i=t.start(n);if(e({node:r,pos:s,start:i}))return{start:i,depth:n,node:r,pos:s}}throw Error("no ancestor found")};class J0 extends Pe{constructor(n){const{$from:r,$to:s}=n;super(r,s);W(this,"_$from");W(this,"_$to");this._$from=r,this._$to=s}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(n){return n instanceof J0&&n.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(n){var l;const r=({pos:u,node:c})=>c.type.name===BD.name?!0:n.resolve(u).depth<=0,{pos:s}=HD(this.$from,r);this._$from=n.resolve(s);const{pos:i,node:o}=HD(this.$to,r);this._$to=n.resolve(i+o.nodeSize),((l=this.getFirstNode())==null?void 0:l.type.name)===Y0.name&&(this._$from=n.resolve(this.$from.pos+2),this._$to=n.resolve(this.$to.pos+2));const a=this;a.$anchor=this._$from,a.$head=this._$to,a.ranges=[new Rb(this._$from,this._$to)]}static create(n,r,s){const i=n.resolve(r),o=n.resolve(s),a=new _e(i,o);return new J0(a)}getFirstNode(){return this.content().content.firstChild}}var il=(t=>(t.AlignLeft="align-left",t.AlignRight="align-right",t.AlignCenter="align-center",t))(il||{});const Y0=Ye.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:t,dispatch:e})=>{try{if(!e)return;const n=t.selection.$from,s=b1(n,({node:l})=>!this.options.nestedColumns&&l.type==this.type?!0:l.type==this.type);if(s===void 0)return;let i=[];s.node.descendants((l,u,c)=>{(c==null?void 0:c.type.name)===Y0.name&&i.push(l)}),i=i.reverse().filter(l=>l.content.size>0);const o=t.doc.resolve(s.pos),a=new De(o);return t=t.setSelection(a),i.forEach(l=>t=t.insert(s.pos,l)),t=t.deleteSelection(),e(t)}catch(n){console.error(n)}},setColumns:(t,e=!1)=>({tr:n,dispatch:r})=>{try{const{doc:s,selection:i}=n;if(!r){console.log("no dispatch");return}const o=new J0(i);o.expandSelection(s);const{openStart:a,openEnd:l}=o.content();if(a!==l){console.warn("failed depth check");return}let u;if(e){const h=o.content().toJSON(),p=jD(h),m=VD(t-1);u=UD({content:[p,...m]})}else{const h=VD(t);u=UD({content:h})}const c=s.type.schema.nodeFromJSON(FD({content:[u]}));if(c===null)return;const f=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===Y0.name))(f)){console.warn("content not allowed");return}return n=n.setSelection(o),n=n.replaceSelectionWith(c,!1),r(n)}catch(s){console.error(s)}},setLayout:t=>({commands:e})=>e.updateAttributes("columns",{layout:t})}},renderHTML({HTMLAttributes:t}){return["div",{"data-type":"columns",class:`layout-${t.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),u$=(t,e)=>{const{view:n,state:{selection:{from:r}}}=t,s=document.querySelectorAll(".has-focus"),i=s.length,a=s[i-1];if(a&&a.getAttribute("data-type")&&a.getAttribute("data-type")===e||a&&a.classList&&a.classList.contains(e))return a;const l=n.domAtPos(r).node;let u=l;for(u.tagName||(u=l.parentElement);u&&!(u.getAttribute("data-type")&&u.getAttribute("data-type")===e)&&!u.classList.contains(e);)u=u.parentElement;return u},Qw=N.forwardRef(({children:t,className:e,withShadow:n=!0,withBorder:r=!1,...s},i)=>{const o=he(e,"bg-white rounded",n?"shadow-lg":"",r?"border border-neutral-200":"");return S.jsx("div",{className:o,...s,ref:i,children:t})});Qw.displayName="Surface";const zD=({content:t,children:e})=>{const[n,r]=N.useState(!1);return S.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,n&&S.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:t})]})},$D=N.forwardRef(({shouldShowContent:t=!0,children:e,isVertical:n=!1,className:r,...s},i)=>{const o=he("text-black inline-flex h-full leading-none gap-0.5",n?"flex-col p-2":"flex-row p-1 items-center",r);return t?t&&S.jsx(Qw,{className:o,...s,ref:i,children:e}):null});$D.displayName="Toolbar";const GD=N.forwardRef(({horizontal:t,className:e,...n},r)=>{const s=he("bg-neutral-200",t?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return S.jsx("div",{className:s,ref:r,...n})});GD.displayName="Toolbar.Divider";const WD=N.forwardRef(({children:t,buttonSize:e="icon",variant:n="ghost",className:r,tooltip:s,activeClassname:i,...o},a)=>{const l=he("gap-1 min-w-[2rem] px-2 w-auto",r),u=S.jsx(sl,{activeClassname:i,className:l,variant:n,buttonSize:e,ref:a,...o,children:t});return s?S.jsx(zD,{content:s,children:u}):u});WD.displayName="ToolbarButton";const Wu={Wrapper:$D,Divider:GD,Button:WD},c$=({editor:t,appendTo:e})=>{const n=N.useCallback(()=>{const l=u$(t,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[t]),r=N.useCallback(()=>t.isActive("columns"),[t]),s=N.useCallback(()=>{t.chain().focus().setLayout(il.AlignLeft).run()},[t]),i=N.useCallback(()=>{t.chain().focus().setLayout(il.AlignRight).run()},[t]),o=N.useCallback(()=>{t.chain().focus().setLayout(il.AlignCenter).run()},[t]),a=N.useCallback(()=>{t.chain().focus().deleteNode("columns").run()},[t]);return S.jsx(VT,{editor:t,pluginKey:`columnsMenu-${o$()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:n,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[kU],sticky:"popper"},children:S.jsxs(Wu.Wrapper,{children:[S.jsx(Wu.Button,{tooltip:"Align left",active:t.isActive("columns",{layout:il.AlignLeft}),activeClassname:"bg-yellow-300 hover:brightness-90",onClick:s,children:S.jsx(rV,{size:20})}),S.jsx(Wu.Button,{tooltip:"Align center",active:t.isActive("columns",{layout:il.AlignCenter}),activeClassname:"bg-yellow-300 hover:brightness-90",onClick:o,children:S.jsx(qT,{size:20})}),S.jsx(Wu.Button,{tooltip:"Align right",active:t.isActive("columns",{layout:il.AlignRight}),activeClassname:"bg-yellow-300 hover:brightness-90",onClick:i,children:S.jsx(sV,{size:20})}),S.jsx(Wu.Button,{tooltip:"Remove column",onClick:a,children:S.jsx(ow,{size:20})})]})})},KD=N.createContext(null),X0=()=>N.useContext(KD),f$=({children:t,isPreviewMode:e})=>S.jsx(KD.Provider,{value:e,children:t}),qD=({height:t,width:e})=>S.jsx("span",{className:"flex items-center justify-center ",children:S.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${t?`h-${t}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),d$=({editor:t,onError:e})=>{var o;const{toolRef:n,toolVisibilty:r,setToolVisibility:s,toolbar:i}=qw({editor:t,onError:e});return S.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center relative",children:[S.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>s(Me.FONT_FAMILY),children:[S.jsx("span",{className:"text-sm",children:((o=RD.find(a=>t==null?void 0:t.isActive("textStyle",{fontFamily:a.value})))==null?void 0:o.title)||"Font"}),S.jsx(E0,{size:16})]}),S.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),S.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>s(Me.HEADING),children:[S.jsx("span",{className:"text-sm",children:t!=null&&t.isActive("heading",{level:1})?"Heading 1":t!=null&&t.isActive("heading",{level:2})?"Heading 2":t!=null&&t.isActive("heading",{level:3})?"Heading 3":"Text"}),S.jsx(E0,{size:16})]}),S.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),i.map((a,l)=>a?S.jsx("div",{className:"tooltip tooltip-neutral tooltip-bottom text-xs","data-tip":a.title,children:S.jsx("span",{onClick:()=>a.onClick(),className:he("rounded w-8 h-8 p-1 flex cursor-pointer justify-center items-center transition",a.isActive?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:typeof a.icon=="string"?S.jsx("img",{src:a.icon,className:"w-4"}):a.icon})},a.title):S.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"},l)),r===Me.FONT_FAMILY&&S.jsx(Xz,{setToolVisibility:s,editor:t,elementRef:n}),r===Me.HEADING&&S.jsx(t$,{setVisibility:s,editor:t,elementRef:n}),r===Me.TEXT_COLOR&&S.jsx(e$,{setVisibility:s,editor:t,elementRef:n}),r===Me.HIGHLIGHT&&S.jsx(PD,{setVisibility:s,editor:t,elementRef:n}),r===Me.ALIGNMENT&&S.jsx(ID,{setToolVisibility:s,editor:t,elementRef:n}),r===Me.LIST&&S.jsx(Zz,{setToolVisibility:s,editor:t,elementRef:n}),r===Me.LINK&&S.jsx(LD,{setToolVisibility:s,editor:t,elementRef:n})]})},zn=()=>new Map,Jw=t=>{const e=zn();return t.forEach((n,r)=>{e.set(r,n)}),e},or=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},h$=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},p$=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Oi=()=>new Set,Yw=t=>t[t.length-1],m$=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},_i=Array.from,g$=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Xw=Array.isArray;class Zw{constructor(){this._observers=zn()}on(e,n){return or(this._observers,e,Oi).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return _i((this._observers.get(e)||zn()).values()).forEach(r=>r(...n))}destroy(){this._observers=zn()}}class QD{constructor(){this._observers=zn()}on(e,n){or(this._observers,e,Oi).add(n)}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return _i((this._observers.get(e)||zn()).values()).forEach(r=>r(...n))}destroy(){this._observers=zn()}}const gs=Math.floor,Z0=Math.abs,y$=Math.log10,Lo=(t,e)=>t<e?t:e,Mi=(t,e)=>t>e?t:e,JD=t=>t!==0?t<0:1/t<0,$s=Date.now,b$=1200,w$=2500,em=3e4,eA=t=>{if(t.shouldConnect&&t.ws===null){const e=new WebSocket(t.url),n=t.binaryType;let r=null;n&&(e.binaryType=n),t.ws=e,t.connecting=!0,t.connected=!1,e.onmessage=o=>{t.lastMessageReceived=$s();const a=o.data,l=typeof a=="string"?JSON.parse(a):a;l&&l.type==="pong"&&(clearTimeout(r),r=setTimeout(i,em/2)),t.emit("message",[l,t])};const s=o=>{t.ws!==null&&(t.ws=null,t.connecting=!1,t.connected?(t.connected=!1,t.emit("disconnect",[{type:"disconnect",error:o},t])):t.unsuccessfulReconnects++,setTimeout(eA,Lo(y$(t.unsuccessfulReconnects+1)*b$,w$),t)),clearTimeout(r)},i=()=>{t.ws===e&&t.send({type:"ping"})};e.onclose=()=>s(null),e.onerror=o=>s(o),e.onopen=()=>{t.lastMessageReceived=$s(),t.connecting=!1,t.connected=!0,t.unsuccessfulReconnects=0,t.emit("connect",[{type:"connect"},t]),r=setTimeout(i,em/2)}}};class A$ extends QD{constructor(e,{binaryType:n}={}){super(),this.url=e,this.ws=null,this.binaryType=n||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&em<$s()-this.lastMessageReceived&&this.ws.close()},em/2),eA(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&eA(this)}}const Gs=t=>new Error(t),ys=()=>{throw Gs("Method unimplemented")},Sr=()=>{throw Gs("Unexpected case")},YD=1,XD=2,tA=4,nA=8,Hd=32,Ni=64,Tr=128,tm=31,rA=63,ol=127,v$=2147483647,x$=crypto.getRandomValues.bind(crypto),ZD=Math.random,eO=()=>x$(new Uint32Array(1))[0],k$=t=>t[gs(ZD()*t.length)],E$="10000000-1000-4000-8000"+-1e11,tO=()=>E$.replace(/[018]/g,t=>(t^eO()&15>>t/4).toString(16)),nO=Number.MAX_SAFE_INTEGER,C$=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&gs(t)===t),S$=String.fromCharCode,T$=t=>t.toLowerCase(),D$=/^\s*/g,O$=t=>t.replace(D$,""),_$=/([A-Z])/g,rO=(t,e)=>O$(t.replace(_$,n=>`${e}${T$(n)}`)),M$=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},zd=typeof TextEncoder<"u"?new TextEncoder:null,sA=zd?t=>zd.encode(t):M$;let $d=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});$d&&$d.decode(new Uint8Array).length===1&&($d=null);class Gd{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const un=()=>new Gd,N$=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Rt=t=>{const e=new Uint8Array(N$(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},R$=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Mi(n,e)*2),t.cpos=0)},cn=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Wd=cn,Ne=(t,e)=>{for(;e>ol;)cn(t,Tr|ol&e),e=gs(e/128);cn(t,ol&e)},iA=(t,e)=>{const n=JD(e);for(n&&(e=-e),cn(t,(e>rA?Tr:0)|(n?Ni:0)|rA&e),e=gs(e/64);e>0;)cn(t,(e>ol?Tr:0)|ol&e),e=gs(e/128)},oA=new Uint8Array(3e4),P$=oA.length/3,I$=(t,e)=>{if(e.length<P$){const n=zd.encodeInto(e,oA).written||0;Ne(t,n);for(let r=0;r<n;r++)cn(t,oA[r])}else jt(t,sA(e))},L$=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Ne(t,r);for(let s=0;s<r;s++)cn(t,n.codePointAt(s))},Ws=zd&&zd.encodeInto?I$:L$,nm=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Lo(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Mi(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},jt=(t,e)=>{Ne(t,e.byteLength),nm(t,e)},aA=(t,e)=>{R$(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},B$=(t,e)=>aA(t,4).setFloat32(0,e,!1),F$=(t,e)=>aA(t,8).setFloat64(0,e,!1),j$=(t,e)=>aA(t,8).setBigInt64(0,e,!1),sO=new DataView(new ArrayBuffer(4)),U$=t=>(sO.setFloat32(0,t),sO.getFloat32(0)===t),Ku=(t,e)=>{switch(typeof e){case"string":cn(t,119),Ws(t,e);break;case"number":C$(e)&&Z0(e)<=v$?(cn(t,125),iA(t,e)):U$(e)?(cn(t,124),B$(t,e)):(cn(t,123),F$(t,e));break;case"bigint":cn(t,122),j$(t,e);break;case"object":if(e===null)cn(t,126);else if(Xw(e)){cn(t,117),Ne(t,e.length);for(let n=0;n<e.length;n++)Ku(t,e[n])}else if(e instanceof Uint8Array)cn(t,116),jt(t,e);else{cn(t,118);const n=Object.keys(e);Ne(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];Ws(t,s),Ku(t,e[s])}}break;case"boolean":cn(t,e?120:121);break;default:cn(t,127)}};class iO extends Gd{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Ne(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const oO=t=>{t.count>0&&(iA(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ne(t.encoder,t.count-2))};class rm{constructor(){this.encoder=new Gd,this.s=0,this.count=0}write(e){this.s===e?this.count++:(oO(this),this.count=1,this.s=e)}toUint8Array(){return oO(this),Rt(this.encoder)}}const aO=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);iA(t.encoder,e),t.count>1&&Ne(t.encoder,t.count-2)}};class lA{constructor(){this.encoder=new Gd,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(aO(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return aO(this),Rt(this.encoder)}}class V${constructor(){this.sarr=[],this.s="",this.lensE=new rm}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Gd;return this.sarr.push(this.s),this.s="",Ws(e,this.sarr.join("")),nm(e,this.lensE.toUint8Array()),Rt(e)}}const lO=Gs("Unexpected end of array"),uO=Gs("Integer out of Range");class sm{constructor(e){this.arr=e,this.pos=0}}const Ks=t=>new sm(t),H$=t=>t.pos!==t.arr.length,z$=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},fn=t=>z$(t,We(t)),al=t=>t.arr[t.pos++],We=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&ol)*n,n*=128,s<Tr)return e;if(e>nO)throw uO}throw lO},uA=t=>{let e=t.arr[t.pos++],n=e&rA,r=64;const s=(e&Ni)>0?-1:1;if(!(e&Tr))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&ol)*r,r*=128,e<Tr)return s*n;if(n>nO)throw uO}throw lO},Ri=$d?t=>$d.decode(fn(t)):t=>{let e=We(t);if(e===0)return"";{let n=String.fromCodePoint(al(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(al(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},cA=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},$$=[t=>{},t=>null,uA,t=>cA(t,4).getFloat32(0,!1),t=>cA(t,8).getFloat64(0,!1),t=>cA(t,8).getBigInt64(0,!1),t=>!1,t=>!0,Ri,t=>{const e=We(t),n={};for(let r=0;r<e;r++){const s=Ri(t);n[s]=qu(t)}return n},t=>{const e=We(t),n=[];for(let r=0;r<e;r++)n.push(qu(t));return n},fn],qu=t=>$$[127-al(t)](t);class cO extends sm{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),H$(this)?this.count=We(this)+1:this.count=-1),this.count--,this.s}}class im extends sm{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=uA(this);const e=JD(this.s);this.count=1,e&&(this.s=-this.s,this.count=We(this)+2)}return this.count--,this.s}}class fA extends sm{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=uA(this),n=e&1;this.diff=gs(e/2),this.count=1,n&&(this.count=We(this)+2)}return this.s+=this.diff,this.count--,this.s}}class G${constructor(e){this.decoder=new im(e),this.str=Ri(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const fO=t=>t===void 0?null:t;class W${constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let dO=new W$,dA=!0;try{typeof localStorage<"u"&&localStorage&&(dO=localStorage,dA=!1)}catch{}const hO=dO,K$=t=>dA||addEventListener("storage",t),q$=t=>dA||removeEventListener("storage",t),Q$=Object.assign,hA=Object.keys,J$=(t,e)=>{for(const n in t)e(t[n],n)},pO=t=>hA(t).length,mO=t=>hA(t).length,Y$=t=>{for(const e in t)return!1;return!0},X$=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},gO=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Z$=(t,e)=>t===e||mO(t)===mO(e)&&X$(t,(n,r)=>(n!==void 0||gO(e,r))&&e[r]===n),pA=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&pA(t,e,n+1)}},eG=()=>{},tG=t=>t,nG=(t,e)=>t===e,Kd=(t,e)=>{if(t==null||e==null)return nG(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Kd(t.get(n),e.get(n)))return!1;break}case Object:if(pO(t)!==pO(e))return!1;for(const n in t)if(!gO(t,n)||!Kd(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Kd(t[n],e[n]))return!1;break;default:return!1}return!0},rG=(t,e)=>e.includes(t),Qu=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",mA=typeof window<"u"&&typeof document<"u"&&!Qu;let qs;const sG=()=>{if(qs===void 0)if(Qu){qs=zn();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&qs.set(e,""),e=r):e!==null&&(qs.set(e,r),e=null)}e!==null&&qs.set(e,"")}else typeof location=="object"?(qs=zn(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");qs.set(`--${rO(e,"-")}`,n),qs.set(`-${rO(e,"-")}`,n)}})):qs=zn();return qs},gA=t=>sG().has(t),om=t=>fO(Qu?process.env[t.toUpperCase().replaceAll("-","_")]:hO.getItem(t));(t=>gA("--"+t)||om(t)!==null)("production");const yO=Qu&&rG(process.env.FORCE_COLOR,["true","1","2"]),iG=!gA("--no-colors")&&(!Qu||process.stdout.isTTY||yO)&&(!Qu||gA("--color")||yO||om("COLORTERM")!==null||(om("TERM")||"").includes("color"));class oG{constructor(e,n){this.left=e,this.right=n}}const Pi=(t,e)=>new oG(t,e),aG=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const lG=t=>h$(t,(e,n)=>`${n}:${e};`).join(""),uG=JSON.stringify,cG=(t=>class{constructor(n){this._=n}destroy(){t(this._)}})(clearTimeout),yA=(t,e)=>new cG(setTimeout(e,t)),Ii=Symbol,Wr=Ii(),ll=Ii(),bO=Ii(),bA=Ii(),wO=Ii(),AO=Ii(),vO=Ii(),am=Ii(),lm=Ii(),fG=t=>{var r;t.length===1&&((r=t[0])==null?void 0:r.constructor)===Function&&(t=t[0]());const e=[];let n=0;for(;n<t.length;n++){const s=t[n];s===void 0||s.constructor===String||s.constructor===Number||s.constructor===Object&&e.push(JSON.stringify(s))}return e},xO=[wO,vO,am,bO];let wA=0,kO=$s();const dG=(t,e)=>{const n=xO[wA],r=om("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return wA=(wA+1)%xO.length,e+=": ",s?(...i)=>{var l;i.length===1&&((l=i[0])==null?void 0:l.constructor)===Function&&(i=i[0]());const o=$s(),a=o-kO;kO=o,t(n,e,lm,...i.map(u=>{switch(u!=null&&u.constructor===Uint8Array&&(u=Array.from(u)),typeof u){case"string":case"symbol":return u;default:return uG(u)}}),n," +"+a+"ms")}:eG},hG={[Wr]:Pi("font-weight","bold"),[ll]:Pi("font-weight","normal"),[bO]:Pi("color","blue"),[wO]:Pi("color","green"),[bA]:Pi("color","grey"),[AO]:Pi("color","red"),[vO]:Pi("color","purple"),[am]:Pi("color","orange"),[lm]:Pi("color","black")},EO=iG?t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=zn();let s=[],i=0;for(;i<t.length;i++){const a=t[i],l=hG[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const u=lG(r);i>0||u.length>0?(e.push("%c"+a),n.push(u)):e.push(a)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const a=t[i];a instanceof Symbol||s.push(a)}return s}:fG,CO=(...t)=>{console.log(...EO(t)),SO.forEach(e=>e.print(t))},pG=(...t)=>{console.warn(...EO(t)),t.unshift(am),SO.forEach(e=>e.print(t))},SO=Oi(),mG=t=>dG(CO,t),TO=t=>new Promise(t);Promise.all.bind(Promise);const gG=t=>Promise.reject(t),AA=t=>Promise.resolve(t),DO=t=>new Uint8Array(t),yG=(t,e,n)=>new Uint8Array(t,e,n),bG=t=>new Uint8Array(t),wG=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=S$(t[n]);return btoa(e)},AG=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),vG=t=>{const e=atob(t),n=DO(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},xG=t=>{const e=Buffer.from(t,"base64");return yG(e.buffer,e.byteOffset,e.byteLength)},OO=mA?wG:AG,_O=mA?vG:xG,kG=t=>{const e=DO(t.byteLength);return e.set(t),e},MO=new Map;class EG{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:_O(n.newValue||"")}),K$(this._onChange)}postMessage(e){hO.setItem(this.room,OO(bG(e)))}close(){q$(this._onChange)}}const CG=typeof BroadcastChannel>"u"?EG:BroadcastChannel,vA=t=>or(MO,t,()=>{const e=Oi(),n=new CG(t);return n.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:n,subs:e}}),SG=(t,e)=>(vA(t).subs.add(e),e),TG=(t,e)=>{const n=vA(t),r=n.subs.delete(e);return r&&n.subs.size===0&&(n.bc.close(),MO.delete(t)),r},DG=(t,e,n=null)=>{const r=vA(t);r.bc.postMessage(e),r.subs.forEach(s=>s(e,n))},NO=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},RO=t=>({[Symbol.iterator](){return this},next:t}),OG=(t,e)=>RO(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),xA=(t,e)=>RO(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class kA{constructor(e,n){this.clock=e,this.len=n}}class Ju{constructor(){this.clients=new Map}}const Bo=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);for(let o=0;o<r.length;o++){const a=r[o];ZO(t,i,a.clock,a.len,n)}}),_G=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=gs((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Yu=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&_G(n,e.clock)!==null},EA=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?s.len=Mi(s.len,i.clock+i.len-s.clock):(r<n&&(e[r]=i),r++)}e.length=r})},CA=t=>{const e=new Ju;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)m$(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return EA(e),e},qd=(t,e,n,r)=>{or(t.clients,e,()=>[]).push(new kA(n,r))},PO=()=>new Ju,IO=t=>{const e=PO();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const a=o.id.clock;let l=o.length;if(i+1<n.length)for(let u=n[i+1];i+1<n.length&&u.deleted;u=n[++i+1])l+=u.length;s.push(new kA(a,l))}}s.length>0&&e.clients.set(r,s)}),e},Xu=(t,e)=>{Ne(t.restEncoder,e.clients.size),_i(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Ne(t.restEncoder,n);const s=r.length;Ne(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},SA=t=>{const e=new Ju,n=We(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=We(t.restDecoder),i=We(t.restDecoder);if(i>0){const o=or(e.clients,s,()=>[]);for(let a=0;a<i;a++)o.push(new kA(t.readDsClock(),t.readDsLen()))}}return e},LO=(t,e,n)=>{const r=new Ju,s=We(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=We(t.restDecoder),a=We(t.restDecoder),l=n.clients.get(o)||[],u=zt(n,o);for(let c=0;c<a;c++){const f=t.readDsClock(),d=f+t.readDsLen();if(f<u){u<d&&qd(r,o,u,d-u);let h=Qs(l,f),p=l[h];for(!p.deleted&&p.id.clock<f&&(l.splice(h+1,0,xm(e,p,f-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(h,0,xm(e,p,d-p.id.clock)),p.delete(e))}else qd(r,o,f,d-f)}}if(r.clients.size>0){const i=new cl;return Ne(i.restEncoder,0),Xu(i,r),i.toUint8Array()}return null},BO=eO;class ul extends Zw{constructor({guid:e=tO(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=BO(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new JO,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=TO(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});const l=()=>TO(u=>{const c=f=>{(f===void 0||f===!0)&&(this.off("sync",c),u())};this.on("sync",c)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&vt(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(_i(this.subdocs).map(e=>e.guid))}transact(e,n=null){return vt(this,e,n)}get(e,n=kn){const r=or(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==kn&&s!==n)if(s===kn){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,rc)}getText(e=""){return this.get(e,dl)}getMap(e=""){return this.get(e,sc)}getXmlElement(e=""){return this.get(e,$n)}getXmlFragment(e=""){return this.get(e,hl)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){_i(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new ul({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,vt(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class FO{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return We(this.restDecoder)}readDsLen(){return We(this.restDecoder)}}class jO extends FO{readLeftID(){return Ke(We(this.restDecoder),We(this.restDecoder))}readRightID(){return Ke(We(this.restDecoder),We(this.restDecoder))}readClient(){return We(this.restDecoder)}readInfo(){return al(this.restDecoder)}readString(){return Ri(this.restDecoder)}readParentInfo(){return We(this.restDecoder)===1}readTypeRef(){return We(this.restDecoder)}readLen(){return We(this.restDecoder)}readAny(){return qu(this.restDecoder)}readBuf(){return kG(fn(this.restDecoder))}readJSON(){return JSON.parse(Ri(this.restDecoder))}readKey(){return Ri(this.restDecoder)}}class MG{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=We(this.restDecoder),this.dsCurrVal}readDsLen(){const e=We(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Zu extends MG{constructor(e){super(e),this.keys=[],We(e),this.keyClockDecoder=new fA(fn(e)),this.clientDecoder=new im(fn(e)),this.leftClockDecoder=new fA(fn(e)),this.rightClockDecoder=new fA(fn(e)),this.infoDecoder=new cO(fn(e),al),this.stringDecoder=new G$(fn(e)),this.parentInfoDecoder=new cO(fn(e),al),this.typeRefDecoder=new im(fn(e)),this.lenDecoder=new im(fn(e))}readLeftID(){return new ec(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ec(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return qu(this.restDecoder)}readBuf(){return fn(this.restDecoder)}readJSON(){return qu(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class UO{constructor(){this.restEncoder=un()}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Ne(this.restEncoder,e)}writeDsLen(e){Ne(this.restEncoder,e)}}class Qd extends UO{writeLeftID(e){Ne(this.restEncoder,e.client),Ne(this.restEncoder,e.clock)}writeRightID(e){Ne(this.restEncoder,e.client),Ne(this.restEncoder,e.clock)}writeClient(e){Ne(this.restEncoder,e)}writeInfo(e){Wd(this.restEncoder,e)}writeString(e){Ws(this.restEncoder,e)}writeParentInfo(e){Ne(this.restEncoder,e?1:0)}writeTypeRef(e){Ne(this.restEncoder,e)}writeLen(e){Ne(this.restEncoder,e)}writeAny(e){Ku(this.restEncoder,e)}writeBuf(e){jt(this.restEncoder,e)}writeJSON(e){Ws(this.restEncoder,JSON.stringify(e))}writeKey(e){Ws(this.restEncoder,e)}}class VO{constructor(){this.restEncoder=un(),this.dsCurrVal=0}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Ne(this.restEncoder,n)}writeDsLen(e){e===0&&Sr(),Ne(this.restEncoder,e-1),this.dsCurrVal+=e}}class cl extends VO{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new lA,this.clientEncoder=new rm,this.leftClockEncoder=new lA,this.rightClockEncoder=new lA,this.infoEncoder=new iO(Wd),this.stringEncoder=new V$,this.parentInfoEncoder=new iO(Wd),this.typeRefEncoder=new rm,this.lenEncoder=new rm}toUint8Array(){const e=un();return Ne(e,0),jt(e,this.keyClockEncoder.toUint8Array()),jt(e,this.clientEncoder.toUint8Array()),jt(e,this.leftClockEncoder.toUint8Array()),jt(e,this.rightClockEncoder.toUint8Array()),jt(e,Rt(this.infoEncoder)),jt(e,this.stringEncoder.toUint8Array()),jt(e,Rt(this.parentInfoEncoder)),jt(e,this.typeRefEncoder.toUint8Array()),jt(e,this.lenEncoder.toUint8Array()),nm(e,Rt(this.restEncoder)),Rt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ku(this.restEncoder,e)}writeBuf(e){jt(this.restEncoder,e)}writeJSON(e){Ku(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const NG=(t,e,n,r)=>{r=Mi(r,e[0].id.clock);const s=Qs(e,r);Ne(t.restEncoder,e.length-s),t.writeClient(n),Ne(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},TA=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{zt(e,i)>s&&r.set(i,s)}),eh(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),Ne(t.restEncoder,r.size),_i(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{NG(t,e.clients.get(s),s,i)})},RG=(t,e)=>{const n=zn(),r=We(t.restDecoder);for(let s=0;s<r;s++){const i=We(t.restDecoder),o=new Array(i),a=t.readClient();let l=We(t.restDecoder);n.set(a,{i:0,refs:o});for(let u=0;u<i;u++){const c=t.readInfo();switch(tm&c){case 0:{const f=t.readLen();o[u]=new Kr(Ke(a,l),f),l+=f;break}case 10:{const f=We(t.restDecoder);o[u]=new qr(Ke(a,l),f),l+=f;break}default:{const f=(c&(Ni|Tr))===0,d=new Et(Ke(a,l),null,(c&Tr)===Tr?t.readLeftID():null,null,(c&Ni)===Ni?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(c&Hd)===Hd?t.readString():null,__(t,c));o[u]=d,l+=d.length}}}}return n},PG=(t,e,n)=>{const r=[];let s=_i(n.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=n.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=n.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const a=new JO,l=new Map,u=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let c=o.refs[o.i++];const f=new Map,d=()=>{for(const h of r){const p=h.id.client,m=n.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),s=s.filter(g=>g!==p)}r.length=0};for(;;){if(c.constructor!==qr){const p=or(f,c.id.client,()=>zt(e,c.id.client))-c.id.clock;if(p<0)r.push(c),u(c.id.client,c.id.clock-1),d();else{const m=c.getMissing(t,e);if(m!==null){r.push(c);const g=n.get(m)||{refs:[],i:0};if(g.refs.length===g.i)u(m,zt(e,m)),d();else{c=g.refs[g.i++];continue}}else(p===0||p<c.length)&&(c.integrate(t,p),f.set(c.id.client,c.id.clock+c.length))}}if(r.length>0)c=r.pop();else if(o!==null&&o.i<o.refs.length)c=o.refs[o.i++];else{if(o=i(),o===null)break;c=o.refs[o.i++]}}if(a.clients.size>0){const h=new cl;return TA(h,a,new Map),Ne(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},IG=(t,e)=>TA(t,e.doc.store,e.beforeState),LG=(t,e,n,r=new Zu(t))=>vt(e,s=>{s.local=!1;let i=!1;const o=s.doc,a=o.store,l=RG(r,o),u=PG(s,a,l),c=a.pendingStructs;if(c){for(const[d,h]of c.missing)if(h<zt(a,d)){i=!0;break}if(u){for(const[d,h]of u.missing){const p=c.missing.get(d);(p==null||p>h)&&c.missing.set(d,h)}c.update=dm([c.update,u.update])}}else a.pendingStructs=u;const f=LO(r,s,a);if(a.pendingDs){const d=new Zu(Ks(a.pendingDs));We(d.restDecoder);const h=LO(d,s,a);f&&h?a.pendingDs=dm([f,h]):a.pendingDs=f||h}else a.pendingDs=f;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,um(s.doc,d)}},n,!1),um=(t,e,n,r=Zu)=>{const s=Ks(e);LG(s,t,n,new r(s))},BG=(t,e,n)=>um(t,e,n,jO),FG=(t,e,n=new Map)=>{TA(t,e.store,n),Xu(t,IO(e.store))},jG=(t,e=new Uint8Array([0]),n=new cl)=>{const r=HO(e);FG(n,t,r);const s=[n.toUint8Array()];if(t.store.pendingDs&&s.push(t.store.pendingDs),t.store.pendingStructs&&s.push(rW(t.store.pendingStructs.update,e)),s.length>1){if(n.constructor===Qd)return tW(s.map((i,o)=>o===0?i:iW(i)));if(n.constructor===cl)return dm(s)}return s[0]},UG=(t,e)=>jG(t,e,new Qd),VG=t=>{const e=new Map,n=We(t.restDecoder);for(let r=0;r<n;r++){const s=We(t.restDecoder),i=We(t.restDecoder);e.set(s,i)}return e},HO=t=>VG(new FO(Ks(t))),zO=(t,e)=>(Ne(t.restEncoder,e.size),_i(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Ne(t.restEncoder,n),Ne(t.restEncoder,r)}),t),HG=(t,e)=>zO(t,eh(e.store)),zG=(t,e=new VO)=>(t instanceof Map?zO(e,t):HG(e,t),e.toUint8Array()),$G=t=>zG(t,new UO);class GG{constructor(){this.l=[]}}const $O=()=>new GG,GO=(t,e)=>t.l.push(e),WO=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},KO=(t,e,n)=>pA(t.l,[e,n]);class ec{constructor(e,n){this.client=e,this.clock=n}}const tc=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Ke=(t,e)=>new ec(t,e),Jd=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Sr()},Yd=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Xd{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}const Zd=t=>new Xd(t.type==null?null:Ke(t.type.client,t.type.clock),t.tname??null,t.item==null?null:Ke(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class WG{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const KG=(t,e,n=0)=>new WG(t,e,n),cm=(t,e,n)=>{let r=null,s=null;return t._item===null?s=Jd(t):r=Ke(t._item.id.client,t._item.id.clock),new Xd(r,s,e,n)},DA=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return cm(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return cm(t,Ke(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return cm(t,r.lastId,n);r=r.right}return cm(t,null,n)},qG=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,a=t.assoc;let l=null,u=0;if(s!==null){if(zt(r,s.client)<=s.clock)return null;const c=n?zA(r,s):{item:nc(r,s),diff:0},f=c.item;if(!(f instanceof Et))return null;if(l=f.parent,l._item===null||!l._item.deleted){u=f.deleted||!f.countable?0:c.diff+(a>=0?0:1);let d=f.left;for(;d!==null;)!d.deleted&&d.countable&&(u+=d.length),d=d.left}}else{if(o!==null)l=e.get(o);else if(i!==null){if(zt(r,i.client)<=i.clock)return null;const{item:c}=n?zA(r,i):{item:nc(r,i)};if(c instanceof Et&&c.content instanceof ws)l=c.content.type;else return null}else throw Sr();a>=0?u=l._length:u=0}return KG(l,u,t.assoc)},qO=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&tc(t.item,e.item)&&tc(t.type,e.type)&&t.assoc===e.assoc;class OA{constructor(e,n){this.ds=e,this.sv=n}}const QO=(t,e)=>new OA(t,e),_A=t=>QO(IO(t.store),eh(t.store)),fl=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Yu(e.ds,t.id),MA=(t,e)=>{const n=or(t.meta,MA,Oi),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<zt(r,i)&&ar(t,Ke(i,s))}),Bo(t,e.ds,s=>{}),n.add(e))};class JO{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const eh=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},zt=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},YO=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Sr()}n.push(e)},Qs=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=gs(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=gs((n+r)/2)}throw Sr()},nc=(t,e)=>{const n=t.clients.get(e.client);return n[Qs(n,e.clock)]},NA=(t,e,n)=>{const r=Qs(e,n),s=e[r];return s.id.clock<n&&s instanceof Et?(e.splice(r+1,0,xm(t,s,n-s.id.clock)),r+1):r},ar=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[NA(t,n,e.clock)]},XO=(t,e,n)=>{const r=e.clients.get(n.client),s=Qs(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Kr&&r.splice(s+1,0,xm(t,i,n.clock-i.id.clock+1)),i},QG=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Qs(r,e.id.clock)]=n},ZO=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=NA(t,e,n),a;do a=e[o++],i<a.id.clock+a.length&&NA(t,e,i),s(a);while(o<e.length&&e[o].id.clock<i)};let JG=class{constructor(e,n,r){this.doc=e,this.deleteSet=new Ju,this.beforeState=eh(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};const e_=(t,e)=>e.deleteSet.clients.size===0&&!p$(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(EA(e.deleteSet),IG(t,e),Xu(t,e.deleteSet),!0),t_=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&or(t.changed,e,Oi).add(n)},fm=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Et&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},YG=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const a=s[o],l=a.clock+a.len;for(let u=Qs(i,a.clock),c=i[u];u<i.length&&c.id.clock<l;c=i[++u]){const f=i[u];if(a.clock+a.len<=f.id.clock)break;f instanceof Et&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},XG=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],a=Lo(s.length-1,1+Qs(s,o.clock+o.len-1));for(let l=a,u=s[l];l>0&&u.id.clock>=o.clock;u=s[l])l-=1+fm(s,l)}})},n_=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{EA(i),n.afterState=eh(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,u)=>a.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(l=l.filter(c=>c.target._item===null||!c.target._item.deleted),l.forEach(c=>{c.currentTarget=u,c._path=null}),l.sort((c,f)=>c.path.length-f.path.length),KO(u._dEH,l,n))})}),a.push(()=>r.emit("afterTransaction",[n,r])),pA(a,[]),n._needFormattingCleanup&&wW(n)}finally{r.gc&&YG(i,s,r.gcFilter),XG(i,s),n.afterState.forEach((c,f)=>{const d=n.beforeState.get(f)||0;if(d!==c){const h=s.clients.get(f),p=Mi(Qs(h,d),1);for(let m=h.length-1;m>=p;)m-=1+fm(h,m)}});for(let c=o.length-1;c>=0;c--){const{client:f,clock:d}=o[c].id,h=s.clients.get(f),p=Qs(h,d);p+1<h.length&&fm(h,p+1)>1||p>0&&fm(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(CO(am,Wr,"[yjs] ",ll,AO,"Changed the client-id because another client seems to be using it."),r.clientID=BO()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const c=new Qd;e_(c,n)&&r.emit("update",[c.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const c=new cl;e_(c,n)&&r.emit("updateV2",[c.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:u}=n;(a.size>0||u.size>0||l.size>0)&&(a.forEach(c=>{c.clientID=r.clientID,c.collectionid==null&&(c.collectionid=r.collectionid),r.subdocs.add(c)}),u.forEach(c=>r.subdocs.delete(c)),r.emit("subdocs",[{loaded:l,added:a,removed:u},r,n]),u.forEach(c=>c.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):n_(t,e+1)}}},vt=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new JG(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const a=t._transaction===s[0];t._transaction=null,a&&n_(s,0)}}return o};class ZG{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const r_=(t,e,n)=>{Bo(t,n.deletions,r=>{r instanceof Et&&e.scope.some(s=>Yd(s,r))&&$A(r,!1)})},s_=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;vt(s,a=>{for(;e.length>0&&t.currStackItem===null;){const l=s.store,u=e.pop(),c=new Set,f=[];let d=!1;Bo(a,u.insertions,h=>{if(h instanceof Et){if(h.redone!==null){let{item:p,diff:m}=zA(l,h.id);m>0&&(p=ar(a,Ke(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>Yd(p,h))&&f.push(h)}}),Bo(a,u.deletions,h=>{h instanceof Et&&i.some(p=>Yd(p,h))&&!Yu(u.insertions,h.id)&&c.add(h)}),c.forEach(h=>{d=O_(a,h,c,u.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let h=f.length-1;h>=0;h--){const p=f[h];t.deleteFilter(p)&&(p.delete(a),d=!0)}t.currStackItem=d?u:null}a.changed.forEach((l,u)=>{l.has(null)&&u._searchMarker&&(u._searchMarker.length=0)}),r=a},t);const o=t.currStackItem;if(o!=null){const a=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:a,origin:t},t]),t.currStackItem=null}return o};class i_ extends Zw{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:a=Xw(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const u=this.undoing,c=this.redoing,f=u?this.redoStack:this.undoStack;u?this.stopCapturing():c||this.clear(!1,!0);const d=new Ju;l.afterState.forEach((g,y)=>{const v=l.beforeState.get(y)||0,w=g-v;w>0&&qd(d,y,v,w)});const h=$s();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&f.length>0&&!u&&!c){const g=f[f.length-1];g.deletions=CA([g.deletions,l.deleteSet]),g.insertions=CA([g.insertions,d])}else f.push(new ZG(l.deleteSet,d)),p=!0;!u&&!c&&(this.lastChange=h),Bo(l,l.deleteSet,g=>{g instanceof Et&&this.scope.some(y=>Yd(y,g))&&$A(g,!0)});const m=[{stackItem:f[f.length-1],origin:l.origin,type:u?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){e=Xw(e)?e:[e],e.forEach(n=>{this.scope.every(r=>r!==n)&&(n.doc!==this.doc&&pG("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>r_(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>r_(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=s_(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=s_(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*eW(t){const e=We(t.restDecoder);for(let n=0;n<e;n++){const r=We(t.restDecoder),s=t.readClient();let i=We(t.restDecoder);for(let o=0;o<r;o++){const a=t.readInfo();if(a===10){const l=We(t.restDecoder);yield new qr(Ke(s,i),l),i+=l}else if(tm&a){const l=(a&(Ni|Tr))===0,u=new Et(Ke(s,i),null,(a&Tr)===Tr?t.readLeftID():null,null,(a&Ni)===Ni?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&Hd)===Hd?t.readString():null,__(t,a));yield u,i+=u.length}else{const l=t.readLen();yield new Kr(Ke(s,i),l),i+=l}}}}class RA{constructor(e,n){this.gen=eW(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===qr);return this.curr}}class PA{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const tW=t=>dm(t,jO,Qd),nW=(t,e)=>{if(t.constructor===Kr){const{client:n,clock:r}=t.id;return new Kr(Ke(n,r+e),t.length-e)}else if(t.constructor===qr){const{client:n,clock:r}=t.id;return new qr(Ke(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new Et(Ke(r,s+e),null,Ke(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},dm=(t,e=Zu,n=cl)=>{if(t.length===1)return t[0];const r=t.map(c=>new e(Ks(c)));let s=r.map(c=>new RA(c,!0)),i=null;const o=new n,a=new PA(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){const p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===qr?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){const c=s[0],f=c.curr.id.client;if(i!==null){let d=c.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=c.next(),h=!0;if(d===null||d.id.client!==f||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(f!==i.struct.id.client)Fo(a,i.struct,i.offset),i={struct:d,offset:0},c.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===qr)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{Fo(a,i.struct,i.offset);const p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new qr(Ke(f,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===qr?i.struct.length-=p:d=nW(d,p)),i.struct.mergeWith(d)||(Fo(a,i.struct,i.offset),i={struct:d,offset:0},c.next())}}else i={struct:c.curr,offset:0},c.next();for(let d=c.curr;d!==null&&d.id.client===f&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==qr;d=c.next())Fo(a,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(Fo(a,i.struct,i.offset),i=null),IA(a);const l=r.map(c=>SA(c)),u=CA(l);return Xu(o,u),o.toUint8Array()},rW=(t,e,n=Zu,r=cl)=>{const s=HO(e),i=new r,o=new PA(i),a=new n(Ks(t)),l=new RA(a,!1);for(;l.curr;){const c=l.curr,f=c.id.client,d=s.get(f)||0;if(l.curr.constructor===qr){l.next();continue}if(c.id.clock+c.length>d)for(Fo(o,c,Mi(d-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Fo(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}IA(o);const u=SA(a);return Xu(i,u),i.toUint8Array()},o_=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Rt(t.encoder.restEncoder)}),t.encoder.restEncoder=un(),t.written=0)},Fo=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&o_(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ne(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},IA=t=>{o_(t);const e=t.encoder.restEncoder;Ne(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];Ne(e,r.written),nm(e,r.restEncoder)}},sW=(t,e,n,r)=>{const s=new n(Ks(t)),i=new RA(s,!1),o=new r,a=new PA(o);for(let u=i.curr;u!==null;u=i.next())Fo(a,e(u),0);IA(a);const l=SA(s);return Xu(o,l),o.toUint8Array()},iW=t=>sW(t,tG,Zu,Qd),a_="You must not compute changes after the event-handler fired.";class hm{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=oW(this.currentTarget,this.target))}deletes(e){return Yu(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Gs(a_);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,a;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",a=Yw(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",a=Yw(l.content.getContent())):(o="add",a=void 0)}else if(this.deletes(i))o="delete",a=Yw(i.content.getContent());else return;e.set(s,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Gs(a_);const n=this.target,r=Oi(),s=Oi(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const l=()=>{a&&i.push(a)};for(let u=n._start;u!==null;u=u.right)u.deleted?this.deletes(u)&&!this.adds(u)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=u.length,s.add(u)):this.adds(u)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(u.content.getContent()),r.add(u)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=u.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const oW=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},l_=80;let LA=0;class aW{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=LA++}}const lW=t=>{t.timestamp=LA++},u_=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=LA++},uW=(t,e,n)=>{if(t.length>=l_){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return u_(r,e,n),r}else{const r=new aW(e,n);return t.push(r),r}},pm=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>Z0(e-i.index)<Z0(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,lW(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&Z0(n.index-s)<r.parent.length/l_?(u_(n,r,s),n):uW(t._searchMarker,r,s)},th=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=Mi(e,s.index+n))}},mm=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;or(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;KO(r._eH,n,e)};class kn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=$O(),this._dEH=$O(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw ys()}clone(){throw ys()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){GO(this._eH,e)}observeDeep(e){GO(this._dEH,e)}unobserve(e){WO(this._eH,e)}unobserveDeep(e){WO(this._dEH,e)}toJSON(){}}const c_=(t,e,n)=>{e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&r>0;a++)s.push(o[a]),r--;e=0}}i=i.right}return s},f_=t=>{const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},d_=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&fl(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},nh=(t,e)=>{let n=0,r=t._start;for(;r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},h_=(t,e)=>{const n=[];return nh(t,(r,s)=>{n.push(e(r,s,t))}),n},cW=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},p_=(t,e)=>{const n=pm(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},gm=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,a=i.store,l=n===null?e._start:n.right;let u=[];const c=()=>{u.length>0&&(s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ml(u)),s.integrate(t,0),u=[])};r.forEach(f=>{if(f===null)u.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(f);break;default:switch(c(),f.constructor){case Uint8Array:case ArrayBuffer:s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new rh(new Uint8Array(f))),s.integrate(t,0);break;case ul:s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ih(f)),s.integrate(t,0);break;default:if(f instanceof kn)s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ws(f)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),c()},m_=()=>Gs("Length exceeded!"),g_=(t,e,n,r)=>{if(n>e._length)throw m_();if(n===0)return e._searchMarker&&th(e._searchMarker,n,r.length),gm(t,e,null,r);const s=n,i=pm(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&ar(t,Ke(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&th(e._searchMarker,s,r.length),gm(t,e,o,r)},fW=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return gm(t,e,s,n)},y_=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=pm(e,n);let a=e._start;for(o!==null&&(a=o.p,n-=o.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&ar(t,Ke(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&ar(t,Ke(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw m_();e._searchMarker&&th(e._searchMarker,s,-i+r)},ym=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},BA=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let a;if(r==null)a=new ml([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new ml([r]);break;case Uint8Array:a=new rh(r);break;case ul:a=new ih(r);break;default:if(r instanceof kn)a=new ws(r);else throw new Error("Unexpected content type")}new Et(Ke(o,zt(i.store,o)),s,s&&s.lastId,null,null,e,n,a).integrate(t,0)},FA=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},b_=t=>{const e={};return t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},w_=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted},dW=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&fl(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},bm=t=>OG(t.entries(),e=>!e[1].deleted);class hW extends hm{}class rc extends kn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new rc;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new rc}clone(){const e=new rc;return e.insert(0,this.toArray().map(n=>n instanceof kn?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,n){super._callObserver(e,n),mm(this,e,new hW(this,e))}insert(e,n){this.doc!==null?vt(this.doc,r=>{g_(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?vt(this.doc,n=>{fW(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?vt(this.doc,r=>{y_(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return p_(this,e)}toArray(){return f_(this)}slice(e=0,n=this.length){return c_(this,e,n)}toJSON(){return this.map(e=>e instanceof kn?e.toJSON():e)}map(e){return h_(this,e)}forEach(e){nh(this,e)}[Symbol.iterator](){return cW(this)}_write(e){e.writeTypeRef(BW)}}const pW=t=>new rc;class mW extends hm{constructor(e,n,r){super(e,n),this.keysChanged=r}}class sc extends kn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new sc}clone(){const e=new sc;return this.forEach((n,r)=>{e.set(r,n instanceof kn?n.clone():n)}),e}_callObserver(e,n){mm(this,e,new mW(this,e,n))}toJSON(){const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof kn?s.toJSON():s}}),e}get size(){return[...bm(this._map)].length}keys(){return xA(bm(this._map),e=>e[0])}values(){return xA(bm(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return xA(bm(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?vt(this.doc,n=>{ym(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?vt(this.doc,r=>{BA(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return FA(this,e)}has(e){return w_(this,e)}clear(){this.doc!==null?vt(this.doc,e=>{this.forEach(function(n,r,s){ym(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(FW)}}const gW=t=>new sc,jo=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Z$(t,e);class jA{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&Sr(),this.right.content.constructor){case Zt:this.right.deleted||ic(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const A_=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Zt:e.right.deleted||ic(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&ar(t,Ke(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},wm=(t,e,n,r)=>{const s=new Map,i=r?pm(e,n):null;if(i){const o=new jA(i.p.left,i.p,i.index,s);return A_(t,o,n-i.index)}else{const o=new jA(null,e._start,0,s);return A_(t,o,n)}},v_=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Zt&&jo(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,a)=>{const l=n.left,u=n.right,c=new Et(Ke(i,zt(s.store,i)),l,l&&l.lastId,u,u&&u.id,e,null,new Zt(a,o));c.integrate(t,0),n.right=c,n.forward()})},ic=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},x_=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Zt&&jo(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},k_=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const a in r){const l=r[a],u=n.currentAttributes.get(a)??null;if(!jo(u,l)){o.set(a,u);const{left:c,right:f}=n;n.right=new Et(Ke(i,zt(s.store,i)),c,c&&c.lastId,f,f&&f.id,e,null,new Zt(a,l)),n.right.integrate(t,0),n.forward()}}return o},UA=(t,e,n,r,s)=>{n.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});const i=t.doc,o=i.clientID;x_(n,s);const a=k_(t,e,n,s),l=r.constructor===String?new bs(r):r instanceof kn?new ws(r):new pl(r);let{left:u,right:c,index:f}=n;e._searchMarker&&th(e._searchMarker,n.index,l.getLength()),c=new Et(Ke(o,zt(i.store,o)),u,u&&u.lastId,c,c&&c.id,e,null,l),c.integrate(t,0),n.right=c,n.index=f,n.forward(),v_(t,e,n,a)},E_=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;x_(n,s);const a=k_(t,e,n,s);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Zt));){if(!n.right.deleted)switch(n.right.content.constructor){case Zt:{const{key:l,value:u}=n.right.content,c=s[l];if(c!==void 0){if(jo(c,u))a.delete(l);else{if(r===0)break e;a.set(l,u)}n.right.delete(t)}else n.currentAttributes.set(l,u);break}default:r<n.right.length&&ar(t,Ke(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
473
+ For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return V.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},UH="DialogDescriptionWarning",VH=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${$3(UH).contentName}}.`;return V.useEffect(()=>{var i;const s=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},G3=_3,W3=N3,K3=P3,Tw=I3,Dw=L3,Ow=F3,_w=U3,q3=H3;function HH(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const Q3=N.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,handleOnly:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{},direction:"bottom"}),H0=()=>{const t=N.useContext(Q3);if(!t)throw new Error("useDrawerContext must be used within a Drawer.Root");return t};HH("[vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1)}[vaul-drawer][vaul-drawer-direction=bottom]{transform:translate3d(0,100%,0)}[vaul-drawer][vaul-drawer-direction=top]{transform:translate3d(0,-100%,0)}[vaul-drawer][vaul-drawer-direction=left]{transform:translate3d(-100%,0,0)}[vaul-drawer][vaul-drawer-direction=right]{transform:translate3d(100%,0,0)}.vaul-dragging .vaul-scrollable [vault-drawer-direction=top]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=bottom]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=left]{overflow-x:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=right]{overflow-x:hidden!important}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]::after{content:'';position:absolute;background:inherit;background-color:inherit}[vaul-drawer][vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[vaul-drawer][vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[vaul-handle]{display:block;position:relative;opacity:.8;margin-left:auto;margin-right:auto;height:5px;width:56px;border-radius:1rem;touch-action:pan-y;cursor:grab}[vaul-handle]:active,[vaul-handle]:hover{opacity:1}[vaul-handle]:active{cursor:grabbing}[vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay=true]):not([data-state=closed]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible=false]){opacity:1}@media (hover:hover) and (pointer:fine){[vaul-drawer]{user-select:none}}@media (pointer:fine){[vaul-handle-hitarea]:{width:100%;height:100%}}");const zH=typeof window<"u"?N.useLayoutEffect:N.useEffect;function Mw(...t){return(...e)=>{for(let n of t)typeof n=="function"&&n(...e)}}function $H(){return Nw(/^Mac/)}function GH(){return Nw(/^iPhone/)}function WH(){return Nw(/^iPad/)||$H()&&navigator.maxTouchPoints>1}function J3(){return GH()||WH()}function Nw(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.platform):void 0}const Rw=typeof document<"u"&&window.visualViewport;function Y3(t){let e=window.getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowX+e.overflowY)}function X3(t){for(Y3(t)&&(t=t.parentElement);t&&!Y3(t);)t=t.parentElement;return t||document.scrollingElement||document.documentElement}const KH=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let z0=0,Pw;function qH(t={}){let{isDisabled:e}=t;zH(()=>{if(!e)return z0++,z0===1&&(J3()?Pw=JH():Pw=QH()),()=>{z0--,z0===0&&Pw()}},[e])}function QH(){return Mw(Z3(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`))}function JH(){let t,e=0,n=f=>{t=X3(f.target),!(t===document.documentElement&&t===document.body)&&(e=f.changedTouches[0].pageY)},r=f=>{if(!t||t===document.documentElement||t===document.body){f.preventDefault();return}let d=f.changedTouches[0].pageY,h=t.scrollTop,p=t.scrollHeight-t.clientHeight;p!==0&&((h<=0&&d>e||h>=p&&d<e)&&f.preventDefault(),e=d)},s=f=>{let d=f.target;Iw(d)&&d!==document.activeElement&&(f.preventDefault(),d.style.transform="translateY(-2000px)",d.focus(),requestAnimationFrame(()=>{d.style.transform=""}))},i=f=>{let d=f.target;Iw(d)&&(d.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{d.style.transform="",Rw&&(Rw.height<window.innerHeight?requestAnimationFrame(()=>{eD(d)}):Rw.addEventListener("resize",()=>eD(d),{once:!0}))}))},o=()=>{window.scrollTo(0,0)},a=window.pageXOffset,l=window.pageYOffset,u=Mw(Z3(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let c=Mw(Rd(document,"touchstart",n,{passive:!1,capture:!0}),Rd(document,"touchmove",r,{passive:!1,capture:!0}),Rd(document,"touchend",s,{passive:!1,capture:!0}),Rd(document,"focus",i,!0),Rd(window,"scroll",o));return()=>{u(),c(),window.scrollTo(a,l)}}function Z3(t,e,n){let r=t.style[e];return t.style[e]=n,()=>{t.style[e]=r}}function Rd(t,e,n,r){return t.addEventListener(e,n,r),()=>{t.removeEventListener(e,n,r)}}function eD(t){let e=document.scrollingElement||document.documentElement;for(;t&&t!==e;){let n=X3(t);if(n!==document.documentElement&&n!==document.body&&n!==t){let r=n.getBoundingClientRect().top,s=t.getBoundingClientRect().top,i=t.getBoundingClientRect().bottom;const o=n.getBoundingClientRect().bottom;i>o&&(n.scrollTop+=s-r)}t=n.parentElement}}function Iw(t){return t instanceof HTMLInputElement&&!KH.has(t.type)||t instanceof HTMLTextAreaElement||t instanceof HTMLElement&&t.isContentEditable}function YH(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function XH(...t){return e=>t.forEach(n=>YH(n,e))}function tD(...t){return V.useCallback(XH(...t),t)}let Pd=null;function ZH({isOpen:t,modal:e,nested:n,hasBeenOpened:r,preventScrollRestoration:s,noBodyStyles:i}){const[o,a]=N.useState(()=>typeof window<"u"?window.location.href:""),l=N.useRef(0),u=N.useCallback(()=>{if(Pd===null&&t&&!i){Pd={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:d}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-l.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const h=d-window.innerHeight;h&&l.current>=d&&(document.body.style.top=`${-(l.current+h)}px`)}),300)}},[t]),c=N.useCallback(()=>{if(Pd!==null&&!i){const f=-parseInt(document.body.style.top,10),d=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Pd),window.requestAnimationFrame(()=>{if(s&&o!==window.location.href){a(window.location.href);return}window.scrollTo(d,f)}),Pd=null}},[o]);return N.useEffect(()=>{function f(){l.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),N.useEffect(()=>{n||!r||(t?(!window.matchMedia("(display-mode: standalone)").matches&&u(),e||window.setTimeout(()=>{c()},500)):c())},[t,r,o,e,n,u,c]),{restorePositionSetting:c}}const nD=new WeakMap;function Dt(t,e,n=!1){if(!t||!(t instanceof HTMLElement))return;let r={};Object.entries(e).forEach(([s,i])=>{if(s.startsWith("--")){t.style.setProperty(s,i);return}r[s]=t.style[s],t.style[s]=i}),!n&&nD.set(t,r)}function $0(t,e){if(!t||!(t instanceof HTMLElement))return;let n=nD.get(t);n&&(e?t.style[e]=n[e]:Object.entries(n).forEach(([r,s])=>{t.style[r]=s}))}const Xt=t=>{switch(t){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return t}};function G0(t,e){if(!t)return null;const n=window.getComputedStyle(t),r=n.transform||n.webkitTransform||n.mozTransform;let s=r.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[Xt(e)?13:12]):(s=r.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[Xt(e)?5:4]):null)}function ez(t){return 8*(Math.log(t+1)-2)}const At={DURATION:.5,EASE:[.32,.72,0,1]},rD=.4;function sD(t){const e=N.useRef(t);return N.useEffect(()=>{e.current=t}),N.useMemo(()=>(...n)=>e.current==null?void 0:e.current.call(e,...n),[])}function tz({defaultProp:t,onChange:e}){const n=N.useState(t),[r]=n,s=N.useRef(r),i=sD(e);return N.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),n}function nz({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,s]=tz({defaultProp:e,onChange:n}),i=t!==void 0,o=i?t:r,a=sD(n),l=N.useCallback(u=>{if(i){const f=typeof u=="function"?u(t):u;f!==t&&a(f)}else s(u)},[i,t,s,a]);return[o,l]}function rz({activeSnapPointProp:t,setActiveSnapPointProp:e,snapPoints:n,drawerRef:r,overlayRef:s,fadeFromIndex:i,onSnapPointChange:o,direction:a="bottom"}){const[l,u]=nz({prop:t,defaultProp:n==null?void 0:n[0],onChange:e}),c=N.useMemo(()=>l===(n==null?void 0:n[n.length-1])||null,[n,l]),f=n&&n.length>0&&(i||i===0)&&!Number.isNaN(i)&&n[i]===l||!n,d=N.useMemo(()=>n==null?void 0:n.findIndex(w=>w===l),[n,l]),h=N.useMemo(()=>{var w;return(w=n==null?void 0:n.map(A=>{const x=typeof window<"u",k=typeof A=="string";let C=0;if(k&&(C=parseInt(A,10)),Xt(a)){const _=k?C:x?A*window.innerHeight:0;return x?a==="bottom"?window.innerHeight-_:-window.innerHeight+_:_}const O=k?C:x?A*window.innerWidth:0;return x?a==="right"?window.innerWidth-O:-window.innerWidth+O:O}))!=null?w:[]},[n]),p=N.useMemo(()=>d!==null?h==null?void 0:h[d]:null,[h,d]),m=N.useCallback(w=>{var A;const x=(A=h==null?void 0:h.findIndex(k=>k===w))!=null?A:null;o(x),Dt(r.current,{transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,transform:Xt(a)?`translate3d(0, ${w}px, 0)`:`translate3d(${w}px, 0, 0)`}),h&&x!==h.length-1&&x!==i?Dt(s.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,opacity:"0"}):Dt(s.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,opacity:"1"}),u(x!==null?n==null?void 0:n[x]:null)},[r.current,n,h,i,s,u]);N.useEffect(()=>{if(l||t){var w;const A=(w=n==null?void 0:n.findIndex(x=>x===t||x===l))!=null?w:-1;h&&A!==-1&&typeof h[A]=="number"&&m(h[A])}},[l,t,n,h,m]);function g({draggedDistance:w,closeDrawer:A,velocity:x,dismissible:k}){if(i===void 0)return;const C=a==="bottom"||a==="right"?(p??0)-w:(p??0)+w,O=d===i-1,_=d===0,D=w>0;if(O&&Dt(s.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),x>2&&!D){k?A():m(h[0]);return}if(x>2&&D&&h&&n){m(h[n.length-1]);return}const R=h==null?void 0:h.reduce((F,G)=>typeof F!="number"||typeof G!="number"?F:Math.abs(G-C)<Math.abs(F-C)?G:F),L=Xt(a)?window.innerHeight:window.innerWidth;if(x>rD&&Math.abs(w)<L*.4){const F=D?1:-1;if(F>0&&c){m(h[n.length-1]);return}if(_&&F<0&&k&&A(),d===null)return;m(h[d+F]);return}m(R)}function y({draggedDistance:w}){if(p===null)return;const A=a==="bottom"||a==="right"?p-w:p+w;(a==="bottom"||a==="right")&&A<h[h.length-1]||(a==="top"||a==="left")&&A>h[h.length-1]||Dt(r.current,{transform:Xt(a)?`translate3d(0, ${A}px, 0)`:`translate3d(${A}px, 0, 0)`})}function v(w,A){if(!n||typeof d!="number"||!h||i===void 0)return null;const x=d===i-1;if(d>=i&&A)return 0;if(x&&!A)return 1;if(!f&&!x)return null;const C=x?d+1:d-1,O=x?h[C]-h[C-1]:h[C+1]-h[C],_=w/Math.abs(O);return x?1-_:_}return{isLastSnapPoint:c,activeSnapPoint:l,shouldFade:f,getPercentageDragged:v,setActiveSnapPoint:u,activeSnapPointIndex:d,onRelease:g,onDrag:y,snapPointsOffset:h}}const sz=.25,iz=100,iD=8,nl=16,oD=26,Lw="vaul-dragging";function aD({open:t,onOpenChange:e,children:n,shouldScaleBackground:r,onDrag:s,onRelease:i,snapPoints:o,nested:a=!1,setBackgroundColorOnScale:l=!0,closeThreshold:u=sz,scrollLockTimeout:c=iz,dismissible:f=!0,handleOnly:d=!1,fadeFromIndex:h=o&&o.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:y=!0,onClose:v,noBodyStyles:w,direction:A="bottom",preventScrollRestoration:x=!0,disablePreventScroll:k=!1}){var C;const[O=!1,_]=N.useState(!1),[D,R]=N.useState(!1),[L,F]=N.useState(!1),[G,B]=N.useState(!1),[H,Q]=N.useState(!1),[te,Z]=N.useState(!1),pe=N.useRef(null),Ee=N.useRef(null),Re=N.useRef(null),Ce=N.useRef(null),ke=N.useRef(null),He=N.useRef(!1),Ue=N.useRef(null),ze=N.useRef(0),Le=N.useRef(!1),tt=N.useRef(0),le=N.useRef(null),$e=N.useRef(((C=le.current)==null?void 0:C.getBoundingClientRect().height)||0),ae=N.useRef(0),be=N.useCallback(ne=>{o&&ne===ue.length-1&&(Ee.current=new Date)},[]),{activeSnapPoint:Be,activeSnapPointIndex:z,setActiveSnapPoint:q,onRelease:re,snapPointsOffset:ue,onDrag:P,shouldFade:b,getPercentageDragged:E}=rz({snapPoints:o,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:le,fadeFromIndex:h,overlayRef:pe,onSnapPointChange:be,direction:A});qH({isDisabled:!O||H||!y||te||!D||k});const{restorePositionSetting:M}=ZH({isOpen:O,modal:y,nested:a,hasBeenOpened:D,preventScrollRestoration:x,noBodyStyles:w});function j(){return(window.innerWidth-oD)/window.innerWidth}function K(ne){var ie;!f&&!o||le.current&&!le.current.contains(ne.target)||($e.current=((ie=le.current)==null?void 0:ie.getBoundingClientRect().height)||0,Q(!0),Re.current=new Date,J3()&&window.addEventListener("touchend",()=>He.current=!1,{once:!0}),ne.target.setPointerCapture(ne.pointerId),ze.current=Xt(A)?ne.clientY:ne.clientX)}function Y(ne,ie){var Te;let me=ne;const qe=(Te=window.getSelection())==null?void 0:Te.toString(),nt=le.current?G0(le.current,A):null,yt=new Date;if(me.hasAttribute("data-vaul-no-drag")||me.closest("[data-vaul-no-drag]"))return!1;if(A==="right"||A==="left")return!0;if(Ee.current&&yt.getTime()-Ee.current.getTime()<500)return!1;if(nt!==null&&(A==="bottom"?nt>0:nt<0))return!0;if(qe&&qe.length>0)return!1;if(ke.current&&yt.getTime()-ke.current.getTime()<c&&nt===0||ie)return ke.current=yt,!1;for(;me;){if(me.scrollHeight>me.clientHeight){if(me.scrollTop!==0)return ke.current=new Date,!1;if(me.getAttribute("role")==="dialog")return!0}me=me.parentNode}return!0}function ye(ne){if(le.current&&H){const ie=A==="bottom"||A==="right"?1:-1,Te=(ze.current-(Xt(A)?ne.clientY:ne.clientX))*ie,me=Te>0,qe=o&&!f&&!me;if(qe&&z===0)return;const nt=Math.abs(Te),yt=document.querySelector("[vaul-drawer-wrapper]");let sn=nt/$e.current;const Ft=E(nt,me);if(Ft!==null&&(sn=Ft),qe&&sn>=1||!He.current&&!Y(ne.target,me))return;if(le.current.classList.add(Lw),He.current=!0,Dt(le.current,{transition:"none"}),Dt(pe.current,{transition:"none"}),o&&P({draggedDistance:Te}),me&&!o){const wr=ez(Te),Ar=Math.min(wr*-1,0)*ie;Dt(le.current,{transform:Xt(A)?`translate3d(0, ${Ar}px, 0)`:`translate3d(${Ar}px, 0, 0)`});return}const Is=1-sn;if((b||h&&z===h-1)&&(s==null||s(ne,sn),Dt(pe.current,{opacity:`${Is}`,transition:"none"},!0)),yt&&pe.current&&r){const wr=Math.min(j()+sn*(1-j()),1),Ar=8-sn*8,Wf=Math.max(0,14-sn*14);Dt(yt,{borderRadius:`${Ar}px`,transform:Xt(A)?`scale(${wr}) translate3d(0, ${Wf}px, 0)`:`scale(${wr}) translate3d(${Wf}px, 0, 0)`,transition:"none"},!0)}if(!o){const wr=nt*ie;Dt(le.current,{transform:Xt(A)?`translate3d(0, ${wr}px, 0)`:`translate3d(${wr}px, 0, 0)`})}}}N.useEffect(()=>()=>{ft(!1),M()},[]),N.useEffect(()=>{var ne;function ie(){if(!le.current)return;const Te=document.activeElement;if(Iw(Te)||Le.current){var me;const qe=((me=window.visualViewport)==null?void 0:me.height)||0;let nt=window.innerHeight-qe;const yt=le.current.getBoundingClientRect().height||0;ae.current||(ae.current=yt);const sn=le.current.getBoundingClientRect().top;if(Math.abs(tt.current-nt)>60&&(Le.current=!Le.current),o&&o.length>0&&ue&&z){const Ft=ue[z]||0;nt+=Ft}if(tt.current=nt,yt>qe||Le.current){const Ft=le.current.getBoundingClientRect().height;let Is=Ft;Ft>qe&&(Is=qe-oD),g?le.current.style.height=`${Ft-Math.max(nt,0)}px`:le.current.style.height=`${Math.max(Is,qe-sn)}px`}else le.current.style.height=`${ae.current}px`;o&&o.length>0&&!Le.current?le.current.style.bottom="0px":le.current.style.bottom=`${Math.max(nt,0)}px`}}return(ne=window.visualViewport)==null||ne.addEventListener("resize",ie),()=>{var Te;return(Te=window.visualViewport)==null?void 0:Te.removeEventListener("resize",ie)}},[z,o,ue]);function Se(){le.current&&(Ve(),v==null||v(),Dt(le.current,{transform:Xt(A)?`translate3d(0, ${A==="bottom"?"100%":"-100%"}, 0)`:`translate3d(${A==="right"?"100%":"-100%"}, 0, 0)`,transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),Dt(pe.current,{opacity:"0",transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),ft(!1),setTimeout(()=>{F(!1),_(!1)},300),setTimeout(()=>{o&&q(o[0])},At.DURATION*1e3))}N.useEffect(()=>{if(!O&&r){const ne=setTimeout(()=>{$0(document.body)},200);return()=>clearTimeout(ne)}},[O,r]),N.useLayoutEffect(()=>{t?(_(!0),R(!0)):Se()},[t]),N.useEffect(()=>{G&&(e==null||e(O))},[O]),N.useEffect(()=>{B(!0)},[]);function Je(){if(!le.current)return;const ne=document.querySelector("[vaul-drawer-wrapper]"),ie=G0(le.current,A);Dt(le.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`}),Dt(pe.current,{transition:`opacity ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,opacity:"1"}),r&&ie&&ie>0&&O&&Dt(ne,{borderRadius:`${iD}px`,overflow:"hidden",...Xt(A)?{transform:`scale(${j()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${j()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${At.DURATION}s`,transitionTimingFunction:`cubic-bezier(${At.EASE.join(",")})`},!0)}function Ve(){!H||!le.current||(le.current.classList.remove(Lw),He.current=!1,Q(!1),Ce.current=new Date)}function Fe(ne){if(!H||!le.current)return;le.current.classList.remove(Lw),He.current=!1,Q(!1),Ce.current=new Date;const ie=G0(le.current,A);if(!Y(ne.target,!1)||!ie||Number.isNaN(ie)||Re.current===null)return;const Te=Ce.current.getTime()-Re.current.getTime(),me=ze.current-(Xt(A)?ne.clientY:ne.clientX),qe=Math.abs(me)/Te;if(qe>.05&&(Z(!0),setTimeout(()=>{Z(!1)},200)),o){re({draggedDistance:me*(A==="bottom"||A==="right"?1:-1),closeDrawer:Se,velocity:qe,dismissible:f}),i==null||i(ne,!0);return}if(A==="bottom"||A==="right"?me>0:me<0){Je(),i==null||i(ne,!0);return}if(qe>rD){Se(),i==null||i(ne,!1);return}var nt;const yt=Math.min((nt=le.current.getBoundingClientRect().height)!=null?nt:0,window.innerHeight);if(ie>=yt*u){Se(),i==null||i(ne,!1);return}i==null||i(ne,!0),Je()}N.useEffect(()=>{O&&(Dt(document.documentElement,{scrollBehavior:"auto"}),Ee.current=new Date,ft(!0))},[O]),N.useEffect(()=>{if(le.current&&L){var ne;const ie=le==null||(ne=le.current)==null?void 0:ne.querySelectorAll("*");ie==null||ie.forEach(Te=>{const me=Te;(me.scrollHeight>me.clientHeight||me.scrollWidth>me.clientWidth)&&me.classList.add("vaul-scrollable")})}},[L]);function ft(ne){const ie=document.querySelector("[vaul-drawer-wrapper]");!ie||!r||(ne?(l&&(w||(Dt(document.body,{background:document.body.style.backgroundColor||document.body.style.background}),Dt(document.body,{background:"black"},!0))),Dt(ie,{borderRadius:`${iD}px`,overflow:"hidden",...Xt(A)?{transform:`scale(${j()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${j()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${At.DURATION}s`,transitionTimingFunction:`cubic-bezier(${At.EASE.join(",")})`})):($0(ie,"overflow"),$0(ie,"transform"),$0(ie,"borderRadius"),Dt(ie,{transitionProperty:"transform, border-radius",transitionDuration:`${At.DURATION}s`,transitionTimingFunction:`cubic-bezier(${At.EASE.join(",")})`})))}function Xn(ne){const ie=ne?(window.innerWidth-nl)/window.innerWidth:1,Te=ne?-nl:0;Ue.current&&window.clearTimeout(Ue.current),Dt(le.current,{transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,transform:`scale(${ie}) translate3d(0, ${Te}px, 0)`}),!ne&&le.current&&(Ue.current=setTimeout(()=>{const me=G0(le.current,A);Dt(le.current,{transition:"none",transform:Xt(A)?`translate3d(0, ${me}px, 0)`:`translate3d(${me}px, 0, 0)`})},500))}function br(ne,ie){if(ie<0)return;const Te=Xt(A)?window.innerHeight:window.innerWidth,me=(Te-nl)/Te,qe=me+ie*(1-me),nt=-nl+ie*nl;Dt(le.current,{transform:Xt(A)?`scale(${qe}) translate3d(0, ${nt}px, 0)`:`scale(${qe}) translate3d(${nt}px, 0, 0)`,transition:"none"})}function X(ne,ie){const Te=Xt(A)?window.innerHeight:window.innerWidth,me=ie?(Te-nl)/Te:1,qe=ie?-nl:0;ie&&Dt(le.current,{transition:`transform ${At.DURATION}s cubic-bezier(${At.EASE.join(",")})`,transform:Xt(A)?`scale(${me}) translate3d(0, ${qe}px, 0)`:`scale(${me}) translate3d(${qe}px, 0, 0)`})}return N.createElement(G3,{modal:y,onOpenChange:ne=>{if(t!==void 0){e==null||e(ne);return}ne?(R(!0),_(ne)):Se()},open:O},N.createElement(Q3.Provider,{value:{visible:L,activeSnapPoint:Be,snapPoints:o,setActiveSnapPoint:q,drawerRef:le,overlayRef:pe,scaleBackground:ft,onOpenChange:e,onPress:K,setVisible:F,onRelease:Fe,onDrag:ye,dismissible:f,handleOnly:d,isOpen:O,isDragging:H,shouldFade:b,closeDrawer:Se,onNestedDrag:br,onNestedOpenChange:Xn,onNestedRelease:X,keyboardIsOpen:Le,openProp:t,modal:y,snapPointsOffset:ue,direction:A}},n))}const oz=250,az=120,lD=N.forwardRef(function({preventCycle:t=!1,children:e,...n},r){const{visible:s,closeDrawer:i,isDragging:o,snapPoints:a,activeSnapPoint:l,setActiveSnapPoint:u,dismissible:c,handleOnly:f,onPress:d,onDrag:h}=H0(),p=N.useRef(null),m=N.useRef(!1);function g(){if(m.current){w();return}window.setTimeout(()=>{y()},az)}function y(){if(o||t||m.current){w();return}if(w(),(!a||a.length===0)&&c){i();return}if(l===a[a.length-1]&&c){i();return}const x=a.findIndex(C=>C===l);if(x===-1)return;const k=a[x+1];u(k)}function v(){p.current=window.setTimeout(()=>{m.current=!0},oz)}function w(){window.clearTimeout(p.current),m.current=!1}return N.createElement("div",{onClick:g,onDoubleClick:()=>{m.current=!0,i()},onPointerCancel:w,onPointerDown:A=>{f&&d(A),v()},onPointerMove:A=>{f&&h(A)},ref:r,"vaul-drawer-visible":s?"true":"false","vaul-handle":"","aria-hidden":"true",...n},N.createElement("span",{"vaul-handle-hitarea":"","aria-hidden":"true"},e))});lD.displayName="Drawer.Handle";const uD=N.forwardRef(function({children:t,...e},n){const{overlayRef:r,snapPoints:s,onRelease:i,shouldFade:o,isOpen:a,visible:l}=H0(),u=tD(n,r),c=s&&s.length>0;return N.createElement(Tw,{onMouseUp:i,ref:u,"vaul-drawer-visible":l?"true":"false","vaul-overlay":"","vaul-snap-points":a&&c?"true":"false","vaul-snap-points-overlay":a&&o?"true":"false",...e})});uD.displayName="Drawer.Overlay";const cD=N.forwardRef(function({onOpenAutoFocus:t,onPointerDownOutside:e,onAnimationEnd:n,style:r,...s},i){const{drawerRef:o,onPress:a,onRelease:l,onDrag:u,dismissible:c,keyboardIsOpen:f,snapPointsOffset:d,visible:h,closeDrawer:p,modal:m,openProp:g,onOpenChange:y,setVisible:v,handleOnly:w,direction:A}=H0(),x=tD(i,o),k=N.useRef(null),C=N.useRef(!1),O=(_,D,R=0)=>{if(C.current)return!0;const L=Math.abs(_.y),F=Math.abs(_.x),G=F>L,B=["bottom","right"].includes(D)?1:-1;if(D==="left"||D==="right"){if(!(_.x*B<0)&&F>=0&&F<=R)return G}else if(!(_.y*B<0)&&L>=0&&L<=R)return!G;return C.current=!0,!0};return N.useEffect(()=>{v(!0)},[]),N.createElement(Dw,{"vaul-drawer":"","vaul-drawer-direction":A,"vaul-drawer-visible":h?"true":"false",...s,ref:x,style:d&&d.length>0?{"--snap-point-height":`${d[0]}px`,...r}:r,onOpenAutoFocus:_=>{if(t)t(_);else{var D;_.preventDefault(),(D=o.current)==null||D.focus()}},onPointerDown:_=>{w||(s.onPointerDown==null||s.onPointerDown.call(s,_),k.current={x:_.clientX,y:_.clientY},a(_))},onPointerDownOutside:_=>{if(e==null||e(_),!m||_.defaultPrevented){_.preventDefault();return}f.current&&(f.current=!1),_.preventDefault(),y==null||y(!1),!(!c||g!==void 0)&&p()},onFocusOutside:_=>{if(!m){_.preventDefault();return}},onEscapeKeyDown:_=>{if(!m){_.preventDefault();return}},onPointerMove:_=>{if(w||(s.onPointerMove==null||s.onPointerMove.call(s,_),!k.current))return;const D=_.clientY-k.current.y,R=_.clientX-k.current.x,L=_.pointerType==="touch"?10:2;O({x:R,y:D},A,L)?u(_):(Math.abs(R)>L||Math.abs(D)>L)&&(k.current=null)},onPointerUp:_=>{s.onPointerUp==null||s.onPointerUp.call(s,_),k.current=null,C.current=!1,l(_)}})});cD.displayName="Drawer.Content";function lz({onDrag:t,onOpenChange:e,...n}){const{onNestedDrag:r,onNestedOpenChange:s,onNestedRelease:i}=H0();if(!r)throw new Error("Drawer.NestedRoot must be placed in another drawer");return N.createElement(aD,{nested:!0,onClose:()=>{s(!1)},onDrag:(o,a)=>{r(o,a),t==null||t(o,a)},onOpenChange:o=>{o&&s(o),e==null||e(o)},onRelease:i,...n})}const ps={Root:aD,NestedRoot:lz,Content:cD,Handle:lD,Overlay:uD,Trigger:W3,Portal:K3,Close:q3,Title:Ow,Description:_w},fD=({shouldScaleBackground:t=!0,...e})=>S.jsx(ps.Root,{shouldScaleBackground:t,...e});fD.displayName="Drawer";const dD=ps.Trigger,uz=ps.Portal,hD=N.forwardRef(({className:t,...e},n)=>S.jsx(ps.Overlay,{ref:n,className:he("fixed inset-0 z-50 bg-black/5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));hD.displayName=ps.Overlay.displayName;const pD=N.forwardRef(({className:t,children:e,...n},r)=>S.jsxs(uz,{children:[S.jsx(hD,{}),S.jsx(Vu,{trapped:!1,children:S.jsxs(ps.Content,{ref:r,className:he("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-[16px] drop-shadow-2xl bg-white",t),...n,children:[S.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-white"}),e,S.jsx(ps.Close,{className:"absolute right-2 top-4 hover:bg-gray-200 rounded-full p-2 ring-offset-white transition focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2 disabled:pointer-events-none text-black data-[state=open]:bg-gray-100 data-[state=open]:text-black",children:S.jsx(cV,{size:20,fill:"black"})})]})})]}));pD.displayName="DrawerContent";const mD=({className:t,...e})=>S.jsx("div",{className:he("grid gap-1.5 p-4 text-center sm:text-left",t),...e});mD.displayName="DrawerHeader";const gD=N.forwardRef(({className:t,...e},n)=>S.jsx(ps.Title,{ref:n,className:he("text-lg font-semibold leading-none tracking-tight",t),...e}));gD.displayName=ps.Title.displayName;const cz=N.forwardRef(({className:t,...e},n)=>S.jsx(ps.Description,{ref:n,className:he("text-sm text-black",t),...e}));cz.displayName=ps.Description.displayName;const fz=({title:t,content:e,contentClassName:n})=>S.jsxs(pD,{className:"w-full z-20",children:[S.jsx(mD,{className:"px-4 pt-0",children:S.jsx(gD,{className:"text-left sm:text-center text-base",children:t})}),S.jsx("div",{className:he("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",n),children:e&&e})]}),dz=G3,hz=W3,pz=K3,mz=q3,yD=V.forwardRef(({className:t,...e},n)=>S.jsx(Tw,{ref:n,className:he("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));yD.displayName=Tw.displayName;const bD=V.forwardRef(({className:t,children:e,...n},r)=>S.jsxs(pz,{children:[S.jsx(yD,{}),S.jsx(Vu,{trapped:!1,children:S.jsxs(Dw,{ref:r,className:he("fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 bg-white duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",t),...n,children:[S.jsx("div",{}),e]})})]}));bD.displayName=Dw.displayName;const wD=({className:t,...e})=>S.jsx("div",{className:he("grid gap-1.5 p-4 text-center sm:text-left",t),...e});wD.displayName="DialogHeader";const AD=({className:t,...e})=>S.jsx("div",{className:he("flex space-x-2",t),...e});AD.displayName="DialogFooter";const vD=V.forwardRef(({className:t,...e},n)=>S.jsx(Ow,{ref:n,className:he("text-lg font-semibold leading-none tracking-tight",t),...e}));vD.displayName=Ow.displayName;const gz=V.forwardRef(({className:t,...e},n)=>S.jsx(_w,{ref:n,className:he("text-sm text-black",t),...e}));gz.displayName=_w.displayName;function yz(t){return Object.prototype.toString.call(t)==="[object Object]"}function xD(t){return yz(t)||Array.isArray(t)}function bz(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function Bw(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;const s=JSON.stringify(Object.keys(t.breakpoints||{})),i=JSON.stringify(Object.keys(e.breakpoints||{}));return s!==i?!1:n.every(o=>{const a=t[o],l=e[o];return typeof a=="function"?`${a}`==`${l}`:!xD(a)||!xD(l)?a===l:Bw(a,l)})}function kD(t){return t.concat().sort((e,n)=>e.name>n.name?1:-1).map(e=>e.options)}function wz(t,e){if(t.length!==e.length)return!1;const n=kD(t),r=kD(e);return n.every((s,i)=>{const o=r[i];return Bw(s,o)})}function Fw(t){return typeof t=="number"}function jw(t){return typeof t=="string"}function Uw(t){return typeof t=="boolean"}function ED(t){return Object.prototype.toString.call(t)==="[object Object]"}function Mt(t){return Math.abs(t)}function Vw(t){return Math.sign(t)}function Id(t,e){return Mt(t-e)}function Az(t,e){if(t===0||e===0||Mt(t)<=Mt(e))return 0;const n=Id(Mt(t),Mt(e));return Mt(n/t)}function Ld(t){return Fd(t).map(Number)}function ms(t){return t[Bd(t)]}function Bd(t){return Math.max(0,t.length-1)}function Hw(t,e){return e===Bd(t)}function CD(t,e=0){return Array.from(Array(t),(n,r)=>e+r)}function Fd(t){return Object.keys(t)}function SD(t,e){return[t,e].reduce((n,r)=>(Fd(r).forEach(s=>{const i=n[s],o=r[s],a=ED(i)&&ED(o);n[s]=a?SD(i,o):o}),n),{})}function zw(t,e){return typeof e.MouseEvent<"u"&&t instanceof e.MouseEvent}function vz(t,e){const n={start:r,center:s,end:i};function r(){return 0}function s(l){return i(l)/2}function i(l){return e-l}function o(l,u){return jw(t)?n[t](l):t(e,l,u)}return{measure:o}}function jd(){let t=[];function e(s,i,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(i,o,a),l=()=>s.removeEventListener(i,o,a);else{const u=s;u.addListener(o),l=()=>u.removeListener(o)}return t.push(l),r}function n(){t=t.filter(s=>s())}const r={add:e,clear:n};return r}function xz(t,e,n,r){const s=jd(),i=1e3/60;let o=null,a=0,l=0;function u(){s.add(t,"visibilitychange",()=>{t.hidden&&p()})}function c(){h(),s.clear()}function f(g){if(!l)return;o||(o=g);const y=g-o;for(o=g,a+=y;a>=i;)n(),a-=i;const v=Mt(a/i);r(v),l&&e.requestAnimationFrame(f)}function d(){l||(l=e.requestAnimationFrame(f))}function h(){e.cancelAnimationFrame(l),o=null,a=0,l=0}function p(){o=null,a=0}return{init:u,destroy:c,start:d,stop:h,update:n,render:r}}function kz(t,e){const n=e==="rtl",r=t==="y",s=r?"y":"x",i=r?"x":"y",o=!r&&n?-1:1,a=c(),l=f();function u(p){const{height:m,width:g}=p;return r?m:g}function c(){return r?"top":n?"right":"left"}function f(){return r?"bottom":n?"left":"right"}function d(p){return p*o}return{scroll:s,cross:i,startEdge:a,endEdge:l,measureSize:u,direction:d}}function rl(t=0,e=0){const n=Mt(t-e);function r(u){return u<t}function s(u){return u>e}function i(u){return r(u)||s(u)}function o(u){return i(u)?r(u)?t:e:u}function a(u){return n?u-n*Math.ceil((u-e)/n):u}return{length:n,max:e,min:t,constrain:o,reachedAny:i,reachedMax:s,reachedMin:r,removeOffset:a}}function TD(t,e,n){const{constrain:r}=rl(0,t),s=t+1;let i=o(e);function o(d){return n?Mt((s+d)%s):r(d)}function a(){return i}function l(d){return i=o(d),f}function u(d){return c().set(a()+d)}function c(){return TD(t,a(),n)}const f={get:a,set:l,add:u,clone:c};return f}function Ez(t,e,n,r,s,i,o,a,l,u,c,f,d,h,p,m,g,y,v){const{cross:w,direction:A}=t,x=["INPUT","SELECT","TEXTAREA"],k={passive:!1},C=jd(),O=jd(),_=rl(50,225).constrain(h.measure(20)),D={mouse:300,touch:400},R={mouse:500,touch:600},L=p?43:25;let F=!1,G=0,B=0,H=!1,Q=!1,te=!1,Z=!1;function pe(ae){if(!v)return;function be(z){(Uw(v)||v(ae,z))&&Ue(z)}const Be=e;C.add(Be,"dragstart",z=>z.preventDefault(),k).add(Be,"touchmove",()=>{},k).add(Be,"touchend",()=>{}).add(Be,"touchstart",be).add(Be,"mousedown",be).add(Be,"touchcancel",Le).add(Be,"contextmenu",Le).add(Be,"click",tt,!0)}function Ee(){C.clear(),O.clear()}function Re(){const ae=Z?n:e;O.add(ae,"touchmove",ze,k).add(ae,"touchend",Le).add(ae,"mousemove",ze,k).add(ae,"mouseup",Le)}function Ce(ae){const be=ae.nodeName||"";return x.includes(be)}function ke(){return(p?R:D)[Z?"mouse":"touch"]}function He(ae,be){const Be=f.add(Vw(ae)*-1),z=c.byDistance(ae,!p).distance;return p||Mt(ae)<_?z:g&&be?z*.5:c.byIndex(Be.get(),0).distance}function Ue(ae){const be=zw(ae,r);Z=be,te=p&&be&&!ae.buttons&&F,F=Id(s.get(),o.get())>=2,!(be&&ae.button!==0)&&(Ce(ae.target)||(H=!0,i.pointerDown(ae),u.useFriction(0).useDuration(0),s.set(o),Re(),G=i.readPoint(ae),B=i.readPoint(ae,w),d.emit("pointerDown")))}function ze(ae){if(!zw(ae,r)&&ae.touches.length>=2)return Le(ae);const Be=i.readPoint(ae),z=i.readPoint(ae,w),q=Id(Be,G),re=Id(z,B);if(!Q&&!Z&&(!ae.cancelable||(Q=q>re,!Q)))return Le(ae);const ue=i.pointerMove(ae);q>m&&(te=!0),u.useFriction(.3).useDuration(.75),a.start(),s.add(A(ue)),ae.preventDefault()}function Le(ae){const Be=c.byDistance(0,!1).index!==f.get(),z=i.pointerUp(ae)*ke(),q=He(A(z),Be),re=Az(z,q),ue=L-10*re,P=y+re/50;Q=!1,H=!1,O.clear(),u.useDuration(ue).useFriction(P),l.distance(q,!p),Z=!1,d.emit("pointerUp")}function tt(ae){te&&(ae.stopPropagation(),ae.preventDefault(),te=!1)}function le(){return H}return{init:pe,destroy:Ee,pointerDown:le}}function Cz(t,e){let r,s;function i(f){return f.timeStamp}function o(f,d){const p=`client${(d||t.scroll)==="x"?"X":"Y"}`;return(zw(f,e)?f:f.touches[0])[p]}function a(f){return r=f,s=f,o(f)}function l(f){const d=o(f)-o(s),h=i(f)-i(r)>170;return s=f,h&&(r=f),d}function u(f){if(!r||!s)return 0;const d=o(s)-o(r),h=i(f)-i(r),p=i(f)-i(s)>170,m=d/h;return h&&!p&&Mt(m)>.1?m:0}return{pointerDown:a,pointerMove:l,pointerUp:u,readPoint:o}}function Sz(){function t(n){const{offsetTop:r,offsetLeft:s,offsetWidth:i,offsetHeight:o}=n;return{top:r,right:s+i,bottom:r+o,left:s,width:i,height:o}}return{measure:t}}function Tz(t){function e(r){return t*(r/100)}return{measure:e}}function Dz(t,e,n,r,s,i,o){let a,l,u=[],c=!1;function f(m){return s.measureSize(o.measure(m))}function d(m){if(!i)return;l=f(t),u=r.map(f);function g(v){for(const w of v){const A=w.target===t,x=r.indexOf(w.target),k=A?l:u[x],C=f(A?t:r[x]);if(Mt(C-k)>=.5){n.requestAnimationFrame(()=>{m.reInit(),e.emit("resize")});break}}}a=new ResizeObserver(v=>{c||(Uw(i)||i(m,v))&&g(v)}),[t].concat(r).forEach(v=>a.observe(v))}function h(){a&&a.disconnect(),c=!0}return{init:d,destroy:h}}function Oz(t,e,n,r,s){let i=0,o=0,a=r,l=s,u=t.get(),c=0;function f(){const x=n.get()-t.get(),k=!a;let C=0;return k?(i=0,t.set(n),C=x):(i+=x/a,i*=l,u+=i,t.add(i),C=u-c),o=Vw(C),c=u,A}function d(){const x=n.get()-e.get();return Mt(x)<.001}function h(){return a}function p(){return o}function m(){return i}function g(){return v(r)}function y(){return w(s)}function v(x){return a=x,A}function w(x){return l=x,A}const A={direction:p,duration:h,velocity:m,seek:f,settled:d,useBaseFriction:y,useBaseDuration:g,useFriction:w,useDuration:v};return A}function _z(t,e,n,r,s){const i=s.measure(10),o=s.measure(50),a=rl(.1,.99);let l=!1;function u(){return!(l||!t.reachedAny(n.get())||!t.reachedAny(e.get()))}function c(h){if(!u())return;const p=t.reachedMin(e.get())?"min":"max",m=Mt(t[p]-e.get()),g=n.get()-e.get(),y=a.constrain(m/o);n.subtract(g*y),!h&&Mt(g)<i&&(n.set(t.constrain(n.get())),r.useDuration(25).useBaseFriction())}function f(h){l=!h}return{shouldConstrain:u,constrain:c,toggleActive:f}}function Mz(t,e,n,r,s){const i=rl(-e+t,0),o=f(),a=c(),l=d();function u(p,m){return Id(p,m)<1}function c(){const p=o[0],m=ms(o),g=o.lastIndexOf(p),y=o.indexOf(m)+1;return rl(g,y)}function f(){return n.map((p,m)=>{const{min:g,max:y}=i,v=i.constrain(p),w=!m,A=Hw(n,m);return w?y:A||u(g,v)?g:u(y,v)?y:v}).map(p=>parseFloat(p.toFixed(3)))}function d(){if(e<=t+s)return[i.max];if(r==="keepSnaps")return o;const{min:p,max:m}=a;return o.slice(p,m)}return{snapsContained:l,scrollContainLimit:a}}function Nz(t,e,n){const r=e[0],s=n?r-t:ms(e);return{limit:rl(s,r)}}function Rz(t,e,n,r){const i=e.min+.1,o=e.max+.1,{reachedMin:a,reachedMax:l}=rl(i,o);function u(d){return d===1?l(n.get()):d===-1?a(n.get()):!1}function c(d){if(!u(d))return;const h=t*(d*-1);r.forEach(p=>p.add(h))}return{loop:c}}function Pz(t){const{max:e,length:n}=t;function r(i){const o=i-e;return n?o/-n:0}return{get:r}}function Iz(t,e,n,r,s){const{startEdge:i,endEdge:o}=t,{groupSlides:a}=s,l=f().map(e.measure),u=d(),c=h();function f(){return a(r).map(m=>ms(m)[o]-m[0][i]).map(Mt)}function d(){return r.map(m=>n[i]-m[i]).map(m=>-Mt(m))}function h(){return a(u).map(m=>m[0]).map((m,g)=>m+l[g])}return{snaps:u,snapsAligned:c}}function Lz(t,e,n,r,s,i){const{groupSlides:o}=s,{min:a,max:l}=r,u=c();function c(){const d=o(i),h=!t||e==="keepSnaps";return n.length===1?[i]:h?d:d.slice(a,l).map((p,m,g)=>{const y=!m,v=Hw(g,m);if(y){const w=ms(g[0])+1;return CD(w)}if(v){const w=Bd(i)-ms(g)[0]+1;return CD(w,ms(g)[0])}return p})}return{slideRegistry:u}}function Bz(t,e,n,r,s){const{reachedAny:i,removeOffset:o,constrain:a}=r;function l(p){return p.concat().sort((m,g)=>Mt(m)-Mt(g))[0]}function u(p){const m=t?o(p):a(p),g=e.map((v,w)=>({diff:c(v-m,0),index:w})).sort((v,w)=>Mt(v.diff)-Mt(w.diff)),{index:y}=g[0];return{index:y,distance:m}}function c(p,m){const g=[p,p+n,p-n];if(!t)return p;if(!m)return l(g);const y=g.filter(v=>Vw(v)===m);return y.length?l(y):ms(g)-n}function f(p,m){const g=e[p]-s.get(),y=c(g,m);return{index:p,distance:y}}function d(p,m){const g=s.get()+p,{index:y,distance:v}=u(g),w=!t&&i(g);if(!m||w)return{index:y,distance:p};const A=e[y]-v,x=p+c(A,0);return{index:y,distance:x}}return{byDistance:d,byIndex:f,shortcut:c}}function Fz(t,e,n,r,s,i,o){function a(f){const d=f.distance,h=f.index!==e.get();i.add(d),d&&(r.duration()?t.start():(t.update(),t.render(1),t.update())),h&&(n.set(e.get()),e.set(f.index),o.emit("select"))}function l(f,d){const h=s.byDistance(f,d);a(h)}function u(f,d){const h=e.clone().set(f),p=s.byIndex(h.get(),d);a(p)}return{distance:l,index:u}}function jz(t,e,n,r,s,i,o){let a=0;function l(){i.add(document,"keydown",u,!1),e.forEach(c)}function u(d){d.code==="Tab"&&(a=new Date().getTime())}function c(d){const h=()=>{if(new Date().getTime()-a>10)return;t.scrollLeft=0;const g=e.indexOf(d),y=n.findIndex(v=>v.includes(g));Fw(y)&&(s.useDuration(0),r.index(y,0),o.emit("slideFocus"))};i.add(d,"focus",h,{passive:!0,capture:!0})}return{init:l}}function W0(t){let e=t;function n(){return e}function r(l){e=o(l)}function s(l){e+=o(l)}function i(l){e-=o(l)}function o(l){return Fw(l)?l:l.get()}return{get:n,set:r,add:s,subtract:i}}function DD(t,e){const n=t.scroll==="x"?i:o,r=e.style;let s=!1;function i(f){return`translate3d(${f}px,0px,0px)`}function o(f){return`translate3d(0px,${f}px,0px)`}function a(f){s||(r.transform=n(t.direction(f)))}function l(f){s=!f}function u(){s||(r.transform="",e.getAttribute("style")||e.removeAttribute("style"))}return{clear:u,to:a,toggleActive:l}}function Uz(t,e,n,r,s,i,o,a,l){const c=Ld(s),f=Ld(s).reverse(),d=y().concat(v());function h(C,O){return C.reduce((_,D)=>_-s[D],O)}function p(C,O){return C.reduce((_,D)=>h(_,O)>0?_.concat([D]):_,[])}function m(C){return i.map((O,_)=>({start:O-r[_]+.5+C,end:O+e-.5+C}))}function g(C,O,_){const D=m(O);return C.map(R=>{const L=_?0:-n,F=_?n:0,G=_?"end":"start",B=D[R][G];return{index:R,loopPoint:B,slideLocation:W0(-1),translate:DD(t,l[R]),target:()=>a.get()>B?L:F}})}function y(){const C=o[0],O=p(f,C);return g(O,n,!1)}function v(){const C=e-o[0]-1,O=p(c,C);return g(O,-n,!0)}function w(){return d.every(({index:C})=>{const O=c.filter(_=>_!==C);return h(O,e)<=.1})}function A(){d.forEach(C=>{const{target:O,translate:_,slideLocation:D}=C,R=O();R!==D.get()&&(_.to(R),D.set(R))})}function x(){d.forEach(C=>C.translate.clear())}return{canLoop:w,clear:x,loop:A,loopPoints:d}}function Vz(t,e,n){let r,s=!1;function i(l){if(!n)return;function u(c){for(const f of c)if(f.type==="childList"){l.reInit(),e.emit("slidesChanged");break}}r=new MutationObserver(c=>{s||(Uw(n)||n(l,c))&&u(c)}),r.observe(t,{childList:!0})}function o(){r&&r.disconnect(),s=!0}return{init:i,destroy:o}}function Hz(t,e,n,r){const s={};let i=null,o=null,a,l=!1;function u(){a=new IntersectionObserver(p=>{l||(p.forEach(m=>{const g=e.indexOf(m.target);s[g]=m}),i=null,o=null,n.emit("slidesInView"))},{root:t.parentElement,threshold:r}),e.forEach(p=>a.observe(p))}function c(){a&&a.disconnect(),l=!0}function f(p){return Fd(s).reduce((m,g)=>{const y=parseInt(g),{isIntersecting:v}=s[y];return(p&&v||!p&&!v)&&m.push(y),m},[])}function d(p=!0){if(p&&i)return i;if(!p&&o)return o;const m=f(p);return p&&(i=m),p||(o=m),m}return{init:u,destroy:c,get:d}}function zz(t,e,n,r,s,i){const{measureSize:o,startEdge:a,endEdge:l}=t,u=n[0]&&s,c=p(),f=m(),d=n.map(o),h=g();function p(){if(!u)return 0;const v=n[0];return Mt(e[a]-v[a])}function m(){if(!u)return 0;const v=i.getComputedStyle(ms(r));return parseFloat(v.getPropertyValue(`margin-${l}`))}function g(){return n.map((v,w,A)=>{const x=!w,k=Hw(A,w);return x?d[w]+c:k?d[w]+f:A[w+1][a]-v[a]}).map(Mt)}return{slideSizes:d,slideSizesWithGaps:h,startGap:c,endGap:f}}function $z(t,e,n,r,s,i,o,a,l){const{startEdge:u,endEdge:c,direction:f}=t,d=Fw(n);function h(y,v){return Ld(y).filter(w=>w%v===0).map(w=>y.slice(w,w+v))}function p(y){return y.length?Ld(y).reduce((v,w,A)=>{const x=ms(v)||0,k=x===0,C=w===Bd(y),O=s[u]-i[x][u],_=s[u]-i[w][c],D=!r&&k?f(o):0,R=!r&&C?f(a):0,L=Mt(_-R-(O+D));return A&&L>e+l&&v.push(w),C&&v.push(y.length),v},[]).map((v,w,A)=>{const x=Math.max(A[w-1]||0);return y.slice(x,v)}):[]}function m(y){return d?h(y,n):p(y)}return{groupSlides:m}}function Gz(t,e,n,r,s,i,o){const{align:a,axis:l,direction:u,startIndex:c,loop:f,duration:d,dragFree:h,dragThreshold:p,inViewThreshold:m,slidesToScroll:g,skipSnaps:y,containScroll:v,watchResize:w,watchSlides:A,watchDrag:x}=i,k=2,C=Sz(),O=C.measure(e),_=n.map(C.measure),D=kz(l,u),R=D.measureSize(O),L=Tz(R),F=vz(a,R),G=!f&&!!v,B=f||!!v,{slideSizes:H,slideSizesWithGaps:Q,startGap:te,endGap:Z}=zz(D,O,_,n,B,s),pe=$z(D,R,g,f,O,_,te,Z,k),{snaps:Ee,snapsAligned:Re}=Iz(D,F,O,_,pe),Ce=-ms(Ee)+ms(Q),{snapsContained:ke,scrollContainLimit:He}=Mz(R,Ce,Re,v,k),Ue=G?ke:Re,{limit:ze}=Nz(Ce,Ue,f),Le=TD(Bd(Ue),c,f),tt=Le.clone(),le=Ld(n),$e=({dragHandler:Je,scrollBody:Ve,scrollBounds:Fe,options:{loop:ft}})=>{ft||Fe.constrain(Je.pointerDown()),Ve.seek()},ae=({scrollBody:Je,translate:Ve,location:Fe,offsetLocation:ft,scrollLooper:Xn,slideLooper:br,dragHandler:X,animation:ne,eventHandler:ie,scrollBounds:Te,options:{loop:me}},qe)=>{const nt=Je.velocity(),yt=Je.settled(),sn=!Te.shouldConstrain(),Ft=me?yt:yt&&sn;Ft&&!X.pointerDown()&&(ne.stop(),ie.emit("settle")),Ft||ie.emit("scroll"),ft.set(Fe.get()-nt+nt*qe),me&&(Xn.loop(Je.direction()),br.loop()),Ve.to(ft.get())},be=xz(r,s,()=>$e(Se),Je=>ae(Se,Je)),Be=.68,z=Ue[Le.get()],q=W0(z),re=W0(z),ue=W0(z),P=Oz(q,re,ue,d,Be),b=Bz(f,Ue,Ce,ze,ue),E=Fz(be,Le,tt,P,b,ue,o),M=Pz(ze),j=jd(),K=Hz(e,n,o,m),{slideRegistry:Y}=Lz(G,v,Ue,He,pe,le),ye=jz(t,n,Y,E,P,j,o),Se={ownerDocument:r,ownerWindow:s,eventHandler:o,containerRect:O,slideRects:_,animation:be,axis:D,dragHandler:Ez(D,t,r,s,ue,Cz(D,s),q,be,E,P,b,Le,o,L,h,p,y,Be,x),eventStore:j,percentOfView:L,index:Le,indexPrevious:tt,limit:ze,location:q,offsetLocation:re,options:i,resizeHandler:Dz(e,o,s,n,D,w,C),scrollBody:P,scrollBounds:_z(ze,re,ue,P,L),scrollLooper:Rz(Ce,ze,re,[q,re,ue]),scrollProgress:M,scrollSnapList:Ue.map(M.get),scrollSnaps:Ue,scrollTarget:b,scrollTo:E,slideLooper:Uz(D,R,Ce,H,Q,Ee,Ue,re,n),slideFocus:ye,slidesHandler:Vz(e,o,A),slidesInView:K,slideIndexes:le,slideRegistry:Y,slidesToScroll:pe,target:ue,translate:DD(D,e)};return Se}function Wz(){let t={},e;function n(u){e=u}function r(u){return t[u]||[]}function s(u){return r(u).forEach(c=>c(e,u)),l}function i(u,c){return t[u]=r(u).concat([c]),l}function o(u,c){return t[u]=r(u).filter(f=>f!==c),l}function a(){t={}}const l={init:n,emit:s,off:o,on:i,clear:a};return l}const Kz={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function qz(t){function e(i,o){return SD(i,o||{})}function n(i){const o=i.breakpoints||{},a=Fd(o).filter(l=>t.matchMedia(l).matches).map(l=>o[l]).reduce((l,u)=>e(l,u),{});return e(i,a)}function r(i){return i.map(o=>Fd(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(t.matchMedia)}return{mergeOptions:e,optionsAtMedia:n,optionsMediaQueries:r}}function Qz(t){let e=[];function n(i,o){return e=o.filter(({options:a})=>t.optionsAtMedia(a).active!==!1),e.forEach(a=>a.init(i,t)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function r(){e=e.filter(i=>i.destroy())}return{init:n,destroy:r}}function K0(t,e,n){const r=t.ownerDocument,s=r.defaultView,i=qz(s),o=Qz(i),a=jd(),l=Wz(),{mergeOptions:u,optionsAtMedia:c,optionsMediaQueries:f}=i,{on:d,off:h,emit:p}=l,m=R;let g=!1,y,v=u(Kz,K0.globalOptions),w=u(v),A=[],x,k,C;function O(){const{container:$e,slides:ae}=w;k=(jw($e)?t.querySelector($e):$e)||t.children[0];const Be=jw(ae)?k.querySelectorAll(ae):ae;C=[].slice.call(Be||k.children)}function _($e){const ae=Gz(t,k,C,r,s,$e,l);if($e.loop&&!ae.slideLooper.canLoop()){const be=Object.assign({},$e,{loop:!1});return _(be)}return ae}function D($e,ae){g||(v=u(v,$e),w=c(v),A=ae||A,O(),y=_(w),f([v,...A.map(({options:be})=>be)]).forEach(be=>a.add(be,"change",R)),w.active&&(y.translate.to(y.location.get()),y.animation.init(),y.slidesInView.init(),y.slideFocus.init(),y.eventHandler.init(le),y.resizeHandler.init(le),y.slidesHandler.init(le),y.options.loop&&y.slideLooper.loop(),k.offsetParent&&C.length&&y.dragHandler.init(le),x=o.init(le,A)))}function R($e,ae){const be=Ee();L(),D(u({startIndex:be},$e),ae),l.emit("reInit")}function L(){y.dragHandler.destroy(),y.eventStore.clear(),y.translate.clear(),y.slideLooper.clear(),y.resizeHandler.destroy(),y.slidesHandler.destroy(),y.slidesInView.destroy(),y.animation.destroy(),o.destroy(),a.clear()}function F(){g||(g=!0,a.clear(),L(),l.emit("destroy"),l.clear())}function G($e,ae,be){!w.active||g||(y.scrollBody.useBaseFriction().useDuration(ae===!0?0:w.duration),y.scrollTo.index($e,be||0))}function B($e){const ae=y.index.add(1).get();G(ae,$e,-1)}function H($e){const ae=y.index.add(-1).get();G(ae,$e,1)}function Q(){return y.index.add(1).get()!==Ee()}function te(){return y.index.add(-1).get()!==Ee()}function Z(){return y.scrollSnapList}function pe(){return y.scrollProgress.get(y.location.get())}function Ee(){return y.index.get()}function Re(){return y.indexPrevious.get()}function Ce(){return y.slidesInView.get()}function ke(){return y.slidesInView.get(!1)}function He(){return x}function Ue(){return y}function ze(){return t}function Le(){return k}function tt(){return C}const le={canScrollNext:Q,canScrollPrev:te,containerNode:Le,internalEngine:Ue,destroy:F,off:h,on:d,emit:p,plugins:He,previousScrollSnap:Re,reInit:m,rootNode:ze,scrollNext:B,scrollPrev:H,scrollProgress:pe,scrollSnapList:Z,scrollTo:G,selectedScrollSnap:Ee,slideNodes:tt,slidesInView:Ce,slidesNotInView:ke};return D(e,n),setTimeout(()=>l.emit("init"),0),le}K0.globalOptions=void 0;function $w(t={},e=[]){const n=N.useRef(t),r=N.useRef(e),[s,i]=N.useState(),[o,a]=N.useState(),l=N.useCallback(()=>{s&&s.reInit(n.current,r.current)},[s]);return N.useEffect(()=>{if(bz()&&o){K0.globalOptions=$w.globalOptions;const u=K0(o,n.current,r.current);return i(u),()=>u.destroy()}else i(void 0)},[o,i]),N.useEffect(()=>{Bw(n.current,t)||(n.current=t,l())},[t,l]),N.useEffect(()=>{wz(r.current,e)||(r.current=e,l())},[e,l]),[a,s]}$w.globalOptions=void 0;const OD=N.createContext(null);function Ud(){const t=N.useContext(OD);if(!t)throw new Error("useCarousel must be used within a <Carousel />");return t}const _D=N.forwardRef(({orientation:t="horizontal",opts:e,setApi:n,plugins:r,className:s,children:i,...o},a)=>{const[l,u]=$w({...e,axis:t==="horizontal"?"x":"y"},r),[c,f]=N.useState(!1),[d,h]=N.useState(!1),p=N.useCallback(v=>{v&&(f(v.canScrollPrev()),h(v.canScrollNext()))},[]),m=N.useCallback(()=>{u==null||u.scrollPrev()},[u]),g=N.useCallback(()=>{u==null||u.scrollNext()},[u]),y=N.useCallback(v=>{v.key==="ArrowLeft"?(v.preventDefault(),m()):v.key==="ArrowRight"&&(v.preventDefault(),g())},[m,g]);return N.useEffect(()=>{!u||!n||n(u)},[u,n]),N.useEffect(()=>{if(u)return p(u),u.on("reInit",p),u.on("select",p),()=>{u==null||u.off("select",p)}},[u,p]),S.jsx(OD.Provider,{value:{carouselRef:l,api:u,opts:e,orientation:t||((e==null?void 0:e.axis)==="y"?"vertical":"horizontal"),scrollPrev:m,scrollNext:g,canScrollPrev:c,canScrollNext:d},children:S.jsx("div",{ref:a,onKeyDownCapture:y,className:he("relative",s),role:"region","aria-roledescription":"carousel",...o,children:i})})});_D.displayName="Carousel";const MD=N.forwardRef(({className:t,...e},n)=>{const{carouselRef:r,orientation:s}=Ud();return S.jsx("div",{ref:r,className:"overflow-hidden",children:S.jsx("div",{ref:n,className:he("flex",s==="horizontal"?"-ml-4":"-mt-4 flex-col",t),...e})})});MD.displayName="CarouselContent";const Gw=N.forwardRef(({className:t,...e},n)=>{const{orientation:r}=Ud();return S.jsx("div",{ref:n,role:"group","aria-roledescription":"slide",className:he("min-w-0 shrink-0 grow-0 basis-full",r==="horizontal"?"pl-4":"pt-4",t),...e})});Gw.displayName="CarouselItem";const ND=N.forwardRef(({index:t,className:e,...n},r)=>{const{api:s}=Ud(),[i,o]=N.useState(0),[,a]=N.useState([]),l=N.useCallback(d=>{s&&s.scrollTo(d)},[s]),u=N.useCallback(d=>{d&&a(d.scrollSnapList())},[]),c=N.useCallback(d=>{d&&o(d.selectedScrollSnap())},[]);N.useEffect(()=>{s&&(u(s),c(s),s.on("reInit",u),s.on("reInit",c),s.on("select",c))},[s,u,c]);const f=i===t;return S.jsx("button",{ref:r,className:he("w-2 h-2 transition-colors duration-200 rounded-full",f?"bg-black":"bg-[#E8EBEC] hover:bg-black/50",e),onClick:()=>l(t),...n})});ND.displayName="CarouselIndicator";const Jz=N.forwardRef(({className:t,...e},n)=>{const{scrollPrev:r,canScrollPrev:s}=Ud();return S.jsx("button",{ref:n,className:he("btn bg-white hover:bg-[#F2F4F5] transition text-black flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",t),disabled:!s,onClick:r,...e,children:S.jsx("span",{children:"Back"})})});Jz.displayName="CarouselPrevious";const Yz=N.forwardRef(({className:t,...e},n)=>{const{scrollNext:r,canScrollNext:s}=Ud();return S.jsx("button",{ref:n,className:he("btn bg-black hover:bg-black text-white flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",t),disabled:!s,onClick:r,...e,children:S.jsx("span",{children:"Next"})})});Yz.displayName="CarouselNext";const q0=V.forwardRef(({className:t,label:e,type:n="text",isValid:r=!0,message:s,onChange:i,leftIcon:o,rightIcon:a,...l},u)=>{const c=V.useRef(null),f=Gr(u,c),d=V.useCallback(()=>{var m;(m=c.current)==null||m.focus()},[]),h=V.useMemo(()=>{if(o==null)return;const m=V.Children.only(o);if(V.isValidElement(m))return V.cloneElement(m,{...m.props,onClick:g=>{var y,v;(v=(y=m.props).onClick)==null||v.call(y,g),d()},className:he("absolute left-3 text-[#A1AAB1]",{"cursor-not-allowed":l.disabled})})},[d,o,l.disabled]),p=V.useMemo(()=>{if(a==null)return;const m=V.Children.only(a);if(V.isValidElement(m))return V.cloneElement(m,{...m.props,onClick:g=>{var y,v;(v=(y=m.props).onClick)==null||v.call(y,g),d()},className:he("absolute right-3 cursor-pointer text-[#A1AAB1]",{"cursor-not-allowed":l.disabled},{"text-red-500":!r})})},[d,a,l.disabled,r]);return S.jsxs("div",{className:"flex flex-col",children:[e?S.jsx("label",{className:"mb-2 text-sm font-medium",children:e}):null,S.jsxs("div",{className:"relative flex items-center group",children:[h,S.jsx("input",{type:n,className:he("flex h-9 w-full rounded border-[1px] border-[#E8EBEC] hover:border-black bg-transparent px-3 py-2 text-sm text-black transition-colors file:border-0 file:bg-transparent file:text-sm placeholder:text-[#A1AAB1] focus-visible:outline-none focus-visible:border-black",{"pr-3 pl-10":h},{"pr-10":p},{"border-red-500":!r},{"disabled:cursor-not-allowed disabled:bg-[#E8EBEC] disabled:border-[#A1AAB1] disabled:text-[#A1AAB1]":l.disabled},t),onChange:i,ref:f,...l}),p]}),s?S.jsx("p",{className:he("text-sm mt-2 font-normal text-wrap text-justify",{"text-red-500":!r,"text-black":r}),children:s}):null]})});q0.displayName="TextField";const sl=N.forwardRef(({active:t,buttonSize:e="medium",children:n,disabled:r,variant:s="primary",className:i,activeClassname:o,isLoading:a=!1,...l},u)=>{const c=he("flex items-center justify-center border-2 gap-2 transition text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",s==="primary"&&he("text-white bg-black border-black",!r&&!t&&"hover:bg-neutral-800 active:bg-neutral-900",t&&he("bg-neutral-900 dark:bg-neutral-300",o)),s==="secondary"&&he("text-neutral-900 border-black",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200",t&&"bg-neutral-200"),s==="tertiary"&&he("bg-neutral-50 text-neutral-900 border-transparent",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200",t&&he("bg-neutral-200",o)),s==="ghost"&&he("bg-transparent border-transparent text-neutral-900",!r&&!t&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10",t&&he("bg-black/10",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return S.jsx("button",{ref:u,disabled:r,className:c,...l,children:a?S.jsx(eV,{size:20,className:"animate-spin",fill:"transparent",stroke:"currentColor"}):n})});sl.displayName="Button";const RD=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:t=>{t.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:t=>{t.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:t=>{t.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:t=>{t.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:t=>{t.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:t=>{t.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:t=>{t.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:t=>{t.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:t=>{t.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:t=>{t.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:t=>{t.chain().focus().setFontFamily("cursive").run()}}],Ww=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}],Vd=1024*100,Kw={IMAGE_SIZE:"Image size should be less than 2 MB"},qw=({editor:t,onError:e})=>{const{ref:n,toolVisibilty:r,setToolVisibility:s}=hV(Me.NONE),i=[{icon:S.jsx(KU,{size:20}),title:"Text Color",onClick:()=>s(Me.TEXT_COLOR),isActive:r===Me.TEXT_COLOR},{icon:S.jsx(QT,{size:20}),title:"Highlight",onClick:()=>s(Me.HIGHLIGHT),isActive:r===Me.HIGHLIGHT},null,{icon:S.jsx(ew,{size:20}),title:"Bold",onClick:()=>t==null?void 0:t.chain().focus().toggleBold().run(),isActive:t==null?void 0:t.isActive("bold")},{icon:S.jsx(tw,{size:20}),title:"Italic",onClick:()=>t==null?void 0:t.chain().focus().toggleItalic().run(),isActive:t==null?void 0:t.isActive("italic")},{icon:S.jsx(lw,{size:20}),title:"Underlined",onClick:()=>t==null?void 0:t.chain().focus().toggleUnderline().run(),isActive:t==null?void 0:t.isActive("underline")},{icon:S.jsx(sw,{size:20}),title:"Strikethrough",onClick:()=>t==null?void 0:t.chain().focus().toggleStrike().run(),isActive:t==null?void 0:t.isActive("strike")},null,{icon:S.jsx(D0,{size:20}),title:"List",onClick:()=>{t==null||t.chain().focus().toggleBulletList().run(),s(Me.NONE)},isActive:t==null?void 0:t.isActive("bulletList")},{icon:S.jsx(Uu,{size:20}),title:"Ordered List",onClick:()=>{t==null||t.chain().focus().toggleOrderedList().run(),s(Me.NONE)},isActive:t==null?void 0:t.isActive("orderedList")},{icon:S.jsx(rw,{size:20}),title:"To-do List",onClick:()=>{t==null||t.chain().focus().toggleTaskList().run(),s(Me.NONE)},isActive:t==null?void 0:t.isActive("taskList")},{icon:S.jsx(Od,{size:20}),title:"Alignment",onClick:()=>s(Me.ALIGNMENT),isActive:r===Me.ALIGNMENT},{icon:S.jsx(O0,{size:20}),title:"Quote",onClick:()=>t==null?void 0:t.chain().focus().toggleBlockquote().run(),isActive:t==null?void 0:t.isActive("blockquote")},null,{icon:S.jsx(JT,{size:20}),title:"Upload Image",onClick:()=>{t==null||t.chain().focus().deleteRange(t.state.selection).run();const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=async()=>{var l;if((l=a.files)!=null&&l.length){const u=a.files[0];if(u.size>Vd){e&&typeof e=="function"&&e(Kw.IMAGE_SIZE);return}const f=t.view.state.selection.from;uw(u,t.view,f)}},a.click()},isActive:!1},{icon:S.jsx(nw,{size:20}),title:"Link",onClick:()=>s(Me.LINK),isActive:t==null?void 0:t.isActive("link")},{icon:S.jsx(Md,{size:20}),title:"Code",onClick:()=>t==null?void 0:t.chain().focus().toggleCodeBlock().run(),isActive:t==null?void 0:t.isActive("codeBlock")},{icon:S.jsx(iw,{size:20}),title:"Add table",onClick:()=>t==null?void 0:t.chain().focus().insertTable({rows:3,cols:2,withHeaderRow:!0}).run(),isActive:r===Me.TEXT_COLOR}],o=[{icon:S.jsx(aw,{size:24}),title:"Text formating",onClick:()=>s(Me.TEXT_FORMATING),isActive:r===Me.TEXT_FORMATING},{icon:S.jsx(iw,{size:24}),title:"Add table",onClick:()=>t==null?void 0:t.chain().focus().insertTable({rows:3,cols:2,withHeaderRow:!0}).run(),isActive:!0},{icon:S.jsx(rw,{size:24}),title:"To-do list",onClick:()=>{t==null||t.chain().focus().toggleTaskList().run(),s(Me.NONE)},isActive:!0},{icon:S.jsx(JT,{size:24}),title:"Add image",onClick:()=>{t==null||t.chain().focus().deleteRange(t.state.selection).run();const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=async()=>{var l;if((l=a.files)!=null&&l.length){const u=a.files[0];if(u.size>Vd){e&&typeof e=="function"&&e(Kw.IMAGE_SIZE);return}const f=t.view.state.selection.from;uw(u,t.view,f)}},a.click()},isActive:!0},{icon:S.jsx(uV,{size:24}),title:"Undo",onClick:()=>{t==null||t.chain().focus().undo().run()},isActive:t==null?void 0:t.can().undo()},{icon:S.jsx(oV,{size:24}),title:"Redo",onClick:()=>{t==null||t.chain().focus().redo().run()},isActive:t==null?void 0:t.can().redo()}];return{toolbar:i,bottomToolbar:o,toolRef:n,toolVisibilty:r,setToolVisibility:s}},PD=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return S.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[S.jsx(Z1,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetHighlight().run(),e(Me.NONE)}}),r.map(s=>S.jsx("div",{onClick:()=>{t.chain().focus().toggleHighlight({color:s.color}).run(),e(Me.NONE)},className:he("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:S.jsx(_d,{size:14,className:he(t.isActive("highlight",{color:s.color})?"visible":"invisible")})},s.color))]})},Xz=({elementRef:t,editor:e,setToolVisibility:n})=>S.jsx("div",{ref:t,className:he("z-50 h-auto absolute top-14 left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-lg transition-all rounded animate-in fade-in slide-in-from-top-1"),children:RD.map(r=>S.jsx("button",{onClick:()=>{r.command(e),n(Me.NONE)},style:{fontFamily:r.title},className:he("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm text-black transition",e.isActive("textStyle",{fontFamily:r.value})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx("p",{className:"font-medium",children:r.title})},r.title))}),ID=({elementRef:t,editor:e,setToolVisibility:n})=>S.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-14 left-[60%] translate-x-1/2 flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[S.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),n(Me.NONE)},className:he("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"left"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx(Od,{})}),S.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),n(Me.NONE)},className:he("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"center"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx(Y1,{})}),S.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),n(Me.NONE)},className:he("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"right"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:S.jsx(X1,{})})]}),Zz=({elementRef:t,editor:e,setToolVisibility:n})=>S.jsxs("div",{ref:t,className:he("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all"),children:[S.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:S.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),n(Me.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:S.jsx(D0,{size:20})})}),S.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:S.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),n(Me.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:S.jsx(Uu,{size:20})})}),S.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:S.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),n(Me.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:S.jsx(rw,{size:20})})})]}),LD=({elementRef:t,editor:e,setToolVisibility:n,bubbleMenu:r,setIsLinkPopupOpen:s})=>{const[i,o]=N.useState(e.getAttributes("link").href),a=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let l=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(l="https://"+i);try{l.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:l}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:l}).run(),n(Me.NONE),r&&s&&s(!1)};return S.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-14 translate-x-1/2 items-center flex max-h-[330px] overflow-y-auto scroll-smooth rounded-lg bg-white p-2 shadow-lg transition-all",children:[S.jsx(q0,{onChange:l=>o(l.target.value),className:"w-full",placeholder:"Add link here",value:i}),S.jsx("div",{className:"h-full flex items-center",children:S.jsx(sl,{variant:"secondary",onClick:()=>a(),className:"min-w-fit h-[36px]",children:"Apply"})})]})},e$=({editor:t,setVisibility:e,elementRef:n})=>S.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[S.jsx(Z1,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetColor().run(),e(Me.NONE)}}),Ww.map(r=>S.jsx("div",{onClick:()=>{t.chain().focus().setColor(r.color).run(),e(Me.NONE)},className:he("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",r.code),children:S.jsx(_d,{size:14,className:he(t.isActive("textStyle",{color:r.color})?"visible":"invisible")})},r.color))]}),t$=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{title:"Text",description:"Normal",icon:S.jsx(aw,{size:20}),command:s=>s.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:S.jsx(C0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:1}).run()},isActive:()=>t.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:S.jsx(S0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:2}).run()},isActive:()=>t.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:S.jsx(T0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:3}).run()},isActive:()=>t.isActive("heading",{level:3})}];return S.jsx("div",{ref:n,className:he("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-lg animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(s=>S.jsxs("button",{onClick:()=>{s.command(t),e(Me.NONE)},className:he("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":s.isActive(),"hover:bg-[#f2f2f2]":!s.isActive()}),children:[S.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:s.icon}),S.jsxs("div",{children:[S.jsx("p",{className:"font-medium",children:s.title}),S.jsxs("p",{className:"text-xs text-stone-500",children:[" ",s.description," "]})]})]},s.title))})},n$=({editor:t,setToolVisibility:e})=>{const n=[{title:"Text",description:"Normal",icon:S.jsx(aw,{size:20}),command:r=>r.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:S.jsx(C0,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:1}).run()},isActive:()=>t.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:S.jsx(S0,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:2}).run()},isActive:()=>t.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:S.jsx(T0,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:3}).run()},isActive:()=>t.isActive("heading",{level:3})}];return S.jsx(fz,{title:"Text formating",content:S.jsxs("div",{className:"px-4 flex flex-col gap-2 w-full",children:[S.jsx("div",{className:"flex justify-start sm:justify-center items-center gap-1",children:n.map(r=>S.jsx("button",{onClick:()=>r.command(t),className:he("flex w-fit items-center font-medium space-x-2 rounded p-2 text-center text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":r.isActive(),"hover:bg-[#f2f2f2]":!r.isActive()}),children:r.title},r.title))}),S.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-1 justify-evenly w-full sm:w-fit p-1",children:[S.jsx("button",{onClick:()=>{t==null||t.chain().focus().setTextAlign("left").run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive({textAlign:"left"}),"hover:bg-[#f2f2f2]":!t.isActive({textAlign:"left"})}),children:S.jsx(Od,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().setTextAlign("center").run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive({textAlign:"center"}),"hover:bg-[#f2f2f2]":!t.isActive({textAlign:"center"})}),children:S.jsx(Y1,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().setTextAlign("right").run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive({textAlign:"right"}),"hover:bg-[#f2f2f2]":!t.isActive({textAlign:"right"})}),children:S.jsx(X1,{size:20})})]}),S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-1 justify-evenly w-full sm:w-fit p-1",children:[S.jsx(hz,{asChild:!0,children:S.jsx("button",{onClick:()=>e(Me.LINK_POPUP),className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("link"),"hover:bg-[#f2f2f2]":!t.isActive("link")}),children:S.jsx(nw,{size:20})})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleCodeBlock().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("codeBlock"),"hover:bg-[#f2f2f2]":!t.isActive("codeBlock")}),children:S.jsx(Md,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleBlockquote().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("blockquote"),"hover:bg-[#f2f2f2]":!t.isActive("blockquote")}),children:S.jsx(O0,{size:20})})]})]}),S.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-1 justify-evenly w-full sm:w-fit p-1",children:[S.jsx("button",{onClick:()=>{t.chain().focus().toggleBold().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("bold"),"hover:bg-[#f2f2f2]":!t.isActive("bold")}),children:S.jsx(ew,{size:20})}),S.jsx("button",{onClick:()=>{t.chain().focus().toggleItalic().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("italic"),"hover:bg-[#f2f2f2]":!t.isActive("italic")}),children:S.jsx(tw,{size:20})}),S.jsx("button",{onClick:()=>{t.chain().focus().toggleUnderline().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("underline"),"hover:bg-[#f2f2f2]":!t.isActive("bold")}),children:S.jsx(lw,{size:20})}),S.jsx("button",{onClick:()=>{t.chain().focus().toggleStrike().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("strike"),"hover:bg-[#f2f2f2]":!t.isActive("bold")}),children:S.jsx(sw,{size:20})})]}),S.jsxs("div",{className:"bg-[#f8f9fa] rounded flex flex-[0.5] sm:flex-none gap-2 justify-evenly w-full sm:w-fit p-1",children:[S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleBulletList().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("bulletList"),"hover:bg-[#f2f2f2]":!t.isActive("bulletList")}),children:S.jsx(D0,{size:20})}),S.jsx("button",{onClick:()=>{t==null||t.chain().focus().toggleOrderedList().run()},className:he("flex items-center space-x-2 rounded px-4 py-1 text-black transition h-9",{"bg-yellow-300 hover:brightness-90":t.isActive("orderedList"),"hover:bg-[#f2f2f2]":!t.isActive("orderedList")}),children:S.jsx(Uu,{size:20})})]})]}),S.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[S.jsx("p",{className:"text-left sm:text-center text-lg font-semibold leading-none tracking-tight",children:"Text color"}),S.jsxs(_D,{opts:{align:"start",dragFree:!0,slidesToScroll:"auto"},className:"w-full max-w-md mx-auto",children:[S.jsxs(MD,{children:[S.jsx(Gw,{style:{flexBasis:"calc(100% / 12)"},children:S.jsx(Z1,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetColor().run()}})}),Ww.map((r,s)=>S.jsx(Gw,{style:{flexBasis:"calc(100% / 12)"},children:S.jsx("button",{onClick:()=>{t.chain().focus().setColor(r.color).run()},className:he("w-6 h-6 mb-1 drop-shadow rounded-full flex justify-center items-center cursor-pointer transition",r.code),children:S.jsx(_d,{size:14,className:he(t.isActive("textStyle",{color:r.color})?"visible":"invisible")})},r.color)},s))]}),S.jsx("div",{className:"flex justify-center gap-2 mt-4 w-full max-w-sm",children:Array.from({length:Ww.length/8}).map((r,s)=>S.jsx(ND,{index:s},s))})]})]})]})})},r$=t=>{const e=[{name:"Bold",isActive:()=>t.editor.isActive("bold"),command:()=>t.editor.chain().focus().toggleBold().run(),icon:S.jsx(ew,{size:20})},{name:"Italic",isActive:()=>t.editor.isActive("italic"),command:()=>t.editor.chain().focus().toggleItalic().run(),icon:S.jsx(tw,{size:20})},{name:"Underline",isActive:()=>t.editor.isActive("underline"),command:()=>t.editor.chain().focus().toggleUnderline().run(),icon:S.jsx(lw,{size:20})},{name:"Strikethrough",isActive:()=>t.editor.isActive("strike"),command:()=>t.editor.chain().focus().toggleStrike().run(),icon:S.jsx(sw,{size:20})},{name:"Alignment",isActive:()=>f===Me.ALIGNMENT,command:()=>c(Me.ALIGNMENT),icon:S.jsx(Od,{size:20})},{name:"Code",isActive:()=>t.editor.isActive("codeBlock"),command:()=>t.editor.chain().focus().toggleCodeBlock().run(),icon:S.jsx(Md,{size:20})},{name:"Link",isActive:()=>t.editor.isActive("link"),command:()=>l(!a),icon:S.jsx(nw,{size:20})}],n={...t,shouldShow:({state:h,editor:p})=>{const{selection:m}=h,{empty:g}=m;return!(p.isActive("image")||g||k1(m))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{s(!1),o(!1),l(!1)}}},[r,s]=N.useState(!1),[i,o]=N.useState(!1),[a,l]=N.useState(!1),{toolRef:u,setToolVisibility:c,toolVisibilty:f}=qw({editor:t.editor}),d=({editor:h})=>{const{from:p,to:m}=h.state.selection;if(p===m)return!1;let g=!1;return h.state.doc.nodesBetween(p,m,y=>{y.marks&&y.marks.forEach(v=>{v.type.name==="highlight"&&v.attrs.color==="yellow"&&(g=!0)})}),!g};return S.jsxs(VT,{...n,shouldShow:d,className:"hidden lg:flex gap-2 overflow-hidden rounded-[12px] h-[52px] min-w-[550px] w-full py-2 px-4 bg-white items-center shadow-lg",children:[S.jsx(fV,{editor:t.editor,isOpen:r,setIsOpen:()=>{s(!r),o(!1)}}),e.map((h,p)=>S.jsxs("div",{className:"flex items-center",children:[S.jsx("button",{onClick:h.command,className:he("min-w-fit w-8 h-8 px-2 rounded",{"bg-yellow-300":h.isActive()}),children:h.icon}),(p===4||p===6)&&S.jsx("div",{className:"w-1.5 h-4 bg-gray-300 mx-2"})]},p)),S.jsx(dV,{editor:t.editor,isOpen:i,setIsOpen:()=>{o(!i),s(!1)}}),S.jsx("button",{onClick:()=>c(Me.HIGHLIGHT),className:he("min-w-fit w-8 h-8 px-2",{"bg-yellow-300":f===Me.HIGHLIGHT}),children:S.jsx(QT,{size:20})}),f===Me.ALIGNMENT&&S.jsx(ID,{setToolVisibility:c,editor:t.editor,elementRef:u}),a&&S.jsx(LD,{setToolVisibility:c,editor:t.editor,elementRef:u,bubbleMenu:!0,setIsLinkPopupOpen:l}),f===Me.HIGHLIGHT&&S.jsx(PD,{setVisibility:c,editor:t.editor,elementRef:u})]})};function s$(){const t=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let n=0;n<36;n++)n===8||n===13||n===18||n===23?e[n]="-":e[n]=t[Math.ceil(Math.random()*t.length-1)];return e.join("")}var i$=s$;const o$=Np(i$),BD=Ye.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:t=>t.getAttribute("data-position"),renderHTML:t=>({"data-position":t.position})}}},renderHTML({HTMLAttributes:t}){return["div",rt(t,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),a$=(t,e)=>Array.from({length:t},(n,r)=>e(r)),Q0=({type:t,content:e})=>e?{type:t,content:e}:{type:t},l$=({content:t})=>Q0({type:"paragraph",content:t}),FD=({content:t})=>Q0({type:"dBlock",content:t}),jD=({content:t})=>Q0({type:"column",content:t}),UD=({content:t})=>Q0({type:"columns",content:t}),VD=t=>{const e=[FD({content:[l$({})]})];return a$(t,()=>jD({content:e}))},HD=(t,e)=>{for(let n=t.depth;n>0;n--){const r=t.node(n),s=n>0?t.before(n):0,i=t.start(n);if(e({node:r,pos:s,start:i}))return{start:i,depth:n,node:r,pos:s}}throw Error("no ancestor found")};class J0 extends Pe{constructor(n){const{$from:r,$to:s}=n;super(r,s);W(this,"_$from");W(this,"_$to");this._$from=r,this._$to=s}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(n){return n instanceof J0&&n.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(n){var l;const r=({pos:u,node:c})=>c.type.name===BD.name?!0:n.resolve(u).depth<=0,{pos:s}=HD(this.$from,r);this._$from=n.resolve(s);const{pos:i,node:o}=HD(this.$to,r);this._$to=n.resolve(i+o.nodeSize),((l=this.getFirstNode())==null?void 0:l.type.name)===Y0.name&&(this._$from=n.resolve(this.$from.pos+2),this._$to=n.resolve(this.$to.pos+2));const a=this;a.$anchor=this._$from,a.$head=this._$to,a.ranges=[new Rb(this._$from,this._$to)]}static create(n,r,s){const i=n.resolve(r),o=n.resolve(s),a=new _e(i,o);return new J0(a)}getFirstNode(){return this.content().content.firstChild}}var il=(t=>(t.AlignLeft="align-left",t.AlignRight="align-right",t.AlignCenter="align-center",t))(il||{});const Y0=Ye.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:t,dispatch:e})=>{try{if(!e)return;const n=t.selection.$from,s=b1(n,({node:l})=>!this.options.nestedColumns&&l.type==this.type?!0:l.type==this.type);if(s===void 0)return;let i=[];s.node.descendants((l,u,c)=>{(c==null?void 0:c.type.name)===Y0.name&&i.push(l)}),i=i.reverse().filter(l=>l.content.size>0);const o=t.doc.resolve(s.pos),a=new De(o);return t=t.setSelection(a),i.forEach(l=>t=t.insert(s.pos,l)),t=t.deleteSelection(),e(t)}catch(n){console.error(n)}},setColumns:(t,e=!1)=>({tr:n,dispatch:r})=>{try{const{doc:s,selection:i}=n;if(!r){console.log("no dispatch");return}const o=new J0(i);o.expandSelection(s);const{openStart:a,openEnd:l}=o.content();if(a!==l){console.warn("failed depth check");return}let u;if(e){const h=o.content().toJSON(),p=jD(h),m=VD(t-1);u=UD({content:[p,...m]})}else{const h=VD(t);u=UD({content:h})}const c=s.type.schema.nodeFromJSON(FD({content:[u]}));if(c===null)return;const f=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===Y0.name))(f)){console.warn("content not allowed");return}return n=n.setSelection(o),n=n.replaceSelectionWith(c,!1),r(n)}catch(s){console.error(s)}},setLayout:t=>({commands:e})=>e.updateAttributes("columns",{layout:t})}},renderHTML({HTMLAttributes:t}){return["div",{"data-type":"columns",class:`layout-${t.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),u$=(t,e)=>{const{view:n,state:{selection:{from:r}}}=t,s=document.querySelectorAll(".has-focus"),i=s.length,a=s[i-1];if(a&&a.getAttribute("data-type")&&a.getAttribute("data-type")===e||a&&a.classList&&a.classList.contains(e))return a;const l=n.domAtPos(r).node;let u=l;for(u.tagName||(u=l.parentElement);u&&!(u.getAttribute("data-type")&&u.getAttribute("data-type")===e)&&!u.classList.contains(e);)u=u.parentElement;return u},Qw=N.forwardRef(({children:t,className:e,withShadow:n=!0,withBorder:r=!1,...s},i)=>{const o=he(e,"bg-white rounded",n?"shadow-lg":"",r?"border border-neutral-200":"");return S.jsx("div",{className:o,...s,ref:i,children:t})});Qw.displayName="Surface";const zD=({content:t,children:e})=>{const[n,r]=N.useState(!1);return S.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,n&&S.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:t})]})},$D=N.forwardRef(({shouldShowContent:t=!0,children:e,isVertical:n=!1,className:r,...s},i)=>{const o=he("text-black inline-flex h-full leading-none gap-0.5",n?"flex-col p-2":"flex-row p-1 items-center",r);return t?t&&S.jsx(Qw,{className:o,...s,ref:i,children:e}):null});$D.displayName="Toolbar";const GD=N.forwardRef(({horizontal:t,className:e,...n},r)=>{const s=he("bg-neutral-200",t?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return S.jsx("div",{className:s,ref:r,...n})});GD.displayName="Toolbar.Divider";const WD=N.forwardRef(({children:t,buttonSize:e="icon",variant:n="ghost",className:r,tooltip:s,activeClassname:i,...o},a)=>{const l=he("gap-1 min-w-[2rem] px-2 w-auto",r),u=S.jsx(sl,{activeClassname:i,className:l,variant:n,buttonSize:e,ref:a,...o,children:t});return s?S.jsx(zD,{content:s,children:u}):u});WD.displayName="ToolbarButton";const Wu={Wrapper:$D,Divider:GD,Button:WD},c$=({editor:t,appendTo:e})=>{const n=N.useCallback(()=>{const l=u$(t,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[t]),r=N.useCallback(()=>t.isActive("columns"),[t]),s=N.useCallback(()=>{t.chain().focus().setLayout(il.AlignLeft).run()},[t]),i=N.useCallback(()=>{t.chain().focus().setLayout(il.AlignRight).run()},[t]),o=N.useCallback(()=>{t.chain().focus().setLayout(il.AlignCenter).run()},[t]),a=N.useCallback(()=>{t.chain().focus().deleteNode("columns").run()},[t]);return S.jsx(VT,{editor:t,pluginKey:`columnsMenu-${o$()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:n,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[kU],sticky:"popper"},children:S.jsxs(Wu.Wrapper,{children:[S.jsx(Wu.Button,{tooltip:"Align left",active:t.isActive("columns",{layout:il.AlignLeft}),activeClassname:"bg-yellow-300 hover:brightness-90",onClick:s,children:S.jsx(rV,{size:20})}),S.jsx(Wu.Button,{tooltip:"Align center",active:t.isActive("columns",{layout:il.AlignCenter}),activeClassname:"bg-yellow-300 hover:brightness-90",onClick:o,children:S.jsx(qT,{size:20})}),S.jsx(Wu.Button,{tooltip:"Align right",active:t.isActive("columns",{layout:il.AlignRight}),activeClassname:"bg-yellow-300 hover:brightness-90",onClick:i,children:S.jsx(sV,{size:20})}),S.jsx(Wu.Button,{tooltip:"Remove column",onClick:a,children:S.jsx(ow,{size:20})})]})})},KD=N.createContext(null),X0=()=>N.useContext(KD),f$=({children:t,isPreviewMode:e})=>S.jsx(KD.Provider,{value:e,children:t}),qD=({height:t,width:e})=>S.jsx("span",{className:"flex items-center justify-center ",children:S.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${t?`h-${t}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),d$=({editor:t,onError:e})=>{var o;const{toolRef:n,toolVisibilty:r,setToolVisibility:s,toolbar:i}=qw({editor:t,onError:e});return S.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center relative",children:[S.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>s(Me.FONT_FAMILY),children:[S.jsx("span",{className:"text-sm",children:((o=RD.find(a=>t==null?void 0:t.isActive("textStyle",{fontFamily:a.value})))==null?void 0:o.title)||"Font"}),S.jsx(E0,{size:16})]}),S.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),S.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>s(Me.HEADING),children:[S.jsx("span",{className:"text-sm",children:t!=null&&t.isActive("heading",{level:1})?"Heading 1":t!=null&&t.isActive("heading",{level:2})?"Heading 2":t!=null&&t.isActive("heading",{level:3})?"Heading 3":"Text"}),S.jsx(E0,{size:16})]}),S.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),i.map((a,l)=>a?S.jsx("div",{className:"tooltip tooltip-neutral tooltip-bottom text-xs","data-tip":a.title,children:S.jsx("span",{onClick:()=>a.onClick(),className:he("rounded w-8 h-8 p-1 flex cursor-pointer justify-center items-center transition",a.isActive?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:typeof a.icon=="string"?S.jsx("img",{src:a.icon,className:"w-4"}):a.icon})},a.title):S.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"},l)),r===Me.FONT_FAMILY&&S.jsx(Xz,{setToolVisibility:s,editor:t,elementRef:n}),r===Me.HEADING&&S.jsx(t$,{setVisibility:s,editor:t,elementRef:n}),r===Me.TEXT_COLOR&&S.jsx(e$,{setVisibility:s,editor:t,elementRef:n}),r===Me.HIGHLIGHT&&S.jsx(PD,{setVisibility:s,editor:t,elementRef:n}),r===Me.ALIGNMENT&&S.jsx(ID,{setToolVisibility:s,editor:t,elementRef:n}),r===Me.LIST&&S.jsx(Zz,{setToolVisibility:s,editor:t,elementRef:n}),r===Me.LINK&&S.jsx(LD,{setToolVisibility:s,editor:t,elementRef:n})]})},zn=()=>new Map,Jw=t=>{const e=zn();return t.forEach((n,r)=>{e.set(r,n)}),e},or=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},h$=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},p$=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Oi=()=>new Set,Yw=t=>t[t.length-1],m$=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},_i=Array.from,g$=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Xw=Array.isArray;class Zw{constructor(){this._observers=zn()}on(e,n){return or(this._observers,e,Oi).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return _i((this._observers.get(e)||zn()).values()).forEach(r=>r(...n))}destroy(){this._observers=zn()}}class QD{constructor(){this._observers=zn()}on(e,n){or(this._observers,e,Oi).add(n)}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return _i((this._observers.get(e)||zn()).values()).forEach(r=>r(...n))}destroy(){this._observers=zn()}}const gs=Math.floor,Z0=Math.abs,y$=Math.log10,Lo=(t,e)=>t<e?t:e,Mi=(t,e)=>t>e?t:e,JD=t=>t!==0?t<0:1/t<0,$s=Date.now,b$=1200,w$=2500,em=3e4,eA=t=>{if(t.shouldConnect&&t.ws===null){const e=new WebSocket(t.url),n=t.binaryType;let r=null;n&&(e.binaryType=n),t.ws=e,t.connecting=!0,t.connected=!1,e.onmessage=o=>{t.lastMessageReceived=$s();const a=o.data,l=typeof a=="string"?JSON.parse(a):a;l&&l.type==="pong"&&(clearTimeout(r),r=setTimeout(i,em/2)),t.emit("message",[l,t])};const s=o=>{t.ws!==null&&(t.ws=null,t.connecting=!1,t.connected?(t.connected=!1,t.emit("disconnect",[{type:"disconnect",error:o},t])):t.unsuccessfulReconnects++,setTimeout(eA,Lo(y$(t.unsuccessfulReconnects+1)*b$,w$),t)),clearTimeout(r)},i=()=>{t.ws===e&&t.send({type:"ping"})};e.onclose=()=>s(null),e.onerror=o=>s(o),e.onopen=()=>{t.lastMessageReceived=$s(),t.connecting=!1,t.connected=!0,t.unsuccessfulReconnects=0,t.emit("connect",[{type:"connect"},t]),r=setTimeout(i,em/2)}}};class A$ extends QD{constructor(e,{binaryType:n}={}){super(),this.url=e,this.ws=null,this.binaryType=n||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&em<$s()-this.lastMessageReceived&&this.ws.close()},em/2),eA(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&eA(this)}}const Gs=t=>new Error(t),ys=()=>{throw Gs("Method unimplemented")},Sr=()=>{throw Gs("Unexpected case")},YD=1,XD=2,tA=4,nA=8,Hd=32,Ni=64,Tr=128,tm=31,rA=63,ol=127,v$=2147483647,x$=crypto.getRandomValues.bind(crypto),ZD=Math.random,eO=()=>x$(new Uint32Array(1))[0],k$=t=>t[gs(ZD()*t.length)],E$="10000000-1000-4000-8000"+-1e11,tO=()=>E$.replace(/[018]/g,t=>(t^eO()&15>>t/4).toString(16)),nO=Number.MAX_SAFE_INTEGER,C$=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&gs(t)===t),S$=String.fromCharCode,T$=t=>t.toLowerCase(),D$=/^\s*/g,O$=t=>t.replace(D$,""),_$=/([A-Z])/g,rO=(t,e)=>O$(t.replace(_$,n=>`${e}${T$(n)}`)),M$=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},zd=typeof TextEncoder<"u"?new TextEncoder:null,sA=zd?t=>zd.encode(t):M$;let $d=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});$d&&$d.decode(new Uint8Array).length===1&&($d=null);class Gd{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const un=()=>new Gd,N$=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Rt=t=>{const e=new Uint8Array(N$(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},R$=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Mi(n,e)*2),t.cpos=0)},cn=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Wd=cn,Ne=(t,e)=>{for(;e>ol;)cn(t,Tr|ol&e),e=gs(e/128);cn(t,ol&e)},iA=(t,e)=>{const n=JD(e);for(n&&(e=-e),cn(t,(e>rA?Tr:0)|(n?Ni:0)|rA&e),e=gs(e/64);e>0;)cn(t,(e>ol?Tr:0)|ol&e),e=gs(e/128)},oA=new Uint8Array(3e4),P$=oA.length/3,I$=(t,e)=>{if(e.length<P$){const n=zd.encodeInto(e,oA).written||0;Ne(t,n);for(let r=0;r<n;r++)cn(t,oA[r])}else jt(t,sA(e))},L$=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Ne(t,r);for(let s=0;s<r;s++)cn(t,n.codePointAt(s))},Ws=zd&&zd.encodeInto?I$:L$,nm=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Lo(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Mi(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},jt=(t,e)=>{Ne(t,e.byteLength),nm(t,e)},aA=(t,e)=>{R$(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},B$=(t,e)=>aA(t,4).setFloat32(0,e,!1),F$=(t,e)=>aA(t,8).setFloat64(0,e,!1),j$=(t,e)=>aA(t,8).setBigInt64(0,e,!1),sO=new DataView(new ArrayBuffer(4)),U$=t=>(sO.setFloat32(0,t),sO.getFloat32(0)===t),Ku=(t,e)=>{switch(typeof e){case"string":cn(t,119),Ws(t,e);break;case"number":C$(e)&&Z0(e)<=v$?(cn(t,125),iA(t,e)):U$(e)?(cn(t,124),B$(t,e)):(cn(t,123),F$(t,e));break;case"bigint":cn(t,122),j$(t,e);break;case"object":if(e===null)cn(t,126);else if(Xw(e)){cn(t,117),Ne(t,e.length);for(let n=0;n<e.length;n++)Ku(t,e[n])}else if(e instanceof Uint8Array)cn(t,116),jt(t,e);else{cn(t,118);const n=Object.keys(e);Ne(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];Ws(t,s),Ku(t,e[s])}}break;case"boolean":cn(t,e?120:121);break;default:cn(t,127)}};class iO extends Gd{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Ne(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const oO=t=>{t.count>0&&(iA(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ne(t.encoder,t.count-2))};class rm{constructor(){this.encoder=new Gd,this.s=0,this.count=0}write(e){this.s===e?this.count++:(oO(this),this.count=1,this.s=e)}toUint8Array(){return oO(this),Rt(this.encoder)}}const aO=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);iA(t.encoder,e),t.count>1&&Ne(t.encoder,t.count-2)}};class lA{constructor(){this.encoder=new Gd,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(aO(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return aO(this),Rt(this.encoder)}}class V${constructor(){this.sarr=[],this.s="",this.lensE=new rm}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Gd;return this.sarr.push(this.s),this.s="",Ws(e,this.sarr.join("")),nm(e,this.lensE.toUint8Array()),Rt(e)}}const lO=Gs("Unexpected end of array"),uO=Gs("Integer out of Range");class sm{constructor(e){this.arr=e,this.pos=0}}const Ks=t=>new sm(t),H$=t=>t.pos!==t.arr.length,z$=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},fn=t=>z$(t,We(t)),al=t=>t.arr[t.pos++],We=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&ol)*n,n*=128,s<Tr)return e;if(e>nO)throw uO}throw lO},uA=t=>{let e=t.arr[t.pos++],n=e&rA,r=64;const s=(e&Ni)>0?-1:1;if(!(e&Tr))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&ol)*r,r*=128,e<Tr)return s*n;if(n>nO)throw uO}throw lO},Ri=$d?t=>$d.decode(fn(t)):t=>{let e=We(t);if(e===0)return"";{let n=String.fromCodePoint(al(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(al(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},cA=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},$$=[t=>{},t=>null,uA,t=>cA(t,4).getFloat32(0,!1),t=>cA(t,8).getFloat64(0,!1),t=>cA(t,8).getBigInt64(0,!1),t=>!1,t=>!0,Ri,t=>{const e=We(t),n={};for(let r=0;r<e;r++){const s=Ri(t);n[s]=qu(t)}return n},t=>{const e=We(t),n=[];for(let r=0;r<e;r++)n.push(qu(t));return n},fn],qu=t=>$$[127-al(t)](t);class cO extends sm{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),H$(this)?this.count=We(this)+1:this.count=-1),this.count--,this.s}}class im extends sm{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=uA(this);const e=JD(this.s);this.count=1,e&&(this.s=-this.s,this.count=We(this)+2)}return this.count--,this.s}}class fA extends sm{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=uA(this),n=e&1;this.diff=gs(e/2),this.count=1,n&&(this.count=We(this)+2)}return this.s+=this.diff,this.count--,this.s}}class G${constructor(e){this.decoder=new im(e),this.str=Ri(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const fO=t=>t===void 0?null:t;class W${constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let dO=new W$,dA=!0;try{typeof localStorage<"u"&&localStorage&&(dO=localStorage,dA=!1)}catch{}const hO=dO,K$=t=>dA||addEventListener("storage",t),q$=t=>dA||removeEventListener("storage",t),Q$=Object.assign,hA=Object.keys,J$=(t,e)=>{for(const n in t)e(t[n],n)},pO=t=>hA(t).length,mO=t=>hA(t).length,Y$=t=>{for(const e in t)return!1;return!0},X$=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},gO=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Z$=(t,e)=>t===e||mO(t)===mO(e)&&X$(t,(n,r)=>(n!==void 0||gO(e,r))&&e[r]===n),pA=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&pA(t,e,n+1)}},eG=()=>{},tG=t=>t,nG=(t,e)=>t===e,Kd=(t,e)=>{if(t==null||e==null)return nG(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Kd(t.get(n),e.get(n)))return!1;break}case Object:if(pO(t)!==pO(e))return!1;for(const n in t)if(!gO(t,n)||!Kd(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Kd(t[n],e[n]))return!1;break;default:return!1}return!0},rG=(t,e)=>e.includes(t),Qu=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",mA=typeof window<"u"&&typeof document<"u"&&!Qu;let qs;const sG=()=>{if(qs===void 0)if(Qu){qs=zn();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&qs.set(e,""),e=r):e!==null&&(qs.set(e,r),e=null)}e!==null&&qs.set(e,"")}else typeof location=="object"?(qs=zn(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");qs.set(`--${rO(e,"-")}`,n),qs.set(`-${rO(e,"-")}`,n)}})):qs=zn();return qs},gA=t=>sG().has(t),om=t=>fO(Qu?process.env[t.toUpperCase().replaceAll("-","_")]:hO.getItem(t));(t=>gA("--"+t)||om(t)!==null)("production");const yO=Qu&&rG(process.env.FORCE_COLOR,["true","1","2"]),iG=!gA("--no-colors")&&(!Qu||process.stdout.isTTY||yO)&&(!Qu||gA("--color")||yO||om("COLORTERM")!==null||(om("TERM")||"").includes("color"));class oG{constructor(e,n){this.left=e,this.right=n}}const Pi=(t,e)=>new oG(t,e),aG=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const lG=t=>h$(t,(e,n)=>`${n}:${e};`).join(""),uG=JSON.stringify,cG=(t=>class{constructor(n){this._=n}destroy(){t(this._)}})(clearTimeout),yA=(t,e)=>new cG(setTimeout(e,t)),Ii=Symbol,Wr=Ii(),ll=Ii(),bO=Ii(),bA=Ii(),wO=Ii(),AO=Ii(),vO=Ii(),am=Ii(),lm=Ii(),fG=t=>{var r;t.length===1&&((r=t[0])==null?void 0:r.constructor)===Function&&(t=t[0]());const e=[];let n=0;for(;n<t.length;n++){const s=t[n];s===void 0||s.constructor===String||s.constructor===Number||s.constructor===Object&&e.push(JSON.stringify(s))}return e},xO=[wO,vO,am,bO];let wA=0,kO=$s();const dG=(t,e)=>{const n=xO[wA],r=om("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return wA=(wA+1)%xO.length,e+=": ",s?(...i)=>{var l;i.length===1&&((l=i[0])==null?void 0:l.constructor)===Function&&(i=i[0]());const o=$s(),a=o-kO;kO=o,t(n,e,lm,...i.map(u=>{switch(u!=null&&u.constructor===Uint8Array&&(u=Array.from(u)),typeof u){case"string":case"symbol":return u;default:return uG(u)}}),n," +"+a+"ms")}:eG},hG={[Wr]:Pi("font-weight","bold"),[ll]:Pi("font-weight","normal"),[bO]:Pi("color","blue"),[wO]:Pi("color","green"),[bA]:Pi("color","grey"),[AO]:Pi("color","red"),[vO]:Pi("color","purple"),[am]:Pi("color","orange"),[lm]:Pi("color","black")},EO=iG?t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=zn();let s=[],i=0;for(;i<t.length;i++){const a=t[i],l=hG[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const u=lG(r);i>0||u.length>0?(e.push("%c"+a),n.push(u)):e.push(a)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const a=t[i];a instanceof Symbol||s.push(a)}return s}:fG,CO=(...t)=>{console.log(...EO(t)),SO.forEach(e=>e.print(t))},pG=(...t)=>{console.warn(...EO(t)),t.unshift(am),SO.forEach(e=>e.print(t))},SO=Oi(),mG=t=>dG(CO,t),TO=t=>new Promise(t);Promise.all.bind(Promise);const gG=t=>Promise.reject(t),AA=t=>Promise.resolve(t),DO=t=>new Uint8Array(t),yG=(t,e,n)=>new Uint8Array(t,e,n),bG=t=>new Uint8Array(t),wG=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=S$(t[n]);return btoa(e)},AG=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),vG=t=>{const e=atob(t),n=DO(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},xG=t=>{const e=Buffer.from(t,"base64");return yG(e.buffer,e.byteOffset,e.byteLength)},OO=mA?wG:AG,_O=mA?vG:xG,kG=t=>{const e=DO(t.byteLength);return e.set(t),e},MO=new Map;class EG{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:_O(n.newValue||"")}),K$(this._onChange)}postMessage(e){hO.setItem(this.room,OO(bG(e)))}close(){q$(this._onChange)}}const CG=typeof BroadcastChannel>"u"?EG:BroadcastChannel,vA=t=>or(MO,t,()=>{const e=Oi(),n=new CG(t);return n.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:n,subs:e}}),SG=(t,e)=>(vA(t).subs.add(e),e),TG=(t,e)=>{const n=vA(t),r=n.subs.delete(e);return r&&n.subs.size===0&&(n.bc.close(),MO.delete(t)),r},DG=(t,e,n=null)=>{const r=vA(t);r.bc.postMessage(e),r.subs.forEach(s=>s(e,n))},NO=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},RO=t=>({[Symbol.iterator](){return this},next:t}),OG=(t,e)=>RO(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),xA=(t,e)=>RO(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class kA{constructor(e,n){this.clock=e,this.len=n}}class Ju{constructor(){this.clients=new Map}}const Bo=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);for(let o=0;o<r.length;o++){const a=r[o];ZO(t,i,a.clock,a.len,n)}}),_G=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=gs((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Yu=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&_G(n,e.clock)!==null},EA=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?s.len=Mi(s.len,i.clock+i.len-s.clock):(r<n&&(e[r]=i),r++)}e.length=r})},CA=t=>{const e=new Ju;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)m$(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return EA(e),e},qd=(t,e,n,r)=>{or(t.clients,e,()=>[]).push(new kA(n,r))},PO=()=>new Ju,IO=t=>{const e=PO();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const a=o.id.clock;let l=o.length;if(i+1<n.length)for(let u=n[i+1];i+1<n.length&&u.deleted;u=n[++i+1])l+=u.length;s.push(new kA(a,l))}}s.length>0&&e.clients.set(r,s)}),e},Xu=(t,e)=>{Ne(t.restEncoder,e.clients.size),_i(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Ne(t.restEncoder,n);const s=r.length;Ne(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},SA=t=>{const e=new Ju,n=We(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=We(t.restDecoder),i=We(t.restDecoder);if(i>0){const o=or(e.clients,s,()=>[]);for(let a=0;a<i;a++)o.push(new kA(t.readDsClock(),t.readDsLen()))}}return e},LO=(t,e,n)=>{const r=new Ju,s=We(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=We(t.restDecoder),a=We(t.restDecoder),l=n.clients.get(o)||[],u=zt(n,o);for(let c=0;c<a;c++){const f=t.readDsClock(),d=f+t.readDsLen();if(f<u){u<d&&qd(r,o,u,d-u);let h=Qs(l,f),p=l[h];for(!p.deleted&&p.id.clock<f&&(l.splice(h+1,0,xm(e,p,f-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(h,0,xm(e,p,d-p.id.clock)),p.delete(e))}else qd(r,o,f,d-f)}}if(r.clients.size>0){const i=new cl;return Ne(i.restEncoder,0),Xu(i,r),i.toUint8Array()}return null},BO=eO;class ul extends Zw{constructor({guid:e=tO(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=BO(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new JO,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=TO(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});const l=()=>TO(u=>{const c=f=>{(f===void 0||f===!0)&&(this.off("sync",c),u())};this.on("sync",c)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&vt(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(_i(this.subdocs).map(e=>e.guid))}transact(e,n=null){return vt(this,e,n)}get(e,n=kn){const r=or(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==kn&&s!==n)if(s===kn){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,rc)}getText(e=""){return this.get(e,dl)}getMap(e=""){return this.get(e,sc)}getXmlElement(e=""){return this.get(e,$n)}getXmlFragment(e=""){return this.get(e,hl)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){_i(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new ul({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,vt(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class FO{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return We(this.restDecoder)}readDsLen(){return We(this.restDecoder)}}class jO extends FO{readLeftID(){return Ke(We(this.restDecoder),We(this.restDecoder))}readRightID(){return Ke(We(this.restDecoder),We(this.restDecoder))}readClient(){return We(this.restDecoder)}readInfo(){return al(this.restDecoder)}readString(){return Ri(this.restDecoder)}readParentInfo(){return We(this.restDecoder)===1}readTypeRef(){return We(this.restDecoder)}readLen(){return We(this.restDecoder)}readAny(){return qu(this.restDecoder)}readBuf(){return kG(fn(this.restDecoder))}readJSON(){return JSON.parse(Ri(this.restDecoder))}readKey(){return Ri(this.restDecoder)}}class MG{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=We(this.restDecoder),this.dsCurrVal}readDsLen(){const e=We(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Zu extends MG{constructor(e){super(e),this.keys=[],We(e),this.keyClockDecoder=new fA(fn(e)),this.clientDecoder=new im(fn(e)),this.leftClockDecoder=new fA(fn(e)),this.rightClockDecoder=new fA(fn(e)),this.infoDecoder=new cO(fn(e),al),this.stringDecoder=new G$(fn(e)),this.parentInfoDecoder=new cO(fn(e),al),this.typeRefDecoder=new im(fn(e)),this.lenDecoder=new im(fn(e))}readLeftID(){return new ec(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ec(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return qu(this.restDecoder)}readBuf(){return fn(this.restDecoder)}readJSON(){return qu(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class UO{constructor(){this.restEncoder=un()}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Ne(this.restEncoder,e)}writeDsLen(e){Ne(this.restEncoder,e)}}class Qd extends UO{writeLeftID(e){Ne(this.restEncoder,e.client),Ne(this.restEncoder,e.clock)}writeRightID(e){Ne(this.restEncoder,e.client),Ne(this.restEncoder,e.clock)}writeClient(e){Ne(this.restEncoder,e)}writeInfo(e){Wd(this.restEncoder,e)}writeString(e){Ws(this.restEncoder,e)}writeParentInfo(e){Ne(this.restEncoder,e?1:0)}writeTypeRef(e){Ne(this.restEncoder,e)}writeLen(e){Ne(this.restEncoder,e)}writeAny(e){Ku(this.restEncoder,e)}writeBuf(e){jt(this.restEncoder,e)}writeJSON(e){Ws(this.restEncoder,JSON.stringify(e))}writeKey(e){Ws(this.restEncoder,e)}}class VO{constructor(){this.restEncoder=un(),this.dsCurrVal=0}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Ne(this.restEncoder,n)}writeDsLen(e){e===0&&Sr(),Ne(this.restEncoder,e-1),this.dsCurrVal+=e}}class cl extends VO{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new lA,this.clientEncoder=new rm,this.leftClockEncoder=new lA,this.rightClockEncoder=new lA,this.infoEncoder=new iO(Wd),this.stringEncoder=new V$,this.parentInfoEncoder=new iO(Wd),this.typeRefEncoder=new rm,this.lenEncoder=new rm}toUint8Array(){const e=un();return Ne(e,0),jt(e,this.keyClockEncoder.toUint8Array()),jt(e,this.clientEncoder.toUint8Array()),jt(e,this.leftClockEncoder.toUint8Array()),jt(e,this.rightClockEncoder.toUint8Array()),jt(e,Rt(this.infoEncoder)),jt(e,this.stringEncoder.toUint8Array()),jt(e,Rt(this.parentInfoEncoder)),jt(e,this.typeRefEncoder.toUint8Array()),jt(e,this.lenEncoder.toUint8Array()),nm(e,Rt(this.restEncoder)),Rt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ku(this.restEncoder,e)}writeBuf(e){jt(this.restEncoder,e)}writeJSON(e){Ku(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const NG=(t,e,n,r)=>{r=Mi(r,e[0].id.clock);const s=Qs(e,r);Ne(t.restEncoder,e.length-s),t.writeClient(n),Ne(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},TA=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{zt(e,i)>s&&r.set(i,s)}),eh(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),Ne(t.restEncoder,r.size),_i(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{NG(t,e.clients.get(s),s,i)})},RG=(t,e)=>{const n=zn(),r=We(t.restDecoder);for(let s=0;s<r;s++){const i=We(t.restDecoder),o=new Array(i),a=t.readClient();let l=We(t.restDecoder);n.set(a,{i:0,refs:o});for(let u=0;u<i;u++){const c=t.readInfo();switch(tm&c){case 0:{const f=t.readLen();o[u]=new Kr(Ke(a,l),f),l+=f;break}case 10:{const f=We(t.restDecoder);o[u]=new qr(Ke(a,l),f),l+=f;break}default:{const f=(c&(Ni|Tr))===0,d=new Et(Ke(a,l),null,(c&Tr)===Tr?t.readLeftID():null,null,(c&Ni)===Ni?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(c&Hd)===Hd?t.readString():null,__(t,c));o[u]=d,l+=d.length}}}}return n},PG=(t,e,n)=>{const r=[];let s=_i(n.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=n.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=n.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const a=new JO,l=new Map,u=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let c=o.refs[o.i++];const f=new Map,d=()=>{for(const h of r){const p=h.id.client,m=n.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),s=s.filter(g=>g!==p)}r.length=0};for(;;){if(c.constructor!==qr){const p=or(f,c.id.client,()=>zt(e,c.id.client))-c.id.clock;if(p<0)r.push(c),u(c.id.client,c.id.clock-1),d();else{const m=c.getMissing(t,e);if(m!==null){r.push(c);const g=n.get(m)||{refs:[],i:0};if(g.refs.length===g.i)u(m,zt(e,m)),d();else{c=g.refs[g.i++];continue}}else(p===0||p<c.length)&&(c.integrate(t,p),f.set(c.id.client,c.id.clock+c.length))}}if(r.length>0)c=r.pop();else if(o!==null&&o.i<o.refs.length)c=o.refs[o.i++];else{if(o=i(),o===null)break;c=o.refs[o.i++]}}if(a.clients.size>0){const h=new cl;return TA(h,a,new Map),Ne(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},IG=(t,e)=>TA(t,e.doc.store,e.beforeState),LG=(t,e,n,r=new Zu(t))=>vt(e,s=>{s.local=!1;let i=!1;const o=s.doc,a=o.store,l=RG(r,o),u=PG(s,a,l),c=a.pendingStructs;if(c){for(const[d,h]of c.missing)if(h<zt(a,d)){i=!0;break}if(u){for(const[d,h]of u.missing){const p=c.missing.get(d);(p==null||p>h)&&c.missing.set(d,h)}c.update=dm([c.update,u.update])}}else a.pendingStructs=u;const f=LO(r,s,a);if(a.pendingDs){const d=new Zu(Ks(a.pendingDs));We(d.restDecoder);const h=LO(d,s,a);f&&h?a.pendingDs=dm([f,h]):a.pendingDs=f||h}else a.pendingDs=f;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,um(s.doc,d)}},n,!1),um=(t,e,n,r=Zu)=>{const s=Ks(e);LG(s,t,n,new r(s))},BG=(t,e,n)=>um(t,e,n,jO),FG=(t,e,n=new Map)=>{TA(t,e.store,n),Xu(t,IO(e.store))},jG=(t,e=new Uint8Array([0]),n=new cl)=>{const r=HO(e);FG(n,t,r);const s=[n.toUint8Array()];if(t.store.pendingDs&&s.push(t.store.pendingDs),t.store.pendingStructs&&s.push(rW(t.store.pendingStructs.update,e)),s.length>1){if(n.constructor===Qd)return tW(s.map((i,o)=>o===0?i:iW(i)));if(n.constructor===cl)return dm(s)}return s[0]},UG=(t,e)=>jG(t,e,new Qd),VG=t=>{const e=new Map,n=We(t.restDecoder);for(let r=0;r<n;r++){const s=We(t.restDecoder),i=We(t.restDecoder);e.set(s,i)}return e},HO=t=>VG(new FO(Ks(t))),zO=(t,e)=>(Ne(t.restEncoder,e.size),_i(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Ne(t.restEncoder,n),Ne(t.restEncoder,r)}),t),HG=(t,e)=>zO(t,eh(e.store)),zG=(t,e=new VO)=>(t instanceof Map?zO(e,t):HG(e,t),e.toUint8Array()),$G=t=>zG(t,new UO);class GG{constructor(){this.l=[]}}const $O=()=>new GG,GO=(t,e)=>t.l.push(e),WO=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},KO=(t,e,n)=>pA(t.l,[e,n]);class ec{constructor(e,n){this.client=e,this.clock=n}}const tc=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Ke=(t,e)=>new ec(t,e),Jd=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Sr()},Yd=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Xd{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}const Zd=t=>new Xd(t.type==null?null:Ke(t.type.client,t.type.clock),t.tname??null,t.item==null?null:Ke(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class WG{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const KG=(t,e,n=0)=>new WG(t,e,n),cm=(t,e,n)=>{let r=null,s=null;return t._item===null?s=Jd(t):r=Ke(t._item.id.client,t._item.id.clock),new Xd(r,s,e,n)},DA=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return cm(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return cm(t,Ke(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return cm(t,r.lastId,n);r=r.right}return cm(t,null,n)},qG=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,a=t.assoc;let l=null,u=0;if(s!==null){if(zt(r,s.client)<=s.clock)return null;const c=n?zA(r,s):{item:nc(r,s),diff:0},f=c.item;if(!(f instanceof Et))return null;if(l=f.parent,l._item===null||!l._item.deleted){u=f.deleted||!f.countable?0:c.diff+(a>=0?0:1);let d=f.left;for(;d!==null;)!d.deleted&&d.countable&&(u+=d.length),d=d.left}}else{if(o!==null)l=e.get(o);else if(i!==null){if(zt(r,i.client)<=i.clock)return null;const{item:c}=n?zA(r,i):{item:nc(r,i)};if(c instanceof Et&&c.content instanceof ws)l=c.content.type;else return null}else throw Sr();a>=0?u=l._length:u=0}return KG(l,u,t.assoc)},qO=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&tc(t.item,e.item)&&tc(t.type,e.type)&&t.assoc===e.assoc;class OA{constructor(e,n){this.ds=e,this.sv=n}}const QO=(t,e)=>new OA(t,e),_A=t=>QO(IO(t.store),eh(t.store)),fl=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Yu(e.ds,t.id),MA=(t,e)=>{const n=or(t.meta,MA,Oi),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<zt(r,i)&&ar(t,Ke(i,s))}),Bo(t,e.ds,s=>{}),n.add(e))};class JO{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const eh=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},zt=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},YO=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Sr()}n.push(e)},Qs=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=gs(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=gs((n+r)/2)}throw Sr()},nc=(t,e)=>{const n=t.clients.get(e.client);return n[Qs(n,e.clock)]},NA=(t,e,n)=>{const r=Qs(e,n),s=e[r];return s.id.clock<n&&s instanceof Et?(e.splice(r+1,0,xm(t,s,n-s.id.clock)),r+1):r},ar=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[NA(t,n,e.clock)]},XO=(t,e,n)=>{const r=e.clients.get(n.client),s=Qs(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Kr&&r.splice(s+1,0,xm(t,i,n.clock-i.id.clock+1)),i},QG=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Qs(r,e.id.clock)]=n},ZO=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=NA(t,e,n),a;do a=e[o++],i<a.id.clock+a.length&&NA(t,e,i),s(a);while(o<e.length&&e[o].id.clock<i)};let JG=class{constructor(e,n,r){this.doc=e,this.deleteSet=new Ju,this.beforeState=eh(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};const e_=(t,e)=>e.deleteSet.clients.size===0&&!p$(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(EA(e.deleteSet),IG(t,e),Xu(t,e.deleteSet),!0),t_=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&or(t.changed,e,Oi).add(n)},fm=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Et&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},YG=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const a=s[o],l=a.clock+a.len;for(let u=Qs(i,a.clock),c=i[u];u<i.length&&c.id.clock<l;c=i[++u]){const f=i[u];if(a.clock+a.len<=f.id.clock)break;f instanceof Et&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},XG=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],a=Lo(s.length-1,1+Qs(s,o.clock+o.len-1));for(let l=a,u=s[l];l>0&&u.id.clock>=o.clock;u=s[l])l-=1+fm(s,l)}})},n_=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{EA(i),n.afterState=eh(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,u)=>a.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(l=l.filter(c=>c.target._item===null||!c.target._item.deleted),l.forEach(c=>{c.currentTarget=u,c._path=null}),l.sort((c,f)=>c.path.length-f.path.length),KO(u._dEH,l,n))})}),a.push(()=>r.emit("afterTransaction",[n,r])),pA(a,[]),n._needFormattingCleanup&&wW(n)}finally{r.gc&&YG(i,s,r.gcFilter),XG(i,s),n.afterState.forEach((c,f)=>{const d=n.beforeState.get(f)||0;if(d!==c){const h=s.clients.get(f),p=Mi(Qs(h,d),1);for(let m=h.length-1;m>=p;)m-=1+fm(h,m)}});for(let c=o.length-1;c>=0;c--){const{client:f,clock:d}=o[c].id,h=s.clients.get(f),p=Qs(h,d);p+1<h.length&&fm(h,p+1)>1||p>0&&fm(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(CO(am,Wr,"[yjs] ",ll,AO,"Changed the client-id because another client seems to be using it."),r.clientID=BO()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const c=new Qd;e_(c,n)&&r.emit("update",[c.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const c=new cl;e_(c,n)&&r.emit("updateV2",[c.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:u}=n;(a.size>0||u.size>0||l.size>0)&&(a.forEach(c=>{c.clientID=r.clientID,c.collectionid==null&&(c.collectionid=r.collectionid),r.subdocs.add(c)}),u.forEach(c=>r.subdocs.delete(c)),r.emit("subdocs",[{loaded:l,added:a,removed:u},r,n]),u.forEach(c=>c.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):n_(t,e+1)}}},vt=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new JG(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const a=t._transaction===s[0];t._transaction=null,a&&n_(s,0)}}return o};class ZG{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const r_=(t,e,n)=>{Bo(t,n.deletions,r=>{r instanceof Et&&e.scope.some(s=>Yd(s,r))&&$A(r,!1)})},s_=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;vt(s,a=>{for(;e.length>0&&t.currStackItem===null;){const l=s.store,u=e.pop(),c=new Set,f=[];let d=!1;Bo(a,u.insertions,h=>{if(h instanceof Et){if(h.redone!==null){let{item:p,diff:m}=zA(l,h.id);m>0&&(p=ar(a,Ke(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>Yd(p,h))&&f.push(h)}}),Bo(a,u.deletions,h=>{h instanceof Et&&i.some(p=>Yd(p,h))&&!Yu(u.insertions,h.id)&&c.add(h)}),c.forEach(h=>{d=O_(a,h,c,u.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let h=f.length-1;h>=0;h--){const p=f[h];t.deleteFilter(p)&&(p.delete(a),d=!0)}t.currStackItem=d?u:null}a.changed.forEach((l,u)=>{l.has(null)&&u._searchMarker&&(u._searchMarker.length=0)}),r=a},t);const o=t.currStackItem;if(o!=null){const a=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:a,origin:t},t]),t.currStackItem=null}return o};class i_ extends Zw{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:a=Xw(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const u=this.undoing,c=this.redoing,f=u?this.redoStack:this.undoStack;u?this.stopCapturing():c||this.clear(!1,!0);const d=new Ju;l.afterState.forEach((g,y)=>{const v=l.beforeState.get(y)||0,w=g-v;w>0&&qd(d,y,v,w)});const h=$s();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&f.length>0&&!u&&!c){const g=f[f.length-1];g.deletions=CA([g.deletions,l.deleteSet]),g.insertions=CA([g.insertions,d])}else f.push(new ZG(l.deleteSet,d)),p=!0;!u&&!c&&(this.lastChange=h),Bo(l,l.deleteSet,g=>{g instanceof Et&&this.scope.some(y=>Yd(y,g))&&$A(g,!0)});const m=[{stackItem:f[f.length-1],origin:l.origin,type:u?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){e=Xw(e)?e:[e],e.forEach(n=>{this.scope.every(r=>r!==n)&&(n.doc!==this.doc&&pG("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>r_(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>r_(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=s_(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=s_(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*eW(t){const e=We(t.restDecoder);for(let n=0;n<e;n++){const r=We(t.restDecoder),s=t.readClient();let i=We(t.restDecoder);for(let o=0;o<r;o++){const a=t.readInfo();if(a===10){const l=We(t.restDecoder);yield new qr(Ke(s,i),l),i+=l}else if(tm&a){const l=(a&(Ni|Tr))===0,u=new Et(Ke(s,i),null,(a&Tr)===Tr?t.readLeftID():null,null,(a&Ni)===Ni?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&Hd)===Hd?t.readString():null,__(t,a));yield u,i+=u.length}else{const l=t.readLen();yield new Kr(Ke(s,i),l),i+=l}}}}class RA{constructor(e,n){this.gen=eW(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===qr);return this.curr}}class PA{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const tW=t=>dm(t,jO,Qd),nW=(t,e)=>{if(t.constructor===Kr){const{client:n,clock:r}=t.id;return new Kr(Ke(n,r+e),t.length-e)}else if(t.constructor===qr){const{client:n,clock:r}=t.id;return new qr(Ke(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new Et(Ke(r,s+e),null,Ke(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},dm=(t,e=Zu,n=cl)=>{if(t.length===1)return t[0];const r=t.map(c=>new e(Ks(c)));let s=r.map(c=>new RA(c,!0)),i=null;const o=new n,a=new PA(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){const p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===qr?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){const c=s[0],f=c.curr.id.client;if(i!==null){let d=c.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=c.next(),h=!0;if(d===null||d.id.client!==f||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(f!==i.struct.id.client)Fo(a,i.struct,i.offset),i={struct:d,offset:0},c.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===qr)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{Fo(a,i.struct,i.offset);const p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new qr(Ke(f,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===qr?i.struct.length-=p:d=nW(d,p)),i.struct.mergeWith(d)||(Fo(a,i.struct,i.offset),i={struct:d,offset:0},c.next())}}else i={struct:c.curr,offset:0},c.next();for(let d=c.curr;d!==null&&d.id.client===f&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==qr;d=c.next())Fo(a,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(Fo(a,i.struct,i.offset),i=null),IA(a);const l=r.map(c=>SA(c)),u=CA(l);return Xu(o,u),o.toUint8Array()},rW=(t,e,n=Zu,r=cl)=>{const s=HO(e),i=new r,o=new PA(i),a=new n(Ks(t)),l=new RA(a,!1);for(;l.curr;){const c=l.curr,f=c.id.client,d=s.get(f)||0;if(l.curr.constructor===qr){l.next();continue}if(c.id.clock+c.length>d)for(Fo(o,c,Mi(d-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Fo(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}IA(o);const u=SA(a);return Xu(i,u),i.toUint8Array()},o_=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Rt(t.encoder.restEncoder)}),t.encoder.restEncoder=un(),t.written=0)},Fo=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&o_(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ne(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},IA=t=>{o_(t);const e=t.encoder.restEncoder;Ne(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];Ne(e,r.written),nm(e,r.restEncoder)}},sW=(t,e,n,r)=>{const s=new n(Ks(t)),i=new RA(s,!1),o=new r,a=new PA(o);for(let u=i.curr;u!==null;u=i.next())Fo(a,e(u),0);IA(a);const l=SA(s);return Xu(o,l),o.toUint8Array()},iW=t=>sW(t,tG,Zu,Qd),a_="You must not compute changes after the event-handler fired.";class hm{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=oW(this.currentTarget,this.target))}deletes(e){return Yu(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Gs(a_);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,a;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",a=Yw(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",a=Yw(l.content.getContent())):(o="add",a=void 0)}else if(this.deletes(i))o="delete",a=Yw(i.content.getContent());else return;e.set(s,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Gs(a_);const n=this.target,r=Oi(),s=Oi(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const l=()=>{a&&i.push(a)};for(let u=n._start;u!==null;u=u.right)u.deleted?this.deletes(u)&&!this.adds(u)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=u.length,s.add(u)):this.adds(u)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(u.content.getContent()),r.add(u)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=u.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const oW=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},l_=80;let LA=0;class aW{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=LA++}}const lW=t=>{t.timestamp=LA++},u_=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=LA++},uW=(t,e,n)=>{if(t.length>=l_){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return u_(r,e,n),r}else{const r=new aW(e,n);return t.push(r),r}},pm=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>Z0(e-i.index)<Z0(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,lW(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&Z0(n.index-s)<r.parent.length/l_?(u_(n,r,s),n):uW(t._searchMarker,r,s)},th=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=Mi(e,s.index+n))}},mm=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;or(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;KO(r._eH,n,e)};class kn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=$O(),this._dEH=$O(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw ys()}clone(){throw ys()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){GO(this._eH,e)}observeDeep(e){GO(this._dEH,e)}unobserve(e){WO(this._eH,e)}unobserveDeep(e){WO(this._dEH,e)}toJSON(){}}const c_=(t,e,n)=>{e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&r>0;a++)s.push(o[a]),r--;e=0}}i=i.right}return s},f_=t=>{const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},d_=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&fl(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},nh=(t,e)=>{let n=0,r=t._start;for(;r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},h_=(t,e)=>{const n=[];return nh(t,(r,s)=>{n.push(e(r,s,t))}),n},cW=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},p_=(t,e)=>{const n=pm(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},gm=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,a=i.store,l=n===null?e._start:n.right;let u=[];const c=()=>{u.length>0&&(s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ml(u)),s.integrate(t,0),u=[])};r.forEach(f=>{if(f===null)u.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(f);break;default:switch(c(),f.constructor){case Uint8Array:case ArrayBuffer:s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new rh(new Uint8Array(f))),s.integrate(t,0);break;case ul:s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ih(f)),s.integrate(t,0);break;default:if(f instanceof kn)s=new Et(Ke(o,zt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ws(f)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),c()},m_=()=>Gs("Length exceeded!"),g_=(t,e,n,r)=>{if(n>e._length)throw m_();if(n===0)return e._searchMarker&&th(e._searchMarker,n,r.length),gm(t,e,null,r);const s=n,i=pm(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&ar(t,Ke(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&th(e._searchMarker,s,r.length),gm(t,e,o,r)},fW=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return gm(t,e,s,n)},y_=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=pm(e,n);let a=e._start;for(o!==null&&(a=o.p,n-=o.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&ar(t,Ke(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&ar(t,Ke(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw m_();e._searchMarker&&th(e._searchMarker,s,-i+r)},ym=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},BA=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let a;if(r==null)a=new ml([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new ml([r]);break;case Uint8Array:a=new rh(r);break;case ul:a=new ih(r);break;default:if(r instanceof kn)a=new ws(r);else throw new Error("Unexpected content type")}new Et(Ke(o,zt(i.store,o)),s,s&&s.lastId,null,null,e,n,a).integrate(t,0)},FA=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},b_=t=>{const e={};return t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},w_=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted},dW=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&fl(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},bm=t=>OG(t.entries(),e=>!e[1].deleted);class hW extends hm{}class rc extends kn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new rc;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new rc}clone(){const e=new rc;return e.insert(0,this.toArray().map(n=>n instanceof kn?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,n){super._callObserver(e,n),mm(this,e,new hW(this,e))}insert(e,n){this.doc!==null?vt(this.doc,r=>{g_(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?vt(this.doc,n=>{fW(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?vt(this.doc,r=>{y_(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return p_(this,e)}toArray(){return f_(this)}slice(e=0,n=this.length){return c_(this,e,n)}toJSON(){return this.map(e=>e instanceof kn?e.toJSON():e)}map(e){return h_(this,e)}forEach(e){nh(this,e)}[Symbol.iterator](){return cW(this)}_write(e){e.writeTypeRef(BW)}}const pW=t=>new rc;class mW extends hm{constructor(e,n,r){super(e,n),this.keysChanged=r}}class sc extends kn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new sc}clone(){const e=new sc;return this.forEach((n,r)=>{e.set(r,n instanceof kn?n.clone():n)}),e}_callObserver(e,n){mm(this,e,new mW(this,e,n))}toJSON(){const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof kn?s.toJSON():s}}),e}get size(){return[...bm(this._map)].length}keys(){return xA(bm(this._map),e=>e[0])}values(){return xA(bm(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return xA(bm(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?vt(this.doc,n=>{ym(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?vt(this.doc,r=>{BA(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return FA(this,e)}has(e){return w_(this,e)}clear(){this.doc!==null?vt(this.doc,e=>{this.forEach(function(n,r,s){ym(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(FW)}}const gW=t=>new sc,jo=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Z$(t,e);class jA{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&Sr(),this.right.content.constructor){case Zt:this.right.deleted||ic(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const A_=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Zt:e.right.deleted||ic(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&ar(t,Ke(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},wm=(t,e,n,r)=>{const s=new Map,i=r?pm(e,n):null;if(i){const o=new jA(i.p.left,i.p,i.index,s);return A_(t,o,n-i.index)}else{const o=new jA(null,e._start,0,s);return A_(t,o,n)}},v_=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Zt&&jo(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,a)=>{const l=n.left,u=n.right,c=new Et(Ke(i,zt(s.store,i)),l,l&&l.lastId,u,u&&u.id,e,null,new Zt(a,o));c.integrate(t,0),n.right=c,n.forward()})},ic=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},x_=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Zt&&jo(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},k_=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const a in r){const l=r[a],u=n.currentAttributes.get(a)??null;if(!jo(u,l)){o.set(a,u);const{left:c,right:f}=n;n.right=new Et(Ke(i,zt(s.store,i)),c,c&&c.lastId,f,f&&f.id,e,null,new Zt(a,l)),n.right.integrate(t,0),n.forward()}}return o},UA=(t,e,n,r,s)=>{n.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});const i=t.doc,o=i.clientID;x_(n,s);const a=k_(t,e,n,s),l=r.constructor===String?new bs(r):r instanceof kn?new ws(r):new pl(r);let{left:u,right:c,index:f}=n;e._searchMarker&&th(e._searchMarker,n.index,l.getLength()),c=new Et(Ke(o,zt(i.store,o)),u,u&&u.lastId,c,c&&c.id,e,null,l),c.integrate(t,0),n.right=c,n.index=f,n.forward(),v_(t,e,n,a)},E_=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;x_(n,s);const a=k_(t,e,n,s);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Zt));){if(!n.right.deleted)switch(n.right.content.constructor){case Zt:{const{key:l,value:u}=n.right.content,c=s[l];if(c!==void 0){if(jo(c,u))a.delete(l);else{if(r===0)break e;a.set(l,u)}n.right.delete(t)}else n.currentAttributes.set(l,u);break}default:r<n.right.length&&ar(t,Ke(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
474
474
  `;n.right=new Et(Ke(o,zt(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new bs(l)),n.right.integrate(t,0),n.forward()}v_(t,e,n,a)},C_=(t,e,n,r,s)=>{let i=e;const o=zn();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Zt){const u=i.content;o.set(u.key,u)}i=i.right}let a=0,l=!1;for(;e!==i;){if(n===e&&(l=!0),!e.deleted){const u=e.content;switch(u.constructor){case Zt:{const{key:c,value:f}=u,d=r.get(c)??null;(o.get(c)!==u||d===f)&&(e.delete(t),a++,!l&&(s.get(c)??null)===f&&d!==f&&(d===null?s.delete(c):s.set(c,d))),!l&&!e.deleted&&ic(s,u);break}}}e=e.right}return a},yW=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Zt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},bW=t=>{let e=0;return vt(t.doc,n=>{let r=t._start,s=t._start,i=zn();const o=Jw(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Zt:ic(o,s.content);break;default:e+=C_(n,r,s,i,o),i=Jw(o),r=s;break}s=s.right}}),e},wW=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&ZO(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Zt&&o.constructor!==Kr&&e.add(o.parent)})}vt(n,r=>{Bo(t,t.deleteSet,s=>{if(s instanceof Kr||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Zt?e.add(i):yW(r,s)});for(const s of e)bW(s)})},S_=(t,e,n)=>{const r=n,s=Jw(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case ws:case pl:case bs:n<e.right.length&&ar(t,Ke(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&C_(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&th(o._searchMarker,e.index,-r+n),e};class AW extends hm{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];vt(e,r=>{const s=new Map,i=new Map;let o=this.target._start,a=null;const l={};let u="",c=0,f=0;const d=()=>{if(a!==null){let h=null;switch(a){case"delete":f>0&&(h={delete:f}),f=0;break;case"insert":(typeof u=="object"||u.length>0)&&(h={insert:u},s.size>0&&(h.attributes={},s.forEach((p,m)=>{p!==null&&(h.attributes[m]=p)}))),u="";break;case"retain":c>0&&(h={retain:c},Y$(l)||(h.attributes=Q$({},l))),c=0;break}h&&n.push(h),a=null}};for(;o!==null;){switch(o.content.constructor){case ws:case pl:this.adds(o)?this.deletes(o)||(d(),a="insert",u=o.content.getContent()[0],d()):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),f+=1):o.deleted||(a!=="retain"&&(d(),a="retain"),c+=1);break;case bs:this.adds(o)?this.deletes(o)||(a!=="insert"&&(d(),a="insert"),u+=o.content.str):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),f+=o.length):o.deleted||(a!=="retain"&&(d(),a="retain"),c+=o.length);break;case Zt:{const{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=s.get(h)??null;jo(m,p)?p!==null&&o.delete(r):(a==="retain"&&d(),jo(p,i.get(h)??null)?delete l[h]:l[h]=p)}}else if(this.deletes(o)){i.set(h,p);const m=s.get(h)??null;jo(m,p)||(a==="retain"&&d(),l[h]=m)}else if(!o.deleted){i.set(h,p);const m=l[h];m!==void 0&&(jo(m,p)?m!==null&&o.delete(r):(a==="retain"&&d(),p===null?delete l[h]:l[h]=p))}o.deleted||(a==="insert"&&d(),ic(s,o.content));break}}o=o.right}for(d();n.length>0;){const h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class dl extends kn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new dl}clone(){const e=new dl;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new AW(this,e,n);mm(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===bs&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?vt(this.doc,r=>{const s=new jA(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const a=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
475
475
  `?o.insert.slice(0,-1):o.insert;(typeof a!="string"||a.length>0)&&UA(r,this,s,a,o.attributes||{})}else o.retain!==void 0?E_(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&S_(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){const s=[],i=new Map,o=this.doc;let a="",l=this._start;function u(){if(a.length>0){const f={};let d=!1;i.forEach((p,m)=>{d=!0,f[m]=p});const h={insert:a};d&&(h.attributes=f),s.push(h),a=""}}const c=()=>{for(;l!==null;){if(fl(l,e)||n!==void 0&&fl(l,n))switch(l.content.constructor){case bs:{const f=i.get("ychange");e!==void 0&&!fl(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(u(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!fl(l,n)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(u(),i.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(u(),i.delete("ychange")),a+=l.content.str;break}case ws:case pl:{u();const f={insert:l.content.getContent()[0]};if(i.size>0){const d={};f.attributes=d,i.forEach((h,p)=>{d[p]=h})}s.push(f);break}case Zt:fl(l,e)&&(u(),ic(i,l.content));break}l=l.right}u()};return e||n?vt(o,f=>{e&&MA(f,e),n&&MA(f,n),c()},"cleanup"):c(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?vt(s,i=>{const o=wm(i,this,e,!r);r||(r={},o.currentAttributes.forEach((a,l)=>{r[l]=a})),UA(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?vt(s,i=>{const o=wm(i,this,e,!r);UA(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?vt(r,s=>{S_(s,wm(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?vt(s,i=>{const o=wm(i,this,e,!1);o.right!==null&&E_(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?vt(this.doc,n=>{ym(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?vt(this.doc,r=>{BA(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return FA(this,e)}getAttributes(){return b_(this)}_write(e){e.writeTypeRef(jW)}}const vW=t=>new dl;class VA{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===$n||n.constructor===hl)&&n._start!==null)e=n._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class hl extends kn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new hl}clone(){const e=new hl;return e.insert(0,this.toArray().map(n=>n instanceof kn?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new VA(this,e)}querySelector(e){e=e.toUpperCase();const r=new VA(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),_i(new VA(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){mm(this,e,new EW(this,n,e))}toString(){return h_(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),nh(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?vt(this.doc,r=>{g_(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)vt(this.doc,r=>{const s=e&&e instanceof kn?e._item:e;gm(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw Gs("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?vt(this.doc,r=>{y_(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return f_(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return p_(this,e)}slice(e=0,n=this.length){return c_(this,e,n)}forEach(e){nh(this,e)}_write(e){e.writeTypeRef(VW)}}const xW=t=>new hl;class $n extends hl{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new $n(this.nodeName)}clone(){const e=new $n(this.nodeName),n=this.getAttributes();return J$(n,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof kn?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const a in e)r.push(a);r.sort();const s=r.length;for(let a=0;a<s;a++){const l=r[a];n.push(l+'="'+e[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?vt(this.doc,n=>{ym(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?vt(this.doc,r=>{BA(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return FA(this,e)}hasAttribute(e){return w_(this,e)}getAttributes(e){return e?dW(this,e):b_(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const a=i[o];typeof a=="string"&&s.setAttribute(o,a)}return nh(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(UW),e.writeKey(this.nodeName)}}const kW=t=>new $n(t.readKey());class EW extends hm{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Am extends sc{constructor(e){super(),this.hookName=e}_copy(){return new Am(this.hookName)}clone(){const e=new Am(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(HW),e.writeKey(this.hookName)}}const CW=t=>new Am(t.readKey());class Dr extends dl{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Dr}clone(){const e=new Dr;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,a)=>o.key<a.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const a=i.attrs[o];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(zW)}}const SW=t=>new Dr;class HA{constructor(e,n){this.id=e,this.length=n}get deleted(){throw ys()}mergeWith(e){return!1}write(e,n,r){throw ys()}integrate(e,n){throw ys()}}const TW=0;class Kr extends HA{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),YO(e.doc.store,this)}write(e,n){e.writeInfo(TW),e.writeLen(this.length-n)}getMissing(e,n){return null}}class rh{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new rh(this.content)}splice(e){throw ys()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const DW=t=>new rh(t.readBuf());class sh{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new sh(this.len)}splice(e){const n=new sh(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){qd(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const OW=t=>new sh(t.readLen()),T_=(t,e)=>new ul({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class ih{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ih(T_(this.doc.guid,this.opts))}splice(e){throw ys()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const _W=t=>new ih(T_(t.readString(),t.readAny()));class pl{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new pl(this.embed)}splice(e){throw ys()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const MW=t=>new pl(t.readJSON());class Zt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Zt(this.key,this.value)}splice(e){throw ys()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const NW=t=>new Zt(t.readKey(),t.readJSON());class vm{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new vm(this.arr)}splice(e){const n=new vm(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const RW=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new vm(n)};class ml{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ml(this.arr)}splice(e){const n=new ml(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const PW=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new ml(n)};class bs{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new bs(this.str)}splice(e){const n=new bs(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const IW=t=>new bs(t.readString()),LW=[pW,gW,vW,kW,xW,CW,SW],BW=0,FW=1,jW=2,UW=3,VW=4,HW=5,zW=6;class ws{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new ws(this.type._copy())}splice(e){throw ys()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const $W=t=>new ws(LW[t.readTypeRef()](t)),zA=(t,e)=>{let n=e,r=0,s;do r>0&&(n=Ke(n.client,n.clock+r)),s=nc(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof Et);return{item:s,diff:r}},$A=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},xm=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new Et(Ke(r,s+n),e,Ke(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=Ke(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},D_=(t,e)=>g$(t,n=>Yu(n.deletions,e)),O_=(t,e,n,r,s,i)=>{const o=t.doc,a=o.store,l=o.clientID,u=e.redone;if(u!==null)return ar(t,u);let c=e.parent._item,f=null,d;if(c!==null&&c.deleted===!0){if(c.redone===null&&(!n.has(c)||O_(t,c,n,r,s,i)===null))return null;for(;c.redone!==null;)c=ar(t,c.redone)}const h=c===null?e.parent:c.content.type;if(e.parentSub===null){for(f=e.left,d=e;f!==null;){let y=f;for(;y!==null&&y.parent._item!==c;)y=y.redone===null?null:ar(t,y.redone);if(y!==null&&y.parent._item===c){f=y;break}f=f.left}for(;d!==null;){let y=d;for(;y!==null&&y.parent._item!==c;)y=y.redone===null?null:ar(t,y.redone);if(y!==null&&y.parent._item===c){d=y;break}d=d.right}}else if(d=null,e.right&&!s){for(f=e;f!==null&&f.right!==null&&(f.right.redone||Yu(r,f.right.id)||D_(i.undoStack,f.right.id)||D_(i.redoStack,f.right.id));)for(f=f.right;f.redone;)f=ar(t,f.redone);if(f&&f.right!==null)return null}else f=h._map.get(e.parentSub)||null;const p=zt(a,l),m=Ke(l,p),g=new Et(m,f,f&&f.lastId,d,d&&d.id,h,e.parentSub,e.content.copy());return e.redone=m,$A(g,!0),g.integrate(t,0),g};let Et=class Yk extends HA{constructor(e,n,r,s,i,o,a,l){super(e,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?XD:0}set marker(e){(this.info&nA)>0!==e&&(this.info^=nA)}get marker(){return(this.info&nA)>0}get keep(){return(this.info&YD)>0}set keep(e){this.keep!==e&&(this.info^=YD)}get countable(){return(this.info&XD)>0}get deleted(){return(this.info&tA)>0}set deleted(e){this.deleted!==e&&(this.info^=tA)}markDeleted(){this.info|=tA}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=zt(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=zt(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ec&&this.id.client!==this.parent.client&&this.parent.clock>=zt(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=XO(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ar(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Kr||this.right&&this.right.constructor===Kr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Yk&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Yk&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ec){const r=nc(n,this.parent);r.constructor===Kr?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=XO(e,e.doc.store,Ke(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),tc(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(tc(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(nc(e.doc.store,s.origin)))i.has(nc(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),YO(e.doc.store,this),this.content.integrate(e,this),t_(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Kr(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Ke(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&tc(e.origin,this.lastId)&&this.right===e&&tc(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),qd(e.deleteSet,this.id.client,this.id.clock,this.length),t_(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Sr();this.content.gc(e),n?QG(e,this,new Kr(this.id,this.length)):this.content=new sh(this.length)}write(e,n){const r=n>0?Ke(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&tm|(r===null?0:Tr)|(s===null?0:Ni)|(i===null?0:Hd);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const u=Jd(a);e.writeParentInfo(!0),e.writeString(u)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===ec?(e.writeParentInfo(!1),e.writeLeftID(a)):Sr();i!==null&&e.writeString(i)}this.content.write(e,n)}};const __=(t,e)=>GW[e&tm](t),GW=[()=>{Sr()},OW,RW,DW,IW,MW,NW,$W,PW,_W,()=>{Sr()}],WW=10;class qr extends HA{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Sr()}write(e,n){e.writeInfo(WW),Ne(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const M_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},N_="__ $YJS$ __";M_[N_]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),M_[N_]=!0;function km(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var R_={exports:{}};(function(t,e){(function(n){t.exports=n()})(function(){var n=Math.floor,r=Math.abs,s=Math.pow;return function(){function i(o,a,l){function u(d,h){if(!a[d]){if(!o[d]){var p=typeof km=="function"&&km;if(!h&&p)return p(d,!0);if(c)return c(d,!0);var m=new Error("Cannot find module '"+d+"'");throw m.code="MODULE_NOT_FOUND",m}var g=a[d]={exports:{}};o[d][0].call(g.exports,function(y){var v=o[d][1][y];return u(v||y)},g,g.exports,i,o,a,l)}return a[d].exports}for(var c=typeof km=="function"&&km,f=0;f<l.length;f++)u(l[f]);return u}return i}()({1:[function(i,o,a){function l(A){var x=A.length;if(0<x%4)throw new Error("Invalid string. Length must be a multiple of 4");var k=A.indexOf("=");k===-1&&(k=x);var C=k===x?0:4-k%4;return[k,C]}function u(A,x,k){return 3*(x+k)/4-k}function c(A){var x,k,C=l(A),O=C[0],_=C[1],D=new g(u(A,O,_)),R=0,L=0<_?O-4:O;for(k=0;k<L;k+=4)x=m[A.charCodeAt(k)]<<18|m[A.charCodeAt(k+1)]<<12|m[A.charCodeAt(k+2)]<<6|m[A.charCodeAt(k+3)],D[R++]=255&x>>16,D[R++]=255&x>>8,D[R++]=255&x;return _===2&&(x=m[A.charCodeAt(k)]<<2|m[A.charCodeAt(k+1)]>>4,D[R++]=255&x),_===1&&(x=m[A.charCodeAt(k)]<<10|m[A.charCodeAt(k+1)]<<4|m[A.charCodeAt(k+2)]>>2,D[R++]=255&x>>8,D[R++]=255&x),D}function f(A){return p[63&A>>18]+p[63&A>>12]+p[63&A>>6]+p[63&A]}function d(A,x,k){for(var C,O=[],_=x;_<k;_+=3)C=(16711680&A[_]<<16)+(65280&A[_+1]<<8)+(255&A[_+2]),O.push(f(C));return O.join("")}function h(A){for(var x,k=A.length,C=k%3,O=[],_=16383,D=0,R=k-C;D<R;D+=_)O.push(d(A,D,D+_>R?R:D+_));return C===1?(x=A[k-1],O.push(p[x>>2]+p[63&x<<4]+"==")):C===2&&(x=(A[k-2]<<8)+A[k-1],O.push(p[x>>10]+p[63&x>>4]+p[63&x<<2]+"=")),O.join("")}a.byteLength=function(A){var x=l(A),k=x[0],C=x[1];return 3*(k+C)/4-C},a.toByteArray=c,a.fromByteArray=h;for(var p=[],m=[],g=typeof Uint8Array>"u"?Array:Uint8Array,y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",v=0,w=y.length;v<w;++v)p[v]=y[v],m[y.charCodeAt(v)]=v;m[45]=62,m[95]=63},{}],2:[function(){},{}],3:[function(i,o,a){(function(){(function(){var l=String.fromCharCode,u=Math.min;function c(b){if(2147483647<b)throw new RangeError('The value "'+b+'" is invalid for option "size"');var E=new Uint8Array(b);return E.__proto__=f.prototype,E}function f(b,E,M){if(typeof b=="number"){if(typeof E=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(b)}return d(b,E,M)}function d(b,E,M){if(typeof b=="string")return g(b,E);if(ArrayBuffer.isView(b))return y(b);if(b==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(z(b,ArrayBuffer)||b&&z(b.buffer,ArrayBuffer))return v(b,E,M);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var j=b.valueOf&&b.valueOf();if(j!=null&&j!==b)return f.from(j,E,M);var K=w(b);if(K)return K;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return f.from(b[Symbol.toPrimitive]("string"),E,M);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}function h(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(0>b)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function p(b,E,M){return h(b),0>=b||E===void 0?c(b):typeof M=="string"?c(b).fill(E,M):c(b).fill(E)}function m(b){return h(b),c(0>b?0:0|A(b))}function g(b,E){if((typeof E!="string"||E==="")&&(E="utf8"),!f.isEncoding(E))throw new TypeError("Unknown encoding: "+E);var M=0|x(b,E),j=c(M),K=j.write(b,E);return K!==M&&(j=j.slice(0,K)),j}function y(b){for(var E=0>b.length?0:0|A(b.length),M=c(E),j=0;j<E;j+=1)M[j]=255&b[j];return M}function v(b,E,M){if(0>E||b.byteLength<E)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<E+(M||0))throw new RangeError('"length" is outside of buffer bounds');var j;return j=E===void 0&&M===void 0?new Uint8Array(b):M===void 0?new Uint8Array(b,E):new Uint8Array(b,E,M),j.__proto__=f.prototype,j}function w(b){if(f.isBuffer(b)){var E=0|A(b.length),M=c(E);return M.length===0||b.copy(M,0,0,E),M}return b.length===void 0?b.type==="Buffer"&&Array.isArray(b.data)?y(b.data):void 0:typeof b.length!="number"||q(b.length)?c(0):y(b)}function A(b){if(b>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|b}function x(b,E){if(f.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||z(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);var M=b.length,j=2<arguments.length&&arguments[2]===!0;if(!j&&M===0)return 0;for(var K=!1;;)switch(E){case"ascii":case"latin1":case"binary":return M;case"utf8":case"utf-8":return le(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*M;case"hex":return M>>>1;case"base64":return be(b).length;default:if(K)return j?-1:le(b).length;E=(""+E).toLowerCase(),K=!0}}function k(b,E,M){var j=!1;if((E===void 0||0>E)&&(E=0),E>this.length||((M===void 0||M>this.length)&&(M=this.length),0>=M)||(M>>>=0,E>>>=0,M<=E))return"";for(b||(b="utf8");;)switch(b){case"hex":return Ee(this,E,M);case"utf8":case"utf-8":return Q(this,E,M);case"ascii":return Z(this,E,M);case"latin1":case"binary":return pe(this,E,M);case"base64":return H(this,E,M);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Re(this,E,M);default:if(j)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),j=!0}}function C(b,E,M){var j=b[E];b[E]=b[M],b[M]=j}function O(b,E,M,j,K){if(b.length===0)return-1;if(typeof M=="string"?(j=M,M=0):2147483647<M?M=2147483647:-2147483648>M&&(M=-2147483648),M=+M,q(M)&&(M=K?0:b.length-1),0>M&&(M=b.length+M),M>=b.length){if(K)return-1;M=b.length-1}else if(0>M)if(K)M=0;else return-1;if(typeof E=="string"&&(E=f.from(E,j)),f.isBuffer(E))return E.length===0?-1:_(b,E,M,j,K);if(typeof E=="number")return E&=255,typeof Uint8Array.prototype.indexOf=="function"?K?Uint8Array.prototype.indexOf.call(b,E,M):Uint8Array.prototype.lastIndexOf.call(b,E,M):_(b,[E],M,j,K);throw new TypeError("val must be string, number or Buffer")}function _(b,E,M,j,K){function Y(br,X){return ye===1?br[X]:br.readUInt16BE(X*ye)}var ye=1,Se=b.length,Je=E.length;if(j!==void 0&&(j=(j+"").toLowerCase(),j==="ucs2"||j==="ucs-2"||j==="utf16le"||j==="utf-16le")){if(2>b.length||2>E.length)return-1;ye=2,Se/=2,Je/=2,M/=2}var Ve;if(K){var Fe=-1;for(Ve=M;Ve<Se;Ve++)if(Y(b,Ve)!==Y(E,Fe===-1?0:Ve-Fe))Fe!==-1&&(Ve-=Ve-Fe),Fe=-1;else if(Fe===-1&&(Fe=Ve),Ve-Fe+1===Je)return Fe*ye}else for(M+Je>Se&&(M=Se-Je),Ve=M;0<=Ve;Ve--){for(var ft=!0,Xn=0;Xn<Je;Xn++)if(Y(b,Ve+Xn)!==Y(E,Xn)){ft=!1;break}if(ft)return Ve}return-1}function D(b,E,M,j){M=+M||0;var K=b.length-M;j?(j=+j,j>K&&(j=K)):j=K;var Y=E.length;j>Y/2&&(j=Y/2);for(var ye,Se=0;Se<j;++Se){if(ye=parseInt(E.substr(2*Se,2),16),q(ye))return Se;b[M+Se]=ye}return Se}function R(b,E,M,j){return Be(le(E,b.length-M),b,M,j)}function L(b,E,M,j){return Be($e(E),b,M,j)}function F(b,E,M,j){return L(b,E,M,j)}function G(b,E,M,j){return Be(be(E),b,M,j)}function B(b,E,M,j){return Be(ae(E,b.length-M),b,M,j)}function H(b,E,M){return E===0&&M===b.length?re.fromByteArray(b):re.fromByteArray(b.slice(E,M))}function Q(b,E,M){M=u(b.length,M);for(var j=[],K=E;K<M;){var Y=b[K],ye=null,Se=239<Y?4:223<Y?3:191<Y?2:1;if(K+Se<=M){var Je,Ve,Fe,ft;Se===1?128>Y&&(ye=Y):Se===2?(Je=b[K+1],(192&Je)==128&&(ft=(31&Y)<<6|63&Je,127<ft&&(ye=ft))):Se===3?(Je=b[K+1],Ve=b[K+2],(192&Je)==128&&(192&Ve)==128&&(ft=(15&Y)<<12|(63&Je)<<6|63&Ve,2047<ft&&(55296>ft||57343<ft)&&(ye=ft))):Se===4&&(Je=b[K+1],Ve=b[K+2],Fe=b[K+3],(192&Je)==128&&(192&Ve)==128&&(192&Fe)==128&&(ft=(15&Y)<<18|(63&Je)<<12|(63&Ve)<<6|63&Fe,65535<ft&&1114112>ft&&(ye=ft)))}ye===null?(ye=65533,Se=1):65535<ye&&(ye-=65536,j.push(55296|1023&ye>>>10),ye=56320|1023&ye),j.push(ye),K+=Se}return te(j)}function te(b){var E=b.length;if(E<=4096)return l.apply(String,b);for(var M="",j=0;j<E;)M+=l.apply(String,b.slice(j,j+=4096));return M}function Z(b,E,M){var j="";M=u(b.length,M);for(var K=E;K<M;++K)j+=l(127&b[K]);return j}function pe(b,E,M){var j="";M=u(b.length,M);for(var K=E;K<M;++K)j+=l(b[K]);return j}function Ee(b,E,M){var j=b.length;(!E||0>E)&&(E=0),(!M||0>M||M>j)&&(M=j);for(var K="",Y=E;Y<M;++Y)K+=tt(b[Y]);return K}function Re(b,E,M){for(var j=b.slice(E,M),K="",Y=0;Y<j.length;Y+=2)K+=l(j[Y]+256*j[Y+1]);return K}function Ce(b,E,M){if(b%1!=0||0>b)throw new RangeError("offset is not uint");if(b+E>M)throw new RangeError("Trying to access beyond buffer length")}function ke(b,E,M,j,K,Y){if(!f.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(E>K||E<Y)throw new RangeError('"value" argument is out of bounds');if(M+j>b.length)throw new RangeError("Index out of range")}function He(b,E,M,j){if(M+j>b.length)throw new RangeError("Index out of range");if(0>M)throw new RangeError("Index out of range")}function Ue(b,E,M,j,K){return E=+E,M>>>=0,K||He(b,E,M,4),ue.write(b,E,M,j,23,4),M+4}function ze(b,E,M,j,K){return E=+E,M>>>=0,K||He(b,E,M,8),ue.write(b,E,M,j,52,8),M+8}function Le(b){if(b=b.split("=")[0],b=b.trim().replace(P,""),2>b.length)return"";for(;b.length%4!=0;)b+="=";return b}function tt(b){return 16>b?"0"+b.toString(16):b.toString(16)}function le(b,E){E=E||1/0;for(var M,j=b.length,K=null,Y=[],ye=0;ye<j;++ye){if(M=b.charCodeAt(ye),55295<M&&57344>M){if(!K){if(56319<M){-1<(E-=3)&&Y.push(239,191,189);continue}else if(ye+1===j){-1<(E-=3)&&Y.push(239,191,189);continue}K=M;continue}if(56320>M){-1<(E-=3)&&Y.push(239,191,189),K=M;continue}M=(K-55296<<10|M-56320)+65536}else K&&-1<(E-=3)&&Y.push(239,191,189);if(K=null,128>M){if(0>(E-=1))break;Y.push(M)}else if(2048>M){if(0>(E-=2))break;Y.push(192|M>>6,128|63&M)}else if(65536>M){if(0>(E-=3))break;Y.push(224|M>>12,128|63&M>>6,128|63&M)}else if(1114112>M){if(0>(E-=4))break;Y.push(240|M>>18,128|63&M>>12,128|63&M>>6,128|63&M)}else throw new Error("Invalid code point")}return Y}function $e(b){for(var E=[],M=0;M<b.length;++M)E.push(255&b.charCodeAt(M));return E}function ae(b,E){for(var M,j,K,Y=[],ye=0;ye<b.length&&!(0>(E-=2));++ye)M=b.charCodeAt(ye),j=M>>8,K=M%256,Y.push(K),Y.push(j);return Y}function be(b){return re.toByteArray(Le(b))}function Be(b,E,M,j){for(var K=0;K<j&&!(K+M>=E.length||K>=b.length);++K)E[K+M]=b[K];return K}function z(b,E){return b instanceof E||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===E.name}function q(b){return b!==b}var re=i("base64-js"),ue=i("ieee754");a.Buffer=f,a.SlowBuffer=function(b){return+b!=b&&(b=0),f.alloc(+b)},a.INSPECT_MAX_BYTES=50,a.kMaxLength=2147483647,f.TYPED_ARRAY_SUPPORT=function(){try{var b=new Uint8Array(1);return b.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},b.foo()===42}catch{return!1}}(),f.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){return f.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){return f.isBuffer(this)?this.byteOffset:void 0}}),typeof Symbol<"u"&&Symbol.species!=null&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),f.poolSize=8192,f.from=function(b,E,M){return d(b,E,M)},f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,f.alloc=function(b,E,M){return p(b,E,M)},f.allocUnsafe=function(b){return m(b)},f.allocUnsafeSlow=function(b){return m(b)},f.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==f.prototype},f.compare=function(b,E){if(z(b,Uint8Array)&&(b=f.from(b,b.offset,b.byteLength)),z(E,Uint8Array)&&(E=f.from(E,E.offset,E.byteLength)),!f.isBuffer(b)||!f.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(b===E)return 0;for(var M=b.length,j=E.length,K=0,Y=u(M,j);K<Y;++K)if(b[K]!==E[K]){M=b[K],j=E[K];break}return M<j?-1:j<M?1:0},f.isEncoding=function(b){switch((b+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(b,E){if(!Array.isArray(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return f.alloc(0);var M;if(E===void 0)for(E=0,M=0;M<b.length;++M)E+=b[M].length;var j=f.allocUnsafe(E),K=0;for(M=0;M<b.length;++M){var Y=b[M];if(z(Y,Uint8Array)&&(Y=f.from(Y)),!f.isBuffer(Y))throw new TypeError('"list" argument must be an Array of Buffers');Y.copy(j,K),K+=Y.length}return j},f.byteLength=x,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var b=this.length;if(b%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var E=0;E<b;E+=2)C(this,E,E+1);return this},f.prototype.swap32=function(){var b=this.length;if(b%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var E=0;E<b;E+=4)C(this,E,E+3),C(this,E+1,E+2);return this},f.prototype.swap64=function(){var b=this.length;if(b%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var E=0;E<b;E+=8)C(this,E,E+7),C(this,E+1,E+6),C(this,E+2,E+5),C(this,E+3,E+4);return this},f.prototype.toString=function(){var b=this.length;return b===0?"":arguments.length===0?Q(this,0,b):k.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(b){if(!f.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||f.compare(this,b)===0},f.prototype.inspect=function(){var b="",E=a.INSPECT_MAX_BYTES;return b=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(b+=" ... "),"<Buffer "+b+">"},f.prototype.compare=function(b,E,M,j,K){if(z(b,Uint8Array)&&(b=f.from(b,b.offset,b.byteLength)),!f.isBuffer(b))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof b);if(E===void 0&&(E=0),M===void 0&&(M=b?b.length:0),j===void 0&&(j=0),K===void 0&&(K=this.length),0>E||M>b.length||0>j||K>this.length)throw new RangeError("out of range index");if(j>=K&&E>=M)return 0;if(j>=K)return-1;if(E>=M)return 1;if(E>>>=0,M>>>=0,j>>>=0,K>>>=0,this===b)return 0;for(var Y=K-j,ye=M-E,Se=u(Y,ye),Je=this.slice(j,K),Ve=b.slice(E,M),Fe=0;Fe<Se;++Fe)if(Je[Fe]!==Ve[Fe]){Y=Je[Fe],ye=Ve[Fe];break}return Y<ye?-1:ye<Y?1:0},f.prototype.includes=function(b,E,M){return this.indexOf(b,E,M)!==-1},f.prototype.indexOf=function(b,E,M){return O(this,b,E,M,!0)},f.prototype.lastIndexOf=function(b,E,M){return O(this,b,E,M,!1)},f.prototype.write=function(b,E,M,j){if(E===void 0)j="utf8",M=this.length,E=0;else if(M===void 0&&typeof E=="string")j=E,M=this.length,E=0;else if(isFinite(E))E>>>=0,isFinite(M)?(M>>>=0,j===void 0&&(j="utf8")):(j=M,M=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var K=this.length-E;if((M===void 0||M>K)&&(M=K),0<b.length&&(0>M||0>E)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");j||(j="utf8");for(var Y=!1;;)switch(j){case"hex":return D(this,b,E,M);case"utf8":case"utf-8":return R(this,b,E,M);case"ascii":return L(this,b,E,M);case"latin1":case"binary":return F(this,b,E,M);case"base64":return G(this,b,E,M);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,b,E,M);default:if(Y)throw new TypeError("Unknown encoding: "+j);j=(""+j).toLowerCase(),Y=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},f.prototype.slice=function(b,E){var M=this.length;b=~~b,E=E===void 0?M:~~E,0>b?(b+=M,0>b&&(b=0)):b>M&&(b=M),0>E?(E+=M,0>E&&(E=0)):E>M&&(E=M),E<b&&(E=b);var j=this.subarray(b,E);return j.__proto__=f.prototype,j},f.prototype.readUIntLE=function(b,E,M){b>>>=0,E>>>=0,M||Ce(b,E,this.length);for(var j=this[b],K=1,Y=0;++Y<E&&(K*=256);)j+=this[b+Y]*K;return j},f.prototype.readUIntBE=function(b,E,M){b>>>=0,E>>>=0,M||Ce(b,E,this.length);for(var j=this[b+--E],K=1;0<E&&(K*=256);)j+=this[b+--E]*K;return j},f.prototype.readUInt8=function(b,E){return b>>>=0,E||Ce(b,1,this.length),this[b]},f.prototype.readUInt16LE=function(b,E){return b>>>=0,E||Ce(b,2,this.length),this[b]|this[b+1]<<8},f.prototype.readUInt16BE=function(b,E){return b>>>=0,E||Ce(b,2,this.length),this[b]<<8|this[b+1]},f.prototype.readUInt32LE=function(b,E){return b>>>=0,E||Ce(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+16777216*this[b+3]},f.prototype.readUInt32BE=function(b,E){return b>>>=0,E||Ce(b,4,this.length),16777216*this[b]+(this[b+1]<<16|this[b+2]<<8|this[b+3])},f.prototype.readIntLE=function(b,E,M){b>>>=0,E>>>=0,M||Ce(b,E,this.length);for(var j=this[b],K=1,Y=0;++Y<E&&(K*=256);)j+=this[b+Y]*K;return K*=128,j>=K&&(j-=s(2,8*E)),j},f.prototype.readIntBE=function(b,E,M){b>>>=0,E>>>=0,M||Ce(b,E,this.length);for(var j=E,K=1,Y=this[b+--j];0<j&&(K*=256);)Y+=this[b+--j]*K;return K*=128,Y>=K&&(Y-=s(2,8*E)),Y},f.prototype.readInt8=function(b,E){return b>>>=0,E||Ce(b,1,this.length),128&this[b]?-1*(255-this[b]+1):this[b]},f.prototype.readInt16LE=function(b,E){b>>>=0,E||Ce(b,2,this.length);var M=this[b]|this[b+1]<<8;return 32768&M?4294901760|M:M},f.prototype.readInt16BE=function(b,E){b>>>=0,E||Ce(b,2,this.length);var M=this[b+1]|this[b]<<8;return 32768&M?4294901760|M:M},f.prototype.readInt32LE=function(b,E){return b>>>=0,E||Ce(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},f.prototype.readInt32BE=function(b,E){return b>>>=0,E||Ce(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},f.prototype.readFloatLE=function(b,E){return b>>>=0,E||Ce(b,4,this.length),ue.read(this,b,!0,23,4)},f.prototype.readFloatBE=function(b,E){return b>>>=0,E||Ce(b,4,this.length),ue.read(this,b,!1,23,4)},f.prototype.readDoubleLE=function(b,E){return b>>>=0,E||Ce(b,8,this.length),ue.read(this,b,!0,52,8)},f.prototype.readDoubleBE=function(b,E){return b>>>=0,E||Ce(b,8,this.length),ue.read(this,b,!1,52,8)},f.prototype.writeUIntLE=function(b,E,M,j){if(b=+b,E>>>=0,M>>>=0,!j){var K=s(2,8*M)-1;ke(this,b,E,M,K,0)}var Y=1,ye=0;for(this[E]=255&b;++ye<M&&(Y*=256);)this[E+ye]=255&b/Y;return E+M},f.prototype.writeUIntBE=function(b,E,M,j){if(b=+b,E>>>=0,M>>>=0,!j){var K=s(2,8*M)-1;ke(this,b,E,M,K,0)}var Y=M-1,ye=1;for(this[E+Y]=255&b;0<=--Y&&(ye*=256);)this[E+Y]=255&b/ye;return E+M},f.prototype.writeUInt8=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,1,255,0),this[E]=255&b,E+1},f.prototype.writeUInt16LE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,2,65535,0),this[E]=255&b,this[E+1]=b>>>8,E+2},f.prototype.writeUInt16BE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,2,65535,0),this[E]=b>>>8,this[E+1]=255&b,E+2},f.prototype.writeUInt32LE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,4,4294967295,0),this[E+3]=b>>>24,this[E+2]=b>>>16,this[E+1]=b>>>8,this[E]=255&b,E+4},f.prototype.writeUInt32BE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,4,4294967295,0),this[E]=b>>>24,this[E+1]=b>>>16,this[E+2]=b>>>8,this[E+3]=255&b,E+4},f.prototype.writeIntLE=function(b,E,M,j){if(b=+b,E>>>=0,!j){var K=s(2,8*M-1);ke(this,b,E,M,K-1,-K)}var Y=0,ye=1,Se=0;for(this[E]=255&b;++Y<M&&(ye*=256);)0>b&&Se===0&&this[E+Y-1]!==0&&(Se=1),this[E+Y]=255&(b/ye>>0)-Se;return E+M},f.prototype.writeIntBE=function(b,E,M,j){if(b=+b,E>>>=0,!j){var K=s(2,8*M-1);ke(this,b,E,M,K-1,-K)}var Y=M-1,ye=1,Se=0;for(this[E+Y]=255&b;0<=--Y&&(ye*=256);)0>b&&Se===0&&this[E+Y+1]!==0&&(Se=1),this[E+Y]=255&(b/ye>>0)-Se;return E+M},f.prototype.writeInt8=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,1,127,-128),0>b&&(b=255+b+1),this[E]=255&b,E+1},f.prototype.writeInt16LE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,2,32767,-32768),this[E]=255&b,this[E+1]=b>>>8,E+2},f.prototype.writeInt16BE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,2,32767,-32768),this[E]=b>>>8,this[E+1]=255&b,E+2},f.prototype.writeInt32LE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,4,2147483647,-2147483648),this[E]=255&b,this[E+1]=b>>>8,this[E+2]=b>>>16,this[E+3]=b>>>24,E+4},f.prototype.writeInt32BE=function(b,E,M){return b=+b,E>>>=0,M||ke(this,b,E,4,2147483647,-2147483648),0>b&&(b=4294967295+b+1),this[E]=b>>>24,this[E+1]=b>>>16,this[E+2]=b>>>8,this[E+3]=255&b,E+4},f.prototype.writeFloatLE=function(b,E,M){return Ue(this,b,E,!0,M)},f.prototype.writeFloatBE=function(b,E,M){return Ue(this,b,E,!1,M)},f.prototype.writeDoubleLE=function(b,E,M){return ze(this,b,E,!0,M)},f.prototype.writeDoubleBE=function(b,E,M){return ze(this,b,E,!1,M)},f.prototype.copy=function(b,E,M,j){if(!f.isBuffer(b))throw new TypeError("argument should be a Buffer");if(M||(M=0),j||j===0||(j=this.length),E>=b.length&&(E=b.length),E||(E=0),0<j&&j<M&&(j=M),j===M||b.length===0||this.length===0)return 0;if(0>E)throw new RangeError("targetStart out of bounds");if(0>M||M>=this.length)throw new RangeError("Index out of range");if(0>j)throw new RangeError("sourceEnd out of bounds");j>this.length&&(j=this.length),b.length-E<j-M&&(j=b.length-E+M);var K=j-M;if(this===b&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(E,M,j);else if(this===b&&M<E&&E<j)for(var Y=K-1;0<=Y;--Y)b[Y+E]=this[Y+M];else Uint8Array.prototype.set.call(b,this.subarray(M,j),E);return K},f.prototype.fill=function(b,E,M,j){if(typeof b=="string"){if(typeof E=="string"?(j=E,E=0,M=this.length):typeof M=="string"&&(j=M,M=this.length),j!==void 0&&typeof j!="string")throw new TypeError("encoding must be a string");if(typeof j=="string"&&!f.isEncoding(j))throw new TypeError("Unknown encoding: "+j);if(b.length===1){var K=b.charCodeAt(0);(j==="utf8"&&128>K||j==="latin1")&&(b=K)}}else typeof b=="number"&&(b&=255);if(0>E||this.length<E||this.length<M)throw new RangeError("Out of range index");if(M<=E)return this;E>>>=0,M=M===void 0?this.length:M>>>0,b||(b=0);var Y;if(typeof b=="number")for(Y=E;Y<M;++Y)this[Y]=b;else{var ye=f.isBuffer(b)?b:f.from(b,j),Se=ye.length;if(Se===0)throw new TypeError('The value "'+b+'" is invalid for argument "value"');for(Y=0;Y<M-E;++Y)this[Y+E]=ye[Y%Se]}return this};var P=/[^+/0-9A-Za-z-_]/g}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:9}],4:[function(i,o,a){(function(l){(function(){function u(){let f;try{f=a.storage.getItem("debug")}catch{}return!f&&typeof l<"u"&&"env"in l&&(f=l.env.DEBUG),f}a.formatArgs=function(f){if(f[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+f[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;f.splice(1,0,d,"color: inherit");let h=0,p=0;f[0].replace(/%[a-zA-Z%]/g,m=>{m==="%%"||(h++,m==="%c"&&(p=h))}),f.splice(p,0,d)},a.save=function(f){try{f?a.storage.setItem("debug",f):a.storage.removeItem("debug")}catch{}},a.load=u,a.useColors=function(){return!!(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},a.storage=function(){try{return localStorage}catch{}}(),a.destroy=(()=>{let f=!1;return()=>{f||(f=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),a.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],a.log=console.debug||console.log||(()=>{}),o.exports=i("./common")(a);const{formatters:c}=o.exports;c.j=function(f){try{return JSON.stringify(f)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}}).call(this)}).call(this,i("_process"))},{"./common":5,_process:12}],5:[function(i,o){o.exports=function(a){function l(f){function d(...m){if(!d.enabled)return;const g=d,y=+new Date,v=y-(h||y);g.diff=v,g.prev=h,g.curr=y,h=y,m[0]=l.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let w=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(x,k)=>{if(x==="%%")return"%";w++;const C=l.formatters[k];if(typeof C=="function"){const O=m[w];x=C.call(g,O),m.splice(w,1),w--}return x}),l.formatArgs.call(g,m),(g.log||l.log).apply(g,m)}let h,p=null;return d.namespace=f,d.useColors=l.useColors(),d.color=l.selectColor(f),d.extend=u,d.destroy=l.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>p===null?l.enabled(f):p,set:m=>{p=m}}),typeof l.init=="function"&&l.init(d),d}function u(f,d){const h=l(this.namespace+(typeof d>"u"?":":d)+f);return h.log=this.log,h}function c(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}return l.debug=l,l.default=l,l.coerce=function(f){return f instanceof Error?f.stack||f.message:f},l.disable=function(){const f=[...l.names.map(c),...l.skips.map(c).map(d=>"-"+d)].join(",");return l.enable(""),f},l.enable=function(f){l.save(f),l.names=[],l.skips=[];let d;const h=(typeof f=="string"?f:"").split(/[\s,]+/),p=h.length;for(d=0;d<p;d++)h[d]&&(f=h[d].replace(/\*/g,".*?"),f[0]==="-"?l.skips.push(new RegExp("^"+f.substr(1)+"$")):l.names.push(new RegExp("^"+f+"$")))},l.enabled=function(f){if(f[f.length-1]==="*")return!0;let d,h;for(d=0,h=l.skips.length;d<h;d++)if(l.skips[d].test(f))return!1;for(d=0,h=l.names.length;d<h;d++)if(l.names[d].test(f))return!0;return!1},l.humanize=i("ms"),l.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(a).forEach(f=>{l[f]=a[f]}),l.names=[],l.skips=[],l.formatters={},l.selectColor=function(f){let d=0;for(let h=0;h<f.length;h++)d=(d<<5)-d+f.charCodeAt(h),d|=0;return l.colors[r(d)%l.colors.length]},l.enable(l.load()),l}},{ms:11}],6:[function(i,o){function a(l,u){for(const c in u)Object.defineProperty(l,c,{value:u[c],enumerable:!0,configurable:!0});return l}o.exports=function(l,u,c){if(!l||typeof l=="string")throw new TypeError("Please pass an Error to err-code");c||(c={}),typeof u=="object"&&(c=u,u=""),u&&(c.code=u);try{return a(l,c)}catch{c.message=l.message,c.stack=l.stack;const d=function(){};return d.prototype=Object.create(Object.getPrototypeOf(l)),a(new d,c)}}},{}],7:[function(i,o){function a(D){console&&console.warn&&console.warn(D)}function l(){l.init.call(this)}function u(D){if(typeof D!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof D)}function c(D){return D._maxListeners===void 0?l.defaultMaxListeners:D._maxListeners}function f(D,R,L,F){var G,B,H;if(u(L),B=D._events,B===void 0?(B=D._events=Object.create(null),D._eventsCount=0):(B.newListener!==void 0&&(D.emit("newListener",R,L.listener?L.listener:L),B=D._events),H=B[R]),H===void 0)H=B[R]=L,++D._eventsCount;else if(typeof H=="function"?H=B[R]=F?[L,H]:[H,L]:F?H.unshift(L):H.push(L),G=c(D),0<G&&H.length>G&&!H.warned){H.warned=!0;var Q=new Error("Possible EventEmitter memory leak detected. "+H.length+" "+(R+" listeners added. Use emitter.setMaxListeners() to increase limit"));Q.name="MaxListenersExceededWarning",Q.emitter=D,Q.type=R,Q.count=H.length,a(Q)}return D}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(D,R,L){var F={fired:!1,wrapFn:void 0,target:D,type:R,listener:L},G=d.bind(F);return G.listener=L,F.wrapFn=G,G}function p(D,R,L){var F=D._events;if(F===void 0)return[];var G=F[R];return G===void 0?[]:typeof G=="function"?L?[G.listener||G]:[G]:L?v(G):g(G,G.length)}function m(D){var R=this._events;if(R!==void 0){var L=R[D];if(typeof L=="function")return 1;if(L!==void 0)return L.length}return 0}function g(D,R){for(var L=Array(R),F=0;F<R;++F)L[F]=D[F];return L}function y(D,R){for(;R+1<D.length;R++)D[R]=D[R+1];D.pop()}function v(D){for(var R=Array(D.length),L=0;L<R.length;++L)R[L]=D[L].listener||D[L];return R}function w(D,R,L){typeof D.on=="function"&&A(D,"error",R,L)}function A(D,R,L,F){if(typeof D.on=="function")F.once?D.once(R,L):D.on(R,L);else if(typeof D.addEventListener=="function")D.addEventListener(R,function G(B){F.once&&D.removeEventListener(R,G),L(B)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof D)}var x,k=typeof Reflect=="object"?Reflect:null,C=k&&typeof k.apply=="function"?k.apply:function(D,R,L){return Function.prototype.apply.call(D,R,L)};x=k&&typeof k.ownKeys=="function"?k.ownKeys:Object.getOwnPropertySymbols?function(D){return Object.getOwnPropertyNames(D).concat(Object.getOwnPropertySymbols(D))}:function(D){return Object.getOwnPropertyNames(D)};var O=Number.isNaN||function(D){return D!==D};o.exports=l,o.exports.once=function(D,R){return new Promise(function(L,F){function G(H){D.removeListener(R,B),F(H)}function B(){typeof D.removeListener=="function"&&D.removeListener("error",G),L([].slice.call(arguments))}A(D,R,B,{once:!0}),R!=="error"&&w(D,G,{once:!0})})},l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var _=10;Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(D){if(typeof D!="number"||0>D||O(D))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+D+".");_=D}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(D){if(typeof D!="number"||0>D||O(D))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+D+".");return this._maxListeners=D,this},l.prototype.getMaxListeners=function(){return c(this)},l.prototype.emit=function(D){for(var R=[],L=1;L<arguments.length;L++)R.push(arguments[L]);var F=D==="error",G=this._events;if(G!==void 0)F=F&&G.error===void 0;else if(!F)return!1;if(F){var B;if(0<R.length&&(B=R[0]),B instanceof Error)throw B;var H=new Error("Unhandled error."+(B?" ("+B.message+")":""));throw H.context=B,H}var Q=G[D];if(Q===void 0)return!1;if(typeof Q=="function")C(Q,this,R);else for(var te=Q.length,Z=g(Q,te),L=0;L<te;++L)C(Z[L],this,R);return!0},l.prototype.addListener=function(D,R){return f(this,D,R,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(D,R){return f(this,D,R,!0)},l.prototype.once=function(D,R){return u(R),this.on(D,h(this,D,R)),this},l.prototype.prependOnceListener=function(D,R){return u(R),this.prependListener(D,h(this,D,R)),this},l.prototype.removeListener=function(D,R){var L,F,G,B,H;if(u(R),F=this._events,F===void 0)return this;if(L=F[D],L===void 0)return this;if(L===R||L.listener===R)--this._eventsCount==0?this._events=Object.create(null):(delete F[D],F.removeListener&&this.emit("removeListener",D,L.listener||R));else if(typeof L!="function"){for(G=-1,B=L.length-1;0<=B;B--)if(L[B]===R||L[B].listener===R){H=L[B].listener,G=B;break}if(0>G)return this;G===0?L.shift():y(L,G),L.length===1&&(F[D]=L[0]),F.removeListener!==void 0&&this.emit("removeListener",D,H||R)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(D){var R,L,F;if(L=this._events,L===void 0)return this;if(L.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):L[D]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete L[D]),this;if(arguments.length===0){var G,B=Object.keys(L);for(F=0;F<B.length;++F)G=B[F],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(R=L[D],typeof R=="function")this.removeListener(D,R);else if(R!==void 0)for(F=R.length-1;0<=F;F--)this.removeListener(D,R[F]);return this},l.prototype.listeners=function(D){return p(this,D,!0)},l.prototype.rawListeners=function(D){return p(this,D,!1)},l.listenerCount=function(D,R){return typeof D.listenerCount=="function"?D.listenerCount(R):m.call(D,R)},l.prototype.listenerCount=m,l.prototype.eventNames=function(){return 0<this._eventsCount?x(this._events):[]}},{}],8:[function(i,o){o.exports=function(){if(typeof globalThis>"u")return null;var a={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return a.RTCPeerConnection?a:null}},{}],9:[function(i,o,a){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */a.read=function(l,u,c,f,d){var h,p,m=8*d-f-1,g=(1<<m)-1,y=g>>1,v=-7,w=c?d-1:0,A=c?-1:1,x=l[u+w];for(w+=A,h=x&(1<<-v)-1,x>>=-v,v+=m;0<v;h=256*h+l[u+w],w+=A,v-=8);for(p=h&(1<<-v)-1,h>>=-v,v+=f;0<v;p=256*p+l[u+w],w+=A,v-=8);if(h===0)h=1-y;else{if(h===g)return p?NaN:(x?-1:1)*(1/0);p+=s(2,f),h-=y}return(x?-1:1)*p*s(2,h-f)},a.write=function(l,u,c,f,d,h){var p,m,g,y=Math.LN2,v=Math.log,w=8*h-d-1,A=(1<<w)-1,x=A>>1,k=d===23?s(2,-24)-s(2,-77):0,C=f?0:h-1,O=f?1:-1,_=0>u||u===0&&0>1/u?1:0;for(u=r(u),isNaN(u)||u===1/0?(m=isNaN(u)?1:0,p=A):(p=n(v(u)/y),1>u*(g=s(2,-p))&&(p--,g*=2),u+=1<=p+x?k/g:k*s(2,1-x),2<=u*g&&(p++,g/=2),p+x>=A?(m=0,p=A):1<=p+x?(m=(u*g-1)*s(2,d),p+=x):(m=u*s(2,x-1)*s(2,d),p=0));8<=d;l[c+C]=255&m,C+=O,m/=256,d-=8);for(p=p<<d|m,w+=d;0<w;l[c+C]=255&p,C+=O,p/=256,w-=8);l[c+C-O]|=128*_}},{}],10:[function(i,o){o.exports=typeof Object.create=="function"?function(a,l){l&&(a.super_=l,a.prototype=Object.create(l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:function(a,l){if(l){a.super_=l;var u=function(){};u.prototype=l.prototype,a.prototype=new u,a.prototype.constructor=a}}},{}],11:[function(i,o){var a=Math.round;function l(d){if(d+="",!(100<d.length)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(h){var p=parseFloat(h[1]),m=(h[2]||"ms").toLowerCase();return m==="years"||m==="year"||m==="yrs"||m==="yr"||m==="y"?315576e5*p:m==="weeks"||m==="week"||m==="w"?6048e5*p:m==="days"||m==="day"||m==="d"?864e5*p:m==="hours"||m==="hour"||m==="hrs"||m==="hr"||m==="h"?36e5*p:m==="minutes"||m==="minute"||m==="mins"||m==="min"||m==="m"?6e4*p:m==="seconds"||m==="second"||m==="secs"||m==="sec"||m==="s"?1e3*p:m==="milliseconds"||m==="millisecond"||m==="msecs"||m==="msec"||m==="ms"?p:void 0}}}function u(d){var h=r(d);return 864e5<=h?a(d/864e5)+"d":36e5<=h?a(d/36e5)+"h":6e4<=h?a(d/6e4)+"m":1e3<=h?a(d/1e3)+"s":d+"ms"}function c(d){var h=r(d);return 864e5<=h?f(d,h,864e5,"day"):36e5<=h?f(d,h,36e5,"hour"):6e4<=h?f(d,h,6e4,"minute"):1e3<=h?f(d,h,1e3,"second"):d+" ms"}function f(d,h,p,m){return a(d/p)+" "+m+(h>=1.5*p?"s":"")}o.exports=function(d,h){h=h||{};var p=typeof d;if(p=="string"&&0<d.length)return l(d);if(p==="number"&&isFinite(d))return h.long?c(d):u(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},{}],12:[function(i,o){function a(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function u(k){if(m===setTimeout)return setTimeout(k,0);if((m===a||!m)&&setTimeout)return m=setTimeout,setTimeout(k,0);try{return m(k,0)}catch{try{return m.call(null,k,0)}catch{return m.call(this,k,0)}}}function c(k){if(g===clearTimeout)return clearTimeout(k);if((g===l||!g)&&clearTimeout)return g=clearTimeout,clearTimeout(k);try{return g(k)}catch{try{return g.call(null,k)}catch{return g.call(this,k)}}}function f(){A&&v&&(A=!1,v.length?w=v.concat(w):x=-1,w.length&&d())}function d(){if(!A){var k=u(f);A=!0;for(var C=w.length;C;){for(v=w,w=[];++x<C;)v&&v[x].run();x=-1,C=w.length}v=null,A=!1,c(k)}}function h(k,C){this.fun=k,this.array=C}function p(){}var m,g,y=o.exports={};(function(){try{m=typeof setTimeout=="function"?setTimeout:a}catch{m=a}try{g=typeof clearTimeout=="function"?clearTimeout:l}catch{g=l}})();var v,w=[],A=!1,x=-1;y.nextTick=function(k){var C=Array(arguments.length-1);if(1<arguments.length)for(var O=1;O<arguments.length;O++)C[O-1]=arguments[O];w.push(new h(k,C)),w.length!==1||A||u(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},y.title="browser",y.browser=!0,y.env={},y.argv=[],y.version="",y.versions={},y.on=p,y.addListener=p,y.once=p,y.off=p,y.removeListener=p,y.removeAllListeners=p,y.emit=p,y.prependListener=p,y.prependOnceListener=p,y.listeners=function(){return[]},y.binding=function(){throw new Error("process.binding is not supported")},y.cwd=function(){return"/"},y.chdir=function(){throw new Error("process.chdir is not supported")},y.umask=function(){return 0}},{}],13:[function(i,o){(function(a){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let l;o.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window>"u"?a:window):u=>(l||(l=Promise.resolve())).then(u).catch(c=>setTimeout(()=>{throw c},0))}).call(this)}).call(this,typeof tr>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:tr)},{}],14:[function(i,o){(function(a,l){(function(){var u=i("safe-buffer").Buffer,c=l.crypto||l.msCrypto;o.exports=c&&c.getRandomValues?function(f,d){if(f>4294967295)throw new RangeError("requested too many random bytes");var h=u.allocUnsafe(f);if(0<f)if(65536<f)for(var p=0;p<f;p+=65536)c.getRandomValues(h.slice(p,p+65536));else c.getRandomValues(h);return typeof d=="function"?a.nextTick(function(){d(null,h)}):h}:function(){throw new Error(`Secure random number generation is not supported by this browser.
476
476
  Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,i("_process"),typeof tr>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:tr)},{_process:12,"safe-buffer":30}],15:[function(i,o){function a(p,m){p.prototype=Object.create(m.prototype),p.prototype.constructor=p,p.__proto__=m}function l(p,m,g){function y(w,A,x){return typeof m=="string"?m:m(w,A,x)}g||(g=Error);var v=function(w){function A(x,k,C){return w.call(this,y(x,k,C))||this}return a(A,w),A}(g);v.prototype.name=g.name,v.prototype.code=p,h[p]=v}function u(p,m){if(Array.isArray(p)){var g=p.length;return p=p.map(function(y){return y+""}),2<g?"one of ".concat(m," ").concat(p.slice(0,g-1).join(", "),", or ")+p[g-1]:g===2?"one of ".concat(m," ").concat(p[0]," or ").concat(p[1]):"of ".concat(m," ").concat(p[0])}return"of ".concat(m," ").concat(p+"")}function c(p,m,g){return p.substr(0,m.length)===m}function f(p,m,g){return(g===void 0||g>p.length)&&(g=p.length),p.substring(g-m.length,g)===m}function d(p,m,g){return typeof g!="number"&&(g=0),!(g+m.length>p.length)&&p.indexOf(m,g)!==-1}var h={};l("ERR_INVALID_OPT_VALUE",function(p,m){return'The value "'+m+'" is invalid for option "'+p+'"'},TypeError),l("ERR_INVALID_ARG_TYPE",function(p,m,g){var y;typeof m=="string"&&c(m,"not ")?(y="must not be",m=m.replace(/^not /,"")):y="must be";var v;if(f(p," argument"))v="The ".concat(p," ").concat(y," ").concat(u(m,"type"));else{var w=d(p,".")?"property":"argument";v='The "'.concat(p,'" ').concat(w," ").concat(y," ").concat(u(m,"type"))}return v+=". Received type ".concat(typeof g),v},TypeError),l("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),l("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),l("ERR_STREAM_PREMATURE_CLOSE","Premature close"),l("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),l("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),l("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),l("ERR_STREAM_WRITE_AFTER_END","write after end"),l("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),l("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),l("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),o.exports.codes=h},{}],16:[function(i,o){(function(a){(function(){function l(y){return this instanceof l?(d.call(this,y),h.call(this,y),this.allowHalfOpen=!0,void(y&&(y.readable===!1&&(this.readable=!1),y.writable===!1&&(this.writable=!1),y.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",u))))):new l(y)}function u(){this._writableState.ended||a.nextTick(c,this)}function c(y){y.end()}var f=Object.keys||function(y){var v=[];for(var w in y)v.push(w);return v};o.exports=l;var d=i("./_stream_readable"),h=i("./_stream_writable");i("inherits")(l,d);for(var p,m=f(h.prototype),g=0;g<m.length;g++)p=m[g],l.prototype[p]||(l.prototype[p]=h.prototype[p]);Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(y){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=y,this._writableState.destroyed=y)}})}).call(this)}).call(this,i("_process"))},{"./_stream_readable":18,"./_stream_writable":20,_process:12,inherits:10}],17:[function(i,o){function a(u){return this instanceof a?void l.call(this,u):new a(u)}o.exports=a;var l=i("./_stream_transform");i("inherits")(a,l),a.prototype._transform=function(u,c,f){f(null,u)}},{"./_stream_transform":19,inherits:10}],18:[function(i,o){(function(a,l){(function(){function u(P){return Re.from(P)}function c(P){return Re.isBuffer(P)||P instanceof Ce}function f(P,b,E){return typeof P.prependListener=="function"?P.prependListener(b,E):void(P._events&&P._events[b]?Array.isArray(P._events[b])?P._events[b].unshift(E):P._events[b]=[E,P._events[b]]:P.on(b,E))}function d(P,b,E){te=te||i("./_stream_duplex"),P=P||{},typeof E!="boolean"&&(E=b instanceof te),this.objectMode=!!P.objectMode,E&&(this.objectMode=this.objectMode||!!P.readableObjectMode),this.highWaterMark=$e(this,P,"readableHighWaterMark",E),this.buffer=new Le,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=P.emitClose!==!1,this.autoDestroy=!!P.autoDestroy,this.destroyed=!1,this.defaultEncoding=P.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,P.encoding&&(!He&&(He=i("string_decoder/").StringDecoder),this.decoder=new He(P.encoding),this.encoding=P.encoding)}function h(P){if(te=te||i("./_stream_duplex"),!(this instanceof h))return new h(P);var b=this instanceof te;this._readableState=new d(P,this,b),this.readable=!0,P&&(typeof P.read=="function"&&(this._read=P.read),typeof P.destroy=="function"&&(this._destroy=P.destroy)),Ee.call(this)}function p(P,b,E,M,j){Z("readableAddChunk",b);var K=P._readableState;if(b===null)K.reading=!1,w(P,K);else{var Y;if(j||(Y=g(K,b)),Y)re(P,Y);else if(!(K.objectMode||b&&0<b.length))M||(K.reading=!1,k(P,K));else if(typeof b=="string"||K.objectMode||Object.getPrototypeOf(b)===Re.prototype||(b=u(b)),M)K.endEmitted?re(P,new q):m(P,K,b,!0);else if(K.ended)re(P,new Be);else{if(K.destroyed)return!1;K.reading=!1,K.decoder&&!E?(b=K.decoder.write(b),K.objectMode||b.length!==0?m(P,K,b,!1):k(P,K)):m(P,K,b,!1)}}return!K.ended&&(K.length<K.highWaterMark||K.length===0)}function m(P,b,E,M){b.flowing&&b.length===0&&!b.sync?(b.awaitDrain=0,P.emit("data",E)):(b.length+=b.objectMode?1:E.length,M?b.buffer.unshift(E):b.buffer.push(E),b.needReadable&&A(P)),k(P,b)}function g(P,b){var E;return c(b)||typeof b=="string"||b===void 0||P.objectMode||(E=new be("chunk",["string","Buffer","Uint8Array"],b)),E}function y(P){return 1073741824<=P?P=1073741824:(P--,P|=P>>>1,P|=P>>>2,P|=P>>>4,P|=P>>>8,P|=P>>>16,P++),P}function v(P,b){return 0>=P||b.length===0&&b.ended?0:b.objectMode?1:P===P?(P>b.highWaterMark&&(b.highWaterMark=y(P)),P<=b.length?P:b.ended?b.length:(b.needReadable=!0,0)):b.flowing&&b.length?b.buffer.head.data.length:b.length}function w(P,b){if(Z("onEofChunk"),!b.ended){if(b.decoder){var E=b.decoder.end();E&&E.length&&(b.buffer.push(E),b.length+=b.objectMode?1:E.length)}b.ended=!0,b.sync?A(P):(b.needReadable=!1,!b.emittedReadable&&(b.emittedReadable=!0,x(P)))}}function A(P){var b=P._readableState;Z("emitReadable",b.needReadable,b.emittedReadable),b.needReadable=!1,b.emittedReadable||(Z("emitReadable",b.flowing),b.emittedReadable=!0,a.nextTick(x,P))}function x(P){var b=P._readableState;Z("emitReadable_",b.destroyed,b.length,b.ended),!b.destroyed&&(b.length||b.ended)&&(P.emit("readable"),b.emittedReadable=!1),b.needReadable=!b.flowing&&!b.ended&&b.length<=b.highWaterMark,F(P)}function k(P,b){b.readingMore||(b.readingMore=!0,a.nextTick(C,P,b))}function C(P,b){for(;!b.reading&&!b.ended&&(b.length<b.highWaterMark||b.flowing&&b.length===0);){var E=b.length;if(Z("maybeReadMore read 0"),P.read(0),E===b.length)break}b.readingMore=!1}function O(P){return function(){var b=P._readableState;Z("pipeOnDrain",b.awaitDrain),b.awaitDrain&&b.awaitDrain--,b.awaitDrain===0&&pe(P,"data")&&(b.flowing=!0,F(P))}}function _(P){var b=P._readableState;b.readableListening=0<P.listenerCount("readable"),b.resumeScheduled&&!b.paused?b.flowing=!0:0<P.listenerCount("data")&&P.resume()}function D(P){Z("readable nexttick read 0"),P.read(0)}function R(P,b){b.resumeScheduled||(b.resumeScheduled=!0,a.nextTick(L,P,b))}function L(P,b){Z("resume",b.reading),b.reading||P.read(0),b.resumeScheduled=!1,P.emit("resume"),F(P),b.flowing&&!b.reading&&P.read(0)}function F(P){var b=P._readableState;for(Z("flow",b.flowing);b.flowing&&P.read()!==null;);}function G(P,b){if(b.length===0)return null;var E;return b.objectMode?E=b.buffer.shift():!P||P>=b.length?(E=b.decoder?b.buffer.join(""):b.buffer.length===1?b.buffer.first():b.buffer.concat(b.length),b.buffer.clear()):E=b.buffer.consume(P,b.decoder),E}function B(P){var b=P._readableState;Z("endReadable",b.endEmitted),b.endEmitted||(b.ended=!0,a.nextTick(H,b,P))}function H(P,b){if(Z("endReadableNT",P.endEmitted,P.length),!P.endEmitted&&P.length===0&&(P.endEmitted=!0,b.readable=!1,b.emit("end"),P.autoDestroy)){var E=b._writableState;(!E||E.autoDestroy&&E.finished)&&b.destroy()}}function Q(P,b){for(var E=0,M=P.length;E<M;E++)if(P[E]===b)return E;return-1}o.exports=h;var te;h.ReadableState=d;var Z;i("events").EventEmitter;var pe=function(P,b){return P.listeners(b).length},Ee=i("./internal/streams/stream"),Re=i("buffer").Buffer,Ce=l.Uint8Array||function(){},ke=i("util");Z=ke&&ke.debuglog?ke.debuglog("stream"):function(){};var He,Ue,ze,Le=i("./internal/streams/buffer_list"),tt=i("./internal/streams/destroy"),le=i("./internal/streams/state"),$e=le.getHighWaterMark,ae=i("../errors").codes,be=ae.ERR_INVALID_ARG_TYPE,Be=ae.ERR_STREAM_PUSH_AFTER_EOF,z=ae.ERR_METHOD_NOT_IMPLEMENTED,q=ae.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;i("inherits")(h,Ee);var re=tt.errorOrDestroy,ue=["error","close","destroy","pause","resume"];Object.defineProperty(h.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(P){this._readableState&&(this._readableState.destroyed=P)}}),h.prototype.destroy=tt.destroy,h.prototype._undestroy=tt.undestroy,h.prototype._destroy=function(P,b){b(P)},h.prototype.push=function(P,b){var E,M=this._readableState;return M.objectMode?E=!0:typeof P=="string"&&(b=b||M.defaultEncoding,b!==M.encoding&&(P=Re.from(P,b),b=""),E=!0),p(this,P,b,!1,E)},h.prototype.unshift=function(P){return p(this,P,null,!0,!1)},h.prototype.isPaused=function(){return this._readableState.flowing===!1},h.prototype.setEncoding=function(P){He||(He=i("string_decoder/").StringDecoder);var b=new He(P);this._readableState.decoder=b,this._readableState.encoding=this._readableState.decoder.encoding;for(var E=this._readableState.buffer.head,M="";E!==null;)M+=b.write(E.data),E=E.next;return this._readableState.buffer.clear(),M!==""&&this._readableState.buffer.push(M),this._readableState.length=M.length,this},h.prototype.read=function(P){Z("read",P),P=parseInt(P,10);var b=this._readableState,E=P;if(P!==0&&(b.emittedReadable=!1),P===0&&b.needReadable&&((b.highWaterMark===0?0<b.length:b.length>=b.highWaterMark)||b.ended))return Z("read: emitReadable",b.length,b.ended),b.length===0&&b.ended?B(this):A(this),null;if(P=v(P,b),P===0&&b.ended)return b.length===0&&B(this),null;var M=b.needReadable;Z("need readable",M),(b.length===0||b.length-P<b.highWaterMark)&&(M=!0,Z("length less than watermark",M)),b.ended||b.reading?(M=!1,Z("reading or ended",M)):M&&(Z("do read"),b.reading=!0,b.sync=!0,b.length===0&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1,!b.reading&&(P=v(E,b)));var j;return j=0<P?G(P,b):null,j===null?(b.needReadable=b.length<=b.highWaterMark,P=0):(b.length-=P,b.awaitDrain=0),b.length===0&&(!b.ended&&(b.needReadable=!0),E!==P&&b.ended&&B(this)),j!==null&&this.emit("data",j),j},h.prototype._read=function(){re(this,new z("_read()"))},h.prototype.pipe=function(P,b){function E(ne,ie){Z("onunpipe"),ne===Ve&&ie&&ie.hasUnpiped===!1&&(ie.hasUnpiped=!0,j())}function M(){Z("onend"),P.end()}function j(){Z("cleanup"),P.removeListener("close",ye),P.removeListener("finish",Se),P.removeListener("drain",br),P.removeListener("error",Y),P.removeListener("unpipe",E),Ve.removeListener("end",M),Ve.removeListener("end",Je),Ve.removeListener("data",K),X=!0,Fe.awaitDrain&&(!P._writableState||P._writableState.needDrain)&&br()}function K(ne){Z("ondata");var ie=P.write(ne);Z("dest.write",ie),ie===!1&&((Fe.pipesCount===1&&Fe.pipes===P||1<Fe.pipesCount&&Q(Fe.pipes,P)!==-1)&&!X&&(Z("false write response, pause",Fe.awaitDrain),Fe.awaitDrain++),Ve.pause())}function Y(ne){Z("onerror",ne),Je(),P.removeListener("error",Y),pe(P,"error")===0&&re(P,ne)}function ye(){P.removeListener("finish",Se),Je()}function Se(){Z("onfinish"),P.removeListener("close",ye),Je()}function Je(){Z("unpipe"),Ve.unpipe(P)}var Ve=this,Fe=this._readableState;switch(Fe.pipesCount){case 0:Fe.pipes=P;break;case 1:Fe.pipes=[Fe.pipes,P];break;default:Fe.pipes.push(P)}Fe.pipesCount+=1,Z("pipe count=%d opts=%j",Fe.pipesCount,b);var ft=(!b||b.end!==!1)&&P!==a.stdout&&P!==a.stderr,Xn=ft?M:Je;Fe.endEmitted?a.nextTick(Xn):Ve.once("end",Xn),P.on("unpipe",E);var br=O(Ve);P.on("drain",br);var X=!1;return Ve.on("data",K),f(P,"error",Y),P.once("close",ye),P.once("finish",Se),P.emit("pipe",Ve),Fe.flowing||(Z("pipe resume"),Ve.resume()),P},h.prototype.unpipe=function(P){var b=this._readableState,E={hasUnpiped:!1};if(b.pipesCount===0)return this;if(b.pipesCount===1)return P&&P!==b.pipes?this:(P||(P=b.pipes),b.pipes=null,b.pipesCount=0,b.flowing=!1,P&&P.emit("unpipe",this,E),this);if(!P){var M=b.pipes,j=b.pipesCount;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var K=0;K<j;K++)M[K].emit("unpipe",this,{hasUnpiped:!1});return this}var Y=Q(b.pipes,P);return Y===-1?this:(b.pipes.splice(Y,1),b.pipesCount-=1,b.pipesCount===1&&(b.pipes=b.pipes[0]),P.emit("unpipe",this,E),this)},h.prototype.on=function(P,b){var E=Ee.prototype.on.call(this,P,b),M=this._readableState;return P==="data"?(M.readableListening=0<this.listenerCount("readable"),M.flowing!==!1&&this.resume()):P=="readable"&&!M.endEmitted&&!M.readableListening&&(M.readableListening=M.needReadable=!0,M.flowing=!1,M.emittedReadable=!1,Z("on readable",M.length,M.reading),M.length?A(this):!M.reading&&a.nextTick(D,this)),E},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(P,b){var E=Ee.prototype.removeListener.call(this,P,b);return P==="readable"&&a.nextTick(_,this),E},h.prototype.removeAllListeners=function(P){var b=Ee.prototype.removeAllListeners.apply(this,arguments);return(P==="readable"||P===void 0)&&a.nextTick(_,this),b},h.prototype.resume=function(){var P=this._readableState;return P.flowing||(Z("resume"),P.flowing=!P.readableListening,R(this,P)),P.paused=!1,this},h.prototype.pause=function(){return Z("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Z("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(P){var b=this,E=this._readableState,M=!1;for(var j in P.on("end",function(){if(Z("wrapped end"),E.decoder&&!E.ended){var Y=E.decoder.end();Y&&Y.length&&b.push(Y)}b.push(null)}),P.on("data",function(Y){if(Z("wrapped data"),E.decoder&&(Y=E.decoder.write(Y)),!(E.objectMode&&Y==null)&&(E.objectMode||Y&&Y.length)){var ye=b.push(Y);ye||(M=!0,P.pause())}}),P)this[j]===void 0&&typeof P[j]=="function"&&(this[j]=function(Y){return function(){return P[Y].apply(P,arguments)}}(j));for(var K=0;K<ue.length;K++)P.on(ue[K],this.emit.bind(this,ue[K]));return this._read=function(Y){Z("wrapped _read",Y),M&&(M=!1,P.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Ue===void 0&&(Ue=i("./internal/streams/async_iterator")),Ue(this)}),Object.defineProperty(h.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(h.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(h.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(P){this._readableState&&(this._readableState.flowing=P)}}),h._fromList=G,Object.defineProperty(h.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(h.from=function(P,b){return ze===void 0&&(ze=i("./internal/streams/from")),ze(h,P,b)})}).call(this)}).call(this,i("_process"),typeof tr>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:tr)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/async_iterator":21,"./internal/streams/buffer_list":22,"./internal/streams/destroy":23,"./internal/streams/from":25,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,events:7,inherits:10,"string_decoder/":31,util:2}],19:[function(i,o){function a(y,v){var w=this._transformState;w.transforming=!1;var A=w.writecb;if(A===null)return this.emit("error",new h);w.writechunk=null,w.writecb=null,v!=null&&this.push(v),A(y);var x=this._readableState;x.reading=!1,(x.needReadable||x.length<x.highWaterMark)&&this._read(x.highWaterMark)}function l(y){return this instanceof l?(g.call(this,y),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,y&&(typeof y.transform=="function"&&(this._transform=y.transform),typeof y.flush=="function"&&(this._flush=y.flush)),void this.on("prefinish",u)):new l(y)}function u(){var y=this;typeof this._flush!="function"||this._readableState.destroyed?c(this,null,null):this._flush(function(v,w){c(y,v,w)})}function c(y,v,w){if(v)return y.emit("error",v);if(w!=null&&y.push(w),y._writableState.length)throw new m;if(y._transformState.transforming)throw new p;return y.push(null)}o.exports=l;var f=i("../errors").codes,d=f.ERR_METHOD_NOT_IMPLEMENTED,h=f.ERR_MULTIPLE_CALLBACK,p=f.ERR_TRANSFORM_ALREADY_TRANSFORMING,m=f.ERR_TRANSFORM_WITH_LENGTH_0,g=i("./_stream_duplex");i("inherits")(l,g),l.prototype.push=function(y,v){return this._transformState.needTransform=!1,g.prototype.push.call(this,y,v)},l.prototype._transform=function(y,v,w){w(new d("_transform()"))},l.prototype._write=function(y,v,w){var A=this._transformState;if(A.writecb=w,A.writechunk=y,A.writeencoding=v,!A.transforming){var x=this._readableState;(A.needTransform||x.needReadable||x.length<x.highWaterMark)&&this._read(x.highWaterMark)}},l.prototype._read=function(){var y=this._transformState;y.writechunk===null||y.transforming?y.needTransform=!0:(y.transforming=!0,this._transform(y.writechunk,y.writeencoding,y.afterTransform))},l.prototype._destroy=function(y,v){g.prototype._destroy.call(this,y,function(w){v(w)})}},{"../errors":15,"./_stream_duplex":16,inherits:10}],20:[function(i,o){(function(a,l){(function(){function u(z){var q=this;this.next=null,this.entry=null,this.finish=function(){B(q,z)}}function c(z){return Z.from(z)}function f(z){return Z.isBuffer(z)||z instanceof pe}function d(){}function h(z,q,re){H=H||i("./_stream_duplex"),z=z||{},typeof re!="boolean"&&(re=q instanceof H),this.objectMode=!!z.objectMode,re&&(this.objectMode=this.objectMode||!!z.writableObjectMode),this.highWaterMark=Ce(this,z,"writableHighWaterMark",re),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var ue=z.decodeStrings===!1;this.decodeStrings=!ue,this.defaultEncoding=z.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){k(q,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=z.emitClose!==!1,this.autoDestroy=!!z.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new u(this)}function p(z){H=H||i("./_stream_duplex");var q=this instanceof H;return q||Be.call(p,this)?(this._writableState=new h(z,this,q),this.writable=!0,z&&(typeof z.write=="function"&&(this._write=z.write),typeof z.writev=="function"&&(this._writev=z.writev),typeof z.destroy=="function"&&(this._destroy=z.destroy),typeof z.final=="function"&&(this._final=z.final)),void te.call(this)):new p(z)}function m(z,q){var re=new $e;be(z,re),a.nextTick(q,re)}function g(z,q,re,ue){var P;return re===null?P=new le:typeof re!="string"&&!q.objectMode&&(P=new He("chunk",["string","Buffer"],re)),!P||(be(z,P),a.nextTick(ue,P),!1)}function y(z,q,re){return z.objectMode||z.decodeStrings===!1||typeof q!="string"||(q=Z.from(q,re)),q}function v(z,q,re,ue,P,b){if(!re){var E=y(q,ue,P);ue!==E&&(re=!0,P="buffer",ue=E)}var M=q.objectMode?1:ue.length;q.length+=M;var j=q.length<q.highWaterMark;if(j||(q.needDrain=!0),q.writing||q.corked){var K=q.lastBufferedRequest;q.lastBufferedRequest={chunk:ue,encoding:P,isBuf:re,callback:b,next:null},K?K.next=q.lastBufferedRequest:q.bufferedRequest=q.lastBufferedRequest,q.bufferedRequestCount+=1}else w(z,q,!1,M,ue,P,b);return j}function w(z,q,re,ue,P,b,E){q.writelen=ue,q.writecb=E,q.writing=!0,q.sync=!0,q.destroyed?q.onwrite(new tt("write")):re?z._writev(P,q.onwrite):z._write(P,b,q.onwrite),q.sync=!1}function A(z,q,re,ue,P){--q.pendingcb,re?(a.nextTick(P,ue),a.nextTick(F,z,q),z._writableState.errorEmitted=!0,be(z,ue)):(P(ue),z._writableState.errorEmitted=!0,be(z,ue),F(z,q))}function x(z){z.writing=!1,z.writecb=null,z.length-=z.writelen,z.writelen=0}function k(z,q){var re=z._writableState,ue=re.sync,P=re.writecb;if(typeof P!="function")throw new ze;if(x(re),q)A(z,re,ue,q,P);else{var b=D(re)||z.destroyed;b||re.corked||re.bufferProcessing||!re.bufferedRequest||_(z,re),ue?a.nextTick(C,z,re,b,P):C(z,re,b,P)}}function C(z,q,re,ue){re||O(z,q),q.pendingcb--,ue(),F(z,q)}function O(z,q){q.length===0&&q.needDrain&&(q.needDrain=!1,z.emit("drain"))}function _(z,q){q.bufferProcessing=!0;var re=q.bufferedRequest;if(z._writev&&re&&re.next){var ue=q.bufferedRequestCount,P=Array(ue),b=q.corkedRequestsFree;b.entry=re;for(var E=0,M=!0;re;)P[E]=re,re.isBuf||(M=!1),re=re.next,E+=1;P.allBuffers=M,w(z,q,!0,q.length,P,"",b.finish),q.pendingcb++,q.lastBufferedRequest=null,b.next?(q.corkedRequestsFree=b.next,b.next=null):q.corkedRequestsFree=new u(q),q.bufferedRequestCount=0}else{for(;re;){var j=re.chunk,K=re.encoding,Y=re.callback,ye=q.objectMode?1:j.length;if(w(z,q,!1,ye,j,K,Y),re=re.next,q.bufferedRequestCount--,q.writing)break}re===null&&(q.lastBufferedRequest=null)}q.bufferedRequest=re,q.bufferProcessing=!1}function D(z){return z.ending&&z.length===0&&z.bufferedRequest===null&&!z.finished&&!z.writing}function R(z,q){z._final(function(re){q.pendingcb--,re&&be(z,re),q.prefinished=!0,z.emit("prefinish"),F(z,q)})}function L(z,q){q.prefinished||q.finalCalled||(typeof z._final!="function"||q.destroyed?(q.prefinished=!0,z.emit("prefinish")):(q.pendingcb++,q.finalCalled=!0,a.nextTick(R,z,q)))}function F(z,q){var re=D(q);if(re&&(L(z,q),q.pendingcb===0&&(q.finished=!0,z.emit("finish"),q.autoDestroy))){var ue=z._readableState;(!ue||ue.autoDestroy&&ue.endEmitted)&&z.destroy()}return re}function G(z,q,re){q.ending=!0,F(z,q),re&&(q.finished?a.nextTick(re):z.once("finish",re)),q.ended=!0,z.writable=!1}function B(z,q,re){var ue=z.entry;for(z.entry=null;ue;){var P=ue.callback;q.pendingcb--,P(re),ue=ue.next}q.corkedRequestsFree.next=z}o.exports=p;var H;p.WritableState=h;var Q={deprecate:i("util-deprecate")},te=i("./internal/streams/stream"),Z=i("buffer").Buffer,pe=l.Uint8Array||function(){},Ee=i("./internal/streams/destroy"),Re=i("./internal/streams/state"),Ce=Re.getHighWaterMark,ke=i("../errors").codes,He=ke.ERR_INVALID_ARG_TYPE,Ue=ke.ERR_METHOD_NOT_IMPLEMENTED,ze=ke.ERR_MULTIPLE_CALLBACK,Le=ke.ERR_STREAM_CANNOT_PIPE,tt=ke.ERR_STREAM_DESTROYED,le=ke.ERR_STREAM_NULL_VALUES,$e=ke.ERR_STREAM_WRITE_AFTER_END,ae=ke.ERR_UNKNOWN_ENCODING,be=Ee.errorOrDestroy;i("inherits")(p,te),h.prototype.getBuffer=function(){for(var z=this.bufferedRequest,q=[];z;)q.push(z),z=z.next;return q},function(){try{Object.defineProperty(h.prototype,"buffer",{get:Q.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var Be;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Be=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function(z){return!!Be.call(this,z)||this===p&&z&&z._writableState instanceof h}})):Be=function(z){return z instanceof this},p.prototype.pipe=function(){be(this,new Le)},p.prototype.write=function(z,q,re){var ue=this._writableState,P=!1,b=!ue.objectMode&&f(z);return b&&!Z.isBuffer(z)&&(z=c(z)),typeof q=="function"&&(re=q,q=null),b?q="buffer":!q&&(q=ue.defaultEncoding),typeof re!="function"&&(re=d),ue.ending?m(this,re):(b||g(this,ue,z,re))&&(ue.pendingcb++,P=v(this,ue,b,z,q,re)),P},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var z=this._writableState;z.corked&&(z.corked--,!z.writing&&!z.corked&&!z.bufferProcessing&&z.bufferedRequest&&_(this,z))},p.prototype.setDefaultEncoding=function(z){if(typeof z=="string"&&(z=z.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((z+"").toLowerCase())))throw new ae(z);return this._writableState.defaultEncoding=z,this},Object.defineProperty(p.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function(z,q,re){re(new Ue("_write()"))},p.prototype._writev=null,p.prototype.end=function(z,q,re){var ue=this._writableState;return typeof z=="function"?(re=z,z=null,q=null):typeof q=="function"&&(re=q,q=null),z!=null&&this.write(z,q),ue.corked&&(ue.corked=1,this.uncork()),ue.ending||G(this,ue,re),this},Object.defineProperty(p.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(p.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(z){this._writableState&&(this._writableState.destroyed=z)}}),p.prototype.destroy=Ee.destroy,p.prototype._undestroy=Ee.undestroy,p.prototype._destroy=function(z,q){q(z)}}).call(this)}).call(this,i("_process"),typeof tr>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:tr)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,inherits:10,"util-deprecate":32}],21:[function(i,o){(function(a){(function(){function l(O,_,D){return _ in O?Object.defineProperty(O,_,{value:D,enumerable:!0,configurable:!0,writable:!0}):O[_]=D,O}function u(O,_){return{value:O,done:_}}function c(O){var _=O[m];if(_!==null){var D=O[x].read();D!==null&&(O[w]=null,O[m]=null,O[g]=null,_(u(D,!1)))}}function f(O){a.nextTick(c,O)}function d(O,_){return function(D,R){O.then(function(){return _[v]?void D(u(void 0,!0)):void _[A](D,R)},R)}}var h,p=i("./end-of-stream"),m=Symbol("lastResolve"),g=Symbol("lastReject"),y=Symbol("error"),v=Symbol("ended"),w=Symbol("lastPromise"),A=Symbol("handlePromise"),x=Symbol("stream"),k=Object.getPrototypeOf(function(){}),C=Object.setPrototypeOf((h={get stream(){return this[x]},next:function(){var O=this,_=this[y];if(_!==null)return Promise.reject(_);if(this[v])return Promise.resolve(u(void 0,!0));if(this[x].destroyed)return new Promise(function(F,G){a.nextTick(function(){O[y]?G(O[y]):F(u(void 0,!0))})});var D,R=this[w];if(R)D=new Promise(d(R,this));else{var L=this[x].read();if(L!==null)return Promise.resolve(u(L,!1));D=new Promise(this[A])}return this[w]=D,D}},l(h,Symbol.asyncIterator,function(){return this}),l(h,"return",function(){var O=this;return new Promise(function(_,D){O[x].destroy(null,function(R){return R?void D(R):void _(u(void 0,!0))})})}),h),k);o.exports=function(O){var _,D=Object.create(C,(_={},l(_,x,{value:O,writable:!0}),l(_,m,{value:null,writable:!0}),l(_,g,{value:null,writable:!0}),l(_,y,{value:null,writable:!0}),l(_,v,{value:O._readableState.endEmitted,writable:!0}),l(_,A,{value:function(R,L){var F=D[x].read();F?(D[w]=null,D[m]=null,D[g]=null,R(u(F,!1))):(D[m]=R,D[g]=L)},writable:!0}),_));return D[w]=null,p(O,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var L=D[g];return L!==null&&(D[w]=null,D[m]=null,D[g]=null,L(R)),void(D[y]=R)}var F=D[m];F!==null&&(D[w]=null,D[m]=null,D[g]=null,F(u(void 0,!0))),D[v]=!0}),O.on("readable",f.bind(null,D)),D}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":24,_process:12}],22:[function(i,o){function a(w,A){var x=Object.keys(w);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(w);A&&(k=k.filter(function(C){return Object.getOwnPropertyDescriptor(w,C).enumerable})),x.push.apply(x,k)}return x}function l(w){for(var A,x=1;x<arguments.length;x++)A=arguments[x]==null?{}:arguments[x],x%2?a(Object(A),!0).forEach(function(k){u(w,k,A[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(A)):a(Object(A)).forEach(function(k){Object.defineProperty(w,k,Object.getOwnPropertyDescriptor(A,k))});return w}function u(w,A,x){return A in w?Object.defineProperty(w,A,{value:x,enumerable:!0,configurable:!0,writable:!0}):w[A]=x,w}function c(w,A){if(!(w instanceof A))throw new TypeError("Cannot call a class as a function")}function f(w,A){for(var x,k=0;k<A.length;k++)x=A[k],x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(w,x.key,x)}function d(w,A,x){return A&&f(w.prototype,A),w}function h(w,A,x){m.prototype.copy.call(w,A,x)}var p=i("buffer"),m=p.Buffer,g=i("util"),y=g.inspect,v=y&&y.custom||"inspect";o.exports=function(){function w(){c(this,w),this.head=null,this.tail=null,this.length=0}return d(w,[{key:"push",value:function(A){var x={data:A,next:null};0<this.length?this.tail.next=x:this.head=x,this.tail=x,++this.length}},{key:"unshift",value:function(A){var x={data:A,next:this.head};this.length===0&&(this.tail=x),this.head=x,++this.length}},{key:"shift",value:function(){if(this.length!==0){var A=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,A}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(A){if(this.length===0)return"";for(var x=this.head,k=""+x.data;x=x.next;)k+=A+x.data;return k}},{key:"concat",value:function(A){if(this.length===0)return m.alloc(0);for(var x=m.allocUnsafe(A>>>0),k=this.head,C=0;k;)h(k.data,x,C),C+=k.data.length,k=k.next;return x}},{key:"consume",value:function(A,x){var k;return A<this.head.data.length?(k=this.head.data.slice(0,A),this.head.data=this.head.data.slice(A)):A===this.head.data.length?k=this.shift():k=x?this._getString(A):this._getBuffer(A),k}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(A){var x=this.head,k=1,C=x.data;for(A-=C.length;x=x.next;){var O=x.data,_=A>O.length?O.length:A;if(C+=_===O.length?O:O.slice(0,A),A-=_,A===0){_===O.length?(++k,this.head=x.next?x.next:this.tail=null):(this.head=x,x.data=O.slice(_));break}++k}return this.length-=k,C}},{key:"_getBuffer",value:function(A){var x=m.allocUnsafe(A),k=this.head,C=1;for(k.data.copy(x),A-=k.data.length;k=k.next;){var O=k.data,_=A>O.length?O.length:A;if(O.copy(x,x.length-A,0,_),A-=_,A===0){_===O.length?(++C,this.head=k.next?k.next:this.tail=null):(this.head=k,k.data=O.slice(_));break}++C}return this.length-=C,x}},{key:v,value:function(A,x){return y(this,l({},x,{depth:0,customInspect:!1}))}}]),w}()},{buffer:3,util:2}],23:[function(i,o){(function(a){(function(){function l(f,d){c(f,d),u(f)}function u(f){f._writableState&&!f._writableState.emitClose||f._readableState&&!f._readableState.emitClose||f.emit("close")}function c(f,d){f.emit("error",d)}o.exports={destroy:function(f,d){var h=this,p=this._readableState&&this._readableState.destroyed,m=this._writableState&&this._writableState.destroyed;return p||m?(d?d(f):f&&(this._writableState?!this._writableState.errorEmitted&&(this._writableState.errorEmitted=!0,a.nextTick(c,this,f)):a.nextTick(c,this,f)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(f||null,function(g){!d&&g?h._writableState?h._writableState.errorEmitted?a.nextTick(u,h):(h._writableState.errorEmitted=!0,a.nextTick(l,h,g)):a.nextTick(l,h,g):d?(a.nextTick(u,h),d(g)):a.nextTick(u,h)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(f,d){var h=f._readableState,p=f._writableState;h&&h.autoDestroy||p&&p.autoDestroy?f.destroy(d):f.emit("error",d)}}}).call(this)}).call(this,i("_process"))},{_process:12}],24:[function(i,o){function a(d){var h=!1;return function(){if(!h){h=!0;for(var p=arguments.length,m=Array(p),g=0;g<p;g++)m[g]=arguments[g];d.apply(this,m)}}}function l(){}function u(d){return d.setHeader&&typeof d.abort=="function"}function c(d,h,p){if(typeof h=="function")return c(d,null,h);h||(h={}),p=a(p||l);var m=h.readable||h.readable!==!1&&d.readable,g=h.writable||h.writable!==!1&&d.writable,y=function(){d.writable||w()},v=d._writableState&&d._writableState.finished,w=function(){g=!1,v=!0,m||p.call(d)},A=d._readableState&&d._readableState.endEmitted,x=function(){m=!1,A=!0,g||p.call(d)},k=function(_){p.call(d,_)},C=function(){var _;return m&&!A?(d._readableState&&d._readableState.ended||(_=new f),p.call(d,_)):g&&!v?(d._writableState&&d._writableState.ended||(_=new f),p.call(d,_)):void 0},O=function(){d.req.on("finish",w)};return u(d)?(d.on("complete",w),d.on("abort",C),d.req?O():d.on("request",O)):g&&!d._writableState&&(d.on("end",y),d.on("close",y)),d.on("end",x),d.on("finish",w),h.error!==!1&&d.on("error",k),d.on("close",C),function(){d.removeListener("complete",w),d.removeListener("abort",C),d.removeListener("request",O),d.req&&d.req.removeListener("finish",w),d.removeListener("end",y),d.removeListener("close",y),d.removeListener("finish",w),d.removeListener("end",x),d.removeListener("error",k),d.removeListener("close",C)}}var f=i("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;o.exports=c},{"../../../errors":15}],25:[function(i,o){o.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],26:[function(i,o){function a(v){var w=!1;return function(){w||(w=!0,v.apply(void 0,arguments))}}function l(v){if(v)throw v}function u(v){return v.setHeader&&typeof v.abort=="function"}function c(v,w,A,x){x=a(x);var k=!1;v.on("close",function(){k=!0}),p===void 0&&(p=i("./end-of-stream")),p(v,{readable:w,writable:A},function(O){return O?x(O):(k=!0,void x())});var C=!1;return function(O){if(!k)return C?void 0:(C=!0,u(v)?v.abort():typeof v.destroy=="function"?v.destroy():void x(O||new y("pipe")))}}function f(v){v()}function d(v,w){return v.pipe(w)}function h(v){return v.length&&typeof v[v.length-1]=="function"?v.pop():l}var p,m=i("../../../errors").codes,g=m.ERR_MISSING_ARGS,y=m.ERR_STREAM_DESTROYED;o.exports=function(){for(var v=arguments.length,w=Array(v),A=0;A<v;A++)w[A]=arguments[A];var x=h(w);if(Array.isArray(w[0])&&(w=w[0]),2>w.length)throw new g("streams");var k,C=w.map(function(O,_){var D=_<w.length-1;return c(O,D,0<_,function(R){k||(k=R),R&&C.forEach(f),D||(C.forEach(f),x(k))})});return w.reduce(d)}},{"../../../errors":15,"./end-of-stream":24}],27:[function(i,o){function a(u,c,f){return u.highWaterMark==null?c?u[f]:null:u.highWaterMark}var l=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;o.exports={getHighWaterMark:function(u,c,f,d){var h=a(c,d,f);if(h!=null){if(!(isFinite(h)&&n(h)===h)||0>h){var p=d?f:"highWaterMark";throw new l(p,h)}return n(h)}return u.objectMode?16:16384}}},{"../../../errors":15}],28:[function(i,o){o.exports=i("events").EventEmitter},{events:7}],29:[function(i,o,a){a=o.exports=i("./lib/_stream_readable.js"),a.Stream=a,a.Readable=a,a.Writable=i("./lib/_stream_writable.js"),a.Duplex=i("./lib/_stream_duplex.js"),a.Transform=i("./lib/_stream_transform.js"),a.PassThrough=i("./lib/_stream_passthrough.js"),a.finished=i("./lib/internal/streams/end-of-stream.js"),a.pipeline=i("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(i,o,a){function l(d,h){for(var p in d)h[p]=d[p]}function u(d,h,p){return f(d,h,p)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var c=i("buffer"),f=c.Buffer;f.from&&f.alloc&&f.allocUnsafe&&f.allocUnsafeSlow?o.exports=c:(l(c,a),a.Buffer=u),u.prototype=Object.create(f.prototype),l(f,u),u.from=function(d,h,p){if(typeof d=="number")throw new TypeError("Argument must not be a number");return f(d,h,p)},u.alloc=function(d,h,p){if(typeof d!="number")throw new TypeError("Argument must be a number");var m=f(d);return h===void 0?m.fill(0):typeof p=="string"?m.fill(h,p):m.fill(h),m},u.allocUnsafe=function(d){if(typeof d!="number")throw new TypeError("Argument must be a number");return f(d)},u.allocUnsafeSlow=function(d){if(typeof d!="number")throw new TypeError("Argument must be a number");return c.SlowBuffer(d)}},{buffer:3}],31:[function(i,o,a){function l(C){if(!C)return"utf8";for(var O;;)switch(C){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return C;default:if(O)return;C=(""+C).toLowerCase(),O=!0}}function u(C){var O=l(C);if(typeof O!="string"&&(x.isEncoding===k||!k(C)))throw new Error("Unknown encoding: "+C);return O||C}function c(C){this.encoding=u(C);var O;switch(this.encoding){case"utf16le":this.text=m,this.end=g,O=4;break;case"utf8":this.fillLast=p,O=4;break;case"base64":this.text=y,this.end=v,O=3;break;default:return this.write=w,void(this.end=A)}this.lastNeed=0,this.lastTotal=0,this.lastChar=x.allocUnsafe(O)}function f(C){return 127>=C?0:C>>5==6?2:C>>4==14?3:C>>3==30?4:C>>6==2?-1:-2}function d(C,O,_){var D=O.length-1;if(D<_)return 0;var R=f(O[D]);return 0<=R?(0<R&&(C.lastNeed=R-1),R):--D<_||R===-2?0:(R=f(O[D]),0<=R?(0<R&&(C.lastNeed=R-2),R):--D<_||R===-2?0:(R=f(O[D]),0<=R?(0<R&&(R===2?R=0:C.lastNeed=R-3),R):0))}function h(C,O){if((192&O[0])!=128)return C.lastNeed=0,"�";if(1<C.lastNeed&&1<O.length){if((192&O[1])!=128)return C.lastNeed=1,"�";if(2<C.lastNeed&&2<O.length&&(192&O[2])!=128)return C.lastNeed=2,"�"}}function p(C){var O=this.lastTotal-this.lastNeed,_=h(this,C);return _===void 0?this.lastNeed<=C.length?(C.copy(this.lastChar,O,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(C.copy(this.lastChar,O,0,C.length),void(this.lastNeed-=C.length)):_}function m(C,O){if((C.length-O)%2==0){var _=C.toString("utf16le",O);if(_){var D=_.charCodeAt(_.length-1);if(55296<=D&&56319>=D)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=C[C.length-2],this.lastChar[1]=C[C.length-1],_.slice(0,-1)}return _}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=C[C.length-1],C.toString("utf16le",O,C.length-1)}function g(C){var O=C&&C.length?this.write(C):"";if(this.lastNeed){var _=this.lastTotal-this.lastNeed;return O+this.lastChar.toString("utf16le",0,_)}return O}function y(C,O){var _=(C.length-O)%3;return _==0?C.toString("base64",O):(this.lastNeed=3-_,this.lastTotal=3,_==1?this.lastChar[0]=C[C.length-1]:(this.lastChar[0]=C[C.length-2],this.lastChar[1]=C[C.length-1]),C.toString("base64",O,C.length-_))}function v(C){var O=C&&C.length?this.write(C):"";return this.lastNeed?O+this.lastChar.toString("base64",0,3-this.lastNeed):O}function w(C){return C.toString(this.encoding)}function A(C){return C&&C.length?this.write(C):""}var x=i("safe-buffer").Buffer,k=x.isEncoding||function(C){switch(C=""+C,C&&C.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};a.StringDecoder=c,c.prototype.write=function(C){if(C.length===0)return"";var O,_;if(this.lastNeed){if(O=this.fillLast(C),O===void 0)return"";_=this.lastNeed,this.lastNeed=0}else _=0;return _<C.length?O?O+this.text(C,_):this.text(C,_):O||""},c.prototype.end=function(C){var O=C&&C.length?this.write(C):"";return this.lastNeed?O+"�":O},c.prototype.text=function(C,O){var _=d(this,C,O);if(!this.lastNeed)return C.toString("utf8",O);this.lastTotal=_;var D=C.length-(_-this.lastNeed);return C.copy(this.lastChar,0,D),C.toString("utf8",O,D)},c.prototype.fillLast=function(C){return this.lastNeed<=C.length?(C.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(C.copy(this.lastChar,this.lastTotal-this.lastNeed,0,C.length),void(this.lastNeed-=C.length))}},{"safe-buffer":30}],32:[function(i,o){(function(a){(function(){function l(u){try{if(!a.localStorage)return!1}catch{return!1}var c=a.localStorage[u];return c!=null&&(c+"").toLowerCase()==="true"}o.exports=function(u,c){function f(){if(!d){if(l("throwDeprecation"))throw new Error(c);l("traceDeprecation")?console.trace(c):console.warn(c),d=!0}return u.apply(this,arguments)}if(l("noDeprecation"))return u;var d=!1;return f}}).call(this)}).call(this,typeof tr>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:tr)},{}],"/":[function(i,o){function a(v){return v.replace(/a=ice-options:trickle\s\n/g,"")}function l(v){console.warn(v)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const u=i("debug")("simple-peer"),c=i("get-browser-rtc"),f=i("randombytes"),d=i("readable-stream"),h=i("queue-microtask"),p=i("err-code"),{Buffer:m}=i("buffer"),g=65536;class y extends d.Duplex{constructor(w){if(w=Object.assign({allowHalfOpen:!1},w),super(w),this._id=f(4).toString("hex").slice(0,7),this._debug("new peer %o",w),this.channelName=w.initiator?w.channelName||f(20).toString("hex"):null,this.initiator=w.initiator||!1,this.channelConfig=w.channelConfig||y.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},y.config,w.config),this.offerOptions=w.offerOptions||{},this.answerOptions=w.answerOptions||{},this.sdpTransform=w.sdpTransform||(A=>A),this.streams=w.streams||(w.stream?[w.stream]:[]),this.trickle=w.trickle===void 0||w.trickle,this.allowHalfTrickle=w.allowHalfTrickle!==void 0&&w.allowHalfTrickle,this.iceCompleteTimeout=w.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=w.wrtc&&typeof w.wrtc=="object"?w.wrtc:c(),!this._wrtc)throw p(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(A){return void this.destroy(p(A,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=A=>{this._onIceCandidate(A)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(A=>{this.destroy(p(A,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=A=>{this._setupData(A)},this.streams&&this.streams.forEach(A=>{this.addStream(A)}),this._pc.ontrack=A=>{this._onTrack(A)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(w){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof w=="string")try{w=JSON.parse(w)}catch{w={}}this._debug("signal()"),w.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),w.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(w.transceiverRequest.kind,w.transceiverRequest.init)),w.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(w.candidate):this._pendingCandidates.push(w.candidate)),w.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(w)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(A=>{this._addIceCandidate(A)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(A=>{this.destroy(p(A,"ERR_SET_REMOTE_DESCRIPTION"))}),w.sdp||w.candidate||w.renegotiate||w.transceiverRequest||this.destroy(p(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(w){const A=new this._wrtc.RTCIceCandidate(w);this._pc.addIceCandidate(A).catch(x=>{!A.address||A.address.endsWith(".local")?l("Ignoring unsupported ICE candidate."):this.destroy(p(x,"ERR_ADD_ICE_CANDIDATE"))})}send(w){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(w)}}addTransceiver(w,A){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(w,A),this._needsNegotiation()}catch(x){this.destroy(p(x,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:w,init:A}})}}addStream(w){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),w.getTracks().forEach(A=>{this.addTrack(A,w)})}}addTrack(w,A){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const x=this._senderMap.get(w)||new Map;let k=x.get(A);if(!k)k=this._pc.addTrack(w,A),x.set(A,k),this._senderMap.set(w,x),this._needsNegotiation();else throw k.removed?p(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):p(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(w,A,x){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const k=this._senderMap.get(w),C=k?k.get(x):null;if(!C)throw p(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");A&&this._senderMap.set(A,k),C.replaceTrack==null?this.destroy(p(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):C.replaceTrack(A)}removeTrack(w,A){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const x=this._senderMap.get(w),k=x?x.get(A):null;if(!k)throw p(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{k.removed=!0,this._pc.removeTrack(k)}catch(C){C.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(k):this.destroy(p(C,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(w){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),w.getTracks().forEach(A=>{this.removeTrack(A,w)})}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,h(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(w){this._destroy(w,()=>{})}_destroy(w,A){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",w&&(w.message||w)),h(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",w&&(w.message||w)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,w&&this.emit("error",w),this.emit("close"),A()}))}_setupData(w){if(!w.channel)return this.destroy(p(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=w.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=g),this.channelName=this._channel.label,this._channel.onmessage=x=>{this._onChannelMessage(x)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=x=>{const k=x.error instanceof Error?x.error:new Error(`Datachannel error: ${x.message} ${x.filename}:${x.lineno}:${x.colno}`);this.destroy(p(k,"ERR_DATA_CHANNEL"))};let A=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(A&&this._onChannelClose(),A=!0):A=!1},5e3)}_read(){}_write(w,A,x){if(this.destroyed)return x(p(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(w)}catch(k){return this.destroy(p(k,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>g?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=x):x(null)}else this._debug("write before connect"),this._chunk=w,this._cb=x}_onFinish(){if(!this.destroyed){const w=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?w():this.once("connect",w)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(w=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(w.sdp=a(w.sdp)),w.sdp=this.sdpTransform(w.sdp);const A=()=>{if(!this.destroyed){const x=this._pc.localDescription||w;this._debug("signal"),this.emit("signal",{type:x.type,sdp:x.sdp})}};this._pc.setLocalDescription(w).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?A():this.once("_iceComplete",A))}).catch(x=>{this.destroy(p(x,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(w=>{this.destroy(p(w,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(w=>{w.mid||!w.sender.track||w.requested||(w.requested=!0,this.addTransceiver(w.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(w=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(w.sdp=a(w.sdp)),w.sdp=this.sdpTransform(w.sdp);const A=()=>{if(!this.destroyed){const x=this._pc.localDescription||w;this._debug("signal"),this.emit("signal",{type:x.type,sdp:x.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(w).then(()=>{this.destroyed||(this.trickle||this._iceComplete?A():this.once("_iceComplete",A))}).catch(x=>{this.destroy(p(x,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(w=>{this.destroy(p(w,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(p(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const w=this._pc.iceConnectionState,A=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",w,A),this.emit("iceStateChange",w,A),(w==="connected"||w==="completed")&&(this._pcReady=!0,this._maybeReady()),w==="failed"&&this.destroy(p(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),w==="closed"&&this.destroy(p(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(w){const A=x=>(Object.prototype.toString.call(x.values)==="[object Array]"&&x.values.forEach(k=>{Object.assign(x,k)}),x);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(x=>{const k=[];x.forEach(C=>{k.push(A(C))}),w(null,k)},x=>w(x)):0<this._pc.getStats.length?this._pc.getStats(x=>{if(this.destroyed)return;const k=[];x.result().forEach(C=>{const O={};C.names().forEach(_=>{O[_]=C.stat(_)}),O.id=C.id,O.type=C.type,O.timestamp=C.timestamp,k.push(A(O))}),w(null,k)},x=>w(x)):w(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const w=()=>{this.destroyed||this.getStats((A,x)=>{if(this.destroyed)return;A&&(x=[]);const k={},C={},O={};let _=!1;x.forEach(R=>{(R.type==="remotecandidate"||R.type==="remote-candidate")&&(k[R.id]=R),(R.type==="localcandidate"||R.type==="local-candidate")&&(C[R.id]=R),(R.type==="candidatepair"||R.type==="candidate-pair")&&(O[R.id]=R)});const D=R=>{_=!0;let L=C[R.localCandidateId];L&&(L.ip||L.address)?(this.localAddress=L.ip||L.address,this.localPort=+L.port):L&&L.ipAddress?(this.localAddress=L.ipAddress,this.localPort=+L.portNumber):typeof R.googLocalAddress=="string"&&(L=R.googLocalAddress.split(":"),this.localAddress=L[0],this.localPort=+L[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let F=k[R.remoteCandidateId];F&&(F.ip||F.address)?(this.remoteAddress=F.ip||F.address,this.remotePort=+F.port):F&&F.ipAddress?(this.remoteAddress=F.ipAddress,this.remotePort=+F.portNumber):typeof R.googRemoteAddress=="string"&&(F=R.googRemoteAddress.split(":"),this.remoteAddress=F[0],this.remotePort=+F[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(x.forEach(R=>{R.type==="transport"&&R.selectedCandidatePairId&&D(O[R.selectedCandidatePairId]),(R.type==="googCandidatePair"&&R.googActiveConnection==="true"||(R.type==="candidatepair"||R.type==="candidate-pair")&&R.selected)&&D(R)}),!_&&(!Object.keys(O).length||Object.keys(C).length))return void setTimeout(w,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(L){return this.destroy(p(L,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const R=this._cb;this._cb=null,R(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};w()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>g)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(w=>{this._pc.removeTrack(w),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(w){this.destroyed||(w.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:w.candidate.candidate,sdpMLineIndex:w.candidate.sdpMLineIndex,sdpMid:w.candidate.sdpMid}}):!w.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),w.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(w){if(this.destroyed)return;let A=w.data;A instanceof ArrayBuffer&&(A=m.from(A)),this.push(A)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const w=this._cb;this._cb=null,w(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(w){this.destroyed||w.streams.forEach(A=>{this._debug("on track"),this.emit("track",w.track,A),this._remoteTracks.push({track:w.track,stream:A}),this._remoteStreams.some(x=>x.id===A.id)||(this._remoteStreams.push(A),h(()=>{this._debug("on stream"),this.emit("stream",A)}))})}_debug(){const w=[].slice.call(arguments);w[0]="["+this._id+"] "+w[0],u.apply(null,w)}}y.WEBRTC_SUPPORT=!!c(),y.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},y.channelConfig={},o.exports=y},{buffer:3,debug:4,"err-code":6,"get-browser-rtc":8,"queue-microtask":13,randombytes:14,"readable-stream":29}]},{},[])("/")})})(R_);var KW=R_.exports;const qW=Np(KW),GA=0,WA=1,P_=2,I_=(t,e)=>{Ne(t,GA);const n=$G(e);jt(t,n)},L_=(t,e,n)=>{Ne(t,WA),jt(t,UG(e,n))},QW=(t,e,n)=>L_(e,n,fn(t)),B_=(t,e,n)=>{try{BG(e,fn(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},JW=(t,e)=>{Ne(t,P_),jt(t,e)},YW=B_,XW=(t,e,n,r)=>{const s=We(t);switch(s){case GA:QW(t,e,n);break;case WA:B_(t,n,r);break;case P_:YW(t,n,r);break;default:throw new Error("Unknown message type")}return s},KA=3e4;class ZW extends QD{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=$s();this.getLocalState()!==null&&KA/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((s,i)=>{i!==this.clientID&&KA<=n-s.lastUpdated&&this.states.has(i)&&r.push(i)}),r.length>0&&qA(this,r,"timeout")},gs(KA/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,r=this.meta.get(n),s=r===void 0?0:r.clock+1,i=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:s,lastUpdated:$s()});const o=[],a=[],l=[],u=[];e===null?u.push(n):i==null?e!=null&&o.push(n):(a.push(n),Kd(i,e)||l.push(n)),(o.length>0||l.length>0||u.length>0)&&this.emit("change",[{added:o,updated:l,removed:u},"local"]),this.emit("update",[{added:o,updated:a,removed:u},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const qA=(t,e,n)=>{const r=[];for(let s=0;s<e.length;s++){const i=e[s];if(t.states.has(i)){if(t.states.delete(i),i===t.clientID){const o=t.meta.get(i);t.meta.set(i,{clock:o.clock+1,lastUpdated:$s()})}r.push(i)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},Em=(t,e,n=t.states)=>{const r=e.length,s=un();Ne(s,r);for(let i=0;i<r;i++){const o=e[i],a=n.get(o)||null,l=t.meta.get(o).clock;Ne(s,o),Ne(s,l),Ws(s,JSON.stringify(a))}return Rt(s)},eK=(t,e,n)=>{const r=Ks(e),s=$s(),i=[],o=[],a=[],l=[],u=We(r);for(let c=0;c<u;c++){const f=We(r);let d=We(r);const h=JSON.parse(Ri(r)),p=t.meta.get(f),m=t.states.get(f),g=p===void 0?0:p.clock;(g<d||g===d&&h===null&&t.states.has(f))&&(h===null?f===t.clientID&&t.getLocalState()!=null?d++:t.states.delete(f):t.states.set(f,h),t.meta.set(f,{clock:d,lastUpdated:s}),p===void 0&&h!==null?i.push(f):p!==void 0&&h===null?l.push(f):h!==null&&(Kd(h,m)||a.push(f),o.push(f)))}(i.length>0||a.length>0||l.length>0)&&t.emit("change",[{added:i,updated:a,removed:l},n]),(i.length>0||o.length>0||l.length>0)&&t.emit("update",[{added:i,updated:o,removed:l},n])},tK=(t,e)=>{const n=sA(t).buffer,r=sA(e).buffer;return crypto.subtle.importKey("raw",n,"PBKDF2",!1,["deriveKey"]).then(s=>crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:1e5,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]))},F_=(t,e)=>{if(!e)return AA(t);const n=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,t).then(r=>{const s=un();return Ws(s,"AES-GCM"),jt(s,n),jt(s,new Uint8Array(r)),Rt(s)})},nK=(t,e)=>{const n=un();return Ku(n,t),F_(Rt(n),e)},j_=(t,e)=>{if(!e)return AA(t);const n=Ks(t);Ri(n)!=="AES-GCM"&&gG(Gs("Unknown encryption algorithm"));const s=fn(n),i=fn(n);return crypto.subtle.decrypt({name:"AES-GCM",iv:s},e,i).then(o=>new Uint8Array(o))},rK=(t,e)=>j_(t,e).then(n=>qu(Ks(new Uint8Array(n)))),Or=mG("y-webrtc"),oc=0,U_=3,oh=1,QA=4,Cm=new Map,gl=new Map,V_=t=>{let e=!0;t.webrtcConns.forEach(n=>{n.synced||(e=!1)}),(!e&&t.synced||e&&!t.synced)&&(t.synced=e,t.provider.emit("synced",[{synced:e}]),Or("synced ",Wr,t.name,ll," with all peers"))},H_=(t,e,n)=>{const r=Ks(e),s=un(),i=We(r);if(t===void 0)return null;const o=t.awareness,a=t.doc;let l=!1;switch(i){case oc:{Ne(s,oc);const u=XW(r,s,a,t);u===WA&&!t.synced&&n(),u===GA&&(l=!0);break}case U_:Ne(s,oh),jt(s,Em(o,Array.from(o.getStates().keys()))),l=!0;break;case oh:eK(o,fn(r),t);break;case QA:{const u=al(r)===1,c=Ri(r);if(c!==t.peerId&&(t.bcConns.has(c)&&!u||!t.bcConns.has(c)&&u)){const f=[],d=[];u?(t.bcConns.add(c),d.push(c)):(t.bcConns.delete(c),f.push(c)),t.provider.emit("peers",[{added:d,removed:f,webrtcPeers:Array.from(t.webrtcConns.keys()),bcPeers:Array.from(t.bcConns)}]),G_(t)}break}default:return console.error("Unable to compute message"),s}return l?s:null},sK=(t,e)=>{const n=t.room;return Or("received message from ",Wr,t.remotePeerId,bA," (",n.name,")",ll,lm),H_(n,e,()=>{t.synced=!0,Or("synced ",Wr,n.name,ll," with ",Wr,t.remotePeerId),V_(n)})},JA=(t,e)=>{Or("send message to ",Wr,t.remotePeerId,ll,bA," (",t.room.name,")",lm);try{t.peer.send(Rt(e))}catch{}},iK=(t,e)=>{Or("broadcast message in ",Wr,t.name,ll),t.webrtcConns.forEach(n=>{try{n.peer.send(e)}catch{}})};class z_{constructor(e,n,r,s){Or("establishing connection to ",Wr,r),this.room=s,this.remotePeerId=r,this.glareToken=void 0,this.closed=!1,this.connected=!1,this.synced=!1,this.peer=new qW({initiator:n,...s.provider.peerOpts}),this.peer.on("signal",i=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),XA(e,s,{to:r,from:s.peerId,type:"signal",token:this.glareToken,signal:i})}),this.peer.on("connect",()=>{Or("connected to ",Wr,r),this.connected=!0;const o=s.provider.doc,a=s.awareness,l=un();Ne(l,oc),I_(l,o),JA(this,l);const u=a.getStates();if(u.size>0){const c=un();Ne(c,oh),jt(c,Em(a,Array.from(u.keys()))),JA(this,c)}}),this.peer.on("close",()=>{this.connected=!1,this.closed=!0,s.webrtcConns.has(this.remotePeerId)&&(s.webrtcConns.delete(this.remotePeerId),s.provider.emit("peers",[{removed:[this.remotePeerId],added:[],webrtcPeers:Array.from(s.webrtcConns.keys()),bcPeers:Array.from(s.bcConns)}])),V_(s),this.peer.destroy(),Or("closed connection to ",Wr,r),YA(s)}),this.peer.on("error",i=>{Or("Error in connection to ",Wr,r,": ",i),YA(s)}),this.peer.on("data",i=>{const o=sK(this,i);o!==null&&JA(this,o)})}destroy(){this.peer.destroy()}}const Uo=(t,e)=>F_(e,t.key).then(n=>t.mux(()=>DG(t.name,n))),$_=(t,e)=>{t.bcconnected&&Uo(t,e),iK(t,e)},YA=t=>{Cm.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[t.name]}),t.webrtcConns.size<t.provider.maxConns&&XA(e,t,{type:"announce",from:t.peerId}))})},G_=t=>{if(t.provider.filterBcConns){const e=un();Ne(e,QA),Wd(e,1),Ws(e,t.peerId),Uo(t,Rt(e))}};class oK{constructor(e,n,r,s){this.peerId=tO(),this.doc=e,this.awareness=n.awareness,this.provider=n,this.synced=!1,this.name=r,this.key=s,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=NO(),this.bcconnected=!1,this._bcSubscriber=i=>j_(new Uint8Array(i),s).then(o=>this.mux(()=>{const a=H_(this,o,()=>{});a&&Uo(this,Rt(a))})),this._docUpdateHandler=(i,o)=>{const a=un();Ne(a,oc),JW(a,i),$_(this,Rt(a))},this._awarenessUpdateHandler=({added:i,updated:o,removed:a},l)=>{const u=i.concat(o).concat(a),c=un();Ne(c,oh),jt(c,Em(this.awareness,u)),$_(this,Rt(c))},this._beforeUnloadHandler=()=>{qA(this.awareness,[e.clientID],"window unload"),gl.forEach(i=>{i.disconnect()})},typeof window<"u"?window.addEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.on("exit",this._beforeUnloadHandler)}connect(){this.doc.on("update",this._docUpdateHandler),this.awareness.on("update",this._awarenessUpdateHandler),YA(this);const e=this.name;SG(e,this._bcSubscriber),this.bcconnected=!0,G_(this);const n=un();Ne(n,oc),I_(n,this.doc),Uo(this,Rt(n));const r=un();Ne(r,oc),L_(r,this.doc),Uo(this,Rt(r));const s=un();Ne(s,U_),Uo(this,Rt(s));const i=un();Ne(i,oh),jt(i,Em(this.awareness,[this.doc.clientID])),Uo(this,Rt(i))}disconnect(){Cm.forEach(n=>{n.connected&&n.send({type:"unsubscribe",topics:[this.name]})}),qA(this.awareness,[this.doc.clientID],"disconnect");const e=un();Ne(e,QA),Wd(e,0),Ws(e,this.peerId),Uo(this,Rt(e)),TG(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(n=>n.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const aK=(t,e,n,r)=>{if(gl.has(n))throw Gs(`A Yjs Doc connected to room "${n}" already exists!`);const s=new oK(t,e,n,r);return gl.set(n,s),s},XA=(t,e,n)=>{e.key?nK(n,e.key).then(r=>{t.send({type:"publish",topic:e.name,data:OO(r)})}):t.send({type:"publish",topic:e.name,data:n})};class lK extends A${constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{Or(`connected (${e})`);const n=Array.from(gl.keys());this.send({type:"subscribe",topics:n}),gl.forEach(r=>XA(this,r,{type:"announce",from:r.peerId}))}),this.on("message",n=>{switch(n.type){case"publish":{const r=n.topic,s=gl.get(r);if(s==null||typeof r!="string")return;const i=o=>{const a=s.webrtcConns,l=s.peerId;if(o==null||o.from===l||o.to!==void 0&&o.to!==l||s.bcConns.has(o.from))return;const u=a.has(o.from)?()=>{}:()=>s.provider.emit("peers",[{removed:[],added:[o.from],webrtcPeers:Array.from(s.webrtcConns.keys()),bcPeers:Array.from(s.bcConns)}]);switch(o.type){case"announce":a.size<s.provider.maxConns&&(or(a,o.from,()=>new z_(this,!0,o.from,s)),u());break;case"signal":if(o.signal.type==="offer"){const c=a.get(o.from);if(c){const f=o.token,d=c.glareToken;if(d&&d>f){Or("offer rejected: ",o.from);return}c.glareToken=void 0}}if(o.signal.type==="answer"){Or("offer answered by: ",o.from);const c=a.get(o.from);c.glareToken=void 0}o.to===l&&(or(a,o.from,()=>new z_(this,!1,o.from,s)).peer.signal(o.signal),u());break}};s.key?typeof n.data=="string"&&rK(_O(n.data),s.key).then(i):i(n.data)}}}),this.on("disconnect",()=>Or(`disconnect (${e})`))}}const ZA=t=>{t.emit("status",[{connected:t.connected}])};class uK extends Zw{constructor(e,n,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:s=null,awareness:i=new ZW(n),maxConns:o=20+gs(ZD()*15),filterBcConns:a=!0,peerOpts:l={}}={}){super(),this.roomName=e,this.doc=n,this.filterBcConns=a,this.awareness=i,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=l,this.key=s?tK(s,e):AA(null),this.room=null,this.key.then(u=>{this.room=aK(n,this,e,u),this.shouldConnect?this.room.connect():this.room.disconnect(),ZA(this)}),this.connect(),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const n=or(Cm,e,()=>new lK(e));this.signalingConns.push(n),n.providers.add(this)}),this.room&&(this.room.connect(),ZA(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),Cm.delete(e.url))}),this.room&&(this.room.disconnect(),ZA(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),gl.delete(this.roomName)}),super.destroy()}}const cK={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"}},fK=/[\uD800-\uDBFF]/,dK=/[\uDC00-\uDFFF]/,hK=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&fK.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&dK.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},Pt=new _t("y-sync"),Li=new _t("y-undo"),Sm=new _t("yjs-cursor"),Tm=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Yu(e.ds,t.id),pK=[{light:"#ecd44433",dark:"#ecd444"}],mK=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Oi();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,k$(e))}return t.get(n)},gK=(t,{colors:e=pK,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const a=new bK(t,i),l=new bt({props:{editable:u=>{const c=Pt.getState(u);return c.snapshot==null&&c.prevSnapshot==null}},key:Pt,state:{init:(u,c)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(u,c)=>{const f=u.getMeta(Pt);if(f!==void 0){c=Object.assign({},c);for(const d in f)c[d]=f[d]}return c.addToHistory=u.getMeta("addToHistory")!==!1,c.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,c.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,a.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&yA(0,()=>{a.prosemirrorView!=null&&(f.restore==null?a._renderSnapshot(f.snapshot,f.prevSnapshot,c):(a._renderSnapshot(f.snapshot,f.snapshot,c),delete c.restore,delete c.snapshot,delete c.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),c}},view:u=>(a.initView(u),i==null&&a._forceRerender(),s(),{update:()=>{const c=l.getState(u.state);if(c.snapshot==null&&c.prevSnapshot==null&&(o||u.state.doc.content.findDiffStart(u.state.doc.type.createAndFill().content)!==null)){if(o=!0,c.addToHistory===!1&&!c.isChangeOrigin){const f=Li.getState(u.state),d=f&&f.undoManager;d&&d.stopCapturing()}a.mux(()=>{c.doc.transact(f=>{f.meta.set("addToHistory",c.addToHistory),a._prosemirrorChanged(u.state.doc)},Pt)})}},destroy:()=>{a.destroy()}})});return l},yK=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=uh(n.doc,n.type,e.anchor,n.mapping),s=uh(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&(t=t.setSelection(_e.create(t.doc,r,s)))}},ev=(t,e)=>({anchor:Mm(e.selection.anchor,t.type,t.mapping),head:Mm(e.selection.head,t.type,t.mapping)});class bK{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=NO(),this.mapping=n,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=ev(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(mA&&this._domSelectionInView===null&&(yA(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=aG.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=QO(PO(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Pt,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Dm(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(se.from(e),0,0));n.setMeta(Pt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Dm(s,this.prosemirrorView.state.schema,this.mapping)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(se.from(n),0,0));e&&r.setSelection(_e.create(r.doc,e.anchor,e.head)),this.prosemirrorView.dispatch(r.setMeta(Pt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc;e||(e=_A(this.doc)),(e instanceof Uint8Array||n instanceof Uint8Array)&&((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Sr(),s=new ul({gc:!1}),um(s,n),n=_A(s),um(s,e),e=_A(s)),this.mapping.clear(),this.mux(()=>{s.transact(i=>{const o=r.permanentUserData;o&&o.dss.forEach(c=>{Bo(i,c,f=>{})});const a=(c,f)=>{const d=c==="added"?o.getUserByClientId(f.client):o.getUserByDeletedId(f);return{user:d,type:c,color:mK(r.colorMapping,r.colors,d)}},l=d_(this.type,new OA(n.ds,e.sv)).map(c=>!c._item.deleted||Tm(c._item,e)||Tm(c._item,n)?Dm(c,this.prosemirrorView.state.schema,new Map,e,n,a):null).filter(c=>c!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(se.from(l),0,0));this.prosemirrorView.dispatch(u.setMeta(Pt,{isChangeOrigin:!0}))},Pt)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Pt.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(a,l)=>this.mapping.delete(l);Bo(n,n.deleteSet,a=>{if(a.constructor===Et){const l=a.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(a=>W_(a,this.prosemirrorView.state.schema,this.mapping)).filter(a=>a!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(se.from(i),0,0));yK(o,this.beforeTransactionSelection,this),o=o.setMeta(Pt,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof i_}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{rv(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=ev(this,this.prosemirrorView.state)},Pt)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const W_=(t,e,n,r,s,i)=>{const o=n.get(t);if(o===void 0){if(t instanceof $n)return Dm(t,e,n,r,s,i);throw ys()}return o},Dm=(t,e,n,r,s,i)=>{const o=[],a=l=>{if(l.constructor===$n){const u=W_(l,e,n,r,s,i);u!==null&&o.push(u)}else{const u=wK(l,e,n,r,s,i);u!==null&&u.forEach(c=>{c!==null&&o.push(c)})}};r===void 0||s===void 0?t.toArray().forEach(a):d_(t,new OA(s.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Tm(t._item,r)?Tm(t._item,s)||(l.ychange=i?i("added",t._item.id):{type:"added"}):l.ychange=i?i("removed",t._item.id):{type:"removed"});const u=e.node(t.nodeName,l,o);return n.set(t,u),u}catch{return t.doc.transact(u=>{t._item.delete(u)},Pt),n.delete(t),null}},wK=(t,e,n,r,s,i)=>{const o=[],a=t.toDelta(r,s,i);try{for(let l=0;l<a.length;l++){const u=a[l],c=[];for(const f in u.attributes)c.push(e.mark(f,u.attributes[f]));o.push(e.text(u.insert,c))}}catch{return t.doc.transact(u=>{t._item.delete(u)},Pt),null}return o},AK=(t,e)=>{const n=new Dr,r=t.map(s=>({insert:s.text,attributes:J_(s.marks)}));return n.applyDelta(r),e.set(n,t),n},vK=(t,e)=>{const n=new $n(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Om(t).map(r=>tv(r,e))),e.set(n,t),n},tv=(t,e)=>t instanceof Array?AK(t,e):vK(t,e),K_=t=>typeof t=="object"&&t!==null,nv=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],a=e[i];r=i==="ychange"||o===a||K_(o)&&K_(a)&&nv(o,a)}return r},Om=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},q_=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&hA(r.attributes||{}).length===e[s].marks.length&&e[s].marks.every(i=>nv(r.attributes[i.type.name]||{},i.attrs)))},ah=(t,e)=>{if(t instanceof $n&&!(e instanceof Array)&&sv(t,e)){const n=Om(e);return t._length===n.length&&nv(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>ah(r,n[s]))}return t instanceof Dr&&e instanceof Array&&q_(t,e)},_m=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Q_=(t,e,n)=>{const r=t.toArray(),s=Om(e),i=s.length,o=r.length,a=Lo(o,i);let l=0,u=0,c=!1;for(;l<a;l++){const f=r[l],d=s[l];if(_m(n.get(f),d))c=!0;else if(!ah(f,d))break}for(;l+u<a;u++){const f=r[o-u-1],d=s[i-u-1];if(_m(n.get(f),d))c=!0;else if(!ah(f,d))break}return{equalityFactor:l+u,foundMappedChild:c}},xK=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof bs?e+=n.content.str:n.content instanceof Zt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},kK=(t,e,n)=>{n.set(t,e);const{nAttrs:r,str:s}=xK(t),i=e.map(u=>({insert:u.text,attributes:Object.assign({},r,J_(u.marks))})),{insert:o,remove:a,index:l}=hK(s,i.map(u=>u.insert).join(""));t.delete(l,a),t.insert(l,o),t.applyDelta(i.map(u=>({retain:u.insert.length,attributes:u.attributes})))},J_=t=>{const e={};return t.forEach(n=>{n.type.name!=="ychange"&&(e[n.type.name]=n.attrs)}),e},rv=(t,e,n,r)=>{if(e instanceof $n&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.set(e,n),e instanceof $n){const f=e.getAttributes(),d=n.attrs;for(const h in d)d[h]!==null?f[h]!==d[h]&&h!=="ychange"&&e.setAttribute(h,d[h]):e.removeAttribute(h);for(const h in f)d[h]===void 0&&e.removeAttribute(h)}const s=Om(n),i=s.length,o=e.toArray(),a=o.length,l=Lo(i,a);let u=0,c=0;for(;u<l;u++){const f=o[u],d=s[u];if(!_m(r.get(f),d))if(ah(f,d))r.set(f,d);else break}for(;c+u+1<l;c++){const f=o[a-c-1],d=s[i-c-1];if(!_m(r.get(f),d))if(ah(f,d))r.set(f,d);else break}t.transact(()=>{for(;a-u-c>0&&i-u-c>0;){const d=o[u],h=s[u],p=o[a-c-1],m=s[i-c-1];if(d instanceof Dr&&h instanceof Array)q_(d,h)||kK(d,h,r),u+=1;else{let g=d instanceof $n&&sv(d,h),y=p instanceof $n&&sv(p,m);if(g&&y){const v=Q_(d,h,r),w=Q_(p,m,r);v.foundMappedChild&&!w.foundMappedChild?y=!1:!v.foundMappedChild&&w.foundMappedChild||v.equalityFactor<w.equalityFactor?g=!1:y=!1}g?(rv(t,d,h,r),u+=1):y?(rv(t,p,m,r),c+=1):(r.delete(e.get(u)),e.delete(u,1),e.insert(u,[tv(h,r)]),u+=1)}}const f=a-u-c;if(a===1&&i===0&&o[0]instanceof Dr?(r.delete(o[0]),o[0].delete(0,o[0].length)):f>0&&(e.slice(u,u+f).forEach(d=>r.delete(d)),e.delete(u,f)),u+c<i){const d=[];for(let h=u;h<i-c;h++)d.push(tv(s[h],r));e.insert(u,d)}},Pt)},sv=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let lh=null;const EK=()=>{const t=lh;lh=null,t.forEach((e,n)=>{const r=n.state.tr,s=Pt.getState(n.state);s&&s.binding&&!s.binding.isDestroyed&&(e.forEach((i,o)=>{r.setMeta(o,i)}),n.dispatch(r))})},CK=(t,e,n)=>{lh||(lh=new Map,yA(0,EK)),or(lh,t,zn).set(e,n)},Mm=(t,e,n)=>{if(t===0)return DA(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Dr){if(r._length>=t)return DA(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new Xd(r._item===null?null:r._item.id,r._item===null?Jd(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new Xd(r._item===null?null:r._item.id,r._item===null?Jd(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Sr();if(t===0&&r.constructor!==Dr&&r!==e)return SK(r._item.parent,r._item)}return DA(e,e._length,-1)},SK=(t,e)=>{let n=null,r=null;return t._item===null?r=Jd(t):n=Ke(t._item.id.client,t._item.id.clock),new Xd(n,r,e.id)},uh=(t,e,n,r)=>{const s=qG(n,t);if(s===null||s.type!==e&&!Yd(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Dr)o=s.index;else if(i._item===null||!i._item.deleted){let a=i._first,l=0;for(;l<i._length&&l<s.index&&a!==null;){if(!a.deleted){const u=a.content.type;l++,u instanceof Dr?o+=u._length:o+=r.get(u).nodeSize}a=a.right}o+=1}for(;i!==e&&i._item!==null;){const a=i._item.parent;if(a._item===null||!a._item.deleted){o+=1;let l=a._first;for(;l!==null;){const u=l.content.type;if(u===i)break;l.deleted||(u instanceof Dr?o+=u._length:o+=r.get(u).nodeSize),l=l.right}}i=a}return o-1},TK=(t,e,n)=>t!==e,DK=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode("⁠"),s=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(s,null),e},Y_=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),OK=/^#[0-9a-fA-F]{6}$/,X_=(t,e,n,r,s)=>{const i=Pt.getState(t),o=i.doc,a=[];return i.snapshot!=null||i.prevSnapshot!=null||i.binding===null?kt.create(t.doc,[]):(e.getStates().forEach((l,u)=>{if(n(o.clientID,u,l)&&l.cursor!=null){const c=l.user||{};c.color==null?c.color="#ffa500":OK.test(c.color)||console.warn("A user uses an unsupported color format",c),c.name==null&&(c.name=`User: ${u}`);let f=uh(o,i.type,Zd(l.cursor.anchor),i.binding.mapping),d=uh(o,i.type,Zd(l.cursor.head),i.binding.mapping);if(f!==null&&d!==null){const h=Mi(t.doc.content.size-1,0);f=Lo(f,h),d=Lo(d,h),a.push(nn.widget(d,()=>r(c),{key:u+"",side:10}));const p=Lo(f,d),m=Mi(f,d);a.push(nn.inline(p,m,s(c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),kt.create(t.doc,a))},_K=(t,{awarenessStateFilter:e=TK,cursorBuilder:n=DK,selectionBuilder:r=Y_,getSelection:s=o=>o.selection}={},i="cursor")=>new bt({key:Sm,state:{init(o,a){return X_(a,t,e,n,r)},apply(o,a,l,u){const c=Pt.getState(u),f=o.getMeta(Sm);return c&&c.isChangeOrigin||f&&f.awarenessUpdated?X_(u,t,e,n,r):a.map(o.mapping,o.doc)}},props:{decorations:o=>Sm.getState(o)},view:o=>{const a=()=>{o.docView&&CK(o,Sm,{awarenessUpdated:!0})},l=()=>{const u=Pt.getState(o.state),c=t.getLocalState()||{};if(u.binding!=null)if(o.hasFocus()){const f=s(o.state),d=Mm(f.anchor,u.type,u.binding.mapping),h=Mm(f.head,u.type,u.binding.mapping);(c.cursor==null||!qO(Zd(c.cursor.anchor),d)||!qO(Zd(c.cursor.head),h))&&t.setLocalStateField(i,{anchor:d,head:h})}else c.cursor!=null&&uh(u.doc,u.type,Zd(c.cursor.anchor),u.binding.mapping)!==null&&t.setLocalStateField(i,null)};return t.on("change",a),o.dom.addEventListener("focusin",l),o.dom.addEventListener("focusout",l),{update:l,destroy:()=>{o.dom.removeEventListener("focusin",l),o.dom.removeEventListener("focusout",l),t.off("change",a),t.setLocalStateField(i,null)}}}}),MK=t=>{const e=Li.getState(t).undoManager;if(e!=null)return e.undo(),!0},NK=t=>{const e=Li.getState(t).undoManager;if(e!=null)return e.redo(),!0},RK=new Set(["paragraph"]),PK=(t,e)=>!(t instanceof Et)||!(t.content instanceof ws)||!(t.content.type instanceof dl||t.content.type instanceof $n&&e.has(t.content.type.nodeName))||t.content.type._length===0,IK=({protectedNodes:t=RK,trackedOrigins:e=[],undoManager:n=null}={})=>new bt({key:Li,state:{init:(r,s)=>{const i=Pt.getState(s),o=n||new i_(i.type,{trackedOrigins:new Set([Pt].concat(e)),deleteFilter:a=>PK(a,t),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const a=Pt.getState(o).binding,l=s.undoManager,u=l.undoStack.length>0,c=l.redoStack.length>0;return a?{undoManager:l,prevSel:ev(a,i),hasUndoOps:u,hasRedoOps:c}:u!==s.hasUndoOps||c!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):s}},view:r=>{const s=Pt.getState(r.state),i=Li.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const a=s.binding;a&&o.meta.set(a,Li.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const a=s.binding;a&&(a.beforeTransactionSelection=o.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}}),LK=wt.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Li.getState(e).undoManager.undoStack.length===0?!1:n?MK(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Li.getState(e).undoManager.redoStack.length===0?!1:n?NK(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=IK(),n=e.spec.view;e.spec.view=i=>{const{undoManager:o}=Li.getState(i.state);o.restore&&(o.restore(),o.restore=()=>{});const a=n?n(i):void 0;return{destroy:()=>{const l=o.trackedOrigins.has(o),u=o._observers;o.restore=()=>{l&&o.trackedOrigins.add(o),o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=u},a!=null&&a.destroy&&a.destroy()}}};const r={...this.options.ySyncOptions?{...this.options.ySyncOptions}:{},...this.options.onFirstRender?{...this.options.onFirstRender}:{}};return[gK(t,r),e]}}),Z_=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),eM=()=>null,BK=wt.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-cursor__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:Y_,onUpdate:eM}},onCreate(){this.options.onUpdate!==eM&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor')},addStorage(){return{users:[]}},addCommands(){return{updateUser:t=>()=>(this.options.user=t,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:t=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(t))}},addProseMirrorPlugins(){return[_K((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=Z_(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Z_(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),FK=/^\s*>\s$/,jK=Ye.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",rt(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ru({find:FK,type:this.type})]}}),UK=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VK=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,HK=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,zK=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,$K=Yt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",rt(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[qa({find:UK,type:this.type}),qa({find:HK,type:this.type})]},addPasteRules(){return[No({find:VK,type:this.type}),No({find:zK,type:this.type})]}}),GK=Ye.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",rt(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),tM=Yt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",rt(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=yd(t,this.type);return Object.entries(n).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),nM=/^\s*([-+*])\s$/,rM=Ye.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",rt(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(GK.name,this.editor.getAttributes(tM.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ru({find:nM,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ru({find:nM,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(tM.name),editor:this.editor})),[t]}}),WK=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,KK=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,qK=Yt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",rt(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[qa({find:WK,type:this.type})]},addPasteRules(){return[No({find:KK,type:this.type})]}}),QK=/^```([a-z]+)?[\s\n]$/,JK=/^~~~([a-z]+)?[\s\n]$/,YK=Ye.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",rt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`