agent-comms 3.28.0 → 3.29.0

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 (44) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +1 -1
  4. package/dist/bridges/user/web/dist/bundle.js +1 -1
  5. package/dist/bridges/user/web/dist/mesh-worker.js +1 -1
  6. package/dist/bridges/user/web/dist/sw.js +1 -1
  7. package/dist/bridges/user/web/frontend/dispatch-action.d.ts +1 -1
  8. package/dist/bridges/user/web/frontend/dispatch-action.d.ts.map +1 -1
  9. package/dist/bridges/user/web/frontend/dispatch-action.js +26 -0
  10. package/dist/bridges/user/web/frontend/dispatch-action.js.map +1 -1
  11. package/dist/bridges/user/web/frontend/mesh-worker.d.ts.map +1 -1
  12. package/dist/bridges/user/web/frontend/mesh-worker.js +1 -5
  13. package/dist/bridges/user/web/frontend/mesh-worker.js.map +1 -1
  14. package/dist/bridges/user/web/server.d.ts +4 -19
  15. package/dist/bridges/user/web/server.d.ts.map +1 -1
  16. package/dist/bridges/user/web/server.js +13 -201
  17. package/dist/bridges/user/web/server.js.map +1 -1
  18. package/dist/bridges/user/web/test/orpc-router.integration.test.d.ts +1 -1
  19. package/dist/bridges/user/web/test/orpc-router.integration.test.js +4 -4
  20. package/dist/bridges/user/web/test/orpc-router.integration.test.js.map +1 -1
  21. package/dist/bridges/user/web/test/web-server.integration.test.js +9 -12
  22. package/dist/bridges/user/web/test/web-server.integration.test.js.map +1 -1
  23. package/dist/core/hub-session.d.ts +6 -5
  24. package/dist/core/hub-session.d.ts.map +1 -1
  25. package/dist/core/hub-session.js +5 -5
  26. package/dist/core/hub-session.js.map +1 -1
  27. package/dist/core/mesh-graph.d.ts +4 -3
  28. package/dist/core/mesh-graph.d.ts.map +1 -1
  29. package/dist/core/mesh-graph.js +3 -3
  30. package/dist/core/mesh-graph.js.map +1 -1
  31. package/dist/core/room-router.d.ts +9 -4
  32. package/dist/core/room-router.d.ts.map +1 -1
  33. package/dist/core/room-router.js +2 -2
  34. package/dist/core/room-router.js.map +1 -1
  35. package/dist/test/hub-mode-session.integration.test.js +29 -0
  36. package/dist/test/hub-mode-session.integration.test.js.map +1 -1
  37. package/dist/test/hub-session-dispatch.test.js +24 -0
  38. package/dist/test/hub-session-dispatch.test.js.map +1 -1
  39. package/dist/test/mesh-graph.test.d.ts +1 -1
  40. package/dist/test/mesh-graph.test.js +36 -2
  41. package/dist/test/mesh-graph.test.js.map +1 -1
  42. package/dist/test/room-router.test.js +42 -0
  43. package/dist/test/room-router.test.js.map +1 -1
  44. package/package.json +1 -1
@@ -46,4 +46,4 @@ Error generating stack: `+e.message+`
46
46
  `},al=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},ol=function(){A.useEffect(function(){return document.body.setAttribute(rl,(al()+1).toString()),function(){var e=al()-1;e<=0?document.body.removeAttribute(rl):document.body.setAttribute(rl,e.toString())}},[])},sl=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;ol();var a=A.useMemo(function(){return tl(i)},[i]);return A.createElement(nl,{styles:il(a,!t,i,n?``:`!important`)})},cl=!1;if(typeof window<`u`)try{var ll=Object.defineProperty({},"passive",{get:function(){return cl=!0,!0}});window.addEventListener(`test`,ll,ll),window.removeEventListener(`test`,ll,ll)}catch{cl=!1}var ul=cl?{passive:!1}:!1,dl=function(e){return e.tagName===`TEXTAREA`},fl=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!dl(e)&&n[t]===`visible`)},pl=function(e){return fl(e,`overflowY`)},ml=function(e){return fl(e,`overflowX`)},hl=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),vl(e,r)){var i=yl(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},gl=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},_l=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},vl=function(e,t){return e===`v`?pl(t):ml(t)},yl=function(e,t){return e===`v`?gl(t):_l(t)},bl=function(e,t){return e===`h`&&t===`rtl`?-1:1},xl=function(e,t,n,r,i){var a=bl(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=yl(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&vl(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},Sl=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Cl=function(e){return[e.deltaX,e.deltaY]},wl=function(e){return e&&`current`in e?e.current:e},Tl=function(e,t){return e[0]===t[0]&&e[1]===t[1]},El=function(e){return`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
- `},Dl=0,Ol=[];function kl(e){var t=A.useRef([]),n=A.useRef([0,0]),r=A.useRef(),i=A.useState(Dl++)[0],a=A.useState(Zc)[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=Dc([e.lockRef.current],(e.shards||[]).map(wl),!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=Sl(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=hl(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=hl(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 xl(h,t,e,h===`h`?s:c,!0)},[]),c=A.useCallback(function(e){var n=e;if(Ol.length&&Ol[Ol.length-1]===a){var r=`deltaY`in n?Cl(n):Sl(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Tl(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(wl).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:Al(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=Sl(e),r.current=void 0},[]),d=A.useCallback(function(t){l(t.type,Cl(t),t.target,s(t,e.lockRef.current))},[]),f=A.useCallback(function(t){l(t.type,Sl(t),t.target,s(t,e.lockRef.current))},[]);A.useEffect(function(){return Ol.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,ul),document.addEventListener(`touchmove`,c,ul),document.addEventListener(`touchstart`,u,ul),function(){Ol=Ol.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,ul),document.removeEventListener(`touchmove`,c,ul),document.removeEventListener(`touchstart`,u,ul)}},[]);var p=e.removeScrollBar,m=e.inert;return A.createElement(A.Fragment,null,m?A.createElement(a,{styles:El(i)}):null,p?A.createElement(sl,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Al(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var jl=Vc(Hc,kl),Ml=A.forwardRef(function(e,t){return A.createElement(Wc,Tc({},e,{ref:t,sideCar:jl}))});Ml.classNames=Wc.classNames;var Nl=(0,A.createContext)({size:`sm`}),Pl=V(e=>{let t=z(`InputClearButton`,null,e),{size:n,variant:r,vars:i,classNames:a,styles:o,...s}=t,c=(0,A.use)(Nl),{resolvedClassNames:l,resolvedStyles:u}=zn({classNames:a,styles:o,props:t});return(0,R.jsx)(yc,{variant:r||`transparent`,size:n||c?.size||`sm`,classNames:l,styles:u,__staticSelector:`InputClearButton`,style:{pointerEvents:`all`,background:`var(--input-bg)`,...s.style},...s})});Pl.displayName=`@mantine/core/InputClearButton`;var Fl={xs:7,sm:8,md:10,lg:12,xl:15};function Il({__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,R.jsxs)(`div`,{"data-combined-clear-section":!0,style:{display:`flex`,gap:2,alignItems:`center`,paddingInlineEnd:Fl[i]},children:[o,n||r]}):n===null?null:n||o||r}var Ll=(0,A.createContext)({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0}),Rl={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`},zl=xt((e,{size:t})=>({description:{"--input-description-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Bl=V(e=>{let t=z(`InputDescription`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,__inheritStyles:l=!0,attributes:u,...d}=z(`InputDescription`,null,t),f=(0,A.use)(Ll),p=B({name:[`InputWrapper`,c],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,rootSelector:`description`,vars:s,varsResolver:zl}),m=l&&f?.getStyles||p;return(0,R.jsx)(H,{component:`p`,...m(`description`,f?.getStyles?{className:r,style:i}:void 0),...d})});Bl.classes=Rl,Bl.varsResolver=zl,Bl.displayName=`@mantine/core/InputDescription`;var Vl=xt((e,{size:t})=>({error:{"--input-error-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Hl=V(e=>{let t=z(`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=B({name:[`InputWrapper`,l],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`error`,vars:s,varsResolver:Vl}),p=(0,A.use)(Ll),m=u&&p?.getStyles||f;return(0,R.jsx)(H,{component:`p`,...m(`error`,p?.getStyles?{className:r,style:i}:void 0),...d})});Hl.classes=Rl,Hl.varsResolver=Vl,Hl.displayName=`@mantine/core/InputError`;var Ul={labelElement:`label`},Wl=xt((e,{size:t})=>({label:{"--input-label-size":fe(t),"--input-asterisk-color":void 0}})),Gl=V(e=>{let t=z(`InputLabel`,Ul,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,_=B({name:[`InputWrapper`,p],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`label`,vars:s,varsResolver:Wl}),v=(0,A.use)(Ll),y=v?.getStyles||_,b=g.component||c,x=typeof b!=`string`||b===`label`;return(0,R.jsxs)(H,{...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,R.jsx)(`span`,{...y(`required`),"aria-hidden":!0,children:` *`})]})});Gl.classes=Rl,Gl.varsResolver=Wl,Gl.displayName=`@mantine/core/InputLabel`;var Kl=V(e=>{let t=z(`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=B({name:[`InputPlaceholder`,c],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:d,rootSelector:`placeholder`});return(0,R.jsx)(H,{...p(`placeholder`),mod:[{error:!!l},u],component:`span`,...f})});Kl.classes=Rl,Kl.displayName=`@mantine/core/InputPlaceholder`;var ql=xt((e,{size:t})=>({success:{"--input-success-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Jl=V(e=>{let t=z(`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=B({name:[`InputWrapper`,l],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`success`,vars:s,varsResolver:ql}),p=(0,A.use)(Ll),m=u&&p?.getStyles||f;return(0,R.jsx)(H,{component:`p`,...m(`success`,p?.getStyles?{className:r,style:i}:void 0),...d})});Jl.classes=Rl,Jl.varsResolver=ql,Jl.displayName=`@mantine/core/InputSuccess`;function Yl(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 Xl={labelElement:`label`,inputContainer:e=>e,inputWrapperOrder:[`label`,`description`,`input`,`error`]},Zl=xt((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)})`}})),Ql=V(e=>{let t=z(`InputWrapper`,Xl,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=B({name:[`InputWrapper`,u],props:E||t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:O,vars:s,varsResolver:Zl}),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,R.jsx)(Gl,{labelElement:x,id:pe,htmlFor:ae,required:te,...M,..._,children:p},`label`),he=ce&&(0,R.jsx)(Bl,{...v,...M,size:v?.size||M.size,id:v?.id||ie,children:g},`description`),ge=(0,R.jsx)(A.Fragment,{children:d(S)},`input`),P=oe&&(0,A.createElement)(Hl,{...y,...M,size:y?.size||M.size,key:`error`,id:y?.id||ne},m),F=se&&(0,A.createElement)(Jl,{...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,R.jsx)(Ll,{value:{getStyles:j,describedBy:fe,inputId:ae,labelId:pe,...Yl(f,{hasDescription:ce,hasError:oe||se})},children:(0,R.jsx)(H,{variant:l,size:c,mod:[{error:!!m,success:!!h&&!m},D],id:x===`label`?void 0:w,...j(`root`),...k,children:_e})})});Ql.classes=Rl,Ql.varsResolver=Zl,Ql.displayName=`@mantine/core/InputWrapper`;var $l={variant:`default`,leftSectionPointerEvents:`none`,rightSectionPointerEvents:`none`,withAria:!0,withErrorStyles:!0,withSuccessStyles:!0,size:`sm`,loading:!1,loadingPosition:`right`},eu=xt((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}})),tu=Pr(e=>{let t=z(`Input`,$l,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}=ar(fe),he=(0,A.use)(Ll),ge={offsetBottom:he?.offsetBottom,offsetTop:he?.offsetTop},P=B({name:[`Input`,c],props:l||t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:ne,stylesCtx:ge,rootSelector:`wrapper`,vars:w,varsResolver:eu}),F=k?{required:s,disabled:m,"aria-invalid":f?!0:void 0,"aria-describedby":he?.describedBy,id:he?.inputId||O}:{},_e=se?(0,R.jsx)(oc,{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=Il({__clearable:ie,__clearSection:re,rightSection:se&&ce===`right`?_e:v,__defaultRightSection:oe,size:u,__clearSectionMode:ae});return(0,R.jsx)(Nl,{value:{size:u||`sm`},children:(0,R.jsxs)(H,{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,R.jsx)(`div`,{...g,"data-position":`left`,...P(`section`,{className:g?.className,style:g?.style}),children:ve}),(0,R.jsx)(H,{component:`input`,...me,...F,required:s,mod:{disabled:m,error:!!f&&j,success:!!p&&!f&&M},variant:C,__size:te,...P(`input`)}),le&&(0,R.jsx)(`div`,{...N,...P(`bottomSection`,{className:N?.className,style:N?.style}),children:le}),ye&&(0,R.jsx)(`div`,{...y,"data-position":`right`,...P(`section`,{className:y?.className,style:y?.style}),children:ye})]})})});tu.classes=Rl,tu.varsResolver=eu,tu.Wrapper=Ql,tu.Label=Gl,tu.Error=Hl,tu.Success=Jl,tu.Description=Bl,tu.Placeholder=Kl,tu.ClearButton=Pl,tu.displayName=`@mantine/core/Input`;function nu(e,t,n){let r=z([`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}=ar(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 ru={__staticSelector:`InputBase`,withAria:!0,size:`sm`},K=Pr(e=>{let{inputProps:t,wrapperProps:n,...r}=nu(`InputBase`,ru,e);return(0,R.jsx)(tu.Wrapper,{...n,children:(0,R.jsx)(tu,{...t,...r})})});K.classes={...tu.classes,...tu.Wrapper.classes},K.displayName=`@mantine/core/InputBase`;function iu(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 au({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=ai(s.borderTopWidth)+ai(c.borderTopWidth),u=ai(s.borderLeftWidth)+ai(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=>{iu(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 ou={root:`m_96b553a6`},su=xt((e,{transitionDuration:t},{shouldReduceMotion:n})=>({root:{"--transition-duration":e.respectReducedMotion&&n?`0ms`:typeof t==`number`?`${t}ms`:t||`150ms`}})),cu=V(e=>{let t=z(`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=B({name:`FloatingIndicator`,classes:ou,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,vars:s,varsResolver:su,stylesCtx:{shouldReduceMotion:Ge()}}),y=(0,A.useRef)(null),{initialized:b,hidden:x}=au({target:c,parent:l,ref:y,displayAfterTransitionEnd:f,onTransitionStart:p,onTransitionEnd:m}),S=Ue(g,y);return!c||!l?null:(0,R.jsx)(H,{ref:S,mod:[{initialized:b,hidden:x},d],...v(`root`),..._})});cu.displayName=`@mantine/core/FloatingIndicator`,cu.classes=ou,cu.varsResolver=su;function lu({style:e,size:t=16,...n}){return(0,R.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,R.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`})})}lu.displayName=`@mantine/core/AccordionChevron`;var uu={root:`m_b6d8b162`};function du(e){if(e===`start`)return`start`;if(e===`end`||e)return`end`}var fu={inherit:!1},pu=xt((e,{variant:t,lineClamp:n,gradient:r,size:i,textWrap:a})=>({root:{"--text-fz":fe(i),"--text-lh":pe(i),"--text-gradient":t===`gradient`?Wt(r,e):void 0,"--text-line-clamp":typeof n==`number`?n.toString():void 0,"--text-text-wrap":a}})),mu=Pr(e=>{let t=z(`Text`,fu,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=B({name:[`Text`,l],props:t,classes:uu,className:d,style:f,classNames:p,styles:m,unstyled:h,attributes:y,vars:u,varsResolver:pu});return(0,R.jsx)(H,{...x(`root`,{focusable:!0}),component:s?`span`:`p`,variant:g,mod:[{truncate:du(r),lineClamp:typeof n==`number`,inline:i,inherit:a},_],size:v,...b})});mu.classes=uu,mu.varsResolver=pu,mu.displayName=`@mantine/core/Text`;var[hu,gu]=M(`AppShell was not found in tree`),_u={root:`m_89ab340`,navbar:`m_45252eee`,aside:`m_9cdde9a`,header:`m_3b16f56b`,main:`m_8983817`,footer:`m_3840c879`,section:`m_6dcfc7c7`},vu=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellAside`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{component:`aside`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`aside`,{className:Ct({[Ml.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-aside-z-index":`calc(${c??d.zIndex} + 1)`}})});vu.classes=_u,vu.displayName=`@mantine/core/AppShellAside`;var yu=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellFooter`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{component:`footer`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`footer`,{className:Ct({[Ml.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-footer-z-index":(c??d.zIndex)?.toString()}})});yu.classes=_u,yu.displayName=`@mantine/core/AppShellFooter`;var bu=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellHeader`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{component:`header`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`header`,{className:Ct({[Ml.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-header-z-index":(c??d.zIndex)?.toString()}})});bu.classes=_u,bu.displayName=`@mantine/core/AppShellHeader`;var xu=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`AppShellMain`,null,e),s=gu();return(0,R.jsx)(H,{component:`main`,...s.getStyles(`main`,{className:n,style:r,classNames:t,styles:i}),...o})});xu.classes=_u,xu.displayName=`@mantine/core/AppShellMain`;var Su=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellNavbar`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{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)`}})});Su.classes=_u,Su.displayName=`@mantine/core/AppShellNavbar`;var Cu=Pr(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,grow:o,mod:s,...c}=z(`AppShellSection`,null,e),l=gu();return(0,R.jsx)(H,{mod:[{grow:o},s],...l.getStyles(`section`,{className:n,style:r,classNames:t,styles:i}),...c})});Cu.classes=_u,Cu.displayName=`@mantine/core/AppShellSection`;function wu(e){return typeof e==`object`?e.base:e}function Tu(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 Eu(e){return!(typeof e!=`object`||!e||Object.keys(e).length===1&&`base`in e)}function Du({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`)),Tu(o)){let t=E(wu(o));e[`--app-shell-aside-width`]=t,e[`--app-shell-aside-offset`]=t}if(Eu(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 Ou({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`),Tu(i)){let t=E(wu(i));e[`--app-shell-footer-height`]=t,a&&(e[`--app-shell-footer-offset`]=t)}Eu(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 ku({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`),Tu(i)){let t=E(wu(i));e[`--app-shell-header-height`]=t,a&&(e[`--app-shell-header-offset`]=t)}Eu(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 Au({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`)),Tu(o)){let t=E(wu(o));e[`--app-shell-navbar-width`]=t,e[`--app-shell-navbar-offset`]=t,a===`static`&&(e[`--app-shell-navbar-grid-width`]=t)}if(Eu(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 ju(e){return Number(e)===0?`0px`:ue(e)}function Mu({padding:e,baseStyles:t,minMediaStyles:n}){Tu(e)&&(t[`--app-shell-padding`]=ju(wu(e))),Eu(e)&&(e.base&&(t[`--app-shell-padding`]=ju(e.base)),v(e).forEach(t=>{t!==`base`&&(n[t]=n[t]||{},n[t][`--app-shell-padding`]=ju(e[t]))}))}function Nu({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`),Au({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,navbar:e,theme:a,mode:o}),Du({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,aside:r,theme:a,mode:o}),ku({baseStyles:l,minMediaStyles:s,header:t,mode:o}),Ou({baseStyles:l,minMediaStyles:s,footer:n,mode:o}),Mu({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 Pu({navbar:e,header:t,aside:n,footer:r,padding:i,mode:a,selector:o}){let s=Cn(),c=Qt(),{media:l,baseStyles:u}=Nu({navbar:e,header:t,footer:r,aside:n,padding:i,theme:s,mode:a});return(0,R.jsx)(nr,{media:l,styles:u,selector:o||c.cssVariablesSelector})}function Fu({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 Iu={withBorder:!0,padding:0,transitionDuration:200,transitionTimingFunction:`ease`,zIndex:se(`app`),mode:`fixed`},Lu=xt((e,{transitionDuration:t,transitionTimingFunction:n})=>({root:{"--app-shell-transition-duration":`${t}ms`,"--app-shell-transition-timing-function":n}})),Ru=V(e=>{let t=z(`AppShell`,Iu,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=B({name:`AppShell`,classes:_u,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:S,vars:s,varsResolver:Lu}),E=Fu({disabled:g,transitionDuration:d}),D=ze(C);return(0,R.jsxs)(hu,{value:{getStyles:T,withBorder:l,zIndex:m,disabled:g,offsetScrollbars:y,mode:b},children:[(0,R.jsx)(Pu,{navbar:c,header:p,aside:_,footer:v,padding:u,mode:b,selector:b===`static`?`#${D}`:void 0}),(0,R.jsx)(H,{...T(`root`),id:D,mod:[{resizing:E,layout:h,disabled:g,mode:b},x],...w})]})});Ru.classes=_u,Ru.varsResolver=Lu,Ru.displayName=`@mantine/core/AppShell`,Ru.Navbar=Su,Ru.Header=bu,Ru.Main=xu,Ru.Aside=vu,Ru.Footer=yu,Ru.Section=Cu;function zu(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=>zu(e))}:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?{value:e,label:`${e}`}:e}function Bu(e){return e?e.map(e=>zu(e)):[]}function Vu(e){return e.reduce((e,t)=>`group`in t?{...e,...Vu(t.items)}:(e[`${t.value}`]=t,e),{})}var Hu={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`},Uu={error:null},Wu=xt((e,{size:t,color:n})=>({chevron:{"--combobox-chevron-size":N(t,`combobox-chevron-size`),"--combobox-chevron-color":n?Vt(n,e):void 0}})),Gu=V(e=>{let t=z(`ComboboxChevron`,Uu,e),{size:n,error:r,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,attributes:u,mod:d,...f}=t,p=B({name:`ComboboxChevron`,classes:Hu,props:t,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,varsResolver:Wu,attributes:u,rootSelector:`chevron`});return(0,R.jsx)(H,{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,R.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`})})});Gu.classes=Hu,Gu.varsResolver=Wu,Gu.displayName=`@mantine/core/ComboboxChevron`;var[Ku,qu]=M(`Combobox component was not found in tree`);function Ju({onMouseDown:e,onClick:t,onClear:n,...r}){return(0,R.jsx)(tu.ClearButton,{tabIndex:-1,"aria-hidden":!0,...r,onMouseDown:t=>{t.preventDefault(),e?.(t)},onClick:e=>{n(),t?.(e)}})}Ju.displayName=`@mantine/core/ComboboxClearButton`;var Yu=V(e=>{let{classNames:t,styles:n,className:r,style:i,hidden:a,...o}=z(`ComboboxDropdown`,null,e),s=qu();return(0,R.jsx)(Qs.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})})});Yu.classes=Hu,Yu.displayName=`@mantine/core/ComboboxDropdown`;var Xu={refProp:`ref`},Zu=V(e=>{let{children:t,refProp:n,ref:r}=z(`ComboboxDropdownTarget`,Xu,e);if(qu(),!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,R.jsx)(Qs.Target,{ref:r,refProp:n,children:t})});Zu.displayName=`@mantine/core/ComboboxDropdownTarget`;var Qu=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`ComboboxEmpty`,null,e),s=qu();return(0,R.jsx)(H,{...s.getStyles(`empty`,{className:n,classNames:t,styles:i,style:r}),...o})});Qu.classes=Hu,Qu.displayName=`@mantine/core/ComboboxEmpty`;function q({onKeyDown:e,onClick:t,withKeyboardNavigation:n,withAriaAttributes:r,withExpandedAttribute:i,targetType:a,autoComplete:o}){let s=qu(),[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 $u={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},J=V(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=z(`ComboboxEventsTarget`,$u,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=qu(),f=q({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))})});J.displayName=`@mantine/core/ComboboxEventsTarget`;var Y=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`ComboboxFooter`,null,e),s=qu();return(0,R.jsx)(H,{...s.getStyles(`footer`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});Y.classes=Hu,Y.displayName=`@mantine/core/ComboboxFooter`;var X=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,children:o,label:s,id:c,...l}=z(`ComboboxGroup`,null,e),u=qu(),d=ze(c),f=s!=null&&s!==!1&&s!==``;return(0,R.jsxs)(H,{role:`group`,"aria-labelledby":f?d:void 0,...u.getStyles(`group`,{className:n,classNames:t,style:r,styles:i}),...l,children:[f&&(0,R.jsx)(`div`,{id:d,...u.getStyles(`groupLabel`,{classNames:t,styles:i}),children:s}),o]})});X.classes=Hu,X.displayName=`@mantine/core/ComboboxGroup`;var ed=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`ComboboxHeader`,null,e),s=qu();return(0,R.jsx)(H,{...s.getStyles(`header`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});ed.classes=Hu,ed.displayName=`@mantine/core/ComboboxHeader`;function td({value:e,valuesDivider:t=`,`,...n}){return(0,R.jsx)(`input`,{type:`hidden`,value:Array.isArray(e)?e.join(t):e?`${e}`:``,...n})}td.displayName=`@mantine/core/ComboboxHiddenInput`;var nd=V(e=>{let t=z(`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=qu(),_=(0,A.useId)(),v=c||_;return(0,R.jsx)(H,{...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)}})});nd.classes=Hu,nd.displayName=`@mantine/core/ComboboxOption`;var rd=V(e=>{let{classNames:t,className:n,style:r,styles:i,id:a,onMouseDown:o,labelledBy:s,...c}=z(`ComboboxOptions`,null,e),l=qu(),u=ze(a);return(0,A.useEffect)(()=>{l.store.setListId(u)},[u]),(0,R.jsx)(H,{...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)}})});rd.classes=Hu,rd.displayName=`@mantine/core/ComboboxOptions`;var id={withAriaAttributes:!0,withKeyboardNavigation:!0},ad=V(e=>{let{classNames:t,styles:n,unstyled:r,vars:i,withAriaAttributes:a,onKeyDown:o,onClick:s,withKeyboardNavigation:c,size:l,ref:u,...d}=z(`ComboboxSearch`,id,e),f=qu(),p=f.getStyles(`search`),m=q({targetType:`input`,withAriaAttributes:a,withKeyboardNavigation:c,withExpandedAttribute:!1,onKeyDown:o,onClick:s,autoComplete:`off`});return(0,R.jsx)(tu,{ref:Ue(u,f.store.searchRef),classNames:[{input:p.className},t],styles:[{input:p.style},n],size:l||f.size,...m,...d,__staticSelector:`Combobox`})});ad.classes=Hu,ad.displayName=`@mantine/core/ComboboxSearch`;var od={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},sd=V(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=z(`ComboboxTarget`,od,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=qu(),f=q({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,R.jsx)(Qs.Target,{refProp:n,ref:Ue(c,d.store.targetRef),children:p})});sd.displayName=`@mantine/core/ComboboxTarget`;function cd(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 ld(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 ud(e){for(let t=0;t<e.length;t+=1)if(!e[t].hasAttribute(`data-combobox-disabled`))return t;return-1}function dd({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(ld(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(cd(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(ud(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 fd={keepMounted:!0,keepMountedMode:`display-none`,withinPortal:!0,resetSelectionOnOptionHover:!1,width:`target`,transitionProps:{transition:`fade`,duration:0},size:`sm`},pd=xt((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`)}})),Z=e=>{let t=z(`Combobox`,fd,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=dd(),x=o||b,S=B({name:p||`Combobox`,classes:Hu,props:t,classNames:n,styles:r,unstyled:i,attributes:h,vars:s,varsResolver:pd}),C=()=>{l?.(),x.closeDropdown()};return(0,R.jsx)(Ku,{value:{getStyles:S,store:x,onOptionSubmit:c,size:u,resetSelectionOnOptionHover:f,readOnly:m,floatingHeight:g},children:(0,R.jsx)(Qs,{opened:x.dropdownOpened,...v,middlewares:y,onChange:e=>!e&&C(),withRoles:!1,unstyled:i,children:a})})};Z.extend=e=>e,Z.classes=Hu,Z.varsResolver=pd,Z.displayName=`@mantine/core/Combobox`,Z.Target=sd,Z.Dropdown=Yu,Z.Options=rd,Z.Option=nd,Z.Search=ad,Z.Empty=Qu,Z.Chevron=Gu,Z.Footer=Y,Z.Header=ed,Z.EventsTarget=J,Z.DropdownTarget=Zu,Z.Group=X,Z.ClearButton=Ju,Z.HiddenInput=td;function md({size:e,style:t,...n}){let r=e===void 0?t:{width:E(e),height:E(e),...t};return(0,R.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,R.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 hd(e){return`group`in e}function gd({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;hd(o)&&i.push({group:o.group,items:gd({options:o.items,search:t,limit:n-i.length})}),hd(o)||o.label.toLowerCase().includes(r)&&i.push(o)}return i}function _d(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 vd(e,t=new Set){if(Array.isArray(e))for(let n of e)if(hd(n))vd(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 yd(e,t){return Array.isArray(e)?e.includes(t):e===t}function bd({data:e,withCheckIcon:t,withAlignedLabels:n,value:r,checkIconPosition:i,unstyled:a,renderOption:o}){if(!hd(e)){let s=yd(r,e.value),c=t&&(s?(0,R.jsx)(md,{className:Hu.optionsDropdownCheckIcon}):n?(0,R.jsx)(`div`,{className:Hu.optionsDropdownCheckPlaceholder}):null),l=(0,R.jsxs)(R.Fragment,{children:[i===`left`&&c,(0,R.jsx)(`span`,{children:e.label}),i===`right`&&c]});return(0,R.jsx)(Z.Option,{value:e.value,disabled:e.disabled,className:Ct({[Hu.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,R.jsx)(bd,{data:e,value:r,unstyled:a,withCheckIcon:t,withAlignedLabels:n,checkIconPosition:i,renderOption:o},`${e.value}`));return(0,R.jsx)(Z.Group,{label:e.group,children:s})}function xd({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=qu();vd(e);let x=typeof i==`string`?(r||gd)({options:e,search:l?i:``,limit:a??1/0}):e,S=_d(x),C=x.map((e,t)=>(0,R.jsx)(bd,{data:e,withCheckIcon:u,withAlignedLabels:d,value:f,checkIconPosition:p,unstyled:h,renderOption:_},hd(e)?`group-${typeof e.group==`string`?e.group:t}`:`${e.value}`));return(0,R.jsx)(Z.Dropdown,{hidden:t||n&&S,"data-composed":!0,children:(0,R.jsxs)(Z.Options,{labelledBy:g,"aria-label":y,children:[c?(0,R.jsx)(ss.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,R.jsx)(Z.Empty,{children:m})]})})}var Sd={root:`m_347db0ec`,"root--dot":`m_fbd81e3d`,label:`m_5add502a`,section:`m_91fdda9b`},Cd=xt((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`?Vt(n,e):void 0}}}),wd=Pr(e=>{let t=z(`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=B({name:`Badge`,props:t,classes:Sd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:y,vars:s,varsResolver:Cd});return(0,R.jsxs)(H,{variant:m,mod:[{block:h,circle:_,"with-right-section":!!f,"with-left-section":!!d},v],...x(`root`,{variant:m}),...b,children:[d&&(0,R.jsx)(`span`,{...x(`section`),"data-position":`left`,children:d}),(0,R.jsx)(`span`,{...x(`label`),children:p}),f&&(0,R.jsx)(`span`,{...x(`section`),"data-position":`right`,children:f})]})});wd.classes=Sd,wd.varsResolver=Cd,wd.displayName=`@mantine/core/Badge`;var Td={root:`m_fea6bf1a`,burger:`m_d4fb9cad`},Ed=xt((e,{color:t,size:n,lineSize:r,transitionDuration:i,transitionTimingFunction:a})=>({root:{"--burger-color":t?Vt(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}})),Dd=V(e=>{let t=z(`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=B({name:`Burger`,classes:Td,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:s,varsResolver:Ed});return(0,R.jsxs)(ds,{...h(`root`),...m,children:[(0,R.jsx)(H,{mod:[`reduce-motion`,{opened:c}],...h(`burger`)}),l]})});Dd.classes=Td,Dd.varsResolver=Ed,Dd.displayName=`@mantine/core/Burger`;var Od={root:`m_77c9d27d`,inner:`m_80f1301b`,label:`m_811560b9`,section:`m_a74036a`,loader:`m_a25b86ee`,group:`m_80d6d844`,groupSection:`m_70be2a01`},kd={orientation:`horizontal`},Ad=xt((e,{borderWidth:t})=>({group:{"--button-border-width":E(t)}})),jd=V(e=>{let t=z(`ButtonGroup`,kd,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,orientation:s,vars:c,borderWidth:l,mod:u,attributes:d,...f}=z(`ButtonGroup`,kd,e),p=B({name:`ButtonGroup`,props:t,classes:Od,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:c,varsResolver:Ad,rootSelector:`group`});return(0,R.jsx)(H,{...p(`group`),mod:[{orientation:s},u],role:`group`,...f})});jd.classes=Od,jd.varsResolver=Ad,jd.displayName=`@mantine/core/ButtonGroup`;var Md=xt((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}}}),Nd=V(e=>{let t=z(`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=B({name:`ButtonGroupSection`,props:t,classes:Od,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:s,varsResolver:Md,rootSelector:`groupSection`});return(0,R.jsx)(H,{...p(`groupSection`),...f})});Nd.classes=Od,Nd.varsResolver=Md,Nd.displayName=`@mantine/core/ButtonGroupSection`;var Pd={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${E(1)}))`},out:{opacity:0,transform:`translate(-50%, -200%)`},common:{transformOrigin:`center`},transitionProperty:`transform, opacity`},Fd=xt((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}}}),Id=Pr(e=>{let t=z(`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=B({name:`Button`,props:t,classes:Od,className:i,style:n,classNames:g,styles:_,unstyled:v,attributes:S,vars:r,varsResolver:Fd}),T=!!c,E=!!l;return(0,R.jsxs)(ds,{...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,R.jsx)(Is,{mounted:p,transition:Pd,duration:150,children:e=>(0,R.jsx)(H,{component:`span`,...w(`loader`,{style:e}),"aria-hidden":!0,children:(0,R.jsx)(oc,{color:`var(--button-color)`,size:`calc(var(--button-height) / 1.8)`,...m})})}),(0,R.jsxs)(`span`,{...w(`inner`),children:[c&&(0,R.jsx)(H,{component:`span`,...w(`section`),mod:{position:`left`},children:c}),(0,R.jsx)(H,{component:`span`,mod:{loading:p},...w(`label`),children:s}),l&&(0,R.jsx)(H,{component:`span`,...w(`section`),mod:{position:`right`},children:l})]})]})});Id.classes=Od,Id.varsResolver=Fd,Id.displayName=`@mantine/core/Button`,Id.Group=jd,Id.GroupSection=Nd;function Ld(e){let t=e.currentTarget;return yt(t).activeElement!==t}function Rd(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 zd={root:`m_f0824112`,description:`m_57492dcc`,section:`m_690090b5`,label:`m_1f6ac4c4`,body:`m_f07af9d2`,children:`m_e17b862f`,chevron:`m_1fd8a00b`},Bd=xt((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)}}}),Vd=Pr(e=>{let t=z(`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=B({name:`NavLink`,props:t,classes:zd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:C,vars:s,varsResolver:Bd}),[k,A]=We({value:c,defaultValue:l,finalValue:!1,onChange:u}),j=!!d,M=e=>{w?.(e),j&&(e.preventDefault(),A(!k))};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(ds,{...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,R.jsx)(H,{component:`span`,...O(`section`),mod:{position:`left`},children:m}),(0,R.jsxs)(H,{...O(`body`),mod:{"no-wrap":y},children:[(0,R.jsx)(H,{component:`span`,...O(`label`),children:g}),(0,R.jsx)(H,{component:`span`,mod:{active:f},...O(`description`),children:_})]}),(j||h!==void 0)&&(0,R.jsx)(H,{...O(`section`),component:`span`,mod:{rotate:k&&!v,position:`right`},children:j&&h===void 0?(0,R.jsx)(lu,{...O(`chevron`)}):h})]}),j&&(0,R.jsx)(Wr,{expanded:k,keepMounted:E,...O(`collapse`),children:(0,R.jsx)(`div`,{...O(`children`),children:d})})]})});Vd.classes=zd,Vd.varsResolver=Bd,Vd.displayName=`@mantine/core/NavLink`;var Hd={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},Ud={withItemsBorders:!0},Wd=xt((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:de(t),"--sc-color":n?Vt(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)}})),Gd=Nr(e=>{let t=z(`SegmentedControl`,Ud,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=B({name:`SegmentedControl`,props:t,classes:Hd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:E,vars:s,varsResolver:Wd}),j=Cn(),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)(H,{...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)(H,{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:L({color:y,theme:j,autoContrast:C})},key:`${e.value}-label`},(0,R.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,R.jsxs)(H,{...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,R.jsx)(cu,{target:ae[`${ce}`],parent:re,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...k(`indicator`)},te),de]})});Gd.classes=Hd,Gd.varsResolver=Wd,Gd.displayName=`@mantine/core/SegmentedControl`;var Kd={size:`sm`,withCheckIcon:!0,allowDeselect:!0,checkIconPosition:`left`,openOnFocus:!0},qd=Nr(e=>{let t=z([`Input`,`InputWrapper`,`Select`],Kd,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)(()=>Bu(m),[m]),I=(0,A.useRef)({}),Ee=(0,A.useMemo)(()=>Vu(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=dd({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}=zn({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,R.jsx)(Z.ClearButton,{...pe,onClear:()=>{ke(null,null),Le(``),ge?.()}}),He=de&&Oe!=null&&!S&&!x;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(Z,{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,R.jsx)(Z.Target,{targetType:k?`input`:`button`,autoComplete:P,withExpandedAttribute:!0,children:(0,R.jsx)(K,{id:De,__defaultRightSection:(0,R.jsx)(Z.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(Ld(e)){if(!x){let t=Rd(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,R.jsx)(xd,{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,R.jsx)(Z.HiddenInput,{value:Oe,name:re,form:ie,disabled:S,...me})]})});qd.classes={...K.classes,...Z.classes},qd.displayName=`@mantine/core/Select`;var Jd={root:`m_6d731127`},Yd={gap:`md`,align:`stretch`,justify:`flex-start`},Xd=xt((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":ue(t),"--stack-align":n,"--stack-justify":r}})),Zd=V(e=>{let t=z(`Stack`,Yd,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=B({name:`Stack`,props:t,classes:Jd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:Xd});return(0,R.jsx)(H,{...m(`root`),variant:d,...p})});Zd.classes=Jd,Zd.varsResolver=Xd,Zd.displayName=`@mantine/core/Stack`;var[Qd,$d]=M(`Tabs component was not found in the tree`),ef={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`},tf=V(e=>{let t=z(`TabsList`,null,e),{children:n,className:r,grow:i,justify:a,classNames:o,styles:s,style:c,mod:l,...u}=t,d=$d();return(0,R.jsx)(H,{...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})});tf.classes=ef,tf.displayName=`@mantine/core/TabsList`;var nf=V(e=>{let t=z(`TabsPanel`,null,e),{children:n,className:r,value:i,classNames:a,styles:o,style:s,mod:c,keepMounted:l,...u}=t,d=sn(),f=$d();(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,R.jsx)(A.Activity,{mode:p?`visible`:`hidden`,children:n}):m||p?n:null;return(0,R.jsx)(H,{...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})});nf.classes=ef,nf.displayName=`@mantine/core/TabsPanel`;var rf=V(e=>{let t=z(`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=Cn(),{dir:y}=Hr(),b=$d(),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,R.jsxs)(ds,{...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?Vt(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,R.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`left`,children:a}),r&&(0,R.jsx)(`span`,{...b.getStyles(`tabLabel`,C),children:r}),i&&(0,R.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`right`,children:i})]})});rf.classes=ef,rf.displayName=`@mantine/core/TabsTab`;var af=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,of={keepMounted:!0,keepMountedMode:`activity`,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},sf=xt((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":de(t),"--tabs-color":Vt(n,e),"--tabs-text-color":Xt(r,e)?L({color:n,theme:e,autoContrast:r}):void 0}})),cf=V(e=>{let t=z(`Tabs`,of,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=B({name:`Tabs`,props:t,classes:ef,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:sf});return(0,R.jsx)(Qd,{value:{placement:h,value:te,orientation:a,id:O,loop:s,activateTabWithKeyboard:l,getTabId:ee(`${O}-tab`,af),getPanelId:ee(`${O}-panel`,af),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,R.jsx)(H,{id:O,variant:d,mod:[{orientation:a,inverted:a===`horizontal`&&m,placement:a===`vertical`&&h},T],...re(`root`),...D,children:o})})});cf.classes=ef,cf.varsResolver=sf,cf.displayName=`@mantine/core/Tabs`,cf.Tab=rf,cf.Panel=nf,cf.List=tf;var lf=V(e=>{let t=z([`Input`,`InputWrapper`,`TextInput`],null,e);return(0,R.jsx)(K,{component:`input`,...t,__staticSelector:`TextInput`})});lf.classes=K.classes,lf.displayName=`@mantine/core/TextInput`;var uf=_();function df(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 ff(e,t,n){let r=e.trim();return r.length===0?{kind:`ignored`}:r.startsWith(`/`)?pf(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 pf(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}`}}}}var mf=11,hf=19;function gf(e){return e.slice(mf,hf)}function _f(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} ${e.status} by ${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 vf(e){return{type:`chat`,sender:e.from,content:e.content,timestamp:e.timestamp}}function yf({message:e}){switch(e.type){case`chat`:return(0,R.jsxs)(wc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,R.jsx)(mu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,R.jsx)(mu,{c:`dimmed`,size:`xs`,span:!0,children:gf(e.timestamp)}),(0,R.jsxs)(mu,{span:!0,children:[`: `,e.content]})]});case`dm`:return(0,R.jsxs)(wc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,R.jsx)(wd,{color:`grape`,size:`xs`,children:`DM`}),(0,R.jsx)(mu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,R.jsx)(mu,{c:`dimmed`,size:`xs`,span:!0,children:gf(e.timestamp)}),(0,R.jsxs)(mu,{span:!0,children:[`: `,e.content]})]});case`system`:return(0,R.jsx)(mu,{c:`dimmed`,fs:`italic`,size:`sm`,children:e.text});case`status`:return(0,R.jsx)(mu,{c:`yellow`,size:`xs`,children:e.text})}}function bf({messages:e}){let t=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.length]),(0,R.jsx)(ss,{flex:1,p:`md`,viewportRef:t,"aria-label":`Conversation`,children:(0,R.jsx)(Zd,{gap:4,children:e.map((e,t)=>(0,R.jsx)(yf,{message:e},t))})})}function xf({messages:e,rooms:t,currentRoom:n,dmTarget:r,connected:i,sidebarOpened:a,onToggleSidebar:o,onSendAction:s,onLeaveRoom:c,onConnectToMesh:l}){let[u,d]=(0,A.useState)(``),f=(n===void 0?void 0:t.find(e=>e.id===n)?.name??n)??(r===void 0?`Select a room`:`DM with ${r}`),p=()=>{let e=u.trim();if(e){switch(ff(e,n,r).kind){case`action`:s(e);break;case`local`:s(e)}d(``)}};return(0,R.jsxs)(Zd,{h:`100%`,gap:0,children:[(0,R.jsxs)(wc,{component:`header`,justify:`space-between`,px:`md`,py:`sm`,bg:`dark.6`,children:[(0,R.jsxs)(wc,{gap:`sm`,children:[(0,R.jsx)(Dd,{opened:a,onClick:o,size:`sm`,"aria-label":`Toggle sidebar`}),(0,R.jsx)(mu,{fw:600,children:f})]}),n!==void 0&&(0,R.jsx)(Id,{size:`xs`,variant:`subtle`,onClick:c,children:`Leave`})]}),(0,R.jsx)(bf,{messages:e}),!i&&e.length===0&&(0,R.jsxs)(Zd,{align:`center`,justify:`center`,gap:`md`,p:`xl`,children:[(0,R.jsx)(mu,{c:`dimmed`,children:`Connect to a local mesh to discover agents and rooms.`}),(0,R.jsx)(Id,{variant:`outline`,onClick:l,children:`Connect to local mesh`})]}),(0,R.jsxs)(wc,{px:`md`,py:`sm`,gap:`xs`,bg:`dark.6`,children:[(0,R.jsx)(lf,{flex:1,placeholder:`Type a message or /command...`,"aria-label":`Message`,autoComplete:`off`,value:u,onChange:e=>{d(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&p()}}),(0,R.jsx)(Id,{onClick:p,children:`Send`})]})]})}function Sf(e){return typeof e==`object`&&!!e}function Cf(e){return Array.isArray(e)}function wf(e){return Array.isArray(e)}function Tf(e){return Array.isArray(e)}function Ef(e){return Sf(e)&&Array.isArray(e.nodes)&&Array.isArray(e.edges)}function Df(e){return!Sf(e)||typeof e.rttMs!=`number`||!Sf(e.local)||!Sf(e.outcome)?!1:typeof e.outcome.result==`string`}async function Of(){let e=await(await fetch(`/api/agents`)).json();if(!Cf(e))throw Error(`Invalid agents response`);return e}async function kf(){let e=await(await fetch(`/api/rooms`)).json();if(!wf(e))throw Error(`Invalid rooms response`);return e}async function Af(e,t){let n=t===void 0?`/api/rooms/${encodeURIComponent(e)}/messages`:`/api/rooms/${encodeURIComponent(e)}/messages?since=${encodeURIComponent(t)}`,r=await(await fetch(n)).json();if(!Tf(r))throw Error(`Invalid messages response`);return r}async function jf(e){try{let t=await e.json();if(Sf(t)&&typeof t.error==`string`)return t.error}catch{}return e.statusText||`HTTP ${String(e.status)}`}async function Mf(){let e=await fetch(`/api/mesh/graph`);if(!e.ok)throw Error(await jf(e));let t=await e.json();if(!Ef(t))throw Error(`Invalid mesh graph response`);return t}async function Nf(e,t){let n=new URLSearchParams({target:e});t!==void 0&&n.set(`timeoutMs`,String(t));let r=await fetch(`/api/mesh/trace?${n.toString()}`);if(!r.ok)throw Error(await jf(r));let i=await r.json();if(!Df(i))throw Error(`Invalid mesh trace response`);return i}function Pf(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 Ff(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return If(this.cover(t,n),t,n,e)}function If(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 Lf(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)If(this,o[n],s[n],e[n]);return this}function Rf(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 zf(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Bf(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 Vf(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Q(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 Vf(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 Vf(p[3],g,_,c,l),new Vf(p[2],o,_,g,l),new Vf(p[1],g,s,c,_),new Vf(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 Hf(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 Uf(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Wf(){return this._root}function Gf(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Kf(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new Vf(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 Vf(i,l,u,s,c)),(i=r[2])&&t.push(new Vf(i,a,u,l,c)),(i=r[1])&&t.push(new Vf(i,l,o,s,u)),(i=r[0])&&t.push(new Vf(i,a,o,l,u))}return this}function qf(e){var t=[],n=[],r;for(this._root&&t.push(new Vf(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 Vf(a,o,s,u,d)),(a=i[1])&&t.push(new Vf(a,u,s,c,d)),(a=i[2])&&t.push(new Vf(a,o,d,u,l)),(a=i[3])&&t.push(new Vf(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 Jf(e){return e[0]}function Yf(e){return arguments.length?(this._x=e,this):this._x}function Xf(e){return e[1]}function Zf(e){return arguments.length?(this._y=e,this):this._y}function Qf(e,t,n){var r=new $f(t??Jf,n??Xf,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function $f(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 ep(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var $=Qf.prototype=$f.prototype;$.copy=function(){var e=new $f(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=ep(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]=ep(r));return e},$.add=Ff,$.addAll=Lf,$.cover=Rf,$.data=zf,$.extent=Bf,$.find=Q,$.remove=Hf,$.removeAll=Uf,$.root=Wf,$.size=Gf,$.visit=Kf,$.visitAfter=qf,$.x=Yf,$.y=Zf;function tp(e){return function(){return e}}function np(e){return(e()-.5)*1e-6}function rp(e){return e.index}function ip(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function ap(e){var t=rp,n=d,r,i=tp(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||np(l),m=f.y+f.vy-d.y-d.vy||np(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=ip(u,d.source)),typeof d.target!=`object`&&(d.target=ip(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:tp(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:tp(+e),h(),f):i},f}var op={value:()=>{}};function sp(){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 cp(n)}function cp(e){this._=e}function lp(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}})}cp.prototype=sp.prototype={constructor:cp,on:function(e,t){var n=this._,r=lp(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=up(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]=dp(n[i],e.name,t);else if(t==null)for(i in n)n[i]=dp(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 cp(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 up(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function dp(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=op,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var fp=0,pp=0,mp=0,hp=1e3,gp,_p,vp=0,yp=0,bp=0,xp=typeof performance==`object`&&performance.now?performance:Date,Sp=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Cp(){return yp||=(Sp(wp),xp.now()+bp)}function wp(){yp=0}function Tp(){this._call=this._time=this._next=null}Tp.prototype=Ep.prototype={constructor:Tp,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Cp():+n)+(t==null?0:+t),!this._next&&_p!==this&&(_p?_p._next=this:gp=this,_p=this),this._call=e,this._time=n,jp()},stop:function(){this._call&&(this._call=null,this._time=1/0,jp())}};function Ep(e,t,n){var r=new Tp;return r.restart(e,t,n),r}function Dp(){Cp(),++fp;for(var e=gp,t;e;)(t=yp-e._time)>=0&&e._call.call(void 0,t),e=e._next;--fp}function Op(){yp=(vp=xp.now())+bp,fp=pp=0;try{Dp()}finally{fp=0,Ap(),yp=0}}function kp(){var e=xp.now(),t=e-vp;t>hp&&(bp-=t,vp=e)}function Ap(){for(var e,t=gp,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:gp=n);_p=e,jp(r)}function jp(e){fp||(pp&&=clearTimeout(pp),e-yp>24?(e<1/0&&(pp=setTimeout(Op,e-xp.now()-bp)),mp&&=clearInterval(mp)):(mp||=(vp=xp.now(),setInterval(kp,hp)),fp=1,Sp(Op)))}var Mp=1664525,Np=1013904223,Pp=4294967296;function Fp(){let e=1;return()=>(e=(Mp*e+Np)%Pp)/Pp}function Ip(e){return e.x}function Lp(e){return e.y}var Rp=10,zp=Math.PI*(3-Math.sqrt(5));function Bp(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=Ep(d),l=sp(`tick`,`end`),u=Fp();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=Rp*Math.sqrt(.5+t),a=t*zp;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 Vp(){var e,t,n,r,i=tp(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=Qf(e,Ip,Lp).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=np(n),m+=d*d),f===0&&(f=np(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=np(n),m+=d*d),f===0&&(f=np(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:tp(+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 Hp=600,Up=400,Wp=300,Gp=10,Kp=8;function qp(e){let t=e.nodes.map(e=>({id:e})),n=e.edges.map(e=>({source:e.from,target:e.to,kind:e.kind})),r=Bp(t).force(`link`,ap(n).id(e=>e.id)).force(`charge`,Vp()).force(`center`,Pf(Hp/2,Up/2)).stop();for(let e=0;e<Wp;e++)r.tick();return{nodes:t,links:n}}function Jp(e){return typeof e==`object`?e:void 0}function Yp({graph:e,selectedDevice:t,onSelectDevice:n}){let{nodes:r,links:i}=(0,A.useMemo)(()=>qp(e),[e]);return r.length===0?(0,R.jsx)(mu,{c:`dimmed`,p:`md`,children:`No known devices in the mesh graph.`}):(0,R.jsx)(H,{p:`md`,children:(0,R.jsxs)(`svg`,{role:`img`,"aria-label":`Mesh connection graph`,viewBox:`0 0 ${String(Hp)} ${String(Up)}`,width:`100%`,style:{maxHeight:Up},children:[i.map(e=>{let t=Jp(e.source),n=Jp(e.target);return!t||!n?null:(0,R.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,R.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,R.jsx)(`circle`,{r:Gp,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,R.jsx)(`text`,{y:22,textAnchor:`middle`,fontSize:10,fill:`var(--mantine-color-text)`,children:e.id.slice(0,Kp)})]},e.id))]})})}var Xp=8;function Zp(e){return e.relayed?e.hubAddress===void 0?`relayed`:`relayed via ${e.hubAddress}`:`direct`}function Qp({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,Xp)}));return(0,R.jsxs)(Zd,{p:`md`,gap:`sm`,children:[(0,R.jsxs)(wc,{align:`flex-end`,gap:`xs`,children:[(0,R.jsx)(qd,{label:`Target device`,placeholder:`Choose a device`,size:`xs`,data:s,value:t??null,onChange:e=>{e!==null&&n(e)}}),(0,R.jsx)(Id,{size:`xs`,disabled:t===void 0||i,loading:i,onClick:r,children:`Trace`})]}),a!==void 0&&(0,R.jsx)(mu,{c:`red`,children:a}),o!==void 0&&(0,R.jsxs)(Zd,{gap:4,children:[(0,R.jsxs)(wc,{gap:`xs`,children:[(0,R.jsx)(wd,{color:o.outcome.result===`ok`?`green`:`red`,children:o.outcome.result===`ok`?`ok`:o.outcome.code??`error`}),(0,R.jsxs)(mu,{size:`sm`,children:[o.rttMs,`ms round trip`]})]}),(0,R.jsxs)(mu,{size:`sm`,c:`dimmed`,children:[`Local: `,Zp(o.local)]}),o.remote!==void 0&&(0,R.jsxs)(mu,{size:`sm`,c:`dimmed`,children:[`Remote: `,Zp(o.remote)]})]})]})}function $p({graph:e}){let[t,n]=(0,A.useState)(void 0),[r,i]=(0,A.useState)(!1),[a,o]=(0,A.useState)(void 0),[s,c]=(0,A.useState)(void 0);function l(){t!==void 0&&(i(!0),o(void 0),c(void 0),Nf(t).then(e=>{c(e)}).catch(e=>{o(e instanceof Error?e.message:String(e))}).finally(()=>{i(!1)}))}return e===void 0?(0,R.jsx)(mu,{c:`dimmed`,p:`md`,children:`Mesh graph is not available on this connection.`}):(0,R.jsxs)(cf,{defaultValue:`graph`,children:[(0,R.jsxs)(cf.List,{children:[(0,R.jsx)(cf.Tab,{value:`graph`,children:`Graph`}),(0,R.jsx)(cf.Tab,{value:`trace`,children:`Trace`})]}),(0,R.jsx)(cf.Panel,{value:`graph`,children:(0,R.jsx)(Yp,{graph:e,selectedDevice:t,onSelectDevice:n})}),(0,R.jsx)(cf.Panel,{value:`trace`,children:(0,R.jsx)(Zd,{children:(0,R.jsx)(Qp,{targets:e.nodes,selectedTarget:t,onSelectTarget:n,onTrace:l,loading:r,error:a,result:s})})})]})}function em(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)),em(a,i,n)}function tm(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)),tm(i,r)}var nm=`Project room for `;function rm(e){return e.description.startsWith(nm)}function im(e){return e.description.slice(17)}function am(e,t){let n=t.filter(e=>!rm(e)),r=new Map;for(let e of t)rm(e)&&r.set(im(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=cm(Array.from(i)),o=a===`/`?[]:om(a),s={children:new Map,agents:[]};for(let t of e)em(s,om(t.cwd).slice(o.length),t);for(let e of r.keys())tm(s,om(e).slice(o.length));return{roots:um(lm(s,a,``,r)),manualRooms:n}}function om(e){return e.split(`/`).filter(e=>e.length>0)}function sm(...e){return`/`+e.join(`/`)}function cm(e){if(e.length===0)return`/`;let t=e.map(om),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?`/`:sm(...t[0]?.slice(0,r)??[])}function lm(e,t,n,r){let i=[];for(let[a,o]of e.children){let e=n===``&&t===`/`?`/`+a:n===``?t+`/`+a:n+`/`+a,s=lm(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:um(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 um(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}var dm=[{value:`public`,label:`Public`},{value:`private`,label:`Private`},{value:`secret`,label:`Secret`}];function fm(e){return e===`public`||e===`private`||e===`secret`}function pm({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,R.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&(t(r.trim(),a,s.trim()),i(``),o(`public`),c(``))},children:(0,R.jsxs)(Zd,{gap:`xs`,p:`xs`,children:[(0,R.jsx)(lf,{label:`Room name`,name:`room-name`,required:!0,placeholder:`e.g. project-alpha`,size:`xs`,value:r,onChange:e=>{i(e.target.value)}}),(0,R.jsx)(qd,{label:`Type`,name:`room-type`,size:`xs`,data:dm,value:a,allowDeselect:!1,onChange:e=>{fm(e)&&o(e)}}),(0,R.jsx)(lf,{label:`Description (optional)`,name:`room-description`,placeholder:`What is this room about?`,size:`xs`,value:s,onChange:e=>{c(e.target.value)}}),(0,R.jsxs)(wc,{gap:`xs`,children:[(0,R.jsx)(Id,{type:`submit`,size:`xs`,flex:1,children:`Create`}),(0,R.jsx)(Id,{type:`button`,size:`xs`,flex:1,variant:`default`,onClick:n,children:`Cancel`})]})]})}):null}function mm({visible:e,onSubmit:t,onCancel:n}){let[r,i]=(0,A.useState)(``);if(!e)return null;let a=()=>{let e=r.trim();e&&(t(e),i(``))};return(0,R.jsxs)(wc,{gap:`xs`,py:4,children:[(0,R.jsx)(lf,{flex:1,size:`xs`,placeholder:`Room name...`,"aria-label":`Room name`,autoComplete:`off`,value:r,onChange:e=>{i(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&a(),e.key===`Escape`&&n()}}),(0,R.jsx)(Id,{size:`xs`,onClick:a,children:`Join`})]})}var hm={active:`green`,idle:`yellow`,busy:`red`,offline:`gray`};function gm({status:e}){return(0,R.jsx)(H,{w:8,h:8,style:{borderRadius:`50%`,backgroundColor:`var(--mantine-color-${hm[e]}-6)`}})}function _m({tree:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return(0,R.jsxs)(H,{mb:`xs`,children:[e.roots.map(e=>(0,R.jsx)(vm,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path)),e.manualRooms.length>0&&(0,R.jsxs)(H,{py:4,children:[(0,R.jsx)(mu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,px:`xs`,py:4,children:`Rooms`}),e.manualRooms.map(e=>(0,R.jsx)(Vd,{label:`${e.name} (${String(e.members.length)})`,active:i===e.id,onClick:()=>{t(e.id)}},e.id))]})]})}function vm({node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return e.type===`agent`?(0,R.jsx)(bm,{node:e,onSelectAgent:n,onRenameAgent:r}):(0,R.jsx)(ym,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i})}function ym({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,R.jsx)(Vd,{label:e.name,leftSection:(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`📁`}),defaultOpened:!0,active:o,...s,children:e.children.map(e=>(0,R.jsx)(vm,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path))})}function bm({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,R.jsx)(lf,{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,R.jsx)(Vd,{label:e.name,leftSection:(0,R.jsx)(gm,{status:e.status}),onClick:()=>{t(e.agentId)},onDoubleClick:c})}function xm({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=am(f?t:t.filter(e=>e.status!==`offline`),e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(wc,{justify:`space-between`,px:`md`,py:`sm`,children:[(0,R.jsx)(mu,{size:`sm`,fw:600,c:`accent`,children:`Agent Comms`}),(0,R.jsx)(mc,{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,R.jsxs)(ss,{flex:1,px:`xs`,children:[(0,R.jsx)(_m,{tree:m,onJoinRoom:r,onSelectAgent:i,onRenameAgent:a,currentRoom:n}),(0,R.jsxs)(wc,{justify:`space-between`,px:`xs`,py:4,children:[(0,R.jsx)(mu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,children:`Create`}),(0,R.jsx)(mc,{variant:`default`,size:`sm`,"aria-label":`Create room`,title:`Create room`,onClick:()=>{l(e=>!e)},children:`+`})]}),(0,R.jsx)(pm,{visible:c,onSubmit:(e,t,n)=>{o(e,t,n),l(!1)},onCancel:()=>{l(!1)}}),(0,R.jsx)(Id,{fullWidth:!0,size:`xs`,variant:`outline`,onClick:()=>{d(e=>!e)},children:`+ Join Room`}),(0,R.jsx)(mm,{visible:u,onSubmit:e=>{s(e),d(!1)},onCancel:()=>{d(!1)}})]})]})}function Sm(e){let[t,{toggle:n}]=Ye(!0),[r,i]=(0,A.useState)(`chat`);return(0,R.jsxs)(Ru,{navbar:{width:260,breakpoint:`sm`,collapsed:{desktop:!t,mobile:!t}},children:[(0,R.jsxs)(Ru.Navbar,{children:[(0,R.jsx)(xm,{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,R.jsx)(Gd,{m:`xs`,size:`xs`,fullWidth:!0,value:r,onChange:i,data:[{label:`Chat`,value:`chat`},{label:`Mesh`,value:`mesh`}]})]}),(0,R.jsx)(Ru.Main,{h:`100vh`,children:r===`chat`?(0,R.jsx)(xf,{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,R.jsx)($p,{graph:e.meshGraph})})]})}var Cm={currentRoom:void 0,dmTarget:void 0,agents:[],rooms:[],messages:[],connected:!1,meshGraph:void 0},wm=class{state={...Cm};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()}setMeshGraph(e){this.state={...this.state,meshGraph: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={...Cm,messages:[]},this.notify()}notify(){let e=this.state;for(let t of this.listeners)t(e)}};function Tm(e){return(0,A.useSyncExternalStore)(t=>e.subscribe(t),()=>e.get())}function Em(e){return Array.isArray(e)?e:e==null?[]:[e]}var Dm=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function Om(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}var km=class{index=BigInt(1);generate(){let e=this.index.toString(36);return this.index++,e}};function Am(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}var jm=Symbol.asyncDispose??Symbol.for(`asyncDispose`),Mm=class{isDone=!1;isExecuteComplete=!1;cleanup;next;constructor(e,t){this.cleanup=t,this.next=Om(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[jm](){this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`}))}[Symbol.asyncIterator](){return this}};function Nm(e){return JSON.stringify(e)}function Pm(e){for(let t of Object.values(e))if(t!==void 0)return!0;return!1}function Fm(e){if(!e)return!1;let t=typeof e;return t===`object`||t===`function`}var Im=new WeakMap;function Lm(e,t,{bind:n=!0}={}){let r=Reflect.get(e,t);if(!n||typeof r!=`function`)return r;let i=Im.get(r);i||Im.set(r,i=new WeakMap);let a=i.get(e);return a||i.set(e,a=r.bind(e)),a}var Rm=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 Dm(`Queue was closed.`),this.closed={reason:e},this.pendingPulls.forEach(([,t])=>t(e)),this.pendingPulls.length=0)}abort(e){e??=new Dm(`Queue was aborted.`),this.items.length=0,this.close(e)}},zm=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function Bm(e){try{return encodeURIComponent(e)}catch{return encodeURIComponent(e.replace(zm,`�`))}}function Vm(e){if(!e.includes(`%`))return e;try{return decodeURIComponent(e)}catch{return e}}function Hm(e){return e[0]??{}}var Um=`orpc`;function Wm(e){return e instanceof Error&&e.name.includes(`Abort`)}Object.getPrototypeOf(async function*(){}).constructor;function Gm(e){let t;return()=>{if(t)return t.result;let n=e();return t={result:n},n}}function Km(e){return`/${e.map(encodeURIComponent).join(`/`)}`}var qm=Symbol.for(`ORPC_TRACER`);function Jm(){return globalThis[qm]}function Ym(e){let t=Jm();if(t)return typeof e==`string`?t.startSpan(e):t.startSpan(e.name,e.parent)}function Xm(e,t){e&&e.recordException(Wm(t)?`info`:`error`,Zm(t))}function Zm(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 Qm(e,t){let n=Jm();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 Xm(e,t),t}finally{e.end()}})}function $m(e,t){let n=Jm();return!e||!n?t():n.withActiveSpan(e,t)}function eh(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o;return new Mm(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 th(e,t){let n=Gm(()=>Ym(e));return eh(t,{runWith:e=>$m(n(),e),mapResult(e){return n()?.addEvent(e.done?`completed`:`yielded`),e},onError(e){Xm(n(),e)},onFinish(){n()?.end()}})}function nh(e,...t){return typeof e==`function`?e(...t):e}function rh(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){return Lm(r in t?t:nh(e),r)},has(n,r){return Reflect.has(t,r)||Reflect.has(nh(e),r)}})}function*ih(e){if(!Fm(e))return;let t=Object.getPrototypeOf(e);for(;t!=null;)t.constructor&&(yield t.constructor),t=Object.getPrototypeOf(t)}function ah(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}var oh=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function sh(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o=Gm(()=>e.getReader()),s=Gm(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 ch(e,t){let n=Gm(()=>Ym(e));return sh(t,{runWith:e=>$m(n(),e),mapResult(e){return n()?.addEvent(e.done?`closed`:`enqueued`),e},onError(e){Xm(n(),e)},onFinish(){n()?.end()}})}function lh(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 uh(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 dh=class extends TypeError{},fh=class extends Error{constructor(e,t={}){super(t?.message??`Error Event`,t),this.data=e}},ph=/\r\n|[\n\r]/;function mh(e){return ph.test(e)}function hh(e){if(mh(e))throw new dh(`Event's id must not contain a carriage return or newline character`)}function gh(e){if(!Number.isInteger(e)||e<0)throw new dh(`Event's retry must be a integer and >= 0`)}function _h(e){if(mh(e))throw new dh(`Event's comment must not contain a carriage return or newline character`)}var vh=Symbol.for(`STANDARD_SERVER_EVENT_META`),yh=Symbol.for(`STANDARD_SERVER_EVENT_SOURCE`);function bh(e,t){let n;if(t.id!==void 0&&(hh(t.id),n??={},n.id=t.id),t.retry!==void 0&&(gh(t.retry),n??={},n.retry=t.retry),t.comments!==void 0){for(let e of t.comments)_h(e);n??={},n.comments=t.comments}return n?new Proxy(e,{get(e,t,r){return t===yh?e:t===vh?n:Lm(e,t)}}):e}function xh(e){if(!Fm(e))return[e,void 0];let t=e[vh];return[e[yh]??e,t]}function Sh(e){if(Fm(e))return e[vh]}function Ch(e,t=`inline`){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,`_`).replace(/[\\"]/g,`\\$&`)}"; filename*=utf-8''${Bm(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function wh(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 Vm(t)}else if(t)return Vm(t);let r=e.match(/(?:^|;)\s*filename=(?:"((?:\\.|[^"\\])*)"|([^";]*))/i);return r?.[1]===void 0?r?.[2]?.trim()||void 0:r[1].replace(/\\(.)/g,`$1`)}function Th(e){if(typeof e==`string`||e===void 0)return e;if(e.length!==0)return e.join(`, `)}function Eh(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:[...Em(t),...Em(i)]}return n}function Dh(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 Oh(e){return Fm(e)?Object.values(e).every(e=>e===void 0||typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)):!1}function kh(e){return Number.isInteger(e)}var Ah={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},jh,Mh=class e extends Error{static{let t=Symbol.for(`ORPC_ERROR_CONSTRUCTORS`);globalThis[t]??=new WeakSet,jh=globalThis[t],jh.add(e)}name=`ORPCError`;defined=!1;code;data;constructor(e,...t){let n=Hm(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(!jh.has(this))return super[Symbol.hasInstance](e);for(let t of ih(e))if(jh.has(t))return!0;return!1}},Nh=class extends Error{name=`MalformedResponseError`;response;constructor(e){super(e.message,e),this.response=e.response}};function Ph(e){return e instanceof Mh?e:new Mh(`INTERNAL_SERVER_ERROR`,{cause:e})}function Fh(e){if(!ah(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 Ih(e,t={}){let n=new Mh(e.code,{...e,...t});return n.defined=e.defined,n}function Lh(e){let t=new Mh(`MALFORMED_ORPC_RESPONSE`,{message:e.message??Vh(e.response),data:e.response});return t.cause=new Nh({...e,message:t.message}),t}var Rh=1,zh=256;function Bh(e){return e.length>=Rh&&e.length<=zh}function Vh(e){return typeof e.body==`string`&&Bh(e.body)?e.body:ah(e.body)&&typeof e.body.message==`string`&&Bh(e.body.message)?e.body.message:(Object.entries(Ah).find(([,t])=>t===e.status)?.[0])?.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function Hh(e,{mapResult:t,mapError:n,...r}){return eh(e,{...r,mapResult:t&&(async e=>{let n=await t(e);if(n.value!==e.value){let t=Sh(e.value);if(t&&Fm(n.value))return{done:n.done,value:bh(n.value,t)}}return n}),mapError:n&&(async e=>{let t=await n(e);if(t!==e){let n=Sh(e);if(n&&Fm(t))return bh(t,n)}return t})})}var Uh=/^\/([\s\S]*)\/([a-z]*)$/,Wh={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(Uh);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)}}},Gh=class{handlers;inlineBuiltInHandlers;handlerEntries;omitUndefinedProperties;constructor(e={}){this.omitUndefinedProperties=e.omitUndefinedProperties!==!1,this.handlers=Object.assign(new oh,Wh);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 Wh&&(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(ah(e)){let a=new oh;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}},Kh=class{jsonSerializer;defaultSerializeOptions;constructor(e={}){this.jsonSerializer=new Gh(e),this.defaultSerializeOptions=e.serialize}serialize(e,t={}){if(e===void 0||e instanceof ReadableStream||e instanceof Blob)return e;if(Am(e))return Hh(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.serializeValue(e.value,!1)},mapError:e=>new fh(this.serializeValue(Ph(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`,Nm({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:Am(e)?Hh(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.deserializeValue(e.value)},mapError:e=>{if(!(e instanceof fh))return e;let t=this.deserializeValue(e.data);return Fh(t)?Ih(t,{cause:e}):new fh(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})}},qh=new Set([`then`,`bind`,`call`,`apply`,`valueOf`,`toString`,`toJSON`]);function Jh(e){return{...e,context:e.context??{}}}function Yh(e){return[e[0],Jh(e[1]??{})]}function Xh(e,{path:t=[],...n}={}){let r=(...r)=>{let[i,a]=Yh(r);return lh([...Em(n.interceptors),...Em(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`||qh.has(a))return Reflect.get(r,a);let o=i.get(a);return o===void 0&&(o=Xh(e,{...n,path:[...t,a],scoped:n.scoped?.[a]}),i.set(a,o)),o}})}function Zh(e,t){return new Mm(async()=>{for(;;){let{json:t}=await e.pull();switch(t.event){case void 0:case`message`:{let e=t.data;return Fm(e)&&(e=bh(e,t)),{value:e,done:!1}}case`error`:throw bh(new fh(t.data),t);case`close`:{let e=t.data;return Fm(e)&&(e=bh(e,t)),{value:e,done:!0}}}}},t)}var Qh=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]=xh(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 fh){if(!this.isDone){this.isDone=!0;let[t,n]=xh(e);await this.send({kind:`event-stream`,id:this.messageId,json:{...n,event:`error`,data:t.data}})}return}throw this.isDone=!0,e}}};function $h(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 eg=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 tg(e,t){let n=Th(e.json.headers?.[`content-type`]),r=Th(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 Rm;return{resolveBody:async()=>Zh(e,t),eventStreamMessageQueue:e}}if(n!==void 0){let e=new Rm;return{resolveBody:async()=>$h(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=Th(e.json.headers?.[`content-disposition`]),i=t===void 0?void 0:wh(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 ng(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`]??=Ch(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,Am(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 rg=class{constructor(e){this.send=e}idGenerator=new km;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 ng(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:Pm(r.headers)?r.headers:void 0,body:r.jsonBody},binary:r.binary}),Am(n.body)){let r=new Qh(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 eg(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 Dm(`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=tg(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 Dm(`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 Dm(`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 Dm(`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 ig(e){return!(!Fm(e)||typeof e.id!=`string`||typeof e.kind!=`string`||e.binary!==void 0&&!(e.binary instanceof Uint8Array)&&!(e.binary instanceof Blob))}function ag(e){return!(e.kind!==`response`||!Fm(e.json)||e.json.status!==void 0&&!kh(e.json.status)||e.json.headers!==void 0&&!Oh(e.json.headers))}function og(e){return e.kind===`cancel`&&e.json===void 0&&e.binary===void 0}function sg(e){return!(e.kind!==`event-stream`||e.binary!==void 0||!Fm(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 cg(e){return e.kind===`octet-stream`&&Fm(e.json)&&(e.json.close===void 0||typeof e.json.close==`boolean`)}function lg(e){return e.kind===`stream/cancel`&&e.json===void 0&&e.binary===void 0}function ug(e){return ag(e)||og(e)||sg(e)||cg(e)||lg(e)}var dg=255,fg=new TextEncoder,pg=new TextDecoder;async function mg(e,t={}){if(e.binary===void 0){let n=Nm(e);return t.prefix?t.prefix+n:n}let n=Nm({...e,binary:void 0}),r=fg.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]=dg,a.set(i,r.length+1),a}function hg(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 ig(n)?{matched:!0,message:n}:{matched:!1}}if(t.prefix){let n=fg.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(dg);if(n===-1){let t=JSON.parse(pg.decode(e));return ig(t)?{matched:!0,message:t}:{matched:!1}}let r=e.subarray(0,n),i=e.subarray(n+1),a=JSON.parse(pg.decode(r));return ig(a)?(a.binary=i,{matched:!0,message:a}):{matched:!1}}catch{return{matched:!1}}}function gg(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 _g=class{name=`~composite`;plugins;constructor(e=[]){this.plugins=uh(e)}init(e){for(let t of this.plugins)t.init&&(e=t.init(e));return e}},vg=class{constructor(e,t,n={}){this.codec=e,this.transport=t,n=new _g(n.plugins).init(n),this.interceptors=n.interceptors,this.transportInterceptors=n.transportInterceptors}interceptors;transportInterceptors;call(e,t,n){return Qm(`${Um}.${e.join(`/`)}`,r=>(r?.setAttribute(`rpc.system`,Um),r?.setAttribute(`rpc.method`,e.join(`.`)),Jm()&&Am(t)?t=rh(t,th(`consume_async_iterator_object_input`,t)):Jm()&&t instanceof ReadableStream&&(t=rh(t,ch(`consume_octet_stream_input`,t))),lh(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=Jm(),a=i?.getActiveSpan()??r,o=await Qm({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 lh(this.transportInterceptors,{...n,path:e,request:o},({path:e,request:t,...n})=>Qm({name:`send_request`,parent:i?.getActiveSpan()??a},()=>this.transport.send(t,e,n))),c=await Qm({name:`decode_response`,parent:a},()=>this.codec.decodeResponse(s,e,n));if(c.kind===`error`)throw c.error;let l=c.output;return Jm()&&Am(l)?rh(l,th(`consume_async_iterator_object_output`,l)):Jm()&&l instanceof ReadableStream?rh(l,ch(`consume_octet_stream_output`,l)):l})))}},yg=/\/$/,bg=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 Kh}async encodeInput(e,t,n){let r=xg(await nh(this.headers,n,t,e));n.lastEventId!==void 0&&(r=Eh(r,{"last-event-id":n.lastEventId}));let i=await nh(this.expectedMethod,n,t,e),[a,o,s]=Dh(await nh(this.baseUrl,n,t,e)),c=`${a.replace(yg,``)}${Km(t)}`,l=this.serializer.serialize(e);if(i===`GET`&&!(l instanceof Blob)&&!(l instanceof ReadableStream)&&!(l instanceof FormData)&&!Am(l)){let a=await nh(this.maxUrlLength,n,t,e),u=new URLSearchParams(o);u.append(`data`,Nm(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 Lh({message:`Invalid RPC response format.`,response:{status:e.status,headers:e.headers,body:n},cause:t})}})();return t?{kind:`output`,output:r}:Fh(r)?{kind:`error`,error:Ih(r)}:{kind:`error`,error:Lh({response:{headers:e.headers,status:e.status,body:n}})}}};function xg(e){return typeof e.forEach==`function`?gg(e):e}function Sg(e,t,n){n?e.postMessage(t,n):e.postMessage(t)}function Cg(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 wg(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 Tg=class{peer;constructor({port:e,experimental_transfer:t,encodePeerMessage:n,decodePeerMessage:r}){this.peer=new rg(async r=>{let i=await nh(t,r,e);i?Sg(e,r,i):Sg(e,await mg(r,n))}),Cg(e,async e=>{let t;if(typeof e==`string`||e instanceof Uint8Array){let n=hg(e,r);n.matched&&ug(n.message)&&(t=n.message)}else ig(e)&&ug(e)&&(t=e);return t===void 0?{matched:!1}:(await this.peer.message(t),{matched:!0})}),wg(e,async()=>{await this.peer.close()})}async send(e,t,n){return await this.peer.request(e)}},Eg=class extends vg{constructor(e){let t=new bg(e),n=new Tg(e);super(t,n,e)}};async function Dg(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`)});default:return{content:`Unknown action: ${String(t.action)}`,isError:!0}}}var Og=new Set([`room_message`,`dm`,`room_invite`,`member_joined`,`member_left`,`room_members`,`member_status`,`delivery_status`,`invite_declined`,`name_changed`]);function kg(e){return Og.has(e.type)}var Ag=19877,jg=10,Mg=class{worker;client;state={agents:[],rooms:[],connected:!1};listeners=new Set;deliveryListeners=new Set;eventPumpGeneration=0;constructor(){typeof window<`u`&&window.addEventListener(`pagehide`,()=>{this.disconnect()})}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));Ng(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=Xh(new Eg({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(Ag,jg)}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?Dg(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=Sh(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(Fg),n=Object.values(e.state.rooms).filter(Ig);this.state={...this.state,agents:t,rooms:n},this.notify();break}case`state_patch`:this.applyPatch(e.patch);break;case`delivery`:if(kg(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 Ng(e){return typeof e==`object`&&!!e&&`type`in e}function Pg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fg(e){return Pg(e)&&typeof e.id==`string`&&typeof e.name==`string`}function Ig(e){return Pg(e)&&typeof e.id==`string`&&typeof e.name==`string`}var Lg=Rn({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`]}}),Rg=/^(localhost|127\.\d+\.\d+\.\d+)(:\d+)?$/;function zg(e){return Rg.test(e)}function Bg(e){return e.getItem(`agent-comms-connected`)===`true`}var Vg=`Project room for `;function Hg(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 Ug(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===`${Vg}${e.path}`);return n?{kind:`room`,targetId:n.id}:void 0}default:return e}}function Wg(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 Gg=document.createElement(`style`);Gg.textContent=l,document.head.appendChild(Gg);var Kg=zg(location.host),qg=document.getElementById(`root`);if(qg===null)throw Error(`missing #root element`);var Jg=new wm,Yg=new Mg,Xg=!1;Yg.subscribe(e=>{e.agents.length>0&&Jg.setAgents(e.agents),e.rooms.length>0&&Jg.setRooms(e.rooms),Jg.setConnected(e.connected),e.connected!==Xg&&(Xg=e.connected,Zg({type:`system`,text:e.connected?`Connected to mesh`:`Disconnected — reconnecting...`}))}),Yg.onDelivery(e=>{let t=_f(e,Jg.get().currentRoom);t&&Zg(t),(e.type===`member_joined`||e.type===`member_left`||e.type===`member_status`||e.type===`name_changed`)&&$g()});function Zg(e){Jg.addMessage(e)}async function Qg(e){let t=await Yg.sendAction(e);Zg({type:t.isError?`status`:`system`,text:t.isError?`Error: ${t.content}`:t.content}),t.isError||$g()}async function $g(){if(!Kg)return;let[e,t]=await Promise.all([Of(),kf()]);Jg.setAgents(e),Jg.setRooms(t),await e_()}async function e_(){try{Jg.setMeshGraph(await Mf())}catch{}}async function t_(e){if(Jg.setDmTarget(void 0),Jg.setCurrentRoom(e),Jg.clearMessages(),Qg({action:`join_room`,room:e}),Kg){let t=await Af(e);Jg.setMessages(t.map(vf))}Zg({type:`system`,text:`Joined ${e}`})}function n_(e){Jg.setCurrentRoom(void 0),Jg.setDmTarget(e),Jg.clearMessages()}function r_(){let e=Jg.get(),t=e.currentRoom;if(t!==void 0&&t!==``){let n=e.rooms.find(e=>e.id===t)?.name??t;Qg({action:`leave_room`,room:t}),Jg.setCurrentRoom(void 0),Jg.clearMessages(),Zg({type:`system`,text:`Left room "${n}"`})}}function i_(e){let t=Jg.get(),n=ff(e,t.currentRoom,t.dmTarget),r=df(n);if(r)switch(r.kind){case`join_room`:t_(r.room);return;case`leave_room`:r_();return}switch(n.kind){case`action`:Qg(n.action);break;case`local`:Zg({type:`system`,text:n.result.text})}}function a_(e,t,n){Qg({action:`create_room`,name:e,type:t,...n?{description:n}:{}})}function o_(e){t_(e)}function s_(e,t){Qg({action:`rename_agent`,agent:e,name:t})}function c_(){localStorage.setItem(`agent-comms-connected`,`true`),Yg.connect()}function l_(){let e=Tm(Jg);return(0,A.useEffect)(()=>{Wg({currentRoom:e.currentRoom,dmTarget:e.dmTarget})},[e.currentRoom,e.dmTarget]),(0,R.jsx)(Sm,{rooms:e.rooms,agents:e.agents,currentRoom:e.currentRoom,dmTarget:e.dmTarget,messages:e.messages,connected:e.connected,meshGraph:e.meshGraph,onJoinRoom:e=>{t_(e)},onSelectAgent:n_,onRenameAgent:s_,onLeaveRoom:r_,onSendAction:i_,onCreateRoom:a_,onJoinRoomInput:o_,onConnectToMesh:c_})}(0,uf.createRoot)(qg).render((0,R.jsx)(Ln,{theme:Lg,defaultColorScheme:`dark`,children:(0,R.jsx)(l_,{})}));var u_=Hg(location.search),d_=Bg(localStorage);(Kg||d_)&&Yg.connect(),$g().then(()=>{if(!u_)return;let e=Ug(u_,Jg.get().rooms);if(e)switch(e.kind){case`room`:t_(e.targetId);break;case`dm`:n_(e.targetId)}});
49
+ `},Dl=0,Ol=[];function kl(e){var t=A.useRef([]),n=A.useRef([0,0]),r=A.useRef(),i=A.useState(Dl++)[0],a=A.useState(Zc)[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=Dc([e.lockRef.current],(e.shards||[]).map(wl),!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=Sl(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=hl(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=hl(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 xl(h,t,e,h===`h`?s:c,!0)},[]),c=A.useCallback(function(e){var n=e;if(Ol.length&&Ol[Ol.length-1]===a){var r=`deltaY`in n?Cl(n):Sl(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Tl(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(wl).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:Al(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=Sl(e),r.current=void 0},[]),d=A.useCallback(function(t){l(t.type,Cl(t),t.target,s(t,e.lockRef.current))},[]),f=A.useCallback(function(t){l(t.type,Sl(t),t.target,s(t,e.lockRef.current))},[]);A.useEffect(function(){return Ol.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,ul),document.addEventListener(`touchmove`,c,ul),document.addEventListener(`touchstart`,u,ul),function(){Ol=Ol.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,ul),document.removeEventListener(`touchmove`,c,ul),document.removeEventListener(`touchstart`,u,ul)}},[]);var p=e.removeScrollBar,m=e.inert;return A.createElement(A.Fragment,null,m?A.createElement(a,{styles:El(i)}):null,p?A.createElement(sl,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Al(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var jl=Vc(Hc,kl),Ml=A.forwardRef(function(e,t){return A.createElement(Wc,Tc({},e,{ref:t,sideCar:jl}))});Ml.classNames=Wc.classNames;var Nl=(0,A.createContext)({size:`sm`}),Pl=V(e=>{let t=z(`InputClearButton`,null,e),{size:n,variant:r,vars:i,classNames:a,styles:o,...s}=t,c=(0,A.use)(Nl),{resolvedClassNames:l,resolvedStyles:u}=zn({classNames:a,styles:o,props:t});return(0,R.jsx)(yc,{variant:r||`transparent`,size:n||c?.size||`sm`,classNames:l,styles:u,__staticSelector:`InputClearButton`,style:{pointerEvents:`all`,background:`var(--input-bg)`,...s.style},...s})});Pl.displayName=`@mantine/core/InputClearButton`;var Fl={xs:7,sm:8,md:10,lg:12,xl:15};function Il({__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,R.jsxs)(`div`,{"data-combined-clear-section":!0,style:{display:`flex`,gap:2,alignItems:`center`,paddingInlineEnd:Fl[i]},children:[o,n||r]}):n===null?null:n||o||r}var Ll=(0,A.createContext)({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0}),Rl={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`},zl=xt((e,{size:t})=>({description:{"--input-description-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Bl=V(e=>{let t=z(`InputDescription`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,__inheritStyles:l=!0,attributes:u,...d}=z(`InputDescription`,null,t),f=(0,A.use)(Ll),p=B({name:[`InputWrapper`,c],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,rootSelector:`description`,vars:s,varsResolver:zl}),m=l&&f?.getStyles||p;return(0,R.jsx)(H,{component:`p`,...m(`description`,f?.getStyles?{className:r,style:i}:void 0),...d})});Bl.classes=Rl,Bl.varsResolver=zl,Bl.displayName=`@mantine/core/InputDescription`;var Vl=xt((e,{size:t})=>({error:{"--input-error-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Hl=V(e=>{let t=z(`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=B({name:[`InputWrapper`,l],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`error`,vars:s,varsResolver:Vl}),p=(0,A.use)(Ll),m=u&&p?.getStyles||f;return(0,R.jsx)(H,{component:`p`,...m(`error`,p?.getStyles?{className:r,style:i}:void 0),...d})});Hl.classes=Rl,Hl.varsResolver=Vl,Hl.displayName=`@mantine/core/InputError`;var Ul={labelElement:`label`},Wl=xt((e,{size:t})=>({label:{"--input-label-size":fe(t),"--input-asterisk-color":void 0}})),Gl=V(e=>{let t=z(`InputLabel`,Ul,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,_=B({name:[`InputWrapper`,p],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`label`,vars:s,varsResolver:Wl}),v=(0,A.use)(Ll),y=v?.getStyles||_,b=g.component||c,x=typeof b!=`string`||b===`label`;return(0,R.jsxs)(H,{...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,R.jsx)(`span`,{...y(`required`),"aria-hidden":!0,children:` *`})]})});Gl.classes=Rl,Gl.varsResolver=Wl,Gl.displayName=`@mantine/core/InputLabel`;var Kl=V(e=>{let t=z(`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=B({name:[`InputPlaceholder`,c],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:d,rootSelector:`placeholder`});return(0,R.jsx)(H,{...p(`placeholder`),mod:[{error:!!l},u],component:`span`,...f})});Kl.classes=Rl,Kl.displayName=`@mantine/core/InputPlaceholder`;var ql=xt((e,{size:t})=>({success:{"--input-success-size":t===void 0?void 0:`calc(${fe(t)} - ${E(2)})`}})),Jl=V(e=>{let t=z(`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=B({name:[`InputWrapper`,l],props:t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`success`,vars:s,varsResolver:ql}),p=(0,A.use)(Ll),m=u&&p?.getStyles||f;return(0,R.jsx)(H,{component:`p`,...m(`success`,p?.getStyles?{className:r,style:i}:void 0),...d})});Jl.classes=Rl,Jl.varsResolver=ql,Jl.displayName=`@mantine/core/InputSuccess`;function Yl(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 Xl={labelElement:`label`,inputContainer:e=>e,inputWrapperOrder:[`label`,`description`,`input`,`error`]},Zl=xt((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)})`}})),Ql=V(e=>{let t=z(`InputWrapper`,Xl,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=B({name:[`InputWrapper`,u],props:E||t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:O,vars:s,varsResolver:Zl}),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,R.jsx)(Gl,{labelElement:x,id:pe,htmlFor:ae,required:te,...M,..._,children:p},`label`),he=ce&&(0,R.jsx)(Bl,{...v,...M,size:v?.size||M.size,id:v?.id||ie,children:g},`description`),ge=(0,R.jsx)(A.Fragment,{children:d(S)},`input`),P=oe&&(0,A.createElement)(Hl,{...y,...M,size:y?.size||M.size,key:`error`,id:y?.id||ne},m),F=se&&(0,A.createElement)(Jl,{...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,R.jsx)(Ll,{value:{getStyles:j,describedBy:fe,inputId:ae,labelId:pe,...Yl(f,{hasDescription:ce,hasError:oe||se})},children:(0,R.jsx)(H,{variant:l,size:c,mod:[{error:!!m,success:!!h&&!m},D],id:x===`label`?void 0:w,...j(`root`),...k,children:_e})})});Ql.classes=Rl,Ql.varsResolver=Zl,Ql.displayName=`@mantine/core/InputWrapper`;var $l={variant:`default`,leftSectionPointerEvents:`none`,rightSectionPointerEvents:`none`,withAria:!0,withErrorStyles:!0,withSuccessStyles:!0,size:`sm`,loading:!1,loadingPosition:`right`},eu=xt((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}})),tu=Pr(e=>{let t=z(`Input`,$l,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}=ar(fe),he=(0,A.use)(Ll),ge={offsetBottom:he?.offsetBottom,offsetTop:he?.offsetTop},P=B({name:[`Input`,c],props:l||t,classes:Rl,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:ne,stylesCtx:ge,rootSelector:`wrapper`,vars:w,varsResolver:eu}),F=k?{required:s,disabled:m,"aria-invalid":f?!0:void 0,"aria-describedby":he?.describedBy,id:he?.inputId||O}:{},_e=se?(0,R.jsx)(oc,{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=Il({__clearable:ie,__clearSection:re,rightSection:se&&ce===`right`?_e:v,__defaultRightSection:oe,size:u,__clearSectionMode:ae});return(0,R.jsx)(Nl,{value:{size:u||`sm`},children:(0,R.jsxs)(H,{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,R.jsx)(`div`,{...g,"data-position":`left`,...P(`section`,{className:g?.className,style:g?.style}),children:ve}),(0,R.jsx)(H,{component:`input`,...me,...F,required:s,mod:{disabled:m,error:!!f&&j,success:!!p&&!f&&M},variant:C,__size:te,...P(`input`)}),le&&(0,R.jsx)(`div`,{...N,...P(`bottomSection`,{className:N?.className,style:N?.style}),children:le}),ye&&(0,R.jsx)(`div`,{...y,"data-position":`right`,...P(`section`,{className:y?.className,style:y?.style}),children:ye})]})})});tu.classes=Rl,tu.varsResolver=eu,tu.Wrapper=Ql,tu.Label=Gl,tu.Error=Hl,tu.Success=Jl,tu.Description=Bl,tu.Placeholder=Kl,tu.ClearButton=Pl,tu.displayName=`@mantine/core/Input`;function nu(e,t,n){let r=z([`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}=ar(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 ru={__staticSelector:`InputBase`,withAria:!0,size:`sm`},K=Pr(e=>{let{inputProps:t,wrapperProps:n,...r}=nu(`InputBase`,ru,e);return(0,R.jsx)(tu.Wrapper,{...n,children:(0,R.jsx)(tu,{...t,...r})})});K.classes={...tu.classes,...tu.Wrapper.classes},K.displayName=`@mantine/core/InputBase`;function iu(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 au({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=ai(s.borderTopWidth)+ai(c.borderTopWidth),u=ai(s.borderLeftWidth)+ai(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=>{iu(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 ou={root:`m_96b553a6`},su=xt((e,{transitionDuration:t},{shouldReduceMotion:n})=>({root:{"--transition-duration":e.respectReducedMotion&&n?`0ms`:typeof t==`number`?`${t}ms`:t||`150ms`}})),cu=V(e=>{let t=z(`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=B({name:`FloatingIndicator`,classes:ou,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,vars:s,varsResolver:su,stylesCtx:{shouldReduceMotion:Ge()}}),y=(0,A.useRef)(null),{initialized:b,hidden:x}=au({target:c,parent:l,ref:y,displayAfterTransitionEnd:f,onTransitionStart:p,onTransitionEnd:m}),S=Ue(g,y);return!c||!l?null:(0,R.jsx)(H,{ref:S,mod:[{initialized:b,hidden:x},d],...v(`root`),..._})});cu.displayName=`@mantine/core/FloatingIndicator`,cu.classes=ou,cu.varsResolver=su;function lu({style:e,size:t=16,...n}){return(0,R.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,R.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`})})}lu.displayName=`@mantine/core/AccordionChevron`;var uu={root:`m_b6d8b162`};function du(e){if(e===`start`)return`start`;if(e===`end`||e)return`end`}var fu={inherit:!1},pu=xt((e,{variant:t,lineClamp:n,gradient:r,size:i,textWrap:a})=>({root:{"--text-fz":fe(i),"--text-lh":pe(i),"--text-gradient":t===`gradient`?Wt(r,e):void 0,"--text-line-clamp":typeof n==`number`?n.toString():void 0,"--text-text-wrap":a}})),mu=Pr(e=>{let t=z(`Text`,fu,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=B({name:[`Text`,l],props:t,classes:uu,className:d,style:f,classNames:p,styles:m,unstyled:h,attributes:y,vars:u,varsResolver:pu});return(0,R.jsx)(H,{...x(`root`,{focusable:!0}),component:s?`span`:`p`,variant:g,mod:[{truncate:du(r),lineClamp:typeof n==`number`,inline:i,inherit:a},_],size:v,...b})});mu.classes=uu,mu.varsResolver=pu,mu.displayName=`@mantine/core/Text`;var[hu,gu]=M(`AppShell was not found in tree`),_u={root:`m_89ab340`,navbar:`m_45252eee`,aside:`m_9cdde9a`,header:`m_3b16f56b`,main:`m_8983817`,footer:`m_3840c879`,section:`m_6dcfc7c7`},vu=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellAside`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{component:`aside`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`aside`,{className:Ct({[Ml.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-aside-z-index":`calc(${c??d.zIndex} + 1)`}})});vu.classes=_u,vu.displayName=`@mantine/core/AppShellAside`;var yu=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellFooter`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{component:`footer`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`footer`,{className:Ct({[Ml.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-footer-z-index":(c??d.zIndex)?.toString()}})});yu.classes=_u,yu.displayName=`@mantine/core/AppShellFooter`;var bu=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellHeader`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{component:`header`,mod:[{"with-border":s??d.withBorder},l],...d.getStyles(`header`,{className:Ct({[Ml.classNames.zeroRight]:d.offsetScrollbars},n),classNames:t,styles:i,style:r}),...u,__vars:{"--app-shell-header-z-index":(c??d.zIndex)?.toString()}})});bu.classes=_u,bu.displayName=`@mantine/core/AppShellHeader`;var xu=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`AppShellMain`,null,e),s=gu();return(0,R.jsx)(H,{component:`main`,...s.getStyles(`main`,{className:n,style:r,classNames:t,styles:i}),...o})});xu.classes=_u,xu.displayName=`@mantine/core/AppShellMain`;var Su=V(e=>{let{classNames:t,className:n,style:r,styles:i,unstyled:a,vars:o,withBorder:s,zIndex:c,mod:l,...u}=z(`AppShellNavbar`,null,e),d=gu();return d.disabled?null:(0,R.jsx)(H,{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)`}})});Su.classes=_u,Su.displayName=`@mantine/core/AppShellNavbar`;var Cu=Pr(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,grow:o,mod:s,...c}=z(`AppShellSection`,null,e),l=gu();return(0,R.jsx)(H,{mod:[{grow:o},s],...l.getStyles(`section`,{className:n,style:r,classNames:t,styles:i}),...c})});Cu.classes=_u,Cu.displayName=`@mantine/core/AppShellSection`;function wu(e){return typeof e==`object`?e.base:e}function Tu(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 Eu(e){return!(typeof e!=`object`||!e||Object.keys(e).length===1&&`base`in e)}function Du({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`)),Tu(o)){let t=E(wu(o));e[`--app-shell-aside-width`]=t,e[`--app-shell-aside-offset`]=t}if(Eu(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 Ou({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`),Tu(i)){let t=E(wu(i));e[`--app-shell-footer-height`]=t,a&&(e[`--app-shell-footer-offset`]=t)}Eu(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 ku({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`),Tu(i)){let t=E(wu(i));e[`--app-shell-header-height`]=t,a&&(e[`--app-shell-header-offset`]=t)}Eu(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 Au({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`)),Tu(o)){let t=E(wu(o));e[`--app-shell-navbar-width`]=t,e[`--app-shell-navbar-offset`]=t,a===`static`&&(e[`--app-shell-navbar-grid-width`]=t)}if(Eu(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 ju(e){return Number(e)===0?`0px`:ue(e)}function Mu({padding:e,baseStyles:t,minMediaStyles:n}){Tu(e)&&(t[`--app-shell-padding`]=ju(wu(e))),Eu(e)&&(e.base&&(t[`--app-shell-padding`]=ju(e.base)),v(e).forEach(t=>{t!==`base`&&(n[t]=n[t]||{},n[t][`--app-shell-padding`]=ju(e[t]))}))}function Nu({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`),Au({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,navbar:e,theme:a,mode:o}),Du({baseStyles:l,minMediaStyles:s,maxMediaStyles:c,aside:r,theme:a,mode:o}),ku({baseStyles:l,minMediaStyles:s,header:t,mode:o}),Ou({baseStyles:l,minMediaStyles:s,footer:n,mode:o}),Mu({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 Pu({navbar:e,header:t,aside:n,footer:r,padding:i,mode:a,selector:o}){let s=Cn(),c=Qt(),{media:l,baseStyles:u}=Nu({navbar:e,header:t,footer:r,aside:n,padding:i,theme:s,mode:a});return(0,R.jsx)(nr,{media:l,styles:u,selector:o||c.cssVariablesSelector})}function Fu({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 Iu={withBorder:!0,padding:0,transitionDuration:200,transitionTimingFunction:`ease`,zIndex:se(`app`),mode:`fixed`},Lu=xt((e,{transitionDuration:t,transitionTimingFunction:n})=>({root:{"--app-shell-transition-duration":`${t}ms`,"--app-shell-transition-timing-function":n}})),Ru=V(e=>{let t=z(`AppShell`,Iu,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=B({name:`AppShell`,classes:_u,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:S,vars:s,varsResolver:Lu}),E=Fu({disabled:g,transitionDuration:d}),D=ze(C);return(0,R.jsxs)(hu,{value:{getStyles:T,withBorder:l,zIndex:m,disabled:g,offsetScrollbars:y,mode:b},children:[(0,R.jsx)(Pu,{navbar:c,header:p,aside:_,footer:v,padding:u,mode:b,selector:b===`static`?`#${D}`:void 0}),(0,R.jsx)(H,{...T(`root`),id:D,mod:[{resizing:E,layout:h,disabled:g,mode:b},x],...w})]})});Ru.classes=_u,Ru.varsResolver=Lu,Ru.displayName=`@mantine/core/AppShell`,Ru.Navbar=Su,Ru.Header=bu,Ru.Main=xu,Ru.Aside=vu,Ru.Footer=yu,Ru.Section=Cu;function zu(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=>zu(e))}:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?{value:e,label:`${e}`}:e}function Bu(e){return e?e.map(e=>zu(e)):[]}function Vu(e){return e.reduce((e,t)=>`group`in t?{...e,...Vu(t.items)}:(e[`${t.value}`]=t,e),{})}var Hu={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`},Uu={error:null},Wu=xt((e,{size:t,color:n})=>({chevron:{"--combobox-chevron-size":N(t,`combobox-chevron-size`),"--combobox-chevron-color":n?Vt(n,e):void 0}})),Gu=V(e=>{let t=z(`ComboboxChevron`,Uu,e),{size:n,error:r,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,attributes:u,mod:d,...f}=t,p=B({name:`ComboboxChevron`,classes:Hu,props:t,style:i,className:a,classNames:o,styles:s,unstyled:c,vars:l,varsResolver:Wu,attributes:u,rootSelector:`chevron`});return(0,R.jsx)(H,{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,R.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`})})});Gu.classes=Hu,Gu.varsResolver=Wu,Gu.displayName=`@mantine/core/ComboboxChevron`;var[Ku,qu]=M(`Combobox component was not found in tree`);function Ju({onMouseDown:e,onClick:t,onClear:n,...r}){return(0,R.jsx)(tu.ClearButton,{tabIndex:-1,"aria-hidden":!0,...r,onMouseDown:t=>{t.preventDefault(),e?.(t)},onClick:e=>{n(),t?.(e)}})}Ju.displayName=`@mantine/core/ComboboxClearButton`;var Yu=V(e=>{let{classNames:t,styles:n,className:r,style:i,hidden:a,...o}=z(`ComboboxDropdown`,null,e),s=qu();return(0,R.jsx)(Qs.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})})});Yu.classes=Hu,Yu.displayName=`@mantine/core/ComboboxDropdown`;var Xu={refProp:`ref`},Zu=V(e=>{let{children:t,refProp:n,ref:r}=z(`ComboboxDropdownTarget`,Xu,e);if(qu(),!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,R.jsx)(Qs.Target,{ref:r,refProp:n,children:t})});Zu.displayName=`@mantine/core/ComboboxDropdownTarget`;var Qu=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`ComboboxEmpty`,null,e),s=qu();return(0,R.jsx)(H,{...s.getStyles(`empty`,{className:n,classNames:t,styles:i,style:r}),...o})});Qu.classes=Hu,Qu.displayName=`@mantine/core/ComboboxEmpty`;function q({onKeyDown:e,onClick:t,withKeyboardNavigation:n,withAriaAttributes:r,withExpandedAttribute:i,targetType:a,autoComplete:o}){let s=qu(),[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 $u={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},J=V(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=z(`ComboboxEventsTarget`,$u,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=qu(),f=q({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))})});J.displayName=`@mantine/core/ComboboxEventsTarget`;var Y=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`ComboboxFooter`,null,e),s=qu();return(0,R.jsx)(H,{...s.getStyles(`footer`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});Y.classes=Hu,Y.displayName=`@mantine/core/ComboboxFooter`;var X=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,children:o,label:s,id:c,...l}=z(`ComboboxGroup`,null,e),u=qu(),d=ze(c),f=s!=null&&s!==!1&&s!==``;return(0,R.jsxs)(H,{role:`group`,"aria-labelledby":f?d:void 0,...u.getStyles(`group`,{className:n,classNames:t,style:r,styles:i}),...l,children:[f&&(0,R.jsx)(`div`,{id:d,...u.getStyles(`groupLabel`,{classNames:t,styles:i}),children:s}),o]})});X.classes=Hu,X.displayName=`@mantine/core/ComboboxGroup`;var ed=V(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=z(`ComboboxHeader`,null,e),s=qu();return(0,R.jsx)(H,{...s.getStyles(`header`,{className:n,classNames:t,style:r,styles:i}),...o,onMouseDown:e=>{e.preventDefault()}})});ed.classes=Hu,ed.displayName=`@mantine/core/ComboboxHeader`;function td({value:e,valuesDivider:t=`,`,...n}){return(0,R.jsx)(`input`,{type:`hidden`,value:Array.isArray(e)?e.join(t):e?`${e}`:``,...n})}td.displayName=`@mantine/core/ComboboxHiddenInput`;var nd=V(e=>{let t=z(`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=qu(),_=(0,A.useId)(),v=c||_;return(0,R.jsx)(H,{...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)}})});nd.classes=Hu,nd.displayName=`@mantine/core/ComboboxOption`;var rd=V(e=>{let{classNames:t,className:n,style:r,styles:i,id:a,onMouseDown:o,labelledBy:s,...c}=z(`ComboboxOptions`,null,e),l=qu(),u=ze(a);return(0,A.useEffect)(()=>{l.store.setListId(u)},[u]),(0,R.jsx)(H,{...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)}})});rd.classes=Hu,rd.displayName=`@mantine/core/ComboboxOptions`;var id={withAriaAttributes:!0,withKeyboardNavigation:!0},ad=V(e=>{let{classNames:t,styles:n,unstyled:r,vars:i,withAriaAttributes:a,onKeyDown:o,onClick:s,withKeyboardNavigation:c,size:l,ref:u,...d}=z(`ComboboxSearch`,id,e),f=qu(),p=f.getStyles(`search`),m=q({targetType:`input`,withAriaAttributes:a,withKeyboardNavigation:c,withExpandedAttribute:!1,onKeyDown:o,onClick:s,autoComplete:`off`});return(0,R.jsx)(tu,{ref:Ue(u,f.store.searchRef),classNames:[{input:p.className},t],styles:[{input:p.style},n],size:l||f.size,...m,...d,__staticSelector:`Combobox`})});ad.classes=Hu,ad.displayName=`@mantine/core/ComboboxSearch`;var od={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},sd=V(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:a,targetType:o,autoComplete:s,ref:c,...l}=z(`ComboboxTarget`,od,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=qu(),f=q({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,R.jsx)(Qs.Target,{refProp:n,ref:Ue(c,d.store.targetRef),children:p})});sd.displayName=`@mantine/core/ComboboxTarget`;function cd(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 ld(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 ud(e){for(let t=0;t<e.length;t+=1)if(!e[t].hasAttribute(`data-combobox-disabled`))return t;return-1}function dd({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(ld(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(cd(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(ud(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 fd={keepMounted:!0,keepMountedMode:`display-none`,withinPortal:!0,resetSelectionOnOptionHover:!1,width:`target`,transitionProps:{transition:`fade`,duration:0},size:`sm`},pd=xt((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`)}})),Z=e=>{let t=z(`Combobox`,fd,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=dd(),x=o||b,S=B({name:p||`Combobox`,classes:Hu,props:t,classNames:n,styles:r,unstyled:i,attributes:h,vars:s,varsResolver:pd}),C=()=>{l?.(),x.closeDropdown()};return(0,R.jsx)(Ku,{value:{getStyles:S,store:x,onOptionSubmit:c,size:u,resetSelectionOnOptionHover:f,readOnly:m,floatingHeight:g},children:(0,R.jsx)(Qs,{opened:x.dropdownOpened,...v,middlewares:y,onChange:e=>!e&&C(),withRoles:!1,unstyled:i,children:a})})};Z.extend=e=>e,Z.classes=Hu,Z.varsResolver=pd,Z.displayName=`@mantine/core/Combobox`,Z.Target=sd,Z.Dropdown=Yu,Z.Options=rd,Z.Option=nd,Z.Search=ad,Z.Empty=Qu,Z.Chevron=Gu,Z.Footer=Y,Z.Header=ed,Z.EventsTarget=J,Z.DropdownTarget=Zu,Z.Group=X,Z.ClearButton=Ju,Z.HiddenInput=td;function md({size:e,style:t,...n}){let r=e===void 0?t:{width:E(e),height:E(e),...t};return(0,R.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,R.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 hd(e){return`group`in e}function gd({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;hd(o)&&i.push({group:o.group,items:gd({options:o.items,search:t,limit:n-i.length})}),hd(o)||o.label.toLowerCase().includes(r)&&i.push(o)}return i}function _d(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 vd(e,t=new Set){if(Array.isArray(e))for(let n of e)if(hd(n))vd(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 yd(e,t){return Array.isArray(e)?e.includes(t):e===t}function bd({data:e,withCheckIcon:t,withAlignedLabels:n,value:r,checkIconPosition:i,unstyled:a,renderOption:o}){if(!hd(e)){let s=yd(r,e.value),c=t&&(s?(0,R.jsx)(md,{className:Hu.optionsDropdownCheckIcon}):n?(0,R.jsx)(`div`,{className:Hu.optionsDropdownCheckPlaceholder}):null),l=(0,R.jsxs)(R.Fragment,{children:[i===`left`&&c,(0,R.jsx)(`span`,{children:e.label}),i===`right`&&c]});return(0,R.jsx)(Z.Option,{value:e.value,disabled:e.disabled,className:Ct({[Hu.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,R.jsx)(bd,{data:e,value:r,unstyled:a,withCheckIcon:t,withAlignedLabels:n,checkIconPosition:i,renderOption:o},`${e.value}`));return(0,R.jsx)(Z.Group,{label:e.group,children:s})}function xd({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=qu();vd(e);let x=typeof i==`string`?(r||gd)({options:e,search:l?i:``,limit:a??1/0}):e,S=_d(x),C=x.map((e,t)=>(0,R.jsx)(bd,{data:e,withCheckIcon:u,withAlignedLabels:d,value:f,checkIconPosition:p,unstyled:h,renderOption:_},hd(e)?`group-${typeof e.group==`string`?e.group:t}`:`${e.value}`));return(0,R.jsx)(Z.Dropdown,{hidden:t||n&&S,"data-composed":!0,children:(0,R.jsxs)(Z.Options,{labelledBy:g,"aria-label":y,children:[c?(0,R.jsx)(ss.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,R.jsx)(Z.Empty,{children:m})]})})}var Sd={root:`m_347db0ec`,"root--dot":`m_fbd81e3d`,label:`m_5add502a`,section:`m_91fdda9b`},Cd=xt((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`?Vt(n,e):void 0}}}),wd=Pr(e=>{let t=z(`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=B({name:`Badge`,props:t,classes:Sd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:y,vars:s,varsResolver:Cd});return(0,R.jsxs)(H,{variant:m,mod:[{block:h,circle:_,"with-right-section":!!f,"with-left-section":!!d},v],...x(`root`,{variant:m}),...b,children:[d&&(0,R.jsx)(`span`,{...x(`section`),"data-position":`left`,children:d}),(0,R.jsx)(`span`,{...x(`label`),children:p}),f&&(0,R.jsx)(`span`,{...x(`section`),"data-position":`right`,children:f})]})});wd.classes=Sd,wd.varsResolver=Cd,wd.displayName=`@mantine/core/Badge`;var Td={root:`m_fea6bf1a`,burger:`m_d4fb9cad`},Ed=xt((e,{color:t,size:n,lineSize:r,transitionDuration:i,transitionTimingFunction:a})=>({root:{"--burger-color":t?Vt(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}})),Dd=V(e=>{let t=z(`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=B({name:`Burger`,classes:Td,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:s,varsResolver:Ed});return(0,R.jsxs)(ds,{...h(`root`),...m,children:[(0,R.jsx)(H,{mod:[`reduce-motion`,{opened:c}],...h(`burger`)}),l]})});Dd.classes=Td,Dd.varsResolver=Ed,Dd.displayName=`@mantine/core/Burger`;var Od={root:`m_77c9d27d`,inner:`m_80f1301b`,label:`m_811560b9`,section:`m_a74036a`,loader:`m_a25b86ee`,group:`m_80d6d844`,groupSection:`m_70be2a01`},kd={orientation:`horizontal`},Ad=xt((e,{borderWidth:t})=>({group:{"--button-border-width":E(t)}})),jd=V(e=>{let t=z(`ButtonGroup`,kd,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,orientation:s,vars:c,borderWidth:l,mod:u,attributes:d,...f}=z(`ButtonGroup`,kd,e),p=B({name:`ButtonGroup`,props:t,classes:Od,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:c,varsResolver:Ad,rootSelector:`group`});return(0,R.jsx)(H,{...p(`group`),mod:[{orientation:s},u],role:`group`,...f})});jd.classes=Od,jd.varsResolver=Ad,jd.displayName=`@mantine/core/ButtonGroup`;var Md=xt((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}}}),Nd=V(e=>{let t=z(`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=B({name:`ButtonGroupSection`,props:t,classes:Od,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:s,varsResolver:Md,rootSelector:`groupSection`});return(0,R.jsx)(H,{...p(`groupSection`),...f})});Nd.classes=Od,Nd.varsResolver=Md,Nd.displayName=`@mantine/core/ButtonGroupSection`;var Pd={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${E(1)}))`},out:{opacity:0,transform:`translate(-50%, -200%)`},common:{transformOrigin:`center`},transitionProperty:`transform, opacity`},Fd=xt((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}}}),Id=Pr(e=>{let t=z(`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=B({name:`Button`,props:t,classes:Od,className:i,style:n,classNames:g,styles:_,unstyled:v,attributes:S,vars:r,varsResolver:Fd}),T=!!c,E=!!l;return(0,R.jsxs)(ds,{...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,R.jsx)(Is,{mounted:p,transition:Pd,duration:150,children:e=>(0,R.jsx)(H,{component:`span`,...w(`loader`,{style:e}),"aria-hidden":!0,children:(0,R.jsx)(oc,{color:`var(--button-color)`,size:`calc(var(--button-height) / 1.8)`,...m})})}),(0,R.jsxs)(`span`,{...w(`inner`),children:[c&&(0,R.jsx)(H,{component:`span`,...w(`section`),mod:{position:`left`},children:c}),(0,R.jsx)(H,{component:`span`,mod:{loading:p},...w(`label`),children:s}),l&&(0,R.jsx)(H,{component:`span`,...w(`section`),mod:{position:`right`},children:l})]})]})});Id.classes=Od,Id.varsResolver=Fd,Id.displayName=`@mantine/core/Button`,Id.Group=jd,Id.GroupSection=Nd;function Ld(e){let t=e.currentTarget;return yt(t).activeElement!==t}function Rd(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 zd={root:`m_f0824112`,description:`m_57492dcc`,section:`m_690090b5`,label:`m_1f6ac4c4`,body:`m_f07af9d2`,children:`m_e17b862f`,chevron:`m_1fd8a00b`},Bd=xt((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)}}}),Vd=Pr(e=>{let t=z(`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=B({name:`NavLink`,props:t,classes:zd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:C,vars:s,varsResolver:Bd}),[k,A]=We({value:c,defaultValue:l,finalValue:!1,onChange:u}),j=!!d,M=e=>{w?.(e),j&&(e.preventDefault(),A(!k))};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(ds,{...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,R.jsx)(H,{component:`span`,...O(`section`),mod:{position:`left`},children:m}),(0,R.jsxs)(H,{...O(`body`),mod:{"no-wrap":y},children:[(0,R.jsx)(H,{component:`span`,...O(`label`),children:g}),(0,R.jsx)(H,{component:`span`,mod:{active:f},...O(`description`),children:_})]}),(j||h!==void 0)&&(0,R.jsx)(H,{...O(`section`),component:`span`,mod:{rotate:k&&!v,position:`right`},children:j&&h===void 0?(0,R.jsx)(lu,{...O(`chevron`)}):h})]}),j&&(0,R.jsx)(Wr,{expanded:k,keepMounted:E,...O(`collapse`),children:(0,R.jsx)(`div`,{...O(`children`),children:d})})]})});Vd.classes=zd,Vd.varsResolver=Bd,Vd.displayName=`@mantine/core/NavLink`;var Hd={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},Ud={withItemsBorders:!0},Wd=xt((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:de(t),"--sc-color":n?Vt(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)}})),Gd=Nr(e=>{let t=z(`SegmentedControl`,Ud,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=B({name:`SegmentedControl`,props:t,classes:Hd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:E,vars:s,varsResolver:Wd}),j=Cn(),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)(H,{...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)(H,{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:L({color:y,theme:j,autoContrast:C})},key:`${e.value}-label`},(0,R.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,R.jsxs)(H,{...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,R.jsx)(cu,{target:ae[`${ce}`],parent:re,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...k(`indicator`)},te),de]})});Gd.classes=Hd,Gd.varsResolver=Wd,Gd.displayName=`@mantine/core/SegmentedControl`;var Kd={size:`sm`,withCheckIcon:!0,allowDeselect:!0,checkIconPosition:`left`,openOnFocus:!0},qd=Nr(e=>{let t=z([`Input`,`InputWrapper`,`Select`],Kd,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)(()=>Bu(m),[m]),I=(0,A.useRef)({}),Ee=(0,A.useMemo)(()=>Vu(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=dd({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}=zn({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,R.jsx)(Z.ClearButton,{...pe,onClear:()=>{ke(null,null),Le(``),ge?.()}}),He=de&&Oe!=null&&!S&&!x;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(Z,{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,R.jsx)(Z.Target,{targetType:k?`input`:`button`,autoComplete:P,withExpandedAttribute:!0,children:(0,R.jsx)(K,{id:De,__defaultRightSection:(0,R.jsx)(Z.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(Ld(e)){if(!x){let t=Rd(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,R.jsx)(xd,{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,R.jsx)(Z.HiddenInput,{value:Oe,name:re,form:ie,disabled:S,...me})]})});qd.classes={...K.classes,...Z.classes},qd.displayName=`@mantine/core/Select`;var Jd={root:`m_6d731127`},Yd={gap:`md`,align:`stretch`,justify:`flex-start`},Xd=xt((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":ue(t),"--stack-align":n,"--stack-justify":r}})),Zd=V(e=>{let t=z(`Stack`,Yd,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=B({name:`Stack`,props:t,classes:Jd,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:Xd});return(0,R.jsx)(H,{...m(`root`),variant:d,...p})});Zd.classes=Jd,Zd.varsResolver=Xd,Zd.displayName=`@mantine/core/Stack`;var[Qd,$d]=M(`Tabs component was not found in the tree`),ef={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`},tf=V(e=>{let t=z(`TabsList`,null,e),{children:n,className:r,grow:i,justify:a,classNames:o,styles:s,style:c,mod:l,...u}=t,d=$d();return(0,R.jsx)(H,{...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})});tf.classes=ef,tf.displayName=`@mantine/core/TabsList`;var nf=V(e=>{let t=z(`TabsPanel`,null,e),{children:n,className:r,value:i,classNames:a,styles:o,style:s,mod:c,keepMounted:l,...u}=t,d=sn(),f=$d();(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,R.jsx)(A.Activity,{mode:p?`visible`:`hidden`,children:n}):m||p?n:null;return(0,R.jsx)(H,{...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})});nf.classes=ef,nf.displayName=`@mantine/core/TabsPanel`;var rf=V(e=>{let t=z(`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=Cn(),{dir:y}=Hr(),b=$d(),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,R.jsxs)(ds,{...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?Vt(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,R.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`left`,children:a}),r&&(0,R.jsx)(`span`,{...b.getStyles(`tabLabel`,C),children:r}),i&&(0,R.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`right`,children:i})]})});rf.classes=ef,rf.displayName=`@mantine/core/TabsTab`;var af=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,of={keepMounted:!0,keepMountedMode:`activity`,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},sf=xt((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":de(t),"--tabs-color":Vt(n,e),"--tabs-text-color":Xt(r,e)?L({color:n,theme:e,autoContrast:r}):void 0}})),cf=V(e=>{let t=z(`Tabs`,of,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=B({name:`Tabs`,props:t,classes:ef,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:sf});return(0,R.jsx)(Qd,{value:{placement:h,value:te,orientation:a,id:O,loop:s,activateTabWithKeyboard:l,getTabId:ee(`${O}-tab`,af),getPanelId:ee(`${O}-panel`,af),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,R.jsx)(H,{id:O,variant:d,mod:[{orientation:a,inverted:a===`horizontal`&&m,placement:a===`vertical`&&h},T],...re(`root`),...D,children:o})})});cf.classes=ef,cf.varsResolver=sf,cf.displayName=`@mantine/core/Tabs`,cf.Tab=rf,cf.Panel=nf,cf.List=tf;var lf=V(e=>{let t=z([`Input`,`InputWrapper`,`TextInput`],null,e);return(0,R.jsx)(K,{component:`input`,...t,__staticSelector:`TextInput`})});lf.classes=K.classes,lf.displayName=`@mantine/core/TextInput`;var uf=_();function df(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 ff(e,t,n){let r=e.trim();return r.length===0?{kind:`ignored`}:r.startsWith(`/`)?pf(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 pf(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}`}}}}var mf=11,hf=19;function gf(e){return e.slice(mf,hf)}function _f(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} ${e.status} by ${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 vf(e){return{type:`chat`,sender:e.from,content:e.content,timestamp:e.timestamp}}function yf({message:e}){switch(e.type){case`chat`:return(0,R.jsxs)(wc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,R.jsx)(mu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,R.jsx)(mu,{c:`dimmed`,size:`xs`,span:!0,children:gf(e.timestamp)}),(0,R.jsxs)(mu,{span:!0,children:[`: `,e.content]})]});case`dm`:return(0,R.jsxs)(wc,{gap:`xs`,wrap:`wrap`,align:`baseline`,children:[(0,R.jsx)(wd,{color:`grape`,size:`xs`,children:`DM`}),(0,R.jsx)(mu,{fw:600,c:`accent`,span:!0,children:e.sender}),(0,R.jsx)(mu,{c:`dimmed`,size:`xs`,span:!0,children:gf(e.timestamp)}),(0,R.jsxs)(mu,{span:!0,children:[`: `,e.content]})]});case`system`:return(0,R.jsx)(mu,{c:`dimmed`,fs:`italic`,size:`sm`,children:e.text});case`status`:return(0,R.jsx)(mu,{c:`yellow`,size:`xs`,children:e.text})}}function bf({messages:e}){let t=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.length]),(0,R.jsx)(ss,{flex:1,p:`md`,viewportRef:t,"aria-label":`Conversation`,children:(0,R.jsx)(Zd,{gap:4,children:e.map((e,t)=>(0,R.jsx)(yf,{message:e},t))})})}function xf({messages:e,rooms:t,currentRoom:n,dmTarget:r,connected:i,sidebarOpened:a,onToggleSidebar:o,onSendAction:s,onLeaveRoom:c,onConnectToMesh:l}){let[u,d]=(0,A.useState)(``),f=(n===void 0?void 0:t.find(e=>e.id===n)?.name??n)??(r===void 0?`Select a room`:`DM with ${r}`),p=()=>{let e=u.trim();if(e){switch(ff(e,n,r).kind){case`action`:s(e);break;case`local`:s(e)}d(``)}};return(0,R.jsxs)(Zd,{h:`100%`,gap:0,children:[(0,R.jsxs)(wc,{component:`header`,justify:`space-between`,px:`md`,py:`sm`,bg:`dark.6`,children:[(0,R.jsxs)(wc,{gap:`sm`,children:[(0,R.jsx)(Dd,{opened:a,onClick:o,size:`sm`,"aria-label":`Toggle sidebar`}),(0,R.jsx)(mu,{fw:600,children:f})]}),n!==void 0&&(0,R.jsx)(Id,{size:`xs`,variant:`subtle`,onClick:c,children:`Leave`})]}),(0,R.jsx)(bf,{messages:e}),!i&&e.length===0&&(0,R.jsxs)(Zd,{align:`center`,justify:`center`,gap:`md`,p:`xl`,children:[(0,R.jsx)(mu,{c:`dimmed`,children:`Connect to a local mesh to discover agents and rooms.`}),(0,R.jsx)(Id,{variant:`outline`,onClick:l,children:`Connect to local mesh`})]}),(0,R.jsxs)(wc,{px:`md`,py:`sm`,gap:`xs`,bg:`dark.6`,children:[(0,R.jsx)(lf,{flex:1,placeholder:`Type a message or /command...`,"aria-label":`Message`,autoComplete:`off`,value:u,onChange:e=>{d(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&p()}}),(0,R.jsx)(Id,{onClick:p,children:`Send`})]})]})}function Sf(e){return typeof e==`object`&&!!e}function Cf(e){return Array.isArray(e)}function wf(e){return Array.isArray(e)}function Tf(e){return Array.isArray(e)}function Ef(e){return Sf(e)&&Array.isArray(e.nodes)&&Array.isArray(e.edges)}function Df(e){return!Sf(e)||typeof e.rttMs!=`number`||!Sf(e.local)||!Sf(e.outcome)?!1:typeof e.outcome.result==`string`}async function Of(){let e=await(await fetch(`/api/agents`)).json();if(!Cf(e))throw Error(`Invalid agents response`);return e}async function kf(){let e=await(await fetch(`/api/rooms`)).json();if(!wf(e))throw Error(`Invalid rooms response`);return e}async function Af(e,t){let n=t===void 0?`/api/rooms/${encodeURIComponent(e)}/messages`:`/api/rooms/${encodeURIComponent(e)}/messages?since=${encodeURIComponent(t)}`,r=await(await fetch(n)).json();if(!Tf(r))throw Error(`Invalid messages response`);return r}async function jf(e){try{let t=await e.json();if(Sf(t)&&typeof t.error==`string`)return t.error}catch{}return e.statusText||`HTTP ${String(e.status)}`}async function Mf(){let e=await fetch(`/api/mesh/graph`);if(!e.ok)throw Error(await jf(e));let t=await e.json();if(!Ef(t))throw Error(`Invalid mesh graph response`);return t}async function Nf(e,t){let n=new URLSearchParams({target:e});t!==void 0&&n.set(`timeoutMs`,String(t));let r=await fetch(`/api/mesh/trace?${n.toString()}`);if(!r.ok)throw Error(await jf(r));let i=await r.json();if(!Df(i))throw Error(`Invalid mesh trace response`);return i}function Pf(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 Ff(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return If(this.cover(t,n),t,n,e)}function If(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 Lf(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)If(this,o[n],s[n],e[n]);return this}function Rf(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 zf(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Bf(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 Vf(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Q(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 Vf(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 Vf(p[3],g,_,c,l),new Vf(p[2],o,_,g,l),new Vf(p[1],g,s,c,_),new Vf(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 Hf(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 Uf(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Wf(){return this._root}function Gf(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Kf(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new Vf(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 Vf(i,l,u,s,c)),(i=r[2])&&t.push(new Vf(i,a,u,l,c)),(i=r[1])&&t.push(new Vf(i,l,o,s,u)),(i=r[0])&&t.push(new Vf(i,a,o,l,u))}return this}function qf(e){var t=[],n=[],r;for(this._root&&t.push(new Vf(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 Vf(a,o,s,u,d)),(a=i[1])&&t.push(new Vf(a,u,s,c,d)),(a=i[2])&&t.push(new Vf(a,o,d,u,l)),(a=i[3])&&t.push(new Vf(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 Jf(e){return e[0]}function Yf(e){return arguments.length?(this._x=e,this):this._x}function Xf(e){return e[1]}function Zf(e){return arguments.length?(this._y=e,this):this._y}function Qf(e,t,n){var r=new $f(t??Jf,n??Xf,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function $f(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 ep(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var $=Qf.prototype=$f.prototype;$.copy=function(){var e=new $f(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=ep(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]=ep(r));return e},$.add=Ff,$.addAll=Lf,$.cover=Rf,$.data=zf,$.extent=Bf,$.find=Q,$.remove=Hf,$.removeAll=Uf,$.root=Wf,$.size=Gf,$.visit=Kf,$.visitAfter=qf,$.x=Yf,$.y=Zf;function tp(e){return function(){return e}}function np(e){return(e()-.5)*1e-6}function rp(e){return e.index}function ip(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function ap(e){var t=rp,n=d,r,i=tp(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||np(l),m=f.y+f.vy-d.y-d.vy||np(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=ip(u,d.source)),typeof d.target!=`object`&&(d.target=ip(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:tp(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:tp(+e),h(),f):i},f}var op={value:()=>{}};function sp(){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 cp(n)}function cp(e){this._=e}function lp(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}})}cp.prototype=sp.prototype={constructor:cp,on:function(e,t){var n=this._,r=lp(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=up(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]=dp(n[i],e.name,t);else if(t==null)for(i in n)n[i]=dp(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 cp(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 up(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function dp(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=op,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var fp=0,pp=0,mp=0,hp=1e3,gp,_p,vp=0,yp=0,bp=0,xp=typeof performance==`object`&&performance.now?performance:Date,Sp=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Cp(){return yp||=(Sp(wp),xp.now()+bp)}function wp(){yp=0}function Tp(){this._call=this._time=this._next=null}Tp.prototype=Ep.prototype={constructor:Tp,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Cp():+n)+(t==null?0:+t),!this._next&&_p!==this&&(_p?_p._next=this:gp=this,_p=this),this._call=e,this._time=n,jp()},stop:function(){this._call&&(this._call=null,this._time=1/0,jp())}};function Ep(e,t,n){var r=new Tp;return r.restart(e,t,n),r}function Dp(){Cp(),++fp;for(var e=gp,t;e;)(t=yp-e._time)>=0&&e._call.call(void 0,t),e=e._next;--fp}function Op(){yp=(vp=xp.now())+bp,fp=pp=0;try{Dp()}finally{fp=0,Ap(),yp=0}}function kp(){var e=xp.now(),t=e-vp;t>hp&&(bp-=t,vp=e)}function Ap(){for(var e,t=gp,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:gp=n);_p=e,jp(r)}function jp(e){fp||(pp&&=clearTimeout(pp),e-yp>24?(e<1/0&&(pp=setTimeout(Op,e-xp.now()-bp)),mp&&=clearInterval(mp)):(mp||=(vp=xp.now(),setInterval(kp,hp)),fp=1,Sp(Op)))}var Mp=1664525,Np=1013904223,Pp=4294967296;function Fp(){let e=1;return()=>(e=(Mp*e+Np)%Pp)/Pp}function Ip(e){return e.x}function Lp(e){return e.y}var Rp=10,zp=Math.PI*(3-Math.sqrt(5));function Bp(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=Ep(d),l=sp(`tick`,`end`),u=Fp();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=Rp*Math.sqrt(.5+t),a=t*zp;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 Vp(){var e,t,n,r,i=tp(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=Qf(e,Ip,Lp).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=np(n),m+=d*d),f===0&&(f=np(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=np(n),m+=d*d),f===0&&(f=np(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:tp(+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 Hp=600,Up=400,Wp=300,Gp=10,Kp=8;function qp(e){let t=e.nodes.map(e=>({id:e})),n=e.edges.map(e=>({source:e.from,target:e.to,kind:e.kind})),r=Bp(t).force(`link`,ap(n).id(e=>e.id)).force(`charge`,Vp()).force(`center`,Pf(Hp/2,Up/2)).stop();for(let e=0;e<Wp;e++)r.tick();return{nodes:t,links:n}}function Jp(e){return typeof e==`object`?e:void 0}function Yp({graph:e,selectedDevice:t,onSelectDevice:n}){let{nodes:r,links:i}=(0,A.useMemo)(()=>qp(e),[e]);return r.length===0?(0,R.jsx)(mu,{c:`dimmed`,p:`md`,children:`No known devices in the mesh graph.`}):(0,R.jsx)(H,{p:`md`,children:(0,R.jsxs)(`svg`,{role:`img`,"aria-label":`Mesh connection graph`,viewBox:`0 0 ${String(Hp)} ${String(Up)}`,width:`100%`,style:{maxHeight:Up},children:[i.map(e=>{let t=Jp(e.source),n=Jp(e.target);return!t||!n?null:(0,R.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,R.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,R.jsx)(`circle`,{r:Gp,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,R.jsx)(`text`,{y:22,textAnchor:`middle`,fontSize:10,fill:`var(--mantine-color-text)`,children:e.id.slice(0,Kp)})]},e.id))]})})}var Xp=8;function Zp(e){return e.relayed?e.hubAddress===void 0?`relayed`:`relayed via ${e.hubAddress}`:`direct`}function Qp({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,Xp)}));return(0,R.jsxs)(Zd,{p:`md`,gap:`sm`,children:[(0,R.jsxs)(wc,{align:`flex-end`,gap:`xs`,children:[(0,R.jsx)(qd,{label:`Target device`,placeholder:`Choose a device`,size:`xs`,data:s,value:t??null,onChange:e=>{e!==null&&n(e)}}),(0,R.jsx)(Id,{size:`xs`,disabled:t===void 0||i,loading:i,onClick:r,children:`Trace`})]}),a!==void 0&&(0,R.jsx)(mu,{c:`red`,children:a}),o!==void 0&&(0,R.jsxs)(Zd,{gap:4,children:[(0,R.jsxs)(wc,{gap:`xs`,children:[(0,R.jsx)(wd,{color:o.outcome.result===`ok`?`green`:`red`,children:o.outcome.result===`ok`?`ok`:o.outcome.code??`error`}),(0,R.jsxs)(mu,{size:`sm`,children:[o.rttMs,`ms round trip`]})]}),(0,R.jsxs)(mu,{size:`sm`,c:`dimmed`,children:[`Local: `,Zp(o.local)]}),o.remote!==void 0&&(0,R.jsxs)(mu,{size:`sm`,c:`dimmed`,children:[`Remote: `,Zp(o.remote)]})]})]})}function $p({graph:e}){let[t,n]=(0,A.useState)(void 0),[r,i]=(0,A.useState)(!1),[a,o]=(0,A.useState)(void 0),[s,c]=(0,A.useState)(void 0);function l(){t!==void 0&&(i(!0),o(void 0),c(void 0),Nf(t).then(e=>{c(e)}).catch(e=>{o(e instanceof Error?e.message:String(e))}).finally(()=>{i(!1)}))}return e===void 0?(0,R.jsx)(mu,{c:`dimmed`,p:`md`,children:`Mesh graph is not available on this connection.`}):(0,R.jsxs)(cf,{defaultValue:`graph`,children:[(0,R.jsxs)(cf.List,{children:[(0,R.jsx)(cf.Tab,{value:`graph`,children:`Graph`}),(0,R.jsx)(cf.Tab,{value:`trace`,children:`Trace`})]}),(0,R.jsx)(cf.Panel,{value:`graph`,children:(0,R.jsx)(Yp,{graph:e,selectedDevice:t,onSelectDevice:n})}),(0,R.jsx)(cf.Panel,{value:`trace`,children:(0,R.jsx)(Zd,{children:(0,R.jsx)(Qp,{targets:e.nodes,selectedTarget:t,onSelectTarget:n,onTrace:l,loading:r,error:a,result:s})})})]})}function em(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)),em(a,i,n)}function tm(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)),tm(i,r)}var nm=`Project room for `;function rm(e){return e.description.startsWith(nm)}function im(e){return e.description.slice(17)}function am(e,t){let n=t.filter(e=>!rm(e)),r=new Map;for(let e of t)rm(e)&&r.set(im(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=cm(Array.from(i)),o=a===`/`?[]:om(a),s={children:new Map,agents:[]};for(let t of e)em(s,om(t.cwd).slice(o.length),t);for(let e of r.keys())tm(s,om(e).slice(o.length));return{roots:um(lm(s,a,``,r)),manualRooms:n}}function om(e){return e.split(`/`).filter(e=>e.length>0)}function sm(...e){return`/`+e.join(`/`)}function cm(e){if(e.length===0)return`/`;let t=e.map(om),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?`/`:sm(...t[0]?.slice(0,r)??[])}function lm(e,t,n,r){let i=[];for(let[a,o]of e.children){let e=n===``&&t===`/`?`/`+a:n===``?t+`/`+a:n+`/`+a,s=lm(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:um(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 um(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}var dm=[{value:`public`,label:`Public`},{value:`private`,label:`Private`},{value:`secret`,label:`Secret`}];function fm(e){return e===`public`||e===`private`||e===`secret`}function pm({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,R.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&(t(r.trim(),a,s.trim()),i(``),o(`public`),c(``))},children:(0,R.jsxs)(Zd,{gap:`xs`,p:`xs`,children:[(0,R.jsx)(lf,{label:`Room name`,name:`room-name`,required:!0,placeholder:`e.g. project-alpha`,size:`xs`,value:r,onChange:e=>{i(e.target.value)}}),(0,R.jsx)(qd,{label:`Type`,name:`room-type`,size:`xs`,data:dm,value:a,allowDeselect:!1,onChange:e=>{fm(e)&&o(e)}}),(0,R.jsx)(lf,{label:`Description (optional)`,name:`room-description`,placeholder:`What is this room about?`,size:`xs`,value:s,onChange:e=>{c(e.target.value)}}),(0,R.jsxs)(wc,{gap:`xs`,children:[(0,R.jsx)(Id,{type:`submit`,size:`xs`,flex:1,children:`Create`}),(0,R.jsx)(Id,{type:`button`,size:`xs`,flex:1,variant:`default`,onClick:n,children:`Cancel`})]})]})}):null}function mm({visible:e,onSubmit:t,onCancel:n}){let[r,i]=(0,A.useState)(``);if(!e)return null;let a=()=>{let e=r.trim();e&&(t(e),i(``))};return(0,R.jsxs)(wc,{gap:`xs`,py:4,children:[(0,R.jsx)(lf,{flex:1,size:`xs`,placeholder:`Room name...`,"aria-label":`Room name`,autoComplete:`off`,value:r,onChange:e=>{i(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&a(),e.key===`Escape`&&n()}}),(0,R.jsx)(Id,{size:`xs`,onClick:a,children:`Join`})]})}var hm={active:`green`,idle:`yellow`,busy:`red`,offline:`gray`};function gm({status:e}){return(0,R.jsx)(H,{w:8,h:8,style:{borderRadius:`50%`,backgroundColor:`var(--mantine-color-${hm[e]}-6)`}})}function _m({tree:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return(0,R.jsxs)(H,{mb:`xs`,children:[e.roots.map(e=>(0,R.jsx)(vm,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path)),e.manualRooms.length>0&&(0,R.jsxs)(H,{py:4,children:[(0,R.jsx)(mu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,px:`xs`,py:4,children:`Rooms`}),e.manualRooms.map(e=>(0,R.jsx)(Vd,{label:`${e.name} (${String(e.members.length)})`,active:i===e.id,onClick:()=>{t(e.id)}},e.id))]})]})}function vm({node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i}){return e.type===`agent`?(0,R.jsx)(bm,{node:e,onSelectAgent:n,onRenameAgent:r}):(0,R.jsx)(ym,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i})}function ym({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,R.jsx)(Vd,{label:e.name,leftSection:(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`📁`}),defaultOpened:!0,active:o,...s,children:e.children.map(e=>(0,R.jsx)(vm,{node:e,onJoinRoom:t,onSelectAgent:n,onRenameAgent:r,currentRoom:i},e.type===`agent`?e.agentId:e.path))})}function bm({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,R.jsx)(lf,{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,R.jsx)(Vd,{label:e.name,leftSection:(0,R.jsx)(gm,{status:e.status}),onClick:()=>{t(e.agentId)},onDoubleClick:c})}function xm({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=am(f?t:t.filter(e=>e.status!==`offline`),e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(wc,{justify:`space-between`,px:`md`,py:`sm`,children:[(0,R.jsx)(mu,{size:`sm`,fw:600,c:`accent`,children:`Agent Comms`}),(0,R.jsx)(mc,{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,R.jsxs)(ss,{flex:1,px:`xs`,children:[(0,R.jsx)(_m,{tree:m,onJoinRoom:r,onSelectAgent:i,onRenameAgent:a,currentRoom:n}),(0,R.jsxs)(wc,{justify:`space-between`,px:`xs`,py:4,children:[(0,R.jsx)(mu,{size:`xs`,c:`dimmed`,fw:700,tt:`uppercase`,children:`Create`}),(0,R.jsx)(mc,{variant:`default`,size:`sm`,"aria-label":`Create room`,title:`Create room`,onClick:()=>{l(e=>!e)},children:`+`})]}),(0,R.jsx)(pm,{visible:c,onSubmit:(e,t,n)=>{o(e,t,n),l(!1)},onCancel:()=>{l(!1)}}),(0,R.jsx)(Id,{fullWidth:!0,size:`xs`,variant:`outline`,onClick:()=>{d(e=>!e)},children:`+ Join Room`}),(0,R.jsx)(mm,{visible:u,onSubmit:e=>{s(e),d(!1)},onCancel:()=>{d(!1)}})]})]})}function Sm(e){let[t,{toggle:n}]=Ye(!0),[r,i]=(0,A.useState)(`chat`);return(0,R.jsxs)(Ru,{navbar:{width:260,breakpoint:`sm`,collapsed:{desktop:!t,mobile:!t}},children:[(0,R.jsxs)(Ru.Navbar,{children:[(0,R.jsx)(xm,{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,R.jsx)(Gd,{m:`xs`,size:`xs`,fullWidth:!0,value:r,onChange:i,data:[{label:`Chat`,value:`chat`},{label:`Mesh`,value:`mesh`}]})]}),(0,R.jsx)(Ru.Main,{h:`100vh`,children:r===`chat`?(0,R.jsx)(xf,{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,R.jsx)($p,{graph:e.meshGraph})})]})}var Cm={currentRoom:void 0,dmTarget:void 0,agents:[],rooms:[],messages:[],connected:!1,meshGraph:void 0},wm=class{state={...Cm};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()}setMeshGraph(e){this.state={...this.state,meshGraph: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={...Cm,messages:[]},this.notify()}notify(){let e=this.state;for(let t of this.listeners)t(e)}};function Tm(e){return(0,A.useSyncExternalStore)(t=>e.subscribe(t),()=>e.get())}function Em(e){return Array.isArray(e)?e:e==null?[]:[e]}var Dm=class extends Error{constructor(...e){super(...e),this.name=`AbortError`}};function Om(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}var km=class{index=BigInt(1);generate(){let e=this.index.toString(36);return this.index++,e}};function Am(e){return!e||typeof e!=`object`?!1:`next`in e&&typeof e.next==`function`&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}var jm=Symbol.asyncDispose??Symbol.for(`asyncDispose`),Mm=class{isDone=!1;isExecuteComplete=!1;cleanup;next;constructor(e,t){this.cleanup=t,this.next=Om(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[jm](){this.isDone=!0,this.isExecuteComplete||(this.isExecuteComplete=!0,await this.cleanup({kind:`cancelled`}))}[Symbol.asyncIterator](){return this}};function Nm(e){return JSON.stringify(e)}function Pm(e){for(let t of Object.values(e))if(t!==void 0)return!0;return!1}function Fm(e){if(!e)return!1;let t=typeof e;return t===`object`||t===`function`}var Im=new WeakMap;function Lm(e,t,{bind:n=!0}={}){let r=Reflect.get(e,t);if(!n||typeof r!=`function`)return r;let i=Im.get(r);i||Im.set(r,i=new WeakMap);let a=i.get(e);return a||i.set(e,a=r.bind(e)),a}var Rm=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 Dm(`Queue was closed.`),this.closed={reason:e},this.pendingPulls.forEach(([,t])=>t(e)),this.pendingPulls.length=0)}abort(e){e??=new Dm(`Queue was aborted.`),this.items.length=0,this.close(e)}},zm=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function Bm(e){try{return encodeURIComponent(e)}catch{return encodeURIComponent(e.replace(zm,`�`))}}function Vm(e){if(!e.includes(`%`))return e;try{return decodeURIComponent(e)}catch{return e}}function Hm(e){return e[0]??{}}var Um=`orpc`;function Wm(e){return e instanceof Error&&e.name.includes(`Abort`)}Object.getPrototypeOf(async function*(){}).constructor;function Gm(e){let t;return()=>{if(t)return t.result;let n=e();return t={result:n},n}}function Km(e){return`/${e.map(encodeURIComponent).join(`/`)}`}var qm=Symbol.for(`ORPC_TRACER`);function Jm(){return globalThis[qm]}function Ym(e){let t=Jm();if(t)return typeof e==`string`?t.startSpan(e):t.startSpan(e.name,e.parent)}function Xm(e,t){e&&e.recordException(Wm(t)?`info`:`error`,Zm(t))}function Zm(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 Qm(e,t){let n=Jm();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 Xm(e,t),t}finally{e.end()}})}function $m(e,t){let n=Jm();return!e||!n?t():n.withActiveSpan(e,t)}function eh(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o;return new Mm(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 th(e,t){let n=Gm(()=>Ym(e));return eh(t,{runWith:e=>$m(n(),e),mapResult(e){return n()?.addEvent(e.done?`completed`:`yielded`),e},onError(e){Xm(n(),e)},onFinish(){n()?.end()}})}function nh(e,...t){return typeof e==`function`?e(...t):e}function rh(e,t){return new Proxy(typeof e==`function`?t:e,{get(n,r){return Lm(r in t?t:nh(e),r)},has(n,r){return Reflect.has(t,r)||Reflect.has(nh(e),r)}})}function*ih(e){if(!Fm(e))return;let t=Object.getPrototypeOf(e);for(;t!=null;)t.constructor&&(yield t.constructor),t=Object.getPrototypeOf(t)}function ah(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}var oh=(()=>{let e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function sh(e,{runWith:t,mapResult:n,mapError:r,onError:i,onFinish:a}){t??=e=>e();let o=Gm(()=>e.getReader()),s=Gm(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 ch(e,t){let n=Gm(()=>Ym(e));return sh(t,{runWith:e=>$m(n(),e),mapResult(e){return n()?.addEvent(e.done?`closed`:`enqueued`),e},onError(e){Xm(n(),e)},onFinish(){n()?.end()}})}function lh(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 uh(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 dh=class extends TypeError{},fh=class extends Error{constructor(e,t={}){super(t?.message??`Error Event`,t),this.data=e}},ph=/\r\n|[\n\r]/;function mh(e){return ph.test(e)}function hh(e){if(mh(e))throw new dh(`Event's id must not contain a carriage return or newline character`)}function gh(e){if(!Number.isInteger(e)||e<0)throw new dh(`Event's retry must be a integer and >= 0`)}function _h(e){if(mh(e))throw new dh(`Event's comment must not contain a carriage return or newline character`)}var vh=Symbol.for(`STANDARD_SERVER_EVENT_META`),yh=Symbol.for(`STANDARD_SERVER_EVENT_SOURCE`);function bh(e,t){let n;if(t.id!==void 0&&(hh(t.id),n??={},n.id=t.id),t.retry!==void 0&&(gh(t.retry),n??={},n.retry=t.retry),t.comments!==void 0){for(let e of t.comments)_h(e);n??={},n.comments=t.comments}return n?new Proxy(e,{get(e,t,r){return t===yh?e:t===vh?n:Lm(e,t)}}):e}function xh(e){if(!Fm(e))return[e,void 0];let t=e[vh];return[e[yh]??e,t]}function Sh(e){if(Fm(e))return e[vh]}function Ch(e,t=`inline`){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,`_`).replace(/[\\"]/g,`\\$&`)}"; filename*=utf-8''${Bm(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}function wh(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 Vm(t)}else if(t)return Vm(t);let r=e.match(/(?:^|;)\s*filename=(?:"((?:\\.|[^"\\])*)"|([^";]*))/i);return r?.[1]===void 0?r?.[2]?.trim()||void 0:r[1].replace(/\\(.)/g,`$1`)}function Th(e){if(typeof e==`string`||e===void 0)return e;if(e.length!==0)return e.join(`, `)}function Eh(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:[...Em(t),...Em(i)]}return n}function Dh(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 Oh(e){return Fm(e)?Object.values(e).every(e=>e===void 0||typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)):!1}function kh(e){return Number.isInteger(e)}var Ah={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},jh,Mh=class e extends Error{static{let t=Symbol.for(`ORPC_ERROR_CONSTRUCTORS`);globalThis[t]??=new WeakSet,jh=globalThis[t],jh.add(e)}name=`ORPCError`;defined=!1;code;data;constructor(e,...t){let n=Hm(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(!jh.has(this))return super[Symbol.hasInstance](e);for(let t of ih(e))if(jh.has(t))return!0;return!1}},Nh=class extends Error{name=`MalformedResponseError`;response;constructor(e){super(e.message,e),this.response=e.response}};function Ph(e){return e instanceof Mh?e:new Mh(`INTERNAL_SERVER_ERROR`,{cause:e})}function Fh(e){if(!ah(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 Ih(e,t={}){let n=new Mh(e.code,{...e,...t});return n.defined=e.defined,n}function Lh(e){let t=new Mh(`MALFORMED_ORPC_RESPONSE`,{message:e.message??Vh(e.response),data:e.response});return t.cause=new Nh({...e,message:t.message}),t}var Rh=1,zh=256;function Bh(e){return e.length>=Rh&&e.length<=zh}function Vh(e){return typeof e.body==`string`&&Bh(e.body)?e.body:ah(e.body)&&typeof e.body.message==`string`&&Bh(e.body.message)?e.body.message:(Object.entries(Ah).find(([,t])=>t===e.status)?.[0])?.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function Hh(e,{mapResult:t,mapError:n,...r}){return eh(e,{...r,mapResult:t&&(async e=>{let n=await t(e);if(n.value!==e.value){let t=Sh(e.value);if(t&&Fm(n.value))return{done:n.done,value:bh(n.value,t)}}return n}),mapError:n&&(async e=>{let t=await n(e);if(t!==e){let n=Sh(e);if(n&&Fm(t))return bh(t,n)}return t})})}var Uh=/^\/([\s\S]*)\/([a-z]*)$/,Wh={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(Uh);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)}}},Gh=class{handlers;inlineBuiltInHandlers;handlerEntries;omitUndefinedProperties;constructor(e={}){this.omitUndefinedProperties=e.omitUndefinedProperties!==!1,this.handlers=Object.assign(new oh,Wh);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 Wh&&(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(ah(e)){let a=new oh;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}},Kh=class{jsonSerializer;defaultSerializeOptions;constructor(e={}){this.jsonSerializer=new Gh(e),this.defaultSerializeOptions=e.serialize}serialize(e,t={}){if(e===void 0||e instanceof ReadableStream||e instanceof Blob)return e;if(Am(e))return Hh(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.serializeValue(e.value,!1)},mapError:e=>new fh(this.serializeValue(Ph(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`,Nm({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:Am(e)?Hh(e,{mapResult:e=>e.value===void 0?e:{done:e.done,value:this.deserializeValue(e.value)},mapError:e=>{if(!(e instanceof fh))return e;let t=this.deserializeValue(e.data);return Fh(t)?Ih(t,{cause:e}):new fh(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})}},qh=new Set([`then`,`bind`,`call`,`apply`,`valueOf`,`toString`,`toJSON`]);function Jh(e){return{...e,context:e.context??{}}}function Yh(e){return[e[0],Jh(e[1]??{})]}function Xh(e,{path:t=[],...n}={}){let r=(...r)=>{let[i,a]=Yh(r);return lh([...Em(n.interceptors),...Em(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`||qh.has(a))return Reflect.get(r,a);let o=i.get(a);return o===void 0&&(o=Xh(e,{...n,path:[...t,a],scoped:n.scoped?.[a]}),i.set(a,o)),o}})}function Zh(e,t){return new Mm(async()=>{for(;;){let{json:t}=await e.pull();switch(t.event){case void 0:case`message`:{let e=t.data;return Fm(e)&&(e=bh(e,t)),{value:e,done:!1}}case`error`:throw bh(new fh(t.data),t);case`close`:{let e=t.data;return Fm(e)&&(e=bh(e,t)),{value:e,done:!0}}}}},t)}var Qh=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]=xh(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 fh){if(!this.isDone){this.isDone=!0;let[t,n]=xh(e);await this.send({kind:`event-stream`,id:this.messageId,json:{...n,event:`error`,data:t.data}})}return}throw this.isDone=!0,e}}};function $h(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 eg=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 tg(e,t){let n=Th(e.json.headers?.[`content-type`]),r=Th(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 Rm;return{resolveBody:async()=>Zh(e,t),eventStreamMessageQueue:e}}if(n!==void 0){let e=new Rm;return{resolveBody:async()=>$h(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=Th(e.json.headers?.[`content-disposition`]),i=t===void 0?void 0:wh(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 ng(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`]??=Ch(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,Am(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 rg=class{constructor(e){this.send=e}idGenerator=new km;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 ng(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:Pm(r.headers)?r.headers:void 0,body:r.jsonBody},binary:r.binary}),Am(n.body)){let r=new Qh(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 eg(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 Dm(`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=tg(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 Dm(`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 Dm(`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 Dm(`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 ig(e){return!(!Fm(e)||typeof e.id!=`string`||typeof e.kind!=`string`||e.binary!==void 0&&!(e.binary instanceof Uint8Array)&&!(e.binary instanceof Blob))}function ag(e){return!(e.kind!==`response`||!Fm(e.json)||e.json.status!==void 0&&!kh(e.json.status)||e.json.headers!==void 0&&!Oh(e.json.headers))}function og(e){return e.kind===`cancel`&&e.json===void 0&&e.binary===void 0}function sg(e){return!(e.kind!==`event-stream`||e.binary!==void 0||!Fm(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 cg(e){return e.kind===`octet-stream`&&Fm(e.json)&&(e.json.close===void 0||typeof e.json.close==`boolean`)}function lg(e){return e.kind===`stream/cancel`&&e.json===void 0&&e.binary===void 0}function ug(e){return ag(e)||og(e)||sg(e)||cg(e)||lg(e)}var dg=255,fg=new TextEncoder,pg=new TextDecoder;async function mg(e,t={}){if(e.binary===void 0){let n=Nm(e);return t.prefix?t.prefix+n:n}let n=Nm({...e,binary:void 0}),r=fg.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]=dg,a.set(i,r.length+1),a}function hg(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 ig(n)?{matched:!0,message:n}:{matched:!1}}if(t.prefix){let n=fg.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(dg);if(n===-1){let t=JSON.parse(pg.decode(e));return ig(t)?{matched:!0,message:t}:{matched:!1}}let r=e.subarray(0,n),i=e.subarray(n+1),a=JSON.parse(pg.decode(r));return ig(a)?(a.binary=i,{matched:!0,message:a}):{matched:!1}}catch{return{matched:!1}}}function gg(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 _g=class{name=`~composite`;plugins;constructor(e=[]){this.plugins=uh(e)}init(e){for(let t of this.plugins)t.init&&(e=t.init(e));return e}},vg=class{constructor(e,t,n={}){this.codec=e,this.transport=t,n=new _g(n.plugins).init(n),this.interceptors=n.interceptors,this.transportInterceptors=n.transportInterceptors}interceptors;transportInterceptors;call(e,t,n){return Qm(`${Um}.${e.join(`/`)}`,r=>(r?.setAttribute(`rpc.system`,Um),r?.setAttribute(`rpc.method`,e.join(`.`)),Jm()&&Am(t)?t=rh(t,th(`consume_async_iterator_object_input`,t)):Jm()&&t instanceof ReadableStream&&(t=rh(t,ch(`consume_octet_stream_input`,t))),lh(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{let i=Jm(),a=i?.getActiveSpan()??r,o=await Qm({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 lh(this.transportInterceptors,{...n,path:e,request:o},({path:e,request:t,...n})=>Qm({name:`send_request`,parent:i?.getActiveSpan()??a},()=>this.transport.send(t,e,n))),c=await Qm({name:`decode_response`,parent:a},()=>this.codec.decodeResponse(s,e,n));if(c.kind===`error`)throw c.error;let l=c.output;return Jm()&&Am(l)?rh(l,th(`consume_async_iterator_object_output`,l)):Jm()&&l instanceof ReadableStream?rh(l,ch(`consume_octet_stream_output`,l)):l})))}},yg=/\/$/,bg=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 Kh}async encodeInput(e,t,n){let r=xg(await nh(this.headers,n,t,e));n.lastEventId!==void 0&&(r=Eh(r,{"last-event-id":n.lastEventId}));let i=await nh(this.expectedMethod,n,t,e),[a,o,s]=Dh(await nh(this.baseUrl,n,t,e)),c=`${a.replace(yg,``)}${Km(t)}`,l=this.serializer.serialize(e);if(i===`GET`&&!(l instanceof Blob)&&!(l instanceof ReadableStream)&&!(l instanceof FormData)&&!Am(l)){let a=await nh(this.maxUrlLength,n,t,e),u=new URLSearchParams(o);u.append(`data`,Nm(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 Lh({message:`Invalid RPC response format.`,response:{status:e.status,headers:e.headers,body:n},cause:t})}})();return t?{kind:`output`,output:r}:Fh(r)?{kind:`error`,error:Ih(r)}:{kind:`error`,error:Lh({response:{headers:e.headers,status:e.status,body:n}})}}};function xg(e){return typeof e.forEach==`function`?gg(e):e}function Sg(e,t,n){n?e.postMessage(t,n):e.postMessage(t)}function Cg(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 wg(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 Tg=class{peer;constructor({port:e,experimental_transfer:t,encodePeerMessage:n,decodePeerMessage:r}){this.peer=new rg(async r=>{let i=await nh(t,r,e);i?Sg(e,r,i):Sg(e,await mg(r,n))}),Cg(e,async e=>{let t;if(typeof e==`string`||e instanceof Uint8Array){let n=hg(e,r);n.matched&&ug(n.message)&&(t=n.message)}else ig(e)&&ug(e)&&(t=e);return t===void 0?{matched:!1}:(await this.peer.message(t),{matched:!0})}),wg(e,async()=>{await this.peer.close()})}async send(e,t,n){return await this.peer.request(e)}},Eg=class extends vg{constructor(e){let t=new bg(e),n=new Tg(e);super(t,n,e)}};function Dg(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 Og(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 Dg(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 kg=new Set([`room_message`,`dm`,`room_invite`,`member_joined`,`member_left`,`room_members`,`member_status`,`delivery_status`,`invite_declined`,`name_changed`]);function Ag(e){return kg.has(e.type)}var jg=19877,Mg=10,Ng=class{worker;client;state={agents:[],rooms:[],connected:!1};listeners=new Set;deliveryListeners=new Set;eventPumpGeneration=0;constructor(){typeof window<`u`&&window.addEventListener(`pagehide`,()=>{this.disconnect()})}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));Pg(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=Xh(new Eg({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(jg,Mg)}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?Og(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=Sh(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(Ig),n=Object.values(e.state.rooms).filter(Lg);this.state={...this.state,agents:t,rooms:n},this.notify();break}case`state_patch`:this.applyPatch(e.patch);break;case`delivery`:if(Ag(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 Pg(e){return typeof e==`object`&&!!e&&`type`in e}function Fg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ig(e){return Fg(e)&&typeof e.id==`string`&&typeof e.name==`string`}function Lg(e){return Fg(e)&&typeof e.id==`string`&&typeof e.name==`string`}var Rg=Rn({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`]}}),zg=/^(localhost|127\.\d+\.\d+\.\d+)(:\d+)?$/;function Bg(e){return zg.test(e)}function Vg(e){return e.getItem(`agent-comms-connected`)===`true`}var Hg=`Project room for `;function Ug(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 Wg(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===`${Hg}${e.path}`);return n?{kind:`room`,targetId:n.id}:void 0}default:return e}}function Gg(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 Kg=document.createElement(`style`);Kg.textContent=l,document.head.appendChild(Kg);var qg=Bg(location.host),Jg=document.getElementById(`root`);if(Jg===null)throw Error(`missing #root element`);var Yg=new wm,Xg=new Ng,Zg=!1;Xg.subscribe(e=>{e.agents.length>0&&Yg.setAgents(e.agents),e.rooms.length>0&&Yg.setRooms(e.rooms),Yg.setConnected(e.connected),e.connected!==Zg&&(Zg=e.connected,Qg({type:`system`,text:e.connected?`Connected to mesh`:`Disconnected — reconnecting...`}))}),Xg.onDelivery(e=>{let t=_f(e,Yg.get().currentRoom);t&&Qg(t),(e.type===`member_joined`||e.type===`member_left`||e.type===`member_status`||e.type===`name_changed`)&&e_()});function Qg(e){Yg.addMessage(e)}async function $g(e){let t=await Xg.sendAction(e);Qg({type:t.isError?`status`:`system`,text:t.isError?`Error: ${t.content}`:t.content}),t.isError||e_()}async function e_(){if(!qg)return;let[e,t]=await Promise.all([Of(),kf()]);Yg.setAgents(e),Yg.setRooms(t),await t_()}async function t_(){try{Yg.setMeshGraph(await Mf())}catch{}}async function n_(e){if(Yg.setDmTarget(void 0),Yg.setCurrentRoom(e),Yg.clearMessages(),$g({action:`join_room`,room:e}),qg){let t=await Af(e);Yg.setMessages(t.map(vf))}Qg({type:`system`,text:`Joined ${e}`})}function r_(e){Yg.setCurrentRoom(void 0),Yg.setDmTarget(e),Yg.clearMessages()}function i_(){let e=Yg.get(),t=e.currentRoom;if(t!==void 0&&t!==``){let n=e.rooms.find(e=>e.id===t)?.name??t;$g({action:`leave_room`,room:t}),Yg.setCurrentRoom(void 0),Yg.clearMessages(),Qg({type:`system`,text:`Left room "${n}"`})}}function a_(e){let t=Yg.get(),n=ff(e,t.currentRoom,t.dmTarget),r=df(n);if(r)switch(r.kind){case`join_room`:n_(r.room);return;case`leave_room`:i_();return}switch(n.kind){case`action`:$g(n.action);break;case`local`:Qg({type:`system`,text:n.result.text})}}function o_(e,t,n){$g({action:`create_room`,name:e,type:t,...n?{description:n}:{}})}function s_(e){n_(e)}function c_(e,t){$g({action:`rename_agent`,agent:e,name:t})}function l_(){localStorage.setItem(`agent-comms-connected`,`true`),Xg.connect()}function u_(){let e=Tm(Yg);return(0,A.useEffect)(()=>{Gg({currentRoom:e.currentRoom,dmTarget:e.dmTarget})},[e.currentRoom,e.dmTarget]),(0,R.jsx)(Sm,{rooms:e.rooms,agents:e.agents,currentRoom:e.currentRoom,dmTarget:e.dmTarget,messages:e.messages,connected:e.connected,meshGraph:e.meshGraph,onJoinRoom:e=>{n_(e)},onSelectAgent:r_,onRenameAgent:c_,onLeaveRoom:i_,onSendAction:a_,onCreateRoom:o_,onJoinRoomInput:s_,onConnectToMesh:l_})}(0,uf.createRoot)(Jg).render((0,R.jsx)(Ln,{theme:Rg,defaultColorScheme:`dark`,children:(0,R.jsx)(u_,{})}));var d_=Ug(location.search),f_=Vg(localStorage);(qg||f_)&&Xg.connect(),e_().then(()=>{if(!d_)return;let e=Wg(d_,Yg.get().rooms);if(e)switch(e.kind){case`room`:n_(e.targetId);break;case`dm`:r_(e.targetId)}});