@miravo/cli-linux-arm64-musl 0.7.9 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/console-dist/assets/{api-Bf6pFRhP.js → api-5BZroqlO.js} +1 -1
  2. package/console-dist/assets/api-BwgmLQCC.js +1 -0
  3. package/console-dist/assets/{catalog-DqOwOydE.js → catalog-B477tO5a.js} +1 -1
  4. package/console-dist/assets/catalog-BRYmHbXV.js +1 -0
  5. package/console-dist/assets/{catalog-source-W3TI0pmx.js → catalog-source-DL6GXE84.js} +1 -1
  6. package/console-dist/assets/control-Dc6xLiUf.js +1 -0
  7. package/console-dist/assets/control-HqgjVMLG.js +1 -0
  8. package/console-dist/assets/events-BvwhACji.js +1 -0
  9. package/console-dist/assets/{events-BTqDmbVu.js → events-przfMV9x.js} +1 -1
  10. package/console-dist/assets/{fleet-C20wXA8E.js → fleet-C2Ipwzu5.js} +1 -1
  11. package/console-dist/assets/fleet-D3Y6h1O_.js +1 -0
  12. package/console-dist/assets/{get-error-message-yQcVJ-Ja.js → get-error-message-CFs0lSQP.js} +1 -1
  13. package/console-dist/assets/index-AfBFCD9D.js +12 -0
  14. package/console-dist/assets/{instance-detail-STqgvf7K.js → instance-detail-CQ6RO9hI.js} +1 -1
  15. package/console-dist/assets/{login-BJaFYYGh.js → login-CtfweHfy.js} +1 -1
  16. package/console-dist/assets/models-C57soXUz.js +1 -0
  17. package/console-dist/assets/models-CX3jQBRk.js +1 -0
  18. package/console-dist/assets/platforms-DMUEIKyH.js +1 -0
  19. package/console-dist/assets/{platforms-DbzXekvY.js → platforms-nMtu3Mg5.js} +1 -1
  20. package/console-dist/assets/{query-fetch-error-BqiDQT2r.js → query-fetch-error-2yqCNP9X.js} +1 -1
  21. package/console-dist/assets/spawn-protocol-scope-picker-DUXJ8giB.js +1 -0
  22. package/console-dist/assets/tabs-D64chVAn.js +1 -0
  23. package/console-dist/assets/tags-BbNGPS4O.js +1 -0
  24. package/console-dist/assets/{tags-DAJ-rQYR.js → tags-Cl6Nj2-E.js} +2 -2
  25. package/console-dist/assets/{transition-nav-link-Bf02_OAE.js → transition-nav-link-CDSeWWsP.js} +1 -1
  26. package/console-dist/assets/{use-engine-command-mutation-RvjgD8uv.js → use-engine-command-mutation-CIly3RgV.js} +1 -1
  27. package/console-dist/assets/{use-platform-stream-BVf5gGJM.js → use-platform-stream-BBDJCrNY.js} +2 -2
  28. package/console-dist/assets/use-transition-navigate-Bxh77tVE.js +2 -0
  29. package/console-dist/assets/validation-Bt4EQDja.js +1 -0
  30. package/console-dist/index.html +21 -20
  31. package/miravo +0 -0
  32. package/package.json +1 -1
  33. package/console-dist/assets/api-wyOH3ffs.js +0 -1
  34. package/console-dist/assets/catalog-CTpesUtM.js +0 -1
  35. package/console-dist/assets/control-BLUTBbet.js +0 -1
  36. package/console-dist/assets/control-UqwbqlvO.js +0 -1
  37. package/console-dist/assets/events-Z0rGFYfs.js +0 -1
  38. package/console-dist/assets/fleet-BNba_zGa.js +0 -1
  39. package/console-dist/assets/index-B_Xu4s7C.js +0 -12
  40. package/console-dist/assets/models-2VnPNXiF.js +0 -1
  41. package/console-dist/assets/models-DhRo1Ytd.js +0 -1
  42. package/console-dist/assets/platforms-DrKstIAm.js +0 -1
  43. package/console-dist/assets/tabs-CCixnxMe.js +0 -1
  44. package/console-dist/assets/tags-CNJIRrPw.js +0 -1
  45. package/console-dist/assets/use-transition-navigate-DtyJz2Z1.js +0 -2
  46. package/console-dist/assets/validation-_QtRYqIT.js +0 -1
  47. /package/console-dist/assets/{not-found-BbQLiHmm.js → not-found-Dw4OTZHH.js} +0 -0
  48. /package/console-dist/assets/{select-display-items-y2L7MHmk.js → select-display-items-Bqb6Sbg6.js} +0 -0
  49. /package/console-dist/assets/{vendor-table-SVvT6QrW.js → vendor-table-BAHQgdwg.js} +0 -0
@@ -0,0 +1 @@
1
+ import{r as e}from"./api-5BZroqlO.js";export{e as changePassword};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{A as r,M as i,S as a,o,v as s}from"./api-Bf6pFRhP.js";import{i as c,t as l}from"./query-fetch-error-BqiDQT2r.js";import{t as u}from"./proxy-Be4WzmcS.js";import{t as d}from"./AnimatePresence-CPmH1DMY.js";import{a as f,i as p,l as m,n as h,o as ee,r as g,s as _,t as v}from"./copy-button-DnGsXbVV.js";import{C as y,S as b,c as te,d as x,g as S,l as C}from"./format-B9CcV2dj.js";import{n as w,t as T}from"./utils-XFKvwlFT.js";import{M as E,P as D,j as ne,n as O,t as k}from"./use-platform-stream-BVf5gGJM.js";import{t as A}from"./catalog-template-icons-3S8RvUxD.js";import{l as j}from"./select-CMOnuEoT.js";import{a as M}from"./platform-targets-BIQ1lKOg.js";import{i as N,n as P,r as F,t as I}from"./tabs-CCixnxMe.js";import{r as re}from"./checkbox-C84IyqEB.js";import{a as L,c as R,d as z,i as B,l as V,n as H,o as ie,r as ae,s as oe,t as se,u as ce}from"./catalog-source-W3TI0pmx.js";import{c as U,i as W,n as G,r as K,t as le}from"./use-engine-command-mutation-RvjgD8uv.js";import{t as q}from"./badge-i00PiRCo.js";import{t as ue}from"./label-DTHSKF2S.js";import{n as J}from"./get-error-message-yQcVJ-Ja.js";var de=w(`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`}]]),fe=w(`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`}]]),pe=w(`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`}]]),Y=e(t(),1),X=n(),Z=20,me=14,Q=`flex w-3.5 shrink-0 items-center justify-center`;function he({instance:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,X.jsxs)(X.Fragment,{children:[l.map(a=>(0,X.jsx)(ge,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name)),!a&&u>0&&(0,X.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+Z}px`},onClick:()=>o(!0),children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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+Z}px`},onClick:()=>c(e=>!e),children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0,children:s?(0,X.jsx)(j,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,X.jsx)(M,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,X.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,X.jsx)(ge,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name))]})]})}function ge({member:e,depth:t,area:n,line:r,instanceId:i,detail:a}){let o=e.kind===`property`,s=t*14+Z+(o?me:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,X.jsx)(v,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:()=>(0,X.jsxs)(`button`,{type:`button`,className:T(`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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0,children:(0,X.jsx)(`span`,{className:T(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,X.jsx)(`span`,{title:e.name,className:T(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:te(e.name)}),o&&(0,X.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,X.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,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,X.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?j:M,f=i===`area`?`text-primary`:`text-foreground`;return(0,X.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,X.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,X.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{title:n??void 0,className:T(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,X.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,X.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,X.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 _e(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function ve(e,t,n){let r=[];for(let i of e){let e=_e(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 ye({detail:e}){let[t,n]=(0,Y.useState)(new Set),r=(0,Y.useRef)(null),i=(0,Y.useMemo)(()=>[...new Set(e.models)],[e.models]),u=i.join(`,`),d=c({queryKey:s.catalog.modelSchemasBatch(u),queryFn:async()=>Promise.all(i.map(e=>o(`/catalog/models/${e}`,a.catalogModelDetail)))}),f=d.isPending&&!d.data,p=(0,Y.useMemo)(()=>{let e=new Map;if(!d.data)return e;for(let[t,n]of d.data.entries())e.set(i[t],n);return e},[d.data,i]),m=(0,Y.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}`,ve(e.twins,p,t));return n},[e.topology,p]);(0,Y.useEffect)(()=>{if(f)return;let t=e.name;if(r.current===t)return;let i=new Set;for(let t of e.topology){i.add(`area:${t.name}`);for(let e of t.lines)i.add(`line:${t.name}/${e.name}`)}outer:for(let t of e.topology)for(let e of t.lines){let n=(m.get(`${t.name}/${e.name}`)??[])[0];if(n){i.add(`inst:${t.name}/${e.name}/${n.id}`);break outer}}n(i),r.current=t},[f,e.name,e.topology,m]);let h=(0,Y.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return f?null:d.isError&&!d.data?(0,X.jsx)(l,{message:J(d.error,`Failed to load model schemas.`),onRetry:()=>void d.refetch(),isRetrying:d.isFetching&&!d.isPending}):(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:0,label:S(n.name),labelTitle:n.name,tag:`AREA`,tagKind:`area`,expanded:i,onToggle:()=>h(r),hasChildren:!0}),i&&n.lines.map(r=>{let i=`line:${n.name}/${r.name}`,a=t.has(i),o=m.get(`${n.name}/${r.name}`)??[];return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:1,label:S(r.name),labelTitle:r.name,tag:`LINE`,tagKind:`line`,count:o.length,expanded:a,onToggle:()=>h(i),hasChildren:!0}),a&&o.map(i=>{let a=`inst:${n.name}/${r.name}/${i.id}`,o=t.has(a);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:2,label:C(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:S(i.model),subtitleTitle:i.model,count:i.tags.length+i.properties.length,expanded:o,onToggle:()=>h(a),hasChildren:i.tags.length+i.properties.length>0}),o&&(0,X.jsx)(he,{instance:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}function be(e){return e.lines.reduce((e,t)=>e+t.twins.reduce((e,t)=>e+t.count,0),0)}function xe(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function Se(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?xe(e):0;n+=r.count*i}return n}function Ce({template:e,onClose:t}){let[n,r]=(0,Y.useState)(new Set),i=c({queryKey:s.catalog.templateDetail(e?.id??``),queryFn:()=>o(`/catalog/templates/${e?.id}`,a.catalogTemplateDetail),enabled:e!==null}),d=i.data,f=i.isPending&&!d,p=i.isError,h=J(i.error,`Failed to load environment.`),ee=d?.models?.join(`,`)??``,g=c({queryKey:s.catalog.modelSchemasBatch(ee),queryFn:async()=>{let e=d?.models??[];return e.length===0?[]:Promise.all(e.map(e=>o(`/catalog/models/${e}`,a.catalogModelDetail)))},enabled:d!==null}),_=(0,Y.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 Se(d,e)},[d,g.data]);(0,Y.useEffect)(()=>{e&&d&&r(new Set(d.topology.map(e=>e.name)))},[e,d]);let v=(0,Y.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=k(),b=y.status===`running`;return(0,X.jsx)(L,{open:e!==null,onOpenChange:e=>{if(!e){if(b){m.message(`Deploy still running. Cancel it or wait before closing.`);return}y.reset(),t()}},children:(0,X.jsx)(ie,{side:`right`,showCloseButton:!b,className:`flex w-full flex-col gap-4 touch-manipulation`,children:f?null:p&&!d?(0,X.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,X.jsx)(l,{message:h,onRetry:()=>void i.refetch(),isRetrying:i.isFetching})}):d?(0,X.jsxs)(u.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,X.jsxs)(R,{className:`gap-1 pb-0 pe-12`,children:[(0,X.jsx)(V,{className:`font-heading text-base uppercase tracking-wide`,children:d.name}),d.description&&(0,X.jsx)(oe,{className:`text-xs leading-relaxed text-foreground/88`,children:d.description})]}),(0,X.jsxs)(I,{defaultValue:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,X.jsxs)(F,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[(0,X.jsx)(N,{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,X.jsx)(N,{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,X.jsx)(N,{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,X.jsx)(P,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.topology.length,` areas`]}),(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.instanceCount,` twins`]}),(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.models.length,` models`]}),_!==null&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[_,` tags`]}),d.settings?.tickIntervalMs&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,d.settings.tickIntervalMs,`ms`]}),d.settings?.timeMultiplier&&d.settings.timeMultiplier!==1&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.settings.timeMultiplier,`× speed`]}),(0,X.jsx)(O,{stream:y})]}),d.namespace&&(d.namespace.enterprise||d.namespace.site||d.namespace.prefix)&&(0,X.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,X.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,X.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,X.jsx)(we,{area:e,expanded:n.has(e.name),onToggle:()=>v(e.name)},e.name)),d.settings&&(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,X.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,X.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`Settings`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,X.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.tickIntervalMs??1e3,`ms`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,X.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,X.jsx)(P,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,X.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,X.jsx)(ye,{detail:d})})})})}),(0,X.jsx)(P,{value:`deploy`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(B,{kind:`template`,id:d.id,displayName:d.name,yamlPath:`/catalog/templates/${d.id}/yaml`,yamlFilename:`${d.id}.miravo.yaml`,stream:y})})})]})]},d.id):(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Environment not found`})})})}function we({area:e,expanded:t,onToggle:n}){let r=be(e);return(0,X.jsxs)(`div`,{className:K,children:[(0,X.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,X.jsx)(de,{className:`size-3.5 text-primary`}),(0,X.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:S(e.name)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,X.jsxs)(q,{variant:`secondary`,className:`text-xs`,children:[r,` twins`]}),(0,X.jsxs)(q,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,X.jsx)(j,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,X.jsx)(d,{initial:!1,children:t&&(0,X.jsx)(u.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,X.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,X.jsx)(Te,{line:e},e.name))})},`content`)})]})}function Te({line:e}){return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(pe,{className:`size-3.5`}),(0,X.jsx)(`span`,{title:e.name,children:S(e.name)}),(0,X.jsx)(fe,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.twins.reduce((e,t)=>e+t.count,0),` twins`]})]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.twins.map(e=>(0,X.jsx)(Ee,{twin:e},`${e.model}-${e.count}`))})]})}function Ee({twin:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:S(e.model)}),(0,X.jsxs)(q,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}var De=[`builtin`,`personal`];function Oe(){let[e,t]=(0,Y.useState)(``),[n,m]=(0,Y.useState)(`all`),[v,te]=(0,Y.useState)({}),[S,C]=(0,Y.useState)(null),[w,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null),N=(0,Y.useRef)(null),P=le();(0,Y.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(),N.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let F=c({queryKey:s.catalog.templates(),queryFn:()=>o(`/catalog/templates`,a.catalogTemplates)}),I=F.data??[],L=w===null?null:I.find(e=>e.id===w)??null,R=F.isPending&&!F.data,z=F.isError&&!F.data,B=F.isError&&!!F.data,V=J(F.error,`Failed to load environments.`),H=e=>v[e]??1,ie=(0,Y.useCallback)((e,t)=>{te(n=>({...n,[e]:Math.max(1,Math.min(10,t))}))},[]),oe=(0,Y.useCallback)(e=>{M(e)},[]),se=(0,Y.useCallback)(e=>{E(e);let t=r(e);O(t),A(i(t))},[]),ce=async e=>{let t=i(D);if(t)return A(t),!1;A(null),C(e);try{return await P.mutateAsync({type:`loadTemplate`,templatePath:e,count:H(e),namePrefix:D.trim()||r(e)}),!0}catch{return!1}finally{C(null)}},U=(0,Y.useMemo)(()=>{let e={all:I.length};for(let t of De)e[t]=0;for(let t of I){let n=ae(t.source);e[n]=(e[n]??0)+1}return e},[I]),W=e.toLowerCase(),G=I.filter(e=>n===`all`||ae(e.source)===n).filter(e=>W?e.name.toLowerCase().includes(W)||e.id.toLowerCase().includes(W)||(e.description?.toLowerCase().includes(W)??!1):!0);return(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Environment Catalog`}),(0,X.jsx)(q,{variant:`outline`,className:`text-xs`,children:z?(0,X.jsx)(`span`,{className:`text-destructive`,children:`Unavailable`}):R&&I.length===0?(0,X.jsx)(X.Fragment,{children:`Loading...`}):(0,X.jsxs)(X.Fragment,{children:[new Set(I.map(e=>e.id)).size,` environments`]})})]}),(0,X.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.`})]}),z&&(0,X.jsx)(l,{message:V,onRetry:()=>void F.refetch(),isRetrying:F.isFetching}),B&&(0,X.jsx)(l,{message:`${V} Showing cached environments.`,onRetry:()=>void F.refetch(),isRetrying:F.isFetching}),!z&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`div`,{className:`relative max-w-xs flex-1 min-w-[14rem]`,children:[(0,X.jsx)(ne,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,X.jsx)(b,{ref:N,placeholder:`Filter environments...`,value:e,onChange:e=>t(e.target.value),className:`pl-9 pr-7`}),!e&&(0,X.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,X.jsx)(je,{value:n,counts:U,onChange:m})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @[720px]/templates:grid-cols-2`,"aria-busy":R&&!z,children:z?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(d,{children:G.map((e,t)=>(0,X.jsx)(u.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,X.jsx)(ke,{template:e,count:H(e.id),launching:S===e.id,onCountChange:ie,onInspect:oe,onLaunch:se})},`${e.source}:${e.id}`))}),G.length===0&&I.length>0&&(0,X.jsx)(`p`,{className:`col-span-full py-8 text-center text-sm text-muted-foreground`,children:`No environments match the current filters.`})]})}),I.length>0&&(0,X.jsx)(`div`,{className:T(K,`p-0`),children:(0,X.jsx)(`div`,{className:`community-teaser relative overflow-hidden rounded-[inherit]`,children:(0,X.jsx)(`div`,{className:`relative z-10 mx-auto max-w-3xl px-5 py-10 sm:px-10 sm:py-12`,children:(0,X.jsxs)(`div`,{className:`grid items-center gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,17rem)]`,children:[(0,X.jsxs)(`div`,{className:`order-2 flex min-w-0 flex-col gap-4 lg:order-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,X.jsx)(`p`,{className:`blueprint-title text-primary`,children:`Future channel`}),(0,X.jsx)(`span`,{className:`blueprint-stat text-[10px] text-muted-foreground`,children:`MIRAVO_REGISTRY · NOT_CONNECTED`})]}),(0,X.jsx)(`h2`,{className:`font-heading text-xl font-semibold tracking-tight sm:text-2xl`,children:`Community Environments`}),(0,X.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,X.jsx)(`div`,{children:(0,X.jsx)(q,{variant:`outline`,className:`community-teaser-soon border-primary/35 bg-primary/5 text-[10px] text-primary`,children:`Coming Soon`})})]}),(0,X.jsx)(`div`,{className:`order-1 flex justify-center lg:order-2 lg:justify-end`,children:(0,X.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,X.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,X.jsx)(re,{className:`size-9 text-primary`,"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] tracking-[0.18em] text-muted-foreground`,children:`AWAITING SIGNAL`}),(0,X.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] text-muted-foreground`,children:`Uplink idle`})]})})]})})})}),(0,X.jsx)(h,{open:w!==null,onOpenChange:e=>{e||E(null)},children:(0,X.jsxs)(g,{className:`min-w-0 sm:max-w-md`,children:[(0,X.jsxs)(ee,{children:[(0,X.jsx)(_,{children:`Launch environment?`}),(0,X.jsx)(p,{children:L!==null&&(0,X.jsxs)(X.Fragment,{children:[`This adds `,H(L.id),` instance`,H(L.id)===1?``:`s`,` of`,` `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:x(L.name)}),` `,`to the running environment.`]})})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsx)(ue,{htmlFor:`launch-name-prefix`,className:`text-xs font-medium text-foreground`,children:`Name prefix`}),(0,X.jsx)(b,{id:`launch-name-prefix`,value:D,maxLength:120,onChange:e=>{let t=e.target.value;O(t),A(i(t))},placeholder:L?r(L.id):`Prefix`,className:T(`min-w-0 font-mono text-xs`,k&&`border-destructive`),"aria-invalid":k!=null,"aria-describedby":`launch-name-prefix-hint`}),(0,X.jsxs)(`p`,{id:`launch-name-prefix-hint`,className:`min-w-0 wrap-break-word text-[11px] text-muted-foreground`,children:[`Generated IDs use this prefix. Example`,` `,(0,X.jsx)(`span`,{className:`break-all font-mono text-foreground`,children:`${D.trim()||(L?r(L.id):`env`)}-pump-001`})]}),k?(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:k}):null]}),(0,X.jsxs)(f,{children:[(0,X.jsx)(y,{variant:`outline`,disabled:S!==null,onClick:()=>E(null),children:`Cancel`}),(0,X.jsx)(y,{disabled:S!==null||L===null||k!=null,onClick:async()=>{L!==null&&await ce(L.id)&&E(null)},children:S===L?.id?`Launching...`:`Launch`})]})]})}),(0,X.jsx)(Ce,{template:j,onClose:()=>M(null)})]})}var ke=(0,Y.memo)(function({template:e,count:t,launching:n,onCountChange:r,onInspect:i,onLaunch:a}){return(0,X.jsxs)(`div`,{className:T(W,`flex flex-col gap-4 p-5`),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.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,X.jsx)(A,{id:e.id,className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-heading text-sm font-semibold uppercase tracking-wide`,children:x(e.name)}),(0,X.jsx)(`p`,{className:`line-clamp-3 text-xs leading-relaxed text-foreground/75`,children:e.description??`Industrial environment.`}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id})]})]}),(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.models.map(e=>(0,X.jsx)(q,{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,X.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-4 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.instanceCount}),` instances`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.models.length}),` models`]}),e.memberCount>0&&(0,X.jsxs)(`span`,{children:[`~`,(0,X.jsx)(`span`,{className:`text-foreground`,children:Ae(e.memberCount)}),` tags/cycle`]}),(0,X.jsx)(q,{variant:`outline`,className:T(`ml-auto shrink-0 font-sans text-[10px] font-medium uppercase tracking-wide`,se(e.source)),children:H(e.source)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center rounded-[var(--miravo-radius-tight)] border bg-muted/30`,children:[(0,X.jsx)(y,{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.id,t-1)},children:(0,X.jsx)(z,{className:`size-3`})}),(0,X.jsx)(`span`,{className:`flex size-7 items-center justify-center border-x font-mono text-xs`,children:t}),(0,X.jsx)(y,{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.id,t+1)},children:(0,X.jsx)(E,{className:`size-3`})})]}),(0,X.jsxs)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e),className:G,children:[(0,X.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),(0,X.jsxs)(y,{size:`sm`,className:`ml-auto`,disabled:n,onClick:()=>a(e.id),children:[(0,X.jsx)(U,{className:`mr-1 size-3`}),n?`...`:`Launch`]})]})]})});function Ae(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function je({value:e,counts:t,onChange:n}){return(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`radiogroup`,"aria-label":`Filter by source`,children:[{id:`all`,label:`All`},...De.map(e=>({id:e,label:H(e)}))].map(r=>{let i=e===r.id,a=t[r.id]??0,o=r.id!==`all`&&a===0;return(0,X.jsxs)(`label`,{className:T(`inline-flex h-7 items-center gap-1.5 rounded-[var(--miravo-radius-pill)] border px-3 text-xs font-medium transition-colors`,i?`border-primary/60 bg-primary/15 text-primary`:`border-border/60 bg-card/30 text-muted-foreground hover:border-border hover:bg-muted/40 hover:text-foreground`,o?`cursor-not-allowed opacity-40 hover:border-border/60 hover:bg-card/30 hover:text-muted-foreground`:`cursor-pointer`),children:[(0,X.jsx)(`input`,{type:`radio`,name:`catalog-source-filter`,value:r.id,checked:i,disabled:o,onChange:()=>n(r.id),className:`sr-only`}),(0,X.jsx)(`span`,{children:r.label}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] opacity-70`,children:a})]},r.id)})})}export{Oe as t};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{N as r,S as i,j as a,o,v as s}from"./api-5BZroqlO.js";import{i as c,t as l}from"./query-fetch-error-2yqCNP9X.js";import{t as u}from"./proxy-Be4WzmcS.js";import{t as d}from"./AnimatePresence-CPmH1DMY.js";import{a as f,i as p,l as m,n as h,o as ee,r as g,s as _,t as v}from"./copy-button-DnGsXbVV.js";import{C as y,S as b,c as te,d as x,g as S,l as C}from"./format-B9CcV2dj.js";import{n as w,t as T}from"./utils-XFKvwlFT.js";import{M as E,P as D,j as ne,n as O,t as k}from"./use-platform-stream-BBDJCrNY.js";import{t as A}from"./catalog-template-icons-3S8RvUxD.js";import{l as j}from"./select-CMOnuEoT.js";import{a as M}from"./platform-targets-BIQ1lKOg.js";import{i as N,n as P,r as F,t as I}from"./tabs-D64chVAn.js";import{r as re}from"./checkbox-C84IyqEB.js";import{a as L,c as R,d as z,i as B,l as V,n as H,o as ie,r as ae,s as oe,t as se,u as ce}from"./catalog-source-DL6GXE84.js";import{c as U,i as W,n as G,r as K,t as le}from"./use-engine-command-mutation-CIly3RgV.js";import{t as q}from"./badge-i00PiRCo.js";import{t as ue}from"./label-DTHSKF2S.js";import{n as J}from"./get-error-message-CFs0lSQP.js";var de=w(`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`}]]),fe=w(`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`}]]),pe=w(`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`}]]),Y=e(t(),1),X=n(),Z=20,me=14,Q=`flex w-3.5 shrink-0 items-center justify-center`;function he({instance:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,X.jsxs)(X.Fragment,{children:[l.map(a=>(0,X.jsx)(ge,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name)),!a&&u>0&&(0,X.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+Z}px`},onClick:()=>o(!0),children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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+Z}px`},onClick:()=>c(e=>!e),children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0,children:s?(0,X.jsx)(j,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,X.jsx)(M,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,X.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,X.jsx)(ge,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name))]})]})}function ge({member:e,depth:t,area:n,line:r,instanceId:i,detail:a}){let o=e.kind===`property`,s=t*14+Z+(o?me:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,X.jsx)(v,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:()=>(0,X.jsxs)(`button`,{type:`button`,className:T(`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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0,children:(0,X.jsx)(`span`,{className:T(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,X.jsx)(`span`,{title:e.name,className:T(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:te(e.name)}),o&&(0,X.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,X.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,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,X.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?j:M,f=i===`area`?`text-primary`:`text-foreground`;return(0,X.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,X.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,X.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{title:n??void 0,className:T(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,X.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,X.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,X.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 _e(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function ve(e,t,n){let r=[];for(let i of e){let e=_e(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 ye({detail:e}){let[t,n]=(0,Y.useState)(new Set),r=(0,Y.useRef)(null),a=(0,Y.useMemo)(()=>[...new Set(e.models)],[e.models]),u=a.join(`,`),d=c({queryKey:s.catalog.modelSchemasBatch(u),queryFn:async()=>Promise.all(a.map(e=>o(`/catalog/models/${e}`,i.catalogModelDetail)))}),f=d.isPending&&!d.data,p=(0,Y.useMemo)(()=>{let e=new Map;if(!d.data)return e;for(let[t,n]of d.data.entries())e.set(a[t],n);return e},[d.data,a]),m=(0,Y.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}`,ve(e.twins,p,t));return n},[e.topology,p]);(0,Y.useEffect)(()=>{if(f)return;let t=e.name;if(r.current===t)return;let i=new Set;for(let t of e.topology){i.add(`area:${t.name}`);for(let e of t.lines)i.add(`line:${t.name}/${e.name}`)}outer:for(let t of e.topology)for(let e of t.lines){let n=(m.get(`${t.name}/${e.name}`)??[])[0];if(n){i.add(`inst:${t.name}/${e.name}/${n.id}`);break outer}}n(i),r.current=t},[f,e.name,e.topology,m]);let h=(0,Y.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return f?null:d.isError&&!d.data?(0,X.jsx)(l,{message:J(d.error,`Failed to load model schemas.`),onRetry:()=>void d.refetch(),isRetrying:d.isFetching&&!d.isPending}):(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:0,label:S(n.name),labelTitle:n.name,tag:`AREA`,tagKind:`area`,expanded:i,onToggle:()=>h(r),hasChildren:!0}),i&&n.lines.map(r=>{let i=`line:${n.name}/${r.name}`,a=t.has(i),o=m.get(`${n.name}/${r.name}`)??[];return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:1,label:S(r.name),labelTitle:r.name,tag:`LINE`,tagKind:`line`,count:o.length,expanded:a,onToggle:()=>h(i),hasChildren:!0}),a&&o.map(i=>{let a=`inst:${n.name}/${r.name}/${i.id}`,o=t.has(a);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:2,label:C(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:S(i.model),subtitleTitle:i.model,count:i.tags.length+i.properties.length,expanded:o,onToggle:()=>h(a),hasChildren:i.tags.length+i.properties.length>0}),o&&(0,X.jsx)(he,{instance:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}function be(e){return e.lines.reduce((e,t)=>e+t.twins.reduce((e,t)=>e+t.count,0),0)}function xe(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function Se(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?xe(e):0;n+=r.count*i}return n}function Ce({template:e,onClose:t}){let[n,r]=(0,Y.useState)(new Set),a=c({queryKey:s.catalog.templateDetail(e?.id??``),queryFn:()=>o(`/catalog/templates/${e?.id}`,i.catalogTemplateDetail),enabled:e!==null}),d=a.data,f=a.isPending&&!d,p=a.isError,h=J(a.error,`Failed to load environment.`),ee=d?.models?.join(`,`)??``,g=c({queryKey:s.catalog.modelSchemasBatch(ee),queryFn:async()=>{let e=d?.models??[];return e.length===0?[]:Promise.all(e.map(e=>o(`/catalog/models/${e}`,i.catalogModelDetail)))},enabled:d!==null}),_=(0,Y.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 Se(d,e)},[d,g.data]);(0,Y.useEffect)(()=>{e&&d&&r(new Set(d.topology.map(e=>e.name)))},[e,d]);let v=(0,Y.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=k(),b=y.status===`running`;return(0,X.jsx)(L,{open:e!==null,onOpenChange:e=>{if(!e){if(b){m.message(`Deploy still running. Cancel it or wait before closing.`);return}y.reset(),t()}},children:(0,X.jsx)(ie,{side:`right`,showCloseButton:!b,className:`flex w-full flex-col gap-4 touch-manipulation`,children:f?null:p&&!d?(0,X.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,X.jsx)(l,{message:h,onRetry:()=>void a.refetch(),isRetrying:a.isFetching})}):d?(0,X.jsxs)(u.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,X.jsxs)(R,{className:`gap-1 pb-0 pe-12`,children:[(0,X.jsx)(V,{className:`font-heading text-base uppercase tracking-wide`,children:d.name}),d.description&&(0,X.jsx)(oe,{className:`text-xs leading-relaxed text-foreground/88`,children:d.description})]}),(0,X.jsxs)(I,{defaultValue:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,X.jsxs)(F,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[(0,X.jsx)(N,{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,X.jsx)(N,{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,X.jsx)(N,{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,X.jsx)(P,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.topology.length,` areas`]}),(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.instanceCount,` twins`]}),(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.models.length,` models`]}),_!==null&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[_,` tags`]}),d.settings?.tickIntervalMs&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,d.settings.tickIntervalMs,`ms`]}),d.settings?.timeMultiplier&&d.settings.timeMultiplier!==1&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.settings.timeMultiplier,`× speed`]}),(0,X.jsx)(O,{stream:y})]}),d.namespace&&(d.namespace.enterprise||d.namespace.site||d.namespace.prefix)&&(0,X.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,X.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,X.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,X.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,X.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,X.jsx)(we,{area:e,expanded:n.has(e.name),onToggle:()=>v(e.name)},e.name)),d.settings&&(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,X.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,X.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`Settings`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,X.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.tickIntervalMs??1e3,`ms`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,X.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,X.jsx)(P,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,X.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,X.jsx)(ye,{detail:d})})})})}),(0,X.jsx)(P,{value:`deploy`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(B,{kind:`template`,id:d.id,displayName:d.name,yamlPath:`/catalog/templates/${d.id}/yaml`,yamlFilename:`${d.id}.miravo.yaml`,stream:y})})})]})]},d.id):(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Environment not found`})})})}function we({area:e,expanded:t,onToggle:n}){let r=be(e);return(0,X.jsxs)(`div`,{className:K,children:[(0,X.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,X.jsx)(de,{className:`size-3.5 text-primary`}),(0,X.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:S(e.name)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,X.jsxs)(q,{variant:`secondary`,className:`text-xs`,children:[r,` twins`]}),(0,X.jsxs)(q,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,X.jsx)(j,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,X.jsx)(d,{initial:!1,children:t&&(0,X.jsx)(u.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,X.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,X.jsx)(Te,{line:e},e.name))})},`content`)})]})}function Te({line:e}){return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(pe,{className:`size-3.5`}),(0,X.jsx)(`span`,{title:e.name,children:S(e.name)}),(0,X.jsx)(fe,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.twins.reduce((e,t)=>e+t.count,0),` twins`]})]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.twins.map(e=>(0,X.jsx)(Ee,{twin:e},`${e.model}-${e.count}`))})]})}function Ee({twin:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:S(e.model)}),(0,X.jsxs)(q,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}var De=[`builtin`,`personal`];function Oe(){let[e,t]=(0,Y.useState)(``),[n,m]=(0,Y.useState)(`all`),[v,te]=(0,Y.useState)({}),[S,C]=(0,Y.useState)(null),[w,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null),N=(0,Y.useRef)(null),P=le();(0,Y.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(),N.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let F=c({queryKey:s.catalog.templates(),queryFn:()=>o(`/catalog/templates`,i.catalogTemplates)}),I=F.data??[],L=w===null?null:I.find(e=>e.id===w)??null,R=F.isPending&&!F.data,z=F.isError&&!F.data,B=F.isError&&!!F.data,V=J(F.error,`Failed to load environments.`),H=e=>v[e]??1,ie=(0,Y.useCallback)((e,t)=>{te(n=>({...n,[e]:Math.max(1,Math.min(10,t))}))},[]),oe=(0,Y.useCallback)(e=>{M(e)},[]),se=(0,Y.useCallback)(e=>{E(e);let t=a(e);O(t),A(r(t))},[]),ce=async e=>{let t=r(D);if(t)return A(t),!1;A(null),C(e);try{return await P.mutateAsync({type:`loadTemplate`,templatePath:e,count:H(e),namePrefix:D.trim()||a(e)}),!0}catch{return!1}finally{C(null)}},U=(0,Y.useMemo)(()=>{let e={all:I.length};for(let t of De)e[t]=0;for(let t of I){let n=ae(t.source);e[n]=(e[n]??0)+1}return e},[I]),W=e.toLowerCase(),G=I.filter(e=>n===`all`||ae(e.source)===n).filter(e=>W?e.name.toLowerCase().includes(W)||e.id.toLowerCase().includes(W)||(e.description?.toLowerCase().includes(W)??!1):!0);return(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Environment Catalog`}),(0,X.jsx)(q,{variant:`outline`,className:`text-xs`,children:z?(0,X.jsx)(`span`,{className:`text-destructive`,children:`Unavailable`}):R&&I.length===0?(0,X.jsx)(X.Fragment,{children:`Loading...`}):(0,X.jsxs)(X.Fragment,{children:[new Set(I.map(e=>e.id)).size,` environments`]})})]}),(0,X.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.`})]}),z&&(0,X.jsx)(l,{message:V,onRetry:()=>void F.refetch(),isRetrying:F.isFetching}),B&&(0,X.jsx)(l,{message:`${V} Showing cached environments.`,onRetry:()=>void F.refetch(),isRetrying:F.isFetching}),!z&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`div`,{className:`relative max-w-xs flex-1 min-w-[14rem]`,children:[(0,X.jsx)(ne,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,X.jsx)(b,{ref:N,placeholder:`Filter environments...`,value:e,onChange:e=>t(e.target.value),className:`pl-9 pr-7`}),!e&&(0,X.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,X.jsx)(je,{value:n,counts:U,onChange:m})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @[720px]/templates:grid-cols-2`,"aria-busy":R&&!z,children:z?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(d,{children:G.map((e,t)=>(0,X.jsx)(u.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,X.jsx)(ke,{template:e,count:H(e.id),launching:S===e.id,onCountChange:ie,onInspect:oe,onLaunch:se})},`${e.source}:${e.id}`))}),G.length===0&&I.length>0&&(0,X.jsx)(`p`,{className:`col-span-full py-8 text-center text-sm text-muted-foreground`,children:`No environments match the current filters.`})]})}),I.length>0&&(0,X.jsx)(`div`,{className:T(K,`p-0`),children:(0,X.jsx)(`div`,{className:`community-teaser relative overflow-hidden rounded-[inherit]`,children:(0,X.jsx)(`div`,{className:`relative z-10 mx-auto max-w-3xl px-5 py-10 sm:px-10 sm:py-12`,children:(0,X.jsxs)(`div`,{className:`grid items-center gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,17rem)]`,children:[(0,X.jsxs)(`div`,{className:`order-2 flex min-w-0 flex-col gap-4 lg:order-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,X.jsx)(`p`,{className:`blueprint-title text-primary`,children:`Future channel`}),(0,X.jsx)(`span`,{className:`blueprint-stat text-[10px] text-muted-foreground`,children:`MIRAVO_REGISTRY · NOT_CONNECTED`})]}),(0,X.jsx)(`h2`,{className:`font-heading text-xl font-semibold tracking-tight sm:text-2xl`,children:`Community Environments`}),(0,X.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,X.jsx)(`div`,{children:(0,X.jsx)(q,{variant:`outline`,className:`community-teaser-soon border-primary/35 bg-primary/5 text-[10px] text-primary`,children:`Coming Soon`})})]}),(0,X.jsx)(`div`,{className:`order-1 flex justify-center lg:order-2 lg:justify-end`,children:(0,X.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,X.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,X.jsx)(re,{className:`size-9 text-primary`,"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] tracking-[0.18em] text-muted-foreground`,children:`AWAITING SIGNAL`}),(0,X.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] text-muted-foreground`,children:`Uplink idle`})]})})]})})})}),(0,X.jsx)(h,{open:w!==null,onOpenChange:e=>{e||E(null)},children:(0,X.jsxs)(g,{className:`min-w-0 sm:max-w-md`,children:[(0,X.jsxs)(ee,{children:[(0,X.jsx)(_,{children:`Launch environment?`}),(0,X.jsx)(p,{children:L!==null&&(0,X.jsxs)(X.Fragment,{children:[`This adds `,H(L.id),` instance`,H(L.id)===1?``:`s`,` of`,` `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:x(L.name)}),` `,`to the running environment.`]})})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsx)(ue,{htmlFor:`launch-name-prefix`,className:`text-xs font-medium text-foreground`,children:`Name prefix`}),(0,X.jsx)(b,{id:`launch-name-prefix`,value:D,maxLength:120,onChange:e=>{let t=e.target.value;O(t),A(r(t))},placeholder:L?a(L.id):`Prefix`,className:T(`min-w-0 font-mono text-xs`,k&&`border-destructive`),"aria-invalid":k!=null,"aria-describedby":`launch-name-prefix-hint`}),(0,X.jsxs)(`p`,{id:`launch-name-prefix-hint`,className:`min-w-0 wrap-break-word text-[11px] text-muted-foreground`,children:[`Generated IDs use this prefix. Example`,` `,(0,X.jsx)(`span`,{className:`break-all font-mono text-foreground`,children:`${D.trim()||(L?a(L.id):`env`)}-pump-001`})]}),k?(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:k}):null]}),(0,X.jsxs)(f,{children:[(0,X.jsx)(y,{variant:`outline`,disabled:S!==null,onClick:()=>E(null),children:`Cancel`}),(0,X.jsx)(y,{disabled:S!==null||L===null||k!=null,onClick:async()=>{L!==null&&await ce(L.id)&&E(null)},children:S===L?.id?`Launching...`:`Launch`})]})]})}),(0,X.jsx)(Ce,{template:j,onClose:()=>M(null)})]})}var ke=(0,Y.memo)(function({template:e,count:t,launching:n,onCountChange:r,onInspect:i,onLaunch:a}){return(0,X.jsxs)(`div`,{className:T(W,`flex flex-col gap-4 p-5`),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.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,X.jsx)(A,{id:e.id,className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-heading text-sm font-semibold uppercase tracking-wide`,children:x(e.name)}),(0,X.jsx)(`p`,{className:`line-clamp-3 text-xs leading-relaxed text-foreground/75`,children:e.description??`Industrial environment.`}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id})]})]}),(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.models.map(e=>(0,X.jsx)(q,{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,X.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-4 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.instanceCount}),` instances`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.models.length}),` models`]}),e.memberCount>0&&(0,X.jsxs)(`span`,{children:[`~`,(0,X.jsx)(`span`,{className:`text-foreground`,children:Ae(e.memberCount)}),` tags/cycle`]}),(0,X.jsx)(q,{variant:`outline`,className:T(`ml-auto shrink-0 font-sans text-[10px] font-medium uppercase tracking-wide`,se(e.source)),children:H(e.source)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center rounded-[var(--miravo-radius-tight)] border bg-muted/30`,children:[(0,X.jsx)(y,{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.id,t-1)},children:(0,X.jsx)(z,{className:`size-3`})}),(0,X.jsx)(`span`,{className:`flex size-7 items-center justify-center border-x font-mono text-xs`,children:t}),(0,X.jsx)(y,{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.id,t+1)},children:(0,X.jsx)(E,{className:`size-3`})})]}),(0,X.jsxs)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e),className:G,children:[(0,X.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),(0,X.jsxs)(y,{size:`sm`,className:`ml-auto`,disabled:n,onClick:()=>a(e.id),children:[(0,X.jsx)(U,{className:`mr-1 size-3`}),n?`...`:`Launch`]})]})]})});function Ae(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function je({value:e,counts:t,onChange:n}){return(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`radiogroup`,"aria-label":`Filter by source`,children:[{id:`all`,label:`All`},...De.map(e=>({id:e,label:H(e)}))].map(r=>{let i=e===r.id,a=t[r.id]??0,o=r.id!==`all`&&a===0;return(0,X.jsxs)(`label`,{className:T(`inline-flex h-7 items-center gap-1.5 rounded-[var(--miravo-radius-pill)] border px-3 text-xs font-medium transition-colors`,i?`border-primary/60 bg-primary/15 text-primary`:`border-border/60 bg-card/30 text-muted-foreground hover:border-border hover:bg-muted/40 hover:text-foreground`,o?`cursor-not-allowed opacity-40 hover:border-border/60 hover:bg-card/30 hover:text-muted-foreground`:`cursor-pointer`),children:[(0,X.jsx)(`input`,{type:`radio`,name:`catalog-source-filter`,value:r.id,checked:i,disabled:o,onChange:()=>n(r.id),className:`sr-only`}),(0,X.jsx)(`span`,{children:r.label}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] opacity-70`,children:a})]},r.id)})})}export{Oe as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./catalog-B477tO5a.js";export{e as CatalogPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{$ as n,J as r,Q as i,X as a,Y as o,Z as s,at as c,q as l}from"./vendor-ui-CWUk2ulb.js";import{S as u,a as ee,k as d,o as te,s as ne,v as f}from"./api-Bf6pFRhP.js";import{i as re,s as ie,t as ae}from"./query-fetch-error-BqiDQT2r.js";import{t as p}from"./proxy-Be4WzmcS.js";import{t as oe}from"./AnimatePresence-CPmH1DMY.js";import{a as se,i as ce,l as m,n as le,o as ue,r as de,s as fe}from"./copy-button-DnGsXbVV.js";import{C as h,S as pe,T as g}from"./format-B9CcV2dj.js";import{n as _,t as v}from"./utils-XFKvwlFT.js";import{C as me,E as he,N as ge,O as _e,S as ve,T as ye,_ as be,a as xe,b as Se,c as Ce,d as we,g as Te,h as Ee,i as De,k as Oe,o as ke,p as Ae,r as je,s as Me,w as Ne,y as Pe}from"./use-platform-stream-BVf5gGJM.js";import{a as Fe,c as Ie,i as y,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./select-CMOnuEoT.js";import{a as He,i as Ue,n as We,r as b,t as Ge}from"./platform-targets-BIQ1lKOg.js";import{a as Ke,o as x}from"./tabs-CCixnxMe.js";import{t as qe}from"./download-DmUZKo9N.js";import{r as Je}from"./checkbox-C84IyqEB.js";import{t as Ye}from"./badge-i00PiRCo.js";import{t as S}from"./label-DTHSKF2S.js";import{n as C}from"./get-error-message-yQcVJ-Ja.js";var Xe=_(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),w=_(`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`}]]),T=c();function E({...e}){return(0,T.jsx)(r,{"data-slot":`sheet`,...e})}function D({...e}){return(0,T.jsx)(o,{"data-slot":`sheet-portal`,...e})}function O({className:e,...t}){return(0,T.jsx)(n,{"data-slot":`sheet-overlay`,className:v(`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 k({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...o}){return(0,T.jsxs)(D,{children:[(0,T.jsx)(O,{}),(0,T.jsxs)(a,{"data-slot":`sheet-content`,"data-side":n,className:v(`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),...o,children:[t,r&&(0,T.jsxs)(i,{"data-slot":`sheet-close`,render:(0,T.jsx)(h,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,T.jsx)(g,{}),(0,T.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function A({className:e,...t}){return(0,T.jsx)(`div`,{"data-slot":`sheet-header`,className:v(`flex flex-col gap-0.5 p-2`,e),...t})}function j({className:e,...t}){return(0,T.jsx)(l,{"data-slot":`sheet-title`,className:v(`text-base font-medium text-foreground`,e),...t})}function Ze({className:e,...t}){return(0,T.jsx)(s,{"data-slot":`sheet-description`,className:v(`text-sm text-muted-foreground`,e),...t})}var M=e(t(),1),N=[{value:`opcua`,label:`OPC UA`},{value:`mqtt`,label:`MQTT`},{value:`modbus`,label:`Modbus`}];function Qe({value:e,onValueChange:t,labelledBy:n}){return(0,T.jsx)(`fieldset`,{"aria-labelledby":n,className:`min-w-0 border-0 p-0`,children:(0,T.jsx)(`div`,{className:`flex gap-1.5`,children:N.map(n=>{let r=e===n.value;return(0,T.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(n.value),className:v(`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,T.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 font-mono text-[11px] font-medium leading-none tracking-wide`,children:[(0,T.jsx)(Ke,{className:`size-2.5 shrink-0 -translate-y-px opacity-80`,"aria-hidden":!0}),(0,T.jsx)(`span`,{children:n.label})]})},n.value)})})})}var P=`172.17.0.1`;async function $e(e){let t=await te(`/catalog/models/${encodeURIComponent(e)}/le-dt.json`,u.catalogModelLeDt);return JSON.stringify(t,null,2)}async function et(e,t={host:P}){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 ee(tt(e,r.data),u.catalogTemplateLeTemplateJson)}function tt(e,t){return`/catalog/templates/${encodeURIComponent(e)}/le-template.json${F(t)}`}function F(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 nt(e){return`${d(e)}-001`}function rt(e,t){return[t,...e?.filter(e=>e.id!==t.id)??[]]}async function it(e){let t=await e.create();e.onCreated(t);try{await e.refresh()}catch(t){e.onRefreshFailed(t)}}function at(e){return Ue.find(t=>t.id===e)?.label??e}function ot(e){return e===`template`?`Litmus Edge Template`:`Litmus Edge`}function st({kind:e,id:t,displayName:n,yamlPath:r,yamlFilename:i,stream:a}){let o=ie(),s=re({queryKey:f.platforms.targets(),queryFn:()=>we()}),c=s.data??[],[l,ee]=(0,M.useState)(``),[d,te]=(0,M.useState)(`opcua`),[_,Ke]=(0,M.useState)(`litmus-edge`),[Xe,w]=(0,M.useState)(!1),[E,D]=(0,M.useState)(!1),[O,k]=(0,M.useState)(b.id),[A,j]=(0,M.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[Ze,N]=(0,M.useState)(!1),[tt,F]=(0,M.useState)(!1),{testing:st,runTest:I,cancelInFlight:L}=ke(),[ct,R]=(0,M.useState)(!1),[z,B]=(0,M.useState)(P),[V,lt]=(0,M.useState)(!1),[H,U]=(0,M.useState)(null),[W,ut]=(0,M.useState)(!1),G=(0,M.useRef)(0),K=(0,M.useRef)(null),dt=(0,M.useRef)(a.status),ft=(0,M.useId)(),q=(0,M.useCallback)(()=>{G.current+=1,K.current?.abort(),K.current=null,ut(!1),U(null)},[]);(0,M.useEffect)(()=>()=>{G.current+=1,K.current?.abort(),K.current=null},[]),(0,M.useEffect)(()=>{let e=dt.current;dt.current=a.status,e===`running`&&a.status===`complete`&&o.invalidateQueries({queryKey:f.platforms.operationsList()})},[o,a.status]),(0,M.useEffect)(()=>{E&&(k(b.id),j({label:``,hostname:``,apiToken:``,sourceHostname:``}),N(!1))},[E]);let pt=O===b.id&&A.hostname.trim().length>0&&A.sourceHostname.trim().length>0&&A.apiToken.trim().length>0,J=c.find(e=>e.id===l),mt=(0,M.useCallback)(n=>{w(!1),q(),l&&(e===`model`?a.startApply(ye({targetId:l,model:t,protocol:d,result:n})):a.startApply(he({targetId:l,template:t,result:n})))},[l,t,e,d,a,q]),ht=(0,M.useCallback)(async n=>{if(!l)return;a.operation&&a.status!==`running`&&a.reset(),K.current?.abort(),G.current+=1;let r=G.current,i=new AbortController;K.current=i,ut(!0),U(null);try{let a=await Ae(e===`model`?ye({targetId:l,model:t,protocol:d,result:n}):he({targetId:l,template:t,result:n}),{signal:i.signal});if(r!==G.current)return;U(a.plan)}catch(e){if(r!==G.current||xe(e))return;m.error(C(e,`Plan failed.`))}finally{r===G.current&&ut(!1)}},[l,e,t,d,a]),gt=(0,M.useCallback)(async()=>{if(O!==b.id){m.error(`${at(O)} target setup is coming soon.`);return}if(!A.label||!A.hostname||!A.sourceHostname){m.error(`Label, hostname, and source host are required.`);return}if(!A.apiToken){m.error(`API token is required for new targets.`);return}F(!0);try{await it({create:()=>Ce({...A,platformId:O}),onCreated:e=>{o.setQueryData(f.platforms.targets(),t=>rt(t,e)),ee(e.id),D(!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:`${C(e,`Target list refresh failed.`)} Reload targets before retrying another add.`})}})}catch(e){m.error(C(e,`Failed to add target.`))}finally{F(!1)}},[O,A,s,o]),_t=(0,M.useCallback)(()=>{pt&&I({hostname:A.hostname.trim(),sourceHostname:A.sourceHostname.trim(),apiToken:A.apiToken.trim()})},[pt,A,I]),vt=_===`source-yaml`,yt=_===`litmus-edge`||vt,Y=(0,M.useCallback)(async n=>{if(vt){try{let t=await ne(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(_===`litmus-edge`)try{if(e===`model`){let e=await $e(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:P,i=`${t}.le-template.json`,a=await et(t,{host:r}),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`)}},[_,vt,e,t,r,i]),bt=(0,M.useCallback)(()=>{if(yt){if(_===`litmus-edge`&&e===`template`){B(P),R(!0);return}Y()}},[yt,_,e,Y]),xt=(0,M.useCallback)(async()=>{lt(!0);try{await Y({templateHost:z}),R(!1)}finally{lt(!1)}},[z,Y]),X=a.status===`running`,Z=a.cancelRequested,Q=!!l&&!X,St=!!a.operation||X,$=St?Me(a):null;return(0,T.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 px-1 py-2`,children:[(0,T.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,T.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Deploy`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Target`}),s.isError&&s.data===void 0&&(0,T.jsx)(ae,{message:C(s.error,`Failed to load targets.`),onRetry:()=>void s.refetch(),isRetrying:s.isFetching&&!s.isPending}),(0,T.jsx)(Ee,{targets:c,value:l,onValueChange:ee,loading:s.isPending&&s.data===void 0,size:`sm`,className:`min-w-0 w-full border-border/65 bg-background/55 text-xs text-foreground`,onAddNew:()=>D(!0)})]}),e===`model`&&c.length>0&&(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{id:ft,className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Protocol binding`}),(0,T.jsx)(Qe,{value:d,onValueChange:te,labelledBy:ft})]}),c.length>0&&(0,T.jsxs)(`button`,{type:`button`,disabled:!Q,onClick:()=>w(!0),className:v(`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,T.jsxs)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:[(0,T.jsx)(`span`,{className:v(`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,T.jsx)(Je,{className:v(`relative size-5`,Q?`text-primary`:`text-foreground/75`)})]}),(0,T.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,T.jsx)(`span`,{className:v(`font-heading text-[11px] font-semibold uppercase tracking-[0.16em]`,Q?`text-primary`:`text-foreground/78`),children:Q?`Review deploy`:X?`Deploy in progress…`:`Awaiting target`}),(0,T.jsx)(`span`,{className:v(`truncate font-mono text-[13px] leading-tight tracking-tight`,Q?`text-foreground`:`text-foreground/80`),children:J?.label??`Select a target above`})]}),(0,T.jsx)(`span`,{className:v(`flex shrink-0 items-center pr-2.5 sm:pr-3`,Q&&`pl-1`),children:(0,T.jsx)(`span`,{className:v(`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,T.jsx)(He,{className:`size-4`,strokeWidth:2.25})})})]})]})}),(0,T.jsx)(oe,{children:St&&$?(0,T.jsx)(be,{title:$.title,subtitle:$.subtitle,canDismiss:!X,footerAction:X&&a.operation?.operationId?(0,T.jsx)(h,{variant:`outline`,size:`sm`,disabled:Z,"aria-busy":Z,className:v(`ml-auto group h-8 gap-1.5 px-3 text-xs`,Z?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),onClick:()=>{a.cancel().catch(()=>{})},children:Z?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(x,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,T.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,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(g,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,T.jsx)(p.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})}):(0,T.jsx)(`div`,{className:`ml-auto shrink-0 flex items-center`,children:(0,T.jsx)(h,{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,T.jsx)(Se,{operation:a.operation,catalogTemplates:[{id:t,name:n}],logs:a.logs}):(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(x,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`text-xs text-foreground/88`,children:`Connecting to Litmus Edge…`})]}),(0,T.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/40`,children:(0,T.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}),(W||H)&&!X?(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,T.jsx)(ge,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,T.jsxs)(`span`,{className:`truncate`,children:[`Preview for `,J?.label??`target`,`: `,n]})]}),(0,T.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:q,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),`Close preview`]})]}),W?(0,T.jsx)(De,{}):H?(0,T.jsx)(je,{plan:H,planKind:`apply`,onCloseTable:q}):null]}):null,(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border/40 pt-5`,children:[(0,T.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Export`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Format`}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,T.jsxs)(Ve,{value:_,onValueChange:e=>{e&&Ke(e)},children:[(0,T.jsx)(Be,{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,T.jsx)(Ie,{placeholder:`Select format`,children:t=>{if(t===`source-yaml`)return`Source YAML`;let n=Ue.find(e=>e.id===t);return n?.id===`litmus-edge`?ot(e):n?.exportLabel??`Select format`}})}),(0,T.jsxs)(Le,{children:[(0,T.jsxs)(ze,{children:[(0,T.jsx)(Fe,{children:`Platform`}),Ge.map(t=>(0,T.jsx)(y,{value:t.id,children:t.id===`litmus-edge`?ot(e):t.exportLabel},t.id)),We.map(e=>(0,T.jsx)(y,{value:e.id,disabled:!0,children:(0,T.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.exportLabel,(0,T.jsx)(Ye,{variant:`outline`,className:`px-1 py-0 text-[10px] text-foreground/72`,children:`Coming Soon`})]})},e.id))]}),(0,T.jsx)(Re,{}),(0,T.jsxs)(ze,{children:[(0,T.jsx)(Fe,{children:`Source`}),(0,T.jsxs)(y,{value:`source-yaml`,children:[`Source YAML`,` `,(0,T.jsx)(`span`,{className:`text-foreground/72`,children:e===`model`?`.twin.yaml`:`.miravo.yaml`})]})]})]})]}),(0,T.jsxs)(h,{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:!yt,onClick:bt,children:[(0,T.jsx)(qe,{className:`size-3.5`}),`Download`]})]})]}),(0,T.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/70`,children:(0,T.jsx)(Pe,{format:_,kind:e})})]}),J&&(0,T.jsx)(ve,{open:Xe,onOpenChange:w,type:`apply`,label:n,targetLabel:J.label,hostname:J.hostname,sourceHostname:J.sourceHostname,onConfirm:mt,defaultDeviceName:e===`model`?nt(t):void 0,defaultNamePrefix:e===`template`?t:void 0,metadata:e===`model`?[{label:`Protocol`,value:d.toUpperCase()},_e]:Oe,applyPreview:{onPreview:e=>void ht(e),planLoading:W,disabled:!l||X}}),(0,T.jsx)(Te,{open:E,editing:!1,platformId:O,form:A,showToken:Ze,saving:tt,testing:st,canTestConnection:pt,onOpenChange:D,onPlatformChange:k,onFormChange:j,onShowTokenChange:N,onSave:()=>void gt(),onTestConnection:_t,onCancelInFlight:L}),(0,T.jsx)(le,{open:ct,onOpenChange:e=>{R(e),e||B(P)},children:(0,T.jsxs)(de,{className:`sm:max-w-md`,children:[(0,T.jsxs)(ue,{children:[(0,T.jsx)(fe,{children:`Download Litmus Edge Template`}),(0,T.jsx)(ce,{children:me})]}),(0,T.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,T.jsx)(S,{htmlFor:`deploy-export-source-host`,children:Ne}),(0,T.jsx)(pe,{id:`deploy-export-source-host`,value:z,onChange:e=>B(e.target.value),placeholder:P,autoComplete:`off`,className:`font-mono text-sm`}),(0,T.jsxs)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Use an IP or hostname reachable from Litmus Edge (e.g.`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:P}),` for Docker bridge).`]})]}),(0,T.jsxs)(se,{className:`gap-2 sm:gap-0`,children:[(0,T.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>R(!1),disabled:V,children:`Cancel`}),(0,T.jsxs)(h,{type:`button`,className:`gap-1.5`,onClick:()=>void xt(),disabled:V,"aria-busy":V,children:[V?(0,T.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,T.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]})]})})]})}var I={builtin:`Built-in`,personal:`Personal`,community:`Community`},L=`border-border/60 bg-muted/40 text-muted-foreground`,ct={builtin:L,personal:`border-primary/40 bg-primary/10 text-primary`,community:`border-accent/40 bg-accent/10 text-accent`};function R(e){return e===`cwd`||e===`namespace`?`personal`:e}function z(e){return I[R(e)]??e}function B(e){return ct[R(e)]??L}export{E as a,A as c,Xe as d,st as i,j as l,z as n,k as o,R as r,Ze as s,B as t,w as u};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{$ as n,J as r,Q as i,X as a,Y as o,Z as s,at as c,q as l}from"./vendor-ui-CWUk2ulb.js";import{A as ee,S as u,a as d,o as te,s as ne,v as f}from"./api-5BZroqlO.js";import{i as re,s as ie,t as ae}from"./query-fetch-error-2yqCNP9X.js";import{t as p}from"./proxy-Be4WzmcS.js";import{t as oe}from"./AnimatePresence-CPmH1DMY.js";import{a as se,i as ce,l as m,n as le,o as ue,r as de,s as fe}from"./copy-button-DnGsXbVV.js";import{C as h,S as pe,T as g}from"./format-B9CcV2dj.js";import{n as _,t as v}from"./utils-XFKvwlFT.js";import{C as me,E as he,N as ge,O as _e,S as ve,T as ye,_ as be,a as xe,b as Se,c as Ce,d as we,g as Te,h as Ee,i as De,k as Oe,o as ke,p as Ae,r as je,s as Me,w as Ne,y as Pe}from"./use-platform-stream-BBDJCrNY.js";import{a as Fe,c as Ie,i as y,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./select-CMOnuEoT.js";import{a as He,i as Ue,n as We,r as b,t as Ge}from"./platform-targets-BIQ1lKOg.js";import{a as Ke,o as x}from"./tabs-D64chVAn.js";import{t as qe}from"./download-DmUZKo9N.js";import{r as Je}from"./checkbox-C84IyqEB.js";import{t as Ye}from"./badge-i00PiRCo.js";import{t as S}from"./label-DTHSKF2S.js";import{n as C}from"./get-error-message-CFs0lSQP.js";var Xe=_(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),w=_(`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`}]]),T=c();function E({...e}){return(0,T.jsx)(r,{"data-slot":`sheet`,...e})}function D({...e}){return(0,T.jsx)(o,{"data-slot":`sheet-portal`,...e})}function O({className:e,...t}){return(0,T.jsx)(n,{"data-slot":`sheet-overlay`,className:v(`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 k({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...o}){return(0,T.jsxs)(D,{children:[(0,T.jsx)(O,{}),(0,T.jsxs)(a,{"data-slot":`sheet-content`,"data-side":n,className:v(`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),...o,children:[t,r&&(0,T.jsxs)(i,{"data-slot":`sheet-close`,render:(0,T.jsx)(h,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,T.jsx)(g,{}),(0,T.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function A({className:e,...t}){return(0,T.jsx)(`div`,{"data-slot":`sheet-header`,className:v(`flex flex-col gap-0.5 p-2`,e),...t})}function j({className:e,...t}){return(0,T.jsx)(l,{"data-slot":`sheet-title`,className:v(`text-base font-medium text-foreground`,e),...t})}function Ze({className:e,...t}){return(0,T.jsx)(s,{"data-slot":`sheet-description`,className:v(`text-sm text-muted-foreground`,e),...t})}var M=e(t(),1),N=[{value:`opcua`,label:`OPC UA`},{value:`mqtt`,label:`MQTT`},{value:`modbus`,label:`Modbus`}];function Qe({value:e,onValueChange:t,labelledBy:n}){return(0,T.jsx)(`fieldset`,{"aria-labelledby":n,className:`min-w-0 border-0 p-0`,children:(0,T.jsx)(`div`,{className:`flex gap-1.5`,children:N.map(n=>{let r=e===n.value;return(0,T.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(n.value),className:v(`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,T.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 font-mono text-[11px] font-medium leading-none tracking-wide`,children:[(0,T.jsx)(Ke,{className:`size-2.5 shrink-0 -translate-y-px opacity-80`,"aria-hidden":!0}),(0,T.jsx)(`span`,{children:n.label})]})},n.value)})})})}var P=`172.17.0.1`;async function $e(e){let t=await te(`/catalog/models/${encodeURIComponent(e)}/le-dt.json`,u.catalogModelLeDt);return JSON.stringify(t,null,2)}async function et(e,t={host:P}){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 d(tt(e,r.data),u.catalogTemplateLeTemplateJson)}function tt(e,t){return`/catalog/templates/${encodeURIComponent(e)}/le-template.json${F(t)}`}function F(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 nt(e){return`${ee(e)}-001`}function rt(e,t){return[t,...e?.filter(e=>e.id!==t.id)??[]]}async function it(e){let t=await e.create();e.onCreated(t);try{await e.refresh()}catch(t){e.onRefreshFailed(t)}}function at(e){return Ue.find(t=>t.id===e)?.label??e}function ot(e){return e===`template`?`Litmus Edge Template`:`Litmus Edge`}function st({kind:e,id:t,displayName:n,yamlPath:r,yamlFilename:i,stream:a}){let o=ie(),s=re({queryKey:f.platforms.targets(),queryFn:()=>we()}),c=s.data??[],[l,ee]=(0,M.useState)(``),[d,te]=(0,M.useState)(`opcua`),[_,Ke]=(0,M.useState)(`litmus-edge`),[Xe,w]=(0,M.useState)(!1),[E,D]=(0,M.useState)(!1),[O,k]=(0,M.useState)(b.id),[A,j]=(0,M.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[Ze,N]=(0,M.useState)(!1),[tt,F]=(0,M.useState)(!1),{testing:st,runTest:I,cancelInFlight:L}=ke(),[ct,R]=(0,M.useState)(!1),[z,B]=(0,M.useState)(P),[V,lt]=(0,M.useState)(!1),[H,U]=(0,M.useState)(null),[W,ut]=(0,M.useState)(!1),G=(0,M.useRef)(0),K=(0,M.useRef)(null),dt=(0,M.useRef)(a.status),ft=(0,M.useId)(),q=(0,M.useCallback)(()=>{G.current+=1,K.current?.abort(),K.current=null,ut(!1),U(null)},[]);(0,M.useEffect)(()=>()=>{G.current+=1,K.current?.abort(),K.current=null},[]),(0,M.useEffect)(()=>{let e=dt.current;dt.current=a.status,e===`running`&&a.status===`complete`&&o.invalidateQueries({queryKey:f.platforms.operationsList()})},[o,a.status]),(0,M.useEffect)(()=>{E&&(k(b.id),j({label:``,hostname:``,apiToken:``,sourceHostname:``}),N(!1))},[E]);let pt=O===b.id&&A.hostname.trim().length>0&&A.sourceHostname.trim().length>0&&A.apiToken.trim().length>0,J=c.find(e=>e.id===l),mt=(0,M.useCallback)(n=>{w(!1),q(),l&&(e===`model`?a.startApply(ye({targetId:l,model:t,protocol:d,result:n})):a.startApply(he({targetId:l,template:t,result:n})))},[l,t,e,d,a,q]),ht=(0,M.useCallback)(async n=>{if(!l)return;a.operation&&a.status!==`running`&&a.reset(),K.current?.abort(),G.current+=1;let r=G.current,i=new AbortController;K.current=i,ut(!0),U(null);try{let a=await Ae(e===`model`?ye({targetId:l,model:t,protocol:d,result:n}):he({targetId:l,template:t,result:n}),{signal:i.signal});if(r!==G.current)return;U(a.plan)}catch(e){if(r!==G.current||xe(e))return;m.error(C(e,`Plan failed.`))}finally{r===G.current&&ut(!1)}},[l,e,t,d,a]),gt=(0,M.useCallback)(async()=>{if(O!==b.id){m.error(`${at(O)} target setup is coming soon.`);return}if(!A.label||!A.hostname||!A.sourceHostname){m.error(`Label, hostname, and source host are required.`);return}if(!A.apiToken){m.error(`API token is required for new targets.`);return}F(!0);try{await it({create:()=>Ce({...A,platformId:O}),onCreated:e=>{o.setQueryData(f.platforms.targets(),t=>rt(t,e)),ee(e.id),D(!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:`${C(e,`Target list refresh failed.`)} Reload targets before retrying another add.`})}})}catch(e){m.error(C(e,`Failed to add target.`))}finally{F(!1)}},[O,A,s,o]),_t=(0,M.useCallback)(()=>{pt&&I({hostname:A.hostname.trim(),sourceHostname:A.sourceHostname.trim(),apiToken:A.apiToken.trim()})},[pt,A,I]),vt=_===`source-yaml`,yt=_===`litmus-edge`||vt,Y=(0,M.useCallback)(async n=>{if(vt){try{let t=await ne(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(_===`litmus-edge`)try{if(e===`model`){let e=await $e(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:P,i=`${t}.le-template.json`,a=await et(t,{host:r}),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`)}},[_,vt,e,t,r,i]),bt=(0,M.useCallback)(()=>{if(yt){if(_===`litmus-edge`&&e===`template`){B(P),R(!0);return}Y()}},[yt,_,e,Y]),xt=(0,M.useCallback)(async()=>{lt(!0);try{await Y({templateHost:z}),R(!1)}finally{lt(!1)}},[z,Y]),X=a.status===`running`,Z=a.cancelRequested,Q=!!l&&!X,St=!!a.operation||X,$=St?Me(a):null;return(0,T.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 px-1 py-2`,children:[(0,T.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,T.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Deploy`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Target`}),s.isError&&s.data===void 0&&(0,T.jsx)(ae,{message:C(s.error,`Failed to load targets.`),onRetry:()=>void s.refetch(),isRetrying:s.isFetching&&!s.isPending}),(0,T.jsx)(Ee,{targets:c,value:l,onValueChange:ee,loading:s.isPending&&s.data===void 0,size:`sm`,className:`min-w-0 w-full border-border/65 bg-background/55 text-xs text-foreground`,onAddNew:()=>D(!0)})]}),e===`model`&&c.length>0&&(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{id:ft,className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Protocol binding`}),(0,T.jsx)(Qe,{value:d,onValueChange:te,labelledBy:ft})]}),c.length>0&&(0,T.jsxs)(`button`,{type:`button`,disabled:!Q,onClick:()=>w(!0),className:v(`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,T.jsxs)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:[(0,T.jsx)(`span`,{className:v(`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,T.jsx)(Je,{className:v(`relative size-5`,Q?`text-primary`:`text-foreground/75`)})]}),(0,T.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,T.jsx)(`span`,{className:v(`font-heading text-[11px] font-semibold uppercase tracking-[0.16em]`,Q?`text-primary`:`text-foreground/78`),children:Q?`Review deploy`:X?`Deploy in progress…`:`Awaiting target`}),(0,T.jsx)(`span`,{className:v(`truncate font-mono text-[13px] leading-tight tracking-tight`,Q?`text-foreground`:`text-foreground/80`),children:J?.label??`Select a target above`})]}),(0,T.jsx)(`span`,{className:v(`flex shrink-0 items-center pr-2.5 sm:pr-3`,Q&&`pl-1`),children:(0,T.jsx)(`span`,{className:v(`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,T.jsx)(He,{className:`size-4`,strokeWidth:2.25})})})]})]})}),(0,T.jsx)(oe,{children:St&&$?(0,T.jsx)(be,{title:$.title,subtitle:$.subtitle,canDismiss:!X,footerAction:X&&a.operation?.operationId?(0,T.jsx)(h,{variant:`outline`,size:`sm`,disabled:Z,"aria-busy":Z,className:v(`ml-auto group h-8 gap-1.5 px-3 text-xs`,Z?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),onClick:()=>{a.cancel().catch(()=>{})},children:Z?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(x,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,T.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,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(g,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,T.jsx)(p.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})}):(0,T.jsx)(`div`,{className:`ml-auto shrink-0 flex items-center`,children:(0,T.jsx)(h,{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,T.jsx)(Se,{operation:a.operation,catalogTemplates:[{id:t,name:n}],logs:a.logs}):(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(x,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`text-xs text-foreground/88`,children:`Connecting to Litmus Edge…`})]}),(0,T.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/40`,children:(0,T.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}),(W||H)&&!X?(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,T.jsx)(ge,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,T.jsxs)(`span`,{className:`truncate`,children:[`Preview for `,J?.label??`target`,`: `,n]})]}),(0,T.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:q,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),`Close preview`]})]}),W?(0,T.jsx)(De,{}):H?(0,T.jsx)(je,{plan:H,planKind:`apply`,onCloseTable:q}):null]}):null,(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border/40 pt-5`,children:[(0,T.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Export`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Format`}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,T.jsxs)(Ve,{value:_,onValueChange:e=>{e&&Ke(e)},children:[(0,T.jsx)(Be,{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,T.jsx)(Ie,{placeholder:`Select format`,children:t=>{if(t===`source-yaml`)return`Source YAML`;let n=Ue.find(e=>e.id===t);return n?.id===`litmus-edge`?ot(e):n?.exportLabel??`Select format`}})}),(0,T.jsxs)(Le,{children:[(0,T.jsxs)(ze,{children:[(0,T.jsx)(Fe,{children:`Platform`}),Ge.map(t=>(0,T.jsx)(y,{value:t.id,children:t.id===`litmus-edge`?ot(e):t.exportLabel},t.id)),We.map(e=>(0,T.jsx)(y,{value:e.id,disabled:!0,children:(0,T.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.exportLabel,(0,T.jsx)(Ye,{variant:`outline`,className:`px-1 py-0 text-[10px] text-foreground/72`,children:`Coming Soon`})]})},e.id))]}),(0,T.jsx)(Re,{}),(0,T.jsxs)(ze,{children:[(0,T.jsx)(Fe,{children:`Source`}),(0,T.jsxs)(y,{value:`source-yaml`,children:[`Source YAML`,` `,(0,T.jsx)(`span`,{className:`text-foreground/72`,children:e===`model`?`.twin.yaml`:`.miravo.yaml`})]})]})]})]}),(0,T.jsxs)(h,{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:!yt,onClick:bt,children:[(0,T.jsx)(qe,{className:`size-3.5`}),`Download`]})]})]}),(0,T.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/70`,children:(0,T.jsx)(Pe,{format:_,kind:e})})]}),J&&(0,T.jsx)(ve,{open:Xe,onOpenChange:w,type:`apply`,label:n,targetLabel:J.label,hostname:J.hostname,sourceHostname:J.sourceHostname,onConfirm:mt,defaultDeviceName:e===`model`?nt(t):void 0,defaultNamePrefix:e===`template`?t:void 0,metadata:e===`model`?[{label:`Protocol`,value:d.toUpperCase()},_e]:Oe,applyPreview:{onPreview:e=>void ht(e),planLoading:W,disabled:!l||X}}),(0,T.jsx)(Te,{open:E,editing:!1,platformId:O,form:A,showToken:Ze,saving:tt,testing:st,canTestConnection:pt,onOpenChange:D,onPlatformChange:k,onFormChange:j,onShowTokenChange:N,onSave:()=>void gt(),onTestConnection:_t,onCancelInFlight:L}),(0,T.jsx)(le,{open:ct,onOpenChange:e=>{R(e),e||B(P)},children:(0,T.jsxs)(de,{className:`sm:max-w-md`,children:[(0,T.jsxs)(ue,{children:[(0,T.jsx)(fe,{children:`Download Litmus Edge Template`}),(0,T.jsx)(ce,{children:me})]}),(0,T.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,T.jsx)(S,{htmlFor:`deploy-export-source-host`,children:Ne}),(0,T.jsx)(pe,{id:`deploy-export-source-host`,value:z,onChange:e=>B(e.target.value),placeholder:P,autoComplete:`off`,className:`font-mono text-sm`}),(0,T.jsxs)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Use an IP or hostname reachable from Litmus Edge (e.g.`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:P}),` for Docker bridge).`]})]}),(0,T.jsxs)(se,{className:`gap-2 sm:gap-0`,children:[(0,T.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>R(!1),disabled:V,children:`Cancel`}),(0,T.jsxs)(h,{type:`button`,className:`gap-1.5`,onClick:()=>void xt(),disabled:V,"aria-busy":V,children:[V?(0,T.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,T.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]})]})})]})}var I={builtin:`Built-in`,personal:`Personal`,community:`Community`},L=`border-border/60 bg-muted/40 text-muted-foreground`,ct={builtin:L,personal:`border-primary/40 bg-primary/10 text-primary`,community:`border-accent/40 bg-accent/10 text-accent`};function R(e){return e===`cwd`||e===`namespace`?`personal`:e}function z(e){return I[R(e)]??e}function B(e){return ct[R(e)]??L}export{E as a,A as c,Xe as d,st as i,j as l,z as n,k as o,R as r,Ze as s,B as t,w as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./control-HqgjVMLG.js";export{e as ControlPage};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{A as r,B as i,F as a,I as o,L as s,N as c,it as l,k as u}from"./api-5BZroqlO.js";import{t as d}from"./proxy-Be4WzmcS.js";import{t as f}from"./AnimatePresence-CPmH1DMY.js";import{i as p,r as m}from"./dist-xY0pK9Wy.js";import{a as h,i as g,l as ee,n as _,o as v,r as te,s as y,t as b}from"./copy-button-DnGsXbVV.js";import{t as x}from"./shallow-Cin0mLuv.js";import{C as S,S as C,T as ne,d as re,f as w,u as T}from"./format-B9CcV2dj.js";import{n as E,t as D}from"./utils-XFKvwlFT.js";import{t as ie}from"./activity-Cy_niK56.js";import{t as O}from"./arrow-right-BjBb4z7g.js";import{c as k,i as A,l as ae,n as oe,s as se,t as ce}from"./select-CMOnuEoT.js";import{a as le,c as j,i as ue,n as M,o as N,r as de,s as fe,t as pe}from"./tabs-D64chVAn.js";import{a as P,c as me,i as he,l as ge,n as _e,r as ve,s as F,t as I}from"./validation-Bt4EQDja.js";import{i as ye,n as be,r as xe,t as Se}from"./checkbox-C84IyqEB.js";import{t as Ce}from"./layers-1figUpjG.js";import{c as we,r as Te,t as L}from"./use-engine-command-mutation-CIly3RgV.js";import{t as R}from"./triangle-alert-BXrJNk3g.js";import{i as Ee,n as De,t as Oe}from"./tooltip-D1ydB4g3.js";import{t as ke}from"./transition-nav-link-CDSeWWsP.js";import{t as z}from"./badge-i00PiRCo.js";import{t as B}from"./label-DTHSKF2S.js";import{a as V,c as H,i as U,l as W,n as G,o as K,r as q,s as J,t as Y}from"./combobox-BJecIYHE.js";import{t as Ae}from"./spawn-protocol-scope-picker-DUXJ8giB.js";var je=E(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=E(`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`}]]),Ne=E(`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`}]]),Pe=E(`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`}]]),Fe=E(`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`}]]),Ie=E(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Le=E(`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`}]]),Re=E(`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`}]]),ze=E(`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`}]]),Be=E(`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`}]]),X=e(t(),1),Z=n(),Ve={mqtt:le,opcua:be,modbus:Me},He={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus TCP`},Ue={mqtt:o,opcua:s,modbus:a};function We({adapter:e}){let t=e.pending?`pending`:e.enabled?`enabled`:`disabled`;return(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:(0,Z.jsx)(d.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,Z.jsxs)(z,{className:`gap-1 bg-info/20 text-info hover:bg-info/20`,children:[(0,Z.jsx)(N,{className:`size-3 animate-spin`}),e.enabled?`Disabling...`:`Enabling...`]}):e.enabled?(0,Z.jsxs)(z,{className:`gap-1 bg-success/20 text-success hover:bg-success/20`,children:[(0,Z.jsx)(j,{className:`size-3`}),`Enabled`]}):(0,Z.jsxs)(z,{variant:`outline`,className:`gap-1 text-muted-foreground`,children:[(0,Z.jsx)(je,{className:`size-2`}),`Disabled`]})},t)})}function Ge({metrics:e}){return e?e.connected?null:(0,Z.jsxs)(z,{variant:`destructive`,className:`gap-1`,children:[(0,Z.jsx)(fe,{className:`size-3`}),`Disconnected`]}):null}function Ke({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,Z.jsx)(j,{className:r,"aria-hidden":!0}):n===`busy`?(0,Z.jsx)(ie,{className:r,"aria-hidden":!0}):n===`saturated`?(0,Z.jsx)(R,{className:r,"aria-hidden":!0}):null;return(0,Z.jsxs)(z,{className:D(`gap-1`,t[n]??``),children:[i,n]})}function Q({label:e,value:t,valueClassName:n}){return(0,Z.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,Z.jsx)(`span`,{className:`blueprint-title text-[10px] leading-tight text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:D(`mt-1.5 font-mono text-[13px] leading-none tabular-nums tracking-tight text-foreground`,n),children:t})]})}function qe({metrics:e}){return(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(Q,{label:`Messages sent`,value:T(e.messagesPublished)}),(0,Z.jsx)(Q,{label:`Attempted`,value:T(e.messagesAttempted)}),(0,Z.jsx)(Q,{label:`Skipped (unchanged)`,value:T(e.messagesFiltered)}),(0,Z.jsx)(Q,{label:`Errors`,value:T(e.errorsCount),valueClassName:e.errorsCount>0?`text-destructive`:void 0}),(0,Z.jsx)(Q,{label:`Publish latency`,value:`${e.lastPublishMs.toFixed(1)} ms`}),e.health?(0,Z.jsx)(Q,{label:`Queued messages`,value:String(e.health.pendingWorkCount)}):null]})}function Je({port:e}){return(0,Z.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,Z.jsx)(R,{className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Before enabling`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-warning`,children:[`Ensure port `,(0,Z.jsx)(`code`,{className:`font-mono font-bold`,children:e}),` is available on the host.`]}),(0,Z.jsxs)(`ul`,{className:`mt-1 list-inside list-disc space-y-0.5 text-warning`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:`Docker:`}),` Restart with`,` `,(0,Z.jsxs)(`code`,{className:`font-mono`,children:[`-p `,e,`:`,e]}),` `,`to expose the port.`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:`Bare metal:`}),` Run `,(0,Z.jsxs)(`code`,{className:`font-mono`,children:[`lsof -i :`,e]}),` to check availability.`]})]})]})]})}function Ye({adapter:e,metrics:t}){let[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(!1),c=L(),l=Ve[e.name]??be,u=He[e.name]??e.name,p=Ue[e.name]??0,m=o||e.pending===!0,h=(0,X.useMemo)(()=>{let t=e.config?.port;return typeof t==`number`?t:p},[e.config,p]);return(0,Z.jsxs)(`div`,{className:`protocol-card-art min-w-0 border`,children:[(0,Z.jsxs)(`div`,{className:`relative z-2`,children:[(0,Z.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,Z.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,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-start justify-between gap-x-3 gap-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.enabled&&!e.pending&&(0,Z.jsx)(`span`,{className:`protocol-card-live-dot`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`whitespace-nowrap font-medium tracking-tight`,children:u}),(0,Z.jsx)(We,{adapter:e}),e.enabled&&!e.pending&&t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ge,{metrics:t}),t.health?(0,Z.jsx)(Ke,{health:t.health}):(0,Z.jsxs)(z,{className:`gap-1 bg-success/20 text-success hover:bg-success/20`,children:[(0,Z.jsx)(j,{className:`size-3 shrink-0`,"aria-hidden":!0}),`healthy`]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.enabled&&t&&!e.pending&&(0,Z.jsxs)(`span`,{className:`protocol-card-metric-readout text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-normal uppercase tracking-[0.12em] text-muted-foreground`,children:`out`}),` `,(0,Z.jsx)(`span`,{className:`text-foreground`,children:T(t.messagesPublished)}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:` msgs`}),t.errorsCount>0&&(0,Z.jsxs)(`span`,{className:`ml-1.5 text-destructive`,children:[t.errorsCount,` err`]})]}),(0,Z.jsx)(ae,{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,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 px-4 pb-2 pl-11`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,Z.jsx)(b,{value:e.endpoint,label:`Copy endpoint URL`})]})]}),(0,Z.jsx)(f,{initial:!1,children:n&&(0,Z.jsx)(d.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,Z.jsx)(`div`,{className:`protocol-card-art-body border-t`,children:e.enabled&&t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`px-4 pb-4 pt-4`,"aria-labelledby":`protocol-telemetry-${e.name}`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,Z.jsx)(`h4`,{id:`protocol-telemetry-${e.name}`,className:`blueprint-title shrink-0 text-muted-foreground`,children:`Telemetry`}),(0,Z.jsxs)(ke,{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,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:`Browse Tags`}),(0,Z.jsx)(O,{className:`size-3 shrink-0 text-primary transition-transform group-hover/footer-link:translate-x-0.5`})]})]}),(0,Z.jsx)(qe,{metrics:t})]}),(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsxs)(S,{variant:`destructive`,size:`sm`,className:`gap-1.5`,disabled:m,onClick:async()=>{s(!0);try{await c.mutateAsync({type:`disableAdapter`,adapter:e.name})}catch{}finally{s(!1)}},children:[m?(0,Z.jsx)(N,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Fe,{className:`size-3.5`}),m?`Disabling...`:`Disable ${u}`]}),!m&&(0,Z.jsx)(`span`,{className:`text-xs leading-snug text-muted-foreground`,children:`Active connections will be dropped.`})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 py-4`,children:[!m&&(0,Z.jsx)(Je,{port:i&&Number(i)||h}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(B,{htmlFor:`port-${e.name}`,className:`text-xs`,children:`Port`}),(0,Z.jsx)(C,{id:`port-${e.name}`,type:`number`,placeholder:String(h),value:i,onChange:e=>a(e.target.value),className:`w-28`,disabled:m})]}),(0,Z.jsxs)(S,{size:`sm`,className:`gap-1.5`,disabled:m,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:[m?(0,Z.jsx)(N,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Ie,{className:`size-3.5`}),m?`Enabling...`:`Enable ${u}`]})]})]})})},`panel`)})]})}function Xe(){let{instances:e,models:t,templateRuns:n}=l(x(e=>({instances:e.instances,models:e.models,templateRuns:e.templateRuns}))),i=L(),[a,o]=(0,X.useState)(``),[s,p]=(0,X.useState)(`1`),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,te]=(0,X.useState)([]),[y,b]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),[E,ie]=(0,X.useState)(``),O=(0,X.useMemo)(()=>E?t.filter(e=>e.name.toLowerCase().includes(E.toLowerCase())):t,[t,E]),k=Number(s)||1,A=a?r(a):``,ae=m.trim()?m.trim():u(g.trim()||A||`instance`,1);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(Ce,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Fleet Management`]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Spawn Instances`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-0 sm:flex-1`,children:(0,Z.jsxs)(Y,{value:a||null,onValueChange:e=>o(e??``),onInputValueChange:ie,children:[(0,Z.jsx)(q,{placeholder:`Select model`,className:`h-8 w-full min-w-0`,showClear:!!a}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[O.map(e=>(0,Z.jsx)(U,{value:e.name,children:e.name},e.name)),O.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(C,{type:`number`,value:s,onChange:e=>p(e.target.value),className:`h-8 w-16 text-xs`,min:`1`,"aria-label":`Number of instances to spawn`}),(0,Z.jsx)(S,{size:`sm`,className:`h-8`,disabled:y!=null||w!=null||!a,onClick:()=>{if(m.trim()&&k!==1){ee.error(`Exact instance ID requires count 1.`);return}let e=P(he,{model:a,count:k,...m.trim()?{instanceName:m.trim()}:{},...g.trim()?{instancePrefix:g.trim()}:{},...v.length>0?{protocolScope:v}:{}});e&&i.mutate({type:`spawn`,...e})},children:`Spawn`})]})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(B,{htmlFor:`fleet-station-instance-name`,className:`text-[10px]`,children:`Exact instance ID`}),(0,Z.jsx)(C,{id:`fleet-station-instance-name`,value:m,maxLength:120,onChange:e=>{let t=e.target.value;h(t),t&&(_(``),T(null)),b(c(t))},placeholder:k===1?`Exact instance ID`:`Exact name needs count 1`,disabled:k!==1,className:D(`h-8 min-w-0 font-mono text-xs`,y&&`border-destructive`),"aria-invalid":y!=null,"aria-label":`Exact instance ID`}),y?(0,Z.jsx)(`p`,{className:`text-[10px] text-destructive`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(B,{htmlFor:`fleet-station-instance-prefix`,className:`text-[10px]`,children:`Generated prefix`}),(0,Z.jsx)(C,{id:`fleet-station-instance-prefix`,value:g,maxLength:120,onChange:e=>{let t=e.target.value;_(t),t&&(h(``),b(null)),T(c(t))},placeholder:A||`Generated prefix`,className:D(`h-8 min-w-0 font-mono text-xs`,w&&`border-destructive`),"aria-invalid":w!=null,"aria-label":`Generated prefix`}),w?(0,Z.jsx)(`p`,{className:`text-[10px] text-destructive`,children:w}):null]})]}),(0,Z.jsx)(Ae,{value:v,onChange:te,className:`pt-1`}),(0,Z.jsxs)(`span`,{className:`min-w-0 wrap-break-word text-[10px] text-muted-foreground`,children:[t.length,` models · `,e.length,` running · default`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:A||`auto`}),` · preview`,` `,(0,Z.jsx)(`span`,{className:`break-all font-mono text-foreground`,children:ae})]})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Environment Runs`}),(0,Z.jsx)(f,{initial:!1,children:n.map(e=>(0,Z.jsx)(d.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,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-[var(--miravo-radius-tight)] border px-2.5 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-medium`,children:re(e.templateName)}),(0,Z.jsxs)(z,{variant:`secondary`,className:`shrink-0 text-[10px]`,children:[e.instanceIds.length,` inst`]})]}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-1.5 text-destructive hover:text-destructive`,"aria-label":`Unload environment run`,onClick:()=>i.mutate({type:`unloadTemplateRun`,templateRunId:e.templateRunId}),children:(0,Z.jsx)(ne,{className:`size-3`})})]})},e.templateRunId))})]})]})]})]})}function Ze(){let{instances:e,models:t}=l(x(e=>({instances:e.instances,models:e.models}))),n=L(),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),u=(0,X.useMemo)(()=>s?e.filter(e=>e.id.toLowerCase().includes(s.toLowerCase())):e,[e,s]),p=(0,X.useMemo)(()=>{let n=e.find(e=>e.id===r);return n?t.find(e=>e.name===n.model)?.faultNames??[]:[]},[r,e,t]),m=(0,X.useMemo)(()=>e.filter(e=>e.activeFaults.length>0),[e]),h=m.reduce((e,t)=>e+t.activeFaults.length,0);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(R,{className:`size-3.5 ${h>0?`text-destructive`:`text-muted-foreground`}`}),`Fault Lab`,(0,Z.jsx)(f,{children:h>0&&(0,Z.jsx)(d.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,Z.jsxs)(z,{variant:`destructive`,className:`text-[10px]`,children:[h,` active`]})},`fault-count`)})]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(Y,{value:r||null,onValueChange:e=>{i(e??``),o(``)},onInputValueChange:c,children:[(0,Z.jsx)(q,{placeholder:`Select instance`,className:`h-8 min-h-11 w-full min-w-0 touch-manipulation sm:min-h-8`,showClear:!!r}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[u.map(e=>(0,Z.jsxs)(U,{value:e.id,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id}),e.activeFaults.length>0&&(0,Z.jsx)(z,{variant:`destructive`,className:`ml-auto text-[10px]`,children:e.activeFaults.length})]},e.id)),u.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]}),(0,Z.jsxs)(ce,{value:a,onValueChange:e=>o(e??``),children:[(0,Z.jsx)(se,{className:`h-8 min-h-11 w-full touch-manipulation sm:min-h-8`,"aria-label":`Fault type`,children:(0,Z.jsx)(k,{placeholder:r?`Select fault`:`Pick instance first`})}),(0,Z.jsx)(oe,{alignItemWithTrigger:!1,align:`start`,children:p.map(e=>(0,Z.jsx)(A,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(S,{variant:`destructive`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!a,onClick:()=>{let e=P(I,{instanceId:r,fault:a});e&&n.mutate({type:`triggerFault`,...e})},children:`Trigger`}),(0,Z.jsx)(S,{variant:`secondary`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!a,onClick:()=>{let e=P(I,{instanceId:r,fault:a});e&&n.mutate({type:`clearFault`,...e})},children:`Clear`})]}),(0,Z.jsx)(F,{}),(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:m.length>0?(0,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Faulted Instances`}),(0,Z.jsx)(f,{initial:!1,children:m.map(e=>(0,Z.jsx)(d.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,Z.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,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-destructive`,children:e.activeFaults.join(`, `)})]})},e.id))})]},`faulted`):(0,Z.jsxs)(d.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,Z.jsx)(j,{className:`size-3.5 text-success`}),`All clear — no active faults`]},`all-clear`)})]})]})}function Qe(){let e=l(e=>e.instances),t=L(),[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),c=(0,X.useMemo)(()=>o?e.filter(e=>e.id.toLowerCase().includes(o.toLowerCase())):e,[e,o]),u=(0,X.useMemo)(()=>e.filter(e=>e.isQuarantined),[e]),p=(0,X.useMemo)(()=>e.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,[e]),m=(0,X.useMemo)(()=>e.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,[e]);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(Re,{className:`size-3.5 text-muted-foreground`}),`Instance Actions`]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Remove Instance`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-0 sm:flex-1`,children:(0,Z.jsxs)(Y,{value:n||null,onValueChange:e=>{r(e??``),a(!1)},onInputValueChange:s,children:[(0,Z.jsx)(q,{placeholder:`Select instance`,className:`h-8 w-full min-w-0`,showClear:!!n}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[c.map(e=>(0,Z.jsx)(U,{value:e.id,children:(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),c.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),i&&n?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-destructive`,children:`Remove?`}),(0,Z.jsx)(S,{size:`sm`,variant:`destructive`,className:`h-7 text-xs`,onClick:()=>{t.mutate({type:`removeInstance`,instanceId:n}),a(!1),r(``)},children:`Confirm`}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>a(!1),children:`Cancel`})]}):(0,Z.jsxs)(S,{className:`h-8 w-full shrink-0 gap-1.5 sm:w-auto`,variant:`destructive`,size:`sm`,disabled:!n,onClick:()=>{P(_e,{instanceId:n})&&a(!0)},children:[(0,Z.jsx)(Be,{className:`size-3`}),`Remove`]})]})]}),(0,Z.jsx)(F,{}),(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:u.length>0?(0,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wider text-warning`,children:[`Quarantined`,(0,Z.jsx)(z,{variant:`secondary`,className:`text-[10px] text-warning`,children:u.length})]}),(0,Z.jsx)(f,{initial:!1,children:u.map(e=>(0,Z.jsx)(d.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,Z.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,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Z.jsx)(S,{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,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Fleet Health`}),(0,Z.jsx)(`div`,{className:`flex items-center gap-4 text-xs`,children:e.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-2 rounded-full bg-success`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:p}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`healthy`})]}),m>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-2 rounded-full bg-warning`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:m}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`faulted`})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ze,{className:`size-3 text-success`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`0 quarantined`})]})]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`No instances running`})})]},`fleet-health`)})]})]})}function $e(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 et(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 tt({data:e}){let t=(0,X.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,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`svg`,{viewBox:`0 0 200 32`,className:`h-8 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":`TPS trend sparkline`,children:[(0,Z.jsx)(`line`,{x1:`0`,y1:`10.7`,x2:`200`,y2:`10.7`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`line`,{x1:`0`,y1:`21.3`,x2:`200`,y2:`21.3`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`path`,{d:t.points,fill:`none`,stroke:`var(--primary)`,strokeWidth:`1.5`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`60s ago · `,t.min.toFixed(1)]}),(0,Z.jsxs)(`span`,{children:[t.max.toFixed(1),` · now`]})]})]}):(0,Z.jsx)(`div`,{className:`flex h-8 items-center text-[10px] text-muted-foreground`,children:`Collecting...`})}var nt={running:`bg-success`,paused:`bg-warning`,idle:`bg-muted-foreground`,stopped:`bg-destructive`};function rt({state:e}){let t=nt[e]??`bg-muted-foreground`,n=e===`running`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`size-2.5 rounded-full ${t}`}),n&&(0,Z.jsx)(`span`,{className:`absolute size-2.5 animate-ping rounded-full ${t} opacity-40`})]}),(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:(0,Z.jsx)(d.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 $({label:e,tooltip:t,tooltipClassName:n}){return(0,Z.jsxs)(`div`,{className:`inline-flex w-fit min-w-0 max-w-full items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`blueprint-title min-w-0 shrink text-[11px] leading-tight text-muted-foreground`,children:e}),(0,Z.jsxs)(Oe,{children:[(0,Z.jsx)(Ee,{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,Z.jsx)(`button`,{type:`button`}),"aria-label":`About ${e}`,children:(0,Z.jsx)(ye,{className:`size-3`,"aria-hidden":!0})}),(0,Z.jsx)(De,{side:`top`,className:D(`max-w-xs`,n),children:t})]})]})}function it(){let{engineState:e,connectionState:t}=l(x(e=>({engineState:e.engineState,connectionState:e.connectionState}))),n=L();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Run state`,tooltip:(0,Z.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,Z.jsx)(rt,{state:e}),t===`live`&&(e===`running`||e===`paused`)&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-2`,children:(0,Z.jsxs)(S,{type:`button`,size:`sm`,variant:e===`paused`?`default`:`outline`,className:D(`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,Z.jsx)(we,{className:`size-3`}):(0,Z.jsx)(Pe,{className:`size-3`}),e===`paused`?`Resume`:`Pause`]})})]})}function at(){let{speedMultiplier:e,connectionState:t}=l(x(e=>({speedMultiplier:e.speedMultiplier,connectionState:e.connectionState}))),n=L(),[r,i]=(0,X.useState)(String(e)),a=t===`live`;return(0,X.useEffect)(()=>{i(String(e))},[e]),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Speed`,tooltip:(0,Z.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,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[e,`x`]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{htmlFor:`speed-multiplier`,className:`sr-only`,children:`Speed multiplier`}),(0,Z.jsx)(C,{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,Z.jsx)(S,{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=P(ve,{multiplier:Number(r)});e&&n.mutate({type:`setSpeed`,multiplier:e.multiplier})},children:`Set`})]})]})}function ot(){let{tick:e,simulationTime:t,tps:n,tpsHistory:r,uptimeMs:i,instanceCount:a,memberValueCount:o}=l(x(e=>({tick:e.tick,simulationTime:e.simulationTime,tps:e.tps,tpsHistory:e.tpsHistory,uptimeMs:e.uptimeMs,instanceCount:e.instanceCount,memberValueCount:e.memberValueCount})));return(0,Z.jsxs)(`div`,{className:D(Te,`px-4 py-3`),children:[(0,Z.jsxs)(`header`,{className:`mb-3 border-b border-border/60 pb-2`,children:[(0,Z.jsx)(`h2`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Engine vitals`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Scheduler, speed, cycle count, and throughput for this session.`})]}),(0,Z.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,Z.jsx)(it,{}),(0,Z.jsx)(at,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Cycle`,tooltipClassName:`flex flex-col items-start gap-2 text-left`,tooltip:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.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,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[`The number is `,(0,Z.jsx)(`span`,{className:`font-medium`,children:`tick`}),` count — completed scheduler steps since this run. Each tick refreshes the plant model and live tags.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.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,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Real`}),` is wall-clock uptime since the run started (real time).`]})]})}),(0,Z.jsx)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:T(e)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex w-full min-w-0 flex-col gap-0.5 leading-tight`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Sim`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:et(t)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Real`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:$e(i)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Throughput`,tooltip:(0,Z.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,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[n.toFixed(1),` tps`]}),(0,Z.jsxs)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[a,` inst · `,w(o),` tags`]})]}),(0,Z.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`TPS Trend`,tooltip:(0,Z.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,Z.jsx)(tt,{data:r})]})]})]})}var st=[`MQTT Sparkplug B`,`EtherNet/IP`,`Siemens S7`];function ct({enabled:e,total:t}){let n=t===0?`empty`:e===0?`idle`:`live`;return(0,Z.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,Z.jsxs)(`span`,{className:`relative flex size-1.5 items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:D(`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,Z.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-success/60`})]}),(0,Z.jsxs)(`span`,{className:`text-[11px] leading-none text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`mx-1 text-muted-foreground/60`,children:`/`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:t}),(0,Z.jsx)(`span`,{className:`ml-1.5 text-[10px] uppercase tracking-[0.14em]`,children:`active`})]})]})}function lt(){let{availableAdapters:e,adapterMetrics:t}=l(x(e=>({availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled).length;return(0,Z.jsxs)(`section`,{className:D(Te,`flex min-w-0 flex-col hover:border-border`),children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-border/60 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.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,Z.jsx)(Le,{className:`size-3.5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Protocol Gateway`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-pretty text-xs text-muted-foreground`,children:`Northbound adapters publishing engine telemetry to external systems.`})]})]}),(0,Z.jsx)(ct,{enabled:n,total:e.length})]}),e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 px-4 py-4`,children:(0,Z.jsx)(f,{children:e.map((e,n)=>{let r=t.find(t=>t.name===e.name)?.metrics;return(0,Z.jsx)(d.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,Z.jsx)(Ye,{adapter:e,metrics:r})},e.name)})})}),(0,Z.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: ${st.join(`, `)}, and more`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(xe,{className:`size-3 text-muted-foreground/70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Roadmap`})]}),(0,Z.jsxs)(`ul`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[st.map(e=>(0,Z.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,Z.jsx)(`li`,{className:`font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground/75`,children:`+ more`})]})]})]})}function ut(){let e=l(e=>e.instances),t=L(),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,children:[(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(Ne,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Danger Zone`]})}),(0,Z.jsx)(J,{className:`flex flex-1 flex-col`,children:(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Reset environment`}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Removes `,e.length,` running instance`,e.length===1?``:`s`,` and all loaded environments.`]})]}),(0,Z.jsx)(S,{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,Z.jsx)(_,{open:n,onOpenChange:e=>{r(e),e||a(!1)},children:(0,Z.jsxs)(te,{children:[(0,Z.jsxs)(v,{children:[(0,Z.jsx)(y,{children:`Reset Environment`}),(0,Z.jsx)(g,{children:`Removes all running instances and loaded environments.`})]}),(0,Z.jsx)(`div`,{className:`space-y-3 text-sm`,children:(0,Z.jsx)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border p-3`,children:(0,Z.jsxs)(B,{htmlFor:`clear-persisted-state`,className:`items-start`,children:[(0,Z.jsx)(Se,{id:`clear-persisted-state`,checked:i,onCheckedChange:e=>a(e===!0)}),(0,Z.jsxs)(`span`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`block font-medium text-foreground`,children:`Also clear persisted state`}),(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Start empty on the next restart.`})]})]})})}),(0,Z.jsxs)(h,{children:[(0,Z.jsx)(S,{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,Z.jsx)(S,{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 dt(){let[e,t]=p(`tab`,m([`monitor`,`operate`]).withDefault(`monitor`));return(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Mission Control`}),(0,Z.jsxs)(z,{variant:`outline`,title:`Miravo version ${i}`,className:`font-mono text-[10px] leading-none text-muted-foreground`,children:[`v`,i]})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Engine telemetry, protocol management, and fleet operations.`})]}),(0,Z.jsxs)(pe,{value:e,onValueChange:e=>{t(e)},className:`min-h-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,Z.jsxs)(de,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Z.jsxs)(ue,{value:`monitor`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(ge,{className:`size-3.5 shrink-0`}),`Monitor`]}),(0,Z.jsxs)(ue,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(me,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,Z.jsx)(M,{value:`monitor`,className:`flex-1 py-2`,children:(0,Z.jsxs)(d.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,Z.jsx)(ot,{}),(0,Z.jsx)(lt,{})]},`monitor`)}),(0,Z.jsx)(M,{value:`operate`,className:`flex-1 py-2`,children:(0,Z.jsxs)(d.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,Z.jsx)(Xe,{}),(0,Z.jsx)(Qe,{}),(0,Z.jsx)(Ze,{}),(0,Z.jsx)(ut,{})]},`operate`)})]})]})}export{Le as n,dt as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./events-przfMV9x.js";export{e as EventsPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{S as r,o as i,rt as a,v as o}from"./api-Bf6pFRhP.js";import{i as ee,s as te,t as s}from"./query-fetch-error-BqiDQT2r.js";import{t as c}from"./proxy-Be4WzmcS.js";import{t as ne}from"./AnimatePresence-CPmH1DMY.js";import{u as l}from"./chunk-OE4NN4TA-DBWZidbW.js";import{C as u,_ as d,t as f}from"./format-B9CcV2dj.js";import{c as re,i as p,n as m,s as ie,t as ae}from"./select-CMOnuEoT.js";import{n as h,t as oe}from"./use-transition-navigate-DtyJz2Z1.js";import{t as se}from"./badge-i00PiRCo.js";import{n as ce}from"./transition-types-CPlGtM8w.js";import{n as le}from"./auth-screen-backdrop-CgwRhIbi.js";import{n as g}from"./get-error-message-yQcVJ-Ja.js";import{r as ue}from"./runtime-link-D-uJbw97.js";import{a as de,i as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./combobox-BJecIYHE.js";import{a as _,c as v,i as y,o as b,r as ve,s as ye,t as be}from"./select-display-items-y2L7MHmk.js";var x=e(t(),1);function xe(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 Se(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 S(e){if(`targetLabel`in e)return typeof e.targetLabel==`string`?e.targetLabel:void 0}function C(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=S(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 Ce(e,t){let n=new Date(e);return n.toDateString()===t.toDateString()?n.toLocaleTimeString(f):n.toLocaleString(f,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function w(e){if(`instanceId`in e&&typeof e.instanceId==`string`)return e.instanceId}function T(e){return e.type===`platform:operation`||e.type===`platform:resource`?S(e):w(e)}function E(e){return`fault`in e?d(e.fault):e.type===`platform:operation`||e.type===`platform:resource`?C(e):`from`in e&&`to`in e?`${d(e.from)} \u2192 ${d(e.to)}`:``}function D(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()}`}var O=n(),k=1500;function A(){let e=te(),[t]=l(),n=t.get(`type`)??`all`,d=t.get(`instanceId`)??``,[f,S]=(0,x.useState)(n),[C,A]=(0,x.useState)(d),[j,we]=(0,x.useState)(!0),M=ue(a(e=>e.connectionState))===null,N=a(e=>e.events.length),P=(0,x.useRef)(!1),F=a(e=>e.instances),Te=oe(),I=ee({queryKey:o.events(f,C),queryFn:()=>i(D(f,C,null),r.events),refetchInterval:j&&M?k:!1,staleTime:5e3}),[Ee,L]=(0,x.useState)([]),[De,R]=(0,x.useState)(!1),[Oe,z]=(0,x.useState)(null),B=`${f}::${C}`,V=(0,x.useRef)(B);(0,x.useEffect)(()=>{B!==V.current&&(V.current=B,L([]),z(null),U(!1))},[B]),(0,x.useEffect)(()=>{S(e=>e===n?e:n)},[n]),(0,x.useEffect)(()=>{A(e=>e===d?e:d)},[d]);let[H,U]=(0,x.useState)(()=>(I.data?.events.length??0)>0),W=I.data?[I.data,...Ee]:[],G=W.flatMap(e=>e.events),K=W[W.length-1],q=K?.hasMore??!1;(0,x.useEffect)(()=>{G.length>0&&!H&&U(!0)},[G.length,H]);let J=(0,x.useRef)(N);(0,x.useEffect)(()=>{N!==J.current&&(J.current=N,j&&M?(e.invalidateQueries({queryKey:o.events(f,C)}),P.current=!1):j&&(P.current=!0))},[N,j,M,e,f,C]),(0,x.useEffect)(()=>{!j||!M||!P.current||(P.current=!1,e.invalidateQueries({queryKey:o.events(f,C)}))},[j,M,e,f,C]);let[Y,ke]=(0,x.useState)(``),X=(0,x.useMemo)(()=>Y?F.filter(e=>e.id.toLowerCase().includes(Y.toLowerCase())):F,[F,Y]),Z=I.isPending&&!I.data&&!I.isError,Ae=j&&!Z&&!H&&G.length===0,Q=I.error??Oe,je=I.isError&&!I.data,$=(0,x.useCallback)(()=>{I.refetch()},[I]),Me=async()=>{if(K?.nextCursor){R(!0),z(null);try{let e=await i(D(f,C,K.nextCursor),r.events);L(t=>[...t,e])}catch(e){z(e instanceof Error?e:Error(g(e,`Failed to fetch events.`)))}finally{R(!1)}}};if(je)return(0,O.jsx)(le,{className:`min-h-full`,children:(0,O.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,O.jsx)(`div`,{className:`w-full max-w-md`,children:(0,O.jsx)(s,{message:g(Q,`Failed to fetch events.`),onRetry:$,isRetrying:I.isFetching})})})});let Ne=new Date;return(0,O.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,O.jsx)(s,{message:`${g(Q,`Failed to fetch events.`)} Showing cached events.`,onRetry:$,isRetrying:I.isFetching}):null,(0,O.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,O.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,O.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Event Log`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Real-time event stream from the engine.`}),j&&!M?(0,O.jsx)(`p`,{className:`text-xs text-warning`,role:`status`,children:`Live refresh pauses until the Miravo link is live again.`}):null]}),(0,O.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,O.jsx)(`button`,{type:`button`,onClick:()=>we(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,O.jsx)(ne,{mode:`wait`,initial:!1,children:j?(0,O.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,O.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-success`}),(0,O.jsx)(`span`,{className:`font-medium text-success`,children:`LIVE`})]},`live`):(0,O.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,O.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`}),(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:`Paused`})]},`paused`)})}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,O.jsxs)(_e,{value:C||null,onValueChange:e=>{A(e??``)},onInputValueChange:ke,children:[(0,O.jsx)(he,{placeholder:`All instances`,className:`h-8 w-full min-w-0`,showClear:!!C}),(0,O.jsx)(pe,{children:(0,O.jsxs)(de,{children:[X.map(e=>(0,O.jsx)(fe,{value:e.id,children:(0,O.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),X.length===0&&(0,O.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,O.jsxs)(ae,{value:f,onValueChange:e=>{S(e??`all`)},items:be,children:[(0,O.jsx)(ie,{className:`w-full min-w-0 lg:w-48`,"aria-label":`Event type filter`,children:(0,O.jsx)(re,{placeholder:`Filter by type`})}),(0,O.jsxs)(m,{alignItemWithTrigger:!1,align:`start`,children:[(0,O.jsx)(p,{value:`all`,children:`All events`}),(0,O.jsx)(p,{value:`fault:triggered`,children:`Fault Triggered`}),(0,O.jsx)(p,{value:`fault:cleared`,children:`Fault Cleared`}),(0,O.jsx)(p,{value:`lifecycle:changed`,children:`Lifecycle Changed`}),(0,O.jsx)(p,{value:`instance:created`,children:`Instance Created`}),(0,O.jsx)(p,{value:`instance:removed`,children:`Instance Removed`}),(0,O.jsx)(p,{value:`engine:state-changed`,children:`Engine State`}),(0,O.jsx)(p,{value:`platform:resource`,children:`Platform Resource`}),(0,O.jsx)(p,{value:`platform:operation`,children:`Platform Operation`})]})]})})]})]}),(0,O.jsx)(me,{className:`min-w-0 py-0`,children:(0,O.jsx)(ge,{className:`p-0`,children:(0,O.jsxs)(ve,{children:[(0,O.jsx)(ye,{children:(0,O.jsxs)(v,{children:[(0,O.jsx)(b,{className:`hidden w-12 sm:table-cell`,children:`#`}),(0,O.jsx)(b,{children:`Type`}),(0,O.jsx)(b,{children:`Context`}),(0,O.jsx)(b,{children:`Details`}),(0,O.jsx)(b,{className:`hidden text-right md:table-cell`,children:`Cycle #`}),(0,O.jsx)(b,{className:`hidden text-right sm:table-cell`,children:`Wall Clock`})]})}),(0,O.jsxs)(y,{children:[G.map(e=>{let t=w(e),n=T(e),r=e.type===`platform:resource`||e.type===`platform:operation`;return(0,O.jsxs)(v,{className:t?`transition-colors`:``,onMouseEnter:t?()=>h(`/instance/${t}`):void 0,children:[(0,O.jsx)(_,{className:`hidden font-mono text-xs text-muted-foreground sm:table-cell`,children:e.id}),(0,O.jsx)(_,{children:(0,O.jsx)(se,{variant:xe(e.type),className:`text-xs ${Se(e.type)}`,children:r?e.type===`platform:operation`?`platform:${e.operationType}`:`${e.action}:${e.resourceType}`:e.type})}),(0,O.jsx)(_,{className:`font-mono text-xs`,children:t?(0,O.jsx)(`button`,{type:`button`,className:`rounded-[var(--miravo-radius-tight)] text-left text-primary outline-none underline-offset-4 hover:underline focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onFocus:()=>h(`/instance/${t}`),onClick:()=>Te(`/instance/${t}`,{transitionType:ce}),children:n??t}):n??`—`}),(0,O.jsx)(_,{className:`max-w-xs truncate font-mono text-xs`,children:E(e)||(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,O.jsx)(_,{className:`hidden text-right font-mono text-xs md:table-cell`,children:e.tick}),(0,O.jsx)(_,{className:`hidden text-right text-xs text-muted-foreground sm:table-cell`,children:Ce(e.timestamp,Ne)})]},e.id)}),!Z&&G.length===0&&(0,O.jsx)(v,{children:(0,O.jsx)(_,{colSpan:6,className:`py-8 text-center text-muted-foreground`,children:Ae?`Listening for events…`:`No events`})})]})]})})}),q&&(0,O.jsx)(`div`,{className:`flex justify-center border-t border-border/40 pt-4`,children:(0,O.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>void Me(),disabled:De,children:`Load older events`})})]})}export{A as t};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{S as r,it as i,o as a,v as o}from"./api-5BZroqlO.js";import{i as ee,s as te,t as s}from"./query-fetch-error-2yqCNP9X.js";import{t as c}from"./proxy-Be4WzmcS.js";import{t as ne}from"./AnimatePresence-CPmH1DMY.js";import{u as l}from"./chunk-OE4NN4TA-DBWZidbW.js";import{C as u,_ as d,t as f}from"./format-B9CcV2dj.js";import{c as re,i as p,n as m,s as ie,t as ae}from"./select-CMOnuEoT.js";import{n as h,t as oe}from"./use-transition-navigate-Bxh77tVE.js";import{t as se}from"./badge-i00PiRCo.js";import{n as ce}from"./transition-types-CPlGtM8w.js";import{n as le}from"./auth-screen-backdrop-CgwRhIbi.js";import{n as g}from"./get-error-message-CFs0lSQP.js";import{r as ue}from"./runtime-link-D-uJbw97.js";import{a as de,i as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./combobox-BJecIYHE.js";import{a as _,c as v,i as y,o as b,r as ve,s as ye,t as be}from"./select-display-items-Bqb6Sbg6.js";var x=e(t(),1);function xe(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 Se(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 S(e){if(`targetLabel`in e)return typeof e.targetLabel==`string`?e.targetLabel:void 0}function C(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=S(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 Ce(e,t){let n=new Date(e);return n.toDateString()===t.toDateString()?n.toLocaleTimeString(f):n.toLocaleString(f,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function w(e){if(`instanceId`in e&&typeof e.instanceId==`string`)return e.instanceId}function T(e){return e.type===`platform:operation`||e.type===`platform:resource`?S(e):w(e)}function E(e){return`fault`in e?d(e.fault):e.type===`platform:operation`||e.type===`platform:resource`?C(e):`from`in e&&`to`in e?`${d(e.from)} \u2192 ${d(e.to)}`:``}function D(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()}`}var O=n(),k=1500;function A(){let e=te(),[t]=l(),n=t.get(`type`)??`all`,d=t.get(`instanceId`)??``,[f,S]=(0,x.useState)(n),[C,A]=(0,x.useState)(d),[j,we]=(0,x.useState)(!0),M=ue(i(e=>e.connectionState))===null,N=i(e=>e.events.length),P=(0,x.useRef)(!1),F=i(e=>e.instances),Te=oe(),I=ee({queryKey:o.events(f,C),queryFn:()=>a(D(f,C,null),r.events),refetchInterval:j&&M?k:!1,staleTime:5e3}),[Ee,L]=(0,x.useState)([]),[De,R]=(0,x.useState)(!1),[Oe,z]=(0,x.useState)(null),B=`${f}::${C}`,V=(0,x.useRef)(B);(0,x.useEffect)(()=>{B!==V.current&&(V.current=B,L([]),z(null),U(!1))},[B]),(0,x.useEffect)(()=>{S(e=>e===n?e:n)},[n]),(0,x.useEffect)(()=>{A(e=>e===d?e:d)},[d]);let[H,U]=(0,x.useState)(()=>(I.data?.events.length??0)>0),W=I.data?[I.data,...Ee]:[],G=W.flatMap(e=>e.events),K=W[W.length-1],q=K?.hasMore??!1;(0,x.useEffect)(()=>{G.length>0&&!H&&U(!0)},[G.length,H]);let J=(0,x.useRef)(N);(0,x.useEffect)(()=>{N!==J.current&&(J.current=N,j&&M?(e.invalidateQueries({queryKey:o.events(f,C)}),P.current=!1):j&&(P.current=!0))},[N,j,M,e,f,C]),(0,x.useEffect)(()=>{!j||!M||!P.current||(P.current=!1,e.invalidateQueries({queryKey:o.events(f,C)}))},[j,M,e,f,C]);let[Y,ke]=(0,x.useState)(``),X=(0,x.useMemo)(()=>Y?F.filter(e=>e.id.toLowerCase().includes(Y.toLowerCase())):F,[F,Y]),Z=I.isPending&&!I.data&&!I.isError,Ae=j&&!Z&&!H&&G.length===0,Q=I.error??Oe,je=I.isError&&!I.data,$=(0,x.useCallback)(()=>{I.refetch()},[I]),Me=async()=>{if(K?.nextCursor){R(!0),z(null);try{let e=await a(D(f,C,K.nextCursor),r.events);L(t=>[...t,e])}catch(e){z(e instanceof Error?e:Error(g(e,`Failed to fetch events.`)))}finally{R(!1)}}};if(je)return(0,O.jsx)(le,{className:`min-h-full`,children:(0,O.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,O.jsx)(`div`,{className:`w-full max-w-md`,children:(0,O.jsx)(s,{message:g(Q,`Failed to fetch events.`),onRetry:$,isRetrying:I.isFetching})})})});let Ne=new Date;return(0,O.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,O.jsx)(s,{message:`${g(Q,`Failed to fetch events.`)} Showing cached events.`,onRetry:$,isRetrying:I.isFetching}):null,(0,O.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,O.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,O.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Event Log`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Real-time event stream from the engine.`}),j&&!M?(0,O.jsx)(`p`,{className:`text-xs text-warning`,role:`status`,children:`Live refresh pauses until the Miravo link is live again.`}):null]}),(0,O.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,O.jsx)(`button`,{type:`button`,onClick:()=>we(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,O.jsx)(ne,{mode:`wait`,initial:!1,children:j?(0,O.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,O.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-success`}),(0,O.jsx)(`span`,{className:`font-medium text-success`,children:`LIVE`})]},`live`):(0,O.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,O.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`}),(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:`Paused`})]},`paused`)})}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,O.jsxs)(_e,{value:C||null,onValueChange:e=>{A(e??``)},onInputValueChange:ke,children:[(0,O.jsx)(he,{placeholder:`All instances`,className:`h-8 w-full min-w-0`,showClear:!!C}),(0,O.jsx)(pe,{children:(0,O.jsxs)(de,{children:[X.map(e=>(0,O.jsx)(fe,{value:e.id,children:(0,O.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),X.length===0&&(0,O.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,O.jsxs)(ae,{value:f,onValueChange:e=>{S(e??`all`)},items:be,children:[(0,O.jsx)(ie,{className:`w-full min-w-0 lg:w-48`,"aria-label":`Event type filter`,children:(0,O.jsx)(re,{placeholder:`Filter by type`})}),(0,O.jsxs)(m,{alignItemWithTrigger:!1,align:`start`,children:[(0,O.jsx)(p,{value:`all`,children:`All events`}),(0,O.jsx)(p,{value:`fault:triggered`,children:`Fault Triggered`}),(0,O.jsx)(p,{value:`fault:cleared`,children:`Fault Cleared`}),(0,O.jsx)(p,{value:`lifecycle:changed`,children:`Lifecycle Changed`}),(0,O.jsx)(p,{value:`instance:created`,children:`Instance Created`}),(0,O.jsx)(p,{value:`instance:removed`,children:`Instance Removed`}),(0,O.jsx)(p,{value:`engine:state-changed`,children:`Engine State`}),(0,O.jsx)(p,{value:`platform:resource`,children:`Platform Resource`}),(0,O.jsx)(p,{value:`platform:operation`,children:`Platform Operation`})]})]})})]})]}),(0,O.jsx)(me,{className:`min-w-0 py-0`,children:(0,O.jsx)(ge,{className:`p-0`,children:(0,O.jsxs)(ve,{children:[(0,O.jsx)(ye,{children:(0,O.jsxs)(v,{children:[(0,O.jsx)(b,{className:`hidden w-12 sm:table-cell`,children:`#`}),(0,O.jsx)(b,{children:`Type`}),(0,O.jsx)(b,{children:`Context`}),(0,O.jsx)(b,{children:`Details`}),(0,O.jsx)(b,{className:`hidden text-right md:table-cell`,children:`Cycle #`}),(0,O.jsx)(b,{className:`hidden text-right sm:table-cell`,children:`Wall Clock`})]})}),(0,O.jsxs)(y,{children:[G.map(e=>{let t=w(e),n=T(e),r=e.type===`platform:resource`||e.type===`platform:operation`;return(0,O.jsxs)(v,{className:t?`transition-colors`:``,onMouseEnter:t?()=>h(`/instance/${t}`):void 0,children:[(0,O.jsx)(_,{className:`hidden font-mono text-xs text-muted-foreground sm:table-cell`,children:e.id}),(0,O.jsx)(_,{children:(0,O.jsx)(se,{variant:xe(e.type),className:`text-xs ${Se(e.type)}`,children:r?e.type===`platform:operation`?`platform:${e.operationType}`:`${e.action}:${e.resourceType}`:e.type})}),(0,O.jsx)(_,{className:`font-mono text-xs`,children:t?(0,O.jsx)(`button`,{type:`button`,className:`rounded-[var(--miravo-radius-tight)] text-left text-primary outline-none underline-offset-4 hover:underline focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onFocus:()=>h(`/instance/${t}`),onClick:()=>Te(`/instance/${t}`,{transitionType:ce}),children:n??t}):n??`—`}),(0,O.jsx)(_,{className:`max-w-xs truncate font-mono text-xs`,children:E(e)||(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,O.jsx)(_,{className:`hidden text-right font-mono text-xs md:table-cell`,children:e.tick}),(0,O.jsx)(_,{className:`hidden text-right text-xs text-muted-foreground sm:table-cell`,children:Ce(e.timestamp,Ne)})]},e.id)}),!Z&&G.length===0&&(0,O.jsx)(v,{children:(0,O.jsx)(_,{colSpan:6,className:`py-8 text-center text-muted-foreground`,children:Ae?`Listening for events…`:`No events`})})]})]})})}),q&&(0,O.jsx)(`div`,{className:`flex justify-center border-t border-border/40 pt-4`,children:(0,O.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>void Me(),disabled:De,children:`Load older events`})})]})}export{A as t};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{S as r,o as i,rt as a,v as o,y as s}from"./api-Bf6pFRhP.js";import{i as c,n as l}from"./dist-xY0pK9Wy.js";import{n as u}from"./chunk-OE4NN4TA-DBWZidbW.js";import{t as d}from"./shallow-Cin0mLuv.js";import{S as f,T as p,_ as m,b as h,c as g,d as _,f as v,l as ee,m as te,s as ne,u as y,y as re}from"./format-B9CcV2dj.js";import{t as b}from"./utils-XFKvwlFT.js";import{t as x}from"./arrow-right-BjBb4z7g.js";import{t as S}from"./arrow-up-down-C1oJAmrw.js";import{c as C,i as w,n as T,s as E,t as D}from"./select-CMOnuEoT.js";import{t as ie}from"./circle-question-mark-CJvcT6V6.js";import{i as O,n as k,t as A}from"./tooltip-D1ydB4g3.js";import{n as ae,t as oe}from"./use-transition-navigate-DtyJz2Z1.js";import{t as se}from"./badge-i00PiRCo.js";import{n as ce}from"./transition-types-CPlGtM8w.js";import{a as le,i as ue,n as de,o as fe,r as pe,s as me,t as he}from"./combobox-BJecIYHE.js";import{a as j,c as M,i as ge,n as _e,o as N,r as ve,s as ye}from"./select-display-items-y2L7MHmk.js";var P=e(t(),1);function F(e){return s.prefetchQuery({queryKey:o.instances.detail(e),queryFn:()=>i(`/instances/${e}`,r.instanceDetail),staleTime:2e3})}var I=n(),L={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},R={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},z={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function B({label:e,pip:t,pulse:n}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,I.jsx)(`span`,{className:b(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,L[t])}),(0,I.jsx)(`span`,{className:b(`relative inline-flex size-1.5 rounded-full`,L[t])})]}):(0,I.jsx)(`span`,{"aria-hidden":!0,className:b(`size-1.5 shrink-0 rounded-full`,L[t])})),(0,I.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function V({children:e,tone:t=`foreground`,live:n}){return(0,I.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:b(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,R[t]),children:e})}function H({children:e}){return(0,I.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function U(e,t){return e===t?``:t}function be({statusFilter:e,onStatusFilter:t}){let{instances:n,tps:r,memberValueCount:i,availableAdapters:o,adapterMetrics:s}=a(d(e=>({instances:e.instances,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),c=(0,P.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]),l=(0,P.useMemo)(()=>{let e=o.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>z[e.name]??e.name)}},[o,s]),f=c.activeFaultCount>0,p=f?`destructive`:c.quarantined>0?`warning`:`success`,m=f?`faulted`:`healthy`;return(0,I.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,I.jsxs)(`button`,{type:`button`,onClick:()=>t(U(e,m)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":f?`Filter to faulted instances`:`Filter to healthy instances`,className:b(`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,I.jsx)(B,{label:`Health`,pip:p}),(0,I.jsxs)(V,{tone:f?`destructive`:`success`,children:[c.pct,`%`]}),(0,I.jsx)(H,{children:c.total===0?`No instances`:[`${c.total} instance${c.total===1?``:`s`}`,c.faulted>0&&`${c.faulted} faulted`,c.quarantined>0&&`${c.quarantined} quarantined`,`${c.modelCount} model${c.modelCount===1?``:`s`}`].filter(Boolean).join(` · `)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted instances`,className:b(`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,I.jsx)(B,{label:`Faults`,pip:f?`destructive`:`success`}),(0,I.jsx)(V,{tone:f?`destructive`:`foreground`,live:!0,children:c.activeFaultCount}),(0,I.jsx)(H,{children:f?`${c.affectedCount} instance${c.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(O,{render:(0,I.jsx)(u,{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,I.jsx)(B,{label:`Tags`,pip:`primary`,pulse:!0}),(0,I.jsx)(V,{children:v(i)}),(0,I.jsxs)(H,{children:[(0,I.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,I.jsx)(k,{side:`bottom`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,I.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,I.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[y(i),` tags`]}),(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,I.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),l.enabled.length>0&&(0,I.jsx)(W,{labels:l.labels,totalMessages:l.totalMessages,totalErrors:l.totalErrors,perAdapter:l.enabled.map(e=>({name:z[e.name]??e.name,metrics:s.find(t=>t.name===e.name)?.metrics}))})]})}function W({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,I.jsxs)(A,{children:[(0,I.jsxs)(O,{render:(0,I.jsx)(u,{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,I.jsx)(B,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,I.jsx)(V,{tone:n>0?`warning`:`foreground`,live:!0,children:v(t)}),(0,I.jsxs)(H,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,I.jsx)(k,{side:`bottom`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,I.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,I.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[y(t),` total`]}),(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,I.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[y(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,I.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var G=`Commissioning → instance is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function xe(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 Se(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function Ce(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var K={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 we({state:e}){let t=K[e];return(0,I.jsxs)(A,{children:[(0,I.jsxs)(O,{render:(0,I.jsx)(`span`,{className:b(`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,I.jsx)(`span`,{"aria-hidden":!0,className:b(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,I.jsx)(`span`,{children:g(t.label)})]}),(0,I.jsx)(k,{side:`top`,children:t.help})]})}function q({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,I.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,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,I.jsx)(`span`,{children:e}),n&&(0,I.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,I.jsx)(S,{className:b(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,I.jsx)(N,{className:s,"aria-sort":l,children:r?(0,I.jsxs)(A,{children:[(0,I.jsx)(O,{render:u}),(0,I.jsx)(k,{side:`top`,children:r})]}):u})}function J({title:e,body:t,action:n}){return(0,I.jsx)(M,{children:(0,I.jsx)(j,{colSpan:7,className:`py-10`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,I.jsxs)(u,{to: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,I.jsx)(x,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Y(){let{instances:e,connectionState:t}=a(d(e=>({instances:e.instances,connectionState:e.connectionState}))),[n,r]=c(`q`,l.withDefault(``)),[i,o]=c(`model`,l.withDefault(``)),[s,u]=c(`lifecycle`,l.withDefault(``)),[g,v]=c(`status`,l.withDefault(``)),y=Se(g)?g:``,[S,L]=(0,P.useState)(`id`),[R,z]=(0,P.useState)(`asc`),B=(0,P.useRef)(null),V=oe(),[H,U]=(0,P.useState)(``);(0,P.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,P.useCallback)(e=>{e===S?z(e=>e===`asc`?`desc`:`asc`):(L(e),z(`asc`))},[S]),K=(0,P.useCallback)(e=>{v(e===``?``:e)},[v]),Y=(0,P.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]),X=(0,P.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),Te=(0,P.useMemo)(()=>[{value:`all`,label:`All stages`},...X.map(e=>({value:e,label:m(e)}))],[X]),Z=(0,P.useMemo)(()=>H?Y.filter(([e])=>h(e,H)):Y,[Y,H]),Ee=(0,P.useMemo)(()=>i?{value:i,label:_(i)}:null,[i]),Q=(0,P.useMemo)(()=>{let t=e;return i&&(t=t.filter(e=>e.model===i)),s&&(t=t.filter(e=>e.lifecycleStage===s)),n&&(t=t.filter(e=>re(e.id,n)||h(e.model,n))),y===`faulted`&&(t=t.filter(e=>e.activeFaults.length>0)),y===`quarantined`&&(t=t.filter(e=>e.isQuarantined)),y===`healthy`&&(t=t.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),xe(t,S,R)},[e,n,y,i,s,S,R]),De=y!==``||i!==``||s!==``||n!==``,Oe=(0,P.useCallback)(()=>{r(``),v(``),o(``),u(``)},[r,v,o,u]),$=(0,P.useCallback)(e=>{V(`/instance/${e}`,{transitionType:ce})},[V]),ke=e.length===0&&t!==`live`,Ae=e.length===0&&t===`live`;return(0,I.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,I.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Fleet Overview`}),(0,I.jsx)(be,{statusFilter:y,onStatusFilter:K}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(he,{value:Ee,onValueChange:e=>void o(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:U,children:[(0,I.jsx)(pe,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!i}),(0,I.jsx)(de,{children:(0,I.jsxs)(le,{children:[Z.map(([e,t])=>(0,I.jsxs)(ue,{value:{value:e,label:_(e)},children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:_(e)}),(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),Z.length===0&&(0,I.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),X.length>1&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsxs)(D,{value:s||`all`,onValueChange:e=>void u(!e||e===`all`?``:e),items:Te,children:[(0,I.jsx)(E,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,I.jsx)(C,{placeholder:`All stages`})}),(0,I.jsxs)(T,{alignItemWithTrigger:!1,align:`start`,children:[(0,I.jsx)(w,{value:`all`,children:`All stages`}),X.map(e=>(0,I.jsx)(w,{value:e,children:m(e)},e))]})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(O,{render:(0,I.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,I.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}),(0,I.jsx)(k,{side:`top`,children:G})]})]}),(0,I.jsxs)(D,{value:y||`all`,onValueChange:e=>void v(!e||e===`all`?``:e),items:_e,children:[(0,I.jsx)(E,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,I.jsx)(C,{placeholder:`All status`})}),(0,I.jsxs)(T,{alignItemWithTrigger:!1,align:`start`,children:[(0,I.jsx)(w,{value:`all`,children:`All status`}),(0,I.jsx)(w,{value:`healthy`,children:`Healthy`}),(0,I.jsx)(w,{value:`faulted`,children:`Faulted`}),(0,I.jsx)(w,{value:`quarantined`,children:`Quarantined`})]})]}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(f,{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,I.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:`/`})]}),De&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,onClick:Oe,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,I.jsx)(p,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,I.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[Q.length,` of `,e.length]})]})]}),(0,I.jsx)(fe,{className:`py-0`,children:(0,I.jsx)(me,{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,I.jsxs)(ve,{children:[(0,I.jsx)(ye,{children:(0,I.jsxs)(M,{children:[(0,I.jsx)(q,{label:`Instance`,sortKey:`id`,current:S,direction:R,onSort:W}),(0,I.jsx)(q,{label:`Model`,sortKey:`model`,current:S,direction:R,onSort:W,className:`hidden sm:table-cell`}),(0,I.jsx)(q,{label:`Lifecycle`,sortKey:`lifecycle`,current:S,direction:R,onSort:W,tooltip:G}),(0,I.jsx)(q,{label:`Operating age`,sortKey:`hours`,current:S,direction:R,onSort:W,tooltip:`Cumulative operating hours since the instance started running.`,className:`hidden text-right md:table-cell`}),(0,I.jsx)(q,{label:`Faults`,sortKey:`faults`,current:S,direction:R,onSort:W,tooltip:`Count of active (uncleared) faults on this instance.`}),(0,I.jsx)(q,{label:`Status`,sortKey:`status`,current:S,direction:R,onSort:W}),(0,I.jsx)(N,{children:(0,I.jsx)(`span`,{className:`sr-only`,children:`Navigate to instance`})})]})}),(0,I.jsx)(ge,{children:ke?(0,I.jsx)(J,{title:`Connecting to runtime`,body:`Live fleet data will appear once the connection is up.`}):Ae?(0,I.jsx)(J,{title:`No running instances`,body:`Start an environment from the Catalog to see instances.`,action:{label:`Open Catalog`,href:`/catalog`}}):Q.length===0?(0,I.jsx)(J,{title:`No matches`,body:`Adjust filters or clear them to see the full fleet.`}):Q.map(e=>{let t=Ce(e),n=ne(e.id),r=ee(e.id);return(0,I.jsxs)(M,{tabIndex:0,"aria-label":`Open instance ${r}`,className:b(`group cursor-pointer outline-none transition-colors`,`focus-visible:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset`),onClick:()=>$(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),$(e.id))},onMouseEnter:()=>{ae(`/instance/${e.id}`),F(e.id)},onFocus:()=>{ae(`/instance/${e.id}`),F(e.id)},children:[(0,I.jsx)(j,{className:`text-sm`,children:(0,I.jsx)(P.ViewTransition,{name:`instance-${e.id}`,default:`none`,children:(0,I.jsx)(`span`,{className:`inline-flex max-w-full truncate rounded-(--miravo-radius-tight) text-left`,title:`${r} (${e.id})`,children:n})})}),(0,I.jsx)(j,{className:`hidden text-sm sm:table-cell`,children:_(e.model)}),(0,I.jsx)(j,{children:(0,I.jsx)(se,{variant:`secondary`,className:`text-xs`,children:m(e.lifecycleStage)})}),(0,I.jsx)(j,{className:`hidden font-mono text-sm md:table-cell`,children:te(e.operatingHours)}),(0,I.jsx)(j,{children:e.activeFaults.length>0?(0,I.jsxs)(A,{children:[(0,I.jsx)(O,{render:(0,I.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,I.jsxs)(k,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,I.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,I.jsx)(j,{children:(0,I.jsx)(we,{state:t})}),(0,I.jsx)(j,{children:(0,I.jsx)(x,{className:`size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,"aria-hidden":!0})})]},e.id)})})]})})})]})}export{Y as t};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{S as r,it as i,o as a,v as o,y as s}from"./api-5BZroqlO.js";import{i as c,n as l}from"./dist-xY0pK9Wy.js";import{n as u}from"./chunk-OE4NN4TA-DBWZidbW.js";import{t as d}from"./shallow-Cin0mLuv.js";import{S as f,T as p,_ as m,b as h,c as g,d as _,f as v,l as ee,m as te,s as ne,u as y,y as re}from"./format-B9CcV2dj.js";import{t as b}from"./utils-XFKvwlFT.js";import{t as x}from"./arrow-right-BjBb4z7g.js";import{t as S}from"./arrow-up-down-C1oJAmrw.js";import{c as C,i as w,n as T,s as E,t as D}from"./select-CMOnuEoT.js";import{t as ie}from"./circle-question-mark-CJvcT6V6.js";import{i as O,n as k,t as A}from"./tooltip-D1ydB4g3.js";import{n as ae,t as oe}from"./use-transition-navigate-Bxh77tVE.js";import{t as se}from"./badge-i00PiRCo.js";import{n as ce}from"./transition-types-CPlGtM8w.js";import{a as le,i as ue,n as de,o as fe,r as pe,s as me,t as he}from"./combobox-BJecIYHE.js";import{a as j,c as M,i as ge,n as _e,o as N,r as ve,s as ye}from"./select-display-items-Bqb6Sbg6.js";var P=e(t(),1);function F(e){return s.prefetchQuery({queryKey:o.instances.detail(e),queryFn:()=>a(`/instances/${e}`,r.instanceDetail),staleTime:2e3})}var I=n(),L={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},R={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},z={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function B({label:e,pip:t,pulse:n}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,I.jsx)(`span`,{className:b(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,L[t])}),(0,I.jsx)(`span`,{className:b(`relative inline-flex size-1.5 rounded-full`,L[t])})]}):(0,I.jsx)(`span`,{"aria-hidden":!0,className:b(`size-1.5 shrink-0 rounded-full`,L[t])})),(0,I.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function V({children:e,tone:t=`foreground`,live:n}){return(0,I.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:b(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,R[t]),children:e})}function H({children:e}){return(0,I.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function U(e,t){return e===t?``:t}function be({statusFilter:e,onStatusFilter:t}){let{instances:n,tps:r,memberValueCount:a,availableAdapters:o,adapterMetrics:s}=i(d(e=>({instances:e.instances,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),c=(0,P.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]),l=(0,P.useMemo)(()=>{let e=o.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>z[e.name]??e.name)}},[o,s]),f=c.activeFaultCount>0,p=f?`destructive`:c.quarantined>0?`warning`:`success`,m=f?`faulted`:`healthy`;return(0,I.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,I.jsxs)(`button`,{type:`button`,onClick:()=>t(U(e,m)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":f?`Filter to faulted instances`:`Filter to healthy instances`,className:b(`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,I.jsx)(B,{label:`Health`,pip:p}),(0,I.jsxs)(V,{tone:f?`destructive`:`success`,children:[c.pct,`%`]}),(0,I.jsx)(H,{children:c.total===0?`No instances`:[`${c.total} instance${c.total===1?``:`s`}`,c.faulted>0&&`${c.faulted} faulted`,c.quarantined>0&&`${c.quarantined} quarantined`,`${c.modelCount} model${c.modelCount===1?``:`s`}`].filter(Boolean).join(` · `)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted instances`,className:b(`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,I.jsx)(B,{label:`Faults`,pip:f?`destructive`:`success`}),(0,I.jsx)(V,{tone:f?`destructive`:`foreground`,live:!0,children:c.activeFaultCount}),(0,I.jsx)(H,{children:f?`${c.affectedCount} instance${c.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(O,{render:(0,I.jsx)(u,{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,I.jsx)(B,{label:`Tags`,pip:`primary`,pulse:!0}),(0,I.jsx)(V,{children:v(a)}),(0,I.jsxs)(H,{children:[(0,I.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,I.jsx)(k,{side:`bottom`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,I.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),a>=1e6&&(0,I.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[y(a),` tags`]}),(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,I.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),l.enabled.length>0&&(0,I.jsx)(W,{labels:l.labels,totalMessages:l.totalMessages,totalErrors:l.totalErrors,perAdapter:l.enabled.map(e=>({name:z[e.name]??e.name,metrics:s.find(t=>t.name===e.name)?.metrics}))})]})}function W({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,I.jsxs)(A,{children:[(0,I.jsxs)(O,{render:(0,I.jsx)(u,{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,I.jsx)(B,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,I.jsx)(V,{tone:n>0?`warning`:`foreground`,live:!0,children:v(t)}),(0,I.jsxs)(H,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,I.jsx)(k,{side:`bottom`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,I.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,I.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[y(t),` total`]}),(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,I.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[y(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,I.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var G=`Commissioning → instance is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function xe(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 Se(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function Ce(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var K={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 we({state:e}){let t=K[e];return(0,I.jsxs)(A,{children:[(0,I.jsxs)(O,{render:(0,I.jsx)(`span`,{className:b(`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,I.jsx)(`span`,{"aria-hidden":!0,className:b(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,I.jsx)(`span`,{children:g(t.label)})]}),(0,I.jsx)(k,{side:`top`,children:t.help})]})}function q({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,I.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,I.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,I.jsx)(`span`,{children:e}),n&&(0,I.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,I.jsx)(S,{className:b(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,I.jsx)(N,{className:s,"aria-sort":l,children:r?(0,I.jsxs)(A,{children:[(0,I.jsx)(O,{render:u}),(0,I.jsx)(k,{side:`top`,children:r})]}):u})}function J({title:e,body:t,action:n}){return(0,I.jsx)(M,{children:(0,I.jsx)(j,{colSpan:7,className:`py-10`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,I.jsxs)(u,{to: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,I.jsx)(x,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Y(){let{instances:e,connectionState:t}=i(d(e=>({instances:e.instances,connectionState:e.connectionState}))),[n,r]=c(`q`,l.withDefault(``)),[a,o]=c(`model`,l.withDefault(``)),[s,u]=c(`lifecycle`,l.withDefault(``)),[g,v]=c(`status`,l.withDefault(``)),y=Se(g)?g:``,[S,L]=(0,P.useState)(`id`),[R,z]=(0,P.useState)(`asc`),B=(0,P.useRef)(null),V=oe(),[H,U]=(0,P.useState)(``);(0,P.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,P.useCallback)(e=>{e===S?z(e=>e===`asc`?`desc`:`asc`):(L(e),z(`asc`))},[S]),K=(0,P.useCallback)(e=>{v(e===``?``:e)},[v]),Y=(0,P.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]),X=(0,P.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),Te=(0,P.useMemo)(()=>[{value:`all`,label:`All stages`},...X.map(e=>({value:e,label:m(e)}))],[X]),Z=(0,P.useMemo)(()=>H?Y.filter(([e])=>h(e,H)):Y,[Y,H]),Ee=(0,P.useMemo)(()=>a?{value:a,label:_(a)}:null,[a]),Q=(0,P.useMemo)(()=>{let t=e;return a&&(t=t.filter(e=>e.model===a)),s&&(t=t.filter(e=>e.lifecycleStage===s)),n&&(t=t.filter(e=>re(e.id,n)||h(e.model,n))),y===`faulted`&&(t=t.filter(e=>e.activeFaults.length>0)),y===`quarantined`&&(t=t.filter(e=>e.isQuarantined)),y===`healthy`&&(t=t.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),xe(t,S,R)},[e,n,y,a,s,S,R]),De=y!==``||a!==``||s!==``||n!==``,Oe=(0,P.useCallback)(()=>{r(``),v(``),o(``),u(``)},[r,v,o,u]),$=(0,P.useCallback)(e=>{V(`/instance/${e}`,{transitionType:ce})},[V]),ke=e.length===0&&t!==`live`,Ae=e.length===0&&t===`live`;return(0,I.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,I.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Fleet Overview`}),(0,I.jsx)(be,{statusFilter:y,onStatusFilter:K}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(he,{value:Ee,onValueChange:e=>void o(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:U,children:[(0,I.jsx)(pe,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!a}),(0,I.jsx)(de,{children:(0,I.jsxs)(le,{children:[Z.map(([e,t])=>(0,I.jsxs)(ue,{value:{value:e,label:_(e)},children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:_(e)}),(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),Z.length===0&&(0,I.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),X.length>1&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsxs)(D,{value:s||`all`,onValueChange:e=>void u(!e||e===`all`?``:e),items:Te,children:[(0,I.jsx)(E,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,I.jsx)(C,{placeholder:`All stages`})}),(0,I.jsxs)(T,{alignItemWithTrigger:!1,align:`start`,children:[(0,I.jsx)(w,{value:`all`,children:`All stages`}),X.map(e=>(0,I.jsx)(w,{value:e,children:m(e)},e))]})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(O,{render:(0,I.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,I.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}),(0,I.jsx)(k,{side:`top`,children:G})]})]}),(0,I.jsxs)(D,{value:y||`all`,onValueChange:e=>void v(!e||e===`all`?``:e),items:_e,children:[(0,I.jsx)(E,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,I.jsx)(C,{placeholder:`All status`})}),(0,I.jsxs)(T,{alignItemWithTrigger:!1,align:`start`,children:[(0,I.jsx)(w,{value:`all`,children:`All status`}),(0,I.jsx)(w,{value:`healthy`,children:`Healthy`}),(0,I.jsx)(w,{value:`faulted`,children:`Faulted`}),(0,I.jsx)(w,{value:`quarantined`,children:`Quarantined`})]})]}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(f,{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,I.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:`/`})]}),De&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,onClick:Oe,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,I.jsx)(p,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,I.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[Q.length,` of `,e.length]})]})]}),(0,I.jsx)(fe,{className:`py-0`,children:(0,I.jsx)(me,{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,I.jsxs)(ve,{children:[(0,I.jsx)(ye,{children:(0,I.jsxs)(M,{children:[(0,I.jsx)(q,{label:`Instance`,sortKey:`id`,current:S,direction:R,onSort:W}),(0,I.jsx)(q,{label:`Model`,sortKey:`model`,current:S,direction:R,onSort:W,className:`hidden sm:table-cell`}),(0,I.jsx)(q,{label:`Lifecycle`,sortKey:`lifecycle`,current:S,direction:R,onSort:W,tooltip:G}),(0,I.jsx)(q,{label:`Operating age`,sortKey:`hours`,current:S,direction:R,onSort:W,tooltip:`Cumulative operating hours since the instance started running.`,className:`hidden text-right md:table-cell`}),(0,I.jsx)(q,{label:`Faults`,sortKey:`faults`,current:S,direction:R,onSort:W,tooltip:`Count of active (uncleared) faults on this instance.`}),(0,I.jsx)(q,{label:`Status`,sortKey:`status`,current:S,direction:R,onSort:W}),(0,I.jsx)(N,{children:(0,I.jsx)(`span`,{className:`sr-only`,children:`Navigate to instance`})})]})}),(0,I.jsx)(ge,{children:ke?(0,I.jsx)(J,{title:`Connecting to runtime`,body:`Live fleet data will appear once the connection is up.`}):Ae?(0,I.jsx)(J,{title:`No running instances`,body:`Start an environment from the Catalog to see instances.`,action:{label:`Open Catalog`,href:`/catalog`}}):Q.length===0?(0,I.jsx)(J,{title:`No matches`,body:`Adjust filters or clear them to see the full fleet.`}):Q.map(e=>{let t=Ce(e),n=ne(e.id),r=ee(e.id);return(0,I.jsxs)(M,{tabIndex:0,"aria-label":`Open instance ${r}`,className:b(`group cursor-pointer outline-none transition-colors`,`focus-visible:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset`),onClick:()=>$(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),$(e.id))},onMouseEnter:()=>{ae(`/instance/${e.id}`),F(e.id)},onFocus:()=>{ae(`/instance/${e.id}`),F(e.id)},children:[(0,I.jsx)(j,{className:`text-sm`,children:(0,I.jsx)(P.ViewTransition,{name:`instance-${e.id}`,default:`none`,children:(0,I.jsx)(`span`,{className:`inline-flex max-w-full truncate rounded-(--miravo-radius-tight) text-left`,title:`${r} (${e.id})`,children:n})})}),(0,I.jsx)(j,{className:`hidden text-sm sm:table-cell`,children:_(e.model)}),(0,I.jsx)(j,{children:(0,I.jsx)(se,{variant:`secondary`,className:`text-xs`,children:m(e.lifecycleStage)})}),(0,I.jsx)(j,{className:`hidden font-mono text-sm md:table-cell`,children:te(e.operatingHours)}),(0,I.jsx)(j,{children:e.activeFaults.length>0?(0,I.jsxs)(A,{children:[(0,I.jsx)(O,{render:(0,I.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,I.jsxs)(k,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,I.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,I.jsx)(j,{children:(0,I.jsx)(we,{state:t})}),(0,I.jsx)(j,{children:(0,I.jsx)(x,{className:`size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,"aria-hidden":!0})})]},e.id)})})]})})})]})}export{Y as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./fleet-C2Ipwzu5.js";export{e as FleetPage};
@@ -1 +1 @@
1
- import{C as e}from"./api-Bf6pFRhP.js";function t(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:typeof e==`string`&&e.trim().length>0?e:t}function n(t){if(e.is(t)&&t.hint?.trim())return t.hint}export{t as n,n as t};
1
+ import{C as e}from"./api-5BZroqlO.js";function t(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:typeof e==`string`&&e.trim().length>0?e:t}function n(t){if(e.is(t)&&t.hint?.trim())return t.hint}export{t as n,n as t};