@miravo/cli-linux-arm64-musl 0.11.0 → 0.13.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-BG2sUkwk.js +1 -0
- package/console-dist/assets/api-CKfC8_zv.js +1 -0
- package/console-dist/assets/asset-detail-B2YDSfM1.js +1 -0
- package/console-dist/assets/asset-detail-actions-BrttEn24.js +1 -0
- package/console-dist/assets/{backup-power-BDMAO2bO.js → backup-power-Cm_Ij5yj.js} +1 -1
- package/console-dist/assets/{boiler-CWAR1Nq2.js → boiler-BQwqgoVY.js} +1 -1
- package/console-dist/assets/by-path-e6y8DTMV.js +1 -0
- package/console-dist/assets/catalog-Bz24KMiz.js +1 -0
- package/console-dist/assets/catalog-DOGCbTe4.js +1 -0
- package/console-dist/assets/catalog-template-icons-7CBAYTtP.js +1 -0
- package/console-dist/assets/chevron-right-CrNKVFcI.js +1 -0
- package/console-dist/assets/{chiller-BSx8eUMN.js → chiller-Jug0vRg-.js} +1 -1
- package/console-dist/assets/{commercial-building-CNvi6IZK.js → commercial-building-D95MTyEI.js} +1 -1
- package/console-dist/assets/{compressor-D63w6Ir2.js → compressor-BkWNdwvy.js} +1 -1
- package/console-dist/assets/{console-panel-CMDoBJiO.js → console-panel-iWo8EgKP.js} +1 -1
- package/console-dist/assets/control-BMhNX7vM.js +1 -0
- package/console-dist/assets/control-CML5aS8w.js +1 -0
- package/console-dist/assets/{district-heating-Cr4CrgCA.js → district-heating-B_YycTG-.js} +1 -1
- package/console-dist/assets/{events-RmbRTKFV.js → events-5RYkaW81.js} +1 -1
- package/console-dist/assets/events-z582V8se.js +1 -0
- package/console-dist/assets/{export-tab-fZDO4r2u.js → export-tab-BsV7px7m.js} +1 -1
- package/console-dist/assets/factory-3x3_UmJZ.js +1 -0
- package/console-dist/assets/factory-LkZOsGje.js +1 -0
- package/console-dist/assets/floor-page-D0qm0GgG.js +1 -0
- package/console-dist/assets/{genset-BRgqR1AT.js → genset-DBpkUT9p.js} +1 -1
- package/console-dist/assets/{get-error-message-dM0BMfdP.js → get-error-message-C9VW9IZB.js} +1 -1
- package/console-dist/assets/{index-CvuwOe37.js → index-M2C34y3X.js} +3 -3
- package/console-dist/assets/{integration-api-D2tA69Yb.js → integration-api-ChbzMP5N.js} +1 -1
- package/console-dist/assets/integrations-BpOu11IH.js +1 -0
- package/console-dist/assets/{integrations-iAjWxaDS.js → integrations-Cop24rSE.js} +1 -1
- package/console-dist/assets/{login-DpNKicxy.js → login-BZANmwgH.js} +1 -1
- package/console-dist/assets/models-BgGuH6PQ.js +1 -0
- package/console-dist/assets/models-C09Ba-2G.js +1 -0
- package/console-dist/assets/{pharma-cleanroom-ClJRwROz.js → pharma-cleanroom-BbYfEQjP.js} +1 -1
- package/console-dist/assets/protocol-card-B8XGneNM.js +1 -0
- package/console-dist/assets/registry-BXGfJ4np.js +2 -0
- package/console-dist/assets/{rtu-D-1lltcO.js → rtu-BR4DhLbE.js} +1 -1
- package/console-dist/assets/shallow-Cin0mLuv.js +1 -0
- package/console-dist/assets/{smart-factory-cem4tLAv.js → smart-factory-DozakG3N.js} +1 -1
- package/console-dist/assets/{stages-hidkaJPI.js → stages-C0cErwSQ.js} +1 -1
- package/console-dist/assets/{status-CZFZLqVk.js → status-DNfdEhTs.js} +1 -1
- package/console-dist/assets/status-kit-pFRjEjVU.js +1 -0
- package/console-dist/assets/tags-BjW65yls.js +1 -0
- package/console-dist/assets/{tags-BBz30-eV.js → tags-Bw7b0x14.js} +1 -1
- package/console-dist/assets/{tank-THHXGdzg.js → tank-xgQfMS2d.js} +1 -1
- package/console-dist/assets/{transition-nav-link-B11-gXld.js → transition-nav-link-CSrpkA7_.js} +1 -1
- package/console-dist/assets/use-engine-command-mutation-DrMOfYty.js +1 -0
- package/console-dist/assets/use-transition-navigate-D2Y8kfw6.js +2 -0
- package/console-dist/assets/{useQuery-M9KTdi7Q.js → useQuery-Cl48zZ73.js} +1 -1
- package/console-dist/assets/{validation-BkfmaBBi.js → validation-Cxhiswz2.js} +1 -1
- package/console-dist/assets/{water-treatment-CfVR0p0L.js → water-treatment-jG0T2rhc.js} +1 -1
- package/console-dist/index.html +30 -30
- package/miravo +1 -1
- package/package.json +1 -1
- package/console-dist/assets/api-B2QJEzbS.js +0 -1
- package/console-dist/assets/api-Vq4lny_H.js +0 -1
- package/console-dist/assets/asset-detail-E-TllNHT.js +0 -1
- package/console-dist/assets/asset-detail-actions-jjbvaDES.js +0 -1
- package/console-dist/assets/asset-panel-DDziFlFl.js +0 -1
- package/console-dist/assets/by-path-VBqTBdlG.js +0 -1
- package/console-dist/assets/catalog-BlkPPAWE.js +0 -1
- package/console-dist/assets/catalog-CQopEu5C.js +0 -1
- package/console-dist/assets/catalog-template-icons-BOSywIKV.js +0 -1
- package/console-dist/assets/chevron-left-XHFooLn1.js +0 -1
- package/console-dist/assets/chevron-right-CMSQPSEo.js +0 -1
- package/console-dist/assets/control-CBviLxJB.js +0 -1
- package/console-dist/assets/control-jNqzZWa9.js +0 -1
- package/console-dist/assets/events-D531_1EZ.js +0 -1
- package/console-dist/assets/factory-C2OucdpQ.js +0 -1
- package/console-dist/assets/factory-CgSIjU5V.js +0 -1
- package/console-dist/assets/factory-DLE12zAd.js +0 -1
- package/console-dist/assets/floor-page-D0mX5OuA.js +0 -1
- package/console-dist/assets/integrations-BLG4PT3c.js +0 -1
- package/console-dist/assets/model-schemas-3w38IPdc.js +0 -1
- package/console-dist/assets/models-CMN9Eppf.js +0 -1
- package/console-dist/assets/models-I_V8J5Y0.js +0 -1
- package/console-dist/assets/play-kg50os4l.js +0 -1
- package/console-dist/assets/protocol-card-ARSwIjkN.js +0 -1
- package/console-dist/assets/registry-Dau_GjK6.js +0 -2
- package/console-dist/assets/tags-K96jT8PY.js +0 -1
- package/console-dist/assets/use-engine-command-mutation-CHqjOqfS.js +0 -1
- package/console-dist/assets/use-transition-navigate-B-nk4aWh.js +0 -2
- /package/console-dist/assets/{circle-x-_o0nl0Rg.js → circle-x-6JtFdy1_.js} +0 -0
- /package/console-dist/assets/{dom-Cm_OH5jc.js → dom-CQuChC3G.js} +0 -0
- /package/console-dist/assets/{not-found-C4YVKP97.js → not-found-Cc35S-lZ.js} +0 -0
- /package/console-dist/assets/{runtime-link-vBANRqcD.js → runtime-link-BRnaEnOm.js} +0 -0
- /package/console-dist/assets/{tabs-BbQkzBZZ.js → tabs-Ch_VG8_S.js} +0 -0
- /package/console-dist/assets/{vendor-table-B0Z9e_sn.js → vendor-table-BQAIXM34.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
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{B as r,ot as i}from"./api-B2QJEzbS.js";import{t as a}from"./proxy-CWZabK8f.js";import{t as o}from"./AnimatePresence-BSSlw02V.js";import{i as s,r as c}from"./dist-xY0pK9Wy.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./dialog-B5PqrKVw.js";import{n as h,r as g}from"./protocol-card-ARSwIjkN.js";import{C as _,S as ee,d as v,l as te}from"./format-Bx7DF-TB.js";import{n as y,t as b}from"./utils-XFKvwlFT.js";import{n as x}from"./server-BVem_egD.js";import{n as S}from"./circle-x-_o0nl0Rg.js";import{n as C,t as w}from"./sliders-horizontal-BNKmYQgd.js";import{t as T}from"./pause-CqW7v5Dc.js";import{t as E}from"./play-kg50os4l.js";import{t as ne}from"./rocket-KZ5oHK1G.js";import{t as re}from"./triangle-alert-DoAwrRgk.js";import{a as ie,n as ae,r as D,t as O}from"./validation-BkfmaBBi.js";import{i as oe,n as k,t as A}from"./tooltip-B3vOB1Vu.js";import{t as j}from"./badge-Bk1DaL6C.js";import{t as M}from"./label-2sIXTEUK.js";import{a as N,t as P}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as F,n as I,r as L,t as R}from"./tabs-BbQkzBZZ.js";import{i as z,r as B,t as V}from"./console-panel-CMDoBJiO.js";import{a as H,c as U,i as W,l as G,n as K,o as q,r as se,s as J,t as ce}from"./combobox-B8h0-NHs.js";import{c as le,i as ue,n as de,s as fe,t as pe}from"./select-BWlrSYlA.js";var me=y(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Y=y(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),X=e(t(),1),Z=n();function he(){let{assets:e,models:t}=i(g(e=>({assets:e.assets,models:e.models}))),n=P(),[r,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),f=(0,X.useMemo)(()=>u?e.filter(e=>e.id.toLowerCase().includes(u.toLowerCase())):e,[e,u]),p=(0,X.useMemo)(()=>{let n=e.find(e=>e.id===r);return n?t.find(e=>e.name===n.model)?.faultNames??[]:[]},[r,e,t]),m=(0,X.useMemo)(()=>e.filter(e=>e.activeFaults.length>0),[e]),h=m.reduce((e,t)=>e+t.activeFaults.length,0);return(0,Z.jsxs)(q,{className:`h-full min-w-0`,children:[(0,Z.jsx)(U,{className:`pb-3`,children:(0,Z.jsxs)(G,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(re,{className:`size-3.5 ${h>0?`text-destructive`:`text-muted-foreground`}`}),`Fault Lab`,(0,Z.jsx)(o,{children:h>0&&(0,Z.jsx)(a.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},children:(0,Z.jsxs)(j,{variant:`destructive`,className:`text-[10px]`,children:[h,` active`]})},`fault-count`)})]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(ce,{value:r||null,onValueChange:e=>{s(e??``),l(``)},onInputValueChange:d,children:[(0,Z.jsx)(se,{placeholder:`Select asset`,"aria-label":`Fault asset`,className:`h-8 min-h-11 w-full min-w-0 touch-manipulation sm:min-h-8`,showClear:!!r}),(0,Z.jsx)(K,{children:(0,Z.jsxs)(H,{children:[f.map(e=>(0,Z.jsxs)(W,{value:e.id,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id}),e.activeFaults.length>0&&(0,Z.jsx)(j,{variant:`destructive`,className:`ml-auto text-[10px]`,children:e.activeFaults.length})]},e.id)),f.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No assets found`})]})})]}),(0,Z.jsxs)(pe,{value:c,onValueChange:e=>l(e??``),children:[(0,Z.jsx)(fe,{className:`h-8 min-h-11 w-full touch-manipulation sm:min-h-8`,"aria-label":`Fault type`,children:(0,Z.jsx)(le,{placeholder:r?`Select fault`:`Pick asset first`})}),(0,Z.jsx)(de,{alignItemWithTrigger:!1,align:`start`,children:p.map(e=>(0,Z.jsx)(ue,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(_,{variant:`destructive`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!c,onClick:()=>{let e=D(O,{assetId:r,fault:c});e&&n.mutate({type:`triggerFault`,...e})},children:`Trigger`}),(0,Z.jsx)(_,{variant:`secondary`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!c,onClick:()=>{let e=D(O,{assetId:r,fault:c});e&&n.mutate({type:`clearFault`,...e})},children:`Clear`})]}),(0,Z.jsx)(ie,{}),(0,Z.jsx)(o,{mode:`wait`,initial:!1,children:m.length>0?(0,Z.jsxs)(a.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Faulted Assets`}),(0,Z.jsx)(o,{initial:!1,children:m.map(e=>(0,Z.jsx)(a.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:6,transition:{duration:.1}},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full touch-manipulation items-center justify-between rounded-[var(--miravo-radius-tight)] border border-destructive/20 bg-destructive/5 px-2.5 py-1.5 text-left transition-colors hover:bg-destructive/10 sm:min-h-0`,onClick:()=>{s(e.id),l(``)},children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-destructive`,children:e.activeFaults.join(`, `)})]})},e.id))})]},`faulted`):(0,Z.jsxs)(a.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex items-center gap-2 py-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(S,{className:`size-3.5 text-success`}),`All clear — no active faults`]},`all-clear`)})]})]})}function ge(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function _e(e){if(!Number.isFinite(e)||e<=0)return`0s`;if(e<60)return`${e.toFixed(1)}s`;let t=Math.floor(e),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?r>0?`${n}d ${r}h`:i>0?`${n}d ${i}m`:`${n}d`:r>0?`${r}h ${i}m`:i>0?`${i}m ${a}s`:`${a}s`}function ve({data:e}){let t=(0,X.useMemo)(()=>{if(e.length<2)return null;let t=e.map(e=>e.tps),n=Math.max(...t,.1),r=Math.min(...t,0),i=n-r||1;return{points:t.map((e,n)=>{let a=n/(t.length-1)*200,o=2+(1-(e-r)/i)*28;return`${n===0?`M`:`L`}${a.toFixed(1)},${o.toFixed(1)}`}).join(` `),min:r,max:n}},[e]);return t?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`svg`,{viewBox:`0 0 200 32`,className:`h-8 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":`TPS trend sparkline`,children:[(0,Z.jsx)(`line`,{x1:`0`,y1:`10.7`,x2:`200`,y2:`10.7`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`line`,{x1:`0`,y1:`21.3`,x2:`200`,y2:`21.3`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`path`,{d:t.points,fill:`none`,stroke:`var(--primary)`,strokeWidth:`1.5`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`60s ago · `,t.min.toFixed(1)]}),(0,Z.jsxs)(`span`,{children:[t.max.toFixed(1),` · now`]})]})]}):(0,Z.jsx)(`div`,{className:`flex h-8 items-center text-[10px] text-muted-foreground`,children:`Collecting...`})}var ye={running:`bg-success`,paused:`bg-warning`,idle:`bg-muted-foreground`,stopped:`bg-destructive`};function be({state:e}){let t=ye[e]??`bg-muted-foreground`,n=e===`running`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`size-2.5 rounded-full ${t}`}),n&&(0,Z.jsx)(`span`,{className:`absolute size-2.5 animate-ping rounded-full ${t} opacity-40`})]}),(0,Z.jsx)(o,{mode:`wait`,initial:!1,children:(0,Z.jsx)(a.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{type:`spring`,stiffness:500,damping:30},className:`font-mono text-lg font-bold uppercase tracking-wider`,children:e},e)})]})}function Q({label:e,tooltip:t,tooltipClassName:n}){return(0,Z.jsxs)(`div`,{className:`inline-flex w-fit min-w-0 max-w-full items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`blueprint-title min-w-0 shrink text-[11px] leading-tight text-muted-foreground`,children:e}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(oe,{className:`inline-flex size-4 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border-0 bg-transparent p-0 text-muted-foreground shadow-none outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring`,render:(0,Z.jsx)(`button`,{type:`button`}),"aria-label":`About ${e}`,children:(0,Z.jsx)(x,{className:`size-3`,"aria-hidden":!0})}),(0,Z.jsx)(k,{side:`top`,className:b(`max-w-xs`,n),children:t})]})]})}function $(){let{engineState:e,connectionState:t}=i(g(e=>({engineState:e.engineState,connectionState:e.connectionState}))),n=P();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Run state`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Whether the scheduler is running, paused, idle, or stopped. Pause freezes simulated time; resume continues from the same tick.`})}),(0,Z.jsx)(be,{state:e}),t===`live`&&(e===`running`||e===`paused`)&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-2`,children:(0,Z.jsxs)(_,{type:`button`,size:`sm`,variant:e===`paused`?`default`:`outline`,className:b(`h-8 min-h-11 w-fit touch-manipulation gap-1.5 px-3 text-xs sm:min-h-8`,e===`running`&&`border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 hover:text-warning focus-visible:border-warning/50 focus-visible:ring-warning/25 border-warning/35`),onClick:()=>n.mutate({type:e===`paused`?`resume`:`pause`}),children:[e===`paused`?(0,Z.jsx)(E,{className:`size-3`}):(0,Z.jsx)(T,{className:`size-3`}),e===`paused`?`Resume`:`Pause`]})})]})}function xe(){let{speedMultiplier:e,connectionState:t}=i(g(e=>({speedMultiplier:e.speedMultiplier,connectionState:e.connectionState}))),n=P(),[r,a]=(0,X.useState)(String(e)),o=t===`live`;return(0,X.useEffect)(()=>{a(String(e))},[e]),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Speed`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Runs the factory at this multiple of real time. 1× is real time; higher values speed up the model. Change it with the field and Set.`})}),(0,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[e,`x`]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(M,{htmlFor:`speed-multiplier`,className:`sr-only`,children:`Speed multiplier`}),(0,Z.jsx)(ee,{id:`speed-multiplier`,type:`number`,value:r,onChange:e=>a(e.target.value),className:`h-8 min-h-11 w-[4.75rem] touch-manipulation font-mono text-xs tabular-nums sm:min-h-8`,min:`1`,max:`1000`,disabled:!o}),(0,Z.jsx)(_,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 min-h-11 touch-manipulation px-3 text-xs sm:min-h-8`,disabled:!o,onClick:()=>{let e=D(ae,{multiplier:Number(r)});e&&n.mutate({type:`setSpeed`,multiplier:e.multiplier})},children:`Set`})]})]})}function Se(){let{tick:e,simulationTime:t,tps:n,tpsHistory:r,uptimeMs:a,assetCount:o,memberValueCount:s}=i(g(e=>({tick:e.tick,simulationTime:e.simulationTime,tps:e.tps,tpsHistory:e.tpsHistory,uptimeMs:e.uptimeMs,assetCount:e.assetCount,memberValueCount:e.memberValueCount})));return(0,Z.jsxs)(`div`,{className:b(N,`px-4 py-3`),children:[(0,Z.jsxs)(`header`,{className:`mb-3 border-b border-border/60 pb-2`,children:[(0,Z.jsx)(`h2`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Engine vitals`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Scheduler, speed, cycle count, and throughput for this session.`})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-2 gap-3 @2xl/main:gap-4 @3xl/main:grid-cols-3 @5xl/main:grid-cols-6`,children:[(0,Z.jsx)($,{}),(0,Z.jsx)(xe,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Cycle`,tooltipClassName:`flex flex-col items-start gap-2 text-left`,tooltip:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Cycle`}),` compares simulated progress with wall time: how many steps ran, how much model time advanced, and how long this session has been open.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[`The number is `,(0,Z.jsx)(`span`,{className:`font-medium`,children:`tick`}),` count — completed scheduler steps since this run. Each tick refreshes the plant model and live tags.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Sim`}),` is simulated elapsed time. Each tick adds (tick interval × speed) to this clock. Generators, lifecycle, and in-model timestamps use Sim, not your system clock. It stops advancing while paused.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Real`}),` is wall-clock uptime since the run started (real time).`]})]})}),(0,Z.jsx)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:te(e)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex w-full min-w-0 flex-col gap-0.5 leading-tight`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Sim`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:_e(t)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Real`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:ge(a)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`Throughput`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Ticks per second: how fast the engine is stepping. Rises and falls with workload, speed setting, and CPU headroom.`})}),(0,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[n.toFixed(1),` tps`]}),(0,Z.jsxs)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[o,` inst · `,v(s),` tags`]})]}),(0,Z.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-2`,children:[(0,Z.jsx)(Q,{label:`TPS Trend`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Recent ticks-per-second samples over about the last minute. Flat or noisy lines usually mean load or speed changes.`})}),(0,Z.jsx)(ve,{data:r})]})]})]})}function Ce({enabled:e,total:t}){return(0,Z.jsxs)(z,{tone:t===0?`off`:e===0?`idle`:`live`,children:[(0,Z.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`mx-1 text-muted-foreground/60`,children:`/`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:t}),(0,Z.jsx)(`span`,{className:`ml-1.5`}),(0,Z.jsx)(B,{children:`active`})]})}function we(){let{availableAdapters:e,adapterMetrics:t}=i(g(e=>({availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled).length;return(0,Z.jsxs)(V,{icon:Y,title:`Protocol Gateway`,description:`Northbound adapters publishing engine telemetry to external systems.`,aside:(0,Z.jsx)(Ce,{enabled:n,total:e.length}),bodyClassName:`p-0`,children:[e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 px-4 py-4`,children:(0,Z.jsx)(o,{children:e.map((e,n)=>{let r=t.find(t=>t.name===e.name)?.metrics;return(0,Z.jsx)(a.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{type:`spring`,stiffness:380,damping:30,delay:n*.05},children:(0,Z.jsx)(h,{adapter:e,metrics:r})},e.name)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 border-t border-border/60 bg-background/40 px-4 py-2.5`,role:`status`,"aria-label":`Upcoming protocol adapters`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(ne,{className:`size-3 text-muted-foreground/70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Roadmap`})]}),(0,Z.jsx)(`span`,{className:`font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground`,children:`More protocols to come`})]})]})}function Te(){let{assets:e,templates:t}=i(g(e=>({assets:e.assets,templates:e.templates}))),n=P(),[r,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(q,{className:`min-w-0`,children:[(0,Z.jsx)(U,{className:`pb-3`,children:(0,Z.jsxs)(G,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(me,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Danger Zone`]})}),(0,Z.jsx)(J,{className:`flex flex-1 flex-col`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-3 @2xl/main:flex-row @2xl/main:items-center @2xl/main:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Reset factory`}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Unloads `,t.length,` template`,t.length===1?``:`s`,` and removes`,` `,e.length,` asset`,e.length===1?``:`s`,`, including standalone ones.`]})]}),(0,Z.jsx)(_,{className:`min-h-11 w-full shrink-0 touch-manipulation @2xl/main:w-auto sm:min-h-7`,variant:`destructive`,size:`sm`,onClick:()=>a(!0),children:`Reset`})]})})]}),(0,Z.jsx)(m,{open:r,onOpenChange:a,children:(0,Z.jsxs)(d,{children:[(0,Z.jsxs)(l,{children:[(0,Z.jsx)(f,{children:`Reset Factory`}),(0,Z.jsx)(p,{children:`Unloads every template and removes every asset, including standalone ones. With persistence on, the empty factory is saved and stays empty after a restart.`})]}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(_,{variant:`outline`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,onClick:()=>a(!1),disabled:o,children:`Cancel`}),(0,Z.jsx)(_,{variant:`destructive`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,disabled:o,onClick:async()=>{s(!0);try{await n.mutateAsync({type:`resetFactory`}),a(!1)}catch{}finally{s(!1)}},children:o?`Resetting...`:`Confirm Reset`})]})]})})]})}function Ee(){let[e,t]=s(`tab`,c([`monitor`,`operate`]).withDefault(`monitor`));return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Mission Control`}),(0,Z.jsxs)(j,{variant:`outline`,title:`Miravo version ${r}`,className:`font-mono text-[10px] leading-none text-muted-foreground`,children:[`v`,r]})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Engine telemetry, protocol management, and fault operations.`})]}),(0,Z.jsxs)(R,{value:e,onValueChange:e=>{t(e)},className:`min-h-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,Z.jsxs)(L,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Z.jsxs)(F,{value:`monitor`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(C,{className:`size-3.5 shrink-0`}),`Monitor`]}),(0,Z.jsxs)(F,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(w,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,Z.jsx)(I,{value:`monitor`,className:`flex-1 py-2`,children:(0,Z.jsxs)(a.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col gap-5 sm:gap-6`,children:[(0,Z.jsx)(Se,{}),(0,Z.jsx)(we,{})]},`monitor`)}),(0,Z.jsx)(I,{value:`operate`,className:`flex-1 py-2`,children:(0,Z.jsxs)(a.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`grid min-h-0 min-w-0 grid-cols-1 items-start gap-5 @2xl/main:grid-cols-2 @2xl/main:gap-4`,children:[(0,Z.jsx)(he,{}),(0,Z.jsx)(Te,{})]},`operate`)})]})]})}export{Y as n,Ee as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./events-RmbRTKFV.js";export{e as EventsPage};
|
|
@@ -1 +0,0 @@
|
|
|
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,ot as a,v as o,y as s}from"./api-B2QJEzbS.js";import{f as c,t as l}from"./useQuery-M9KTdi7Q.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{r as S,t as C}from"./protocol-card-ARSwIjkN.js";import{C as w,S as ne,T as re,c as T,d as E,g as D,h as O,l as k,m as A,p as j,s as M,u as N,v as ie,w as P,y as F}from"./format-Bx7DF-TB.js";import{n as I,t as L}from"./utils-XFKvwlFT.js";import{t as R}from"./activity-Cy_niK56.js";import{n as ae,r as oe,t as z}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-BOSywIKV.js";import{t as he}from"./chevron-down-x70Pto6j.js";import{t as ge}from"./chevron-right-CMSQPSEo.js";import{n as _e,t as ve}from"./circle-x-_o0nl0Rg.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-D2tA69Yb.js";import{t as Oe}from"./copy-button-CSUP1VjU.js";import{n as ke,r as Ae,t as je}from"./source-host-miravo-B8eM2IHw.js";import{t as Me}from"./factory-DLE12zAd.js";import{t as B}from"./loader-circle-DjgHgHHl.js";import{t as Ne}from"./plus-Cl4Ay5Ry.js";import{t as Pe}from"./radio-BxpVYiyS.js";import{t as Fe}from"./query-fetch-error-CWLZA2L5.js";import{t as Ie}from"./rocket-KZ5oHK1G.js";import{a as Le,f as Re,i as ze,n as Be,o as Ve,r as He}from"./export-tab-fZDO4r2u.js";import{t as Ue}from"./trash-2-BH9HDsZv.js";import{t as We}from"./triangle-alert-DoAwrRgk.js";import{i as V,n as H,t as U}from"./tooltip-B3vOB1Vu.js";import{n as Ge,t as Ke}from"./use-transition-navigate-B-nk4aWh.js";import{t as qe}from"./badge-Bk1DaL6C.js";import{n as Je}from"./transition-types-BKZuWApE.js";import{t as Ye}from"./label-2sIXTEUK.js";import{n as Xe,t as Ze}from"./get-error-message-dM0BMfdP.js";import{c as Qe,i as $e,o as et,t as tt}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as nt,n as rt,r as it,t as at}from"./tabs-BbQkzBZZ.js";import{i as W,n as G,r as K,t as ot}from"./console-panel-CMDoBJiO.js";import{a as st,i as ct,n as lt,o as ut,r as dt,s as ft,t as pt}from"./combobox-B8h0-NHs.js";import{c as mt,i as q,n as ht,s as gt,t as _t}from"./select-BWlrSYlA.js";import{a as J,c as vt,i as yt,n as bt,o as xt,r as St,s as Ct}from"./select-display-items-DN2G8DNG.js";import{t as wt}from"./checkbox-DEAkDfFr.js";import{n as Tt,r as Et,t as Dt}from"./integration-targets-Byvdd3Or.js";import{n as Ot,t as kt}from"./registry-Dau_GjK6.js";var At=I(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),jt=I(`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`}]]),Mt=I(`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`}]]),Nt=I(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Pt=I(`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`}]]),Ft=I(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),It=I(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Lt=I(`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`}]]),Rt=I(`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`}]]),zt=I(`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`}]]),Bt=I(`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`}]]),Vt=I(`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`}]]),Ht=I(`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`}]]),Y=e(t(),1),X=n();function Z({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`skeleton`,className:L(`animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted`,e),...t})}var Ut=`https://miravo.dev/docs`;function Wt(){let{adapters:e,metrics:t}=a(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,o=n.reduce((e,t)=>e+i(t.name),0);return(0,X.jsxs)(ot,{id:`connect`,icon:Bt,title:`Connect`,description:`Point a client here to read live values.`,aside:(0,X.jsxs)(W,{tone:o>0?`live`:n.length>0?`idle`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:o}),(0,X.jsx)(K,{children:o===1?`client`:`clients`})]}),bodyClassName:`gap-2`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(g,{to:`/control`,className:G,children:[`Configure protocols`,(0,X.jsx)(oe,{className:`size-3`,"aria-hidden":!0})]}),(0,X.jsxs)(`a`,{href:`${Ut}/protocols`,target:`_blank`,rel:`noopener noreferrer`,className:L(G,`ml-auto`),children:[(0,X.jsx)(jt,{className:`size-3`,"aria-hidden":!0}),`Protocol docs`]})]}),children:[n.length===0&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No protocol is serving yet.`}),n.map(e=>{let t=i(e.name),n=C[e.name]??e.name;return(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,t>0?`bg-success`:`bg-muted-foreground/55`)}),(0,X.jsx)(`span`,{className:`text-sm font-medium tracking-tight`,children:n}),(0,X.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:t>0?`text-foreground`:void 0,children:t}),` `,`connected`]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 pl-3.5`,children:[(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,X.jsx)(Oe,{value:e.endpoint??``,label:`Copy ${n} endpoint`})]})]},e.name)}),r.length>0&&(0,X.jsxs)(`p`,{className:`pt-1 text-xs text-muted-foreground`,children:[r.map(e=>C[e.name]??e.name).join(`, `),` `,r.length===1?`is`:`are`,` off.`]})]})}var Gt=[`devices`,`models`,`assets`],Kt=[`assets`,`models`,`devices`],qt={devices:`DeviceHub devices`,models:`Digital Twins models`,assets:`Digital Twins instances`},Jt={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.`}},Yt=`Miravo calls this API.`,Xt={assets:`models`};function Zt(e,t){let n=new Set(e);if(n.has(t)){n.delete(t);for(let[e,r]of Object.entries(Xt))r===t&&n.delete(e)}else{n.add(t);let e=Xt[t];e&&n.add(e)}return n}var Qt=[{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.`}];function $t({open:e,onOpenChange:t,isApply:n,scopeOptions:r,scope:i,onToggleScope:a,ifUnmanaged:o,onIfUnmanagedChange:s}){let c=(0,Y.useId)(),l=`if-unmanaged-${c}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(he,{className:L(`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,X.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:L(`overflow-hidden`,!e&&`pointer-events-none`),"aria-hidden":!e,inert:!e,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-1 pt-px`,children:r.map(e=>{let t=Object.entries(Xt).find(([t,n])=>n===e)?.[0],r=t!==void 0&&i.has(t),o=n?Jt[e].apply:Jt[e].cleanup;return(0,X.jsxs)(Ye,{htmlFor:`scope-${e}`,className:L(`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,X.jsx)(`span`,{className:`pt-0.5`,children:(0,X.jsx)(wt,{id:`scope-${e}`,checked:i.has(e),disabled:r,onCheckedChange:()=>a(e)})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 leading-snug`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:qt[e]}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[11px] font-normal leading-tight text-muted-foreground`,children:o})]}),r?(0,X.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,X.jsxs)(`div`,{className:`mt-2.5 space-y-1.5 border-t border-border/40 pt-2`,children:[(0,X.jsx)(`p`,{id:`${c}-legend`,className:`text-[11px] font-medium uppercase tracking-wide text-foreground/80`,children:`Collision policy`}),(0,X.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-legend`,className:`flex flex-col gap-1`,children:Qt.map(e=>(0,X.jsxs)(Ye,{htmlFor:`if-unmanaged-${e.value}`,className:L(`flex cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-[11px] transition-colors`,o===e.value?`border-primary/45 bg-primary/8`:`border-border/40 bg-muted/10 hover:bg-muted/25`),children:[(0,X.jsx)(`input`,{id:`if-unmanaged-${e.value}`,type:`radio`,name:l,value:e.value,checked:o===e.value,onChange:()=>s(e.value),className:`mt-0.5 size-3.5 shrink-0 accent-primary`}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`mt-px block text-[11px] leading-tight text-foreground/74`,children:e.hint})]})]},e.value))})]})]})]})}function en({label:e,help:t,mono:n=!1,children:r}){return(0,X.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,X.jsx)(`dt`,{className:`min-w-0 pt-px`,children:(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium leading-snug text-muted-foreground`,children:e}),(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{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,X.jsx)(we,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:t})]})]})}):(0,X.jsx)(`dt`,{className:`min-w-0 pt-px text-[11px] font-medium text-muted-foreground`,children:e}),n?(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[11px] leading-normal text-foreground/90`,children:r}):(0,X.jsx)(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground`,children:r})]})}function tn({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 nn({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId},scope:n.scope}}var rn=/^\(?unchanged\)?$/i,an=/^device=(\S+)/;function on(e){let t=e.blockReason??e.detail;if(!(!t||rn.test(t)))return t.replace(/^\((.*)\)$/,`$1`)}function sn(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`:on(i),boundDevice:e?.detail?.match(an)?.[1]})}for(let[e,i]of t)r.has(e)||n.push({action:i.action,resourceType:`asset`,name:e,note:on(i),boundDevice:i.detail?.match(an)?.[1]});return n}function cn(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 ln(e){return sn(e).filter(e=>e.action!==`noop`&&e.action!==`blocked`).length}var un={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`}},dn=[`create`,`update`,`replace`,`delete`,`noop`],fn=[`create`,`update`,`replace`,`delete`],pn=6,mn={device:[`device`,`devices`],model:[`twin model`,`twin models`],asset:[`twin instance`,`twin instances`]};function hn(e,[t,n]){return`${e} ${e===1?t:n}`}function gn(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 _n(e){return gn(e).map(([e,t])=>hn(t.length,mn[e])).join(` · `)}function vn(e){return`${e.action}-${e.resourceType}-${e.name}-${e.protocol??``}`}function yn(e){return e.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)}function bn({groups:e}){return(0,X.jsx)(`div`,{"aria-hidden":!0,className:`flex h-1.5 w-full gap-0.5 overflow-hidden rounded-full`,children:[`blocked`,...dn].map(t=>{let n=e.get(t)?.length??0;return n>0?(0,X.jsx)(`span`,{className:L(`h-full rounded-full`,un[t].dot),style:{flexGrow:n}},t):null})})}function xn({entry:e}){let{note:t}=e;return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 py-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11.5px] text-foreground`,title:e.name,children:e.name}),e.protocol?(0,X.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,X.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,X.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted-foreground`,title:t,children:t}):null]})}function Sn({action:e,entries:t,open:n,onToggle:r}){let i=un[e];return(0,X.jsxs)(`li`,{children:[(0,X.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,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-2 shrink-0 rounded-full`,i.dot)}),(0,X.jsx)(`span`,{className:L(`w-20 shrink-0 text-sm font-medium`,e===`noop`?`text-muted-foreground`:`text-foreground`),children:i.label}),(0,X.jsx)(`span`,{className:L(`w-8 shrink-0 font-mono text-sm tabular-nums`,i.text),children:t.length}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:_n(t)}),(0,X.jsx)(ge,{"aria-hidden":!0,className:L(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200`,n&&`rotate-90`)})]}),n?(0,X.jsx)(`div`,{className:`mb-2 ml-[1.1rem] flex flex-col gap-2 border-l border-border/60 pt-1 pl-[1.9rem]`,children:gn(t).map(([e,t])=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:mn[e][1]}),(0,X.jsx)(`ul`,{children:t.map(e=>(0,X.jsx)(xn,{entry:e},vn(e)))})]},e))}):null]})}function Cn({entries:e}){return(0,X.jsxs)(`div`,{role:`note`,className:`rounded-[var(--miravo-radius-tight)] border border-warning/30 bg-warning/8 px-3 py-2.5`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,X.jsx)(We,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),e.length,` `,e.length===1?`resource is`:`resources are`,` skipped`]}),(0,X.jsx)(`ul`,{className:`mt-1 pl-5.5`,children:e.map(e=>(0,X.jsx)(xn,{entry:e},vn(e)))})]})}function wn({groups:e,planKind:t}){let n=fn.filter(t=>(e.get(t)?.length??0)>0);return n.length===0?(0,X.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:t===`cleanup`?`Nothing to remove`:`Nothing to change`}):(0,X.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:n.map((t,n)=>(0,X.jsxs)(Y.Fragment,{children:[n>0?(0,X.jsx)(`span`,{className:`mx-1.5 font-normal text-muted-foreground/60`,children:`·`}):null,(0,X.jsx)(`span`,{className:L(`font-mono tabular-nums`,un[t].text),children:e.get(t)?.length}),` `,(0,X.jsx)(`span`,{className:`font-normal text-foreground/90`,children:un[t].phrase})]},t))})}function Tn({plan:e,planKind:t=`apply`}){let n=sn(e.entries),r=cn(n),i=fn.reduce((e,t)=>e+(r.get(t)?.length??0),0),[a,o]=(0,Y.useState)(()=>new Set(i<=pn?fn:[])),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,X.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,X.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:[t===`cleanup`?`Expected removals`:`Expected changes`,(0,X.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/80`,children:`dry run · nothing runs until you confirm`})]}),(0,X.jsx)(wn,{groups:r,planKind:t}),(0,X.jsxs)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:[l>0?`${l} already in place · `:``,yn(e.scope)]})]})}),n.length>0?(0,X.jsx)(bn,{groups:r}):null,c.length>0?(0,X.jsx)(Cn,{entries:c}):null,n.length>0?(0,X.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:dn.map(e=>{let t=r.get(e);return t?(0,X.jsx)(Sn,{action:e,entries:t,open:a.has(e),onToggle:()=>s(e)},e):null})}):(0,X.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 En=[`a`,`b`,`c`];function Dn(){return(0,X.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,X.jsx)(Z,{className:`h-2.5 w-28`}),(0,X.jsx)(Z,{className:`h-5 w-56`}),(0,X.jsx)(Z,{className:`h-3 w-40`}),(0,X.jsx)(Z,{className:`h-1.5 w-full rounded-full`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-1`,children:En.map(e=>(0,X.jsx)(Z,{className:`h-7 w-full`},e))})]})}var On={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`},kn=He.map(e=>({value:e,label:On[e]}));function An({open:e,onOpenChange:t,action:n,subject:r,label:i,target:a,stream:s}){let c=n===`apply`,u=c?Gt:Kt,[d,f]=(0,Y.useState)(new Set(u)),[p,m]=(0,Y.useState)(`fail`),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(Object.keys(a.exposedPorts??{}).length>0),[S,C]=(0,Y.useState)(Le(a.exposedPorts)),[ne,re]=(0,Y.useState)(r.kind===`asset`?r.protocol:He[0]??`modbus`),T=r.kind===`asset`?{kind:`asset`,assetId:r.assetId,protocol:ne}:r,E=r.kind===`asset`?[ne]:He,D=c?ze(a.exposedPorts,S,E):{},O=u.filter(e=>d.has(e)),k=O.length>0&&D!==null,A={scope:O,ifUnmanaged:p,...c&&D?{exposedPorts:D}:{}},j=tn({targetId:a.id,subject:T,result:A}),M=nn({targetId:a.id,subject:T,result:A}),N=l({queryKey:o.integrations.plan(n,JSON.stringify(c?j:M)),queryFn:({signal:e})=>c?be(j,{signal:e}):Te(M,{signal:e}),enabled:e&&k,retry:!1,gcTime:0}),ie=s.status===`running`,P=()=>{k&&(s.operation&&s.status!==`running`&&s.reset(),c?s.startApply(j):s.startCleanup(M),t(!1))},F=N.data?.plan,I=F?ln(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=N.error?[Xe(N.error,`Plan failed`),Ze(N.error)].filter(Boolean).join(`. `):null;return(0,X.jsx)(te,{open:e,onOpenChange:t,children:(0,X.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,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,X.jsxs)(ee,{className:`flex items-center gap-2 text-sm font-semibold leading-snug`,children:[c?(0,X.jsx)(Ie,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(Ue,{className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),c?`Apply`:`Clean up`,` `,i,` `,c?`to`:`from`,` `,a.label]}),(0,X.jsxs)(x,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[a.hostname,c?(0,X.jsx)(`span`,{className:`font-sans`,children:` · reaches Miravo at `}):null,c?a.sourceHostname:null]})]}),(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-4 pb-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[c&&r.kind===`asset`?(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Protocol`}),(0,X.jsxs)(_t,{value:ne,onValueChange:e=>e&&re(e),items:kn,children:[(0,X.jsx)(gt,{size:`sm`,className:`w-32`,"aria-label":`Protocol`,children:(0,X.jsx)(mt,{})}),(0,X.jsx)(ht,{alignItemWithTrigger:!1,align:`start`,children:kn.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]})]}):null,k?R?(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-xs`,children:[(0,X.jsxs)(`p`,{className:`text-destructive`,children:[`Dry run failed: `,R]}),(0,X.jsx)(w,{size:`sm`,variant:`outline`,onClick:()=>void N.refetch(),children:`Retry dry run`})]}):F?(0,X.jsx)(Tn,{plan:F,planKind:n}):(0,X.jsx)(Dn,{}):(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{open:h,onOpenChange:g,isApply:c,scopeOptions:u,scope:d,onToggleScope:e=>f(t=>Zt(t,e)),ifUnmanaged:p,onIfUnmanagedChange:m}),h?(0,X.jsxs)(`dl`,{className:`flex flex-col gap-0 text-xs leading-snug`,children:[(0,X.jsx)(en,{label:`Litmus Edge API`,help:Yt,mono:!0,children:a.hostname}),(0,X.jsx)(en,{label:ke,help:je,mono:!0,children:a.sourceHostname}),c?(0,X.jsx)(`div`,{className:`border-b border-border/35 py-2.5`,children:(0,X.jsx)(Be,{open:_,onOpenChange:v,protocols:E,values:S,onChange:C,hint:`Enter the host port Litmus Edge should dial. Leave blank to use Miravo's own port. Saved for this target.`})}):null]}):null]})]})}),(0,X.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,X.jsx)(w,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsxs)(w,{type:`button`,variant:c?`default`:`destructive`,onClick:P,disabled:!k||ie,children:[c?(0,X.jsx)(Ie,{className:`size-3`,"aria-hidden":!0}):(0,X.jsx)(Ue,{className:`size-3`,"aria-hidden":!0}),L]})]})]})})}function jn(e,t,n){let r=new Set,i=[];for(let a of e){if(a.targetId!==t||a.factoryName!==n)continue;let e=a.templateId===void 0?`asset`:`template`,o=a.templateId??a.assetId;if(o===void 0)continue;let s=`${e}:${o}`;r.has(s)||(r.add(s),a.operationType===`apply`?a.status===`success`||a.status===`partial`||a.status===`noop`?i.push({subjectId:o,kind:e,completedAt:a.completedAt}):r.delete(s):a.status!==`success`&&a.status!==`noop`&&r.delete(s))}return i}var Mn=500;function Nn(e){return e.kind===`template`?`template:${e.templateId}`:`asset:${e.assetId}`}function Pn(e,t){return`${Nn(e)}|${t}`}function Fn(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 In(e,t){let n=new Map;for(let r of e){if(r.factoryName!==t)continue;let e=r.templateId===void 0?r.assetId===void 0?null:{kind:`asset`,assetId:r.assetId,protocol:`modbus`}:{kind:`template`,templateId:r.templateId};if(!e)continue;let i=Pn(e,r.targetId);n.has(i)||n.set(i,{status:Fn(r),operationType:r.operationType,targetId:r.targetId,targetLabel:r.targetLabel,completedAt:r.completedAt,error:r.error})}return n}function Ln(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 Rn(){let e=a(e=>e.factoryName),t=l({queryKey:o.integrations.operationsFactory(),queryFn:()=>ye({limit:Mn})});return{query:t,cells:(0,Y.useMemo)(()=>In(t.data?.operations??[],e),[t.data,e])}}var zn=5,Bn=`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 Vn(e){return e.kind===`template`?e.templateId:e.assetId}function Hn({row:e}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[e.subject.kind===`template`?(0,X.jsx)(me,{id:e.subject.templateId,className:`size-3.5 shrink-0 text-primary`}):(0,X.jsx)(Lt,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.label}),e.detail?(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.detail}):null]})]})}function Un({cell:e,running:t}){if(t)return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-primary`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-primary`}),`Running…`]});if(!e||e.status===`none`)return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.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,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs`,title:e.error??void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,n?`bg-success`:`bg-destructive`)}),(0,X.jsx)(`span`,{className:n?`text-foreground`:`text-destructive`,children:n?`Applied`:e.operationType===`cleanup`?`Clean up failed`:`Failed`}),(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:A(e.completedAt)})]})}function Wn({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,X.jsxs)(`li`,{className:L(Bn,`transition-colors hover:bg-muted/20`,a&&`pl-9`),children:[(0,X.jsx)(Hn,{row:e}),(0,X.jsxs)(`div`,{className:`col-start-1 row-start-2 @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,X.jsx)(Un,{cell:n,running:r}),n?.status===`failed`&&n.error?(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-[11px] text-destructive/80`,children:n.error}):null]}),(0,X.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,X.jsx)(w,{size:`xs`,variant:`outline`,disabled:i,"aria-label":`${n?.status===`failed`?`Retry`:`Apply`} ${s}`,className:$e,onClick:()=>o(`apply`),children:n?.status===`failed`?`Retry`:`Apply`}),c?(0,X.jsxs)(de,{children:[(0,X.jsx)(ue,{render:(0,X.jsx)(w,{size:`icon-xs`,variant:`ghost`,disabled:i,"aria-label":`More actions for ${s}`,className:`text-muted-foreground hover:text-foreground`}),children:(0,X.jsx)(Rt,{"aria-hidden":!0})}),(0,X.jsxs)(le,{align:`end`,className:`min-w-40`,children:[(0,X.jsxs)(ce,{className:`gap-2 text-xs`,onClick:()=>o(`apply`),children:[(0,X.jsx)(Ht,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Re-apply`]}),(0,X.jsxs)(ce,{variant:`destructive`,className:`gap-2 text-xs`,onClick:()=>o(`cleanup`),children:[(0,X.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),`Clean up`]})]})]}):null]})]})}function Gn({target:e,running:t,disabled:n,onCleanup:r}){let i=a(e=>e.factoryName),s=jn(l({queryKey:o.integrations.operationsForTarget(e.id),queryFn:()=>xe(e.id)}).data??[],e.id,i).filter(e=>!t.has(e.subjectId));return s.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`li`,{className:`bg-muted/20 px-4 pt-2.5 pb-1.5`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:`No longer running`}),(0,X.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.`]})]}),s.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,X.jsxs)(`li`,{className:L(Bn,`bg-muted/20`),children:[(0,X.jsx)(Hn,{row:i}),(0,X.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,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-muted-foreground/60`}),`Applied`,(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:A(t.completedAt)})]}),(0,X.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,X.jsxs)(w,{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,X.jsx)(Ue,{className:`size-3`,"aria-hidden":!0}),`Clean up`]})})]},`${t.kind}:${t.subjectId}`)})]})}function Kn(e,t){return t>0?`fault`:e>0?`live`:`off`}function qn({target:e,templates:t,assets:n,running:r,cells:i,stream:a,onAction:o}){let[s,c]=(0,Y.useState)(!1),{applied:l,failed:u}=Ln(i,e.id),d=a.status===`running`,f=t=>i.get(Pn(t.subject,e.id)),p=n.length>zn,m=n.filter(e=>f(e)?.status===`applied`).length,h=(t,n=!1)=>{let r=a.operation,i=d&&r?.label===Vn(t.subject)&&(r.targetLabel===e.label||r.targetLabel===e.id);return(0,X.jsx)(Wn,{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,X.jsx)(ot,{icon:z,title:e.label,description:(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.hostname}),aside:(0,X.jsxs)(W,{tone:Kn(l,u),children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:l}),(0,X.jsx)(K,{children:`applied`}),u>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mx-1.5 text-muted-foreground/60`,children:`·`}),(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:u}),(0,X.jsx)(K,{children:`failed`})]}):null]}),className:`@container/deploy`,bodyClassName:`p-0`,children:(0,X.jsxs)(`ul`,{className:`divide-y divide-border/50 py-1`,children:[t.length===0&&n.length===0?(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`li`,{className:Bn,children:[(0,X.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,X.jsx)(ge,{className:L(`size-3.5 shrink-0 text-muted-foreground transition-transform`,s&&`rotate-90`),"aria-hidden":!0}),`Standalone assets`,(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:n.length})]}),(0,X.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,X.jsx)(Gn,{target:e,running:r,disabled:d,onCleanup:t=>o(t,e,`cleanup`)})]})})}function Jn({targets:e,cells:t,stream:n}){let{templates:r,assets:i}=a(S(e=>({templates:e.templates,assets:e.assets}))),[o,s]=(0,Y.useState)(null);if(e.length===0)return(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(z,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`No Litmus Edge target yet`]}),(0,X.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,X.jsxs)(g,{to:`/integrations`,className:P({size:`sm`}),children:[(0,X.jsx)(Ne,{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,X.jsxs)(`section`,{"aria-label":`Deployments`,className:L(`grid items-start gap-4`,e.length>1&&`@5xl/main:grid-cols-2`),children:[e.map(e=>(0,X.jsx)(qn,{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)),o?(0,X.jsx)(An,{open:!0,onOpenChange:e=>!e&&s(null),action:o.action,subject:o.row.subject,label:o.row.label,target:o.target,stream:n}):null]})}var Yn={status:`idle`,operation:null,error:null,logs:[],cancelRequested:!1},Xn=200;function Zn(){let[e,t]=(0,Y.useState)(Yn),n=(0,Y.useRef)(null),r=(0,Y.useRef)(0),i=c(),a=(0,Y.useRef)(0),s=(0,Y.useCallback)(e=>{let n=Xe(e,`Integration operation failed.`),r=Ze(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,Y.useCallback)(e=>{switch(e.event){case`accepted`:Qn(e.data,t);break;case`log`:er({...e.data,id:`log-${r.current++}`},t);break;case`started`:tr(e.data,t);break;case`phase`:nr(e.data,t);break;case`resource`:rr(e.data,t);break;case`complete`:ir(e.data,t);break;case`cancelled`:or(e.data,t);break;case`retrying`:sr(e.data,t);break;case`error`:s(Error(e.data.message));break}},[s]),u=(0,Y.useCallback)(e=>{let c=++a.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=Se(e,e=>{a.current===c&&(l(e),cr(e)&&(i.invalidateQueries({queryKey:o.integrations.targets()}),i.invalidateQueries({queryKey:o.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,s(e))})},[l,s,i]),d=(0,Y.useCallback)(e=>{let c=++a.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=De(e,e=>{a.current===c&&(l(e),cr(e)&&(i.invalidateQueries({queryKey:o.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,s(e))})},[l,s,i]),f=(0,Y.useCallback)(()=>{a.current++,n.current?.abort(),n.current=null,t(Yn)},[]),p=(0,Y.useCallback)(async()=>{let n=e.operation?.operationId;if(!(!n||e.status!==`running`||e.cancelRequested)){t(e=>ar(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,Y.useEffect)(()=>()=>{a.current++,n.current?.abort(),n.current=null},[]),{...e,startApply:u,startCleanup:d,reset:f,cancel:p}}function Qn(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 $n(e){return e.templateId??e.assetId??`unknown`}function er(e,t){t(t=>({...t,logs:[...t.logs,e].slice(-Xn)}))}function tr(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:$n(e),targetLabel:e.targetLabel,totalPlanned:e.totalPlanned,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now(),attempt:e.attempt,maxAttempts:e.maxAttempts}}))}function nr(e,t){t(t=>{if(!Q(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 rr(e,t){t(t=>{if(!Q(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 ir(e,t){t(t=>{if(!Q(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 ar(e,t){return!Q(e,t)||e.status!==`running`?e:{...e,cancelRequested:!0}}function or(e,t){t(t=>{if(!Q(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 sr(e,t){t(t=>Q(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 Q(e,t){return e.operation?.operationId===t}function cr(e){return e.event===`complete`||e.event===`cancelled`||e.event===`error`}var lr={initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,originY:0},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:350,damping:40}},ur={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 dr({children:e,variant:t=`default`}){let n=t===`default`;return(0,X.jsx)(u.div,{...n?lr:ur,layout:n,className:`mx-auto w-full`,children:e})}var fr=Y.memo(({children:e,className:t,delay:n=1e3,...r})=>{let[i,a]=(0,Y.useState)(0),o=(0,Y.useMemo)(()=>Y.Children.toArray(e),[e]);(0,Y.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,Y.useMemo)(()=>o.slice(0,i+1).reverse(),[i,o]);return(0,X.jsx)(`div`,{className:L(`flex flex-col items-center gap-4`,t),...r,children:(0,X.jsx)(f,{children:s.map(e=>(0,X.jsx)(dr,{children:e},e.key))})})});fr.displayName=`AnimatedList`;function pr({type:e,errorMessage:t,className:n}){return null}var mr=`text-destructive hover:bg-destructive/25 hover:text-foreground`,hr={device:`Devices`,tags:`Tags`,model:`Models`,asset:`Assets`,"param-sync":`Parameters`};function gr(e){return hr[e]??e}function _r(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 vr(e){return e===`noop`?`no-op`:e}function yr({status:e}){switch(e){case`success`:return(0,X.jsx)(_e,{className:`size-3.5 shrink-0 text-success`});case`failed`:return(0,X.jsx)(ve,{className:`size-3.5 shrink-0 text-destructive`});case`pending`:return(0,X.jsx)(B,{className:`size-3.5 shrink-0 animate-spin text-primary/90`})}}function br({status:e}){switch(e){case`done`:return(0,X.jsx)(_e,{className:`size-3.5 text-success`});case`active`:return(0,X.jsx)(B,{className:`size-3.5 animate-spin text-primary`});case`pending`:return(0,X.jsx)(Ft,{className:`size-3.5 text-foreground/55`})}}function xr({entry:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,className:L(`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,X.jsx)(yr,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground`,children:e.name}),(0,X.jsx)(`span`,{className:L(`inline-flex rounded-[var(--miravo-radius-tight)] px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,_r(e.action)),children:vr(e.action)}),e.error&&(0,X.jsx)(he,{className:L(`size-3 text-foreground/75 transition-transform`,t&&`rotate-180`)})]}),(0,X.jsx)(f,{initial:!1,children:t&&e.error&&(0,X.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,X.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,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error}),(0,X.jsx)(Oe,{value:e.error,label:`Copy error`,className:L(mr,`shrink-0`)})]}),(0,X.jsx)(pr,{type:`apply`,errorMessage:e.error,className:`mb-1 mt-2.5 w-full min-w-0`})]})})]})}function Sr({phase:e,open:t,onOpenChange:n}){let r=e.resources.length,i=r===e.total,a=e.resources.length>0;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,className:L(`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,X.jsx)(br,{status:e.status}),(0,X.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-foreground`,children:gr(e.name)}),(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-foreground/70`,children:[r,`/`,e.total]}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[i&&e.status===`done`&&(0,X.jsx)(_e,{className:`size-3 text-success`}),a&&(0,X.jsx)(he,{className:L(`size-3 text-foreground/75 transition-transform`,!t&&`-rotate-90`),"aria-hidden":!0})]})]}),(0,X.jsx)(f,{initial:!1,children:a&&t&&(0,X.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,X.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,X.jsx)(d.Provider,{value:null,children:e.resources.map((e,t)=>(0,X.jsx)(dr,{variant:`subtle`,children:(0,X.jsx)(xr,{entry:e})},`${e.name}-${t}`))})})})})]})}function Cr({operation:e}){let t=e.status===`complete`,n=e.status===`cancelled`,r=e.failed>0,i=e.totalPlanned>0?Math.min(100,Tr(e)/e.totalPlanned*100):0;return(0,X.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,X.jsx)(u.div,{"aria-hidden":`true`,className:L(`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 wr(e){return e.duration==null?(Date.now()-e.startedAt)/1e3:e.duration/1e3}function Tr(e){let t=e.applied+e.failed;return e.totalPlanned>0?Math.min(t,e.totalPlanned):t}var Er={complete:{Icon:_e,className:`size-4 text-success`},partial:{Icon:Pt,className:`size-4 text-warning`},cancelled:{Icon:At,className:`size-4 text-foreground/65`},error:{Icon:ve,className:`size-4 text-destructive`},running:{Icon:B,className:`size-4 animate-spin text-warning`}};function Dr({icon:e,className:t}){return(0,X.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,X.jsx)(e,{className:t})})}function Or({operation:e,sourceLabel:t,isAllExpanded:n,onToggleAll:r}){let i=wr(e),a=Tr(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=Er[d];return(0,X.jsxs)(`div`,{className:L(`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,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(f,{mode:`wait`,initial:!1,children:(0,X.jsx)(Dr,{icon:p.Icon,className:p.className},d)}),(0,X.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,X.jsxs)(`span`,{className:`w-full min-w-0 text-[10px] leading-tight text-foreground/78`,children:[(0,X.jsx)(`span`,{className:`font-sans break-words`,children:t}),(0,X.jsx)(`span`,{className:`font-mono break-words`,children:` → ${e.targetLabel}`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(qe,{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,X.jsxs)(`span`,{className:`gap-1`,children:[(0,X.jsx)(f,{mode:`popLayout`,initial:!1,children:(0,X.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,X.jsx)(`span`,{className:`text-foreground/72`,children:e.type===`apply`?`applied`:`deleted`})]})}),(0,X.jsx)(f,{initial:!1,children:e.failed>0&&(0,X.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,X.jsxs)(qe,{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,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] leading-none text-foreground/75`,children:[(0,X.jsx)(It,{className:`size-3 shrink-0 block text-foreground/65`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`tabular-nums leading-none`,children:typeof i==`number`?`${i.toFixed(1)}s`:`...`})]}),r&&(0,X.jsx)(`div`,{className:`flex items-center border-l border-border/40 pl-2`,children:(0,X.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,X.jsx)(Nt,{className:L(`size-3.5 transition-transform duration-300`,!n&&`opacity-70 scale-y-[-1]`)})})})]})]}),(0,X.jsx)(Cr,{operation:e})]})]})}function kr(e){return e?e.closest(`[data-edge-op-scroll]`)??e.closest(`.overflow-y-auto`):null}var Ar=350;function jr(e){e?.scrollIntoView({block:`end`,behavior:`auto`,inline:`nearest`})}function Mr(e){let t=()=>jr(e);t(),requestAnimationFrame(t),requestAnimationFrame(()=>requestAnimationFrame(t)),window.setTimeout(t,0),window.setTimeout(t,48),window.setTimeout(t,120)}function Nr({logs:e}){return e.length===0?null:(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5 px-2 pb-2`,children:e.map(e=>(0,X.jsxs)(`div`,{className:L(`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,X.jsx)(ae,{className:`mt-0.5 size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(Pt,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:e.message})]},e.id))})}function Pr({operation:e,logs:t}){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(!0),a=(0,Y.useRef)(e.status);a.current=e.status;let o=(0,Y.useRef)(!1),[s,c]=(0,Y.useState)(new Set),l=e.label;(0,Y.useLayoutEffect)(()=>{let e=kr(n.current);if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<Ar};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,Y.useLayoutEffect)(()=>{if(e.status===`running`){i.current&&jr(r.current),o.current=!0;return}o.current&&=(Mr(r.current),!1)},[e.status,e.applied,e.failed,e.phases]),(0,Y.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&&jr(r.current)})});return s.observe(t),i.current&&jr(r.current),()=>{s.disconnect(),cancelAnimationFrame(o)}},[e.status]);let d=e.phases.length>0,p=s.size===0;return(0,X.jsxs)(`div`,{ref:n,className:`flex min-w-0 w-full flex-col gap-2`,children:[(0,X.jsx)(Or,{operation:e,sourceLabel:l,isAllExpanded:p,onToggleAll:d?()=>{c(p?new Set(e.phases.map(e=>e.name)):new Set)}:void 0}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1 px-2 pt-2 pb-4`,children:e.phases.map(e=>(0,X.jsx)(`div`,{children:(0,X.jsx)(Sr,{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,X.jsx)(f,{initial:!1,children:e.error&&e.retryPending&&(0,X.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,X.jsx)(B,{className:`size-4 shrink-0 animate-spin`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.error})]})}),(0,X.jsx)(f,{initial:!1,children:e.error&&e.status===`error`&&(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left wrap-anywhere text-destructive`,children:e.error}),(0,X.jsx)(Oe,{value:e.error,label:`Copy error`,className:L(mr,`shrink-0`)})]}),(0,X.jsx)(pr,{type:e.type,errorMessage:e.error,className:`mt-3 w-full min-w-0`})]})}),t&&t.length>0?(0,X.jsx)(Nr,{logs:t}):null,(0,X.jsx)(`div`,{ref:r,className:`h-px w-full shrink-0`,"aria-hidden":!0})]})}function Fr({title:e,subtitle:t,footerAction:n,canDismiss:r=!0,onDismiss:i,children:a}){return(0,Y.useEffect)(()=>{function e(e){e.key===`Escape`&&r&&i()}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r,i]),(0,X.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,X.jsxs)(Ve,{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,X.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,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(Pe,{className:`size-4 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`font-heading text-xs font-semibold tracking-tight text-foreground`,children:e}),t?(0,X.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/80`,children:t}):null]})]}),r?(0,X.jsx)(w,{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,X.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,X.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,X.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 Ir(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 Lr({stream:e,onReset:t}){if(!e.operation&&e.status!==`running`)return null;let{title:n,subtitle:r}=Ir(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,X.jsx)(Fr,{title:n,subtitle:r,canDismiss:!o,footerAction:o&&e.operation?.operationId?(0,X.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:c,"aria-busy":c,className:L(P({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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(re,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,X.jsx)(u.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):s?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,X.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,X.jsxs)(g,{to:`/integrations?tab=activity`,className:L(P({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,X.jsx)(R,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,X.jsx)(ge,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,X.jsx)(w,{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,X.jsx)(pr,{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,X.jsx)(Pr,{operation:e.operation,logs:e.logs}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(B,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,X.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 Rr({targetCount:e,applied:t,failed:n,lastOp:r}){return(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.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,X.jsx)(z,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Litmus Edge`}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(W,{tone:e>0?`live`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,X.jsx)(K,{children:e===1?`target`:`targets`})]}),(0,X.jsxs)(W,{tone:t>0?`live`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:t}),(0,X.jsx)(K,{children:`applied`})]}),n>0?(0,X.jsxs)(W,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:n}),(0,X.jsx)(K,{children:`failed`})]}):null,r?(0,X.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`last run `,A(r.completedAt)]}):null,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(g,{to:`/integrations`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(Re,{className:`size-3`,"aria-hidden":!0}),`Manage targets`]}),(0,X.jsxs)(g,{to:`/integrations?tab=activity`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(R,{className:`size-3`,"aria-hidden":!0}),`Activity`]}),(0,X.jsxs)(`a`,{href:`${Ut}/integrations/litmus-edge`,target:`_blank`,rel:`noopener noreferrer`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(jt,{className:`size-3`,"aria-hidden":!0}),`Docs`]})]})]})}function zr(){let e=Zn(),t=l({queryKey:o.integrations.targets(),queryFn:()=>Ce()}),{query:n,cells:r}=Rn(),i=t.data,a=n.data?.operations;if(!i||!a){let e=t.error??n.error;return e?(0,X.jsx)(Fe,{message:Xe(e,`Could not load Litmus Edge status.`),onRetry:()=>{t.refetch(),n.refetch()},isRetrying:t.isFetching||n.isFetching}):(0,X.jsx)(Z,{className:`h-64 w-full`})}let{applied:s,failed:c}=Ln(r),u=a[0];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(Rr,{targetCount:i.length,applied:s,failed:c,lastOp:u}),(0,X.jsx)(Jn,{targets:i,cells:r,stream:e}),e.operation||e.status===`running`?(0,X.jsx)(Lr,{stream:e,onReset:e.reset}):null]})}function Br(){let e=l({queryKey:o.integrations.targets(),queryFn:()=>Ce()}),{cells:t}=Rn(),n=e.data?.length??0,{applied:r,failed:i}=Ln(t);return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,i>0?`bg-destructive`:r>0?`bg-success`:`bg-muted-foreground/50`)}),n===0?(0,X.jsx)(`span`,{className:`font-sans`,children:`No target yet`}):(0,X.jsxs)(`span`,{className:`truncate`,children:[n,` `,n===1?`target`:`targets`,` ·`,` `,(0,X.jsx)(`span`,{className:`text-foreground`,children:r}),` applied`,i>0?(0,X.jsxs)(`span`,{className:`text-destructive`,children:[` · `,i,` failed`]}):null]})]})}var Vr={"litmus-edge":{icon:z,Panel:zr,Summary:Br}};function Hr(e){return e?`/?tab=integrations&integration=${e}`:`/?tab=integrations`}function Ur(){return(0,X.jsxs)(ot,{icon:Vt,title:`Integrations`,description:`Send this factory to the platforms you build on.`,bodyClassName:`gap-1 px-2 py-2`,footer:(0,X.jsxs)(g,{to:Hr(),className:G,children:[`Open integrations`,(0,X.jsx)(oe,{className:`size-3`,"aria-hidden":!0})]}),children:[Dt.map(e=>{let{icon:t,Summary:n}=Vr[e.id];return(0,X.jsxs)(g,{to:Hr(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,X.jsx)(t,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.label}),(0,X.jsx)(n,{})]}),(0,X.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,X.jsxs)(`p`,{className:`px-2 pt-1 pb-0.5 text-[11px] text-muted-foreground`,children:[`Coming soon: `,Tt.map(e=>e.label).join(`, `),`.`]})]})}function Wr(e){return s.prefetchQuery({queryKey:o.assets.detail(e),queryFn:()=>i(`/assets/${e}`,r.assetDetail),staleTime:2e3})}var Gr=`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function Kr(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 qr(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var Jr={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 Yr({state:e}){let t=Jr[e];return(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(`span`,{className:L(`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,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,X.jsx)(`span`,{children:T(t.label)})]}),(0,X.jsx)(H,{side:`top`,children:t.help})]})}function $({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,X.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,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,X.jsx)(`span`,{children:e}),n&&(0,X.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,X.jsx)(se,{className:L(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,X.jsx)(xt,{className:s,"aria-sort":l,children:r?(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:u}),(0,X.jsx)(H,{side:`top`,children:r})]}):u})}function Xr({title:e,body:t,action:n}){return(0,X.jsx)(vt,{children:(0,X.jsx)(J,{colSpan:8,className:`py-10`,children:(0,X.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,X.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,X.jsx)(oe,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Zr({assets:e,state:t,templateByAsset:n,sortKey:r,sortDir:i,onSort:a,onOpenAsset:o}){return(0,X.jsx)(ut,{className:`py-0`,children:(0,X.jsx)(ft,{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,X.jsxs)(St,{children:[(0,X.jsx)(Ct,{children:(0,X.jsxs)(vt,{children:[(0,X.jsx)($,{label:`Asset`,sortKey:`id`,current:r,direction:i,onSort:a}),(0,X.jsx)($,{label:`Template`,sortKey:`template`,current:r,direction:i,onSort:a,className:`hidden md:table-cell`}),(0,X.jsx)($,{label:`Model`,sortKey:`model`,current:r,direction:i,onSort:a,className:`hidden sm:table-cell`}),(0,X.jsx)($,{label:`Lifecycle`,sortKey:`lifecycle`,current:r,direction:i,onSort:a,tooltip:Gr}),(0,X.jsx)($,{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,X.jsx)($,{label:`Faults`,sortKey:`faults`,current:r,direction:i,onSort:a,tooltip:`Count of active (uncleared) faults on this asset.`}),(0,X.jsx)($,{label:`Status`,sortKey:`status`,current:r,direction:i,onSort:a}),(0,X.jsx)(xt,{children:(0,X.jsx)(`span`,{className:`sr-only`,children:`Navigate to asset`})})]})}),(0,X.jsx)(yt,{children:t===`connecting`?(0,X.jsx)(Xr,{title:`Connecting to runtime`,body:`Live asset data will appear once the connection is up.`}):t===`empty`?(0,X.jsx)(Xr,{title:`No running assets`,body:`Start a factory from the Catalog to see assets.`,action:{label:`Open Catalog`,href:`/catalog`}}):e.length===0?(0,X.jsx)(Xr,{title:`No matches`,body:`Adjust filters or clear them to see all assets.`}):e.map(e=>{let t=qr(e),r=M(e.id);return(0,X.jsxs)(vt,{tabIndex:0,"aria-label":`Open asset ${r}`,className:L(`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:()=>{Ge(`/asset/${e.id}`),Wr(e.id)},onFocus:()=>{Ge(`/asset/${e.id}`),Wr(e.id)},children:[(0,X.jsx)(J,{className:`text-sm`,children:(0,X.jsx)(Y.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,X.jsx)(`span`,{className:`inline-flex max-w-full truncate rounded-(--miravo-radius-tight) text-left`,title:e.id,children:r})})}),(0,X.jsx)(J,{className:`hidden text-sm text-muted-foreground md:table-cell`,children:n.get(e.id)??`Standalone`}),(0,X.jsx)(J,{className:`hidden text-sm sm:table-cell`,children:N(e.model)}),(0,X.jsx)(J,{children:(0,X.jsx)(qe,{variant:`secondary`,className:`text-xs`,children:D(e.lifecycleStage)})}),(0,X.jsx)(J,{className:`hidden font-mono text-sm md:table-cell`,children:j(e.operatingHours)}),(0,X.jsx)(J,{children:e.activeFaults.length>0?(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:(0,X.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,X.jsxs)(H,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,X.jsx)(J,{children:(0,X.jsx)(Yr,{state:t})}),(0,X.jsx)(J,{children:(0,X.jsx)(oe,{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 Qr=`~all`,$r=`~standalone`;function ei(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function ti(){let{assets:e,templates:t,connectionState:n}=a(S(e=>({assets:e.assets,templates:e.templates,connectionState:e.connectionState}))),[r,i]=p(`q`,m.withDefault(``)),[o,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=ei(_)?_:``,[b,ee]=(0,Y.useState)(`id`),[x,te]=(0,Y.useState)(`asc`),C=(0,Y.useRef)(null),w=Ke(),[T,E]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),C.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let O=(0,Y.useCallback)(e=>{e===b?te(e=>e===`asc`?`desc`:`asc`):(ee(e),te(`asc`))},[b]),k=(0,Y.useMemo)(()=>{let e=new Map;for(let n of t)for(let t of n.assetIds)e.set(t,n.templateName);return e},[t]),A=(0,Y.useMemo)(()=>[{value:Qr,label:`All templates`},{value:$r,label:`Standalone`},...t.map(e=>({value:e.templateId,label:e.templateName}))],[t]),j=(0,Y.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]),M=(0,Y.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),P=(0,Y.useMemo)(()=>[{value:`all`,label:`All stages`},...M.map(e=>({value:e,label:D(e)}))],[M]),I=(0,Y.useMemo)(()=>T?j.filter(([e])=>F(e,T)):j,[j,T]),L=(0,Y.useMemo)(()=>o?{value:o,label:N(o)}:null,[o]),R=(0,Y.useMemo)(()=>{let n=e;if(g)n=n.filter(e=>!k.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 o&&(n=n.filter(e=>e.model===o)),c&&(n=n.filter(e=>e.lifecycleStage===c)),r&&(n=n.filter(e=>ie(e.id,r)||F(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)),Kr(n,b,x,k)},[e,t,k,u,g,r,y,o,c,b,x]),ae=y!==``||u!==``||g||o!==``||c!==``||r!==``,oe=(0,Y.useCallback)(()=>{i(``),v(``),d(``),h(``),s(``),l(``)},[i,v,d,h,s,l]),z=(0,Y.useCallback)(e=>{w(`/asset/${e}`,{transitionType:Je})},[w]),se=e.length>0?`rows`:n===`live`?`empty`:`connecting`;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.length>0&&(0,X.jsxs)(_t,{value:g?$r:u||Qr,onValueChange:e=>{h(e===$r?`1`:``),d(!e||e===Qr||e===$r?``:e)},items:A,children:[(0,X.jsx)(gt,{className:`h-8 w-44`,"aria-label":`Template filter`,children:(0,X.jsx)(mt,{placeholder:`All templates`})}),(0,X.jsx)(ht,{alignItemWithTrigger:!1,align:`start`,children:A.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]}),(0,X.jsxs)(pt,{value:L,onValueChange:e=>void s(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:E,children:[(0,X.jsx)(dt,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!o}),(0,X.jsx)(lt,{children:(0,X.jsxs)(st,{children:[I.map(([e,t])=>(0,X.jsxs)(ct,{value:{value:e,label:N(e)},children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:N(e)}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),I.length===0&&(0,X.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),M.length>1&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(_t,{value:c||`all`,onValueChange:e=>void l(!e||e===`all`?``:e),items:P,children:[(0,X.jsx)(gt,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,X.jsx)(mt,{placeholder:`All stages`})}),(0,X.jsxs)(ht,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All stages`}),M.map(e=>(0,X.jsx)(q,{value:e,children:D(e)},e))]})]}),(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:(0,X.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,X.jsx)(we,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,children:`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`})]})]}),(0,X.jsxs)(_t,{value:y||`all`,onValueChange:e=>void v(!e||e===`all`?``:e),items:bt,children:[(0,X.jsx)(gt,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,X.jsx)(mt,{placeholder:`All status`})}),(0,X.jsxs)(ht,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All status`}),(0,X.jsx)(q,{value:`healthy`,children:`Healthy`}),(0,X.jsx)(q,{value:`faulted`,children:`Faulted`}),(0,X.jsx)(q,{value:`quarantined`,children:`Quarantined`})]})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.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,X.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:`/`})]}),ae&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:oe,className:`flex items-center gap-1 rounded-(--miravo-radius-tight) px-1 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(re,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[R.length,` of `,e.length]})]})]}),(0,X.jsx)(Zr,{assets:R,state:se,templateByAsset:k,sortKey:b,sortDir:x,onSort:O,onOpenAsset:z})]})}var ni={running:`live`,paused:`idle`,stopped:`fault`};function ri(){let{factoryName:e,engineState:t,seed:n,speed:r,bootTemplate:i}=a(S(e=>({factoryName:e.factoryName,engineState:e.engineState,seed:e.seed,speed:e.speedMultiplier,bootTemplate:e.bootTemplate})));return(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:e&&!Qe(e)?O(e):`Factory`}),(0,X.jsx)(W,{tone:ni[t]??`off`,children:(0,X.jsx)(K,{children:t})})]}),(0,X.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-muted-foreground`,children:[e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{children:[`id `,(0,X.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`})]}):null,(0,X.jsxs)(`span`,{children:[`seed `,(0,X.jsx)(`span`,{className:`text-foreground`,children:n??`-`})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`span`,{className:`text-foreground`,children:[r,`×`]}),` speed`]}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(`span`,{children:[`booted with `,(0,X.jsx)(`span`,{className:`text-foreground`,children:i.name})]})]}):null]})]}),(0,X.jsxs)(g,{to:`/catalog`,className:P({size:`sm`}),children:[(0,X.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),`Load template`]})]})}var ii=Dt.map(e=>e.id),ai=`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 oi(){let[e,t]=p(`integration`,h(ii).withDefault(Et.id)),{Panel:n}=Vr[e];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`nav`,{"aria-label":`Integrations`,className:`flex flex-wrap gap-2`,children:[Dt.map(n=>{let{icon:r}=Vr[n.id],i=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>void t(n.id),className:L(ai,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,X.jsx)(r,{className:L(`size-3.5`,i&&`text-primary`),"aria-hidden":!0}),n.label]},n.id)}),Tt.map(e=>(0,X.jsxs)(`span`,{"aria-disabled":!0,className:L(ai,`cursor-default border-dashed border-border/60 text-muted-foreground/70`),children:[(0,X.jsx)(Vt,{className:`size-3.5`,"aria-hidden":!0}),e.label,(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Soon`})]},e.id))]}),(0,X.jsx)(n,{})]})}function si(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 ci={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`},li={healthy:`bg-success`,faulted:`bg-destructive`,quarantined:`bg-warning`};function ui({group:e,label:t,templateId:n}){let[r]=e.ids;return(0,X.jsxs)(g,{to:e.ids.length===1&&r?`/asset/${r}`:si({model:e.model,template:n}),title:e.ids.join(`, `),className:L(`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`,ci[e.health]),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,li[e.health])}),t,e.ids.length>1&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.ids.length]}),e.health!==`healthy`&&(0,X.jsxs)(`span`,{className:`sr-only`,children:[`, `,e.health]})]})}function di(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var fi=24;function pi(){let{assets:e,templates:t}=a(S(e=>({assets:e.assets,templates:e.templates}))),[n,r]=(0,Y.useState)(!1),i=new Set(t.flatMap(e=>e.assetIds)),o=e.filter(e=>!i.has(e.id));if(o.length===0)return null;let s=n?o:o.slice(0,fi);return(0,X.jsxs)(`section`,{"aria-label":`Standalone assets`,className:L(et,`flex flex-col gap-4 p-5`),children:[(0,X.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(Lt,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:`Standalone assets`}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/75`,children:`Spawned from a model, outside any template.`})]})]}),(0,X.jsxs)(`ul`,{className:`flex flex-wrap gap-1.5`,children:[s.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(ui,{group:{model:e.model,ids:[e.id],health:di(e)},label:e.id})},e.id)),o.length>fi&&(0,X.jsx)(`li`,{children:(0,X.jsx)(w,{size:`xs`,variant:`ghost`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`+${o.length-fi} more`})})]}),(0,X.jsxs)(`div`,{className:`mt-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:o.length}),` asset`,o.length===1?``:`s`]}),(0,X.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(g,{to:si({standalone:!0}),className:L(P({size:`sm`,variant:`outline`}),$e),children:[(0,X.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),(0,X.jsxs)(g,{to:`/models`,className:L(P({size:`sm`,variant:`ghost`}),`ml-auto text-muted-foreground`),children:[(0,X.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),`Spawn asset`]})]})]})}function mi({template:e,open:t,onOpenChange:n}){let r=tt(),[i,a]=(0,Y.useState)(!1);return(0,X.jsx)(te,{open:t,onOpenChange:n,children:(0,X.jsxs)(b,{children:[(0,X.jsxs)(v,{children:[(0,X.jsxs)(ee,{children:[`Unload `,e.templateName]}),(0,X.jsxs)(x,{children:[`Removes its `,e.assetIds.length,` asset`,e.assetIds.length===1?``:`s`,`. Standalone assets stay.`]})]}),(0,X.jsxs)(y,{children:[(0,X.jsx)(w,{variant:`outline`,onClick:()=>n(!1),disabled:i,children:`Cancel`}),(0,X.jsx)(w,{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 hi({value:e,label:t}){return(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e}),` `,t,e===1?``:`s`]})}function gi(e,t){let n=new Set(e.assetIds),r=new Set;for(let e of t)n.has(e.id)&&di(e)!==`healthy`&&r.add(N(e.model));return[...r]}function _i({template:e,highlighted:t=!1}){let{assets:n,engineState:s}=a(S(e=>({assets:e.assets,engineState:e.engineState}))),c=l({queryKey:o.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=c.data?.find(t=>t.id===e.templateId)?.description,h=new Set(e.assetIds),_=n.filter(e=>h.has(e.id)&&di(e)!==`healthy`).length,v=_>0?gi(e,n):[],y=e.areas.reduce((e,t)=>e+t.lines.length,0);return(0,X.jsxs)(`section`,{id:`template-${e.templateId}`,"aria-label":e.templateName,className:L(et,`flex scroll-mt-4 flex-col gap-4 p-5 transition-shadow`,t&&`ring-2 ring-ring`),children:[(0,X.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(me,{id:e.templateId,className:`size-5`})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:e.templateName}),(0,X.jsx)(`span`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.templateId})]}),_>0?(0,X.jsxs)(W,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:_}),` `,(0,X.jsx)(K,{children:`faulted`})]}):(0,X.jsx)(W,{tone:s===`running`?`live`:`idle`,children:(0,X.jsx)(K,{children:s===`running`?`running`:`paused`})})]}),m?(0,X.jsx)(`p`,{className:`line-clamp-2 text-pretty text-xs leading-relaxed text-muted-foreground`,children:m}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(hi,{value:e.areas.length,label:`area`}),(0,X.jsx)(hi,{value:y,label:`line`}),(0,X.jsx)(hi,{value:e.assetIds.length,label:`asset`}),(0,X.jsx)(hi,{value:e.models.length,label:`model`})]}),v.length>0?(0,X.jsxs)(g,{to:si({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,X.jsx)(We,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[_,` faulted:`]}),` `,v.join(`, `)]})]}):null,(0,X.jsxs)(`footer`,{className:`mt-auto flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(w,{type:`button`,size:`sm`,variant:`outline`,className:$e,onClick:()=>p(!0),children:[(0,X.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),Ot(e.templateId)?(0,X.jsxs)(g,{to:kt(e.templateId),className:P({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Me,{className:`size-3.5`,"aria-hidden":!0}),`Open floor`]}):null,(0,X.jsx)(w,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>d(!0),children:`Unload`})]}),(0,X.jsx)(mi,{template:e,open:u,onOpenChange:d}),(0,X.jsx)(pe,{templateId:f?e.templateId:null,onClose:()=>p(!1),actions:(0,X.jsxs)(g,{to:si({template:e.templateId}),className:P({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),fallbackTitle:e.templateName})]})}var vi={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},yi={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},bi={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function xi({label:e,pip:t,pulse:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,X.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,X.jsx)(`span`,{className:L(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,vi[t])}),(0,X.jsx)(`span`,{className:L(`relative inline-flex size-1.5 rounded-full`,vi[t])})]}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:L(`size-1.5 shrink-0 rounded-full`,vi[t])})),(0,X.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function Si({children:e,tone:t=`foreground`,live:n}){return(0,X.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:L(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,yi[t]),children:e})}function Ci({children:e}){return(0,X.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function wi(e,t){return e===t?``:t}function Ti({statusFilter:e,onStatusFilter:t}){let{assets:n,tps:r,memberValueCount:i,availableAdapters:o,adapterMetrics:s}=a(S(e=>({assets:e.assets,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),c=(0,Y.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,Y.useMemo)(()=>{let e=o.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>bi[e.name]??e.name)}},[o,s]),u=c.activeFaultCount>0,d=u?`destructive`:c.quarantined>0?`warning`:`success`,f=u?`faulted`:`healthy`;return(0,X.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,X.jsxs)(`button`,{type:`button`,onClick:()=>t(wi(e,f)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":u?`Filter to faulted assets`:`Filter to healthy assets`,className:L(`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,X.jsx)(xi,{label:`Health`,pip:d}),(0,X.jsxs)(Si,{tone:u?`destructive`:`success`,children:[c.pct,`%`]}),(0,X.jsx)(Ci,{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,X.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted assets`,className:L(`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,X.jsx)(xi,{label:`Faults`,pip:u?`destructive`:`success`}),(0,X.jsx)(Si,{tone:u?`destructive`:`foreground`,live:!0,children:c.activeFaultCount}),(0,X.jsx)(Ci,{children:u?`${c.affectedCount} asset${c.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.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,X.jsx)(xi,{label:`Tags`,pip:`primary`,pulse:!0}),(0,X.jsx)(Si,{children:E(i)}),(0,X.jsxs)(Ci,{children:[(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,X.jsx)(H,{side:`bottom`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,X.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[k(i),` tags`]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),l.enabled.length>0&&(0,X.jsx)(Ei,{labels:l.labels,totalMessages:l.totalMessages,totalErrors:l.totalErrors,perAdapter:l.enabled.map(e=>({name:bi[e.name]??e.name,metrics:s.find(t=>t.name===e.name)?.metrics}))})]})}function Ei({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.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,X.jsx)(xi,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,X.jsx)(Si,{tone:n>0?`warning`:`foreground`,live:!0,children:E(t)}),(0,X.jsxs)(Ci,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,X.jsx)(H,{side:`bottom`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,X.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[k(t),` total`]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,X.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[k(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var Di=2500,Oi=[`overview`,`assets`,`integrations`];function ki({value:e}){return(0,X.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 font-mono text-[10px] leading-4 tabular-nums text-muted-foreground`,children:e})}function Ai({children:e}){return(0,X.jsx)(u.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e})}function ji(){return(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(zt,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`Nothing is running yet`]}),(0,X.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,X.jsx)(g,{to:`/catalog`,className:P({size:`sm`}),children:`Open catalog`})]})}function Mi({highlight:e}){let{templates:t,assetCount:n}=a(S(e=>({templates:e.templates,assetCount:e.assets.length})));return(0,X.jsx)(`div`,{className:`@container/overview`,children:(0,X.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,X.jsx)(ji,{}):(0,X.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,22rem),1fr))] gap-4`,children:[t.map(t=>(0,X.jsx)(_i,{template:t,highlighted:t.templateId===e},t.templateId)),(0,X.jsx)(pi,{})]}),(0,X.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,X.jsx)(Wt,{}),(0,X.jsx)(Ur,{})]})]})})}function Ni(){let{hash:e}=_(),{templates:t,assetCount:n}=a(S(e=>({templates:e.templates,assetCount:e.assets.length}))),[r,i]=p(`tab`,h(Oi).withDefault(`overview`)),[o,s]=p(`highlight`,m.withDefault(``)),[c,l]=p(`status`,m.withDefault(``)),u=c===`healthy`||c===`faulted`||c===`quarantined`?c:``;(0,Y.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===o);return(0,Y.useEffect)(()=>{if(!o||!d)return;document.getElementById(`template-${o}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=setTimeout(()=>void s(null,{history:`replace`}),Di);return()=>clearTimeout(e)},[o,d,s]),(0,X.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,X.jsx)(ri,{}),(0,X.jsx)(Ti,{statusFilter:u,onStatusFilter:e=>{l(e||null),e!==``&&i(`assets`)}}),(0,X.jsxs)(at,{value:r,onValueChange:e=>void i(e),children:[(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(it,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,X.jsxs)(nt,{value:`overview`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(fe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Overview`,(0,X.jsx)(ki,{value:t.length})]}),(0,X.jsxs)(nt,{value:`assets`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Mt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Assets`,(0,X.jsx)(ki,{value:n})]}),(0,X.jsxs)(nt,{value:`integrations`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Vt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Integrations`]})]})}),(0,X.jsx)(rt,{value:`overview`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(Mi,{highlight:o})})}),(0,X.jsx)(rt,{value:`assets`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(ti,{})})}),(0,X.jsx)(rt,{value:`integrations`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(oi,{})})})]})]})}export{Ft as a,zt as i,Ut as n,Mt as o,Vt as r,jt as s,Ni as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./factory-C2OucdpQ.js";export{e as FactoryPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./utils-XFKvwlFT.js";var t=e(`factory`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
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{Dt as r,S as i,St as a,_t as o,ft as s,o as c,ot as l,v as u,y as d,yt as f}from"./api-B2QJEzbS.js";import{a as p,c as m,f as h,i as g,l as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./useQuery-M9KTdi7Q.js";import{i as w}from"./dist-xY0pK9Wy.js";import{l as T,n as E}from"./chunk-OE4NN4TA-DBWZidbW.js";import{C as D,d as O,g as k,w as A}from"./format-Bx7DF-TB.js";import{n as j,t as M}from"./utils-XFKvwlFT.js";import{t as ee}from"./arrow-up-right-CwPw_2U1.js";import{t as te}from"./chevron-right-CMSQPSEo.js";import{t as ne}from"./factory-DLE12zAd.js";import{t as re}from"./minus-CaT9UaQx.js";import{t as ie}from"./pause-CqW7v5Dc.js";import{t as ae}from"./play-kg50os4l.js";import{t as oe}from"./plus-Cl4Ay5Ry.js";import{i as se,n as ce,t as le}from"./tooltip-B3vOB1Vu.js";import{t as ue}from"./use-engine-command-mutation-CHqjOqfS.js";import{i as de,n as fe,r as pe,t as me}from"./tabs-BbQkzBZZ.js";import{a as he,c as ge,i as _e,o as ve,t as ye}from"./events-format-C5HTkIsC.js";import{n as be,r as xe}from"./registry-Dau_GjK6.js";import{I as Se,i as Ce,n as we,r as Te,u as Ee}from"./dom-Cm_OH5jc.js";import{i as De,n as Oe,r as ke,t as Ae}from"./asset-panel-DDziFlFl.js";function je(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Me(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ne=class extends r{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,s.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,o=n.some((t,n)=>t!==e[n]),s=i||o,c=s?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!a(e,n)});!s&&!c||(s&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(s&&(je(e,n).forEach(e=>{e.destroy()}),je(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=f(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new y(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Me(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&s.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},N=e(t(),1);function Pe({queries:e,...t},n){let r=h(n),i=C(),a=_(),c=N.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);c.forEach(e=>{b(e),v(e,a,r.getQueryCache().get(e.queryHash))}),m(a);let[l]=N.useState(()=>new Ne(r,c,t)),[u,d,f]=l.getOptimisticResult(c,t.combine),S=!i&&t.subscribed!==!1;N.useSyncExternalStore(N.useCallback(e=>S?l.subscribe(s.batchCalls(e)):o,[l,S]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),N.useEffect(()=>{l.setQueries(c,t)},[c,t,l]);let w=u.some((e,t)=>p(c[t],e))?u.flatMap((e,t)=>{let n=c[t];return n&&p(n,e)?g(n,new y(r,n),a):[]}):[];if(w.length>0)throw Promise.all(w);let T=u.find((e,t)=>{let n=c[t];return n&&x({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(T?.error)throw T.error;return d(f())}var Fe=j(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Ie=j(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),Le=j(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Re=j(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),ze=6,Be=.9,Ve=.035,He=e=>1-(1-e)**3;function Ue(e,t){let{svg:n,P:r}=e,i=we(n,`[data-intro]`).map(e=>({g:e,i:+(e.dataset.intro??0)})),a=e.reducedMotion();return{lampTest:()=>!1,done:()=>a,draw(e){if(a)return;let n=(e-t)/1e3,o=!1;for(let{g:e,i:t}of i){let i=(n-t*Ve)/Be;if(i>=1){e.hasAttribute(`transform`)&&(e.removeAttribute(`transform`),e.style.opacity=``);continue}o=!0;let a=He(Math.max(0,i));e.setAttribute(`transform`,Se(r,[0,0,ze*(1-a)])),e.style.opacity=String(a)}a=!o}}}var We=`data-floor-keys`,Ge=6,Ke=1.6;function qe(e,t,n={}){let r=t.width,i=t.height,a=n.keyTarget===void 0?e.parentElement:n.keyTarget,o=()=>n.reducedMotion?.()??!1,s=0,c=0,l=r,u=i;function d(){let t=e.getBoundingClientRect(),n=t.width/Math.max(1,t.height);!t.width||!t.height||(n>r/i?(l=i*n,u=i):(l=r,u=r/n),s=(r-l)/2,c=(i-u)/2)}d();let f={x:s,y:c,s:1,tx:s,ty:c,ts:1},p=new Set,m=!1,h=``,g=()=>({scale:f.ts,x:f.x,y:f.y,width:l/f.s,height:u/f.s,panning:m});function _(){let e=g();n.onViewChange?.(e);for(let t of p)t(e)}function v(e){e.ts=Math.max(1,Math.min(Ge,e.ts));let t=l/e.ts,n=u/e.ts;e.tx=Math.max(s,Math.min(s+l-t,e.tx)),e.ty=Math.max(c,Math.min(c+u-n,e.ty))}function y(e,t,n){let r=Math.max(1,Math.min(Ge,f.ts*e));f.tx=t-(t-f.tx)*f.ts/r,f.ty=n-(n-f.ty)*f.ts/r,f.ts=r,v(f)}let b=(t,n)=>{let r=e.getBoundingClientRect();return[f.x+(t-r.left)/r.width*(l/f.s),f.y+(n-r.top)/r.height*(u/f.s)]},x=()=>[f.tx+l/f.ts/2,f.ty+u/f.ts/2],S=()=>{f.tx=s,f.ty=c,f.ts=1};function C(t){let n=we(e,`[data-asset="${t}"]`);if(!n.length)return;let r=1/0,i=1/0,a=-1/0,o=-1/0,s=e.getScreenCTM()?.inverse();for(let e of n){let t=e,n=t.getBBox();if(!n.width&&!n.height)continue;let c=s&&t.getScreenCTM()?s.multiply(t.getScreenCTM()):null;for(let[e,t]of[[n.x,n.y],[n.x+n.width,n.y],[n.x,n.y+n.height],[n.x+n.width,n.y+n.height]]){let n=c?new DOMPoint(e,t).matrixTransform(c):{x:e,y:t};r=Math.min(r,n.x),i=Math.min(i,n.y),a=Math.max(a,n.x),o=Math.max(o,n.y)}}let c=a-r+52,d=o-i+52;f.ts=Math.min(l/c,u/d,4),f.tx=(r+a)/2-l/f.ts/2,f.ty=(i+o)/2-u/f.ts/2,v(f)}let w=new ResizeObserver(()=>{let e=f.ts;d(),e<=1.01?(S(),f.x=s,f.y=c):v(f)});w.observe(e);let T=e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let[t,n]=b(e.clientX,e.clientY);y(Math.exp(-e.deltaY*.012),t,n)},E=new Map,D=null,O=null,k=t=>{if(E.set(t.pointerId,[t.clientX,t.clientY]),E.size===2){let[e,t]=[...E.values()];O={d:Math.hypot(e[0]-t[0],e[1]-t[1]),s:f.ts},D=null;return}f.ts>1.01&&(D={x:t.clientX,y:t.clientY,tx:f.tx,ty:f.ty,moved:!1},e.setPointerCapture(t.pointerId))},A=t=>{if(E.has(t.pointerId)&&E.set(t.pointerId,[t.clientX,t.clientY]),O&&E.size===2){let[e,t]=[...E.values()],[n,r]=b((e[0]+t[0])/2,(e[1]+t[1])/2);y(O.s*Math.hypot(e[0]-t[0],e[1]-t[1])/O.d/f.ts,n,r);return}if(!D)return;let n=e.getBoundingClientRect(),r=l/f.s/n.width;f.tx=D.tx-(t.clientX-D.x)*r,f.ty=D.ty-(t.clientY-D.y)*r,Math.hypot(t.clientX-D.x,t.clientY-D.y)>3&&(D.moved=!0,m=!0,a?.setAttribute(`data-panning`,``)),v(f),f.x=f.tx,f.y=f.ty},j=e=>{E.delete(e.pointerId),E.size<2&&(O=null),D=null,m=!1,a?.removeAttribute(`data-panning`)},M=e=>{let t=n.assetAt?.(e.clientX,e.clientY)??null;t?C(t):S()},ee=e=>{if(e.target instanceof Element&&e.target.closest(`input,textarea`)||e.key.startsWith(`Arrow`)&&e.target instanceof Element&&e.target.closest(`[data-floor-keys]`))return;let[t,n]=x(),r=40/f.ts,i=new Map([[`+`,()=>y(Ke,t,n)],[`=`,()=>y(Ke,t,n)],[`-`,()=>y(1/Ke,t,n)],[`0`,S],[`ArrowLeft`,()=>{f.tx-=r,v(f)}],[`ArrowRight`,()=>{f.tx+=r,v(f)}],[`ArrowUp`,()=>{f.ty-=r,v(f)}],[`ArrowDown`,()=>{f.ty+=r,v(f)}]]).get(e.key);i&&(e.preventDefault(),i())};e.addEventListener(`wheel`,T,{passive:!1}),e.addEventListener(`pointerdown`,k),e.addEventListener(`pointermove`,A),e.addEventListener(`pointerup`,j),e.addEventListener(`pointercancel`,j),e.addEventListener(`dblclick`,M),a?.addEventListener(`keydown`,ee);let te=a?.hasAttribute(`tabindex`)??!0;return a&&!te&&a.setAttribute(`tabindex`,`0`),{zoomIn:()=>y(Ke,...x()),zoomOut:()=>y(1/Ke,...x()),fit:S,flyTo:C,zoomAt:y,scale:()=>f.s,subscribe(e){return p.add(e),()=>p.delete(e)},step(t){let n=o()||D?1:1-Math.exp(-t/.12);f.x+=(f.tx-f.x)*n,f.y+=(f.ty-f.y)*n,f.s+=(f.ts-f.s)*n,Math.abs(f.s-f.ts)<1e-4&&(f.s=f.ts);let r=`${f.x.toFixed(2)} ${f.y.toFixed(2)} ${(l/f.s).toFixed(2)} ${(u/f.s).toFixed(2)}`,i=`${f.ts>1.01}|${m}`;(e.getAttribute(`viewBox`)!==r||i!==h)&&(e.setAttribute(`viewBox`,r),f.ts>1.01?a?.setAttribute(`data-zoomed`,``):a?.removeAttribute(`data-zoomed`),h=i,_())},state:f,dispose(){w.disconnect(),e.removeEventListener(`wheel`,T),e.removeEventListener(`pointerdown`,k),e.removeEventListener(`pointermove`,A),e.removeEventListener(`pointerup`,j),e.removeEventListener(`pointercancel`,j),e.removeEventListener(`dblclick`,M),a?.removeEventListener(`keydown`,ee),a&&!te&&a.removeAttribute(`tabindex`),a?.removeAttribute(`data-zoomed`),a?.removeAttribute(`data-panning`),p.clear()}}}function Je(e){return null}var Ye=250,Xe=2;function Ze(e,t){let{svg:n,feed:r}=e,i=Ue(e,performance.now()),a=t(e),o=(e,t)=>Ce(n,e,t),s=qe(n,e.size,{reducedMotion:e.reducedMotion,assetAt:o}),c=!1,l=0,u=0,d=0,f=0,p=0;function m(t){l=0;let n=u?Math.min((t-u)/1e3,1/20):1/60;u=t,i.draw(t),t-d>Ye&&(a.data(i.lampTest()),d=t);let o=r.engineState()===`paused`,h=o?0:n;f+=h,p=o?p+n:0,(!i.done()||p<Xe)&&a.draw({dt:n,sdt:h,t:f,still:e.reducedMotion(),introDone:i.done()}),s.step(n),c&&(l=requestAnimationFrame(m))}let h=()=>{if(document.hidden){l&&cancelAnimationFrame(l),l=0;return}u=0,c&&!l&&(l=requestAnimationFrame(m))};document.addEventListener(`visibilitychange`,h);function g(){c=!1,l&&cancelAnimationFrame(l),l=0}return{start(){c||(c=!0,u=0,document.hidden||(l=requestAnimationFrame(m)))},stop:g,resync:a.resync,dispose(){g(),document.removeEventListener(`visibilitychange`,h),s.dispose();for(let e of we(n,`[${Te}]`))e.remove()},view:s,assetAt:o,status:a.status}}var P=n(),Qe={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};function $e({things:e,selected:t,label:n,onFocusMachine:r,onActivate:i}){let[a,o]=(0,N.useState)(0),s=(0,N.useRef)([]);(0,N.useEffect)(()=>{let n=e.findIndex(e=>e.key===t);n>=0&&o(n)},[t,e]);let c=t=>{let n=(t+e.length)%e.length;o(n),s.current[n]?.focus()},l=(e,t)=>{let n=Qe[e.key],r=n===void 0?void 0:t+n;e.key===`Home`&&(r=0),e.key===`End`&&(r=-1),r!==void 0&&(e.preventDefault(),c(r))};return(0,P.jsx)(`div`,{role:`toolbar`,"aria-label":`Machines`,[We]:``,className:`sr-only`,children:e.map((e,c)=>(0,P.jsx)(`button`,{ref:e=>{s.current[c]=e},type:`button`,tabIndex:c===a?0:-1,"aria-label":n(e),"aria-pressed":e.key===t,onFocus:()=>{o(c),r(e.key)},onBlur:()=>r(null),onKeyDown:e=>l(e,c),onClick:t=>{t.stopPropagation(),i(e.key)}},e.key))})}var et=4,tt=400,nt={g:`bg-success`,a:`bg-warning`,r:`bg-destructive`,"":`bg-muted-foreground/50`};function rt(e,t,n){let r=e.getBoundingClientRect(),i=1/0,a=-1/0,o=1/0,s=-1/0;for(let e of t.querySelectorAll(`[data-asset="${CSS.escape(n)}"]`)){let t=e.getBoundingClientRect();t.width&&(i=Math.min(i,t.left),a=Math.max(a,t.right),o=Math.min(o,t.top),s=Math.max(s,t.bottom))}return Number.isFinite(i)?{id:n,x:Math.max(72,Math.min(r.width-72,(i+a)/2-r.left)),y:Math.max(40,o-r.top-10),box:{left:i-r.left,top:o-r.top,width:a-i,height:s-o}}:null}function it(e,t,n){for(let n of e.querySelectorAll(`[${t}]`))n.removeAttribute(t);if(n)for(let r of e.querySelectorAll(`[data-asset="${CSS.escape(n)}"]`))r.setAttribute(t,``)}function at({layout:e,ids:t,caption:n,feed:r,things:i,selected:a,onSelect:o,onRuntime:s}){let c=(0,N.useRef)(null),u=(0,N.useRef)(null),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(null),[_,v]=(0,N.useState)(1),[,y]=(0,N.useState)(0),b=(0,N.useRef)({onSelect:o,onRuntime:s});b.current={onSelect:o,onRuntime:s},(0,N.useLayoutEffect)(()=>{let n=u.current;if(!n)return;let i=matchMedia(`(prefers-reduced-motion: reduce)`),a=Ze({svg:n,size:{width:e.width,height:e.height},P:e.kit.P,feed:r,flows:e.flows,ids:t,reducedMotion:()=>i.matches},e.compose);a.start(),f(a),b.current.onRuntime(a);let o=a.view.subscribe(e=>{v(e.scale),e.panning?m(null):m(e=>e&&c.current?rt(c.current,n,e.id):e)}),s=Je(a),l=window;return s&&(l.__sf={...s,joints:e.joints,select:e=>b.current.onSelect(e),showTag:e=>c.current&&m(rt(c.current,n,e))}),()=>{o(),a.dispose(),b.current.onRuntime(null),s&&delete l.__sf}},[e,t,r]),(0,N.useEffect)(()=>{let e=u.current;e&&it(e,`data-selected`,a)},[a]),(0,N.useEffect)(()=>{let e=u.current;if(e&&it(e,`data-hover`,p?.id??null),!p)return;let t=setInterval(()=>y(e=>e+1),tt);return()=>clearInterval(t)},[p?.id,p]);let x=(0,N.useRef)(null),S=p?i.find(e=>e.key===p.id):void 0,[C,w]=p&&d?d.status(p.id):[``,``],T=l(e=>e.assets),E=i.flatMap(e=>(T.find(t=>t.id===e.assetId)?.activeFaults??[]).map(t=>({thing:e,fault:t})));return(0,P.jsxs)(`section`,{ref:c,"aria-label":`Factory floor`,className:`floor-scene @container relative min-h-0 overflow-hidden bg-background outline-none [background-image:linear-gradient(color-mix(in_srgb,var(--border)_45%,transparent)_1px,transparent_1px),linear-gradient(90deg,color-mix(in_srgb,var(--border)_45%,transparent)_1px,transparent_1px)] [background-size:48px_48px] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,onPointerMove:e=>{let t=c.current,n=u.current;if(!d||!t||!n||t.hasAttribute(`data-panning`))return;let r=d.assetAt(e.clientX,e.clientY);r!==(p?.id??null)&&m(r?rt(t,n,r):null)},onPointerLeave:()=>m(null),onPointerDown:e=>{x.current=[e.clientX,e.clientY]},onClick:e=>{let t=x.current;t&&Math.hypot(e.clientX-t[0],e.clientY-t[1])>et||o(d?.assetAt(e.clientX,e.clientY)??null)},onKeyDown:e=>{e.key===`Escape`&&a&&o(null)},children:[(0,P.jsx)(`svg`,{ref:u,className:`iso-svg floor-svg`,viewBox:`0 0 ${e.width} ${e.height}`,role:`img`,"aria-label":e.label,children:(0,P.jsx)(Ee,{value:e.kit,children:(0,P.jsx)(e.Scene,{ids:t})})}),(0,P.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 flex flex-wrap items-start justify-between gap-x-3 gap-y-2`,children:[(0,P.jsxs)(`p`,{className:`pt-1 pl-1 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:[`Floor `,(0,P.jsx)(`span`,{className:`text-primary`,children:`·`}),` `,n]}),E.length>0?(0,P.jsx)(`ul`,{className:`pointer-events-auto ml-auto flex max-w-full flex-col items-end gap-1.5`,children:E.map(({thing:e,fault:t})=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(e.key)},className:`flex max-w-full items-center gap-2 rounded-[var(--miravo-radius-pill)] border border-destructive/40 bg-background/90 px-2.5 py-1 text-[11px] text-destructive outline-none transition-colors hover:border-destructive/70 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,P.jsx)(`span`,{className:`size-1.5 shrink-0 animate-pulse rounded-full bg-destructive`}),(0,P.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[10px] opacity-80`,children:t.replace(/_/g,` `)})]})},`${e.key}:${t}`))}):null]}),p?(0,P.jsxs)(`div`,{role:`status`,className:`pointer-events-none absolute z-10 flex -translate-x-1/2 -translate-y-full items-center gap-2 whitespace-nowrap rounded-[var(--miravo-radius-pill)] border border-border/80 bg-background/95 px-2.5 py-1 shadow-[0_14px_40px_-20px_#000]`,style:{left:p.x,top:p.y},children:[(0,P.jsx)(`span`,{className:M(`size-1.5 rounded-full`,nt[w]??nt[``])}),(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:S?.name??p.id}),(0,P.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,children:ke(C)})]}):null,h&&p?.id===h?(0,P.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute rounded-[var(--miravo-radius-tight)] ring-2 ring-ring ring-offset-2 ring-offset-background`,style:{left:p.box.left-4,top:p.box.top-4,width:p.box.width+8,height:p.box.height+8}}):null,(0,P.jsx)($e,{things:i,selected:a,label:e=>`${e.name}, ${ke(d?d.status(e.key)[0]:``)}`,onFocusMachine:e=>{g(e);let t=c.current,n=u.current;m(e&&t&&n?rt(t,n,e):null)},onActivate:e=>{o(e),d?.view.flyTo(e)}}),(0,P.jsx)(`p`,{className:`pointer-events-none absolute bottom-3 left-4 hidden text-[10px] text-muted-foreground/80 @3xl:block`,children:`Drag to pan · Ctrl/⌘ + scroll to zoom · Double-click a machine, or Tab to it and press Enter, to fly to it`}),(0,P.jsxs)(`div`,{className:`absolute right-3 bottom-3 flex items-center gap-0.5 rounded-[var(--miravo-radius-stadium-sm)] border border-border/70 bg-background/90 p-0.5`,children:[(0,P.jsx)(ot,{label:`Zoom out`,onClick:()=>d?.view.zoomOut(),children:(0,P.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})}),(0,P.jsxs)(`span`,{className:`min-w-10 text-center font-mono text-[10px] tabular-nums text-muted-foreground`,children:[_.toFixed(1),`×`]}),(0,P.jsx)(ot,{label:`Zoom in`,onClick:()=>d?.view.zoomIn(),children:(0,P.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0})}),(0,P.jsx)(ot,{label:`Fit floor`,onClick:()=>d?.view.fit(),children:(0,P.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0})})]})]})}function ot({label:e,onClick:t,children:n}){return(0,P.jsx)(`button`,{type:`button`,"aria-label":e,title:e,onClick:e=>{e.stopPropagation(),t()},className:`grid size-7 place-items-center rounded-[var(--miravo-radius-tight)] text-muted-foreground outline-none transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:n})}var st=3e3;function ct(e){return e.type===`fault:triggered`?`bg-destructive`:e.type===`fault:cleared`?`bg-success`:`bg-muted-foreground/50`}function lt({assetIds:e,nameOf:t,onSelect:n}){let r=S({queryKey:u.events(`all`,``),queryFn:()=>c(ye(`all`,``,null),i.events),refetchInterval:st}),a=new Date,o=(r.data?.events??[]).filter(t=>{if(ge(t))return!1;let n=ve(t);return n===void 0||e.has(n)});return(0,P.jsxs)(`div`,{className:`flex flex-col`,children:[o.length===0?(0,P.jsx)(`p`,{className:`px-4 py-6 text-xs text-muted-foreground`,children:r.isPending?`Loading events…`:`No events yet. Inject a fault to see one here.`}):(0,P.jsx)(`ol`,{className:`flex flex-col px-2 py-2`,children:o.map(e=>{let r=ve(e),i=_e(e);return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&n(r),className:`flex w-full items-start gap-2.5 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left outline-none transition-colors enabled:hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,P.jsx)(`span`,{className:M(`mt-1.5 size-1.5 shrink-0 rounded-full`,ct(e))}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,P.jsxs)(`span`,{className:`truncate text-xs`,children:[(0,P.jsx)(`span`,{className:`text-foreground`,children:r?t(r):`Engine`}),(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,k(e.type.replace(/[:-]/g,`_`))]})]}),i?(0,P.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:i}):null]}),(0,P.jsx)(`time`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums`,children:he(e.timestamp,a)})]})},e.id)})}),(0,P.jsx)(`div`,{className:`border-t border-border/50 px-4 py-3`,children:(0,P.jsxs)(E,{to:`/events`,className:A({size:`sm`,variant:`ghost`,className:`-ml-2 gap-1`}),children:[`All events`,(0,P.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0})]})})]})}function ut(e){return(typeof e==`number`||typeof e==`string`)&&e!==``}function dt(e){let t=(0,N.useId)();return ut(e)?`${e}`:t}var F=typeof window<`u`?N.useLayoutEffect:N.useEffect;function I(e){let t=(0,N.useRef)(e);return F(()=>{t.current=e},[e]),(0,N.useCallback)((...e)=>t.current?.(...e),[t])}function ft(...e){return I(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function pt(e,t){let n=e?.[`data-testid`];return ut(n)?`${n}`:ut(t)?`${t}`:void 0}function mt(e,t){return t?e*2+1:e+1}function ht(e,t){return t?e*2-1:e}function gt(e,t,n){let r=mt(e,n);return t===void 0?`${r} / -1`:`${r} / span ${ht(t,n)}`}function _t(e){return`${e*2} / span 1`}function vt({crossCount:e,crossSpan:t,crossStart:n,hasGutters:r}){let i=t===void 0?e:n+t;if(n===0&&i===e)return`1 / -1`;let a=mt(n,r),o=mt(i-1,r)+1;return r&&(n>0&&a--,i<e&&o++),`${a} / ${o}`}function yt(e,t){return Number.isInteger(e)&&e>=1&&e<t}function L(e,t=`Assertion error`){if(!e)throw Error(t)}var bt=(0,N.createContext)(null);function xt(){let e=(0,N.useContext)(bt);return L(e,`Grid Context not found; did you render a Cell or Gridline outside of a Grid?`),e}function St({children:e,className:t,column:n,columnSpan:r=1,elementRef:i,id:a,row:o,rowSpan:s=1,style:c,...l}){let u=dt(a),{gutters:d,registerCell:f}=xt(),p=(0,N.useRef)(null),m=ft(p,i);return F(()=>{let e=p.current;if(e!==null)return f({column:n,columnSpan:r,element:e,id:u,row:o,rowSpan:s})},[n,r,u,f,o,s]),(0,P.jsx)(`div`,{...l,className:t,"data-cell":!0,"data-testid":pt(l,a),id:u,ref:m,style:{overflow:`auto`,...c,minHeight:0,minWidth:0,gridColumn:gt(n,r,d.column),gridRow:gt(o,s,d.row)},children:e})}St.displayName=`Cell`;var Ct;function wt(){return Ct===void 0&&(Ct=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Ct}function Tt({expandHitTargets:e,axis:t,rect:n}){let r=e?wt()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<r){let e=r-n.width;n=new DOMRect(n.x-e/2,n.y,n.width+e,n.height)}if(n.height<r){let e=r-n.height;n=new DOMRect(n.x,n.y-e/2,n.width,n.height+e)}return n}function Et({axis:e,cells:t,index:n,rect:r}){let i=[r];for(let r of t){let t=e===`column`?r.column:r.row,a=e===`column`?r.columnSpan:r.rowSpan;if(t>=n||t+a<=n)continue;let o=r.element.getBoundingClientRect(),s=e===`column`?o.top:o.left,c=e===`column`?o.bottom:o.right;c<=s||(i=i.flatMap(t=>{let n=e===`column`?t.top:t.left,r=e===`column`?t.bottom:t.right;if(s>=r||c<=n)return[t];let i=[],a=(n,r)=>{i.push(e===`column`?new DOMRect(t.x,n,t.width,r-n):new DOMRect(n,t.y,r-n,t.height))};return n<s&&a(n,s),r>c&&a(c,r),i}))}return i}function Dt({axis:e,cells:t,crossTrackCount:n,expandHitTargets:r,resizeAxis:i,axisSize:a,includeDisabled:o,separatorPlacements:s}){let{items:c,separators:l}=i,u=c.length,d=-1,f=-1,p=0;if(c.forEach((e,t)=>{e.constraintProps.disabled||(p++,d===-1&&(d=t),f=t)}),!o&&p<2)return[];let m=e=>o||e>d&&e<=f,h=[],g=(e,t,n)=>({axis:i,axisSize:a,items:[c[e-1],c[e]],rect:t,separator:n}),_=(n,r)=>{let i;for(let a of t){let t=e===`column`?a.row:a.column,o=e===`column`?a.rowSpan:a.columnSpan;if(r===`start`?t===n:t+o-1===n){let t=a.element.getBoundingClientRect();if(r===`start`){let n=e===`column`?t.top:t.left;i=i===void 0?n:Math.min(i,n)}else{let n=e===`column`?t.bottom:t.right;i=i===void 0?n:Math.max(i,n)}}}return i},v=new Set;for(let a of l){let c=s.get(a);if(!c||c.index<1||c.index>=u||(v.add(c.index),!o&&(a.disabled||a.element.hasAttribute(`aria-disabled`)))||!m(c.index))continue;let l=a.element.getBoundingClientRect(),{crossSpan:d,crossStart:f}=c,p=d===void 0?n:f+d,y=e===`column`?l.top:l.left,b=e===`column`?l.bottom:l.right;if(f>0){let e=_(f-1,`end`);e!==void 0&&e<y&&(y=e)}if(p<n){let e=_(p,`start`);e!==void 0&&e>b&&(b=e)}l=e===`column`?new DOMRect(l.x,y,l.width,b-y):new DOMRect(y,l.y,b-y,l.height),l=Tt({expandHitTargets:r,axis:i,rect:l}),o?h.push(g(c.index,l,a)):Et({axis:e,cells:t,index:c.index,rect:l}).forEach(e=>{h.push(g(c.index,e,a))})}let y=(n,a)=>{Et({axis:e,cells:t,index:n,rect:Tt({expandHitTargets:r,axis:i,rect:a})}).forEach(e=>{h.push(g(n,e))})},b=Array.from({length:n},()=>Array(u));for(let r of t){let[t,i,a,o]=e===`column`?[r.column,r.columnSpan,r.row,r.rowSpan]:[r.row,r.rowSpan,r.column,r.columnSpan];for(let e=Math.max(0,a);e<Math.min(n,a+o);e++)for(let n=Math.max(0,t);n<Math.min(u,t+i);n++)b[e][n]??=r}let x=new Map,S=t=>{let n=x.get(t);if(!n){let r=t.element.getBoundingClientRect();n=e===`column`?{crossEnd:r.bottom,crossStart:r.top,end:r.right,start:r.left}:{crossEnd:r.right,crossStart:r.left,end:r.bottom,start:r.top},x.set(t,n)}return n},C=({crossEnd:t,crossStart:n,end:r,start:i})=>e===`column`?new DOMRect(i,n,r-i,t-n):new DOMRect(n,i,t-n,r-i);for(let e=1;e<u;e++){if(v.has(e)||!m(e))continue;let t;for(let r=0;r<n;r++){let n=b[r][e-1],i=b[r][e],a;if((n||i)&&n!==i){let e=n?S(n):void 0,t=i?S(i):void 0,r=e?.end??t.start,o=t?.start??e.end,s=Math.max(e?.crossStart??-1/0,t?.crossStart??-1/0),c=Math.min(e?.crossEnd??1/0,t?.crossEnd??1/0);a={crossEnd:Math.max(s,c),crossStart:s,end:Math.max(r,o),start:Math.min(r,o)}}a?t=t?{crossEnd:Math.max(t.crossEnd,a.crossEnd),crossStart:Math.min(t.crossStart,a.crossStart),end:Math.max(t.end,a.end),start:Math.min(t.start,a.start)}:a:t&&=(y(e,C(t)),void 0)}t&&y(e,C(t))}return h}function R(e){let t=parseFloat(e??``);return Number.isFinite(t)?t:0}function Ot({axis:e,element:t,gutterSizes:n,hasGutters:r,layout:i,trackIds:a}){let o=a.length,s=r?o*2-1:o,c=t.ownerDocument.defaultView?.getComputedStyle(t),l=e===`column`?c?.gridTemplateColumns:c?.gridTemplateRows;if(l){let e=l.trim().split(/\s+/);if(e.length===s&&e.every(e=>/^-?[\d.]+px$/.test(e))){let t=a.map((t,n)=>R(e[r?n*2:n]));return{availableSize:t.reduce((e,t)=>e+t,0),trackSizes:t}}}let u=e===`column`?t.offsetWidth:t.offsetHeight,d=e===`column`?R(c?.paddingLeft)+R(c?.paddingRight)+R(c?.borderLeftWidth)+R(c?.borderRightWidth):R(c?.paddingTop)+R(c?.paddingBottom)+R(c?.borderTopWidth)+R(c?.borderBottomWidth),f=R(e===`column`?c?.columnGap:c?.rowGap),p=n.reduce((e,t)=>e+t,0),m=Math.max(0,u-d-f*Math.max(0,s-1)-p);return{availableSize:m,trackSizes:a.map(e=>i&&i[e]!==void 0?i[e]/100*m:m/o)}}function kt(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}var At=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0){if(n.length===1){n[0].call(null,t);return}let e,r=Array.from(n);for(let n=0;n<r.length;n++){let i=r[n];try{i.call(null,t)}catch(t){e??={error:t}}}if(e)throw e.error}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},z={cursorFlags:0,state:`inactive`},jt=new At;function B(){return z}function Mt(e){return jt.addListener(`change`,e)}function Nt(e,t=[],n,r=!1){let i=z,a={...z};a.cursorFlags=e,a.state===`active`&&(a.didPointerMove||=r,a.previews=t,n&&(a.previewLayoutMap=n)),z=a,jt.emit(`change`,{prev:i,next:a})}function V(e){let t=z;z=e,t.state===`active`&&e.state!==`active`&&t.didPointerMove&&t.hitRegions.forEach(({separator:e})=>{e&&e.element.ownerDocument.activeElement===e.element&&e.element.blur()}),jt.emit(`change`,{prev:t,next:e})}function Pt(e){z.state!==`active`||!z.previews.some(t=>t.separator===e)||V({...z,previews:z.previews.map(t=>t.separator===e?{...t}:t)})}function Ft(e){if(z.state===`inactive`)return;let t=z.hitRegions.filter(t=>t.axis!==e),n=z.state===`active`&&z.previews.some(t=>t.axis===e);if(!(t.length===z.hitRegions.length&&!n))if(t.length===0)V({cursorFlags:0,state:`inactive`});else if(z.state===`active`){let n=new Map(z.initialLayoutMap),r=new Map(z.previewLayoutMap);n.delete(e),r.delete(e),V({...z,cursorFlags:0,hitRegions:t,initialLayoutMap:n,previewLayoutMap:r,previews:z.previews.filter(t=>t.axis!==e)})}else V({...z,hitRegions:t})}var It=e=>e,Lt=()=>{},Rt=1,zt=2,Bt=4,Vt=8,Ht=3,Ut=12,Wt;function Gt(){return Wt===void 0&&(Wt=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Wt=!0)),Wt}function Kt({cursorFlags:e,axes:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&Gt()){let t=(e&Rt)!==0,n=(e&zt)!==0,r=(e&Bt)!==0,i=(e&Vt)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return Gt()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var qt=new WeakMap;function Jt(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=qt.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=B();switch(r.state!==`inactive`&&r.ownerDocument!==e&&(r={cursorFlags:0,state:`inactive`}),r.state){case`active`:case`hover`:{let e=Kt({cursorFlags:r.cursorFlags,axes:r.hitRegions.map(e=>e.axis),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}qt.set(e,{prevStyle:t,styleSheet:n})}function Yt(e){return e.state===`inactive`?void 0:e.ownerDocument}function Xt({next:e,prev:t}){let n=Yt(t),r=Yt(e);n&&n!==r&&Jt(n),r&&Jt(r)}function Zt({axis:e}){let{layoutStrategy:t,orientation:n,items:r}=e;return t?t.calculateAvailableSize():r.reduce((e,t)=>(e+=n===`horizontal`?t.element.offsetWidth:t.element.offsetHeight,e),0)}function Qt(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function $t(e,t){return Array.from(t).sort((t,n)=>{let r=e===`horizontal`?en(t,n):tn(t,n);return r===0?Qt(t.element,n.element):r})}function en(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function tn(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function nn(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function rn(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function an({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=rn(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return L(i,`No rect found`),i}function on({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});let{element:r,orientation:i,items:a,separators:o}=t,s=$t(i,Array.from(r.children).filter(nn).filter(e=>!e.hasAttribute(`data-resize-preview`)).map(e=>({element:e}))).map(({element:e})=>e),c=[],l=!1,u=!1,d=-1,f,p=-1,m=0,h,g=[];{let e=-1;for(let t of s)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(m++,d===-1&&(d=e),p=e))}if(n||m>1){let r=-1;for(let m of s)if(m.hasAttribute(`data-panel`)){r++;let o=a.find(e=>e.element===m);if(o){if(h){let a=h.element.getBoundingClientRect(),s=m.getBoundingClientRect(),_;if(u){let e=i===`horizontal`?new DOMRect(a.right,a.top,0,a.height):new DOMRect(a.left,a.bottom,a.width,0),t=i===`horizontal`?new DOMRect(s.left,s.top,0,s.height):new DOMRect(s.left,s.top,s.width,0);switch(g.length){case 0:_=[e,t];break;case 1:{let n=g[0];_=[n,an({orientation:i,rects:[a,s],targetRect:n.element.getBoundingClientRect()})===a?t:e];break}default:_=g;break}}else _=g.length?g:[i===`horizontal`?new DOMRect(a.right,s.top,s.left-a.right,s.height):new DOMRect(s.left,a.bottom,s.width,s.top-a.bottom)];for(let i of _){let a=Tt({expandHitTargets:e,axis:t,rect:`width`in i?i:i.element.getBoundingClientRect()});(n||!l&&!(r<=d||r>p))&&(f??=Zt({axis:t}),c.push({axis:t,axisSize:f,items:[h,o],separator:`width`in i?void 0:i,rect:a})),l=!1}}u=!1,h=o,g=[]}}else if(m.hasAttribute(`data-separator`)){m.ariaDisabled!==null&&(l=!0);let e=o.find(e=>e.element===m);e?g.push(e):(h=void 0,g=[])}else u=!0}return c}function sn(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function cn(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function ln(e){return e/100*window.innerHeight}function un(e){return e/100*window.innerWidth}function H({axisSize:e,itemElement:t,styleProp:n}){let r,[i,a]=kt(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=cn(t,i);break;case`em`:r=sn(t,i);break;case`vh`:r=ln(i);break;case`vw`:r=un(i);break}return r}function U(e){return parseFloat(e.toFixed(3))}function dn(e){let{items:t}=e,n=Zt({axis:e});return n===0?t.map(e=>({groupResizeBehavior:e.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:e.constraintProps.collapsible===!0,defaultSize:void 0,disabled:e.constraintProps.disabled,minSize:0,maxSize:100,itemId:e.id})):t.map(e=>{let{element:t,constraintProps:r}=e,i=0;r.collapsedSize!==void 0&&(i=U(H({axisSize:n,itemElement:t,styleProp:r.collapsedSize})/n*100));let a;r.collapsedThreshold!==void 0&&(a=U(H({axisSize:n,itemElement:t,styleProp:r.collapsedThreshold})/n*100));let o;r.defaultSize!==void 0&&(o=U(H({axisSize:n,itemElement:t,styleProp:r.defaultSize})/n*100));let s=0;r.minSize!==void 0&&(s=U(H({axisSize:n,itemElement:t,styleProp:r.minSize})/n*100));let c=100;return r.maxSize!==void 0&&(c=U(H({axisSize:n,itemElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:o,disabled:r.disabled,minSize:s,maxSize:c,itemId:e.id}})}var W=new Map,fn=new At,pn=0,mn=[],hn;function gn(){pn++}function _n(){for(let e=0;e<mn.length;e++)try{fn.emit(`axisChange`,mn[e])}catch(e){hn??={error:e}}mn.length=0}function vn(){if(pn===1&&_n(),pn--,pn===0&&hn){let{error:e}=hn;throw hn=void 0,e}}function yn(e){W=new Map(W),W.delete(e)}function bn(e,t){for(let[t]of W)if(t.id===e)return t}function G(e,t){for(let[t,n]of W)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function K(){return W}function xn(e,t){return fn.addListener(`axisChange`,n=>{n.axis.id===e&&t(n)})}function q(e,t,n){let r=W.get(e);W=new Map(W),W.set(e,t);let i={axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t};pn>0?mn.push(i):fn.emit(`axisChange`,i)}function Sn(e,{pointerId:t,pointerType:n}){return t===e.pointerId||n===`pen`&&e.pointerType===`pen`}function Cn(e,t,n={}){return e.ownerDocument===t&&(n.pointerId===void 0||Sn(e,n))}function wn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function J(e,t,n=0){return Math.abs(U(e)-U(t))<=n}function Y(e,t){return J(e,t)?0:e>t?1:-1}function Tn({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsedThreshold:a,collapsible:o,disabled:s,maxSize:c=100,minSize:l=0}=t;if(s&&!e)return n;if(Y(r,l)<0)if(o){let e=a??(l-i)/2,t=Y(n,i)<=0,o=t?i+e:l-e,s=Y(r,o);r=Y(r,i)<=0||s<0||a!==void 0&&t&&s===0?i:l}else r=l;return r=Math.min(c,r),r=U(r),r}function En({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(J(e,0))return t;let o=a===`imperative-api`,s=n.map(({itemId:e})=>t[e]),c=n.map(({itemId:e})=>i[e]),l=[...s],[u,d]=r;L(u!=null,`Invalid first pivot index`),L(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];L(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(L(n!=null,`Previous layout not found for panel index ${t}`),J(n,i)){let t=o-n;Y(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];L(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(L(n!=null,`Previous layout not found for panel index ${t}`),J(n,o)){let t=n-i;Y(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];L(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsedSize:a,collapsedThreshold:o,collapsible:c,minSize:l}=r;if(c&&Y(i,l)<0){let t=l-a,n=o??t/2;if(Y(i+Math.abs(e),l)<0){let r=Y(Math.abs(e),n);e=r>0||r===0&&o===void 0&&e<0?e<0?-t:t:0}}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];L(e!=null,`Previous layout not found for panel index ${r}`);let a=Tn({overrideDisabledItems:o,itemConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];L(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Tn({overrideDisabledItems:o,itemConstraints:n[t],prevSize:i,size:a});if(!J(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(wn(c,l))return i;{let t=e<0?d:u,r=s[t];L(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Tn({overrideDisabledItems:o,itemConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!J(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];L(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Tn({overrideDisabledItems:o,itemConstraints:n[r],prevSize:i,size:a});if(J(i,s)||(t-=s-i,l[r]=s),J(t,0))break;e>0?r--:r++}}}return J(Object.values(l).reduce((e,t)=>t+e,0),100,.1)?l.reduce((e,t,r)=>(e[n[r].itemId]=t,e),{}):i}function X(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Y(e[n],t[n])!==0)return!1;return!0}function Dn(e){gn();try{On(e)}finally{vn()}}function On({commit:e,event:t,hitRegions:n,initialLayoutMap:r,mountedAxes:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=B(),l=c.state===`active`?c.previews:[],u=new Map(c.state===`active`?c.previewLayoutMap:void 0);n.forEach(n=>{let{axis:o,axisSize:c}=n,{orientation:d,items:f}=o;if(e&&o.resizePreviewMode!==`separator`)return;let{disableCursor:p}=o.mutableState,m=0;m=a?d===`horizontal`?(t.clientX-a.x)/c*100:(t.clientY-a.y)/c*100:d===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let h=r.get(o),g=i.get(o);if(!h||!g)return;let{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:b,separatorToItems:x}=g;if(v&&b&&x){let t=o.resizePreviewMode===`separator`?u.get(o)??b:b,r=En({delta:m,initialLayout:h,itemConstraints:v,pivotIndices:n.items.map(e=>f.indexOf(e)),prevLayout:t,trigger:`mouse-or-touch`});if(o.resizePreviewMode===`separator`&&!e&&!X(r,t)){u.set(o,r);let e=0,t=f.map(t=>(e+=r[t.id]-h[t.id],c/100*e));l=l.map(e=>{if(e.axis!==o)return e;let n=t[e.itemIndex];return n===e.offset?e:{...e,offset:n}})}if(X(r,t)&&m!==0&&!p)switch(d){case`horizontal`:s|=m<0?Rt:zt;break;case`vertical`:s|=m<0?Bt:Vt;break}(o.resizePreviewMode!==`separator`||e)&&!X(r,b)&&q(n.axis,{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:r,requestedAxisSize:y,requestedLayout:r,separatorToItems:x})}});let d=0;t.movementX===0?d|=o&Ht:d|=s&Ht,t.movementY===0?d|=o&Ut:d|=s&Ut;let f=c.state===`active`&&(t.clientX!==c.pointerDownAtPoint.x||t.clientY!==c.pointerDownAtPoint.y);Nt(d,l,u,f)}function kn(e,t){let n=B();if(n.state!==`active`||!Cn(n,e,t))return;let r=K();gn();try{Dn({commit:!0,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),_n(),V({cursorFlags:0,state:`inactive`}),n.hitRegions.length>0&&(t.preventDefault?.(),n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=G(e.axis.id,!0);q(e.axis,t,{isUserInteraction:!0})}))}finally{vn()}}function An(e){if(e.defaultPrevented)return;let{clientX:t,clientY:n,movementX:r,movementY:i}=e;kn(e.currentTarget,{clientX:t,clientY:n,movementX:r,movementY:i})}function jn(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=rn(n,a.rect);switch(e){case`horizontal`:(t.x<i.x||t.x===i.x&&t.y<=i.y)&&(r=a,i=t);break;case`vertical`:(t.y<i.y||t.y===i.y&&t.x<=i.x)&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Mn(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Nn(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:zn(e),b:zn(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();L(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:Rn(Ln(n.a)),b:Rn(Ln(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Pn=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Fn(e){let t=getComputedStyle(Bn(e)??e).display;return t===`flex`||t===`inline-flex`}function In(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Fn(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Pn.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Ln(e){let t=e.length;for(;t--;){let n=e[t];if(L(n,`Missing node`),In(n))return n}return null}function Rn(e){return e&&Number(getComputedStyle(e).zIndex)||0}function zn(e){let t=[];for(;e;)t.push(e),e=Bn(e);return t}function Bn(e){let{parentNode:t}=e;return Mn(t)?t.host:t}function Vn(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Hn(e){try{return e.matches(`:modal`)}catch{return!1}}function Un({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(nn(n)){let t=n.closest(`dialog`);if(t&&!t.contains(e)&&Hn(t))return!1}if(!nn(n)||n.contains(e)||e.contains(n))return!0;if(Nn(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Vn(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Wn(e,t,n){let r=[];return t.forEach((t,i)=>{if(i.disabled||i.element.ownerDocument!==n)return;let a=on({axis:i}),o=jn(i.orientation,a,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&Un({axisElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&r.push(o.hitRegion)}),r}function Z({layout:e,itemConstraints:t}){let n=t.map(({itemId:t})=>e[t]),r=[...n],i=r.reduce((e,t)=>e+t,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(e=>`${e}%`).join(`, `)}`);if(!J(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];L(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];L(i!=null,`No layout data found for index ${e}`);let o=r[e];L(o!=null,`No layout data found for index ${e}`);let s=Tn({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!J(a,0))for(let e=0;e<t.length;e++){let n=r[e];L(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Tn({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,J(a,0)))break}return r.reduce((e,n,r)=>(e[t[r].itemId]=n,e),{})}function Gn({axisId:e,itemId:t}){let n=()=>{let t=K();for(let[n,{defaultLayoutDeferred:r,derivedItemConstraints:i,layout:a,axisSize:o,separatorToItems:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedItemConstraints:i,axis:n,axisSize:o,layout:a,separatorToItems:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedItemConstraints.find(e=>e.itemId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().axis.items.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,items:n,prevLayout:r,derivedItemConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&J(n.collapsedSize,r[n.itemId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:U(100-e)}}return En({delta:l?o-e:e-o,initialLayout:r,itemConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedItemConstraints:r,axis:i,axisSize:s,layout:c,separatorToItems:l}=n(),u=Z({layout:o({nextSize:e,items:i.items,prevLayout:c,derivedItemConstraints:r}),itemConstraints:r});X(c,u)||q(i,{defaultLayoutDeferred:t,derivedItemConstraints:r,axisSize:s,layout:u,requestedAxisSize:s,requestedLayout:u,separatorToItems:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{axis:e}=n(),r=a(),{element:o}=i();return{asPercentage:r,inPixels:e.layoutStrategy?e.layoutStrategy.getItemSizeInPixels(t):e.orientation===`horizontal`?o.offsetWidth:o.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&J(t,n)},resize:e=>{let{axis:t}=n(),{element:r}=i(),a=Zt({axis:t});s(U(H({axisSize:a,itemElement:r,styleProp:e})/a*100))}}}function Kn(e){e.defaultPrevented||Wn(e,K(),e.currentTarget).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.items.find(e=>e.constraintProps.defaultSize!==void 0);if(n){let r=n.constraintProps.defaultSize,i=Gn({axisId:t.axis.id,itemId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function qn(e){let t=K();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Jn({axisId:e}){let t=()=>{let t=K();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedItemConstraints:r,axis:i,axisSize:a,layout:o,separatorToItems:s}=t(),c=Z({layout:e,itemConstraints:r});return n?o:(X(o,c)||q(i,{defaultLayoutDeferred:n,derivedItemConstraints:r,axisSize:a,layout:c,requestedAxisSize:a,requestedLayout:c,separatorToItems:s}),c)}}}function Q(e,t){let n=qn(e),r=G(n.id,!0),i=n.separators.find(t=>t.element===e);L(i,`Matching separator not found`);let a=r.separatorToItems.get(i);L(a,`Matching panels not found`);let o=a.map(e=>n.items.indexOf(e)),s=Jn({axisId:n.id}).getLayout(),c=Z({layout:En({delta:t,initialLayout:s,itemConstraints:r.derivedItemConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),itemConstraints:r.derivedItemConstraints});X(s,c)||q(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedItemConstraints:r.derivedItemConstraints,axisSize:r.axisSize,layout:c,requestedAxisSize:r.axisSize,requestedLayout:c,separatorToItems:r.separatorToItems},{isUserInteraction:!0})}function Yn(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=qn(t);if(!(n.disabled||n.separators.find(e=>e.element===t)?.disabled))switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Q(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Q(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Q(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Q(t,-5);break;case`End`:e.preventDefault(),Q(t,100);break;case`Enter`:{e.preventDefault();let{derivedItemConstraints:r,layout:i,separatorToItems:a}=G(n.id,!0),o=n.separators.find(e=>e.element===t);L(o,`Matching separator not found`);let s=a.get(o);L(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.itemId===c.id);if(L(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Q(t,(l.collapsedSize===e?n.mutableState.expandedItemSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let t=n.separators.map(e=>e.element),r=Array.from(t).findIndex(t=>t===e.currentTarget);L(r!==null,`Index not found`),t[e.shiftKey?r>0?r-1:t.length-1:r+1<t.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Q(t,-100);break}}function Xn(e,t){let n=B();if(n.state!==`active`||!Cn(n,e,t))return!1;let r=K();gn();try{n.previewLayoutMap.forEach((e,t)=>{let n=r.get(t);t.resizePreviewMode===`separator`&&n&&!X(e,n.layout)&&q(t,{...n,layout:e,requestedAxisSize:n.axisSize,requestedLayout:e})}),_n(),V({cursorFlags:0,state:`inactive`}),n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=G(e.axis.id,!0);q(e.axis,t,{isUserInteraction:!0})})}finally{vn()}return!0}function Zn(e){let t=B();if(t.state!==`active`)return;let n=t.hitRegions.flatMap(({separator:e})=>e?[e.element]:[]);!n.some(t=>t===e.target)||n.some(t=>t.hasPointerCapture?.(e.pointerId))||Xn(e.currentTarget,e)}function Qn(e){Xn(e.currentTarget,e)}function $n(e,t){let{element:n,orientation:r,items:i}=e,a=n.getBoundingClientRect(),o=r===`horizontal`;return on({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:r,rect:s,separator:c},l)=>{let u=i.indexOf(r[0]),d=o?s.left+s.width/2:s.top+s.height/2;return{active:t.some(t=>t.axis!==e||t.items[0]!==r[0]?!1:c||t.separator?t.separator===c:J(d,o?t.rect.left+t.rect.width/2:t.rect.top+t.rect.height/2)),axis:e,key:c?`separator-${c.id}`:`panel-${r[0].id}-${l}`,offset:0,itemIndex:u,rect:new DOMRect((o&&!c?d:s.left)-a.left-n.clientLeft+n.scrollLeft,(!o&&!c?d:s.top)-a.top-n.clientTop+n.scrollTop,o&&!c?0:s.width,!o&&!c?0:s.height),separator:c}})}function er(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=B();if(t.state===`active`){Sn(t,e)&&Xn(t.ownerDocument,t);return}let n=K(),r=Wn(e,n,e.currentTarget);if(r.length===0)return;let i=new Map,a=!1;r.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let t=n.get(e.axis);t&&i.set(e.axis,t.layout)});let o=Array.from(i.keys()).flatMap(e=>e.resizePreviewMode===`separator`?$n(e,r):[]);V({cursorFlags:0,didPointerMove:!1,hitRegions:r,initialLayoutMap:i,ownerDocument:e.currentTarget,pointerDownAtPoint:{x:e.clientX,y:e.clientY},pointerId:e.pointerId,pointerType:e.pointerType,previewLayoutMap:new Map(i),previews:o,state:`active`}),e.preventDefault()}function tr(e){let t=e.currentTarget,n=K(),r=B();switch(r.state){case`active`:if(!Cn(r,t,e))return;Dn({commit:!1,event:e,hitRegions:r.hitRegions,initialLayoutMap:r.initialLayoutMap,mountedAxes:n,prevCursorFlags:r.cursorFlags})}}function nr(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=B(),r=K();switch(n.state){case`active`:if(!Cn(n,t,e))return;if(e.buttons===0){Xn(t,e);return}for(let t of n.hitRegions)if(t.separator){let{element:n}=t.separator;n.isConnected&&!n.hasPointerCapture?.(e.pointerId)&&n.setPointerCapture?.(e.pointerId)}Dn({commit:!1,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags});break;default:{let i=Wn(e,r,t);i.length===0?n.state!==`inactive`&&V({cursorFlags:0,state:`inactive`}):V({cursorFlags:0,hitRegions:i,ownerDocument:t,state:`hover`});break}}}function rr(e){if(e.relatedTarget instanceof HTMLIFrameElement){let t=B();switch(t.state){case`hover`:t.ownerDocument===e.currentTarget&&V({cursorFlags:0,state:`inactive`})}}}function ir(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||kn(e.currentTarget,e)}function ar(e){e.target===e.currentTarget&&Xn(e.currentTarget.document)}function or(e){Xn(e.currentTarget.document)}function sr(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=U(i.defaultSize);n+=e,r[i.itemId]=e}else r[i.itemId]=void 0;let i=e.length-t;if(i!==0){let t=U((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.itemId]=t)}return r}function cr(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}function lr({axis:e,itemConstraints:t}){let n=e.items.map(({id:e})=>e).join(`,`),r=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(r&&cr(e.items,r)?r:sr(t))}function ur({itemIds:e,layout:t}){return Z({layout:t,itemConstraints:e.map(e=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:e,maxSize:100,minSize:0}))})}function dr(e,t,n){if(!n[0])return;let r=e.items.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Zt({axis:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:U(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function fr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function pr(e,t){return e.length===t.length?e.every((e,n)=>fr(e,t[n])):!1}function mr({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.items){let e=r[l.id]??0;switch(l.constraintProps.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=U(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=U((r[e]??0)/a*l);else{let e=U(l/c.length);for(let t of c)u[t]=e}return u}var hr=new Map,gr=!1;function _r(e){let t=!0;L(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{let r;gn();try{for(let i of n){let{borderBoxSize:n,target:a}=i;if(a===e.element){if(t){let t=Zt({axis:e});if(t===0)break;let n=G(e.id);if(!n)break;let r=dn(e),i=n.requestedAxisSize,a=n.requestedLayout;n.defaultLayoutDeferred&&(i=t,a=ur({itemIds:e.items.map(({id:e})=>e),layout:lr({axis:e,itemConstraints:r})}));let o=Z({layout:mr({axis:e,nextAxisSize:t,prevAxisSize:i,prevLayout:a}),itemConstraints:r});if(!n.defaultLayoutDeferred&&X(n.layout,o)&&pr(n.derivedItemConstraints,r)&&n.axisSize===t)continue;q(e,{defaultLayoutDeferred:!1,derivedItemConstraints:r,axisSize:t,layout:o,requestedAxisSize:i,requestedLayout:a,separatorToItems:n.separatorToItems})}}else try{dr(e,a,n)}catch(e){r??={error:e}}}}finally{vn()}if(r)throw r.error});a.observe(e.element),e.items.forEach(e=>{L(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Zt({axis:e}),s=dn(e),c=lr({axis:e,itemConstraints:s}),l=Z({layout:c,itemConstraints:s}),u=e.element.ownerDocument,d=u.defaultView;hr.set(u,(hr.get(u)??0)+1);let f=new Map;return on({axis:e,includeDisabled:!0}).forEach(e=>{e.separator&&f.set(e.separator,e.items)}),q(e,{defaultLayoutDeferred:o===0,derivedItemConstraints:s,axisSize:o,layout:l,requestedAxisSize:o,requestedLayout:ur({itemIds:e.items.map(({id:e})=>e),layout:c}),separatorToItems:f}),e.separators.forEach(e=>{L(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Yn)}),gr||(gr=!0,Mt(Xt)),hr.get(u)===1&&(u.addEventListener(`contextmenu`,An,!0),u.addEventListener(`dblclick`,Kn,!0),u.addEventListener(`lostpointercapture`,Zn,!0),u.addEventListener(`pointercancel`,Qn,!0),u.addEventListener(`pointerdown`,er,!0),u.addEventListener(`pointerleave`,tr),u.addEventListener(`pointermove`,nr),u.addEventListener(`pointerout`,rr),u.addEventListener(`pointerup`,ir,!0),d?.addEventListener(`blur`,ar),d?.addEventListener(`pagehide`,or)),function(){t=!1,hr.set(u,Math.max(0,(hr.get(u)??0)-1)),yn(e),Ft(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Yn)}),hr.get(u)||(u.removeEventListener(`contextmenu`,An,!0),u.removeEventListener(`dblclick`,Kn,!0),u.removeEventListener(`lostpointercapture`,Zn,!0),u.removeEventListener(`pointercancel`,Qn,!0),u.removeEventListener(`pointerdown`,er,!0),u.removeEventListener(`pointerleave`,tr),u.removeEventListener(`pointermove`,nr),u.removeEventListener(`pointerout`,rr),u.removeEventListener(`pointerup`,ir,!0),d?.removeEventListener(`blur`,ar),d?.removeEventListener(`pagehide`,or)),a.disconnect()}}function vr({derivedItemConstraints:e,axis:t,layout:n,prevLayout:r,requestedLayout:i}){let a=t.items.map(({id:e})=>e).join(`,`);t.mutableState.layouts[a]=i,r&&e.forEach(e=>{if(e.collapsible){let i=J(e.collapsedSize,n[e.itemId]),a=J(e.collapsedSize,r[e.itemId]);i&&!a&&(t.mutableState.expandedItemSizes[e.itemId]=r[e.itemId])}})}function yr(){let[e,t]=(0,N.useState)({});return[e,(0,N.useCallback)(()=>t({}),[])]}function br(e){let t=(0,N.useRef)({...e});return F(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var xr=(0,N.createContext)(null);function Sr({layout:e,itemConstraints:t,itemId:n,itemIndex:r}){let i,a,o=e[n],s=t.find(e=>e.itemId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Z({layout:En({delta:l-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],i=Z({layout:En({delta:c-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Cr({attributes:e,axisId:t,axisOrientation:n,children:r,className:i,"data-testid":a,disableCursor:o,disabled:s,disableDoubleClick:c,elementRef:l,id:u,isSharedHitRegion:d,preview:f,registerSeparator:p,requiredStyle:m,style:h,styleDefaults:g,tabIndex:_=0,updateSeparatorProps:v}){let y=br({disabled:s,disableDoubleClick:c,children:r,className:i,preview:f,style:h}),[b,x]=(0,N.useState)({}),[S,C]=(0,N.useState)(`inactive`),[w,T]=(0,N.useState)(!1),E=(0,N.useRef)(null),D=(0,N.useRef)(null),O=ft(E,l),k=n===`horizontal`?`vertical`:`horizontal`;F(()=>{let e=E.current;if(e!==null){let n={disabled:y.disabled,disableDoubleClick:y.disableDoubleClick,element:e,id:u,get children(){return y.children},get className(){return y.className},get preview(){return y.preview},get style(){return y.style}};D.current=n;let r=p(n),i=Mt(e=>{C(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===n||(d?.(e)??!1))?e.next.state:`inactive`)}),a=xn(t,e=>{let{derivedItemConstraints:t,layout:r,separatorToItems:i}=e.next,a=i.get(n);if(a){let n=a[0],i=t.findIndex(e=>e.itemId===n.id),{layoutStrategy:o}=e.axis;x({...Sr({layout:r,itemConstraints:t,itemId:n.id,itemIndex:i}),...o?.getItemAriaControls&&{valueControls:o.getItemAriaControls(n.id)}})}});return()=>{D.current=null,i(),a(),r()}}},[t,u,d,p,y]),F(()=>{let e=D.current;e&&Pt(e)},[f]),(0,N.useEffect)(()=>{v(u,{disabled:s,disableDoubleClick:c})},[s,c,u,v]);let A;s&&!o&&(A=`not-allowed`);let j;if(s)j=`disabled`;else switch(S){case`active`:j=`active`;break;default:j=w?`focus`:S}return(0,P.jsx)(`div`,{...e,"aria-controls":b.valueControls,"aria-disabled":s||void 0,"aria-orientation":k,"aria-valuemax":b.valueMax,"aria-valuemin":b.valueMin,"aria-valuenow":b.valueNow,children:r,className:i,"data-separator":j,"data-testid":a,id:u,onBlur:()=>T(!1),onFocus:()=>T(!0),ref:O,role:`separator`,style:{...g,cursor:A,...h,...m,touchAction:`none`},tabIndex:s?void 0:_})}function wr({axis:e,children:t,className:n,crossSpan:r,crossStart:i,disabled:a,elementRef:o,index:s,style:c}){let l=dt(void 0),{getDisableCursor:u,getResizeAxisId:d,gutters:f,registerSeparator:p,separatorPlacements:m,trackCounts:h,updateSeparatorProps:g}=xt(),_=d(e),v=e===`column`?`row`:`column`,y=h[v],b=!!a||!yt(s,h[e]),x=!0;for(let t of m.values())if(t.axis===e&&t.index===s&&!t.disabled&&t.crossStart<i){x=!1;break}let S=(0,N.useCallback)(e=>e.axis.id===_&&e.axis.items.indexOf(e.items[1])===s,[_,s]),C=(0,N.useCallback)(t=>p({axis:e,crossSpan:r,crossStart:i,disabled:!!a,index:s},t),[e,r,i,a,s,p]),w=_t(s),T=vt({crossCount:y,crossSpan:r,crossStart:i,hasGutters:f[v]});return(0,P.jsx)(Cr,{axisId:_,axisOrientation:e===`column`?`horizontal`:`vertical`,className:n,disableCursor:u(),disabled:b,disableDoubleClick:void 0,elementRef:o,id:l,isSharedHitRegion:S,registerSeparator:C,requiredStyle:{gridColumn:e===`column`?w:T,gridRow:e===`row`?w:T},style:c,tabIndex:x?0:-1,updateSeparatorProps:g,children:t})}function Tr(e){let{children:t,className:n,disabled:r,elementRef:i,style:a}=e;return e.type===`column`?(0,P.jsx)(wr,{axis:`column`,className:n,crossSpan:e.rowSpan,crossStart:e.row??0,disabled:r,elementRef:i,index:e.column,style:a,children:t}):(0,P.jsx)(wr,{axis:`row`,className:n,crossSpan:e.columnSpan,crossStart:e.column??0,disabled:r,elementRef:i,index:e.row,style:a,children:t})}Tr.displayName=`Gridline`;var $=[`column`,`row`],Er={columns:{},rows:{}};function Dr({children:e,className:t,columns:n,defaultLayout:r,disableCursor:i,disabled:a,elementRef:o,gridRef:s,id:c,onLayoutChange:l,onLayoutChanged:u,resizeTargetMinimumSize:d={coarse:20,fine:10},rows:f,style:p,...m}){let h=dt(c),g=(0,N.useCallback)(e=>e===`column`?`${h}:columns`:`${h}:rows`,[h]),_=Or(n,`columns`),v=Or(f,`rows`),y=e=>e===`column`?_:v,b=(0,N.useRef)({onLayoutChange:Er,onLayoutChanged:Er}),x=I(e=>{Mr(b.current.onLayoutChange,e)||(b.current.onLayoutChange=e,l?.(e))}),S=I((e,t,n)=>{Mr(b.current.onLayoutChanged,e)||(b.current.onLayoutChanged=e,u?.(e,{isUserInteraction:t,requestedLayout:n}))}),C=(0,N.useRef)(null),w=ft(C,o),[T,E]=yr(),D=(0,N.useRef)({cells:[],column:{expandedItemSizes:{},layouts:{}},loggedErrors:new Set,row:{expandedItemSizes:{},layouts:{}},separators:new Map}),O={column:!1,row:!1};for(let e of D.current.separators.values())O[e.axis]=!0;kr(e,O);let k=br({defaultLayout:r,disableCursor:i,resizeTargetMinimumSize:d}),A=I(()=>!!k.disableCursor),j=(0,N.useCallback)(e=>{let t=D.current;return t.cells=[...t.cells,e],E(),()=>{t.cells=t.cells.filter(t=>t!==e),E()}},[E]),M=(0,N.useCallback)((e,t)=>{let n=D.current;return n.separators=new Map(n.separators),n.separators.set(t,e),E(),()=>{n.separators=new Map(n.separators),n.separators.delete(t),E()}},[E]),ee=(0,N.useCallback)((e,{disabled:t,disableDoubleClick:n})=>{for(let r of D.current.separators.keys())r.id===e&&(r.disabled=t,r.disableDoubleClick=n)},[]),te=D.current.separators,ne=(0,N.useMemo)(()=>({getDisableCursor:A,getResizeAxisId:g,gutters:{column:O.column,row:O.row},id:h,registerCell:j,registerSeparator:M,separatorPlacements:te,trackCounts:{column:_.length,row:v.length},updateSeparatorProps:ee}),[_.length,A,g,O.column,O.row,h,j,M,v.length,te,ee]),re=(0,N.useRef)([]);F(()=>{let e=C.current;if(e===null)return;let t=D.current,n=jr({cells:t.cells,separatorPlacements:t.separators,trackCounts:{column:_.length,row:v.length}});n.forEach(e=>{t.loggedErrors.has(e)||console.error(e)}),t.loggedErrors=new Set(n);let r=e=>Array.from(t.separators.entries()).filter(([,t])=>t.axis===e).sort(([,e],[,t])=>e.index-t.index).map(([e])=>e),i=$.map(n=>{let i=n===`column`?_:v,o=n===`column`?v:_,s=i.map(e=>e.id),c=g(n),l=r(n),u=l.length>0,d=i.map(({id:t,...n},r)=>({element:e,id:s[r],idIsStable:!0,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:void 0,constraintProps:n})),f=()=>{let r=[];if(u){for(let[e,a]of t.separators)if(a.axis===n&&yt(a.index,i.length)){let t=e.element.getBoundingClientRect();r[a.index]=Math.max(r[a.index]??0,n===`column`?t.width:t.height)}}return Ot({axis:n,element:e,gutterSizes:r.filter(e=>e!==void 0),hasGutters:u,layout:G(c)?.layout,trackIds:s})},p,m=k.defaultLayout?.[n===`column`?`columns`:`rows`];if(m!==void 0&&Object.keys(m).length===s.length){p={};for(let e of s){let t=m[e];t!==void 0&&(p[e]=t)}}return{disabled:!!a,element:e,id:c,layoutStrategy:{getItemAriaControls:e=>{let r=s.indexOf(e);return t.cells.filter(e=>{let t=n===`column`?e.column:e.row,i=n===`column`?e.columnSpan:e.rowSpan;return t<=r&&r<t+i}).map(e=>e.element.id).filter(Boolean).join(` `)||void 0},calculateAvailableSize:()=>f().availableSize,calculateHitRegions:({expandHitTargets:e,axis:r,includeDisabled:i})=>Dt({axis:n,cells:t.cells,crossTrackCount:o.length,expandHitTargets:e,resizeAxis:r,axisSize:f().availableSize,includeDisabled:i,separatorPlacements:t.separators}),getItemSizeInPixels:e=>f().trackSizes[s.indexOf(e)]??0},mutableState:{defaultLayout:p,disableCursor:!!k.disableCursor,expandedItemSizes:t[n].expandedItemSizes,layouts:t[n].layouts},orientation:n===`column`?`horizontal`:`vertical`,items:d,resizePreviewMode:`panel`,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:l}});re.current=i;let o=i.map(e=>_r(e)),s=()=>{let[e,t]=i.map(e=>G(e.id));if(!(!e||!t||e.defaultLayoutDeferred||t.defaultLayoutDeferred))return{layout:{columns:e.layout,rows:t.layout},requestedLayout:{columns:e.requestedLayout,rows:t.requestedLayout}}};{let e=s();if(e)try{try{x(e.layout)}finally{S(e.layout,!1,e.requestedLayout)}}catch(e){throw re.current=[],o.forEach(e=>e()),e}}let c=i.map(e=>xn(e.id,t=>{let{defaultLayoutDeferred:n,derivedItemConstraints:r,layout:a,requestedLayout:o}=t.next;if(n||r.length===0)return;vr({derivedItemConstraints:r,axis:e,layout:a,prevLayout:t.prev?.layout,requestedLayout:o});let c=s();if(c){let e=B(),n=e.state!==`active`||!e.hitRegions.some(e=>i.includes(e.axis));try{x(c.layout)}finally{n&&S(c.layout,t.isUserInteraction,c.requestedLayout)}}}));return()=>{re.current=[],o.forEach(e=>e()),c.forEach(e=>e())}},[_,a,g,h,S,x,v,T,k]),(0,N.useEffect)(()=>{re.current.forEach(e=>{e.mutableState.defaultLayout=r?.[e.orientation===`horizontal`?`columns`:`rows`],e.mutableState.disableCursor=!!i})}),(0,N.useImperativeHandle)(s,()=>{let e=()=>{let[e,t]=$.map(g);return!bn(e)||!bn(t)?{columns:{},rows:{}}:{columns:Jn({axisId:e}).getLayout(),rows:Jn({axisId:t}).getLayout()}},t=e=>e.map(e=>`"${e}"`).join(`, `),n=(e,n)=>{let r=g(e),i=()=>{let i=bn(r);return L(i,`Grid "${h}" has not been mounted`),L(i.items.some(e=>e.id===n),`Grid "${h}" no longer contains a ${e} with id "${n}"; ${e} ids are ${t(i.items.map(e=>e.id))}`),Gn({axisId:r,itemId:n})};return{collapse:()=>i().collapse(),expand:()=>i().expand(),getSize:()=>i().getSize(),isCollapsed:()=>i().isCollapsed(),resize:e=>i().resize(e)}};return{getLayout:e,getTrackById:(e,r)=>{let i=e===`column`?_:v,a=`${r}`;return L(i.some(e=>e.id===a),`Grid "${h}" does not contain a ${e} with id "${a}"; ${e} ids are ${t(i.map(e=>e.id))}`),n(e,a)},getTrackByIndex:(e,t)=>{let r=e===`column`?_:v,i=Number.isInteger(t)?r[t]:void 0;return L(i,`Grid "${h}" does not contain a ${e} at index ${t}; it has ${r.length} ${e}s`),n(e,i.id)},setLayout:t=>($.forEach(e=>{let n=t[e===`column`?`columns`:`rows`],r=g(e);n&&bn(r)&&Jn({axisId:r}).setLayout(n)}),e())}},[_,g,h,v]);let ie=()=>$.map(e=>{let t=G(g(e)),n=y(e);return(t&&!t.defaultLayoutDeferred?n.map(e=>`minmax(0, ${t.layout[e.id]??1}fr)`):Ar(n,r?.[e===`column`?`columns`:`rows`])).join(O[e]?` auto `:` `)}).join(`|`),[ae,oe]=(0,N.useSyncExternalStore)((0,N.useCallback)(e=>{let t=$.map(t=>xn(g(t),e));return()=>t.forEach(e=>e())},[g]),ie,ie).split(`|`);return(0,P.jsx)(bt.Provider,{value:ne,children:(0,P.jsx)(`div`,{...m,className:t,"data-grid":!0,"data-testid":pt(m,c),id:h,ref:w,style:{height:`100%`,width:`100%`,overflow:`hidden`,...p,display:`grid`,gridTemplateColumns:ae,gridTemplateRows:oe,touchAction:`none`},children:(0,P.jsx)(xr.Provider,{value:null,children:e})})})}Dr.displayName=`Grid`;function Or(e,t){let n=JSON.stringify(e);return(0,N.useMemo)(()=>{let r=typeof e==`number`?Array.from({length:e},(e,t)=>({id:`${t}`})):e.map((e,t)=>({...e,id:`${e.id??t}`}));return L(r.length>0,`Grid must have at least one track; "${t}" is ${n}`),r},[n])}function kr(e,t){N.Children.forEach(e,e=>{if((0,N.isValidElement)(e))if(e.type===Tr){let{type:n}=e.props;n===`column`?t.column=!0:n===`row`&&(t.row=!0)}else typeof e.type==`symbol`&&e.props!==null&&typeof e.props==`object`&&`children`in e.props&&kr(e.props.children,t)})}function Ar(e,t){if(t)return e.map(e=>`minmax(0, ${t[e.id]??1}fr)`);let n=e.map(e=>e.defaultSize===void 0?void 0:kt(e.defaultSize)),r=100,i=0;return n.forEach(e=>{e===void 0?i++:e[1]===`%`&&(r-=e[0])}),n.map(e=>{if(e===void 0)return`minmax(0, ${Math.max(0,r)/Math.max(1,i)}fr)`;let[t,n]=e;return n===`%`?`minmax(0, ${t}fr)`:`${t}${n}`})}function jr({cells:e,separatorPlacements:t,trackCounts:n}){let r=[];for(let t of e)$.forEach(e=>{let[i,a]=e===`column`?[t.column,t.columnSpan]:[t.row,t.rowSpan],o=n[e];(!Number.isInteger(i)||!Number.isInteger(a)||i<0||a<1||i+a>o)&&r.push(`Invalid Cell ${e} placement (${e}: ${i}, ${e}Span: ${a}); Grid has ${o} ${e}s`)});let i=({axis:e,crossSpan:t,crossStart:n,disabled:r,index:i})=>{let a=e===`column`?`row`:`column`,o=`type="${e}" ${e}={${i}}`;return(n!==0||t!==void 0)&&(o+=` ${a}={${n}}`),t!==void 0&&(o+=` ${a}Span={${t}}`),r&&(o+=` disabled`),`<Gridline ${o} />`},a=Array.from(t.values()).filter(e=>{let{axis:t,crossSpan:i,crossStart:a,index:o}=e,s=t===`column`?`row`:`column`,c=n[t],l=n[s],u=!0;return yt(o,c)||(r.push(`Invalid ${t} Gridline ${t} (${o}); must be between 1 and ${c-1}`),u=!1),!Number.isInteger(a)||a<0||a>=l?(r.push(`Invalid ${t} Gridline ${s} (${a}); must be between 0 and ${l-1}`),u=!1):i!==void 0&&(!Number.isInteger(i)||i<1||a+i>l)&&(r.push(`Invalid ${t} Gridline ${s}Span (${i}); Grid has ${l} ${s}s`),u=!1),u}),o=e=>{let t=n[e.axis===`column`?`row`:`column`];return[e.crossStart,e.crossSpan===void 0?t:e.crossStart+e.crossSpan]};return a.forEach((t,n)=>{let{axis:s,index:c}=t,[l,u]=o(t);for(let n of e){let[e,a,o,d]=s===`column`?[n.column,n.columnSpan,n.row,n.rowSpan]:[n.row,n.rowSpan,n.column,n.columnSpan];if(e<c&&c<e+a&&o<u&&l<o+d){let n=s===`column`?`row`:`column`;r.push(`${i(t)} overlaps a Cell that spans across it (${s}: ${e}, ${s}Span: ${a}, ${n}: ${o}, ${n}Span: ${d}); use the ${n} and ${n}Span props to render gridlines beside the Cell instead`)}}for(let e of a.slice(n+1))if(e.axis===s&&e.index===c){let[n,a]=o(e);n<u&&l<a&&r.push(`${i(t)} overlaps ${i(e)}`)}}),r}function Mr(e,t){return X(e.columns,t.columns)&&X(e.rows,t.rows)}function Nr(e){for(let t=1;t<e.length;t++)if(Qt(e[t-1],e[t])>0)return!1;return!0}function Pr({separator:e}){let{element:t}=e,n=(0,N.useRef)(null);return F(()=>{let e=t.cloneNode(!0),r=[t,...t.querySelectorAll(`*`)],i=[e,...e.querySelectorAll(`*`)],a=t.ownerDocument.defaultView;return r.forEach((e,t)=>{let n=i[t];if(n instanceof a.HTMLElement||n instanceof a.SVGElement){let t=a.getComputedStyle(e);for(let e=0;e<t.length;e++){let r=t.item(e);n.style.setProperty(r,t.getPropertyValue(r))}}n.removeAttribute(`data-testid`),n.removeAttribute(`id`)}),Object.assign(e.style,{boxSizing:`border-box`,height:`100%`,margin:`0`,position:`static`,transform:`none`,width:`100%`}),n.current.appendChild(e),()=>e.remove()},[t]),(0,P.jsx)(`div`,{ref:n,style:{height:`100%`,opacity:.65,pointerEvents:`none`,width:`100%`}})}function Fr(){let e=(0,N.useContext)(xr);return L(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Ir(e){let{registerOverlay:t}=Fr(),n=(0,N.useRef)(e);fr(n.current,e)||(n.current=e);let r=n.current;return F(()=>t(r),[t,r]),null}Ir.displayName=`SeparatorOverlay`;function Lr({active:e,orientation:t,style:n,...r}){let i;switch(t){case`horizontal`:i={height:`100%`,minWidth:`1px`};break;case`vertical`:i={minHeight:`1px`,width:`100%`};break}return(0,P.jsx)(`div`,{...r,"data-separator-overlay":e?`active`:`inactive`,style:{...i,...n,flexShrink:0,pointerEvents:`none`}})}function Rr({overlay:e,preview:t}){let{axis:n,offset:r,rect:i,separator:a}=t,o=n.orientation===`horizontal`,s=a?.preview,c=e;return(0,N.isValidElement)(s)&&s.type===Ir&&(c=s.props,s=void 0),s??(c?s=(0,P.jsx)(Lr,{...c,active:t.active,orientation:n.orientation}):a&&(s=(0,P.jsx)(Pr,{separator:a}))),(0,P.jsx)(`div`,{"aria-hidden":`true`,"data-resize-preview":!0,inert:!0,style:{height:i.height,left:i.left,pointerEvents:`none`,position:`absolute`,top:i.top,transform:o?`translateX(${r}px)`:`translateY(${r}px)`,width:i.width},children:s})}function zr(e){return Array.from(e).sort(Qt)}function Br(e,t){let n=(0,N.useRef)({getLayout:()=>({}),setLayout:It});(0,N.useImperativeHandle)(t,()=>n.current,[]),F(()=>{Object.assign(n.current,Jn({axisId:e}))})}function Vr({groupId:e,resizePreviewMode:t}){let[n,r]=(0,N.useState)([]),i=(0,N.useRef)(n);return F(()=>{let n=n=>{let a=bn(e),o=t===`separator`&&n.state===`active`?n.previews.filter(e=>e.axis===a&&(e.active||!J(e.offset,0))):[],s=i.current;s.length===o.length&&o.every((e,t)=>e===s[t])||(i.current=o,r(o))};if(t!==`separator`){n(B());return}let a=Mt(({next:e})=>n(e));return n(B()),a},[e,t]),n}function Hr({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizePreviewMode:d=`panel`,resizeTargetMinimumSize:f={coarse:20,fine:10},style:p,...m}){let h=(0,N.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=I(e=>{X(h.current.onLayoutChange,e)||(h.current.onLayoutChange=e,c?.(e))}),_=I((e,t,n)=>{X(h.current.onLayoutChanged,e)||(h.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t,requestedLayout:n}))}),v=dt(s),[y,b]=(0,N.useState)(),x=Vr({groupId:v,resizePreviewMode:d}),S=(0,N.useRef)(null),[C,w]=yr(),T=(0,N.useRef)([]),E=(0,N.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),D=ft(S,a);Br(v,o);let O=I((e,t)=>{let r=G(e);if(r)return{flexGrow:r.layout[t]??1};if(n?.[t])return{flexGrow:n?.[t]}}),k=br({defaultLayout:n,disableCursor:r,resizeTargetMinimumSize:f}),A=(0,N.useMemo)(()=>({get disableCursor(){return!!k.disableCursor},getPanelStyles:O,id:v,orientation:u,registerPanel:e=>{let t=E.current;return t.panels=$t(u,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerOverlay:e=>(b(e),()=>{b(void 0)}),registerSeparator:e=>{let t=E.current;return t.separators=$t(u,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=E.current.panels.find(t=>t.id===e);n&&(n.constraintProps.disabled=t);let r=bn(v),i=G(v);r&&i&&q(r,{...i,derivedItemConstraints:dn(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=E.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[O,v,w,u,k]),j=(0,N.useRef)(null);return F(()=>{let e=S.current;if(e===null)return;let t=E.current;t.panels=$t(u,t.panels),t.separators=$t(u,t.separators),T.current=zr([...t.panels.map(({element:e})=>e),...t.separators.map(({element:e})=>e)]);let n;if(k.defaultLayout!==void 0&&Object.keys(k.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=k.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!k.disableCursor,expandedItemSizes:E.current.lastExpandedPanelSizes,layouts:E.current.layouts},orientation:u,items:t.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:t.separators};j.current=r;let a=_r(r),{defaultLayoutDeferred:o,derivedItemConstraints:s,layout:c,requestedLayout:l}=G(r.id,!0);if(!o&&s.length>0)try{try{g(c)}finally{_(c,!1,l)}}catch(e){throw j.current=null,a(),e}let f=xn(v,e=>{let{defaultLayoutDeferred:t,derivedItemConstraints:n,layout:i,requestedLayout:a}=e.next;if(t||n.length===0)return;vr({derivedItemConstraints:n,axis:r,layout:i,prevLayout:e.prev?.layout,requestedLayout:a});let o=B(),s=o.state!==`active`||!o.hitRegions.some(e=>e.axis===r);try{g(i)}finally{s&&_(i,e.isUserInteraction,a)}});return()=>{j.current=null,a(),f()}},[i,v,_,g,u,C,d,k]),F(()=>{Nr(T.current)||w()}),(0,N.useEffect)(()=>{let e=j.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,P.jsx)(xr.Provider,{value:A,children:(0,P.jsxs)(`div`,{...m,className:t,"data-group":!0,"data-testid":pt(m,s),id:v,ref:D,style:{height:`100%`,width:`100%`,overflow:`hidden`,position:d===`separator`?`relative`:void 0,...p,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:[e,x.map(e=>(0,P.jsx)(Rr,{overlay:y,preview:e},e.key))]})})}Hr.displayName=`Group`;function Ur(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function Wr({id:e,panelIds:t,storage:n}){let r=Ur(e,[]),i=n.getItem(r);if(i)try{let e=JSON.parse(i);if(t){let n=e[t.join(`,`)];if(n&&Array.isArray(n.layout)&&t.length===n.layout.length){let e={};for(let r=0;r<t.length;r++)e[t[r]]=n.layout[r];return e}}else{let t=Object.keys(e);if(t.length===1){let n=e[t[0]];if(n&&Array.isArray(n.layout)){let e=t[0].split(`,`);if(e.length===n.layout.length){let t={};for(let r=0;r<e.length;r++)t[e[r]]=n.layout[r];return t}}}}}catch{}}function Gr({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:r=localStorage,...i}){let a=n!==void 0,o=`id`in i?i.id:i.groupId,s=Ur(o,n??[]),c=(0,N.useSyncExternalStore)(Kr,()=>r.getItem(s),()=>r.getItem(s)),l=(0,N.useMemo)(()=>{if(c){let e=JSON.parse(c),t=Object.values(e);if(Array.from(t).every(e=>typeof e==`number`))return e}},[c]),u=(0,N.useMemo)(()=>{if(!l)return Wr({id:o,panelIds:n,storage:r})},[l,o,n,r]),d=l??u,f=(0,N.useRef)(null),p=(0,N.useCallback)(()=>{let e=f.current;e&&(f.current=null,clearTimeout(e))},[]);(0,N.useLayoutEffect)(()=>()=>{p()},[p]);let m=(0,N.useCallback)((e,n)=>{if(t&&!n.isUserInteraction)return;p();let i=n.requestedLayout??e,s;s=a?Ur(o,Object.keys(i)):Ur(o,[]);try{r.setItem(s,JSON.stringify(i))}catch(e){console.error(e)}},[p,a,o,t,r]);return{defaultLayout:d,onLayoutChange:(0,N.useCallback)(t=>{p(),e===0?m(t,{isUserInteraction:!1}):f.current=setTimeout(()=>{m(t,{isUserInteraction:!1})},e)},[p,e,m]),onLayoutChanged:m}}function Kr(){return function(){}}function qr(e,t){let{id:n}=Fr(),r=(0,N.useRef)({collapse:Lt,expand:Lt,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Lt});(0,N.useImperativeHandle)(t,()=>r.current,[]),F(()=>{Object.assign(r.current,Gn({axisId:n,itemId:e}))})}function Jr({children:e,className:t,collapsedSize:n=`0%`,collapsedThreshold:r,collapsible:i=!1,defaultSize:a,disabled:o,elementRef:s,groupResizeBehavior:c=`preserve-relative-size`,id:l,maxSize:u=`100%`,minSize:d=`0%`,onResize:f,panelRef:p,style:m,...h}){let g=ut(l),_=dt(l),v=br({disabled:o}),y=(0,N.useRef)(null),b=ft(y,s),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=Fr(),E=f!==null,D=I((e,t,n)=>{f?.(e,l,n)});F(()=>{let e=y.current;if(e!==null)return w({element:e,id:_,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,constraintProps:{groupResizeBehavior:c,collapsedSize:n,collapsedThreshold:r,collapsible:i,defaultSize:a,disabled:v.disabled,maxSize:u,minSize:d}})},[c,n,r,i,a,E,_,g,u,d,D,w,v]),(0,N.useEffect)(()=>{T(_,{disabled:o})},[o,_,T]),qr(_,p);let O=()=>{let e=x(S,_);if(e)return JSON.stringify(e)},k=(0,N.useSyncExternalStore)(e=>xn(S,e),O,O),A;return A=k?JSON.parse(k):a===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:a},(0,P.jsx)(`div`,{...h,"data-disabled":o||void 0,"data-panel":!0,"data-testid":pt(h,l),id:_,ref:b,style:{...Yr,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...A},children:(0,P.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...m,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:e})})}Jr.displayName=`Panel`;var Yr={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Xr(){return(0,N.useRef)(null)}var Zr={flexBasis:`auto`},Qr={flexGrow:0,flexShrink:0};function $r({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,preview:o,style:s,...c}){let l=dt(a),{disableCursor:u,id:d,orientation:f,registerSeparator:p,updateSeparatorProps:m}=Fr();return(0,P.jsx)(Cr,{attributes:c,axisId:d,axisOrientation:f,className:t,"data-testid":pt(c,a),disableCursor:u,disabled:n,disableDoubleClick:r,elementRef:i,id:l,preview:o,registerSeparator:p,requiredStyle:Qr,style:s,styleDefaults:Zr,updateSeparatorProps:m,children:e})}$r.displayName=`Separator`;function ei({className:e,...t}){return(0,P.jsx)(Hr,{"data-slot":`resizable-panel-group`,className:M(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function ti({...e}){return(0,P.jsx)(Jr,{"data-slot":`resizable-panel`,...e})}function ni({withHandle:e,className:t,...n}){return(0,P.jsx)($r,{"data-slot":`resizable-handle`,className:M(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,P.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`})})}var ri=`(min-width: 64rem)`,ii=`]`;function ai(){let[e,t]=(0,N.useState)(()=>matchMedia(ri).matches);return(0,N.useEffect)(()=>{let e=matchMedia(ri),n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function oi(e){return e instanceof HTMLElement&&(e.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.tagName))}function si(){let e=Xr(),[t,n]=(0,N.useState)(!1),r=(0,N.useCallback)(()=>{let t=e.current;t&&(t.isCollapsed()?t.expand():t.collapse())},[e]),i=(0,N.useCallback)(()=>{e.current?.isCollapsed()&&e.current.expand()},[e]);return(0,N.useEffect)(()=>{let e=e=>{e.key!==ii||e.metaKey||e.ctrlKey||e.altKey||oi(e.target)||(e.preventDefault(),r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),{panelRef:e,collapsed:t,setCollapsed:n,toggle:r,expand:i}}function ci({panel:e}){let t=e.collapsed?`Show inspector`:`Hide inspector`,n=e.collapsed?Re:Le;return(0,P.jsxs)(le,{children:[(0,P.jsx)(se,{render:(0,P.jsx)(D,{size:`icon-sm`,variant:`ghost`,"aria-label":t,"aria-pressed":!e.collapsed,className:`max-lg:hidden`,onClick:e.toggle}),children:(0,P.jsx)(n,{className:`size-4`,"aria-hidden":!0})}),(0,P.jsxs)(ce,{children:[t,` `,(0,P.jsx)(`kbd`,{className:`ml-1 font-mono text-[10px] text-muted-foreground`,children:ii})]})]})}function li({panel:e,canvas:t,inspector:n}){let r=ai(),i=Gr({id:`miravo:floor-split`,storage:localStorage});return r?(0,P.jsxs)(ei,{id:`floor-split`,className:`min-h-0 flex-1`,defaultLayout:i.defaultLayout,onLayoutChanged:i.onLayoutChanged,children:[(0,P.jsx)(ti,{id:`canvas`,minSize:`40`,className:`grid overflow-hidden!`,children:t}),(0,P.jsx)(ni,{disableDoubleClick:!0,onDoubleClick:e.toggle,className:`w-px bg-border/50 transition-colors after:w-2 hover:bg-primary/40 data-[separator=active]:bg-primary/60`}),(0,P.jsx)(ti,{id:`inspector`,panelRef:e.panelRef,defaultSize:368,minSize:288,maxSize:640,collapsible:!0,onResize:t=>e.setCollapsed(t.inPixels===0),className:`flex flex-col`,children:n})]}):(0,P.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)] grid-rows-[clamp(18rem,68vw,34rem)_auto]`,children:[t,n]})}var ui={live:`bg-success`,idle:`bg-warning`,fault:`bg-destructive`,off:`bg-muted-foreground/50`},di=[[`station`,`Stations`,`flow order`],[`utility`,`Utilities`,`shared services`]];function fi({label:e,value:t}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,P.jsx)(`span`,{className:`font-mono text-lg font-semibold tabular-nums`,children:t})]})}function pi({things:e,line:t,onSelect:n}){let r=l(e=>e.assets),i=new Map(r.map(e=>[e.id,e.activeFaults.length])),a=new Map(t?.stations.map(e=>[e.id,e])),o=t?.stations.at(-1)?.good??0,s=t?.stations.reduce((e,t)=>e+t.scrap,0)??0,c=e.filter(e=>(i.get(e.assetId)??0)>0).length;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 px-4 pt-4 pb-5`,children:[(0,P.jsx)(fi,{label:`Shipped`,value:O(o)}),(0,P.jsx)(fi,{label:`Yield`,value:o+s>0?`${(o/(o+s)*100).toFixed(1)}%`:`–`}),(0,P.jsx)(fi,{label:`Faulted`,value:String(c)})]}),di.map(([t,r,o])=>(0,P.jsx)(Oe,{title:r,note:o,children:(0,P.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:e.filter(e=>e.kind===t).map(e=>{let t=a.get(e.assetId),r=(i.get(e.assetId)??0)>0;return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),className:`group flex w-full items-center gap-2.5 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,P.jsx)(`span`,{className:M(`size-1.5 shrink-0 rounded-full`,ui[e.kind===`utility`?r?`fault`:`live`:De(t?.state,r)])}),(0,P.jsx)(`span`,{className:`shrink-0 text-sm`,children:e.name}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground tabular-nums`,children:r?`fault`:t?`${ke(t.state)} · ${O(t.good)}`:e.assetId}),(0,P.jsx)(te,{className:`size-3.5 shrink-0 text-muted-foreground/60 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})},e.key)})})},t))]})}var mi=[1,2,5,10];function hi({speed:e}){let t=l(e=>e.engineState),n=ue(),r=t===`paused`,i=mi.includes(e),a=t=>{t!==e&&n.mutateAsync({type:`setSpeed`,multiplier:t}).then(()=>d.invalidateQueries({queryKey:u.floor.state()})).catch(()=>{})};return(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(D,{size:`sm`,variant:`outline`,disabled:n.isPending||t!==`running`&&!r,onClick:()=>n.mutate({type:r?`resume`:`pause`}),className:`w-24 gap-1.5`,children:[r?(0,P.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}):(0,P.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0}),r?`Resume`:`Pause`]}),(0,P.jsxs)(`fieldset`,{"aria-label":`Simulation speed`,className:`flex h-8 items-center gap-0.5 rounded-[var(--miravo-radius-stadium-sm)] border border-border/70 p-0.5`,children:[mi.map(t=>(0,P.jsx)(gi,{value:t,active:t===e,onSelect:a},t)),i?null:(0,P.jsx)(gi,{value:e,active:!0,onSelect:a})]})]})}function gi({value:e,active:t,onSelect:n}){return(0,P.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>n(e),className:M(`h-full min-w-9 rounded-[var(--miravo-radius-tight)] px-2 font-mono text-[11px] tabular-nums outline-none transition-colors`,`text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,t&&`bg-secondary text-foreground`),children:[e,`×`]})}var _i=1500;function vi(e,t){return e?.find(e=>e.stations.some(e=>t.has(e.id)))}function yi(e){let t=S({queryKey:u.floor.state(),queryFn:()=>c(`/state`,i.state),refetchInterval:_i}),n=Pe({queries:e.assetIds.map(e=>({queryKey:u.assets.detail(e),queryFn:()=>c(`/assets/${e}`,i.assetDetail),staleTime:1/0}))}),r=(0,N.useMemo)(()=>new Set(e.assetIds),[e.assetIds]),a=vi(t.data?.lines,r),o=(0,N.useRef)({line:a,speed:t.data?.config.timeMultiplier,details:n});o.current={line:a,speed:t.data?.config.timeMultiplier,details:n};let s=(0,N.useMemo)(()=>{let e=(e,t)=>{let n=l.getState().memberValues.get(e)?.get(t)?.value;return n===void 0?(o.current.details.find(t=>t.data?.id===e)?.data)?.members[t]?.value??void 0:n};return{num(t,n,r=0){let i=e(t,n);return typeof i==`number`?i:typeof i==`boolean`?Number(i):r},param(e,t,n=0){let r=o.current.details.find(t=>t.data?.id===e)?.data?.parameters[t]?.value;return typeof r==`number`?r:n},text(t,n){let r=e(t,n);return typeof r==`string`?r:void 0},station(t){let n=o.current.line?.stations.find(e=>e.id===t);if(!n)return;let r=e(t,`state_label`),i=e(t,`good_count`),a=e(t,`scrap_count`);return{state:typeof r==`string`?r:n.state,good:typeof i==`number`?Math.max(i,n.good):n.good,scrap:typeof a==`number`?Math.max(a,n.scrap):n.scrap}},buffers(){return o.current.line?.buffers??[]},faults(e){return l.getState().assets.find(t=>t.id===e)?.activeFaults??[]},engineState(){return l.getState().engineState},simSpeed(){return o.current.speed??l.getState().speedMultiplier},simTime(){return l.getState().simulationTime}}},[]),d=l(e=>e.speedMultiplier);return{feed:s,line:a,speed:t.data?.config.timeMultiplier??d}}var bi={running:`bg-success`,paused:`bg-warning`,stopped:`bg-destructive`},xi=500;function Si({title:e,body:t}){return(0,P.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,P.jsx)(ne,{className:`size-6 text-muted-foreground`,"aria-hidden":!0}),(0,P.jsx)(`h1`,{className:`font-heading text-lg font-medium tracking-tight`,children:e}),(0,P.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:t}),(0,P.jsx)(E,{to:`/`,className:A({size:`sm`,variant:`outline`}),children:`Back to Factory`})]})}function Ci(){let{templateId:e=``}=T(),t=l(t=>t.templates.find(t=>t.templateId===e));return be(e)?t?(0,P.jsx)(wi,{template:t,entry:(0,N.use)(xe(e))}):(0,P.jsx)(Si,{title:`Template not running`,body:`Load it from the Catalog, then open its floor from the Factory page.`}):(0,P.jsx)(Si,{title:`No floor for this template`,body:`Only templates with a hand-placed layout have a floor view.`})}function wi({template:e,entry:t}){let{feed:n,line:r,speed:i}=yi(e),a=l(e=>e.assets),o=l(e=>e.engineState),s=t.resolve({template:e,assets:a,line:r}),c=s.status===`ready`?JSON.stringify(s.ids):``,u=(0,N.useMemo)(()=>c?JSON.parse(c):null,[c]),d=(0,N.useMemo)(()=>u?t.things(u):[],[t,u]),[f,p]=w(`asset`),[m,h]=(0,N.useState)(`inspect`),[g,_]=(0,N.useState)(null),v=d.find(e=>e.key===f)??null,[,y]=(0,N.useState)(0),b=v===null;(0,N.useEffect)(()=>{if(!b)return;let e=setInterval(()=>y(e=>e+1),xi);return()=>clearInterval(e)},[b]);let x=e=>{p(e),h(`inspect`)},S=(0,N.useRef)(null),C=si();return(0,P.jsxs)(`div`,{className:`flex min-h-full flex-col lg:h-full lg:min-h-0`,children:[(0,P.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-3 border-b border-border/50 px-4 py-3 sm:px-5`,children:[(0,P.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,P.jsxs)(E,{to:`/#template-${e.templateId}`,className:`group/back -mx-1.5 inline-flex shrink-0 items-center gap-1.5 rounded-[var(--miravo-radius-tight)] px-1.5 py-1 text-sm text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,P.jsx)(Fe,{className:`size-3.5 transition-transform group-hover/back:-translate-x-0.5`,"aria-hidden":!0}),`Factory`]}),(0,P.jsx)(`span`,{"aria-hidden":!0,className:`text-sm text-muted-foreground/40`,children:`/`}),(0,P.jsx)(`h1`,{"aria-current":`page`,title:e.templateId,className:`truncate font-heading text-base font-medium tracking-tight`,children:e.templateName}),(0,P.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 pl-1 max-sm:hidden`,children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:M(`size-1.5 rounded-full`,bi[o]??`bg-muted-foreground/50`)}),(0,P.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:o})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(hi,{speed:i}),u!==null&&(0,P.jsx)(ci,{panel:C})]})]}),u===null?s.status===`pending`?(0,P.jsx)(`div`,{className:`flex-1`}):(0,P.jsx)(Si,{title:`Layout does not match`,body:t.mismatch}):(0,P.jsx)(li,{panel:C,canvas:(0,P.jsx)(at,{layout:t.layout,ids:u,caption:t.caption,feed:n,things:d,selected:v?.key??null,onSelect:e=>{x(e),e&&(C.expand(),matchMedia(`(max-width: 63.999rem)`).matches&&S.current?.scrollIntoView({behavior:`smooth`,block:`start`}))},onRuntime:_}),inspector:(0,P.jsx)(`aside`,{ref:S,className:`flex min-w-0 flex-1 scroll-mt-2 flex-col border-border/50 border-t lg:min-h-0 lg:border-t-0`,children:(0,P.jsxs)(me,{value:m,onValueChange:e=>h(e),className:`flex flex-1 flex-col gap-0 lg:min-h-0`,children:[(0,P.jsxs)(pe,{variant:`line`,className:`sticky top-0 z-10 h-10! w-full shrink-0 justify-start gap-0.5 border-b border-border/50 bg-background px-3 lg:static`,children:[(0,P.jsx)(de,{value:`inspect`,className:`px-2.5 text-xs`,children:v?`Inspector`:t.tab??`Line`}),(0,P.jsx)(de,{value:`activity`,className:`px-2.5 text-xs`,children:`Activity`})]}),(0,P.jsx)(fe,{value:`inspect`,className:`flex-1 lg:min-h-0 lg:overflow-y-auto`,children:v===null?t.Overview?(0,P.jsx)(t.Overview,{things:d,status:e=>g?.status(e)??[`--`,``],onSelect:e=>x(e)}):(0,P.jsx)(pi,{things:d,line:r,onSelect:e=>x(e)}):(0,P.jsx)(Ae,{thing:v,assetId:v.assetId,line:r,basis:t.statusBasis,onBack:()=>x(null)},v.key)}),(0,P.jsx)(fe,{value:`activity`,className:`flex-1 lg:min-h-0 lg:overflow-y-auto`,children:(0,P.jsx)(lt,{assetIds:new Set(e.assetIds),nameOf:e=>d.find(t=>t.assetId===e)?.name??e,onSelect:e=>x(e)})})]})})})]})}export{Ci as FloorPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./integrations-iAjWxaDS.js";export{e as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,o as t,v as n}from"./api-B2QJEzbS.js";import{t as r}from"./useQuery-M9KTdi7Q.js";function i(i){return r({queryKey:n.catalog.modelSchemasBatch(i.join(`,`)),queryFn:()=>Promise.all(i.map(n=>t(`/catalog/models/${n}`,e.catalogModelDetail))),enabled:i.length>0})}export{i as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./models-I_V8J5Y0.js";export{e as ModelsPage};
|