@miravo/cli-linux-x64 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/console-dist/assets/catalog-BKhsnMBa.js +1 -0
  2. package/console-dist/assets/catalog-Ia1pbi0U.js +1 -0
  3. package/console-dist/assets/control-M9POk7sD.js +1 -0
  4. package/console-dist/assets/control-xSKU0dgF.js +1 -0
  5. package/console-dist/assets/copy-button-BK3jqKBZ.js +1 -0
  6. package/console-dist/assets/deploy-tab-zi4NXsfj.js +1 -0
  7. package/console-dist/assets/events-BRekhc6s.js +1 -0
  8. package/console-dist/assets/{events-40FcPI5G.js → events-CfrhnDG_.js} +1 -1
  9. package/console-dist/assets/fleet-Bk6J6tiE.js +1 -0
  10. package/console-dist/assets/{fleet-CcWeGysy.js → fleet-CcdFCWOI.js} +1 -1
  11. package/console-dist/assets/{index-0Q8wjuZr.js → index-DVW3M0iW.js} +5 -5
  12. package/console-dist/assets/instance-detail-bpv-KYmO.js +1 -0
  13. package/console-dist/assets/{login-B9bEXW-9.js → login-DV1Fd0nK.js} +1 -1
  14. package/console-dist/assets/models-BOPuZsyi.js +1 -0
  15. package/console-dist/assets/models-BbWAxRFR.js +1 -0
  16. package/console-dist/assets/platforms-Dq6BGck6.js +1 -0
  17. package/console-dist/assets/platforms-H2Z4z-EX.js +1 -0
  18. package/console-dist/assets/route-preload-CMl-AryU.js +2 -0
  19. package/console-dist/assets/tabs-BgPF8MSY.js +1 -0
  20. package/console-dist/assets/tags-DZpOeuyx.js +4 -0
  21. package/console-dist/assets/tags-nAOAgZzI.js +1 -0
  22. package/console-dist/assets/{transition-nav-link-CuWixOOd.js → transition-nav-link-B89fDRXR.js} +1 -1
  23. package/console-dist/assets/use-engine-command-mutation-DTvKLMBg.js +1 -0
  24. package/console-dist/assets/use-platform-stream-BZTQlkbS.js +2 -0
  25. package/console-dist/assets/{use-transition-navigate-C3Y3EWRr.js → use-transition-navigate-CG8tHeYN.js} +1 -1
  26. package/console-dist/assets/validation-CyzCfw_2.js +1 -0
  27. package/console-dist/icon.png +0 -0
  28. package/console-dist/index.html +19 -19
  29. package/miravo +0 -0
  30. package/package.json +1 -1
  31. package/console-dist/assets/catalog-CurT8GX7.js +0 -1
  32. package/console-dist/assets/catalog-Dq3afUeM.js +0 -1
  33. package/console-dist/assets/control-DbOdtp7Q.js +0 -1
  34. package/console-dist/assets/control-O0UYo7WO.js +0 -1
  35. package/console-dist/assets/deploy-tab-BjWxHSsV.js +0 -1
  36. package/console-dist/assets/dialog-DD0yn-KA.js +0 -1
  37. package/console-dist/assets/events-Dq2kZb5H.js +0 -1
  38. package/console-dist/assets/fleet-C4qL3Z_E.js +0 -1
  39. package/console-dist/assets/instance-detail-4xiHIeF2.js +0 -1
  40. package/console-dist/assets/models-6X-8K2W2.js +0 -1
  41. package/console-dist/assets/models-wWuV5zGw.js +0 -1
  42. package/console-dist/assets/platforms-C5DxJAky.js +0 -1
  43. package/console-dist/assets/platforms-DrizMC87.js +0 -1
  44. package/console-dist/assets/route-preload-Dz8gP8hl.js +0 -2
  45. package/console-dist/assets/tabs-Bwhx891Q.js +0 -1
  46. package/console-dist/assets/tags-CbYqG-S1.js +0 -1
  47. package/console-dist/assets/tags-Z8A51KqE.js +0 -4
  48. package/console-dist/assets/use-engine-command-mutation-CQc8tXfc.js +0 -1
  49. package/console-dist/assets/use-platform-stream-7982hIDJ.js +0 -2
  50. package/console-dist/assets/validation-4FJlp2qx.js +0 -1
  51. package/console-dist/favicon.svg +0 -1
  52. package/console-dist/miravo-logo.png +0 -0
@@ -0,0 +1 @@
1
+ import{t as e}from"./catalog-Ia1pbi0U.js";export{e as CatalogPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-mizMYESS.js";import{_ as r,a as i}from"./api-Bef9FEIU.js";import{a,n as o,t as s}from"./get-error-message-DhCjoSSJ.js";import{t as c}from"./proxy-CgM57W61.js";import{t as l}from"./AnimatePresence-CVhkybDC.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./copy-button-BK3jqKBZ.js";import{n as _,t as v}from"./createLucideIcon-Yddw9eHa.js";import{g as y,m as b,n as x,p as S,t as C,x as w}from"./input-BCiRHEmc.js";import{C as T,n as E,t as D,w as O}from"./use-platform-stream-BZTQlkbS.js";import{t as k}from"./catalog-template-icons-b6a6Gty-.js";import{l as A}from"./select-4wihIkEE.js";import{a as j}from"./platform-targets-BbVxaqAc.js";import{i as M,n as N,r as P,t as F}from"./tabs-BgPF8MSY.js";import{n as ee}from"./checkbox-Xly18Uyz.js";import{a as I,c as te,i as L,l as R,n as z,o as B,r as V,s as ne,t as H}from"./deploy-tab-zi4NXsfj.js";import{c as U,i as re,n as ie,r as W,t as ae}from"./use-engine-command-mutation-DTvKLMBg.js";import{t as G}from"./badge-tnWgSITj.js";import{t as K}from"./query-keys-Co1J4HmV.js";var q=v(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),oe=v(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),se=v(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),J=e(t(),1),Y=n();function ce(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function le(e,t,n){let r=[];for(let i of e){let e=ce(i.model),a=t.get(i.model),o=[],s=[];if(a)for(let[e,t]of Object.entries(a.members)){let n={name:e,kind:t.kind,dataType:t.dataType,unit:t.unit,euRange:t.euRange};t.kind===`property`?s.push(n):o.push(n)}for(let t=0;t<i.count;t++){let t=(n.get(i.model)??0)+1;n.set(i.model,t),r.push({id:`${e}-${String(t).padStart(3,`0`)}`,model:i.model,tags:o,properties:s})}}return r}function ue({detail:e}){let[t,n]=(0,J.useState)(new Set),o=(0,J.useRef)(null),s=(0,J.useMemo)(()=>[...new Set(e.models)],[e.models]),c=s.join(`,`),l=a({queryKey:K.catalog.modelSchemasBatch(c),queryFn:async()=>Promise.all(s.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail)))}),u=l.isPending&&!l.data,d=(0,J.useMemo)(()=>{let e=new Map;if(!l.data)return e;for(let[t,n]of l.data.entries())e.set(s[t],n);return e},[l.data,s]),f=(0,J.useMemo)(()=>{let t=new Map,n=new Map;for(let r of e.topology)for(let e of r.lines)n.set(`${r.name}/${e.name}`,le(e.twins,d,t));return n},[e.topology,d]);(0,J.useEffect)(()=>{if(u)return;let t=e.name;if(o.current===t)return;let r=new Set;for(let t of e.topology){r.add(`area:${t.name}`);for(let e of t.lines)r.add(`line:${t.name}/${e.name}`)}outer:for(let t of e.topology)for(let e of t.lines){let n=(f.get(`${t.name}/${e.name}`)??[])[0];if(n){r.add(`inst:${t.name}/${e.name}/${n.id}`);break outer}}n(r),o.current=t},[u,e.name,e.topology,f]);let p=(0,J.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return u?null:(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 py-2 pl-1 pr-2 touch-manipulation sm:py-2.5 sm:pl-1.5 sm:pr-2.5`,children:e.topology.map(n=>{let r=`area:${n.name}`,i=t.has(r);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)($,{depth:0,label:w(n.name),labelTitle:n.name,tag:`AREA`,tagKind:`area`,expanded:i,onToggle:()=>p(r),hasChildren:!0}),i&&n.lines.map(r=>{let i=`line:${n.name}/${r.name}`,a=t.has(i),o=f.get(`${n.name}/${r.name}`)??[];return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)($,{depth:1,label:w(r.name),labelTitle:r.name,tag:`LINE`,tagKind:`line`,count:o.length,expanded:a,onToggle:()=>p(i),hasChildren:!0}),a&&o.map(i=>{let a=`inst:${n.name}/${r.name}/${i.id}`,o=t.has(a);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)($,{depth:2,label:b(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:w(i.model),subtitleTitle:i.model,count:i.tags.length+i.properties.length,expanded:o,onToggle:()=>p(a),hasChildren:i.tags.length+i.properties.length>0}),o&&(0,Y.jsx)(fe,{instance:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}var X=20,de=14,Z=`flex w-3.5 shrink-0 items-center justify-center`;function fe({instance:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,Y.jsxs)(Y.Fragment,{children:[l.map(a=>(0,Y.jsx)(Q,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name)),!a&&u>0&&(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 border-t border-border/30 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-muted/40 touch-manipulation sm:min-h-0 sm:py-1.5`,style:{paddingLeft:`${t*14+X}px`},onClick:()=>o(!0),children:[(0,Y.jsx)(`span`,{className:Z,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 border-t border-border/30 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-muted/40 touch-manipulation sm:min-h-0 sm:py-1.5`,style:{paddingLeft:`${t*14+X}px`},onClick:()=>c(e=>!e),children:[(0,Y.jsx)(`span`,{className:Z,"aria-hidden":!0,children:s?(0,Y.jsx)(A,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,Y.jsx)(j,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,Y.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,Y.jsx)(Q,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name))]})]})}function Q({member:e,depth:t,area:n,line:r,instanceId:i,detail:a}){let o=e.kind===`property`,s=t*14+X+(o?de:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,Y.jsx)(g,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:(0,Y.jsxs)(`button`,{type:`button`,className:_(`flex w-full cursor-pointer flex-col gap-1 border-t border-border/25 py-2 text-left font-mono text-xs hover:bg-muted/35 touch-manipulation sm:min-h-0 sm:flex-row sm:items-center sm:gap-1.5 sm:py-1.5`,o&&`opacity-65`),style:{paddingLeft:`${s}px`},children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:Z,"aria-hidden":!0,children:(0,Y.jsx)(`span`,{className:_(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,Y.jsx)(`span`,{title:e.name,className:_(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:S(e.name)}),o&&(0,Y.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] bg-muted/60 px-1 py-px text-[10px] text-muted-foreground`,children:`PROP`})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 pl-0 sm:ml-auto sm:flex-1 sm:justify-end sm:pl-0 sm:pr-1`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,Y.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,Y.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground`,children:[`[`,e.euRange[0],`–`,e.euRange[1],`]`]})]})]})})}function $({depth:e,label:t,labelTitle:n,tag:r,tagKind:i,subtitle:a,subtitleTitle:o,count:s,expanded:c,onToggle:l,hasChildren:u}){let d=c?A:j,f=i===`area`?`text-primary`:`text-foreground`;return(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full flex-col gap-1 border-t border-border/35 py-2 pr-2 text-left text-xs transition-colors touch-manipulation first:border-t-0 hover:bg-muted/40 sm:min-h-0 sm:flex-row sm:flex-wrap sm:items-center sm:gap-1.5 sm:gap-y-0 sm:py-1.5`,style:{paddingLeft:`${12+e*14}px`},onClick:l,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 w-full items-center gap-1.5 sm:w-auto sm:flex-1 sm:flex-wrap sm:items-center`,children:[u?(0,Y.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{title:n??void 0,className:_(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,Y.jsx)(`span`,{title:o??void 0,className:`hidden min-w-0 max-w-[min(11rem,38vw)] shrink truncate font-mono text-xs text-muted-foreground sm:inline`,children:a}),s!==void 0&&(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,Y.jsx)(`span`,{title:o??void 0,className:`min-w-0 truncate pl-7 font-mono text-xs text-muted-foreground sm:hidden`,children:a})]})}function pe(e){return e.lines.reduce((e,t)=>e+t.twins.reduce((e,t)=>e+t.count,0),0)}function me(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function he(e,t){let n=0;for(let r of e.topology)for(let e of r.lines)for(let r of e.twins){let e=t.get(r.model),i=e?me(e):0;n+=r.count*i}return n}function ge({template:e,onClose:t}){let[n,l]=(0,J.useState)(new Set),u=a({queryKey:K.catalog.templateDetail(e?.id??``),queryFn:()=>i(`/catalog/templates/${e?.id}`,r.catalogTemplateDetail),enabled:e!==null}),d=u.data,f=u.isPending&&!d,p=u.isError,m=s(u.error,`Failed to load environment.`),h=d?.models?.join(`,`)??``,g=a({queryKey:K.catalog.modelSchemasBatch(h),queryFn:async()=>{let e=d?.models??[];return e.length===0?[]:Promise.all(e.map(e=>i(`/catalog/models/${e}`,r.catalogModelDetail)))},enabled:d!==null}),_=(0,J.useMemo)(()=>{if(!d||!g.data)return null;let e=new Map;for(let[t,n]of g.data.entries())e.set(d.models[t],n);return he(d,e)},[d,g.data]);(0,J.useEffect)(()=>{e&&d&&l(new Set(d.topology.map(e=>e.name)))},[e,d]);let v=(0,J.useCallback)(e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=D();return(0,Y.jsx)(z,{open:e!==null,onOpenChange:e=>{e||(y.reset(),t())},children:(0,Y.jsx)(V,{side:`right`,className:`flex w-full flex-col gap-4 touch-manipulation`,children:f?null:p&&!d?(0,Y.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,Y.jsx)(o,{message:m,onRetry:()=>void u.refetch(),isRetrying:u.isFetching})}):d?(0,Y.jsxs)(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,Y.jsxs)(I,{className:`gap-1 pb-0 pe-12`,children:[(0,Y.jsx)(B,{className:`font-heading text-base uppercase tracking-wide`,children:d.name}),d.description&&(0,Y.jsx)(L,{className:`text-xs leading-relaxed text-foreground/88`,children:d.description})]}),(0,Y.jsxs)(F,{defaultValue:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,Y.jsxs)(P,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[(0,Y.jsx)(M,{value:`overview`,className:`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`,children:`Overview`}),(0,Y.jsx)(M,{value:`uns`,className:`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`,children:`UNS`}),(0,Y.jsx)(M,{value:`deploy`,className:`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`,children:`Deploy`})]}),(0,Y.jsx)(N,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(G,{variant:`outline`,className:`font-mono text-xs`,children:[d.topology.length,` areas`]}),(0,Y.jsxs)(G,{variant:`outline`,className:`font-mono text-xs`,children:[d.instanceCount,` twins`]}),(0,Y.jsxs)(G,{variant:`outline`,className:`font-mono text-xs`,children:[d.models.length,` models`]}),_!==null&&(0,Y.jsxs)(G,{variant:`outline`,className:`font-mono text-xs`,children:[_,` tags`]}),d.settings?.tickIntervalMs&&(0,Y.jsxs)(G,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,d.settings.tickIntervalMs,`ms`]}),d.settings?.timeMultiplier&&d.settings.timeMultiplier!==1&&(0,Y.jsxs)(G,{variant:`outline`,className:`font-mono text-xs`,children:[d.settings.timeMultiplier,`× speed`]}),(0,Y.jsx)(E,{stream:y})]}),d.namespace&&(d.namespace.enterprise||d.namespace.site||d.namespace.prefix)&&(0,Y.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,Y.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,Y.jsxs)(`dl`,{className:`mt-1 grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-2`,children:[d.namespace.enterprise&&(0,Y.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,Y.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,Y.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:d.namespace.enterprise})]}),d.namespace.site&&(0,Y.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,Y.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,Y.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:d.namespace.site})]}),d.namespace.prefix&&(0,Y.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Y.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,Y.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:d.namespace.prefix})]})]})]}),d.topology.map(e=>(0,Y.jsx)(_e,{area:e,expanded:n.has(e.name),onToggle:()=>v(e.name)},e.name)),d.settings&&(0,Y.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-heading text-xs font-semibold uppercase tracking-[0.12em] text-warning`,children:[(0,Y.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Settings`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,Y.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.tickIntervalMs??1e3,`ms`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,Y.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,Y.jsx)(N,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,Y.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,Y.jsx)(ue,{detail:d})})})})}),(0,Y.jsx)(N,{value:`deploy`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,Y.jsx)(H,{kind:`template`,id:d.id,displayName:d.name,yamlPath:`/catalog/templates/${d.id}/yaml`,yamlFilename:`${d.id}.miravo.yaml`,stream:y})})})]})]},d.id):(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Environment not found`})})})}function _e({area:e,expanded:t,onToggle:n}){let r=pe(e);return(0,Y.jsxs)(`div`,{className:W,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 px-2.5 py-2 text-left text-xs font-medium transition-colors hover:bg-muted/30 touch-manipulation sm:min-h-0 sm:py-1.5`,onClick:n,children:[(0,Y.jsx)(q,{className:`size-3.5 text-primary`}),(0,Y.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:w(e.name)}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,Y.jsxs)(G,{variant:`secondary`,className:`text-xs`,children:[r,` twins`]}),(0,Y.jsxs)(G,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,Y.jsx)(A,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,Y.jsx)(l,{initial:!1,children:t&&(0,Y.jsx)(c.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,Y.jsx)(ve,{line:e},e.name))})},`content`)})]})}function ve({line:e}){return(0,Y.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Y.jsx)(se,{className:`size-3.5`}),(0,Y.jsx)(`span`,{title:e.name,children:w(e.name)}),(0,Y.jsx)(oe,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.twins.reduce((e,t)=>e+t.count,0),` twins`]})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.twins.map(e=>(0,Y.jsx)(ye,{twin:e},`${e.model}-${e.count}`))})]})}function ye({twin:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,Y.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:w(e.model)}),(0,Y.jsxs)(G,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-4 gap-y-1 border-t border-border/20 pt-1.5 font-mono text-xs`,children:Object.entries(e.parameters).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Y.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}function be(){let[e,t]=(0,J.useState)(``),[n,g]=(0,J.useState)({}),[v,b]=(0,J.useState)(null),[S,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(null),D=(0,J.useRef)(null),O=ae();(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),D.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let k=a({queryKey:K.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),A=k.data??[],j=k.isPending&&!k.data,M=k.isError&&!k.data,N=k.isError&&!!k.data,P=s(k.error,`Failed to load environments.`),F=e=>n[e]??1,I=(0,J.useCallback)((e,t)=>{g(n=>({...n,[e]:Math.max(1,Math.min(10,t))}))},[]),L=(0,J.useCallback)(e=>{E(e)},[]),R=(0,J.useCallback)(e=>{w(e)},[]),z=async e=>{b(e);try{return await O.mutateAsync({type:`loadTemplate`,templatePath:e,count:F(e)}),!0}catch{return!1}finally{b(null)}},B=e.toLowerCase(),V=B?A.filter(e=>e.name.toLowerCase().includes(B)||(e.description?.toLowerCase().includes(B)??!1)):A;return(0,Y.jsxs)(`div`,{className:`@container/templates mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Environment Catalog`}),(0,Y.jsx)(G,{variant:`outline`,className:`text-xs`,children:M?(0,Y.jsx)(`span`,{className:`text-destructive`,children:`Unavailable`}):j&&A.length===0?(0,Y.jsx)(Y.Fragment,{children:`Loading...`}):(0,Y.jsxs)(Y.Fragment,{children:[A.length,` built-in`]})})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose an environment to launch a realistic industrial system. Each environment includes pre-configured asset models with realistic physics, lifecycle degradation, and fault modes.`})]}),M&&(0,Y.jsx)(o,{message:P,onRetry:()=>void k.refetch(),isRetrying:k.isFetching}),N&&(0,Y.jsx)(o,{message:`${P} Showing cached environments.`,onRetry:()=>void k.refetch(),isRetrying:k.isFetching}),!M&&(0,Y.jsxs)(`div`,{className:`relative max-w-xs`,children:[(0,Y.jsx)(te,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,Y.jsx)(C,{ref:D,placeholder:`Filter environments...`,value:e,onChange:e=>t(e.target.value),className:`pl-9 pr-7`}),!e&&(0,Y.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-[var(--miravo-radius-tight)] border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @[720px]/templates:grid-cols-2`,"aria-busy":j&&!M,children:M?null:(0,Y.jsxs)(Y.Fragment,{children:[j&&A.length===0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-44 animate-pulse rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 bg-card/30`}),(0,Y.jsx)(`div`,{className:`h-44 animate-pulse rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 bg-card/30`}),(0,Y.jsx)(`div`,{className:`h-44 animate-pulse rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 bg-card/30`}),(0,Y.jsx)(`div`,{className:`h-44 animate-pulse rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 bg-card/30`})]}),(0,Y.jsx)(l,{children:V.map((e,t)=>(0,Y.jsx)(c.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.96,transition:{duration:.15}},transition:{type:`spring`,stiffness:380,damping:30,delay:t*.04},className:`grid`,children:(0,Y.jsx)(xe,{template:e,count:F(e.name),launching:v===e.name,onCountChange:I,onInspect:L,onLaunch:R})},e.name))}),V.length===0&&A.length>0&&(0,Y.jsxs)(`p`,{className:`col-span-full py-8 text-center text-sm text-muted-foreground`,children:[`No environments match “`,e,`”`]})]})}),A.length>0&&(0,Y.jsx)(`div`,{className:_(W,`p-0`),children:(0,Y.jsx)(`div`,{className:`community-teaser relative overflow-hidden rounded-[inherit]`,children:(0,Y.jsx)(`div`,{className:`relative z-10 mx-auto max-w-3xl px-5 py-10 sm:px-10 sm:py-12`,children:(0,Y.jsxs)(`div`,{className:`grid items-center gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,17rem)]`,children:[(0,Y.jsxs)(`div`,{className:`order-2 flex min-w-0 flex-col gap-4 lg:order-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`p`,{className:`blueprint-title text-primary`,children:`Future channel`}),(0,Y.jsx)(`span`,{className:`blueprint-stat text-[10px] text-muted-foreground`,children:`MIRAVO_REGISTRY · NOT_CONNECTED`})]}),(0,Y.jsx)(`h2`,{className:`font-heading text-xl font-semibold tracking-tight sm:text-2xl`,children:`Community Environments`}),(0,Y.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:`Share your industrial environments with the Miravo community. Publish custom environments, discover configurations from other engineers, and fork them as your starting point.`}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(G,{variant:`outline`,className:`community-teaser-soon border-primary/35 bg-primary/5 text-[10px] text-primary`,children:`Coming Soon`})})]}),(0,Y.jsx)(`div`,{className:`order-1 flex justify-center lg:order-2 lg:justify-end`,children:(0,Y.jsxs)(`div`,{className:`community-teaser-module relative flex w-full max-w-[14rem] flex-col items-center justify-center gap-3 border border-primary/15 bg-muted/15 py-8 sm:max-w-[15.5rem] sm:py-10`,"aria-hidden":!0,children:[(0,Y.jsx)(`div`,{className:`community-teaser-icon-ring relative z-[1] flex size-[4.25rem] items-center justify-center rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-gradient-to-br from-primary/18 to-primary/5`,children:(0,Y.jsx)(ee,{className:`size-9 text-primary`,"aria-hidden":!0})}),(0,Y.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] tracking-[0.18em] text-muted-foreground`,children:`AWAITING SIGNAL`}),(0,Y.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] text-muted-foreground`,children:`Uplink idle`})]})})]})})})}),(0,Y.jsx)(f,{open:S!==null,onOpenChange:e=>{e||w(null)},children:(0,Y.jsxs)(m,{children:[(0,Y.jsxs)(p,{children:[(0,Y.jsx)(h,{children:`Launch environment?`}),(0,Y.jsx)(d,{children:S!==null&&(0,Y.jsxs)(Y.Fragment,{children:[`This adds `,F(S),` instance`,F(S)===1?``:`s`,` of`,` `,(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:y(S)}),` `,`to the running environment.`]})})]}),(0,Y.jsxs)(u,{children:[(0,Y.jsx)(x,{variant:`outline`,disabled:v!==null,onClick:()=>w(null),children:`Cancel`}),(0,Y.jsx)(x,{disabled:v!==null||S===null,onClick:async()=>{S!==null&&await z(S)&&w(null)},children:v===S?`Launching...`:`Launch`})]})]})}),(0,Y.jsx)(ge,{template:T,onClose:()=>E(null)})]})}var xe=(0,J.memo)(function({template:e,count:t,launching:n,onCountChange:r,onInspect:i,onLaunch:a}){return(0,Y.jsxs)(`div`,{className:_(re,`flex flex-col gap-4 p-5`),children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,Y.jsx)(k,{id:e.id,className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`font-heading text-sm font-semibold uppercase tracking-wide`,children:y(e.name)}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-muted-foreground`,children:e.description??`Industrial environment.`})]})]}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.models.map(e=>(0,Y.jsx)(G,{variant:`outline`,className:`h-auto min-h-5 rounded-[var(--miravo-radius-tight)] px-1.5 py-0 font-mono text-[10px] font-normal text-primary`,children:e},e))})}),(0,Y.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-4 font-mono text-[11px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:e.instanceCount}),` instances`]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:e.models.length}),` models`]}),e.memberCount>0&&(0,Y.jsxs)(`span`,{children:[`~`,(0,Y.jsx)(`span`,{className:`text-foreground`,children:Se(e.memberCount)}),` tags/cycle`]}),(0,Y.jsx)(G,{variant:`secondary`,className:`ml-auto shrink-0 font-sans text-[10px] font-medium`,children:e.source})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center rounded-[var(--miravo-radius-tight)] border bg-muted/30`,children:[(0,Y.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-7 rounded-none rounded-l-md`,disabled:t<=1,"aria-label":`Decrease count`,onClick:n=>{n.stopPropagation(),r(e.name,t-1)},children:(0,Y.jsx)(R,{className:`size-3`})}),(0,Y.jsx)(`span`,{className:`flex size-7 items-center justify-center border-x font-mono text-xs`,children:t}),(0,Y.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-7 rounded-none rounded-r-md`,disabled:t>=10,"aria-label":`Increase count`,onClick:n=>{n.stopPropagation(),r(e.name,t+1)},children:(0,Y.jsx)(T,{className:`size-3`})})]}),(0,Y.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e),className:ie,children:[(0,Y.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),(0,Y.jsxs)(x,{size:`sm`,className:`ml-auto`,disabled:n,onClick:()=>a(e.name),children:[(0,Y.jsx)(U,{className:`mr-1 size-3`}),n?`...`:`Launch`]})]})]})});function Se(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}export{be as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./control-xSKU0dgF.js";export{e as ControlPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-mizMYESS.js";import{A as r,D as i,E as a,M as o,N as s,O as c,S as l,T as u,j as d,k as f,w as p,x as ee}from"./api-Bef9FEIU.js";import{t as m}from"./proxy-CgM57W61.js";import{t as h}from"./AnimatePresence-CVhkybDC.js";import{i as te,r as ne}from"./dist-jROhexoH.js";import{a as re,i as ie,n as ae,o as oe,r as se,s as ce,t as le}from"./copy-button-BK3jqKBZ.js";import{t as g}from"./shallow-ODRQsuRf.js";import{n as _,t as v}from"./createLucideIcon-Yddw9eHa.js";import{i as ue,n as de,t as fe}from"./tooltip-TtanriwA.js";import{_ as pe,a as me,g as he,h as y,n as b,t as x}from"./input-BCiRHEmc.js";import{r as S}from"./engine-store-BUO-9Dsh.js";import{t as ge}from"./activity-DP0Us3HU.js";import{t as _e}from"./arrow-right-DrKCU9WM.js";import{c as ve,i as ye,l as be,n as xe,s as Se,t as Ce}from"./select-4wihIkEE.js";import{a as we,c as C,i as w,n as T,o as E,r as Te,s as D,t as O}from"./tabs-BgPF8MSY.js";import{a as k,c as Ee,i as De,l as Oe,n as ke,r as Ae,s as A,t as j}from"./validation-CyzCfw_2.js";import{n as je,r as Me,t as Ne}from"./checkbox-Xly18Uyz.js";import{n as Pe,t as M}from"./server-D7sb2mj5.js";import{c as Fe,r as N,t as P}from"./use-engine-command-mutation-DTvKLMBg.js";import{t as F}from"./triangle-alert-DPtblpQC.js";import{t as Ie}from"./transition-nav-link-B89fDRXR.js";import{t as I}from"./badge-tnWgSITj.js";import{t as L}from"./label-xIWEC6lW.js";import{a as R,c as z,i as B,l as V,n as H,o as U,r as W,s as G,t as K}from"./combobox-gGNWoksU.js";var Le=v(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Re=v(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),ze=v(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Be=v(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Ve=v(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),He=v(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),q=v(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Ue=v(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),We=v(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ge=v(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),J=e(t(),1);f({path:d().min(1),name:d().min(1),description:d().optional(),memberCount:c().int().nonnegative(),methodCount:c().int().nonnegative(),faultCount:c().int().nonnegative(),hasLifecycle:u(),lifecycleStageCount:c().int().nonnegative()}),f({path:d().min(1),id:d().min(1),name:d().min(1),description:d().optional(),areaCount:c().int().nonnegative(),twinAssignmentCount:c().int().nonnegative(),inlineModelCount:c().int().nonnegative(),uniqueModelCount:c().int().nonnegative(),modelNames:p(d().min(1)),totalTwinCount:c().int().nonnegative()});var Ke=f({severity:a([`error`,`warning`]),message:d(),fix:d()});f({valid:u(),templatePath:d(),issues:p(Ke)});var qe=d().min(1).max(128).regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/),Je=o([c().finite(),d(),u()]),Ye=f({id:d().min(1),model:d().min(1),browsePath:p(d().min(1)).min(1),parameters:r(d(),Je),lifecycleStage:d().min(1),operatingHours:c().finite().nonnegative(),activeFaults:p(d().min(1)),templateRunId:c().int().positive().optional(),observationState:r(d(),r(d(),s())).optional().default({}),faultState:r(d(),f({remaining:c().int(),elapsed:c().int(),recovering:u(),recoveryElapsed:c().int(),recoveryTicks:c().int()})).optional().default({})}),Xe=f({templateRunId:c().int().positive(),templateName:d().min(1),templatePath:d()}),Ze=f({name:d().min(1),enabled:u(),config:r(d(),s())});f({version:i(1),savedAt:d().min(1),environmentName:qe,models:p(d().min(1)),instances:p(Ye),templateRuns:p(Xe),adapters:p(Ze).default([])});var Y=n(),Qe={mqtt:we,opcua:M,modbus:Re},$e={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus TCP`},et={mqtt:ee,opcua:l,modbus:502};function tt({adapter:e}){let t=e.pending?`pending`:e.enabled?`enabled`:`disabled`;return(0,Y.jsx)(h,{mode:`wait`,initial:!1,children:(0,Y.jsx)(m.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:500,damping:30},children:e.pending?(0,Y.jsxs)(I,{className:`gap-1 bg-info/20 text-info hover:bg-info/20`,children:[(0,Y.jsx)(E,{className:`size-3 animate-spin`}),e.enabled?`Disabling...`:`Enabling...`]}):e.enabled?(0,Y.jsxs)(I,{className:`gap-1 bg-success/20 text-success hover:bg-success/20`,children:[(0,Y.jsx)(C,{className:`size-3`}),`Enabled`]}):(0,Y.jsxs)(I,{variant:`outline`,className:`gap-1 text-muted-foreground`,children:[(0,Y.jsx)(Le,{className:`size-2`}),`Disabled`]})},t)})}function nt({metrics:e}){return e?e.connected?null:(0,Y.jsxs)(I,{variant:`destructive`,className:`gap-1`,children:[(0,Y.jsx)(D,{className:`size-3`}),`Disconnected`]}):null}function rt({health:e}){if(!e)return null;let t={healthy:`bg-success/20 text-success hover:bg-success/20`,busy:`bg-warning/20 text-warning hover:bg-warning/20`,saturated:`bg-destructive/20 text-destructive hover:bg-destructive/20`},n=e.state,r=`size-3 shrink-0`,i=n===`healthy`?(0,Y.jsx)(C,{className:r,"aria-hidden":!0}):n===`busy`?(0,Y.jsx)(ge,{className:r,"aria-hidden":!0}):n===`saturated`?(0,Y.jsx)(F,{className:r,"aria-hidden":!0}):null;return(0,Y.jsxs)(I,{className:_(`gap-1`,t[n]??``),children:[i,n]})}function X({label:e,value:t,valueClassName:n}){return(0,Y.jsxs)(`div`,{className:`flex min-h-[3.35rem] flex-col justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/55 px-3 py-2 transition-colors hover:border-muted-foreground/25`,children:[(0,Y.jsx)(`span`,{className:`blueprint-title text-[10px] leading-tight text-muted-foreground`,children:e}),(0,Y.jsx)(`span`,{className:_(`mt-1.5 font-mono text-[13px] leading-none tabular-nums tracking-tight text-foreground`,n),children:t})]})}function it({metrics:e}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:[(0,Y.jsx)(X,{label:`Messages sent`,value:y(e.messagesPublished)}),(0,Y.jsx)(X,{label:`Attempted`,value:y(e.messagesAttempted)}),(0,Y.jsx)(X,{label:`Skipped (unchanged)`,value:y(e.messagesFiltered)}),(0,Y.jsx)(X,{label:`Errors`,value:y(e.errorsCount),valueClassName:e.errorsCount>0?`text-destructive`:void 0}),(0,Y.jsx)(X,{label:`Publish latency`,value:`${e.lastPublishMs.toFixed(1)} ms`}),e.health?(0,Y.jsx)(X,{label:`Queued messages`,value:String(e.health.pendingWorkCount)}):null]})}function at({port:e}){return(0,Y.jsxs)(`div`,{className:`flex gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-warning/30 bg-warning/10 p-3 text-sm text-warning`,children:[(0,Y.jsx)(F,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:`Before enabling`}),(0,Y.jsxs)(`p`,{className:`mt-1 text-warning`,children:[`Ensure port `,(0,Y.jsx)(`code`,{className:`font-mono font-bold`,children:e}),` is available on the host.`]}),(0,Y.jsxs)(`ul`,{className:`mt-1 list-inside list-disc space-y-0.5 text-warning`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Docker:`}),` Restart with`,` `,(0,Y.jsxs)(`code`,{className:`font-mono`,children:[`-p `,e,`:`,e]}),` `,`to expose the port.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Bare metal:`}),` Run `,(0,Y.jsxs)(`code`,{className:`font-mono`,children:[`lsof -i :`,e]}),` to check availability.`]})]})]})]})}function ot({adapter:e,metrics:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),c=P(),l=Qe[e.name]??M,u=$e[e.name]??e.name,d=et[e.name]??0,f=o||e.pending===!0,p=(0,J.useMemo)(()=>{let t=e.config?.port;return typeof t==`number`?t:d},[e.config,d]);return(0,Y.jsxs)(`div`,{className:`protocol-card-art min-w-0 border`,children:[(0,Y.jsxs)(`div`,{className:`relative z-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`group/row flex w-full min-w-0 cursor-pointer gap-3 px-4 py-3 text-left transition-colors duration-[var(--miravo-duration-base)] ease-[var(--miravo-ease)] hover:bg-muted/35`,onClick:()=>r(!n),children:[(0,Y.jsx)(l,{className:`mt-0.5 size-5 shrink-0 text-muted-foreground transition-[transform,color] duration-[var(--miravo-duration-base)] ease-[var(--miravo-ease)] group-hover/row:-rotate-[8deg] group-hover/row:scale-[1.08] group-hover/row:text-primary motion-reduce:transition-none motion-reduce:group-hover/row:rotate-0 motion-reduce:group-hover/row:scale-100`,"aria-hidden":!0}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:(0,Y.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-start justify-between gap-x-3 gap-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.enabled&&!e.pending&&(0,Y.jsx)(`span`,{className:`protocol-card-live-dot`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap font-medium tracking-tight`,children:u}),(0,Y.jsx)(tt,{adapter:e}),e.enabled&&!e.pending&&t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(nt,{metrics:t}),t.health?(0,Y.jsx)(rt,{health:t.health}):(0,Y.jsxs)(I,{className:`gap-1 bg-success/20 text-success hover:bg-success/20`,children:[(0,Y.jsx)(C,{className:`size-3 shrink-0`,"aria-hidden":!0}),`healthy`]})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.enabled&&t&&!e.pending&&(0,Y.jsxs)(`span`,{className:`protocol-card-metric-readout text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-normal uppercase tracking-[0.12em] text-muted-foreground`,children:`out`}),` `,(0,Y.jsx)(`span`,{className:`text-foreground`,children:y(t.messagesPublished)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` msgs`}),t.errorsCount>0&&(0,Y.jsxs)(`span`,{className:`ml-1.5 text-destructive`,children:[t.errorsCount,` err`]})]}),(0,Y.jsx)(be,{className:`size-4 shrink-0 text-muted-foreground transition-[transform,color] duration-[var(--miravo-duration-base)] ease-[var(--miravo-ease)] group-hover/row:translate-y-0.5 group-hover/row:text-primary motion-reduce:transition-none motion-reduce:group-hover/row:translate-y-0 ${n?`rotate-180`:``}`})]})]})})]}),e.enabled&&!e.pending&&e.endpoint&&(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 px-4 pb-2 pl-11`,children:[(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,Y.jsx)(le,{value:e.endpoint,label:`Copy endpoint URL`})]})]}),(0,Y.jsx)(h,{initial:!1,children:n&&(0,Y.jsx)(m.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`protocol-card-art-body border-t`,children:e.enabled&&t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{className:`px-4 pb-4 pt-4`,"aria-labelledby":`protocol-telemetry-${e.name}`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,Y.jsx)(`h4`,{id:`protocol-telemetry-${e.name}`,className:`blueprint-title shrink-0 text-muted-foreground`,children:`Telemetry`}),(0,Y.jsxs)(Ie,{to:`/tags?protocol=${e.name}`,className:`group/footer-link inline-flex w-full min-h-8 min-w-0 max-w-full shrink-0 items-center justify-start gap-1.5 rounded-[var(--miravo-radius-pill)] border border-primary/25 bg-primary/5 px-2.5 py-1.5 text-xs font-medium leading-tight text-primary transition-colors hover:border-primary/40 hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background sm:w-fit`,children:[(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`Browse Tags`}),(0,Y.jsx)(_e,{className:`size-3 shrink-0 text-primary transition-transform group-hover/footer-link:translate-x-0.5`})]})]}),(0,Y.jsx)(it,{metrics:t})]}),(0,Y.jsx)(`footer`,{className:`protocol-card-art-footer flex flex-col gap-4 border-t border-border/80 px-4 pb-4 pt-4`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsxs)(b,{variant:`destructive`,size:`sm`,className:`gap-1.5`,disabled:f,onClick:async()=>{s(!0);try{await c.mutateAsync({type:`disableAdapter`,adapter:e.name})}catch{}finally{s(!1)}},children:[f?(0,Y.jsx)(E,{className:`size-3.5 animate-spin`}):(0,Y.jsx)(Ve,{className:`size-3.5`}),f?`Disabling...`:`Disable ${u}`]}),!f&&(0,Y.jsx)(`span`,{className:`text-xs leading-snug text-muted-foreground`,children:`Active connections will be dropped.`})]})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 py-4`,children:[!f&&(0,Y.jsx)(at,{port:i&&Number(i)||p}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(L,{htmlFor:`port-${e.name}`,className:`text-xs`,children:`Port`}),(0,Y.jsx)(x,{id:`port-${e.name}`,type:`number`,placeholder:String(p),value:i,onChange:e=>a(e.target.value),className:`w-28`,disabled:f})]}),(0,Y.jsxs)(b,{size:`sm`,className:`gap-1.5`,disabled:f,onClick:async()=>{s(!0);try{let t=i?Number(i):void 0,n={};t&&Number.isFinite(t)&&(n.port=t),await c.mutateAsync({type:`enableAdapter`,adapter:e.name,...Object.keys(n).length>0?{config:n}:{}})}catch{}finally{s(!1)}},children:[f?(0,Y.jsx)(E,{className:`size-3.5 animate-spin`}):(0,Y.jsx)(He,{className:`size-3.5`}),f?`Enabling...`:`Enable ${u}`]})]})]})})},`panel`)})]})}function st(){let{instances:e,models:t,templateRuns:n}=S(g(e=>({instances:e.instances,models:e.models,templateRuns:e.templateRuns}))),r=P(),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(`1`),[c,l]=(0,J.useState)(``),u=(0,J.useMemo)(()=>c?t.filter(e=>e.name.toLowerCase().includes(c.toLowerCase())):t,[t,c]);return(0,Y.jsxs)(U,{className:`h-full min-w-0`,children:[(0,Y.jsx)(z,{className:`pb-3`,children:(0,Y.jsxs)(V,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Y.jsx)(Pe,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Fleet Management`]})}),(0,Y.jsxs)(G,{className:`flex flex-1 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Spawn Instances`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-0 sm:flex-1`,children:(0,Y.jsxs)(K,{value:i||null,onValueChange:e=>a(e??``),onInputValueChange:l,children:[(0,Y.jsx)(W,{placeholder:`Select model`,className:`h-8 w-full min-w-0`,showClear:!!i}),(0,Y.jsx)(H,{children:(0,Y.jsxs)(R,{children:[u.map(e=>(0,Y.jsx)(B,{value:e.name,children:e.name},e.name)),u.length===0&&(0,Y.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]})}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsx)(x,{type:`number`,value:o,onChange:e=>s(e.target.value),className:`h-8 w-16 text-xs`,min:`1`,"aria-label":`Number of instances to spawn`}),(0,Y.jsx)(b,{size:`sm`,className:`h-8`,onClick:()=>{let e=k(De,{model:i,count:Number(o)});e&&r.mutate({type:`spawn`,...e})},children:`Spawn`})]})]}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` models · `,e.length,` running`]})]}),n.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Environment Runs`}),(0,Y.jsx)(h,{initial:!1,children:n.map(e=>(0,Y.jsx)(m.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4,transition:{duration:.12}},transition:{type:`spring`,stiffness:400,damping:30},children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between rounded-[var(--miravo-radius-tight)] border px-2.5 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[(0,Y.jsx)(`span`,{className:`truncate text-xs font-medium`,children:he(e.templateName)}),(0,Y.jsxs)(I,{variant:`secondary`,className:`shrink-0 text-[10px]`,children:[e.instanceIds.length,` inst`]})]}),(0,Y.jsx)(b,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-1.5 text-destructive hover:text-destructive`,"aria-label":`Unload environment run`,onClick:()=>r.mutate({type:`unloadTemplateRun`,templateRunId:e.templateRunId}),children:(0,Y.jsx)(me,{className:`size-3`})})]})},e.templateRunId))})]})]})]})]})}function ct(){let{instances:e,models:t}=S(g(e=>({instances:e.instances,models:e.models}))),n=P(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),l=(0,J.useMemo)(()=>s?e.filter(e=>e.id.toLowerCase().includes(s.toLowerCase())):e,[e,s]),u=(0,J.useMemo)(()=>{let n=e.find(e=>e.id===r);return n?t.find(e=>e.name===n.model)?.faultNames??[]:[]},[r,e,t]),d=(0,J.useMemo)(()=>e.filter(e=>e.activeFaults.length>0),[e]),f=d.reduce((e,t)=>e+t.activeFaults.length,0);return(0,Y.jsxs)(U,{className:`h-full min-w-0`,children:[(0,Y.jsx)(z,{className:`pb-3`,children:(0,Y.jsxs)(V,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Y.jsx)(F,{className:`size-3.5 ${f>0?`text-destructive`:`text-muted-foreground`}`}),`Fault Lab`,(0,Y.jsx)(h,{children:f>0&&(0,Y.jsx)(m.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},children:(0,Y.jsxs)(I,{variant:`destructive`,className:`text-[10px]`,children:[f,` active`]})},`fault-count`)})]})}),(0,Y.jsxs)(G,{className:`flex flex-1 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsxs)(K,{value:r||null,onValueChange:e=>{i(e??``),o(``)},onInputValueChange:c,children:[(0,Y.jsx)(W,{placeholder:`Select instance`,className:`h-8 min-h-11 w-full min-w-0 touch-manipulation sm:min-h-8`,showClear:!!r}),(0,Y.jsx)(H,{children:(0,Y.jsxs)(R,{children:[l.map(e=>(0,Y.jsxs)(B,{value:e.id,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id}),e.activeFaults.length>0&&(0,Y.jsx)(I,{variant:`destructive`,className:`ml-auto text-[10px]`,children:e.activeFaults.length})]},e.id)),l.length===0&&(0,Y.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]}),(0,Y.jsxs)(Ce,{value:a,onValueChange:e=>o(e??``),children:[(0,Y.jsx)(Se,{className:`h-8 min-h-11 w-full touch-manipulation sm:min-h-8`,"aria-label":`Fault type`,children:(0,Y.jsx)(ve,{placeholder:r?`Select fault`:`Pick instance first`})}),(0,Y.jsx)(xe,{alignItemWithTrigger:!1,align:`start`,children:u.map(e=>(0,Y.jsx)(ye,{value:e,children:e},e))})]})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(b,{variant:`destructive`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!a,onClick:()=>{let e=k(j,{instanceId:r,fault:a});e&&n.mutate({type:`triggerFault`,...e})},children:`Trigger`}),(0,Y.jsx)(b,{variant:`secondary`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!a,onClick:()=>{let e=k(j,{instanceId:r,fault:a});e&&n.mutate({type:`clearFault`,...e})},children:`Clear`})]}),(0,Y.jsx)(A,{}),(0,Y.jsx)(h,{mode:`wait`,initial:!1,children:d.length>0?(0,Y.jsxs)(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Faulted Instances`}),(0,Y.jsx)(h,{initial:!1,children:d.map(e=>(0,Y.jsx)(m.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:6,transition:{duration:.1}},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full touch-manipulation items-center justify-between rounded-[var(--miravo-radius-tight)] border border-destructive/20 bg-destructive/5 px-2.5 py-1.5 text-left transition-colors hover:bg-destructive/10 sm:min-h-0`,onClick:()=>{i(e.id),o(``)},children:[(0,Y.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-destructive`,children:e.activeFaults.join(`, `)})]})},e.id))})]},`faulted`):(0,Y.jsxs)(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex items-center gap-2 py-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(C,{className:`size-3.5 text-success`}),`All clear — no active faults`]},`all-clear`)})]})]})}function lt(){let e=S(e=>e.instances),t=P(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),c=(0,J.useMemo)(()=>o?e.filter(e=>e.id.toLowerCase().includes(o.toLowerCase())):e,[e,o]),l=(0,J.useMemo)(()=>e.filter(e=>e.isQuarantined),[e]),u=(0,J.useMemo)(()=>e.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,[e]),d=(0,J.useMemo)(()=>e.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,[e]);return(0,Y.jsxs)(U,{className:`h-full min-w-0`,children:[(0,Y.jsx)(z,{className:`pb-3`,children:(0,Y.jsxs)(V,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Y.jsx)(Ue,{className:`size-3.5 text-muted-foreground`}),`Instance Actions`]})}),(0,Y.jsxs)(G,{className:`flex flex-1 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Remove Instance`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-0 sm:flex-1`,children:(0,Y.jsxs)(K,{value:n||null,onValueChange:e=>{r(e??``),a(!1)},onInputValueChange:s,children:[(0,Y.jsx)(W,{placeholder:`Select instance`,className:`h-8 w-full min-w-0`,showClear:!!n}),(0,Y.jsx)(H,{children:(0,Y.jsxs)(R,{children:[c.map(e=>(0,Y.jsx)(B,{value:e.id,children:(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),c.length===0&&(0,Y.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),i&&n?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:shrink-0`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-destructive`,children:`Remove?`}),(0,Y.jsx)(b,{size:`sm`,variant:`destructive`,className:`h-7 text-xs`,onClick:()=>{t.mutate({type:`removeInstance`,instanceId:n}),a(!1),r(``)},children:`Confirm`}),(0,Y.jsx)(b,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>a(!1),children:`Cancel`})]}):(0,Y.jsxs)(b,{className:`h-8 w-full shrink-0 gap-1.5 sm:w-auto`,variant:`destructive`,size:`sm`,disabled:!n,onClick:()=>{k(ke,{instanceId:n})&&a(!0)},children:[(0,Y.jsx)(Ge,{className:`size-3`}),`Remove`]})]})]}),(0,Y.jsx)(A,{}),(0,Y.jsx)(h,{mode:`wait`,initial:!1,children:l.length>0?(0,Y.jsxs)(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wider text-warning`,children:[`Quarantined`,(0,Y.jsx)(I,{variant:`secondary`,className:`text-[10px] text-warning`,children:l.length})]}),(0,Y.jsx)(h,{initial:!1,children:l.map(e=>(0,Y.jsx)(m.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,transition:{duration:.1}},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between rounded-[var(--miravo-radius-tight)] border border-warning/20 bg-warning/5 px-2.5 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Y.jsx)(b,{size:`sm`,variant:`outline`,className:`h-6 shrink-0 text-[10px]`,onClick:()=>t.mutate({type:`unquarantine`,instanceId:e.id}),children:`Unquarantine`})]})},e.id))})]},`quarantined`):(0,Y.jsxs)(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Fleet Health`}),(0,Y.jsx)(`div`,{className:`flex items-center gap-4 text-xs`,children:e.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`size-2 rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:u}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`healthy`})]}),d>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`size-2 rounded-full bg-warning`}),(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:d}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`faulted`})]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(We,{className:`size-3 text-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`0 quarantined`})]})]}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`No instances running`})})]},`fleet-health`)})]})]})}function ut(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function dt(e){if(!Number.isFinite(e)||e<=0)return`0s`;if(e<60)return`${e.toFixed(1)}s`;let t=Math.floor(e),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?r>0?`${n}d ${r}h`:i>0?`${n}d ${i}m`:`${n}d`:r>0?`${r}h ${i}m`:i>0?`${i}m ${a}s`:`${a}s`}function ft({data:e}){let t=(0,J.useMemo)(()=>{if(e.length<2)return null;let t=e.map(e=>e.tps),n=Math.max(...t,.1),r=Math.min(...t,0),i=n-r||1;return{points:t.map((e,n)=>{let a=n/(t.length-1)*200,o=2+(1-(e-r)/i)*28;return`${n===0?`M`:`L`}${a.toFixed(1)},${o.toFixed(1)}`}).join(` `),min:r,max:n}},[e]);return t?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`svg`,{viewBox:`0 0 200 32`,className:`h-8 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":`TPS trend sparkline`,children:[(0,Y.jsx)(`line`,{x1:`0`,y1:`10.7`,x2:`200`,y2:`10.7`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Y.jsx)(`line`,{x1:`0`,y1:`21.3`,x2:`200`,y2:`21.3`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Y.jsx)(`path`,{d:t.points,fill:`none`,stroke:`var(--primary)`,strokeWidth:`1.5`})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[`60s ago · `,t.min.toFixed(1)]}),(0,Y.jsxs)(`span`,{children:[t.max.toFixed(1),` · now`]})]})]}):(0,Y.jsx)(`div`,{className:`flex h-8 items-center text-[10px] text-muted-foreground`,children:`Collecting...`})}var pt={running:`bg-success`,paused:`bg-warning`,idle:`bg-muted-foreground`,stopped:`bg-destructive`};function mt({state:e}){let t=pt[e]??`bg-muted-foreground`,n=e===`running`;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:`size-2.5 rounded-full ${t}`}),n&&(0,Y.jsx)(`span`,{className:`absolute size-2.5 animate-ping rounded-full ${t} opacity-40`})]}),(0,Y.jsx)(h,{mode:`wait`,initial:!1,children:(0,Y.jsx)(m.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{type:`spring`,stiffness:500,damping:30},className:`font-mono text-lg font-bold uppercase tracking-wider`,children:e},e)})]})}function Z({label:e,tooltip:t,tooltipClassName:n}){return(0,Y.jsxs)(`div`,{className:`inline-flex w-fit min-w-0 max-w-full items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`blueprint-title min-w-0 shrink text-[11px] leading-tight text-muted-foreground`,children:e}),(0,Y.jsxs)(fe,{children:[(0,Y.jsx)(ue,{className:`inline-flex size-4 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border-0 bg-transparent p-0 text-muted-foreground shadow-none outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring`,render:(0,Y.jsx)(`button`,{type:`button`}),"aria-label":`About ${e}`,children:(0,Y.jsx)(Me,{className:`size-3`,"aria-hidden":!0})}),(0,Y.jsx)(de,{side:`top`,className:_(`max-w-xs`,n),children:t})]})]})}function ht(){let{engineState:e,connectionState:t}=S(g(e=>({engineState:e.engineState,connectionState:e.connectionState}))),n=P();return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(Z,{label:`Run state`,tooltip:(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Whether the scheduler is running, paused, idle, or stopped. Pause freezes simulated time; resume continues from the same tick.`})}),(0,Y.jsx)(mt,{state:e}),t===`live`&&(e===`running`||e===`paused`)&&(0,Y.jsx)(`div`,{className:`mt-1 flex items-center gap-2`,children:(0,Y.jsxs)(b,{type:`button`,size:`sm`,variant:e===`paused`?`default`:`outline`,className:_(`h-8 min-h-11 w-fit touch-manipulation gap-1.5 px-3 text-xs sm:min-h-8`,e===`running`&&`border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 hover:text-warning focus-visible:border-warning/50 focus-visible:ring-warning/25 border-warning/35`),onClick:()=>n.mutate({type:e===`paused`?`resume`:`pause`}),children:[e===`paused`?(0,Y.jsx)(Fe,{className:`size-3`}):(0,Y.jsx)(Be,{className:`size-3`}),e===`paused`?`Resume`:`Pause`]})})]})}function gt(){let{speedMultiplier:e,connectionState:t}=S(g(e=>({speedMultiplier:e.speedMultiplier,connectionState:e.connectionState}))),n=P(),[r,i]=(0,J.useState)(String(e)),a=t===`live`;return(0,J.useEffect)(()=>{i(String(e))},[e]),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(Z,{label:`Speed`,tooltip:(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Runs the environment at this multiple of real time. 1× is real time; higher values speed up the model. Change it with the field and Set.`})}),(0,Y.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[e,`x`]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(L,{htmlFor:`speed-multiplier`,className:`sr-only`,children:`Speed multiplier`}),(0,Y.jsx)(x,{id:`speed-multiplier`,type:`number`,value:r,onChange:e=>i(e.target.value),className:`h-8 min-h-11 w-[4.75rem] touch-manipulation font-mono text-xs tabular-nums sm:min-h-8`,min:`1`,max:`1000`,disabled:!a}),(0,Y.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 min-h-11 touch-manipulation px-3 text-xs sm:min-h-8`,disabled:!a,onClick:()=>{let e=k(Ae,{multiplier:Number(r)});e&&n.mutate({type:`setSpeed`,multiplier:e.multiplier})},children:`Set`})]})]})}function _t(){let{tick:e,simulationTime:t,tps:n,tpsHistory:r,uptimeMs:i,instanceCount:a,memberValueCount:o}=S(g(e=>({tick:e.tick,simulationTime:e.simulationTime,tps:e.tps,tpsHistory:e.tpsHistory,uptimeMs:e.uptimeMs,instanceCount:e.instanceCount,memberValueCount:e.memberValueCount})));return(0,Y.jsxs)(`div`,{className:_(N,`px-4 py-3`),children:[(0,Y.jsxs)(`header`,{className:`mb-3 border-b border-border/60 pb-2`,children:[(0,Y.jsx)(`h2`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Engine vitals`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Scheduler, speed, cycle count, and throughput for this session.`})]}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 grid-cols-2 gap-3 @2xl/main:gap-4 @3xl/main:grid-cols-3 @5xl/main:grid-cols-6`,children:[(0,Y.jsx)(ht,{}),(0,Y.jsx)(gt,{}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(Z,{label:`Cycle`,tooltipClassName:`flex flex-col items-start gap-2 text-left`,tooltip:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Cycle`}),` compares simulated progress with wall time: how many steps ran, how much model time advanced, and how long this session has been open.`]}),(0,Y.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[`The number is `,(0,Y.jsx)(`span`,{className:`font-medium`,children:`tick`}),` count — completed scheduler steps since this run. Each tick refreshes the plant model and live tags.`]}),(0,Y.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Sim`}),` is simulated elapsed time. Each tick adds (tick interval × speed) to this clock. Generators, lifecycle, and in-model timestamps use Sim, not your system clock. It stops advancing while paused.`]}),(0,Y.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Real`}),` is wall-clock uptime since the run started (real time).`]})]})}),(0,Y.jsx)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:y(e)}),(0,Y.jsxs)(`div`,{className:`mt-1 flex w-full min-w-0 flex-col gap-0.5 leading-tight`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Sim`}),(0,Y.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:dt(t)})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Real`}),(0,Y.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:ut(i)})]})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(Z,{label:`Throughput`,tooltip:(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Ticks per second: how fast the engine is stepping. Rises and falls with workload, speed setting, and CPU headroom.`})}),(0,Y.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[n.toFixed(1),` tps`]}),(0,Y.jsxs)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[a,` inst · `,pe(o),` tags`]})]}),(0,Y.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-2`,children:[(0,Y.jsx)(Z,{label:`TPS Trend`,tooltip:(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Recent ticks-per-second samples over about the last minute. Flat or noisy lines usually mean load or speed changes.`})}),(0,Y.jsx)(ft,{data:r})]})]})]})}var Q=[`MQTT Sparkplug B`,`EtherNet/IP`,`Siemens S7`];function vt({enabled:e,total:t}){let n=t===0?`empty`:e===0?`idle`:`live`;return(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 rounded-[var(--miravo-radius-pill)] border border-border/60 bg-background/60 px-2.5 py-1 backdrop-blur-sm`,children:[(0,Y.jsxs)(`span`,{className:`relative flex size-1.5 items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:_(`size-1.5 rounded-full`,n===`live`?`bg-success shadow-[0_0_0_1px_color-mix(in_srgb,var(--success)_50%,transparent),0_0_12px_color-mix(in_srgb,var(--success)_42%,transparent)]`:n===`idle`?`bg-warning/85 shadow-[0_0_0_1px_color-mix(in_srgb,var(--warning)_50%,transparent),0_0_12px_color-mix(in_srgb,var(--warning)_38%,transparent)]`:`bg-muted-foreground/55`)}),n===`live`&&(0,Y.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-success/60`})]}),(0,Y.jsxs)(`span`,{className:`text-[11px] leading-none text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,Y.jsx)(`span`,{className:`mx-1 text-muted-foreground/60`,children:`/`}),(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:t}),(0,Y.jsx)(`span`,{className:`ml-1.5 text-[10px] uppercase tracking-[0.14em]`,children:`active`})]})]})}function $(){let{availableAdapters:e,adapterMetrics:t}=S(g(e=>({availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled).length;return(0,Y.jsxs)(`section`,{className:_(N,`flex min-w-0 flex-col hover:border-border`),children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-border/60 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-background/70 text-muted-foreground`,"aria-hidden":!0,children:(0,Y.jsx)(q,{className:`size-3.5`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h3`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Protocol Gateway`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-pretty text-xs text-muted-foreground`,children:`Northbound adapters publishing engine telemetry to external systems.`})]})]}),(0,Y.jsx)(vt,{enabled:n,total:e.length})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 px-4 py-4`,children:(0,Y.jsx)(h,{children:e.map((e,n)=>{let r=t.find(t=>t.name===e.name)?.metrics;return(0,Y.jsx)(m.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{type:`spring`,stiffness:380,damping:30,delay:n*.05},children:(0,Y.jsx)(ot,{adapter:e,metrics:r})},e.name)})})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 border-t border-border/60 bg-background/40 px-4 py-2.5`,role:`status`,"aria-label":`Upcoming protocol adapters: ${Q.join(`, `)}, and more`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsx)(je,{className:`size-3 text-muted-foreground/70`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Roadmap`})]}),(0,Y.jsxs)(`ul`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[Q.map(e=>(0,Y.jsx)(`li`,{className:`rounded-[var(--miravo-radius-tight)] border border-dashed border-border/70 bg-background/40 px-2 py-0.5 font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground`,children:e},e)),(0,Y.jsx)(`li`,{className:`font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground/75`,children:`+ more`})]})]})]})}function yt(){let e=S(e=>e.instances),t=P(),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,children:[(0,Y.jsxs)(U,{className:`h-full min-w-0`,children:[(0,Y.jsx)(z,{className:`pb-3`,children:(0,Y.jsxs)(V,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Y.jsx)(ze,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Danger Zone`]})}),(0,Y.jsx)(G,{className:`flex flex-1 flex-col`,children:(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-3 @2xl/main:flex-row @2xl/main:items-center @2xl/main:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Reset environment`}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Removes `,e.length,` running instance`,e.length===1?``:`s`,` and all loaded environments.`]})]}),(0,Y.jsx)(b,{className:`min-h-11 w-full shrink-0 touch-manipulation @2xl/main:w-auto sm:min-h-7`,variant:`destructive`,size:`sm`,onClick:()=>r(!0),children:`Reset`})]})})]}),(0,Y.jsx)(ae,{open:n,onOpenChange:e=>{r(e),e||a(!1)},children:(0,Y.jsxs)(se,{children:[(0,Y.jsxs)(oe,{children:[(0,Y.jsx)(ce,{children:`Reset Environment`}),(0,Y.jsx)(ie,{children:`Removes all running instances and loaded environments.`})]}),(0,Y.jsx)(`div`,{className:`space-y-3 text-sm`,children:(0,Y.jsx)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border p-3`,children:(0,Y.jsxs)(L,{htmlFor:`clear-persisted-state`,className:`items-start`,children:[(0,Y.jsx)(Ne,{id:`clear-persisted-state`,checked:i,onCheckedChange:e=>a(e===!0)}),(0,Y.jsxs)(`span`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium text-foreground`,children:`Also clear persisted state`}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Start empty on the next restart.`})]})]})})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(b,{variant:`outline`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,onClick:()=>{r(!1),a(!1)},disabled:o,children:`Cancel`}),(0,Y.jsx)(b,{variant:`destructive`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,disabled:o,onClick:async()=>{s(!0);try{await t.mutateAsync({type:`resetEnvironment`,...i?{clearPersistence:!0}:{}}),r(!1),a(!1)}catch{}finally{s(!1)}},children:o?`Resetting...`:`Confirm Reset`})]})]})})]})}function bt(){let[e,t]=te(`tab`,ne([`monitor`,`operate`]).withDefault(`monitor`));return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Mission Control`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Engine telemetry, protocol management, and fleet operations.`})]}),(0,Y.jsxs)(O,{value:e,onValueChange:e=>{t(e)},className:`min-h-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,Y.jsxs)(Te,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Y.jsxs)(w,{value:`monitor`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(Oe,{className:`size-3.5 shrink-0`}),`Monitor`]}),(0,Y.jsxs)(w,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(Ee,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,Y.jsx)(T,{value:`monitor`,className:`flex-1 py-2`,children:(0,Y.jsxs)(m.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col gap-5 sm:gap-6`,children:[(0,Y.jsx)(_t,{}),(0,Y.jsx)($,{})]},`monitor`)}),(0,Y.jsx)(T,{value:`operate`,className:`flex-1 py-2`,children:(0,Y.jsxs)(m.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`grid min-h-0 min-w-0 grid-cols-1 items-stretch gap-5 @2xl/main:grid-cols-2 @2xl/main:gap-4`,children:[(0,Y.jsx)(st,{}),(0,Y.jsx)(lt,{}),(0,Y.jsx)(ct,{}),(0,Y.jsx)(yt,{})]},`operate`)})]})]})}export{q as n,bt as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{B as n,G as r,H as i,K as a,U as o,V as s,W as c,at as l,ot as u}from"./vendor-ui-mizMYESS.js";import{n as d,t as f}from"./createLucideIcon-Yddw9eHa.js";import{i as p,n as m,t as h}from"./tooltip-TtanriwA.js";import{a as g,n as _,o as v}from"./input-BCiRHEmc.js";var y=l(),b=e(t(),1),ee=e(u(),1);function x(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var S=e=>{switch(e){case`success`:return T;case`info`:return D;case`warning`:return E;case`error`:return O;default:return null}},C=Array(12).fill(0),w=({visible:e,className:t})=>b.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},b.createElement(`div`,{className:`sonner-spinner`},C.map((e,t)=>b.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),T=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},b.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),E=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},b.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),D=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),O=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),k=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},b.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),b.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),te=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},A=1,j=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:A++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],b.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(M(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||A++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},ne=(e,t)=>{let n=t?.id||A++;return j.addToast({title:e,...t,id:n}),n},M=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,N=Object.assign(ne,{success:j.success,info:j.info,warning:j.warning,error:j.error,custom:j.custom,message:j.message,promise:j.promise,dismiss:j.dismiss,loading:j.loading},{getHistory:()=>j.toasts,getToasts:()=>j.getActiveToasts()});x(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function P(e){return e.label!==void 0}var F=3,I=`24px`,L=`16px`,R=4e3,z=356,re=14,ie=45,ae=200;function B(...e){return e.filter(Boolean).join(` `)}function oe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var se=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:ee,gap:x,expandByDefault:C,classNames:T,icons:E,closeButtonAriaLabel:D=`Close toast`}=e,[O,A]=b.useState(null),[j,ne]=b.useState(null),[M,N]=b.useState(!1),[F,I]=b.useState(!1),[L,z]=b.useState(!1),[re,se]=b.useState(!1),[V,H]=b.useState(!1),[ce,U]=b.useState(0),[le,W]=b.useState(0),G=b.useRef(n.duration||y||R),K=b.useRef(null),q=b.useRef(null),ue=c===0,de=c+1<=o,J=n.type,Y=n.dismissible!==!1,fe=n.className||``,pe=n.descriptionClassName||``,X=b.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),me=b.useMemo(()=>n.closeButton??p,[n.closeButton,p]),he=b.useMemo(()=>n.duration||y||R,[n.duration,y]),ge=b.useRef(0),Z=b.useRef(0),_e=b.useRef(0),Q=b.useRef(null),[ve,ye]=ee.split(`-`),be=b.useMemo(()=>s.reduce((e,t,n)=>n>=X?e:e+t.height,0),[s,X]),xe=te(),Se=n.invert||t,Ce=J===`loading`;Z.current=b.useMemo(()=>X*x+be,[X,be]),b.useEffect(()=>{G.current=he},[he]),b.useEffect(()=>{N(!0)},[]),b.useEffect(()=>{let e=q.current;if(e){let t=e.getBoundingClientRect().height;return W(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),b.useLayoutEffect(()=>{if(!M)return;let e=q.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,W(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[M,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let $=b.useCallback(()=>{I(!0),U(Z.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},ae)},[n,d,a,Z]);b.useEffect(()=>{if(n.promise&&J===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||xe?(()=>{if(_e.current<ge.current){let e=new Date().getTime()-ge.current;G.current-=e}_e.current=new Date().getTime()})():G.current!==1/0&&(ge.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),$()},G.current)),()=>clearTimeout(e)},[u,i,n,J,xe,$]),b.useEffect(()=>{n.delete&&($(),n.onDismiss==null||n.onDismiss.call(n,n))},[$,n.delete]);function we(){return E?.loading?b.createElement(`div`,{className:B(T?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":J===`loading`},E.loading):b.createElement(w,{className:B(T?.loader,n?.classNames?.loader),visible:J===`loading`})}let Te=n.icon||E?.[J]||S(J);return b.createElement(`li`,{tabIndex:0,ref:q,className:B(_,fe,T?.toast,n?.classNames?.toast,T?.default,T?.[J],n?.classNames?.[J]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":M,"data-promise":!!n.promise,"data-swiped":V,"data-removed":F,"data-visible":de,"data-y-position":ve,"data-x-position":ye,"data-index":c,"data-front":ue,"data-swiping":L,"data-dismissible":Y,"data-type":J,"data-invert":Se,"data-swipe-out":re,"data-swipe-direction":j,"data-expanded":!!(u||C&&M),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${F?ce:Z.current}px`,"--initial-height":C?`auto`:`${le}px`,...m,...n.style},onDragEnd:()=>{z(!1),A(null),Q.current=null},onPointerDown:e=>{e.button!==2&&(Ce||!Y||(K.current=new Date,U(Z.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(z(!0),Q.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(re||!Y)return;Q.current=null;let e=Number(q.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(q.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-K.current?.getTime(),i=O===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=ie||a>.11){U(Z.current),n.onDismiss==null||n.onDismiss.call(n,n),ne(O===`x`?e>0?`right`:`left`:t>0?`down`:`up`),$(),se(!0);return}else{var o,s;(o=q.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=q.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}H(!1),z(!1),A(null)},onPointerMove:t=>{var n,r;if(!Q.current||!Y||window.getSelection()?.toString().length>0)return;let i=t.clientY-Q.current.y,a=t.clientX-Q.current.x,o=e.swipeDirections??oe(ee);!O&&(Math.abs(a)>1||Math.abs(i)>1)&&A(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(O===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(O===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&H(!0),(n=q.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=q.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},me&&!n.jsx&&J!==`loading`?b.createElement(`button`,{"aria-label":D,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!Y?()=>{}:()=>{$(),n.onDismiss==null||n.onDismiss.call(n,n)},className:B(T?.closeButton,n?.classNames?.closeButton)},E?.close??k):null,(J||n.icon||n.promise)&&n.icon!==null&&(E?.[J]!==null||n.icon)?b.createElement(`div`,{"data-icon":``,className:B(T?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||we():null,n.type===`loading`?null:Te):null,b.createElement(`div`,{"data-content":``,className:B(T?.content,n?.classNames?.content)},b.createElement(`div`,{"data-title":``,className:B(T?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?b.createElement(`div`,{"data-description":``,className:B(v,pe,T?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),b.isValidElement(n.cancel)?n.cancel:n.cancel&&P(n.cancel)?b.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{P(n.cancel)&&Y&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),$())},className:B(T?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,b.isValidElement(n.action)?n.action:n.action&&P(n.action)?b.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{P(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&$())},className:B(T?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function V(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function H(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?L:I;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var ce=b.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=F,toastOptions:g,dir:_=V(),gap:v=re,icons:y,containerAriaLabel:x=`Notifications`}=e,[S,C]=b.useState([]),w=b.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=b.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=b.useState([]),[O,k]=b.useState(!1),[te,A]=b.useState(!1),[ne,M]=b.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=b.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=b.useRef(null),L=b.useRef(!1),R=b.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||j.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return b.useEffect(()=>j.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{ee.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[S]),b.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),b.useEffect(()=>{S.length<=1&&k(!1)},[S]),b.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),b.useEffect(()=>{if(N.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[N.current]),b.createElement(`section`,{ref:t,"aria-label":`${x} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?b.createElement(`ol`,{key:t,dir:_===`auto`?V():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":ne,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${z}px`,"--gap":`${v}px`,...m,...H(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{te||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>b.createElement(se,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:te,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:R,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:v,expanded:O,swipeDirections:e.swipeDirections}))):null}))}),U=f(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]);function le({...e}){return(0,y.jsx)(s,{"data-slot":`dialog`,...e})}function W({...e}){return(0,y.jsx)(i,{"data-slot":`dialog-portal`,...e})}function G({className:e,...t}){return(0,y.jsx)(a,{"data-slot":`dialog-overlay`,className:d(`fixed inset-0 isolate z-50 bg-black/10 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`,e),...t})}function K({className:e,children:t,showCloseButton:n=!0,...i}){return(0,y.jsxs)(W,{children:[(0,y.jsx)(G,{}),(0,y.jsxs)(o,{"data-slot":`dialog-content`,className:d(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-[var(--miravo-radius-stadium-sm)] bg-background p-4 text-sm 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`,e),...i,children:[t,n&&(0,y.jsxs)(r,{"data-slot":`dialog-close`,render:(0,y.jsx)(_,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,y.jsx)(g,{}),(0,y.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function q({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`dialog-header`,className:d(`flex flex-col gap-2`,e),...t})}function ue({className:e,showCloseButton:t=!1,children:n,...i}){return(0,y.jsxs)(`div`,{"data-slot":`dialog-footer`,className:d(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-[var(--miravo-radius-stadium-sm)] border-t p-4 sm:flex-row sm:justify-end`,e),...i,children:[n,t&&(0,y.jsx)(r,{render:(0,y.jsx)(_,{variant:`outline`}),children:`Close`})]})}function de({className:e,...t}){return(0,y.jsx)(n,{"data-slot":`dialog-title`,className:d(`text-base leading-none font-medium`,e),...t})}function J({className:e,...t}){return(0,y.jsx)(c,{"data-slot":`dialog-description`,className:d(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Y(e,t){if(!t?.body||!t.createElement||typeof t.execCommand!=`function`)return!1;let n=t.createElement(`textarea`),r=t.activeElement;n.value=e,n.setAttribute(`readonly`,``),n.setAttribute(`aria-hidden`,`true`),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`-9999px`,n.style.opacity=`0`,t.body.appendChild(n),n.focus(),n.select(),n.setSelectionRange(0,n.value.length);try{return t.execCommand(`copy`)}finally{t.body.removeChild(n),r?.focus?.()}}async function fe(e,t=globalThis){let n=t.navigator?.clipboard?.writeText;if(n)try{await n(e);return}catch{if(Y(e,t.document))return;throw Error(`Clipboard write failed`)}if(!Y(e,t.document))throw Error(`Clipboard API unavailable`)}function pe({value:e,label:t=`Copy`,className:n,successMessage:r=`Copied to clipboard`,successDescription:i,tooltipSide:a=`right`,render:o}){let[s,c]=(0,b.useState)(!1),l=(0,b.useRef)(void 0),u=(0,b.useCallback)(async t=>{t.stopPropagation();try{await fe(e),c(!0),N.success(r,{description:i}),clearTimeout(l.current),l.current=setTimeout(()=>c(!1),1500)}catch{N.error(`Failed to copy`)}},[i,r,e]),f=s?(0,y.jsx)(v,{className:`size-3 text-success`}):(0,y.jsx)(U,{className:`size-3`}),g=typeof o==`function`?o({copied:s,icon:f}):o,_=g&&(0,b.isValidElement)(g)?(0,b.cloneElement)(g,{className:d(g.props.className,n),onClick:u,"aria-label":g.props[`aria-label`]??t}):void 0;return(0,y.jsxs)(h,{children:[(0,y.jsx)(p,{className:_?void 0:d(`relative inline-flex size-6 items-center justify-center rounded-[var(--miravo-radius-tight)] text-muted-foreground hover:bg-muted hover:text-foreground before:absolute before:inset-[-10px] before:content-['']`,n),onClick:_?void 0:u,closeOnClick:!1,"aria-label":t,render:_,children:f}),(0,y.jsx)(m,{side:a,children:s?`Copied!`:t})]})}export{ue as a,ce as c,J as i,N as l,le as n,q as o,K as r,de as s,pe as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{B as n,G as r,H as i,K as a,U as o,V as s,W as c,at as l}from"./vendor-ui-mizMYESS.js";import{_ as u,a as d,i as f,o as ee}from"./api-Bef9FEIU.js";import{a as te,c as ne}from"./get-error-message-DhCjoSSJ.js";import{t as p}from"./proxy-CgM57W61.js";import{t as re}from"./AnimatePresence-CVhkybDC.js";import{a as ie,i as ae,l as m,n as oe,o as se,r as ce,s as le}from"./copy-button-BK3jqKBZ.js";import{n as h,t as g}from"./createLucideIcon-Yddw9eHa.js";import{a as ue,n as _,t as de}from"./input-BCiRHEmc.js";import{_ as fe,a as pe,b as me,c as he,f as ge,g as _e,i as ve,m as ye,p as be,r as xe,x as Se,y as Ce}from"./use-platform-stream-BZTQlkbS.js";import{a as we,c as Te,i as v,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./select-4wihIkEE.js";import{a as je,i as y,n as Me,r as b,t as Ne}from"./platform-targets-BbVxaqAc.js";import{a as x,o as S}from"./tabs-BgPF8MSY.js";import{t as C}from"./download-BPgKzo-_.js";import{n as Pe}from"./checkbox-Xly18Uyz.js";import{t as Fe}from"./badge-tnWgSITj.js";import{t as w}from"./query-keys-Co1J4HmV.js";import{t as T}from"./label-xIWEC6lW.js";var E=g(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),D=g(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),O=g(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),k=l();function A({...e}){return(0,k.jsx)(s,{"data-slot":`sheet`,...e})}function j({...e}){return(0,k.jsx)(i,{"data-slot":`sheet-portal`,...e})}function M({className:e,...t}){return(0,k.jsx)(a,{"data-slot":`sheet-overlay`,className:h(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,e),...t})}function N({className:e,children:t,side:n=`right`,showCloseButton:i=!0,...a}){return(0,k.jsxs)(j,{children:[(0,k.jsx)(M,{}),(0,k.jsxs)(o,{"data-slot":`sheet-content`,"data-side":n,className:h(`fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm 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-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-[calc(100vw-1rem)] data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-[calc(100vw-1rem)] data-[side=right]:max-w-xl data-[side=right]:border-l data-[side=right]:pl-1 data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] 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-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem]`,e),...a,children:[t,i&&(0,k.jsxs)(r,{"data-slot":`sheet-close`,render:(0,k.jsx)(_,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,k.jsx)(ue,{}),(0,k.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function P({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`sheet-header`,className:h(`flex flex-col gap-0.5 p-2`,e),...t})}function F({className:e,...t}){return(0,k.jsx)(n,{"data-slot":`sheet-title`,className:h(`text-base font-medium text-foreground`,e),...t})}function Ie({className:e,...t}){return(0,k.jsx)(c,{"data-slot":`sheet-description`,className:h(`text-sm text-muted-foreground`,e),...t})}var I=e(t(),1),L=[{value:`opcua`,label:`OPC UA`},{value:`mqtt`,label:`MQTT`},{value:`modbus`,label:`Modbus`}];function Le({value:e,onValueChange:t,labelledBy:n}){return(0,k.jsx)(`fieldset`,{"aria-labelledby":n,className:`min-w-0 border-0 p-0`,children:(0,k.jsx)(`div`,{className:`flex gap-1.5`,children:L.map(n=>{let r=e===n.value;return(0,k.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(n.value),className:h(`flex flex-1 items-center justify-center rounded-[var(--miravo-radius-pill)] border py-1.5 text-center transition-[background-color,border-color,color,box-shadow] duration-200`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/80 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,r?`border-primary/45 bg-primary/10 text-primary shadow-[inset_0_1px_0_0_rgba(255,255,255,0.06),0_0_0_1px_color-mix(in_srgb,var(--primary)_25%,transparent)]`:`border-border/75 bg-background/55 text-foreground/82 hover:border-border/90 hover:bg-background/70 hover:text-foreground/92`),children:(0,k.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 font-mono text-[11px] font-medium leading-none tracking-wide`,children:[(0,k.jsx)(x,{className:`size-2.5 shrink-0 -translate-y-px opacity-80`,"aria-hidden":!0}),(0,k.jsx)(`span`,{children:n.label})]})},n.value)})})})}var R=`172.17.0.1`;async function Re(e){let t=await d(`/catalog/models/${encodeURIComponent(e)}/le-dt.json`,u.catalogModelLeDt);return JSON.stringify(t,null,2)}async function ze(e,t={host:R}){let n=u.catalogTemplateLeTemplateJson.query;if(!n)throw Error(`Missing query schema for ${u.catalogTemplateLeTemplateJson.method} ${u.catalogTemplateLeTemplateJson.path}`);let r=n.safeParse(t);if(!r.success)throw Error(`Invalid request for ${u.catalogTemplateLeTemplateJson.method} ${u.catalogTemplateLeTemplateJson.path}: ${r.error.message}`);return f(`/catalog/templates/${encodeURIComponent(e)}/le-template.json${Be(r.data)}`,u.catalogTemplateLeTemplateJson)}function Be(e){let t=new URLSearchParams;return e.host&&t.set(`host`,e.host),e.protocol&&t.set(`protocol`,e.protocol),t.size>0?`?${t.toString()}`:``}function z(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function Ve(e){return`${z(e)}-001`}function He(e,t){return[t,...e?.filter(e=>e.id!==t.id)??[]]}async function Ue(e){let t=await e.create();e.onCreated(t);try{await e.refresh()}catch(t){e.onRefreshFailed(t)}}function We(e){return y.find(t=>t.id===e)?.label??e}function Ge(e){return e===`template`?`Litmus Edge Template`:`Litmus Edge Digital Twin`}function Ke({kind:e,id:t,displayName:n,yamlPath:r,yamlFilename:i,stream:a}){let o=ne(),s=te({queryKey:w.platforms.targets(),queryFn:()=>he()}),c=s.data??[],[l,d]=(0,I.useState)(``),[f,g]=(0,I.useState)(`opcua`),[x,E]=(0,I.useState)(`litmus-edge`),[D,O]=(0,I.useState)(!1),[A,j]=(0,I.useState)(!1),[M,N]=(0,I.useState)(b.id),[P,F]=(0,I.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[Ie,L]=(0,I.useState)(!1),[Be,z]=(0,I.useState)(!1),{testing:Ke,runTest:qe,cancelInFlight:Je}=xe(),[Ye,B]=(0,I.useState)(!1),[V,H]=(0,I.useState)(R),[U,Xe]=(0,I.useState)(!1),[W,G]=(0,I.useState)(!1),Ze=(0,I.useId)(),Qe=a.operation?.operationId;(0,I.useEffect)(()=>{G(!1)},[Qe]),(0,I.useEffect)(()=>{A&&(N(b.id),F({label:``,hostname:``,apiToken:``,sourceHostname:``}),L(!1))},[A]);let K=M===b.id&&P.hostname.trim().length>0&&P.sourceHostname.trim().length>0&&P.apiToken.trim().length>0,q=c.find(e=>e.id===l),$e=(0,I.useCallback)(n=>{O(!1),l&&(e===`model`?a.startApply({targetId:l,model:t,protocol:f,scope:n.scope,deviceName:n.deviceName,ifUnmanaged:n.ifUnmanaged}):a.startApply({targetId:l,template:t,scope:n.scope,ifUnmanaged:n.ifUnmanaged}))},[l,t,e,f,a]),et=(0,I.useCallback)(async()=>{if(M!==b.id){m.error(`${We(M)} target setup is coming soon.`);return}if(!P.label||!P.hostname||!P.sourceHostname){m.error(`Label, hostname, and source host are required.`);return}if(!P.apiToken){m.error(`API token is required for new targets.`);return}z(!0);try{await Ue({create:()=>pe({...P,platformId:M}),onCreated:e=>{o.setQueryData(w.platforms.targets(),t=>He(t,e)),d(e.id),j(!1),m.success(`Target added.`)},refresh:async()=>{let e=await s.refetch();if(e.error)throw e.error},onRefreshFailed:e=>{m.error(`Target added, but target list refresh failed.`,{description:e instanceof Error&&e.message?`${e.message} Reload targets before retrying another add.`:`Reload targets before retrying another add.`})}})}catch(e){m.error(e instanceof Error?e.message:`Failed to add target.`)}finally{z(!1)}},[M,P,s,o]),tt=(0,I.useCallback)(()=>{K&&qe({hostname:P.hostname.trim(),sourceHostname:P.sourceHostname.trim(),apiToken:P.apiToken.trim()})},[K,P,qe]),J=x===`source-yaml`,Y=x===`litmus-edge`||J,X=(0,I.useCallback)(async n=>{if(J){try{let t=await ee(r,e===`model`?u.catalogModelYaml:u.catalogTemplateYaml),n=new Blob([t],{type:`text/yaml`}),a=URL.createObjectURL(n),o=document.createElement(`a`);o.href=a,o.download=i,o.click(),URL.revokeObjectURL(a),m.success(`Exported ${i}`)}catch{m.error(`Failed to export YAML`)}return}if(x===`litmus-edge`)try{if(e===`model`){let e=await Re(t),n=new Blob([e],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t}.le-dt.json`,i.click(),URL.revokeObjectURL(r),m.success(`Exported ${t}.le-dt.json`)}else{let e=n?.templateHost?.trim()??``,r=e.length>0?e:R,i=`${t}.le-template.json`,a=await ze(t,{host:r,protocol:f}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=i,s.click(),URL.revokeObjectURL(o),m.success(`Exported ${i}`)}}catch{m.error(`Failed to export platform format`)}},[x,J,e,t,r,i,f]),nt=(0,I.useCallback)(()=>{if(Y){if(x===`litmus-edge`&&e===`template`){H(R),B(!0);return}X()}},[Y,x,e,X]),rt=(0,I.useCallback)(async()=>{Xe(!0);try{await X({templateHost:V}),B(!1)}finally{Xe(!1)}},[V,X]),Z=a.status===`running`,Q=!!l&&!Z,it=!!a.operation||Z,$=it?ve(a):null;return(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 px-1 py-2`,children:[(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,k.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Deploy`}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(T,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Target`}),(0,k.jsx)(ge,{targets:c,value:l,onValueChange:d,size:`sm`,className:`min-w-0 w-full border-border/65 bg-background/55 text-xs text-foreground`,onAddNew:()=>j(!0)})]}),e===`model`&&c.length>0&&(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(T,{id:Ze,className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Protocol binding`}),(0,k.jsx)(Le,{value:f,onValueChange:g,labelledBy:Ze})]}),c.length>0&&(0,k.jsxs)(`button`,{type:`button`,disabled:!Q,onClick:()=>O(!0),className:h(`group flex w-full min-h-14 min-w-0 items-stretch overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] text-left outline-none`,`transition-[border-color,box-shadow,background-color] duration-200 ease-out`,`focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:pointer-events-none disabled:opacity-55`,Q?[`border-2 border-primary/40 bg-background`,`bg-linear-to-r from-primary/12 via-background to-background`,`shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025)]`,`hover:border-primary/56 hover:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025),0_0_14px_-8px_color-mix(in_srgb,var(--primary)_18%,transparent),0_0_22px_-12px_color-mix(in_srgb,var(--primary)_8%,transparent)]`]:[`border border-dashed border-border/65 bg-muted/15`,`hover:bg-muted/22`]),children:[(0,k.jsxs)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:[(0,k.jsx)(`span`,{className:h(`absolute inset-y-2 -right-px w-px bg-linear-to-b from-transparent via-primary/30 to-transparent opacity-70`,!Q&&`via-border/80`)}),(0,k.jsx)(Pe,{className:h(`relative size-5`,Q?`text-primary`:`text-foreground/75`)})]}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-0.5 overflow-hidden px-3 py-2.5 sm:px-4`,children:[(0,k.jsx)(`span`,{className:h(`font-heading text-[11px] font-semibold uppercase tracking-[0.16em]`,Q?`text-primary`:`text-foreground/78`),children:Q?`Commit deploy`:Z?`Deploy in progress…`:`Awaiting target`}),(0,k.jsx)(`span`,{className:h(`truncate font-mono text-[13px] leading-tight tracking-tight`,Q?`text-foreground`:`text-foreground/80`),children:q?.label??`Select a target above`})]}),(0,k.jsx)(`span`,{className:h(`flex shrink-0 items-center pr-2.5 sm:pr-3`,Q&&`pl-1`),children:(0,k.jsx)(`span`,{className:h(`flex size-9 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border bg-transparent transition-[border-color,color] duration-200`,Q?`border-primary/40 text-primary group-hover:border-primary/55`:`border-border/75 text-foreground/75`),"aria-hidden":!0,children:(0,k.jsx)(je,{className:`size-4`,strokeWidth:2.25})})})]})]})}),(0,k.jsx)(re,{children:it&&$?(0,k.jsx)(ye,{title:$.title,subtitle:$.subtitle,footerAction:Z&&a.operation?.operationId?(0,k.jsx)(_,{variant:`outline`,size:`sm`,disabled:W,"aria-busy":W,className:h(`ml-auto group h-8 gap-1.5 px-3 text-xs`,W?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),onClick:async()=>{G(!0);try{await a.cancel()}catch{G(!1)}},children:W?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(S,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,k.jsx)(p.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ue,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,k.jsx)(p.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})}):(0,k.jsx)(`div`,{className:`ml-auto shrink-0 flex items-center`,children:(0,k.jsx)(_,{type:`button`,variant:`secondary`,size:`xs`,className:`h-7 px-3 text-[10px] font-medium`,onClick:a.reset,children:`Close`})}),onDismiss:a.reset,children:a.operation?(0,k.jsx)(fe,{operation:a.operation,catalogTemplates:[{id:t,name:n}]}):(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(S,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,k.jsx)(`span`,{className:`text-xs text-foreground/88`,children:`Connecting to Litmus Edge…`})]}),(0,k.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/40`,children:(0,k.jsx)(p.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})},`deploy-stream`):null}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border/40 pt-5`,children:[(0,k.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Export`}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(T,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Format`}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,k.jsxs)(Ae,{value:x,onValueChange:e=>{e&&E(e)},children:[(0,k.jsx)(ke,{size:`sm`,className:`h-9! min-h-9 min-w-0 flex-1 border-border/65 bg-background/55 py-0 text-xs text-foreground`,children:(0,k.jsx)(Te,{placeholder:`Select format`,children:t=>{if(t===`source-yaml`)return`Source YAML`;let n=y.find(e=>e.id===t);return n?.id===`litmus-edge`?Ge(e):n?.exportLabel??`Select format`}})}),(0,k.jsxs)(Ee,{children:[(0,k.jsxs)(Oe,{children:[(0,k.jsx)(we,{children:`Platform`}),Ne.map(t=>(0,k.jsx)(v,{value:t.id,children:t.id===`litmus-edge`?Ge(e):t.exportLabel},t.id)),Me.map(e=>(0,k.jsx)(v,{value:e.id,disabled:!0,children:(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.exportLabel,(0,k.jsx)(Fe,{variant:`outline`,className:`px-1 py-0 text-[10px] text-foreground/72`,children:`Coming Soon`})]})},e.id))]}),(0,k.jsx)(De,{}),(0,k.jsxs)(Oe,{children:[(0,k.jsx)(we,{children:`Source`}),(0,k.jsxs)(v,{value:`source-yaml`,children:[`Source YAML`,` `,(0,k.jsx)(`span`,{className:`text-foreground/72`,children:e===`model`?`.twin.yaml`:`.miravo.yaml`})]})]})]})]}),(0,k.jsxs)(_,{variant:`outline`,size:`sm`,className:`h-9 min-h-9 shrink-0 gap-1.5 border-border/70 bg-background/50 px-4 text-xs font-medium text-foreground sm:w-auto`,disabled:!Y,onClick:nt,children:[(0,k.jsx)(C,{className:`size-3.5`}),`Download`]})]})]}),(0,k.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/70`,children:(0,k.jsx)(_e,{format:x,kind:e})})]}),q&&(0,k.jsx)(Ce,{open:D,onOpenChange:O,type:`apply`,label:n,targetLabel:q.label,hostname:q.hostname,sourceHostname:q.sourceHostname,onConfirm:$e,defaultDeviceName:e===`model`?Ve(t):void 0}),(0,k.jsx)(be,{open:A,editing:!1,platformId:M,form:P,showToken:Ie,saving:Be,testing:Ke,canTestConnection:K,onOpenChange:j,onPlatformChange:N,onFormChange:F,onShowTokenChange:L,onSave:()=>void et(),onTestConnection:tt,onCancelInFlight:Je}),(0,k.jsx)(oe,{open:Ye,onOpenChange:e=>{B(e),e||H(R)},children:(0,k.jsxs)(ce,{className:`sm:max-w-md`,children:[(0,k.jsxs)(se,{children:[(0,k.jsx)(le,{children:`Download Litmus Edge Template`}),(0,k.jsx)(ae,{children:me})]}),(0,k.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,k.jsx)(T,{htmlFor:`deploy-export-source-host`,children:Se}),(0,k.jsx)(de,{id:`deploy-export-source-host`,value:V,onChange:e=>H(e.target.value),placeholder:R,autoComplete:`off`,className:`font-mono text-sm`}),(0,k.jsxs)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Use an IP or hostname reachable from Litmus Edge (e.g.`,` `,(0,k.jsx)(`span`,{className:`font-mono`,children:R}),` for Docker bridge).`]})]}),(0,k.jsxs)(ie,{className:`gap-2 sm:gap-0`,children:[(0,k.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>B(!1),disabled:U,children:`Cancel`}),(0,k.jsxs)(_,{type:`button`,className:`gap-1.5`,onClick:()=>void rt(),disabled:U,"aria-busy":U,children:[U?(0,k.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,k.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]})]})})]})}export{P as a,D as c,Ie as i,E as l,A as n,F as o,N as r,O as s,Ke as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./events-CfrhnDG_.js";export{e as EventsPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-mizMYESS.js";import{_ as r,a as i}from"./api-Bef9FEIU.js";import{a,c as ee,n as o,t as s}from"./get-error-message-DhCjoSSJ.js";import{t as c}from"./proxy-CgM57W61.js";import{t as l}from"./AnimatePresence-CVhkybDC.js";import{u as te}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{S as u,n as ne,s as d}from"./input-BCiRHEmc.js";import{r as f}from"./engine-store-BUO-9Dsh.js";import{c as p,i as m,n as re,s as h,t as ie}from"./select-4wihIkEE.js";import{t as ae}from"./route-preload-Dz8gP8hl.js";import{t as oe}from"./use-transition-navigate-C3Y3EWRr.js";import{t as se}from"./badge-tnWgSITj.js";import{t as g}from"./query-keys-Co1J4HmV.js";import{n as ce}from"./transition-types-CMW7IObN.js";import{n as le}from"./auth-screen-backdrop-OrOL41MR.js";import{a as ue,i as de,n as fe,o as pe,r as me,s as he,t as _}from"./combobox-gGNWoksU.js";import{a as v,c as y,i as b,o as x,r as ge,s as _e,t as ve}from"./select-display-items-DUJCelf2.js";var S=e(t(),1),C=n(),ye=1500,w=[`row-1`,`row-2`,`row-3`,`row-4`,`row-5`,`row-6`];function be(e){return e.includes(`triggered`)?`destructive`:e.includes(`cleared`)||e.includes(`created`)?`default`:e.includes(`removed`)||e.includes(`lifecycle`)?`secondary`:(e.includes(`state-changed`),`outline`)}function xe(e){return e.includes(`state-changed`)?`border-info/30 bg-info/20 text-info hover:bg-info/20`:e===`platform:operation`?`border-chart-4/30 bg-chart-4/20 text-chart-4 hover:bg-chart-4/20`:e===`platform:resource`?`border-chart-4/30 bg-chart-4/15 text-chart-4 hover:bg-chart-4/15`:``}function T(e){if(`targetLabel`in e)return typeof e.targetLabel==`string`?e.targetLabel:void 0}function E(e){if(e.type===`platform:operation`){let t=e.operationType===`apply`?`Apply`:`Cleanup`,n=e.applied,r=e.operationType===`apply`?`applied`:`deleted`,i=e.failed>0?`, ${e.failed} failed`:``,a=T(e)??`Unknown target`;return`${t} ${e.templateId} \u2192 ${a} (${n} ${r}${i})`}return e.type===`platform:resource`?`${e.status===`success`?`✓`:`✗`} ${e.action} ${e.resourceType} ${e.resourceName}`:``}function D(e,t){let n=new Date(e);return n.toDateString()===t.toDateString()?n.toLocaleTimeString(d):n.toLocaleString(d,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function O(e){if(`instanceId`in e&&typeof e.instanceId==`string`)return e.instanceId}function k(e){return e.type===`platform:operation`||e.type===`platform:resource`?T(e):O(e)}function A(e){return`fault`in e?u(e.fault):e.type===`platform:operation`||e.type===`platform:resource`?E(e):`from`in e&&`to`in e?`${u(e.from)} \u2192 ${u(e.to)}`:``}function j(e,t,n){let r=new URLSearchParams;return r.set(`limit`,`50`),e!==`all`&&r.set(`type`,e),t&&r.set(`instanceId`,t),n!==null&&r.set(`cursor`,String(n)),`/events?${r.toString()}`}function M(){let e=ee(),[t]=te(),n=t.get(`type`)??`all`,u=t.get(`instanceId`)??``,[d,T]=(0,S.useState)(n),[E,M]=(0,S.useState)(u),[N,Se]=(0,S.useState)(!0),P=f(e=>e.events.length),F=f(e=>e.instances),Ce=oe(),I=a({queryKey:g.events(d,E),queryFn:()=>i(j(d,E,null),r.events),refetchInterval:N?ye:!1,staleTime:5e3}),[we,L]=(0,S.useState)([]),[Te,R]=(0,S.useState)(!1),[Ee,z]=(0,S.useState)(null),B=`${d}::${E}`,V=(0,S.useRef)(B);(0,S.useEffect)(()=>{B!==V.current&&(V.current=B,L([]),z(null),U(!1))},[B]),(0,S.useEffect)(()=>{T(e=>e===n?e:n)},[n]),(0,S.useEffect)(()=>{M(e=>e===u?e:u)},[u]);let[H,U]=(0,S.useState)(()=>(I.data?.events.length??0)>0),W=I.data?[I.data,...we]:[],G=W.flatMap(e=>e.events),K=W[W.length-1],De=K?.hasMore??!1;(0,S.useEffect)(()=>{G.length>0&&!H&&U(!0)},[G.length,H]);let q=(0,S.useRef)(P);(0,S.useEffect)(()=>{P!==q.current&&(q.current=P,N&&e.invalidateQueries({queryKey:g.events(d,E)}))},[P,N,e,d,E]);let[J,Oe]=(0,S.useState)(``),Y=(0,S.useMemo)(()=>J?F.filter(e=>e.id.toLowerCase().includes(J.toLowerCase())):F,[F,J]),X=I.isPending&&!I.data&&!I.isError,Z=N&&!X&&!H&&G.length===0,Q=I.error??Ee,ke=I.isError&&!I.data,$=(0,S.useCallback)(()=>{I.refetch()},[I]),Ae=async()=>{if(K?.nextCursor){R(!0),z(null);try{let e=await i(j(d,E,K.nextCursor),r.events);L(t=>[...t,e])}catch(e){z(e instanceof Error?e:Error(String(e)))}finally{R(!1)}}};if(ke)return(0,C.jsx)(le,{className:`min-h-full`,children:(0,C.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,C.jsx)(`div`,{className:`w-full max-w-md`,children:(0,C.jsx)(o,{message:s(Q,`Failed to fetch events.`),onRetry:$,isRetrying:I.isFetching})})})});let je=new Date;return(0,C.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[Q&&G.length>0?(0,C.jsx)(o,{message:`${s(Q,`Failed to fetch events.`)} Showing cached events.`,onRetry:$,isRetrying:I.isFetching}):null,(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:flex-row lg:items-center lg:justify-between lg:gap-4`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,C.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Event Log`}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Real-time event stream from the engine.`})]}),(0,C.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-2 sm:flex-row sm:flex-nowrap sm:items-center sm:gap-2 lg:w-auto lg:max-w-full`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>Se(e=>!e),className:`flex h-7 shrink-0 items-center self-start overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/40 px-2 py-1 text-xs transition-colors hover:bg-muted sm:self-auto`,children:(0,C.jsx)(l,{mode:`wait`,initial:!1,children:N?(0,C.jsxs)(c.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-success`}),(0,C.jsx)(`span`,{className:`font-medium text-success`,children:`LIVE`})]},`live`):(0,C.jsxs)(c.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Paused`})]},`paused`)})}),(0,C.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,C.jsxs)(_,{value:E||null,onValueChange:e=>{M(e??``)},onInputValueChange:Oe,children:[(0,C.jsx)(me,{placeholder:`All instances`,className:`h-8 w-full min-w-0`,showClear:!!E}),(0,C.jsx)(fe,{children:(0,C.jsxs)(ue,{children:[Y.map(e=>(0,C.jsx)(de,{value:e.id,children:(0,C.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),Y.length===0&&(0,C.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),(0,C.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,C.jsxs)(ie,{value:d,onValueChange:e=>{T(e??`all`)},items:ve,children:[(0,C.jsx)(h,{className:`w-full min-w-0 lg:w-48`,"aria-label":`Event type filter`,children:(0,C.jsx)(p,{placeholder:`Filter by type`})}),(0,C.jsxs)(re,{alignItemWithTrigger:!1,align:`start`,children:[(0,C.jsx)(m,{value:`all`,children:`All events`}),(0,C.jsx)(m,{value:`fault:triggered`,children:`Fault Triggered`}),(0,C.jsx)(m,{value:`fault:cleared`,children:`Fault Cleared`}),(0,C.jsx)(m,{value:`lifecycle:changed`,children:`Lifecycle Changed`}),(0,C.jsx)(m,{value:`instance:created`,children:`Instance Created`}),(0,C.jsx)(m,{value:`instance:removed`,children:`Instance Removed`}),(0,C.jsx)(m,{value:`engine:state-changed`,children:`Engine State`}),(0,C.jsx)(m,{value:`platform:resource`,children:`Platform Resource`}),(0,C.jsx)(m,{value:`platform:operation`,children:`Platform Operation`})]})]})})]})]}),(0,C.jsx)(pe,{className:`min-w-0 py-0`,children:(0,C.jsx)(he,{className:`p-0`,children:(0,C.jsxs)(ge,{children:[(0,C.jsx)(_e,{children:(0,C.jsxs)(y,{children:[(0,C.jsx)(x,{className:`hidden w-12 sm:table-cell`,children:`#`}),(0,C.jsx)(x,{children:`Type`}),(0,C.jsx)(x,{children:`Context`}),(0,C.jsx)(x,{children:`Details`}),(0,C.jsx)(x,{className:`hidden text-right md:table-cell`,children:`Cycle #`}),(0,C.jsx)(x,{className:`hidden text-right sm:table-cell`,children:`Wall Clock`})]})}),(0,C.jsxs)(b,{children:[X&&w.map(e=>(0,C.jsxs)(y,{children:[(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`h-4 w-8 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/40`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-5 w-28 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/40`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-36 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-56 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{className:`hidden md:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-16 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-20 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})})]},e)),G.map(e=>{let t=O(e),n=k(e),r=e.type===`platform:resource`||e.type===`platform:operation`;return(0,C.jsxs)(y,{className:t?`cursor-pointer transition-colors`:``,onMouseEnter:t?()=>ae(`/instance/${t}`):void 0,onClick:t?()=>Ce(`/instance/${t}`,{transitionType:ce}):void 0,children:[(0,C.jsx)(v,{className:`hidden font-mono text-xs text-muted-foreground sm:table-cell`,children:e.id}),(0,C.jsx)(v,{children:(0,C.jsx)(se,{variant:be(e.type),className:`text-xs ${xe(e.type)}`,children:r?e.type===`platform:operation`?`platform:${e.operationType}`:`${e.action}:${e.resourceType}`:e.type})}),(0,C.jsx)(v,{className:`font-mono text-xs`,children:n??`—`}),(0,C.jsx)(v,{className:`max-w-xs truncate font-mono text-xs`,children:A(e)||(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,C.jsx)(v,{className:`hidden text-right font-mono text-xs md:table-cell`,children:e.tick}),(0,C.jsx)(v,{className:`hidden text-right text-xs text-muted-foreground sm:table-cell`,children:D(e.timestamp,je)})]},e.id)}),Z&&w.map(e=>(0,C.jsxs)(y,{children:[(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`h-4 w-8 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-5 w-28 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-36 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-56 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})}),(0,C.jsx)(v,{className:`hidden md:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-16 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})}),(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-20 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})})]},`warmup-${e}`)),!X&&!Z&&G.length===0&&(0,C.jsx)(y,{children:(0,C.jsx)(v,{colSpan:6,className:`py-8 text-center text-muted-foreground`,children:`No events`})})]})]})})}),De&&(0,C.jsx)(`div`,{className:`flex justify-center border-t border-border/40 pt-4`,children:(0,C.jsx)(ne,{variant:`outline`,size:`sm`,onClick:()=>void Ae(),disabled:Te,children:`Load older events`})})]})}export{M as t};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-mizMYESS.js";import{_ as r,a as i}from"./api-Bef9FEIU.js";import{a,c as ee,n as o,t as s}from"./get-error-message-DhCjoSSJ.js";import{t as c}from"./proxy-CgM57W61.js";import{t as l}from"./AnimatePresence-CVhkybDC.js";import{u as te}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{S as u,n as ne,s as d}from"./input-BCiRHEmc.js";import{r as f}from"./engine-store-BUO-9Dsh.js";import{c as p,i as m,n as re,s as h,t as ie}from"./select-4wihIkEE.js";import{t as ae}from"./route-preload-CMl-AryU.js";import{t as oe}from"./use-transition-navigate-CG8tHeYN.js";import{t as se}from"./badge-tnWgSITj.js";import{t as g}from"./query-keys-Co1J4HmV.js";import{n as ce}from"./transition-types-CMW7IObN.js";import{n as le}from"./auth-screen-backdrop-OrOL41MR.js";import{a as ue,i as de,n as fe,o as pe,r as me,s as he,t as _}from"./combobox-gGNWoksU.js";import{a as v,c as y,i as b,o as x,r as ge,s as _e,t as ve}from"./select-display-items-DUJCelf2.js";var S=e(t(),1),C=n(),ye=1500,w=[`row-1`,`row-2`,`row-3`,`row-4`,`row-5`,`row-6`];function be(e){return e.includes(`triggered`)?`destructive`:e.includes(`cleared`)||e.includes(`created`)?`default`:e.includes(`removed`)||e.includes(`lifecycle`)?`secondary`:(e.includes(`state-changed`),`outline`)}function xe(e){return e.includes(`state-changed`)?`border-info/30 bg-info/20 text-info hover:bg-info/20`:e===`platform:operation`?`border-chart-4/30 bg-chart-4/20 text-chart-4 hover:bg-chart-4/20`:e===`platform:resource`?`border-chart-4/30 bg-chart-4/15 text-chart-4 hover:bg-chart-4/15`:``}function T(e){if(`targetLabel`in e)return typeof e.targetLabel==`string`?e.targetLabel:void 0}function E(e){if(e.type===`platform:operation`){let t=e.operationType===`apply`?`Apply`:`Cleanup`,n=e.applied,r=e.operationType===`apply`?`applied`:`deleted`,i=e.failed>0?`, ${e.failed} failed`:``,a=T(e)??`Unknown target`;return`${t} ${e.templateId} \u2192 ${a} (${n} ${r}${i})`}return e.type===`platform:resource`?`${e.status===`success`?`✓`:`✗`} ${e.action} ${e.resourceType} ${e.resourceName}`:``}function D(e,t){let n=new Date(e);return n.toDateString()===t.toDateString()?n.toLocaleTimeString(d):n.toLocaleString(d,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function O(e){if(`instanceId`in e&&typeof e.instanceId==`string`)return e.instanceId}function k(e){return e.type===`platform:operation`||e.type===`platform:resource`?T(e):O(e)}function A(e){return`fault`in e?u(e.fault):e.type===`platform:operation`||e.type===`platform:resource`?E(e):`from`in e&&`to`in e?`${u(e.from)} \u2192 ${u(e.to)}`:``}function j(e,t,n){let r=new URLSearchParams;return r.set(`limit`,`50`),e!==`all`&&r.set(`type`,e),t&&r.set(`instanceId`,t),n!==null&&r.set(`cursor`,String(n)),`/events?${r.toString()}`}function M(){let e=ee(),[t]=te(),n=t.get(`type`)??`all`,u=t.get(`instanceId`)??``,[d,T]=(0,S.useState)(n),[E,M]=(0,S.useState)(u),[N,Se]=(0,S.useState)(!0),P=f(e=>e.events.length),F=f(e=>e.instances),Ce=oe(),I=a({queryKey:g.events(d,E),queryFn:()=>i(j(d,E,null),r.events),refetchInterval:N?ye:!1,staleTime:5e3}),[we,L]=(0,S.useState)([]),[Te,R]=(0,S.useState)(!1),[Ee,z]=(0,S.useState)(null),B=`${d}::${E}`,V=(0,S.useRef)(B);(0,S.useEffect)(()=>{B!==V.current&&(V.current=B,L([]),z(null),U(!1))},[B]),(0,S.useEffect)(()=>{T(e=>e===n?e:n)},[n]),(0,S.useEffect)(()=>{M(e=>e===u?e:u)},[u]);let[H,U]=(0,S.useState)(()=>(I.data?.events.length??0)>0),W=I.data?[I.data,...we]:[],G=W.flatMap(e=>e.events),K=W[W.length-1],De=K?.hasMore??!1;(0,S.useEffect)(()=>{G.length>0&&!H&&U(!0)},[G.length,H]);let q=(0,S.useRef)(P);(0,S.useEffect)(()=>{P!==q.current&&(q.current=P,N&&e.invalidateQueries({queryKey:g.events(d,E)}))},[P,N,e,d,E]);let[J,Oe]=(0,S.useState)(``),Y=(0,S.useMemo)(()=>J?F.filter(e=>e.id.toLowerCase().includes(J.toLowerCase())):F,[F,J]),X=I.isPending&&!I.data&&!I.isError,Z=N&&!X&&!H&&G.length===0,Q=I.error??Ee,ke=I.isError&&!I.data,$=(0,S.useCallback)(()=>{I.refetch()},[I]),Ae=async()=>{if(K?.nextCursor){R(!0),z(null);try{let e=await i(j(d,E,K.nextCursor),r.events);L(t=>[...t,e])}catch(e){z(e instanceof Error?e:Error(String(e)))}finally{R(!1)}}};if(ke)return(0,C.jsx)(le,{className:`min-h-full`,children:(0,C.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,C.jsx)(`div`,{className:`w-full max-w-md`,children:(0,C.jsx)(o,{message:s(Q,`Failed to fetch events.`),onRetry:$,isRetrying:I.isFetching})})})});let je=new Date;return(0,C.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[Q&&G.length>0?(0,C.jsx)(o,{message:`${s(Q,`Failed to fetch events.`)} Showing cached events.`,onRetry:$,isRetrying:I.isFetching}):null,(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:flex-row lg:items-center lg:justify-between lg:gap-4`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,C.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Event Log`}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Real-time event stream from the engine.`})]}),(0,C.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-2 sm:flex-row sm:flex-nowrap sm:items-center sm:gap-2 lg:w-auto lg:max-w-full`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>Se(e=>!e),className:`flex h-7 shrink-0 items-center self-start overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/40 px-2 py-1 text-xs transition-colors hover:bg-muted sm:self-auto`,children:(0,C.jsx)(l,{mode:`wait`,initial:!1,children:N?(0,C.jsxs)(c.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-success`}),(0,C.jsx)(`span`,{className:`font-medium text-success`,children:`LIVE`})]},`live`):(0,C.jsxs)(c.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Paused`})]},`paused`)})}),(0,C.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,C.jsxs)(_,{value:E||null,onValueChange:e=>{M(e??``)},onInputValueChange:Oe,children:[(0,C.jsx)(me,{placeholder:`All instances`,className:`h-8 w-full min-w-0`,showClear:!!E}),(0,C.jsx)(fe,{children:(0,C.jsxs)(ue,{children:[Y.map(e=>(0,C.jsx)(de,{value:e.id,children:(0,C.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),Y.length===0&&(0,C.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),(0,C.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,C.jsxs)(ie,{value:d,onValueChange:e=>{T(e??`all`)},items:ve,children:[(0,C.jsx)(h,{className:`w-full min-w-0 lg:w-48`,"aria-label":`Event type filter`,children:(0,C.jsx)(p,{placeholder:`Filter by type`})}),(0,C.jsxs)(re,{alignItemWithTrigger:!1,align:`start`,children:[(0,C.jsx)(m,{value:`all`,children:`All events`}),(0,C.jsx)(m,{value:`fault:triggered`,children:`Fault Triggered`}),(0,C.jsx)(m,{value:`fault:cleared`,children:`Fault Cleared`}),(0,C.jsx)(m,{value:`lifecycle:changed`,children:`Lifecycle Changed`}),(0,C.jsx)(m,{value:`instance:created`,children:`Instance Created`}),(0,C.jsx)(m,{value:`instance:removed`,children:`Instance Removed`}),(0,C.jsx)(m,{value:`engine:state-changed`,children:`Engine State`}),(0,C.jsx)(m,{value:`platform:resource`,children:`Platform Resource`}),(0,C.jsx)(m,{value:`platform:operation`,children:`Platform Operation`})]})]})})]})]}),(0,C.jsx)(pe,{className:`min-w-0 py-0`,children:(0,C.jsx)(he,{className:`p-0`,children:(0,C.jsxs)(ge,{children:[(0,C.jsx)(_e,{children:(0,C.jsxs)(y,{children:[(0,C.jsx)(x,{className:`hidden w-12 sm:table-cell`,children:`#`}),(0,C.jsx)(x,{children:`Type`}),(0,C.jsx)(x,{children:`Context`}),(0,C.jsx)(x,{children:`Details`}),(0,C.jsx)(x,{className:`hidden text-right md:table-cell`,children:`Cycle #`}),(0,C.jsx)(x,{className:`hidden text-right sm:table-cell`,children:`Wall Clock`})]})}),(0,C.jsxs)(b,{children:[X&&w.map(e=>(0,C.jsxs)(y,{children:[(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`h-4 w-8 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/40`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-5 w-28 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/40`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-36 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-56 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{className:`hidden md:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-16 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-20 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})})]},e)),G.map(e=>{let t=O(e),n=k(e),r=e.type===`platform:resource`||e.type===`platform:operation`;return(0,C.jsxs)(y,{className:t?`cursor-pointer transition-colors`:``,onMouseEnter:t?()=>ae(`/instance/${t}`):void 0,onClick:t?()=>Ce(`/instance/${t}`,{transitionType:ce}):void 0,children:[(0,C.jsx)(v,{className:`hidden font-mono text-xs text-muted-foreground sm:table-cell`,children:e.id}),(0,C.jsx)(v,{children:(0,C.jsx)(se,{variant:be(e.type),className:`text-xs ${xe(e.type)}`,children:r?e.type===`platform:operation`?`platform:${e.operationType}`:`${e.action}:${e.resourceType}`:e.type})}),(0,C.jsx)(v,{className:`font-mono text-xs`,children:n??`—`}),(0,C.jsx)(v,{className:`max-w-xs truncate font-mono text-xs`,children:A(e)||(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,C.jsx)(v,{className:`hidden text-right font-mono text-xs md:table-cell`,children:e.tick}),(0,C.jsx)(v,{className:`hidden text-right text-xs text-muted-foreground sm:table-cell`,children:D(e.timestamp,je)})]},e.id)}),Z&&w.map(e=>(0,C.jsxs)(y,{children:[(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`h-4 w-8 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-5 w-28 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/30`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-36 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})}),(0,C.jsx)(v,{children:(0,C.jsx)(`div`,{className:`h-4 w-56 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})}),(0,C.jsx)(v,{className:`hidden md:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-16 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})}),(0,C.jsx)(v,{className:`hidden sm:table-cell`,children:(0,C.jsx)(`div`,{className:`ml-auto h-4 w-20 animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted/20`})})]},`warmup-${e}`)),!X&&!Z&&G.length===0&&(0,C.jsx)(y,{children:(0,C.jsx)(v,{colSpan:6,className:`py-8 text-center text-muted-foreground`,children:`No events`})})]})]})})}),De&&(0,C.jsx)(`div`,{className:`flex justify-center border-t border-border/40 pt-4`,children:(0,C.jsx)(ne,{variant:`outline`,size:`sm`,onClick:()=>void Ae(),disabled:Te,children:`Load older events`})})]})}export{M as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./fleet-CcdFCWOI.js";export{e as FleetPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-mizMYESS.js";import{_ as r,a as i,g as a}from"./api-Bef9FEIU.js";import{i as o,n as s}from"./dist-jROhexoH.js";import{c,n as l}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{t as u}from"./shallow-ODRQsuRf.js";import{n as d}from"./createLucideIcon-Yddw9eHa.js";import{i as f,n as p,t as m}from"./tooltip-TtanriwA.js";import{S as h,T as g,_,a as v,g as y,h as b,m as ee,p as x,t as te,w as ne,y as re}from"./input-BCiRHEmc.js";import{r as S}from"./engine-store-BUO-9Dsh.js";import{t as C}from"./arrow-right-DrKCU9WM.js";import{t as w}from"./arrow-up-down-CBuv2TSF.js";import{c as T,i as E,n as D,s as O,t as k}from"./select-4wihIkEE.js";import{t as ie}from"./circle-question-mark-Q_q7JZnT.js";import{t as ae}from"./route-preload-Dz8gP8hl.js";import{t as oe}from"./badge-tnWgSITj.js";import{t as A}from"./skeleton-C6iEH-9E.js";import{t as j}from"./query-keys-Co1J4HmV.js";import{n as se}from"./transition-types-CMW7IObN.js";import{a as ce,i as M,n as le,o as ue,r as de,s as fe,t as pe}from"./combobox-gGNWoksU.js";import{a as N,c as P,i as me,n as he,o as F,r as ge,s as I}from"./select-display-items-DUJCelf2.js";var L=e(t(),1);function _e(e){return a.prefetchQuery({queryKey:j.instances.detail(e),queryFn:()=>i(`/instances/${e}`,r.instanceDetail),staleTime:2e3})}var R=n(),z={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},B={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},V={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function H({label:e,pip:t,pulse:n}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,R.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,R.jsx)(`span`,{className:d(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,z[t])}),(0,R.jsx)(`span`,{className:d(`relative inline-flex size-1.5 rounded-full`,z[t])})]}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:d(`size-1.5 shrink-0 rounded-full`,z[t])})),(0,R.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function U({children:e,tone:t=`foreground`,live:n}){return(0,R.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:d(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,B[t]),children:e})}function W({children:e}){return(0,R.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function G(e,t){return e===t?``:t}function ve({statusFilter:e,onStatusFilter:t}){let{instances:n,tps:r,memberValueCount:i,availableAdapters:a,adapterMetrics:o}=S(u(e=>({instances:e.instances,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),s=(0,L.useMemo)(()=>{let e=n.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,t=n.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,r=n.filter(e=>e.isQuarantined).length,i=n.length;return{healthy:e,faulted:t,quarantined:r,total:i,pct:i>0?Math.round(e/i*100):100,activeFaultCount:n.reduce((e,t)=>e+t.activeFaults.length,0),modelCount:new Set(n.map(e=>e.model)).size,affectedCount:new Set(n.filter(e=>e.activeFaults.length>0).map(e=>e.id)).size}},[n]),c=(0,L.useMemo)(()=>{let e=a.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(o.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(o.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>V[e.name]??e.name)}},[a,o]),h=s.activeFaultCount>0,g=h?`destructive`:s.quarantined>0?`warning`:`success`,v=h?`faulted`:`healthy`;return(0,R.jsxs)(`section`,{"aria-label":`Fleet status`,className:`flex w-full min-w-0 max-w-full flex-col divide-y divide-border/40 overflow-hidden rounded-(--miravo-radius-stadium-sm) border sm:flex-row sm:divide-x sm:divide-y-0`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(G(e,v)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":h?`Filter to faulted instances`:`Filter to healthy instances`,className:d(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,(e===`healthy`||e===`faulted`)&&`bg-muted/50`),children:[(0,R.jsx)(H,{label:`Health`,pip:g}),(0,R.jsxs)(U,{tone:h?`destructive`:`success`,children:[s.pct,`%`]}),(0,R.jsx)(W,{children:s.total===0?`No instances`:[`${s.total} instance${s.total===1?``:`s`}`,s.faulted>0&&`${s.faulted} faulted`,s.quarantined>0&&`${s.quarantined} quarantined`,`${s.modelCount} model${s.modelCount===1?``:`s`}`].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted instances`,className:d(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,e===`faulted`&&`bg-muted/50`),children:[(0,R.jsx)(H,{label:`Faults`,pip:h?`destructive`:`success`}),(0,R.jsx)(U,{tone:h?`destructive`:`foreground`,live:!0,children:s.activeFaultCount}),(0,R.jsx)(W,{children:h?`${s.affectedCount} instance${s.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,R.jsxs)(m,{children:[(0,R.jsxs)(f,{render:(0,R.jsx)(l,{to:`/tags`,"aria-label":`Open tag stream`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,R.jsx)(H,{label:`Tags`,pip:`primary`,pulse:!0}),(0,R.jsx)(U,{children:_(i)}),(0,R.jsxs)(W,{children:[(0,R.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,R.jsx)(p,{side:`bottom`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,R.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,R.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[b(i),` tags`]}),(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,R.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),c.enabled.length>0&&(0,R.jsx)(K,{labels:c.labels,totalMessages:c.totalMessages,totalErrors:c.totalErrors,perAdapter:c.enabled.map(e=>({name:V[e.name]??e.name,metrics:o.find(t=>t.name===e.name)?.metrics}))})]})}function K({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,R.jsxs)(m,{children:[(0,R.jsxs)(f,{render:(0,R.jsx)(l,{to:`/control`,"aria-label":`Open control — protocol adapters`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,R.jsx)(H,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,R.jsx)(U,{tone:n>0?`warning`:`foreground`,live:!0,children:_(t)}),(0,R.jsxs)(W,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,R.jsx)(p,{side:`bottom`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,R.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,R.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[b(t),` total`]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[b(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,R.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var q=`Commissioning → instance is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function ye(e,t,n){let r=n===`asc`?1:-1;return[...e].sort((e,n)=>{switch(t){case`id`:return e.id.localeCompare(n.id)*r;case`model`:return e.model.localeCompare(n.model)*r;case`lifecycle`:return e.lifecycleStage.localeCompare(n.lifecycleStage)*r;case`hours`:return(e.operatingHours-n.operatingHours)*r;case`faults`:return(e.activeFaults.length-n.activeFaults.length)*r;case`status`:{let t=e=>e.isQuarantined?2:+(e.activeFaults.length>0);return(t(e)-t(n))*r}default:return 0}})}function be(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function xe(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var J={healthy:{pip:`bg-success`,ring:`border-success/40 text-success`,label:`healthy`,help:`No active faults, not quarantined.`},faulted:{pip:`bg-warning`,ring:`border-warning/40 text-warning`,label:`faulted`,help:`One or more active faults; instance is still running.`},quarantined:{pip:`bg-destructive`,ring:`border-destructive/40 text-destructive`,label:`quarantined`,help:`Instance isolated from production flows pending review.`}};function Se({state:e}){let t=J[e];return(0,R.jsxs)(m,{children:[(0,R.jsxs)(f,{render:(0,R.jsx)(`span`,{className:d(`inline-flex h-5 items-center gap-1.5 rounded-(--miravo-radius-pill) border bg-background/30 px-2 text-[11px] font-medium`,t.ring)}),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:d(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,R.jsx)(`span`,{children:x(t.label)})]}),(0,R.jsx)(p,{side:`top`,children:t.help})]})}function Y({label:e,sortKey:t,subtitle:n,tooltip:r,current:i,direction:a,onSort:o,className:s}){let c=i===t,l=c?a===`asc`?`ascending`:`descending`:`none`,u=(0,R.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 whitespace-nowrap rounded-(--miravo-radius-tight) text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onClick:()=>o(t),children:[(0,R.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,R.jsx)(`span`,{children:e}),n&&(0,R.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,R.jsx)(w,{className:d(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,R.jsx)(F,{className:s,"aria-sort":l,children:r?(0,R.jsxs)(m,{children:[(0,R.jsx)(f,{render:u}),(0,R.jsx)(p,{side:`top`,children:r})]}):u})}function Ce({rows:e=6}){return(0,R.jsx)(R.Fragment,{children:Array.from({length:e}).map((e,t)=>(0,R.jsxs)(P,{"aria-hidden":!0,children:[(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-24`})}),(0,R.jsx)(N,{className:`hidden sm:table-cell`,children:(0,R.jsx)(A,{className:`h-4 w-20`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-16`})}),(0,R.jsx)(N,{className:`hidden md:table-cell`,children:(0,R.jsx)(A,{className:`ml-auto h-4 w-14`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-6`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-5 w-20 rounded-(--miravo-radius-pill)`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-4`})})]},`skel-${t}`))})}function X({title:e,body:t,action:n}){return(0,R.jsx)(P,{children:(0,R.jsx)(N,{colSpan:7,className:`py-10`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,R.jsxs)(`a`,{href:n.href,className:`mt-1 inline-flex items-center gap-1 rounded-(--miravo-radius-tight) text-xs font-medium text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,children:[n.label,(0,R.jsx)(C,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Z(){let{instances:e,connectionState:t}=S(u(e=>({instances:e.instances,connectionState:e.connectionState}))),[n,r]=o(`q`,s.withDefault(``)),[i,a]=o(`model`,s.withDefault(``)),[l,d]=o(`lifecycle`,s.withDefault(``)),[_,b]=o(`status`,s.withDefault(``)),x=be(_)?_:``,[w,A]=(0,L.useState)(`id`),[j,z]=(0,L.useState)(`asc`),B=(0,L.useRef)(null),V=c(),[H,U]=(0,L.useState)(``);(0,L.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),B.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let W=(0,L.useCallback)(e=>{e===w?z(e=>e===`asc`?`desc`:`asc`):(A(e),z(`asc`))},[w]),G=(0,L.useCallback)(e=>{b(e===``?``:e)},[b]),K=(0,L.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.model,(t.get(n.model)??0)+1);return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[e]),J=(0,L.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),Z=(0,L.useMemo)(()=>[{value:`all`,label:`All stages`},...J.map(e=>({value:e,label:h(e)}))],[J]),Q=(0,L.useMemo)(()=>H?K.filter(([e])=>g(e,H)):K,[K,H]),we=(0,L.useMemo)(()=>i?{value:i,label:y(i)}:null,[i]),$=(0,L.useMemo)(()=>{let t=e;return i&&(t=t.filter(e=>e.model===i)),l&&(t=t.filter(e=>e.lifecycleStage===l)),n&&(t=t.filter(e=>ne(e.id,n)||g(e.model,n))),x===`faulted`&&(t=t.filter(e=>e.activeFaults.length>0)),x===`quarantined`&&(t=t.filter(e=>e.isQuarantined)),x===`healthy`&&(t=t.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),ye(t,w,j)},[e,n,x,i,l,w,j]),Te=x!==``||i!==``||l!==``||n!==``,Ee=(0,L.useCallback)(()=>{r(``),b(``),a(``),d(``)},[r,b,a,d]),De=(0,L.useCallback)(e=>{(0,L.startTransition)(()=>{(0,L.addTransitionType)(se),V(`/instance/${e}`)})},[V]),Oe=e.length===0&&t!==`live`,ke=e.length===0&&t===`live`;return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,R.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Fleet Overview`}),(0,R.jsx)(ve,{statusFilter:x,onStatusFilter:G}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(pe,{value:we,onValueChange:e=>void a(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:U,children:[(0,R.jsx)(de,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!i}),(0,R.jsx)(le,{children:(0,R.jsxs)(ce,{children:[Q.map(([e,t])=>(0,R.jsxs)(M,{value:{value:e,label:y(e)},children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:y(e)}),(0,R.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),Q.length===0&&(0,R.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),J.length>1&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsxs)(k,{value:l||`all`,onValueChange:e=>void d(!e||e===`all`?``:e),items:Z,children:[(0,R.jsx)(O,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,R.jsx)(T,{placeholder:`All stages`})}),(0,R.jsxs)(D,{alignItemWithTrigger:!1,align:`start`,children:[(0,R.jsx)(E,{value:`all`,children:`All stages`}),J.map(e=>(0,R.jsx)(E,{value:e,children:h(e)},e))]})]}),(0,R.jsxs)(m,{children:[(0,R.jsx)(f,{render:(0,R.jsx)(`button`,{type:`button`,"aria-label":`About lifecycle stages`,className:`flex size-6 items-center justify-center rounded-(--miravo-radius-tight) text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,R.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}),(0,R.jsx)(p,{side:`top`,children:q})]})]}),(0,R.jsxs)(k,{value:x||`all`,onValueChange:e=>void b(!e||e===`all`?``:e),items:he,children:[(0,R.jsx)(O,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,R.jsx)(T,{placeholder:`All status`})}),(0,R.jsxs)(D,{alignItemWithTrigger:!1,align:`start`,children:[(0,R.jsx)(E,{value:`all`,children:`All status`}),(0,R.jsx)(E,{value:`healthy`,children:`Healthy`}),(0,R.jsx)(E,{value:`faulted`,children:`Faulted`}),(0,R.jsx)(E,{value:`quarantined`,children:`Quarantined`})]})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(te,{ref:B,placeholder:`Search...`,value:n,onChange:e=>void r(e.target.value),"aria-label":`Search instances by id or model`,className:`h-8 w-40 pr-7 text-xs`}),!n&&(0,R.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-(--miravo-radius-tight) border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),Te&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:Ee,className:`flex items-center gap-1 rounded-(--miravo-radius-tight) px-1 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,R.jsx)(v,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,R.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[$.length,` of `,e.length]})]})]}),(0,R.jsx)(ue,{className:`py-0`,children:(0,R.jsx)(fe,{className:`p-0 [&_thead_tr_th:last-child]:w-6 [&_thead_tr_th:last-child]:px-1 sm:[&_thead_tr_th:last-child]:w-8 sm:[&_thead_tr_th:last-child]:px-2 [&_tbody_tr_td:last-child]:px-1 sm:[&_tbody_tr_td:last-child]:px-2`,children:(0,R.jsxs)(ge,{children:[(0,R.jsx)(I,{children:(0,R.jsxs)(P,{children:[(0,R.jsx)(Y,{label:`Instance`,sortKey:`id`,current:w,direction:j,onSort:W}),(0,R.jsx)(Y,{label:`Model`,sortKey:`model`,current:w,direction:j,onSort:W,className:`hidden sm:table-cell`}),(0,R.jsx)(Y,{label:`Lifecycle`,sortKey:`lifecycle`,current:w,direction:j,onSort:W,tooltip:q}),(0,R.jsx)(Y,{label:`Operating age`,sortKey:`hours`,current:w,direction:j,onSort:W,tooltip:`Cumulative operating hours since the instance started running.`,className:`hidden text-right md:table-cell`}),(0,R.jsx)(Y,{label:`Faults`,sortKey:`faults`,current:w,direction:j,onSort:W,tooltip:`Count of active (uncleared) faults on this instance.`}),(0,R.jsx)(Y,{label:`Status`,sortKey:`status`,current:w,direction:j,onSort:W}),(0,R.jsx)(F,{children:(0,R.jsx)(`span`,{className:`sr-only`,children:`Navigate to instance`})})]})}),(0,R.jsx)(me,{children:Oe?(0,R.jsx)(Ce,{rows:6}):ke?(0,R.jsx)(X,{title:`No running instances`,body:`Start an environment on a platform to deploy simulated instances into the fleet.`,action:{label:`Open Platforms`,href:`/platforms`}}):$.length===0?(0,R.jsx)(X,{title:`No matches`,body:`Adjust filters or clear them to see the full fleet.`}):$.map(e=>{let t=xe(e);return(0,R.jsxs)(P,{className:`group cursor-pointer transition-colors`,onMouseEnter:()=>{ae(`/instance/${e.id}`),_e(e.id)},onClick:()=>De(e.id),children:[(0,R.jsx)(N,{className:`text-sm`,children:(0,R.jsx)(L.ViewTransition,{name:`instance-${e.id}`,default:`none`,children:(0,R.jsx)(`span`,{children:ee(e.id)})})}),(0,R.jsx)(N,{className:`hidden text-sm sm:table-cell`,children:y(e.model)}),(0,R.jsx)(N,{children:(0,R.jsx)(oe,{variant:`secondary`,className:`text-xs`,children:h(e.lifecycleStage)})}),(0,R.jsx)(N,{className:`hidden font-mono text-sm md:table-cell`,children:re(e.operatingHours)}),(0,R.jsx)(N,{children:e.activeFaults.length>0?(0,R.jsxs)(m,{children:[(0,R.jsx)(f,{render:(0,R.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-(--miravo-radius-pill) bg-destructive/15 px-1.5 font-mono text-[11px] font-semibold tabular-nums text-destructive`}),children:e.activeFaults.length}),(0,R.jsxs)(p,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,R.jsx)(N,{children:(0,R.jsx)(Se,{state:t})}),(0,R.jsx)(N,{children:(0,R.jsx)(C,{className:`size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0})})]},e.id)})})]})})})]})}export{Z as t};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-mizMYESS.js";import{_ as r,a as i,g as a}from"./api-Bef9FEIU.js";import{i as o,n as s}from"./dist-jROhexoH.js";import{c,n as l}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{t as u}from"./shallow-ODRQsuRf.js";import{n as d}from"./createLucideIcon-Yddw9eHa.js";import{i as f,n as p,t as m}from"./tooltip-TtanriwA.js";import{S as h,T as g,_,a as v,g as y,h as b,m as ee,p as x,t as te,w as ne,y as re}from"./input-BCiRHEmc.js";import{r as S}from"./engine-store-BUO-9Dsh.js";import{t as C}from"./arrow-right-DrKCU9WM.js";import{t as w}from"./arrow-up-down-CBuv2TSF.js";import{c as T,i as E,n as D,s as O,t as k}from"./select-4wihIkEE.js";import{t as ie}from"./circle-question-mark-Q_q7JZnT.js";import{t as ae}from"./route-preload-CMl-AryU.js";import{t as oe}from"./badge-tnWgSITj.js";import{t as A}from"./skeleton-C6iEH-9E.js";import{t as j}from"./query-keys-Co1J4HmV.js";import{n as se}from"./transition-types-CMW7IObN.js";import{a as ce,i as M,n as le,o as ue,r as de,s as fe,t as pe}from"./combobox-gGNWoksU.js";import{a as N,c as P,i as me,n as he,o as F,r as ge,s as I}from"./select-display-items-DUJCelf2.js";var L=e(t(),1);function _e(e){return a.prefetchQuery({queryKey:j.instances.detail(e),queryFn:()=>i(`/instances/${e}`,r.instanceDetail),staleTime:2e3})}var R=n(),z={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},B={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},V={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function H({label:e,pip:t,pulse:n}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,R.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,R.jsx)(`span`,{className:d(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,z[t])}),(0,R.jsx)(`span`,{className:d(`relative inline-flex size-1.5 rounded-full`,z[t])})]}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:d(`size-1.5 shrink-0 rounded-full`,z[t])})),(0,R.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function U({children:e,tone:t=`foreground`,live:n}){return(0,R.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:d(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,B[t]),children:e})}function W({children:e}){return(0,R.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function G(e,t){return e===t?``:t}function ve({statusFilter:e,onStatusFilter:t}){let{instances:n,tps:r,memberValueCount:i,availableAdapters:a,adapterMetrics:o}=S(u(e=>({instances:e.instances,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),s=(0,L.useMemo)(()=>{let e=n.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,t=n.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,r=n.filter(e=>e.isQuarantined).length,i=n.length;return{healthy:e,faulted:t,quarantined:r,total:i,pct:i>0?Math.round(e/i*100):100,activeFaultCount:n.reduce((e,t)=>e+t.activeFaults.length,0),modelCount:new Set(n.map(e=>e.model)).size,affectedCount:new Set(n.filter(e=>e.activeFaults.length>0).map(e=>e.id)).size}},[n]),c=(0,L.useMemo)(()=>{let e=a.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(o.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(o.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>V[e.name]??e.name)}},[a,o]),h=s.activeFaultCount>0,g=h?`destructive`:s.quarantined>0?`warning`:`success`,v=h?`faulted`:`healthy`;return(0,R.jsxs)(`section`,{"aria-label":`Fleet status`,className:`flex w-full min-w-0 max-w-full flex-col divide-y divide-border/40 overflow-hidden rounded-(--miravo-radius-stadium-sm) border sm:flex-row sm:divide-x sm:divide-y-0`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(G(e,v)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":h?`Filter to faulted instances`:`Filter to healthy instances`,className:d(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,(e===`healthy`||e===`faulted`)&&`bg-muted/50`),children:[(0,R.jsx)(H,{label:`Health`,pip:g}),(0,R.jsxs)(U,{tone:h?`destructive`:`success`,children:[s.pct,`%`]}),(0,R.jsx)(W,{children:s.total===0?`No instances`:[`${s.total} instance${s.total===1?``:`s`}`,s.faulted>0&&`${s.faulted} faulted`,s.quarantined>0&&`${s.quarantined} quarantined`,`${s.modelCount} model${s.modelCount===1?``:`s`}`].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted instances`,className:d(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,e===`faulted`&&`bg-muted/50`),children:[(0,R.jsx)(H,{label:`Faults`,pip:h?`destructive`:`success`}),(0,R.jsx)(U,{tone:h?`destructive`:`foreground`,live:!0,children:s.activeFaultCount}),(0,R.jsx)(W,{children:h?`${s.affectedCount} instance${s.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,R.jsxs)(m,{children:[(0,R.jsxs)(f,{render:(0,R.jsx)(l,{to:`/tags`,"aria-label":`Open tag stream`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,R.jsx)(H,{label:`Tags`,pip:`primary`,pulse:!0}),(0,R.jsx)(U,{children:_(i)}),(0,R.jsxs)(W,{children:[(0,R.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,R.jsx)(p,{side:`bottom`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,R.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,R.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[b(i),` tags`]}),(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,R.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),c.enabled.length>0&&(0,R.jsx)(K,{labels:c.labels,totalMessages:c.totalMessages,totalErrors:c.totalErrors,perAdapter:c.enabled.map(e=>({name:V[e.name]??e.name,metrics:o.find(t=>t.name===e.name)?.metrics}))})]})}function K({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,R.jsxs)(m,{children:[(0,R.jsxs)(f,{render:(0,R.jsx)(l,{to:`/control`,"aria-label":`Open control — protocol adapters`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,R.jsx)(H,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,R.jsx)(U,{tone:n>0?`warning`:`foreground`,live:!0,children:_(t)}),(0,R.jsxs)(W,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,R.jsx)(p,{side:`bottom`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,R.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,R.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[b(t),` total`]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[b(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,R.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var q=`Commissioning → instance is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function ye(e,t,n){let r=n===`asc`?1:-1;return[...e].sort((e,n)=>{switch(t){case`id`:return e.id.localeCompare(n.id)*r;case`model`:return e.model.localeCompare(n.model)*r;case`lifecycle`:return e.lifecycleStage.localeCompare(n.lifecycleStage)*r;case`hours`:return(e.operatingHours-n.operatingHours)*r;case`faults`:return(e.activeFaults.length-n.activeFaults.length)*r;case`status`:{let t=e=>e.isQuarantined?2:+(e.activeFaults.length>0);return(t(e)-t(n))*r}default:return 0}})}function be(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function xe(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var J={healthy:{pip:`bg-success`,ring:`border-success/40 text-success`,label:`healthy`,help:`No active faults, not quarantined.`},faulted:{pip:`bg-warning`,ring:`border-warning/40 text-warning`,label:`faulted`,help:`One or more active faults; instance is still running.`},quarantined:{pip:`bg-destructive`,ring:`border-destructive/40 text-destructive`,label:`quarantined`,help:`Instance isolated from production flows pending review.`}};function Se({state:e}){let t=J[e];return(0,R.jsxs)(m,{children:[(0,R.jsxs)(f,{render:(0,R.jsx)(`span`,{className:d(`inline-flex h-5 items-center gap-1.5 rounded-(--miravo-radius-pill) border bg-background/30 px-2 text-[11px] font-medium`,t.ring)}),children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:d(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,R.jsx)(`span`,{children:x(t.label)})]}),(0,R.jsx)(p,{side:`top`,children:t.help})]})}function Y({label:e,sortKey:t,subtitle:n,tooltip:r,current:i,direction:a,onSort:o,className:s}){let c=i===t,l=c?a===`asc`?`ascending`:`descending`:`none`,u=(0,R.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 whitespace-nowrap rounded-(--miravo-radius-tight) text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onClick:()=>o(t),children:[(0,R.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,R.jsx)(`span`,{children:e}),n&&(0,R.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,R.jsx)(w,{className:d(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,R.jsx)(F,{className:s,"aria-sort":l,children:r?(0,R.jsxs)(m,{children:[(0,R.jsx)(f,{render:u}),(0,R.jsx)(p,{side:`top`,children:r})]}):u})}function Ce({rows:e=6}){return(0,R.jsx)(R.Fragment,{children:Array.from({length:e}).map((e,t)=>(0,R.jsxs)(P,{"aria-hidden":!0,children:[(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-24`})}),(0,R.jsx)(N,{className:`hidden sm:table-cell`,children:(0,R.jsx)(A,{className:`h-4 w-20`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-16`})}),(0,R.jsx)(N,{className:`hidden md:table-cell`,children:(0,R.jsx)(A,{className:`ml-auto h-4 w-14`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-6`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-5 w-20 rounded-(--miravo-radius-pill)`})}),(0,R.jsx)(N,{children:(0,R.jsx)(A,{className:`h-4 w-4`})})]},`skel-${t}`))})}function X({title:e,body:t,action:n}){return(0,R.jsx)(P,{children:(0,R.jsx)(N,{colSpan:7,className:`py-10`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,R.jsxs)(`a`,{href:n.href,className:`mt-1 inline-flex items-center gap-1 rounded-(--miravo-radius-tight) text-xs font-medium text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,children:[n.label,(0,R.jsx)(C,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Z(){let{instances:e,connectionState:t}=S(u(e=>({instances:e.instances,connectionState:e.connectionState}))),[n,r]=o(`q`,s.withDefault(``)),[i,a]=o(`model`,s.withDefault(``)),[l,d]=o(`lifecycle`,s.withDefault(``)),[_,b]=o(`status`,s.withDefault(``)),x=be(_)?_:``,[w,A]=(0,L.useState)(`id`),[j,z]=(0,L.useState)(`asc`),B=(0,L.useRef)(null),V=c(),[H,U]=(0,L.useState)(``);(0,L.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),B.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let W=(0,L.useCallback)(e=>{e===w?z(e=>e===`asc`?`desc`:`asc`):(A(e),z(`asc`))},[w]),G=(0,L.useCallback)(e=>{b(e===``?``:e)},[b]),K=(0,L.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.model,(t.get(n.model)??0)+1);return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[e]),J=(0,L.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),Z=(0,L.useMemo)(()=>[{value:`all`,label:`All stages`},...J.map(e=>({value:e,label:h(e)}))],[J]),Q=(0,L.useMemo)(()=>H?K.filter(([e])=>g(e,H)):K,[K,H]),we=(0,L.useMemo)(()=>i?{value:i,label:y(i)}:null,[i]),$=(0,L.useMemo)(()=>{let t=e;return i&&(t=t.filter(e=>e.model===i)),l&&(t=t.filter(e=>e.lifecycleStage===l)),n&&(t=t.filter(e=>ne(e.id,n)||g(e.model,n))),x===`faulted`&&(t=t.filter(e=>e.activeFaults.length>0)),x===`quarantined`&&(t=t.filter(e=>e.isQuarantined)),x===`healthy`&&(t=t.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),ye(t,w,j)},[e,n,x,i,l,w,j]),Te=x!==``||i!==``||l!==``||n!==``,Ee=(0,L.useCallback)(()=>{r(``),b(``),a(``),d(``)},[r,b,a,d]),De=(0,L.useCallback)(e=>{(0,L.startTransition)(()=>{(0,L.addTransitionType)(se),V(`/instance/${e}`)})},[V]),Oe=e.length===0&&t!==`live`,ke=e.length===0&&t===`live`;return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,R.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Fleet Overview`}),(0,R.jsx)(ve,{statusFilter:x,onStatusFilter:G}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(pe,{value:we,onValueChange:e=>void a(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:U,children:[(0,R.jsx)(de,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!i}),(0,R.jsx)(le,{children:(0,R.jsxs)(ce,{children:[Q.map(([e,t])=>(0,R.jsxs)(M,{value:{value:e,label:y(e)},children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:y(e)}),(0,R.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),Q.length===0&&(0,R.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),J.length>1&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsxs)(k,{value:l||`all`,onValueChange:e=>void d(!e||e===`all`?``:e),items:Z,children:[(0,R.jsx)(O,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,R.jsx)(T,{placeholder:`All stages`})}),(0,R.jsxs)(D,{alignItemWithTrigger:!1,align:`start`,children:[(0,R.jsx)(E,{value:`all`,children:`All stages`}),J.map(e=>(0,R.jsx)(E,{value:e,children:h(e)},e))]})]}),(0,R.jsxs)(m,{children:[(0,R.jsx)(f,{render:(0,R.jsx)(`button`,{type:`button`,"aria-label":`About lifecycle stages`,className:`flex size-6 items-center justify-center rounded-(--miravo-radius-tight) text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,R.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}),(0,R.jsx)(p,{side:`top`,children:q})]})]}),(0,R.jsxs)(k,{value:x||`all`,onValueChange:e=>void b(!e||e===`all`?``:e),items:he,children:[(0,R.jsx)(O,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,R.jsx)(T,{placeholder:`All status`})}),(0,R.jsxs)(D,{alignItemWithTrigger:!1,align:`start`,children:[(0,R.jsx)(E,{value:`all`,children:`All status`}),(0,R.jsx)(E,{value:`healthy`,children:`Healthy`}),(0,R.jsx)(E,{value:`faulted`,children:`Faulted`}),(0,R.jsx)(E,{value:`quarantined`,children:`Quarantined`})]})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(te,{ref:B,placeholder:`Search...`,value:n,onChange:e=>void r(e.target.value),"aria-label":`Search instances by id or model`,className:`h-8 w-40 pr-7 text-xs`}),!n&&(0,R.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-(--miravo-radius-tight) border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),Te&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:Ee,className:`flex items-center gap-1 rounded-(--miravo-radius-tight) px-1 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,R.jsx)(v,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,R.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[$.length,` of `,e.length]})]})]}),(0,R.jsx)(ue,{className:`py-0`,children:(0,R.jsx)(fe,{className:`p-0 [&_thead_tr_th:last-child]:w-6 [&_thead_tr_th:last-child]:px-1 sm:[&_thead_tr_th:last-child]:w-8 sm:[&_thead_tr_th:last-child]:px-2 [&_tbody_tr_td:last-child]:px-1 sm:[&_tbody_tr_td:last-child]:px-2`,children:(0,R.jsxs)(ge,{children:[(0,R.jsx)(I,{children:(0,R.jsxs)(P,{children:[(0,R.jsx)(Y,{label:`Instance`,sortKey:`id`,current:w,direction:j,onSort:W}),(0,R.jsx)(Y,{label:`Model`,sortKey:`model`,current:w,direction:j,onSort:W,className:`hidden sm:table-cell`}),(0,R.jsx)(Y,{label:`Lifecycle`,sortKey:`lifecycle`,current:w,direction:j,onSort:W,tooltip:q}),(0,R.jsx)(Y,{label:`Operating age`,sortKey:`hours`,current:w,direction:j,onSort:W,tooltip:`Cumulative operating hours since the instance started running.`,className:`hidden text-right md:table-cell`}),(0,R.jsx)(Y,{label:`Faults`,sortKey:`faults`,current:w,direction:j,onSort:W,tooltip:`Count of active (uncleared) faults on this instance.`}),(0,R.jsx)(Y,{label:`Status`,sortKey:`status`,current:w,direction:j,onSort:W}),(0,R.jsx)(F,{children:(0,R.jsx)(`span`,{className:`sr-only`,children:`Navigate to instance`})})]})}),(0,R.jsx)(me,{children:Oe?(0,R.jsx)(Ce,{rows:6}):ke?(0,R.jsx)(X,{title:`No running instances`,body:`Start an environment on a platform to deploy simulated instances into the fleet.`,action:{label:`Open Platforms`,href:`/platforms`}}):$.length===0?(0,R.jsx)(X,{title:`No matches`,body:`Adjust filters or clear them to see the full fleet.`}):$.map(e=>{let t=xe(e);return(0,R.jsxs)(P,{className:`group cursor-pointer transition-colors`,onMouseEnter:()=>{ae(`/instance/${e.id}`),_e(e.id)},onClick:()=>De(e.id),children:[(0,R.jsx)(N,{className:`text-sm`,children:(0,R.jsx)(L.ViewTransition,{name:`instance-${e.id}`,default:`none`,children:(0,R.jsx)(`span`,{children:ee(e.id)})})}),(0,R.jsx)(N,{className:`hidden text-sm sm:table-cell`,children:y(e.model)}),(0,R.jsx)(N,{children:(0,R.jsx)(oe,{variant:`secondary`,className:`text-xs`,children:h(e.lifecycleStage)})}),(0,R.jsx)(N,{className:`hidden font-mono text-sm md:table-cell`,children:re(e.operatingHours)}),(0,R.jsx)(N,{children:e.activeFaults.length>0?(0,R.jsxs)(m,{children:[(0,R.jsx)(f,{render:(0,R.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-(--miravo-radius-pill) bg-destructive/15 px-1.5 font-mono text-[11px] font-semibold tabular-nums text-destructive`}),children:e.activeFaults.length}),(0,R.jsxs)(p,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,R.jsx)(N,{children:(0,R.jsx)(Se,{state:t})}),(0,R.jsx)(N,{children:(0,R.jsx)(C,{className:`size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0})})]},e.id)})})]})})})]})}export{Z as t};