@miravo/cli-linux-x64 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/console-dist/assets/api-DEoRnScz.js +1 -0
- package/console-dist/assets/api-GfuYYI6q.js +1 -0
- package/console-dist/assets/{asset-detail-C4zF_8rm.js → asset-detail-CbRJwcZg.js} +1 -1
- package/console-dist/assets/{asset-detail-actions-Dv9g2Z9t.js → asset-detail-actions-Ceb1_r18.js} +1 -1
- package/console-dist/assets/{backup-power-CAc85zvh.js → backup-power-qtHJlSI4.js} +1 -1
- package/console-dist/assets/{by-path-DmADo_qX.js → by-path-CKZo157c.js} +1 -1
- package/console-dist/assets/catalog-CshTwzQu.js +1 -0
- package/console-dist/assets/{catalog-BMLSbdye.js → catalog-Lt1tguKF.js} +1 -1
- package/console-dist/assets/{catalog-template-icons-DGyxSm-F.js → catalog-template-icons-DvKspieo.js} +1 -1
- package/console-dist/assets/{commercial-building-CINKWcQV.js → commercial-building-Bk4sBQtx.js} +1 -1
- package/console-dist/assets/{console-panel-Cg2sBJcN.js → console-panel-DOt0r_Oz.js} +1 -1
- package/console-dist/assets/control-89sOxkPx.js +1 -0
- package/console-dist/assets/control-BBMXQRSU.js +1 -0
- package/console-dist/assets/{district-heating-DqGtrEKq.js → district-heating-BofEIyfg.js} +1 -1
- package/console-dist/assets/events-DFkG5maw.js +1 -0
- package/console-dist/assets/{events-Dz_zsLGE.js → events-NZs3OoQw.js} +1 -1
- package/console-dist/assets/export-tab-R8Oac9J5.js +1 -0
- package/console-dist/assets/factory-BYX8AmsW.js +1 -0
- package/console-dist/assets/factory-Cp52pnAL.js +1 -0
- package/console-dist/assets/{floor-page-BOlkyLaW.js → floor-page-CiS52QbQ.js} +1 -1
- package/console-dist/assets/{get-error-message-CEvauOXv.js → get-error-message-DJGhcwLn.js} +1 -1
- package/console-dist/assets/{index-B7ZG1VO6.js → index-B8B-S-lq.js} +5 -5
- package/console-dist/assets/{integration-api-iM6SWQ6d.js → integration-api-B5s7_LWo.js} +1 -1
- package/console-dist/assets/{integrations-NcPRP3je.js → integrations-Bg7xzjIj.js} +1 -1
- package/console-dist/assets/integrations-CG1fPcwM.js +1 -0
- package/console-dist/assets/{login-snbitj6V.js → login-Dq1AJRqO.js} +1 -1
- package/console-dist/assets/{models-Dy_JFNac.js → models-BYr_QK_5.js} +1 -1
- package/console-dist/assets/models-jmRXhSoh.js +1 -0
- package/console-dist/assets/{pharma-cleanroom-CBgNUnIv.js → pharma-cleanroom-oxgPn6h6.js} +1 -1
- package/console-dist/assets/{protocol-card-Cp8O59cX.js → protocol-card-1DCkgN_l.js} +1 -1
- package/console-dist/assets/{registry-Kj-oMlVm.js → registry-BqqyCPJz.js} +2 -2
- package/console-dist/assets/{status-kit-BLG7OeIE.js → status-kit-Darp7bPB.js} +1 -1
- package/console-dist/assets/tags-DlnWXo4p.js +1 -0
- package/console-dist/assets/{tags-bloWH2Qa.js → tags-r7Fx_0yG.js} +2 -2
- package/console-dist/assets/{transition-nav-link-CBN2nulP.js → transition-nav-link-DIx78Lol.js} +1 -1
- package/console-dist/assets/use-engine-command-mutation-CTbPh58S.js +1 -0
- package/console-dist/assets/{use-transition-navigate-BDkvJJsk.js → use-transition-navigate-aOjMH_eS.js} +2 -2
- package/console-dist/assets/{useQuery-smgfSdOx.js → useQuery-BfWNkVkT.js} +1 -1
- package/console-dist/assets/validation-DSsZ8qyt.js +1 -0
- package/console-dist/assets/{water-treatment-BJXMtYlP.js → water-treatment-COXMW4qC.js} +1 -1
- package/console-dist/index.html +23 -23
- package/miravo +2 -2
- package/package.json +1 -1
- package/console-dist/assets/api-Dw9ti2cu.js +0 -1
- package/console-dist/assets/api-tM5PSXjr.js +0 -1
- package/console-dist/assets/catalog-Ccubt-hm.js +0 -1
- package/console-dist/assets/control-B-TcWj5c.js +0 -1
- package/console-dist/assets/control-DXA-_1Gu.js +0 -1
- package/console-dist/assets/events-iYGC0JpW.js +0 -1
- package/console-dist/assets/export-tab-BS4GlLBV.js +0 -1
- package/console-dist/assets/factory-BCPLmUx4.js +0 -1
- package/console-dist/assets/factory-CBXx3oBo.js +0 -1
- package/console-dist/assets/integrations-Bw0jY-xH.js +0 -1
- package/console-dist/assets/models-CsdLFBfC.js +0 -1
- package/console-dist/assets/tags-BRYVC9vb.js +0 -1
- package/console-dist/assets/use-engine-command-mutation-oLQW2r4F.js +0 -1
- package/console-dist/assets/validation-BOdAwXQ_.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,v as a,vt as o}from"./api-GfuYYI6q.js";import{f as s,t as c}from"./useQuery-BfWNkVkT.js";import{t as l}from"./proxy-CWZabK8f.js";import{t as u}from"./AnimatePresence-BSSlw02V.js";import{u as d}from"./chunk-OE4NN4TA-DBWZidbW.js";import{C as f}from"./format-Bx7DF-TB.js";import{t as p}from"./query-fetch-error-CWLZA2L5.js";import{n as m,t as ee}from"./use-transition-navigate-aOjMH_eS.js";import{t as h}from"./badge-Bk1DaL6C.js";import{n as te}from"./transition-types-BKZuWApE.js";import{n as ne}from"./auth-screen-backdrop-CEykEbfF.js";import{n as g}from"./get-error-message-DJGhcwLn.js";import{r as re}from"./runtime-link-BRnaEnOm.js";import{a as ie,i as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./combobox-B8h0-NHs.js";import{c as de,i as _,n as fe,s as pe,t as v}from"./select-BWlrSYlA.js";import{a as y,c as b,i as x,o as S,r as me,s as he,t as ge}from"./select-display-items-DN2G8DNG.js";import{a as _e,c as ve,i as ye,n as be,o as xe,r as Se,s as Ce,t as C}from"./events-format-C5HTkIsC.js";var w=e(t(),1),T=n(),E=1500;function D(){let e=s(),[t]=d(),n=t.get(`type`)??`all`,D=t.get(`assetId`)??``,[O,k]=(0,w.useState)(n),[A,j]=(0,w.useState)(D),[M,we]=(0,w.useState)(!0),N=re(o(e=>e.connectionState))===null,P=o(e=>e.events.length),F=(0,w.useRef)(!1),I=o(e=>e.assets),Te=ee(),L=c({queryKey:a.events(O,A),queryFn:()=>i(C(O,A,null),r.events),refetchInterval:M&&N?E:!1,staleTime:5e3}),[Ee,R]=(0,w.useState)([]),[De,z]=(0,w.useState)(!1),[Oe,B]=(0,w.useState)(null),V=`${O}::${A}`,H=(0,w.useRef)(V);(0,w.useEffect)(()=>{V!==H.current&&(H.current=V,R([]),B(null),W(!1))},[V]),(0,w.useEffect)(()=>{k(e=>e===n?e:n)},[n]),(0,w.useEffect)(()=>{j(e=>e===D?e:D)},[D]);let[U,W]=(0,w.useState)(()=>(L.data?.events.length??0)>0),G=L.data?[L.data,...Ee]:[],K=G.flatMap(e=>e.events).filter(e=>!ve(e)),q=G[G.length-1],ke=q?.hasMore??!1;(0,w.useEffect)(()=>{K.length>0&&!U&&W(!0)},[K.length,U]);let J=(0,w.useRef)(P);(0,w.useEffect)(()=>{P!==J.current&&(J.current=P,M&&N?(e.invalidateQueries({queryKey:a.events(O,A)}),F.current=!1):M&&(F.current=!0))},[P,M,N,e,O,A]),(0,w.useEffect)(()=>{!M||!N||!F.current||(F.current=!1,e.invalidateQueries({queryKey:a.events(O,A)}))},[M,N,e,O,A]);let[Y,Ae]=(0,w.useState)(``),X=(0,w.useMemo)(()=>Y?I.filter(e=>e.id.toLowerCase().includes(Y.toLowerCase())):I,[I,Y]),Z=L.isPending&&!L.data&&!L.isError,je=M&&!Z&&!U&&K.length===0,Q=L.error??Oe,Me=L.isError&&!L.data,$=(0,w.useCallback)(()=>{L.refetch()},[L]),Ne=async()=>{if(q?.nextCursor){z(!0),B(null);try{let e=await i(C(O,A,q.nextCursor),r.events);R(t=>[...t,e])}catch(e){B(e instanceof Error?e:Error(g(e,`Failed to fetch events.`)))}finally{z(!1)}}};if(Me)return(0,T.jsx)(ne,{className:`min-h-full`,children:(0,T.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,T.jsx)(`div`,{className:`w-full max-w-md`,children:(0,T.jsx)(p,{message:g(Q,`Failed to fetch events.`),onRetry:$,isRetrying:L.isFetching})})})});let Pe=new Date;return(0,T.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&&K.length>0?(0,T.jsx)(p,{message:`${g(Q,`Failed to fetch events.`)} Showing cached events.`,onRetry:$,isRetrying:L.isFetching}):null,(0,T.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,T.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,T.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Event Log`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Real-time event stream from the engine.`}),M&&!N?(0,T.jsx)(`p`,{className:`text-xs text-warning`,role:`status`,children:`Live refresh pauses until the Miravo link is live again.`}):null]}),(0,T.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,T.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,T.jsx)(u,{mode:`wait`,initial:!1,children:M?(0,T.jsxs)(l.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,T.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-success`}),(0,T.jsx)(`span`,{className:`font-medium text-success`,children:`LIVE`})]},`live`):(0,T.jsxs)(l.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,T.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:`Paused`})]},`paused`)})}),(0,T.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,T.jsxs)(ue,{value:A||null,onValueChange:e=>{j(e??``)},onInputValueChange:Ae,children:[(0,T.jsx)(ce,{placeholder:`All assets`,className:`h-8 w-full min-w-0`,showClear:!!A}),(0,T.jsx)(oe,{children:(0,T.jsxs)(ie,{children:[X.map(e=>(0,T.jsx)(ae,{value:e.id,children:(0,T.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),X.length===0&&(0,T.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No assets found`})]})})]})}),(0,T.jsx)(`div`,{className:`min-w-0 flex-1 lg:w-48 lg:flex-none`,children:(0,T.jsxs)(v,{value:O,onValueChange:e=>{k(e??`all`)},items:ge,children:[(0,T.jsx)(pe,{className:`w-full min-w-0 lg:w-48`,"aria-label":`Event type filter`,children:(0,T.jsx)(de,{placeholder:`Filter by type`})}),(0,T.jsxs)(fe,{alignItemWithTrigger:!1,align:`start`,children:[(0,T.jsx)(_,{value:`all`,children:`All events`}),(0,T.jsx)(_,{value:`fault:triggered`,children:`Fault Triggered`}),(0,T.jsx)(_,{value:`fault:cleared`,children:`Fault Cleared`}),(0,T.jsx)(_,{value:`lifecycle:changed`,children:`Lifecycle Changed`}),(0,T.jsx)(_,{value:`asset:maintenance`,children:`Maintenance`}),(0,T.jsx)(_,{value:`asset:created`,children:`Asset Created`}),(0,T.jsx)(_,{value:`asset:removed`,children:`Asset Removed`}),(0,T.jsx)(_,{value:`engine:state-changed`,children:`Engine State`})]})]})})]})]}),(0,T.jsx)(se,{className:`min-w-0 py-0`,children:(0,T.jsx)(le,{className:`p-0`,children:(0,T.jsxs)(me,{children:[(0,T.jsx)(he,{children:(0,T.jsxs)(b,{children:[(0,T.jsx)(S,{className:`hidden w-12 sm:table-cell`,children:`#`}),(0,T.jsx)(S,{children:`Type`}),(0,T.jsx)(S,{children:`Context`}),(0,T.jsx)(S,{children:`Details`}),(0,T.jsx)(S,{className:`hidden text-right md:table-cell`,children:`Cycle #`}),(0,T.jsx)(S,{className:`hidden text-right sm:table-cell`,children:`Wall Clock`})]})}),(0,T.jsxs)(x,{children:[K.map(e=>{let t=xe(e),n=Ce(e);return(0,T.jsxs)(b,{className:t?`transition-colors`:``,onMouseEnter:t?()=>m(`/asset/${t}`):void 0,children:[(0,T.jsx)(y,{className:`hidden font-mono text-xs text-muted-foreground sm:table-cell`,children:e.id}),(0,T.jsx)(y,{children:(0,T.jsx)(h,{variant:Se(e.type),className:`text-xs ${be(e.type)}`,children:e.type})}),(0,T.jsx)(y,{className:`font-mono text-xs`,children:t?(0,T.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:()=>m(`/asset/${t}`),onClick:()=>Te(`/asset/${t}`,{transitionType:te}),children:n??t}):n??`—`}),(0,T.jsx)(y,{className:`max-w-xs truncate font-mono text-xs`,children:ye(e)||(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,T.jsx)(y,{className:`hidden text-right font-mono text-xs md:table-cell`,children:e.tick}),(0,T.jsx)(y,{className:`hidden text-right text-xs text-muted-foreground sm:table-cell`,children:_e(e.timestamp,Pe)})]},e.id)}),!Z&&K.length===0&&(0,T.jsx)(b,{children:(0,T.jsx)(y,{colSpan:6,className:`py-8 text-center text-muted-foreground`,children:je?`Listening for events…`:`No events`})})]})]})})}),ke&&(0,T.jsx)(`div`,{className:`flex justify-center border-t border-border/40 pt-4`,children:(0,T.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>void Ne(),disabled:De,children:`Load older events`})})]})}export{D as t};
|
|
@@ -0,0 +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,et as c,ot as l}from"./vendor-ui-D8j69UH4.js";import{S as u,Z as d,a as f,nt as p,o as m,s as h}from"./api-GfuYYI6q.js";import{a as g,c as _,i as v,n as y,o as b,r as x,t as ee}from"./dialog-B5PqrKVw.js";import{C as S,S as C,T as w}from"./format-Bx7DF-TB.js";import{n as T,t as E}from"./utils-XFKvwlFT.js";import{t as D}from"./chevron-down-x70Pto6j.js";import{t as O}from"./download-i8CTJ7oi.js";import{n as k,t as A}from"./source-host-miravo-B8eM2IHw.js";import{t as j}from"./loader-circle-DjgHgHHl.js";import"./use-engine-command-mutation-CTbPh58S.js";import{t as M}from"./label-2sIXTEUK.js";var N=T(`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`}]]),P=l();function F({...e}){return(0,P.jsx)(o,{"data-slot":`sheet`,...e})}function I({...e}){return(0,P.jsx)(a,{"data-slot":`sheet-portal`,...e})}function L({className:e,...t}){return(0,P.jsx)(c,{"data-slot":`sheet-overlay`,className:E(`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 R({className:e,children:t,side:r=`right`,showCloseButton:i=!0,...a}){return(0,P.jsxs)(I,{children:[(0,P.jsx)(L,{}),(0,P.jsxs)(s,{"data-slot":`sheet-content`,"data-side":r,className:E(`fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-[calc(100vw-1rem)] data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-[calc(100vw-1rem)] data-[side=right]:max-w-xl data-[side=right]:border-l data-[side=right]:pl-1 data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem]`,e),...a,children:[t,i&&(0,P.jsxs)(n,{"data-slot":`sheet-close`,render:(0,P.jsx)(S,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,P.jsx)(w,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function z({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`sheet-header`,className:E(`flex flex-col gap-0.5 p-2`,e),...t})}function B({className:e,...t}){return(0,P.jsx)(r,{"data-slot":`sheet-title`,className:E(`text-base font-medium text-foreground`,e),...t})}function V({className:e,...t}){return(0,P.jsx)(i,{"data-slot":`sheet-description`,className:E(`text-sm text-muted-foreground`,e),...t})}var H=e(t(),1);function U({format:e,kind:t}){return e===`source-yaml`?t===`model`?`Raw asset model definition. Edit locally, version-control, or use as input for the CLI.`:`Raw factory definition with topology and namespace. Edit, share, or apply via CLI.`:e===`litmus-edge`?t===`model`?`Litmus Edge Digital Twin JSON for manual import via the Litmus Edge UI.`:`Litmus Edge template JSON (DeviceHub devices + Digital Twins). Import directly via the Litmus Edge UI.`:`Select a format to download.`}function W({children:e,className:t}){return(0,P.jsx)(`div`,{className:E(`max-h-[min(36rem,75vh)] min-h-0 overflow-y-auto rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 p-4 sm:p-5`,t),children:e})}var G=[`modbus`,`opcua`,`mqtt`],K={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`};function q(e){return e===``?null:!/^\d+$/.test(e)||!p(Number(e))?`Use a port from 1 to 65535.`:null}function J(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,String(t)]))}function Y(e,t,n){let r={...e};for(let e of n){let n=(t[e]??``).trim();if(q(n))return null;n===``?delete r[e]:r[e]=Number(n)}return r}function X({open:e,onOpenChange:t,protocols:n,values:r,onChange:i,hint:a}){let o=(0,H.useId)();return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),"aria-expanded":e,className:`flex w-full items-center gap-1 text-left text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[(0,P.jsx)(D,{className:E(`size-3 transition-transform`,!e&&`-rotate-90`),"aria-hidden":!0}),`Miravo ports remapped (Docker)?`]}),e?(0,P.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:a}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:n.map(e=>{let t=r[e]??``,n=q(t.trim());return(0,P.jsxs)(`div`,{className:`w-24 space-y-1`,children:[(0,P.jsx)(M,{htmlFor:`${o}-${e}`,className:`text-[11px] text-muted-foreground`,children:K[e]}),(0,P.jsx)(C,{id:`${o}-${e}`,inputMode:`numeric`,placeholder:String(d[e]),value:t,"aria-invalid":n!==null,onChange:t=>i({...r,[e]:t.currentTarget.value}),className:`h-8 font-mono text-[12px]`}),n?(0,P.jsx)(`p`,{className:`text-[10px] text-destructive`,children:n}):null]},e)})})]}):null]})}var Z=`172.17.0.1`;async function Q(e){let t=await m(`/catalog/models/${encodeURIComponent(e)}/le-dt.json`,u.catalogModelLeDt);return JSON.stringify(t,null,2)}async function te(e,t={host:Z}){let n=u.catalogTemplateLeTemplateJson.query;if(!n)throw Error(`Missing query schema for ${u.catalogTemplateLeTemplateJson.method} ${u.catalogTemplateLeTemplateJson.path}`);let r=n.safeParse({host:t.host,protocol:t.protocol,modbusPort:t.exposedPorts?.modbus,opcuaPort:t.exposedPorts?.opcua,mqttPort:t.exposedPorts?.mqtt});if(!r.success)throw Error(`Invalid request for ${u.catalogTemplateLeTemplateJson.method} ${u.catalogTemplateLeTemplateJson.path}: ${r.error.message}`);return f(ne(e,r.data),u.catalogTemplateLeTemplateJson)}function ne(e,t){return`/catalog/templates/${encodeURIComponent(e)}/le-template.json${re(t)}`}function re(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&r!==``&&t.set(n,String(r));return t.size>0?`?${t.toString()}`:``}function $(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n),_.success(`Exported ${t}`)}function ie({kind:e,id:t,yamlPath:n,yamlFilename:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(Z),[c,l]=(0,H.useState)(!1),[d,f]=(0,H.useState)({}),[p,m]=(0,H.useState)(!1),w=(0,H.useCallback)(async()=>{try{let t=await h(n,e===`model`?u.catalogModelYaml:u.catalogTemplateYaml);$(new Blob([t],{type:`text/yaml`}),r)}catch{_.error(`Failed to export YAML`)}},[e,n,r]),T=(0,H.useCallback)(async()=>{try{let e=await Q(t);$(new Blob([e],{type:`application/json`}),`${t}.le-dt.json`)}catch{_.error(`Failed to export integration format`)}},[t]),E=(0,H.useCallback)(async(e,n)=>{try{let r=e.trim();return $(await te(t,{host:r.length>0?r:Z,exposedPorts:n}),`${t}.le-template.json`),!0}catch{return _.error(`Failed to export integration format`),!1}},[t]),D=(0,H.useCallback)(()=>{s(Z),f({}),l(!1),a(!0)},[]),N=(0,H.useCallback)(async()=>{let e=Y(void 0,d,G);if(!e){l(!0);return}m(!0);try{await E(o,e)&&a(!1)}finally{m(!1)}},[d,o,E]);return(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pb-2`,children:[[{key:`source-yaml`,label:e===`model`?`Source YAML (.asset.yaml)`:`Source YAML (.miravo.yaml)`,onDownload:()=>void w()},{key:`litmus-edge`,label:e===`model`?`Litmus Edge Digital Twin (JSON)`:`Litmus Edge template (JSON)`,onDownload:e===`model`?()=>void T():D}].map(t=>(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 p-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:t.label}),(0,P.jsxs)(S,{variant:`outline`,size:`sm`,className:`h-8 shrink-0 gap-1.5 text-xs`,"aria-label":`Download ${t.label}`,onClick:t.onDownload,children:[(0,P.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]}),(0,P.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/70`,children:(0,P.jsx)(U,{format:t.key,kind:e})})]},t.key)),(0,P.jsx)(ee,{open:i,onOpenChange:a,children:(0,P.jsxs)(y,{className:`sm:max-w-md`,children:[(0,P.jsxs)(g,{children:[(0,P.jsx)(b,{children:`Download Litmus Edge Template`}),(0,P.jsx)(x,{children:A})]}),(0,P.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,P.jsx)(M,{htmlFor:`export-source-host`,children:k}),(0,P.jsx)(C,{id:`export-source-host`,value:o,onChange:e=>s(e.target.value),placeholder:Z,autoComplete:`off`,className:`font-mono text-sm`}),(0,P.jsxs)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Use an IP or hostname reachable from Litmus Edge (e.g.`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:Z}),` for Docker bridge).`]}),(0,P.jsx)(X,{open:c,onOpenChange:l,protocols:G,values:d,onChange:f,hint:`Enter the host port Litmus Edge should dial. Leave blank to use Miravo's own port.`})]}),(0,P.jsxs)(v,{className:`gap-2 sm:gap-0`,children:[(0,P.jsx)(S,{type:`button`,variant:`outline`,onClick:()=>a(!1),disabled:p,children:`Cancel`}),(0,P.jsxs)(S,{type:`button`,className:`gap-1.5`,onClick:()=>void N(),disabled:p,"aria-busy":p,children:[p?(0,P.jsx)(j,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,P.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]})]})})]})}export{J as a,R as c,B as d,N as f,Y as i,V as l,X as n,W as o,G as r,F as s,ie as t,z as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,v as a,vt as o,y as s}from"./api-GfuYYI6q.js";import{f as c,t as l}from"./useQuery-BfWNkVkT.js";import{t as u,u as d}from"./proxy-CWZabK8f.js";import{t as f}from"./AnimatePresence-BSSlw02V.js";import{i as p,n as m,r as h}from"./dist-xY0pK9Wy.js";import{n as g,s as _}from"./chunk-OE4NN4TA-DBWZidbW.js";import{a as v,i as y,n as b,o as ee,r as x,t as te}from"./dialog-B5PqrKVw.js";import{t as S}from"./shallow-Cin0mLuv.js";import{C,S as ne,T as w,c as re,d as T,g as ie,h as ae,l as E,m as D,p as O,s as k,u as A,v as oe,w as j,y as M}from"./format-Bx7DF-TB.js";import{n as N,t as P}from"./utils-XFKvwlFT.js";import{t as F}from"./activity-Cy_niK56.js";import{n as I,r as L,t as R}from"./server-BVem_egD.js";import{c as se,i as ce,n as le,s as ue,t as de}from"./dropdown-menu-B_MMNbTy.js";import{i as fe,n as pe,t as me}from"./catalog-template-icons-DvKspieo.js";import{t as he}from"./chevron-down-x70Pto6j.js";import{t as ge}from"./chevron-right-CrNKVFcI.js";import{n as _e,t as ve}from"./circle-x-6JtFdy1_.js";import{a as ye,c as be,i as xe,l as Se,o as Ce,p as we,s as Te,t as Ee,u as De}from"./integration-api-B5s7_LWo.js";import{t as Oe}from"./protocol-card-1DCkgN_l.js";import{t as ke}from"./copy-button-CSUP1VjU.js";import{n as Ae,r as je,t as Me}from"./source-host-miravo-B8eM2IHw.js";import{i as Ne,n as Pe,t as Fe}from"./registry-BqqyCPJz.js";import{t as z}from"./loader-circle-DjgHgHHl.js";import{c as Ie,i as Le,o as Re,t as ze}from"./use-engine-command-mutation-CTbPh58S.js";import{t as Be}from"./plus-Cl4Ay5Ry.js";import{t as Ve}from"./radio-BxpVYiyS.js";import{t as He}from"./query-fetch-error-CWLZA2L5.js";import{t as Ue}from"./rocket-KZ5oHK1G.js";import{a as We,f as Ge,i as Ke,n as qe,o as Je,r as Ye}from"./export-tab-R8Oac9J5.js";import{t as Xe}from"./trash-2-BH9HDsZv.js";import{t as Ze}from"./triangle-alert-DoAwrRgk.js";import{i as B,n as V,t as H}from"./tooltip-B3vOB1Vu.js";import{n as Qe,t as $e}from"./use-transition-navigate-aOjMH_eS.js";import{t as et}from"./badge-Bk1DaL6C.js";import{n as tt}from"./transition-types-BKZuWApE.js";import{t as nt}from"./label-2sIXTEUK.js";import{n as rt,t as it}from"./get-error-message-DJGhcwLn.js";import{i as U,n as W,r as G,t as at}from"./console-panel-DOt0r_Oz.js";import{i as ot,n as st,r as ct,t as lt}from"./tabs-Ch_VG8_S.js";import{a as ut,i as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./combobox-B8h0-NHs.js";import{c as _t,i as K,n as vt,s as yt,t as bt}from"./select-BWlrSYlA.js";import{a as q,c as xt,i as St,n as Ct,o as wt,r as Tt,s as Et}from"./select-display-items-DN2G8DNG.js";import{t as Dt}from"./checkbox-DEAkDfFr.js";import{n as Ot,r as kt,t as At}from"./integration-targets-Byvdd3Or.js";var jt=N(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Mt=N(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Nt=N(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Pt=N(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Ft=N(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),It=N(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Lt=N(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Rt=N(`component`,[[`path`,{d:`M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1uwlt4`}],[`path`,{d:`M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z`,key:`10291m`}],[`path`,{d:`M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z`,key:`1tqoq1`}],[`path`,{d:`M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1x6lto`}]]),zt=N(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Bt=N(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Vt=N(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),Ht=N(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Ut=N(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),J=e(t(),1),Y=n();function X({className:e,...t}){return(0,Y.jsx)(`div`,{"data-slot":`skeleton`,className:P(`animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted`,e),...t})}var Wt=`https://miravo.dev/docs`;function Gt(){let{adapters:e,metrics:t}=o(S(e=>({adapters:e.availableAdapters,metrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled&&!e.pending&&e.endpoint),r=e.filter(e=>!n.includes(e)),i=e=>t.find(t=>t.name===e)?.metrics.clients?.active??0,a=n.reduce((e,t)=>e+i(t.name),0);return(0,Y.jsxs)(at,{id:`connect`,icon:Vt,title:`Connect`,description:`Point a client here to read live values.`,aside:(0,Y.jsxs)(U,{tone:a>0?`live`:n.length>0?`idle`:`off`,children:[(0,Y.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:a}),(0,Y.jsx)(G,{children:a===1?`client`:`clients`})]}),bodyClassName:`gap-2`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(g,{to:`/control`,className:W,children:[`Configure protocols`,(0,Y.jsx)(L,{className:`size-3`,"aria-hidden":!0})]}),(0,Y.jsxs)(`a`,{href:`${Wt}/protocols`,target:`_blank`,rel:`noopener noreferrer`,className:P(W,`ml-auto`),children:[(0,Y.jsx)(Mt,{className:`size-3`,"aria-hidden":!0}),`Protocol docs`]})]}),children:[n.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No protocol is serving yet.`}),n.map(e=>{let t=i(e.name),n=Oe[e.name]??e.name;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-[var(--miravo-radius-stadium-sm)] border border-muted-foreground/20 bg-background/40 px-3 py-2.5 transition-colors hover:border-muted-foreground/25`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-1.5 shrink-0 rounded-full`,t>0?`bg-success`:`bg-muted-foreground/55`)}),(0,Y.jsx)(`span`,{className:`text-sm font-medium tracking-tight`,children:n}),(0,Y.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:t>0?`text-foreground`:void 0,children:t}),` `,`connected`]})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 pl-3.5`,children:[(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,Y.jsx)(ke,{value:e.endpoint??``,label:`Copy ${n} endpoint`})]})]},e.name)}),r.length>0&&(0,Y.jsxs)(`p`,{className:`pt-1 text-xs text-muted-foreground`,children:[r.map(e=>Oe[e.name]??e.name).join(`, `),` `,r.length===1?`is`:`are`,` off.`]})]})}var Kt=[`devices`,`models`,`assets`],qt=[`assets`,`models`,`devices`],Jt={devices:`DeviceHub devices`,models:`Digital Twins models`,assets:`Digital Twins instances`},Yt={devices:{apply:`DeviceHub device records and settings on Litmus Edge.`,cleanup:`Remove DeviceHub device records managed from Miravo.`},models:{apply:`Digital Twins model definitions synced to the integration.`,cleanup:`Remove Digital Twins model definitions created by Miravo.`},assets:{apply:`Digital Twins instances bound to DeviceHub devices.`,cleanup:`Remove Digital Twins instances deployed for this target.`}},Xt=`Miravo calls this API.`,Zt={assets:`models`};function Qt(e,t){let n=new Set(e);if(n.has(t)){n.delete(t);for(let[e,r]of Object.entries(Zt))r===t&&n.delete(e)}else{n.add(t);let e=Zt[t];e&&n.add(e)}return n}var $t=[{value:`fail`,title:`Fail if unmanaged exists`,hint:`Stop if the target has unmanaged resources.`},{value:`skip`,title:`Skip unmanaged resources`,hint:`Only update resources managed by Miravo.`}],en=[{value:`this`,title:`This Miravo instance`,hint:`Only what this Miravo applied. Leaves other machines' resources on a shared target.`},{value:`all`,title:`All Miravo instances`,hint:`Also what other Miravo instances applied for it.`}];function tn({legend:e,name:t,options:n,value:r,onChange:i}){let a=(0,J.useId)();return(0,Y.jsxs)(`div`,{className:`mt-2.5 space-y-1.5 border-t border-border/40 pt-2`,children:[(0,Y.jsx)(`p`,{id:`${a}-legend`,className:`text-[11px] font-medium uppercase tracking-wide text-foreground/80`,children:e}),(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`${a}-legend`,className:`flex flex-col gap-1`,children:n.map(e=>(0,Y.jsxs)(nt,{htmlFor:`${t}-${e.value}`,className:P(`flex cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-[11px] transition-colors`,r===e.value?`border-primary/45 bg-primary/8`:`border-border/40 bg-muted/10 hover:bg-muted/25`),children:[(0,Y.jsx)(`input`,{id:`${t}-${e.value}`,type:`radio`,name:`${t}-${a}`,value:e.value,checked:r===e.value,onChange:()=>i(e.value),className:`mt-0.5 size-3.5 shrink-0 accent-primary`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),(0,Y.jsx)(`span`,{className:`mt-px block text-[11px] leading-tight text-foreground/74`,children:e.hint})]})]},e.value))})]})}function nn({open:e,onOpenChange:t,isApply:n,scopeOptions:r,scope:i,onToggleScope:a,ifUnmanaged:o,onIfUnmanagedChange:s,instances:c,onInstancesChange:l}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center justify-between gap-2 rounded-[var(--miravo-radius-tight)] bg-muted/40 px-2.5 py-2 text-left text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/55 aria-expanded:text-foreground`,onClick:()=>t(!e),"aria-expanded":e,children:[`Advanced`,(0,Y.jsx)(he,{className:P(`size-3.5 shrink-0 text-muted-foreground transition-transform ease-out group-hover:text-foreground/80`,e?`duration-500 rotate-180 text-foreground/80`:`duration-280`),"aria-hidden":!0})]}),(0,Y.jsxs)(u.div,{initial:!1,animate:{maxHeight:e?520:0,opacity:+!!e},transition:{maxHeight:{duration:e?.52:.28,ease:e?[.16,1,.3,1]:[.4,0,.2,1]},opacity:{duration:e?.42:.24,ease:e?[.16,1,.3,1]:[.4,0,.2,1]}},className:P(`overflow-hidden`,!e&&`pointer-events-none`),"aria-hidden":!e,inert:!e,children:[(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 pt-px`,children:r.map(e=>{let t=Object.entries(Zt).find(([t,n])=>n===e)?.[0],r=t!==void 0&&i.has(t),o=n?Yt[e].apply:Yt[e].cleanup;return(0,Y.jsxs)(nt,{htmlFor:`scope-${e}`,className:P(`flex min-h-9 cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border border-border/40 bg-muted/10 px-2.5 py-1.5 text-[11px] transition-colors`,r?`opacity-95`:`hover:bg-muted/25`),children:[(0,Y.jsx)(`span`,{className:`pt-0.5`,children:(0,Y.jsx)(Dt,{id:`scope-${e}`,checked:i.has(e),disabled:r,onCheckedChange:()=>a(e)})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 leading-snug`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:Jt[e]}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[11px] font-normal leading-tight text-muted-foreground`,children:o})]}),r?(0,Y.jsx)(`span`,{className:`shrink-0 self-start rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-primary/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-primary`,title:`Required when Digital Twins instances are selected (models must stay in scope).`,children:`Required`}):null]},e)})}),n?(0,Y.jsx)(tn,{legend:`Collision policy`,name:`if-unmanaged`,options:$t,value:o,onChange:s}):(0,Y.jsx)(tn,{legend:`Remove resources of`,name:`cleanup-instances`,options:en,value:c,onChange:l})]})]})}function rn({label:e,help:t,mono:n=!1,children:r}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 items-start gap-x-4 border-b border-border/35 py-2.5 first:pt-0`,children:[t?(0,Y.jsx)(`dt`,{className:`min-w-0 pt-px`,children:(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium leading-snug text-muted-foreground`,children:e}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(B,{type:`button`,className:`inline-flex size-5 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`About ${e}`,children:(0,Y.jsx)(we,{className:`size-3`,"aria-hidden":!0})}),(0,Y.jsx)(V,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:t})]})]})}):(0,Y.jsx)(`dt`,{className:`min-w-0 pt-px text-[11px] font-medium text-muted-foreground`,children:e}),n?(0,Y.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[11px] leading-normal text-foreground/90`,children:r}):(0,Y.jsx)(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground`,children:r})]})}function an({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId,protocol:t.protocol},scope:n.scope,ifUnmanaged:n.ifUnmanaged,exposedPorts:n.exposedPorts}}function on({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId},scope:n.scope,instances:n.instances}}var sn=/^\(?unchanged\)?$/i,cn=/^device=(\S+)/;function ln(e){let t=e.blockReason??e.detail;if(!(!t||sn.test(t)))return t.replace(/^\((.*)\)$/,`$1`)}function un(e){let t=new Map;for(let n of e)n.resourceType===`param-sync`&&t.set(n.name,n);let n=[],r=new Set;for(let i of e){if(i.resourceType===`param-sync`)continue;let e=i.resourceType===`asset`?t.get(i.name):void 0;e&&r.add(i.name);let a=e!==void 0&&i.action===`noop`&&e.action!==`noop`;n.push({action:a?e.action:i.action,resourceType:i.resourceType,name:i.name,protocol:i.protocol,note:a?`device binding changes`:ln(i),boundDevice:e?.detail?.match(cn)?.[1]})}for(let[e,i]of t)r.has(e)||n.push({action:i.action,resourceType:`asset`,name:e,note:ln(i),boundDevice:i.detail?.match(cn)?.[1]});return n}function dn(e){let t=new Map;for(let n of e){let e=t.get(n.action);e?e.push(n):t.set(n.action,[n])}return t}function fn(e){return un(e).filter(e=>e.action!==`noop`&&e.action!==`blocked`).length}var pn={create:{label:`Create`,phrase:`to create`,dot:`bg-success`,text:`text-success`},update:{label:`Update`,phrase:`to update`,dot:`bg-info`,text:`text-info`},replace:{label:`Replace`,phrase:`to replace`,dot:`bg-chart-2`,text:`text-chart-2`},delete:{label:`Remove`,phrase:`to remove`,dot:`bg-destructive`,text:`text-destructive`},blocked:{label:`Skipped`,phrase:`skipped`,dot:`bg-warning`,text:`text-warning`},noop:{label:`Unchanged`,phrase:`unchanged`,dot:`bg-muted-foreground/40`,text:`text-muted-foreground`}},mn=[`create`,`update`,`replace`,`delete`,`noop`],hn=[`create`,`update`,`replace`,`delete`],gn=6,_n={device:[`device`,`devices`],model:[`twin model`,`twin models`],asset:[`twin instance`,`twin instances`]};function vn(e,[t,n]){return`${e} ${e===1?t:n}`}function yn(e){let t=new Map;for(let n of e){let e=t.get(n.resourceType);e?e.push(n):t.set(n.resourceType,[n])}return[...t]}function bn(e){return yn(e).map(([e,t])=>vn(t.length,_n[e])).join(` · `)}function xn(e){return`${e.action}-${e.resourceType}-${e.name}-${e.protocol??``}`}function Sn(e){return e.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)}function Cn({groups:e}){return(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`flex h-1.5 w-full gap-0.5 overflow-hidden rounded-full`,children:[`blocked`,...mn].map(t=>{let n=e.get(t)?.length??0;return n>0?(0,Y.jsx)(`span`,{className:P(`h-full rounded-full`,pn[t].dot),style:{flexGrow:n}},t):null})})}function wn({entry:e}){let{note:t}=e;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 py-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11.5px] text-foreground`,title:e.name,children:e.name}),e.protocol?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] border border-border/60 px-1 font-mono text-[9.5px] uppercase text-muted-foreground`,children:e.protocol}):null,e.boundDevice?(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-[10.5px] text-muted-foreground`,title:`Device this twin instance reads from`,children:[`→ `,e.boundDevice]}):null,t?(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted-foreground`,title:t,children:t}):null]})}function Tn({action:e,entries:t,open:n,onToggle:r}){let i=pn[e];return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`group flex w-full min-w-0 items-center gap-3 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-2 shrink-0 rounded-full`,i.dot)}),(0,Y.jsx)(`span`,{className:P(`w-20 shrink-0 text-sm font-medium`,e===`noop`?`text-muted-foreground`:`text-foreground`),children:i.label}),(0,Y.jsx)(`span`,{className:P(`w-8 shrink-0 font-mono text-sm tabular-nums`,i.text),children:t.length}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:bn(t)}),(0,Y.jsx)(ge,{"aria-hidden":!0,className:P(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200`,n&&`rotate-90`)})]}),n?(0,Y.jsx)(`div`,{className:`mb-2 ml-[1.1rem] flex flex-col gap-2 border-l border-border/60 pt-1 pl-[1.9rem]`,children:yn(t).map(([e,t])=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:_n[e][1]}),(0,Y.jsx)(`ul`,{children:t.map(e=>(0,Y.jsx)(wn,{entry:e},xn(e)))})]},e))}):null]})}function En({entries:e}){return(0,Y.jsxs)(`div`,{role:`note`,className:`rounded-[var(--miravo-radius-tight)] border border-warning/30 bg-warning/8 px-3 py-2.5`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,Y.jsx)(Ze,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),e.length,` `,e.length===1?`resource is`:`resources are`,` skipped`]}),(0,Y.jsx)(`ul`,{className:`mt-1 pl-5.5`,children:e.map(e=>(0,Y.jsx)(wn,{entry:e},xn(e)))})]})}function Dn({groups:e,planKind:t}){let n=hn.filter(t=>(e.get(t)?.length??0)>0);return n.length===0?(0,Y.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:t===`cleanup`?`Nothing to remove`:`Nothing to change`}):(0,Y.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:n.map((t,n)=>(0,Y.jsxs)(J.Fragment,{children:[n>0?(0,Y.jsx)(`span`,{className:`mx-1.5 font-normal text-muted-foreground/60`,children:`·`}):null,(0,Y.jsx)(`span`,{className:P(`font-mono tabular-nums`,pn[t].text),children:e.get(t)?.length}),` `,(0,Y.jsx)(`span`,{className:`font-normal text-foreground/90`,children:pn[t].phrase})]},t))})}function On({plan:e,planKind:t=`apply`}){let n=un(e.entries),r=dn(n),i=hn.reduce((e,t)=>e+(r.get(t)?.length??0),0),[a,o]=(0,J.useState)(()=>new Set(i<=gn?hn:[])),s=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=r.get(`blocked`)??[],l=r.get(`noop`)?.length??0;return(0,Y.jsxs)(`section`,{"aria-label":`Dry run`,className:`flex flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 p-4`,children:[(0,Y.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:[t===`cleanup`?`Expected removals`:`Expected changes`,(0,Y.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/80`,children:`dry run · nothing runs until you confirm`})]}),(0,Y.jsx)(Dn,{groups:r,planKind:t}),(0,Y.jsxs)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:[l>0?`${l} already in place · `:``,Sn(e.scope)]})]})}),n.length>0?(0,Y.jsx)(Cn,{groups:r}):null,c.length>0?(0,Y.jsx)(En,{entries:c}):null,n.length>0?(0,Y.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:mn.map(e=>{let t=r.get(e);return t?(0,Y.jsx)(Tn,{action:e,entries:t,open:a.has(e),onToggle:()=>s(e)},e):null})}):(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t===`cleanup`?`No Miravo-managed resources matched this scope on the target.`:`The target already matches this template.`})]})}var kn=[`a`,`b`,`c`];function An(){return(0,Y.jsxs)(`div`,{role:`status`,"aria-busy":!0,"aria-label":`Loading dry run`,className:`flex flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 p-4`,children:[(0,Y.jsx)(X,{className:`h-2.5 w-28`}),(0,Y.jsx)(X,{className:`h-5 w-56`}),(0,Y.jsx)(X,{className:`h-3 w-40`}),(0,Y.jsx)(X,{className:`h-1.5 w-full rounded-full`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 pt-1`,children:kn.map(e=>(0,Y.jsx)(X,{className:`h-7 w-full`},e))})]})}var jn={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`},Mn=Ye.map(e=>({value:e,label:jn[e]}));function Nn({open:e,onOpenChange:t,action:n,subject:r,label:i,target:o,stream:s}){let c=n===`apply`,u=c?Kt:qt,[d,f]=(0,J.useState)(new Set(u)),[p,m]=(0,J.useState)(`fail`),[h,g]=(0,J.useState)(`this`),[_,v]=(0,J.useState)(!1),[S,ne]=(0,J.useState)(Object.keys(o.exposedPorts??{}).length>0),[w,re]=(0,J.useState)(We(o.exposedPorts)),[T,ie]=(0,J.useState)(r.kind===`asset`?r.protocol:Ye[0]??`modbus`),ae=r.kind===`asset`?{kind:`asset`,assetId:r.assetId,protocol:T}:r,E=r.kind===`asset`?[T]:Ye,D=c?Ke(o.exposedPorts,w,E):{},O=u.filter(e=>d.has(e)),k=O.length>0&&D!==null,A={scope:O,ifUnmanaged:p,...c&&D?{exposedPorts:D}:{},instances:h},oe=an({targetId:o.id,subject:ae,result:A}),j=on({targetId:o.id,subject:ae,result:A}),M=l({queryKey:a.integrations.plan(n,JSON.stringify(c?oe:j)),queryFn:({signal:e})=>c?be(oe,{signal:e}):Te(j,{signal:e}),enabled:e&&k,retry:!1,gcTime:0}),N=s.status===`running`,P=()=>{k&&(s.operation&&s.status!==`running`&&s.reset(),c?s.startApply(oe):s.startCleanup(j),t(!1))},F=M.data?.plan,I=F?fn(F.entries):null,L;L=c?I===null?`Apply`:I===0?`Re-apply anyway`:`Apply ${I} ${I===1?`change`:`changes`}`:I?`Clean up ${I} ${I===1?`resource`:`resources`}`:`Clean up`;let R=M.error?[rt(M.error,`Plan failed`),it(M.error)].filter(Boolean).join(`. `):null;return(0,Y.jsx)(te,{open:e,onOpenChange:t,children:(0,Y.jsxs)(b,{showCloseButton:!0,className:`flex max-h-[90vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-3xl`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,Y.jsxs)(ee,{className:`flex items-center gap-2 text-sm font-semibold leading-snug`,children:[c?(0,Y.jsx)(Ue,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,Y.jsx)(Xe,{className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),c?`Apply`:`Clean up`,` `,i,` `,c?`to`:`from`,` `,o.label]}),(0,Y.jsxs)(x,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[o.hostname,c?(0,Y.jsx)(`span`,{className:`font-sans`,children:` · reaches Miravo at `}):null,c?o.sourceHostname:null]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-4 pb-3`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[c&&r.kind===`asset`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Protocol`}),(0,Y.jsxs)(bt,{value:T,onValueChange:e=>e&&ie(e),items:Mn,children:[(0,Y.jsx)(yt,{size:`sm`,className:`w-32`,"aria-label":`Protocol`,children:(0,Y.jsx)(_t,{})}),(0,Y.jsx)(vt,{alignItemWithTrigger:!1,align:`start`,children:Mn.map(e=>(0,Y.jsx)(K,{value:e.value,children:e.label},e.value))})]})]}):null,k?R?(0,Y.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-xs`,children:[(0,Y.jsxs)(`p`,{className:`text-destructive`,children:[`Dry run failed: `,R]}),(0,Y.jsx)(C,{size:`sm`,variant:`outline`,onClick:()=>void M.refetch(),children:`Retry dry run`})]}):F?(0,Y.jsx)(On,{plan:F,planKind:n}):(0,Y.jsx)(An,{}):(0,Y.jsx)(`p`,{className:`text-[11px] text-destructive`,children:O.length===0?`Select at least one scope under Advanced.`:`Fix the invalid host port under Advanced.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(nn,{open:_,onOpenChange:v,isApply:c,scopeOptions:u,scope:d,onToggleScope:e=>f(t=>Qt(t,e)),ifUnmanaged:p,onIfUnmanagedChange:m,instances:h,onInstancesChange:g}),_?(0,Y.jsxs)(`dl`,{className:`flex flex-col gap-0 text-xs leading-snug`,children:[(0,Y.jsx)(rn,{label:`Litmus Edge API`,help:Xt,mono:!0,children:o.hostname}),(0,Y.jsx)(rn,{label:Ae,help:Me,mono:!0,children:o.sourceHostname}),c?(0,Y.jsx)(`div`,{className:`border-b border-border/35 py-2.5`,children:(0,Y.jsx)(qe,{open:S,onOpenChange:ne,protocols:E,values:w,onChange:re,hint:`Enter the host port Litmus Edge should dial. Leave blank to use Miravo's own port. Saved for this target.`})}):null]}):null]})]})}),(0,Y.jsxs)(y,{className:`mx-0 mb-0 shrink-0 flex flex-col gap-2 border-t border-border/60 px-5 py-4 sm:flex-row sm:justify-end`,children:[(0,Y.jsx)(C,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Y.jsxs)(C,{type:`button`,variant:c?`default`:`destructive`,onClick:P,disabled:!k||N,children:[c?(0,Y.jsx)(Ue,{className:`size-3`,"aria-hidden":!0}):(0,Y.jsx)(Xe,{className:`size-3`,"aria-hidden":!0}),L]})]})]})})}function Pn(e,t){let n=new Set,r=[];for(let i of e){if(i.targetId!==t)continue;let e=i.templateId===void 0?`asset`:`template`,a=i.templateId??i.assetId;if(a===void 0)continue;let o=`${e}:${a}`;n.has(o)||(n.add(o),i.operationType===`apply`?i.status===`success`||i.status===`partial`||i.status===`noop`?r.push({subjectId:a,kind:e,completedAt:i.completedAt}):n.delete(o):i.status!==`success`&&i.status!==`noop`&&n.delete(o))}return r}var Fn=500;function In(e){return e.kind===`template`?`template:${e.templateId}`:`asset:${e.assetId}`}function Ln(e,t){return`${In(e)}|${t}`}function Rn(e){return e.operationType===`apply`?e.status===`success`||e.status===`partial`||e.status===`noop`?`applied`:`failed`:e.status===`success`||e.status===`noop`?`none`:`failed`}function zn(e){let t=new Map;for(let n of e){let e=n.templateId===void 0?n.assetId===void 0?null:{kind:`asset`,assetId:n.assetId,protocol:`modbus`}:{kind:`template`,templateId:n.templateId};if(!e)continue;let r=Ln(e,n.targetId);t.has(r)||t.set(r,{status:Rn(n),operationType:n.operationType,targetId:n.targetId,targetLabel:n.targetLabel,completedAt:n.completedAt,error:n.error})}return t}function Bn(e,t){let n=0,r=0;for(let i of e.values())t!==void 0&&i.targetId!==t||(i.status===`applied`?n+=1:i.status===`failed`&&(r+=1));return{applied:n,failed:r}}function Vn(){let e=l({queryKey:a.integrations.operationsFactory(),queryFn:()=>ye({limit:Fn})});return{query:e,cells:(0,J.useMemo)(()=>zn(e.data?.operations??[]),[e.data])}}var Hn=5,Un=`grid min-h-11 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2 @lg/deploy:grid-cols-[minmax(0,1fr)_minmax(9rem,auto)_6.5rem]`;function Wn(e){return e.kind===`template`?e.templateId:e.assetId}function Gn({row:e}){return(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[e.subject.kind===`template`?(0,Y.jsx)(me,{id:e.subject.templateId,className:`size-3.5 shrink-0 text-primary`}):(0,Y.jsx)(Rt,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.label}),e.detail?(0,Y.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.detail}):null]})]})}function Kn({cell:e,running:t}){if(t)return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-primary`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-primary`}),`Running…`]});if(!e||e.status===`none`)return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full border border-muted-foreground/60`}),`Not applied`]});let n=e.status===`applied`;return(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs`,title:e.error??void 0,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-1.5 shrink-0 rounded-full`,n?`bg-success`:`bg-destructive`)}),(0,Y.jsx)(`span`,{className:n?`text-foreground`:`text-destructive`,children:n?`Applied`:e.operationType===`cleanup`?`Clean up failed`:`Failed`}),(0,Y.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:D(e.completedAt)})]})}function qn({row:e,target:t,cell:n,running:r,disabled:i,indent:a,onAction:o}){let s=`${e.label} on ${t.label}`,c=n?.status===`applied`||n?.status===`failed`;return(0,Y.jsxs)(`li`,{className:P(Un,`transition-colors hover:bg-muted/20`,a&&`pl-9`),children:[(0,Y.jsx)(Gn,{row:e}),(0,Y.jsxs)(`div`,{className:`col-start-1 row-start-2 @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,Y.jsx)(Kn,{cell:n,running:r}),n?.status===`failed`&&n.error?(0,Y.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-[11px] text-destructive/80`,children:n.error}):null]}),(0,Y.jsxs)(`div`,{className:`col-start-2 row-span-2 row-start-1 flex items-center justify-end gap-1 @lg/deploy:col-start-auto @lg/deploy:row-span-1 @lg/deploy:row-start-auto`,children:[n?.status===`applied`?null:(0,Y.jsx)(C,{size:`xs`,variant:`outline`,disabled:i,"aria-label":`${n?.status===`failed`?`Retry`:`Apply`} ${s}`,className:Le,onClick:()=>o(`apply`),children:n?.status===`failed`?`Retry`:`Apply`}),c?(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:(0,Y.jsx)(C,{size:`icon-xs`,variant:`ghost`,disabled:i,"aria-label":`More actions for ${s}`,className:`text-muted-foreground hover:text-foreground`}),children:(0,Y.jsx)(zt,{"aria-hidden":!0})}),(0,Y.jsxs)(le,{align:`end`,className:`min-w-40`,children:[(0,Y.jsxs)(ce,{className:`gap-2 text-xs`,onClick:()=>o(`apply`),children:[(0,Y.jsx)(Ut,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Re-apply`]}),(0,Y.jsxs)(ce,{variant:`destructive`,className:`gap-2 text-xs`,onClick:()=>o(`cleanup`),children:[(0,Y.jsx)(Xe,{className:`size-3.5`,"aria-hidden":!0}),`Clean up`]})]})]}):null]})]})}function Jn({target:e,running:t,disabled:n,onCleanup:r}){let i=Pn(l({queryKey:a.integrations.operationsForTarget(e.id),queryFn:()=>xe(e.id)}).data??[],e.id).filter(e=>!t.has(e.subjectId));return i.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`li`,{className:`bg-muted/20 px-4 pt-2.5 pb-1.5`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:`No longer running`}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:[`Still on `,e.label,` from an earlier apply. Clean up removes what Miravo created.`]})]}),i.map(t=>{let i=t.kind===`template`?{subject:{kind:`template`,templateId:t.subjectId},label:t.subjectId}:{subject:{kind:`asset`,assetId:t.subjectId,protocol:`modbus`},label:t.subjectId};return(0,Y.jsxs)(`li`,{className:P(Un,`bg-muted/20`),children:[(0,Y.jsx)(Gn,{row:i}),(0,Y.jsxs)(`span`,{className:`col-start-1 row-start-2 inline-flex items-center gap-1.5 text-xs text-muted-foreground @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-muted-foreground/60`}),`Applied`,(0,Y.jsx)(`span`,{className:`font-mono text-[11px]`,children:D(t.completedAt)})]}),(0,Y.jsx)(`div`,{className:`col-start-2 row-span-2 row-start-1 flex justify-end @lg/deploy:col-start-auto @lg/deploy:row-span-1 @lg/deploy:row-start-auto`,children:(0,Y.jsxs)(C,{size:`xs`,variant:`ghost`,disabled:n,"aria-label":`Clean up ${t.subjectId} on ${e.label}`,className:`text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>r(i),children:[(0,Y.jsx)(Xe,{className:`size-3`,"aria-hidden":!0}),`Clean up`]})})]},`${t.kind}:${t.subjectId}`)})]})}function Yn(e,t){return t>0?`fault`:e>0?`live`:`off`}function Xn({target:e,templates:t,assets:n,running:r,cells:i,stream:a,onAction:o}){let[s,c]=(0,J.useState)(!1),{applied:l,failed:u}=Bn(i,e.id),d=a.status===`running`,f=t=>i.get(Ln(t.subject,e.id)),p=n.length>Hn,m=n.filter(e=>f(e)?.status===`applied`).length,h=(t,n=!1)=>{let r=a.operation,i=d&&r?.label===Wn(t.subject)&&(r.targetLabel===e.label||r.targetLabel===e.id);return(0,Y.jsx)(qn,{row:t,target:e,cell:f(t),running:i,disabled:d,indent:n,onAction:n=>o(t,e,n)},`${t.subject.kind}:${t.label}`)};return(0,Y.jsx)(at,{icon:R,title:e.label,description:(0,Y.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.hostname}),aside:(0,Y.jsxs)(U,{tone:Yn(l,u),children:[(0,Y.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:l}),(0,Y.jsx)(G,{children:`applied`}),u>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mx-1.5 text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:u}),(0,Y.jsx)(G,{children:`failed`})]}):null]}),className:`@container/deploy`,bodyClassName:`p-0`,children:(0,Y.jsxs)(`ul`,{className:`divide-y divide-border/50 py-1`,children:[t.length===0&&n.length===0?(0,Y.jsx)(`li`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`Nothing is running. Load a template to send it to Litmus Edge.`}):null,t.map(e=>h(e)),p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`li`,{className:Un,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,className:`flex min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Y.jsx)(ge,{className:P(`size-3.5 shrink-0 text-muted-foreground transition-transform`,s&&`rotate-90`),"aria-hidden":!0}),`Standalone assets`,(0,Y.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:n.length})]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m>0?`${m} applied`:`Not applied`})]}),s?n.map(e=>h(e,!0)):null]}):n.map(e=>h(e)),(0,Y.jsx)(Jn,{target:e,running:r,disabled:d,onCleanup:t=>o(t,e,`cleanup`)})]})})}function Zn({targets:e,cells:t,stream:n}){let{templates:r,assets:i}=o(S(e=>({templates:e.templates,assets:e.assets}))),[a,s]=(0,J.useState)(null);if(e.length===0)return(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Y.jsx)(R,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`No Litmus Edge target yet`]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add a device with its hostname and an API token. Then apply templates and assets to it from here.`}),(0,Y.jsxs)(g,{to:`/integrations`,className:j({size:`sm`}),children:[(0,Y.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),`Add target`]})]});let c=new Set(r.flatMap(e=>e.assetIds)),l=r.map(e=>({subject:{kind:`template`,templateId:e.templateId},label:e.templateName,detail:e.templateId})),u=i.filter(e=>!c.has(e.id)).map(e=>({subject:{kind:`asset`,assetId:e.id,protocol:`modbus`},label:e.id})),d=new Set([...r.map(e=>e.templateId),...i.map(e=>e.id)]);return(0,Y.jsxs)(`section`,{"aria-label":`Deployments`,className:P(`grid items-start gap-4`,e.length>1&&`@5xl/main:grid-cols-2`),children:[e.map(e=>(0,Y.jsx)(Xn,{target:e,templates:l,assets:u,running:d,cells:t,stream:n,onAction:(e,t,n)=>s({row:e,target:t,action:n})},e.id)),a?(0,Y.jsx)(Nn,{open:!0,onOpenChange:e=>!e&&s(null),action:a.action,subject:a.row.subject,label:a.row.label,target:a.target,stream:n}):null]})}var Qn={status:`idle`,operation:null,error:null,logs:[],cancelRequested:!1},$n=200;function er(){let[e,t]=(0,J.useState)(Qn),n=(0,J.useRef)(null),r=(0,J.useRef)(0),i=c(),o=(0,J.useRef)(0),s=(0,J.useCallback)(e=>{let n=rt(e,`Integration operation failed.`),r=it(e),i=r?`${n} ${r}`:n;t(e=>({...e,status:`error`,cancelRequested:!1,error:i,operation:e.operation?{...e.operation,status:`error`,error:i}:null}))},[]),l=(0,J.useCallback)(e=>{switch(e.event){case`accepted`:tr(e.data,t);break;case`log`:rr({...e.data,id:`log-${r.current++}`},t);break;case`started`:ir(e.data,t);break;case`phase`:ar(e.data,t);break;case`resource`:or(e.data,t);break;case`complete`:sr(e.data,t);break;case`cancelled`:lr(e.data,t);break;case`retrying`:ur(e.data,t);break;case`error`:s(Error(e.data.message));break}},[s]),u=(0,J.useCallback)(e=>{let c=++o.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=Se(e,e=>{o.current===c&&(l(e),dr(e)&&(i.invalidateQueries({queryKey:a.integrations.targets()}),i.invalidateQueries({queryKey:a.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{o.current===c&&(n.current=null,s(e))})},[l,s,i]),d=(0,J.useCallback)(e=>{let c=++o.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=De(e,e=>{o.current===c&&(l(e),dr(e)&&(i.invalidateQueries({queryKey:a.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{o.current===c&&(n.current=null,s(e))})},[l,s,i]),f=(0,J.useCallback)(()=>{o.current++,n.current?.abort(),n.current=null,t(Qn)},[]),p=(0,J.useCallback)(async()=>{let n=e.operation?.operationId;if(!(!n||e.status!==`running`||e.cancelRequested)){t(e=>cr(e,n));try{await Ee(n)||s(Error(`Operation finished before cancellation was accepted.`))}catch(e){s(e instanceof Error?e:Error(`Cancellation failed.`))}}},[e.operation?.operationId,e.status,e.cancelRequested,s]);return(0,J.useEffect)(()=>()=>{o.current++,n.current?.abort(),n.current=null},[]),{...e,startApply:u,startCleanup:d,reset:f,cancel:p}}function tr(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:e.templateId??e.assetId??(e.type===`apply`?`Preparing apply`:`Preparing cleanup`),targetLabel:e.targetId??`Resolving target`,totalPlanned:0,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now()}}))}function nr(e){return e.templateId??e.assetId??`unknown`}function rr(e,t){t(t=>({...t,logs:[...t.logs,e].slice(-$n)}))}function ir(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:nr(e),targetLabel:e.targetLabel,totalPlanned:e.totalPlanned,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now(),attempt:e.attempt,maxAttempts:e.maxAttempts}}))}function ar(e,t){t(t=>{if(!Z(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e),r=n.findIndex(t=>t.name===e.phase),i=r>=0?n.map((t,n)=>n===r?{...t,status:`active`,total:e.total}:t):[...n,{name:e.phase,total:e.total,resources:[],status:`active`}];return{...t,operation:{...t.operation,phases:i}}})}function or(e,t){t(t=>{if(!Z(t,e.operationId))return t;let n={name:e.name,action:e.action,status:e.status,error:e.error},r=t.operation.phases.map(t=>t.name===e.phase&&t.status===`active`?{...t,resources:[...t.resources,n]}:t);return{...t,operation:{...t.operation,phases:r,applied:t.operation.applied+ +(e.status===`success`&&e.action!==`noop`),failed:t.operation.failed+ +(e.status===`failed`)}}})}function sr(e,t){t(t=>{if(!Z(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...t,status:`complete`,cancelRequested:!1,error:null,operation:{...t.operation,phases:n,applied:e.applied??e.deleted??0,failed:e.failed,duration:e.duration,status:`complete`}}})}function cr(e,t){return!Z(e,t)||e.status!==`running`?e:{...e,cancelRequested:!0}}function lr(e,t){t(t=>{if(!Z(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...t,status:`complete`,cancelRequested:!1,error:null,operation:{...t.operation,phases:n,applied:e.applied??e.deleted??0,failed:e.failed,duration:e.duration,status:`cancelled`}}})}function ur(e,t){t(t=>Z(t,e.operationId)?{...t,status:`running`,cancelRequested:!1,error:null,operation:{...t.operation,status:`running`,retryPending:!0,retryDelayMs:e.delayMs,attempt:e.attempt,maxAttempts:e.maxAttempts,error:e.error,applied:0,failed:0,phases:[]}}:t)}function Z(e,t){return e.operation?.operationId===t}function dr(e){return e.event===`complete`||e.event===`cancelled`||e.event===`error`}var fr={initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,originY:0},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:350,damping:40}},pr={initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{type:`tween`,duration:.22,ease:[.16,1,.3,1]}};function mr({children:e,variant:t=`default`}){let n=t===`default`;return(0,Y.jsx)(u.div,{...n?fr:pr,layout:n,className:`mx-auto w-full`,children:e})}var hr=J.memo(({children:e,className:t,delay:n=1e3,...r})=>{let[i,a]=(0,J.useState)(0),o=(0,J.useMemo)(()=>J.Children.toArray(e),[e]);(0,J.useEffect)(()=>{let e=null;return i<o.length-1&&(e=setTimeout(()=>{a(e=>(e+1)%o.length)},n)),()=>{e!==null&&clearTimeout(e)}},[i,n,o.length]);let s=(0,J.useMemo)(()=>o.slice(0,i+1).reverse(),[i,o]);return(0,Y.jsx)(`div`,{className:P(`flex flex-col items-center gap-4`,t),...r,children:(0,Y.jsx)(f,{children:s.map(e=>(0,Y.jsx)(mr,{children:e},e.key))})})});hr.displayName=`AnimatedList`;function gr({type:e,errorMessage:t,className:n}){return null}var _r=`text-destructive hover:bg-destructive/25 hover:text-foreground`,vr={device:`Devices`,tags:`Tags`,model:`Models`,asset:`Assets`,"param-sync":`Parameters`};function yr(e){return vr[e]??e}function br(e){switch(e){case`create`:return`border border-success/30 bg-success/15 text-success`;case`update`:return`border border-chart-3/30 bg-chart-3/15 text-chart-3`;case`replace`:return`border border-warning/30 bg-warning/15 text-warning`;case`delete`:return`border border-destructive/30 bg-destructive/15 text-destructive`;case`noop`:return`border border-border/60 bg-muted/70 text-foreground/75`;default:return`border border-border/50 bg-muted/80 text-foreground/85`}}function xr(e){return e===`noop`?`no-op`:e}function Sr({status:e}){switch(e){case`success`:return(0,Y.jsx)(_e,{className:`size-3.5 shrink-0 text-success`});case`failed`:return(0,Y.jsx)(ve,{className:`size-3.5 shrink-0 text-destructive`});case`pending`:return(0,Y.jsx)(z,{className:`size-3.5 shrink-0 animate-spin text-primary/90`})}}function Cr({status:e}){switch(e){case`done`:return(0,Y.jsx)(_e,{className:`size-3.5 text-success`});case`active`:return(0,Y.jsx)(z,{className:`size-3.5 animate-spin text-primary`});case`pending`:return(0,Y.jsx)(It,{className:`size-3.5 text-foreground/55`})}}function wr({entry:e}){let[t,n]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:P(`flex items-center gap-2 rounded-[var(--miravo-radius-tight)] px-2 py-1 text-left transition-colors`,e.error?`cursor-pointer hover:bg-muted/40`:`cursor-default`),onClick:()=>e.error&&n(!t),disabled:!e.error,children:[(0,Y.jsx)(Sr,{status:e.status}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground`,children:e.name}),(0,Y.jsx)(`span`,{className:P(`inline-flex rounded-[var(--miravo-radius-tight)] px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,br(e.action)),children:xr(e.action)}),e.error&&(0,Y.jsx)(he,{className:P(`size-3 text-foreground/75 transition-transform`,t&&`rotate-180`)})]}),(0,Y.jsx)(f,{initial:!1,children:t&&e.error&&(0,Y.jsxs)(u.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.18},className:`overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`mb-0 flex min-w-0 w-full items-center gap-1.5 rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/15 px-2.5 py-1.5 text-[10px] font-medium leading-relaxed`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 text-left whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error}),(0,Y.jsx)(ke,{value:e.error,label:`Copy error`,className:P(_r,`shrink-0`)})]}),(0,Y.jsx)(gr,{type:`apply`,errorMessage:e.error,className:`mb-1 mt-2.5 w-full min-w-0`})]})})]})}function Tr({phase:e,open:t,onOpenChange:n}){let r=e.resources.length,i=r===e.total,a=e.resources.length>0;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:P(`flex w-full items-center gap-2 rounded-[var(--miravo-radius-tight)] px-1 py-1 text-left transition-colors`,a&&`hover:bg-muted/40`,!a&&`cursor-default`),disabled:!a,"aria-expanded":a?t:void 0,onClick:()=>a&&n(!t),children:[(0,Y.jsx)(Cr,{status:e.status}),(0,Y.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-foreground`,children:yr(e.name)}),(0,Y.jsxs)(`span`,{className:`font-mono text-[10px] text-foreground/70`,children:[r,`/`,e.total]}),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[i&&e.status===`done`&&(0,Y.jsx)(_e,{className:`size-3 text-success`}),a&&(0,Y.jsx)(he,{className:P(`size-3 text-foreground/75 transition-transform`,!t&&`-rotate-90`),"aria-hidden":!0})]})]}),(0,Y.jsx)(f,{initial:!1,children:a&&t&&(0,Y.jsx)(u.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`ml-2 flex min-w-0 flex-col border-l border-border/55 pl-2.5 pr-1.5 pb-1 pt-0.5`,children:(0,Y.jsx)(d.Provider,{value:null,children:e.resources.map((e,t)=>(0,Y.jsx)(mr,{variant:`subtle`,children:(0,Y.jsx)(wr,{entry:e})},`${e.name}-${t}`))})})})})]})}function Er({operation:e}){let t=e.status===`complete`,n=e.status===`cancelled`,r=e.failed>0,i=e.totalPlanned>0?Math.min(100,Or(e)/e.totalPlanned*100):0;return(0,Y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,role:`progressbar`,"aria-valuenow":Math.round(i),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Operation progress`,children:(0,Y.jsx)(u.div,{"aria-hidden":`true`,className:P(`h-full rounded-full transition-colors duration-500`,n?`bg-foreground/30`:t&&!r?`bg-success`:`bg-warning`),initial:{width:`0%`},animate:{width:`${i}%`},transition:{duration:.4,ease:[.25,.1,.25,1]}})})}function Dr(e){return e.duration==null?(Date.now()-e.startedAt)/1e3:e.duration/1e3}function Or(e){let t=e.applied+e.failed;return e.totalPlanned>0?Math.min(t,e.totalPlanned):t}var kr={complete:{Icon:_e,className:`size-4 text-success`},partial:{Icon:Ft,className:`size-4 text-warning`},cancelled:{Icon:jt,className:`size-4 text-foreground/65`},error:{Icon:ve,className:`size-4 text-destructive`},running:{Icon:z,className:`size-4 animate-spin text-warning`}};function Ar({icon:e,className:t}){return(0,Y.jsx)(u.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},className:`shrink-0`,children:(0,Y.jsx)(e,{className:t})})}function jr({operation:e,sourceLabel:t,isAllExpanded:n,onToggleAll:r}){let i=Dr(e),a=Or(e),o=e.status===`complete`,s=e.status===`cancelled`,c=e.status===`error`,l=e.failed>0,d=o&&!l?`complete`:o&&l?`partial`:s?`cancelled`:c?`error`:`running`,p=kr[d];return(0,Y.jsxs)(`div`,{className:P(`sticky top-0 z-10 flex min-w-0 w-full flex-col gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border px-3 pt-2.5 pb-3.5 backdrop-blur-sm transition-colors duration-500`,o&&!l&&`border-success/30 bg-success/5`,o&&l&&`border-warning/30 bg-warning/5`,s&&`border-border/60 bg-muted/50`,c&&`border-destructive/30 bg-destructive/5`,!o&&!s&&!c&&`border-warning/20 bg-warning/5`),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Y.jsx)(f,{mode:`wait`,initial:!1,children:(0,Y.jsx)(Ar,{icon:p.Icon,className:p.className},d)}),(0,Y.jsx)(`span`,{className:`text-xs font-medium leading-none text-foreground`,children:s?`Cancelled`:o?l?`Completed with errors`:`Complete`:c?`Failed`:e.retryPending?`Failed, retrying attempt ${e.attempt?e.attempt+1:2}/${e.maxAttempts} in ${e.retryDelayMs?e.retryDelayMs/1e3:3}s...`:e.attempt&&e.maxAttempts&&e.attempt>1?`Retrying attempt ${e.attempt}/${e.maxAttempts}...`:e.type===`apply`?`Applying...`:`Cleaning up...`}),(0,Y.jsxs)(`span`,{className:`w-full min-w-0 text-[10px] leading-tight text-foreground/78`,children:[(0,Y.jsx)(`span`,{className:`font-sans break-words`,children:t}),(0,Y.jsx)(`span`,{className:`font-mono break-words`,children:` → ${e.targetLabel}`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(et,{variant:`secondary`,className:`h-5 min-h-5 gap-0 overflow-hidden border border-border/50 bg-muted/70 px-1.5 !py-0 font-mono text-[10px] leading-none text-foreground shadow-sm [&>span]:inline-flex [&>span]:items-center`,children:(0,Y.jsxs)(`span`,{className:`gap-1`,children:[(0,Y.jsx)(f,{mode:`popLayout`,initial:!1,children:(0,Y.jsx)(u.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`inline tabular-nums`,children:a},a)}),`/`,e.totalPlanned,(0,Y.jsx)(`span`,{className:`text-foreground/72`,children:e.type===`apply`?`applied`:`deleted`})]})}),(0,Y.jsx)(f,{initial:!1,children:e.failed>0&&(0,Y.jsx)(u.div,{className:`inline-flex items-center`,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:500,damping:30},children:(0,Y.jsxs)(et,{variant:`destructive`,className:`h-5 min-h-5 gap-0 border border-destructive/35 bg-destructive/20 px-1.5 !py-0 font-mono text-[10px] font-semibold leading-none text-destructive`,children:[e.failed,` failed`]})})})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] leading-none text-foreground/75`,children:[(0,Y.jsx)(Lt,{className:`size-3 shrink-0 block text-foreground/65`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`tabular-nums leading-none`,children:typeof i==`number`?`${i.toFixed(1)}s`:`...`})]}),r&&(0,Y.jsx)(`div`,{className:`flex items-center border-l border-border/40 pl-2`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`flex size-4.5 items-center justify-center rounded-[var(--miravo-radius-tight)] text-foreground/55 transition-colors hover:bg-muted/60 hover:text-foreground`,"aria-label":n?`Collapse all phases`:`Expand all phases`,title:n?`Collapse all`:`Expand all`,children:(0,Y.jsx)(Pt,{className:P(`size-3.5 transition-transform duration-300`,!n&&`opacity-70 scale-y-[-1]`)})})})]})]}),(0,Y.jsx)(Er,{operation:e})]})]})}function Mr(e){return e?e.closest(`[data-edge-op-scroll]`)??e.closest(`.overflow-y-auto`):null}var Nr=350;function Pr(e){e?.scrollIntoView({block:`end`,behavior:`auto`,inline:`nearest`})}function Fr(e){let t=()=>Pr(e);t(),requestAnimationFrame(t),requestAnimationFrame(()=>requestAnimationFrame(t)),window.setTimeout(t,0),window.setTimeout(t,48),window.setTimeout(t,120)}function Ir({logs:e}){return e.length===0?null:(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5 px-2 pb-2`,children:e.map(e=>(0,Y.jsxs)(`div`,{className:P(`flex min-w-0 items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-xs`,e.level===`error`?`border-destructive/35 bg-destructive/12 text-destructive`:e.level===`warn`?`border-warning/35 bg-warning/12 text-warning`:`border-primary/25 bg-primary/8 text-foreground/82`),children:[e.level===`info`?(0,Y.jsx)(I,{className:`mt-0.5 size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,Y.jsx)(Ft,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:e.message})]},e.id))})}function Lr({operation:e,logs:t}){let n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(!0),a=(0,J.useRef)(e.status);a.current=e.status;let o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(new Set),l=e.label;(0,J.useLayoutEffect)(()=>{let e=Mr(n.current);if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<Nr};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,J.useLayoutEffect)(()=>{if(e.status===`running`){i.current&&Pr(r.current),o.current=!0;return}o.current&&=(Fr(r.current),!1)},[e.status,e.applied,e.failed,e.phases]),(0,J.useEffect)(()=>{if(e.status!==`running`)return;let t=n.current;if(!t)return;let o=0,s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{a.current===`running`&&i.current&&Pr(r.current)})});return s.observe(t),i.current&&Pr(r.current),()=>{s.disconnect(),cancelAnimationFrame(o)}},[e.status]);let d=e.phases.length>0,p=s.size===0;return(0,Y.jsxs)(`div`,{ref:n,className:`flex min-w-0 w-full flex-col gap-2`,children:[(0,Y.jsx)(jr,{operation:e,sourceLabel:l,isAllExpanded:p,onToggleAll:d?()=>{c(p?new Set(e.phases.map(e=>e.name)):new Set)}:void 0}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 px-2 pt-2 pb-4`,children:e.phases.map(e=>(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Tr,{phase:e,open:!s.has(e.name),onOpenChange:t=>{c(n=>{let r=new Set(n);return t?r.delete(e.name):r.add(e.name),r})}})},e.name))}),(0,Y.jsx)(f,{initial:!1,children:e.error&&e.retryPending&&(0,Y.jsxs)(u.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`sticky bottom-2 z-20 mx-2 mt-auto mb-2 flex items-center gap-2 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-destructive/40 bg-destructive/15 px-3 py-2 text-xs font-medium text-destructive shadow-md backdrop-blur-md`,children:[(0,Y.jsx)(z,{className:`size-4 shrink-0 animate-spin`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.error})]})}),(0,Y.jsx)(f,{initial:!1,children:e.error&&e.status===`error`&&(0,Y.jsxs)(u.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:`auto`,marginTop:8},exit:{opacity:0,height:0,marginTop:0},transition:{duration:.2},className:`mx-2 mb-4 flex min-w-0 flex-col gap-0 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-destructive/40 bg-destructive/15 px-3 py-2 text-xs font-medium`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 text-left wrap-anywhere text-destructive`,children:e.error}),(0,Y.jsx)(ke,{value:e.error,label:`Copy error`,className:P(_r,`shrink-0`)})]}),(0,Y.jsx)(gr,{type:e.type,errorMessage:e.error,className:`mt-3 w-full min-w-0`})]})}),t&&t.length>0?(0,Y.jsx)(Ir,{logs:t}):null,(0,Y.jsx)(`div`,{ref:r,className:`h-px w-full shrink-0`,"aria-hidden":!0})]})}function Rr({title:e,subtitle:t,footerAction:n,canDismiss:r=!0,onDismiss:i,children:a}){return(0,J.useEffect)(()=>{function e(e){e.key===`Escape`&&r&&i()}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r,i]),(0,Y.jsx)(u.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:16},transition:{type:`spring`,stiffness:380,damping:30},className:`pointer-events-none fixed bottom-4 left-4 right-4 z-[60] sm:left-auto sm:w-full sm:max-w-md`,children:(0,Y.jsxs)(Je,{className:`pointer-events-auto flex flex-col overflow-hidden border-border/70 bg-background p-0 shadow-lg shadow-black/15 ring-1 ring-border/50 backdrop-blur-sm sm:p-0 bg-background shadow-black/50`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2 border-b border-border/45 p-2.5 pb-2 sm:p-3 sm:pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Y.jsx)(Ve,{className:`size-4 shrink-0 text-primary`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`font-heading text-xs font-semibold tracking-tight text-foreground`,children:e}),t?(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/80`,children:t}):null]})]}),r?(0,Y.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0 text-foreground/70 hover:bg-muted/80 hover:text-foreground`,onClick:i,"aria-label":`Dismiss operation panel`,children:(0,Y.jsx)(w,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2.5 pt-2.5 sm:px-3 sm:pt-3`,"data-edge-op-scroll":``,children:a}),n?(0,Y.jsx)(`div`,{className:`flex w-full shrink-0 min-w-0 items-center gap-2 border-t border-border/40 bg-muted/15 p-2.5 sm:p-3`,children:n}):null]})})}function zr(e){let t=e.operation,n=t?.type===`apply`?`apply`:`cleanup`;switch(e.status){case`running`:return{title:`Operation in progress`,subtitle:`Streaming ${n} steps to Litmus Edge`};case`complete`:return t?.status===`cancelled`?{title:`Operation cancelled`,subtitle:`Stopped — resources created so far remain in Litmus Edge.`}:{title:`Operation complete`,subtitle:n===`apply`?`Apply finished — review the summary below.`:`Cleanup finished — review the summary below.`};case`error`:return{title:`Operation failed`,subtitle:e.error??t?.error??`The operation ended with an error.`};default:return{title:`Operation`,subtitle:``}}}function Br({stream:e,onReset:t}){if(!e.operation&&e.status!==`running`)return null;let{title:n,subtitle:r}=zr(e),i=e.status===`complete`,a=e.status===`error`,o=e.status===`running`,s=i||a,c=e.cancelRequested;async function l(){await e.cancel().catch(()=>{})}return(0,Y.jsx)(Rr,{title:n,subtitle:r,canDismiss:!o,footerAction:o&&e.operation?.operationId?(0,Y.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:l,disabled:c,"aria-busy":c,className:P(j({variant:`outline`,size:`sm`}),`group h-8 gap-1.5 px-3 text-xs`,c?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),children:c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(u.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(w,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,Y.jsx)(u.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):s?(0,Y.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 w-full flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,Y.jsxs)(g,{to:`/integrations?tab=activity`,className:P(j({variant:`ghost`,size:`xs`}),`group inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-[11px] font-medium text-foreground/80`,`hover:bg-primary/12 hover:text-primary`),children:[(0,Y.jsx)(F,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,Y.jsx)(ge,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,Y.jsx)(C,{type:`button`,variant:`secondary`,size:`xs`,className:`h-6 px-2.5 text-[11px] font-medium`,onClick:t,children:`Close`})})]}),e.operation?.status===`cancelled`||a&&e.operation?(0,Y.jsx)(gr,{type:e.operation.type,errorMessage:e.operation.error,className:`mt-2.5 w-full min-w-0`}):null]}):void 0,onDismiss:t,children:e.operation?(0,Y.jsx)(Lr,{operation:e.operation,logs:e.logs}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,Y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,Y.jsx)(u.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})})}function Vr({targetCount:e,applied:t,failed:n,lastOp:r}){return(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-background/70 text-primary`,children:(0,Y.jsx)(R,{className:`size-4`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Litmus Edge`}),(0,Y.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-pretty text-xs text-muted-foreground`,children:`Send running templates and assets to Litmus Edge devices: devices, tags and flows. Each change is planned before it runs, and clean up removes only what Miravo created.`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(U,{tone:e>0?`live`:`off`,children:[(0,Y.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,Y.jsx)(G,{children:e===1?`target`:`targets`})]}),(0,Y.jsxs)(U,{tone:t>0?`live`:`off`,children:[(0,Y.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:t}),(0,Y.jsx)(G,{children:`applied`})]}),n>0?(0,Y.jsxs)(U,{tone:`fault`,children:[(0,Y.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:n}),(0,Y.jsx)(G,{children:`failed`})]}):null,r?(0,Y.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`last run `,D(r.completedAt)]}):null,(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,Y.jsxs)(g,{to:`/integrations`,className:W+` text-xs text-muted-foreground`,children:[(0,Y.jsx)(Ge,{className:`size-3`,"aria-hidden":!0}),`Manage targets`]}),(0,Y.jsxs)(g,{to:`/integrations?tab=activity`,className:W+` text-xs text-muted-foreground`,children:[(0,Y.jsx)(F,{className:`size-3`,"aria-hidden":!0}),`Activity`]}),(0,Y.jsxs)(`a`,{href:`${Wt}/integrations/litmus-edge`,target:`_blank`,rel:`noopener noreferrer`,className:W+` text-xs text-muted-foreground`,children:[(0,Y.jsx)(Mt,{className:`size-3`,"aria-hidden":!0}),`Docs`]})]})]})}function Hr(){let e=er(),t=l({queryKey:a.integrations.targets(),queryFn:()=>Ce()}),{query:n,cells:r}=Vn(),i=t.data,o=n.data?.operations;if(!i||!o){let e=t.error??n.error;return e?(0,Y.jsx)(He,{message:rt(e,`Could not load Litmus Edge status.`),onRetry:()=>{t.refetch(),n.refetch()},isRetrying:t.isFetching||n.isFetching}):(0,Y.jsx)(X,{className:`h-64 w-full`})}let{applied:s,failed:c}=Bn(r),u=o[0];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(Vr,{targetCount:i.length,applied:s,failed:c,lastOp:u}),(0,Y.jsx)(Zn,{targets:i,cells:r,stream:e}),e.operation||e.status===`running`?(0,Y.jsx)(Br,{stream:e,onReset:e.reset}):null]})}function Ur(){let e=l({queryKey:a.integrations.targets(),queryFn:()=>Ce()}),{cells:t}=Vn(),n=e.data?.length??0,{applied:r,failed:i}=Bn(t);return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-1.5 shrink-0 rounded-full`,i>0?`bg-destructive`:r>0?`bg-success`:`bg-muted-foreground/50`)}),n===0?(0,Y.jsx)(`span`,{className:`font-sans`,children:`No target yet`}):(0,Y.jsxs)(`span`,{className:`truncate`,children:[n,` `,n===1?`target`:`targets`,` ·`,` `,(0,Y.jsx)(`span`,{className:`text-foreground`,children:r}),` applied`,i>0?(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[` · `,i,` failed`]}):null]})]})}var Wr={"litmus-edge":{icon:R,Panel:Hr,Summary:Ur}};function Gr(e){return e?`/?tab=integrations&integration=${e}`:`/?tab=integrations`}function Kr(){return(0,Y.jsxs)(at,{icon:Ht,title:`Integrations`,description:`Send this factory to the platforms you build on.`,bodyClassName:`gap-1 px-2 py-2`,footer:(0,Y.jsxs)(g,{to:Gr(),className:W,children:[`Open integrations`,(0,Y.jsx)(L,{className:`size-3`,"aria-hidden":!0})]}),children:[At.map(e=>{let{icon:t,Summary:n}=Wr[e.id];return(0,Y.jsxs)(g,{to:Gr(e.id),className:`group flex min-w-0 items-center gap-3 rounded-[var(--miravo-radius-tight)] px-2 py-2 outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Y.jsx)(t,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.label}),(0,Y.jsx)(n,{})]}),(0,Y.jsx)(ge,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]},e.id)}),(0,Y.jsxs)(`p`,{className:`px-2 pt-1 pb-0.5 text-[11px] text-muted-foreground`,children:[`Coming soon: `,Ot.map(e=>e.label).join(`, `),`.`]})]})}function qr(e){return s.prefetchQuery({queryKey:a.assets.detail(e),queryFn:()=>i(`/assets/${e}`,r.assetDetail),staleTime:2e3})}var Jr=`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function Yr(e,t,n,r){let i=n===`asc`?1:-1;return[...e].sort((e,n)=>{switch(t){case`id`:return e.id.localeCompare(n.id)*i;case`template`:return(r.get(e.id)??``).localeCompare(r.get(n.id)??``)*i;case`model`:return e.model.localeCompare(n.model)*i;case`lifecycle`:return e.lifecycleStage.localeCompare(n.lifecycleStage)*i;case`hours`:return(e.operatingHours-n.operatingHours)*i;case`faults`:return(e.activeFaults.length-n.activeFaults.length)*i;case`status`:{let t=e=>e.isQuarantined?2:+(e.activeFaults.length>0);return(t(e)-t(n))*i}default:return 0}})}function Xr(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var Zr={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; asset is still running.`},quarantined:{pip:`bg-destructive`,ring:`border-destructive/40 text-destructive`,label:`quarantined`,help:`Asset isolated from production flows pending review.`}};function Qr({state:e}){let t=Zr[e];return(0,Y.jsxs)(H,{children:[(0,Y.jsxs)(B,{render:(0,Y.jsx)(`span`,{className:P(`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,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,Y.jsx)(`span`,{children:re(t.label)})]}),(0,Y.jsx)(V,{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,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,Y.jsx)(`span`,{children:e}),n&&(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,Y.jsx)(se,{className:P(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,Y.jsx)(wt,{className:s,"aria-sort":l,children:r?(0,Y.jsxs)(H,{children:[(0,Y.jsx)(B,{render:u}),(0,Y.jsx)(V,{side:`top`,children:r})]}):u})}function $r({title:e,body:t,action:n}){return(0,Y.jsx)(xt,{children:(0,Y.jsx)(q,{colSpan:8,className:`py-10`,children:(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,Y.jsxs)(g,{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,Y.jsx)(L,{className:`size-3`,"aria-hidden":!0})]})]})})})}function ei({assets:e,state:t,templateByAsset:n,sortKey:r,sortDir:i,onSort:a,onOpenAsset:o}){return(0,Y.jsx)(pt,{className:`py-0`,children:(0,Y.jsx)(ht,{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,Y.jsxs)(Tt,{children:[(0,Y.jsx)(Et,{children:(0,Y.jsxs)(xt,{children:[(0,Y.jsx)(Q,{label:`Asset`,sortKey:`id`,current:r,direction:i,onSort:a}),(0,Y.jsx)(Q,{label:`Template`,sortKey:`template`,current:r,direction:i,onSort:a,className:`hidden md:table-cell`}),(0,Y.jsx)(Q,{label:`Model`,sortKey:`model`,current:r,direction:i,onSort:a,className:`hidden sm:table-cell`}),(0,Y.jsx)(Q,{label:`Lifecycle`,sortKey:`lifecycle`,current:r,direction:i,onSort:a,tooltip:Jr}),(0,Y.jsx)(Q,{label:`Operating age`,sortKey:`hours`,current:r,direction:i,onSort:a,tooltip:`Cumulative operating hours since the asset started running.`,className:`hidden text-right md:table-cell`}),(0,Y.jsx)(Q,{label:`Faults`,sortKey:`faults`,current:r,direction:i,onSort:a,tooltip:`Count of active (uncleared) faults on this asset.`}),(0,Y.jsx)(Q,{label:`Status`,sortKey:`status`,current:r,direction:i,onSort:a}),(0,Y.jsx)(wt,{children:(0,Y.jsx)(`span`,{className:`sr-only`,children:`Navigate to asset`})})]})}),(0,Y.jsx)(St,{children:t===`connecting`?(0,Y.jsx)($r,{title:`Connecting to runtime`,body:`Live asset data will appear once the connection is up.`}):t===`empty`?(0,Y.jsx)($r,{title:`No running assets`,body:`Start a factory from the Catalog to see assets.`,action:{label:`Open Catalog`,href:`/catalog`}}):e.length===0?(0,Y.jsx)($r,{title:`No matches`,body:`Adjust filters or clear them to see all assets.`}):e.map(e=>{let t=Xr(e),r=k(e.id);return(0,Y.jsxs)(xt,{tabIndex:0,"aria-label":`Open asset ${r}`,className:P(`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:()=>o(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.id))},onMouseEnter:()=>{Qe(`/asset/${e.id}`),qr(e.id)},onFocus:()=>{Qe(`/asset/${e.id}`),qr(e.id)},children:[(0,Y.jsx)(q,{className:`text-sm`,children:(0,Y.jsx)(J.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,Y.jsx)(`span`,{className:`inline-flex max-w-full truncate rounded-(--miravo-radius-tight) text-left`,title:e.id,children:r})})}),(0,Y.jsx)(q,{className:`hidden text-sm text-muted-foreground md:table-cell`,children:n.get(e.id)??`Standalone`}),(0,Y.jsx)(q,{className:`hidden text-sm sm:table-cell`,children:A(e.model)}),(0,Y.jsx)(q,{children:(0,Y.jsx)(et,{variant:`secondary`,className:`text-xs`,children:ie(e.lifecycleStage)})}),(0,Y.jsx)(q,{className:`hidden font-mono text-sm md:table-cell`,children:O(e.operatingHours)}),(0,Y.jsx)(q,{children:e.activeFaults.length>0?(0,Y.jsxs)(H,{children:[(0,Y.jsx)(B,{render:(0,Y.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,Y.jsxs)(V,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,Y.jsx)(q,{children:(0,Y.jsx)(Qr,{state:t})}),(0,Y.jsx)(q,{children:(0,Y.jsx)(L,{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)})})]})})})}var ti=`~all`,ni=`~standalone`;function ri(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function ii(){let{assets:e,templates:t,connectionState:n}=o(S(e=>({assets:e.assets,templates:e.templates,connectionState:e.connectionState}))),[r,i]=p(`q`,m.withDefault(``)),[a,s]=p(`model`,m.withDefault(``)),[c,l]=p(`lifecycle`,m.withDefault(``)),[u,d]=p(`template`,m.withDefault(``)),[f,h]=p(`standalone`,m.withDefault(``)),g=f===`1`,[_,v]=p(`status`,m.withDefault(``)),y=ri(_)?_:``,[b,ee]=(0,J.useState)(`id`),[x,te]=(0,J.useState)(`asc`),C=(0,J.useRef)(null),re=$e(),[T,ae]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),C.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let E=(0,J.useCallback)(e=>{e===b?te(e=>e===`asc`?`desc`:`asc`):(ee(e),te(`asc`))},[b]),D=(0,J.useMemo)(()=>{let e=new Map;for(let n of t)for(let t of n.assetIds)e.set(t,n.templateName);return e},[t]),O=(0,J.useMemo)(()=>[{value:ti,label:`All templates`},{value:ni,label:`Standalone`},...t.map(e=>({value:e.templateId,label:e.templateName}))],[t]),k=(0,J.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.model,(t.get(n.model)??0)+1);return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[e]),j=(0,J.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),N=(0,J.useMemo)(()=>[{value:`all`,label:`All stages`},...j.map(e=>({value:e,label:ie(e)}))],[j]),P=(0,J.useMemo)(()=>T?k.filter(([e])=>M(e,T)):k,[k,T]),F=(0,J.useMemo)(()=>a?{value:a,label:A(a)}:null,[a]),I=(0,J.useMemo)(()=>{let n=e;if(g)n=n.filter(e=>!D.has(e.id));else if(u){let e=new Set(t.find(e=>e.templateId===u)?.assetIds);n=n.filter(t=>e.has(t.id))}return a&&(n=n.filter(e=>e.model===a)),c&&(n=n.filter(e=>e.lifecycleStage===c)),r&&(n=n.filter(e=>oe(e.id,r)||M(e.model,r))),y===`faulted`&&(n=n.filter(e=>e.activeFaults.length>0)),y===`quarantined`&&(n=n.filter(e=>e.isQuarantined)),y===`healthy`&&(n=n.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),Yr(n,b,x,D)},[e,t,D,u,g,r,y,a,c,b,x]),L=y!==``||u!==``||g||a!==``||c!==``||r!==``,R=(0,J.useCallback)(()=>{i(``),v(``),d(``),h(``),s(``),l(``)},[i,v,d,h,s,l]),se=(0,J.useCallback)(e=>{re(`/asset/${e}`,{transitionType:tt})},[re]),ce=e.length>0?`rows`:n===`live`?`empty`:`connecting`;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.length>0&&(0,Y.jsxs)(bt,{value:g?ni:u||ti,onValueChange:e=>{h(e===ni?`1`:``),d(!e||e===ti||e===ni?``:e)},items:O,children:[(0,Y.jsx)(yt,{className:`h-8 w-44`,"aria-label":`Template filter`,children:(0,Y.jsx)(_t,{placeholder:`All templates`})}),(0,Y.jsx)(vt,{alignItemWithTrigger:!1,align:`start`,children:O.map(e=>(0,Y.jsx)(K,{value:e.value,children:e.label},e.value))})]}),(0,Y.jsxs)(gt,{value:F,onValueChange:e=>void s(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:ae,children:[(0,Y.jsx)(mt,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!a}),(0,Y.jsx)(ft,{children:(0,Y.jsxs)(ut,{children:[P.map(([e,t])=>(0,Y.jsxs)(dt,{value:{value:e,label:A(e)},children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:A(e)}),(0,Y.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),P.length===0&&(0,Y.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),j.length>1&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(bt,{value:c||`all`,onValueChange:e=>void l(!e||e===`all`?``:e),items:N,children:[(0,Y.jsx)(yt,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,Y.jsx)(_t,{placeholder:`All stages`})}),(0,Y.jsxs)(vt,{alignItemWithTrigger:!1,align:`start`,children:[(0,Y.jsx)(K,{value:`all`,children:`All stages`}),j.map(e=>(0,Y.jsx)(K,{value:e,children:ie(e)},e))]})]}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(B,{render:(0,Y.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,Y.jsx)(we,{className:`size-3.5`,"aria-hidden":!0})}),(0,Y.jsx)(V,{side:`top`,children:`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`})]})]}),(0,Y.jsxs)(bt,{value:y||`all`,onValueChange:e=>void v(!e||e===`all`?``:e),items:Ct,children:[(0,Y.jsx)(yt,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,Y.jsx)(_t,{placeholder:`All status`})}),(0,Y.jsxs)(vt,{alignItemWithTrigger:!1,align:`start`,children:[(0,Y.jsx)(K,{value:`all`,children:`All status`}),(0,Y.jsx)(K,{value:`healthy`,children:`Healthy`}),(0,Y.jsx)(K,{value:`faulted`,children:`Faulted`}),(0,Y.jsx)(K,{value:`quarantined`,children:`Quarantined`})]})]}),(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(ne,{ref:C,placeholder:`Search...`,value:r,onChange:e=>void i(e.target.value),"aria-label":`Search assets by id or model`,className:`h-8 w-40 pr-7 text-xs`}),!r&&(0,Y.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:`/`})]}),L&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:R,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,Y.jsx)(w,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[I.length,` of `,e.length]})]})]}),(0,Y.jsx)(ei,{assets:I,state:ce,templateByAsset:D,sortKey:b,sortDir:x,onSort:E,onOpenAsset:se})]})}var ai={running:`live`,paused:`idle`,stopped:`fault`};function oi(){let{factoryName:e,engineState:t,seed:n,speed:r,bootTemplate:i}=o(S(e=>({factoryName:e.factoryName,engineState:e.engineState,seed:e.seed,speed:e.speedMultiplier,bootTemplate:e.bootTemplate})));return(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:e&&!Ie(e)?ae(e):`Factory`}),(0,Y.jsx)(U,{tone:ai[t]??`off`,children:(0,Y.jsx)(G,{children:t})})]}),(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-muted-foreground`,children:[e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[`id `,(0,Y.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`})]}):null,(0,Y.jsxs)(`span`,{children:[`seed `,(0,Y.jsx)(`span`,{className:`text-foreground`,children:n??`-`})]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`span`,{className:`text-foreground`,children:[r,`×`]}),` speed`]}),i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,Y.jsxs)(`span`,{children:[`booted with `,(0,Y.jsx)(`span`,{className:`text-foreground`,children:i.name})]})]}):null]})]}),(0,Y.jsxs)(g,{to:`/catalog`,className:j({size:`sm`}),children:[(0,Y.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),`Load template`]})]})}var si=At.map(e=>e.id),ci=`inline-flex h-8 shrink-0 items-center gap-2 rounded-[var(--miravo-radius-pill)] border px-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring`;function li(){let[e,t]=p(`integration`,h(si).withDefault(kt.id)),{Panel:n}=Wr[e];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsxs)(`nav`,{"aria-label":`Integrations`,className:`flex flex-wrap gap-2`,children:[At.map(n=>{let{icon:r}=Wr[n.id],i=n.id===e;return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>void t(n.id),className:P(ci,i?`border-primary/45 bg-primary/10 text-foreground`:`border-border/60 text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:[(0,Y.jsx)(r,{className:P(`size-3.5`,i&&`text-primary`),"aria-hidden":!0}),n.label]},n.id)}),Ot.map(e=>(0,Y.jsxs)(`span`,{"aria-disabled":!0,className:P(ci,`cursor-default border-dashed border-border/60 text-muted-foreground/70`),children:[(0,Y.jsx)(Ht,{className:`size-3.5`,"aria-hidden":!0}),e.label,(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Soon`})]},e.id))]}),(0,Y.jsx)(n,{})]})}function ui(e={}){let t=new URLSearchParams({tab:`assets`});return e.template&&t.set(`template`,e.template),e.standalone&&t.set(`standalone`,`1`),e.model&&t.set(`model`,e.model),e.status&&t.set(`status`,e.status),`/?${t.toString()}`}var di={healthy:`border-muted-foreground/25 bg-muted/40 text-foreground/90 hover:border-muted-foreground/50`,faulted:`border-destructive/40 bg-destructive/10 text-destructive hover:border-destructive/70`,quarantined:`border-warning/40 bg-warning/10 text-warning hover:border-warning/70`},fi={healthy:`bg-success`,faulted:`bg-destructive`,quarantined:`bg-warning`};function pi({group:e,label:t,templateId:n}){let[r]=e.ids;return(0,Y.jsxs)(g,{to:e.ids.length===1&&r?`/asset/${r}`:ui({model:e.model,template:n}),title:e.ids.join(`, `),className:P(`inline-flex h-6 items-center gap-1.5 rounded-[var(--miravo-radius-tight)] border px-1.5 font-mono text-[11px] outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,di[e.health]),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-1.5 shrink-0 rounded-full`,fi[e.health])}),t,e.ids.length>1&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.ids.length]}),e.health!==`healthy`&&(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`, `,e.health]})]})}function mi(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var hi=24;function gi(){let{assets:e,templates:t}=o(S(e=>({assets:e.assets,templates:e.templates}))),[n,r]=(0,J.useState)(!1),i=new Set(t.flatMap(e=>e.assetIds)),a=e.filter(e=>!i.has(e.id));if(a.length===0)return null;let s=n?a:a.slice(0,hi);return(0,Y.jsxs)(`section`,{"aria-label":`Standalone assets`,className:P(Re,`flex flex-col gap-4 p-5`),children:[(0,Y.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,Y.jsx)(Rt,{className:`size-5`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:`Standalone assets`}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/75`,children:`Spawned from a model, outside any template.`})]})]}),(0,Y.jsxs)(`ul`,{className:`flex flex-wrap gap-1.5`,children:[s.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(pi,{group:{model:e.model,ids:[e.id],health:mi(e)},label:e.id})},e.id)),a.length>hi&&(0,Y.jsx)(`li`,{children:(0,Y.jsx)(C,{size:`xs`,variant:`ghost`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`+${a.length-hi} more`})})]}),(0,Y.jsxs)(`div`,{className:`mt-auto font-mono text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:a.length}),` asset`,a.length===1?``:`s`]}),(0,Y.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,Y.jsxs)(g,{to:ui({standalone:!0}),className:P(j({size:`sm`,variant:`outline`}),Le),children:[(0,Y.jsx)(Nt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),(0,Y.jsxs)(g,{to:`/models`,className:P(j({size:`sm`,variant:`ghost`}),`ml-auto text-muted-foreground`),children:[(0,Y.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),`Spawn asset`]})]})]})}function _i({template:e,open:t,onOpenChange:n}){let r=ze(),[i,a]=(0,J.useState)(!1);return(0,Y.jsx)(te,{open:t,onOpenChange:n,children:(0,Y.jsxs)(b,{children:[(0,Y.jsxs)(v,{children:[(0,Y.jsxs)(ee,{children:[`Unload `,e.templateName]}),(0,Y.jsxs)(x,{children:[`Removes its `,e.assetIds.length,` asset`,e.assetIds.length===1?``:`s`,`. Standalone assets stay.`]})]}),(0,Y.jsxs)(y,{children:[(0,Y.jsx)(C,{variant:`outline`,onClick:()=>n(!1),disabled:i,children:`Cancel`}),(0,Y.jsx)(C,{variant:`destructive`,disabled:i,onClick:async()=>{a(!0);try{await r.mutateAsync({type:`unloadTemplate`,templateId:e.templateId}),n(!1)}catch{}finally{a(!1)}},children:`Unload`})]})]})})}function vi({value:e,label:t}){return(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`text-foreground`,children:e}),` `,t,e===1?``:`s`]})}function yi(e,t){let n=new Set(e.assetIds),r=new Set;for(let e of t)n.has(e.id)&&mi(e)!==`healthy`&&r.add(A(e.model));return[...r]}function bi({template:e,highlighted:t=!1}){let{assets:n,engineState:s}=o(S(e=>({assets:e.assets,engineState:e.engineState}))),c=l({queryKey:a.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),m=c.data?.find(t=>t.id===e.templateId)?.description,h=new Set(e.assetIds),_=n.filter(e=>h.has(e.id)&&mi(e)!==`healthy`).length,v=_>0?yi(e,n):[],y=e.areas.reduce((e,t)=>e+t.lines.length,0);return(0,Y.jsxs)(`section`,{id:`template-${e.templateId}`,"aria-label":e.templateName,className:P(Re,`flex scroll-mt-4 flex-col gap-4 p-5 transition-shadow`,t&&`ring-2 ring-ring`),children:[(0,Y.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,Y.jsx)(me,{id:e.templateId,className:`size-5`})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:e.templateName}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.templateId})]}),_>0?(0,Y.jsxs)(U,{tone:`fault`,children:[(0,Y.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:_}),` `,(0,Y.jsx)(G,{children:`faulted`})]}):(0,Y.jsx)(U,{tone:s===`running`?`live`:`idle`,children:(0,Y.jsx)(G,{children:s===`running`?`running`:`paused`})})]}),m?(0,Y.jsx)(`p`,{className:`line-clamp-2 text-pretty text-xs leading-relaxed text-muted-foreground`,children:m}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 font-mono text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(vi,{value:e.areas.length,label:`area`}),(0,Y.jsx)(vi,{value:y,label:`line`}),(0,Y.jsx)(vi,{value:e.assetIds.length,label:`asset`}),(0,Y.jsx)(vi,{value:e.models.length,label:`model`})]}),v.length>0?(0,Y.jsxs)(g,{to:ui({template:e.templateId,status:`faulted`}),className:`flex min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] border border-destructive/30 bg-destructive/8 px-2.5 py-1.5 text-xs text-destructive outline-none transition-colors hover:border-destructive/60 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Y.jsx)(Ze,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsxs)(`span`,{className:`font-medium`,children:[_,` faulted:`]}),` `,v.join(`, `)]})]}):null,(0,Y.jsxs)(`footer`,{className:`mt-auto flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,Y.jsxs)(C,{type:`button`,size:`sm`,variant:`outline`,className:Le,onClick:()=>p(!0),children:[(0,Y.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),Pe(e.templateId)?(0,Y.jsxs)(g,{to:Fe(e.templateId),className:j({size:`sm`,variant:`ghost`}),children:[(0,Y.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),`Open floor`]}):null,(0,Y.jsx)(C,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>d(!0),children:`Unload`})]}),(0,Y.jsx)(_i,{template:e,open:u,onOpenChange:d}),(0,Y.jsx)(pe,{templateId:f?e.templateId:null,onClose:()=>p(!1),live:{assetIds:e.assetIds,models:e.models},actions:(0,Y.jsxs)(g,{to:ui({template:e.templateId}),className:j({size:`sm`,variant:`ghost`}),children:[(0,Y.jsx)(Nt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),fallbackTitle:e.templateName})]})}var xi={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},Si={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},Ci={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function wi({label:e,pip:t,pulse:n}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,Y.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,Y.jsx)(`span`,{className:P(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,xi[t])}),(0,Y.jsx)(`span`,{className:P(`relative inline-flex size-1.5 rounded-full`,xi[t])})]}):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:P(`size-1.5 shrink-0 rounded-full`,xi[t])})),(0,Y.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function Ti({children:e,tone:t=`foreground`,live:n}){return(0,Y.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:P(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,Si[t]),children:e})}function $({children:e}){return(0,Y.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function Ei(e,t){return e===t?``:t}function Di({statusFilter:e,onStatusFilter:t}){let{assets:n,tps:r,memberValueCount:i,availableAdapters:a,adapterMetrics:s}=o(S(e=>({assets:e.assets,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),c=(0,J.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,J.useMemo)(()=>{let e=a.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=>Ci[e.name]??e.name)}},[a,s]),u=c.activeFaultCount>0,d=u?`destructive`:c.quarantined>0?`warning`:`success`,f=u?`faulted`:`healthy`;return(0,Y.jsxs)(`section`,{"aria-label":`Asset status`,className:`grid w-full min-w-0 max-w-full grid-cols-2 overflow-hidden rounded-(--miravo-radius-stadium-sm) border *:border-border/40 *:odd:border-r *:nth-[-n+2]:border-b @2xl/main:grid-cols-4 @2xl/main:*:border-b-0 @2xl/main:*:not-last:border-r`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>t(Ei(e,f)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":u?`Filter to faulted assets`:`Filter to healthy assets`,className:P(`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,Y.jsx)(wi,{label:`Health`,pip:d}),(0,Y.jsxs)(Ti,{tone:u?`destructive`:`success`,children:[c.pct,`%`]}),(0,Y.jsx)($,{children:c.total===0?`No assets`:[`${c.total} asset${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,Y.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted assets`,className:P(`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,Y.jsx)(wi,{label:`Faults`,pip:u?`destructive`:`success`}),(0,Y.jsx)(Ti,{tone:u?`destructive`:`foreground`,live:!0,children:c.activeFaultCount}),(0,Y.jsx)($,{children:u?`${c.affectedCount} asset${c.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,Y.jsxs)(H,{children:[(0,Y.jsxs)(B,{render:(0,Y.jsx)(g,{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,Y.jsx)(wi,{label:`Tags`,pip:`primary`,pulse:!0}),(0,Y.jsx)(Ti,{children:T(i)}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,Y.jsx)(V,{side:`bottom`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,Y.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,Y.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[E(i),` tags`]}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),l.enabled.length>0&&(0,Y.jsx)(Oi,{labels:l.labels,totalMessages:l.totalMessages,totalErrors:l.totalErrors,perAdapter:l.enabled.map(e=>({name:Ci[e.name]??e.name,metrics:s.find(t=>t.name===e.name)?.metrics}))})]})}function Oi({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,Y.jsxs)(H,{children:[(0,Y.jsxs)(B,{render:(0,Y.jsx)(g,{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,Y.jsx)(wi,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,Y.jsx)(Ti,{tone:n>0?`warning`:`foreground`,live:!0,children:T(t)}),(0,Y.jsxs)($,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,Y.jsx)(V,{side:`bottom`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,Y.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,Y.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[E(t),` total`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Y.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[E(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,Y.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var ki=2500,Ai=[`overview`,`assets`,`integrations`];function ji({value:e}){return(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 font-mono text-[10px] leading-4 tabular-nums text-muted-foreground`,children:e})}function Mi({children:e}){return(0,Y.jsx)(u.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e})}function Ni(){return(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Y.jsx)(Bt,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`Nothing is running yet`]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Load a template from the catalog. Its areas, lines and assets show up here, live.`}),(0,Y.jsx)(g,{to:`/catalog`,className:j({size:`sm`}),children:`Open catalog`})]})}function Pi({highlight:e}){let{templates:t,assetCount:n}=o(S(e=>({templates:e.templates,assetCount:e.assets.length})));return(0,Y.jsx)(`div`,{className:`@container/overview`,children:(0,Y.jsxs)(`div`,{className:`grid items-start gap-5 @3xl/overview:grid-cols-[minmax(0,1fr)_20rem] @7xl/overview:grid-cols-[minmax(0,1fr)_22rem]`,children:[t.length===0&&n===0?(0,Y.jsx)(Ni,{}):(0,Y.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,22rem),1fr))] gap-4`,children:[t.map(t=>(0,Y.jsx)(bi,{template:t,highlighted:t.templateId===e},t.templateId)),(0,Y.jsx)(gi,{})]}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-5 @xl/overview:grid-cols-2 @3xl/overview:sticky @3xl/overview:top-4 @3xl/overview:grid-cols-1`,children:[(0,Y.jsx)(Gt,{}),(0,Y.jsx)(Kr,{})]})]})})}function Fi(){let{hash:e}=_(),{templates:t,assetCount:n}=o(S(e=>({templates:e.templates,assetCount:e.assets.length}))),[r,i]=p(`tab`,h(Ai).withDefault(`overview`)),[a,s]=p(`highlight`,m.withDefault(``)),[c,l]=p(`status`,m.withDefault(``)),u=c===`healthy`||c===`faulted`||c===`quarantined`?c:``;(0,J.useEffect)(()=>{if(!e)return;e===`#connect`&&i(null);let t=setTimeout(()=>{let t=document.getElementById(e.slice(1));t?.scrollIntoView({behavior:`smooth`,block:`start`}),t?.focus({preventScroll:!0})},50);return()=>clearTimeout(t)},[e,i]);let d=t.some(e=>e.templateId===a);return(0,J.useEffect)(()=>{if(!a||!d)return;document.getElementById(`template-${a}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=setTimeout(()=>void s(null,{history:`replace`}),ki);return()=>clearTimeout(e)},[a,d,s]),(0,Y.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,Y.jsx)(oi,{}),(0,Y.jsx)(Di,{statusFilter:u,onStatusFilter:e=>{l(e||null),e!==``&&i(`assets`)}}),(0,Y.jsxs)(lt,{value:r,onValueChange:e=>void i(e),children:[(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(ct,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Y.jsxs)(ot,{value:`overview`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(fe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Overview`,(0,Y.jsx)(ji,{value:t.length})]}),(0,Y.jsxs)(ot,{value:`assets`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Assets`,(0,Y.jsx)(ji,{value:n})]}),(0,Y.jsxs)(ot,{value:`integrations`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(Ht,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Integrations`]})]})}),(0,Y.jsx)(st,{value:`overview`,className:`py-2`,children:(0,Y.jsx)(Mi,{children:(0,Y.jsx)(Pi,{highlight:a})})}),(0,Y.jsx)(st,{value:`assets`,className:`py-2`,children:(0,Y.jsx)(Mi,{children:(0,Y.jsx)(ii,{})})}),(0,Y.jsx)(st,{value:`integrations`,className:`py-2`,children:(0,Y.jsx)(Mi,{children:(0,Y.jsx)(li,{})})})]})]})}export{It as a,Bt as i,Wt as n,Nt as o,Ht as r,Mt as s,Fi as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./factory-BYX8AmsW.js";export{e as FactoryPage};
|