agent-comms 8.2.1 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +15 -1
  4. package/dist/bridges/user/web/dist/bundle.js +1 -1
  5. package/dist/bridges/user/web/dist/sw.js +1 -1
  6. package/dist/bridges/user/web/frontend/boot-logic.d.ts +9 -8
  7. package/dist/bridges/user/web/frontend/boot-logic.d.ts.map +1 -1
  8. package/dist/bridges/user/web/frontend/boot-logic.js +9 -12
  9. package/dist/bridges/user/web/frontend/boot-logic.js.map +1 -1
  10. package/dist/bridges/user/web/frontend/main.js +3 -6
  11. package/dist/bridges/user/web/frontend/main.js.map +1 -1
  12. package/dist/bridges/user/web/frontend/mesh-client.d.ts.map +1 -1
  13. package/dist/bridges/user/web/frontend/mesh-client.js +3 -4
  14. package/dist/bridges/user/web/frontend/mesh-client.js.map +1 -1
  15. package/dist/bridges/user/web/frontend/served-by-bridge.d.ts +10 -0
  16. package/dist/bridges/user/web/frontend/served-by-bridge.d.ts.map +1 -0
  17. package/dist/bridges/user/web/frontend/served-by-bridge.js +10 -0
  18. package/dist/bridges/user/web/frontend/served-by-bridge.js.map +1 -0
  19. package/dist/bridges/user/web/server.d.ts +10 -0
  20. package/dist/bridges/user/web/server.d.ts.map +1 -1
  21. package/dist/bridges/user/web/server.js +84 -7
  22. package/dist/bridges/user/web/server.js.map +1 -1
  23. package/dist/bridges/user/web/test/lan-web-server.integration.test.d.ts +7 -0
  24. package/dist/bridges/user/web/test/lan-web-server.integration.test.d.ts.map +1 -0
  25. package/dist/bridges/user/web/test/lan-web-server.integration.test.js +245 -0
  26. package/dist/bridges/user/web/test/lan-web-server.integration.test.js.map +1 -0
  27. package/dist/bridges/user/web/test/web-access.unit.test.d.ts +5 -0
  28. package/dist/bridges/user/web/test/web-access.unit.test.d.ts.map +1 -0
  29. package/dist/bridges/user/web/test/web-access.unit.test.js +271 -0
  30. package/dist/bridges/user/web/test/web-access.unit.test.js.map +1 -0
  31. package/dist/bridges/user/web/test/web-beacon.unit.test.d.ts +5 -0
  32. package/dist/bridges/user/web/test/web-beacon.unit.test.d.ts.map +1 -0
  33. package/dist/bridges/user/web/test/web-beacon.unit.test.js +40 -0
  34. package/dist/bridges/user/web/test/web-beacon.unit.test.js.map +1 -0
  35. package/dist/bridges/user/web/web-access.d.ts +79 -0
  36. package/dist/bridges/user/web/web-access.d.ts.map +1 -0
  37. package/dist/bridges/user/web/web-access.js +262 -0
  38. package/dist/bridges/user/web/web-access.js.map +1 -0
  39. package/dist/bridges/user/web/web-beacon.d.ts +27 -0
  40. package/dist/bridges/user/web/web-beacon.d.ts.map +1 -0
  41. package/dist/bridges/user/web/web-beacon.js +45 -0
  42. package/dist/bridges/user/web/web-beacon.js.map +1 -0
  43. package/dist/core/first-contact.d.ts +2 -0
  44. package/dist/core/first-contact.d.ts.map +1 -1
  45. package/dist/core/first-contact.js +1 -1
  46. package/dist/core/first-contact.js.map +1 -1
  47. package/package.json +2 -2
@@ -46,4 +46,4 @@ Error generating stack: `+e.message+`
46
46
  `},il=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},al=function(){A.useEffect(function(){return document.body.setAttribute(nl,(il()+1).toString()),function(){var e=il()-1;e<=0?document.body.removeAttribute(nl):document.body.setAttribute(nl,e.toString())}},[])},ol=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;al();var a=A.useMemo(function(){return el(i)},[i]);return A.createElement(tl,{styles:rl(a,!t,i,n?``:`!important`)})},sl=!1;if(typeof window<`u`)try{var cl=Object.defineProperty({},"passive",{get:function(){return sl=!0,!0}});window.addEventListener(`test`,cl,cl),window.removeEventListener(`test`,cl,cl)}catch{sl=!1}var ll=sl?{passive:!1}:!1,ul=function(e){return e.tagName===`TEXTAREA`},dl=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!ul(e)&&n[t]===`visible`)},fl=function(e){return dl(e,`overflowY`)},pl=function(e){return dl(e,`overflowX`)},ml=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),_l(e,r)){var i=vl(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},hl=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},gl=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},_l=function(e,t){return e===`v`?fl(t):pl(t)},vl=function(e,t){return e===`v`?hl(t):gl(t)},yl=function(e,t){return e===`h`&&t===`rtl`?-1:1},bl=function(e,t,n,r,i){var a=yl(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=vl(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&_l(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},xl=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Sl=function(e){return[e.deltaX,e.deltaY]},Cl=function(e){return e&&`current`in e?e.current:e},wl=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Tl=function(e){return`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
- `},El=0,Dl=[];function Ol(e){var t=A.useRef([]),n=A.useRef([0,0]),r=A.useRef(),i=A.useState(El++)[0],a=A.useState(Xc)[0],o=A.useRef(e);A.useEffect(function(){o.current=e},[e]),A.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Ec([e.lockRef.current],(e.shards||[]).map(Cl),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=A.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=xl(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=ml(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=ml(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return bl(h,t,e,h===`h`?s:c,!0)},[]),c=A.useCallback(function(e){var n=e;if(Dl.length&&Dl[Dl.length-1]===a){var r=`deltaY`in n?Sl(n):xl(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&wl(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Cl).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=A.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:kl(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=A.useCallback(function(e){n.current=xl(e),r.current=void 0},[]),d=A.useCallback(function(t){l(t.type,Sl(t),t.target,s(t,e.lockRef.current))},[]),f=A.useCallback(function(t){l(t.type,xl(t),t.target,s(t,e.lockRef.current))},[]);A.useEffect(function(){return Dl.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,ll),document.addEventListener(`touchmove`,c,ll),document.addEventListener(`touchstart`,u,ll),function(){Dl=Dl.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,ll),document.removeEventListener(`touchmove`,c,ll),document.removeEventListener(`touchstart`,u,ll)}},[]);var p=e.removeScrollBar,m=e.inert;return A.createElement(A.Fragment,null,m?A.createElement(a,{styles:Tl(i)}):null,p?A.createElement(ol,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function kl(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Al=Bc(Vc,Ol),jl=A.forwardRef(function(e,t){return A.createElement(Uc,wc({},e,{ref:t,sideCar:Al}))});jl.classNames=Uc.classNames;var Ml=(0,A.createContext)({size:`sm`}),Nl=H(e=>{let t=B(`InputClearButton`,null,e),{size:n,variant:r,vars:i,classNames:a,styles:o,...s}=t,c=(0,A.use)(Ml),{resolvedClassNames:l,resolvedStyles:u}=Rn({classNames:a,styles:o,props:t});return(0,z.jsx)(vc,{variant:r||`transparent`,size:n||c?.size||`sm`,classNames:l,styles:u,__staticSelector:`InputClearButton`,style:{pointerEvents:`all`,background:`var(--input-bg)`,...s.style},...s})});Nl.displayName=`@mantine/core/InputClearButton`;var Pl={xs:7,sm:8,md:10,lg:12,xl:15};function Fl({__clearable:e,__clearSection:t,rightSection:n,__defaultRightSection:r,size:i=`sm`,__clearSectionMode:a=`both`}){let o=e&&t;return a===`rightSection`?n===null?null:n||r:a===`clear`?n===null?null:o||r:o&&(n||r)?(0,z.jsxs)(`div`,{"data-combined-clear-section":!0,style:{display:`flex`,gap:2,alignItems:`center`,paddingInlineEnd:Pl[i]},children:[o,n||r]}):n===null?null:n||o||r}var Il=(0,A.createContext)({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0}),Ll={wrapper:`m_6c018570`,input:`m_8fb7ebe7`,bottomSection:`m_93f4ed57`,section:`m_82577fc2`,placeholder:`m_88bacfd0`,root:`m_46b77525`,label:`m_8fdc1311`,required:`m_78a94662`,error:`m_8f816625`,success:`m_9d9d40e0`,description:`m_fe47ce59`},Rl=L((e,{size:t})=>({description:{"--input-description-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),zl=H(e=>{let t=B(`InputDescription`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,__inheritStyles:l=!0,attributes:u,...d}=B(`InputDescription`,null,t),f=(0,A.use)(Il),p=V({name:[`InputWrapper`,c],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,rootSelector:`description`,vars:s,varsResolver:Rl}),m=l&&f?.getStyles||p;return(0,z.jsx)(U,{component:`p`,...m(`description`,f?.getStyles?{className:r,style:i}:void 0),...d})});zl.classes=Ll,zl.varsResolver=Rl,zl.displayName=`@mantine/core/InputDescription`;var Bl=L((e,{size:t})=>({error:{"--input-error-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Vl=H(e=>{let t=B(`InputError`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,__staticSelector:l,__inheritStyles:u=!0,...d}=t,f=V({name:[`InputWrapper`,l],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`error`,vars:s,varsResolver:Bl}),p=(0,A.use)(Il),m=u&&p?.getStyles||f;return(0,z.jsx)(U,{component:`p`,...m(`error`,p?.getStyles?{className:r,style:i}:void 0),...d})});Vl.classes=Ll,Vl.varsResolver=Bl,Vl.displayName=`@mantine/core/InputError`;var Hl={labelElement:`label`},Ul=L((e,{size:t})=>({label:{"--input-label-size":fe(t),"--input-asterisk-color":void 0}})),Wl=H(e=>{let t=B(`InputLabel`,Hl,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,labelElement:c,required:l,htmlFor:u,onMouseDown:d,children:f,__staticSelector:p,mod:m,attributes:h,...g}=t,_=V({name:[`InputWrapper`,p],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`label`,vars:s,varsResolver:Ul}),v=(0,A.use)(Il),y=v?.getStyles||_,b=g.component||c,x=typeof b!=`string`||b===`label`;return(0,z.jsxs)(U,{...y(`label`,v?.getStyles?{className:r,style:i}:void 0),component:c,htmlFor:x?u:void 0,mod:[{required:l},m],onMouseDown:e=>{d?.(e),!e.defaultPrevented&&e.detail>1&&e.preventDefault()},...g,children:[f,l&&(0,z.jsx)(`span`,{...y(`required`),"aria-hidden":!0,children:` *`})]})});Wl.classes=Ll,Wl.varsResolver=Ul,Wl.displayName=`@mantine/core/InputLabel`;var Gl=H(e=>{let t=B(`InputPlaceholder`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,error:l,mod:u,attributes:d,...f}=t,p=V({name:[`InputPlaceholder`,c],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:d,rootSelector:`placeholder`});return(0,z.jsx)(U,{...p(`placeholder`),mod:[{error:!!l},u],component:`span`,...f})});Gl.classes=Ll,Gl.displayName=`@mantine/core/InputPlaceholder`;var Kl=L((e,{size:t})=>({success:{"--input-success-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),ql=H(e=>{let t=B(`InputSuccess`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,__staticSelector:l,__inheritStyles:u=!0,...d}=t,f=V({name:[`InputWrapper`,l],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`success`,vars:s,varsResolver:Kl}),p=(0,A.use)(Il),m=u&&p?.getStyles||f;return(0,z.jsx)(U,{component:`p`,...m(`success`,p?.getStyles?{className:r,style:i}:void 0),...d})});ql.classes=Ll,ql.varsResolver=Kl,ql.displayName=`@mantine/core/InputSuccess`;function Jl(e,{hasDescription:t,hasError:n}){let r=e.findIndex(e=>e===`input`),i=e.slice(0,r),a=e.slice(r+1),o=t&&i.includes(`description`)||n&&i.includes(`error`);return{offsetBottom:t&&a.includes(`description`)||n&&a.includes(`error`),offsetTop:o}}var Yl={labelElement:`label`,inputContainer:e=>e,inputWrapperOrder:[`label`,`description`,`input`,`error`]},Xl=L((e,{size:t})=>({label:{"--input-label-size":fe(t),"--input-asterisk-color":void 0},error:{"--input-error-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`},success:{"--input-success-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`},description:{"--input-description-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Zl=H(e=>{let t=B(`InputWrapper`,Yl,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,variant:l,__staticSelector:u,inputContainer:d,inputWrapperOrder:f,label:p,error:m,success:h,description:g,labelProps:_,descriptionProps:v,errorProps:y,successProps:b,labelElement:x,children:S,withAsterisk:C,id:w,required:T,__stylesApiProps:E,mod:D,attributes:O,...k}=t,j=V({name:[`InputWrapper`,u],props:E||t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:O,vars:s,varsResolver:Xl}),M={size:c,variant:l,__staticSelector:u},ee=ze(w),te=typeof C==`boolean`?C:T,ne=y?.id||`${ee}-error`,re=b?.id||`${ee}-success`,ie=v?.id||`${ee}-description`,ae=ee,oe=!!m&&typeof m!=`boolean`,se=!!h&&typeof h!=`boolean`&&!m,ce=!!g,le=oe&&f.includes(`error`),N=se&&f.includes(`error`),ue=ce&&f.includes(`description`),de=`${le?ne:``} ${N?re:``} ${ue?ie:``}`,fe=de.trim().length>0?de.trim():void 0,pe=_?.id||`${ee}-label`,me=p&&(0,z.jsx)(Wl,{labelElement:x,id:pe,htmlFor:ae,required:te,...M,..._,children:p},`label`),he=ce&&(0,z.jsx)(zl,{...v,...M,size:v?.size||M.size,id:v?.id||ie,children:g},`description`),ge=(0,z.jsx)(A.Fragment,{children:d(S)},`input`),P=oe&&(0,A.createElement)(Vl,{...y,...M,size:y?.size||M.size,key:`error`,id:y?.id||ne},m),F=se&&(0,A.createElement)(ql,{...b,...M,size:b?.size||M.size,key:`success`,id:b?.id||re},h),_e=f.map(e=>{switch(e){case`label`:return me;case`input`:return ge;case`description`:return he;case`error`:return P||F;default:return null}});return(0,z.jsx)(Il,{value:{getStyles:j,describedBy:fe,inputId:ae,labelId:pe,...Jl(f,{hasDescription:ce,hasError:oe||se})},children:(0,z.jsx)(U,{variant:l,size:c,mod:[{error:!!m,success:!!h&&!m},D],id:x===`label`?void 0:w,...j(`root`),...k,children:_e})})});Zl.classes=Ll,Zl.varsResolver=Xl,Zl.displayName=`@mantine/core/InputWrapper`;var Ql={variant:`default`,leftSectionPointerEvents:`none`,rightSectionPointerEvents:`none`,withAria:!0,withErrorStyles:!0,withSuccessStyles:!0,size:`sm`,loading:!1,loadingPosition:`right`},$l=L((e,t,n)=>({wrapper:{"--input-margin-top":n.offsetTop?`calc(var(--mantine-spacing-xs) / 2)`:void 0,"--input-margin-bottom":n.offsetBottom?`calc(var(--mantine-spacing-xs) / 2)`:void 0,"--input-height":N(t.size,`input-height`),"--input-fz":fe(t.size),"--input-radius":t.radius===void 0?void 0:de(t.radius),"--input-left-section-width":t.leftSectionWidth===void 0?void 0:E(t.leftSectionWidth),"--input-right-section-width":t.rightSectionWidth===void 0?void 0:E(t.rightSectionWidth),"--input-padding-y":t.multiline?N(t.size,`input-padding-y`):void 0,"--input-left-section-pointer-events":t.leftSectionPointerEvents,"--input-right-section-pointer-events":t.rightSectionPointerEvents}})),eu=Nr(e=>{let t=B(`Input`,Ql,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,required:s,__staticSelector:c,__stylesApiProps:l,size:u,wrapperProps:d,error:f,success:p,disabled:m,leftSection:h,leftSectionProps:g,leftSectionWidth:_,rightSection:v,rightSectionProps:y,rightSectionWidth:b,rightSectionPointerEvents:x,leftSectionPointerEvents:S,variant:C,vars:w,pointer:T,multiline:E,radius:D,id:O,withAria:k,withErrorStyles:j,withSuccessStyles:M,mod:ee,inputSize:te,attributes:ne,__clearSection:re,__clearable:ie,__clearSectionMode:ae,__defaultRightSection:oe,loading:se,loadingPosition:ce,__bottomSection:le,__bottomSectionProps:N,rootRef:ue,dir:de,...fe}=t,{styleProps:pe,rest:me}=ir(fe),he=(0,A.use)(Il),ge={offsetBottom:he?.offsetBottom,offsetTop:he?.offsetTop},P=V({name:[`Input`,c],props:l||t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:ne,stylesCtx:ge,rootSelector:`wrapper`,vars:w,varsResolver:$l}),F=k?{required:s,disabled:m,"aria-invalid":f?!0:void 0,"aria-describedby":he?.describedBy,id:he?.inputId||O}:{},_e=se?(0,z.jsx)(ac,{size:ce===`left`?`calc(var(--input-left-section-size) / 2)`:`calc(var(--input-right-section-size) / 2)`}):null,ve=se&&ce===`left`?_e:h,ye=Fl({__clearable:ie,__clearSection:re,rightSection:se&&ce===`right`?_e:v,__defaultRightSection:oe,size:u,__clearSectionMode:ae});return(0,z.jsx)(Ml,{value:{size:u||`sm`},children:(0,z.jsxs)(U,{ref:ue,dir:de,...P(`wrapper`),...pe,...d,mod:[{error:!!f&&j,success:!!p&&!f&&M,pointer:T,disabled:m,multiline:E,withRightSection:!!ye,withLeftSection:!!ve,withBottomSection:!!le},ee],variant:C,size:u,children:[ve&&(0,z.jsx)(`div`,{...g,"data-position":`left`,...P(`section`,{className:g?.className,style:g?.style}),children:ve}),(0,z.jsx)(U,{component:`input`,...me,...F,required:s,mod:{disabled:m,error:!!f&&j,success:!!p&&!f&&M},variant:C,__size:te,...P(`input`)}),le&&(0,z.jsx)(`div`,{...N,...P(`bottomSection`,{className:N?.className,style:N?.style}),children:le}),ye&&(0,z.jsx)(`div`,{...y,"data-position":`right`,...P(`section`,{className:y?.className,style:y?.style}),children:ye})]})})});eu.classes=Ll,eu.varsResolver=$l,eu.Wrapper=Zl,eu.Label=Wl,eu.Error=Vl,eu.Success=ql,eu.Description=zl,eu.Placeholder=Gl,eu.ClearButton=Nl,eu.displayName=`@mantine/core/Input`;function tu(e,t,n){let r=B([`Input`,`InputWrapper`,e],t,n),{label:i,description:a,error:o,success:s,required:c,classNames:l,styles:u,className:d,unstyled:f,__staticSelector:p,__stylesApiProps:m,errorProps:h,successProps:g,labelProps:_,descriptionProps:v,wrapperProps:y,id:b,size:x,style:S,inputContainer:C,inputWrapperOrder:w,withAsterisk:T,variant:E,vars:D,mod:O,attributes:k,...A}=r,{styleProps:j,rest:M}=ir(A),ee={label:i,description:a,error:o,success:s,required:c,classNames:l,className:d,__staticSelector:p,__stylesApiProps:m||r,errorProps:h,successProps:g,labelProps:_,descriptionProps:v,unstyled:f,styles:u,size:x,style:S,inputContainer:C,inputWrapperOrder:w,withAsterisk:T,variant:E,id:b,mod:O,attributes:k,...y};return{...M,classNames:l,styles:u,unstyled:f,wrapperProps:{...ee,...j},inputProps:{required:c,classNames:l,styles:u,unstyled:f,size:x,__staticSelector:p,__stylesApiProps:m||r,error:o,success:s,variant:E,id:b,attributes:k}}}var nu={__staticSelector:`InputBase`,withAria:!0,size:`sm`},q=Nr(e=>{let{inputProps:t,wrapperProps:n,...r}=tu(`InputBase`,nu,e);return(0,z.jsx)(eu.Wrapper,{...n,children:(0,z.jsx)(eu,{...t,...r})})});q.classes={...eu.classes,...eu.Wrapper.classes},q.displayName=`@mantine/core/InputBase`;function ru(e,t){if(!t||!e)return!1;let n=t.parentNode;for(;n!=null;){if(n===e)return!0;n=n.parentNode}return!1}function iu({target:e,parent:t,ref:n,displayAfterTransitionEnd:r,onTransitionStart:i,onTransitionEnd:a}){let o=(0,A.useRef)(-1),s=(0,A.useRef)(e),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(typeof r==`boolean`&&r),f=()=>{if(!e||!t||!n.current)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=t.offsetWidth===0?1:i.width/t.offsetWidth,o=t.offsetHeight===0?1:i.height/t.offsetHeight,s=window.getComputedStyle(e),c=window.getComputedStyle(t),l=ii(s.borderTopWidth)+ii(c.borderTopWidth),u=ii(s.borderLeftWidth)+ii(c.borderLeftWidth),d={top:(r.top-i.top)/o-l,left:(r.left-i.left)/a-u,width:r.width/a,height:r.height/o};n.current.style.transform=`translateY(${d.top}px) translateX(${d.left}px)`,n.current.style.width=`${d.width}px`,n.current.style.height=`${d.height}px`},p=()=>{window.clearTimeout(o.current),n.current&&(n.current.style.transitionDuration=`0ms`),f(),o.current=window.setTimeout(()=>{n.current&&(n.current.style.transitionDuration=``)},30)},m=(0,A.useRef)(null),h=(0,A.useRef)(null);return(0,A.useEffect)(()=>{if(c&&s.current!==e&&i&&i(),s.current=e,f(),e)return m.current=new ResizeObserver(p),m.current.observe(e),t&&(h.current=new ResizeObserver(p),h.current.observe(t)),()=>{m.current?.disconnect(),h.current?.disconnect()}},[t,e]),(0,A.useEffect)(()=>{if(t){let e=e=>{ru(e.target,t)&&(p(),d(!1))};return t.addEventListener(`transitionend`,e),()=>{t.removeEventListener(`transitionend`,e)}}},[t]),(0,A.useEffect)(()=>{if(n.current&&a){let e=e=>{e.propertyName===`transform`&&a()};return n.current.addEventListener(`transitionend`,e),()=>{n.current?.removeEventListener(`transitionend`,e)}}},[a]),Xe(()=>{mt()!==`test`&&l(!0)},20,{autoInvoke:!0}),Qe(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`dir`&&p()})},{attributes:!0,attributeFilter:[`dir`]},()=>document.documentElement),{initialized:c,hidden:u}}var au={root:`m_96b553a6`},ou=L((e,{transitionDuration:t},{shouldReduceMotion:n})=>({root:{"--transition-duration":e.respectReducedMotion&&n?`0ms`:typeof t==`number`?`${t}ms`:t||`150ms`}})),su=H(e=>{let t=B(`FloatingIndicator`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,target:c,parent:l,transitionDuration:u,mod:d,displayAfterTransitionEnd:f,onTransitionStart:p,onTransitionEnd:m,attributes:h,ref:g,..._}=t,v=V({name:`FloatingIndicator`,classes:au,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,vars:s,varsResolver:ou,stylesCtx:{shouldReduceMotion:Ge()}}),y=(0,A.useRef)(null),{initialized:b,hidden:x}=iu({target:c,parent:l,ref:y,displayAfterTransitionEnd:f,onTransitionStart:p,onTransitionEnd:m}),S=Ue(g,y);return!c||!l?null:(0,z.jsx)(U,{ref:S,mod:[{initialized:b,hidden:x},d],...v(`root`),..._})});su.displayName=`@mantine/core/FloatingIndicator`,su.classes=au,su.varsResolver=ou;function cu({style:e,size:t=16,...n}){return(0,z.jsx)(`svg`,{viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{...e,width:E(t),height:E(t),display:`block`},...n,children:(0,z.jsx)(`path`,{d:`M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}cu.displayName=`@mantine/core/AccordionChevron`;var lu={root:`m_b6d8b162`};function uu(e){if(e===`start`)return`start`;if(e===`end`||e)return`end`}var du={inherit:!1},fu=L((e,{variant:t,lineClamp:n,gradient:r,size:i,textWrap:a})=>({root:{"--text-fz":fe(i),"--text-lh":pe(i),"--text-gradient":t===`gradient`?Ut(r,e):void 0,"--text-line-clamp":typeof n==`number`?n.toString():void 0,"--text-text-wrap":a}})),pu=Nr(e=>{let t=B(`Text`,du,e),{lineClamp:n,truncate:r,inline:i,inherit:a,gradient:o,span:s,textWrap:c,__staticSelector:l,vars:u,className:d,style:f,classNames:p,styles:m,unstyled:h,variant:g,mod:_,size:v,attributes:y,...b}=t,x=V({name:[`Text`,l],props:t,classes:lu,className:d,style:f,classNames:p,styles:m,unstyled:h,attributes:y,vars:u,varsResolver:fu});return(0,z.jsx)(U,{...x(`root`,{focusable:!0}),component:s?`span`:`p`,variant:g,mod:[{truncate:uu(r),lineClamp:typeof n==`number`,inline:i,inherit:a},_],size:v,...b})});pu.classes=lu,pu.varsResolver=fu,pu.displayName=`@mantine/core/Text`;var[mu,hu]=M(`AppShell was not found in tree`),gu={root:`m_89ab340`,navbar:`m_45252eee`,aside:`m_9cdde9a`,header:`m_3b16f56b`,main:`m_8983817`,footer:`m_3840c879`,section:`m_6dcfc7c7`},_u=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellAside`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`aside`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`aside`,{className:St({[jl.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-aside-z-index":`calc(${c??d.zIndex} + 1)`}})});_u.classes=gu,_u.displayName=`@mantine/core/AppShellAside`;var vu=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellFooter`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`footer`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`footer`,{className:St({[jl.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-footer-z-index":(c??d.zIndex)?.toString()}})});vu.classes=gu,vu.displayName=`@mantine/core/AppShellFooter`;var yu=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellHeader`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`header`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`header`,{className:St({[jl.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-header-z-index":(c??d.zIndex)?.toString()}})});yu.classes=gu,yu.displayName=`@mantine/core/AppShellHeader`;var bu=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`AppShellMain`,null,e),s=hu();return(0,z.jsx)(U,{component:`main`,...s.getStyles(`main`,{className:n,style:r,classNames:t,styles:i}),...o})});bu.classes=gu,bu.displayName=`@mantine/core/AppShellMain`;var xu=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellNavbar`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`nav`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`navbar`,{className:n,classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-navbar-z-index":`calc(${c??d.zIndex} + 1)`}})});xu.classes=gu,xu.displayName=`@mantine/core/AppShellNavbar`;var Su=Nr(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,grow:o,mod:s,...c}=B(`AppShellSection`,null,e),l=hu();return(0,z.jsx)(U,{mod:[{grow:o},s],...l.getStyles(`section`,{className:n,style:r,classNames:t,styles:i}),...c})});Su.classes=gu,Su.displayName=`@mantine/core/AppShellSection`;function Cu(e){return typeof e==`object`?e.base:e}function wu(e){let t=typeof e==`object`&&!!e&&e.base!==void 0&&Object.keys(e).length===1;return typeof e==`number`||typeof e==`string`||t}function Tu(e){return!(typeof e!=`object`||!e||Object.keys(e).length===1&&`base`in e)}function Eu({baseStyles:e,minMediaStyles:t,maxMediaStyles:n,aside:r,theme:i,mode:a}){let o=r?.width,s=`translateX(var(--app-shell-aside-width))`,c=`translateX(calc(var(--app-shell-aside-width) * -1))`;if(r?.breakpoint!==void 0&&!r?.collapsed?.mobile&&(n[r?.breakpoint]=n[r?.breakpoint]||{},a===`fixed`?(n[r?.breakpoint][`--app-shell-aside-width`]=`100%`,n[r?.breakpoint][`--app-shell-aside-offset`]=`0px`):(n[r?.breakpoint][`--app-shell-aside-width`]=`0px`,n[r?.breakpoint][`--app-shell-aside-offset`]=`0px`)),wu(o)){let t=E(Cu(o));e[`--app-shell-aside-width`]=t,e[`--app-shell-aside-offset`]=t}if(Tu(o)&&(o.base!==void 0&&(e[`--app-shell-aside-width`]=E(o.base),e[`--app-shell-aside-offset`]=E(o.base)),v(o).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-aside-width`]=E(o[e]),t[e][`--app-shell-aside-offset`]=E(o[e]))})),r?.breakpoint!==void 0&&a===`static`&&(t[r.breakpoint]=t[r.breakpoint]||{},t[r.breakpoint][`--app-shell-aside-position`]=`sticky`,t[r.breakpoint][`--app-shell-aside-grid-row`]=`2`,t[r.breakpoint][`--app-shell-aside-grid-column`]=`3`,t[r.breakpoint][`--app-shell-main-column-end`]=`3`),r?.collapsed?.desktop){let e=r.breakpoint;t[e]=t[e]||{},t[e][`--app-shell-aside-transform`]=s,t[e][`--app-shell-aside-transform-rtl`]=c,a===`fixed`?t[e][`--app-shell-aside-offset`]=`0px !important`:(t[e][`--app-shell-aside-width`]=`0px`,t[e][`--app-shell-aside-display`]=`none`,t[e][`--app-shell-main-column-end`]=`-1`),t[e][`--app-shell-aside-scroll-locked-visibility`]=`hidden`}if(r?.collapsed?.mobile){let e=ge(r.breakpoint,i.breakpoints)-.1;n[e]=n[e]||{},a===`fixed`?(n[e][`--app-shell-aside-width`]=`100%`,n[e][`--app-shell-aside-offset`]=`0px`):n[e][`--app-shell-aside-width`]=`0px`,n[e][`--app-shell-aside-transform`]=s,n[e][`--app-shell-aside-transform-rtl`]=c,n[e][`--app-shell-aside-scroll-locked-visibility`]=`hidden`}}function Du({baseStyles:e,minMediaStyles:t,footer:n,mode:r}){let i=n?.height,a=r===`static`?!0:n?.offset??!0;if(r===`static`&&n&&(e[`--app-shell-footer-position`]=`sticky`,e[`--app-shell-footer-grid-column`]=`1 / -1`,e[`--app-shell-footer-grid-row`]=`3`),wu(i)){let t=E(Cu(i));e[`--app-shell-footer-height`]=t,a&&(e[`--app-shell-footer-offset`]=t)}Tu(i)&&(i.base!==void 0&&(e[`--app-shell-footer-height`]=E(i.base),a&&(e[`--app-shell-footer-offset`]=E(i.base))),v(i).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-footer-height`]=E(i[e]),a&&(t[e][`--app-shell-footer-offset`]=E(i[e])))})),n?.collapsed&&(e[`--app-shell-footer-transform`]=`translateY(var(--app-shell-footer-height))`,r===`fixed`&&(e[`--app-shell-footer-offset`]=`0px !important`))}function Ou({baseStyles:e,minMediaStyles:t,header:n,mode:r}){let i=n?.height,a=r===`static`?!0:n?.offset??!0;if(r===`static`&&n&&(e[`--app-shell-header-position`]=`sticky`,e[`--app-shell-header-grid-column`]=`1 / -1`,e[`--app-shell-header-grid-row`]=`1`),wu(i)){let t=E(Cu(i));e[`--app-shell-header-height`]=t,a&&(e[`--app-shell-header-offset`]=t)}Tu(i)&&(i.base!==void 0&&(e[`--app-shell-header-height`]=E(i.base),a&&(e[`--app-shell-header-offset`]=E(i.base))),v(i).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-header-height`]=E(i[e]),a&&(t[e][`--app-shell-header-offset`]=E(i[e])))})),n?.collapsed&&(e[`--app-shell-header-transform`]=`translateY(calc(var(--app-shell-header-height) * -1))`,r===`fixed`&&(e[`--app-shell-header-offset`]=`0px !important`))}function ku({baseStyles:e,minMediaStyles:t,maxMediaStyles:n,navbar:r,theme:i,mode:a}){let o=r?.width,s=`translateX(calc(var(--app-shell-navbar-width) * -1))`,c=`translateX(var(--app-shell-navbar-width))`;if(r?.breakpoint!==void 0&&!r?.collapsed?.mobile&&(n[r?.breakpoint]=n[r?.breakpoint]||{},n[r?.breakpoint][`--app-shell-navbar-offset`]=`0px`,n[r?.breakpoint][`--app-shell-navbar-width`]=`100%`,a===`static`&&(n[r?.breakpoint][`--app-shell-navbar-grid-width`]=`0px`)),wu(o)){let t=E(Cu(o));e[`--app-shell-navbar-width`]=t,e[`--app-shell-navbar-offset`]=t,a===`static`&&(e[`--app-shell-navbar-grid-width`]=t)}if(Tu(o)&&(o.base!==void 0&&(e[`--app-shell-navbar-width`]=E(o.base),e[`--app-shell-navbar-offset`]=E(o.base),a===`static`&&(e[`--app-shell-navbar-grid-width`]=E(o.base))),v(o).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-navbar-width`]=E(o[e]),t[e][`--app-shell-navbar-offset`]=E(o[e]),a===`static`&&(t[e][`--app-shell-navbar-grid-width`]=E(o[e])))})),r?.breakpoint!==void 0&&a===`static`&&(t[r.breakpoint]=t[r.breakpoint]||{},t[r.breakpoint][`--app-shell-navbar-position`]=`sticky`,t[r.breakpoint][`--app-shell-navbar-grid-row`]=`2`,t[r.breakpoint][`--app-shell-navbar-grid-column`]=`1`,t[r.breakpoint][`--app-shell-main-column-start`]=`2`),r?.collapsed?.desktop){let e=r.breakpoint;t[e]=t[e]||{},t[e][`--app-shell-navbar-transform`]=s,t[e][`--app-shell-navbar-transform-rtl`]=c,a===`fixed`?t[e][`--app-shell-navbar-offset`]=`0px !important`:(t[e][`--app-shell-navbar-width`]=`0px`,t[e][`--app-shell-navbar-display`]=`none`,t[e][`--app-shell-main-column-start`]=`1`)}if(r?.collapsed?.mobile){let e=ge(r.breakpoint,i.breakpoints)-.1;n[e]=n[e]||{},n[e][`--app-shell-navbar-width`]=`100%`,n[e][`--app-shell-navbar-offset`]=`0px`,a===`static`&&(n[e][`--app-shell-navbar-grid-width`]=`0px`),n[e][`--app-shell-navbar-transform`]=s,n[e][`--app-shell-navbar-transform-rtl`]=c}}function Au(e){return Number(e)===0?`0px`:ue(e)}function ju({padding:e,baseStyles:t,minMediaStyles:n}){wu(e)&&(t[`--app-shell-padding`]=Au(Cu(e))),Tu(e)&&(e.base&&(t[`--app-shell-padding`]=Au(e.base)),v(e).forEach(t=>{t!==`base`&&(n[t]=n[t]||{},n[t][`--app-shell-padding`]=Au(e[t]))}))}function Mu({navbar:e,header:t,footer:n,aside:r,padding:i,theme:a,mode:o}){let s={},c={},l={};o===`static`&&(l[`--app-shell-main-grid-column`]=`1 / -1`,l[`--app-shell-main-grid-row`]=`2`),ku({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,navbar:e,theme:a,mode:o}),Eu({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,aside:r,theme:a,mode:o}),Ou({baseStyles:l,minMediaStyles:s,header:t,mode:o}),Du({baseStyles:l,minMediaStyles:s,footer:n,mode:o}),ju({baseStyles:l,minMediaStyles:s,padding:i});let u=P(v(s),a.breakpoints).map(e=>({query:`(min-width: ${D(e.px)})`,styles:s[e.value]})),d=P(v(c),a.breakpoints).map(e=>({query:`(max-width: ${D(e.px)})`,styles:c[e.value]}));return{baseStyles:l,media:[...u,...d]}}function Nu({navbar:e,header:t,aside:n,footer:r,padding:i,mode:a,selector:o}){let s=Sn(),c=Zt(),{media:l,baseStyles:u}=Mu({navbar:e,header:t,footer:r,aside:n,padding:i,theme:s,mode:a});return(0,z.jsx)(tr,{media:l,styles:u,selector:o||c.cssVariablesSelector})}function Pu({transitionDuration:e,disabled:t}){let[n,r]=(0,A.useState)(!0),i=(0,A.useRef)(-1),a=(0,A.useRef)(-1);return Be(`resize`,()=>{r(!0),clearTimeout(i.current),i.current=window.setTimeout(()=>(0,A.startTransition)(()=>{r(!1)}),200)}),we(()=>{r(!0),clearTimeout(a.current),a.current=window.setTimeout(()=>(0,A.startTransition)(()=>{r(!1)}),e||0)},[t,e]),n}var Fu={withBorder:!0,padding:0,transitionDuration:200,transitionTimingFunction:`ease`,zIndex:se(`app`),mode:`fixed`},Iu=L((e,{transitionDuration:t,transitionTimingFunction:n})=>({root:{"--app-shell-transition-duration":`${t}ms`,"--app-shell-transition-timing-function":n}})),Lu=H(e=>{let t=B(`AppShell`,Fu,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,navbar:c,withBorder:l,padding:u,transitionDuration:d,transitionTimingFunction:f,header:p,zIndex:m,layout:h,disabled:g,aside:_,footer:v,offsetScrollbars:y=!0,mode:b,mod:x,attributes:S,id:C,...w}=t,T=V({name:`AppShell`,classes:gu,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:S,vars:s,varsResolver:Iu}),E=Pu({disabled:g,transitionDuration:d}),D=ze(C);return(0,z.jsxs)(mu,{value:{getStyles:T,withBorder:l,zIndex:m,disabled:g,offsetScrollbars:y,mode:b},children:[(0,z.jsx)(Nu,{navbar:c,header:p,aside:_,footer:v,padding:u,mode:b,selector:b===`static`?`#${D}`:void 0}),(0,z.jsx)(U,{...T(`root`),id:D,mod:[{resizing:E,layout:h,disabled:g,mode:b},x],...w})]})});Lu.classes=gu,Lu.varsResolver=Iu,Lu.displayName=`@mantine/core/AppShell`,Lu.Navbar=xu,Lu.Header=yu,Lu.Main=bu,Lu.Aside=_u,Lu.Footer=vu,Lu.Section=Su;function Ru(e){return typeof e==`string`?{value:e,label:e}:typeof e==`object`&&`value`in e&&!(`label`in e)?{value:e.value,label:`${e.value}`,disabled:e.disabled}:typeof e==`object`&&`group`in e?{group:e.group,items:e.items.map(e=>Ru(e))}:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?{value:e,label:`${e}`}:e}function zu(e){return e?e.map(e=>Ru(e)):[]}function Bu(e){return e.reduce((e,t)=>`group`in t?{...e,...Bu(t.items)}:(e[`${t.value}`]=t,e),{})}var Vu={dropdown:`m_88b62a41`,search:`m_985517d8`,options:`m_b2821a6e`,option:`m_92253aa5`,empty:`m_2530cd1d`,header:`m_858f94bd`,footer:`m_82b967cb`,group:`m_254f3e4f`,groupLabel:`m_2bb2e9e5`,chevron:`m_2943220b`,optionsDropdownOption:`m_390b5f4`,optionsDropdownCheckIcon:`m_8ee53fc2`,optionsDropdownCheckPlaceholder:`m_a530ee0a`},Hu={error:null},Uu=L((e,{size:t,color:n})=>({chevron:{"--combobox-chevron-size":N(t,`combobox-chevron-size`),"--combobox-chevron-color":n?Bt(n,e):void 0}})),Wu=H(e=>{let t=B(`ComboboxChevron`,Hu,e),{size:n,error:r,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,attributes:u,mod:d,...f}=t,p=V({name:`ComboboxChevron`,classes:Vu,props:t,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,varsResolver:Uu,attributes:u,rootSelector:`chevron`});return(0,z.jsx)(U,{component:`svg`,...f,...p(`chevron`),size:n,viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,mod:[`combobox-chevron`,{error:r},d],children:(0,z.jsx)(`path`,{d:`M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})});Wu.classes=Vu,Wu.varsResolver=Uu,Wu.displayName=`@mantine/core/ComboboxChevron`;var[Gu,Ku]=M(`Combobox component was not found in tree`);function qu({onMouseDown:e,onClick:t,onClear:n,...r}){return(0,z.jsx)(eu.ClearButton,{tabIndex:-1,"aria-hidden":!0,...r,onMouseDown:t=>{t.preventDefault(),e?.(t)},onClick:e=>{n(),t?.(e)}})}qu.displayName=`@mantine/core/ComboboxClearButton`;var Ju=H(e=>{let{classNames:t,styles:n,className:r,style:i,hidden:a,...o}=B(`ComboboxDropdown`,null,e),s=Ku();return(0,z.jsx)(Zs.Dropdown,{...o,role:`presentation`,"data-hidden":a||void 0,"data-floating-height":s.floatingHeight||void 0,...s.getStyles(`dropdown`,{className:r,style:i,classNames:t,styles:n})})});Ju.classes=Vu,Ju.displayName=`@mantine/core/ComboboxDropdown`;var Yu={refProp:`ref`},Xu=H(e=>{let{children:t,refProp:n,ref:r}=B(`ComboboxDropdownTarget`,Yu,e);if(Ku(),!j(t))throw Error(`Combobox.DropdownTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return(0,z.jsx)(Zs.Target,{ref:r,refProp:n,children:t})});Xu.displayName=`@mantine/core/ComboboxDropdownTarget`;var Zu=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`ComboboxEmpty`,null,e),s=Ku();return(0,z.jsx)(U,{...s.getStyles(`empty`,{className:n,classNames:t,styles:i,style:r}),...o})});Zu.classes=Vu,Zu.displayName=`@mantine/core/ComboboxEmpty`;function J({onKeyDown:e,onClick:t,withKeyboardNavigation:n,withAriaAttributes:r,withExpandedAttribute:i,targetType:a,autoComplete:o}){let s=Ku(),[c,l]=(0,A.useState)(null),u=t=>{if(e?.(t),!s.readOnly&&n){if(t.nativeEvent.isComposing)return;if(t.nativeEvent.code===`ArrowDown`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectNextOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`ArrowUp`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectPreviousOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`Enter`||t.nativeEvent.code===`NumpadEnter`){if(t.nativeEvent.keyCode===229)return;let e=s.store.getSelectedOptionIndex();s.store.dropdownOpened&&e!==-1?(t.preventDefault(),s.store.clickSelectedOption()):a===`button`&&(t.preventDefault(),s.store.openDropdown(`keyboard`))}t.key===`Escape`&&s.store.closeDropdown(`keyboard`),t.nativeEvent.code===`Space`&&a===`button`&&(t.preventDefault(),s.store.toggleDropdown(`keyboard`))}},d=r?{...i?{role:`combobox`}:{},"aria-haspopup":`listbox`,"aria-expanded":i?!!(s.store.listId&&s.store.dropdownOpened):void 0,"aria-controls":s.store.dropdownOpened&&s.store.listId?s.store.listId:void 0,"aria-activedescendant":s.store.dropdownOpened&&c||void 0,autoComplete:o,"data-expanded":s.store.dropdownOpened||void 0,"data-mantine-stop-propagation":s.store.dropdownOpened||void 0}:{},f=e=>{a===`button`&&e.currentTarget.focus(),t?.(e)};return{...d,onKeyDown:u,onClick:f}}var Qu={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},Y=H(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=B(`ComboboxEventsTarget`,Qu,e),u=bt(t);if(!u)throw Error(`Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let d=Ku(),f=J({targetType:o,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:a,onKeyDown:u.props.onKeyDown,onClick:u.props.onClick,autoComplete:s});return(0,A.cloneElement)(u,{...f,...l,[n]:Ue(c,d.store.targetRef,ht(u))})});Y.displayName=`@mantine/core/ComboboxEventsTarget`;var X=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`ComboboxFooter`,null,e),s=Ku();return(0,z.jsx)(U,{...s.getStyles(`footer`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});X.classes=Vu,X.displayName=`@mantine/core/ComboboxFooter`;var Z=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,children:o,label:s,id:c,...l}=B(`ComboboxGroup`,null,e),u=Ku(),d=ze(c),f=s!=null&&s!==!1&&s!==``;return(0,z.jsxs)(U,{role:`group`,"aria-labelledby":f?d:void 0,...u.getStyles(`group`,{className:n,classNames:t,style:r,styles:i}),...l,children:[f&&(0,z.jsx)(`div`,{id:d,...u.getStyles(`groupLabel`,{classNames:t,styles:i}),children:s}),o]})});Z.classes=Vu,Z.displayName=`@mantine/core/ComboboxGroup`;var $u=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`ComboboxHeader`,null,e),s=Ku();return(0,z.jsx)(U,{...s.getStyles(`header`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});$u.classes=Vu,$u.displayName=`@mantine/core/ComboboxHeader`;function ed({value:e,valuesDivider:t=`,`,...n}){return(0,z.jsx)(`input`,{type:`hidden`,value:Array.isArray(e)?e.join(t):e?`${e}`:``,...n})}ed.displayName=`@mantine/core/ComboboxHiddenInput`;var td=H(e=>{let t=B(`ComboboxOption`,null,e),{classNames:n,className:r,style:i,styles:a,vars:o,onClick:s,id:c,active:l,onMouseDown:u,onMouseOver:d,disabled:f,selected:p,mod:m,...h}=t,g=Ku(),_=(0,A.useId)(),v=c||_;return(0,z.jsx)(U,{...g.getStyles(`option`,{className:r,classNames:n,styles:a,style:i}),...h,id:v,mod:[`combobox-option`,{"combobox-active":l,"combobox-disabled":f,"combobox-selected":p},m],role:`option`,onClick:e=>{f?e.preventDefault():(g.onOptionSubmit?.(t.value,t),s?.(e))},onMouseDown:e=>{e.preventDefault(),u?.(e)},onMouseOver:e=>{g.resetSelectionOnOptionHover&&g.store.resetSelectedOption(),d?.(e)}})});td.classes=Vu,td.displayName=`@mantine/core/ComboboxOption`;var nd=H(e=>{let{classNames:t,className:n,style:r,styles:i,id:a,onMouseDown:o,labelledBy:s,...c}=B(`ComboboxOptions`,null,e),l=Ku(),u=ze(a);return(0,A.useEffect)(()=>{l.store.setListId(u)},[u]),(0,z.jsx)(U,{...l.getStyles(`options`,{className:n,style:r,classNames:t,styles:i}),...c,id:u,role:`listbox`,"aria-labelledby":s,onMouseDown:e=>{e.preventDefault(),o?.(e)}})});nd.classes=Vu,nd.displayName=`@mantine/core/ComboboxOptions`;var rd={withAriaAttributes:!0,withKeyboardNavigation:!0},id=H(e=>{let{classNames:t,styles:n,unstyled:r,vars:i,withAriaAttributes:a,onKeyDown:o,onClick:s,withKeyboardNavigation:c,size:l,ref:u,...d}=B(`ComboboxSearch`,rd,e),f=Ku(),p=f.getStyles(`search`),m=J({targetType:`input`,withAriaAttributes:a,withKeyboardNavigation:c,withExpandedAttribute:!1,onKeyDown:o,onClick:s,autoComplete:`off`});return(0,z.jsx)(eu,{ref:Ue(u,f.store.searchRef),classNames:[{input:p.className},t],styles:[{input:p.style},n],size:l||f.size,...m,...d,__staticSelector:`Combobox`})});id.classes=Vu,id.displayName=`@mantine/core/ComboboxSearch`;var ad={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},od=H(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=B(`ComboboxTarget`,ad,e),u=bt(t);if(!u)throw Error(`Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let d=Ku(),f=J({targetType:o,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:a,onKeyDown:u.props.onKeyDown,onClick:u.props.onClick,autoComplete:s}),p=(0,A.cloneElement)(u,{...f,...l});return(0,z.jsx)(Zs.Target,{refProp:n,ref:Ue(c,d.store.targetRef),children:p})});od.displayName=`@mantine/core/ComboboxTarget`;function sd(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].hasAttribute(`data-combobox-disabled`))return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].hasAttribute(`data-combobox-disabled`))return e}return e}function cd(e,t,n){for(let n=e+1;n<t.length;n+=1)if(!t[n].hasAttribute(`data-combobox-disabled`))return n;if(n){for(let e=0;e<t.length;e+=1)if(!t[e].hasAttribute(`data-combobox-disabled`))return e}return e}function ld(e){for(let t=0;t<e.length;t+=1)if(!e[t].hasAttribute(`data-combobox-disabled`))return t;return-1}function ud({defaultOpened:e,opened:t,onOpenedChange:n,onDropdownClose:r,onDropdownOpen:i,loop:a=!0,scrollBehavior:o=`instant`}={}){let[s,c]=We({value:t,defaultValue:e,finalValue:!1,onChange:n}),l=(0,A.useRef)(null),u=(0,A.useRef)(-1),d=(0,A.useRef)(null),f=(0,A.useRef)(null),p=(0,A.useRef)(-1),m=(0,A.useRef)(-1),h=(0,A.useRef)(-1),g=(0,A.useCallback)((e=`unknown`)=>{s||(c(!0),i?.(e))},[c,i,s]),_=(0,A.useCallback)((e=`unknown`)=>{s&&(c(!1),r?.(e))},[c,r,s]),v=(0,A.useCallback)((e=`unknown`)=>{s?_(e):g(e)},[_,g,s]),y=(0,A.useCallback)(()=>{let e=yt(f.current),t=_t(`#${l.current} [data-combobox-selected]`,e);t?.removeAttribute(`data-combobox-selected`),t?.removeAttribute(`aria-selected`)},[]),b=(0,A.useCallback)(e=>{let t=yt(f.current),n=_t(`#${l.current}`,t),r=n?vt(`[data-combobox-option]`,n):null;if(!r)return null;let i=e>=r.length?0:e<0?r.length-1:e;return u.current=i,r?.[i]&&!r[i].hasAttribute(`data-combobox-disabled`)?(y(),r[i].setAttribute(`data-combobox-selected`,`true`),r[i].setAttribute(`aria-selected`,`true`),r[i].scrollIntoView({block:`nearest`,behavior:o}),r[i].id):null},[o,y]),x=(0,A.useCallback)(()=>{let e=yt(f.current),t=_t(`#${l.current} [data-combobox-active]`,e);if(t){let n=vt(`#${l.current} [data-combobox-option]`,e).findIndex(e=>e===t);return b(n)}return b(0)},[b]),S=(0,A.useCallback)(()=>{let e=yt(f.current),t=vt(`#${l.current} [data-combobox-option]`,e);return b(cd(u.current,t,a))},[b,a]),C=(0,A.useCallback)(()=>{let e=yt(f.current),t=vt(`#${l.current} [data-combobox-option]`,e);return b(sd(u.current,t,a))},[b,a]),w=(0,A.useCallback)(()=>{let e=yt(f.current),t=vt(`#${l.current} [data-combobox-option]`,e);return b(ld(t))},[b]),T=(0,A.useCallback)((e=`selected`,t)=>{if(typeof e==`number`){u.current=e;let n=yt(f.current),r=vt(`#${l.current} [data-combobox-option]`,n);t?.scrollIntoView&&r[e]?.scrollIntoView({block:`nearest`,behavior:o});return}h.current=window.setTimeout(()=>{let n=yt(f.current),r=vt(`#${l.current} [data-combobox-option]`,n),i=r.findIndex(t=>t.hasAttribute(`data-combobox-${e}`));u.current=i,t?.scrollIntoView&&r[i]?.scrollIntoView({block:`nearest`,behavior:o})},0)},[]),E=(0,A.useCallback)(()=>{u.current=-1,y()},[y]),D=(0,A.useCallback)(()=>{let e=yt(f.current);(vt(`#${l.current} [data-combobox-option]`,e)?.[u.current])?.click()},[]),O=(0,A.useCallback)(e=>{l.current=e},[]),k=(0,A.useCallback)(()=>{p.current=window.setTimeout(()=>d.current?.focus(),0)},[]),j=(0,A.useCallback)(()=>{m.current=window.setTimeout(()=>f.current?.focus(),0)},[]),M=(0,A.useCallback)(()=>u.current,[]);return(0,A.useEffect)(()=>()=>{window.clearTimeout(p.current),window.clearTimeout(m.current),window.clearTimeout(h.current)},[]),{dropdownOpened:s,openDropdown:g,closeDropdown:_,toggleDropdown:v,selectedOptionIndex:u.current,getSelectedOptionIndex:M,selectOption:b,selectFirstOption:w,selectActiveOption:x,selectNextOption:S,selectPreviousOption:C,resetSelectedOption:E,updateSelectedOptionIndex:T,listId:l.current,setListId:O,clickSelectedOption:D,searchRef:d,focusSearchInput:k,targetRef:f,focusTarget:j}}var dd={keepMounted:!0,keepMountedMode:`display-none`,withinPortal:!0,resetSelectionOnOptionHover:!1,width:`target`,transitionProps:{transition:`fade`,duration:0},size:`sm`},fd=L((e,{size:t,dropdownPadding:n})=>({options:{"--combobox-option-fz":fe(t),"--combobox-option-padding":N(t,`combobox-option-padding`)},dropdown:{"--combobox-padding":n===void 0?void 0:E(n),"--combobox-option-fz":fe(t),"--combobox-option-padding":N(t,`combobox-option-padding`)}})),Q=e=>{let t=B(`Combobox`,dd,e),{classNames:n,styles:r,unstyled:i,children:a,store:o,vars:s,onOptionSubmit:c,onClose:l,size:u,dropdownPadding:d,resetSelectionOnOptionHover:f,__staticSelector:p,readOnly:m,attributes:h,floatingHeight:g,middlewares:_,...v}=t,y=g===`viewport`?{..._,flip:!1,size:{...typeof _?.size==`object`?_.size:{},padding:typeof _?.size==`object`&&_.size.padding!==void 0?_.size.padding:10,apply:({availableHeight:e,availableWidth:t,elements:n,...r})=>{n.floating.style.setProperty(`--combobox-floating-max-height`,`${e}px`);let i=_?.size;typeof i==`object`&&i.apply?i.apply({availableHeight:e,availableWidth:t,elements:n,...r}):i&&Object.assign(n.floating.style,{maxWidth:`${t}px`,maxHeight:`${e}px`})}}}:_,b=ud(),x=o||b,S=V({name:p||`Combobox`,classes:Vu,props:t,classNames:n,styles:r,unstyled:i,attributes:h,vars:s,varsResolver:fd}),C=()=>{l?.(),x.closeDropdown()};return(0,z.jsx)(Gu,{value:{getStyles:S,store:x,onOptionSubmit:c,size:u,resetSelectionOnOptionHover:f,readOnly:m,floatingHeight:g},children:(0,z.jsx)(Zs,{opened:x.dropdownOpened,...v,middlewares:y,onChange:e=>!e&&C(),withRoles:!1,unstyled:i,children:a})})};Q.extend=e=>e,Q.classes=Vu,Q.varsResolver=fd,Q.displayName=`@mantine/core/Combobox`,Q.Target=od,Q.Dropdown=Ju,Q.Options=nd,Q.Option=td,Q.Search=id,Q.Empty=Zu,Q.Chevron=Wu,Q.Footer=X,Q.Header=$u,Q.EventsTarget=Y,Q.DropdownTarget=Xu,Q.Group=Z,Q.ClearButton=qu,Q.HiddenInput=ed;function pd({size:e,style:t,...n}){let r=e===void 0?t:{width:E(e),height:E(e),...t};return(0,z.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,z.jsx)(`path`,{d:`M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}function md(e){return`group`in e}function hd({options:e,search:t,limit:n}){let r=t.trim().toLowerCase(),i=[];for(let a=0;a<e.length;a+=1){let o=e[a];if(i.length===n)return i;md(o)&&i.push({group:o.group,items:hd({options:o.items,search:t,limit:n-i.length})}),md(o)||o.label.toLowerCase().includes(r)&&i.push(o)}return i}function gd(e){if(e.length===0)return!0;for(let t of e)if(!(`group`in t)||t.items.length>0)return!1;return!0}function _d(e,t=new Set){if(Array.isArray(e))for(let n of e)if(md(n))_d(n.items,t);else{if(n.value===void 0)throw Error(`[@mantine/core] Each option must have value property`);if(t.has(n.value))throw Error(`[@mantine/core] Duplicate options are not supported. Option with value "${n.value}" was provided more than once`);t.add(n.value)}}function vd(e,t){return Array.isArray(e)?e.includes(t):e===t}function yd({data:e,withCheckIcon:t,withAlignedLabels:n,value:r,checkIconPosition:i,unstyled:a,renderOption:o}){if(!md(e)){let s=vd(r,e.value),c=t&&(s?(0,z.jsx)(pd,{className:Vu.optionsDropdownCheckIcon}):n?(0,z.jsx)(`div`,{className:Vu.optionsDropdownCheckPlaceholder}):null),l=(0,z.jsxs)(z.Fragment,{children:[i===`left`&&c,(0,z.jsx)(`span`,{children:e.label}),i===`right`&&c]});return(0,z.jsx)(Q.Option,{value:e.value,disabled:e.disabled,className:St({[Vu.optionsDropdownOption]:!a}),"data-reverse":i===`right`||void 0,"data-checked":s||void 0,"aria-selected":s,active:s,children:typeof o==`function`?o({option:e,checked:s}):l})}let s=e.items.map(e=>(0,z.jsx)(yd,{data:e,value:r,unstyled:a,withCheckIcon:t,withAlignedLabels:n,checkIconPosition:i,renderOption:o},`${e.value}`));return(0,z.jsx)(Q.Group,{label:e.group,children:s})}function bd({data:e,hidden:t,hiddenWhenEmpty:n,filter:r,search:i,limit:a,maxDropdownHeight:o,floatingHeight:s,withScrollArea:c=!0,filterOptions:l=!0,withCheckIcon:u=!1,withAlignedLabels:d=!1,value:f,checkIconPosition:p,nothingFoundMessage:m,unstyled:h,labelId:g,renderOption:_,scrollAreaProps:v,"aria-label":y}){let b=Ku();_d(e);let x=typeof i==`string`?(r||hd)({options:e,search:l?i:``,limit:a??1/0}):e,S=gd(x),C=x.map((e,t)=>(0,z.jsx)(yd,{data:e,withCheckIcon:u,withAlignedLabels:d,value:f,checkIconPosition:p,unstyled:h,renderOption:_},md(e)?`group-${typeof e.group==`string`?e.group:t}`:`${e.value}`));return(0,z.jsx)(Q.Dropdown,{hidden:t||n&&S,"data-composed":!0,children:(0,z.jsxs)(Q.Options,{labelledBy:g,"aria-label":y,children:[c?(0,z.jsx)(os.Autosize,{mah:(s??b.floatingHeight)===`viewport`?`var(--combobox-floating-options-max-height)`:o??220,type:`scroll`,scrollbarSize:`var(--combobox-padding)`,offsetScrollbars:`y`,...v,children:C}):C,S&&m&&(0,z.jsx)(Q.Empty,{children:m})]})})}var xd={root:`m_347db0ec`,"root--dot":`m_fbd81e3d`,label:`m_5add502a`,section:`m_91fdda9b`},Sd=L((e,{radius:t,color:n,gradient:r,variant:i,size:a,autoContrast:o,circle:s})=>{let c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:o});return{root:{"--badge-height":N(a,`badge-height`),"--badge-padding-x":N(a,`badge-padding-x`),"--badge-fz":N(a,`badge-fz`),"--badge-radius":s||t===void 0?void 0:de(t),"--badge-bg":n||i?c.background:void 0,"--badge-color":n||i?c.color:void 0,"--badge-bd":n||i?c.border:void 0,"--badge-dot-color":i===`dot`?Bt(n,e):void 0}}}),Cd=Nr(e=>{let t=B(`Badge`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,radius:c,color:l,gradient:u,leftSection:d,rightSection:f,children:p,variant:m,fullWidth:h,autoContrast:g,circle:_,mod:v,attributes:y,...b}=t,x=V({name:`Badge`,props:t,classes:xd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:y,vars:s,varsResolver:Sd});return(0,z.jsxs)(U,{variant:m,mod:[{block:h,circle:_,"with-right-section":!!f,"with-left-section":!!d},v],...x(`root`,{variant:m}),...b,children:[d&&(0,z.jsx)(`span`,{...x(`section`),"data-position":`left`,children:d}),(0,z.jsx)(`span`,{...x(`label`),children:p}),f&&(0,z.jsx)(`span`,{...x(`section`),"data-position":`right`,children:f})]})});Cd.classes=xd,Cd.varsResolver=Sd,Cd.displayName=`@mantine/core/Badge`;var wd={root:`m_fea6bf1a`,burger:`m_d4fb9cad`},Td=L((e,{color:t,size:n,lineSize:r,transitionDuration:i,transitionTimingFunction:a})=>({root:{"--burger-color":t?Bt(t,e):void 0,"--burger-size":N(n,`burger-size`),"--burger-line-size":r?E(r):void 0,"--burger-transition-duration":i===void 0?void 0:`${i}ms`,"--burger-transition-timing-function":a}})),Ed=H(e=>{let t=B(`Burger`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,opened:c,children:l,transitionDuration:u,transitionTimingFunction:d,lineSize:f,attributes:p,...m}=t,h=V({name:`Burger`,classes:wd,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:s,varsResolver:Td});return(0,z.jsxs)(us,{...h(`root`),...m,children:[(0,z.jsx)(U,{mod:[`reduce-motion`,{opened:c}],...h(`burger`)}),l]})});Ed.classes=wd,Ed.varsResolver=Td,Ed.displayName=`@mantine/core/Burger`;var Dd={root:`m_77c9d27d`,inner:`m_80f1301b`,label:`m_811560b9`,section:`m_a74036a`,loader:`m_a25b86ee`,group:`m_80d6d844`,groupSection:`m_70be2a01`},Od={orientation:`horizontal`},kd=L((e,{borderWidth:t})=>({group:{"--button-border-width":E(t)}})),Ad=H(e=>{let t=B(`ButtonGroup`,Od,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,orientation:s,vars:c,borderWidth:l,mod:u,attributes:d,...f}=B(`ButtonGroup`,Od,e),p=V({name:`ButtonGroup`,props:t,classes:Dd,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:c,varsResolver:kd,rootSelector:`group`});return(0,z.jsx)(U,{...p(`group`),mod:[{orientation:s},u],role:`group`,...f})});Ad.classes=Dd,Ad.varsResolver=kd,Ad.displayName=`@mantine/core/ButtonGroup`;var jd=L((e,{radius:t,color:n,gradient:r,variant:i,autoContrast:a,size:o})=>{let s=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:a});return{groupSection:{"--section-height":N(o,`section-height`),"--section-padding-x":N(o,`section-padding-x`),"--section-fz":o?.includes(`compact`)?fe(o.replace(`compact-`,``)):fe(o),"--section-radius":t===void 0?void 0:de(t),"--section-bg":n||i?s.background:void 0,"--section-color":s.color,"--section-bd":n||i?s.border:void 0}}}),Md=H(e=>{let t=B(`ButtonGroupSection`,null,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,vars:s,gradient:c,radius:l,autoContrast:u,attributes:d,...f}=t,p=V({name:`ButtonGroupSection`,props:t,classes:Dd,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:s,varsResolver:jd,rootSelector:`groupSection`});return(0,z.jsx)(U,{...p(`groupSection`),...f})});Md.classes=Dd,Md.varsResolver=jd,Md.displayName=`@mantine/core/ButtonGroupSection`;var Nd={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${E(1)}))`},out:{opacity:0,transform:`translate(-50%, -200%)`},common:{transformOrigin:`center`},transitionProperty:`transform, opacity`},Pd=L((e,{radius:t,color:n,gradient:r,variant:i,size:a,justify:o,autoContrast:s})=>{let c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:s});return{root:{"--button-justify":o,"--button-height":N(a,`button-height`),"--button-padding-x":N(a,`button-padding-x`),"--button-fz":a?.includes(`compact`)?fe(a.replace(`compact-`,``)):fe(a),"--button-radius":t===void 0?void 0:de(t),"--button-bg":n||i?c.background:void 0,"--button-hover":n||i?c.hover:void 0,"--button-color":c.color,"--button-bd":n||i?c.border:void 0,"--button-hover-color":n||i?c.hoverColor:void 0}}}),Fd=Nr(e=>{let t=B(`Button`,null,e),{style:n,vars:r,className:i,color:a,disabled:o,children:s,leftSection:c,rightSection:l,fullWidth:u,variant:d,radius:f,loading:p,loaderProps:m,gradient:h,classNames:g,styles:_,unstyled:v,"data-disabled":y,autoContrast:b,mod:x,attributes:S,...C}=t,w=V({name:`Button`,props:t,classes:Dd,className:i,style:n,classNames:g,styles:_,unstyled:v,attributes:S,vars:r,varsResolver:Pd}),T=!!c,E=!!l;return(0,z.jsxs)(us,{...w(`root`,{active:!o&&!p&&!y}),unstyled:v,variant:d,disabled:o||p,mod:[{disabled:o||y,loading:p,block:u,"with-left-section":T,"with-right-section":E},x],...C,children:[typeof p==`boolean`&&(0,z.jsx)(Fs,{mounted:p,transition:Nd,duration:150,children:e=>(0,z.jsx)(U,{component:`span`,...w(`loader`,{style:e}),"aria-hidden":!0,children:(0,z.jsx)(ac,{color:`var(--button-color)`,size:`calc(var(--button-height) / 1.8)`,...m})})}),(0,z.jsxs)(`span`,{...w(`inner`),children:[c&&(0,z.jsx)(U,{component:`span`,...w(`section`),mod:{position:`left`},children:c}),(0,z.jsx)(U,{component:`span`,mod:{loading:p},...w(`label`),children:s}),l&&(0,z.jsx)(U,{component:`span`,...w(`section`),mod:{position:`right`},children:l})]})]})});Fd.classes=Dd,Fd.varsResolver=Pd,Fd.displayName=`@mantine/core/Button`,Fd.Group=Ad,Fd.GroupSection=Md;function Id(e){let t=e.currentTarget;return yt(t).activeElement!==t}function Ld(e,t){let n=t.trim().toLowerCase();if(n===``)return;let r=Object.values(e).filter(e=>!e.disabled&&e.label.trim().toLowerCase()===n);return r.length===1?r[0]:void 0}var Rd={root:`m_f0824112`,description:`m_57492dcc`,section:`m_690090b5`,label:`m_1f6ac4c4`,body:`m_f07af9d2`,children:`m_e17b862f`,chevron:`m_1fd8a00b`},zd=L((e,{variant:t,color:n,childrenOffset:r,autoContrast:i})=>{let a=e.variantColorResolver({color:n||e.primaryColor,theme:e,variant:t||`light`,autoContrast:i});return{root:{"--nl-bg":n||t?a.background:void 0,"--nl-hover":n||t?a.hover:void 0,"--nl-color":n||t?a.color:void 0},children:{"--nl-offset":ue(r)}}}),Bd=Nr(e=>{let t=B(`NavLink`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,opened:c,defaultOpened:l,onChange:u,children:d,active:f,disabled:p,leftSection:m,rightSection:h,label:g,description:_,disableRightSectionRotation:v,noWrap:y,childrenOffset:b,autoContrast:x,mod:S,attributes:C,onClick:w,onKeyDown:T,keepMounted:E,...D}=t,O=V({name:`NavLink`,props:t,classes:Rd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:C,vars:s,varsResolver:zd}),[k,A]=We({value:c,defaultValue:l,finalValue:!1,onChange:u}),j=!!d,M=e=>{w?.(e),j&&(e.preventDefault(),A(!k))};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(us,{...O(`root`),component:`a`,onClick:M,onKeyDown:e=>{T?.(e),e.nativeEvent.code===`Space`&&j&&(e.preventDefault(),A(!k))},unstyled:o,mod:[{disabled:p,active:f,expanded:k},S],...D,children:[m&&(0,z.jsx)(U,{component:`span`,...O(`section`),mod:{position:`left`},children:m}),(0,z.jsxs)(U,{...O(`body`),mod:{"no-wrap":y},children:[(0,z.jsx)(U,{component:`span`,...O(`label`),children:g}),(0,z.jsx)(U,{component:`span`,mod:{active:f},...O(`description`),children:_})]}),(j||h!==void 0)&&(0,z.jsx)(U,{...O(`section`),component:`span`,mod:{rotate:k&&!v,position:`right`},children:j&&h===void 0?(0,z.jsx)(cu,{...O(`chevron`)}):h})]}),j&&(0,z.jsx)(Ur,{expanded:k,keepMounted:E,...O(`collapse`),children:(0,z.jsx)(`div`,{...O(`children`),children:d})})]})});Bd.classes=Rd,Bd.varsResolver=zd,Bd.displayName=`@mantine/core/NavLink`;var Vd={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},Hd={withItemsBorders:!0},Ud=L((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:de(t),"--sc-color":n?Bt(n,e):void 0,"--sc-shadow":n?void 0:`var(--mantine-shadow-xs)`,"--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":a,"--sc-padding":N(i,`sc-padding`),"--sc-font-size":fe(i)}})),Wd=Mr(e=>{let t=B(`SegmentedControl`,Hd,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,data:c,value:l,defaultValue:u,onChange:d,size:f,name:p,disabled:m,readOnly:h,fullWidth:g,orientation:_,radius:v,color:y,transitionDuration:b,transitionTimingFunction:x,variant:S,autoContrast:C,withItemsBorders:w,mod:T,attributes:E,ref:D,...O}=t,k=V({name:`SegmentedControl`,props:t,classes:Vd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:E,vars:s,varsResolver:Ud}),j=Sn(),M=c.map(e=>gt(e)?{label:`${e}`,value:e}:e),ee=$e(),[te,ne]=(0,A.useState)(F()),[re,ie]=(0,A.useState)(null),[ae,oe]=(0,A.useState)({}),se=(e,t)=>{e!==null&&ae[t]!==e&&(ae[t]=e,oe({...ae}))},[ce,le]=We({value:l,defaultValue:u,finalValue:Array.isArray(c)?M.find(e=>!e.disabled)?.value??c[0]?.value??null:null,onChange:d}),N=ze(p),ue=M.map(e=>`${e.value}`),de=M.map(e=>(0,A.createElement)(U,{...k(`control`),mod:{active:ce===e.value,orientation:_},key:`${e.value}`},(0,A.createElement)(`input`,{...k(`input`),disabled:m||e.disabled,type:`radio`,name:N,value:`${e.value}`,id:`${N}-${e.value}`,checked:ce===e.value,onChange:()=>!h&&le(e.value),"data-focus-ring":j.focusRing,key:`${e.value}-input`}),(0,A.createElement)(U,{component:`label`,...k(`label`),mod:{active:ce===e.value&&!(m||e.disabled),disabled:m||e.disabled,"read-only":h},htmlFor:`${N}-${e.value}`,ref:t=>se(t,`${e.value}`),__vars:{"--sc-label-color":y===void 0?void 0:R({color:y,theme:j,autoContrast:C})},key:`${e.value}-label`},(0,z.jsx)(`span`,{...k(`innerLabel`),children:e.label})))),fe=Ue(D,ie);return Je(()=>{ne(F())},[c.length]),Je(()=>{oe(e=>{let t={};return ue.forEach(n=>{n in e&&(t[n]=e[n])}),Object.keys(t).length===Object.keys(e).length?e:t})},[ue]),c.length===0?null:(0,z.jsxs)(U,{...k(`root`),variant:S,size:f,ref:fe,mod:[{"full-width":g,orientation:_,initialized:ee,"with-items-borders":w},T],...O,role:`radiogroup`,"data-disabled":m,children:[ce!==void 0&&(0,z.jsx)(su,{target:ae[`${ce}`],parent:re,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...k(`indicator`)},te),de]})});Wd.classes=Vd,Wd.varsResolver=Ud,Wd.displayName=`@mantine/core/SegmentedControl`;var Gd={size:`sm`,withCheckIcon:!0,allowDeselect:!0,checkIconPosition:`left`,openOnFocus:!0},Kd=Mr(e=>{let t=B([`Input`,`InputWrapper`,`Select`],Gd,e),{classNames:n,styles:r,unstyled:i,vars:a,dropdownOpened:o,defaultDropdownOpened:s,onDropdownClose:c,onDropdownOpen:l,onFocus:u,onBlur:d,onClick:f,onChange:p,data:m,value:h,defaultValue:g,selectFirstOptionOnChange:_,selectFirstOptionOnDropdownOpen:v,onOptionSubmit:y,comboboxProps:b,readOnly:x,disabled:S,filter:C,limit:w,withScrollArea:T,maxDropdownHeight:E,floatingHeight:D,size:O,searchable:k,rightSection:j,checkIconPosition:M,withCheckIcon:ee,withAlignedLabels:te,nothingFoundMessage:ne,name:re,form:ie,searchValue:ae,defaultSearchValue:oe,onSearchChange:se,allowDeselect:ce,error:le,rightSectionPointerEvents:N,id:ue,clearable:de,clearSectionMode:fe,clearButtonProps:pe,hiddenInputProps:me,renderOption:he,onClear:ge,autoComplete:P,scrollAreaProps:F,__defaultRightSection:_e,__clearSection:ve,__clearable:ye,chevronColor:be,autoSelectOnBlur:xe,openOnFocus:Se,attributes:Ce,...we}=t,Te=(0,A.useMemo)(()=>zu(m),[m]),I=(0,A.useRef)({}),Ee=(0,A.useMemo)(()=>Bu(Te),[Te]),De=ze(ue),[Oe,ke,Ae]=We({value:h,defaultValue:g,finalValue:null,onChange:p}),je=Oe==null?void 0:`${Oe}`in Ee?Ee[`${Oe}`]:I.current[`${Oe}`],Me=Ze(je),[Ne,Pe,Fe]=We({value:ae,defaultValue:oe,finalValue:je?je.label:``,onChange:se}),Ie=ud({opened:o,defaultOpened:s,onDropdownOpen:()=>{l?.(),v?Ie.selectFirstOption():Ie.updateSelectedOptionIndex(`active`,{scrollIntoView:!0})},onDropdownClose:()=>{c?.(),setTimeout(Ie.resetSelectedOption,0)}}),Le=e=>{Pe(e),Ie.resetSelectedOption()},{resolvedClassNames:Re,resolvedStyles:Be}=Rn({props:t,styles:r,classNames:n});(0,A.useEffect)(()=>{_&&Ie.selectFirstOption()},[_,Ne]),(0,A.useEffect)(()=>{h===null&&Le(``),h!=null&&je&&(Me?.value!==je.value||Me?.label!==je.label)&&Le(je.label)},[h,je]),(0,A.useEffect)(()=>{!Ae&&!Fe&&Le(Oe==null?``:`${Oe}`in Ee?Ee[`${Oe}`]?.label:I.current[`${Oe}`]?.label||``)},[Ee,Oe]),(0,A.useEffect)(()=>{Oe&&`${Oe}`in Ee&&(I.current[`${Oe}`]=Ee[`${Oe}`])},[Ee,Oe]);let Ve=(0,z.jsx)(Q.ClearButton,{...pe,onClear:()=>{ke(null,null),Le(``),ge?.()}}),He=de&&Oe!=null&&!S&&!x;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Q,{store:Ie,__staticSelector:`Select`,classNames:Re,styles:Be,unstyled:i,readOnly:x,size:O,attributes:Ce,floatingHeight:D,keepMounted:xe,onOptionSubmit:e=>{y?.(e);let t=ce&&`${Ee[e].value}`==`${Oe}`?null:Ee[e],n=t?t.value:null;n!==Oe&&ke(n,t),!Ae&&Le(n==null?``:t?.label||``),Ie.closeDropdown()},...b,children:[(0,z.jsx)(Q.Target,{targetType:k?`input`:`button`,autoComplete:P,withExpandedAttribute:!0,children:(0,z.jsx)(q,{id:De,__defaultRightSection:(0,z.jsx)(Q.Chevron,{size:O,error:le,unstyled:i,color:be}),__clearSection:Ve,__clearable:He,__clearSectionMode:fe,rightSection:j,rightSectionPointerEvents:N||`none`,...we,size:O,__staticSelector:`Select`,disabled:S,readOnly:x||!k,value:Ne,onChange:e=>{if(Id(e)){if(!x){let t=Ld(Ee,e.currentTarget.value);t&&`${t.value}`!=`${Oe}`&&(ke(t.value,t),!Ae&&Le(t.label))}return}Le(e.currentTarget.value),Ie.openDropdown(),_&&Ie.selectFirstOption()},onFocus:e=>{Se&&k&&Ie.openDropdown(),u?.(e)},onBlur:e=>{xe&&Ie.clickSelectedOption(),k&&Ie.closeDropdown();let t=Oe!=null&&(`${Oe}`in Ee?Ee[`${Oe}`]:I.current[`${Oe}`]);Le(t&&t.label||``),d?.(e)},onClick:e=>{k?Ie.openDropdown():Ie.toggleDropdown(),f?.(e)},classNames:Re,styles:Be,unstyled:i,pointer:!k,error:le,attributes:Ce})}),(0,z.jsx)(bd,{data:Te,hidden:x||S,filter:C,search:Ne,limit:w,hiddenWhenEmpty:!ne,withScrollArea:T,maxDropdownHeight:E,filterOptions:!!k&&je?.label!==Ne,value:Oe,checkIconPosition:M,withCheckIcon:ee,withAlignedLabels:te,nothingFoundMessage:ne,unstyled:i,labelId:we.label?`${De}-label`:void 0,"aria-label":we.label?void 0:we[`aria-label`],renderOption:he,scrollAreaProps:F})]}),(0,z.jsx)(Q.HiddenInput,{value:Oe,name:re,form:ie,disabled:S,...me})]})});Kd.classes={...q.classes,...Q.classes},Kd.displayName=`@mantine/core/Select`;var qd={root:`m_6d731127`},Jd={gap:`md`,align:`stretch`,justify:`flex-start`},Yd=L((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":ue(t),"--stack-align":n,"--stack-justify":r}})),Xd=H(e=>{let t=B(`Stack`,Jd,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,align:c,justify:l,gap:u,variant:d,attributes:f,...p}=t,m=V({name:`Stack`,props:t,classes:qd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:Yd});return(0,z.jsx)(U,{...m(`root`),variant:d,...p})});Xd.classes=qd,Xd.varsResolver=Yd,Xd.displayName=`@mantine/core/Stack`;var[Zd,Qd]=M(`Tabs component was not found in the tree`),$d={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},ef=H(e=>{let t=B(`TabsList`,null,e),{children:n,className:r,grow:i,justify:a,classNames:o,styles:s,style:c,mod:l,...u}=t,d=Qd();return(0,z.jsx)(U,{...d.getStyles(`list`,{className:r,style:c,classNames:o,styles:s,props:t,variant:d.variant}),role:`tablist`,variant:d.variant,mod:[{grow:i,orientation:d.orientation,placement:d.orientation===`vertical`&&d.placement,inverted:d.inverted},l],"aria-orientation":d.orientation,__vars:{"--tabs-justify":a},...u,children:n})});ef.classes=$d,ef.displayName=`@mantine/core/TabsList`;var tf=H(e=>{let t=B(`TabsPanel`,null,e),{children:n,className:r,value:i,classNames:a,styles:o,style:s,mod:c,keepMounted:l,...u}=t,d=on(),f=Qd();(0,A.useEffect)(()=>(f.setMountedPanel(i,!0),()=>{f.setMountedPanel(i,!1)}),[i]);let p=f.value===i,m=f.keepMounted||l,h=f.keepMountedMode!==`display-none`,g=m&&h&&d!==`test`?(0,z.jsx)(A.Activity,{mode:p?`visible`:`hidden`,children:n}):m||p?n:null;return(0,z.jsx)(U,{...f.getStyles(`panel`,{className:r,classNames:a,styles:o,style:[s,p?void 0:{display:`none`}],props:t}),mod:[{orientation:f.orientation},c],role:`tabpanel`,id:f.getPanelId(i),"aria-labelledby":f.getTabId(i),...u,children:g})});tf.classes=$d,tf.displayName=`@mantine/core/TabsPanel`;var nf=H(e=>{let t=B(`TabsTab`,null,e),{className:n,children:r,rightSection:i,leftSection:a,value:o,onClick:s,onKeyDown:c,disabled:l,color:u,style:d,classNames:f,styles:p,vars:m,mod:h,tabIndex:g,..._}=t,v=Sn(),{dir:y}=Vr(),b=Qd(),x=o===b.value,S=e=>{b.onChange(b.allowTabDeactivation&&o===b.value?null:o),s?.(e)},C={classNames:f,styles:p,props:t};return(0,z.jsxs)(us,{...b.getStyles(`tab`,{className:n,style:d,variant:b.variant,...C}),disabled:l,unstyled:b.unstyled,variant:b.variant,mod:[{active:x,disabled:l,orientation:b.orientation,inverted:b.inverted,placement:b.orientation===`vertical`&&b.placement},h],role:`tab`,id:b.getTabId(o),"aria-selected":x,tabIndex:g===void 0?x||b.value===null?0:-1:g,"aria-controls":b.mountedPanels.current.has(o)?b.getPanelId(o):void 0,onClick:S,__vars:{"--tabs-color":u?Bt(u,v):void 0},onKeyDown:ae({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:b.activateTabWithKeyboard,loop:b.loop,orientation:b.orientation||`horizontal`,dir:y,onKeyDown:c}),..._,children:[a&&(0,z.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`left`,children:a}),r&&(0,z.jsx)(`span`,{...b.getStyles(`tabLabel`,C),children:r}),i&&(0,z.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`right`,children:i})]})});nf.classes=$d,nf.displayName=`@mantine/core/TabsTab`;var rf=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,af={keepMounted:!0,keepMountedMode:`activity`,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},of=L((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":de(t),"--tabs-color":Bt(n,e),"--tabs-text-color":Yt(r,e)?R({color:n,theme:e,autoContrast:r}):void 0}})),sf=H(e=>{let t=B(`Tabs`,af,e),{defaultValue:n,value:r,onChange:i,orientation:a,children:o,loop:s,id:c,activateTabWithKeyboard:l,allowTabDeactivation:u,variant:d,color:f,radius:p,inverted:m,placement:h,keepMounted:g,keepMountedMode:_,classNames:v,styles:y,unstyled:b,className:x,style:S,vars:C,autoContrast:w,mod:T,attributes:E,...D}=t,O=ze(c),k=(0,A.useRef)(new Set),j=Re(),M=(0,A.useCallback)((e,t)=>{let n=k.current;t&&!n.has(e)?(n.add(e),j()):!t&&n.has(e)&&(n.delete(e),j())},[]),[te,ne]=We({value:r,defaultValue:n,finalValue:null,onChange:i}),re=V({name:`Tabs`,props:t,classes:$d,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:of});return(0,z.jsx)(Zd,{value:{placement:h,value:te,orientation:a,id:O,loop:s,activateTabWithKeyboard:l,getTabId:ee(`${O}-tab`,rf),getPanelId:ee(`${O}-panel`,rf),onChange:ne,allowTabDeactivation:u,variant:d,color:f,radius:p,inverted:m,keepMounted:g,keepMountedMode:_,unstyled:b,getStyles:re,mountedPanels:k,setMountedPanel:M},children:(0,z.jsx)(U,{id:O,variant:d,mod:[{orientation:a,inverted:a===`horizontal`&&m,placement:a===`vertical`&&h},T],...re(`root`),...D,children:o})})});sf.classes=$d,sf.varsResolver=of,sf.displayName=`@mantine/core/Tabs`,sf.Tab=nf,sf.Panel=tf,sf.List=ef;var cf=H(e=>{let t=B([`Input`,`InputWrapper`,`TextInput`],null,e);return(0,z.jsx)(q,{component:`input`,...t,__staticSelector:`TextInput`})});cf.classes=q.classes,cf.displayName=`@mantine/core/TextInput`;var lf=A.createContext(void 0),uf=e=>{let t=A.useContext(lf);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},df=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,z.jsx)(lf.Provider,{value:e,children:t})),ff={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},pf=new class{#e=ff;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function mf(e){setTimeout(e,0)}var hf=typeof window>`u`||`Deno`in globalThis;function gf(){}function _f(e,t){return typeof e==`function`?e(t):e}function vf(e){return typeof e==`number`&&e>=0&&e!==1/0}function yf(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bf(e,t){return typeof e==`function`?e(t):e}function xf(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Cf(o,t.options))return!1}else if(!Tf(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Sf(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(wf(t.options.mutationKey)!==wf(a))return!1}else if(!Tf(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Cf(e,t){return(t?.queryKeyHashFn||wf)(e)}function wf(e){return JSON.stringify(e,(e,t)=>Af(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Tf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Tf(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Tf(e[r],t[r]))return!1;return!0}return!1}var Ef=Object.prototype.hasOwnProperty;function Df(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=kf(e)&&kf(t);if(!r&&!(Af(e)&&Af(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Ef.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Df(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Of(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function kf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Af(e){if(!jf(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!jf(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function jf(e){return Object.prototype.toString.call(e)===`[object Object]`}function Mf(e){return new Promise(t=>{pf.setTimeout(t,e)})}function Nf(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Df(e,t)}function Pf(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ff(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var If=Symbol();function Lf(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===If?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Rf(e,t){return typeof e==`function`?e(...t):!!e}function zf(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Bf=()=>hf,$=()=>Bf(),Vf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Hf=new class extends Vf{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Uf=mf;function Wf(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Uf,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Gf=Wf(),Kf=new class extends Vf{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function qf(e){return Math.min(1e3*2**e,3e4)}function Jf(e){return(e??`online`)!==`online`||Kf.isOnline()}var Yf=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Xf(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(gf);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Yf(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Hf.isFocused()&&(e.networkMode===`always`||Kf.isOnline())&&e.canRun(),p=()=>Jf(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??($()?0:3),a=e.retryDelay??qf,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),Mf(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var Zf=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vf(this.gcTime)&&(this.#e=pf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(pf.clearTimeout(this.#e),this.#e=void 0)}};function Qf(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{zf(e,()=>t.signal,()=>n=!0)},u=Lf(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Ff:Pf;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ep:$f,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:$f(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function $f(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ep(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var tp=class extends Zf{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=ip(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=ip(this.options);e.data!==void 0&&(this.setState(rp(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Nf(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(gf).catch(gf):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>bf(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===If||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>bf(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!yf(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Lf(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Qf(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Xf({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Yf&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Yf){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...np(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...rp(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),Gf.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function np(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Jf(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function rp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function ip(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var ap=class extends Vf{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),sp(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cp(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof bf(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Of(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&lp(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||bf(this.options.enabled,this.#t)!==bf(t.enabled,this.#t)||bf(this.options.staleTime,this.#t)!==bf(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||bf(this.options.enabled,this.#t)!==bf(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Of(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(gf)),t}#h(e){return!$()&&bf(this.options.enabled,this.#t)!==!1&&vf(e)}#g(){this.#b();let e=bf(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=yf(this.#r.dataUpdatedAt,e)+1;this.#u=pf.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=pf.setInterval(()=>{(this.options.refetchIntervalInBackground||Hf.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(pf.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(pf.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&sp(e,t),o=i&&lp(e,n,t,r);(a||o)&&(l={...l,...np(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Nf(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Nf(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:up(e,t),refetch:this.refetch,isEnabled:bf(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Of(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();Gf.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function op(e,t){return bf(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||bf(t.retryOnMount,e)!==!1)}function sp(e,t){return op(e,t)||e.state.data!==void 0&&cp(e,t,t.refetchOnMount)}function cp(e,t,n){if(bf(t.enabled,e)!==!1&&bf(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&up(e,t)}return!1}function lp(e,t,n,r){return(e!==t||bf(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&up(e,n)}function up(e,t){return bf(t.enabled,e)!==!1&&e.isStaleByTime(bf(t.staleTime,e))}var dp=class extends Zf{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||fp(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Xf({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Gf.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function fp(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var pp=class extends Vf{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new dp({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=mp(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=mp(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=mp(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=mp(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Gf.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Sf(t,e))}findAll(e={}){return this.getAll().filter(t=>Sf(e,t))}notify(e){Gf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Gf.batch(()=>Promise.all(e.map(e=>e.continue().catch(gf))))}};function mp(e){return e.options.scope?.id}var hp=class extends Vf{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Of(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&wf(t.mutationKey)!==wf(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??fp();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Gf.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},gp=class extends Vf{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Cf(r,t),a=this.get(i);return a||(a=new tp({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Gf.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>xf(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>xf(e,t)):t}notify(e){Gf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Gf.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Gf.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},_p=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new gp,this.#t=e.mutationCache||new pp,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Hf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Kf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bf(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=_f(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Gf.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Gf.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Gf.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=Gf.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(gf).catch(gf)}invalidateQueries(e,t={}){return Gf.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Gf.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(gf)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(gf)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(bf(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(bf(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(gf).catch(gf)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(gf).catch(gf)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Kf.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(wf(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Tf(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(wf(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Tf(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Cf(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===If&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},vp=A.createContext(!1),yp=()=>A.useContext(vp);vp.Provider;function bp(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xp=A.createContext(bp()),Sp=()=>A.useContext(xp),Cp=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Rf(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},wp=e=>{A.useEffect(()=>{e.clearReset()},[e])},Tp=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Rf(n,[e.error,r])),Ep=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Dp=(e,t)=>e?.suspense&&t.isPending,Op=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function kp(e,t,n){let r=yp(),i=Sp(),a=uf(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Ep(o),Cp(o,i,s),wp(i);let[l]=A.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(A.useSyncExternalStore(A.useCallback(e=>{let t=d?l.subscribe(Gf.batchCalls(e)):gf;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),A.useEffect(()=>{l.setOptions(o)},[o,l]),Dp(o,u))throw Op(o,l,i);if(Tp({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Ap(e,t){return kp(e,ap,t)}function jp(e,t){let n=uf(t),[r]=A.useState(()=>new hp(n,e));A.useEffect(()=>{r.setOptions(e)},[r,e]);let i=A.useSyncExternalStore(A.useCallback(e=>r.subscribe(Gf.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=A.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(gf)},[r]);if(i.error&&Rf(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Mp=_();function Np({placeholder:e,ariaLabel:t,submitLabel:n,onSubmit:r,onCancel:i,size:a,autoFocus:o}){let[s,c]=(0,A.useState)(``),[l,u]=(0,A.useState)(void 0);function d(){let e=s.trim();e!==``&&(u(void 0),Promise.resolve(r(e)).then(()=>{c(``)}).catch(e=>{u(e instanceof Error?e.message:String(e))}))}function f(e){e.key===`Enter`&&d(),e.key===`Escape`&&i?.()}return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Cc,{gap:`xs`,flex:1,children:[(0,z.jsx)(cf,{flex:1,...a===void 0?{}:{size:a},placeholder:e,"aria-label":t,autoComplete:`off`,autoFocus:o,value:s,onChange:e=>{c(e.currentTarget.value)},onKeyDown:f}),(0,z.jsx)(Fd,{...a===void 0?{}:{size:a},onClick:d,children:n})]}),l!==void 0&&(0,z.jsx)(pu,{size:`sm`,c:`red`,children:l})]})}function Pp(e){if(e.kind!==`action`)return null;let t=e.action;return t.action===`join_room`?{kind:`join_room`,room:t.room}:t.action===`leave_room`?{kind:`leave_room`}:null}function Fp(e,t,n){let r=e.trim();return r.length===0?{kind:`ignored`}:r.startsWith(`/`)?Ip(r,t):t!==void 0&&t!==``?{kind:`action`,action:{action:`send`,target:t,content:r}}:n!==void 0&&n!==``?{kind:`action`,action:{action:`dm`,target:n,content:r}}:{kind:`local`,result:{type:`error`,text:`Join a room or select an agent first`}}}function Ip(e,t){let n=e.slice(1).split(/\s+/),r=(n[0]??``).toLowerCase();switch(r){case`join`:return n[1]===void 0||n[1]===``?{kind:`local`,result:{type:`error`,text:`Usage: /join <room>`}}:{kind:`action`,action:{action:`join_room`,room:n[1]}};case`leave`:return{kind:`action`,action:{action:`leave_room`,room:n[1]??t??``}};case`rooms`:return{kind:`action`,action:{action:`list_rooms`}};case`agents`:return{kind:`action`,action:{action:`list_agents`}};case`dm`:return n[1]===void 0||n[1]===``||n[2]===void 0||n[2]===``?{kind:`local`,result:{type:`error`,text:`Usage: /dm <agent> <message>`}}:{kind:`action`,action:{action:`dm`,target:n[1],content:n.slice(2).join(` `)}};case`create`:return n[1]===void 0||n[1]===``?{kind:`local`,result:{type:`error`,text:`Usage: /create <name>`}}:{kind:`action`,action:{action:`create_room`,name:n[1],type:`public`}};case`destroy`:return n[1]===void 0||n[1]===``?{kind:`local`,result:{type:`error`,text:`Usage: /destroy <room>`}}:{kind:`action`,action:{action:`destroy_room`,room:n[1]}};case`rename`:return n[1]===void 0||n[1]===``||n[2]===void 0||n[2]===``?{kind:`local`,result:{type:`error`,text:`Usage: /rename <agent> <new-name>`}}:{kind:`action`,action:{action:`rename_agent`,agent:n[1],name:n.slice(2).join(` `)}};case`help`:return{kind:`local`,result:{type:`help`,text:`Commands: /join, /leave, /rooms, /agents, /dm, /create, /destroy, /rename, /help`}};default:return{kind:`local`,result:{type:`unknown`,text:`Unknown command: /${r}`}}}}function Lp(e,t){switch(e.status){case`delivered`:return`delivered to ${t}`;case`read`:return`read by ${t}`;case`queued`:return`queued for ${t} (${e.reason}), not yet delivered`;case`refused`:return`refused by ${t} (${e.code})`;case`dropped`:return`dropped for ${t}, never delivered`;case`expired`:return`expired for ${t}, never delivered`;default:return e}}var Rp=11,zp=19;function Bp(e){return e.slice(Rp,zp)}function Vp(e,t){switch(e.type){case`room_message`:return t===e.message.room?{type:`chat`,sender:e.message.from,content:e.message.content,timestamp:e.message.timestamp}:void 0;case`dm`:return{type:`dm`,sender:e.message.from,content:e.message.content,timestamp:e.message.timestamp};case`member_joined`:return{type:`system`,text:`${e.agent} joined ${e.room}`};case`member_left`:return{type:`system`,text:`${e.agent} left ${e.room}`};case`member_status`:return{type:`status`,text:`${e.agent} is now ${e.status} in ${e.room}`};case`delivery_status`:return{type:`status`,text:`Message ${e.messageId} ${Lp(e.delivery,e.agent)}`};case`room_members`:return t===e.room?{type:`system`,text:`Members: ${e.members.map(e=>`${e.name} (${e.status})`).join(`, `)}`}:void 0;case`room_invite`:{let t=e.roomDescription?` — ${e.roomDescription}`:``;return{type:`system`,text:`${e.fromName} invited you to "${e.room}"${t}`}}case`invite_declined`:return{type:`system`,text:`${e.agentName} declined invite to ${e.room}: "${e.reason}"`};case`name_changed`:return{type:`system`,text:`${e.oldName} is now known as ${e.newName}`};default:return e}}function Hp(e){return{type:`chat`,sender:e.from,content:e.content,timestamp:e.timestamp}}function Up({message:e}){switch(e.type){case`chat`:return(0,z.jsxs)(Cc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,z.jsx)(pu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,z.jsx)(pu,{c:`dimmed`,size:`xs`,span:!0,children:Bp(e.timestamp)}),(0,z.jsxs)(pu,{span:!0,children:[`: `,e.content]})]});case`dm`:return(0,z.jsxs)(Cc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,z.jsx)(Cd,{color:`grape`,size:`xs`,children:`DM`}),(0,z.jsx)(pu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,z.jsx)(pu,{c:`dimmed`,size:`xs`,span:!0,children:Bp(e.timestamp)}),(0,z.jsxs)(pu,{span:!0,children:[`: `,e.content]})]});case`system`:return(0,z.jsx)(pu,{c:`dimmed`,fs:`italic`,size:`sm`,children:e.text});case`status`:return(0,z.jsx)(pu,{c:`yellow`,size:`xs`,children:e.text})}}function Wp({messages:e}){let t=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.length]),(0,z.jsx)(os,{flex:1,p:`md`,viewportRef:t,"aria-label":`Conversation`,children:(0,z.jsx)(Xd,{gap:4,children:e.map((e,t)=>(0,z.jsx)(Up,{message:e},t))})})}function Gp({messages:e,rooms:t,currentRoom:n,dmTarget:r,connected:i,sidebarOpened:a,onToggleSidebar:o,onSendAction:s,onLeaveRoom:c,onConnectToMesh:l}){let u=(n===void 0?void 0:t.find(e=>e.id===n)?.name??n)??(r===void 0?`Select a room`:`DM with ${r}`);return(0,z.jsxs)(Xd,{h:`100%`,gap:0,children:[(0,z.jsxs)(Cc,{component:`header`,justify:`space-between`,px:`md`,py:`sm`,bg:`dark.6`,children:[(0,z.jsxs)(Cc,{gap:`sm`,children:[(0,z.jsx)(Ed,{opened:a,onClick:o,size:`sm`,"aria-label":`Toggle sidebar`}),(0,z.jsx)(pu,{fw:600,children:u})]}),n!==void 0&&(0,z.jsx)(Fd,{size:`xs`,variant:`subtle`,onClick:c,children:`Leave`})]}),(0,z.jsx)(Wp,{messages:e}),!i&&e.length===0&&(0,z.jsxs)(Xd,{align:`center`,justify:`center`,gap:`md`,p:`xl`,children:[(0,z.jsx)(pu,{c:`dimmed`,children:`Connect to a local mesh to discover agents and rooms.`}),(0,z.jsx)(Fd,{variant:`outline`,onClick:l,children:`Connect to local mesh`})]}),(0,z.jsx)(Cc,{px:`md`,py:`sm`,bg:`dark.6`,children:(0,z.jsx)(Np,{ariaLabel:`Message`,placeholder:`Type a message or /command...`,submitLabel:`Send`,onSubmit:e=>{switch(Fp(e,n,r).kind){case`action`:s(e);break;case`local`:s(e)}}})})]})}function Kp(e,t){var n,r=1;e??=0,t??=0;function i(){var i,a=n.length,o,s=0,c=0;for(i=0;i<a;++i)o=n[i],s+=o.x,c+=o.y;for(s=(s/a-e)*r,c=(c/a-t)*r,i=0;i<a;++i)o=n[i],o.x-=s,o.y-=c}return i.initialize=function(e){n=e},i.x=function(t){return arguments.length?(e=+t,i):e},i.y=function(e){return arguments.length?(t=+e,i):t},i.strength=function(e){return arguments.length?(r=+e,i):r},i}function qp(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Jp(this.cover(t,n),t,n,e)}function Jp(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function Yp(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<c&&(c=i),i>u&&(u=i),a<l&&(l=a),a>d&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<r;++n)Jp(this,o[n],s[n],e[n]);return this}function Xp(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function Zp(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Qp(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function $p(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function em(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new $p(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a)){if(p.length){var g=(o+c)/2,_=(s+l)/2;f.push(new $p(p[3],g,_,c,l),new $p(p[2],o,_,g,l),new $p(p[1],g,s,c,_),new $p(p[0],o,s,g,_)),(h=(t>=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b<n){var x=Math.sqrt(n=b);i=e-x,a=t-x,u=e+x,d=t+x,r=p.data}}}return r}function tm(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function nm(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function rm(){return this._root}function im(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function am(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new $p(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new $p(i,l,u,s,c)),(i=r[2])&&t.push(new $p(i,a,u,l,c)),(i=r[1])&&t.push(new $p(i,l,o,s,u)),(i=r[0])&&t.push(new $p(i,a,o,l,u))}return this}function om(e){var t=[],n=[],r;for(this._root&&t.push(new $p(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new $p(a,o,s,u,d)),(a=i[1])&&t.push(new $p(a,u,s,c,d)),(a=i[2])&&t.push(new $p(a,o,d,u,l)),(a=i[3])&&t.push(new $p(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function sm(e){return e[0]}function cm(e){return arguments.length?(this._x=e,this):this._x}function lm(e){return e[1]}function um(e){return arguments.length?(this._y=e,this):this._y}function dm(e,t,n){var r=new fm(t??sm,n??lm,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function fm(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function pm(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var mm=dm.prototype=fm.prototype;mm.copy=function(){var e=new fm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=pm(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=pm(r));return e},mm.add=qp,mm.addAll=Yp,mm.cover=Xp,mm.data=Zp,mm.extent=Qp,mm.find=em,mm.remove=tm,mm.removeAll=nm,mm.root=rm,mm.size=im,mm.visit=am,mm.visitAfter=om,mm.x=cm,mm.y=um;function hm(e){return function(){return e}}function gm(e){return(e()-.5)*1e-6}function _m(e){return e.index}function vm(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function ym(e){var t=_m,n=d,r,i=hm(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n<u;++n)for(var o=0,s,d,f,p,m,h,g;o<i;++o)s=e[o],d=s.source,f=s.target,p=f.x+f.vx-d.x-d.vx||gm(l),m=f.y+f.vy-d.y-d.vy||gm(l),h=Math.sqrt(p*p+m*m),h=(h-a[o])/h*t*r[o],p*=h,m*=h,f.vx-=p*(g=c[o]),f.vy-=m*g,d.vx+=p*(g=1-g),d.vy+=m*g}function p(){if(o){var n,i=o.length,l=e.length,u=new Map(o.map((e,n)=>[t(e,n,o),e])),d;for(n=0,s=Array(i);n<l;++n)d=e[n],d.index=n,typeof d.source!=`object`&&(d.source=vm(u,d.source)),typeof d.target!=`object`&&(d.target=vm(u,d.target)),s[d.source.index]=(s[d.source.index]||0)+1,s[d.target.index]=(s[d.target.index]||0)+1;for(n=0,c=Array(l);n<l;++n)d=e[n],c[n]=s[d.source.index]/(s[d.source.index]+s[d.target.index]);r=Array(l),m(),a=Array(l),h()}}function m(){if(o)for(var t=0,i=e.length;t<i;++t)r[t]=+n(e[t],t,e)}function h(){if(o)for(var t=0,n=e.length;t<n;++t)a[t]=+i(e[t],t,e)}return f.initialize=function(e,t){o=e,l=t,p()},f.links=function(t){return arguments.length?(e=t,p(),f):e},f.id=function(e){return arguments.length?(t=e,f):t},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.strength=function(e){return arguments.length?(n=typeof e==`function`?e:hm(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:hm(+e),h(),f):i},f}var bm={value:()=>{}};function xm(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Sm(n)}function Sm(e){this._=e}function Cm(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Sm.prototype=xm.prototype={constructor:Sm,on:function(e,t){var n=this._,r=Cm(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=wm(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Tm(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Tm(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Sm(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function wm(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Tm(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=bm,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Em=0,Dm=0,Om=0,km=1e3,Am,jm,Mm=0,Nm=0,Pm=0,Fm=typeof performance==`object`&&performance.now?performance:Date,Im=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lm(){return Nm||=(Im(Rm),Fm.now()+Pm)}function Rm(){Nm=0}function zm(){this._call=this._time=this._next=null}zm.prototype=Bm.prototype={constructor:zm,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Lm():+n)+(t==null?0:+t),!this._next&&jm!==this&&(jm?jm._next=this:Am=this,jm=this),this._call=e,this._time=n,Gm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Gm())}};function Bm(e,t,n){var r=new zm;return r.restart(e,t,n),r}function Vm(){Lm(),++Em;for(var e=Am,t;e;)(t=Nm-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Em}function Hm(){Nm=(Mm=Fm.now())+Pm,Em=Dm=0;try{Vm()}finally{Em=0,Wm(),Nm=0}}function Um(){var e=Fm.now(),t=e-Mm;t>km&&(Pm-=t,Mm=e)}function Wm(){for(var e,t=Am,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Am=n);jm=e,Gm(r)}function Gm(e){Em||(Dm&&=clearTimeout(Dm),e-Nm>24?(e<1/0&&(Dm=setTimeout(Hm,e-Fm.now()-Pm)),Om&&=clearInterval(Om)):(Om||=(Mm=Fm.now(),setInterval(Um,km)),Em=1,Im(Hm)))}var Km=1664525,qm=1013904223,Jm=4294967296;function Ym(){let e=1;return()=>(e=(Km*e+qm)%Jm)/Jm}function Xm(e){return e.x}function Zm(e){return e.y}var Qm=10,$m=Math.PI*(3-Math.sqrt(5));function eh(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=Bm(d),l=xm(`tick`,`end`),u=Ym();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=Qm*Math.sqrt(.5+t),a=t*$m;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function th(){var e,t,n,r,i=hm(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=dm(e,Xm,Zm).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=gm(n),m+=d*d),f===0&&(f=gm(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=gm(n),m+=d*d),f===0&&(f=gm(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:hm(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}var nh=600,rh=400,ih=300,ah=10,oh=8;function sh(e){let t=e.nodes.map(e=>({id:e})),n=e.edges.map(e=>({source:e.from,target:e.to,kind:e.kind})),r=eh(t).force(`link`,ym(n).id(e=>e.id)).force(`charge`,th()).force(`center`,Kp(nh/2,rh/2)).stop();for(let e=0;e<ih;e++)r.tick();return{nodes:t,links:n}}function ch(e){return typeof e==`object`?e:void 0}function lh({graph:e,selectedDevice:t,onSelectDevice:n}){let{nodes:r,links:i}=(0,A.useMemo)(()=>sh(e),[e]);return r.length===0?(0,z.jsx)(pu,{c:`dimmed`,p:`md`,children:`No known devices in the mesh graph.`}):(0,z.jsx)(U,{p:`md`,children:(0,z.jsxs)(`svg`,{role:`img`,"aria-label":`Mesh connection graph`,viewBox:`0 0 ${String(nh)} ${String(rh)}`,width:`100%`,style:{maxHeight:rh},children:[i.map(e=>{let t=ch(e.source),n=ch(e.target);return!t||!n?null:(0,z.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:`var(--mantine-color-dark-3)`,strokeWidth:1.5,strokeDasharray:e.kind===`relay`?`4 3`:void 0},`${t.id}-${n.id}`)}),r.map(e=>(0,z.jsxs)(`g`,{transform:`translate(${String(e.x??0)}, ${String(e.y??0)})`,onClick:()=>{n(e.id)},style:{cursor:`pointer`},role:`button`,"aria-label":`Device ${e.id}`,children:[(0,z.jsx)(`circle`,{r:ah,fill:e.id===t?`var(--mantine-color-accent-5)`:`var(--mantine-color-dark-2)`,stroke:`var(--mantine-color-accent-5)`,strokeWidth:e.id===t?2:0}),(0,z.jsx)(`text`,{y:22,textAnchor:`middle`,fontSize:10,fill:`var(--mantine-color-text)`,children:e.id.slice(0,oh)})]},e.id))]})})}var uh=8;function dh(e){return e.relayed?e.hubAddress===void 0?`relayed`:`relayed via ${e.hubAddress}`:`direct`}function fh({targets:e,selectedTarget:t,onSelectTarget:n,onTrace:r,loading:i,error:a,result:o}){let s=e.map(e=>({value:e,label:e.slice(0,uh)}));return(0,z.jsxs)(Xd,{p:`md`,gap:`sm`,children:[(0,z.jsxs)(Cc,{align:`flex-end`,gap:`xs`,children:[(0,z.jsx)(Kd,{label:`Target device`,placeholder:`Choose a device`,size:`xs`,data:s,value:t??null,onChange:e=>{e!==null&&n(e)}}),(0,z.jsx)(Fd,{size:`xs`,disabled:t===void 0||i,loading:i,onClick:r,children:`Trace`})]}),a!==void 0&&(0,z.jsx)(pu,{c:`red`,children:a}),o!==void 0&&(0,z.jsxs)(Xd,{gap:4,children:[(0,z.jsxs)(Cc,{gap:`xs`,children:[(0,z.jsx)(Cd,{color:o.outcome.result===`ok`?`green`:`red`,children:o.outcome.result===`ok`?`ok`:o.outcome.code??`error`}),(0,z.jsxs)(pu,{size:`sm`,children:[o.rttMs,`ms round trip`]})]}),(0,z.jsxs)(pu,{size:`sm`,c:`dimmed`,children:[`Local: `,dh(o.local)]}),o.remote!==void 0&&(0,z.jsxs)(pu,{size:`sm`,c:`dimmed`,children:[`Remote: `,dh(o.remote)]})]})]})}function ph({queryUtils:e}){let[t,n]=(0,A.useState)(void 0),r=Ap(e.getMeshGraph.queryOptions()),i=jp(e.getMeshTrace.mutationOptions());function a(){t!==void 0&&i.mutate({target:t})}let o=r.data;return o===void 0?(0,z.jsx)(pu,{c:`dimmed`,p:`md`,children:`Mesh graph is not available on this connection.`}):(0,z.jsxs)(sf,{defaultValue:`graph`,children:[(0,z.jsxs)(sf.List,{children:[(0,z.jsx)(sf.Tab,{value:`graph`,children:`Graph`}),(0,z.jsx)(sf.Tab,{value:`trace`,children:`Trace`})]}),(0,z.jsx)(sf.Panel,{value:`graph`,children:(0,z.jsx)(lh,{graph:o,selectedDevice:t,onSelectDevice:n})}),(0,z.jsx)(sf.Panel,{value:`trace`,children:(0,z.jsx)(Xd,{children:(0,z.jsx)(fh,{targets:o.nodes,selectedTarget:t,onSelectTarget:n,onTrace:a,loading:i.isPending,error:i.error===null?void 0:i.error instanceof Error?i.error.message:`Unknown error`,result:i.data})})})]})}function mh(e,t,n){let[r,...i]=t;if(r===void 0){e.agents.push(n);return}let a=e.children.get(r);a||(a={children:new Map,agents:[]},e.children.set(r,a)),mh(a,i,n)}function hh(e,t){let[n,...r]=t;if(n===void 0)return;let i=e.children.get(n);i||(i={children:new Map,agents:[]},e.children.set(n,i)),hh(i,r)}var gh=`Project room for `;function _h(e){return e.description.startsWith(gh)}function vh(e){return e.description.slice(17)}function yh(e,t){let n=t.filter(e=>!_h(e)),r=new Map;for(let e of t)_h(e)&&r.set(vh(e),e);let i=new Set;for(let t of e)i.add(t.cwd);for(let e of r.keys())i.add(e);if(i.size===0)return{roots:[],manualRooms:n};let a=Sh(Array.from(i)),o=a===`/`?[]:bh(a),s={children:new Map,agents:[]};for(let t of e)mh(s,bh(t.cwd).slice(o.length),t);for(let e of r.keys())hh(s,bh(e).slice(o.length));return{roots:wh(Ch(s,a,``,r)),manualRooms:n}}function bh(e){return e.split(`/`).filter(e=>e.length>0)}function xh(...e){return`/`+e.join(`/`)}function Sh(e){if(e.length===0)return`/`;let t=e.map(bh),n=Math.min(...t.map(e=>e.length)),r=0;for(let e=0;e<n;e++){let n=t[0]?.[e];if(n===void 0)break;if(t.every(t=>t[e]===n))r++;else break}return r>0&&r--,r===0?`/`:xh(...t[0]?.slice(0,r)??[])}function Ch(e,t,n,r){let i=[];for(let[a,o]of e.children){let e=n===``&&t===`/`?`/`+a:n===``?t+`/`+a:n+`/`+a,s=Ch(o,t,e,r),c=r.get(e);(s.length>0||c)&&i.push({type:`directory`,name:a,path:e,...c?{roomId:c.id}:{},children:wh(s)})}for(let t of e.agents)i.push({type:`agent`,name:t.name,agentId:t.id,status:t.status,cwd:t.cwd});return i}function wh(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}var Th=[{value:`public`,label:`Public`},{value:`private`,label:`Private`},{value:`secret`,label:`Secret`}];function Eh(e){return e===`public`||e===`private`||e===`secret`}function Dh({visible:e,onSubmit:t,onCancel:n}){let[r,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(`public`),[s,c]=(0,A.useState)(``);return e?(0,z.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&(t(r.trim(),a,s.trim()),i(``),o(`public`),c(``))},children:(0,z.jsxs)(Xd,{gap:`xs`,p:`xs`,children:[(0,z.jsx)(cf,{label:`Room name`,name:`room-name`,required:!0,placeholder:`e.g. project-alpha`,size:`xs`,value:r,onChange:e=>{i(e.target.value)}}),(0,z.jsx)(Kd,{label:`Type`,name:`room-type`,size:`xs`,data:Th,value:a,allowDeselect:!1,onChange:e=>{Eh(e)&&o(e)}}),(0,z.jsx)(cf,{label:`Description (optional)`,name:`room-description`,placeholder:`What is this room about?`,size:`xs`,value:s,onChange:e=>{c(e.target.value)}}),(0,z.jsxs)(Cc,{gap:`xs`,children:[(0,z.jsx)(Fd,{type:`submit`,size:`xs`,flex:1,children:`Create`}),(0,z.jsx)(Fd,{type:`button`,size:`xs`,flex:1,variant:`default`,onClick:n,children:`Cancel`})]})]})}):null}function Oh({visible:e,onSubmit:t,onCancel:n}){return e?(0,z.jsx)(U,{py:4,children:(0,z.jsx)(Np,{ariaLabel:`Room name`,placeholder:`Room name...`,submitLabel:`Join`,size:`xs`,onSubmit:t,onCancel:n})}):null}var kh={active:`green`,idle:`yellow`,busy:`red`,offline:`gray`};function Ah({status:e}){return(0,z.jsx)(U,{w:8,h:8,style:{borderRadius:`50%`,backgroundColor:`var(--mantine-color-${kh[e]}-6)`}})}function jh({tree:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return(0,z.jsxs)(U,{mb:`xs`,children:[e.roots.map(e=>(0,z.jsx)(Mh,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path)),e.manualRooms.length>0&&(0,z.jsxs)(U,{py:4,children:[(0,z.jsx)(pu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,px:`xs`,py:4,children:`Rooms`}),e.manualRooms.map(e=>(0,z.jsx)(Bd,{label:`${e.name} (${String(e.members.length)})`,active:i===e.id,onClick:()=>{t(e.id)}},e.id))]})]})}function Mh({node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return e.type===`agent`?(0,z.jsx)(Ph,{node:e,onSelectAgent:n,onRenameAgent:r}):(0,z.jsx)(Nh,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i})}function Nh({node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){let a=e.roomId,o=i===a,s=a===void 0?{}:{onClick:()=>{t(a)}};return(0,z.jsx)(Bd,{label:e.name,leftSection:(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`📁`}),defaultOpened:!0,active:o,...s,children:e.children.map(e=>(0,z.jsx)(Mh,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path))})}function Ph({node:e,onSelectAgent:t,onRenameAgent:n}){let[r,i]=(0,A.useState)(!1),[a,o]=(0,A.useState)(``),s=(0,A.useRef)(null);(0,A.useEffect)(()=>{r&&s.current?.focus()},[r]);let c=()=>{o(e.name),i(!0)},l=()=>{let t=a.trim();t&&t!==e.name&&n(e.agentId,t),i(!1)};return r?(0,z.jsx)(cf,{ref:s,size:`xs`,ml:`md`,"aria-label":`Rename ${e.name}`,value:a,onChange:e=>{o(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&i(!1)},onBlur:l}):(0,z.jsx)(Bd,{label:e.name,leftSection:(0,z.jsx)(Ah,{status:e.status}),onClick:()=>{t(e.agentId)},onDoubleClick:c})}function Fh({rooms:e,agents:t,currentRoom:n,onJoinRoom:r,onSelectAgent:i,onRenameAgent:a,onCreateRoom:o,onJoinRoomInput:s}){let[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(!1),m=yh(f?t:t.filter(e=>e.status!==`offline`),e);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Cc,{justify:`space-between`,px:`md`,py:`sm`,children:[(0,z.jsx)(pu,{size:`sm`,fw:600,c:`accent`,children:`Agent Comms`}),(0,z.jsx)(pc,{variant:f?`filled`:`default`,size:`sm`,"aria-label":`${f?`Hide`:`Show`} offline agents`,title:`${f?`Hide`:`Show`} offline agents`,onClick:()=>{p(e=>!e)},children:f?`◉`:`◎`})]}),(0,z.jsxs)(os,{flex:1,px:`xs`,children:[(0,z.jsx)(jh,{tree:m,onJoinRoom:r,onSelectAgent:i,onRenameAgent:a,currentRoom:n}),(0,z.jsxs)(Cc,{justify:`space-between`,px:`xs`,py:4,children:[(0,z.jsx)(pu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,children:`Create`}),(0,z.jsx)(pc,{variant:`default`,size:`sm`,"aria-label":`Create room`,title:`Create room`,onClick:()=>{l(e=>!e)},children:`+`})]}),(0,z.jsx)(Dh,{visible:c,onSubmit:(e,t,n)=>{o(e,t,n),l(!1)},onCancel:()=>{l(!1)}}),(0,z.jsx)(Fd,{fullWidth:!0,size:`xs`,variant:`outline`,onClick:()=>{d(e=>!e)},children:`+ Join Room`}),(0,z.jsx)(Oh,{visible:u,onSubmit:e=>{s(e),d(!1)},onCancel:()=>{d(!1)}})]})]})}function Ih(e){let[t,{toggle:n}]=Ye(!0),[r,i]=(0,A.useState)(`chat`);return(0,z.jsxs)(Lu,{navbar:{width:260,breakpoint:`sm`,collapsed:{desktop:!t,mobile:!t}},children:[(0,z.jsxs)(Lu.Navbar,{children:[(0,z.jsx)(Fh,{rooms:e.rooms,agents:e.agents,currentRoom:e.currentRoom,onJoinRoom:e.onJoinRoom,onSelectAgent:e.onSelectAgent,onRenameAgent:e.onRenameAgent,onCreateRoom:e.onCreateRoom,onJoinRoomInput:e.onJoinRoomInput}),(0,z.jsx)(Wd,{m:`xs`,size:`xs`,fullWidth:!0,value:r,onChange:i,data:[{label:`Chat`,value:`chat`},{label:`Mesh`,value:`mesh`}]})]}),(0,z.jsx)(Lu.Main,{h:`100vh`,children:r===`chat`?(0,z.jsx)(Gp,{messages:e.messages,rooms:e.rooms,currentRoom:e.currentRoom,dmTarget:e.dmTarget,connected:e.connected,sidebarOpened:t,onToggleSidebar:n,onSendAction:e.onSendAction,onLeaveRoom:e.onLeaveRoom,onConnectToMesh:e.onConnectToMesh}):(0,z.jsx)(ph,{queryUtils:e.queryUtils})})]})}var Lh={currentRoom:void 0,dmTarget:void 0,agents:[],rooms:[],messages:[],connected:!1},Rh=class{state={...Lh};listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}get(){return this.state}setCurrentRoom(e){this.state={...this.state,currentRoom:e},this.notify()}setDmTarget(e){this.state={...this.state,dmTarget:e},this.notify()}setAgents(e){this.state={...this.state,agents:e},this.notify()}setRooms(e){this.state={...this.state,rooms:e},this.notify()}setConnected(e){this.state={...this.state,connected:e},this.notify()}addMessage(e){this.state={...this.state,messages:[...this.state.messages,e]},this.notify()}setMessages(e){this.state={...this.state,messages:e},this.notify()}clearMessages(){this.state={...this.state,messages:[]},this.notify()}reset(){this.state={...Lh,messages:[]},this.notify()}notify(){let e=this.state;for(let t of this.listeners)t(e)}};function zh(e){return(0,A.useSyncExternalStore)(t=>e.subscribe(t),()=>e.get())}function Bh(e){return Array.isArray(e)?e:e==null?[]:[e]}var Vh=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function Hh(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}var Uh=class{index=BigInt(1);generate(){let e=this.index.toString(36);return this.index++,e}};function Wh(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}var Gh=Symbol.asyncDispose??Symbol.for(`asyncDispose`),Kh=class{isDone=!1;isExecuteComplete=!1;cleanup;next;constructor(e,t){this.cleanup=t,this.next=Hh(async()=>{if(this.isDone)return{done:!0,value:void 0};let t;try{let t=await e();return t.done&&(this.isDone=!0),t}catch(e){throw t={value:e},this.isDone=!0,e}finally{this.isDone&&!this.isExecuteComplete&&(this.isExecuteComplete=!0,await this.cleanup(t?{kind:`error`,error:t.value}:{kind:`success`}))}})}async return(e){return this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`})),{done:!0,value:e}}async throw(e){throw this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`,error:e})),e}async[Gh](){this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`}))}[Symbol.asyncIterator](){return this}};function qh(e){return JSON.stringify(e)}function Jh(e){for(let t of Object.values(e))if(t!==void 0)return!0;return!1}function Yh(e){if(!e)return!1;let t=typeof e;return t===`object`||t===`function`}var Xh=new WeakMap;function Zh(e,t,{bind:n=!0}={}){let r=Reflect.get(e,t);if(!n||typeof r!=`function`)return r;let i=Xh.get(r);i||Xh.set(r,i=new WeakMap);let a=i.get(e);return a||i.set(e,a=r.bind(e)),a}var Qh=class{items=[];pendingPulls=[];closed;push(e){if(this.closed)throw this.closed.reason;let t=this.pendingPulls.shift();t?t[0](e):this.items.push(e)}async pull(){if(this.items.length>0)return this.items.shift();if(this.closed)throw this.closed.reason;return new Promise((e,t)=>{this.pendingPulls.push([e,t])})}close(e){this.closed||(e??=new Vh(`Queue was closed.`),this.closed={reason:e},this.pendingPulls.forEach(([,t])=>t(e)),this.pendingPulls.length=0)}abort(e){e??=new Vh(`Queue was aborted.`),this.items.length=0,this.close(e)}},$h=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function eg(e){try{return encodeURIComponent(e)}catch{return encodeURIComponent(e.replace($h,`�`))}}function tg(e){if(!e.includes(`%`))return e;try{return decodeURIComponent(e)}catch{return e}}function ng(e){return e[0]??{}}var rg=`orpc`;function ig(e){return e instanceof Error&&e.name.includes(`Abort`)}Object.getPrototypeOf(async function*(){}).constructor;function ag(e){let t;return()=>{if(t)return t.result;let n=e();return t={result:n},n}}function og(e){return`/${e.map(encodeURIComponent).join(`/`)}`}var sg=Symbol.for(`ORPC_TRACER`);function cg(){return globalThis[sg]}function lg(e){let t=cg();if(t)return typeof e==`string`?t.startSpan(e):t.startSpan(e.name,e.parent)}function ug(e,t){e&&e.recordException(ig(t)?`info`:`error`,dg(t))}function dg(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return`code`in e&&(typeof e.code==`string`||typeof e.code==`number`)&&(t.code=e.code),t}return{message:String(e)}}async function fg(e,t){let n=cg();if(!n)return t();let r=typeof e==`string`?e:e.name,i=typeof e==`string`?void 0:e.parent;return n.startActiveSpan(r,i,async e=>{try{return await t(e)}catch(t){throw ug(e,t),t}finally{e.end()}})}function pg(e,t){let n=cg();return!e||!n?t():n.withActiveSpan(e,t)}function mg(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o;return new Kh(async()=>{try{let r;try{r=await t(()=>e.next()),o=r.done}catch(e){throw o=!0,e}return n?await n(r):r}catch(e){throw await i?.(e),r?await r(e):e}},async n=>{try{if(!o)try{await t(async()=>e.return?.())}catch(e){throw await i?.(e),e}}finally{await a?.()}})}function hg(e,t){let n=ag(()=>lg(e));return mg(t,{runWith:e=>pg(n(),e),mapResult(e){return n()?.addEvent(e.done?`completed`:`yielded`),e},onError(e){ug(n(),e)},onFinish(){n()?.end()}})}function gg(e,...t){return typeof e==`function`?e(...t):e}function _g(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){return Zh(r in t?t:gg(e),r)},has(n,r){return Reflect.has(t,r)||Reflect.has(gg(e),r)}})}function*vg(e){if(!Yh(e))return;let t=Object.getPrototypeOf(e);for(;t!=null;)t.constructor&&(yield t.constructor),t=Object.getPrototypeOf(t)}function yg(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}var bg=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function xg(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o=ag(()=>e.getReader()),s=ag(async()=>a?.());return new ReadableStream({async pull(e){let a;try{let e=await t(()=>o().read());a=n?await n(e):e}catch(t){try{await i?.(t),e.error(r?await r(t):t)}finally{await s()}return}a.done?(e.close(),await s()):e.enqueue(a.value)},async cancel(e){try{try{await t(()=>o().cancel(e))}catch(e){throw await i?.(e),e}}finally{await s()}}})}function Sg(e,t){let n=ag(()=>lg(e));return xg(t,{runWith:e=>pg(n(),e),mapResult(e){return n()?.addEvent(e.done?`closed`:`enqueued`),e},onError(e){ug(n(),e)},onFinish(){n()?.end()}})}function Cg(e,t,n){if(!e?.length)return n(t);let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function wg(e){let t=e.length,n=new Map;for(let r=0;r<t;r++){let t=e[r],i=n.get(t.name);i===void 0?n.set(t.name,[r]):i.push(r)}let r=Array.from({length:t},()=>new Set);for(let i=0;i<t;i++){let t=e[i],a=t.before;if(a!==void 0)for(let e of a){let t=n.get(e);if(t!==void 0)for(let e of t){let t=r[e];t!==void 0&&t.add(i)}}let o=t.after;if(o!==void 0){let e=r[i];if(e!==void 0)for(let t of o){let r=n.get(t);if(r!==void 0)for(let t of r)e.add(t)}}}let i=[],a=new Set,o=new Set;function s(t){if(o.has(t))return;if(a.has(t)){let n=e[t],r=n===void 0?`unknown`:n.name;throw Error(`Circular dependency detected involving plugin "${r}"`)}a.add(t);let n=r[t];if(n!==void 0)for(let e of n)s(e);a.delete(t),o.add(t);let c=e[t];c!==void 0&&i.push(c)}for(let e=0;e<t;e++)s(e);return i}var Tg=class extends TypeError{},Eg=class extends Error{constructor(e,t={}){super(t?.message??`Error Event`,t),this.data=e}},Dg=/\r\n|[\n\r]/;function Og(e){return Dg.test(e)}function kg(e){if(Og(e))throw new Tg(`Event's id must not contain a carriage return or newline character`)}function Ag(e){if(!Number.isInteger(e)||e<0)throw new Tg(`Event's retry must be a integer and >= 0`)}function jg(e){if(Og(e))throw new Tg(`Event's comment must not contain a carriage return or newline character`)}var Mg=Symbol.for(`STANDARD_SERVER_EVENT_META`),Ng=Symbol.for(`STANDARD_SERVER_EVENT_SOURCE`);function Pg(e,t){let n;if(t.id!==void 0&&(kg(t.id),n??={},n.id=t.id),t.retry!==void 0&&(Ag(t.retry),n??={},n.retry=t.retry),t.comments!==void 0){for(let e of t.comments)jg(e);n??={},n.comments=t.comments}return n?new Proxy(e,{get(e,t,r){return t===Ng?e:t===Mg?n:Zh(e,t)}}):e}function Fg(e){if(!Yh(e))return[e,void 0];let t=e[Mg];return[e[Ng]??e,t]}function Ig(e){if(Yh(e))return e[Mg]}function Lg(e,t=`inline`){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,`_`).replace(/[\\"]/g,`\\$&`)}"; filename*=utf-8''${eg(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function Rg(e){let t=e.match(/(?:^|;)\s*filename\*=([^;]*)/i)?.[1]?.trim(),n=t?.match(/^([^']*)'[^']*'(.*)$/);if(n){let[,e=``,t=``]=n;if(/^(?:utf-8|us-ascii)$/i.test(e))return tg(t)}else if(t)return tg(t);let r=e.match(/(?:^|;)\s*filename=(?:"((?:\\.|[^"\\])*)"|([^";]*))/i);return r?.[1]===void 0?r?.[2]?.trim()||void 0:r[1].replace(/\\(.)/g,`$1`)}function zg(e){if(typeof e==`string`||e===void 0)return e;if(e.length!==0)return e.join(`, `)}function Bg(e,t){let n={...e,...t};for(let[r,i]of Object.entries(t)){if(!Object.hasOwn(e,r))continue;let t=e[r];n[r]=t===void 0||i===void 0?t??i:[...Bh(t),...Bh(i)]}return n}function Vg(e){let t=e.indexOf(`#`),n=e.indexOf(`?`),r=n!==-1&&(t===-1||n<t),i=r?n:t===-1?e.length:t,a=t===-1?e.length:t;return[e.slice(0,i),r?e.slice(n,a):void 0,t===-1?void 0:e.slice(t)]}function Hg(e){return Yh(e)?Object.values(e).every(e=>e===void 0||typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)):!1}function Ug(e){return Number.isInteger(e)}var Wg={BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_SUPPORTED:405,NOT_ACCEPTABLE:406,TIMEOUT:408,CONFLICT:409,GONE:410,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNSUPPORTED_MEDIA_TYPE:415,UNPROCESSABLE_CONTENT:422,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},Gg,Kg=class e extends Error{static{let t=Symbol.for(`ORPC_ERROR_CONSTRUCTORS`);globalThis[t]??=new WeakSet,Gg=globalThis[t],Gg.add(e)}name=`ORPCError`;defined=!1;code;data;constructor(e,...t){let n=ng(t),r=n.message??e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `);super(r,n),this.code=e,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(!Gg.has(this))return super[Symbol.hasInstance](e);for(let t of vg(e))if(Gg.has(t))return!0;return!1}},qg=class extends Error{name=`MalformedResponseError`;response;constructor(e){super(e.message,e),this.response=e.response}};function Jg(e){return e instanceof Kg?e:new Kg(`INTERNAL_SERVER_ERROR`,{cause:e})}function Yg(e){if(!yg(e))return!1;let t=[`defined`,`code`,`message`,`data`];return!Object.keys(e).some(e=>!t.includes(e))&&`defined`in e&&typeof e.defined==`boolean`&&`code`in e&&typeof e.code==`string`&&`message`in e&&typeof e.message==`string`}function Xg(e,t={}){let n=new Kg(e.code,{...e,...t});return n.defined=e.defined,n}function Zg(e){let t=new Kg(`MALFORMED_ORPC_RESPONSE`,{message:e.message??t_(e.response),data:e.response});return t.cause=new qg({...e,message:t.message}),t}var Qg=1,$g=256;function e_(e){return e.length>=Qg&&e.length<=$g}function t_(e){return typeof e.body==`string`&&e_(e.body)?e.body:yg(e.body)&&typeof e.body.message==`string`&&e_(e.body.message)?e.body.message:(Object.entries(Wg).find(([,t])=>t===e.status)?.[0])?.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function n_(e,{mapResult:t,mapError:n,...r}){return mg(e,{...r,mapResult:t&&(async e=>{let n=await t(e);if(n.value!==e.value){let t=Ig(e.value);if(t&&Yh(n.value))return{done:n.done,value:Pg(n.value,t)}}return n}),mapError:n&&(async e=>{let t=await n(e);if(t!==e){let n=Ig(e);if(n&&Yh(t))return Pg(t,n)}return t})})}var r_=/^\/([\s\S]*)\/([a-z]*)$/,i_={undefined:{condition(e){return e===void 0},serialize(){return null},deserialize(){},isTerminal:!0},bigint:{condition(e){return typeof e==`bigint`},serialize(e){return e.toString()},deserialize(e){return BigInt(e)},isTerminal:!0},date:{condition(e){return e instanceof Date},serialize(e){return Number.isNaN(e.getTime())?null:e.toISOString()},deserialize(e){return new Date(e??`Invalid Date`)},isTerminal:!0},nan:{condition(e){return typeof e==`number`&&Number.isNaN(e)},serialize(){return null},deserialize(){return NaN},isTerminal:!0},url:{condition(e){return e instanceof URL},serialize(e){return e.toString()},deserialize(e){return new URL(e)},isTerminal:!0},regexp:{condition(e){return e instanceof RegExp},serialize(e){return e.toString()},deserialize(e){let[,t,n]=e.match(r_);return new RegExp(t,n)},isTerminal:!0},set:{condition(e){return e instanceof Set},serialize(e){return Array.from(e)},deserialize(e){return new Set(e)}},map:{condition(e){return e instanceof Map},serialize(e){return Array.from(e.entries())},deserialize(e){return new Map(e)}}},a_=class{handlers;inlineBuiltInHandlers;handlerEntries;omitUndefinedProperties;constructor(e={}){this.omitUndefinedProperties=e.omitUndefinedProperties!==!1,this.handlers=Object.assign(new bg,i_);let t=e.handlers;if(t===void 0){this.inlineBuiltInHandlers=!0;return}let n=!0,r=[];for(let e in t){let i=t[e];this.handlers[e]=i,n&&e in i_&&(n=!1),n&&i!==void 0&&r.push([e,i])}if(!n){r=[];for(let e in this.handlers){let t=this.handlers[e];t!==void 0&&r.push([e,t])}}this.inlineBuiltInHandlers=n,this.handlerEntries=r}serialize(e){let t=[],n=[],r=[],i=this.serializeValue(e,[],t,n,r);return t=t.length===0?void 0:t,n.length===0?{json:i,meta:t}:{json:i,meta:t,maps:n,blobs:r}}serializeValue(e,t,n,r,i){if(this.inlineBuiltInHandlers)switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isNaN(e)?(n.push([`nan`,...t]),null):e;case`undefined`:return n.push([`undefined`,...t]),null;case`bigint`:return n.push([`bigint`,...t]),e.toString();case`object`:if(e===null)return e;if(e instanceof Date)return n.push([`date`,...t]),Number.isNaN(e.getTime())?null:e.toISOString();if(e instanceof URL)return n.push([`url`,...t]),e.toString();if(e instanceof RegExp)return n.push([`regexp`,...t]),e.toString();if(e instanceof Set){let a=this.serializeValue(Array.from(e),t,n,r,i);return n.push([`set`,...t]),a}if(e instanceof Map){let a=this.serializeValue(Array.from(e.entries()),t,n,r,i);return n.push([`map`,...t]),a}}let a=this.handlerEntries;if(a)for(let o=0;o<a.length;o++){let s=a[o],c=s[1];if(c.condition(e)){let a=c.serialize(e);if(c.isTerminal)return n.push([s[0],...t]),a instanceof Blob&&(r.push(t.slice()),i.push(a)),a;let o=this.serializeValue(a,t,n,r,i);return n.push([s[0],...t]),o}}if(e instanceof Blob)return r.push(t.slice()),i.push(e),e;if(Array.isArray(e)){let a=[];for(let o=0;o<e.length;o++)t.push(o),a.push(this.serializeValue(e[o],t,n,r,i)),t.pop();return a}if(yg(e)){let a=new bg;for(let o in e){let s=e[o];(o!==`toJSON`||typeof s!=`function`)&&(s===void 0&&this.omitUndefinedProperties||(t.push(o),a[o]=this.serializeValue(s,t,n,r,i),t.pop()))}return a}return e}deserialize(e){let t={data:e.json};if(e.blobs?.length)for(let n=0;n<e.maps.length;n++){let r=e.maps[n],i=t,a=`data`;for(let e=0;e<r.length;e++)if(i=i[a],a=r[e],!Object.hasOwn(i,a))throw Error(`Security error: Invalid serialized data. Segment "${a}" does not exist.`);i[a]=e.blobs[n]}if(e.meta)for(let n of e.meta){let e=n[0],r=t,i=`data`;for(let e=1;e<n.length;e++)if(r=r[i],i=n[e],!Object.hasOwn(r,i))throw Error(`Security error: Invalid serialized data. Segment "${i}" does not exist.`);r[i]=this.handlers[e].deserialize(r[i])}return t.data}},o_=class{jsonSerializer;defaultSerializeOptions;constructor(e={}){this.jsonSerializer=new a_(e),this.defaultSerializeOptions=e.serialize}serialize(e,t={}){if(e===void 0||e instanceof ReadableStream||e instanceof Blob)return e;if(Wh(e))return n_(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.serializeValue(e.value,!1)},mapError:e=>new Eg(this.serializeValue(Jg(e).toJSON(),!1),{cause:e})});let n=t.useFormDataForBlobFields??this.defaultSerializeOptions?.useFormDataForBlobFields??!0;return this.serializeValue(e,n)}serializeValue(e,t){let{json:n,meta:r,maps:i,blobs:a}=this.jsonSerializer.serialize(e);if(!t||!a?.length)return{json:n,meta:r};let o=new FormData;return o.set(`data`,qh({json:n,meta:r,maps:i})),a.forEach((e,t)=>{o.set(t.toString(),e)}),o}deserialize(e){return e===void 0||e instanceof ReadableStream||e instanceof Blob?e:Wh(e)?n_(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.deserializeValue(e.value)},mapError:e=>{if(!(e instanceof Eg))return e;let t=this.deserializeValue(e.data);return Yg(t)?Xg(t,{cause:e}):new Eg(t,{cause:e})}}):this.deserializeValue(e)}deserializeValue(e){if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e);let t=JSON.parse(e.get(`data`)),n=[];for(let[t,r]of e)r instanceof Blob&&(n[Number(t)]=r);return this.jsonSerializer.deserialize({...t,blobs:n})}},s_=new Set([`then`,`bind`,`call`,`apply`,`valueOf`,`toString`,`toJSON`]);function c_(e){return{...e,context:e.context??{}}}function l_(e){return[e[0],c_(e[1]??{})]}function u_(e,{path:t=[],...n}={}){let r=(...r)=>{let[i,a]=l_(r);return Cg([...Bh(n.interceptors),...Bh(n.scoped?.interceptors)],{...a,input:i,path:t},({path:t,input:n,...r})=>e.call(t,n,r))},i=new Map;return new Proxy(r,{get(r,a){if(typeof a!=`string`||s_.has(a))return Reflect.get(r,a);let o=i.get(a);return o===void 0&&(o=u_(e,{...n,path:[...t,a],scoped:n.scoped?.[a]}),i.set(a,o)),o}})}function d_(e,t){return new Kh(async()=>{for(;;){let{json:t}=await e.pull();switch(t.event){case void 0:case`message`:{let e=t.data;return Yh(e)&&(e=Pg(e,t)),{value:e,done:!1}}case`error`:throw Pg(new Eg(t.data),t);case`close`:{let e=t.data;return Yh(e)&&(e=Pg(e,t)),{value:e,done:!0}}}}},t)}var f_=class{constructor(e,t,n){this.iterator=e,this.messageId=t,this.send=n}isDone=!1;async cancel(){this.isDone||(this.isDone=!0,await this.iterator.return?.())}async transmit(){for(;;)try{let e=await this.iterator.next();if(this.isDone)return;e.done&&(this.isDone=!0);try{let[t,n]=Fg(e.value);await this.send({kind:`event-stream`,id:this.messageId,json:{...n,event:e.done?`close`:void 0,data:t}})}catch(e){throw await this.cancel(),e}if(this.isDone)return}catch(e){if(e instanceof Eg){if(!this.isDone){this.isDone=!0;let[t,n]=Fg(e);await this.send({kind:`event-stream`,id:this.messageId,json:{...n,event:`error`,data:t.data}})}return}throw this.isDone=!0,e}}};function p_(e,t){return new ReadableStream({async pull(n){try{let{json:r,binary:i}=await e.pull();i&&n.enqueue(i instanceof Uint8Array?i:new Uint8Array(await i.arrayBuffer())),r.close&&(await t({kind:`success`}),n.close())}catch(e){await t({kind:`error`,error:e}),n.error(e)}},async cancel(e){await t({kind:`cancelled`,error:e})}})}var m_=class{constructor(e,t,n){this.messageId=t,this.send=n,this.reader=e.getReader()}isDone=!1;reader;async cancel(){this.isDone||(this.isDone=!0,await this.reader.cancel())}async transmit(){for(;;)try{let e=await this.reader.read();if(this.isDone)return;e.done&&(this.isDone=!0);try{await this.send({json:{close:e.done?!0:void 0},binary:e.value,kind:`octet-stream`,id:this.messageId})}catch(e){throw await this.cancel(),e}if(this.isDone)return}catch(e){throw this.isDone=!0,e}}};function h_(e,t){let n=zg(e.json.headers?.[`content-type`]),r=zg(e.json.headers?.[`standard-server`]);if(e.json.body===void 0&&e.binary===void 0){if(n===void 0&&r===`event-stream`){let e=new Qh;return{resolveBody:async()=>d_(e,t),eventStreamMessageQueue:e}}if(n!==void 0){let e=new Qh;return{resolveBody:async()=>p_(e,t),octetStreamMessageQueue:e}}}return{resolveBody:async()=>{let i;try{if(e.binary){if(r===`form-data`){let t={};return n!==void 0&&(t[`content-type`]=n),await new Response(e.binary,{headers:t}).formData()}let t=zg(e.json.headers?.[`content-disposition`]),i=t===void 0?void 0:Rg(t);return new File([e.binary],i??`blob`,{type:n??`application/octet-stream`})}if(r===`url-search-params`){if(typeof e.json.body!=`string`)throw TypeError(`Expected body to be a string for url-search-params bodyHint`);return new URLSearchParams(e.json.body)}return e.json.body}catch(e){throw i={value:e},e}finally{await t(i?{kind:`error`,error:i.value}:{kind:`success`})}}}}async function g_(e,t){if(t={...t},e instanceof ReadableStream)return t[`content-type`]??=`application/octet-stream`,{jsonBody:void 0,headers:t,binary:void 0};if(e instanceof Blob)return t[`content-type`]=e.type,t[`content-disposition`]??=Lg(e instanceof File?e.name??``:`blob`),Number.isFinite(e.size)&&(t[`content-length`]=e.size.toString()),{jsonBody:void 0,headers:t,binary:e};if(t[`standard-server`]=void 0,t[`content-type`]=void 0,Wh(e))return t[`standard-server`]=`event-stream`,{jsonBody:void 0,headers:t,binary:void 0};if(e instanceof FormData){let n=await new Response(e).blob();return t[`standard-server`]=`form-data`,t[`content-type`]=n.type,t[`content-length`]=n.size.toString(),{jsonBody:void 0,headers:t,binary:n}}return e instanceof URLSearchParams?(t[`standard-server`]=`url-search-params`,{jsonBody:e.toString(),headers:t,binary:void 0}):{jsonBody:e,headers:t,binary:void 0}}var __=class{constructor(e){this.send=e}idGenerator=new Uh;requests=new Map;request(e){return new Promise((t,n)=>{let r=e.signal;r?.throwIfAborted();let i=this.idGenerator.generate(),a={resolve:t,reject:n};if(this.requests.set(i,a),r){let e=()=>{this.abortById(i,r.reason).catch(()=>{})};r.addEventListener(`abort`,e),a.removeAbortListener=()=>r.removeEventListener(`abort`,e)}this.transmitRequest(i,a,e)})}async transmitRequest(e,t,n){try{let r=await g_(n.body,n.headers);if(n.signal?.throwIfAborted(),this.requests.get(e)!==t)return;if(await this.send({id:e,kind:`request`,json:{method:n.method===`POST`?void 0:n.method,url:n.url,headers:Jh(r.headers)?r.headers:void 0,body:r.jsonBody},binary:r.binary}),Wh(n.body)){let r=new f_(n.body,e,this.send);this.requests.get(e)===t?(t.eventStreamTransmitter=r,await r.transmit().catch(n=>{if(t.eventStreamTransmitter)return this.abortById(e,n)})):await r.cancel()}else if(n.body instanceof ReadableStream){let r=new m_(n.body,e,this.send);this.requests.get(e)===t?(t.octetStreamTransmitter=r,await r.transmit().catch(n=>{if(t.octetStreamTransmitter)return this.abortById(e,n)})):await r.cancel()}}catch(t){await this.closeById(e,t)}}async message(e){let t=e.id,n=this.requests.get(t);if(!n)return;if(e.kind===`stream/cancel`){let e=Promise.all([n.eventStreamTransmitter?.cancel(),n.octetStreamTransmitter?.cancel()]);n.eventStreamTransmitter=void 0,n.octetStreamTransmitter=void 0,await e;return}if(e.kind===`cancel`){await this.closeById(t,new Vh(`Server canceled the request`));return}if(e.kind===`event-stream`){n.eventStreamMessageQueue?.push(e);return}if(e.kind===`octet-stream`){n.octetStreamMessageQueue?.push(e);return}if(!n.resolve)return;let r=n.resolve;n.resolve=void 0;try{let i=h_(e,async e=>{e.kind===`cancelled`?await this.abortById(t,e.error):(n.eventStreamMessageQueue||n.octetStreamMessageQueue)&&await this.closeById(t,e.error)});n.eventStreamMessageQueue=i.eventStreamMessageQueue,n.octetStreamMessageQueue=i.octetStreamMessageQueue,r({headers:e.json.headers??{},status:e.json.status??200,resolveBody:i.resolveBody}),n.reject=void 0,!n.eventStreamMessageQueue&&!n.octetStreamMessageQueue&&await this.closeById(t)}catch(e){await this.closeById(t,e)}}async close(e){e??=new Vh(`Peer was closed`),await Promise.all(Array.from(this.requests.keys()).map(t=>this.closeById(t,e)))}async closeById(e,t){let n=this.requests.get(e);if(!n)return;this.requests.delete(e),(n.reject||n.eventStreamMessageQueue||n.octetStreamMessageQueue)&&(t??=new Vh(`Request was closed`)),n.reject?.(t),n.resolve=void 0,n.reject=void 0,n.eventStreamMessageQueue?.close(t),n.octetStreamMessageQueue?.close(t),n.eventStreamMessageQueue=void 0,n.octetStreamMessageQueue=void 0;let r=[n.eventStreamTransmitter?.cancel(),n.octetStreamTransmitter?.cancel()];n.eventStreamTransmitter=void 0,n.octetStreamTransmitter=void 0,n.removeAbortListener?.(),n.removeAbortListener=void 0,await Promise.all(r)}async abortById(e,t){let n=this.requests.get(e);if(!n)return;this.requests.delete(e),t??=new Vh(`Request was aborted`),n.reject?.(t),n.resolve=void 0,n.reject=void 0,n.eventStreamMessageQueue?.abort(t),n.octetStreamMessageQueue?.abort(t),n.eventStreamMessageQueue=void 0,n.octetStreamMessageQueue=void 0;let r=[this.send({id:e,kind:`cancel`}),n.eventStreamTransmitter?.cancel(),n.octetStreamTransmitter?.cancel()];n.eventStreamTransmitter=void 0,n.octetStreamTransmitter=void 0,n.removeAbortListener?.(),n.removeAbortListener=void 0,await Promise.all(r)}};function v_(e){return!(!Yh(e)||typeof e.id!=`string`||typeof e.kind!=`string`||e.binary!==void 0&&!(e.binary instanceof Uint8Array)&&!(e.binary instanceof Blob))}function y_(e){return!(e.kind!==`response`||!Yh(e.json)||e.json.status!==void 0&&!Ug(e.json.status)||e.json.headers!==void 0&&!Hg(e.json.headers))}function b_(e){return e.kind===`cancel`&&e.json===void 0&&e.binary===void 0}function x_(e){return!(e.kind!==`event-stream`||e.binary!==void 0||!Yh(e.json)||e.json.id!==void 0&&typeof e.json.id!=`string`||e.json.event!==void 0&&e.json.event!==`message`&&e.json.event!==`error`&&e.json.event!==`close`||e.json.retry!==void 0&&!Number.isFinite(e.json.retry)||e.json.comments!==void 0&&!(Array.isArray(e.json.comments)&&e.json.comments.every(e=>typeof e==`string`)))}function S_(e){return e.kind===`octet-stream`&&Yh(e.json)&&(e.json.close===void 0||typeof e.json.close==`boolean`)}function C_(e){return e.kind===`stream/cancel`&&e.json===void 0&&e.binary===void 0}function w_(e){return y_(e)||b_(e)||x_(e)||S_(e)||C_(e)}var T_=255,E_=new TextEncoder,D_=new TextDecoder;async function O_(e,t={}){if(e.binary===void 0){let n=qh(e);return t.prefix?t.prefix+n:n}let n=qh({...e,binary:void 0}),r=E_.encode(t.prefix?t.prefix+n:n),i=e.binary instanceof Blob?new Uint8Array(await e.binary.arrayBuffer()):e.binary,a=new Uint8Array(r.length+1+i.length);return a.set(r,0),a[r.length]=T_,a.set(i,r.length+1),a}function k_(e,t={}){try{if(typeof e==`string`){if(t.prefix){if(!e.startsWith(t.prefix))return{matched:!1};e=e.slice(t.prefix.length)}let n=JSON.parse(e);return v_(n)?{matched:!0,message:n}:{matched:!1}}if(t.prefix){let n=E_.encode(t.prefix);for(let t=0;t<n.length;t++)if(e[t]!==n[t])return{matched:!1};e=e.subarray(n.length)}let n=e.indexOf(T_);if(n===-1){let t=JSON.parse(D_.decode(e));return v_(t)?{matched:!0,message:t}:{matched:!1}}let r=e.subarray(0,n),i=e.subarray(n+1),a=JSON.parse(D_.decode(r));return v_(a)?(a.binary=i,{matched:!0,message:a}):{matched:!1}}catch{return{matched:!1}}}function A_(e){let t=Object.create(null);return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):t[n]===void 0?t[n]=e:t[n]=[t[n],e]}),t}var j_=class{name=`~composite`;plugins;constructor(e=[]){this.plugins=wg(e)}init(e){for(let t of this.plugins)t.init&&(e=t.init(e));return e}},M_=class{constructor(e,t,n={}){this.codec=e,this.transport=t,n=new j_(n.plugins).init(n),this.interceptors=n.interceptors,this.transportInterceptors=n.transportInterceptors}interceptors;transportInterceptors;call(e,t,n){return fg(`${rg}.${e.join(`/`)}`,r=>(r?.setAttribute(`rpc.system`,rg),r?.setAttribute(`rpc.method`,e.join(`.`)),cg()&&Wh(t)?t=_g(t,hg(`consume_async_iterator_object_input`,t)):cg()&&t instanceof ReadableStream&&(t=_g(t,Sg(`consume_octet_stream_input`,t))),Cg(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=cg(),a=i?.getActiveSpan()??r,o=await fg({name:`encode_input`,parent:a},()=>this.codec.encodeInput(t,e,n));if(a&&i?.inject){let e={...o.headers};i.inject(a,e),o={...o,headers:e}}let s=await Cg(this.transportInterceptors,{...n,path:e,request:o},({path:e,request:t,...n})=>fg({name:`send_request`,parent:i?.getActiveSpan()??a},()=>this.transport.send(t,e,n))),c=await fg({name:`decode_response`,parent:a},()=>this.codec.decodeResponse(s,e,n));if(c.kind===`error`)throw c.error;let l=c.output;return cg()&&Wh(l)?_g(l,hg(`consume_async_iterator_object_output`,l)):cg()&&l instanceof ReadableStream?_g(l,Sg(`consume_octet_stream_output`,l)):l})))}},N_=/\/$/,P_=class{baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;serializer;constructor(e){this.baseUrl=e.url??`/`,this.maxUrlLength=e.maxUrlLength??2083,this.fallbackMethod=e.fallbackMethod??`POST`,this.expectedMethod=e.method??this.fallbackMethod,this.headers=e.headers??{},this.serializer=e.serializer??new o_}async encodeInput(e,t,n){let r=F_(await gg(this.headers,n,t,e));n.lastEventId!==void 0&&(r=Bg(r,{"last-event-id":n.lastEventId}));let i=await gg(this.expectedMethod,n,t,e),[a,o,s]=Vg(await gg(this.baseUrl,n,t,e)),c=`${a.replace(N_,``)}${og(t)}`,l=this.serializer.serialize(e);if(i===`GET`&&!(l instanceof Blob)&&!(l instanceof ReadableStream)&&!(l instanceof FormData)&&!Wh(l)){let a=await gg(this.maxUrlLength,n,t,e),u=new URLSearchParams(o);u.append(`data`,qh(l)??``);let d=`${c}?${u}${s??``}`;if(d.length<=a)return{body:void 0,method:i,headers:r,url:d,signal:n.signal}}return{url:`${c}${o??``}${s??``}`,method:i===`GET`?this.fallbackMethod:i,headers:r,body:l,signal:n.signal}}async decodeResponse(e){let t=e.status<400,n=await e.resolveBody(),r=await(async()=>{try{return this.serializer.deserialize(n)}catch(t){throw Zg({message:`Invalid RPC response format.`,response:{status:e.status,headers:e.headers,body:n},cause:t})}})();return t?{kind:`output`,output:r}:Yg(r)?{kind:`error`,error:Xg(r)}:{kind:`error`,error:Zg({response:{headers:e.headers,status:e.status,body:n}})}}};function F_(e){return typeof e.forEach==`function`?A_(e):e}function I_(e,t,n){n?e.postMessage(t,n):e.postMessage(t)}function L_(e,t){if(`addEventListener`in e)e.addEventListener(`message`,e=>{t(e.data)});else if(`on`in e)e.on(`message`,e=>{t(e?.data)});else if(`onMessage`in e)e.onMessage.addListener(e=>{t(e)});else throw Error(`Cannot find a addEventListener/on/onMessage method on the port`)}function R_(e,t){if(`addEventListener`in e)e.addEventListener(`close`,()=>{t()});else if(`on`in e)e.on(`close`,()=>{t()});else if(`onDisconnect`in e)e.onDisconnect.addListener(()=>{t()});else throw Error(`Cannot find a addEventListener/on/onDisconnect method on the port`)}var z_=class{peer;constructor({port:e,experimental_transfer:t,encodePeerMessage:n,decodePeerMessage:r}){this.peer=new __(async r=>{let i=await gg(t,r,e);i?I_(e,r,i):I_(e,await O_(r,n))}),L_(e,async e=>{let t;if(typeof e==`string`||e instanceof Uint8Array){let n=k_(e,r);n.matched&&w_(n.message)&&(t=n.message)}else v_(e)&&w_(e)&&(t=e);return t===void 0?{matched:!1}:(await this.peer.message(t),{matched:!0})}),R_(e,async()=>{await this.peer.close()})}async send(e,t,n){return await this.peer.request(e)}},B_=class extends M_{constructor(e){let t=new P_(e),n=new z_(e);super(t,n,e)}};function V_(e){return e[0]??{}}Object.getPrototypeOf(async function*(){}).constructor;var H_=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function U_(e,t={}){let n=new Set(t.unbound),r=new H_,i=e;for(;i&&i!==Object.prototype;){for(let t of Object.getOwnPropertyNames(i)){if(t===`constructor`||t in r)continue;let i=Zh(e,t,{bind:!n.has(t)});typeof i==`function`&&(r[t]=i)}for(let t of Object.getOwnPropertySymbols(i)){if(t in r)continue;let i=Zh(e,t,{bind:!n.has(t)});typeof i==`function`&&(r[t]=i)}i=Object.getPrototypeOf(i)}return r}function W_(e,t,n){if(!e?.length)return n(t);let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function G_(e){let t=e.length,n=new Map;for(let r=0;r<t;r++){let t=e[r],i=n.get(t.name);i===void 0?n.set(t.name,[r]):i.push(r)}let r=Array.from({length:t},()=>new Set);for(let i=0;i<t;i++){let t=e[i],a=t.before;if(a!==void 0)for(let e of a){let t=n.get(e);if(t!==void 0)for(let e of t){let t=r[e];t!==void 0&&t.add(i)}}let o=t.after;if(o!==void 0){let e=r[i];if(e!==void 0)for(let t of o){let r=n.get(t);if(r!==void 0)for(let t of r)e.add(t)}}}let i=[],a=new Set,o=new Set;function s(t){if(o.has(t))return;if(a.has(t)){let n=e[t],r=n===void 0?`unknown`:n.name;throw Error(`Circular dependency detected involving plugin "${r}"`)}a.add(t);let n=r[t];if(n!==void 0)for(let e of n)s(e);a.delete(t),o.add(t);let c=e[t];c!==void 0&&i.push(c)}for(let e=0;e<t;e++)s(e);return i}var K_=new Set([`then`,`bind`,`call`,`apply`,`valueOf`,`toString`,`toJSON`]),q_=class{constructor(e=[]){this.plugins=e,this.plugins=G_(e)}name=`~composite`;init(e){for(let t of this.plugins)t.init&&(e=t.init(e));return e}initProcedureOptions(e,t){for(let n of this.plugins)n.initProcedureOptions&&(t=n.initProcedureOptions(e,t));return t}};function J_(e,t={}){return[...t.prefix===void 0?[]:[t.prefix],e,{...t.input===void 0?{}:{input:t.input},...t.type===void 0?{}:{type:t.type},...t.fnOptions===void 0?{}:{fnOptions:t.fnOptions}}]}function Y_(e){return async t=>{let n=await e(t),r;for await(let e of n)t.signal?.throwIfAborted(),r={chunk:e},t.client.setQueryData(t.queryKey,e);if(!r)throw TypeError(`Live query for ${qh(t.queryKey)} did not yield any data. Ensure the query function returns an AsyncIterable with at least one chunk.`);return r.chunk}}var X_=class{constructor(e,t){this.path=e,this.options=t}key(e={}){return J_(this.path,{...e,prefix:this.options.prefix})}};function Z_(e,{refetchMode:t=`reset`,maxChunks:n=1/0}={}){return async r=>{let i=r.client.getQueryCache().find({queryKey:r.queryKey,exact:!0}),a=!!i&&i.state.data!==void 0;a&&(t===`reset`?i.setState({status:`pending`,data:void 0,error:null,fetchStatus:`fetching`}):r.client.setQueryData(r.queryKey,(e=[])=>Q_(e,n)));let o=[],s=await e(r),c=!a||t!==`replace`;r.client.setQueryData(r.queryKey,(e=[])=>Q_(e,n));for await(let e of s){if(r.signal.aborted)throw r.signal.reason;o.push(e),o=Q_(o,n),c&&r.client.setQueryData(r.queryKey,(t=[])=>Q_([...t,e],n))}c||r.client.setQueryData(r.queryKey,o);let l=r.client.getQueryData(r.queryKey);return l?Q_(l,n):o}}function Q_(e,t){return e.length<=t?e:e.slice(e.length-t)}var $_=Symbol.for(`ORPC_TANSTACK_QUERY_OPERATION_CONTEXT`),ev=[`queryInterceptors`,`streamedInterceptors`,`liveInterceptors`,`infiniteInterceptors`,`mutationInterceptors`],tv=[`queryKey`,`queryOptions`,`streamedKey`,`streamedOptions`,`liveKey`,`liveOptions`,`infiniteKey`,`infiniteOptions`,`mutationKey`,`mutationOptions`];function nv(e){if(!Yh(e))return!1;for(let t in e)if(e[t]!==void 0){if(t===`prefix`){if(typeof e[t]!=`string`)return!1}else if(ev.includes(t)){if(!Array.isArray(e[t])||e[t].some(e=>typeof e!=`function`))return!1}else if(tv.includes(t)&&!Yh(e[t]))return!1}return!0}function rv(e,t){if(typeof e!=`function`&&typeof t!=`function`)return{...e,...t};let n=typeof e==`function`?e:t=>({...e,...t}),r=typeof t==`function`?t:e=>({...t,...e});return e=>r(n(e))}function iv(e,t){let n={...e,...t};for(let r of ev){let i=e[r],a=t[r];i&&a&&(n[r]=[...i,...a])}for(let r of tv){let i=e[r],a=t[r];i&&a&&(n[r]=rv(i,a))}return n}var av=class extends X_{call;constructor(e,t,n={}){super(e,n),this.call=t}queryKey(...e){let t=V_(e);return typeof this.options.queryKey==`function`?t=this.options.queryKey(t):this.options.queryKey&&(t={...this.options.queryKey,...t}),t.queryKey??J_(this.path,{prefix:this.options.prefix,type:`query`,input:t.input})}queryOptions(...e){let t=V_(e);typeof this.options.queryOptions==`function`?t=this.options.queryOptions(t):this.options.queryOptions&&(t={...this.options.queryOptions,...t});let n=this.queryKey(t);return{...t,queryKey:n,queryFn:e=>W_(this.options.queryInterceptors,{path:this.path,context:{[$_]:{key:n,type:`query`},...t.context},input:t.input,fnContext:e},({context:e,input:n,fnContext:r})=>{if(n===If||t.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return t.queryFn?t.queryFn(r):this.call(n,{signal:r.signal,context:e})}),...t.input===If||t.queryFn===If?{enabled:!1}:{}}}streamedKey(...e){let t=V_(e);return typeof this.options.streamedKey==`function`?t=this.options.streamedKey(t):this.options.streamedKey&&(t={...this.options.streamedKey,...t}),t.queryKey??J_(this.path,{prefix:this.options.prefix,type:`streamed`,input:t.input,fnOptions:t.queryFnOptions})}streamedOptions(...e){let t=V_(e);typeof this.options.streamedOptions==`function`?t=this.options.streamedOptions(t):this.options.streamedOptions&&(t={...this.options.streamedOptions,...t});let n=this.streamedKey(t);return{...t,queryKey:n,queryFn:e=>W_(Bh(this.options.streamedInterceptors),{path:this.path,context:{[$_]:{key:n,type:`streamed`},...t.context},input:t.input,fnContext:e},({context:e,fnContext:n,input:r})=>{if(r===If||t.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return t.queryFn?t.queryFn(n):Z_(async t=>{let n=await this.call(r,{signal:t.signal,context:e});if(!Wh(n))throw Error(`streamedQuery requires an AsyncIteratorObject output`);return n},t.queryFnOptions)(n)}),...t.input===If||t.queryFn===If?{enabled:!1}:{}}}liveKey(...e){let t=V_(e);return typeof this.options.liveKey==`function`?t=this.options.liveKey(t):this.options.liveKey&&(t={...this.options.liveKey,...t}),t.queryKey??J_(this.path,{prefix:this.options.prefix,type:`live`,input:t.input})}liveOptions(...e){let t=V_(e);typeof this.options.liveOptions==`function`?t=this.options.liveOptions(t):this.options.liveOptions&&(t={...this.options.liveOptions,...t});let n=this.liveKey(t);return{...t,queryKey:n,queryFn:e=>W_(Bh(this.options.liveInterceptors),{path:this.path,context:{[$_]:{key:n,type:`live`},...t.context},input:t.input,fnContext:e},({fnContext:e,input:n,context:r})=>{if(n===If||t.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return t.queryFn?t.queryFn(e):Y_(async e=>{let t=await this.call(n,{signal:e.signal,context:r});if(!Wh(t))throw Error(`liveQuery requires an AsyncIteratorObject output`);return t})(e)}),...t.input===If||t.queryFn===If?{enabled:!1}:{}}}infiniteKey(e){return typeof this.options.infiniteKey==`function`?e=this.options.infiniteKey(e):this.options.infiniteKey&&(e={...this.options.infiniteKey,...e}),e.queryKey??J_(this.path,{prefix:this.options.prefix,type:`infinite`,input:e.input===If?If:e.input(e.initialPageParam)})}infiniteOptions(e){typeof this.options.infiniteOptions==`function`?e=this.options.infiniteOptions(e):this.options.infiniteOptions&&(e={...this.options.infiniteOptions,...e});let t=this.infiniteKey(e);return{...e,queryKey:t,queryFn:n=>W_(Bh(this.options.infiniteInterceptors),{path:this.path,context:{[$_]:{key:t,type:`infinite`},...e.context},input:e.input===If?If:e.input(n.pageParam),fnContext:n},({context:t,input:n,fnContext:r})=>{if(n===If||e.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return e.queryFn?e.queryFn(r):this.call(n,{signal:r.signal,context:t})}),...e.input===If||e.queryFn===If?{enabled:!1}:{}}}mutationKey(e={}){return typeof this.options.mutationKey==`function`?e=this.options.mutationKey(e):this.options.mutationKey&&(e={...this.options.mutationKey,...e}),e.mutationKey??J_(this.path,{prefix:this.options.prefix,type:`mutation`})}mutationOptions(...e){let t=V_(e);typeof this.options.mutationOptions==`function`?t=this.options.mutationOptions(t):this.options.mutationOptions&&(t={...this.options.mutationOptions,...t});let n=this.mutationKey(t);return{...t,mutationKey:n,mutationFn:(e,r)=>W_(Bh(this.options.mutationInterceptors),{path:this.path,context:{[$_]:{key:n,type:`mutation`},...t.context},fnContext:r,input:e},({input:e,fnContext:n,context:r})=>t.mutationFn?t.mutationFn(e,n):this.call(e,{context:r}))}}};function ov(e,t={}){let n=new q_(t.plugins);return t=n.init(t),sv(e,t,n)}function sv(e,t,n){let r=Bh(t.path),i=typeof e==`function`&&(t.scoped===void 0||nv(t.scoped))?U_(new av(r,e,n.initProcedureOptions(r,iv({prefix:t.prefix,queryInterceptors:t.queryInterceptors,streamedInterceptors:t.streamedInterceptors,liveInterceptors:t.liveInterceptors,infiniteInterceptors:t.infiniteInterceptors,mutationInterceptors:t.mutationInterceptors},t.scoped??{}))),{unbound:[`call`]}):U_(new X_(r,t)),a=new Map;return new Proxy(i,{get(i,o){let s=Reflect.get(i,o),c=Reflect.get(e,o);if(typeof o!=`string`||K_.has(o)||!Yh(c))return s;let l=a.get(o);if(l===void 0){let e=sv(c,{...t,path:[...r,o],scoped:t.scoped?.[o]},n);l=typeof s==`function`?new Proxy(s,{get(t,n){return typeof n!=`string`||K_.has(n)?Reflect.get(t,n):Reflect.get(e,n)}}):e,a.set(o,l)}return l}})}function cv(e){if(typeof e!=`object`||!e||!(`endpoint`in e)||typeof e.endpoint!=`string`||!(`keys`in e))return!1;let t=e.keys;return!(typeof t!=`object`||!t||!(`p256dh`in t)||typeof t.p256dh!=`string`||!(`auth`in t)||typeof t.auth!=`string`)}async function lv(e,t){let n=e=>{let n=t[e];return typeof n==`string`?n:``},r=e=>{let n=t[e];return typeof n==`string`?n:void 0},i=()=>{let e=t.type;return e===`public`||e===`private`||e===`secret`?e:`public`};switch(t.action){case`send`:return e.send({target:n(`target`),content:n(`content`)});case`dm`:return e.dm({target:n(`target`),content:n(`content`)});case`join_room`:return e.joinRoom({room:n(`room`)});case`leave_room`:return e.leaveRoom({room:r(`room`)});case`create_room`:return e.createRoom({name:n(`name`),type:i(),description:r(`description`)});case`list_rooms`:return e.listRooms({});case`list_agents`:return e.listAgents({});case`read_room`:return e.readRoom({room:r(`room`)});case`destroy_room`:return e.destroyRoom({room:n(`room`)});case`invite`:return e.invite({room:n(`room`),agent:n(`agent`)});case`decline_invite`:return e.declineInvite({room:n(`room`),reason:n(`reason`)});case`kick`:return e.kick({room:n(`room`),agent:n(`agent`)});case`rename_agent`:return e.renameAgent({agent:n(`agent`),name:n(`name`)});case`push_subscribe`:{let n=t.subscription;return cv(n)?e.pushSubscribe({subscription:n,agentId:r(`agentId`)}):{content:`Invalid push subscription`,isError:!0}}case`push_unsubscribe`:return e.pushUnsubscribe({agentId:r(`agentId`)});default:return{content:`Unknown action: ${String(t.action)}`,isError:!0}}}var uv=new Set([`room_message`,`dm`,`room_invite`,`member_joined`,`member_left`,`room_members`,`member_status`,`delivery_status`,`invite_declined`,`name_changed`]);function dv(e){return uv.has(e.type)}function fv(e){return{getRoomMessages:async t=>e().getRoomMessages(t),getMeshGraph:async()=>e().getMeshGraph({}),getMeshTrace:async t=>e().getMeshTrace(t)}}var pv=19877,mv=10,hv=class{worker;client;state={agents:[],rooms:[],connected:!1};listeners=new Set;deliveryListeners=new Set;eventPumpGeneration=0;readsClient=fv(()=>this.requireClient());queryUtils=ov(this.readsClient);constructor(){typeof window<`u`&&window.addEventListener(`pagehide`,()=>{this.disconnect()})}requireClient(){if(!this.client)throw Error(`Not connected to mesh yet`);return this.client}connect(){if(this.worker)return;let e=new SharedWorker(`./mesh-worker.js`);this.worker=e,e.port.onmessage=e=>{let t=JSON.parse(typeof e.data==`string`?e.data:String(e.data));gv(t)&&(t.type===`connected`?(this.state={...this.state,connected:!0},this.notify()):t.type===`disconnected`&&(this.state={...this.state,connected:!1},this.notify()))},e.port.start();let t=u_(new B_({port:e.port}));if(this.client=t,this.pumpEvents(t,++this.eventPumpGeneration),/^(localhost|127\.\d+\.\d+\.\d+)(:\d+)?$/.test(location.host)){let e=`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/ws/mesh`;this.postLegacyInit(e)}else this.probeLocalMesh(pv,mv)}get(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}onDelivery(e){return this.deliveryListeners.add(e),()=>{this.deliveryListeners.delete(e)}}async sendAction(e){let t=this.client;return t?lv(t,e):{content:`Not connected to mesh yet`,isError:!0}}disconnect(){let e=this.worker,t=this.client;this.worker=void 0,this.client=void 0,this.eventPumpGeneration++,e&&(t?t.disconnect({}).catch(()=>{}).finally(()=>{e.port.close()}):e.port.close())}async pumpEvents(e,t){let n;for(;t===this.eventPumpGeneration;)try{let r=await e.subscribeEvents(n===void 0?{}:{lastEventId:n});for await(let e of r){if(t!==this.eventPumpGeneration)return;let r=Ig(e);r?.id!==void 0&&(n=r.id),this.applyMeshEvent(e)}return}catch{}}applyMeshEvent(e){switch(e.kind){case`state_sync`:{let t=Object.values(e.state.agents).filter(vv),n=Object.values(e.state.rooms).filter(yv);this.state={...this.state,agents:t,rooms:n},this.notify();break}case`state_patch`:this.applyPatch(e.patch);break;case`delivery`:if(dv(e.event))for(let t of this.deliveryListeners)t(e.event)}}applyPatch(e){switch(e.type){case`agent_upsert`:{let t=this.state.agents.filter(t=>t.id!==e.agent.id);t.push(e.agent),this.state={...this.state,agents:t},this.notify();break}case`agent_offline`:{let t=this.state.agents.map(t=>t.id===e.agentId?{...t,status:`offline`}:t);this.state={...this.state,agents:t},this.notify();break}case`room_upsert`:{let t=this.state.rooms.filter(t=>t.id!==e.room.id);t.push(e.room),this.state={...this.state,rooms:t},this.notify();break}case`room_delete`:{let t=this.state.rooms.filter(t=>t.id!==e.roomId);this.state={...this.state,rooms:t},this.notify();break}}}postLegacyInit(e){this.worker?.port.postMessage(JSON.stringify({type:`init`,url:e}))}probeLocalMesh(e,t){let n=0,r=e=>{if(n>=t)return;n++;let i=`ws://127.0.0.1:${String(e)}/ws/mesh`;fetch(`http://127.0.0.1:${String(e)}/`,{mode:`no-cors`}).then(()=>{this.postLegacyInit(i)}).catch(()=>{r(e+1)})};r(e)}notify(){let e=this.state;for(let t of this.listeners)t(e)}};function gv(e){return typeof e==`object`&&!!e&&`type`in e}function _v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vv(e){return _v(e)&&typeof e.id==`string`&&typeof e.name==`string`}function yv(e){return _v(e)&&typeof e.id==`string`&&typeof e.name==`string`}var bv=Ln({primaryColor:`accent`,primaryShade:5,colors:{accent:[`#e5fbff`,`#bdf4ff`,`#85ebff`,`#47e0ff`,`#0fd7ff`,`#00b3d6`,`#009dbd`,`#00849e`,`#006f85`,`#005566`],dark:[`#e4e4e4`,`#b6b6b6`,`#888888`,`#4c5e74`,`#0f3460`,`#132b4f`,`#16213e`,`#1a1a2e`,`#131321`,`#0c0c16`]}}),xv=/^(localhost|127\.\d+\.\d+\.\d+)(:\d+)?$/;function Sv(e){return xv.test(e)}function Cv(e){return e.getItem(`agent-comms-connected`)===`true`}var wv=`Project room for `;function Tv(e){let t=new URLSearchParams(e),n=t.get(`room`);if(n!==null&&n!==``)return{kind:`room`,roomId:n};let r=t.get(`dm`);if(r!==null&&r!==``)return{kind:`dm`,agentId:r};let i=t.get(`cwd`);if(i!==null&&i!==``)return{kind:`cwd`,path:i}}function Ev(e,t){switch(e.kind){case`room`:return t.some(t=>t.id===e.roomId)?{kind:`room`,targetId:e.roomId}:void 0;case`dm`:return{kind:`dm`,targetId:e.agentId};case`cwd`:{let n=t.find(t=>t.description===`${wv}${e.path}`);return n?{kind:`room`,targetId:n.id}:void 0}default:return e}}function Dv(e){let t=new URL(location.href);t.searchParams.delete(`room`),t.searchParams.delete(`dm`),t.searchParams.delete(`cwd`),e.currentRoom!==void 0&&e.currentRoom!==``?t.searchParams.set(`room`,e.currentRoom):e.dmTarget!==void 0&&e.dmTarget!==``&&t.searchParams.set(`dm`,e.dmTarget);let n=t.pathname+t.search+t.hash;history.replaceState(null,``,n)}var Ov=document.createElement(`style`);Ov.textContent=l,document.head.appendChild(Ov);var kv=Sv(location.host),Av=document.getElementById(`root`);if(Av===null)throw Error(`missing #root element`);var jv=new Rh,Mv=new _p,Nv=new hv,Pv=!1;Nv.subscribe(e=>{e.agents.length>0&&jv.setAgents(e.agents),e.rooms.length>0&&jv.setRooms(e.rooms),jv.setConnected(e.connected),e.connected!==Pv&&(Pv=e.connected,Fv({type:`system`,text:e.connected?`Connected to mesh`:`Disconnected — reconnecting...`}))}),Nv.onDelivery(e=>{let t=Vp(e,jv.get().currentRoom);t&&Fv(t),(e.type===`member_joined`||e.type===`member_left`||e.type===`member_status`||e.type===`name_changed`)&&Lv()});function Fv(e){jv.addMessage(e)}async function Iv(e){let t=await Nv.sendAction(e);Fv({type:t.isError?`status`:`system`,text:t.isError?`Error: ${t.content}`:t.content}),t.isError||Lv()}async function Lv(){await Mv.invalidateQueries({queryKey:Nv.queryUtils.getMeshGraph.key()})}async function Rv(e){jv.setDmTarget(void 0),jv.setCurrentRoom(e),jv.clearMessages(),Iv({action:`join_room`,room:e});let t=await Mv.query(Nv.queryUtils.getRoomMessages.queryOptions({input:{room:e}}));jv.setMessages(t.map(Hp)),Fv({type:`system`,text:`Joined ${e}`})}function zv(e){jv.setCurrentRoom(void 0),jv.setDmTarget(e),jv.clearMessages()}function Bv(){let e=jv.get(),t=e.currentRoom;if(t!==void 0&&t!==``){let n=e.rooms.find(e=>e.id===t)?.name??t;Iv({action:`leave_room`,room:t}),jv.setCurrentRoom(void 0),jv.clearMessages(),Fv({type:`system`,text:`Left room "${n}"`})}}function Vv(e){let t=jv.get(),n=Fp(e,t.currentRoom,t.dmTarget),r=Pp(n);if(r)switch(r.kind){case`join_room`:Rv(r.room);return;case`leave_room`:Bv();return}switch(n.kind){case`action`:Iv(n.action);break;case`local`:Fv({type:`system`,text:n.result.text})}}function Hv(e,t,n){Iv({action:`create_room`,name:e,type:t,...n?{description:n}:{}})}function Uv(e){Rv(e)}function Wv(e,t){Iv({action:`rename_agent`,agent:e,name:t})}function Gv(){localStorage.setItem(`agent-comms-connected`,`true`),Nv.connect()}function Kv(){let e=zh(jv);return(0,A.useEffect)(()=>{Dv({currentRoom:e.currentRoom,dmTarget:e.dmTarget})},[e.currentRoom,e.dmTarget]),(0,z.jsx)(Ih,{rooms:e.rooms,agents:e.agents,currentRoom:e.currentRoom,dmTarget:e.dmTarget,messages:e.messages,connected:e.connected,queryUtils:Nv.queryUtils,onJoinRoom:e=>{Rv(e)},onSelectAgent:zv,onRenameAgent:Wv,onLeaveRoom:Bv,onSendAction:Vv,onCreateRoom:Hv,onJoinRoomInput:Uv,onConnectToMesh:Gv})}(0,Mp.createRoot)(Av).render((0,z.jsx)(df,{client:Mv,children:(0,z.jsx)(In,{theme:bv,defaultColorScheme:`dark`,children:(0,z.jsx)(Kv,{})})}));var qv=Tv(location.search),Jv=Cv(localStorage);if((kv||Jv)&&Nv.connect(),qv){let e=Nv.subscribe(t=>{if(t.rooms.length===0)return;e();let n=Ev(qv,t.rooms);if(n)switch(n.kind){case`room`:Rv(n.targetId);break;case`dm`:zv(n.targetId)}})}
49
+ `},El=0,Dl=[];function Ol(e){var t=A.useRef([]),n=A.useRef([0,0]),r=A.useRef(),i=A.useState(El++)[0],a=A.useState(Xc)[0],o=A.useRef(e);A.useEffect(function(){o.current=e},[e]),A.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Ec([e.lockRef.current],(e.shards||[]).map(Cl),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=A.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=xl(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=ml(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=ml(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return bl(h,t,e,h===`h`?s:c,!0)},[]),c=A.useCallback(function(e){var n=e;if(Dl.length&&Dl[Dl.length-1]===a){var r=`deltaY`in n?Sl(n):xl(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&wl(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Cl).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=A.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:kl(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=A.useCallback(function(e){n.current=xl(e),r.current=void 0},[]),d=A.useCallback(function(t){l(t.type,Sl(t),t.target,s(t,e.lockRef.current))},[]),f=A.useCallback(function(t){l(t.type,xl(t),t.target,s(t,e.lockRef.current))},[]);A.useEffect(function(){return Dl.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,ll),document.addEventListener(`touchmove`,c,ll),document.addEventListener(`touchstart`,u,ll),function(){Dl=Dl.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,ll),document.removeEventListener(`touchmove`,c,ll),document.removeEventListener(`touchstart`,u,ll)}},[]);var p=e.removeScrollBar,m=e.inert;return A.createElement(A.Fragment,null,m?A.createElement(a,{styles:Tl(i)}):null,p?A.createElement(ol,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function kl(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Al=Bc(Vc,Ol),jl=A.forwardRef(function(e,t){return A.createElement(Uc,wc({},e,{ref:t,sideCar:Al}))});jl.classNames=Uc.classNames;var Ml=(0,A.createContext)({size:`sm`}),Nl=H(e=>{let t=B(`InputClearButton`,null,e),{size:n,variant:r,vars:i,classNames:a,styles:o,...s}=t,c=(0,A.use)(Ml),{resolvedClassNames:l,resolvedStyles:u}=Rn({classNames:a,styles:o,props:t});return(0,z.jsx)(vc,{variant:r||`transparent`,size:n||c?.size||`sm`,classNames:l,styles:u,__staticSelector:`InputClearButton`,style:{pointerEvents:`all`,background:`var(--input-bg)`,...s.style},...s})});Nl.displayName=`@mantine/core/InputClearButton`;var Pl={xs:7,sm:8,md:10,lg:12,xl:15};function Fl({__clearable:e,__clearSection:t,rightSection:n,__defaultRightSection:r,size:i=`sm`,__clearSectionMode:a=`both`}){let o=e&&t;return a===`rightSection`?n===null?null:n||r:a===`clear`?n===null?null:o||r:o&&(n||r)?(0,z.jsxs)(`div`,{"data-combined-clear-section":!0,style:{display:`flex`,gap:2,alignItems:`center`,paddingInlineEnd:Pl[i]},children:[o,n||r]}):n===null?null:n||o||r}var Il=(0,A.createContext)({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0}),Ll={wrapper:`m_6c018570`,input:`m_8fb7ebe7`,bottomSection:`m_93f4ed57`,section:`m_82577fc2`,placeholder:`m_88bacfd0`,root:`m_46b77525`,label:`m_8fdc1311`,required:`m_78a94662`,error:`m_8f816625`,success:`m_9d9d40e0`,description:`m_fe47ce59`},Rl=L((e,{size:t})=>({description:{"--input-description-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),zl=H(e=>{let t=B(`InputDescription`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,__inheritStyles:l=!0,attributes:u,...d}=B(`InputDescription`,null,t),f=(0,A.use)(Il),p=V({name:[`InputWrapper`,c],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,rootSelector:`description`,vars:s,varsResolver:Rl}),m=l&&f?.getStyles||p;return(0,z.jsx)(U,{component:`p`,...m(`description`,f?.getStyles?{className:r,style:i}:void 0),...d})});zl.classes=Ll,zl.varsResolver=Rl,zl.displayName=`@mantine/core/InputDescription`;var Bl=L((e,{size:t})=>({error:{"--input-error-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Vl=H(e=>{let t=B(`InputError`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,__staticSelector:l,__inheritStyles:u=!0,...d}=t,f=V({name:[`InputWrapper`,l],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`error`,vars:s,varsResolver:Bl}),p=(0,A.use)(Il),m=u&&p?.getStyles||f;return(0,z.jsx)(U,{component:`p`,...m(`error`,p?.getStyles?{className:r,style:i}:void 0),...d})});Vl.classes=Ll,Vl.varsResolver=Bl,Vl.displayName=`@mantine/core/InputError`;var Hl={labelElement:`label`},Ul=L((e,{size:t})=>({label:{"--input-label-size":fe(t),"--input-asterisk-color":void 0}})),Wl=H(e=>{let t=B(`InputLabel`,Hl,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,labelElement:c,required:l,htmlFor:u,onMouseDown:d,children:f,__staticSelector:p,mod:m,attributes:h,...g}=t,_=V({name:[`InputWrapper`,p],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`label`,vars:s,varsResolver:Ul}),v=(0,A.use)(Il),y=v?.getStyles||_,b=g.component||c,x=typeof b!=`string`||b===`label`;return(0,z.jsxs)(U,{...y(`label`,v?.getStyles?{className:r,style:i}:void 0),component:c,htmlFor:x?u:void 0,mod:[{required:l},m],onMouseDown:e=>{d?.(e),!e.defaultPrevented&&e.detail>1&&e.preventDefault()},...g,children:[f,l&&(0,z.jsx)(`span`,{...y(`required`),"aria-hidden":!0,children:` *`})]})});Wl.classes=Ll,Wl.varsResolver=Ul,Wl.displayName=`@mantine/core/InputLabel`;var Gl=H(e=>{let t=B(`InputPlaceholder`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,error:l,mod:u,attributes:d,...f}=t,p=V({name:[`InputPlaceholder`,c],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:d,rootSelector:`placeholder`});return(0,z.jsx)(U,{...p(`placeholder`),mod:[{error:!!l},u],component:`span`,...f})});Gl.classes=Ll,Gl.displayName=`@mantine/core/InputPlaceholder`;var Kl=L((e,{size:t})=>({success:{"--input-success-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),ql=H(e=>{let t=B(`InputSuccess`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,__staticSelector:l,__inheritStyles:u=!0,...d}=t,f=V({name:[`InputWrapper`,l],props:t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`success`,vars:s,varsResolver:Kl}),p=(0,A.use)(Il),m=u&&p?.getStyles||f;return(0,z.jsx)(U,{component:`p`,...m(`success`,p?.getStyles?{className:r,style:i}:void 0),...d})});ql.classes=Ll,ql.varsResolver=Kl,ql.displayName=`@mantine/core/InputSuccess`;function Jl(e,{hasDescription:t,hasError:n}){let r=e.findIndex(e=>e===`input`),i=e.slice(0,r),a=e.slice(r+1),o=t&&i.includes(`description`)||n&&i.includes(`error`);return{offsetBottom:t&&a.includes(`description`)||n&&a.includes(`error`),offsetTop:o}}var Yl={labelElement:`label`,inputContainer:e=>e,inputWrapperOrder:[`label`,`description`,`input`,`error`]},Xl=L((e,{size:t})=>({label:{"--input-label-size":fe(t),"--input-asterisk-color":void 0},error:{"--input-error-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`},success:{"--input-success-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`},description:{"--input-description-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Zl=H(e=>{let t=B(`InputWrapper`,Yl,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,variant:l,__staticSelector:u,inputContainer:d,inputWrapperOrder:f,label:p,error:m,success:h,description:g,labelProps:_,descriptionProps:v,errorProps:y,successProps:b,labelElement:x,children:S,withAsterisk:C,id:w,required:T,__stylesApiProps:E,mod:D,attributes:O,...k}=t,j=V({name:[`InputWrapper`,u],props:E||t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:O,vars:s,varsResolver:Xl}),M={size:c,variant:l,__staticSelector:u},ee=ze(w),te=typeof C==`boolean`?C:T,ne=y?.id||`${ee}-error`,re=b?.id||`${ee}-success`,ie=v?.id||`${ee}-description`,ae=ee,oe=!!m&&typeof m!=`boolean`,se=!!h&&typeof h!=`boolean`&&!m,ce=!!g,le=oe&&f.includes(`error`),N=se&&f.includes(`error`),ue=ce&&f.includes(`description`),de=`${le?ne:``} ${N?re:``} ${ue?ie:``}`,fe=de.trim().length>0?de.trim():void 0,pe=_?.id||`${ee}-label`,me=p&&(0,z.jsx)(Wl,{labelElement:x,id:pe,htmlFor:ae,required:te,...M,..._,children:p},`label`),he=ce&&(0,z.jsx)(zl,{...v,...M,size:v?.size||M.size,id:v?.id||ie,children:g},`description`),ge=(0,z.jsx)(A.Fragment,{children:d(S)},`input`),P=oe&&(0,A.createElement)(Vl,{...y,...M,size:y?.size||M.size,key:`error`,id:y?.id||ne},m),F=se&&(0,A.createElement)(ql,{...b,...M,size:b?.size||M.size,key:`success`,id:b?.id||re},h),_e=f.map(e=>{switch(e){case`label`:return me;case`input`:return ge;case`description`:return he;case`error`:return P||F;default:return null}});return(0,z.jsx)(Il,{value:{getStyles:j,describedBy:fe,inputId:ae,labelId:pe,...Jl(f,{hasDescription:ce,hasError:oe||se})},children:(0,z.jsx)(U,{variant:l,size:c,mod:[{error:!!m,success:!!h&&!m},D],id:x===`label`?void 0:w,...j(`root`),...k,children:_e})})});Zl.classes=Ll,Zl.varsResolver=Xl,Zl.displayName=`@mantine/core/InputWrapper`;var Ql={variant:`default`,leftSectionPointerEvents:`none`,rightSectionPointerEvents:`none`,withAria:!0,withErrorStyles:!0,withSuccessStyles:!0,size:`sm`,loading:!1,loadingPosition:`right`},$l=L((e,t,n)=>({wrapper:{"--input-margin-top":n.offsetTop?`calc(var(--mantine-spacing-xs) / 2)`:void 0,"--input-margin-bottom":n.offsetBottom?`calc(var(--mantine-spacing-xs) / 2)`:void 0,"--input-height":N(t.size,`input-height`),"--input-fz":fe(t.size),"--input-radius":t.radius===void 0?void 0:de(t.radius),"--input-left-section-width":t.leftSectionWidth===void 0?void 0:E(t.leftSectionWidth),"--input-right-section-width":t.rightSectionWidth===void 0?void 0:E(t.rightSectionWidth),"--input-padding-y":t.multiline?N(t.size,`input-padding-y`):void 0,"--input-left-section-pointer-events":t.leftSectionPointerEvents,"--input-right-section-pointer-events":t.rightSectionPointerEvents}})),eu=Nr(e=>{let t=B(`Input`,Ql,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,required:s,__staticSelector:c,__stylesApiProps:l,size:u,wrapperProps:d,error:f,success:p,disabled:m,leftSection:h,leftSectionProps:g,leftSectionWidth:_,rightSection:v,rightSectionProps:y,rightSectionWidth:b,rightSectionPointerEvents:x,leftSectionPointerEvents:S,variant:C,vars:w,pointer:T,multiline:E,radius:D,id:O,withAria:k,withErrorStyles:j,withSuccessStyles:M,mod:ee,inputSize:te,attributes:ne,__clearSection:re,__clearable:ie,__clearSectionMode:ae,__defaultRightSection:oe,loading:se,loadingPosition:ce,__bottomSection:le,__bottomSectionProps:N,rootRef:ue,dir:de,...fe}=t,{styleProps:pe,rest:me}=ir(fe),he=(0,A.use)(Il),ge={offsetBottom:he?.offsetBottom,offsetTop:he?.offsetTop},P=V({name:[`Input`,c],props:l||t,classes:Ll,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:ne,stylesCtx:ge,rootSelector:`wrapper`,vars:w,varsResolver:$l}),F=k?{required:s,disabled:m,"aria-invalid":f?!0:void 0,"aria-describedby":he?.describedBy,id:he?.inputId||O}:{},_e=se?(0,z.jsx)(ac,{size:ce===`left`?`calc(var(--input-left-section-size) / 2)`:`calc(var(--input-right-section-size) / 2)`}):null,ve=se&&ce===`left`?_e:h,ye=Fl({__clearable:ie,__clearSection:re,rightSection:se&&ce===`right`?_e:v,__defaultRightSection:oe,size:u,__clearSectionMode:ae});return(0,z.jsx)(Ml,{value:{size:u||`sm`},children:(0,z.jsxs)(U,{ref:ue,dir:de,...P(`wrapper`),...pe,...d,mod:[{error:!!f&&j,success:!!p&&!f&&M,pointer:T,disabled:m,multiline:E,withRightSection:!!ye,withLeftSection:!!ve,withBottomSection:!!le},ee],variant:C,size:u,children:[ve&&(0,z.jsx)(`div`,{...g,"data-position":`left`,...P(`section`,{className:g?.className,style:g?.style}),children:ve}),(0,z.jsx)(U,{component:`input`,...me,...F,required:s,mod:{disabled:m,error:!!f&&j,success:!!p&&!f&&M},variant:C,__size:te,...P(`input`)}),le&&(0,z.jsx)(`div`,{...N,...P(`bottomSection`,{className:N?.className,style:N?.style}),children:le}),ye&&(0,z.jsx)(`div`,{...y,"data-position":`right`,...P(`section`,{className:y?.className,style:y?.style}),children:ye})]})})});eu.classes=Ll,eu.varsResolver=$l,eu.Wrapper=Zl,eu.Label=Wl,eu.Error=Vl,eu.Success=ql,eu.Description=zl,eu.Placeholder=Gl,eu.ClearButton=Nl,eu.displayName=`@mantine/core/Input`;function tu(e,t,n){let r=B([`Input`,`InputWrapper`,e],t,n),{label:i,description:a,error:o,success:s,required:c,classNames:l,styles:u,className:d,unstyled:f,__staticSelector:p,__stylesApiProps:m,errorProps:h,successProps:g,labelProps:_,descriptionProps:v,wrapperProps:y,id:b,size:x,style:S,inputContainer:C,inputWrapperOrder:w,withAsterisk:T,variant:E,vars:D,mod:O,attributes:k,...A}=r,{styleProps:j,rest:M}=ir(A),ee={label:i,description:a,error:o,success:s,required:c,classNames:l,className:d,__staticSelector:p,__stylesApiProps:m||r,errorProps:h,successProps:g,labelProps:_,descriptionProps:v,unstyled:f,styles:u,size:x,style:S,inputContainer:C,inputWrapperOrder:w,withAsterisk:T,variant:E,id:b,mod:O,attributes:k,...y};return{...M,classNames:l,styles:u,unstyled:f,wrapperProps:{...ee,...j},inputProps:{required:c,classNames:l,styles:u,unstyled:f,size:x,__staticSelector:p,__stylesApiProps:m||r,error:o,success:s,variant:E,id:b,attributes:k}}}var nu={__staticSelector:`InputBase`,withAria:!0,size:`sm`},q=Nr(e=>{let{inputProps:t,wrapperProps:n,...r}=tu(`InputBase`,nu,e);return(0,z.jsx)(eu.Wrapper,{...n,children:(0,z.jsx)(eu,{...t,...r})})});q.classes={...eu.classes,...eu.Wrapper.classes},q.displayName=`@mantine/core/InputBase`;function ru(e,t){if(!t||!e)return!1;let n=t.parentNode;for(;n!=null;){if(n===e)return!0;n=n.parentNode}return!1}function iu({target:e,parent:t,ref:n,displayAfterTransitionEnd:r,onTransitionStart:i,onTransitionEnd:a}){let o=(0,A.useRef)(-1),s=(0,A.useRef)(e),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(typeof r==`boolean`&&r),f=()=>{if(!e||!t||!n.current)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=t.offsetWidth===0?1:i.width/t.offsetWidth,o=t.offsetHeight===0?1:i.height/t.offsetHeight,s=window.getComputedStyle(e),c=window.getComputedStyle(t),l=ii(s.borderTopWidth)+ii(c.borderTopWidth),u=ii(s.borderLeftWidth)+ii(c.borderLeftWidth),d={top:(r.top-i.top)/o-l,left:(r.left-i.left)/a-u,width:r.width/a,height:r.height/o};n.current.style.transform=`translateY(${d.top}px) translateX(${d.left}px)`,n.current.style.width=`${d.width}px`,n.current.style.height=`${d.height}px`},p=()=>{window.clearTimeout(o.current),n.current&&(n.current.style.transitionDuration=`0ms`),f(),o.current=window.setTimeout(()=>{n.current&&(n.current.style.transitionDuration=``)},30)},m=(0,A.useRef)(null),h=(0,A.useRef)(null);return(0,A.useEffect)(()=>{if(c&&s.current!==e&&i&&i(),s.current=e,f(),e)return m.current=new ResizeObserver(p),m.current.observe(e),t&&(h.current=new ResizeObserver(p),h.current.observe(t)),()=>{m.current?.disconnect(),h.current?.disconnect()}},[t,e]),(0,A.useEffect)(()=>{if(t){let e=e=>{ru(e.target,t)&&(p(),d(!1))};return t.addEventListener(`transitionend`,e),()=>{t.removeEventListener(`transitionend`,e)}}},[t]),(0,A.useEffect)(()=>{if(n.current&&a){let e=e=>{e.propertyName===`transform`&&a()};return n.current.addEventListener(`transitionend`,e),()=>{n.current?.removeEventListener(`transitionend`,e)}}},[a]),Xe(()=>{mt()!==`test`&&l(!0)},20,{autoInvoke:!0}),Qe(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`dir`&&p()})},{attributes:!0,attributeFilter:[`dir`]},()=>document.documentElement),{initialized:c,hidden:u}}var au={root:`m_96b553a6`},ou=L((e,{transitionDuration:t},{shouldReduceMotion:n})=>({root:{"--transition-duration":e.respectReducedMotion&&n?`0ms`:typeof t==`number`?`${t}ms`:t||`150ms`}})),su=H(e=>{let t=B(`FloatingIndicator`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,target:c,parent:l,transitionDuration:u,mod:d,displayAfterTransitionEnd:f,onTransitionStart:p,onTransitionEnd:m,attributes:h,ref:g,..._}=t,v=V({name:`FloatingIndicator`,classes:au,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,vars:s,varsResolver:ou,stylesCtx:{shouldReduceMotion:Ge()}}),y=(0,A.useRef)(null),{initialized:b,hidden:x}=iu({target:c,parent:l,ref:y,displayAfterTransitionEnd:f,onTransitionStart:p,onTransitionEnd:m}),S=Ue(g,y);return!c||!l?null:(0,z.jsx)(U,{ref:S,mod:[{initialized:b,hidden:x},d],...v(`root`),..._})});su.displayName=`@mantine/core/FloatingIndicator`,su.classes=au,su.varsResolver=ou;function cu({style:e,size:t=16,...n}){return(0,z.jsx)(`svg`,{viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{...e,width:E(t),height:E(t),display:`block`},...n,children:(0,z.jsx)(`path`,{d:`M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}cu.displayName=`@mantine/core/AccordionChevron`;var lu={root:`m_b6d8b162`};function uu(e){if(e===`start`)return`start`;if(e===`end`||e)return`end`}var du={inherit:!1},fu=L((e,{variant:t,lineClamp:n,gradient:r,size:i,textWrap:a})=>({root:{"--text-fz":fe(i),"--text-lh":pe(i),"--text-gradient":t===`gradient`?Ut(r,e):void 0,"--text-line-clamp":typeof n==`number`?n.toString():void 0,"--text-text-wrap":a}})),pu=Nr(e=>{let t=B(`Text`,du,e),{lineClamp:n,truncate:r,inline:i,inherit:a,gradient:o,span:s,textWrap:c,__staticSelector:l,vars:u,className:d,style:f,classNames:p,styles:m,unstyled:h,variant:g,mod:_,size:v,attributes:y,...b}=t,x=V({name:[`Text`,l],props:t,classes:lu,className:d,style:f,classNames:p,styles:m,unstyled:h,attributes:y,vars:u,varsResolver:fu});return(0,z.jsx)(U,{...x(`root`,{focusable:!0}),component:s?`span`:`p`,variant:g,mod:[{truncate:uu(r),lineClamp:typeof n==`number`,inline:i,inherit:a},_],size:v,...b})});pu.classes=lu,pu.varsResolver=fu,pu.displayName=`@mantine/core/Text`;var[mu,hu]=M(`AppShell was not found in tree`),gu={root:`m_89ab340`,navbar:`m_45252eee`,aside:`m_9cdde9a`,header:`m_3b16f56b`,main:`m_8983817`,footer:`m_3840c879`,section:`m_6dcfc7c7`},_u=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellAside`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`aside`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`aside`,{className:St({[jl.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-aside-z-index":`calc(${c??d.zIndex} + 1)`}})});_u.classes=gu,_u.displayName=`@mantine/core/AppShellAside`;var vu=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellFooter`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`footer`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`footer`,{className:St({[jl.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-footer-z-index":(c??d.zIndex)?.toString()}})});vu.classes=gu,vu.displayName=`@mantine/core/AppShellFooter`;var yu=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellHeader`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`header`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`header`,{className:St({[jl.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-header-z-index":(c??d.zIndex)?.toString()}})});yu.classes=gu,yu.displayName=`@mantine/core/AppShellHeader`;var bu=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`AppShellMain`,null,e),s=hu();return(0,z.jsx)(U,{component:`main`,...s.getStyles(`main`,{className:n,style:r,classNames:t,styles:i}),...o})});bu.classes=gu,bu.displayName=`@mantine/core/AppShellMain`;var xu=H(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=B(`AppShellNavbar`,null,e),d=hu();return d.disabled?null:(0,z.jsx)(U,{component:`nav`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`navbar`,{className:n,classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-navbar-z-index":`calc(${c??d.zIndex} + 1)`}})});xu.classes=gu,xu.displayName=`@mantine/core/AppShellNavbar`;var Su=Nr(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,grow:o,mod:s,...c}=B(`AppShellSection`,null,e),l=hu();return(0,z.jsx)(U,{mod:[{grow:o},s],...l.getStyles(`section`,{className:n,style:r,classNames:t,styles:i}),...c})});Su.classes=gu,Su.displayName=`@mantine/core/AppShellSection`;function Cu(e){return typeof e==`object`?e.base:e}function wu(e){let t=typeof e==`object`&&!!e&&e.base!==void 0&&Object.keys(e).length===1;return typeof e==`number`||typeof e==`string`||t}function Tu(e){return!(typeof e!=`object`||!e||Object.keys(e).length===1&&`base`in e)}function Eu({baseStyles:e,minMediaStyles:t,maxMediaStyles:n,aside:r,theme:i,mode:a}){let o=r?.width,s=`translateX(var(--app-shell-aside-width))`,c=`translateX(calc(var(--app-shell-aside-width) * -1))`;if(r?.breakpoint!==void 0&&!r?.collapsed?.mobile&&(n[r?.breakpoint]=n[r?.breakpoint]||{},a===`fixed`?(n[r?.breakpoint][`--app-shell-aside-width`]=`100%`,n[r?.breakpoint][`--app-shell-aside-offset`]=`0px`):(n[r?.breakpoint][`--app-shell-aside-width`]=`0px`,n[r?.breakpoint][`--app-shell-aside-offset`]=`0px`)),wu(o)){let t=E(Cu(o));e[`--app-shell-aside-width`]=t,e[`--app-shell-aside-offset`]=t}if(Tu(o)&&(o.base!==void 0&&(e[`--app-shell-aside-width`]=E(o.base),e[`--app-shell-aside-offset`]=E(o.base)),v(o).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-aside-width`]=E(o[e]),t[e][`--app-shell-aside-offset`]=E(o[e]))})),r?.breakpoint!==void 0&&a===`static`&&(t[r.breakpoint]=t[r.breakpoint]||{},t[r.breakpoint][`--app-shell-aside-position`]=`sticky`,t[r.breakpoint][`--app-shell-aside-grid-row`]=`2`,t[r.breakpoint][`--app-shell-aside-grid-column`]=`3`,t[r.breakpoint][`--app-shell-main-column-end`]=`3`),r?.collapsed?.desktop){let e=r.breakpoint;t[e]=t[e]||{},t[e][`--app-shell-aside-transform`]=s,t[e][`--app-shell-aside-transform-rtl`]=c,a===`fixed`?t[e][`--app-shell-aside-offset`]=`0px !important`:(t[e][`--app-shell-aside-width`]=`0px`,t[e][`--app-shell-aside-display`]=`none`,t[e][`--app-shell-main-column-end`]=`-1`),t[e][`--app-shell-aside-scroll-locked-visibility`]=`hidden`}if(r?.collapsed?.mobile){let e=ge(r.breakpoint,i.breakpoints)-.1;n[e]=n[e]||{},a===`fixed`?(n[e][`--app-shell-aside-width`]=`100%`,n[e][`--app-shell-aside-offset`]=`0px`):n[e][`--app-shell-aside-width`]=`0px`,n[e][`--app-shell-aside-transform`]=s,n[e][`--app-shell-aside-transform-rtl`]=c,n[e][`--app-shell-aside-scroll-locked-visibility`]=`hidden`}}function Du({baseStyles:e,minMediaStyles:t,footer:n,mode:r}){let i=n?.height,a=r===`static`?!0:n?.offset??!0;if(r===`static`&&n&&(e[`--app-shell-footer-position`]=`sticky`,e[`--app-shell-footer-grid-column`]=`1 / -1`,e[`--app-shell-footer-grid-row`]=`3`),wu(i)){let t=E(Cu(i));e[`--app-shell-footer-height`]=t,a&&(e[`--app-shell-footer-offset`]=t)}Tu(i)&&(i.base!==void 0&&(e[`--app-shell-footer-height`]=E(i.base),a&&(e[`--app-shell-footer-offset`]=E(i.base))),v(i).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-footer-height`]=E(i[e]),a&&(t[e][`--app-shell-footer-offset`]=E(i[e])))})),n?.collapsed&&(e[`--app-shell-footer-transform`]=`translateY(var(--app-shell-footer-height))`,r===`fixed`&&(e[`--app-shell-footer-offset`]=`0px !important`))}function Ou({baseStyles:e,minMediaStyles:t,header:n,mode:r}){let i=n?.height,a=r===`static`?!0:n?.offset??!0;if(r===`static`&&n&&(e[`--app-shell-header-position`]=`sticky`,e[`--app-shell-header-grid-column`]=`1 / -1`,e[`--app-shell-header-grid-row`]=`1`),wu(i)){let t=E(Cu(i));e[`--app-shell-header-height`]=t,a&&(e[`--app-shell-header-offset`]=t)}Tu(i)&&(i.base!==void 0&&(e[`--app-shell-header-height`]=E(i.base),a&&(e[`--app-shell-header-offset`]=E(i.base))),v(i).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-header-height`]=E(i[e]),a&&(t[e][`--app-shell-header-offset`]=E(i[e])))})),n?.collapsed&&(e[`--app-shell-header-transform`]=`translateY(calc(var(--app-shell-header-height) * -1))`,r===`fixed`&&(e[`--app-shell-header-offset`]=`0px !important`))}function ku({baseStyles:e,minMediaStyles:t,maxMediaStyles:n,navbar:r,theme:i,mode:a}){let o=r?.width,s=`translateX(calc(var(--app-shell-navbar-width) * -1))`,c=`translateX(var(--app-shell-navbar-width))`;if(r?.breakpoint!==void 0&&!r?.collapsed?.mobile&&(n[r?.breakpoint]=n[r?.breakpoint]||{},n[r?.breakpoint][`--app-shell-navbar-offset`]=`0px`,n[r?.breakpoint][`--app-shell-navbar-width`]=`100%`,a===`static`&&(n[r?.breakpoint][`--app-shell-navbar-grid-width`]=`0px`)),wu(o)){let t=E(Cu(o));e[`--app-shell-navbar-width`]=t,e[`--app-shell-navbar-offset`]=t,a===`static`&&(e[`--app-shell-navbar-grid-width`]=t)}if(Tu(o)&&(o.base!==void 0&&(e[`--app-shell-navbar-width`]=E(o.base),e[`--app-shell-navbar-offset`]=E(o.base),a===`static`&&(e[`--app-shell-navbar-grid-width`]=E(o.base))),v(o).forEach(e=>{e!==`base`&&(t[e]=t[e]||{},t[e][`--app-shell-navbar-width`]=E(o[e]),t[e][`--app-shell-navbar-offset`]=E(o[e]),a===`static`&&(t[e][`--app-shell-navbar-grid-width`]=E(o[e])))})),r?.breakpoint!==void 0&&a===`static`&&(t[r.breakpoint]=t[r.breakpoint]||{},t[r.breakpoint][`--app-shell-navbar-position`]=`sticky`,t[r.breakpoint][`--app-shell-navbar-grid-row`]=`2`,t[r.breakpoint][`--app-shell-navbar-grid-column`]=`1`,t[r.breakpoint][`--app-shell-main-column-start`]=`2`),r?.collapsed?.desktop){let e=r.breakpoint;t[e]=t[e]||{},t[e][`--app-shell-navbar-transform`]=s,t[e][`--app-shell-navbar-transform-rtl`]=c,a===`fixed`?t[e][`--app-shell-navbar-offset`]=`0px !important`:(t[e][`--app-shell-navbar-width`]=`0px`,t[e][`--app-shell-navbar-display`]=`none`,t[e][`--app-shell-main-column-start`]=`1`)}if(r?.collapsed?.mobile){let e=ge(r.breakpoint,i.breakpoints)-.1;n[e]=n[e]||{},n[e][`--app-shell-navbar-width`]=`100%`,n[e][`--app-shell-navbar-offset`]=`0px`,a===`static`&&(n[e][`--app-shell-navbar-grid-width`]=`0px`),n[e][`--app-shell-navbar-transform`]=s,n[e][`--app-shell-navbar-transform-rtl`]=c}}function Au(e){return Number(e)===0?`0px`:ue(e)}function ju({padding:e,baseStyles:t,minMediaStyles:n}){wu(e)&&(t[`--app-shell-padding`]=Au(Cu(e))),Tu(e)&&(e.base&&(t[`--app-shell-padding`]=Au(e.base)),v(e).forEach(t=>{t!==`base`&&(n[t]=n[t]||{},n[t][`--app-shell-padding`]=Au(e[t]))}))}function Mu({navbar:e,header:t,footer:n,aside:r,padding:i,theme:a,mode:o}){let s={},c={},l={};o===`static`&&(l[`--app-shell-main-grid-column`]=`1 / -1`,l[`--app-shell-main-grid-row`]=`2`),ku({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,navbar:e,theme:a,mode:o}),Eu({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,aside:r,theme:a,mode:o}),Ou({baseStyles:l,minMediaStyles:s,header:t,mode:o}),Du({baseStyles:l,minMediaStyles:s,footer:n,mode:o}),ju({baseStyles:l,minMediaStyles:s,padding:i});let u=P(v(s),a.breakpoints).map(e=>({query:`(min-width: ${D(e.px)})`,styles:s[e.value]})),d=P(v(c),a.breakpoints).map(e=>({query:`(max-width: ${D(e.px)})`,styles:c[e.value]}));return{baseStyles:l,media:[...u,...d]}}function Nu({navbar:e,header:t,aside:n,footer:r,padding:i,mode:a,selector:o}){let s=Sn(),c=Zt(),{media:l,baseStyles:u}=Mu({navbar:e,header:t,footer:r,aside:n,padding:i,theme:s,mode:a});return(0,z.jsx)(tr,{media:l,styles:u,selector:o||c.cssVariablesSelector})}function Pu({transitionDuration:e,disabled:t}){let[n,r]=(0,A.useState)(!0),i=(0,A.useRef)(-1),a=(0,A.useRef)(-1);return Be(`resize`,()=>{r(!0),clearTimeout(i.current),i.current=window.setTimeout(()=>(0,A.startTransition)(()=>{r(!1)}),200)}),we(()=>{r(!0),clearTimeout(a.current),a.current=window.setTimeout(()=>(0,A.startTransition)(()=>{r(!1)}),e||0)},[t,e]),n}var Fu={withBorder:!0,padding:0,transitionDuration:200,transitionTimingFunction:`ease`,zIndex:se(`app`),mode:`fixed`},Iu=L((e,{transitionDuration:t,transitionTimingFunction:n})=>({root:{"--app-shell-transition-duration":`${t}ms`,"--app-shell-transition-timing-function":n}})),Lu=H(e=>{let t=B(`AppShell`,Fu,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,navbar:c,withBorder:l,padding:u,transitionDuration:d,transitionTimingFunction:f,header:p,zIndex:m,layout:h,disabled:g,aside:_,footer:v,offsetScrollbars:y=!0,mode:b,mod:x,attributes:S,id:C,...w}=t,T=V({name:`AppShell`,classes:gu,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:S,vars:s,varsResolver:Iu}),E=Pu({disabled:g,transitionDuration:d}),D=ze(C);return(0,z.jsxs)(mu,{value:{getStyles:T,withBorder:l,zIndex:m,disabled:g,offsetScrollbars:y,mode:b},children:[(0,z.jsx)(Nu,{navbar:c,header:p,aside:_,footer:v,padding:u,mode:b,selector:b===`static`?`#${D}`:void 0}),(0,z.jsx)(U,{...T(`root`),id:D,mod:[{resizing:E,layout:h,disabled:g,mode:b},x],...w})]})});Lu.classes=gu,Lu.varsResolver=Iu,Lu.displayName=`@mantine/core/AppShell`,Lu.Navbar=xu,Lu.Header=yu,Lu.Main=bu,Lu.Aside=_u,Lu.Footer=vu,Lu.Section=Su;function Ru(e){return typeof e==`string`?{value:e,label:e}:typeof e==`object`&&`value`in e&&!(`label`in e)?{value:e.value,label:`${e.value}`,disabled:e.disabled}:typeof e==`object`&&`group`in e?{group:e.group,items:e.items.map(e=>Ru(e))}:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?{value:e,label:`${e}`}:e}function zu(e){return e?e.map(e=>Ru(e)):[]}function Bu(e){return e.reduce((e,t)=>`group`in t?{...e,...Bu(t.items)}:(e[`${t.value}`]=t,e),{})}var Vu={dropdown:`m_88b62a41`,search:`m_985517d8`,options:`m_b2821a6e`,option:`m_92253aa5`,empty:`m_2530cd1d`,header:`m_858f94bd`,footer:`m_82b967cb`,group:`m_254f3e4f`,groupLabel:`m_2bb2e9e5`,chevron:`m_2943220b`,optionsDropdownOption:`m_390b5f4`,optionsDropdownCheckIcon:`m_8ee53fc2`,optionsDropdownCheckPlaceholder:`m_a530ee0a`},Hu={error:null},Uu=L((e,{size:t,color:n})=>({chevron:{"--combobox-chevron-size":N(t,`combobox-chevron-size`),"--combobox-chevron-color":n?Bt(n,e):void 0}})),Wu=H(e=>{let t=B(`ComboboxChevron`,Hu,e),{size:n,error:r,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,attributes:u,mod:d,...f}=t,p=V({name:`ComboboxChevron`,classes:Vu,props:t,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,varsResolver:Uu,attributes:u,rootSelector:`chevron`});return(0,z.jsx)(U,{component:`svg`,...f,...p(`chevron`),size:n,viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,mod:[`combobox-chevron`,{error:r},d],children:(0,z.jsx)(`path`,{d:`M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})});Wu.classes=Vu,Wu.varsResolver=Uu,Wu.displayName=`@mantine/core/ComboboxChevron`;var[Gu,Ku]=M(`Combobox component was not found in tree`);function qu({onMouseDown:e,onClick:t,onClear:n,...r}){return(0,z.jsx)(eu.ClearButton,{tabIndex:-1,"aria-hidden":!0,...r,onMouseDown:t=>{t.preventDefault(),e?.(t)},onClick:e=>{n(),t?.(e)}})}qu.displayName=`@mantine/core/ComboboxClearButton`;var Ju=H(e=>{let{classNames:t,styles:n,className:r,style:i,hidden:a,...o}=B(`ComboboxDropdown`,null,e),s=Ku();return(0,z.jsx)(Zs.Dropdown,{...o,role:`presentation`,"data-hidden":a||void 0,"data-floating-height":s.floatingHeight||void 0,...s.getStyles(`dropdown`,{className:r,style:i,classNames:t,styles:n})})});Ju.classes=Vu,Ju.displayName=`@mantine/core/ComboboxDropdown`;var Yu={refProp:`ref`},Xu=H(e=>{let{children:t,refProp:n,ref:r}=B(`ComboboxDropdownTarget`,Yu,e);if(Ku(),!j(t))throw Error(`Combobox.DropdownTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return(0,z.jsx)(Zs.Target,{ref:r,refProp:n,children:t})});Xu.displayName=`@mantine/core/ComboboxDropdownTarget`;var Zu=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`ComboboxEmpty`,null,e),s=Ku();return(0,z.jsx)(U,{...s.getStyles(`empty`,{className:n,classNames:t,styles:i,style:r}),...o})});Zu.classes=Vu,Zu.displayName=`@mantine/core/ComboboxEmpty`;function J({onKeyDown:e,onClick:t,withKeyboardNavigation:n,withAriaAttributes:r,withExpandedAttribute:i,targetType:a,autoComplete:o}){let s=Ku(),[c,l]=(0,A.useState)(null),u=t=>{if(e?.(t),!s.readOnly&&n){if(t.nativeEvent.isComposing)return;if(t.nativeEvent.code===`ArrowDown`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectNextOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`ArrowUp`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectPreviousOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`Enter`||t.nativeEvent.code===`NumpadEnter`){if(t.nativeEvent.keyCode===229)return;let e=s.store.getSelectedOptionIndex();s.store.dropdownOpened&&e!==-1?(t.preventDefault(),s.store.clickSelectedOption()):a===`button`&&(t.preventDefault(),s.store.openDropdown(`keyboard`))}t.key===`Escape`&&s.store.closeDropdown(`keyboard`),t.nativeEvent.code===`Space`&&a===`button`&&(t.preventDefault(),s.store.toggleDropdown(`keyboard`))}},d=r?{...i?{role:`combobox`}:{},"aria-haspopup":`listbox`,"aria-expanded":i?!!(s.store.listId&&s.store.dropdownOpened):void 0,"aria-controls":s.store.dropdownOpened&&s.store.listId?s.store.listId:void 0,"aria-activedescendant":s.store.dropdownOpened&&c||void 0,autoComplete:o,"data-expanded":s.store.dropdownOpened||void 0,"data-mantine-stop-propagation":s.store.dropdownOpened||void 0}:{},f=e=>{a===`button`&&e.currentTarget.focus(),t?.(e)};return{...d,onKeyDown:u,onClick:f}}var Qu={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},Y=H(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=B(`ComboboxEventsTarget`,Qu,e),u=bt(t);if(!u)throw Error(`Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let d=Ku(),f=J({targetType:o,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:a,onKeyDown:u.props.onKeyDown,onClick:u.props.onClick,autoComplete:s});return(0,A.cloneElement)(u,{...f,...l,[n]:Ue(c,d.store.targetRef,ht(u))})});Y.displayName=`@mantine/core/ComboboxEventsTarget`;var X=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`ComboboxFooter`,null,e),s=Ku();return(0,z.jsx)(U,{...s.getStyles(`footer`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});X.classes=Vu,X.displayName=`@mantine/core/ComboboxFooter`;var Z=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,children:o,label:s,id:c,...l}=B(`ComboboxGroup`,null,e),u=Ku(),d=ze(c),f=s!=null&&s!==!1&&s!==``;return(0,z.jsxs)(U,{role:`group`,"aria-labelledby":f?d:void 0,...u.getStyles(`group`,{className:n,classNames:t,style:r,styles:i}),...l,children:[f&&(0,z.jsx)(`div`,{id:d,...u.getStyles(`groupLabel`,{classNames:t,styles:i}),children:s}),o]})});Z.classes=Vu,Z.displayName=`@mantine/core/ComboboxGroup`;var $u=H(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=B(`ComboboxHeader`,null,e),s=Ku();return(0,z.jsx)(U,{...s.getStyles(`header`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});$u.classes=Vu,$u.displayName=`@mantine/core/ComboboxHeader`;function ed({value:e,valuesDivider:t=`,`,...n}){return(0,z.jsx)(`input`,{type:`hidden`,value:Array.isArray(e)?e.join(t):e?`${e}`:``,...n})}ed.displayName=`@mantine/core/ComboboxHiddenInput`;var td=H(e=>{let t=B(`ComboboxOption`,null,e),{classNames:n,className:r,style:i,styles:a,vars:o,onClick:s,id:c,active:l,onMouseDown:u,onMouseOver:d,disabled:f,selected:p,mod:m,...h}=t,g=Ku(),_=(0,A.useId)(),v=c||_;return(0,z.jsx)(U,{...g.getStyles(`option`,{className:r,classNames:n,styles:a,style:i}),...h,id:v,mod:[`combobox-option`,{"combobox-active":l,"combobox-disabled":f,"combobox-selected":p},m],role:`option`,onClick:e=>{f?e.preventDefault():(g.onOptionSubmit?.(t.value,t),s?.(e))},onMouseDown:e=>{e.preventDefault(),u?.(e)},onMouseOver:e=>{g.resetSelectionOnOptionHover&&g.store.resetSelectedOption(),d?.(e)}})});td.classes=Vu,td.displayName=`@mantine/core/ComboboxOption`;var nd=H(e=>{let{classNames:t,className:n,style:r,styles:i,id:a,onMouseDown:o,labelledBy:s,...c}=B(`ComboboxOptions`,null,e),l=Ku(),u=ze(a);return(0,A.useEffect)(()=>{l.store.setListId(u)},[u]),(0,z.jsx)(U,{...l.getStyles(`options`,{className:n,style:r,classNames:t,styles:i}),...c,id:u,role:`listbox`,"aria-labelledby":s,onMouseDown:e=>{e.preventDefault(),o?.(e)}})});nd.classes=Vu,nd.displayName=`@mantine/core/ComboboxOptions`;var rd={withAriaAttributes:!0,withKeyboardNavigation:!0},id=H(e=>{let{classNames:t,styles:n,unstyled:r,vars:i,withAriaAttributes:a,onKeyDown:o,onClick:s,withKeyboardNavigation:c,size:l,ref:u,...d}=B(`ComboboxSearch`,rd,e),f=Ku(),p=f.getStyles(`search`),m=J({targetType:`input`,withAriaAttributes:a,withKeyboardNavigation:c,withExpandedAttribute:!1,onKeyDown:o,onClick:s,autoComplete:`off`});return(0,z.jsx)(eu,{ref:Ue(u,f.store.searchRef),classNames:[{input:p.className},t],styles:[{input:p.style},n],size:l||f.size,...m,...d,__staticSelector:`Combobox`})});id.classes=Vu,id.displayName=`@mantine/core/ComboboxSearch`;var ad={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},od=H(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=B(`ComboboxTarget`,ad,e),u=bt(t);if(!u)throw Error(`Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let d=Ku(),f=J({targetType:o,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:a,onKeyDown:u.props.onKeyDown,onClick:u.props.onClick,autoComplete:s}),p=(0,A.cloneElement)(u,{...f,...l});return(0,z.jsx)(Zs.Target,{refProp:n,ref:Ue(c,d.store.targetRef),children:p})});od.displayName=`@mantine/core/ComboboxTarget`;function sd(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].hasAttribute(`data-combobox-disabled`))return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].hasAttribute(`data-combobox-disabled`))return e}return e}function cd(e,t,n){for(let n=e+1;n<t.length;n+=1)if(!t[n].hasAttribute(`data-combobox-disabled`))return n;if(n){for(let e=0;e<t.length;e+=1)if(!t[e].hasAttribute(`data-combobox-disabled`))return e}return e}function ld(e){for(let t=0;t<e.length;t+=1)if(!e[t].hasAttribute(`data-combobox-disabled`))return t;return-1}function ud({defaultOpened:e,opened:t,onOpenedChange:n,onDropdownClose:r,onDropdownOpen:i,loop:a=!0,scrollBehavior:o=`instant`}={}){let[s,c]=We({value:t,defaultValue:e,finalValue:!1,onChange:n}),l=(0,A.useRef)(null),u=(0,A.useRef)(-1),d=(0,A.useRef)(null),f=(0,A.useRef)(null),p=(0,A.useRef)(-1),m=(0,A.useRef)(-1),h=(0,A.useRef)(-1),g=(0,A.useCallback)((e=`unknown`)=>{s||(c(!0),i?.(e))},[c,i,s]),_=(0,A.useCallback)((e=`unknown`)=>{s&&(c(!1),r?.(e))},[c,r,s]),v=(0,A.useCallback)((e=`unknown`)=>{s?_(e):g(e)},[_,g,s]),y=(0,A.useCallback)(()=>{let e=yt(f.current),t=_t(`#${l.current} [data-combobox-selected]`,e);t?.removeAttribute(`data-combobox-selected`),t?.removeAttribute(`aria-selected`)},[]),b=(0,A.useCallback)(e=>{let t=yt(f.current),n=_t(`#${l.current}`,t),r=n?vt(`[data-combobox-option]`,n):null;if(!r)return null;let i=e>=r.length?0:e<0?r.length-1:e;return u.current=i,r?.[i]&&!r[i].hasAttribute(`data-combobox-disabled`)?(y(),r[i].setAttribute(`data-combobox-selected`,`true`),r[i].setAttribute(`aria-selected`,`true`),r[i].scrollIntoView({block:`nearest`,behavior:o}),r[i].id):null},[o,y]),x=(0,A.useCallback)(()=>{let e=yt(f.current),t=_t(`#${l.current} [data-combobox-active]`,e);if(t){let n=vt(`#${l.current} [data-combobox-option]`,e).findIndex(e=>e===t);return b(n)}return b(0)},[b]),S=(0,A.useCallback)(()=>{let e=yt(f.current),t=vt(`#${l.current} [data-combobox-option]`,e);return b(cd(u.current,t,a))},[b,a]),C=(0,A.useCallback)(()=>{let e=yt(f.current),t=vt(`#${l.current} [data-combobox-option]`,e);return b(sd(u.current,t,a))},[b,a]),w=(0,A.useCallback)(()=>{let e=yt(f.current),t=vt(`#${l.current} [data-combobox-option]`,e);return b(ld(t))},[b]),T=(0,A.useCallback)((e=`selected`,t)=>{if(typeof e==`number`){u.current=e;let n=yt(f.current),r=vt(`#${l.current} [data-combobox-option]`,n);t?.scrollIntoView&&r[e]?.scrollIntoView({block:`nearest`,behavior:o});return}h.current=window.setTimeout(()=>{let n=yt(f.current),r=vt(`#${l.current} [data-combobox-option]`,n),i=r.findIndex(t=>t.hasAttribute(`data-combobox-${e}`));u.current=i,t?.scrollIntoView&&r[i]?.scrollIntoView({block:`nearest`,behavior:o})},0)},[]),E=(0,A.useCallback)(()=>{u.current=-1,y()},[y]),D=(0,A.useCallback)(()=>{let e=yt(f.current);(vt(`#${l.current} [data-combobox-option]`,e)?.[u.current])?.click()},[]),O=(0,A.useCallback)(e=>{l.current=e},[]),k=(0,A.useCallback)(()=>{p.current=window.setTimeout(()=>d.current?.focus(),0)},[]),j=(0,A.useCallback)(()=>{m.current=window.setTimeout(()=>f.current?.focus(),0)},[]),M=(0,A.useCallback)(()=>u.current,[]);return(0,A.useEffect)(()=>()=>{window.clearTimeout(p.current),window.clearTimeout(m.current),window.clearTimeout(h.current)},[]),{dropdownOpened:s,openDropdown:g,closeDropdown:_,toggleDropdown:v,selectedOptionIndex:u.current,getSelectedOptionIndex:M,selectOption:b,selectFirstOption:w,selectActiveOption:x,selectNextOption:S,selectPreviousOption:C,resetSelectedOption:E,updateSelectedOptionIndex:T,listId:l.current,setListId:O,clickSelectedOption:D,searchRef:d,focusSearchInput:k,targetRef:f,focusTarget:j}}var dd={keepMounted:!0,keepMountedMode:`display-none`,withinPortal:!0,resetSelectionOnOptionHover:!1,width:`target`,transitionProps:{transition:`fade`,duration:0},size:`sm`},fd=L((e,{size:t,dropdownPadding:n})=>({options:{"--combobox-option-fz":fe(t),"--combobox-option-padding":N(t,`combobox-option-padding`)},dropdown:{"--combobox-padding":n===void 0?void 0:E(n),"--combobox-option-fz":fe(t),"--combobox-option-padding":N(t,`combobox-option-padding`)}})),Q=e=>{let t=B(`Combobox`,dd,e),{classNames:n,styles:r,unstyled:i,children:a,store:o,vars:s,onOptionSubmit:c,onClose:l,size:u,dropdownPadding:d,resetSelectionOnOptionHover:f,__staticSelector:p,readOnly:m,attributes:h,floatingHeight:g,middlewares:_,...v}=t,y=g===`viewport`?{..._,flip:!1,size:{...typeof _?.size==`object`?_.size:{},padding:typeof _?.size==`object`&&_.size.padding!==void 0?_.size.padding:10,apply:({availableHeight:e,availableWidth:t,elements:n,...r})=>{n.floating.style.setProperty(`--combobox-floating-max-height`,`${e}px`);let i=_?.size;typeof i==`object`&&i.apply?i.apply({availableHeight:e,availableWidth:t,elements:n,...r}):i&&Object.assign(n.floating.style,{maxWidth:`${t}px`,maxHeight:`${e}px`})}}}:_,b=ud(),x=o||b,S=V({name:p||`Combobox`,classes:Vu,props:t,classNames:n,styles:r,unstyled:i,attributes:h,vars:s,varsResolver:fd}),C=()=>{l?.(),x.closeDropdown()};return(0,z.jsx)(Gu,{value:{getStyles:S,store:x,onOptionSubmit:c,size:u,resetSelectionOnOptionHover:f,readOnly:m,floatingHeight:g},children:(0,z.jsx)(Zs,{opened:x.dropdownOpened,...v,middlewares:y,onChange:e=>!e&&C(),withRoles:!1,unstyled:i,children:a})})};Q.extend=e=>e,Q.classes=Vu,Q.varsResolver=fd,Q.displayName=`@mantine/core/Combobox`,Q.Target=od,Q.Dropdown=Ju,Q.Options=nd,Q.Option=td,Q.Search=id,Q.Empty=Zu,Q.Chevron=Wu,Q.Footer=X,Q.Header=$u,Q.EventsTarget=Y,Q.DropdownTarget=Xu,Q.Group=Z,Q.ClearButton=qu,Q.HiddenInput=ed;function pd({size:e,style:t,...n}){let r=e===void 0?t:{width:E(e),height:E(e),...t};return(0,z.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,z.jsx)(`path`,{d:`M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}function md(e){return`group`in e}function hd({options:e,search:t,limit:n}){let r=t.trim().toLowerCase(),i=[];for(let a=0;a<e.length;a+=1){let o=e[a];if(i.length===n)return i;md(o)&&i.push({group:o.group,items:hd({options:o.items,search:t,limit:n-i.length})}),md(o)||o.label.toLowerCase().includes(r)&&i.push(o)}return i}function gd(e){if(e.length===0)return!0;for(let t of e)if(!(`group`in t)||t.items.length>0)return!1;return!0}function _d(e,t=new Set){if(Array.isArray(e))for(let n of e)if(md(n))_d(n.items,t);else{if(n.value===void 0)throw Error(`[@mantine/core] Each option must have value property`);if(t.has(n.value))throw Error(`[@mantine/core] Duplicate options are not supported. Option with value "${n.value}" was provided more than once`);t.add(n.value)}}function vd(e,t){return Array.isArray(e)?e.includes(t):e===t}function yd({data:e,withCheckIcon:t,withAlignedLabels:n,value:r,checkIconPosition:i,unstyled:a,renderOption:o}){if(!md(e)){let s=vd(r,e.value),c=t&&(s?(0,z.jsx)(pd,{className:Vu.optionsDropdownCheckIcon}):n?(0,z.jsx)(`div`,{className:Vu.optionsDropdownCheckPlaceholder}):null),l=(0,z.jsxs)(z.Fragment,{children:[i===`left`&&c,(0,z.jsx)(`span`,{children:e.label}),i===`right`&&c]});return(0,z.jsx)(Q.Option,{value:e.value,disabled:e.disabled,className:St({[Vu.optionsDropdownOption]:!a}),"data-reverse":i===`right`||void 0,"data-checked":s||void 0,"aria-selected":s,active:s,children:typeof o==`function`?o({option:e,checked:s}):l})}let s=e.items.map(e=>(0,z.jsx)(yd,{data:e,value:r,unstyled:a,withCheckIcon:t,withAlignedLabels:n,checkIconPosition:i,renderOption:o},`${e.value}`));return(0,z.jsx)(Q.Group,{label:e.group,children:s})}function bd({data:e,hidden:t,hiddenWhenEmpty:n,filter:r,search:i,limit:a,maxDropdownHeight:o,floatingHeight:s,withScrollArea:c=!0,filterOptions:l=!0,withCheckIcon:u=!1,withAlignedLabels:d=!1,value:f,checkIconPosition:p,nothingFoundMessage:m,unstyled:h,labelId:g,renderOption:_,scrollAreaProps:v,"aria-label":y}){let b=Ku();_d(e);let x=typeof i==`string`?(r||hd)({options:e,search:l?i:``,limit:a??1/0}):e,S=gd(x),C=x.map((e,t)=>(0,z.jsx)(yd,{data:e,withCheckIcon:u,withAlignedLabels:d,value:f,checkIconPosition:p,unstyled:h,renderOption:_},md(e)?`group-${typeof e.group==`string`?e.group:t}`:`${e.value}`));return(0,z.jsx)(Q.Dropdown,{hidden:t||n&&S,"data-composed":!0,children:(0,z.jsxs)(Q.Options,{labelledBy:g,"aria-label":y,children:[c?(0,z.jsx)(os.Autosize,{mah:(s??b.floatingHeight)===`viewport`?`var(--combobox-floating-options-max-height)`:o??220,type:`scroll`,scrollbarSize:`var(--combobox-padding)`,offsetScrollbars:`y`,...v,children:C}):C,S&&m&&(0,z.jsx)(Q.Empty,{children:m})]})})}var xd={root:`m_347db0ec`,"root--dot":`m_fbd81e3d`,label:`m_5add502a`,section:`m_91fdda9b`},Sd=L((e,{radius:t,color:n,gradient:r,variant:i,size:a,autoContrast:o,circle:s})=>{let c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:o});return{root:{"--badge-height":N(a,`badge-height`),"--badge-padding-x":N(a,`badge-padding-x`),"--badge-fz":N(a,`badge-fz`),"--badge-radius":s||t===void 0?void 0:de(t),"--badge-bg":n||i?c.background:void 0,"--badge-color":n||i?c.color:void 0,"--badge-bd":n||i?c.border:void 0,"--badge-dot-color":i===`dot`?Bt(n,e):void 0}}}),Cd=Nr(e=>{let t=B(`Badge`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,radius:c,color:l,gradient:u,leftSection:d,rightSection:f,children:p,variant:m,fullWidth:h,autoContrast:g,circle:_,mod:v,attributes:y,...b}=t,x=V({name:`Badge`,props:t,classes:xd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:y,vars:s,varsResolver:Sd});return(0,z.jsxs)(U,{variant:m,mod:[{block:h,circle:_,"with-right-section":!!f,"with-left-section":!!d},v],...x(`root`,{variant:m}),...b,children:[d&&(0,z.jsx)(`span`,{...x(`section`),"data-position":`left`,children:d}),(0,z.jsx)(`span`,{...x(`label`),children:p}),f&&(0,z.jsx)(`span`,{...x(`section`),"data-position":`right`,children:f})]})});Cd.classes=xd,Cd.varsResolver=Sd,Cd.displayName=`@mantine/core/Badge`;var wd={root:`m_fea6bf1a`,burger:`m_d4fb9cad`},Td=L((e,{color:t,size:n,lineSize:r,transitionDuration:i,transitionTimingFunction:a})=>({root:{"--burger-color":t?Bt(t,e):void 0,"--burger-size":N(n,`burger-size`),"--burger-line-size":r?E(r):void 0,"--burger-transition-duration":i===void 0?void 0:`${i}ms`,"--burger-transition-timing-function":a}})),Ed=H(e=>{let t=B(`Burger`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,opened:c,children:l,transitionDuration:u,transitionTimingFunction:d,lineSize:f,attributes:p,...m}=t,h=V({name:`Burger`,classes:wd,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:s,varsResolver:Td});return(0,z.jsxs)(us,{...h(`root`),...m,children:[(0,z.jsx)(U,{mod:[`reduce-motion`,{opened:c}],...h(`burger`)}),l]})});Ed.classes=wd,Ed.varsResolver=Td,Ed.displayName=`@mantine/core/Burger`;var Dd={root:`m_77c9d27d`,inner:`m_80f1301b`,label:`m_811560b9`,section:`m_a74036a`,loader:`m_a25b86ee`,group:`m_80d6d844`,groupSection:`m_70be2a01`},Od={orientation:`horizontal`},kd=L((e,{borderWidth:t})=>({group:{"--button-border-width":E(t)}})),Ad=H(e=>{let t=B(`ButtonGroup`,Od,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,orientation:s,vars:c,borderWidth:l,mod:u,attributes:d,...f}=B(`ButtonGroup`,Od,e),p=V({name:`ButtonGroup`,props:t,classes:Dd,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:c,varsResolver:kd,rootSelector:`group`});return(0,z.jsx)(U,{...p(`group`),mod:[{orientation:s},u],role:`group`,...f})});Ad.classes=Dd,Ad.varsResolver=kd,Ad.displayName=`@mantine/core/ButtonGroup`;var jd=L((e,{radius:t,color:n,gradient:r,variant:i,autoContrast:a,size:o})=>{let s=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:a});return{groupSection:{"--section-height":N(o,`section-height`),"--section-padding-x":N(o,`section-padding-x`),"--section-fz":o?.includes(`compact`)?fe(o.replace(`compact-`,``)):fe(o),"--section-radius":t===void 0?void 0:de(t),"--section-bg":n||i?s.background:void 0,"--section-color":s.color,"--section-bd":n||i?s.border:void 0}}}),Md=H(e=>{let t=B(`ButtonGroupSection`,null,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,vars:s,gradient:c,radius:l,autoContrast:u,attributes:d,...f}=t,p=V({name:`ButtonGroupSection`,props:t,classes:Dd,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:s,varsResolver:jd,rootSelector:`groupSection`});return(0,z.jsx)(U,{...p(`groupSection`),...f})});Md.classes=Dd,Md.varsResolver=jd,Md.displayName=`@mantine/core/ButtonGroupSection`;var Nd={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${E(1)}))`},out:{opacity:0,transform:`translate(-50%, -200%)`},common:{transformOrigin:`center`},transitionProperty:`transform, opacity`},Pd=L((e,{radius:t,color:n,gradient:r,variant:i,size:a,justify:o,autoContrast:s})=>{let c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:s});return{root:{"--button-justify":o,"--button-height":N(a,`button-height`),"--button-padding-x":N(a,`button-padding-x`),"--button-fz":a?.includes(`compact`)?fe(a.replace(`compact-`,``)):fe(a),"--button-radius":t===void 0?void 0:de(t),"--button-bg":n||i?c.background:void 0,"--button-hover":n||i?c.hover:void 0,"--button-color":c.color,"--button-bd":n||i?c.border:void 0,"--button-hover-color":n||i?c.hoverColor:void 0}}}),Fd=Nr(e=>{let t=B(`Button`,null,e),{style:n,vars:r,className:i,color:a,disabled:o,children:s,leftSection:c,rightSection:l,fullWidth:u,variant:d,radius:f,loading:p,loaderProps:m,gradient:h,classNames:g,styles:_,unstyled:v,"data-disabled":y,autoContrast:b,mod:x,attributes:S,...C}=t,w=V({name:`Button`,props:t,classes:Dd,className:i,style:n,classNames:g,styles:_,unstyled:v,attributes:S,vars:r,varsResolver:Pd}),T=!!c,E=!!l;return(0,z.jsxs)(us,{...w(`root`,{active:!o&&!p&&!y}),unstyled:v,variant:d,disabled:o||p,mod:[{disabled:o||y,loading:p,block:u,"with-left-section":T,"with-right-section":E},x],...C,children:[typeof p==`boolean`&&(0,z.jsx)(Fs,{mounted:p,transition:Nd,duration:150,children:e=>(0,z.jsx)(U,{component:`span`,...w(`loader`,{style:e}),"aria-hidden":!0,children:(0,z.jsx)(ac,{color:`var(--button-color)`,size:`calc(var(--button-height) / 1.8)`,...m})})}),(0,z.jsxs)(`span`,{...w(`inner`),children:[c&&(0,z.jsx)(U,{component:`span`,...w(`section`),mod:{position:`left`},children:c}),(0,z.jsx)(U,{component:`span`,mod:{loading:p},...w(`label`),children:s}),l&&(0,z.jsx)(U,{component:`span`,...w(`section`),mod:{position:`right`},children:l})]})]})});Fd.classes=Dd,Fd.varsResolver=Pd,Fd.displayName=`@mantine/core/Button`,Fd.Group=Ad,Fd.GroupSection=Md;function Id(e){let t=e.currentTarget;return yt(t).activeElement!==t}function Ld(e,t){let n=t.trim().toLowerCase();if(n===``)return;let r=Object.values(e).filter(e=>!e.disabled&&e.label.trim().toLowerCase()===n);return r.length===1?r[0]:void 0}var Rd={root:`m_f0824112`,description:`m_57492dcc`,section:`m_690090b5`,label:`m_1f6ac4c4`,body:`m_f07af9d2`,children:`m_e17b862f`,chevron:`m_1fd8a00b`},zd=L((e,{variant:t,color:n,childrenOffset:r,autoContrast:i})=>{let a=e.variantColorResolver({color:n||e.primaryColor,theme:e,variant:t||`light`,autoContrast:i});return{root:{"--nl-bg":n||t?a.background:void 0,"--nl-hover":n||t?a.hover:void 0,"--nl-color":n||t?a.color:void 0},children:{"--nl-offset":ue(r)}}}),Bd=Nr(e=>{let t=B(`NavLink`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,opened:c,defaultOpened:l,onChange:u,children:d,active:f,disabled:p,leftSection:m,rightSection:h,label:g,description:_,disableRightSectionRotation:v,noWrap:y,childrenOffset:b,autoContrast:x,mod:S,attributes:C,onClick:w,onKeyDown:T,keepMounted:E,...D}=t,O=V({name:`NavLink`,props:t,classes:Rd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:C,vars:s,varsResolver:zd}),[k,A]=We({value:c,defaultValue:l,finalValue:!1,onChange:u}),j=!!d,M=e=>{w?.(e),j&&(e.preventDefault(),A(!k))};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(us,{...O(`root`),component:`a`,onClick:M,onKeyDown:e=>{T?.(e),e.nativeEvent.code===`Space`&&j&&(e.preventDefault(),A(!k))},unstyled:o,mod:[{disabled:p,active:f,expanded:k},S],...D,children:[m&&(0,z.jsx)(U,{component:`span`,...O(`section`),mod:{position:`left`},children:m}),(0,z.jsxs)(U,{...O(`body`),mod:{"no-wrap":y},children:[(0,z.jsx)(U,{component:`span`,...O(`label`),children:g}),(0,z.jsx)(U,{component:`span`,mod:{active:f},...O(`description`),children:_})]}),(j||h!==void 0)&&(0,z.jsx)(U,{...O(`section`),component:`span`,mod:{rotate:k&&!v,position:`right`},children:j&&h===void 0?(0,z.jsx)(cu,{...O(`chevron`)}):h})]}),j&&(0,z.jsx)(Ur,{expanded:k,keepMounted:E,...O(`collapse`),children:(0,z.jsx)(`div`,{...O(`children`),children:d})})]})});Bd.classes=Rd,Bd.varsResolver=zd,Bd.displayName=`@mantine/core/NavLink`;var Vd={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},Hd={withItemsBorders:!0},Ud=L((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:de(t),"--sc-color":n?Bt(n,e):void 0,"--sc-shadow":n?void 0:`var(--mantine-shadow-xs)`,"--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":a,"--sc-padding":N(i,`sc-padding`),"--sc-font-size":fe(i)}})),Wd=Mr(e=>{let t=B(`SegmentedControl`,Hd,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,data:c,value:l,defaultValue:u,onChange:d,size:f,name:p,disabled:m,readOnly:h,fullWidth:g,orientation:_,radius:v,color:y,transitionDuration:b,transitionTimingFunction:x,variant:S,autoContrast:C,withItemsBorders:w,mod:T,attributes:E,ref:D,...O}=t,k=V({name:`SegmentedControl`,props:t,classes:Vd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:E,vars:s,varsResolver:Ud}),j=Sn(),M=c.map(e=>gt(e)?{label:`${e}`,value:e}:e),ee=$e(),[te,ne]=(0,A.useState)(F()),[re,ie]=(0,A.useState)(null),[ae,oe]=(0,A.useState)({}),se=(e,t)=>{e!==null&&ae[t]!==e&&(ae[t]=e,oe({...ae}))},[ce,le]=We({value:l,defaultValue:u,finalValue:Array.isArray(c)?M.find(e=>!e.disabled)?.value??c[0]?.value??null:null,onChange:d}),N=ze(p),ue=M.map(e=>`${e.value}`),de=M.map(e=>(0,A.createElement)(U,{...k(`control`),mod:{active:ce===e.value,orientation:_},key:`${e.value}`},(0,A.createElement)(`input`,{...k(`input`),disabled:m||e.disabled,type:`radio`,name:N,value:`${e.value}`,id:`${N}-${e.value}`,checked:ce===e.value,onChange:()=>!h&&le(e.value),"data-focus-ring":j.focusRing,key:`${e.value}-input`}),(0,A.createElement)(U,{component:`label`,...k(`label`),mod:{active:ce===e.value&&!(m||e.disabled),disabled:m||e.disabled,"read-only":h},htmlFor:`${N}-${e.value}`,ref:t=>se(t,`${e.value}`),__vars:{"--sc-label-color":y===void 0?void 0:R({color:y,theme:j,autoContrast:C})},key:`${e.value}-label`},(0,z.jsx)(`span`,{...k(`innerLabel`),children:e.label})))),fe=Ue(D,ie);return Je(()=>{ne(F())},[c.length]),Je(()=>{oe(e=>{let t={};return ue.forEach(n=>{n in e&&(t[n]=e[n])}),Object.keys(t).length===Object.keys(e).length?e:t})},[ue]),c.length===0?null:(0,z.jsxs)(U,{...k(`root`),variant:S,size:f,ref:fe,mod:[{"full-width":g,orientation:_,initialized:ee,"with-items-borders":w},T],...O,role:`radiogroup`,"data-disabled":m,children:[ce!==void 0&&(0,z.jsx)(su,{target:ae[`${ce}`],parent:re,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...k(`indicator`)},te),de]})});Wd.classes=Vd,Wd.varsResolver=Ud,Wd.displayName=`@mantine/core/SegmentedControl`;var Gd={size:`sm`,withCheckIcon:!0,allowDeselect:!0,checkIconPosition:`left`,openOnFocus:!0},Kd=Mr(e=>{let t=B([`Input`,`InputWrapper`,`Select`],Gd,e),{classNames:n,styles:r,unstyled:i,vars:a,dropdownOpened:o,defaultDropdownOpened:s,onDropdownClose:c,onDropdownOpen:l,onFocus:u,onBlur:d,onClick:f,onChange:p,data:m,value:h,defaultValue:g,selectFirstOptionOnChange:_,selectFirstOptionOnDropdownOpen:v,onOptionSubmit:y,comboboxProps:b,readOnly:x,disabled:S,filter:C,limit:w,withScrollArea:T,maxDropdownHeight:E,floatingHeight:D,size:O,searchable:k,rightSection:j,checkIconPosition:M,withCheckIcon:ee,withAlignedLabels:te,nothingFoundMessage:ne,name:re,form:ie,searchValue:ae,defaultSearchValue:oe,onSearchChange:se,allowDeselect:ce,error:le,rightSectionPointerEvents:N,id:ue,clearable:de,clearSectionMode:fe,clearButtonProps:pe,hiddenInputProps:me,renderOption:he,onClear:ge,autoComplete:P,scrollAreaProps:F,__defaultRightSection:_e,__clearSection:ve,__clearable:ye,chevronColor:be,autoSelectOnBlur:xe,openOnFocus:Se,attributes:Ce,...we}=t,Te=(0,A.useMemo)(()=>zu(m),[m]),I=(0,A.useRef)({}),Ee=(0,A.useMemo)(()=>Bu(Te),[Te]),De=ze(ue),[Oe,ke,Ae]=We({value:h,defaultValue:g,finalValue:null,onChange:p}),je=Oe==null?void 0:`${Oe}`in Ee?Ee[`${Oe}`]:I.current[`${Oe}`],Me=Ze(je),[Ne,Pe,Fe]=We({value:ae,defaultValue:oe,finalValue:je?je.label:``,onChange:se}),Ie=ud({opened:o,defaultOpened:s,onDropdownOpen:()=>{l?.(),v?Ie.selectFirstOption():Ie.updateSelectedOptionIndex(`active`,{scrollIntoView:!0})},onDropdownClose:()=>{c?.(),setTimeout(Ie.resetSelectedOption,0)}}),Le=e=>{Pe(e),Ie.resetSelectedOption()},{resolvedClassNames:Re,resolvedStyles:Be}=Rn({props:t,styles:r,classNames:n});(0,A.useEffect)(()=>{_&&Ie.selectFirstOption()},[_,Ne]),(0,A.useEffect)(()=>{h===null&&Le(``),h!=null&&je&&(Me?.value!==je.value||Me?.label!==je.label)&&Le(je.label)},[h,je]),(0,A.useEffect)(()=>{!Ae&&!Fe&&Le(Oe==null?``:`${Oe}`in Ee?Ee[`${Oe}`]?.label:I.current[`${Oe}`]?.label||``)},[Ee,Oe]),(0,A.useEffect)(()=>{Oe&&`${Oe}`in Ee&&(I.current[`${Oe}`]=Ee[`${Oe}`])},[Ee,Oe]);let Ve=(0,z.jsx)(Q.ClearButton,{...pe,onClear:()=>{ke(null,null),Le(``),ge?.()}}),He=de&&Oe!=null&&!S&&!x;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Q,{store:Ie,__staticSelector:`Select`,classNames:Re,styles:Be,unstyled:i,readOnly:x,size:O,attributes:Ce,floatingHeight:D,keepMounted:xe,onOptionSubmit:e=>{y?.(e);let t=ce&&`${Ee[e].value}`==`${Oe}`?null:Ee[e],n=t?t.value:null;n!==Oe&&ke(n,t),!Ae&&Le(n==null?``:t?.label||``),Ie.closeDropdown()},...b,children:[(0,z.jsx)(Q.Target,{targetType:k?`input`:`button`,autoComplete:P,withExpandedAttribute:!0,children:(0,z.jsx)(q,{id:De,__defaultRightSection:(0,z.jsx)(Q.Chevron,{size:O,error:le,unstyled:i,color:be}),__clearSection:Ve,__clearable:He,__clearSectionMode:fe,rightSection:j,rightSectionPointerEvents:N||`none`,...we,size:O,__staticSelector:`Select`,disabled:S,readOnly:x||!k,value:Ne,onChange:e=>{if(Id(e)){if(!x){let t=Ld(Ee,e.currentTarget.value);t&&`${t.value}`!=`${Oe}`&&(ke(t.value,t),!Ae&&Le(t.label))}return}Le(e.currentTarget.value),Ie.openDropdown(),_&&Ie.selectFirstOption()},onFocus:e=>{Se&&k&&Ie.openDropdown(),u?.(e)},onBlur:e=>{xe&&Ie.clickSelectedOption(),k&&Ie.closeDropdown();let t=Oe!=null&&(`${Oe}`in Ee?Ee[`${Oe}`]:I.current[`${Oe}`]);Le(t&&t.label||``),d?.(e)},onClick:e=>{k?Ie.openDropdown():Ie.toggleDropdown(),f?.(e)},classNames:Re,styles:Be,unstyled:i,pointer:!k,error:le,attributes:Ce})}),(0,z.jsx)(bd,{data:Te,hidden:x||S,filter:C,search:Ne,limit:w,hiddenWhenEmpty:!ne,withScrollArea:T,maxDropdownHeight:E,filterOptions:!!k&&je?.label!==Ne,value:Oe,checkIconPosition:M,withCheckIcon:ee,withAlignedLabels:te,nothingFoundMessage:ne,unstyled:i,labelId:we.label?`${De}-label`:void 0,"aria-label":we.label?void 0:we[`aria-label`],renderOption:he,scrollAreaProps:F})]}),(0,z.jsx)(Q.HiddenInput,{value:Oe,name:re,form:ie,disabled:S,...me})]})});Kd.classes={...q.classes,...Q.classes},Kd.displayName=`@mantine/core/Select`;var qd={root:`m_6d731127`},Jd={gap:`md`,align:`stretch`,justify:`flex-start`},Yd=L((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":ue(t),"--stack-align":n,"--stack-justify":r}})),Xd=H(e=>{let t=B(`Stack`,Jd,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,align:c,justify:l,gap:u,variant:d,attributes:f,...p}=t,m=V({name:`Stack`,props:t,classes:qd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:Yd});return(0,z.jsx)(U,{...m(`root`),variant:d,...p})});Xd.classes=qd,Xd.varsResolver=Yd,Xd.displayName=`@mantine/core/Stack`;var[Zd,Qd]=M(`Tabs component was not found in the tree`),$d={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},ef=H(e=>{let t=B(`TabsList`,null,e),{children:n,className:r,grow:i,justify:a,classNames:o,styles:s,style:c,mod:l,...u}=t,d=Qd();return(0,z.jsx)(U,{...d.getStyles(`list`,{className:r,style:c,classNames:o,styles:s,props:t,variant:d.variant}),role:`tablist`,variant:d.variant,mod:[{grow:i,orientation:d.orientation,placement:d.orientation===`vertical`&&d.placement,inverted:d.inverted},l],"aria-orientation":d.orientation,__vars:{"--tabs-justify":a},...u,children:n})});ef.classes=$d,ef.displayName=`@mantine/core/TabsList`;var tf=H(e=>{let t=B(`TabsPanel`,null,e),{children:n,className:r,value:i,classNames:a,styles:o,style:s,mod:c,keepMounted:l,...u}=t,d=on(),f=Qd();(0,A.useEffect)(()=>(f.setMountedPanel(i,!0),()=>{f.setMountedPanel(i,!1)}),[i]);let p=f.value===i,m=f.keepMounted||l,h=f.keepMountedMode!==`display-none`,g=m&&h&&d!==`test`?(0,z.jsx)(A.Activity,{mode:p?`visible`:`hidden`,children:n}):m||p?n:null;return(0,z.jsx)(U,{...f.getStyles(`panel`,{className:r,classNames:a,styles:o,style:[s,p?void 0:{display:`none`}],props:t}),mod:[{orientation:f.orientation},c],role:`tabpanel`,id:f.getPanelId(i),"aria-labelledby":f.getTabId(i),...u,children:g})});tf.classes=$d,tf.displayName=`@mantine/core/TabsPanel`;var nf=H(e=>{let t=B(`TabsTab`,null,e),{className:n,children:r,rightSection:i,leftSection:a,value:o,onClick:s,onKeyDown:c,disabled:l,color:u,style:d,classNames:f,styles:p,vars:m,mod:h,tabIndex:g,..._}=t,v=Sn(),{dir:y}=Vr(),b=Qd(),x=o===b.value,S=e=>{b.onChange(b.allowTabDeactivation&&o===b.value?null:o),s?.(e)},C={classNames:f,styles:p,props:t};return(0,z.jsxs)(us,{...b.getStyles(`tab`,{className:n,style:d,variant:b.variant,...C}),disabled:l,unstyled:b.unstyled,variant:b.variant,mod:[{active:x,disabled:l,orientation:b.orientation,inverted:b.inverted,placement:b.orientation===`vertical`&&b.placement},h],role:`tab`,id:b.getTabId(o),"aria-selected":x,tabIndex:g===void 0?x||b.value===null?0:-1:g,"aria-controls":b.mountedPanels.current.has(o)?b.getPanelId(o):void 0,onClick:S,__vars:{"--tabs-color":u?Bt(u,v):void 0},onKeyDown:ae({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:b.activateTabWithKeyboard,loop:b.loop,orientation:b.orientation||`horizontal`,dir:y,onKeyDown:c}),..._,children:[a&&(0,z.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`left`,children:a}),r&&(0,z.jsx)(`span`,{...b.getStyles(`tabLabel`,C),children:r}),i&&(0,z.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`right`,children:i})]})});nf.classes=$d,nf.displayName=`@mantine/core/TabsTab`;var rf=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,af={keepMounted:!0,keepMountedMode:`activity`,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},of=L((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":de(t),"--tabs-color":Bt(n,e),"--tabs-text-color":Yt(r,e)?R({color:n,theme:e,autoContrast:r}):void 0}})),sf=H(e=>{let t=B(`Tabs`,af,e),{defaultValue:n,value:r,onChange:i,orientation:a,children:o,loop:s,id:c,activateTabWithKeyboard:l,allowTabDeactivation:u,variant:d,color:f,radius:p,inverted:m,placement:h,keepMounted:g,keepMountedMode:_,classNames:v,styles:y,unstyled:b,className:x,style:S,vars:C,autoContrast:w,mod:T,attributes:E,...D}=t,O=ze(c),k=(0,A.useRef)(new Set),j=Re(),M=(0,A.useCallback)((e,t)=>{let n=k.current;t&&!n.has(e)?(n.add(e),j()):!t&&n.has(e)&&(n.delete(e),j())},[]),[te,ne]=We({value:r,defaultValue:n,finalValue:null,onChange:i}),re=V({name:`Tabs`,props:t,classes:$d,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:of});return(0,z.jsx)(Zd,{value:{placement:h,value:te,orientation:a,id:O,loop:s,activateTabWithKeyboard:l,getTabId:ee(`${O}-tab`,rf),getPanelId:ee(`${O}-panel`,rf),onChange:ne,allowTabDeactivation:u,variant:d,color:f,radius:p,inverted:m,keepMounted:g,keepMountedMode:_,unstyled:b,getStyles:re,mountedPanels:k,setMountedPanel:M},children:(0,z.jsx)(U,{id:O,variant:d,mod:[{orientation:a,inverted:a===`horizontal`&&m,placement:a===`vertical`&&h},T],...re(`root`),...D,children:o})})});sf.classes=$d,sf.varsResolver=of,sf.displayName=`@mantine/core/Tabs`,sf.Tab=nf,sf.Panel=tf,sf.List=ef;var cf=H(e=>{let t=B([`Input`,`InputWrapper`,`TextInput`],null,e);return(0,z.jsx)(q,{component:`input`,...t,__staticSelector:`TextInput`})});cf.classes=q.classes,cf.displayName=`@mantine/core/TextInput`;var lf=A.createContext(void 0),uf=e=>{let t=A.useContext(lf);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},df=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,z.jsx)(lf.Provider,{value:e,children:t})),ff={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},pf=new class{#e=ff;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function mf(e){setTimeout(e,0)}var hf=typeof window>`u`||`Deno`in globalThis;function gf(){}function _f(e,t){return typeof e==`function`?e(t):e}function vf(e){return typeof e==`number`&&e>=0&&e!==1/0}function yf(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bf(e,t){return typeof e==`function`?e(t):e}function xf(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Cf(o,t.options))return!1}else if(!Tf(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Sf(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(wf(t.options.mutationKey)!==wf(a))return!1}else if(!Tf(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Cf(e,t){return(t?.queryKeyHashFn||wf)(e)}function wf(e){return JSON.stringify(e,(e,t)=>Af(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Tf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Tf(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Tf(e[r],t[r]))return!1;return!0}return!1}var Ef=Object.prototype.hasOwnProperty;function Df(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=kf(e)&&kf(t);if(!r&&!(Af(e)&&Af(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Ef.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Df(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Of(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function kf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Af(e){if(!jf(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!jf(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function jf(e){return Object.prototype.toString.call(e)===`[object Object]`}function Mf(e){return new Promise(t=>{pf.setTimeout(t,e)})}function Nf(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Df(e,t)}function Pf(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ff(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var If=Symbol();function Lf(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===If?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Rf(e,t){return typeof e==`function`?e(...t):!!e}function zf(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Bf=()=>hf,$=()=>Bf(),Vf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Hf=new class extends Vf{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Uf=mf;function Wf(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Uf,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Gf=Wf(),Kf=new class extends Vf{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function qf(e){return Math.min(1e3*2**e,3e4)}function Jf(e){return(e??`online`)!==`online`||Kf.isOnline()}var Yf=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Xf(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(gf);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Yf(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Hf.isFocused()&&(e.networkMode===`always`||Kf.isOnline())&&e.canRun(),p=()=>Jf(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??($()?0:3),a=e.retryDelay??qf,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),Mf(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var Zf=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vf(this.gcTime)&&(this.#e=pf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(pf.clearTimeout(this.#e),this.#e=void 0)}};function Qf(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{zf(e,()=>t.signal,()=>n=!0)},u=Lf(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Ff:Pf;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ep:$f,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:$f(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function $f(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ep(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var tp=class extends Zf{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=ip(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=ip(this.options);e.data!==void 0&&(this.setState(rp(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Nf(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(gf).catch(gf):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>bf(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===If||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>bf(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!yf(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Lf(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Qf(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Xf({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Yf&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Yf){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...np(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...rp(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),Gf.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function np(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Jf(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function rp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function ip(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var ap=class extends Vf{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),sp(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cp(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof bf(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Of(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&lp(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||bf(this.options.enabled,this.#t)!==bf(t.enabled,this.#t)||bf(this.options.staleTime,this.#t)!==bf(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||bf(this.options.enabled,this.#t)!==bf(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Of(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(gf)),t}#h(e){return!$()&&bf(this.options.enabled,this.#t)!==!1&&vf(e)}#g(){this.#b();let e=bf(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=yf(this.#r.dataUpdatedAt,e)+1;this.#u=pf.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=pf.setInterval(()=>{(this.options.refetchIntervalInBackground||Hf.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(pf.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(pf.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&sp(e,t),o=i&&lp(e,n,t,r);(a||o)&&(l={...l,...np(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Nf(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Nf(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:up(e,t),refetch:this.refetch,isEnabled:bf(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Of(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();Gf.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function op(e,t){return bf(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||bf(t.retryOnMount,e)!==!1)}function sp(e,t){return op(e,t)||e.state.data!==void 0&&cp(e,t,t.refetchOnMount)}function cp(e,t,n){if(bf(t.enabled,e)!==!1&&bf(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&up(e,t)}return!1}function lp(e,t,n,r){return(e!==t||bf(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&up(e,n)}function up(e,t){return bf(t.enabled,e)!==!1&&e.isStaleByTime(bf(t.staleTime,e))}var dp=class extends Zf{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||fp(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Xf({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Gf.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function fp(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var pp=class extends Vf{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new dp({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=mp(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=mp(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=mp(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=mp(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Gf.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Sf(t,e))}findAll(e={}){return this.getAll().filter(t=>Sf(e,t))}notify(e){Gf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Gf.batch(()=>Promise.all(e.map(e=>e.continue().catch(gf))))}};function mp(e){return e.options.scope?.id}var hp=class extends Vf{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Of(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&wf(t.mutationKey)!==wf(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??fp();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Gf.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},gp=class extends Vf{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Cf(r,t),a=this.get(i);return a||(a=new tp({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Gf.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>xf(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>xf(e,t)):t}notify(e){Gf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Gf.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Gf.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},_p=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new gp,this.#t=e.mutationCache||new pp,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Hf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Kf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bf(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=_f(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Gf.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Gf.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Gf.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=Gf.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(gf).catch(gf)}invalidateQueries(e,t={}){return Gf.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Gf.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(gf)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(gf)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(bf(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(bf(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(gf).catch(gf)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(gf).catch(gf)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Kf.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(wf(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Tf(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(wf(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Tf(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Cf(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===If&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},vp=A.createContext(!1),yp=()=>A.useContext(vp);vp.Provider;function bp(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xp=A.createContext(bp()),Sp=()=>A.useContext(xp),Cp=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Rf(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},wp=e=>{A.useEffect(()=>{e.clearReset()},[e])},Tp=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Rf(n,[e.error,r])),Ep=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Dp=(e,t)=>e?.suspense&&t.isPending,Op=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function kp(e,t,n){let r=yp(),i=Sp(),a=uf(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Ep(o),Cp(o,i,s),wp(i);let[l]=A.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(A.useSyncExternalStore(A.useCallback(e=>{let t=d?l.subscribe(Gf.batchCalls(e)):gf;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),A.useEffect(()=>{l.setOptions(o)},[o,l]),Dp(o,u))throw Op(o,l,i);if(Tp({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Ap(e,t){return kp(e,ap,t)}function jp(e,t){let n=uf(t),[r]=A.useState(()=>new hp(n,e));A.useEffect(()=>{r.setOptions(e)},[r,e]);let i=A.useSyncExternalStore(A.useCallback(e=>r.subscribe(Gf.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=A.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(gf)},[r]);if(i.error&&Rf(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Mp=_();function Np({placeholder:e,ariaLabel:t,submitLabel:n,onSubmit:r,onCancel:i,size:a,autoFocus:o}){let[s,c]=(0,A.useState)(``),[l,u]=(0,A.useState)(void 0);function d(){let e=s.trim();e!==``&&(u(void 0),Promise.resolve(r(e)).then(()=>{c(``)}).catch(e=>{u(e instanceof Error?e.message:String(e))}))}function f(e){e.key===`Enter`&&d(),e.key===`Escape`&&i?.()}return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Cc,{gap:`xs`,flex:1,children:[(0,z.jsx)(cf,{flex:1,...a===void 0?{}:{size:a},placeholder:e,"aria-label":t,autoComplete:`off`,autoFocus:o,value:s,onChange:e=>{c(e.currentTarget.value)},onKeyDown:f}),(0,z.jsx)(Fd,{...a===void 0?{}:{size:a},onClick:d,children:n})]}),l!==void 0&&(0,z.jsx)(pu,{size:`sm`,c:`red`,children:l})]})}function Pp(e){if(e.kind!==`action`)return null;let t=e.action;return t.action===`join_room`?{kind:`join_room`,room:t.room}:t.action===`leave_room`?{kind:`leave_room`}:null}function Fp(e,t,n){let r=e.trim();return r.length===0?{kind:`ignored`}:r.startsWith(`/`)?Ip(r,t):t!==void 0&&t!==``?{kind:`action`,action:{action:`send`,target:t,content:r}}:n!==void 0&&n!==``?{kind:`action`,action:{action:`dm`,target:n,content:r}}:{kind:`local`,result:{type:`error`,text:`Join a room or select an agent first`}}}function Ip(e,t){let n=e.slice(1).split(/\s+/),r=(n[0]??``).toLowerCase();switch(r){case`join`:return n[1]===void 0||n[1]===``?{kind:`local`,result:{type:`error`,text:`Usage: /join <room>`}}:{kind:`action`,action:{action:`join_room`,room:n[1]}};case`leave`:return{kind:`action`,action:{action:`leave_room`,room:n[1]??t??``}};case`rooms`:return{kind:`action`,action:{action:`list_rooms`}};case`agents`:return{kind:`action`,action:{action:`list_agents`}};case`dm`:return n[1]===void 0||n[1]===``||n[2]===void 0||n[2]===``?{kind:`local`,result:{type:`error`,text:`Usage: /dm <agent> <message>`}}:{kind:`action`,action:{action:`dm`,target:n[1],content:n.slice(2).join(` `)}};case`create`:return n[1]===void 0||n[1]===``?{kind:`local`,result:{type:`error`,text:`Usage: /create <name>`}}:{kind:`action`,action:{action:`create_room`,name:n[1],type:`public`}};case`destroy`:return n[1]===void 0||n[1]===``?{kind:`local`,result:{type:`error`,text:`Usage: /destroy <room>`}}:{kind:`action`,action:{action:`destroy_room`,room:n[1]}};case`rename`:return n[1]===void 0||n[1]===``||n[2]===void 0||n[2]===``?{kind:`local`,result:{type:`error`,text:`Usage: /rename <agent> <new-name>`}}:{kind:`action`,action:{action:`rename_agent`,agent:n[1],name:n.slice(2).join(` `)}};case`help`:return{kind:`local`,result:{type:`help`,text:`Commands: /join, /leave, /rooms, /agents, /dm, /create, /destroy, /rename, /help`}};default:return{kind:`local`,result:{type:`unknown`,text:`Unknown command: /${r}`}}}}function Lp(e,t){switch(e.status){case`delivered`:return`delivered to ${t}`;case`read`:return`read by ${t}`;case`queued`:return`queued for ${t} (${e.reason}), not yet delivered`;case`refused`:return`refused by ${t} (${e.code})`;case`dropped`:return`dropped for ${t}, never delivered`;case`expired`:return`expired for ${t}, never delivered`;default:return e}}var Rp=11,zp=19;function Bp(e){return e.slice(Rp,zp)}function Vp(e,t){switch(e.type){case`room_message`:return t===e.message.room?{type:`chat`,sender:e.message.from,content:e.message.content,timestamp:e.message.timestamp}:void 0;case`dm`:return{type:`dm`,sender:e.message.from,content:e.message.content,timestamp:e.message.timestamp};case`member_joined`:return{type:`system`,text:`${e.agent} joined ${e.room}`};case`member_left`:return{type:`system`,text:`${e.agent} left ${e.room}`};case`member_status`:return{type:`status`,text:`${e.agent} is now ${e.status} in ${e.room}`};case`delivery_status`:return{type:`status`,text:`Message ${e.messageId} ${Lp(e.delivery,e.agent)}`};case`room_members`:return t===e.room?{type:`system`,text:`Members: ${e.members.map(e=>`${e.name} (${e.status})`).join(`, `)}`}:void 0;case`room_invite`:{let t=e.roomDescription?` — ${e.roomDescription}`:``;return{type:`system`,text:`${e.fromName} invited you to "${e.room}"${t}`}}case`invite_declined`:return{type:`system`,text:`${e.agentName} declined invite to ${e.room}: "${e.reason}"`};case`name_changed`:return{type:`system`,text:`${e.oldName} is now known as ${e.newName}`};default:return e}}function Hp(e){return{type:`chat`,sender:e.from,content:e.content,timestamp:e.timestamp}}function Up({message:e}){switch(e.type){case`chat`:return(0,z.jsxs)(Cc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,z.jsx)(pu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,z.jsx)(pu,{c:`dimmed`,size:`xs`,span:!0,children:Bp(e.timestamp)}),(0,z.jsxs)(pu,{span:!0,children:[`: `,e.content]})]});case`dm`:return(0,z.jsxs)(Cc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,z.jsx)(Cd,{color:`grape`,size:`xs`,children:`DM`}),(0,z.jsx)(pu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,z.jsx)(pu,{c:`dimmed`,size:`xs`,span:!0,children:Bp(e.timestamp)}),(0,z.jsxs)(pu,{span:!0,children:[`: `,e.content]})]});case`system`:return(0,z.jsx)(pu,{c:`dimmed`,fs:`italic`,size:`sm`,children:e.text});case`status`:return(0,z.jsx)(pu,{c:`yellow`,size:`xs`,children:e.text})}}function Wp({messages:e}){let t=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.length]),(0,z.jsx)(os,{flex:1,p:`md`,viewportRef:t,"aria-label":`Conversation`,children:(0,z.jsx)(Xd,{gap:4,children:e.map((e,t)=>(0,z.jsx)(Up,{message:e},t))})})}function Gp({messages:e,rooms:t,currentRoom:n,dmTarget:r,connected:i,sidebarOpened:a,onToggleSidebar:o,onSendAction:s,onLeaveRoom:c,onConnectToMesh:l}){let u=(n===void 0?void 0:t.find(e=>e.id===n)?.name??n)??(r===void 0?`Select a room`:`DM with ${r}`);return(0,z.jsxs)(Xd,{h:`100%`,gap:0,children:[(0,z.jsxs)(Cc,{component:`header`,justify:`space-between`,px:`md`,py:`sm`,bg:`dark.6`,children:[(0,z.jsxs)(Cc,{gap:`sm`,children:[(0,z.jsx)(Ed,{opened:a,onClick:o,size:`sm`,"aria-label":`Toggle sidebar`}),(0,z.jsx)(pu,{fw:600,children:u})]}),n!==void 0&&(0,z.jsx)(Fd,{size:`xs`,variant:`subtle`,onClick:c,children:`Leave`})]}),(0,z.jsx)(Wp,{messages:e}),!i&&e.length===0&&(0,z.jsxs)(Xd,{align:`center`,justify:`center`,gap:`md`,p:`xl`,children:[(0,z.jsx)(pu,{c:`dimmed`,children:`Connect to a local mesh to discover agents and rooms.`}),(0,z.jsx)(Fd,{variant:`outline`,onClick:l,children:`Connect to local mesh`})]}),(0,z.jsx)(Cc,{px:`md`,py:`sm`,bg:`dark.6`,children:(0,z.jsx)(Np,{ariaLabel:`Message`,placeholder:`Type a message or /command...`,submitLabel:`Send`,onSubmit:e=>{switch(Fp(e,n,r).kind){case`action`:s(e);break;case`local`:s(e)}}})})]})}function Kp(e,t){var n,r=1;e??=0,t??=0;function i(){var i,a=n.length,o,s=0,c=0;for(i=0;i<a;++i)o=n[i],s+=o.x,c+=o.y;for(s=(s/a-e)*r,c=(c/a-t)*r,i=0;i<a;++i)o=n[i],o.x-=s,o.y-=c}return i.initialize=function(e){n=e},i.x=function(t){return arguments.length?(e=+t,i):e},i.y=function(e){return arguments.length?(t=+e,i):t},i.strength=function(e){return arguments.length?(r=+e,i):r},i}function qp(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Jp(this.cover(t,n),t,n,e)}function Jp(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function Yp(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<c&&(c=i),i>u&&(u=i),a<l&&(l=a),a>d&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<r;++n)Jp(this,o[n],s[n],e[n]);return this}function Xp(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function Zp(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Qp(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function $p(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function em(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new $p(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a)){if(p.length){var g=(o+c)/2,_=(s+l)/2;f.push(new $p(p[3],g,_,c,l),new $p(p[2],o,_,g,l),new $p(p[1],g,s,c,_),new $p(p[0],o,s,g,_)),(h=(t>=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b<n){var x=Math.sqrt(n=b);i=e-x,a=t-x,u=e+x,d=t+x,r=p.data}}}return r}function tm(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function nm(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function rm(){return this._root}function im(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function am(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new $p(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new $p(i,l,u,s,c)),(i=r[2])&&t.push(new $p(i,a,u,l,c)),(i=r[1])&&t.push(new $p(i,l,o,s,u)),(i=r[0])&&t.push(new $p(i,a,o,l,u))}return this}function om(e){var t=[],n=[],r;for(this._root&&t.push(new $p(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new $p(a,o,s,u,d)),(a=i[1])&&t.push(new $p(a,u,s,c,d)),(a=i[2])&&t.push(new $p(a,o,d,u,l)),(a=i[3])&&t.push(new $p(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function sm(e){return e[0]}function cm(e){return arguments.length?(this._x=e,this):this._x}function lm(e){return e[1]}function um(e){return arguments.length?(this._y=e,this):this._y}function dm(e,t,n){var r=new fm(t??sm,n??lm,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function fm(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function pm(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var mm=dm.prototype=fm.prototype;mm.copy=function(){var e=new fm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=pm(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=pm(r));return e},mm.add=qp,mm.addAll=Yp,mm.cover=Xp,mm.data=Zp,mm.extent=Qp,mm.find=em,mm.remove=tm,mm.removeAll=nm,mm.root=rm,mm.size=im,mm.visit=am,mm.visitAfter=om,mm.x=cm,mm.y=um;function hm(e){return function(){return e}}function gm(e){return(e()-.5)*1e-6}function _m(e){return e.index}function vm(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function ym(e){var t=_m,n=d,r,i=hm(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n<u;++n)for(var o=0,s,d,f,p,m,h,g;o<i;++o)s=e[o],d=s.source,f=s.target,p=f.x+f.vx-d.x-d.vx||gm(l),m=f.y+f.vy-d.y-d.vy||gm(l),h=Math.sqrt(p*p+m*m),h=(h-a[o])/h*t*r[o],p*=h,m*=h,f.vx-=p*(g=c[o]),f.vy-=m*g,d.vx+=p*(g=1-g),d.vy+=m*g}function p(){if(o){var n,i=o.length,l=e.length,u=new Map(o.map((e,n)=>[t(e,n,o),e])),d;for(n=0,s=Array(i);n<l;++n)d=e[n],d.index=n,typeof d.source!=`object`&&(d.source=vm(u,d.source)),typeof d.target!=`object`&&(d.target=vm(u,d.target)),s[d.source.index]=(s[d.source.index]||0)+1,s[d.target.index]=(s[d.target.index]||0)+1;for(n=0,c=Array(l);n<l;++n)d=e[n],c[n]=s[d.source.index]/(s[d.source.index]+s[d.target.index]);r=Array(l),m(),a=Array(l),h()}}function m(){if(o)for(var t=0,i=e.length;t<i;++t)r[t]=+n(e[t],t,e)}function h(){if(o)for(var t=0,n=e.length;t<n;++t)a[t]=+i(e[t],t,e)}return f.initialize=function(e,t){o=e,l=t,p()},f.links=function(t){return arguments.length?(e=t,p(),f):e},f.id=function(e){return arguments.length?(t=e,f):t},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.strength=function(e){return arguments.length?(n=typeof e==`function`?e:hm(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:hm(+e),h(),f):i},f}var bm={value:()=>{}};function xm(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Sm(n)}function Sm(e){this._=e}function Cm(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Sm.prototype=xm.prototype={constructor:Sm,on:function(e,t){var n=this._,r=Cm(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=wm(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Tm(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Tm(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Sm(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function wm(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Tm(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=bm,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Em=0,Dm=0,Om=0,km=1e3,Am,jm,Mm=0,Nm=0,Pm=0,Fm=typeof performance==`object`&&performance.now?performance:Date,Im=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lm(){return Nm||=(Im(Rm),Fm.now()+Pm)}function Rm(){Nm=0}function zm(){this._call=this._time=this._next=null}zm.prototype=Bm.prototype={constructor:zm,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Lm():+n)+(t==null?0:+t),!this._next&&jm!==this&&(jm?jm._next=this:Am=this,jm=this),this._call=e,this._time=n,Gm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Gm())}};function Bm(e,t,n){var r=new zm;return r.restart(e,t,n),r}function Vm(){Lm(),++Em;for(var e=Am,t;e;)(t=Nm-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Em}function Hm(){Nm=(Mm=Fm.now())+Pm,Em=Dm=0;try{Vm()}finally{Em=0,Wm(),Nm=0}}function Um(){var e=Fm.now(),t=e-Mm;t>km&&(Pm-=t,Mm=e)}function Wm(){for(var e,t=Am,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Am=n);jm=e,Gm(r)}function Gm(e){Em||(Dm&&=clearTimeout(Dm),e-Nm>24?(e<1/0&&(Dm=setTimeout(Hm,e-Fm.now()-Pm)),Om&&=clearInterval(Om)):(Om||=(Mm=Fm.now(),setInterval(Um,km)),Em=1,Im(Hm)))}var Km=1664525,qm=1013904223,Jm=4294967296;function Ym(){let e=1;return()=>(e=(Km*e+qm)%Jm)/Jm}function Xm(e){return e.x}function Zm(e){return e.y}var Qm=10,$m=Math.PI*(3-Math.sqrt(5));function eh(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=Bm(d),l=xm(`tick`,`end`),u=Ym();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=Qm*Math.sqrt(.5+t),a=t*$m;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function th(){var e,t,n,r,i=hm(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=dm(e,Xm,Zm).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=gm(n),m+=d*d),f===0&&(f=gm(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=gm(n),m+=d*d),f===0&&(f=gm(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:hm(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}var nh=600,rh=400,ih=300,ah=10,oh=8;function sh(e){let t=e.nodes.map(e=>({id:e})),n=e.edges.map(e=>({source:e.from,target:e.to,kind:e.kind})),r=eh(t).force(`link`,ym(n).id(e=>e.id)).force(`charge`,th()).force(`center`,Kp(nh/2,rh/2)).stop();for(let e=0;e<ih;e++)r.tick();return{nodes:t,links:n}}function ch(e){return typeof e==`object`?e:void 0}function lh({graph:e,selectedDevice:t,onSelectDevice:n}){let{nodes:r,links:i}=(0,A.useMemo)(()=>sh(e),[e]);return r.length===0?(0,z.jsx)(pu,{c:`dimmed`,p:`md`,children:`No known devices in the mesh graph.`}):(0,z.jsx)(U,{p:`md`,children:(0,z.jsxs)(`svg`,{role:`img`,"aria-label":`Mesh connection graph`,viewBox:`0 0 ${String(nh)} ${String(rh)}`,width:`100%`,style:{maxHeight:rh},children:[i.map(e=>{let t=ch(e.source),n=ch(e.target);return!t||!n?null:(0,z.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:`var(--mantine-color-dark-3)`,strokeWidth:1.5,strokeDasharray:e.kind===`relay`?`4 3`:void 0},`${t.id}-${n.id}`)}),r.map(e=>(0,z.jsxs)(`g`,{transform:`translate(${String(e.x??0)}, ${String(e.y??0)})`,onClick:()=>{n(e.id)},style:{cursor:`pointer`},role:`button`,"aria-label":`Device ${e.id}`,children:[(0,z.jsx)(`circle`,{r:ah,fill:e.id===t?`var(--mantine-color-accent-5)`:`var(--mantine-color-dark-2)`,stroke:`var(--mantine-color-accent-5)`,strokeWidth:e.id===t?2:0}),(0,z.jsx)(`text`,{y:22,textAnchor:`middle`,fontSize:10,fill:`var(--mantine-color-text)`,children:e.id.slice(0,oh)})]},e.id))]})})}var uh=8;function dh(e){return e.relayed?e.hubAddress===void 0?`relayed`:`relayed via ${e.hubAddress}`:`direct`}function fh({targets:e,selectedTarget:t,onSelectTarget:n,onTrace:r,loading:i,error:a,result:o}){let s=e.map(e=>({value:e,label:e.slice(0,uh)}));return(0,z.jsxs)(Xd,{p:`md`,gap:`sm`,children:[(0,z.jsxs)(Cc,{align:`flex-end`,gap:`xs`,children:[(0,z.jsx)(Kd,{label:`Target device`,placeholder:`Choose a device`,size:`xs`,data:s,value:t??null,onChange:e=>{e!==null&&n(e)}}),(0,z.jsx)(Fd,{size:`xs`,disabled:t===void 0||i,loading:i,onClick:r,children:`Trace`})]}),a!==void 0&&(0,z.jsx)(pu,{c:`red`,children:a}),o!==void 0&&(0,z.jsxs)(Xd,{gap:4,children:[(0,z.jsxs)(Cc,{gap:`xs`,children:[(0,z.jsx)(Cd,{color:o.outcome.result===`ok`?`green`:`red`,children:o.outcome.result===`ok`?`ok`:o.outcome.code??`error`}),(0,z.jsxs)(pu,{size:`sm`,children:[o.rttMs,`ms round trip`]})]}),(0,z.jsxs)(pu,{size:`sm`,c:`dimmed`,children:[`Local: `,dh(o.local)]}),o.remote!==void 0&&(0,z.jsxs)(pu,{size:`sm`,c:`dimmed`,children:[`Remote: `,dh(o.remote)]})]})]})}function ph({queryUtils:e}){let[t,n]=(0,A.useState)(void 0),r=Ap(e.getMeshGraph.queryOptions()),i=jp(e.getMeshTrace.mutationOptions());function a(){t!==void 0&&i.mutate({target:t})}let o=r.data;return o===void 0?(0,z.jsx)(pu,{c:`dimmed`,p:`md`,children:`Mesh graph is not available on this connection.`}):(0,z.jsxs)(sf,{defaultValue:`graph`,children:[(0,z.jsxs)(sf.List,{children:[(0,z.jsx)(sf.Tab,{value:`graph`,children:`Graph`}),(0,z.jsx)(sf.Tab,{value:`trace`,children:`Trace`})]}),(0,z.jsx)(sf.Panel,{value:`graph`,children:(0,z.jsx)(lh,{graph:o,selectedDevice:t,onSelectDevice:n})}),(0,z.jsx)(sf.Panel,{value:`trace`,children:(0,z.jsx)(Xd,{children:(0,z.jsx)(fh,{targets:o.nodes,selectedTarget:t,onSelectTarget:n,onTrace:a,loading:i.isPending,error:i.error===null?void 0:i.error instanceof Error?i.error.message:`Unknown error`,result:i.data})})})]})}function mh(e,t,n){let[r,...i]=t;if(r===void 0){e.agents.push(n);return}let a=e.children.get(r);a||(a={children:new Map,agents:[]},e.children.set(r,a)),mh(a,i,n)}function hh(e,t){let[n,...r]=t;if(n===void 0)return;let i=e.children.get(n);i||(i={children:new Map,agents:[]},e.children.set(n,i)),hh(i,r)}var gh=`Project room for `;function _h(e){return e.description.startsWith(gh)}function vh(e){return e.description.slice(17)}function yh(e,t){let n=t.filter(e=>!_h(e)),r=new Map;for(let e of t)_h(e)&&r.set(vh(e),e);let i=new Set;for(let t of e)i.add(t.cwd);for(let e of r.keys())i.add(e);if(i.size===0)return{roots:[],manualRooms:n};let a=Sh(Array.from(i)),o=a===`/`?[]:bh(a),s={children:new Map,agents:[]};for(let t of e)mh(s,bh(t.cwd).slice(o.length),t);for(let e of r.keys())hh(s,bh(e).slice(o.length));return{roots:wh(Ch(s,a,``,r)),manualRooms:n}}function bh(e){return e.split(`/`).filter(e=>e.length>0)}function xh(...e){return`/`+e.join(`/`)}function Sh(e){if(e.length===0)return`/`;let t=e.map(bh),n=Math.min(...t.map(e=>e.length)),r=0;for(let e=0;e<n;e++){let n=t[0]?.[e];if(n===void 0)break;if(t.every(t=>t[e]===n))r++;else break}return r>0&&r--,r===0?`/`:xh(...t[0]?.slice(0,r)??[])}function Ch(e,t,n,r){let i=[];for(let[a,o]of e.children){let e=n===``&&t===`/`?`/`+a:n===``?t+`/`+a:n+`/`+a,s=Ch(o,t,e,r),c=r.get(e);(s.length>0||c)&&i.push({type:`directory`,name:a,path:e,...c?{roomId:c.id}:{},children:wh(s)})}for(let t of e.agents)i.push({type:`agent`,name:t.name,agentId:t.id,status:t.status,cwd:t.cwd});return i}function wh(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}var Th=[{value:`public`,label:`Public`},{value:`private`,label:`Private`},{value:`secret`,label:`Secret`}];function Eh(e){return e===`public`||e===`private`||e===`secret`}function Dh({visible:e,onSubmit:t,onCancel:n}){let[r,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(`public`),[s,c]=(0,A.useState)(``);return e?(0,z.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&(t(r.trim(),a,s.trim()),i(``),o(`public`),c(``))},children:(0,z.jsxs)(Xd,{gap:`xs`,p:`xs`,children:[(0,z.jsx)(cf,{label:`Room name`,name:`room-name`,required:!0,placeholder:`e.g. project-alpha`,size:`xs`,value:r,onChange:e=>{i(e.target.value)}}),(0,z.jsx)(Kd,{label:`Type`,name:`room-type`,size:`xs`,data:Th,value:a,allowDeselect:!1,onChange:e=>{Eh(e)&&o(e)}}),(0,z.jsx)(cf,{label:`Description (optional)`,name:`room-description`,placeholder:`What is this room about?`,size:`xs`,value:s,onChange:e=>{c(e.target.value)}}),(0,z.jsxs)(Cc,{gap:`xs`,children:[(0,z.jsx)(Fd,{type:`submit`,size:`xs`,flex:1,children:`Create`}),(0,z.jsx)(Fd,{type:`button`,size:`xs`,flex:1,variant:`default`,onClick:n,children:`Cancel`})]})]})}):null}function Oh({visible:e,onSubmit:t,onCancel:n}){return e?(0,z.jsx)(U,{py:4,children:(0,z.jsx)(Np,{ariaLabel:`Room name`,placeholder:`Room name...`,submitLabel:`Join`,size:`xs`,onSubmit:t,onCancel:n})}):null}var kh={active:`green`,idle:`yellow`,busy:`red`,offline:`gray`};function Ah({status:e}){return(0,z.jsx)(U,{w:8,h:8,style:{borderRadius:`50%`,backgroundColor:`var(--mantine-color-${kh[e]}-6)`}})}function jh({tree:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return(0,z.jsxs)(U,{mb:`xs`,children:[e.roots.map(e=>(0,z.jsx)(Mh,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path)),e.manualRooms.length>0&&(0,z.jsxs)(U,{py:4,children:[(0,z.jsx)(pu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,px:`xs`,py:4,children:`Rooms`}),e.manualRooms.map(e=>(0,z.jsx)(Bd,{label:`${e.name} (${String(e.members.length)})`,active:i===e.id,onClick:()=>{t(e.id)}},e.id))]})]})}function Mh({node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return e.type===`agent`?(0,z.jsx)(Ph,{node:e,onSelectAgent:n,onRenameAgent:r}):(0,z.jsx)(Nh,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i})}function Nh({node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){let a=e.roomId,o=i===a,s=a===void 0?{}:{onClick:()=>{t(a)}};return(0,z.jsx)(Bd,{label:e.name,leftSection:(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`📁`}),defaultOpened:!0,active:o,...s,children:e.children.map(e=>(0,z.jsx)(Mh,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path))})}function Ph({node:e,onSelectAgent:t,onRenameAgent:n}){let[r,i]=(0,A.useState)(!1),[a,o]=(0,A.useState)(``),s=(0,A.useRef)(null);(0,A.useEffect)(()=>{r&&s.current?.focus()},[r]);let c=()=>{o(e.name),i(!0)},l=()=>{let t=a.trim();t&&t!==e.name&&n(e.agentId,t),i(!1)};return r?(0,z.jsx)(cf,{ref:s,size:`xs`,ml:`md`,"aria-label":`Rename ${e.name}`,value:a,onChange:e=>{o(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&i(!1)},onBlur:l}):(0,z.jsx)(Bd,{label:e.name,leftSection:(0,z.jsx)(Ah,{status:e.status}),onClick:()=>{t(e.agentId)},onDoubleClick:c})}function Fh({rooms:e,agents:t,currentRoom:n,onJoinRoom:r,onSelectAgent:i,onRenameAgent:a,onCreateRoom:o,onJoinRoomInput:s}){let[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(!1),m=yh(f?t:t.filter(e=>e.status!==`offline`),e);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Cc,{justify:`space-between`,px:`md`,py:`sm`,children:[(0,z.jsx)(pu,{size:`sm`,fw:600,c:`accent`,children:`Agent Comms`}),(0,z.jsx)(pc,{variant:f?`filled`:`default`,size:`sm`,"aria-label":`${f?`Hide`:`Show`} offline agents`,title:`${f?`Hide`:`Show`} offline agents`,onClick:()=>{p(e=>!e)},children:f?`◉`:`◎`})]}),(0,z.jsxs)(os,{flex:1,px:`xs`,children:[(0,z.jsx)(jh,{tree:m,onJoinRoom:r,onSelectAgent:i,onRenameAgent:a,currentRoom:n}),(0,z.jsxs)(Cc,{justify:`space-between`,px:`xs`,py:4,children:[(0,z.jsx)(pu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,children:`Create`}),(0,z.jsx)(pc,{variant:`default`,size:`sm`,"aria-label":`Create room`,title:`Create room`,onClick:()=>{l(e=>!e)},children:`+`})]}),(0,z.jsx)(Dh,{visible:c,onSubmit:(e,t,n)=>{o(e,t,n),l(!1)},onCancel:()=>{l(!1)}}),(0,z.jsx)(Fd,{fullWidth:!0,size:`xs`,variant:`outline`,onClick:()=>{d(e=>!e)},children:`+ Join Room`}),(0,z.jsx)(Oh,{visible:u,onSubmit:e=>{s(e),d(!1)},onCancel:()=>{d(!1)}})]})]})}function Ih(e){let[t,{toggle:n}]=Ye(!0),[r,i]=(0,A.useState)(`chat`);return(0,z.jsxs)(Lu,{navbar:{width:260,breakpoint:`sm`,collapsed:{desktop:!t,mobile:!t}},children:[(0,z.jsxs)(Lu.Navbar,{children:[(0,z.jsx)(Fh,{rooms:e.rooms,agents:e.agents,currentRoom:e.currentRoom,onJoinRoom:e.onJoinRoom,onSelectAgent:e.onSelectAgent,onRenameAgent:e.onRenameAgent,onCreateRoom:e.onCreateRoom,onJoinRoomInput:e.onJoinRoomInput}),(0,z.jsx)(Wd,{m:`xs`,size:`xs`,fullWidth:!0,value:r,onChange:i,data:[{label:`Chat`,value:`chat`},{label:`Mesh`,value:`mesh`}]})]}),(0,z.jsx)(Lu.Main,{h:`100vh`,children:r===`chat`?(0,z.jsx)(Gp,{messages:e.messages,rooms:e.rooms,currentRoom:e.currentRoom,dmTarget:e.dmTarget,connected:e.connected,sidebarOpened:t,onToggleSidebar:n,onSendAction:e.onSendAction,onLeaveRoom:e.onLeaveRoom,onConnectToMesh:e.onConnectToMesh}):(0,z.jsx)(ph,{queryUtils:e.queryUtils})})]})}var Lh={currentRoom:void 0,dmTarget:void 0,agents:[],rooms:[],messages:[],connected:!1},Rh=class{state={...Lh};listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}get(){return this.state}setCurrentRoom(e){this.state={...this.state,currentRoom:e},this.notify()}setDmTarget(e){this.state={...this.state,dmTarget:e},this.notify()}setAgents(e){this.state={...this.state,agents:e},this.notify()}setRooms(e){this.state={...this.state,rooms:e},this.notify()}setConnected(e){this.state={...this.state,connected:e},this.notify()}addMessage(e){this.state={...this.state,messages:[...this.state.messages,e]},this.notify()}setMessages(e){this.state={...this.state,messages:e},this.notify()}clearMessages(){this.state={...this.state,messages:[]},this.notify()}reset(){this.state={...Lh,messages:[]},this.notify()}notify(){let e=this.state;for(let t of this.listeners)t(e)}};function zh(e){return(0,A.useSyncExternalStore)(t=>e.subscribe(t),()=>e.get())}function Bh(e){return Array.isArray(e)?e:e==null?[]:[e]}var Vh=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function Hh(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}var Uh=class{index=BigInt(1);generate(){let e=this.index.toString(36);return this.index++,e}};function Wh(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}var Gh=Symbol.asyncDispose??Symbol.for(`asyncDispose`),Kh=class{isDone=!1;isExecuteComplete=!1;cleanup;next;constructor(e,t){this.cleanup=t,this.next=Hh(async()=>{if(this.isDone)return{done:!0,value:void 0};let t;try{let t=await e();return t.done&&(this.isDone=!0),t}catch(e){throw t={value:e},this.isDone=!0,e}finally{this.isDone&&!this.isExecuteComplete&&(this.isExecuteComplete=!0,await this.cleanup(t?{kind:`error`,error:t.value}:{kind:`success`}))}})}async return(e){return this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`})),{done:!0,value:e}}async throw(e){throw this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`,error:e})),e}async[Gh](){this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`}))}[Symbol.asyncIterator](){return this}};function qh(e){return JSON.stringify(e)}function Jh(e){for(let t of Object.values(e))if(t!==void 0)return!0;return!1}function Yh(e){if(!e)return!1;let t=typeof e;return t===`object`||t===`function`}var Xh=new WeakMap;function Zh(e,t,{bind:n=!0}={}){let r=Reflect.get(e,t);if(!n||typeof r!=`function`)return r;let i=Xh.get(r);i||Xh.set(r,i=new WeakMap);let a=i.get(e);return a||i.set(e,a=r.bind(e)),a}var Qh=class{items=[];pendingPulls=[];closed;push(e){if(this.closed)throw this.closed.reason;let t=this.pendingPulls.shift();t?t[0](e):this.items.push(e)}async pull(){if(this.items.length>0)return this.items.shift();if(this.closed)throw this.closed.reason;return new Promise((e,t)=>{this.pendingPulls.push([e,t])})}close(e){this.closed||(e??=new Vh(`Queue was closed.`),this.closed={reason:e},this.pendingPulls.forEach(([,t])=>t(e)),this.pendingPulls.length=0)}abort(e){e??=new Vh(`Queue was aborted.`),this.items.length=0,this.close(e)}},$h=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function eg(e){try{return encodeURIComponent(e)}catch{return encodeURIComponent(e.replace($h,`�`))}}function tg(e){if(!e.includes(`%`))return e;try{return decodeURIComponent(e)}catch{return e}}function ng(e){return e[0]??{}}var rg=`orpc`;function ig(e){return e instanceof Error&&e.name.includes(`Abort`)}Object.getPrototypeOf(async function*(){}).constructor;function ag(e){let t;return()=>{if(t)return t.result;let n=e();return t={result:n},n}}function og(e){return`/${e.map(encodeURIComponent).join(`/`)}`}var sg=Symbol.for(`ORPC_TRACER`);function cg(){return globalThis[sg]}function lg(e){let t=cg();if(t)return typeof e==`string`?t.startSpan(e):t.startSpan(e.name,e.parent)}function ug(e,t){e&&e.recordException(ig(t)?`info`:`error`,dg(t))}function dg(e){if(e instanceof Error){let t={message:e.message,name:e.name,stack:e.stack};return`code`in e&&(typeof e.code==`string`||typeof e.code==`number`)&&(t.code=e.code),t}return{message:String(e)}}async function fg(e,t){let n=cg();if(!n)return t();let r=typeof e==`string`?e:e.name,i=typeof e==`string`?void 0:e.parent;return n.startActiveSpan(r,i,async e=>{try{return await t(e)}catch(t){throw ug(e,t),t}finally{e.end()}})}function pg(e,t){let n=cg();return!e||!n?t():n.withActiveSpan(e,t)}function mg(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o;return new Kh(async()=>{try{let r;try{r=await t(()=>e.next()),o=r.done}catch(e){throw o=!0,e}return n?await n(r):r}catch(e){throw await i?.(e),r?await r(e):e}},async n=>{try{if(!o)try{await t(async()=>e.return?.())}catch(e){throw await i?.(e),e}}finally{await a?.()}})}function hg(e,t){let n=ag(()=>lg(e));return mg(t,{runWith:e=>pg(n(),e),mapResult(e){return n()?.addEvent(e.done?`completed`:`yielded`),e},onError(e){ug(n(),e)},onFinish(){n()?.end()}})}function gg(e,...t){return typeof e==`function`?e(...t):e}function _g(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){return Zh(r in t?t:gg(e),r)},has(n,r){return Reflect.has(t,r)||Reflect.has(gg(e),r)}})}function*vg(e){if(!Yh(e))return;let t=Object.getPrototypeOf(e);for(;t!=null;)t.constructor&&(yield t.constructor),t=Object.getPrototypeOf(t)}function yg(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}var bg=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function xg(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o=ag(()=>e.getReader()),s=ag(async()=>a?.());return new ReadableStream({async pull(e){let a;try{let e=await t(()=>o().read());a=n?await n(e):e}catch(t){try{await i?.(t),e.error(r?await r(t):t)}finally{await s()}return}a.done?(e.close(),await s()):e.enqueue(a.value)},async cancel(e){try{try{await t(()=>o().cancel(e))}catch(e){throw await i?.(e),e}}finally{await s()}}})}function Sg(e,t){let n=ag(()=>lg(e));return xg(t,{runWith:e=>pg(n(),e),mapResult(e){return n()?.addEvent(e.done?`closed`:`enqueued`),e},onError(e){ug(n(),e)},onFinish(){n()?.end()}})}function Cg(e,t,n){if(!e?.length)return n(t);let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function wg(e){let t=e.length,n=new Map;for(let r=0;r<t;r++){let t=e[r],i=n.get(t.name);i===void 0?n.set(t.name,[r]):i.push(r)}let r=Array.from({length:t},()=>new Set);for(let i=0;i<t;i++){let t=e[i],a=t.before;if(a!==void 0)for(let e of a){let t=n.get(e);if(t!==void 0)for(let e of t){let t=r[e];t!==void 0&&t.add(i)}}let o=t.after;if(o!==void 0){let e=r[i];if(e!==void 0)for(let t of o){let r=n.get(t);if(r!==void 0)for(let t of r)e.add(t)}}}let i=[],a=new Set,o=new Set;function s(t){if(o.has(t))return;if(a.has(t)){let n=e[t],r=n===void 0?`unknown`:n.name;throw Error(`Circular dependency detected involving plugin "${r}"`)}a.add(t);let n=r[t];if(n!==void 0)for(let e of n)s(e);a.delete(t),o.add(t);let c=e[t];c!==void 0&&i.push(c)}for(let e=0;e<t;e++)s(e);return i}var Tg=class extends TypeError{},Eg=class extends Error{constructor(e,t={}){super(t?.message??`Error Event`,t),this.data=e}},Dg=/\r\n|[\n\r]/;function Og(e){return Dg.test(e)}function kg(e){if(Og(e))throw new Tg(`Event's id must not contain a carriage return or newline character`)}function Ag(e){if(!Number.isInteger(e)||e<0)throw new Tg(`Event's retry must be a integer and >= 0`)}function jg(e){if(Og(e))throw new Tg(`Event's comment must not contain a carriage return or newline character`)}var Mg=Symbol.for(`STANDARD_SERVER_EVENT_META`),Ng=Symbol.for(`STANDARD_SERVER_EVENT_SOURCE`);function Pg(e,t){let n;if(t.id!==void 0&&(kg(t.id),n??={},n.id=t.id),t.retry!==void 0&&(Ag(t.retry),n??={},n.retry=t.retry),t.comments!==void 0){for(let e of t.comments)jg(e);n??={},n.comments=t.comments}return n?new Proxy(e,{get(e,t,r){return t===Ng?e:t===Mg?n:Zh(e,t)}}):e}function Fg(e){if(!Yh(e))return[e,void 0];let t=e[Mg];return[e[Ng]??e,t]}function Ig(e){if(Yh(e))return e[Mg]}function Lg(e,t=`inline`){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,`_`).replace(/[\\"]/g,`\\$&`)}"; filename*=utf-8''${eg(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function Rg(e){let t=e.match(/(?:^|;)\s*filename\*=([^;]*)/i)?.[1]?.trim(),n=t?.match(/^([^']*)'[^']*'(.*)$/);if(n){let[,e=``,t=``]=n;if(/^(?:utf-8|us-ascii)$/i.test(e))return tg(t)}else if(t)return tg(t);let r=e.match(/(?:^|;)\s*filename=(?:"((?:\\.|[^"\\])*)"|([^";]*))/i);return r?.[1]===void 0?r?.[2]?.trim()||void 0:r[1].replace(/\\(.)/g,`$1`)}function zg(e){if(typeof e==`string`||e===void 0)return e;if(e.length!==0)return e.join(`, `)}function Bg(e,t){let n={...e,...t};for(let[r,i]of Object.entries(t)){if(!Object.hasOwn(e,r))continue;let t=e[r];n[r]=t===void 0||i===void 0?t??i:[...Bh(t),...Bh(i)]}return n}function Vg(e){let t=e.indexOf(`#`),n=e.indexOf(`?`),r=n!==-1&&(t===-1||n<t),i=r?n:t===-1?e.length:t,a=t===-1?e.length:t;return[e.slice(0,i),r?e.slice(n,a):void 0,t===-1?void 0:e.slice(t)]}function Hg(e){return Yh(e)?Object.values(e).every(e=>e===void 0||typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)):!1}function Ug(e){return Number.isInteger(e)}var Wg={BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_SUPPORTED:405,NOT_ACCEPTABLE:406,TIMEOUT:408,CONFLICT:409,GONE:410,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNSUPPORTED_MEDIA_TYPE:415,UNPROCESSABLE_CONTENT:422,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},Gg,Kg=class e extends Error{static{let t=Symbol.for(`ORPC_ERROR_CONSTRUCTORS`);globalThis[t]??=new WeakSet,Gg=globalThis[t],Gg.add(e)}name=`ORPCError`;defined=!1;code;data;constructor(e,...t){let n=ng(t),r=n.message??e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `);super(r,n),this.code=e,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(!Gg.has(this))return super[Symbol.hasInstance](e);for(let t of vg(e))if(Gg.has(t))return!0;return!1}},qg=class extends Error{name=`MalformedResponseError`;response;constructor(e){super(e.message,e),this.response=e.response}};function Jg(e){return e instanceof Kg?e:new Kg(`INTERNAL_SERVER_ERROR`,{cause:e})}function Yg(e){if(!yg(e))return!1;let t=[`defined`,`code`,`message`,`data`];return!Object.keys(e).some(e=>!t.includes(e))&&`defined`in e&&typeof e.defined==`boolean`&&`code`in e&&typeof e.code==`string`&&`message`in e&&typeof e.message==`string`}function Xg(e,t={}){let n=new Kg(e.code,{...e,...t});return n.defined=e.defined,n}function Zg(e){let t=new Kg(`MALFORMED_ORPC_RESPONSE`,{message:e.message??t_(e.response),data:e.response});return t.cause=new qg({...e,message:t.message}),t}var Qg=1,$g=256;function e_(e){return e.length>=Qg&&e.length<=$g}function t_(e){return typeof e.body==`string`&&e_(e.body)?e.body:yg(e.body)&&typeof e.body.message==`string`&&e_(e.body.message)?e.body.message:(Object.entries(Wg).find(([,t])=>t===e.status)?.[0])?.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function n_(e,{mapResult:t,mapError:n,...r}){return mg(e,{...r,mapResult:t&&(async e=>{let n=await t(e);if(n.value!==e.value){let t=Ig(e.value);if(t&&Yh(n.value))return{done:n.done,value:Pg(n.value,t)}}return n}),mapError:n&&(async e=>{let t=await n(e);if(t!==e){let n=Ig(e);if(n&&Yh(t))return Pg(t,n)}return t})})}var r_=/^\/([\s\S]*)\/([a-z]*)$/,i_={undefined:{condition(e){return e===void 0},serialize(){return null},deserialize(){},isTerminal:!0},bigint:{condition(e){return typeof e==`bigint`},serialize(e){return e.toString()},deserialize(e){return BigInt(e)},isTerminal:!0},date:{condition(e){return e instanceof Date},serialize(e){return Number.isNaN(e.getTime())?null:e.toISOString()},deserialize(e){return new Date(e??`Invalid Date`)},isTerminal:!0},nan:{condition(e){return typeof e==`number`&&Number.isNaN(e)},serialize(){return null},deserialize(){return NaN},isTerminal:!0},url:{condition(e){return e instanceof URL},serialize(e){return e.toString()},deserialize(e){return new URL(e)},isTerminal:!0},regexp:{condition(e){return e instanceof RegExp},serialize(e){return e.toString()},deserialize(e){let[,t,n]=e.match(r_);return new RegExp(t,n)},isTerminal:!0},set:{condition(e){return e instanceof Set},serialize(e){return Array.from(e)},deserialize(e){return new Set(e)}},map:{condition(e){return e instanceof Map},serialize(e){return Array.from(e.entries())},deserialize(e){return new Map(e)}}},a_=class{handlers;inlineBuiltInHandlers;handlerEntries;omitUndefinedProperties;constructor(e={}){this.omitUndefinedProperties=e.omitUndefinedProperties!==!1,this.handlers=Object.assign(new bg,i_);let t=e.handlers;if(t===void 0){this.inlineBuiltInHandlers=!0;return}let n=!0,r=[];for(let e in t){let i=t[e];this.handlers[e]=i,n&&e in i_&&(n=!1),n&&i!==void 0&&r.push([e,i])}if(!n){r=[];for(let e in this.handlers){let t=this.handlers[e];t!==void 0&&r.push([e,t])}}this.inlineBuiltInHandlers=n,this.handlerEntries=r}serialize(e){let t=[],n=[],r=[],i=this.serializeValue(e,[],t,n,r);return t=t.length===0?void 0:t,n.length===0?{json:i,meta:t}:{json:i,meta:t,maps:n,blobs:r}}serializeValue(e,t,n,r,i){if(this.inlineBuiltInHandlers)switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isNaN(e)?(n.push([`nan`,...t]),null):e;case`undefined`:return n.push([`undefined`,...t]),null;case`bigint`:return n.push([`bigint`,...t]),e.toString();case`object`:if(e===null)return e;if(e instanceof Date)return n.push([`date`,...t]),Number.isNaN(e.getTime())?null:e.toISOString();if(e instanceof URL)return n.push([`url`,...t]),e.toString();if(e instanceof RegExp)return n.push([`regexp`,...t]),e.toString();if(e instanceof Set){let a=this.serializeValue(Array.from(e),t,n,r,i);return n.push([`set`,...t]),a}if(e instanceof Map){let a=this.serializeValue(Array.from(e.entries()),t,n,r,i);return n.push([`map`,...t]),a}}let a=this.handlerEntries;if(a)for(let o=0;o<a.length;o++){let s=a[o],c=s[1];if(c.condition(e)){let a=c.serialize(e);if(c.isTerminal)return n.push([s[0],...t]),a instanceof Blob&&(r.push(t.slice()),i.push(a)),a;let o=this.serializeValue(a,t,n,r,i);return n.push([s[0],...t]),o}}if(e instanceof Blob)return r.push(t.slice()),i.push(e),e;if(Array.isArray(e)){let a=[];for(let o=0;o<e.length;o++)t.push(o),a.push(this.serializeValue(e[o],t,n,r,i)),t.pop();return a}if(yg(e)){let a=new bg;for(let o in e){let s=e[o];(o!==`toJSON`||typeof s!=`function`)&&(s===void 0&&this.omitUndefinedProperties||(t.push(o),a[o]=this.serializeValue(s,t,n,r,i),t.pop()))}return a}return e}deserialize(e){let t={data:e.json};if(e.blobs?.length)for(let n=0;n<e.maps.length;n++){let r=e.maps[n],i=t,a=`data`;for(let e=0;e<r.length;e++)if(i=i[a],a=r[e],!Object.hasOwn(i,a))throw Error(`Security error: Invalid serialized data. Segment "${a}" does not exist.`);i[a]=e.blobs[n]}if(e.meta)for(let n of e.meta){let e=n[0],r=t,i=`data`;for(let e=1;e<n.length;e++)if(r=r[i],i=n[e],!Object.hasOwn(r,i))throw Error(`Security error: Invalid serialized data. Segment "${i}" does not exist.`);r[i]=this.handlers[e].deserialize(r[i])}return t.data}},o_=class{jsonSerializer;defaultSerializeOptions;constructor(e={}){this.jsonSerializer=new a_(e),this.defaultSerializeOptions=e.serialize}serialize(e,t={}){if(e===void 0||e instanceof ReadableStream||e instanceof Blob)return e;if(Wh(e))return n_(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.serializeValue(e.value,!1)},mapError:e=>new Eg(this.serializeValue(Jg(e).toJSON(),!1),{cause:e})});let n=t.useFormDataForBlobFields??this.defaultSerializeOptions?.useFormDataForBlobFields??!0;return this.serializeValue(e,n)}serializeValue(e,t){let{json:n,meta:r,maps:i,blobs:a}=this.jsonSerializer.serialize(e);if(!t||!a?.length)return{json:n,meta:r};let o=new FormData;return o.set(`data`,qh({json:n,meta:r,maps:i})),a.forEach((e,t)=>{o.set(t.toString(),e)}),o}deserialize(e){return e===void 0||e instanceof ReadableStream||e instanceof Blob?e:Wh(e)?n_(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.deserializeValue(e.value)},mapError:e=>{if(!(e instanceof Eg))return e;let t=this.deserializeValue(e.data);return Yg(t)?Xg(t,{cause:e}):new Eg(t,{cause:e})}}):this.deserializeValue(e)}deserializeValue(e){if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e);let t=JSON.parse(e.get(`data`)),n=[];for(let[t,r]of e)r instanceof Blob&&(n[Number(t)]=r);return this.jsonSerializer.deserialize({...t,blobs:n})}},s_=new Set([`then`,`bind`,`call`,`apply`,`valueOf`,`toString`,`toJSON`]);function c_(e){return{...e,context:e.context??{}}}function l_(e){return[e[0],c_(e[1]??{})]}function u_(e,{path:t=[],...n}={}){let r=(...r)=>{let[i,a]=l_(r);return Cg([...Bh(n.interceptors),...Bh(n.scoped?.interceptors)],{...a,input:i,path:t},({path:t,input:n,...r})=>e.call(t,n,r))},i=new Map;return new Proxy(r,{get(r,a){if(typeof a!=`string`||s_.has(a))return Reflect.get(r,a);let o=i.get(a);return o===void 0&&(o=u_(e,{...n,path:[...t,a],scoped:n.scoped?.[a]}),i.set(a,o)),o}})}function d_(e,t){return new Kh(async()=>{for(;;){let{json:t}=await e.pull();switch(t.event){case void 0:case`message`:{let e=t.data;return Yh(e)&&(e=Pg(e,t)),{value:e,done:!1}}case`error`:throw Pg(new Eg(t.data),t);case`close`:{let e=t.data;return Yh(e)&&(e=Pg(e,t)),{value:e,done:!0}}}}},t)}var f_=class{constructor(e,t,n){this.iterator=e,this.messageId=t,this.send=n}isDone=!1;async cancel(){this.isDone||(this.isDone=!0,await this.iterator.return?.())}async transmit(){for(;;)try{let e=await this.iterator.next();if(this.isDone)return;e.done&&(this.isDone=!0);try{let[t,n]=Fg(e.value);await this.send({kind:`event-stream`,id:this.messageId,json:{...n,event:e.done?`close`:void 0,data:t}})}catch(e){throw await this.cancel(),e}if(this.isDone)return}catch(e){if(e instanceof Eg){if(!this.isDone){this.isDone=!0;let[t,n]=Fg(e);await this.send({kind:`event-stream`,id:this.messageId,json:{...n,event:`error`,data:t.data}})}return}throw this.isDone=!0,e}}};function p_(e,t){return new ReadableStream({async pull(n){try{let{json:r,binary:i}=await e.pull();i&&n.enqueue(i instanceof Uint8Array?i:new Uint8Array(await i.arrayBuffer())),r.close&&(await t({kind:`success`}),n.close())}catch(e){await t({kind:`error`,error:e}),n.error(e)}},async cancel(e){await t({kind:`cancelled`,error:e})}})}var m_=class{constructor(e,t,n){this.messageId=t,this.send=n,this.reader=e.getReader()}isDone=!1;reader;async cancel(){this.isDone||(this.isDone=!0,await this.reader.cancel())}async transmit(){for(;;)try{let e=await this.reader.read();if(this.isDone)return;e.done&&(this.isDone=!0);try{await this.send({json:{close:e.done?!0:void 0},binary:e.value,kind:`octet-stream`,id:this.messageId})}catch(e){throw await this.cancel(),e}if(this.isDone)return}catch(e){throw this.isDone=!0,e}}};function h_(e,t){let n=zg(e.json.headers?.[`content-type`]),r=zg(e.json.headers?.[`standard-server`]);if(e.json.body===void 0&&e.binary===void 0){if(n===void 0&&r===`event-stream`){let e=new Qh;return{resolveBody:async()=>d_(e,t),eventStreamMessageQueue:e}}if(n!==void 0){let e=new Qh;return{resolveBody:async()=>p_(e,t),octetStreamMessageQueue:e}}}return{resolveBody:async()=>{let i;try{if(e.binary){if(r===`form-data`){let t={};return n!==void 0&&(t[`content-type`]=n),await new Response(e.binary,{headers:t}).formData()}let t=zg(e.json.headers?.[`content-disposition`]),i=t===void 0?void 0:Rg(t);return new File([e.binary],i??`blob`,{type:n??`application/octet-stream`})}if(r===`url-search-params`){if(typeof e.json.body!=`string`)throw TypeError(`Expected body to be a string for url-search-params bodyHint`);return new URLSearchParams(e.json.body)}return e.json.body}catch(e){throw i={value:e},e}finally{await t(i?{kind:`error`,error:i.value}:{kind:`success`})}}}}async function g_(e,t){if(t={...t},e instanceof ReadableStream)return t[`content-type`]??=`application/octet-stream`,{jsonBody:void 0,headers:t,binary:void 0};if(e instanceof Blob)return t[`content-type`]=e.type,t[`content-disposition`]??=Lg(e instanceof File?e.name??``:`blob`),Number.isFinite(e.size)&&(t[`content-length`]=e.size.toString()),{jsonBody:void 0,headers:t,binary:e};if(t[`standard-server`]=void 0,t[`content-type`]=void 0,Wh(e))return t[`standard-server`]=`event-stream`,{jsonBody:void 0,headers:t,binary:void 0};if(e instanceof FormData){let n=await new Response(e).blob();return t[`standard-server`]=`form-data`,t[`content-type`]=n.type,t[`content-length`]=n.size.toString(),{jsonBody:void 0,headers:t,binary:n}}return e instanceof URLSearchParams?(t[`standard-server`]=`url-search-params`,{jsonBody:e.toString(),headers:t,binary:void 0}):{jsonBody:e,headers:t,binary:void 0}}var __=class{constructor(e){this.send=e}idGenerator=new Uh;requests=new Map;request(e){return new Promise((t,n)=>{let r=e.signal;r?.throwIfAborted();let i=this.idGenerator.generate(),a={resolve:t,reject:n};if(this.requests.set(i,a),r){let e=()=>{this.abortById(i,r.reason).catch(()=>{})};r.addEventListener(`abort`,e),a.removeAbortListener=()=>r.removeEventListener(`abort`,e)}this.transmitRequest(i,a,e)})}async transmitRequest(e,t,n){try{let r=await g_(n.body,n.headers);if(n.signal?.throwIfAborted(),this.requests.get(e)!==t)return;if(await this.send({id:e,kind:`request`,json:{method:n.method===`POST`?void 0:n.method,url:n.url,headers:Jh(r.headers)?r.headers:void 0,body:r.jsonBody},binary:r.binary}),Wh(n.body)){let r=new f_(n.body,e,this.send);this.requests.get(e)===t?(t.eventStreamTransmitter=r,await r.transmit().catch(n=>{if(t.eventStreamTransmitter)return this.abortById(e,n)})):await r.cancel()}else if(n.body instanceof ReadableStream){let r=new m_(n.body,e,this.send);this.requests.get(e)===t?(t.octetStreamTransmitter=r,await r.transmit().catch(n=>{if(t.octetStreamTransmitter)return this.abortById(e,n)})):await r.cancel()}}catch(t){await this.closeById(e,t)}}async message(e){let t=e.id,n=this.requests.get(t);if(!n)return;if(e.kind===`stream/cancel`){let e=Promise.all([n.eventStreamTransmitter?.cancel(),n.octetStreamTransmitter?.cancel()]);n.eventStreamTransmitter=void 0,n.octetStreamTransmitter=void 0,await e;return}if(e.kind===`cancel`){await this.closeById(t,new Vh(`Server canceled the request`));return}if(e.kind===`event-stream`){n.eventStreamMessageQueue?.push(e);return}if(e.kind===`octet-stream`){n.octetStreamMessageQueue?.push(e);return}if(!n.resolve)return;let r=n.resolve;n.resolve=void 0;try{let i=h_(e,async e=>{e.kind===`cancelled`?await this.abortById(t,e.error):(n.eventStreamMessageQueue||n.octetStreamMessageQueue)&&await this.closeById(t,e.error)});n.eventStreamMessageQueue=i.eventStreamMessageQueue,n.octetStreamMessageQueue=i.octetStreamMessageQueue,r({headers:e.json.headers??{},status:e.json.status??200,resolveBody:i.resolveBody}),n.reject=void 0,!n.eventStreamMessageQueue&&!n.octetStreamMessageQueue&&await this.closeById(t)}catch(e){await this.closeById(t,e)}}async close(e){e??=new Vh(`Peer was closed`),await Promise.all(Array.from(this.requests.keys()).map(t=>this.closeById(t,e)))}async closeById(e,t){let n=this.requests.get(e);if(!n)return;this.requests.delete(e),(n.reject||n.eventStreamMessageQueue||n.octetStreamMessageQueue)&&(t??=new Vh(`Request was closed`)),n.reject?.(t),n.resolve=void 0,n.reject=void 0,n.eventStreamMessageQueue?.close(t),n.octetStreamMessageQueue?.close(t),n.eventStreamMessageQueue=void 0,n.octetStreamMessageQueue=void 0;let r=[n.eventStreamTransmitter?.cancel(),n.octetStreamTransmitter?.cancel()];n.eventStreamTransmitter=void 0,n.octetStreamTransmitter=void 0,n.removeAbortListener?.(),n.removeAbortListener=void 0,await Promise.all(r)}async abortById(e,t){let n=this.requests.get(e);if(!n)return;this.requests.delete(e),t??=new Vh(`Request was aborted`),n.reject?.(t),n.resolve=void 0,n.reject=void 0,n.eventStreamMessageQueue?.abort(t),n.octetStreamMessageQueue?.abort(t),n.eventStreamMessageQueue=void 0,n.octetStreamMessageQueue=void 0;let r=[this.send({id:e,kind:`cancel`}),n.eventStreamTransmitter?.cancel(),n.octetStreamTransmitter?.cancel()];n.eventStreamTransmitter=void 0,n.octetStreamTransmitter=void 0,n.removeAbortListener?.(),n.removeAbortListener=void 0,await Promise.all(r)}};function v_(e){return!(!Yh(e)||typeof e.id!=`string`||typeof e.kind!=`string`||e.binary!==void 0&&!(e.binary instanceof Uint8Array)&&!(e.binary instanceof Blob))}function y_(e){return!(e.kind!==`response`||!Yh(e.json)||e.json.status!==void 0&&!Ug(e.json.status)||e.json.headers!==void 0&&!Hg(e.json.headers))}function b_(e){return e.kind===`cancel`&&e.json===void 0&&e.binary===void 0}function x_(e){return!(e.kind!==`event-stream`||e.binary!==void 0||!Yh(e.json)||e.json.id!==void 0&&typeof e.json.id!=`string`||e.json.event!==void 0&&e.json.event!==`message`&&e.json.event!==`error`&&e.json.event!==`close`||e.json.retry!==void 0&&!Number.isFinite(e.json.retry)||e.json.comments!==void 0&&!(Array.isArray(e.json.comments)&&e.json.comments.every(e=>typeof e==`string`)))}function S_(e){return e.kind===`octet-stream`&&Yh(e.json)&&(e.json.close===void 0||typeof e.json.close==`boolean`)}function C_(e){return e.kind===`stream/cancel`&&e.json===void 0&&e.binary===void 0}function w_(e){return y_(e)||b_(e)||x_(e)||S_(e)||C_(e)}var T_=255,E_=new TextEncoder,D_=new TextDecoder;async function O_(e,t={}){if(e.binary===void 0){let n=qh(e);return t.prefix?t.prefix+n:n}let n=qh({...e,binary:void 0}),r=E_.encode(t.prefix?t.prefix+n:n),i=e.binary instanceof Blob?new Uint8Array(await e.binary.arrayBuffer()):e.binary,a=new Uint8Array(r.length+1+i.length);return a.set(r,0),a[r.length]=T_,a.set(i,r.length+1),a}function k_(e,t={}){try{if(typeof e==`string`){if(t.prefix){if(!e.startsWith(t.prefix))return{matched:!1};e=e.slice(t.prefix.length)}let n=JSON.parse(e);return v_(n)?{matched:!0,message:n}:{matched:!1}}if(t.prefix){let n=E_.encode(t.prefix);for(let t=0;t<n.length;t++)if(e[t]!==n[t])return{matched:!1};e=e.subarray(n.length)}let n=e.indexOf(T_);if(n===-1){let t=JSON.parse(D_.decode(e));return v_(t)?{matched:!0,message:t}:{matched:!1}}let r=e.subarray(0,n),i=e.subarray(n+1),a=JSON.parse(D_.decode(r));return v_(a)?(a.binary=i,{matched:!0,message:a}):{matched:!1}}catch{return{matched:!1}}}function A_(e){let t=Object.create(null);return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):t[n]===void 0?t[n]=e:t[n]=[t[n],e]}),t}var j_=class{name=`~composite`;plugins;constructor(e=[]){this.plugins=wg(e)}init(e){for(let t of this.plugins)t.init&&(e=t.init(e));return e}},M_=class{constructor(e,t,n={}){this.codec=e,this.transport=t,n=new j_(n.plugins).init(n),this.interceptors=n.interceptors,this.transportInterceptors=n.transportInterceptors}interceptors;transportInterceptors;call(e,t,n){return fg(`${rg}.${e.join(`/`)}`,r=>(r?.setAttribute(`rpc.system`,rg),r?.setAttribute(`rpc.method`,e.join(`.`)),cg()&&Wh(t)?t=_g(t,hg(`consume_async_iterator_object_input`,t)):cg()&&t instanceof ReadableStream&&(t=_g(t,Sg(`consume_octet_stream_input`,t))),Cg(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=cg(),a=i?.getActiveSpan()??r,o=await fg({name:`encode_input`,parent:a},()=>this.codec.encodeInput(t,e,n));if(a&&i?.inject){let e={...o.headers};i.inject(a,e),o={...o,headers:e}}let s=await Cg(this.transportInterceptors,{...n,path:e,request:o},({path:e,request:t,...n})=>fg({name:`send_request`,parent:i?.getActiveSpan()??a},()=>this.transport.send(t,e,n))),c=await fg({name:`decode_response`,parent:a},()=>this.codec.decodeResponse(s,e,n));if(c.kind===`error`)throw c.error;let l=c.output;return cg()&&Wh(l)?_g(l,hg(`consume_async_iterator_object_output`,l)):cg()&&l instanceof ReadableStream?_g(l,Sg(`consume_octet_stream_output`,l)):l})))}},N_=/\/$/,P_=class{baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;serializer;constructor(e){this.baseUrl=e.url??`/`,this.maxUrlLength=e.maxUrlLength??2083,this.fallbackMethod=e.fallbackMethod??`POST`,this.expectedMethod=e.method??this.fallbackMethod,this.headers=e.headers??{},this.serializer=e.serializer??new o_}async encodeInput(e,t,n){let r=F_(await gg(this.headers,n,t,e));n.lastEventId!==void 0&&(r=Bg(r,{"last-event-id":n.lastEventId}));let i=await gg(this.expectedMethod,n,t,e),[a,o,s]=Vg(await gg(this.baseUrl,n,t,e)),c=`${a.replace(N_,``)}${og(t)}`,l=this.serializer.serialize(e);if(i===`GET`&&!(l instanceof Blob)&&!(l instanceof ReadableStream)&&!(l instanceof FormData)&&!Wh(l)){let a=await gg(this.maxUrlLength,n,t,e),u=new URLSearchParams(o);u.append(`data`,qh(l)??``);let d=`${c}?${u}${s??``}`;if(d.length<=a)return{body:void 0,method:i,headers:r,url:d,signal:n.signal}}return{url:`${c}${o??``}${s??``}`,method:i===`GET`?this.fallbackMethod:i,headers:r,body:l,signal:n.signal}}async decodeResponse(e){let t=e.status<400,n=await e.resolveBody(),r=await(async()=>{try{return this.serializer.deserialize(n)}catch(t){throw Zg({message:`Invalid RPC response format.`,response:{status:e.status,headers:e.headers,body:n},cause:t})}})();return t?{kind:`output`,output:r}:Yg(r)?{kind:`error`,error:Xg(r)}:{kind:`error`,error:Zg({response:{headers:e.headers,status:e.status,body:n}})}}};function F_(e){return typeof e.forEach==`function`?A_(e):e}function I_(e,t,n){n?e.postMessage(t,n):e.postMessage(t)}function L_(e,t){if(`addEventListener`in e)e.addEventListener(`message`,e=>{t(e.data)});else if(`on`in e)e.on(`message`,e=>{t(e?.data)});else if(`onMessage`in e)e.onMessage.addListener(e=>{t(e)});else throw Error(`Cannot find a addEventListener/on/onMessage method on the port`)}function R_(e,t){if(`addEventListener`in e)e.addEventListener(`close`,()=>{t()});else if(`on`in e)e.on(`close`,()=>{t()});else if(`onDisconnect`in e)e.onDisconnect.addListener(()=>{t()});else throw Error(`Cannot find a addEventListener/on/onDisconnect method on the port`)}var z_=class{peer;constructor({port:e,experimental_transfer:t,encodePeerMessage:n,decodePeerMessage:r}){this.peer=new __(async r=>{let i=await gg(t,r,e);i?I_(e,r,i):I_(e,await O_(r,n))}),L_(e,async e=>{let t;if(typeof e==`string`||e instanceof Uint8Array){let n=k_(e,r);n.matched&&w_(n.message)&&(t=n.message)}else v_(e)&&w_(e)&&(t=e);return t===void 0?{matched:!1}:(await this.peer.message(t),{matched:!0})}),R_(e,async()=>{await this.peer.close()})}async send(e,t,n){return await this.peer.request(e)}},B_=class extends M_{constructor(e){let t=new P_(e),n=new z_(e);super(t,n,e)}};function V_(e){return e[0]??{}}Object.getPrototypeOf(async function*(){}).constructor;var H_=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function U_(e,t={}){let n=new Set(t.unbound),r=new H_,i=e;for(;i&&i!==Object.prototype;){for(let t of Object.getOwnPropertyNames(i)){if(t===`constructor`||t in r)continue;let i=Zh(e,t,{bind:!n.has(t)});typeof i==`function`&&(r[t]=i)}for(let t of Object.getOwnPropertySymbols(i)){if(t in r)continue;let i=Zh(e,t,{bind:!n.has(t)});typeof i==`function`&&(r[t]=i)}i=Object.getPrototypeOf(i)}return r}function W_(e,t,n){if(!e?.length)return n(t);let r=(t,i)=>{let a=e[i];return a?a({...t,next:(e=t)=>r(e,i+1)}):n(t)};return r(t,0)}function G_(e){let t=e.length,n=new Map;for(let r=0;r<t;r++){let t=e[r],i=n.get(t.name);i===void 0?n.set(t.name,[r]):i.push(r)}let r=Array.from({length:t},()=>new Set);for(let i=0;i<t;i++){let t=e[i],a=t.before;if(a!==void 0)for(let e of a){let t=n.get(e);if(t!==void 0)for(let e of t){let t=r[e];t!==void 0&&t.add(i)}}let o=t.after;if(o!==void 0){let e=r[i];if(e!==void 0)for(let t of o){let r=n.get(t);if(r!==void 0)for(let t of r)e.add(t)}}}let i=[],a=new Set,o=new Set;function s(t){if(o.has(t))return;if(a.has(t)){let n=e[t],r=n===void 0?`unknown`:n.name;throw Error(`Circular dependency detected involving plugin "${r}"`)}a.add(t);let n=r[t];if(n!==void 0)for(let e of n)s(e);a.delete(t),o.add(t);let c=e[t];c!==void 0&&i.push(c)}for(let e=0;e<t;e++)s(e);return i}var K_=new Set([`then`,`bind`,`call`,`apply`,`valueOf`,`toString`,`toJSON`]),q_=class{constructor(e=[]){this.plugins=e,this.plugins=G_(e)}name=`~composite`;init(e){for(let t of this.plugins)t.init&&(e=t.init(e));return e}initProcedureOptions(e,t){for(let n of this.plugins)n.initProcedureOptions&&(t=n.initProcedureOptions(e,t));return t}};function J_(e,t={}){return[...t.prefix===void 0?[]:[t.prefix],e,{...t.input===void 0?{}:{input:t.input},...t.type===void 0?{}:{type:t.type},...t.fnOptions===void 0?{}:{fnOptions:t.fnOptions}}]}function Y_(e){return async t=>{let n=await e(t),r;for await(let e of n)t.signal?.throwIfAborted(),r={chunk:e},t.client.setQueryData(t.queryKey,e);if(!r)throw TypeError(`Live query for ${qh(t.queryKey)} did not yield any data. Ensure the query function returns an AsyncIterable with at least one chunk.`);return r.chunk}}var X_=class{constructor(e,t){this.path=e,this.options=t}key(e={}){return J_(this.path,{...e,prefix:this.options.prefix})}};function Z_(e,{refetchMode:t=`reset`,maxChunks:n=1/0}={}){return async r=>{let i=r.client.getQueryCache().find({queryKey:r.queryKey,exact:!0}),a=!!i&&i.state.data!==void 0;a&&(t===`reset`?i.setState({status:`pending`,data:void 0,error:null,fetchStatus:`fetching`}):r.client.setQueryData(r.queryKey,(e=[])=>Q_(e,n)));let o=[],s=await e(r),c=!a||t!==`replace`;r.client.setQueryData(r.queryKey,(e=[])=>Q_(e,n));for await(let e of s){if(r.signal.aborted)throw r.signal.reason;o.push(e),o=Q_(o,n),c&&r.client.setQueryData(r.queryKey,(t=[])=>Q_([...t,e],n))}c||r.client.setQueryData(r.queryKey,o);let l=r.client.getQueryData(r.queryKey);return l?Q_(l,n):o}}function Q_(e,t){return e.length<=t?e:e.slice(e.length-t)}var $_=Symbol.for(`ORPC_TANSTACK_QUERY_OPERATION_CONTEXT`),ev=[`queryInterceptors`,`streamedInterceptors`,`liveInterceptors`,`infiniteInterceptors`,`mutationInterceptors`],tv=[`queryKey`,`queryOptions`,`streamedKey`,`streamedOptions`,`liveKey`,`liveOptions`,`infiniteKey`,`infiniteOptions`,`mutationKey`,`mutationOptions`];function nv(e){if(!Yh(e))return!1;for(let t in e)if(e[t]!==void 0){if(t===`prefix`){if(typeof e[t]!=`string`)return!1}else if(ev.includes(t)){if(!Array.isArray(e[t])||e[t].some(e=>typeof e!=`function`))return!1}else if(tv.includes(t)&&!Yh(e[t]))return!1}return!0}function rv(e,t){if(typeof e!=`function`&&typeof t!=`function`)return{...e,...t};let n=typeof e==`function`?e:t=>({...e,...t}),r=typeof t==`function`?t:e=>({...t,...e});return e=>r(n(e))}function iv(e,t){let n={...e,...t};for(let r of ev){let i=e[r],a=t[r];i&&a&&(n[r]=[...i,...a])}for(let r of tv){let i=e[r],a=t[r];i&&a&&(n[r]=rv(i,a))}return n}var av=class extends X_{call;constructor(e,t,n={}){super(e,n),this.call=t}queryKey(...e){let t=V_(e);return typeof this.options.queryKey==`function`?t=this.options.queryKey(t):this.options.queryKey&&(t={...this.options.queryKey,...t}),t.queryKey??J_(this.path,{prefix:this.options.prefix,type:`query`,input:t.input})}queryOptions(...e){let t=V_(e);typeof this.options.queryOptions==`function`?t=this.options.queryOptions(t):this.options.queryOptions&&(t={...this.options.queryOptions,...t});let n=this.queryKey(t);return{...t,queryKey:n,queryFn:e=>W_(this.options.queryInterceptors,{path:this.path,context:{[$_]:{key:n,type:`query`},...t.context},input:t.input,fnContext:e},({context:e,input:n,fnContext:r})=>{if(n===If||t.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return t.queryFn?t.queryFn(r):this.call(n,{signal:r.signal,context:e})}),...t.input===If||t.queryFn===If?{enabled:!1}:{}}}streamedKey(...e){let t=V_(e);return typeof this.options.streamedKey==`function`?t=this.options.streamedKey(t):this.options.streamedKey&&(t={...this.options.streamedKey,...t}),t.queryKey??J_(this.path,{prefix:this.options.prefix,type:`streamed`,input:t.input,fnOptions:t.queryFnOptions})}streamedOptions(...e){let t=V_(e);typeof this.options.streamedOptions==`function`?t=this.options.streamedOptions(t):this.options.streamedOptions&&(t={...this.options.streamedOptions,...t});let n=this.streamedKey(t);return{...t,queryKey:n,queryFn:e=>W_(Bh(this.options.streamedInterceptors),{path:this.path,context:{[$_]:{key:n,type:`streamed`},...t.context},input:t.input,fnContext:e},({context:e,fnContext:n,input:r})=>{if(r===If||t.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return t.queryFn?t.queryFn(n):Z_(async t=>{let n=await this.call(r,{signal:t.signal,context:e});if(!Wh(n))throw Error(`streamedQuery requires an AsyncIteratorObject output`);return n},t.queryFnOptions)(n)}),...t.input===If||t.queryFn===If?{enabled:!1}:{}}}liveKey(...e){let t=V_(e);return typeof this.options.liveKey==`function`?t=this.options.liveKey(t):this.options.liveKey&&(t={...this.options.liveKey,...t}),t.queryKey??J_(this.path,{prefix:this.options.prefix,type:`live`,input:t.input})}liveOptions(...e){let t=V_(e);typeof this.options.liveOptions==`function`?t=this.options.liveOptions(t):this.options.liveOptions&&(t={...this.options.liveOptions,...t});let n=this.liveKey(t);return{...t,queryKey:n,queryFn:e=>W_(Bh(this.options.liveInterceptors),{path:this.path,context:{[$_]:{key:n,type:`live`},...t.context},input:t.input,fnContext:e},({fnContext:e,input:n,context:r})=>{if(n===If||t.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return t.queryFn?t.queryFn(e):Y_(async e=>{let t=await this.call(n,{signal:e.signal,context:r});if(!Wh(t))throw Error(`liveQuery requires an AsyncIteratorObject output`);return t})(e)}),...t.input===If||t.queryFn===If?{enabled:!1}:{}}}infiniteKey(e){return typeof this.options.infiniteKey==`function`?e=this.options.infiniteKey(e):this.options.infiniteKey&&(e={...this.options.infiniteKey,...e}),e.queryKey??J_(this.path,{prefix:this.options.prefix,type:`infinite`,input:e.input===If?If:e.input(e.initialPageParam)})}infiniteOptions(e){typeof this.options.infiniteOptions==`function`?e=this.options.infiniteOptions(e):this.options.infiniteOptions&&(e={...this.options.infiniteOptions,...e});let t=this.infiniteKey(e);return{...e,queryKey:t,queryFn:n=>W_(Bh(this.options.infiniteInterceptors),{path:this.path,context:{[$_]:{key:t,type:`infinite`},...e.context},input:e.input===If?If:e.input(n.pageParam),fnContext:n},({context:t,input:n,fnContext:r})=>{if(n===If||e.queryFn===If)throw Error(`queryFn should not be called when skipToken used for skipping`);return e.queryFn?e.queryFn(r):this.call(n,{signal:r.signal,context:t})}),...e.input===If||e.queryFn===If?{enabled:!1}:{}}}mutationKey(e={}){return typeof this.options.mutationKey==`function`?e=this.options.mutationKey(e):this.options.mutationKey&&(e={...this.options.mutationKey,...e}),e.mutationKey??J_(this.path,{prefix:this.options.prefix,type:`mutation`})}mutationOptions(...e){let t=V_(e);typeof this.options.mutationOptions==`function`?t=this.options.mutationOptions(t):this.options.mutationOptions&&(t={...this.options.mutationOptions,...t});let n=this.mutationKey(t);return{...t,mutationKey:n,mutationFn:(e,r)=>W_(Bh(this.options.mutationInterceptors),{path:this.path,context:{[$_]:{key:n,type:`mutation`},...t.context},fnContext:r,input:e},({input:e,fnContext:n,context:r})=>t.mutationFn?t.mutationFn(e,n):this.call(e,{context:r}))}}};function ov(e,t={}){let n=new q_(t.plugins);return t=n.init(t),sv(e,t,n)}function sv(e,t,n){let r=Bh(t.path),i=typeof e==`function`&&(t.scoped===void 0||nv(t.scoped))?U_(new av(r,e,n.initProcedureOptions(r,iv({prefix:t.prefix,queryInterceptors:t.queryInterceptors,streamedInterceptors:t.streamedInterceptors,liveInterceptors:t.liveInterceptors,infiniteInterceptors:t.infiniteInterceptors,mutationInterceptors:t.mutationInterceptors},t.scoped??{}))),{unbound:[`call`]}):U_(new X_(r,t)),a=new Map;return new Proxy(i,{get(i,o){let s=Reflect.get(i,o),c=Reflect.get(e,o);if(typeof o!=`string`||K_.has(o)||!Yh(c))return s;let l=a.get(o);if(l===void 0){let e=sv(c,{...t,path:[...r,o],scoped:t.scoped?.[o]},n);l=typeof s==`function`?new Proxy(s,{get(t,n){return typeof n!=`string`||K_.has(n)?Reflect.get(t,n):Reflect.get(e,n)}}):e,a.set(o,l)}return l}})}function cv(e){if(typeof e!=`object`||!e||!(`endpoint`in e)||typeof e.endpoint!=`string`||!(`keys`in e))return!1;let t=e.keys;return!(typeof t!=`object`||!t||!(`p256dh`in t)||typeof t.p256dh!=`string`||!(`auth`in t)||typeof t.auth!=`string`)}async function lv(e,t){let n=e=>{let n=t[e];return typeof n==`string`?n:``},r=e=>{let n=t[e];return typeof n==`string`?n:void 0},i=()=>{let e=t.type;return e===`public`||e===`private`||e===`secret`?e:`public`};switch(t.action){case`send`:return e.send({target:n(`target`),content:n(`content`)});case`dm`:return e.dm({target:n(`target`),content:n(`content`)});case`join_room`:return e.joinRoom({room:n(`room`)});case`leave_room`:return e.leaveRoom({room:r(`room`)});case`create_room`:return e.createRoom({name:n(`name`),type:i(),description:r(`description`)});case`list_rooms`:return e.listRooms({});case`list_agents`:return e.listAgents({});case`read_room`:return e.readRoom({room:r(`room`)});case`destroy_room`:return e.destroyRoom({room:n(`room`)});case`invite`:return e.invite({room:n(`room`),agent:n(`agent`)});case`decline_invite`:return e.declineInvite({room:n(`room`),reason:n(`reason`)});case`kick`:return e.kick({room:n(`room`),agent:n(`agent`)});case`rename_agent`:return e.renameAgent({agent:n(`agent`),name:n(`name`)});case`push_subscribe`:{let n=t.subscription;return cv(n)?e.pushSubscribe({subscription:n,agentId:r(`agentId`)}):{content:`Invalid push subscription`,isError:!0}}case`push_unsubscribe`:return e.pushUnsubscribe({agentId:r(`agentId`)});default:return{content:`Unknown action: ${String(t.action)}`,isError:!0}}}var uv=/^(localhost|127\.\d+\.\d+\.\d+)(:\d+)?$/;function dv(e){return uv.test(e.host)||e.protocol===`http:`}var fv=new Set([`room_message`,`dm`,`room_invite`,`member_joined`,`member_left`,`room_members`,`member_status`,`delivery_status`,`invite_declined`,`name_changed`]);function pv(e){return fv.has(e.type)}function mv(e){return{getRoomMessages:async t=>e().getRoomMessages(t),getMeshGraph:async()=>e().getMeshGraph({}),getMeshTrace:async t=>e().getMeshTrace(t)}}var hv=19877,gv=10,_v=class{worker;client;state={agents:[],rooms:[],connected:!1};listeners=new Set;deliveryListeners=new Set;eventPumpGeneration=0;readsClient=mv(()=>this.requireClient());queryUtils=ov(this.readsClient);constructor(){typeof window<`u`&&window.addEventListener(`pagehide`,()=>{this.disconnect()})}requireClient(){if(!this.client)throw Error(`Not connected to mesh yet`);return this.client}connect(){if(this.worker)return;let e=new SharedWorker(`./mesh-worker.js`);this.worker=e,e.port.onmessage=e=>{let t=JSON.parse(typeof e.data==`string`?e.data:String(e.data));vv(t)&&(t.type===`connected`?(this.state={...this.state,connected:!0},this.notify()):t.type===`disconnected`&&(this.state={...this.state,connected:!1},this.notify()))},e.port.start();let t=u_(new B_({port:e.port}));if(this.client=t,this.pumpEvents(t,++this.eventPumpGeneration),dv(location)){let e=`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/ws/mesh`;this.postLegacyInit(e)}else this.probeLocalMesh(hv,gv)}get(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}onDelivery(e){return this.deliveryListeners.add(e),()=>{this.deliveryListeners.delete(e)}}async sendAction(e){let t=this.client;return t?lv(t,e):{content:`Not connected to mesh yet`,isError:!0}}disconnect(){let e=this.worker,t=this.client;this.worker=void 0,this.client=void 0,this.eventPumpGeneration++,e&&(t?t.disconnect({}).catch(()=>{}).finally(()=>{e.port.close()}):e.port.close())}async pumpEvents(e,t){let n;for(;t===this.eventPumpGeneration;)try{let r=await e.subscribeEvents(n===void 0?{}:{lastEventId:n});for await(let e of r){if(t!==this.eventPumpGeneration)return;let r=Ig(e);r?.id!==void 0&&(n=r.id),this.applyMeshEvent(e)}return}catch{}}applyMeshEvent(e){switch(e.kind){case`state_sync`:{let t=Object.values(e.state.agents).filter(bv),n=Object.values(e.state.rooms).filter(xv);this.state={...this.state,agents:t,rooms:n},this.notify();break}case`state_patch`:this.applyPatch(e.patch);break;case`delivery`:if(pv(e.event))for(let t of this.deliveryListeners)t(e.event)}}applyPatch(e){switch(e.type){case`agent_upsert`:{let t=this.state.agents.filter(t=>t.id!==e.agent.id);t.push(e.agent),this.state={...this.state,agents:t},this.notify();break}case`agent_offline`:{let t=this.state.agents.map(t=>t.id===e.agentId?{...t,status:`offline`}:t);this.state={...this.state,agents:t},this.notify();break}case`room_upsert`:{let t=this.state.rooms.filter(t=>t.id!==e.room.id);t.push(e.room),this.state={...this.state,rooms:t},this.notify();break}case`room_delete`:{let t=this.state.rooms.filter(t=>t.id!==e.roomId);this.state={...this.state,rooms:t},this.notify();break}}}postLegacyInit(e){this.worker?.port.postMessage(JSON.stringify({type:`init`,url:e}))}probeLocalMesh(e,t){let n=0,r=e=>{if(n>=t)return;n++;let i=`ws://127.0.0.1:${String(e)}/ws/mesh`;fetch(`http://127.0.0.1:${String(e)}/`,{mode:`no-cors`}).then(()=>{this.postLegacyInit(i)}).catch(()=>{r(e+1)})};r(e)}notify(){let e=this.state;for(let t of this.listeners)t(e)}};function vv(e){return typeof e==`object`&&!!e&&`type`in e}function yv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bv(e){return yv(e)&&typeof e.id==`string`&&typeof e.name==`string`}function xv(e){return yv(e)&&typeof e.id==`string`&&typeof e.name==`string`}var Sv=Ln({primaryColor:`accent`,primaryShade:5,colors:{accent:[`#e5fbff`,`#bdf4ff`,`#85ebff`,`#47e0ff`,`#0fd7ff`,`#00b3d6`,`#009dbd`,`#00849e`,`#006f85`,`#005566`],dark:[`#e4e4e4`,`#b6b6b6`,`#888888`,`#4c5e74`,`#0f3460`,`#132b4f`,`#16213e`,`#1a1a2e`,`#131321`,`#0c0c16`]}});function Cv(e){return e.getItem(`agent-comms-connected`)===`true`}function wv(e,t){return dv(e)||Cv(t)}var Tv=`Project room for `;function Ev(e){let t=new URLSearchParams(e),n=t.get(`room`);if(n!==null&&n!==``)return{kind:`room`,roomId:n};let r=t.get(`dm`);if(r!==null&&r!==``)return{kind:`dm`,agentId:r};let i=t.get(`cwd`);if(i!==null&&i!==``)return{kind:`cwd`,path:i}}function Dv(e,t){switch(e.kind){case`room`:return t.some(t=>t.id===e.roomId)?{kind:`room`,targetId:e.roomId}:void 0;case`dm`:return{kind:`dm`,targetId:e.agentId};case`cwd`:{let n=t.find(t=>t.description===`${Tv}${e.path}`);return n?{kind:`room`,targetId:n.id}:void 0}default:return e}}function Ov(e){let t=new URL(location.href);t.searchParams.delete(`room`),t.searchParams.delete(`dm`),t.searchParams.delete(`cwd`),e.currentRoom!==void 0&&e.currentRoom!==``?t.searchParams.set(`room`,e.currentRoom):e.dmTarget!==void 0&&e.dmTarget!==``&&t.searchParams.set(`dm`,e.dmTarget);let n=t.pathname+t.search+t.hash;history.replaceState(null,``,n)}var kv=document.createElement(`style`);kv.textContent=l,document.head.appendChild(kv);var Av=document.getElementById(`root`);if(Av===null)throw Error(`missing #root element`);var jv=new Rh,Mv=new _p,Nv=new _v,Pv=!1;Nv.subscribe(e=>{e.agents.length>0&&jv.setAgents(e.agents),e.rooms.length>0&&jv.setRooms(e.rooms),jv.setConnected(e.connected),e.connected!==Pv&&(Pv=e.connected,Fv({type:`system`,text:e.connected?`Connected to mesh`:`Disconnected — reconnecting...`}))}),Nv.onDelivery(e=>{let t=Vp(e,jv.get().currentRoom);t&&Fv(t),(e.type===`member_joined`||e.type===`member_left`||e.type===`member_status`||e.type===`name_changed`)&&Lv()});function Fv(e){jv.addMessage(e)}async function Iv(e){let t=await Nv.sendAction(e);Fv({type:t.isError?`status`:`system`,text:t.isError?`Error: ${t.content}`:t.content}),t.isError||Lv()}async function Lv(){await Mv.invalidateQueries({queryKey:Nv.queryUtils.getMeshGraph.key()})}async function Rv(e){jv.setDmTarget(void 0),jv.setCurrentRoom(e),jv.clearMessages(),Iv({action:`join_room`,room:e});let t=await Mv.query(Nv.queryUtils.getRoomMessages.queryOptions({input:{room:e}}));jv.setMessages(t.map(Hp)),Fv({type:`system`,text:`Joined ${e}`})}function zv(e){jv.setCurrentRoom(void 0),jv.setDmTarget(e),jv.clearMessages()}function Bv(){let e=jv.get(),t=e.currentRoom;if(t!==void 0&&t!==``){let n=e.rooms.find(e=>e.id===t)?.name??t;Iv({action:`leave_room`,room:t}),jv.setCurrentRoom(void 0),jv.clearMessages(),Fv({type:`system`,text:`Left room "${n}"`})}}function Vv(e){let t=jv.get(),n=Fp(e,t.currentRoom,t.dmTarget),r=Pp(n);if(r)switch(r.kind){case`join_room`:Rv(r.room);return;case`leave_room`:Bv();return}switch(n.kind){case`action`:Iv(n.action);break;case`local`:Fv({type:`system`,text:n.result.text})}}function Hv(e,t,n){Iv({action:`create_room`,name:e,type:t,...n?{description:n}:{}})}function Uv(e){Rv(e)}function Wv(e,t){Iv({action:`rename_agent`,agent:e,name:t})}function Gv(){localStorage.setItem(`agent-comms-connected`,`true`),Nv.connect()}function Kv(){let e=zh(jv);return(0,A.useEffect)(()=>{Ov({currentRoom:e.currentRoom,dmTarget:e.dmTarget})},[e.currentRoom,e.dmTarget]),(0,z.jsx)(Ih,{rooms:e.rooms,agents:e.agents,currentRoom:e.currentRoom,dmTarget:e.dmTarget,messages:e.messages,connected:e.connected,queryUtils:Nv.queryUtils,onJoinRoom:e=>{Rv(e)},onSelectAgent:zv,onRenameAgent:Wv,onLeaveRoom:Bv,onSendAction:Vv,onCreateRoom:Hv,onJoinRoomInput:Uv,onConnectToMesh:Gv})}(0,Mp.createRoot)(Av).render((0,z.jsx)(df,{client:Mv,children:(0,z.jsx)(In,{theme:Sv,defaultColorScheme:`dark`,children:(0,z.jsx)(Kv,{})})}));var qv=Ev(location.search);if(wv(location,localStorage)&&Nv.connect(),qv){let e=Nv.subscribe(t=>{if(t.rooms.length===0)return;e();let n=Dv(qv,t.rooms);if(n)switch(n.kind){case`room`:Rv(n.targetId);break;case`dm`:zv(n.targetId)}})}