@dhzh/foundry 1.3.2 → 1.5.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.
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e,t,a,n,r,i,s={6675(e,t,a){var n=a(5511),r=a(6255),i=a(9366),s=a(4021),o=a(6653),d=a(4466),l=a(2150);let c=(0,d.F)("group/alert relative grid w-full gap-0.5 rounded-lg border px-2 py-1.5 text-start text-xs/relaxed has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pe-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-1.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-3.5",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function u(e){let{className:t,variant:a,...r}=e;return(0,n.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,l.cn)(c({variant:a}),t),...r})}function m(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"alert-title",className:(0,l.cn)("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),...a})}function p(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"alert-description",className:(0,l.cn)("text-xs/relaxed text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",t),...a})}var h=a(9757);let x=(0,d.F)("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",xs:"h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-2.5",sm:"h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",lg:"h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2 [&_svg:not([class*='size-'])]:size-4",icon:"size-7 [&_svg:not([class*='size-'])]:size-3.5","icon-xs":"size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5","icon-sm":"size-6 [&_svg:not([class*='size-'])]:size-3","icon-lg":"size-8 [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default",size:"default"}});function f(e){let{className:t,variant:a="default",size:r="default",...i}=e;return(0,n.jsx)(h.$,{"data-slot":"button",className:(0,l.cn)(x({variant:a,size:r,className:t})),...i})}var g=a(7616),v=a(9356);function b(e){let{className:t,...a}=e;return(0,n.jsx)(g.n,{icon:v.A,strokeWidth:2,"data-slot":"spinner",role:"status","aria-label":"Loading",className:(0,l.cn)("size-4 animate-spin",t),...a})}var j=a(3479),y=a(1085);let w=["settings"];async function N(e){if(!e.ok)throw Error("The Foundry Server could not load Application Settings.");return(await e.json()).data}async function k(){return N(await fetch("/api/settings",{cache:"no-store"}))}async function C(e){return N(await fetch("/api/settings",{body:JSON.stringify(e),headers:{"content-type":"application/json"},method:"PATCH"}))}let P="(prefers-color-scheme: dark)",S=r.createContext(void 0);function E(){return window.matchMedia(P).matches?"dark":"light"}function z(e,t){let a,n="system"===e?E():e,r=t?((a=document.createElement("style")).appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;transition:none!important}")),document.head.appendChild(a),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{a.remove()})})}):null;return document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n),r?.(),n}function _(){let e=r.useContext(S);if(!e)throw Error("useTheme must be used within a ThemeProvider");return e}var A=a(1402),T=a(3735),O=a(7958),F=a(3966),M=a(2918),L=a(9310),D=a(8288);function I(e){let{...t}=e;return(0,n.jsx)(T.s,{"data-slot":"tooltip",...t})}function R(e){let{...t}=e;return(0,n.jsx)(O.k,{"data-slot":"tooltip-trigger",...t})}function U(e){let{className:t,side:a="top",sideOffset:r=4,align:i="center",alignOffset:s=0,children:o,...d}=e;return(0,n.jsx)(F.K,{children:(0,n.jsx)(M.o,{align:i,alignOffset:s,side:a,sideOffset:r,className:"isolate z-50",children:(0,n.jsxs)(L.o,{"data-slot":"tooltip-content",className:(0,l.cn)("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...d,children:[o,(0,n.jsx)(D.P,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-xs bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-inset-s-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-inset-e-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}let $=new(a(7632)).E;var W=a(8071),K=a(6551);let q=["health"],H={pending:"Foundry · Checking…",success:"Foundry · Healthy",error:"Foundry · Unhealthy"};var B=a(3676),V=a(8517),J=a(2802),Q=a(3138),Y=a(4344),G=a(6280),X=a(4038),Z=a(4930),ee=a(7886),et=a(4890),ea=a(2817),en=a(3586),er=a(1585),ei=a(3227),es=a(3373),eo=a(9544);let ed=B.V();function el(e){let{...t}=e;return(0,n.jsx)(V.t,{...t})}function ec(e){let{...t}=e;return(0,n.jsx)(J.S,{"data-slot":"toast-portal",...t})}function eu(e){let{className:t,...a}=e;return(0,n.jsx)(Q.U,{"data-slot":"toast-viewport",className:(0,l.cn)("pointer-events-none fixed inset-x-4 top-4 z-60 mx-auto w-auto max-w-sm outline-none sm:w-full",t),...a})}function em(e){let{className:t,...a}=e;return(0,n.jsx)(Y.m,{"data-slot":"toast",className:(0,l.cn)("group/toast pointer-events-auto absolute end-0 top-0 z-[calc(1000-var(--toast-index))] w-full origin-top rounded-md border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)+calc(var(--toast-index)*var(--gap))+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]","h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+(var(--toast-index)*var(--peek))+(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]","after:absolute after:top-full after:start-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']","data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]","data-limited:opacity-0 data-starting-style:[transform:translateY(-150%)]","[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(-150%)]","data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]","data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]","data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]","data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]","data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]","data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]","data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]","data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",t),...a})}function ep(e){let{className:t,...a}=e;return(0,n.jsx)(G.p,{"data-slot":"toast-content",className:(0,l.cn)("flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100",t),...a})}function eh(e){let{className:t,...a}=e;return(0,n.jsx)(X.S,{"data-slot":"toast-title",className:(0,l.cn)("text-sm font-medium",t),...a})}function ex(e){let{className:t,...a}=e;return(0,n.jsx)(Z.a,{"data-slot":"toast-description",className:(0,l.cn)("text-sm text-muted-foreground",t),...a})}function ef(e){let{className:t,render:a=(0,n.jsx)(f,{variant:"outline",size:"sm"}),...r}=e;return(0,n.jsx)(ee.Q,{"data-slot":"toast-action",render:a,className:(0,l.cn)("shrink-0",t),...r})}function eg(e){let{className:t,children:a,render:r=(0,n.jsx)(f,{variant:"ghost",size:"icon-sm"}),...i}=e;return(0,n.jsx)(et.e,{"data-slot":"toast-close","aria-label":"Close toast",render:r,className:(0,l.cn)("relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground",t),...i,children:a??(0,n.jsx)(g.n,{icon:en.A,strokeWidth:2,"aria-hidden":"true"})})}function ev(e){let{type:t}=e,a=null;return("success"===t&&(a=(0,n.jsx)(g.n,{icon:er.A,strokeWidth:2,"aria-hidden":"true"})),"info"===t&&(a=(0,n.jsx)(g.n,{icon:ei.A,strokeWidth:2,"aria-hidden":"true"})),"warning"===t&&(a=(0,n.jsx)(g.n,{icon:es.A,strokeWidth:2,"aria-hidden":"true"})),"error"===t&&(a=(0,n.jsx)(g.n,{icon:eo.A,strokeWidth:2,className:"text-destructive","aria-hidden":"true"})),"loading"===t&&(a=(0,n.jsx)(g.n,{icon:v.A,strokeWidth:2,className:"animate-spin","aria-hidden":"true"})),a)?(0,n.jsx)("span",{"data-slot":"toast-icon",className:"shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",children:a}):null}function eb(){let{toasts:e}=ea.I();return e.map(e=>(0,n.jsx)(em,{toast:e,children:(0,n.jsxs)(ep,{children:[(0,n.jsx)(ev,{type:e.type}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,n.jsx)(eh,{}),(0,n.jsx)(ex,{})]}),(0,n.jsx)(ef,{}),(0,n.jsx)(eg,{})]})},e.id))}function ej(e){let{children:t,toastManager:a=ed,...r}=e;return(0,n.jsxs)(el,{toastManager:a,...r,children:[t,(0,n.jsx)(ec,{children:(0,n.jsx)(eu,{children:(0,n.jsx)(eb,{})})})]})}B.V,ea.I;var ey=a(4709),ew=a(8189),eN=a(1204),ek=a(9512),eC=a(8337);function eP(e){let{className:t,type:a,...r}=e;return(0,n.jsx)(eC.p,{type:a,"data-slot":"input",className:(0,l.cn)("h-7 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs/relaxed file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...r})}var eS=a(8695);function eE(e){let{className:t,orientation:a="horizontal",...r}=e;return(0,n.jsx)(eS.w,{"data-slot":"separator",orientation:a,className:(0,l.cn)("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",t),...r})}var ez=a(1372),e_=a(3708),eA=a(3596),eT=a(6695),eO=a(6746),eF=a(5470),eM=a(94);function eL(e){let{...t}=e;return(0,n.jsx)(ez.D,{"data-slot":"sheet",...t})}function eD(e){let{...t}=e;return(0,n.jsx)(e_.Z,{"data-slot":"sheet-portal",...t})}function eI(e){let{className:t,...a}=e;return(0,n.jsx)(eA.X,{"data-slot":"sheet-overlay",className:(0,l.cn)("fixed inset-0 z-50 bg-black/80 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",t),...a})}function eR(e){let{className:t,children:a,side:r="right",showCloseButton:i=!0,...s}=e;return(0,n.jsxs)(eD,{children:[(0,n.jsx)(eI,{}),(0,n.jsxs)(eT.h,{"data-slot":"sheet-content","data-side":r,className:(0,l.cn)("fixed z-50 flex flex-col bg-popover bg-clip-padding text-xs/relaxed text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:data-starting-style:translate-y-10 data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:-translate-x-10 rtl:data-[side=left]:data-ending-style:translate-x-10 data-[side=left]:data-starting-style:-translate-x-10 rtl:data-[side=left]:data-starting-style:translate-x-10 data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-10 rtl:data-[side=right]:data-ending-style:-translate-x-10 data-[side=right]:data-starting-style:translate-x-10 rtl:data-[side=right]:data-starting-style:-translate-x-10 data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:-translate-y-10 data-[side=top]:data-starting-style:-translate-y-10 data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",t),...s,children:[a,i&&(0,n.jsxs)(eO.H,{"data-slot":"sheet-close",render:(0,n.jsx)(f,{variant:"ghost",className:"absolute inset-e-4 top-4",size:"icon-sm"}),children:[(0,n.jsx)(g.n,{icon:en.A,strokeWidth:2}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function eU(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"sheet-header",className:(0,l.cn)("flex flex-col gap-1.5 p-6",t),...a})}function e$(e){let{className:t,...a}=e;return(0,n.jsx)(eF.L,{"data-slot":"sheet-title",className:(0,l.cn)("font-heading text-sm font-medium text-foreground",t),...a})}function eW(e){let{className:t,...a}=e;return(0,n.jsx)(eM.r,{"data-slot":"sheet-description",className:(0,l.cn)("text-xs/relaxed text-muted-foreground",t),...a})}function eK(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"skeleton",className:(0,l.cn)("animate-pulse rounded-md bg-muted",t),...a})}var eq=a(8472);let eH=r.createContext(null);function eB(){let e=r.useContext(eH);if(!e)throw Error("useSidebar must be used within a SidebarProvider.");return e}function eV(e){let{defaultOpen:t=!0,open:a,onOpenChange:i,className:s,style:o,children:d,...c}=e,u=function(){let[e,t]=r.useState(()=>matchMedia("(max-width: 767px)").matches);return r.useEffect(()=>{let e=matchMedia("(max-width: 767px)"),a=()=>{t(e.matches)};return e.addEventListener("change",a),()=>e.removeEventListener("change",a)},[]),e}(),[m,p]=r.useState(!1),[h,x]=r.useState(t),f=a??h,g=r.useCallback(e=>{let t="function"==typeof e?e(f):e;i?i(t):x(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[i,f]),v=r.useCallback(()=>u?p(e=>!e):g(e=>!e),[u,g,p]);r.useEffect(()=>{let e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v]);let b=f?"expanded":"collapsed",j=r.useMemo(()=>({state:b,open:f,setOpen:g,isMobile:u,openMobile:m,setOpenMobile:p,toggleSidebar:v}),[b,f,g,u,m,p,v]);return(0,n.jsx)(eH.Provider,{value:j,children:(0,n.jsx)("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"13rem","--sidebar-width-icon":"3rem",...o},className:(0,l.cn)("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",s),...c,children:d})})}function eJ(e){let{side:t="left",variant:a="sidebar",collapsible:r="offcanvas",className:i,children:s,dir:o,...d}=e,{isMobile:c,state:u,openMobile:m,setOpenMobile:p}=eB();return"none"===r?(0,n.jsx)("div",{"data-slot":"sidebar",className:(0,l.cn)("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",i),...d,children:s}):c?(0,n.jsx)(eL,{open:m,onOpenChange:p,...d,children:(0,n.jsxs)(eR,{dir:o,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":"16rem"},side:t,children:[(0,n.jsxs)(eU,{className:"sr-only",children:[(0,n.jsx)(e$,{children:"Sidebar"}),(0,n.jsx)(eW,{children:"Displays the mobile sidebar."})]}),(0,n.jsx)("div",{className:"flex size-full flex-col",children:s})]})}):(0,n.jsxs)("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":u,"data-collapsible":"collapsed"===u?r:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[(0,n.jsx)("div",{"data-slot":"sidebar-gap",className:(0,l.cn)("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),(0,n.jsx)("div",{"data-slot":"sidebar-container","data-side":t,className:(0,l.cn)("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:-left-(--sidebar-width) data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:-right-(--sidebar-width) md:flex","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-e group-data-[side=right]:border-s",i),...d,children:(0,n.jsx)("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:s})})]})}function eQ(e){let{className:t,onClick:a,...r}=e,{toggleSidebar:i}=eB();return(0,n.jsxs)(f,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:(0,l.cn)(t),onClick:e=>{a?.(e),i()},...r,children:[(0,n.jsx)(g.n,{icon:eq.A,strokeWidth:2,className:"rtl:rotate-180"}),(0,n.jsx)("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function eY(e){let{className:t,...a}=e;return(0,n.jsx)("main",{"data-slot":"sidebar-inset",className:(0,l.cn)("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2",t),...a})}function eG(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:(0,l.cn)("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a})}function eX(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:(0,l.cn)("relative flex w-full min-w-0 flex-col px-2 py-1",t),...a})}function eZ(e){let{className:t,render:a,...n}=e;return(0,ek.C)({defaultTagName:"div",props:(0,eN.v6)({className:(0,l.cn)("flex h-8 shrink-0 items-center rounded-md px-2 text-xs text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",t)},n),render:a,state:{slot:"sidebar-group-label",sidebar:"group-label"}})}function e0(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:(0,l.cn)("w-full text-xs",t),...a})}function e1(e){let{className:t,...a}=e;return(0,n.jsx)("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:(0,l.cn)("flex w-full min-w-0 flex-col gap-px",t),...a})}function e2(e){let{className:t,...a}=e;return(0,n.jsx)("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:(0,l.cn)("group/menu-item relative",t),...a})}let e5=(0,d.F)("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-[calc(var(--radius-sm)+2px)] p-2 text-start text-xs ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pe-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-xs",sm:"h-7 text-xs",lg:"h-12 text-xs group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function e4(e){let{render:t,isActive:a=!1,variant:r="default",size:i="default",tooltip:s,className:o,...d}=e,{isMobile:c,state:u}=eB(),m=(0,ek.C)({defaultTagName:"button",props:(0,eN.v6)({className:(0,l.cn)(e5({variant:r,size:i}),o)},d),render:s?(0,n.jsx)(R,{render:t}):t,state:{slot:"sidebar-menu-button",sidebar:"menu-button",size:i,active:a}});return s?("string"==typeof s&&(s={children:s}),(0,n.jsxs)(I,{children:[m,(0,n.jsx)(U,{side:"right",align:"center",hidden:"collapsed"!==u||c,...s})]})):m}var e3=a(9611),e6=a(1274),e8=a(3106),e7=a(9828),e9=a(6016),te=a(2443);let tt=[{title:null,items:[{title:"Dashboard",href:"/dashboard",icon:e3.A}]},{title:"Capabilities",items:[{title:"Skills",href:"/skills",icon:e6.A},{title:"MCPs",href:"/mcps",icon:e8.A},{title:"Prompts",href:"/prompts",icon:e7.A,description:"Reusable text fragments for agent conversations."}]},{title:"Execution",items:[{title:"Runtimes",href:"/runtimes",icon:e9.A,description:"Detection status and Provider assignments for each Runtime."},{title:"Providers",href:"/providers",icon:te.A,description:"Saved model-service connections for each Runtime."}]}];function ta(e){for(let t of tt)for(let a of t.items)if(a.href===e||e.startsWith(`${a.href}/`))return a}function tn(){let e=(0,ew.zy)(),{isMobile:t,setOpenMobile:a}=eB(),r=()=>{t&&a(!1)};return(0,n.jsx)(eJ,{collapsible:"icon","data-testid":"app-sidebar",children:(0,n.jsx)(eG,{children:tt.map(t=>(0,n.jsxs)(eX,{children:[t.title&&(0,n.jsx)(eZ,{children:t.title}),(0,n.jsx)(e0,{children:(0,n.jsx)(e1,{children:t.items.map(t=>(0,n.jsx)(e2,{children:(0,n.jsxs)(e4,{isActive:e.pathname===t.href||e.pathname.startsWith(`${t.href}/`),tooltip:t.title,render:(0,n.jsx)(K.k2,{to:t.href,onClick:r}),children:[(0,n.jsx)(g.n,{icon:t.icon,strokeWidth:2}),(0,n.jsx)("span",{children:t.title})]})},t.href))})})]},t.title??"overview"))})})}var tr=a(6442);function ti(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"empty",className:(0,l.cn)("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",t),...a})}function ts(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"empty-header",className:(0,l.cn)("flex max-w-sm flex-col items-center gap-1",t),...a})}function to(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"empty-title",className:(0,l.cn)("font-heading text-sm font-medium tracking-tight",t),...a})}function td(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"empty-description",className:(0,l.cn)("text-xs/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),...a})}function tl(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"empty-content",className:(0,l.cn)("flex w-full max-w-sm min-w-0 flex-col items-center gap-2 text-xs/relaxed text-balance",t),...a})}function tc(e){let{title:t,description:a,action:r}=e;return(0,n.jsxs)(ti,{children:[(0,n.jsxs)(ts,{children:[(0,n.jsx)(to,{children:t}),(0,n.jsx)(td,{children:a})]}),r?(0,n.jsx)(tl,{children:r}):null]})}var tu=a(5596),tm=a(6989),tp=a(5817),th=a(7414),tx=a(5032),tf=a(1721);function tg(e){let{className:t,size:a="default",...r}=e;return(0,n.jsx)("div",{"data-slot":"card","data-size":a,className:(0,l.cn)("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-lg bg-card py-(--card-spacing) text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg",t),...r})}function tv(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"card-header",className:(0,l.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",t),...a})}function tb(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"card-title",className:(0,l.cn)("font-heading text-sm font-medium",t),...a})}function tj(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"card-description",className:(0,l.cn)("text-xs/relaxed text-muted-foreground",t),...a})}function ty(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"card-action",className:(0,l.cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),...a})}function tw(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"card-content",className:(0,l.cn)("px-(--card-spacing)",t),...a})}function tN(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"card-footer",className:(0,l.cn)("flex items-center rounded-b-lg px-(--card-spacing) [.border-t]:pt-(--card-spacing)",t),...a})}var tk=a(9603),tC=a(1343),tP=a(1374),tS=a(554),tE=a(5921),tz=a(4310),t_=a(9150);function tA(e){let{...t}=e;return(0,n.jsx)(tk.y,{"data-slot":"popover",...t})}function tT(e){let{...t}=e;return(0,n.jsx)(tC.W,{"data-slot":"popover-trigger",...t})}function tO(e){let{className:t,align:a="center",alignOffset:r=0,side:i="bottom",sideOffset:s=4,...o}=e;return(0,n.jsx)(tP.i,{children:(0,n.jsx)(tS.U,{align:a,alignOffset:r,side:i,sideOffset:s,className:"isolate z-50",children:(0,n.jsx)(tE.i,{"data-slot":"popover-content",className:(0,l.cn)("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...o})})})}function tF(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"popover-header",className:(0,l.cn)("flex flex-col gap-1 text-xs",t),...a})}function tM(e){let{className:t,...a}=e;return(0,n.jsx)(tz.e,{"data-slot":"popover-title",className:(0,l.cn)("text-sm font-medium",t),...a})}function tL(e){let{className:t,...a}=e;return(0,n.jsx)(t_.u,{"data-slot":"popover-description",className:(0,l.cn)("text-muted-foreground",t),...a})}function tD(e){return e?["prompts",e]:["prompts"]}function tI(e){return["prompt",e]}async function tR(e,t){if(!e.ok)throw Error(t);return e.json()}async function tU(e){let t=new URLSearchParams({query:e.query});return(await tR(await fetch(`/api/prompts?${t.toString()}`,{cache:"no-store"}),"The Foundry Server could not load Prompts.")).data}async function t$(e){let t=await tR(await fetch(`/api/prompts/${encodeURIComponent(e)}`,{cache:"no-store"}),"The Foundry Server could not load the Prompt.");if("SUCCESS"!==t.status||null===t.data)throw Error(t.message??"The Prompt could not be found.");return t.data}async function tW(e){return(await tR(await fetch("/api/prompts",{body:JSON.stringify(e),headers:{"content-type":"application/json"},method:"POST"}),"The Foundry Server could not create the Prompt.")).data}async function tK(e,t){let a=await tR(await fetch(`/api/prompts/${encodeURIComponent(e)}`,{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"PUT"}),"The Foundry Server could not update the Prompt.");if("SUCCESS"!==a.status||null===a.data)throw Error(a.message??"The Prompt could not be updated.");return a.data}async function tq(e){let t=await tR(await fetch(`/api/prompts/${encodeURIComponent(e)}`,{method:"DELETE"}),"The Foundry Server could not delete the Prompt.");if("SUCCESS"!==t.status||!t.data)throw Error(t.message??"The Prompt could not be deleted.")}function tH(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return(0,j.I)({enabled:t,queryKey:tI(e),queryFn:()=>t$(e),refetchOnWindowFocus:!1,retry:!1})}async function tB(e){try{await navigator.clipboard.writeText(e),ed.add({title:"Prompt copied",type:"success"})}catch{ed.add({title:"Prompt could not be copied",type:"error"})}}var tV=a(8962),tJ=a(7830),tQ=a(2988),tY=a(6091);function tG(e){let{...t}=e;return(0,n.jsx)(tY.V,{"data-slot":"alert-dialog",...t})}function tX(e){let{...t}=e;return(0,n.jsx)(e_.Z,{"data-slot":"alert-dialog-portal",...t})}function tZ(e){let{className:t,...a}=e;return(0,n.jsx)(eA.X,{"data-slot":"alert-dialog-overlay",className:(0,l.cn)("fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",t),...a})}function t0(e){let{className:t,size:a="default",...r}=e;return(0,n.jsxs)(tX,{children:[(0,n.jsx)(tZ,{}),(0,n.jsx)(eT.h,{"data-slot":"alert-dialog-content","data-size":a,className:(0,l.cn)("group/alert-dialog-content fixed top-1/2 start-1/2 z-50 grid w-full -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-3 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...r})]})}function t1(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,l.cn)("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-start sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...a})}function t2(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,l.cn)("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...a})}function t5(e){let{className:t,...a}=e;return(0,n.jsx)(eF.L,{"data-slot":"alert-dialog-title",className:(0,l.cn)("font-heading text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...a})}function t4(e){let{className:t,...a}=e;return(0,n.jsx)(eM.r,{"data-slot":"alert-dialog-description",className:(0,l.cn)("text-xs/relaxed text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),...a})}function t3(e){let{className:t,...a}=e;return(0,n.jsx)(f,{"data-slot":"alert-dialog-action",className:(0,l.cn)(t),...a})}function t6(e){let{className:t,variant:a="outline",size:r="default",...i}=e;return(0,n.jsx)(eO.H,{"data-slot":"alert-dialog-cancel",className:(0,l.cn)(t),render:(0,n.jsx)(f,{variant:a,size:r}),...i})}function t8(e){let{...t}=e;return(0,n.jsx)(ez.D,{"data-slot":"dialog",...t})}function t7(e){let{...t}=e;return(0,n.jsx)(e_.Z,{"data-slot":"dialog-portal",...t})}function t9(e){let{className:t,...a}=e;return(0,n.jsx)(eA.X,{"data-slot":"dialog-overlay",className:(0,l.cn)("fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",t),...a})}function ae(e){let{className:t,children:a,showCloseButton:r=!0,...i}=e;return(0,n.jsxs)(t7,{children:[(0,n.jsx)(t9,{}),(0,n.jsxs)(eT.h,{"data-slot":"dialog-content",className:(0,l.cn)("fixed top-1/2 start-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...i,children:[a,r&&(0,n.jsxs)(eO.H,{"data-slot":"dialog-close",render:(0,n.jsx)(f,{variant:"ghost",className:"absolute top-2 end-2",size:"icon-sm"}),children:[(0,n.jsx)(g.n,{icon:en.A,strokeWidth:2}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function at(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"dialog-header",className:(0,l.cn)("flex flex-col gap-1",t),...a})}function aa(e){let{className:t,showCloseButton:a=!1,children:r,...i}=e;return(0,n.jsxs)("div",{"data-slot":"dialog-footer",className:(0,l.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...i,children:[r,a&&(0,n.jsx)(eO.H,{render:(0,n.jsx)(f,{variant:"outline"}),children:"Close"})]})}function an(e){let{className:t,...a}=e;return(0,n.jsx)(eF.L,{"data-slot":"dialog-title",className:(0,l.cn)("font-heading text-sm font-medium",t),...a})}function ar(e){let{className:t,...a}=e;return(0,n.jsx)(eM.r,{"data-slot":"dialog-description",className:(0,l.cn)("text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),...a})}function ai(e){let{className:t,...a}=e;return(0,n.jsx)("label",{"data-slot":"label",className:(0,l.cn)("flex items-center gap-2 text-xs/relaxed leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...a})}function as(e){let{className:t,...a}=e;return(0,n.jsx)("fieldset",{"data-slot":"field-set",className:(0,l.cn)("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),...a})}function ao(e){let{className:t,variant:a="legend",...r}=e;return(0,n.jsx)("legend",{"data-slot":"field-legend","data-variant":a,className:(0,l.cn)("mb-2 font-medium data-[variant=label]:text-xs/relaxed data-[variant=legend]:text-sm",t),...r})}function ad(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"field-group",className:(0,l.cn)("group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),...a})}let al=(0,d.F)("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function ac(e){let{className:t,orientation:a="vertical",...r}=e;return(0,n.jsx)("div",{role:"group","data-slot":"field","data-orientation":a,className:(0,l.cn)(al({orientation:a}),t),...r})}function au(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"field-content",className:(0,l.cn)("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),...a})}function am(e){let{children:t,className:a,required:r=!1,...i}=e;return(0,n.jsx)(ai,{"data-slot":"field-label",className:(0,l.cn)("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-input/40 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-2 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/30 *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",r&&"after:text-destructive after:content-['*']",a),...i,children:t})}function ap(e){let{className:t,...a}=e;return(0,n.jsx)("p",{"data-slot":"field-description",className:(0,l.cn)("text-start text-xs/relaxed leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),...a})}function ah(e){let{children:t,className:a,...r}=e;return(0,n.jsxs)("div",{"data-slot":"field-separator","data-content":!!t,className:(0,l.cn)("relative -my-2 h-5 text-xs/relaxed group-data-[variant=outline]/field-group:-mb-2",a),...r,children:[(0,n.jsx)(eE,{className:"absolute inset-0 top-1/2"}),t&&(0,n.jsx)("span",{className:"relative mx-auto block w-fit bg-background px-2 text-muted-foreground","data-slot":"field-separator-content",children:t})]})}function ax(e){let{className:t,children:a,errors:i,...s}=e,o=(0,r.useMemo)(()=>{if(a)return a;if(!i?.length)return null;let e=[...new Map(i.map(e=>[e?.message,e])).values()];return e?.length==1?e[0]?.message:(0,n.jsx)("ul",{className:"ms-4 flex list-disc flex-col gap-1",children:e.map((e,t)=>e?.message&&(0,n.jsx)("li",{children:e.message},t))})},[a,i]);return o?(0,n.jsx)("div",{role:"alert","data-slot":"field-error",className:(0,l.cn)("text-xs/relaxed font-normal text-destructive",t),...s,children:o}):null}function af(e){let{className:t,...a}=e;return(0,n.jsx)("textarea",{"data-slot":"textarea",className:(0,l.cn)("flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-input/20 px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...a})}let ag={content:"",description:"",title:""},av=[(0,tV.wD)({base:tV.Sz}),tJ.Lz.contentAttributes.of({"aria-label":"Prompt content"})];function ab(e){return{content:e.content,description:e.description??"",title:e.title}}function aj(e){return JSON.stringify(e)}function ay(e){let t,a,{initialPrompt:i,onRequestCloseChange:o,onClose:d}=e,l=i?.id??"",{resolvedTheme:c}=_(),h=(t=(0,s.jE)(),(0,y.n)({mutationFn:tW,onSuccess:async()=>{await t.invalidateQueries({queryKey:tD()})}})),x=(a=(0,s.jE)(),(0,y.n)({mutationFn:e=>tK(l,e),onSuccess:async()=>{await Promise.all([a.invalidateQueries({queryKey:tD()}),a.invalidateQueries({queryKey:tI(l)})])}})),[v,j]=(0,r.useState)(()=>i?ab(i):ag),[w]=(0,r.useState)(()=>aj(i?ab(i):ag)),[N,k]=(0,r.useState)(null),[C,P]=(0,r.useState)(!1),S=(0,r.useRef)(!1),E=void 0!==i,z=aj(v)!==w,A=h.isPending||x.isPending,T=(0,ew.KP)(()=>z&&!S.current);(0,r.useEffect)(()=>{let e=e=>{z&&!S.current&&e.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[z]);let O=(0,r.useCallback)(()=>{if(!A){if(z)return void P(!0);d()}},[z,A,d]);function F(){P(!1),"blocked"===T.state&&T.reset()}return(0,r.useEffect)(()=>(o(O),()=>o(d)),[d,o,O]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("form",{className:"flex h-[min(48rem,calc(100svh-2rem))] min-h-0 flex-col",onSubmit:function(e){e.preventDefault();let t=""===v.title.trim()?"Title is required.":v.title.trim().length>100?"Title must be no longer than 100 characters.":v.description.trim().length>2e3?"Description must be no longer than 2,000 characters.":""===v.content.trim()?"Content is required.":new TextEncoder().encode(v.content).byteLength>1048576?"Content must be no larger than 1 MiB.":null;if(t)return void k(t);let a={content:v.content,description:v.description.trim()||null,title:v.title.trim()};(E?x:h).mutate(a,{onError:e=>k(e.message),onSuccess:()=>{S.current=!0,ed.add({title:E?"Prompt saved":"Prompt created",type:"success"}),d()}})},children:[E?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(an,{className:"sr-only",children:"Edit Prompt"}),(0,n.jsx)(ar,{className:"sr-only",children:"View or update this saved fragment."})]}):(0,n.jsxs)(at,{className:"shrink-0 border-b px-6 py-5 pe-14",children:[(0,n.jsx)(an,{className:"text-base font-semibold",children:"New Prompt"}),(0,n.jsx)(ar,{children:"Save a reusable text fragment."})]}),(0,n.jsx)(f,{"aria-label":"Close Prompt editor",className:"absolute top-3 inset-e-3",disabled:A,size:"icon-sm",type:"button",variant:"ghost",onClick:O,children:(0,n.jsx)(g.n,{icon:en.A,strokeWidth:2})}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-6 py-5",children:[N&&(0,n.jsxs)(u,{className:"mb-4",variant:"destructive",children:[(0,n.jsx)(m,{children:"Prompt could not be saved"}),(0,n.jsx)(p,{children:N})]}),(0,n.jsxs)(ad,{className:"min-h-0 flex-1 gap-4",children:[(0,n.jsxs)(ac,{"data-invalid":v.title.trim().length>100||void 0,children:[(0,n.jsx)(am,{htmlFor:"prompt-title",required:!0,children:"Title"}),(0,n.jsx)(eP,{id:"prompt-title",maxLength:100,value:v.title,onChange:e=>j(t=>({...t,title:e.target.value}))})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"prompt-description",children:"Description"}),(0,n.jsx)(af,{className:"min-h-16 resize-none",id:"prompt-description",maxLength:2e3,value:v.description,onChange:e=>j(t=>({...t,description:e.target.value}))})]}),(0,n.jsxs)(ac,{className:"min-h-64 flex-1",children:[(0,n.jsx)(am,{required:!0,children:"Content"}),(0,n.jsx)("div",{className:"min-h-64 flex-1 overflow-hidden rounded-md border",children:(0,n.jsx)(tJ.Ay,{basicSetup:{bracketMatching:!0,closeBrackets:!0,foldGutter:!0,highlightActiveLine:!0,lineNumbers:!0},className:"h-full",extensions:av,height:"100%",theme:c,value:v.content,onChange:e=>j(t=>({...t,content:e}))})})]})]})]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-t px-6 py-3",children:[E&&(0,n.jsxs)(f,{type:"button",variant:"outline",onClick:()=>void tB(v.content),children:[(0,n.jsx)(g.n,{icon:tp.A,strokeWidth:2,"data-icon":"inline-start"}),"Copy"]}),(0,n.jsx)("span",{className:"flex-1"}),(0,n.jsx)(f,{disabled:A,type:"button",variant:"outline",onClick:O,children:"Cancel"}),(0,n.jsxs)(f,{disabled:A,type:"submit",children:[A?(0,n.jsx)(b,{"data-icon":"inline-start"}):(0,n.jsx)(g.n,{icon:tQ.A,strokeWidth:2,"data-icon":"inline-start"}),(0,n.jsx)("span",{children:"Save"})]})]})]}),(0,n.jsx)(tG,{open:C||"blocked"===T.state,onOpenChange:e=>{e||F()},children:(0,n.jsxs)(t0,{children:[(0,n.jsxs)(t1,{children:[(0,n.jsx)(t5,{children:"Discard unsaved changes?"}),(0,n.jsx)(t4,{children:"Changes made in this Prompt have not been saved."})]}),(0,n.jsxs)(t2,{children:[(0,n.jsx)(t6,{onClick:F,children:"Keep editing"}),(0,n.jsx)(t3,{variant:"destructive",onClick:function(){(P(!1),S.current=!0,"blocked"===T.state)?T.proceed():d()},children:"Discard"})]})]})})]})}function aw(e){let{promptId:t,onClose:a}=e,i=tH(t??"",null!==t),s=(0,r.useRef)(a),o=(0,r.useCallback)(e=>{s.current=e},[]);return(0,n.jsx)(t8,{open:!0,onOpenChange:e=>{e||s.current()},children:(0,n.jsxs)(ae,{className:"max-h-[calc(100svh-2rem)] overflow-hidden p-0 sm:max-w-4xl",showCloseButton:!1,children:[null===t&&(0,n.jsx)(ay,{onRequestCloseChange:o,onClose:a}),null!==t&&i.isPending&&(0,n.jsxs)("div",{className:"flex h-[min(48rem,calc(100svh-2rem))] min-h-0 flex-col",children:[(0,n.jsx)(an,{className:"sr-only",children:"Edit Prompt"}),(0,n.jsx)(ar,{className:"sr-only",children:"Loading the saved fragment."}),(0,n.jsx)(f,{"aria-label":"Close Prompt editor",className:"absolute top-3 inset-e-3",size:"icon-sm",type:"button",variant:"ghost",onClick:a,children:(0,n.jsx)(g.n,{icon:en.A,strokeWidth:2})}),(0,n.jsxs)("div",{"aria-label":"Loading Prompt",className:"flex min-h-0 flex-1 flex-col gap-4 overflow-hidden px-6 py-5",role:"status",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(eK,{className:"h-4 w-12"}),(0,n.jsx)(eK,{className:"h-7 w-full"})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(eK,{className:"h-4 w-20"}),(0,n.jsx)(eK,{className:"h-16 w-full"})]}),(0,n.jsxs)("div",{className:"flex min-h-64 flex-1 flex-col gap-2",children:[(0,n.jsx)(eK,{className:"h-4 w-14"}),(0,n.jsx)(eK,{className:"min-h-64 flex-1 w-full"})]})]}),(0,n.jsxs)("div",{className:"flex shrink-0 justify-end gap-2 border-t px-6 py-3",children:[(0,n.jsx)(eK,{className:"h-7 w-16"}),(0,n.jsx)(eK,{className:"h-7 w-16"})]})]}),null!==t&&i.isError&&(0,n.jsxs)("div",{className:"flex min-h-48 flex-col p-6",children:[(0,n.jsxs)(at,{children:[(0,n.jsx)(an,{children:"Prompt could not be loaded"}),(0,n.jsx)(ar,{children:i.error.message})]}),(0,n.jsx)("div",{className:"mt-auto flex justify-end",children:(0,n.jsx)(f,{type:"button",variant:"outline",onClick:a,children:"Close"})})]}),null!==t&&i.data&&(0,n.jsx)(ay,{initialPrompt:i.data,onRequestCloseChange:o,onClose:a},i.data.id)]})})}function aN(e){var t;let a,{prompt:i,onOpen:o}=e,d=i.description?`${i.title} \xb7 ${i.description}`:i.title,l=(0,r.useRef)(null),[c,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),v=tH(i.id,!1),j=(t=i.id,a=(0,s.jE)(),(0,y.n)({mutationFn:()=>tq(t),onSuccess:async()=>{a.removeQueries({queryKey:tI(t)}),await a.invalidateQueries({queryKey:tD()})}}));async function w(){x(!0);try{let e=await v.refetch();if(!e.data)return void ed.add({title:"Prompt could not be copied",type:"error"});await tB(e.data.content)}catch{ed.add({title:"Prompt could not be copied",type:"error"})}finally{x(!1)}}return(0,r.useEffect)(()=>{let e=l.current;if(!e)return;let t=()=>{u(e.scrollWidth>e.clientWidth)},a=requestAnimationFrame(t),n=new ResizeObserver(t);return n.observe(e),()=>{cancelAnimationFrame(a),n.disconnect()}},[d]),(0,n.jsx)(tg,{"data-testid":`prompt-${i.id}`,size:"sm",children:(0,n.jsxs)(tv,{className:"has-data-[slot=card-action]:grid-cols-[minmax(0,1fr)_auto]",children:[(0,n.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,n.jsxs)(I,{disabled:!c,children:[(0,n.jsx)(R,{render:(0,n.jsx)("span",{ref:l,className:"block w-full min-w-0 truncate font-heading text-sm font-medium leading-5","data-testid":`prompt-title-${i.id}`}),children:d}),(0,n.jsx)(U,{className:"max-w-lg wrap-break-word text-start",children:d})]}),(0,n.jsx)(tj,{className:"w-full truncate font-mono leading-5","data-testid":`prompt-content-${i.id}`,children:i.excerpt})]}),(0,n.jsxs)(ty,{className:"flex items-center gap-1 self-center",children:[(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(f,{"aria-label":`View ${i.title}`,size:"icon",type:"button",variant:"ghost",onClick:o}),children:(0,n.jsx)(g.n,{icon:tu.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"View"})]}),(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(f,{"aria-label":`Edit ${i.title}`,size:"icon",type:"button",variant:"ghost",onClick:o}),children:(0,n.jsx)(g.n,{icon:tm.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"Edit"})]}),(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(f,{"aria-label":`Copy ${i.title}`,disabled:h,size:"icon",type:"button",variant:"ghost",onClick:()=>void w()}),children:h?(0,n.jsx)(b,{}):(0,n.jsx)(g.n,{icon:tp.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"Copy"})]}),(0,n.jsxs)(tA,{open:m,onOpenChange:p,children:[(0,n.jsx)(tT,{render:(0,n.jsx)(f,{"aria-label":`Delete ${i.title}`,size:"icon",type:"button",variant:"destructive"}),children:(0,n.jsx)(g.n,{icon:th.A,strokeWidth:2})}),(0,n.jsxs)(tO,{align:"end",children:[(0,n.jsxs)(tF,{children:[(0,n.jsx)(tM,{children:"Delete Prompt?"}),(0,n.jsx)(tL,{children:"This Prompt will be removed from Foundry. This action cannot be undone in the app."})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(f,{disabled:j.isPending,type:"button",variant:"outline",onClick:()=>p(!1),children:"Cancel"}),(0,n.jsxs)(f,{disabled:j.isPending,type:"button",variant:"destructive",onClick:()=>j.mutate(void 0,{onError:()=>{ed.add({title:"Prompt could not be deleted",type:"error"})},onSuccess:()=>{p(!1),ed.add({title:"Prompt deleted",type:"success"})}}),children:[j.isPending&&(0,n.jsx)(b,{"data-icon":"inline-start"}),(0,n.jsx)("span",{children:"Delete"})]})]})]})]})]})]})})}let ak=["system","light","dark"],aC=["settings","providers","prompts"],aP=["codex","claude-code"],aS={"claude-code":"Claude Code",codex:"Codex"},aE={"claude-code":["env.ANTHROPIC_BASE_URL","env.ANTHROPIC_AUTH_TOKEN","env.ANTHROPIC_API_KEY","env.ANTHROPIC_MODEL","env.ANTHROPIC_DEFAULT_OPUS_MODEL","env.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME","env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION","env.ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES","env.ANTHROPIC_DEFAULT_SONNET_MODEL","env.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME","env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION","env.ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES","env.ANTHROPIC_DEFAULT_HAIKU_MODEL","env.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME","env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION","env.ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES","env.ANTHROPIC_DEFAULT_FABLE_MODEL","env.ANTHROPIC_DEFAULT_FABLE_MODEL_NAME","env.ANTHROPIC_DEFAULT_FABLE_MODEL_DESCRIPTION","env.ANTHROPIC_DEFAULT_FABLE_MODEL_SUPPORTED_CAPABILITIES","env.CLAUDE_CODE_SUBAGENT_MODEL","env.CLAUDE_CODE_SUBAGENT_MODEL_FORCE","env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS","env.ENABLE_TOOL_SEARCH","env.CLAUDE_CODE_EFFORT_LEVEL","env.DISABLE_AUTOUPDATER","attribution.commit","attribution.pr","attribution.sessionUrl"],codex:["model","review_model","model_provider","[model_providers.<key>].name","[model_providers.<key>].base_url","[model_providers.<key>].wire_api","[model_providers.<key>].experimental_bearer_token"]},az=["image/png","image/jpeg","image/webp","image/svg+xml"],a_=["effort","xhigh_effort","max_effort","thinking","adaptive_thinking","interleaved_thinking"];var aA=a(1993),aT=a(7904),aO=a(8893),aF=a(2874);function aM(e){let{...t}=e;return(0,n.jsx)(aT.N,{"data-slot":"collapsible",...t})}function aL(e){let{...t}=e;return(0,n.jsx)(aO.R,{"data-slot":"collapsible-trigger",...t})}function aD(e){let{...t}=e;return(0,n.jsx)(aF.j,{"data-slot":"collapsible-content",...t})}function aI(e){let{children:t,label:a,summary:r}=e;return(0,n.jsxs)(aM,{children:[(0,n.jsxs)(aL,{className:"group flex w-fit items-center gap-1 rounded-sm py-1 text-xs/relaxed font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50",children:[(0,n.jsx)(g.n,{className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none","data-slot":"collapsible-section-icon",icon:aA.A,strokeWidth:2}),(0,n.jsx)("span",{children:a}),void 0!==r&&(0,n.jsx)("span",{className:"tabular-nums text-muted-foreground/80",children:r})]}),(0,n.jsx)(aD,{className:"h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-150 motion-reduce:transition-none data-ending-style:h-0 data-starting-style:h-0","data-slot":"collapsible-section-content",children:(0,n.jsx)("div",{className:"ms-3 min-w-0 border-s border-border py-2 ps-4","data-slot":"collapsible-section-body",children:t})})]})}var aR=a(3384),aU=a(2529),a$=a(7908);function aW(e){let{className:t,size:a="default",...r}=e;return(0,n.jsx)(aR.C,{"data-slot":"avatar","data-size":a,className:(0,l.cn)("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",t),...r})}function aK(e){let{className:t,...a}=e;return(0,n.jsx)(aU.B,{"data-slot":"avatar-image",className:(0,l.cn)("aspect-square size-full rounded-full object-cover",t),...a})}function aq(e){let{className:t,...a}=e;return(0,n.jsx)(a$.q,{"data-slot":"avatar-fallback",className:(0,l.cn)("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",t),...a})}function aH(e){let{alt:t="",avatar:a,className:r,name:i,size:s}=e;return(0,n.jsxs)(aW,{className:r,size:s,children:[a&&(0,n.jsx)(aK,{alt:t,src:`data:${a.mimeType};base64,${a.data}`}),(0,n.jsx)(aq,{children:i.trim().charAt(0)||"P"})]})}let aB={"claude-code":a(3367),codex:a(2351)};function aV(e){let{runtime:t,size:a=16}=e;return(0,n.jsx)("img",{alt:"","aria-hidden":"true","data-icon":"inline-start","data-runtime-icon":t,height:a,src:aB[t],width:a})}function aJ(e){let{runtime:t}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(aV,{runtime:t}),aS[t]]})}var aQ=a(324);function aY(e){let{className:t,...a}=e;return(0,n.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,l.cn)("group/input-group relative flex h-7 w-full min-w-0 items-center rounded-md border border-input bg-input/20 transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-data-[align=block-end]:rounded-md has-data-[align=block-start]:rounded-md has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/30 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-2 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[textarea]:rounded-md has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",t),...a})}let aG=(0,d.F)("flex h-auto cursor-text items-center justify-center gap-1 py-2 text-xs/relaxed font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 **:data-[slot=kbd]:rounded-[calc(var(--radius-sm)-2px)] **:data-[slot=kbd]:bg-muted-foreground/10 **:data-[slot=kbd]:px-1 **:data-[slot=kbd]:text-[0.625rem] [&>svg:not([class*='size-'])]:size-3.5",{variants:{align:{"inline-start":"order-first ps-2 has-[>button]:ms-[-0.275rem] has-[>kbd]:ms-[-0.275rem]","inline-end":"order-last pe-2 has-[>button]:me-[-0.275rem] has-[>kbd]:me-[-0.275rem]","block-start":"order-first w-full justify-start px-2 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function aX(e){let{className:t,align:a="inline-start",...r}=e;return(0,n.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":a,className:(0,l.cn)(aG({align:a}),t),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...r})}let aZ=(0,d.F)("flex items-center gap-2 rounded-md text-xs/relaxed shadow-none",{variants:{size:{xs:"h-5 gap-1 rounded-[calc(var(--radius-sm)-2px)] px-1 [&>svg:not([class*='size-'])]:size-3",sm:"gap-1","icon-xs":"size-6 p-0 has-[>svg]:p-0","icon-sm":"size-7 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function a0(e){let{className:t,type:a="button",variant:r="ghost",size:i="xs",...s}=e;return(0,n.jsx)(f,{type:a,"data-size":i,variant:r,className:(0,l.cn)(aZ({size:i}),t),...s})}function a1(e){let{className:t,...a}=e;return(0,n.jsx)(eP,{"data-slot":"input-group-control",className:(0,l.cn)("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",t),...a})}function a2(e){let{value:t,...a}=e,[i,s]=(0,r.useState)(!1);return(0,n.jsxs)(aY,{children:[(0,n.jsx)(a1,{...a,type:i?"text":"password",value:t}),(0,n.jsx)(aX,{align:"inline-end",children:(0,n.jsx)(a0,{"aria-label":i?"Hide API Key":"Show API Key",size:"icon-xs",onClick:()=>s(e=>!e),children:(0,n.jsx)(g.n,{icon:i?aQ.A:tu.A,strokeWidth:2})})})]})}var a5=a(8978),a4=a(7612),a3=a(8716);function a6(e){let{className:t,...a}=e;return(0,n.jsx)(a5.y,{"data-slot":"checkbox",className:(0,l.cn)("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",t),...a,children:(0,n.jsx)(a4.P,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:(0,n.jsx)(g.n,{icon:a3.A,strokeWidth:2})})})}var a8=a(6549),a7=a(3574),a9=a(614),ne=a(2120),nt=a(7914),na=a(860),nn=a(7004),nr=a(8402),ni=a(5696),ns=a(4334),no=a(7631),nd=a(9025),nl=a(850),nc=a(6960),nu=a(5174),nm=a(5514),np=a(6539);let nh=a8.H;function nx(e){let{className:t,...a}=e;return(0,n.jsx)(a7.s,{"data-slot":"select-group",className:(0,l.cn)("scroll-my-1 p-1",t),...a})}function nf(e){let{className:t,...a}=e;return(0,n.jsx)(a9.y,{"data-slot":"select-value",className:(0,l.cn)("flex flex-1 text-start",t),...a})}function ng(e){let{className:t,size:a="default",children:r,...i}=e;return(0,n.jsxs)(ne.b,{"data-slot":"select-trigger","data-size":a,className:(0,l.cn)("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-input/20 px-2 py-1.5 text-xs/relaxed whitespace-nowrap transition-colors outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-7 data-[size=sm]:h-6 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",t),...i,children:[r,(0,n.jsx)(nt.w,{render:(0,n.jsx)(g.n,{icon:nu.A,strokeWidth:2,className:"pointer-events-none size-3.5 text-muted-foreground"})})]})}function nv(e){let{className:t,children:a,side:r="bottom",sideOffset:i=4,align:s="center",alignOffset:o=0,alignItemWithTrigger:d=!0,...c}=e;return(0,n.jsx)(na.V,{children:(0,n.jsx)(nn.l,{side:r,sideOffset:i,align:s,alignOffset:o,alignItemWithTrigger:d,className:"isolate z-50",children:(0,n.jsxs)(nr.t,{"data-slot":"select-content","data-align-trigger":d,className:(0,l.cn)("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...c,children:[(0,n.jsx)(nj,{}),(0,n.jsx)(ni.B,{children:a}),(0,n.jsx)(ny,{})]})})})}function nb(e){let{className:t,children:a,...r}=e;return(0,n.jsxs)(ns.e,{"data-slot":"select-item",className:(0,l.cn)("relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...r,children:[(0,n.jsx)(no.h,{"data-slot":"select-item-text",className:"flex flex-1 shrink-0 items-center gap-2 whitespace-nowrap",children:a}),(0,n.jsx)(nd.h,{render:(0,n.jsx)("span",{className:"pointer-events-none absolute end-2 flex items-center justify-center"}),children:(0,n.jsx)(g.n,{icon:a3.A,strokeWidth:2,className:"pointer-events-none"})})]})}function nj(e){let{className:t,...a}=e;return(0,n.jsx)(nl.w,{"data-slot":"select-scroll-up-button",className:(0,l.cn)("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5",t),...a,children:(0,n.jsx)(g.n,{icon:nm.A,strokeWidth:2})})}function ny(e){let{className:t,...a}=e;return(0,n.jsx)(nc.d,{"data-slot":"select-scroll-down-button",className:(0,l.cn)("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5",t),...a,children:(0,n.jsx)(g.n,{icon:np.A,strokeWidth:2})})}var nw=a(3859),nN=a(712);let nk=(0,d.F)("group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-7 min-w-7 px-2 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5",sm:"h-6 min-w-6 rounded-[min(var(--radius-md),8px)] px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",lg:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2"}},defaultVariants:{variant:"default",size:"default"}}),nC=r.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function nP(e){let{className:t,variant:a,size:r,spacing:i=2,orientation:s="horizontal",children:o,...d}=e;return(0,n.jsx)(nN.O,{"data-slot":"toggle-group","data-variant":a,"data-size":r,"data-spacing":i,"data-orientation":s,style:{"--gap":i},className:(0,l.cn)("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-md data-[size=sm]:rounded-[min(var(--radius-md),8px)] data-vertical:flex-col data-vertical:items-stretch",t),...d,children:(0,n.jsx)(nC.Provider,{value:{variant:a,size:r,spacing:i,orientation:s},children:o})})}function nS(e){let{className:t,children:a,variant:i="default",size:s="default",...o}=e,d=r.useContext(nC);return(0,n.jsx)(nw.l,{"data-slot":"toggle-group-item","data-variant":d.variant||i,"data-size":d.size||s,"data-spacing":d.spacing,className:(0,l.cn)("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pe-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:ps-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-s-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-e-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-s-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-s group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",nk({variant:d.variant||i,size:d.size||s}),t),...o,children:a})}function nE(e){return["providers",e]}function nz(e){return["provider",e]}async function n_(e){if(!e.ok)throw Error("The Foundry Server could not load the Provider.");let t=await e.json();if("SUCCESS"!==t.status||null===t.data)throw Error(t.message??"The Provider could not be found.");return t.data}async function nA(e){if(!e.ok)throw Error("The Foundry Server could not load Providers.");return(await e.json()).data}async function nT(e){return nA(await fetch(`/api/providers?runtime=${encodeURIComponent(e)}`,{cache:"no-store"}))}async function nO(e){return n_(await fetch(`/api/providers/${encodeURIComponent(e)}`,{cache:"no-store"}))}async function nF(e){let t=await fetch("/api/providers",{body:JSON.stringify(e),headers:{"content-type":"application/json"},method:"POST"});if(!t.ok)throw Error("The Foundry Server could not create the Provider.");return(await t.json()).data}async function nM(e,t){let a=await fetch(`/api/providers/${encodeURIComponent(e)}`,{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"PUT"});if(!a.ok)throw Error("The Foundry Server could not update the Provider.");let n=await a.json();if("SUCCESS"!==n.status||null===n.data)throw Error(n.message??"The Provider could not be updated.");return n.data}async function nL(e,t){let a=await fetch(`/api/providers/${encodeURIComponent(e)}/copy`,{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"});if(!a.ok)throw Error("The Foundry Server could not copy the Provider.");let n=await a.json();if("SUCCESS"!==n.status||null===n.data)throw Error(n.message??"The Provider could not be copied.");return n.data}async function nD(e){let t=await fetch(`/api/providers/${encodeURIComponent(e)}`,{method:"DELETE"});if(!t.ok)throw Error("The Foundry Server could not delete the Provider.");let a=await t.json();if("SUCCESS"!==a.status||!a.data)throw Error(a.message??"The Provider could not be deleted.")}async function nI(e){let t=await fetch(`/api/providers/${encodeURIComponent(e)}/test-connection`,{method:"POST"});if(!t.ok)throw Error("The Foundry Server could not test the Provider connection.");let a=await t.json();if("SUCCESS"!==a.status||!a.data)throw Error(a.message??"The Provider connection test failed.")}function nR(e){return(0,j.I)({queryKey:nE(e),queryFn:()=>nT(e),refetchOnWindowFocus:!1,retry:!1})}let nU={adaptive_thinking:"Adaptive thinking",effort:"Effort",interleaved_thinking:"Interleaved thinking",max_effort:"Max effort",thinking:"Thinking",xhigh_effort:"XHigh effort"},n$=[{description:"Remove Claude Code attribution from commits, pull requests, and session links.",key:"hideAiAttribution",label:"Hide AI attribution"},{description:"Enable experimental agent teams for interactive sessions.",key:"teammatesMode",label:"Teammates mode"},{description:"Discover MCP tools on demand. The configured endpoint must support tool references.",key:"enableToolSearch",label:"Enable tool search"},{description:"Force Claude Code sessions to use the maximum available reasoning effort.",key:"maxEffortThinking",label:"Max effort thinking"},{description:"Disable background update checks while keeping manual updates available.",key:"disableAutoUpdater",label:"Disable auto-updater"}];function nW(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{avatar:e?.avatar??null,name:e?`${e.name}${t?" Copy":""}`:"",officialWebsite:e?.officialWebsite??"",remark:e?.remark??""}}function nK(e){return{apiKey:e?.configuration.apiKey??"",baseUrl:e?.configuration.baseUrl??"",defaultModel:e?.configuration.defaultModel??"",reviewModel:e?.configuration.reviewModel??""}}function nq(e){return{description:e?.description??"",displayName:e?.displayName??"",model:e?.model??"",supportedCapabilities:e?.supportedCapabilities??[]}}function nH(e){let t=e?.configuration;return{apiKey:t?.apiKey??"",apiKeyHeader:t?.apiKeyHeader??"authorization",baseUrl:t?.baseUrl??"",fableModel:nq(t?.fableModel),haikuModel:nq(t?.haikuModel),opusModel:nq(t?.opusModel),defaultModel:t?.defaultModel??"",sonnetModel:nq(t?.sonnetModel),subagentModel:t?.subagentModel??"",subagentModelForce:t?.subagentModelForce??!1,hideAiAttribution:t?.hideAiAttribution??!1,teammatesMode:t?.teammatesMode??!1,enableToolSearch:t?.enableToolSearch??!1,maxEffortThinking:t?.maxEffortThinking??!1,disableAutoUpdater:t?.disableAutoUpdater??!1}}function nB(e){return e.trim()||null}function nV(e){let t=e.model.trim();return""===t?null:{description:nB(e.description),displayName:nB(e.displayName),model:t,supportedCapabilities:e.supportedCapabilities}}function nJ(e){let{id:t,label:a,value:r,onChange:i}=e,s=""!==r.model.trim();return(0,n.jsxs)(as,{children:[(0,n.jsx)(ao,{children:a}),(0,n.jsxs)(ad,{children:[(0,n.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:`${t}-model`,children:"Model ID"}),(0,n.jsx)(eP,{id:`${t}-model`,maxLength:200,value:r.model,onChange:e=>i({...r,model:e.target.value})})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:`${t}-display-name`,children:"Display name"}),(0,n.jsx)(eP,{disabled:!s,id:`${t}-display-name`,maxLength:100,value:r.displayName,onChange:e=>i({...r,displayName:e.target.value})})]})]}),(0,n.jsx)(aI,{label:"Advanced model options",children:(0,n.jsxs)(ad,{children:[(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:`${t}-description`,children:"Description"}),(0,n.jsx)(af,{disabled:!s,id:`${t}-description`,maxLength:2e3,value:r.description,onChange:e=>i({...r,description:e.target.value})})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:`${t}-capabilities`,children:"Supported capabilities"}),(0,n.jsxs)(nh,{disabled:!s,id:`${t}-capabilities`,multiple:!0,value:r.supportedCapabilities,onValueChange:e=>i({...r,supportedCapabilities:a_.filter(t=>e.includes(t))}),children:[(0,n.jsx)(ng,{className:"w-full",children:(0,n.jsx)(nf,{children:()=>0===r.supportedCapabilities.length?"Select capabilities":r.supportedCapabilities.map(e=>nU[e]).join(", ")})}),(0,n.jsx)(nv,{align:"start",children:(0,n.jsx)(nx,{children:a_.map(e=>(0,n.jsx)(nb,{value:e,children:nU[e]},e))})})]})]})]})})]})]})}function nQ(e){var t,a;let i,o,d,{mode:l,provider:c}=e,h=(0,ew.zy)(),x=(0,ew.Zp)(),g=(i=(0,s.jE)(),(0,y.n)({mutationFn:nF,onSuccess:e=>{i.setQueryData(nE(e.runtime),t=>[e,...t??[]])}})),v=(t=c?.id??"",o=(0,s.jE)(),(0,y.n)({mutationFn:e=>nL(t,e),onSuccess:e=>{o.setQueryData(nE(e.runtime),t=>t?[e,...t]:[e])}})),j=(a=c?.id??"",d=(0,s.jE)(),(0,y.n)({mutationFn:e=>nM(a,e),onSuccess:e=>{d.removeQueries({exact:!0,queryKey:nz(e.id)}),d.setQueryData(nE(e.runtime),t=>t?.map(t=>t.id===e.id?e:t))}})),w="copy"===l,N="edit"===l,k=c?.runtime==="codex"?c:void 0,C=c?.runtime==="claude-code"?c:void 0,[P,S]=(0,r.useState)(c?.runtime??null),[E,z]=(0,r.useState)(null),[_,A]=(0,r.useState)(()=>nW(c,w)),[T,O]=(0,r.useState)(()=>nK(k)),[F,M]=(0,r.useState)(()=>nH(C)),[L,D]=(0,r.useState)(null),$=(0,r.useRef)(null),W="claude-code"===P&&"authorization"===F.apiKeyHeader?"Auth Token":"API Key",q=""!==F.subagentModel.trim(),H="claude-code"===P,B="string"==typeof h.state?.returnTo?h.state.returnTo:`/providers?runtime=${c?.runtime??"codex"}`,V=JSON.stringify(_)!==JSON.stringify(nW(c,w))||"codex"===P&&JSON.stringify(T)!==JSON.stringify(nK(k))||"claude-code"===P&&JSON.stringify(F)!==JSON.stringify(nH(C)),J=g.isError||v.isError||j.isError,Q=g.isPending||v.isPending||j.isPending,Y="Add Provider",G="Choose the Runtime this Provider can be applied to.",X="Add Provider";N?(Y="Edit Provider",G="A Provider Runtime cannot be changed after creation.",X="Save Changes"):w&&(Y="Create from Provider",G="A copy keeps the source Provider Runtime.",X="Create Provider");let Z=e=>{A(nW()),O(nK()),M(nH()),D(null),g.reset(),v.reset(),j.reset(),S(e),z(null)},ee=async e=>{if(!e){A(e=>({...e,avatar:null})),D(null);return}if(!az.includes(e.type)||e.size>2097152){A(e=>({...e,avatar:null})),D("Choose a PNG, JPEG, WebP, or SVG image no larger than 2 MB.");return}try{let t=await new Promise((t,a)=>{let n=new FileReader;n.addEventListener("error",()=>a(Error("Avatar could not be read."))),n.addEventListener("load",()=>{if("string"!=typeof n.result)return void a(Error("Avatar could not be read."));let r=n.result.indexOf(",");-1===r?a(Error("Avatar could not be read.")):t({data:n.result.slice(r+1),mimeType:e.type})}),n.readAsDataURL(e)});A(e=>({...e,avatar:t})),D(null)}catch{A(e=>({...e,avatar:null})),D("The avatar could not be read.")}};return(0,n.jsxs)("main",{className:"w-full pb-12",children:[(0,n.jsx)("header",{className:"pb-5",children:(0,n.jsx)("h1",{className:"text-xl font-semibold",children:Y})}),(0,n.jsx)("form",{onSubmit:e=>{let t;if(e.preventDefault(),null===P||null!==L)return;if("codex"===P)t={avatar:_.avatar,configuration:{apiKey:T.apiKey||null,baseUrl:T.baseUrl,defaultModel:T.defaultModel,protocol:"responses",reviewModel:nB(T.reviewModel)},name:_.name,officialWebsite:nB(_.officialWebsite),remark:nB(_.remark),runtime:P};else{let e=F.defaultModel.trim();if(""===e)return;t={avatar:_.avatar,configuration:{apiKey:F.apiKey,apiKeyHeader:F.apiKeyHeader,baseUrl:F.baseUrl,fableModel:nV(F.fableModel),haikuModel:nV(F.haikuModel),opusModel:nV(F.opusModel),defaultModel:e,protocol:"messages",sonnetModel:nV(F.sonnetModel),subagentModel:nB(F.subagentModel),subagentModelForce:F.subagentModelForce,hideAiAttribution:F.hideAiAttribution,teammatesMode:F.teammatesMode,enableToolSearch:F.enableToolSearch,maxEffortThinking:F.maxEffortThinking,disableAutoUpdater:F.disableAutoUpdater},name:_.name,officialWebsite:nB(_.officialWebsite),remark:nB(_.remark),runtime:P}}let a=e=>{N?ed.add({title:"Provider updated",type:"success"}):ed.add({title:"Provider created",type:"success"}),x("add"===l?`/providers?runtime=${e.runtime}`:B,{replace:!0})};"add"===l?g.mutate(t,{onSuccess:a}):w?v.mutate(t,{onSuccess:a}):j.mutate(t,{onSuccess:a})},children:(0,n.jsxs)(ad,{children:[(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{required:!0,children:"Runtime"}),(0,n.jsx)(nP,{"aria-label":"Runtime",disabled:"add"!==l,spacing:0,value:P?[P]:[],variant:"outline",onValueChange:e=>{let[t]=e.slice(-1);aP.includes(t)&&(e=>{if("add"===l&&e!==P){if(null!==P&&V)return z(e);Z(e)}})(t)},children:aP.map(e=>(0,n.jsx)(nS,{value:e,children:(0,n.jsx)(aJ,{runtime:e})},e))}),(0,n.jsx)(ap,{children:G})]}),null===P?(0,n.jsxs)(u,{children:[(0,n.jsx)(m,{children:"Choose a Runtime"}),(0,n.jsx)(p,{children:"Provider fields appear after a Runtime is selected."})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ah,{children:"Provider"}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"provider-name",required:!0,children:"Name"}),(0,n.jsx)(eP,{id:"provider-name",maxLength:100,required:!0,value:_.name,onChange:e=>A({..._,name:e.target.value})})]}),(0,n.jsxs)(ac,{"data-invalid":null!==L||void 0,children:[(0,n.jsx)(am,{htmlFor:"provider-avatar",children:"Avatar"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{"aria-label":"Choose provider avatar",className:"size-10 cursor-pointer rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring/30",type:"button",onClick:()=>$.current?.click(),children:(0,n.jsx)(aH,{alt:"Provider avatar preview",avatar:_.avatar,name:_.name,size:"lg"})}),(0,n.jsx)(f,{disabled:null===_.avatar,type:"button",variant:"outline",onClick:()=>{A(e=>({...e,avatar:null})),D(null),$.current&&($.current.value="")},children:"Remove avatar"}),(0,n.jsx)(eP,{accept:az.join(","),"aria-invalid":null!==L||void 0,className:"sr-only size-px",id:"provider-avatar",ref:$,type:"file",onChange:e=>{ee(e.target.files?.[0])}})]}),(0,n.jsx)(ap,{children:"Click the avatar to choose a PNG, JPEG, WebP, or SVG up to 2 MB."}),(0,n.jsx)(ax,{children:L})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"provider-website",children:"Official website"}),(0,n.jsx)(eP,{id:"provider-website",maxLength:2048,placeholder:"https://example.com",type:"url",value:_.officialWebsite,onChange:e=>A({..._,officialWebsite:e.target.value})})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"provider-remark",children:"Remark"}),(0,n.jsx)(af,{id:"provider-remark",maxLength:2e3,value:_.remark,onChange:e=>A({..._,remark:e.target.value})})]}),(0,n.jsx)(ah,{children:"Connection"}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"provider-protocol",children:"Protocol"}),(0,n.jsx)(eP,{id:"provider-protocol",readOnly:!0,value:"codex"===P?"Responses API":"Anthropic Messages API"})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"provider-base-url",required:!0,children:"Base URL"}),(0,n.jsx)(eP,{id:"provider-base-url",maxLength:2048,placeholder:"codex"===P?"https://example.com/v1":"https://example.com",required:!0,type:"url",value:"codex"===P?T.baseUrl:F.baseUrl,onChange:e=>{"codex"===P?O({...T,baseUrl:e.target.value}):M({...F,baseUrl:e.target.value})}})]}),"claude-code"===P?(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{required:!0,children:"Authentication method"}),(0,n.jsxs)(nP,{"aria-label":"Authentication method",spacing:0,value:[F.apiKeyHeader],variant:"outline",onValueChange:e=>{let[t]=e.slice(-1);("authorization"===t||"x-api-key"===t)&&M({...F,apiKeyHeader:t})},children:[(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(nS,{value:"authorization"}),children:"Auth Token"}),(0,n.jsx)(U,{children:(0,n.jsx)("code",{className:"font-mono",children:"Authorization: Bearer <xxx>"})})]}),(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(nS,{value:"x-api-key"}),children:"API Key"}),(0,n.jsx)(U,{children:(0,n.jsx)("code",{className:"font-mono",children:"X-Api-Key: <xxx>"})})]})]})]}):null,(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"provider-api-key",required:H,children:W}),(0,n.jsx)(a2,{autoComplete:"off",id:"provider-api-key",maxLength:16384,required:H,value:"codex"===P?T.apiKey:F.apiKey,onChange:e=>{"codex"===P?O({...T,apiKey:e.target.value}):M({...F,apiKey:e.target.value})}}),"codex"===P&&(0,n.jsx)(ap,{children:"Leave blank only when the endpoint accepts requests without credentials."})]}),"codex"===P?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ah,{children:"Models"}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"codex-default-model",required:!0,children:"Default model"}),(0,n.jsx)(eP,{id:"codex-default-model",maxLength:200,required:!0,value:T.defaultModel,onChange:e=>O({...T,defaultModel:e.target.value})})]}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"codex-review-model",children:"Review model"}),(0,n.jsx)(eP,{id:"codex-review-model",maxLength:200,value:T.reviewModel,onChange:e=>O({...T,reviewModel:e.target.value})})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ah,{children:"Models"}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"claude-default-model",required:!0,children:"Default model"}),(0,n.jsx)(eP,{id:"claude-default-model",maxLength:200,required:!0,value:F.defaultModel,onChange:e=>M({...F,defaultModel:e.target.value})})]}),[["opusModel","Opus model"],["sonnetModel","Sonnet model"],["haikuModel","Haiku model"],["fableModel","Fable model"]].map(e=>{let[t,a]=e;return(0,n.jsx)(nJ,{id:`claude-${t}`,label:a,value:F[t],onChange:e=>M({...F,[t]:e})},t)}),(0,n.jsxs)(ac,{children:[(0,n.jsx)(am,{htmlFor:"claude-subagent-model",children:"Subagent model"}),(0,n.jsx)(eP,{id:"claude-subagent-model",maxLength:200,value:F.subagentModel,onChange:e=>{let t=e.target.value;M({...F,subagentModel:t,subagentModelForce:""!==t.trim()&&F.subagentModelForce})}})]}),(0,n.jsxs)(ac,{"data-disabled":!q,orientation:"horizontal",children:[(0,n.jsx)(a6,{checked:F.subagentModelForce,disabled:!q,id:"claude-subagent-model-force",onCheckedChange:e=>M({...F,subagentModelForce:e})}),(0,n.jsxs)(au,{children:[(0,n.jsx)(am,{htmlFor:"claude-subagent-model-force",children:"Force subagent model"}),(0,n.jsx)(ap,{children:"Force Claude Code to use the configured subagent model."})]})]}),(0,n.jsx)(ah,{children:"Others"}),(0,n.jsxs)(as,{children:[(0,n.jsx)(ao,{className:"sr-only",children:"Other Claude Code options"}),(0,n.jsx)(ad,{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:n$.map(e=>{let t=`claude-${e.key}`;return(0,n.jsxs)(ac,{className:"min-w-0",orientation:"horizontal",children:[(0,n.jsx)(a6,{checked:F[e.key],id:t,onCheckedChange:t=>M({...F,[e.key]:t})}),(0,n.jsxs)(au,{className:"min-w-0",children:[(0,n.jsx)(am,{htmlFor:t,children:e.label}),(0,n.jsx)(ap,{children:e.description})]})]},e.key)})})]})]}),J?(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"Provider was not saved"}),(0,n.jsx)(p,{children:"Check the fields and Foundry Server, then try again."})]}):null,(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsx)(f,{nativeButton:!1,render:(0,n.jsx)(K.N_,{to:B,replace:!0}),variant:"outline",children:"Cancel"}),(0,n.jsxs)(f,{disabled:Q||null!==L,type:"submit",children:[Q?(0,n.jsx)(b,{"data-icon":"inline-start"}):null,(0,n.jsx)("span",{children:X})]})]})]})]})},P??"unselected"),(0,n.jsx)(tG,{open:null!==E,onOpenChange:e=>{e||z(null)},children:(0,n.jsxs)(t0,{children:[(0,n.jsxs)(t1,{children:[(0,n.jsx)(t5,{children:"Change Runtime?"}),(0,n.jsx)(t4,{children:"Changing the Runtime will clear the information you've entered."})]}),(0,n.jsxs)(t2,{children:[(0,n.jsx)(t6,{children:"Cancel"}),(0,n.jsx)(t3,{onClick:()=>{E&&Z(E)},children:"Change Runtime"})]})]})})]})}function nY(e){let{mode:t}=e,{providerId:a=""}=(0,ew.g)(),r=(0,j.I)({queryKey:nz(a),queryFn:()=>nO(a),refetchOnWindowFocus:!1,retry:!1});return r.isPending?(0,n.jsx)("main",{className:"w-full","aria-label":"Loading Provider",role:"status",children:(0,n.jsx)(eK,{className:"h-96 w-full"})}):r.isError?(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"Provider could not be loaded"}),(0,n.jsx)(p,{children:r.error.message})]}):(0,n.jsx)(nQ,{mode:t,provider:r.data})}var nG=a(348),nX=a(8727);let nZ=(0,d.F)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-2.5!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border bg-input/20 text-foreground dark:bg-input/30 [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function n0(e){let{className:t,variant:a="default",render:n,...r}=e;return(0,ek.C)({defaultTagName:"span",props:(0,eN.v6)({className:(0,l.cn)(nZ({variant:a}),t)},r),render:n,state:{slot:"badge",variant:a}})}let n1=["runtimes"];class n2 extends Error{}async function n5(e,t){if(!e.ok)throw new n2(t);let a=await e.json();if("SUCCESS"!==a.status||null===a.data)throw new n2(a.message??t);return a.data}async function n4(){return n5(await fetch("/api/runtimes",{cache:"no-store"}),"The Foundry Server could not load Runtimes.")}async function n3(e,t){return n5(await fetch(`/api/runtimes/${e}/preview`,{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}),"The Runtime configuration could not be previewed.")}async function n6(e,t){return n5(await fetch(`/api/runtimes/${e}/apply`,{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}),"The Runtime configuration could not be applied.")}function n8(){return(0,j.I)({queryKey:n1,queryFn:n4,refetchOnWindowFocus:!1,retry:!1})}let n7="official-default";function n9(e){let{className:t,testId:a,value:i}=e,s=(0,r.useRef)(null),[o,d]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{d(e.scrollWidth>e.clientWidth)},a=requestAnimationFrame(t),n=new ResizeObserver(t);return n.observe(e),()=>{cancelAnimationFrame(a),n.disconnect()}},[i]),(0,n.jsxs)(I,{disabled:!o,children:[(0,n.jsx)(R,{render:(0,n.jsx)("span",{ref:s,className:(0,l.cn)("block w-full max-w-full truncate font-mono",t),"data-testid":a,tabIndex:o?0:void 0}),children:i}),(0,n.jsx)(U,{className:"max-w-sm break-all",children:(0,n.jsx)("code",{className:"font-mono",children:i})})]})}function re(e){let{value:t}=e;return(0,n.jsx)("dd",{className:"min-w-0",children:(0,n.jsx)(n9,{className:"text-foreground",value:t})})}function rt(e){let{runtime:t}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(aV,{runtime:t,size:24}),(0,n.jsx)("span",{className:"truncate",children:"Official Default"})]})}function ra(e){let{provider:t}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(aH,{avatar:t.avatar,name:t.name,size:"sm"}),(0,n.jsx)("span",{className:"truncate",children:t.name})]})}function rn(e){let{isPending:t,provider:a,runtime:r,selection:i}=e;return i===n7?(0,n.jsx)(rt,{runtime:r}):a?(0,n.jsx)(ra,{provider:a}):t?"Loading Providers...":"Provider unavailable"}function rr(e,t){ed.add({description:e instanceof n2?e.message:"An unexpected error occurred.",priority:"high",title:t,type:"error"})}function ri(e){let{testId:t,value:a}=e,[i,s]=(0,r.useState)(!1);return"absent"===a.kind?(0,n.jsx)(n9,{className:"text-muted-foreground",testId:t,value:"null"}):"plain"===a.kind?(0,n.jsx)(n9,{testId:t,value:JSON.stringify(a.value)}):(0,n.jsxs)("span",{className:"inline-flex w-full min-w-0 items-center gap-1",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1",children:(0,n.jsx)(n9,{testId:t,value:i?JSON.stringify(a.value):"••••••••"})}),(0,n.jsx)(f,{"aria-label":i?"Hide API Key":"Show API Key",className:"shrink-0",size:"icon-xs",variant:"ghost",onClick:()=>s(e=>!e),children:(0,n.jsx)(g.n,{icon:i?aQ.A:tu.A,strokeWidth:2})})]})}function rs(e){let{field:t}=e;return(0,n.jsxs)("div",{className:"grid min-w-0 gap-2 overflow-hidden rounded-md border bg-muted/30 p-3 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] sm:items-center","data-slot":"preview-field",children:[(0,n.jsxs)("div",{className:"min-w-0 overflow-hidden",children:[(0,n.jsx)(n9,{className:"mb-1 text-[0.6875rem] text-muted-foreground",testId:`preview-field-${t.key}-key`,value:t.key}),(0,n.jsx)(ri,{testId:`preview-field-${t.key}-current`,value:t.current})]}),(0,n.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),(0,n.jsxs)("div",{className:"min-w-0 overflow-hidden",children:[(0,n.jsx)("span",{className:"mb-1 block text-[0.6875rem] uppercase tracking-wide text-muted-foreground",children:t.operation}),(0,n.jsx)(ri,{testId:`preview-field-${t.key}-proposed`,value:t.proposed})]})]})}function ro(e){let{fields:t}=e;return 0===t.length?(0,n.jsx)("p",{className:"text-muted-foreground",children:"No fields in this section."}):(0,n.jsx)("div",{className:"flex min-w-0 flex-col gap-2","data-slot":"preview-fields",children:t.map(e=>(0,n.jsx)(rs,{field:e},e.key))})}function rd(e){let{isOpen:t,runtime:a,onOpenChange:r}=e,i=aE[a];return(0,n.jsx)(t8,{open:t,onOpenChange:r,children:(0,n.jsxs)(ae,{className:"sm:max-w-lg",children:[(0,n.jsxs)(at,{children:[(0,n.jsxs)(an,{className:"flex items-center gap-2",children:[(0,n.jsx)(aV,{runtime:a}),(0,n.jsxs)("span",{children:[aS[a]," fields managed by Foundry"]})]}),(0,n.jsxs)(ar,{children:[i.length," ","configuration fields"]})]}),(0,n.jsx)("ul",{className:"flex max-h-80 flex-col gap-1 overflow-y-auto",children:i.map(e=>(0,n.jsx)("li",{children:(0,n.jsx)("code",{className:"block break-all rounded bg-muted px-2 py-1 text-[0.6875rem]",children:e})},e))}),(0,n.jsx)(aa,{showCloseButton:!0})]})})}function rl(e){let t,{isOpen:a,runtime:i,target:o,onOpenChange:d}=e,l=(0,y.n)({mutationFn:e=>n3(i,e)}),c=(t=(0,s.jE)(),(0,y.n)({mutationFn:e=>n6(i,e),onSuccess:e=>{t.setQueryData(n1,t=>t?.map(t=>t.runtime===e.runtime?e:t))}})),u=l.mutate,[m,p]=(0,r.useState)([]),[h,x]=(0,r.useState)(),g=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;u({providerKey:e,target:o},{onError:e=>rr(e,"Preview failed"),onSuccess:e=>{"provider-key-selection"===e.kind&&p(e.providerKeys)}})},v=l.data,j=v?.kind==="ready"?v:null;return(0,r.useEffect)(()=>{u({target:o},{onError:e=>rr(e,"Preview failed"),onSuccess:e=>{"provider-key-selection"===e.kind&&p(e.providerKeys)}})},[u,o]),(0,n.jsx)(t8,{open:a,onOpenChange:d,children:(0,n.jsxs)(ae,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[(0,n.jsxs)(at,{children:[(0,n.jsx)(an,{children:"Review Changes"}),(0,n.jsx)(ar,{children:"Review every field Foundry manages before applying this Runtime configuration."})]}),l.isPending&&(0,n.jsxs)("div",{className:"flex items-center gap-2 py-8 text-muted-foreground",role:"status",children:[(0,n.jsx)(b,{}),"Reading Runtime configuration…"]}),v&&(0,n.jsxs)("div",{className:"flex w-full min-w-0 max-w-[calc(100vw-4rem)] flex-col gap-4 sm:max-w-184",children:[(0,n.jsxs)("div",{className:"w-full min-w-0 max-w-full overflow-hidden rounded-md border bg-muted/30 p-3",children:[(0,n.jsx)("span",{className:"block text-muted-foreground",children:"Configuration file"}),(0,n.jsx)(n9,{className:"text-foreground",testId:"runtime-configuration-file-path",value:v.file.path})]}),m.length>1&&(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)("label",{className:"font-medium",htmlFor:`${i}-provider-key`,children:"Codex Provider key"}),(0,n.jsxs)(nh,{id:`${i}-provider-key`,value:h,onValueChange:e=>{e&&(x(e),g(e))},children:[(0,n.jsx)(ng,{className:"w-full",children:(0,n.jsx)(nf,{placeholder:"Select a Provider key"})}),(0,n.jsx)(nv,{align:"start",children:(0,n.jsx)(nx,{children:m.map(e=>(0,n.jsx)(nb,{value:e,children:(0,n.jsx)("code",{children:e})},e))})})]})]}),j&&(0,n.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,n.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1 font-medium",children:[(0,n.jsx)("span",{children:"Changes"}),(0,n.jsx)("span",{className:"tabular-nums text-muted-foreground/80",children:j.changes.length})]}),(0,n.jsx)(ro,{fields:j.changes})]}),(0,n.jsx)(aI,{label:"Unchanged managed fields",summary:j.unchanged.length,children:(0,n.jsx)(ro,{fields:j.unchanged})})]})]}),(0,n.jsxs)(aa,{children:[(0,n.jsx)(f,{disabled:l.isPending||c.isPending,variant:"outline",onClick:()=>g(),children:"Refresh"}),(0,n.jsxs)(f,{disabled:!j||l.isPending||c.isPending,onClick:()=>{j&&c.mutate({expectedFileHash:j.file.hash,providerKey:j.providerKey??void 0,target:o},{onError:e=>rr(e,"Apply failed"),onSuccess:()=>{ed.add({description:`${aS[i]} now uses the selected configuration.`,title:"Runtime saved",type:"success"}),d(!1)}})},children:[c.isPending&&(0,n.jsx)(b,{"data-icon":"inline-start"}),(0,n.jsx)("span",{children:"Apply"})]})]})]})})}function rc(e){let{summary:t,onDetect:a}=e,i=nR(t.runtime),s=t.managed&&t.providerId?t.providerId:n7,[o,d]=(0,r.useState)(s),[l,c]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1),g=(0,r.useMemo)(()=>o===n7?{kind:"official-default"}:{kind:"provider",providerId:o},[o]),v=t.detection,b="detected"===v.status,j=i.data?.find(e=>e.id===o);return(0,n.jsxs)(tg,{children:[(0,n.jsxs)(tv,{children:[(0,n.jsx)(tb,{className:"flex items-center gap-2",children:(0,n.jsx)(aJ,{runtime:t.runtime})}),(0,n.jsx)(ty,{children:(0,n.jsx)(n0,{variant:b?"secondary":"destructive",children:b?"Detected":"Not detected"})})]}),(0,n.jsxs)(tw,{className:"flex flex-col gap-4",children:[(0,n.jsxs)("dl",{className:"grid min-w-0 gap-2 text-muted-foreground sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("dt",{children:"Version"}),(0,n.jsx)(re,{value:v.version??"Unavailable"})]}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("dt",{children:"Configuration"}),(0,n.jsx)(re,{value:v.configurationPath})]})]}),v.message&&(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"Runtime unavailable"}),(0,n.jsx)(p,{children:v.message})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)("label",{className:"font-medium",htmlFor:`${t.runtime}-provider`,children:"Provider"}),(0,n.jsxs)(nh,{id:`${t.runtime}-provider`,value:o,onValueChange:e=>e&&d(e),children:[(0,n.jsx)(ng,{className:"w-full",children:(0,n.jsx)(nf,{children:(0,n.jsx)(rn,{isPending:i.isPending,provider:j,runtime:t.runtime,selection:o})})}),(0,n.jsx)(nv,{align:"start",children:(0,n.jsxs)(nx,{children:[(0,n.jsx)(nb,{value:n7,children:(0,n.jsx)(rt,{runtime:t.runtime})}),i.data?.map(e=>(0,n.jsx)(nb,{value:e.id,children:(0,n.jsx)(ra,{provider:e})},e.id))]})})]})]})]}),(0,n.jsxs)(tN,{className:"justify-end gap-2",children:[(0,n.jsx)(f,{size:"sm",variant:"outline",onClick:()=>c(!0),children:"Managed fields"}),(0,n.jsx)(f,{size:"sm",variant:"outline",onClick:a,children:"Detect Again"}),(0,n.jsx)(f,{disabled:i.isPending,size:"sm",onClick:()=>x(!0),children:"Save"})]}),l&&(0,n.jsx)(rd,{isOpen:!0,runtime:t.runtime,onOpenChange:c}),h&&(0,n.jsx)(rl,{isOpen:!0,runtime:t.runtime,target:g,onOpenChange:x})]})}function ru(e){return null!==e&&aP.includes(e)}function rm(e){var t;let a,{isEnabled:i,provider:o,returnTo:d}=e,[l,c]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[p,h]=(0,r.useState)(!1),v=(a=(0,s.jE)(),(0,y.n)({mutationFn:()=>nD(o.id),onSuccess:()=>{a.removeQueries({exact:!0,queryKey:nz(o.id)}),a.setQueryData(nE(o.runtime),e=>e?.filter(e=>e.id!==o.id))}})),j=(t=o.id,(0,y.n)({mutationFn:()=>nI(t)})),w=(0,r.useMemo)(()=>({kind:"provider",providerId:o.id}),[o.id]);return(0,n.jsxs)(tg,{"data-testid":`provider-${o.id}`,size:"sm",children:[(0,n.jsxs)(tv,{className:"has-data-[slot=card-action]:grid-cols-1 @sm/card-header:has-data-[slot=card-action]:grid-cols-[1fr_auto]",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-3 @sm/card-header:row-span-2",children:[(0,n.jsx)(aH,{avatar:o.avatar,name:o.name,size:"lg"}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)(tb,{className:"truncate",children:o.name}),i&&(0,n.jsx)(n0,{variant:"secondary",children:"In Use"})]}),(0,n.jsx)(tj,{className:"min-w-0",children:(0,n.jsxs)("a",{className:"inline-flex max-w-full items-center gap-1 underline-offset-3 hover:text-foreground hover:underline focus-visible:text-foreground focus-visible:outline-none focus-visible:underline",href:o.baseUrl,rel:"noreferrer",target:"_blank",children:[(0,n.jsx)("span",{className:"truncate",children:o.baseUrl}),(0,n.jsx)(g.n,{"aria-hidden":"true",className:"size-3 shrink-0",icon:nG.A,strokeWidth:2})]})})]})]}),(0,n.jsxs)(ty,{className:"col-start-1 row-start-2 mt-2 flex flex-wrap items-center gap-1 justify-self-start @sm/card-header:col-start-2 @sm/card-header:row-span-2 @sm/card-header:row-start-1 @sm/card-header:mt-0 @sm/card-header:self-center @sm/card-header:justify-self-end",children:[(0,n.jsx)(f,{"aria-label":i?`Reapply ${o.name}`:`Apply ${o.name}`,type:"button",onClick:()=>h(!0),children:i?"Reapply":"Apply"}),(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(K.N_,{"aria-label":`Edit ${o.name}`,className:x({size:"icon",variant:"ghost"}),to:`/providers/${o.id}/edit`,state:{returnTo:d}}),children:(0,n.jsx)(g.n,{icon:tm.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"Edit"})]}),(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(K.N_,{"aria-label":`Copy ${o.name}`,className:x({size:"icon",variant:"ghost"}),to:`/providers/${o.id}/copy`,state:{returnTo:d}}),children:(0,n.jsx)(g.n,{icon:tp.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"Copy"})]}),(0,n.jsxs)(tA,{open:null!==u,onOpenChange:e=>{e||m(null)},children:[(0,n.jsxs)(I,{children:[(0,n.jsx)(tT,{render:(0,n.jsx)(R,{render:(0,n.jsx)(f,{"aria-label":`Test ${o.name} connection`,disabled:j.isPending,size:"icon",type:"button",variant:"ghost",onClick:()=>{m(null),j.mutate(void 0,{onError:e=>{m(e.message)},onSuccess:()=>{ed.add({title:"Connection successful",type:"success"})}})}})}),children:j.isPending?(0,n.jsx)(b,{}):(0,n.jsx)(g.n,{icon:nX.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"Test connection"})]}),(0,n.jsxs)(tO,{align:"end",children:[(0,n.jsxs)(tF,{children:[(0,n.jsx)(tM,{children:"Connection failed"}),(0,n.jsx)(tL,{className:"wrap-break-word",children:u})]}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(f,{type:"button",variant:"outline",onClick:()=>m(null),children:"Close"})})]})]}),i?(0,n.jsxs)(I,{children:[(0,n.jsx)(R,{render:(0,n.jsx)(f,{"aria-label":`Delete ${o.name}`,disabled:!0,size:"icon",type:"button",variant:"destructive"}),children:(0,n.jsx)(g.n,{icon:th.A,strokeWidth:2})}),(0,n.jsx)(U,{children:"Provider is in use"})]}):(0,n.jsxs)(tA,{open:l,onOpenChange:c,children:[(0,n.jsx)(tT,{render:(0,n.jsx)(f,{"aria-label":`Delete ${o.name}`,size:"icon",type:"button",variant:"destructive"}),children:(0,n.jsx)(g.n,{icon:th.A,strokeWidth:2})}),(0,n.jsxs)(tO,{align:"end",children:[(0,n.jsxs)(tF,{children:[(0,n.jsx)(tM,{children:"Delete Provider?"}),(0,n.jsx)(tL,{children:"This action cannot be undone."})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(f,{disabled:v.isPending,type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),(0,n.jsxs)(f,{disabled:v.isPending,type:"button",variant:"destructive",onClick:()=>v.mutate(void 0,{onError:()=>{ed.add({title:"Provider could not be deleted",type:"error"})},onSuccess:()=>{c(!1),ed.add({title:"Provider deleted",type:"success"})}}),children:[v.isPending&&(0,n.jsx)(b,{"data-icon":"inline-start"}),(0,n.jsx)("span",{children:"Delete"})]})]})]})]})]})]}),p&&(0,n.jsx)(rl,{isOpen:!0,runtime:o.runtime,target:w,onOpenChange:h})]})}var rp=a(1656),rh=a(2498),rx=a(8474),rf=a(6447),rg=a(4976);async function rv(){let e,t,a=await fetch("/api/data/export",{cache:"no-store"});if(!a.ok)throw Error("The Foundry Server could not export data.");return{content:await a.blob(),filename:(e=a.headers.get("content-disposition"),t=e?.match(/filename="([^"]+\.foundry)"/u),t?.[1]??"foundry-export.foundry")}}async function rb(e){let t=await fetch("/api/data/import/inspect",{body:e,headers:{"content-type":"application/octet-stream"},method:"POST"});if(!t.ok)throw Error("The Foundry Server could not inspect the selected file.");let a=await t.json();if("SUCCESS"!==a.status)throw Error(a.message??"The Foundry Server could not inspect the selected file.");return a.data}async function rj(e){let{file:t,modules:a}=e,n=await fetch(`/api/data/import?modules=${a.join(",")}`,{body:t,headers:{"content-type":"application/octet-stream"},method:"POST"});if(!n.ok)throw Error("The Foundry Server could not import data.");let r=await n.json();if("SUCCESS"!==r.status)throw Error(r.message??"The Foundry Server could not import data.");return r.data}let ry={dark:{icon:rp.A,label:"Dark"},light:{icon:rh.A,label:"Light"},system:{icon:rx.A,label:"System"}},rw={prompts:"Prompts",providers:"Providers",settings:"Application Settings"};function rN(e){return aC.includes(e)}let rk=[{Component:function(){let e;return e=(0,j.I)({queryKey:q,queryFn:async()=>{if(200!==(await fetch("/api/health",{cache:"no-store"})).status)throw Error("Health check failed");return!0},networkMode:"always",staleTime:"static",gcTime:1/0,retry:!1,retryOnMount:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1}),(0,r.useEffect)(()=>{document.title=H[e.status]},[e.status]),(0,n.jsx)(ej,{children:(0,n.jsx)(W.sv,{})})},children:[{index:!0,element:(0,n.jsx)(W.C5,{to:"/dashboard",replace:!0})},{Component:function(){var e;let t,a=(0,ew.zy)(),r=(0,ew.Zp)(),i=(e=a.pathname,ta(e)?.title??"Foundry"),s=(t=ta(a.pathname))&&"description"in t?t.description:null,o=`${a.pathname}${a.search}${a.hash}`;return(0,n.jsxs)(eV,{children:[(0,n.jsx)(tn,{}),(0,n.jsxs)(eY,{children:[(0,n.jsxs)("header",{className:"sticky top-0 z-20 flex h-10 min-w-0 shrink-0 items-center gap-2 border-b bg-background px-3","data-testid":"app-header",children:[(0,n.jsx)(eQ,{"data-testid":"sidebar-trigger"}),(0,n.jsx)(eE,{orientation:"vertical",className:"h-4"}),(0,n.jsx)("span",{className:"text-xs font-medium","data-testid":"page-title",children:i}),s&&(0,n.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:s}),(0,n.jsx)(f,{variant:"ghost",size:"icon-sm",className:"ms-auto","aria-label":"Settings","data-testid":"settings-button",onClick:()=>r("/settings",{state:{returnTo:o}}),children:(0,n.jsx)(g.n,{icon:ey.A,strokeWidth:2})})]}),(0,n.jsx)("div",{className:"flex flex-1 p-4",children:(0,n.jsx)(W.sv,{})})]})]})},children:[{path:"dashboard",Component:function(){return(0,n.jsx)(tc,{title:"Dashboard",description:"Dashboard content will be added here."})}},{path:"prompts",Component:function(){var e;let[t,a]=(0,K.ok)(),[i,s]=(0,r.useState)(null),o=t.get("query")??"",[d,c]=(0,r.useState)(""!==o),h=(0,r.useRef)(null),x=(0,r.useRef)(!1),v=(e={query:o},(0,j.I)({queryKey:tD(e),queryFn:()=>tU(e),refetchOnWindowFocus:!1,retry:!1}));return(0,r.useEffect)(()=>{d&&x.current&&(x.current=!1,h.current?.focus())},[d]),(0,n.jsxs)("main",{className:"flex w-full min-w-0 flex-col gap-5 pb-12",children:[(0,n.jsxs)("header",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("div",{className:(0,l.cn)("relative h-7 min-w-7 shrink transition-[width] duration-200 ease-out",d?"w-full sm:w-72":"w-7"),children:d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.n,{"aria-hidden":"true",className:"pointer-events-none absolute inset-s-2 top-1/2 z-10 size-3.5 -translate-y-1/2 text-muted-foreground",icon:tx.A,strokeWidth:2}),(0,n.jsx)(eP,{ref:h,"aria-label":"Search Prompts",className:"ps-7",placeholder:"Search Prompts",value:o,onBlur:e=>{""===e.currentTarget.value&&c(!1)},onChange:e=>{var t;a((t=e.target.value)?{query:t}:{},{replace:!0})}})]}):(0,n.jsx)(f,{"aria-expanded":"false","aria-label":"Search Prompts",size:"icon",type:"button",variant:"outline",onClick:function(){x.current=!0,c(!0)},children:(0,n.jsx)(g.n,{icon:tx.A,strokeWidth:2})})}),(0,n.jsxs)(f,{className:"shrink-0",type:"button",onClick:()=>s({promptId:null}),children:[(0,n.jsx)(g.n,{icon:tf.A,strokeWidth:2,"data-icon":"inline-start"}),"Add Prompt"]})]}),v.isPending&&(0,n.jsxs)("div",{"aria-label":"Loading Prompts",className:"flex flex-col gap-4",role:"status",children:[(0,n.jsx)(eK,{className:"h-17 w-full"}),(0,n.jsx)(eK,{className:"h-17 w-full"}),(0,n.jsx)(eK,{className:"h-17 w-full"})]}),v.isError&&(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"Prompts could not be loaded"}),(0,n.jsx)(p,{children:"Check the Foundry Server and try again."})]}),v.data?.items.length===0&&(0,n.jsx)(ti,{children:(0,n.jsxs)(ts,{children:[(0,n.jsx)(to,{"aria-level":2,role:"heading",children:o?"No matching Prompts":"No Prompts"}),(0,n.jsx)(td,{children:o?"Try a different search.":"Save a reusable text fragment."})]})}),v.data&&v.data.items.length>0&&(0,n.jsx)("div",{className:"flex flex-col gap-4",children:v.data.items.map(e=>(0,n.jsx)(aN,{prompt:e,onOpen:()=>s({promptId:e.id})},e.id))}),i&&(0,n.jsx)(aw,{promptId:i.promptId,onClose:()=>s(null)})]})}},{path:"skills",Component:function(){return(0,n.jsx)(tc,{title:"Skills",description:"Local skill management will be added here."})}},{path:"mcps",Component:function(){return(0,n.jsx)(tc,{title:"MCPs",description:"MCP server management will be added here."})}},{path:"providers",Component:function(){let[e,t]=(0,K.ok)(),a=e.get("runtime"),i=ru(a)?a:"codex",s=nR(i),o=n8(),d=o.data?.find(e=>e.runtime===i&&e.managed)?.providerId,l=`/providers?runtime=${i}`;return(0,r.useEffect)(()=>{ru(a)||t({runtime:i},{replace:!0})},[a,i,t]),(0,n.jsxs)("main",{className:"flex w-full flex-col gap-5 pb-12",children:[(0,n.jsxs)("header",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,n.jsx)(nP,{"aria-label":"Provider Runtime",spacing:0,value:[i],variant:"outline",children:aP.map(e=>(0,n.jsx)(nS,{nativeButton:!1,render:(0,n.jsx)(K.N_,{to:`/providers?runtime=${e}`}),value:e,children:(0,n.jsx)(aJ,{runtime:e})},e))}),(0,n.jsxs)(f,{className:"ms-auto",nativeButton:!1,render:(0,n.jsx)(K.N_,{to:"/providers/new",state:{returnTo:l}}),children:[(0,n.jsx)(g.n,{icon:tf.A,strokeWidth:2,"data-icon":"inline-start"}),"Add Provider"]})]}),s.isPending?(0,n.jsxs)("div",{className:"flex flex-col gap-4","aria-label":"Loading Providers",role:"status",children:[(0,n.jsx)(eK,{className:"h-20 w-full"}),(0,n.jsx)(eK,{className:"h-20 w-full"})]}):null,s.isError?(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"Providers could not be loaded"}),(0,n.jsx)(p,{children:"Check the Foundry Server and try again."})]}):null,s.data?.length===0?(0,n.jsx)(ti,{children:(0,n.jsxs)(ts,{children:[(0,n.jsxs)(to,{children:["No"," ",aS[i]," ","Providers"]}),(0,n.jsx)(td,{children:"Add a Provider to verify the creation and listing flow."})]})}):null,s.data&&s.data.length>0&&(0,n.jsx)("div",{className:"flex flex-col gap-4",children:s.data.map(e=>(0,n.jsx)(rm,{isEnabled:e.id===d,provider:e,returnTo:l},e.id))})]})}},{path:"runtimes",Component:function(){let e=n8();return e.isPending?(0,n.jsxs)("main",{className:"grid w-full self-start gap-4 md:grid-cols-2","aria-label":"Loading Runtimes",role:"status",children:[(0,n.jsx)(eK,{className:"h-80"}),(0,n.jsx)(eK,{className:"h-80"})]}):e.isError?(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"Runtimes could not be loaded"}),(0,n.jsx)(p,{children:"Check the Foundry Server and try again."})]}):(0,n.jsx)("main",{className:"grid w-full self-start items-start gap-4 pb-12 md:grid-cols-2","data-testid":"runtime-grid",children:e.data.map(t=>(0,n.jsx)(rc,{summary:t,onDetect:()=>void e.refetch()},t.runtime))})}}]},{Component:function(){let e=(0,ew.zy)(),t="string"==typeof e.state?.returnTo?e.state.returnTo:"/dashboard";return(0,n.jsx)("div",{className:"min-h-svh p-4",children:(0,n.jsxs)("div",{className:"mx-auto flex min-h-[calc(100svh-2rem)] w-full max-w-2xl flex-col gap-4",children:[(0,n.jsxs)(K.N_,{to:t,replace:!0,className:x({variant:"link",size:"sm",className:"-ms-2 self-start"}),"data-testid":"standalone-back",children:[(0,n.jsx)(g.n,{icon:tr.A,strokeWidth:2,"data-icon":"inline-start"}),"Back"]}),(0,n.jsx)("div",{className:"flex flex-1",children:(0,n.jsx)(W.sv,{})})]})})},children:[{path:"providers/new",Component:function(){return(0,n.jsx)(nQ,{mode:"add"})}},{path:"providers/:providerId/edit",Component:function(){return(0,n.jsx)(nY,{mode:"edit"})}},{path:"providers/:providerId/copy",Component:function(){return(0,n.jsx)(nY,{mode:"copy"})}},{path:"settings",Component:function(){let e,t,[a,i]=(0,r.useState)(!1),[o,d]=(0,r.useState)(null),[l,c]=(0,r.useState)([]),h=(0,r.useRef)(null),{theme:x}=_(),v=(0,y.n)({mutationFn:rv}),j=(e=(0,s.jE)(),(0,y.n)({mutationFn:rj,onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:["providers"]}),e.invalidateQueries({queryKey:["prompts"]}),e.invalidateQueries({queryKey:["settings"]})])}})),N=(0,y.n)({mutationFn:rb}),k=(t=(0,s.jE)(),(0,y.n)({mutationFn:C,onSuccess:e=>{t.setQueryData(w,e)}})),P=()=>{d(null),c([]),j.reset(),N.reset()};return(0,n.jsxs)("main",{className:"w-full pb-12",children:[(0,n.jsx)("header",{className:"pb-5",children:(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Settings"})}),(0,n.jsxs)("section",{"aria-labelledby":"color-mode-heading",className:"grid gap-4 border-y py-5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h2",{id:"color-mode-heading",className:"text-sm font-medium",children:"Color mode"}),(0,n.jsx)("p",{className:"text-xs/relaxed text-muted-foreground",children:"Match your system, or use light or dark mode."})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 sm:flex-row-reverse",children:[(0,n.jsx)(nP,{"aria-label":"Color mode",disabled:k.isPending,spacing:0,value:[x],variant:"outline",onValueChange:e=>{var t;let a=e[0];a!==x&&void 0!==(t=a)&&ak.includes(t)&&k.mutate({colorMode:a})},children:ak.map(e=>{let t=ry[e];return(0,n.jsxs)(nS,{value:e,children:[(0,n.jsx)(g.n,{icon:t.icon,strokeWidth:2,"data-icon":"inline-start"}),t.label]},e)})}),(0,n.jsx)("span",{className:"grid size-4 place-items-center",children:k.isPending?(0,n.jsx)(b,{"aria-label":"Saving Color Mode"}):null})]}),k.isError?(0,n.jsxs)(u,{className:"sm:col-span-2",variant:"destructive",children:[(0,n.jsx)(m,{children:"Color Mode was not saved"}),(0,n.jsx)(p,{children:"Check the Foundry Server and try again."})]}):null]}),(0,n.jsxs)("section",{"aria-labelledby":"data-heading",className:"grid gap-4 border-b py-5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h2",{id:"data-heading",className:"text-sm font-medium",children:"Data"}),(0,n.jsx)("p",{className:"text-xs/relaxed text-muted-foreground",children:"Application Settings, active Providers, and active Prompts."})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{ref:h,accept:".foundry,application/octet-stream",className:"hidden",type:"file",onChange:e=>{let t=e.currentTarget.files?.[0];t&&(d(t),c([]),j.reset(),N.reset(),N.mutate(t,{onSuccess:e=>{let{modules:t}=e;c(t.flatMap(e=>"available"===e.status&&rN(e.id)?[e.id]:[]))}})),e.currentTarget.value=""}}),(0,n.jsxs)(f,{disabled:j.isPending||N.isPending||v.isPending,type:"button",variant:"outline",onClick:()=>h.current?.click(),children:[(0,n.jsx)(g.n,{"data-icon":"inline-start",icon:rf.A,strokeWidth:2}),"Import Data"]}),(0,n.jsxs)(f,{disabled:j.isPending||N.isPending||v.isPending,type:"button",variant:"outline",onClick:()=>i(!0),children:[(0,n.jsx)(g.n,{"data-icon":"inline-start",icon:rg.A,strokeWidth:2}),"Export Data"]})]})]}),(0,n.jsx)(t8,{open:null!==o,onOpenChange:e=>{e||j.isPending||P()},children:(0,n.jsxs)(ae,{className:"sm:max-w-md",showCloseButton:!1,children:[(0,n.jsxs)(at,{children:[(0,n.jsx)(an,{children:"Import Foundry data"}),(0,n.jsx)(ar,{children:N.data?`Choose the modules to import from ${o?.name??"the selected file"}.`:`Reading ${o?.name??"the selected file"}...`})]}),(0,n.jsxs)("div",{"aria-live":"polite",className:"min-h-24",children:[N.isPending&&(0,n.jsxs)("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)(b,{}),(0,n.jsx)("span",{children:"Checking Foundry export"})]}),N.isError&&(0,n.jsxs)(u,{variant:"destructive",children:[(0,n.jsx)(m,{children:"File could not be read"}),(0,n.jsx)(p,{children:"The selected file is not a valid Foundry export."})]}),N.data&&(0,n.jsxs)("fieldset",{children:[(0,n.jsx)("legend",{className:"sr-only",children:"Import modules"}),(0,n.jsx)("div",{className:"divide-y border-y",children:N.data.modules.map(e=>{var t;let a="available"===e.status&&rN(e.id)?e.id:null,r=`import-module-${e.id}`;return(0,n.jsxs)("label",{className:"flex items-start gap-3 py-3",htmlFor:r,children:[(0,n.jsx)(a6,{checked:null!==a&&l.includes(a),disabled:null===a||j.isPending,id:r,onCheckedChange:e=>{null!==a&&c(t=>e?[...t,a]:t.filter(e=>e!==a))}}),(0,n.jsxs)("span",{className:"min-w-0 space-y-0.5",children:[(0,n.jsx)("span",{className:"block text-xs font-medium",children:rN(t=e.id)?rw[t]:t}),(0,n.jsx)("span",{className:"block text-xs/relaxed text-muted-foreground",children:function(e){if("available"!==e.status)return e.message??"This module cannot be imported.";if("settings"===e.id)return"Replaces the current application settings.";let t=e.itemCount??0,a="providers"===e.id?"Provider":"Prompt";return`${t} ${1===t?a:`${a}s`} will be added.`}(e)})]})]},e.id)})})]})]}),(0,n.jsxs)(aa,{children:[(0,n.jsx)(f,{disabled:j.isPending,type:"button",variant:"outline",onClick:P,children:"Cancel"}),(0,n.jsxs)(f,{disabled:j.isPending||!N.isSuccess||0===l.length,type:"button",onClick:()=>{o&&0!==l.length&&j.mutate({file:o,modules:l},{onError:()=>{ed.add({title:"Data could not be imported",type:"error"})},onSuccess:e=>{let{modules:t}=e,a=t.some(e=>"imported"===e.status),n=t.some(e=>"imported"!==e.status);d(null),c([]),N.reset(),ed.add({description:t.map(e=>{let t;switch(e.id){case"prompts":t="Prompts";break;case"providers":t="Providers";break;case"settings":t="Settings";break;default:t=e.id}return"unsupported"===e.status?`${t} skipped`:"failed"===e.status?`${t} failed`:"providers"===e.id||"prompts"===e.id?`${e.importedItems} ${t} added`:`${t} imported`}).join(". "),...n?a?{title:"Data imported with issues",type:"warning"}:{title:"Data could not be imported",type:"error"}:{title:"Data imported",type:"success"}})}})},children:[j.isPending&&(0,n.jsx)(b,{"data-icon":"inline-start"}),(0,n.jsx)("span",{children:"Import"})]})]})]})}),(0,n.jsx)(tG,{open:a,onOpenChange:e=>{v.isPending||i(e)},children:(0,n.jsxs)(t0,{children:[(0,n.jsxs)(t1,{children:[(0,n.jsx)(t5,{children:"Export Foundry data?"}),(0,n.jsx)(t4,{children:"The exported file includes Provider API keys. Keep it private and store it securely."})]}),(0,n.jsxs)(t2,{children:[(0,n.jsx)(t6,{disabled:v.isPending,children:"Cancel"}),(0,n.jsxs)(t3,{disabled:v.isPending,onClick:()=>{v.mutate(void 0,{onError:()=>{ed.add({title:"Data could not be exported",type:"error"})},onSuccess:e=>{let{content:t,filename:a}=e,n=URL.createObjectURL(t),r=document.createElement("a");r.download=a,r.href=n,document.body.append(r),r.click(),r.remove(),URL.revokeObjectURL(n),i(!1),ed.add({title:"Data exported",type:"success"})}})},children:[v.isPending&&(0,n.jsx)(b,{"data-icon":"inline-start"}),(0,n.jsx)("span",{children:"Export"})]})]})]})})]})}},{path:"*",Component:function(){let e=(0,ew.zy)();return(0,n.jsxs)(ti,{children:[(0,n.jsxs)(ts,{className:"max-w-md gap-3",children:[(0,n.jsx)("p",{"aria-hidden":"true",className:"font-mono text-7xl font-semibold tracking-tighter text-muted-foreground/20",children:"404"}),(0,n.jsx)("h1",{className:"font-heading text-xl font-semibold tracking-tight",children:"This page doesn't exist"}),(0,n.jsx)(td,{children:"The address may be incorrect, or the page may have moved."})]}),(0,n.jsxs)(tl,{className:"gap-4",children:[(0,n.jsxs)("p",{className:"flex max-w-full items-center gap-2 text-muted-foreground",children:[(0,n.jsx)("span",{children:"Requested path"}),(0,n.jsx)("code",{className:"max-w-64 truncate rounded-md bg-muted px-2 py-1 font-mono text-foreground",children:e.pathname})]}),(0,n.jsxs)(f,{nativeButton:!1,render:(0,n.jsx)(K.N_,{to:"/dashboard","data-testid":"not-found-dashboard"}),children:[(0,n.jsx)(g.n,{icon:e3.A,strokeWidth:2,"data-icon":"inline-start"}),"Go to dashboard"]})]})]})}}]}]}],rC=(0,K.Ge)(rk),rP=document.getElementById("root");rP&&i.createRoot(rP).render((0,n.jsx)(r.StrictMode,{children:(0,n.jsx)(s.Ht,{client:$,children:(0,n.jsx)(function(e){let{children:t,disableTransitionOnChange:a=!0}=e,i=(0,j.I)({queryKey:w,queryFn:k,refetchOnWindowFocus:!1,retry:!1,staleTime:1/0}),s=i.data?.colorMode??"system",[o,d]=r.useState(E);return(r.useLayoutEffect(()=>{if(localStorage.removeItem("theme"),d(z(s,a)),"system"!==s)return;let e=window.matchMedia(P),t=()=>{d(z("system",a))};return e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[a,s]),i.isPending)?(0,n.jsx)("div",{className:"grid min-h-svh place-items-center",children:(0,n.jsx)(b,{"aria-label":"Loading Foundry"})}):i.isError?(0,n.jsx)("main",{className:"grid min-h-svh place-items-center p-4",children:(0,n.jsxs)(u,{variant:"destructive",className:"max-w-sm",children:[(0,n.jsx)(m,{children:"Unable to load Foundry"}),(0,n.jsx)(p,{children:"Application Settings could not be loaded."}),(0,n.jsx)(f,{className:"mt-2 justify-self-start",size:"sm",variant:"outline",onClick:()=>i.refetch(),children:"Retry"})]})}):(0,n.jsx)(S.Provider,{value:{resolvedTheme:o,theme:s},children:t})},{children:(0,n.jsx)(function(e){let{delay:t=0,...a}=e;return(0,n.jsx)(A.B,{"data-slot":"tooltip-provider",delay:t,...a})},{children:(0,n.jsx)(o.p,{router:rC})})})})}))}},o={};function d(e){var t=o[e];if(void 0!==t)return t.exports;var a=o[e]={exports:{}};return s[e](a,a.exports,d),a.exports}d.m=s,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(a,n){if(1&n&&(a=this(a)),8&n||"object"==typeof a&&a&&(4&n&&a.__esModule||16&n&&"function"==typeof a.then))return a;var r=Object.create(null);d.r(r);var i={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&a;("object"==typeof s||"function"==typeof s)&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach(e=>{i[e]=()=>a[e]});return i.default=()=>a,d.d(r,i),r},d.d=(e,t,a)=>{var n=(t,a)=>{for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,[a]:t[n]})};n(t,"get"),n(a,"value")},d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),d.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a=[],d.O=(e,t,n,r)=>{if(t){r=r||0;for(var i=a.length;i>0&&a[i-1][2]>r;i--)a[i]=a[i-1];a[i]=[t,n,r];return}for(var s=1/0,i=0;i<a.length;i++){for(var[t,n,r]=a[i],o=!0,l=0;l<t.length;l++)(!1&r||s>=r)&&Object.keys(d.O).every(e=>d.O[e](t[l]))?t.splice(l--,1):(o=!1,r<s&&(s=r));if(o){a.splice(i--,1);var c=n();void 0!==c&&(e=c)}}return e},n={410:0},d.O.j=e=>0===n[e],r=(e,t)=>{var a,r,[i,s,o]=t,l=0;if(i.some(e=>0!==n[e])){for(a in s)d.o(s,a)&&(d.m[a]=s[a]);if(o)var c=o(d)}for(e&&e(t);l<i.length;l++)r=i[l],d.o(n,r)&&n[r]&&n[r][0](),n[r]=0;return d.O(c)},(i=self.rspackChunk_dhzh_foundry_app=self.rspackChunk_dhzh_foundry_app||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var l=d.O(void 0,["783","535","110"],()=>d(6675));l=d.O(l)})();